@azure/msal-common 12.1.0 → 14.0.0-alpha.1
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/account/AccountInfo.d.ts +2 -2
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.js +13 -14
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.d.ts +1 -1
- package/dist/account/CcsCredential.d.ts.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientCredentials.d.ts +2 -2
- package/dist/account/ClientCredentials.d.ts.map +1 -1
- package/dist/account/ClientInfo.d.ts +1 -1
- package/dist/account/ClientInfo.d.ts.map +1 -1
- package/dist/account/ClientInfo.js +6 -4
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/account/DecodedAuthToken.d.ts.map +1 -1
- package/dist/account/TokenClaims.d.ts +1 -1
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +464 -546
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.js +19 -34
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
- package/dist/authority/AuthorityMetadata.js +873 -4
- package/dist/authority/AuthorityMetadata.js.map +1 -1
- package/dist/authority/AuthorityOptions.d.ts +1 -1
- package/dist/authority/AuthorityOptions.d.ts.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/AzureRegion.d.ts +1 -1
- package/dist/authority/AzureRegion.d.ts.map +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -1
- package/dist/authority/CloudDiscoveryMetadata.d.ts +1 -1
- package/dist/authority/CloudDiscoveryMetadata.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/ImdsOptions.d.ts +1 -1
- package/dist/authority/ImdsOptions.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts.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.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.js +85 -107
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -1
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +440 -475
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +21 -22
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +78 -66
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +16 -17
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +22 -19
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -1
- package/dist/cache/entities/CacheRecord.js +4 -5
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +35 -34
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +8 -14
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +8 -14
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +8 -9
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +9 -11
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +16 -25
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +11 -11
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +341 -384
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.js +27 -35
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +208 -241
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +77 -105
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/config/AppTokenProvider.d.ts +2 -2
- package/dist/config/AppTokenProvider.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +9 -9
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +40 -43
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +2 -2
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +27 -58
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/JoseHeader.d.ts +1 -1
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.js +8 -9
- package/dist/crypto/JoseHeader.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +2 -2
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +47 -71
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.js +25 -28
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.d.ts +8 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +187 -181
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +82 -86
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +36 -35
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/JoseHeaderError.d.ts.map +1 -1
- package/dist/error/JoseHeaderError.js +14 -18
- package/dist/error/JoseHeaderError.js.map +1 -1
- package/dist/error/ServerError.d.ts.map +1 -1
- package/dist/error/ServerError.js +7 -11
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +4221 -4476
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +20 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.d.ts +1 -1
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.js +70 -60
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.d.ts +1 -1
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.js +7 -7
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.d.ts +4 -3
- package/dist/network/NetworkManager.d.ts.map +1 -1
- package/dist/network/NetworkManager.js +21 -35
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/RequestThumbprint.d.ts +1 -1
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.js +37 -36
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +3 -3
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +17 -18
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/BaseAuthRequest.d.ts +1 -1
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/CommonOnBehalfOfRequest.d.ts +1 -1
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/dist/request/CommonUsernamePasswordRequest.d.ts +1 -1
- package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -1
- package/dist/request/NativeRequest.d.ts +1 -1
- package/dist/request/NativeRequest.d.ts.map +1 -1
- package/dist/request/NativeSignOutRequest.d.ts +1 -1
- package/dist/request/NativeSignOutRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +111 -113
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.js +23 -28
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.d.ts.map +1 -1
- package/dist/request/ScopeSet.js +70 -70
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +1 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/AuthorizationCodePayload.d.ts +1 -1
- package/dist/response/AuthorizationCodePayload.d.ts.map +1 -1
- package/dist/response/DeviceCodeResponse.d.ts +2 -2
- package/dist/response/DeviceCodeResponse.d.ts.map +1 -1
- package/dist/response/ExternalTokenResponse.d.ts +1 -1
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -1
- package/dist/response/IMDSBadResponse.d.ts +1 -1
- package/dist/response/IMDSBadResponse.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +195 -180
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +3 -4
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +2 -10
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +134 -129
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +4 -4
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +2 -2
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +5 -3
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +23 -32
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +1 -2
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +106 -68
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts +1 -1
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts.map +1 -1
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.js +85 -74
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +28 -27
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/MsalTypes.d.ts +1 -1
- package/dist/utils/MsalTypes.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.d.ts +2 -2
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.js +27 -24
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.d.ts.map +1 -1
- package/dist/utils/StringUtils.js +44 -42
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.d.ts.map +1 -1
- package/dist/utils/TimeUtils.js +16 -19
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +79 -76
- package/dist/_virtual/_tslib.js +0 -90
- package/dist/_virtual/_tslib.js.map +0 -1
- package/dist/client/ClientCredentialClient.d.ts +0 -38
- package/dist/client/ClientCredentialClient.d.ts.map +0 -1
- package/dist/client/ClientCredentialClient.js +0 -203
- package/dist/client/ClientCredentialClient.js.map +0 -1
- package/dist/client/DeviceCodeClient.d.ts +0 -57
- package/dist/client/DeviceCodeClient.d.ts.map +0 -1
- package/dist/client/DeviceCodeClient.js +0 -250
- package/dist/client/DeviceCodeClient.js.map +0 -1
- package/dist/client/OnBehalfOfClient.d.ts +0 -51
- package/dist/client/OnBehalfOfClient.d.ts.map +0 -1
- package/dist/client/OnBehalfOfClient.js +0 -248
- package/dist/client/OnBehalfOfClient.js.map +0 -1
- package/dist/client/UsernamePasswordClient.d.ts +0 -29
- package/dist/client/UsernamePasswordClient.d.ts.map +0 -1
- package/dist/client/UsernamePasswordClient.js +0 -129
- package/dist/client/UsernamePasswordClient.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v14.0.0-alpha.1 2023-05-08 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
3
|
import { AuthorityType } from './AuthorityType.js';
|
|
5
4
|
import { isOpenIdConfigResponse } from './OpenIdConfigResponse.js';
|
|
6
5
|
import { UrlString } from '../url/UrlString.js';
|
|
@@ -25,359 +24,287 @@ import { PerformanceEvents } from '../telemetry/performance/PerformanceEvent.js'
|
|
|
25
24
|
* The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
|
|
26
25
|
* endpoint. It will store the pertinent config data in this object for use during token calls.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
class Authority {
|
|
28
|
+
constructor(authority, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
30
29
|
this.canonicalAuthority = authority;
|
|
31
30
|
this._canonicalAuthority.validateAsUri();
|
|
32
31
|
this.networkInterface = networkInterface;
|
|
33
32
|
this.cacheManager = cacheManager;
|
|
34
33
|
this.authorityOptions = authorityOptions;
|
|
35
|
-
this.regionDiscoveryMetadata = {
|
|
34
|
+
this.regionDiscoveryMetadata = {
|
|
35
|
+
region_used: undefined,
|
|
36
|
+
region_source: undefined,
|
|
37
|
+
region_outcome: undefined,
|
|
38
|
+
};
|
|
36
39
|
this.logger = logger;
|
|
37
40
|
this.performanceClient = performanceClient;
|
|
38
41
|
this.correlationId = correlationId;
|
|
39
42
|
this.regionDiscovery = new RegionDiscovery(networkInterface, this.performanceClient, this.correlationId);
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return AuthorityType.Dsts;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return AuthorityType.Default;
|
|
58
|
-
},
|
|
59
|
-
enumerable: false,
|
|
60
|
-
configurable: true
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(Authority.prototype, "protocolMode", {
|
|
63
|
-
/**
|
|
64
|
-
* ProtocolMode enum representing the way endpoints are constructed.
|
|
65
|
-
*/
|
|
66
|
-
get: function () {
|
|
67
|
-
return this.authorityOptions.protocolMode;
|
|
68
|
-
},
|
|
69
|
-
enumerable: false,
|
|
70
|
-
configurable: true
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(Authority.prototype, "options", {
|
|
73
|
-
/**
|
|
74
|
-
* Returns authorityOptions which can be used to reinstantiate a new authority instance
|
|
75
|
-
*/
|
|
76
|
-
get: function () {
|
|
77
|
-
return this.authorityOptions;
|
|
78
|
-
},
|
|
79
|
-
enumerable: false,
|
|
80
|
-
configurable: true
|
|
81
|
-
});
|
|
82
|
-
Object.defineProperty(Authority.prototype, "canonicalAuthority", {
|
|
83
|
-
/**
|
|
84
|
-
* A URL that is the authority set by the developer
|
|
85
|
-
*/
|
|
86
|
-
get: function () {
|
|
87
|
-
return this._canonicalAuthority.urlString;
|
|
88
|
-
},
|
|
89
|
-
/**
|
|
90
|
-
* Sets canonical authority.
|
|
91
|
-
*/
|
|
92
|
-
set: function (url) {
|
|
93
|
-
this._canonicalAuthority = new UrlString(url);
|
|
94
|
-
this._canonicalAuthority.validateAsUri();
|
|
95
|
-
this._canonicalAuthorityUrlComponents = null;
|
|
96
|
-
},
|
|
97
|
-
enumerable: false,
|
|
98
|
-
configurable: true
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(Authority.prototype, "canonicalAuthorityUrlComponents", {
|
|
101
|
-
/**
|
|
102
|
-
* Get authority components.
|
|
103
|
-
*/
|
|
104
|
-
get: function () {
|
|
105
|
-
if (!this._canonicalAuthorityUrlComponents) {
|
|
106
|
-
this._canonicalAuthorityUrlComponents = this._canonicalAuthority.getUrlComponents();
|
|
107
|
-
}
|
|
108
|
-
return this._canonicalAuthorityUrlComponents;
|
|
109
|
-
},
|
|
110
|
-
enumerable: false,
|
|
111
|
-
configurable: true
|
|
112
|
-
});
|
|
113
|
-
Object.defineProperty(Authority.prototype, "hostnameAndPort", {
|
|
114
|
-
/**
|
|
115
|
-
* Get hostname and port i.e. login.microsoftonline.com
|
|
116
|
-
*/
|
|
117
|
-
get: function () {
|
|
118
|
-
return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();
|
|
119
|
-
},
|
|
120
|
-
enumerable: false,
|
|
121
|
-
configurable: true
|
|
122
|
-
});
|
|
123
|
-
Object.defineProperty(Authority.prototype, "tenant", {
|
|
124
|
-
/**
|
|
125
|
-
* Get tenant for authority.
|
|
126
|
-
*/
|
|
127
|
-
get: function () {
|
|
128
|
-
return this.canonicalAuthorityUrlComponents.PathSegments[0];
|
|
129
|
-
},
|
|
130
|
-
enumerable: false,
|
|
131
|
-
configurable: true
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(Authority.prototype, "authorizationEndpoint", {
|
|
134
|
-
/**
|
|
135
|
-
* OAuth /authorize endpoint for requests
|
|
136
|
-
*/
|
|
137
|
-
get: function () {
|
|
138
|
-
if (this.discoveryComplete()) {
|
|
139
|
-
var endpoint = this.replacePath(this.metadata.authorization_endpoint);
|
|
140
|
-
return this.replaceTenant(endpoint);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
enumerable: false,
|
|
147
|
-
configurable: true
|
|
148
|
-
});
|
|
149
|
-
Object.defineProperty(Authority.prototype, "tokenEndpoint", {
|
|
150
|
-
/**
|
|
151
|
-
* OAuth /token endpoint for requests
|
|
152
|
-
*/
|
|
153
|
-
get: function () {
|
|
154
|
-
if (this.discoveryComplete()) {
|
|
155
|
-
var endpoint = this.replacePath(this.metadata.token_endpoint);
|
|
156
|
-
return this.replaceTenant(endpoint);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
enumerable: false,
|
|
163
|
-
configurable: true
|
|
164
|
-
});
|
|
165
|
-
Object.defineProperty(Authority.prototype, "deviceCodeEndpoint", {
|
|
166
|
-
get: function () {
|
|
167
|
-
if (this.discoveryComplete()) {
|
|
168
|
-
var endpoint = this.replacePath(this.metadata.token_endpoint.replace("/token", "/devicecode"));
|
|
169
|
-
return this.replaceTenant(endpoint);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
enumerable: false,
|
|
176
|
-
configurable: true
|
|
177
|
-
});
|
|
178
|
-
Object.defineProperty(Authority.prototype, "endSessionEndpoint", {
|
|
179
|
-
/**
|
|
180
|
-
* OAuth logout endpoint for requests
|
|
181
|
-
*/
|
|
182
|
-
get: function () {
|
|
183
|
-
if (this.discoveryComplete()) {
|
|
184
|
-
// ROPC policies may not have end_session_endpoint set
|
|
185
|
-
if (!this.metadata.end_session_endpoint) {
|
|
186
|
-
throw ClientAuthError.createLogoutNotSupportedError();
|
|
187
|
-
}
|
|
188
|
-
var endpoint = this.replacePath(this.metadata.end_session_endpoint);
|
|
189
|
-
return this.replaceTenant(endpoint);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
enumerable: false,
|
|
196
|
-
configurable: true
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(Authority.prototype, "selfSignedJwtAudience", {
|
|
199
|
-
/**
|
|
200
|
-
* OAuth issuer for requests
|
|
201
|
-
*/
|
|
202
|
-
get: function () {
|
|
203
|
-
if (this.discoveryComplete()) {
|
|
204
|
-
var endpoint = this.replacePath(this.metadata.issuer);
|
|
205
|
-
return this.replaceTenant(endpoint);
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
enumerable: false,
|
|
212
|
-
configurable: true
|
|
213
|
-
});
|
|
214
|
-
Object.defineProperty(Authority.prototype, "jwksUri", {
|
|
215
|
-
/**
|
|
216
|
-
* Jwks_uri for token signing keys
|
|
217
|
-
*/
|
|
218
|
-
get: function () {
|
|
219
|
-
if (this.discoveryComplete()) {
|
|
220
|
-
var endpoint = this.replacePath(this.metadata.jwks_uri);
|
|
221
|
-
return this.replaceTenant(endpoint);
|
|
44
|
+
// See above for AuthorityType
|
|
45
|
+
get authorityType() {
|
|
46
|
+
const pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
47
|
+
// CIAM auth url pattern is being standardized as: <tenant>.ciamlogin.com
|
|
48
|
+
if (this.canonicalAuthorityUrlComponents.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
49
|
+
return AuthorityType.Ciam;
|
|
50
|
+
}
|
|
51
|
+
if (pathSegments.length) {
|
|
52
|
+
switch (pathSegments[0].toLowerCase()) {
|
|
53
|
+
case Constants.ADFS:
|
|
54
|
+
return AuthorityType.Adfs;
|
|
55
|
+
case Constants.DSTS:
|
|
56
|
+
return AuthorityType.Dsts;
|
|
222
57
|
}
|
|
223
|
-
|
|
224
|
-
|
|
58
|
+
}
|
|
59
|
+
return AuthorityType.Default;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* ProtocolMode enum representing the way endpoints are constructed.
|
|
63
|
+
*/
|
|
64
|
+
get protocolMode() {
|
|
65
|
+
return this.authorityOptions.protocolMode;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns authorityOptions which can be used to reinstantiate a new authority instance
|
|
69
|
+
*/
|
|
70
|
+
get options() {
|
|
71
|
+
return this.authorityOptions;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A URL that is the authority set by the developer
|
|
75
|
+
*/
|
|
76
|
+
get canonicalAuthority() {
|
|
77
|
+
return this._canonicalAuthority.urlString;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sets canonical authority.
|
|
81
|
+
*/
|
|
82
|
+
set canonicalAuthority(url) {
|
|
83
|
+
this._canonicalAuthority = new UrlString(url);
|
|
84
|
+
this._canonicalAuthority.validateAsUri();
|
|
85
|
+
this._canonicalAuthorityUrlComponents = null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get authority components.
|
|
89
|
+
*/
|
|
90
|
+
get canonicalAuthorityUrlComponents() {
|
|
91
|
+
if (!this._canonicalAuthorityUrlComponents) {
|
|
92
|
+
this._canonicalAuthorityUrlComponents =
|
|
93
|
+
this._canonicalAuthority.getUrlComponents();
|
|
94
|
+
}
|
|
95
|
+
return this._canonicalAuthorityUrlComponents;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get hostname and port i.e. login.microsoftonline.com
|
|
99
|
+
*/
|
|
100
|
+
get hostnameAndPort() {
|
|
101
|
+
return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get tenant for authority.
|
|
105
|
+
*/
|
|
106
|
+
get tenant() {
|
|
107
|
+
return this.canonicalAuthorityUrlComponents.PathSegments[0];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* OAuth /authorize endpoint for requests
|
|
111
|
+
*/
|
|
112
|
+
get authorizationEndpoint() {
|
|
113
|
+
if (this.discoveryComplete()) {
|
|
114
|
+
const endpoint = this.replacePath(this.metadata.authorization_endpoint);
|
|
115
|
+
return this.replaceTenant(endpoint);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* OAuth /token endpoint for requests
|
|
123
|
+
*/
|
|
124
|
+
get tokenEndpoint() {
|
|
125
|
+
if (this.discoveryComplete()) {
|
|
126
|
+
const endpoint = this.replacePath(this.metadata.token_endpoint);
|
|
127
|
+
return this.replaceTenant(endpoint);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
get deviceCodeEndpoint() {
|
|
134
|
+
if (this.discoveryComplete()) {
|
|
135
|
+
const endpoint = this.replacePath(this.metadata.token_endpoint.replace("/token", "/devicecode"));
|
|
136
|
+
return this.replaceTenant(endpoint);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* OAuth logout endpoint for requests
|
|
144
|
+
*/
|
|
145
|
+
get endSessionEndpoint() {
|
|
146
|
+
if (this.discoveryComplete()) {
|
|
147
|
+
// ROPC policies may not have end_session_endpoint set
|
|
148
|
+
if (!this.metadata.end_session_endpoint) {
|
|
149
|
+
throw ClientAuthError.createLogoutNotSupportedError();
|
|
225
150
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
151
|
+
const endpoint = this.replacePath(this.metadata.end_session_endpoint);
|
|
152
|
+
return this.replaceTenant(endpoint);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* OAuth issuer for requests
|
|
160
|
+
*/
|
|
161
|
+
get selfSignedJwtAudience() {
|
|
162
|
+
if (this.discoveryComplete()) {
|
|
163
|
+
const endpoint = this.replacePath(this.metadata.issuer);
|
|
164
|
+
return this.replaceTenant(endpoint);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Jwks_uri for token signing keys
|
|
172
|
+
*/
|
|
173
|
+
get jwksUri() {
|
|
174
|
+
if (this.discoveryComplete()) {
|
|
175
|
+
const endpoint = this.replacePath(this.metadata.jwks_uri);
|
|
176
|
+
return this.replaceTenant(endpoint);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
230
182
|
/**
|
|
231
183
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
232
184
|
* @param urlString
|
|
233
185
|
*/
|
|
234
|
-
|
|
186
|
+
replaceTenant(urlString) {
|
|
235
187
|
return urlString.replace(/{tenant}|{tenantid}/g, this.tenant);
|
|
236
|
-
}
|
|
188
|
+
}
|
|
237
189
|
/**
|
|
238
190
|
* Replaces path such as tenant or policy with the current tenant or policy.
|
|
239
191
|
* @param urlString
|
|
240
192
|
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
currentAuthorityParts.forEach(
|
|
247
|
-
|
|
193
|
+
replacePath(urlString) {
|
|
194
|
+
let endpoint = urlString;
|
|
195
|
+
const cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority);
|
|
196
|
+
const cachedAuthorityParts = cachedAuthorityUrl.getUrlComponents().PathSegments;
|
|
197
|
+
const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
198
|
+
currentAuthorityParts.forEach((currentPart, index) => {
|
|
199
|
+
const cachedPart = cachedAuthorityParts[index];
|
|
248
200
|
if (currentPart !== cachedPart) {
|
|
249
|
-
endpoint = endpoint.replace(
|
|
201
|
+
endpoint = endpoint.replace(`/${cachedPart}/`, `/${currentPart}/`);
|
|
250
202
|
}
|
|
251
203
|
});
|
|
252
204
|
return endpoint;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
|
|
265
|
-
},
|
|
266
|
-
enumerable: false,
|
|
267
|
-
configurable: true
|
|
268
|
-
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The default open id configuration endpoint for any canonical authority.
|
|
208
|
+
*/
|
|
209
|
+
get defaultOpenIdConfigurationEndpoint() {
|
|
210
|
+
if (this.authorityType === AuthorityType.Adfs ||
|
|
211
|
+
this.protocolMode === ProtocolMode.OIDC) {
|
|
212
|
+
return `${this.canonicalAuthority}.well-known/openid-configuration`;
|
|
213
|
+
}
|
|
214
|
+
return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
|
|
215
|
+
}
|
|
269
216
|
/**
|
|
270
217
|
* Boolean that returns whethr or not tenant discovery has been completed.
|
|
271
218
|
*/
|
|
272
|
-
|
|
219
|
+
discoveryComplete() {
|
|
273
220
|
return !!this.metadata;
|
|
274
|
-
}
|
|
221
|
+
}
|
|
275
222
|
/**
|
|
276
223
|
* Perform endpoint discovery to discover aliases, preferred_cache, preferred_network
|
|
277
224
|
* and the /authorize, /token and logout endpoints.
|
|
278
225
|
*/
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {
|
|
302
|
-
// Reset the expiration time unless both values came from a successful cache lookup
|
|
303
|
-
metadataEntity.resetExpiresAt();
|
|
304
|
-
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
305
|
-
}
|
|
306
|
-
cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(metadataEntity.preferred_cache);
|
|
307
|
-
this.cacheManager.setAuthorityMetadata(cacheKey, metadataEntity);
|
|
308
|
-
this.metadata = metadataEntity;
|
|
309
|
-
return [2 /*return*/];
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
};
|
|
226
|
+
async resolveEndpointsAsync() {
|
|
227
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityResolveEndpointsAsync, this.correlationId);
|
|
228
|
+
let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
|
|
229
|
+
if (!metadataEntity) {
|
|
230
|
+
metadataEntity = new AuthorityMetadataEntity();
|
|
231
|
+
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
232
|
+
}
|
|
233
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
234
|
+
const cloudDiscoverySource = await this.updateCloudDiscoveryMetadata(metadataEntity);
|
|
235
|
+
this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
|
|
236
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
237
|
+
const endpointSource = await this.updateEndpointMetadata(metadataEntity);
|
|
238
|
+
if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE &&
|
|
239
|
+
endpointSource !== AuthorityMetadataSource.CACHE) {
|
|
240
|
+
// Reset the expiration time unless both values came from a successful cache lookup
|
|
241
|
+
metadataEntity.resetExpiresAt();
|
|
242
|
+
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
243
|
+
}
|
|
244
|
+
const cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(metadataEntity.preferred_cache);
|
|
245
|
+
this.cacheManager.setAuthorityMetadata(cacheKey, metadataEntity);
|
|
246
|
+
this.metadata = metadataEntity;
|
|
247
|
+
}
|
|
314
248
|
/**
|
|
315
249
|
* Update AuthorityMetadataEntity with new endpoints and return where the information came from
|
|
316
250
|
* @param metadataEntity
|
|
317
251
|
*/
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
case 6:
|
|
359
|
-
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
360
|
-
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
|
|
361
|
-
case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
};
|
|
252
|
+
async updateEndpointMetadata(metadataEntity) {
|
|
253
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
254
|
+
let metadata = this.getEndpointMetadataFromConfig();
|
|
255
|
+
if (metadata) {
|
|
256
|
+
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
257
|
+
return AuthorityMetadataSource.CONFIG;
|
|
258
|
+
}
|
|
259
|
+
if (this.isAuthoritySameType(metadataEntity) &&
|
|
260
|
+
metadataEntity.endpointsFromNetwork &&
|
|
261
|
+
!metadataEntity.isExpired()) {
|
|
262
|
+
// No need to update
|
|
263
|
+
return AuthorityMetadataSource.CACHE;
|
|
264
|
+
}
|
|
265
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
266
|
+
metadata = await this.getEndpointMetadataFromNetwork();
|
|
267
|
+
if (metadata) {
|
|
268
|
+
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
269
|
+
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
270
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
271
|
+
metadata = await this.updateMetadataWithRegionalInformation(metadata);
|
|
272
|
+
}
|
|
273
|
+
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
274
|
+
return AuthorityMetadataSource.NETWORK;
|
|
275
|
+
}
|
|
276
|
+
let harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
277
|
+
if (harcodedMetadata &&
|
|
278
|
+
!this.authorityOptions.skipAuthorityMetadataCache) {
|
|
279
|
+
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
280
|
+
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
281
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
282
|
+
harcodedMetadata =
|
|
283
|
+
await this.updateMetadataWithRegionalInformation(harcodedMetadata);
|
|
284
|
+
}
|
|
285
|
+
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
286
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
366
292
|
/**
|
|
367
293
|
* Compares the number of url components after the domain to determine if the cached
|
|
368
294
|
* authority metadata can be used for the requested authority. Protects against same domain different
|
|
369
295
|
* authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
|
|
370
296
|
* @param metadataEntity
|
|
371
297
|
*/
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return cachedParts.length ===
|
|
376
|
-
|
|
298
|
+
isAuthoritySameType(metadataEntity) {
|
|
299
|
+
const cachedAuthorityUrl = new UrlString(metadataEntity.canonical_authority);
|
|
300
|
+
const cachedParts = cachedAuthorityUrl.getUrlComponents().PathSegments;
|
|
301
|
+
return (cachedParts.length ===
|
|
302
|
+
this.canonicalAuthorityUrlComponents.PathSegments.length);
|
|
303
|
+
}
|
|
377
304
|
/**
|
|
378
305
|
* Parse authorityMetadata config option
|
|
379
306
|
*/
|
|
380
|
-
|
|
307
|
+
getEndpointMetadataFromConfig() {
|
|
381
308
|
if (this.authorityOptions.authorityMetadata) {
|
|
382
309
|
try {
|
|
383
310
|
return JSON.parse(this.authorityOptions.authorityMetadata);
|
|
@@ -387,152 +314,142 @@ var Authority = /** @class */ (function () {
|
|
|
387
314
|
}
|
|
388
315
|
}
|
|
389
316
|
return null;
|
|
390
|
-
}
|
|
317
|
+
}
|
|
391
318
|
/**
|
|
392
319
|
* Gets OAuth endpoints from the given OpenID configuration endpoint.
|
|
393
320
|
*
|
|
394
321
|
* @param hasHardcodedMetadata boolean
|
|
395
322
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
323
|
+
async getEndpointMetadataFromNetwork() {
|
|
324
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
325
|
+
const perfEvent = this.performanceClient?.startMeasurement(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
326
|
+
const options = {};
|
|
327
|
+
/*
|
|
328
|
+
* TODO: Add a timeout if the authority exists in our library's
|
|
329
|
+
* hardcoded list of metadata
|
|
330
|
+
*/
|
|
331
|
+
const openIdConfigurationEndpoint = this.defaultOpenIdConfigurationEndpoint;
|
|
332
|
+
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: attempting to retrieve OAuth endpoints from ${openIdConfigurationEndpoint}`);
|
|
333
|
+
try {
|
|
334
|
+
const response = await this.networkInterface.sendGetRequestAsync(openIdConfigurationEndpoint, options);
|
|
335
|
+
const isValidResponse = isOpenIdConfigResponse(response.body);
|
|
336
|
+
if (isValidResponse) {
|
|
337
|
+
perfEvent?.endMeasurement({ success: true });
|
|
338
|
+
return response.body;
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
perfEvent?.endMeasurement({ success: false, errorCode: "invalid_response" });
|
|
342
|
+
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: could not parse response as OpenID configuration`);
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch (e) {
|
|
347
|
+
perfEvent?.endMeasurement({ success: false, errorCode: "request_failure" });
|
|
348
|
+
this.logger.verbose(`Authority.getEndpointMetadataFromNetwork: ${e}`);
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
421
352
|
/**
|
|
422
353
|
* Get OAuth endpoints for common authorities.
|
|
423
354
|
*/
|
|
424
|
-
|
|
355
|
+
getEndpointMetadataFromHardcodedValues() {
|
|
425
356
|
if (this.canonicalAuthority in EndpointMetadata) {
|
|
426
357
|
return EndpointMetadata[this.canonicalAuthority];
|
|
427
358
|
}
|
|
428
359
|
return null;
|
|
429
|
-
}
|
|
360
|
+
}
|
|
430
361
|
/**
|
|
431
362
|
* Update the retrieved metadata with regional information.
|
|
432
363
|
*/
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
return [2 /*return*/, metadata];
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
};
|
|
364
|
+
async updateMetadataWithRegionalInformation(metadata) {
|
|
365
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
366
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
367
|
+
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration?.environmentRegion, this.regionDiscoveryMetadata);
|
|
368
|
+
const azureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion ===
|
|
369
|
+
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
|
|
370
|
+
? autodetectedRegionName
|
|
371
|
+
: this.authorityOptions.azureRegionConfiguration?.azureRegion;
|
|
372
|
+
if (this.authorityOptions.azureRegionConfiguration?.azureRegion ===
|
|
373
|
+
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
374
|
+
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName
|
|
375
|
+
? RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL
|
|
376
|
+
: RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
if (autodetectedRegionName) {
|
|
380
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
381
|
+
this.authorityOptions.azureRegionConfiguration
|
|
382
|
+
?.azureRegion === autodetectedRegionName
|
|
383
|
+
? RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED
|
|
384
|
+
: RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
this.regionDiscoveryMetadata.region_outcome =
|
|
388
|
+
RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (azureRegion) {
|
|
392
|
+
this.regionDiscoveryMetadata.region_used = azureRegion;
|
|
393
|
+
return Authority.replaceWithRegionalInformation(metadata, azureRegion);
|
|
394
|
+
}
|
|
395
|
+
return metadata;
|
|
396
|
+
}
|
|
472
397
|
/**
|
|
473
398
|
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
|
|
474
399
|
* and returns where the information was retrieved from
|
|
475
400
|
* @param metadataEntity
|
|
476
401
|
* @returns AuthorityMetadataSource
|
|
477
402
|
*/
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
525
|
-
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
526
|
-
this.logger.error("Did not find cloud discovery metadata from hardcoded values... Metadata could not be obtained from config, cache, network or hardcoded values. Throwing Untrusted Authority Error.");
|
|
527
|
-
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
};
|
|
403
|
+
async updateCloudDiscoveryMetadata(metadataEntity) {
|
|
404
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
405
|
+
this.logger.verbose("Attempting to get cloud discovery metadata in the config");
|
|
406
|
+
this.logger.verbosePii(`Known Authorities: ${this.authorityOptions.knownAuthorities ||
|
|
407
|
+
Constants.NOT_APPLICABLE}`);
|
|
408
|
+
this.logger.verbosePii(`Authority Metadata: ${this.authorityOptions.authorityMetadata ||
|
|
409
|
+
Constants.NOT_APPLICABLE}`);
|
|
410
|
+
this.logger.verbosePii(`Canonical Authority: ${metadataEntity.canonical_authority || Constants.NOT_APPLICABLE}`);
|
|
411
|
+
let metadata = this.getCloudDiscoveryMetadataFromConfig();
|
|
412
|
+
if (metadata) {
|
|
413
|
+
this.logger.verbose("Found cloud discovery metadata in the config.");
|
|
414
|
+
metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
|
|
415
|
+
return AuthorityMetadataSource.CONFIG;
|
|
416
|
+
}
|
|
417
|
+
// If the cached metadata came from config but that config was not passed to this instance, we must go to the network
|
|
418
|
+
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the cache.");
|
|
419
|
+
const metadataEntityExpired = metadataEntity.isExpired();
|
|
420
|
+
if (this.isAuthoritySameType(metadataEntity) &&
|
|
421
|
+
metadataEntity.aliasesFromNetwork &&
|
|
422
|
+
!metadataEntityExpired) {
|
|
423
|
+
this.logger.verbose("Found metadata in the cache.");
|
|
424
|
+
// No need to update
|
|
425
|
+
return AuthorityMetadataSource.CACHE;
|
|
426
|
+
}
|
|
427
|
+
else if (metadataEntityExpired) {
|
|
428
|
+
this.logger.verbose("The metadata entity is expired.");
|
|
429
|
+
}
|
|
430
|
+
this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
|
|
431
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
432
|
+
metadata = await this.getCloudDiscoveryMetadataFromNetwork();
|
|
433
|
+
if (metadata) {
|
|
434
|
+
this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
|
|
435
|
+
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
436
|
+
return AuthorityMetadataSource.NETWORK;
|
|
437
|
+
}
|
|
438
|
+
this.logger.verbose("Did not find cloud discovery metadata from the network... Attempting to get cloud discovery metadata from hardcoded values.");
|
|
439
|
+
const harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
|
|
440
|
+
if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
|
|
441
|
+
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
|
|
442
|
+
metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
|
|
443
|
+
return AuthorityMetadataSource.HARDCODED_VALUES;
|
|
444
|
+
}
|
|
445
|
+
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
446
|
+
this.logger.error("Did not find cloud discovery metadata from hardcoded values... Metadata could not be obtained from config, cache, network or hardcoded values. Throwing Untrusted Authority Error.");
|
|
447
|
+
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
448
|
+
}
|
|
532
449
|
/**
|
|
533
450
|
* Parse cloudDiscoveryMetadata config or check knownAuthorities
|
|
534
451
|
*/
|
|
535
|
-
|
|
452
|
+
getCloudDiscoveryMetadataFromConfig() {
|
|
536
453
|
// CIAM does not support cloud discovery metadata
|
|
537
454
|
if (this.authorityType === AuthorityType.Ciam) {
|
|
538
455
|
this.logger.verbose("CIAM authorities do not support cloud discovery metadata, generate the aliases from authority host.");
|
|
@@ -543,8 +460,8 @@ var Authority = /** @class */ (function () {
|
|
|
543
460
|
this.logger.verbose("The cloud discovery metadata has been provided as a network response, in the config.");
|
|
544
461
|
try {
|
|
545
462
|
this.logger.verbose("Attempting to parse the cloud discovery metadata.");
|
|
546
|
-
|
|
547
|
-
|
|
463
|
+
const parsedResponse = JSON.parse(this.authorityOptions.cloudDiscoveryMetadata);
|
|
464
|
+
const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(parsedResponse.metadata, this.hostnameAndPort);
|
|
548
465
|
this.logger.verbose("Parsed the cloud discovery metadata.");
|
|
549
466
|
if (metadata) {
|
|
550
467
|
this.logger.verbose("There is returnable metadata attached to the parsed cloud discovery metadata.");
|
|
@@ -565,198 +482,200 @@ var Authority = /** @class */ (function () {
|
|
|
565
482
|
return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
|
|
566
483
|
}
|
|
567
484
|
return null;
|
|
568
|
-
}
|
|
485
|
+
}
|
|
569
486
|
/**
|
|
570
487
|
* Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
|
|
571
488
|
*
|
|
572
489
|
* @param hasHardcodedMetadata boolean
|
|
573
490
|
*/
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
typedResponseBody = response.body;
|
|
601
|
-
if (typedResponseBody.error === Constants.INVALID_INSTANCE) {
|
|
602
|
-
this.logger.error("The CloudInstanceDiscoveryErrorResponse error is invalid_instance.");
|
|
603
|
-
return [2 /*return*/, null];
|
|
604
|
-
}
|
|
605
|
-
this.logger.warning("The CloudInstanceDiscoveryErrorResponse error is " + typedResponseBody.error);
|
|
606
|
-
this.logger.warning("The CloudInstanceDiscoveryErrorResponse error description is " + typedResponseBody.error_description);
|
|
607
|
-
this.logger.warning("Setting the value of the CloudInstanceDiscoveryMetadata (returned from the network) to []");
|
|
608
|
-
metadata = [];
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
this.logger.error("AAD did not return a CloudInstanceDiscoveryResponse or CloudInstanceDiscoveryErrorResponse");
|
|
612
|
-
return [2 /*return*/, null];
|
|
613
|
-
}
|
|
614
|
-
this.logger.verbose("Attempting to find a match between the developer's authority and the CloudInstanceDiscoveryMetadata returned from the network request.");
|
|
615
|
-
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
|
|
616
|
-
return [3 /*break*/, 4];
|
|
617
|
-
case 3:
|
|
618
|
-
error_1 = _b.sent();
|
|
619
|
-
if (error_1 instanceof AuthError) {
|
|
620
|
-
this.logger.error("There was a network error while attempting to get the cloud discovery instance metadata.\nError: " + error_1.errorCode + "\nError Description: " + error_1.errorMessage);
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
typedError = error_1;
|
|
624
|
-
this.logger.error("A non-MSALJS error was thrown while attempting to get the cloud instance discovery metadata.\nError: " + typedError.name + "\nError Description: " + typedError.message);
|
|
625
|
-
}
|
|
626
|
-
return [2 /*return*/, null];
|
|
627
|
-
case 4:
|
|
628
|
-
// Custom Domain scenario, host is trusted because Instance Discovery call succeeded
|
|
629
|
-
if (!match) {
|
|
630
|
-
this.logger.warning("The developer's authority was not found within the CloudInstanceDiscoveryMetadata returned from the network request.");
|
|
631
|
-
this.logger.verbose("Creating custom Authority for custom domain scenario.");
|
|
632
|
-
match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
|
|
633
|
-
}
|
|
634
|
-
return [2 /*return*/, match];
|
|
491
|
+
async getCloudDiscoveryMetadataFromNetwork() {
|
|
492
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
493
|
+
const instanceDiscoveryEndpoint = `${Constants.AAD_INSTANCE_DISCOVERY_ENDPT}${this.canonicalAuthority}oauth2/v2.0/authorize`;
|
|
494
|
+
const options = {};
|
|
495
|
+
/*
|
|
496
|
+
* TODO: Add a timeout if the authority exists in our library's
|
|
497
|
+
* hardcoded list of metadata
|
|
498
|
+
*/
|
|
499
|
+
let match = null;
|
|
500
|
+
try {
|
|
501
|
+
const response = await this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options);
|
|
502
|
+
let typedResponseBody;
|
|
503
|
+
let metadata;
|
|
504
|
+
if (isCloudInstanceDiscoveryResponse(response.body)) {
|
|
505
|
+
typedResponseBody =
|
|
506
|
+
response.body;
|
|
507
|
+
metadata = typedResponseBody.metadata;
|
|
508
|
+
this.logger.verbosePii(`tenant_discovery_endpoint is: ${typedResponseBody.tenant_discovery_endpoint}`);
|
|
509
|
+
}
|
|
510
|
+
else if (isCloudInstanceDiscoveryErrorResponse(response.body)) {
|
|
511
|
+
this.logger.warning(`A CloudInstanceDiscoveryErrorResponse was returned. The cloud instance discovery network request's status code is: ${response.status}`);
|
|
512
|
+
typedResponseBody =
|
|
513
|
+
response.body;
|
|
514
|
+
if (typedResponseBody.error === Constants.INVALID_INSTANCE) {
|
|
515
|
+
this.logger.error("The CloudInstanceDiscoveryErrorResponse error is invalid_instance.");
|
|
516
|
+
return null;
|
|
635
517
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
518
|
+
this.logger.warning(`The CloudInstanceDiscoveryErrorResponse error is ${typedResponseBody.error}`);
|
|
519
|
+
this.logger.warning(`The CloudInstanceDiscoveryErrorResponse error description is ${typedResponseBody.error_description}`);
|
|
520
|
+
this.logger.warning("Setting the value of the CloudInstanceDiscoveryMetadata (returned from the network) to []");
|
|
521
|
+
metadata = [];
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
this.logger.error("AAD did not return a CloudInstanceDiscoveryResponse or CloudInstanceDiscoveryErrorResponse");
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
527
|
+
this.logger.verbose("Attempting to find a match between the developer's authority and the CloudInstanceDiscoveryMetadata returned from the network request.");
|
|
528
|
+
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
if (error instanceof AuthError) {
|
|
532
|
+
this.logger.error(`There was a network error while attempting to get the cloud discovery instance metadata.\nError: ${error.errorCode}\nError Description: ${error.errorMessage}`);
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
const typedError = error;
|
|
536
|
+
this.logger.error(`A non-MSALJS error was thrown while attempting to get the cloud instance discovery metadata.\nError: ${typedError.name}\nError Description: ${typedError.message}`);
|
|
537
|
+
}
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
// Custom Domain scenario, host is trusted because Instance Discovery call succeeded
|
|
541
|
+
if (!match) {
|
|
542
|
+
this.logger.warning("The developer's authority was not found within the CloudInstanceDiscoveryMetadata returned from the network request.");
|
|
543
|
+
this.logger.verbose("Creating custom Authority for custom domain scenario.");
|
|
544
|
+
match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
|
|
545
|
+
}
|
|
546
|
+
return match;
|
|
547
|
+
}
|
|
639
548
|
/**
|
|
640
549
|
* Get cloud discovery metadata for common authorities
|
|
641
550
|
*/
|
|
642
|
-
|
|
551
|
+
getCloudDiscoveryMetadataFromHarcodedValues() {
|
|
643
552
|
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
644
553
|
return InstanceDiscoveryMetadata[this.canonicalAuthority];
|
|
645
554
|
}
|
|
646
555
|
return null;
|
|
647
|
-
}
|
|
556
|
+
}
|
|
648
557
|
/**
|
|
649
558
|
* Helper function to determine if this host is included in the knownAuthorities config option
|
|
650
559
|
*/
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
560
|
+
isInKnownAuthorities() {
|
|
561
|
+
const matches = this.authorityOptions.knownAuthorities.filter((authority) => {
|
|
562
|
+
return (UrlString.getDomainFromUrl(authority).toLowerCase() ===
|
|
563
|
+
this.hostnameAndPort);
|
|
655
564
|
});
|
|
656
565
|
return matches.length > 0;
|
|
657
|
-
}
|
|
566
|
+
}
|
|
658
567
|
/**
|
|
659
568
|
* helper function to populate the authority based on azureCloudOptions
|
|
660
569
|
* @param authorityString
|
|
661
570
|
* @param azureCloudOptions
|
|
662
571
|
*/
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
if (azureCloudOptions &&
|
|
666
|
-
|
|
667
|
-
|
|
572
|
+
static generateAuthority(authorityString, azureCloudOptions) {
|
|
573
|
+
let authorityAzureCloudInstance;
|
|
574
|
+
if (azureCloudOptions &&
|
|
575
|
+
azureCloudOptions.azureCloudInstance !== AzureCloudInstance.None) {
|
|
576
|
+
const tenant = azureCloudOptions.tenant
|
|
577
|
+
? azureCloudOptions.tenant
|
|
578
|
+
: Constants.DEFAULT_COMMON_TENANT;
|
|
579
|
+
authorityAzureCloudInstance = `${azureCloudOptions.azureCloudInstance}/${tenant}/`;
|
|
668
580
|
}
|
|
669
|
-
return authorityAzureCloudInstance
|
|
670
|
-
|
|
581
|
+
return authorityAzureCloudInstance
|
|
582
|
+
? authorityAzureCloudInstance
|
|
583
|
+
: authorityString;
|
|
584
|
+
}
|
|
671
585
|
/**
|
|
672
586
|
* Creates cloud discovery metadata object from a given host
|
|
673
587
|
* @param host
|
|
674
588
|
*/
|
|
675
|
-
|
|
589
|
+
static createCloudDiscoveryMetadataFromHost(host) {
|
|
676
590
|
return {
|
|
677
591
|
preferred_network: host,
|
|
678
592
|
preferred_cache: host,
|
|
679
|
-
aliases: [host]
|
|
593
|
+
aliases: [host],
|
|
680
594
|
};
|
|
681
|
-
}
|
|
595
|
+
}
|
|
682
596
|
/**
|
|
683
597
|
* Searches instance discovery network response for the entry that contains the host in the aliases list
|
|
684
598
|
* @param response
|
|
685
599
|
* @param authority
|
|
686
600
|
*/
|
|
687
|
-
|
|
688
|
-
for (
|
|
689
|
-
|
|
601
|
+
static getCloudDiscoveryMetadataFromNetworkResponse(response, authority) {
|
|
602
|
+
for (let i = 0; i < response.length; i++) {
|
|
603
|
+
const metadata = response[i];
|
|
690
604
|
if (metadata.aliases.indexOf(authority) > -1) {
|
|
691
605
|
return metadata;
|
|
692
606
|
}
|
|
693
607
|
}
|
|
694
608
|
return null;
|
|
695
|
-
}
|
|
609
|
+
}
|
|
696
610
|
/**
|
|
697
611
|
* helper function to generate environment from authority object
|
|
698
612
|
*/
|
|
699
|
-
|
|
613
|
+
getPreferredCache() {
|
|
700
614
|
if (this.discoveryComplete()) {
|
|
701
615
|
return this.metadata.preferred_cache;
|
|
702
616
|
}
|
|
703
617
|
else {
|
|
704
618
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
705
619
|
}
|
|
706
|
-
}
|
|
620
|
+
}
|
|
707
621
|
/**
|
|
708
622
|
* Returns whether or not the provided host is an alias of this authority instance
|
|
709
623
|
* @param host
|
|
710
624
|
*/
|
|
711
|
-
|
|
625
|
+
isAlias(host) {
|
|
712
626
|
return this.metadata.aliases.indexOf(host) > -1;
|
|
713
|
-
}
|
|
627
|
+
}
|
|
714
628
|
/**
|
|
715
629
|
* Checks whether the provided host is that of a public cloud authority
|
|
716
630
|
*
|
|
717
631
|
* @param authority string
|
|
718
632
|
* @returns bool
|
|
719
633
|
*/
|
|
720
|
-
|
|
634
|
+
static isPublicCloudAuthority(host) {
|
|
721
635
|
return Constants.KNOWN_PUBLIC_CLOUDS.indexOf(host) >= 0;
|
|
722
|
-
}
|
|
636
|
+
}
|
|
723
637
|
/**
|
|
724
638
|
* Rebuild the authority string with the region
|
|
725
639
|
*
|
|
726
640
|
* @param host string
|
|
727
641
|
* @param region string
|
|
728
642
|
*/
|
|
729
|
-
|
|
643
|
+
static buildRegionalAuthorityString(host, region, queryString) {
|
|
730
644
|
// Create and validate a Url string object with the initial authority string
|
|
731
|
-
|
|
645
|
+
const authorityUrlInstance = new UrlString(host);
|
|
732
646
|
authorityUrlInstance.validateAsUri();
|
|
733
|
-
|
|
734
|
-
|
|
647
|
+
const authorityUrlParts = authorityUrlInstance.getUrlComponents();
|
|
648
|
+
let hostNameAndPort = `${region}.${authorityUrlParts.HostNameAndPort}`;
|
|
735
649
|
if (this.isPublicCloudAuthority(authorityUrlParts.HostNameAndPort)) {
|
|
736
|
-
hostNameAndPort = region
|
|
650
|
+
hostNameAndPort = `${region}.${Constants.REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX}`;
|
|
737
651
|
}
|
|
738
652
|
// Include the query string portion of the url
|
|
739
|
-
|
|
653
|
+
const url = UrlString.constructAuthorityUriFromObject({
|
|
654
|
+
...authorityUrlInstance.getUrlComponents(),
|
|
655
|
+
HostNameAndPort: hostNameAndPort,
|
|
656
|
+
}).urlString;
|
|
740
657
|
// Add the query string if a query string was provided
|
|
741
658
|
if (queryString)
|
|
742
|
-
return url
|
|
659
|
+
return `${url}?${queryString}`;
|
|
743
660
|
return url;
|
|
744
|
-
}
|
|
661
|
+
}
|
|
745
662
|
/**
|
|
746
663
|
* Replace the endpoints in the metadata object with their regional equivalents.
|
|
747
664
|
*
|
|
748
665
|
* @param metadata OpenIdConfigResponse
|
|
749
666
|
* @param azureRegion string
|
|
750
667
|
*/
|
|
751
|
-
|
|
752
|
-
metadata.authorization_endpoint =
|
|
668
|
+
static replaceWithRegionalInformation(metadata, azureRegion) {
|
|
669
|
+
metadata.authorization_endpoint =
|
|
670
|
+
Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
|
|
753
671
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
754
672
|
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
|
|
755
673
|
if (metadata.end_session_endpoint) {
|
|
756
|
-
metadata.end_session_endpoint =
|
|
674
|
+
metadata.end_session_endpoint =
|
|
675
|
+
Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
|
|
757
676
|
}
|
|
758
677
|
return metadata;
|
|
759
|
-
}
|
|
678
|
+
}
|
|
760
679
|
/**
|
|
761
680
|
* Transform CIAM_AUTHORIY as per the below rules:
|
|
762
681
|
* If no path segments found and it is a CIAM authority (hostname ends with .ciamlogin.com), then transform it
|
|
@@ -766,19 +685,18 @@ var Authority = /** @class */ (function () {
|
|
|
766
685
|
*
|
|
767
686
|
* @param authority
|
|
768
687
|
*/
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
688
|
+
static transformCIAMAuthority(authority) {
|
|
689
|
+
let ciamAuthority = authority.endsWith(Constants.FORWARD_SLASH) ? authority : `${authority}${Constants.FORWARD_SLASH}`;
|
|
690
|
+
const authorityUrl = new UrlString(authority);
|
|
691
|
+
const authorityUrlComponents = authorityUrl.getUrlComponents();
|
|
773
692
|
// check if transformation is needed
|
|
774
693
|
if (authorityUrlComponents.PathSegments.length === 0 && (authorityUrlComponents.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL))) {
|
|
775
|
-
|
|
776
|
-
ciamAuthority =
|
|
694
|
+
const tenantIdOrDomain = authorityUrlComponents.HostNameAndPort.split(".")[0];
|
|
695
|
+
ciamAuthority = `${ciamAuthority}${tenantIdOrDomain}${Constants.AAD_TENANT_DOMAIN_SUFFIX}`;
|
|
777
696
|
}
|
|
778
697
|
return ciamAuthority;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
}());
|
|
698
|
+
}
|
|
699
|
+
}
|
|
782
700
|
|
|
783
701
|
export { Authority };
|
|
784
702
|
//# sourceMappingURL=Authority.js.map
|