@azure/msal-common 13.0.0 → 13.2.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.
- package/LICENSE +21 -21
- package/README.md +62 -62
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/authority/Authority.d.ts +14 -0
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +87 -59
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityMetadata.js +1 -1
- package/dist/authority/AuthorityMetadata.js.map +1 -1
- package/dist/authority/AuthorityOptions.js +1 -1
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.js +1 -1
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +1 -1
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +2 -2
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.js +1 -1
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.js +1 -1
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.js +1 -1
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.js +1 -1
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +15 -8
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.js +1 -1
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +12 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +6 -2
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/JoseHeader.js +1 -1
- package/dist/crypto/JoseHeader.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +1 -1
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.js +1 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts +8 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +11 -1
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/JoseHeaderError.js +1 -1
- package/dist/error/JoseHeaderError.js.map +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +117 -68
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/ThrottlingUtils.js +1 -1
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +1 -1
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/RequestParameterBuilder.js +1 -1
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/ResponseHandler.js +1 -1
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +1 -1
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +2 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +2 -1
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +76 -76
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v13.
|
|
1
|
+
/*! @azure/msal-common v13.2.0 2023-07-05 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -461,6 +461,7 @@ var CacheOutcome;
|
|
|
461
461
|
CacheOutcome["NO_CACHED_ACCESS_TOKEN"] = "2";
|
|
462
462
|
CacheOutcome["CACHED_ACCESS_TOKEN_EXPIRED"] = "3";
|
|
463
463
|
CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
|
|
464
|
+
CacheOutcome["CLAIMS_REQUESTED_CACHE_SKIPPED"] = "5";
|
|
464
465
|
})(CacheOutcome || (CacheOutcome = {}));
|
|
465
466
|
var JsonTypes;
|
|
466
467
|
(function (JsonTypes) {
|
|
@@ -1423,7 +1424,7 @@ var Logger = /** @class */ (function () {
|
|
|
1423
1424
|
|
|
1424
1425
|
/* eslint-disable header/header */
|
|
1425
1426
|
var name = "@azure/msal-common";
|
|
1426
|
-
var version = "13.
|
|
1427
|
+
var version = "13.2.0";
|
|
1427
1428
|
|
|
1428
1429
|
/*
|
|
1429
1430
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1544,6 +1545,10 @@ var ClientConfigurationErrorMessage = {
|
|
|
1544
1545
|
invalidAuthenticationHeader: {
|
|
1545
1546
|
code: "invalid_authentication_header",
|
|
1546
1547
|
desc: "Invalid authentication header provided"
|
|
1548
|
+
},
|
|
1549
|
+
authorityMismatch: {
|
|
1550
|
+
code: "authority_mismatch",
|
|
1551
|
+
desc: "Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority."
|
|
1547
1552
|
}
|
|
1548
1553
|
};
|
|
1549
1554
|
/**
|
|
@@ -1695,6 +1700,12 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1695
1700
|
ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
|
|
1696
1701
|
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
|
|
1697
1702
|
};
|
|
1703
|
+
/**
|
|
1704
|
+
* Create an error when the authority provided in request does not match authority provided in account or MSAL.js configuration.
|
|
1705
|
+
*/
|
|
1706
|
+
ClientConfigurationError.createAuthorityMismatchError = function () {
|
|
1707
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.authorityMismatch.code, ClientConfigurationErrorMessage.authorityMismatch.desc);
|
|
1708
|
+
};
|
|
1698
1709
|
return ClientConfigurationError;
|
|
1699
1710
|
}(ClientAuthError));
|
|
1700
1711
|
|
|
@@ -3297,6 +3308,9 @@ var DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
|
3297
3308
|
logLevel: exports.LogLevel.Info,
|
|
3298
3309
|
correlationId: Constants.EMPTY_STRING
|
|
3299
3310
|
};
|
|
3311
|
+
var DEFAULT_CACHE_OPTIONS = {
|
|
3312
|
+
claimsBasedCachingEnabled: true
|
|
3313
|
+
};
|
|
3300
3314
|
var DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
3301
3315
|
sendGetRequestAsync: function () {
|
|
3302
3316
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3345,12 +3359,13 @@ var DEFAULT_TELEMETRY_OPTIONS = {
|
|
|
3345
3359
|
* @returns Configuration
|
|
3346
3360
|
*/
|
|
3347
3361
|
function buildClientConfiguration(_a) {
|
|
3348
|
-
var userAuthOptions = _a.authOptions, userSystemOptions = _a.systemOptions, userLoggerOption = _a.loggerOptions, storageImplementation = _a.storageInterface, networkImplementation = _a.networkInterface, cryptoImplementation = _a.cryptoInterface, clientCredentials = _a.clientCredentials, libraryInfo = _a.libraryInfo, telemetry = _a.telemetry, serverTelemetryManager = _a.serverTelemetryManager, persistencePlugin = _a.persistencePlugin, serializableCache = _a.serializableCache;
|
|
3362
|
+
var userAuthOptions = _a.authOptions, userSystemOptions = _a.systemOptions, userLoggerOption = _a.loggerOptions, userCacheOptions = _a.cacheOptions, storageImplementation = _a.storageInterface, networkImplementation = _a.networkInterface, cryptoImplementation = _a.cryptoInterface, clientCredentials = _a.clientCredentials, libraryInfo = _a.libraryInfo, telemetry = _a.telemetry, serverTelemetryManager = _a.serverTelemetryManager, persistencePlugin = _a.persistencePlugin, serializableCache = _a.serializableCache;
|
|
3349
3363
|
var loggerOptions = __assign(__assign({}, DEFAULT_LOGGER_IMPLEMENTATION), userLoggerOption);
|
|
3350
3364
|
return {
|
|
3351
3365
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
3352
3366
|
systemOptions: __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),
|
|
3353
3367
|
loggerOptions: loggerOptions,
|
|
3368
|
+
cacheOptions: __assign(__assign({}, DEFAULT_CACHE_OPTIONS), userCacheOptions),
|
|
3354
3369
|
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION, new Logger(loggerOptions)),
|
|
3355
3370
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
3356
3371
|
cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
@@ -6072,7 +6087,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
6072
6087
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
6073
6088
|
case 1:
|
|
6074
6089
|
reqCnfData = _b.sent();
|
|
6075
|
-
parameterBuilder.addPopToken(reqCnfData.
|
|
6090
|
+
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
6076
6091
|
_b.label = 2;
|
|
6077
6092
|
case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
6078
6093
|
}
|
|
@@ -7090,11 +7105,11 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
7090
7105
|
* @param request
|
|
7091
7106
|
*/
|
|
7092
7107
|
SilentFlowClient.prototype.acquireCachedToken = function (request) {
|
|
7093
|
-
var _a, _b, _c, _d;
|
|
7108
|
+
var _a, _b, _c, _d, _e;
|
|
7094
7109
|
return __awaiter(this, void 0, void 0, function () {
|
|
7095
7110
|
var environment, cacheRecord;
|
|
7096
|
-
return __generator(this, function (
|
|
7097
|
-
switch (
|
|
7111
|
+
return __generator(this, function (_f) {
|
|
7112
|
+
switch (_f.label) {
|
|
7098
7113
|
case 0:
|
|
7099
7114
|
// Cannot renew token if no request object is given.
|
|
7100
7115
|
if (!request) {
|
|
@@ -7106,6 +7121,12 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
7106
7121
|
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
|
|
7107
7122
|
throw ClientAuthError.createRefreshRequiredError();
|
|
7108
7123
|
}
|
|
7124
|
+
else if (!this.config.cacheOptions.claimsBasedCachingEnabled && !StringUtils.isEmptyObj(request.claims)) {
|
|
7125
|
+
// Must refresh due to presence of claims in request preventing cache lookup
|
|
7126
|
+
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.CLAIMS_REQUESTED_CACHE_SKIPPED);
|
|
7127
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims-based caching is disabled and claims were requested.");
|
|
7128
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
7129
|
+
}
|
|
7109
7130
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
7110
7131
|
if (!request.account) {
|
|
7111
7132
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -7114,20 +7135,20 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
7114
7135
|
cacheRecord = this.cacheManager.readCacheRecord(request.account, request, environment);
|
|
7115
7136
|
if (!cacheRecord.accessToken) {
|
|
7116
7137
|
// Must refresh due to non-existent access_token.
|
|
7117
|
-
(
|
|
7138
|
+
(_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
7118
7139
|
this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
|
|
7119
7140
|
throw ClientAuthError.createRefreshRequiredError();
|
|
7120
7141
|
}
|
|
7121
7142
|
else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
|
|
7122
7143
|
TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
7123
7144
|
// Must refresh due to expired access_token.
|
|
7124
|
-
(
|
|
7145
|
+
(_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
7125
7146
|
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
|
|
7126
7147
|
throw ClientAuthError.createRefreshRequiredError();
|
|
7127
7148
|
}
|
|
7128
7149
|
else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
|
|
7129
7150
|
// Must refresh due to the refresh_in value.
|
|
7130
|
-
(
|
|
7151
|
+
(_e = this.serverTelemetryManager) === null || _e === void 0 ? void 0 : _e.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
|
|
7131
7152
|
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
|
|
7132
7153
|
throw ClientAuthError.createRefreshRequiredError();
|
|
7133
7154
|
}
|
|
@@ -7135,7 +7156,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
7135
7156
|
this.config.serverTelemetryManager.incrementCacheHits();
|
|
7136
7157
|
}
|
|
7137
7158
|
return [4 /*yield*/, this.generateResultFromCacheRecord(cacheRecord, request)];
|
|
7138
|
-
case 1: return [2 /*return*/,
|
|
7159
|
+
case 1: return [2 /*return*/, _f.sent()];
|
|
7139
7160
|
}
|
|
7140
7161
|
});
|
|
7141
7162
|
});
|
|
@@ -7561,23 +7582,31 @@ var Authority = /** @class */ (function () {
|
|
|
7561
7582
|
this.correlationId = correlationId;
|
|
7562
7583
|
this.regionDiscovery = new RegionDiscovery(networkInterface, this.performanceClient, this.correlationId);
|
|
7563
7584
|
}
|
|
7585
|
+
/**
|
|
7586
|
+
* Get {@link AuthorityType}
|
|
7587
|
+
* @param authorityUri {@link IUri}
|
|
7588
|
+
* @private
|
|
7589
|
+
*/
|
|
7590
|
+
Authority.prototype.getAuthorityType = function (authorityUri) {
|
|
7591
|
+
// CIAM auth url pattern is being standardized as: <tenant>.ciamlogin.com
|
|
7592
|
+
if (authorityUri.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
7593
|
+
return exports.AuthorityType.Ciam;
|
|
7594
|
+
}
|
|
7595
|
+
var pathSegments = authorityUri.PathSegments;
|
|
7596
|
+
if (pathSegments.length) {
|
|
7597
|
+
switch (pathSegments[0].toLowerCase()) {
|
|
7598
|
+
case Constants.ADFS:
|
|
7599
|
+
return exports.AuthorityType.Adfs;
|
|
7600
|
+
case Constants.DSTS:
|
|
7601
|
+
return exports.AuthorityType.Dsts;
|
|
7602
|
+
}
|
|
7603
|
+
}
|
|
7604
|
+
return exports.AuthorityType.Default;
|
|
7605
|
+
};
|
|
7564
7606
|
Object.defineProperty(Authority.prototype, "authorityType", {
|
|
7565
7607
|
// See above for AuthorityType
|
|
7566
7608
|
get: function () {
|
|
7567
|
-
|
|
7568
|
-
if (this.canonicalAuthorityUrlComponents.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
7569
|
-
return exports.AuthorityType.Ciam;
|
|
7570
|
-
}
|
|
7571
|
-
var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7572
|
-
if (pathSegments.length) {
|
|
7573
|
-
switch (pathSegments[0].toLowerCase()) {
|
|
7574
|
-
case Constants.ADFS:
|
|
7575
|
-
return exports.AuthorityType.Adfs;
|
|
7576
|
-
case Constants.DSTS:
|
|
7577
|
-
return exports.AuthorityType.Dsts;
|
|
7578
|
-
}
|
|
7579
|
-
}
|
|
7580
|
-
return exports.AuthorityType.Default;
|
|
7609
|
+
return this.getAuthorityType(this.canonicalAuthorityUrlComponents);
|
|
7581
7610
|
},
|
|
7582
7611
|
enumerable: false,
|
|
7583
7612
|
configurable: true
|
|
@@ -7659,8 +7688,7 @@ var Authority = /** @class */ (function () {
|
|
|
7659
7688
|
*/
|
|
7660
7689
|
get: function () {
|
|
7661
7690
|
if (this.discoveryComplete()) {
|
|
7662
|
-
|
|
7663
|
-
return this.replaceTenant(endpoint);
|
|
7691
|
+
return this.replacePath(this.metadata.authorization_endpoint);
|
|
7664
7692
|
}
|
|
7665
7693
|
else {
|
|
7666
7694
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
@@ -7675,8 +7703,7 @@ var Authority = /** @class */ (function () {
|
|
|
7675
7703
|
*/
|
|
7676
7704
|
get: function () {
|
|
7677
7705
|
if (this.discoveryComplete()) {
|
|
7678
|
-
|
|
7679
|
-
return this.replaceTenant(endpoint);
|
|
7706
|
+
return this.replacePath(this.metadata.token_endpoint);
|
|
7680
7707
|
}
|
|
7681
7708
|
else {
|
|
7682
7709
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
@@ -7688,8 +7715,7 @@ var Authority = /** @class */ (function () {
|
|
|
7688
7715
|
Object.defineProperty(Authority.prototype, "deviceCodeEndpoint", {
|
|
7689
7716
|
get: function () {
|
|
7690
7717
|
if (this.discoveryComplete()) {
|
|
7691
|
-
|
|
7692
|
-
return this.replaceTenant(endpoint);
|
|
7718
|
+
return this.replacePath(this.metadata.token_endpoint.replace("/token", "/devicecode"));
|
|
7693
7719
|
}
|
|
7694
7720
|
else {
|
|
7695
7721
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
@@ -7708,8 +7734,7 @@ var Authority = /** @class */ (function () {
|
|
|
7708
7734
|
if (!this.metadata.end_session_endpoint) {
|
|
7709
7735
|
throw ClientAuthError.createLogoutNotSupportedError();
|
|
7710
7736
|
}
|
|
7711
|
-
|
|
7712
|
-
return this.replaceTenant(endpoint);
|
|
7737
|
+
return this.replacePath(this.metadata.end_session_endpoint);
|
|
7713
7738
|
}
|
|
7714
7739
|
else {
|
|
7715
7740
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
@@ -7724,8 +7749,7 @@ var Authority = /** @class */ (function () {
|
|
|
7724
7749
|
*/
|
|
7725
7750
|
get: function () {
|
|
7726
7751
|
if (this.discoveryComplete()) {
|
|
7727
|
-
|
|
7728
|
-
return this.replaceTenant(endpoint);
|
|
7752
|
+
return this.replacePath(this.metadata.issuer);
|
|
7729
7753
|
}
|
|
7730
7754
|
else {
|
|
7731
7755
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
@@ -7740,8 +7764,7 @@ var Authority = /** @class */ (function () {
|
|
|
7740
7764
|
*/
|
|
7741
7765
|
get: function () {
|
|
7742
7766
|
if (this.discoveryComplete()) {
|
|
7743
|
-
|
|
7744
|
-
return this.replaceTenant(endpoint);
|
|
7767
|
+
return this.replacePath(this.metadata.jwks_uri);
|
|
7745
7768
|
}
|
|
7746
7769
|
else {
|
|
7747
7770
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
@@ -7750,6 +7773,17 @@ var Authority = /** @class */ (function () {
|
|
|
7750
7773
|
enumerable: false,
|
|
7751
7774
|
configurable: true
|
|
7752
7775
|
});
|
|
7776
|
+
/**
|
|
7777
|
+
* Returns a flag indicating that tenant name can be replaced in authority {@link IUri}
|
|
7778
|
+
* @param authorityUri {@link IUri}
|
|
7779
|
+
* @private
|
|
7780
|
+
*/
|
|
7781
|
+
Authority.prototype.canReplaceTenant = function (authorityUri) {
|
|
7782
|
+
return authorityUri.PathSegments.length === 1
|
|
7783
|
+
&& !Authority.reservedTenantDomains.has(authorityUri.PathSegments[0])
|
|
7784
|
+
&& this.getAuthorityType(authorityUri) === exports.AuthorityType.Default
|
|
7785
|
+
&& this.protocolMode === exports.ProtocolMode.AAD;
|
|
7786
|
+
};
|
|
7753
7787
|
/**
|
|
7754
7788
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
7755
7789
|
* @param urlString
|
|
@@ -7762,17 +7796,31 @@ var Authority = /** @class */ (function () {
|
|
|
7762
7796
|
* @param urlString
|
|
7763
7797
|
*/
|
|
7764
7798
|
Authority.prototype.replacePath = function (urlString) {
|
|
7799
|
+
var _this = this;
|
|
7765
7800
|
var endpoint = urlString;
|
|
7766
7801
|
var cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority);
|
|
7767
|
-
var
|
|
7802
|
+
var cachedAuthorityUrlComponents = cachedAuthorityUrl.getUrlComponents();
|
|
7803
|
+
var cachedAuthorityParts = cachedAuthorityUrlComponents.PathSegments;
|
|
7768
7804
|
var currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7769
7805
|
currentAuthorityParts.forEach(function (currentPart, index) {
|
|
7770
7806
|
var cachedPart = cachedAuthorityParts[index];
|
|
7807
|
+
if (index === 0 && _this.canReplaceTenant(cachedAuthorityUrlComponents)) {
|
|
7808
|
+
var tenantId = (new UrlString(_this.metadata.authorization_endpoint)).getUrlComponents().PathSegments[0];
|
|
7809
|
+
/**
|
|
7810
|
+
* Check if AAD canonical authority contains tenant domain name, for example "testdomain.onmicrosoft.com",
|
|
7811
|
+
* by comparing its first path segment to the corresponding authorization endpoint path segment, which is
|
|
7812
|
+
* always resolved with tenant id by OIDC.
|
|
7813
|
+
*/
|
|
7814
|
+
if (cachedPart !== tenantId) {
|
|
7815
|
+
_this.logger.verbose("Replacing tenant domain name " + cachedPart + " with id " + tenantId);
|
|
7816
|
+
cachedPart = tenantId;
|
|
7817
|
+
}
|
|
7818
|
+
}
|
|
7771
7819
|
if (currentPart !== cachedPart) {
|
|
7772
7820
|
endpoint = endpoint.replace("/" + cachedPart + "/", "/" + currentPart + "/");
|
|
7773
7821
|
}
|
|
7774
7822
|
});
|
|
7775
|
-
return endpoint;
|
|
7823
|
+
return this.replaceTenant(endpoint);
|
|
7776
7824
|
};
|
|
7777
7825
|
Object.defineProperty(Authority.prototype, "defaultOpenIdConfigurationEndpoint", {
|
|
7778
7826
|
/**
|
|
@@ -7952,42 +8000,35 @@ var Authority = /** @class */ (function () {
|
|
|
7952
8000
|
};
|
|
7953
8001
|
/**
|
|
7954
8002
|
* Update the retrieved metadata with regional information.
|
|
8003
|
+
* User selected Azure region will be used if configured.
|
|
7955
8004
|
*/
|
|
7956
8005
|
Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
|
|
7957
|
-
var _a, _b, _c, _d
|
|
8006
|
+
var _a, _b, _c, _d;
|
|
7958
8007
|
return __awaiter(this, void 0, void 0, function () {
|
|
7959
|
-
var
|
|
7960
|
-
return __generator(this, function (
|
|
7961
|
-
switch (
|
|
8008
|
+
var userConfiguredAzureRegion, autodetectedRegionName;
|
|
8009
|
+
return __generator(this, function (_e) {
|
|
8010
|
+
switch (_e.label) {
|
|
7962
8011
|
case 0:
|
|
7963
8012
|
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7964
|
-
(_b = this.
|
|
7965
|
-
return [
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
: (_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion;
|
|
7971
|
-
if (((_f = this.authorityOptions.azureRegionConfiguration) === null || _f === void 0 ? void 0 : _f.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7972
|
-
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
|
|
7973
|
-
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
|
|
7974
|
-
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7975
|
-
}
|
|
7976
|
-
else {
|
|
7977
|
-
if (autodetectedRegionName) {
|
|
7978
|
-
this.regionDiscoveryMetadata.region_outcome = (((_g = this.authorityOptions.azureRegionConfiguration) === null || _g === void 0 ? void 0 : _g.azureRegion) === autodetectedRegionName) ?
|
|
7979
|
-
RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
|
|
7980
|
-
RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
7981
|
-
}
|
|
7982
|
-
else {
|
|
7983
|
-
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7984
|
-
}
|
|
8013
|
+
userConfiguredAzureRegion = (_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion;
|
|
8014
|
+
if (!userConfiguredAzureRegion) return [3 /*break*/, 2];
|
|
8015
|
+
if (userConfiguredAzureRegion !== Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
8016
|
+
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
8017
|
+
this.regionDiscoveryMetadata.region_used = userConfiguredAzureRegion;
|
|
8018
|
+
return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, userConfiguredAzureRegion)];
|
|
7985
8019
|
}
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
8020
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
8021
|
+
return [4 /*yield*/, this.regionDiscovery.detectRegion((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.environmentRegion, this.regionDiscoveryMetadata)];
|
|
8022
|
+
case 1:
|
|
8023
|
+
autodetectedRegionName = _e.sent();
|
|
8024
|
+
if (autodetectedRegionName) {
|
|
8025
|
+
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
|
|
8026
|
+
this.regionDiscoveryMetadata.region_used = autodetectedRegionName;
|
|
8027
|
+
return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, autodetectedRegionName)];
|
|
7989
8028
|
}
|
|
7990
|
-
|
|
8029
|
+
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
8030
|
+
_e.label = 2;
|
|
8031
|
+
case 2: return [2 /*return*/, metadata];
|
|
7991
8032
|
}
|
|
7992
8033
|
});
|
|
7993
8034
|
});
|
|
@@ -8300,6 +8341,14 @@ var Authority = /** @class */ (function () {
|
|
|
8300
8341
|
}
|
|
8301
8342
|
return ciamAuthority;
|
|
8302
8343
|
};
|
|
8344
|
+
// Reserved tenant domain names that will not be replaced with tenant id
|
|
8345
|
+
Authority.reservedTenantDomains = (new Set([
|
|
8346
|
+
"{tenant}",
|
|
8347
|
+
"{tenantid}",
|
|
8348
|
+
AADAuthorityConstants.COMMON,
|
|
8349
|
+
AADAuthorityConstants.CONSUMERS,
|
|
8350
|
+
AADAuthorityConstants.ORGANIZATIONS
|
|
8351
|
+
]));
|
|
8303
8352
|
return Authority;
|
|
8304
8353
|
}());
|
|
8305
8354
|
|