UNPKG

@azure/app-configuration

Version:
51 lines (50 loc) 2.62 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var audienceErrorHandlingPolicy_exports = {}; __export(audienceErrorHandlingPolicy_exports, { audienceErrorHandlingPolicy: () => audienceErrorHandlingPolicy }); module.exports = __toCommonJS(audienceErrorHandlingPolicy_exports); var import_core_rest_pipeline = require("@azure/core-rest-pipeline"); const AadAudienceErrorCode = "AADSTS500011"; const NoAudienceErrorMessage = "Unable to authenticate to Azure App Configuration. No authentication token audience was provided. Please set AppConfigurationClientOptions.audience to the appropriate audience for the target cloud. For details on how to configure the authentication token audience visit https://aka.ms/appconfig/client-token-audience."; const WrongAudienceErrorMessage = "Unable to authenticate to Azure App Configuration. An incorrect token audience was provided. Please set AppConfigurationClientOptions.audience to the appropriate audience for the target cloud. For details on how to configure the authentication token audience visit https://aka.ms/appconfig/client-token-audience."; function audienceErrorHandlingPolicy(isAudienceConfigured) { return { name: "audienceErrorHandlingPolicy", async sendRequest(request, next) { try { return await next(request); } catch (error) { if (typeof error.message === "string" && error.message.includes(AadAudienceErrorCode)) { if (isAudienceConfigured) { throw new import_core_rest_pipeline.RestError(WrongAudienceErrorMessage); } else { throw new import_core_rest_pipeline.RestError(NoAudienceErrorMessage); } } throw error; } } }; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { audienceErrorHandlingPolicy }); //# sourceMappingURL=audienceErrorHandlingPolicy.js.map