@azure/msal-common 7.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/_virtual/_tslib.js +1 -1
  2. package/dist/account/AuthToken.js +1 -1
  3. package/dist/account/CcsCredential.js +1 -1
  4. package/dist/account/ClientInfo.js +1 -1
  5. package/dist/authority/Authority.d.ts +20 -1
  6. package/dist/authority/Authority.d.ts.map +1 -1
  7. package/dist/authority/Authority.js +108 -35
  8. package/dist/authority/Authority.js.map +1 -1
  9. package/dist/authority/AuthorityFactory.js +1 -1
  10. package/dist/authority/AuthorityMetadata.d.ts +623 -0
  11. package/dist/authority/AuthorityMetadata.d.ts.map +1 -0
  12. package/dist/authority/AuthorityMetadata.js +12 -0
  13. package/dist/authority/AuthorityMetadata.js.map +1 -0
  14. package/dist/authority/AuthorityOptions.d.ts +1 -0
  15. package/dist/authority/AuthorityOptions.d.ts.map +1 -1
  16. package/dist/authority/AuthorityOptions.js +1 -1
  17. package/dist/authority/AuthorityOptions.js.map +1 -1
  18. package/dist/authority/AuthorityType.js +1 -1
  19. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  20. package/dist/authority/OpenIdConfigResponse.d.ts +1 -0
  21. package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
  22. package/dist/authority/OpenIdConfigResponse.js +3 -2
  23. package/dist/authority/OpenIdConfigResponse.js.map +1 -1
  24. package/dist/authority/ProtocolMode.js +1 -1
  25. package/dist/authority/RegionDiscovery.js +1 -1
  26. package/dist/cache/CacheManager.js +1 -1
  27. package/dist/cache/entities/AccessTokenEntity.js +1 -1
  28. package/dist/cache/entities/AccountEntity.js +1 -1
  29. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  30. package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -0
  31. package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
  32. package/dist/cache/entities/AuthorityMetadataEntity.js +4 -2
  33. package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
  34. package/dist/cache/entities/CacheRecord.js +1 -1
  35. package/dist/cache/entities/CredentialEntity.js +1 -1
  36. package/dist/cache/entities/IdTokenEntity.js +1 -1
  37. package/dist/cache/entities/RefreshTokenEntity.js +1 -1
  38. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  39. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  40. package/dist/cache/persistence/TokenCacheContext.js +1 -1
  41. package/dist/client/AuthorizationCodeClient.js +1 -1
  42. package/dist/client/BaseClient.js +1 -1
  43. package/dist/client/ClientCredentialClient.js +1 -1
  44. package/dist/client/DeviceCodeClient.js +1 -1
  45. package/dist/client/OnBehalfOfClient.js +1 -1
  46. package/dist/client/RefreshTokenClient.js +1 -1
  47. package/dist/client/SilentFlowClient.js +1 -1
  48. package/dist/client/UsernamePasswordClient.js +1 -1
  49. package/dist/config/ClientConfiguration.d.ts +2 -0
  50. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  51. package/dist/config/ClientConfiguration.js +2 -2
  52. package/dist/config/ClientConfiguration.js.map +1 -1
  53. package/dist/crypto/ICrypto.js +1 -1
  54. package/dist/crypto/JoseHeader.js +1 -1
  55. package/dist/crypto/PopTokenGenerator.js +1 -1
  56. package/dist/error/AuthError.js +1 -1
  57. package/dist/error/ClientAuthError.js +1 -1
  58. package/dist/error/ClientConfigurationError.js +1 -1
  59. package/dist/error/InteractionRequiredAuthError.d.ts +9 -0
  60. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
  61. package/dist/error/InteractionRequiredAuthError.js +12 -1
  62. package/dist/error/InteractionRequiredAuthError.js.map +1 -1
  63. package/dist/error/JoseHeaderError.js +1 -1
  64. package/dist/error/ServerError.js +1 -1
  65. package/dist/index.cjs.js +134 -39
  66. package/dist/index.cjs.js.map +1 -1
  67. package/dist/index.js +1 -1
  68. package/dist/logger/Logger.js +1 -1
  69. package/dist/network/INetworkModule.js +1 -1
  70. package/dist/network/NetworkManager.js +1 -1
  71. package/dist/network/ThrottlingUtils.js +1 -1
  72. package/dist/packageMetadata.d.ts +1 -1
  73. package/dist/packageMetadata.js +2 -2
  74. package/dist/packageMetadata.js.map +1 -1
  75. package/dist/request/AuthenticationHeaderParser.js +1 -1
  76. package/dist/request/RequestParameterBuilder.js +1 -1
  77. package/dist/request/RequestValidator.js +1 -1
  78. package/dist/request/ScopeSet.js +1 -1
  79. package/dist/response/ResponseHandler.js +1 -1
  80. package/dist/telemetry/performance/PerformanceClient.js +1 -1
  81. package/dist/telemetry/performance/PerformanceEvent.js +1 -1
  82. package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
  83. package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
  84. package/dist/url/UrlString.js +1 -1
  85. package/dist/utils/Constants.d.ts +2 -1
  86. package/dist/utils/Constants.d.ts.map +1 -1
  87. package/dist/utils/Constants.js +2 -1
  88. package/dist/utils/Constants.js.map +1 -1
  89. package/dist/utils/ProtocolUtils.js +1 -1
  90. package/dist/utils/StringUtils.js +1 -1
  91. package/dist/utils/TimeUtils.js +1 -1
  92. package/package.json +7 -3
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2
2
  'use strict';
3
3
  /*! *****************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2
2
  'use strict';
3
3
  import { ClientAuthError } from '../error/ClientAuthError.js';
4
4
  import { StringUtils } from '../utils/StringUtils.js';
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2
2
  'use strict';
3
3
  /*
4
4
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2
2
  'use strict';
3
3
  import { ClientAuthError } from '../error/ClientAuthError.js';
4
4
  import { StringUtils } from '../utils/StringUtils.js';
@@ -69,6 +69,10 @@ export declare class Authority {
69
69
  * OAuth issuer for requests
70
70
  */
71
71
  get selfSignedJwtAudience(): string;
72
+ /**
73
+ * Jwks_uri for token signing keys
74
+ */
75
+ get jwksUri(): string;
72
76
  /**
73
77
  * Replaces tenant in url path with current tenant. Defaults to common.
74
78
  * @param urlString
@@ -109,8 +113,18 @@ export declare class Authority {
109
113
  private getEndpointMetadataFromConfig;
110
114
  /**
111
115
  * Gets OAuth endpoints from the given OpenID configuration endpoint.
116
+ *
117
+ * @param hasHardcodedMetadata boolean
112
118
  */
113
119
  private getEndpointMetadataFromNetwork;
120
+ /**
121
+ * Get OAuth endpoints for common authorities.
122
+ */
123
+ private getEndpointMetadataFromHardcodedValues;
124
+ /**
125
+ * Update the retrieved metadata with regional information.
126
+ */
127
+ private updateMetadataWithRegionalInformation;
114
128
  /**
115
129
  * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
116
130
  * @param cachedMetadata
@@ -123,9 +137,14 @@ export declare class Authority {
123
137
  private getCloudDiscoveryMetadataFromConfig;
124
138
  /**
125
139
  * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
126
- * @param networkInterface
140
+ *
141
+ * @param hasHardcodedMetadata boolean
127
142
  */
128
143
  private getCloudDiscoveryMetadataFromNetwork;
144
+ /**
145
+ * Get cloud discovery metadata for common authorities
146
+ */
147
+ private getCloudDiscoveryMetadataFromHarcodedValues;
129
148
  /**
130
149
  * Helper function to determine if this host is included in the knownAuthorities config option
131
150
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Authority.d.ts","sourceRoot":"","sources":["../../src/authority/Authority.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD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from '../_virtual/_tslib.js';
4
4
  import { AuthorityType } from './AuthorityType.js';
@@ -6,6 +6,7 @@ import { isOpenIdConfigResponse } from './OpenIdConfigResponse.js';
6
6
  import { UrlString } from '../url/UrlString.js';
7
7
  import { ClientAuthError } from '../error/ClientAuthError.js';
8
8
  import { Constants, AuthorityMetadataSource, RegionDiscoveryOutcomes } from '../utils/Constants.js';
9
+ import { EndpointMetadata, InstanceDiscoveryMetadata } from './AuthorityMetadata.js';
9
10
  import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
10
11
  import { ProtocolMode } from './ProtocolMode.js';
11
12
  import { AuthorityMetadataEntity } from '../cache/entities/AuthorityMetadataEntity.js';
@@ -196,6 +197,22 @@ var Authority = /** @class */ (function () {
196
197
  enumerable: false,
197
198
  configurable: true
198
199
  });
200
+ Object.defineProperty(Authority.prototype, "jwksUri", {
201
+ /**
202
+ * Jwks_uri for token signing keys
203
+ */
204
+ get: function () {
205
+ if (this.discoveryComplete()) {
206
+ var endpoint = this.replacePath(this.metadata.jwks_uri);
207
+ return this.replaceTenant(endpoint);
208
+ }
209
+ else {
210
+ throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
211
+ }
212
+ },
213
+ enumerable: false,
214
+ configurable: true
215
+ });
199
216
  /**
200
217
  * Replaces tenant in url path with current tenant. Defaults to common.
201
218
  * @param urlString
@@ -279,11 +296,11 @@ var Authority = /** @class */ (function () {
279
296
  * @param metadataEntity
280
297
  */
281
298
  Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
282
- var _a;
299
+ var _a, _b;
283
300
  return __awaiter(this, void 0, void 0, function () {
284
- var metadata, autodetectedRegionName, azureRegion;
285
- return __generator(this, function (_b) {
286
- switch (_b.label) {
301
+ var metadata, harcodedMetadata;
302
+ return __generator(this, function (_c) {
303
+ switch (_c.label) {
287
304
  case 0:
288
305
  metadata = this.getEndpointMetadataFromConfig();
289
306
  if (metadata) {
@@ -294,41 +311,30 @@ var Authority = /** @class */ (function () {
294
311
  // No need to update
295
312
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
296
313
  }
314
+ harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
297
315
  return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
298
316
  case 1:
299
- metadata = _b.sent();
317
+ metadata = _c.sent();
300
318
  if (!metadata) return [3 /*break*/, 4];
301
319
  if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
302
- return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
320
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
303
321
  case 2:
304
- autodetectedRegionName = _b.sent();
305
- azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
306
- ? autodetectedRegionName
307
- : this.authorityOptions.azureRegionConfiguration.azureRegion;
308
- if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
309
- this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
310
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
311
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
312
- }
313
- else {
314
- if (autodetectedRegionName) {
315
- this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration.azureRegion === autodetectedRegionName) ?
316
- RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
317
- RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
318
- }
319
- else {
320
- this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
321
- }
322
- }
323
- if (azureRegion) {
324
- this.regionDiscoveryMetadata.region_used = azureRegion;
325
- metadata = Authority.replaceWithRegionalInformation(metadata, azureRegion);
326
- }
327
- _b.label = 3;
322
+ metadata = _c.sent();
323
+ _c.label = 3;
328
324
  case 3:
329
325
  metadataEntity.updateEndpointMetadata(metadata, true);
330
326
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
331
- case 4: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
327
+ case 4:
328
+ if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
329
+ if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
330
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
331
+ case 5:
332
+ harcodedMetadata = _c.sent();
333
+ _c.label = 6;
334
+ case 6:
335
+ metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
336
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
337
+ case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
332
338
  }
333
339
  });
334
340
  });
@@ -359,6 +365,8 @@ var Authority = /** @class */ (function () {
359
365
  };
360
366
  /**
361
367
  * Gets OAuth endpoints from the given OpenID configuration endpoint.
368
+ *
369
+ * @param hasHardcodedMetadata boolean
362
370
  */
363
371
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
364
372
  return __awaiter(this, void 0, void 0, function () {
@@ -385,6 +393,54 @@ var Authority = /** @class */ (function () {
385
393
  });
386
394
  });
387
395
  };
396
+ /**
397
+ * Get OAuth endpoints for common authorities.
398
+ */
399
+ Authority.prototype.getEndpointMetadataFromHardcodedValues = function () {
400
+ if (this.canonicalAuthority in EndpointMetadata) {
401
+ return EndpointMetadata[this.canonicalAuthority];
402
+ }
403
+ return null;
404
+ };
405
+ /**
406
+ * Update the retrieved metadata with regional information.
407
+ */
408
+ Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
409
+ var _a, _b, _c, _d, _e;
410
+ return __awaiter(this, void 0, void 0, function () {
411
+ var autodetectedRegionName, azureRegion;
412
+ return __generator(this, function (_f) {
413
+ switch (_f.label) {
414
+ case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
415
+ case 1:
416
+ autodetectedRegionName = _f.sent();
417
+ azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
418
+ ? autodetectedRegionName
419
+ : (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
420
+ if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
421
+ this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
422
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
423
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
424
+ }
425
+ else {
426
+ if (autodetectedRegionName) {
427
+ this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
428
+ RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
429
+ RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
430
+ }
431
+ else {
432
+ this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
433
+ }
434
+ }
435
+ if (azureRegion) {
436
+ this.regionDiscoveryMetadata.region_used = azureRegion;
437
+ return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, azureRegion)];
438
+ }
439
+ return [2 /*return*/, metadata];
440
+ }
441
+ });
442
+ });
443
+ };
388
444
  /**
389
445
  * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
390
446
  * @param cachedMetadata
@@ -392,7 +448,7 @@ var Authority = /** @class */ (function () {
392
448
  */
393
449
  Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
394
450
  return __awaiter(this, void 0, void 0, function () {
395
- var metadata;
451
+ var metadata, harcodedMetadata;
396
452
  return __generator(this, function (_a) {
397
453
  switch (_a.label) {
398
454
  case 0:
@@ -406,6 +462,7 @@ var Authority = /** @class */ (function () {
406
462
  // No need to update
407
463
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
408
464
  }
465
+ harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
409
466
  return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
410
467
  case 1:
411
468
  metadata = _a.sent();
@@ -413,6 +470,10 @@ var Authority = /** @class */ (function () {
413
470
  metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
414
471
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
415
472
  }
473
+ if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
474
+ metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
475
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
476
+ }
416
477
  else {
417
478
  // Metadata could not be obtained from config, cache or network
418
479
  throw ClientConfigurationError.createUntrustedAuthorityError();
@@ -446,7 +507,8 @@ var Authority = /** @class */ (function () {
446
507
  };
447
508
  /**
448
509
  * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
449
- * @param networkInterface
510
+ *
511
+ * @param hasHardcodedMetadata boolean
450
512
  */
451
513
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
452
514
  return __awaiter(this, void 0, void 0, function () {
@@ -466,7 +528,9 @@ var Authority = /** @class */ (function () {
466
528
  return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
467
529
  case 2:
468
530
  response = _a.sent();
469
- metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
531
+ metadata = isCloudInstanceDiscoveryResponse(response.body)
532
+ ? response.body.metadata
533
+ : [];
470
534
  if (metadata.length === 0) {
471
535
  // If no metadata is returned, authority is untrusted
472
536
  return [2 /*return*/, null];
@@ -486,6 +550,15 @@ var Authority = /** @class */ (function () {
486
550
  });
487
551
  });
488
552
  };
553
+ /**
554
+ * Get cloud discovery metadata for common authorities
555
+ */
556
+ Authority.prototype.getCloudDiscoveryMetadataFromHarcodedValues = function () {
557
+ if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
558
+ return InstanceDiscoveryMetadata[this.canonicalAuthority];
559
+ }
560
+ return null;
561
+ };
489
562
  /**
490
563
  * Helper function to determine if this host is included in the knownAuthorities config option
491
564
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Authority.js","sources":["../../src/authority/Authority.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthorityType } from \"./AuthorityType\";\nimport { isOpenIdConfigResponse, OpenIdConfigResponse } from \"./OpenIdConfigResponse\";\nimport { UrlString } from \"../url/UrlString\";\nimport { IUri } from \"../url/IUri\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { AuthorityMetadataSource, Constants, RegionDiscoveryOutcomes } from \"../utils/Constants\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ProtocolMode } from \"./ProtocolMode\";\nimport { ICacheManager } from \"../cache/interface/ICacheManager\";\nimport { AuthorityMetadataEntity } from \"../cache/entities/AuthorityMetadataEntity\";\nimport { AuthorityOptions , AzureCloudInstance } from \"./AuthorityOptions\";\nimport { CloudInstanceDiscoveryResponse, isCloudInstanceDiscoveryResponse } from \"./CloudInstanceDiscoveryResponse\";\nimport { CloudDiscoveryMetadata } from \"./CloudDiscoveryMetadata\";\nimport { RegionDiscovery } from \"./RegionDiscovery\";\nimport { RegionDiscoveryMetadata } from \"./RegionDiscoveryMetadata\";\nimport { ImdsOptions } from \"./ImdsOptions\";\nimport { AzureCloudOptions } from \"../config/ClientConfiguration\";\n\n/**\n * The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the\n * endpoint. It will store the pertinent config data in this object for use during token calls.\n */\nexport class Authority {\n\n // Canonical authority url string\n private _canonicalAuthority: UrlString;\n // Canonicaly authority url components\n private _canonicalAuthorityUrlComponents: IUri | null;\n // Network interface to make requests with.\n protected networkInterface: INetworkModule;\n // Cache Manager to cache network responses\n protected cacheManager: ICacheManager;\n // Protocol mode to construct endpoints\n private authorityOptions: AuthorityOptions;\n // Authority metadata\n private metadata: AuthorityMetadataEntity;\n // Region discovery service\n private regionDiscovery: RegionDiscovery;\n // Region discovery metadata\n public regionDiscoveryMetadata: RegionDiscoveryMetadata;\n // Proxy url string\n private proxyUrl: string;\n\n constructor(authority: string, networkInterface: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions, proxyUrl?: string) {\n this.canonicalAuthority = authority;\n this._canonicalAuthority.validateAsUri();\n this.networkInterface = networkInterface;\n this.cacheManager = cacheManager;\n this.authorityOptions = authorityOptions;\n this.regionDiscovery = new RegionDiscovery(networkInterface);\n this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };\n this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;\n }\n\n // See above for AuthorityType\n public get authorityType(): AuthorityType {\n const pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;\n\n if (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS) {\n return AuthorityType.Adfs;\n }\n\n return AuthorityType.Default;\n }\n\n /**\n * ProtocolMode enum representing the way endpoints are constructed.\n */\n public get protocolMode(): ProtocolMode {\n return this.authorityOptions.protocolMode;\n }\n\n /**\n * Returns authorityOptions which can be used to reinstantiate a new authority instance\n */\n public get options(): AuthorityOptions {\n return this.authorityOptions;\n }\n\n /**\n * A URL that is the authority set by the developer\n */\n public get canonicalAuthority(): string {\n return this._canonicalAuthority.urlString;\n }\n\n /**\n * Sets canonical authority.\n */\n public set canonicalAuthority(url: string) {\n this._canonicalAuthority = new UrlString(url);\n this._canonicalAuthority.validateAsUri();\n this._canonicalAuthorityUrlComponents = null;\n }\n\n /**\n * Get authority components.\n */\n public get canonicalAuthorityUrlComponents(): IUri {\n if (!this._canonicalAuthorityUrlComponents) {\n this._canonicalAuthorityUrlComponents = this._canonicalAuthority.getUrlComponents();\n }\n\n return this._canonicalAuthorityUrlComponents;\n }\n\n /**\n * Get hostname and port i.e. login.microsoftonline.com\n */\n public get hostnameAndPort(): string {\n return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();\n }\n\n /**\n * Get tenant for authority.\n */\n public get tenant(): string {\n return this.canonicalAuthorityUrlComponents.PathSegments[0];\n }\n\n /**\n * OAuth /authorize endpoint for requests\n */\n public get authorizationEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.authorization_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth /token endpoint for requests\n */\n public get tokenEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.token_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n public get deviceCodeEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.token_endpoint.replace(\"/token\", \"/devicecode\"));\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth logout endpoint for requests\n */\n public get endSessionEndpoint(): string {\n if(this.discoveryComplete()) {\n // ROPC policies may not have end_session_endpoint set\n if (!this.metadata.end_session_endpoint) {\n throw ClientAuthError.createLogoutNotSupportedError();\n }\n const endpoint = this.replacePath(this.metadata.end_session_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth issuer for requests\n */\n public get selfSignedJwtAudience(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.issuer);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Replaces tenant in url path with current tenant. Defaults to common.\n * @param urlString\n */\n private replaceTenant(urlString: string): string {\n return urlString.replace(/{tenant}|{tenantid}/g, this.tenant);\n }\n\n /**\n * Replaces path such as tenant or policy with the current tenant or policy.\n * @param urlString\n */\n private replacePath(urlString: string): string {\n let endpoint = urlString;\n const cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority);\n const cachedAuthorityParts = cachedAuthorityUrl.getUrlComponents().PathSegments;\n const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;\n\n currentAuthorityParts.forEach((currentPart, index) => {\n const cachedPart = cachedAuthorityParts[index];\n if (currentPart !== cachedPart) {\n endpoint = endpoint.replace(`/${cachedPart}/`, `/${currentPart}/`);\n }\n });\n\n return endpoint;\n }\n\n /**\n * The default open id configuration endpoint for any canonical authority.\n */\n protected get defaultOpenIdConfigurationEndpoint(): string {\n if (this.authorityType === AuthorityType.Adfs || this.protocolMode === ProtocolMode.OIDC) {\n return `${this.canonicalAuthority}.well-known/openid-configuration`;\n }\n return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;\n }\n\n /**\n * Boolean that returns whethr or not tenant discovery has been completed.\n */\n discoveryComplete(): boolean {\n return !!this.metadata;\n }\n\n /**\n * Perform endpoint discovery to discover aliases, preferred_cache, preferred_network\n * and the /authorize, /token and logout endpoints.\n */\n public async resolveEndpointsAsync(): Promise<void> {\n let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);\n if (!metadataEntity) {\n metadataEntity = new AuthorityMetadataEntity();\n metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);\n }\n\n const cloudDiscoverySource = await this.updateCloudDiscoveryMetadata(metadataEntity);\n this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);\n const endpointSource = await this.updateEndpointMetadata(metadataEntity);\n\n if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {\n // Reset the expiration time unless both values came from a successful cache lookup\n metadataEntity.resetExpiresAt();\n metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);\n }\n\n const cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(metadataEntity.preferred_cache);\n this.cacheManager.setAuthorityMetadata(cacheKey, metadataEntity);\n this.metadata = metadataEntity;\n }\n\n /**\n * Update AuthorityMetadataEntity with new endpoints and return where the information came from\n * @param metadataEntity\n */\n private async updateEndpointMetadata(metadataEntity: AuthorityMetadataEntity): Promise<AuthorityMetadataSource> {\n let metadata = this.getEndpointMetadataFromConfig();\n if (metadata) {\n metadataEntity.updateEndpointMetadata(metadata, false);\n return AuthorityMetadataSource.CONFIG;\n }\n\n if (this.isAuthoritySameType(metadataEntity) && metadataEntity.endpointsFromNetwork && !metadataEntity.isExpired()) {\n // No need to update\n return AuthorityMetadataSource.CACHE;\n }\n\n metadata = await this.getEndpointMetadataFromNetwork();\n if (metadata) {\n // If the user prefers to use an azure region replace the global endpoints with regional information.\n if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {\n const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl);\n\n const azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG\n ? autodetectedRegionName\n : this.authorityOptions.azureRegionConfiguration.azureRegion;\n\n if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {\n this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?\n RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :\n RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;\n } else {\n if (autodetectedRegionName) {\n this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration.azureRegion === autodetectedRegionName) ?\n RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :\n RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;\n } else {\n this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;\n }\n }\n\n if (azureRegion) {\n this.regionDiscoveryMetadata.region_used = azureRegion;\n metadata = Authority.replaceWithRegionalInformation(metadata, azureRegion);\n }\n }\n\n metadataEntity.updateEndpointMetadata(metadata, true);\n return AuthorityMetadataSource.NETWORK;\n } else {\n throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);\n }\n }\n\n /**\n * Compares the number of url components after the domain to determine if the cached authority metadata can be used for the requested authority\n * Protects against same domain different authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy\n * @param metadataEntity\n */\n private isAuthoritySameType(metadataEntity: AuthorityMetadataEntity): boolean {\n const cachedAuthorityUrl = new UrlString(metadataEntity.canonical_authority);\n const cachedParts = cachedAuthorityUrl.getUrlComponents().PathSegments;\n\n return cachedParts.length === this.canonicalAuthorityUrlComponents.PathSegments.length;\n }\n\n /**\n * Parse authorityMetadata config option\n */\n private getEndpointMetadataFromConfig(): OpenIdConfigResponse | null {\n if (this.authorityOptions.authorityMetadata) {\n try {\n return JSON.parse(this.authorityOptions.authorityMetadata) as OpenIdConfigResponse;\n } catch (e) {\n throw ClientConfigurationError.createInvalidAuthorityMetadataError();\n }\n }\n\n return null;\n }\n\n /**\n * Gets OAuth endpoints from the given OpenID configuration endpoint.\n */\n private async getEndpointMetadataFromNetwork(): Promise<OpenIdConfigResponse | null> {\n const options: ImdsOptions = {};\n if (this.proxyUrl) {\n options.proxyUrl = this.proxyUrl;\n }\n\n try {\n const response = await this.networkInterface.sendGetRequestAsync<OpenIdConfigResponse>(this.defaultOpenIdConfigurationEndpoint, options);\n return isOpenIdConfigResponse(response.body) ? response.body : null;\n } catch (e) {\n return null;\n }\n }\n\n /**\n * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from\n * @param cachedMetadata\n * @param newMetadata\n */\n private async updateCloudDiscoveryMetadata(metadataEntity: AuthorityMetadataEntity): Promise<AuthorityMetadataSource> {\n let metadata = this.getCloudDiscoveryMetadataFromConfig();\n if (metadata) {\n metadataEntity.updateCloudDiscoveryMetadata(metadata, false);\n return AuthorityMetadataSource.CONFIG;\n }\n\n // If The cached metadata came from config but that config was not passed to this instance, we must go to the network\n if (this.isAuthoritySameType(metadataEntity) && metadataEntity.aliasesFromNetwork && !metadataEntity.isExpired()) {\n // No need to update\n return AuthorityMetadataSource.CACHE;\n }\n\n metadata = await this.getCloudDiscoveryMetadataFromNetwork();\n if (metadata) {\n metadataEntity.updateCloudDiscoveryMetadata(metadata, true);\n return AuthorityMetadataSource.NETWORK;\n } else {\n // Metadata could not be obtained from config, cache or network\n throw ClientConfigurationError.createUntrustedAuthorityError();\n }\n }\n\n /**\n * Parse cloudDiscoveryMetadata config or check knownAuthorities\n */\n private getCloudDiscoveryMetadataFromConfig(): CloudDiscoveryMetadata | null {\n // Check if network response was provided in config\n if (this.authorityOptions.cloudDiscoveryMetadata) {\n try {\n const parsedResponse = JSON.parse(this.authorityOptions.cloudDiscoveryMetadata) as CloudInstanceDiscoveryResponse;\n const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(parsedResponse.metadata, this.hostnameAndPort);\n if (metadata) {\n return metadata;\n }\n } catch (e) {\n throw ClientConfigurationError.createInvalidCloudDiscoveryMetadataError();\n }\n }\n\n // If cloudDiscoveryMetadata is empty or does not contain the host, check knownAuthorities\n if (this.isInKnownAuthorities()) {\n return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);\n }\n\n return null;\n }\n\n /**\n * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config\n * @param networkInterface\n */\n private async getCloudDiscoveryMetadataFromNetwork(): Promise<CloudDiscoveryMetadata | null> {\n const instanceDiscoveryEndpoint = `${Constants.AAD_INSTANCE_DISCOVERY_ENDPT}${this.canonicalAuthority}oauth2/v2.0/authorize`;\n const options: ImdsOptions = {};\n if (this.proxyUrl) {\n options.proxyUrl = this.proxyUrl;\n }\n\n let match = null;\n try {\n const response = await this.networkInterface.sendGetRequestAsync<CloudInstanceDiscoveryResponse>(instanceDiscoveryEndpoint, options);\n const metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];\n if (metadata.length === 0) {\n // If no metadata is returned, authority is untrusted\n return null;\n }\n match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);\n } catch(e) {\n return null;\n }\n\n if (!match) {\n // Custom Domain scenario, host is trusted because Instance Discovery call succeeded\n match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);\n }\n return match;\n }\n\n /**\n * Helper function to determine if this host is included in the knownAuthorities config option\n */\n private isInKnownAuthorities(): boolean {\n const matches = this.authorityOptions.knownAuthorities.filter((authority) => {\n return UrlString.getDomainFromUrl(authority).toLowerCase() === this.hostnameAndPort;\n });\n\n return matches.length > 0;\n }\n\n /**\n * helper function to populate the authority based on azureCloudOptions\n * @param authorityString\n * @param azureCloudOptions\n */\n static generateAuthority(authorityString: string, azureCloudOptions?: AzureCloudOptions): string {\n let authorityAzureCloudInstance;\n\n if (azureCloudOptions && azureCloudOptions.azureCloudInstance !== AzureCloudInstance.None) {\n const tenant = azureCloudOptions.tenant ? azureCloudOptions.tenant : Constants.DEFAULT_COMMON_TENANT;\n authorityAzureCloudInstance = `${azureCloudOptions.azureCloudInstance}/${tenant}/`;\n }\n\n return authorityAzureCloudInstance ? authorityAzureCloudInstance : authorityString;\n }\n\n /**\n * Creates cloud discovery metadata object from a given host\n * @param host\n */\n static createCloudDiscoveryMetadataFromHost(host: string): CloudDiscoveryMetadata {\n return {\n preferred_network: host,\n preferred_cache: host,\n aliases: [host]\n };\n }\n\n /**\n * Searches instance discovery network response for the entry that contains the host in the aliases list\n * @param response\n * @param authority\n */\n static getCloudDiscoveryMetadataFromNetworkResponse(response: CloudDiscoveryMetadata[], authority: string): CloudDiscoveryMetadata | null {\n for (let i = 0; i < response.length; i++) {\n const metadata = response[i];\n if (metadata.aliases.indexOf(authority) > -1) {\n return metadata;\n }\n }\n\n return null;\n }\n\n /**\n * helper function to generate environment from authority object\n */\n getPreferredCache(): string {\n if(this.discoveryComplete()) {\n return this.metadata.preferred_cache;\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Returns whether or not the provided host is an alias of this authority instance\n * @param host\n */\n isAlias(host: string): boolean {\n return this.metadata.aliases.indexOf(host) > -1;\n }\n\n /**\n * Checks whether the provided host is that of a public cloud authority\n *\n * @param authority string\n * @returns bool\n */\n static isPublicCloudAuthority(host: string): boolean {\n return Constants.KNOWN_PUBLIC_CLOUDS.indexOf(host) >= 0;\n }\n\n /**\n * Rebuild the authority string with the region\n *\n * @param host string\n * @param region string\n */\n static buildRegionalAuthorityString(host: string, region: string, queryString?: string): string {\n // Create and validate a Url string object with the initial authority string\n const authorityUrlInstance = new UrlString(host);\n authorityUrlInstance.validateAsUri();\n\n const authorityUrlParts = authorityUrlInstance.getUrlComponents();\n\n let hostNameAndPort= `${region}.${authorityUrlParts.HostNameAndPort}`;\n\n if (this.isPublicCloudAuthority(authorityUrlParts.HostNameAndPort)) {\n hostNameAndPort = `${region}.${Constants.REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX}`;\n }\n\n // Include the query string portion of the url\n const url = UrlString.constructAuthorityUriFromObject({\n ...authorityUrlInstance.getUrlComponents(),\n HostNameAndPort: hostNameAndPort\n }).urlString;\n\n // Add the query string if a query string was provided\n if (queryString) return `${url}?${queryString}`;\n\n return url;\n }\n\n /**\n * Replace the endpoints in the metadata object with their regional equivalents.\n *\n * @param metadata OpenIdConfigResponse\n * @param azureRegion string\n */\n static replaceWithRegionalInformation(metadata: OpenIdConfigResponse, azureRegion: string): OpenIdConfigResponse {\n metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);\n // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature\n metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, \"allowestsrnonmsi=true\");\n\n if (metadata.end_session_endpoint) {\n metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);\n }\n\n return metadata;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;AAwBA;;;;;IAyBI,mBAAY,SAAiB,EAAE,gBAAgC,EAAE,YAA2B,EAAE,gBAAkC,EAAE,QAAiB;QAC/I,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACpC,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,CAAC;QACzC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAC7D,IAAI,CAAC,uBAAuB,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;QAC/G,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,SAAS,CAAC,YAAY,CAAC;KACtD;I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ClC,CAAC,SAAS,CAAC;;QAGb,IAAI,WAAW;YAAE,OAAU,GAAG,SAAI,WAAa,CAAC;QAEhD,OAAO,GAAG,CAAC;KACd;;;;;;;IAQM,wCAA8B,GAArC,UAAsC,QAA8B,EAAE,WAAmB;QACrF,QAAQ,CAAC,sBAAsB,GAAG,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;;QAEvH,QAAQ,CAAC,cAAc,GAAG,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,EAAE,uBAAuB,CAAC,CAAC;QAEhI,IAAI,QAAQ,CAAC,oBAAoB,EAAE;YAC/B,QAAQ,CAAC,oBAAoB,GAAG,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;SACtH;QAED,OAAO,QAAQ,CAAC;KACnB;IACL,gBAAC;AAAD,CAAC;;;;"}
1
+ {"version":3,"file":"Authority.js","sources":["../../src/authority/Authority.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthorityType } from \"./AuthorityType\";\nimport { isOpenIdConfigResponse, OpenIdConfigResponse } from \"./OpenIdConfigResponse\";\nimport { UrlString } from \"../url/UrlString\";\nimport { IUri } from \"../url/IUri\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { AuthorityMetadataSource, Constants, RegionDiscoveryOutcomes } from \"../utils/Constants\";\nimport { EndpointMetadata, InstanceDiscoveryMetadata } from \"./AuthorityMetadata\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ProtocolMode } from \"./ProtocolMode\";\nimport { ICacheManager } from \"../cache/interface/ICacheManager\";\nimport { AuthorityMetadataEntity } from \"../cache/entities/AuthorityMetadataEntity\";\nimport { AuthorityOptions , AzureCloudInstance } from \"./AuthorityOptions\";\nimport { CloudInstanceDiscoveryResponse, isCloudInstanceDiscoveryResponse } from \"./CloudInstanceDiscoveryResponse\";\nimport { CloudDiscoveryMetadata } from \"./CloudDiscoveryMetadata\";\nimport { RegionDiscovery } from \"./RegionDiscovery\";\nimport { RegionDiscoveryMetadata } from \"./RegionDiscoveryMetadata\";\nimport { ImdsOptions } from \"./ImdsOptions\";\nimport { AzureCloudOptions } from \"../config/ClientConfiguration\";\n\n/**\n * The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the\n * endpoint. It will store the pertinent config data in this object for use during token calls.\n */\nexport class Authority {\n\n // Canonical authority url string\n private _canonicalAuthority: UrlString;\n // Canonicaly authority url components\n private _canonicalAuthorityUrlComponents: IUri | null;\n // Network interface to make requests with.\n protected networkInterface: INetworkModule;\n // Cache Manager to cache network responses\n protected cacheManager: ICacheManager;\n // Protocol mode to construct endpoints\n private authorityOptions: AuthorityOptions;\n // Authority metadata\n private metadata: AuthorityMetadataEntity;\n // Region discovery service\n private regionDiscovery: RegionDiscovery;\n // Region discovery metadata\n public regionDiscoveryMetadata: RegionDiscoveryMetadata;\n // Proxy url string\n private proxyUrl: string;\n\n constructor(authority: string, networkInterface: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions, proxyUrl?: string) {\n this.canonicalAuthority = authority;\n this._canonicalAuthority.validateAsUri();\n this.networkInterface = networkInterface;\n this.cacheManager = cacheManager;\n this.authorityOptions = authorityOptions;\n this.regionDiscovery = new RegionDiscovery(networkInterface);\n this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };\n this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;\n }\n\n // See above for AuthorityType\n public get authorityType(): AuthorityType {\n const pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;\n\n if (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS) {\n return AuthorityType.Adfs;\n }\n\n return AuthorityType.Default;\n }\n\n /**\n * ProtocolMode enum representing the way endpoints are constructed.\n */\n public get protocolMode(): ProtocolMode {\n return this.authorityOptions.protocolMode;\n }\n\n /**\n * Returns authorityOptions which can be used to reinstantiate a new authority instance\n */\n public get options(): AuthorityOptions {\n return this.authorityOptions;\n }\n\n /**\n * A URL that is the authority set by the developer\n */\n public get canonicalAuthority(): string {\n return this._canonicalAuthority.urlString;\n }\n\n /**\n * Sets canonical authority.\n */\n public set canonicalAuthority(url: string) {\n this._canonicalAuthority = new UrlString(url);\n this._canonicalAuthority.validateAsUri();\n this._canonicalAuthorityUrlComponents = null;\n }\n\n /**\n * Get authority components.\n */\n public get canonicalAuthorityUrlComponents(): IUri {\n if (!this._canonicalAuthorityUrlComponents) {\n this._canonicalAuthorityUrlComponents = this._canonicalAuthority.getUrlComponents();\n }\n\n return this._canonicalAuthorityUrlComponents;\n }\n\n /**\n * Get hostname and port i.e. login.microsoftonline.com\n */\n public get hostnameAndPort(): string {\n return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();\n }\n\n /**\n * Get tenant for authority.\n */\n public get tenant(): string {\n return this.canonicalAuthorityUrlComponents.PathSegments[0];\n }\n\n /**\n * OAuth /authorize endpoint for requests\n */\n public get authorizationEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.authorization_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth /token endpoint for requests\n */\n public get tokenEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.token_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n public get deviceCodeEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.token_endpoint.replace(\"/token\", \"/devicecode\"));\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth logout endpoint for requests\n */\n public get endSessionEndpoint(): string {\n if(this.discoveryComplete()) {\n // ROPC policies may not have end_session_endpoint set\n if (!this.metadata.end_session_endpoint) {\n throw ClientAuthError.createLogoutNotSupportedError();\n }\n const endpoint = this.replacePath(this.metadata.end_session_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth issuer for requests\n */\n public get selfSignedJwtAudience(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.issuer);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Jwks_uri for token signing keys\n */\n public get jwksUri(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.jwks_uri);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Replaces tenant in url path with current tenant. Defaults to common.\n * @param urlString\n */\n private replaceTenant(urlString: string): string {\n return urlString.replace(/{tenant}|{tenantid}/g, this.tenant);\n }\n\n /**\n * Replaces path such as tenant or policy with the current tenant or policy.\n * @param urlString\n */\n private replacePath(urlString: string): string {\n let endpoint = urlString;\n const cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority);\n const cachedAuthorityParts = cachedAuthorityUrl.getUrlComponents().PathSegments;\n const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;\n\n currentAuthorityParts.forEach((currentPart, index) => {\n const cachedPart = cachedAuthorityParts[index];\n if (currentPart !== cachedPart) {\n endpoint = endpoint.replace(`/${cachedPart}/`, `/${currentPart}/`);\n }\n });\n\n return endpoint;\n }\n\n /**\n * The default open id configuration endpoint for any canonical authority.\n */\n protected get defaultOpenIdConfigurationEndpoint(): string {\n if (this.authorityType === AuthorityType.Adfs || this.protocolMode === ProtocolMode.OIDC) {\n return `${this.canonicalAuthority}.well-known/openid-configuration`;\n }\n return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;\n }\n\n /**\n * Boolean that returns whethr or not tenant discovery has been completed.\n */\n discoveryComplete(): boolean {\n return !!this.metadata;\n }\n\n /**\n * Perform endpoint discovery to discover aliases, preferred_cache, preferred_network\n * and the /authorize, /token and logout endpoints.\n */\n public async resolveEndpointsAsync(): Promise<void> {\n let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);\n if (!metadataEntity) {\n metadataEntity = new AuthorityMetadataEntity();\n metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);\n }\n\n const cloudDiscoverySource = await this.updateCloudDiscoveryMetadata(metadataEntity);\n this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);\n const endpointSource = await this.updateEndpointMetadata(metadataEntity);\n\n if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {\n // Reset the expiration time unless both values came from a successful cache lookup\n metadataEntity.resetExpiresAt();\n metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);\n }\n\n const cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(metadataEntity.preferred_cache);\n this.cacheManager.setAuthorityMetadata(cacheKey, metadataEntity);\n this.metadata = metadataEntity;\n }\n\n /**\n * Update AuthorityMetadataEntity with new endpoints and return where the information came from\n * @param metadataEntity\n */\n private async updateEndpointMetadata(metadataEntity: AuthorityMetadataEntity): Promise<AuthorityMetadataSource> {\n let metadata = this.getEndpointMetadataFromConfig();\n if (metadata) {\n metadataEntity.updateEndpointMetadata(metadata, false);\n return AuthorityMetadataSource.CONFIG;\n }\n\n if (this.isAuthoritySameType(metadataEntity) && metadataEntity.endpointsFromNetwork && !metadataEntity.isExpired()) {\n // No need to update\n return AuthorityMetadataSource.CACHE;\n }\n\n let harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();\n metadata = await this.getEndpointMetadataFromNetwork();\n if (metadata) {\n // If the user prefers to use an azure region replace the global endpoints with regional information.\n if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {\n metadata = await this.updateMetadataWithRegionalInformation(metadata);\n }\n\n metadataEntity.updateEndpointMetadata(metadata, true);\n return AuthorityMetadataSource.NETWORK;\n } \n\n if (harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache) {\n // If the user prefers to use an azure region replace the global endpoints with regional information.\n if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {\n harcodedMetadata = await this.updateMetadataWithRegionalInformation(\n harcodedMetadata\n );\n }\n\n metadataEntity.updateEndpointMetadata(harcodedMetadata, false);\n return AuthorityMetadataSource.HARDCODED_VALUES;\n } else {\n throw ClientAuthError.createUnableToGetOpenidConfigError(\n this.defaultOpenIdConfigurationEndpoint\n );\n }\n }\n\n /**\n * Compares the number of url components after the domain to determine if the cached authority metadata can be used for the requested authority\n * Protects against same domain different authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy\n * @param metadataEntity\n */\n private isAuthoritySameType(metadataEntity: AuthorityMetadataEntity): boolean {\n const cachedAuthorityUrl = new UrlString(metadataEntity.canonical_authority);\n const cachedParts = cachedAuthorityUrl.getUrlComponents().PathSegments;\n\n return cachedParts.length === this.canonicalAuthorityUrlComponents.PathSegments.length;\n }\n\n /**\n * Parse authorityMetadata config option\n */\n private getEndpointMetadataFromConfig(): OpenIdConfigResponse | null {\n if (this.authorityOptions.authorityMetadata) {\n try {\n return JSON.parse(this.authorityOptions.authorityMetadata) as OpenIdConfigResponse;\n } catch (e) {\n throw ClientConfigurationError.createInvalidAuthorityMetadataError();\n }\n }\n\n return null;\n }\n\n /**\n * Gets OAuth endpoints from the given OpenID configuration endpoint.\n * \n * @param hasHardcodedMetadata boolean\n */\n private async getEndpointMetadataFromNetwork(): Promise<OpenIdConfigResponse | null> {\n const options: ImdsOptions = {};\n if (this.proxyUrl) {\n options.proxyUrl = this.proxyUrl;\n }\n\n /*\n * TODO: Add a timeout if the authority exists in our library's \n * hardcoded list of metadata\n */\n\n try {\n const response = await this.networkInterface.sendGetRequestAsync<OpenIdConfigResponse>(this.defaultOpenIdConfigurationEndpoint, options);\n return isOpenIdConfigResponse(response.body) ? response.body : null;\n } catch (e) {\n return null;\n }\n }\n\n /**\n * Get OAuth endpoints for common authorities.\n */\n private getEndpointMetadataFromHardcodedValues(): OpenIdConfigResponse | null {\n if (this.canonicalAuthority in EndpointMetadata) {\n return EndpointMetadata[this.canonicalAuthority];\n }\n\n return null;\n }\n\n /**\n * Update the retrieved metadata with regional information.\n */\n private async updateMetadataWithRegionalInformation(metadata: OpenIdConfigResponse): Promise<OpenIdConfigResponse> {\n const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration?.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl);\n\n const azureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG\n ? autodetectedRegionName\n : this.authorityOptions.azureRegionConfiguration?.azureRegion;\n\n if (this.authorityOptions.azureRegionConfiguration?.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {\n this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?\n RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :\n RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;\n } else {\n if (autodetectedRegionName) {\n this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration?.azureRegion === autodetectedRegionName) ?\n RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :\n RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;\n } else {\n this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;\n }\n }\n\n if (azureRegion) {\n this.regionDiscoveryMetadata.region_used = azureRegion;\n return Authority.replaceWithRegionalInformation(metadata, azureRegion);\n }\n\n return metadata;\n }\n\n /**\n * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from\n * @param cachedMetadata\n * @param newMetadata\n */\n private async updateCloudDiscoveryMetadata(metadataEntity: AuthorityMetadataEntity): Promise<AuthorityMetadataSource> {\n let metadata = this.getCloudDiscoveryMetadataFromConfig();\n if (metadata) {\n metadataEntity.updateCloudDiscoveryMetadata(metadata, false);\n return AuthorityMetadataSource.CONFIG;\n }\n\n // If The cached metadata came from config but that config was not passed to this instance, we must go to the network\n if (this.isAuthoritySameType(metadataEntity) && metadataEntity.aliasesFromNetwork && !metadataEntity.isExpired()) {\n // No need to update\n return AuthorityMetadataSource.CACHE;\n }\n\n const harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();\n metadata = await this.getCloudDiscoveryMetadataFromNetwork();\n if (metadata) {\n metadataEntity.updateCloudDiscoveryMetadata(metadata, true);\n return AuthorityMetadataSource.NETWORK;\n } \n \n if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {\n metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);\n return AuthorityMetadataSource.HARDCODED_VALUES;\n } else {\n // Metadata could not be obtained from config, cache or network\n throw ClientConfigurationError.createUntrustedAuthorityError();\n }\n }\n\n /**\n * Parse cloudDiscoveryMetadata config or check knownAuthorities\n */\n private getCloudDiscoveryMetadataFromConfig(): CloudDiscoveryMetadata | null {\n // Check if network response was provided in config\n if (this.authorityOptions.cloudDiscoveryMetadata) {\n try {\n const parsedResponse = JSON.parse(this.authorityOptions.cloudDiscoveryMetadata) as CloudInstanceDiscoveryResponse;\n const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(parsedResponse.metadata, this.hostnameAndPort);\n if (metadata) {\n return metadata;\n }\n } catch (e) {\n throw ClientConfigurationError.createInvalidCloudDiscoveryMetadataError();\n }\n }\n\n // If cloudDiscoveryMetadata is empty or does not contain the host, check knownAuthorities\n if (this.isInKnownAuthorities()) {\n return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);\n }\n\n return null;\n }\n\n /**\n * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config\n * \n * @param hasHardcodedMetadata boolean\n */\n private async getCloudDiscoveryMetadataFromNetwork(): Promise<CloudDiscoveryMetadata | null> {\n const instanceDiscoveryEndpoint = `${Constants.AAD_INSTANCE_DISCOVERY_ENDPT}${this.canonicalAuthority}oauth2/v2.0/authorize`;\n const options: ImdsOptions = {};\n if (this.proxyUrl) {\n options.proxyUrl = this.proxyUrl;\n }\n\n /*\n * TODO: Add a timeout if the authority exists in our library's\n * hardcoded list of metadata\n */\n\n let match = null;\n try {\n const response =\n await this.networkInterface.sendGetRequestAsync<CloudInstanceDiscoveryResponse>(\n instanceDiscoveryEndpoint,\n options\n );\n const metadata = isCloudInstanceDiscoveryResponse(response.body)\n ? response.body.metadata\n : [];\n if (metadata.length === 0) {\n // If no metadata is returned, authority is untrusted\n return null;\n }\n match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(\n metadata,\n this.hostnameAndPort\n );\n } catch (e) {\n return null;\n }\n\n if (!match) {\n // Custom Domain scenario, host is trusted because Instance Discovery call succeeded\n match = Authority.createCloudDiscoveryMetadataFromHost(\n this.hostnameAndPort\n );\n }\n return match;\n }\n\n /**\n * Get cloud discovery metadata for common authorities \n */\n private getCloudDiscoveryMetadataFromHarcodedValues(): CloudDiscoveryMetadata | null {\n if (this.canonicalAuthority in InstanceDiscoveryMetadata) {\n return InstanceDiscoveryMetadata[this.canonicalAuthority];\n }\n\n return null;\n }\n\n /**\n * Helper function to determine if this host is included in the knownAuthorities config option\n */\n private isInKnownAuthorities(): boolean {\n const matches = this.authorityOptions.knownAuthorities.filter((authority) => {\n return UrlString.getDomainFromUrl(authority).toLowerCase() === this.hostnameAndPort;\n });\n\n return matches.length > 0;\n }\n\n /**\n * helper function to populate the authority based on azureCloudOptions\n * @param authorityString\n * @param azureCloudOptions\n */\n static generateAuthority(authorityString: string, azureCloudOptions?: AzureCloudOptions): string {\n let authorityAzureCloudInstance;\n\n if (azureCloudOptions && azureCloudOptions.azureCloudInstance !== AzureCloudInstance.None) {\n const tenant = azureCloudOptions.tenant ? azureCloudOptions.tenant : Constants.DEFAULT_COMMON_TENANT;\n authorityAzureCloudInstance = `${azureCloudOptions.azureCloudInstance}/${tenant}/`;\n }\n\n return authorityAzureCloudInstance ? authorityAzureCloudInstance : authorityString;\n }\n\n /**\n * Creates cloud discovery metadata object from a given host\n * @param host\n */\n static createCloudDiscoveryMetadataFromHost(host: string): CloudDiscoveryMetadata {\n return {\n preferred_network: host,\n preferred_cache: host,\n aliases: [host]\n };\n }\n\n /**\n * Searches instance discovery network response for the entry that contains the host in the aliases list\n * @param response\n * @param authority\n */\n static getCloudDiscoveryMetadataFromNetworkResponse(response: CloudDiscoveryMetadata[], authority: string): CloudDiscoveryMetadata | null {\n for (let i = 0; i < response.length; i++) {\n const metadata = response[i];\n if (metadata.aliases.indexOf(authority) > -1) {\n return metadata;\n }\n }\n\n return null;\n }\n\n /**\n * helper function to generate environment from authority object\n */\n getPreferredCache(): string {\n if(this.discoveryComplete()) {\n return this.metadata.preferred_cache;\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Returns whether or not the provided host is an alias of this authority instance\n * @param host\n */\n isAlias(host: string): boolean {\n return this.metadata.aliases.indexOf(host) > -1;\n }\n\n /**\n * Checks whether the provided host is that of a public cloud authority\n *\n * @param authority string\n * @returns bool\n */\n static isPublicCloudAuthority(host: string): boolean {\n return Constants.KNOWN_PUBLIC_CLOUDS.indexOf(host) >= 0;\n }\n\n /**\n * Rebuild the authority string with the region\n *\n * @param host string\n * @param region string\n */\n static buildRegionalAuthorityString(host: string, region: string, queryString?: string): string {\n // Create and validate a Url string object with the initial authority string\n const authorityUrlInstance = new UrlString(host);\n authorityUrlInstance.validateAsUri();\n\n const authorityUrlParts = authorityUrlInstance.getUrlComponents();\n\n let hostNameAndPort= `${region}.${authorityUrlParts.HostNameAndPort}`;\n\n if (this.isPublicCloudAuthority(authorityUrlParts.HostNameAndPort)) {\n hostNameAndPort = `${region}.${Constants.REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX}`;\n }\n\n // Include the query string portion of the url\n const url = UrlString.constructAuthorityUriFromObject({\n ...authorityUrlInstance.getUrlComponents(),\n HostNameAndPort: hostNameAndPort\n }).urlString;\n\n // Add the query string if a query string was provided\n if (queryString) return `${url}?${queryString}`;\n\n return url;\n }\n\n /**\n * Replace the endpoints in the metadata object with their regional equivalents.\n *\n * @param metadata OpenIdConfigResponse\n * @param azureRegion string\n */\n static replaceWithRegionalInformation(metadata: OpenIdConfigResponse, azureRegion: string): OpenIdConfigResponse {\n metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);\n // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature\n metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, \"allowestsrnonmsi=true\");\n\n if (metadata.end_session_endpoint) {\n metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);\n }\n\n return metadata;\n }\n}\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;AAyBA;;;;;IAyBI,mBAAY,SAAiB,EAAE,gBAAgC,EAAE,YAA2B,EAAE,gBAAkC,EAAE,QAAiB;QAC/I,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACpC,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,CAAC;QACzC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAC7D,IA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oB,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACjD,oBAAoB,CAAC,aAAa,EAAE,CAAC;QAErC,IAAM,iBAAiB,GAAG,oBAAoB,CAAC,gBAAgB,EAAE,CAAC;QAElE,IAAI,eAAe,GAAK,MAAM,SAAI,iBAAiB,CAAC,eAAiB,CAAC;QAEtE,IAAI,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE;YAChE,eAAe,GAAM,MAAM,SAAI,SAAS,CAAC,iCAAmC,CAAC;SAChF;;QAGD,IAAM,GAAG,GAAG,SAAS,CAAC,+BAA+B,uBAC9C,oBAAoB,CAAC,gBAAgB,EAAE,KAC1C,eAAe,EAAE,eAAe,IAClC,CAAC,SAAS,CAAC;;QAGb,IAAI,WAAW;YAAE,OAAU,GAAG,SAAI,WAAa,CAAC;QAEhD,OAAO,GAAG,CAAC;KACd;;;;;;;IAQM,wCAA8B,GAArC,UAAsC,QAA8B,EAAE,WAAmB;QACrF,QAAQ,CAAC,sBAAsB,GAAG,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;;QAEvH,QAAQ,CAAC,cAAc,GAAG,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,EAAE,uBAAuB,CAAC,CAAC;QAEhI,IAAI,QAAQ,CAAC,oBAAoB,EAAE;YAC/B,QAAQ,CAAC,oBAAoB,GAAG,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;SACtH;QAED,OAAO,QAAQ,CAAC;KACnB;IACL,gBAAC;AAAD,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.0.0 2022-06-13 */
1
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2
2
  'use strict';
3
3
  import { __awaiter, __generator } from '../_virtual/_tslib.js';
4
4
  import { Authority } from './Authority.js';