@azure/msal-common 14.0.3 → 14.1.0-alpha.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/dist/account/AccountInfo.d.ts +32 -32
- package/dist/account/AuthToken.d.ts +17 -17
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.mjs +60 -59
- package/dist/account/AuthToken.mjs.map +1 -1
- package/dist/account/CcsCredential.d.ts +9 -9
- package/dist/account/CcsCredential.mjs +8 -8
- package/dist/account/ClientCredentials.d.ts +14 -14
- package/dist/account/ClientInfo.d.ts +19 -19
- package/dist/account/ClientInfo.d.ts.map +1 -1
- package/dist/account/ClientInfo.mjs +39 -38
- package/dist/account/ClientInfo.mjs.map +1 -1
- package/dist/account/TokenClaims.d.ts +65 -65
- package/dist/authority/Authority.d.ts +235 -235
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +743 -765
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts +31 -31
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +52 -50
- package/dist/authority/AuthorityFactory.mjs.map +1 -1
- package/dist/authority/AuthorityMetadata.d.ts +623 -623
- package/dist/authority/AuthorityMetadata.mjs +884 -884
- package/dist/authority/AuthorityOptions.d.ts +21 -21
- package/dist/authority/AuthorityOptions.mjs +18 -18
- package/dist/authority/AuthorityType.d.ts +10 -10
- package/dist/authority/AuthorityType.mjs +13 -13
- package/dist/authority/AzureRegion.d.ts +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts +5 -5
- package/dist/authority/CloudDiscoveryMetadata.d.ts +5 -5
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts +13 -13
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +8 -8
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +9 -9
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +8 -8
- package/dist/authority/ImdsOptions.d.ts +5 -5
- package/dist/authority/OIDCOptions.d.ts +8 -8
- package/dist/authority/OpenIdConfigResponse.d.ts +11 -11
- package/dist/authority/OpenIdConfigResponse.mjs +10 -10
- package/dist/authority/ProtocolMode.d.ts +8 -8
- package/dist/authority/ProtocolMode.mjs +11 -11
- package/dist/authority/RegionDiscovery.d.ts +32 -30
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.mjs +107 -108
- package/dist/authority/RegionDiscovery.mjs.map +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts +6 -6
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +15 -15
- package/dist/cache/CacheManager.d.ts +446 -446
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +1000 -1024
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +56 -56
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.mjs +111 -110
- package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +101 -101
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +222 -221
- package/dist/cache/entities/AccountEntity.mjs.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.d.ts +39 -39
- package/dist/cache/entities/AppMetadataEntity.mjs +66 -66
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +48 -48
- package/dist/cache/entities/AuthorityMetadataEntity.mjs +78 -78
- package/dist/cache/entities/CacheRecord.d.ts +14 -14
- package/dist/cache/entities/CacheRecord.mjs +14 -14
- package/dist/cache/entities/CredentialEntity.d.ts +88 -88
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.mjs +138 -137
- package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts +34 -34
- package/dist/cache/entities/IdTokenEntity.mjs +56 -56
- package/dist/cache/entities/RefreshTokenEntity.d.ts +36 -36
- package/dist/cache/entities/RefreshTokenEntity.mjs +59 -59
- package/dist/cache/entities/ServerTelemetryEntity.d.ts +12 -12
- package/dist/cache/entities/ServerTelemetryEntity.mjs +27 -27
- package/dist/cache/entities/ThrottlingEntity.d.ts +13 -13
- package/dist/cache/entities/ThrottlingEntity.mjs +23 -23
- package/dist/cache/interface/ICacheManager.d.ts +166 -166
- package/dist/cache/interface/ICachePlugin.d.ts +5 -5
- package/dist/cache/interface/ISerializableTokenCache.d.ts +4 -4
- package/dist/cache/persistence/TokenCacheContext.d.ts +23 -23
- package/dist/cache/persistence/TokenCacheContext.mjs +25 -25
- package/dist/cache/utils/CacheTypes.d.ts +69 -69
- package/dist/client/AuthorizationCodeClient.d.ts +73 -73
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +411 -410
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts +51 -51
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +100 -99
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts +35 -35
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +185 -234
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +26 -25
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +127 -103
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/AppTokenProvider.d.ts +38 -38
- package/dist/config/ClientConfiguration.d.ts +150 -150
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +99 -100
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/crypto/ICrypto.d.ts +62 -62
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.mjs +35 -43
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/IGuidGenerator.d.ts +4 -4
- package/dist/crypto/JoseHeader.d.ts +22 -22
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +39 -38
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +60 -59
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +83 -83
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +11 -11
- package/dist/error/AuthError.d.ts +44 -47
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.mjs +50 -52
- package/dist/error/AuthError.mjs.map +1 -1
- package/dist/error/AuthErrorCodes.d.ts +6 -0
- package/dist/error/AuthErrorCodes.d.ts.map +1 -0
- package/dist/error/AuthErrorCodes.mjs +14 -0
- package/dist/error/AuthErrorCodes.mjs.map +1 -0
- package/dist/error/ClientAuthError.d.ts +232 -412
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.mjs +248 -520
- package/dist/error/ClientAuthError.mjs.map +1 -1
- package/dist/error/ClientAuthErrorCodes.d.ts +44 -0
- package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/ClientAuthErrorCodes.mjs +52 -0
- package/dist/error/ClientAuthErrorCodes.mjs.map +1 -0
- package/dist/error/ClientConfigurationError.d.ts +128 -222
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.mjs +140 -281
- package/dist/error/ClientConfigurationError.mjs.map +1 -1
- package/dist/error/ClientConfigurationErrorCodes.d.ts +23 -0
- package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -0
- package/dist/error/ClientConfigurationErrorCodes.mjs +31 -0
- package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -0
- package/dist/error/InteractionRequiredAuthError.d.ts +57 -59
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +80 -79
- package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +6 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +16 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs.map +1 -0
- package/dist/error/JoseHeaderError.d.ts +15 -28
- package/dist/error/JoseHeaderError.d.ts.map +1 -1
- package/dist/error/JoseHeaderError.mjs +24 -40
- package/dist/error/JoseHeaderError.mjs.map +1 -1
- package/dist/error/JoseHeaderErrorCodes.d.ts +3 -0
- package/dist/error/JoseHeaderErrorCodes.d.ts.map +1 -0
- package/dist/error/JoseHeaderErrorCodes.mjs +11 -0
- package/dist/error/JoseHeaderErrorCodes.mjs.map +1 -0
- package/dist/error/ServerError.d.ts +7 -7
- package/dist/error/ServerError.mjs +14 -14
- package/dist/index.cjs +8715 -9047
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +96 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.d.ts +95 -95
- package/dist/logger/Logger.mjs +188 -188
- package/dist/network/INetworkModule.d.ts +29 -29
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.mjs +14 -15
- package/dist/network/INetworkModule.mjs.map +1 -1
- package/dist/network/NetworkManager.d.ts +33 -33
- package/dist/network/NetworkManager.d.ts.map +1 -1
- package/dist/network/NetworkManager.mjs +36 -35
- package/dist/network/NetworkManager.mjs.map +1 -1
- package/dist/network/RequestThumbprint.d.ts +16 -16
- package/dist/network/ThrottlingUtils.d.ts +42 -42
- package/dist/network/ThrottlingUtils.mjs +95 -95
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.mjs +3 -3
- package/dist/request/AuthenticationHeaderParser.d.ts +19 -19
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs +58 -57
- package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
- package/dist/request/BaseAuthRequest.d.ts +40 -40
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +27 -27
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +50 -50
- package/dist/request/CommonClientCredentialRequest.d.ts +17 -17
- package/dist/request/CommonDeviceCodeRequest.d.ts +21 -21
- package/dist/request/CommonEndSessionRequest.d.ts +21 -21
- package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -13
- package/dist/request/CommonRefreshTokenRequest.d.ts +19 -19
- package/dist/request/CommonSilentFlowRequest.d.ts +18 -18
- package/dist/request/CommonUsernamePasswordRequest.d.ts +17 -17
- package/dist/request/NativeRequest.d.ts +19 -19
- package/dist/request/NativeSignOutRequest.d.ts +5 -5
- package/dist/request/RequestParameterBuilder.d.ts +217 -217
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +383 -382
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.d.ts +33 -33
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.mjs +83 -82
- package/dist/request/RequestValidator.mjs.map +1 -1
- package/dist/request/ScopeSet.d.ts +88 -88
- package/dist/request/ScopeSet.d.ts.map +1 -1
- package/dist/request/ScopeSet.mjs +201 -199
- package/dist/request/ScopeSet.mjs.map +1 -1
- package/dist/request/StoreInCache.d.ts +8 -8
- package/dist/response/AuthenticationResult.d.ts +41 -41
- package/dist/response/AuthorizationCodePayload.d.ts +13 -13
- package/dist/response/DeviceCodeResponse.d.ts +25 -25
- package/dist/response/ExternalTokenResponse.d.ts +15 -15
- package/dist/response/IMDSBadResponse.d.ts +4 -4
- package/dist/response/ResponseHandler.d.ts +67 -67
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +314 -313
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +25 -25
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +46 -46
- package/dist/telemetry/performance/IPerformanceClient.d.ts +51 -51
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +5 -5
- package/dist/telemetry/performance/PerformanceClient.d.ts +191 -191
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +409 -408
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +433 -433
- package/dist/telemetry/performance/PerformanceEvent.mjs +234 -234
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +24 -24
- package/dist/telemetry/performance/StubPerformanceClient.mjs +76 -76
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +66 -66
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +197 -197
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts +8 -8
- package/dist/url/IUri.d.ts +12 -12
- package/dist/url/UrlString.d.ts +83 -83
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +283 -281
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +366 -363
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +376 -368
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.d.ts +27 -27
- package/dist/utils/FunctionWrappers.mjs +85 -85
- package/dist/utils/MsalTypes.d.ts +6 -6
- package/dist/utils/ProtocolUtils.d.ts +42 -42
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +71 -70
- package/dist/utils/ProtocolUtils.mjs.map +1 -1
- package/dist/utils/StringUtils.d.ts +40 -40
- package/dist/utils/StringUtils.mjs +95 -95
- package/dist/utils/TimeUtils.d.ts +27 -27
- package/dist/utils/TimeUtils.mjs +45 -45
- package/package.json +1 -1
- package/src/account/AuthToken.ts +8 -7
- package/src/account/ClientInfo.ts +9 -6
- package/src/authority/Authority.ts +76 -94
- package/src/authority/AuthorityFactory.ts +21 -9
- package/src/authority/RegionDiscovery.ts +21 -18
- package/src/cache/CacheManager.ts +37 -77
- package/src/cache/entities/AccessTokenEntity.ts +7 -2
- package/src/cache/entities/AccountEntity.ts +7 -2
- package/src/cache/entities/CredentialEntity.ts +7 -2
- package/src/client/AuthorizationCodeClient.ts +32 -10
- package/src/client/BaseClient.ts +7 -4
- package/src/client/RefreshTokenClient.ts +81 -124
- package/src/client/SilentFlowClient.ts +72 -19
- package/src/config/ClientConfiguration.ts +6 -7
- package/src/crypto/ICrypto.ts +13 -28
- package/src/crypto/JoseHeader.ts +6 -3
- package/src/crypto/PopTokenGenerator.ts +10 -5
- package/src/error/AuthError.ts +24 -26
- package/src/error/AuthErrorCodes.ts +10 -0
- package/src/error/ClientAuthError.ts +227 -632
- package/src/error/ClientAuthErrorCodes.ts +51 -0
- package/src/error/ClientConfigurationError.ts +146 -332
- package/src/error/ClientConfigurationErrorCodes.ts +28 -0
- package/src/error/InteractionRequiredAuthError.ts +60 -55
- package/src/error/InteractionRequiredAuthErrorCodes.ts +13 -0
- package/src/error/JoseHeaderError.ts +11 -31
- package/src/error/JoseHeaderErrorCodes.ts +7 -0
- package/src/index.ts +12 -1
- package/src/network/INetworkModule.ts +10 -7
- package/src/network/NetworkManager.ts +5 -5
- package/src/request/AuthenticationHeaderParser.ts +11 -8
- package/src/request/RequestParameterBuilder.ts +10 -3
- package/src/request/RequestValidator.ts +19 -6
- package/src/request/ScopeSet.ts +23 -7
- package/src/response/ResponseHandler.ts +37 -17
- package/src/telemetry/performance/PerformanceClient.ts +2 -1
- package/src/telemetry/server/ServerTelemetryManager.ts +1 -1
- package/src/url/UrlString.ts +26 -16
- package/src/utils/Constants.ts +11 -3
- package/src/utils/ProtocolUtils.ts +8 -12
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
} from "./OpenIdConfigResponse";
|
|
11
11
|
import { UrlString } from "../url/UrlString";
|
|
12
12
|
import { IUri } from "../url/IUri";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
createClientAuthError,
|
|
15
|
+
ClientAuthErrorCodes,
|
|
16
|
+
} from "../error/ClientAuthError";
|
|
14
17
|
import { INetworkModule } from "../network/INetworkModule";
|
|
15
18
|
import {
|
|
16
19
|
AADAuthorityConstants,
|
|
@@ -23,7 +26,10 @@ import {
|
|
|
23
26
|
InstanceDiscoveryMetadata,
|
|
24
27
|
InstanceDiscoveryMetadataAliases,
|
|
25
28
|
} from "./AuthorityMetadata";
|
|
26
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
createClientConfigurationError,
|
|
31
|
+
ClientConfigurationErrorCodes,
|
|
32
|
+
} from "../error/ClientConfigurationError";
|
|
27
33
|
import { ProtocolMode } from "./ProtocolMode";
|
|
28
34
|
import { ICacheManager } from "../cache/interface/ICacheManager";
|
|
29
35
|
import { AuthorityMetadataEntity } from "../cache/entities/AuthorityMetadataEntity";
|
|
@@ -45,6 +51,7 @@ import { Logger } from "../logger/Logger";
|
|
|
45
51
|
import { AuthError } from "../error/AuthError";
|
|
46
52
|
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
47
53
|
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
54
|
+
import { invokeAsync } from "../utils/FunctionWrappers";
|
|
48
55
|
|
|
49
56
|
/**
|
|
50
57
|
* The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
|
|
@@ -107,6 +114,7 @@ export class Authority {
|
|
|
107
114
|
this.correlationId = correlationId;
|
|
108
115
|
this.regionDiscovery = new RegionDiscovery(
|
|
109
116
|
networkInterface,
|
|
117
|
+
this.logger,
|
|
110
118
|
this.performanceClient,
|
|
111
119
|
this.correlationId
|
|
112
120
|
);
|
|
@@ -205,8 +213,8 @@ export class Authority {
|
|
|
205
213
|
if (this.discoveryComplete()) {
|
|
206
214
|
return this.replacePath(this.metadata.authorization_endpoint);
|
|
207
215
|
} else {
|
|
208
|
-
throw
|
|
209
|
-
|
|
216
|
+
throw createClientAuthError(
|
|
217
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
210
218
|
);
|
|
211
219
|
}
|
|
212
220
|
}
|
|
@@ -218,8 +226,8 @@ export class Authority {
|
|
|
218
226
|
if (this.discoveryComplete()) {
|
|
219
227
|
return this.replacePath(this.metadata.token_endpoint);
|
|
220
228
|
} else {
|
|
221
|
-
throw
|
|
222
|
-
|
|
229
|
+
throw createClientAuthError(
|
|
230
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
223
231
|
);
|
|
224
232
|
}
|
|
225
233
|
}
|
|
@@ -230,8 +238,8 @@ export class Authority {
|
|
|
230
238
|
this.metadata.token_endpoint.replace("/token", "/devicecode")
|
|
231
239
|
);
|
|
232
240
|
} else {
|
|
233
|
-
throw
|
|
234
|
-
|
|
241
|
+
throw createClientAuthError(
|
|
242
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
235
243
|
);
|
|
236
244
|
}
|
|
237
245
|
}
|
|
@@ -243,12 +251,14 @@ export class Authority {
|
|
|
243
251
|
if (this.discoveryComplete()) {
|
|
244
252
|
// ROPC policies may not have end_session_endpoint set
|
|
245
253
|
if (!this.metadata.end_session_endpoint) {
|
|
246
|
-
throw
|
|
254
|
+
throw createClientAuthError(
|
|
255
|
+
ClientAuthErrorCodes.endSessionEndpointNotSupported
|
|
256
|
+
);
|
|
247
257
|
}
|
|
248
258
|
return this.replacePath(this.metadata.end_session_endpoint);
|
|
249
259
|
} else {
|
|
250
|
-
throw
|
|
251
|
-
|
|
260
|
+
throw createClientAuthError(
|
|
261
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
252
262
|
);
|
|
253
263
|
}
|
|
254
264
|
}
|
|
@@ -260,8 +270,8 @@ export class Authority {
|
|
|
260
270
|
if (this.discoveryComplete()) {
|
|
261
271
|
return this.replacePath(this.metadata.issuer);
|
|
262
272
|
} else {
|
|
263
|
-
throw
|
|
264
|
-
|
|
273
|
+
throw createClientAuthError(
|
|
274
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
265
275
|
);
|
|
266
276
|
}
|
|
267
277
|
}
|
|
@@ -273,8 +283,8 @@ export class Authority {
|
|
|
273
283
|
if (this.discoveryComplete()) {
|
|
274
284
|
return this.replacePath(this.metadata.jwks_uri);
|
|
275
285
|
} else {
|
|
276
|
-
throw
|
|
277
|
-
|
|
286
|
+
throw createClientAuthError(
|
|
287
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
278
288
|
);
|
|
279
289
|
}
|
|
280
290
|
}
|
|
@@ -356,6 +366,7 @@ export class Authority {
|
|
|
356
366
|
protected get defaultOpenIdConfigurationEndpoint(): string {
|
|
357
367
|
const canonicalAuthorityHost = this.hostnameAndPort;
|
|
358
368
|
if (
|
|
369
|
+
this.canonicalAuthority.endsWith("v2.0/") ||
|
|
359
370
|
this.authorityType === AuthorityType.Adfs ||
|
|
360
371
|
(this.protocolMode !== ProtocolMode.AAD &&
|
|
361
372
|
!this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost))
|
|
@@ -391,24 +402,24 @@ export class Authority {
|
|
|
391
402
|
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
392
403
|
}
|
|
393
404
|
|
|
394
|
-
|
|
405
|
+
const cloudDiscoverySource = await invokeAsync(
|
|
406
|
+
this.updateCloudDiscoveryMetadata.bind(this),
|
|
395
407
|
PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata,
|
|
408
|
+
this.logger,
|
|
409
|
+
this.performanceClient,
|
|
396
410
|
this.correlationId
|
|
397
|
-
);
|
|
398
|
-
const cloudDiscoverySource = await this.updateCloudDiscoveryMetadata(
|
|
399
|
-
metadataEntity
|
|
400
|
-
);
|
|
411
|
+
)(metadataEntity);
|
|
401
412
|
this.canonicalAuthority = this.canonicalAuthority.replace(
|
|
402
413
|
this.hostnameAndPort,
|
|
403
414
|
metadataEntity.preferred_network
|
|
404
415
|
);
|
|
405
|
-
|
|
416
|
+
const endpointSource = await invokeAsync(
|
|
417
|
+
this.updateEndpointMetadata.bind(this),
|
|
406
418
|
PerformanceEvents.AuthorityUpdateEndpointMetadata,
|
|
419
|
+
this.logger,
|
|
420
|
+
this.performanceClient,
|
|
407
421
|
this.correlationId
|
|
408
|
-
);
|
|
409
|
-
const endpointSource = await this.updateEndpointMetadata(
|
|
410
|
-
metadataEntity
|
|
411
|
-
);
|
|
422
|
+
)(metadataEntity);
|
|
412
423
|
|
|
413
424
|
if (
|
|
414
425
|
cloudDiscoverySource !== AuthorityMetadataSource.CACHE &&
|
|
@@ -469,17 +480,13 @@ export class Authority {
|
|
|
469
480
|
if (
|
|
470
481
|
this.authorityOptions.azureRegionConfiguration?.azureRegion
|
|
471
482
|
) {
|
|
472
|
-
|
|
483
|
+
hardcodedMetadata = await invokeAsync(
|
|
484
|
+
this.updateMetadataWithRegionalInformation.bind(this),
|
|
473
485
|
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
486
|
+
this.logger,
|
|
487
|
+
this.performanceClient,
|
|
474
488
|
this.correlationId
|
|
475
|
-
);
|
|
476
|
-
this.logger.verbose(
|
|
477
|
-
"Found azure region configuration. Updating endpoints with regional information."
|
|
478
|
-
);
|
|
479
|
-
hardcodedMetadata =
|
|
480
|
-
await this.updateMetadataWithRegionalInformation(
|
|
481
|
-
hardcodedMetadata
|
|
482
|
-
);
|
|
489
|
+
)(hardcodedMetadata);
|
|
483
490
|
}
|
|
484
491
|
|
|
485
492
|
metadataEntity.updateEndpointMetadata(hardcodedMetadata, false);
|
|
@@ -505,41 +512,31 @@ export class Authority {
|
|
|
505
512
|
this.logger.verbose("The metadata entity is expired.");
|
|
506
513
|
}
|
|
507
514
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
this.performanceClient?.setPreQueueTime(
|
|
515
|
+
metadata = await invokeAsync(
|
|
516
|
+
this.getEndpointMetadataFromNetwork.bind(this),
|
|
513
517
|
PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork,
|
|
518
|
+
this.logger,
|
|
519
|
+
this.performanceClient,
|
|
514
520
|
this.correlationId
|
|
515
|
-
);
|
|
516
|
-
metadata = await this.getEndpointMetadataFromNetwork();
|
|
521
|
+
)();
|
|
517
522
|
if (metadata) {
|
|
518
|
-
this.logger.verbose(
|
|
519
|
-
"Endpoint metadata was successfully returned from getEndpointMetadataFromNetwork()"
|
|
520
|
-
);
|
|
521
523
|
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
522
524
|
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
523
|
-
|
|
525
|
+
metadata = await invokeAsync(
|
|
526
|
+
this.updateMetadataWithRegionalInformation.bind(this),
|
|
524
527
|
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
528
|
+
this.logger,
|
|
529
|
+
this.performanceClient,
|
|
525
530
|
this.correlationId
|
|
526
|
-
);
|
|
527
|
-
this.logger.verbose(
|
|
528
|
-
"Found azure region configuration. Updating endpoints with regional information."
|
|
529
|
-
);
|
|
530
|
-
metadata = await this.updateMetadataWithRegionalInformation(
|
|
531
|
-
metadata
|
|
532
|
-
);
|
|
531
|
+
)(metadata);
|
|
533
532
|
}
|
|
534
533
|
|
|
535
534
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
536
535
|
return AuthorityMetadataSource.NETWORK;
|
|
537
536
|
} else {
|
|
538
537
|
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
);
|
|
542
|
-
throw ClientAuthError.createUnableToGetOpenidConfigError(
|
|
538
|
+
throw createClientAuthError(
|
|
539
|
+
ClientAuthErrorCodes.openIdConfigError,
|
|
543
540
|
this.defaultOpenIdConfigurationEndpoint
|
|
544
541
|
);
|
|
545
542
|
}
|
|
@@ -575,7 +572,9 @@ export class Authority {
|
|
|
575
572
|
this.authorityOptions.authorityMetadata
|
|
576
573
|
) as OpenIdConfigResponse;
|
|
577
574
|
} catch (e) {
|
|
578
|
-
throw
|
|
575
|
+
throw createClientConfigurationError(
|
|
576
|
+
ClientConfigurationErrorCodes.invalidAuthorityMetadata
|
|
577
|
+
);
|
|
579
578
|
}
|
|
580
579
|
}
|
|
581
580
|
|
|
@@ -593,10 +592,6 @@ export class Authority {
|
|
|
593
592
|
this.correlationId
|
|
594
593
|
);
|
|
595
594
|
|
|
596
|
-
const perfEvent = this.performanceClient?.startMeasurement(
|
|
597
|
-
PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork,
|
|
598
|
-
this.correlationId
|
|
599
|
-
);
|
|
600
595
|
const options: ImdsOptions = {};
|
|
601
596
|
|
|
602
597
|
/*
|
|
@@ -618,23 +613,14 @@ export class Authority {
|
|
|
618
613
|
);
|
|
619
614
|
const isValidResponse = isOpenIdConfigResponse(response.body);
|
|
620
615
|
if (isValidResponse) {
|
|
621
|
-
perfEvent?.end({ success: true });
|
|
622
616
|
return response.body;
|
|
623
617
|
} else {
|
|
624
|
-
perfEvent?.end({
|
|
625
|
-
success: false,
|
|
626
|
-
errorCode: "invalid_response",
|
|
627
|
-
});
|
|
628
618
|
this.logger.verbose(
|
|
629
619
|
`Authority.getEndpointMetadataFromNetwork: could not parse response as OpenID configuration`
|
|
630
620
|
);
|
|
631
621
|
return null;
|
|
632
622
|
}
|
|
633
623
|
} catch (e) {
|
|
634
|
-
perfEvent?.end({
|
|
635
|
-
success: false,
|
|
636
|
-
errorCode: "request_failure",
|
|
637
|
-
});
|
|
638
624
|
this.logger.verbose(
|
|
639
625
|
`Authority.getEndpointMetadataFromNetwork: ${e}`
|
|
640
626
|
);
|
|
@@ -683,18 +669,18 @@ export class Authority {
|
|
|
683
669
|
);
|
|
684
670
|
}
|
|
685
671
|
|
|
686
|
-
|
|
672
|
+
const autodetectedRegionName = await invokeAsync(
|
|
673
|
+
this.regionDiscovery.detectRegion.bind(this.regionDiscovery),
|
|
687
674
|
PerformanceEvents.RegionDiscoveryDetectRegion,
|
|
675
|
+
this.logger,
|
|
676
|
+
this.performanceClient,
|
|
688
677
|
this.correlationId
|
|
678
|
+
)(
|
|
679
|
+
this.authorityOptions.azureRegionConfiguration
|
|
680
|
+
?.environmentRegion,
|
|
681
|
+
this.regionDiscoveryMetadata
|
|
689
682
|
);
|
|
690
683
|
|
|
691
|
-
const autodetectedRegionName =
|
|
692
|
-
await this.regionDiscovery.detectRegion(
|
|
693
|
-
this.authorityOptions.azureRegionConfiguration
|
|
694
|
-
?.environmentRegion,
|
|
695
|
-
this.regionDiscoveryMetadata
|
|
696
|
-
);
|
|
697
|
-
|
|
698
684
|
if (autodetectedRegionName) {
|
|
699
685
|
this.regionDiscoveryMetadata.region_outcome =
|
|
700
686
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
|
|
@@ -796,29 +782,23 @@ export class Authority {
|
|
|
796
782
|
this.logger.verbose("The metadata entity is expired.");
|
|
797
783
|
}
|
|
798
784
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
);
|
|
802
|
-
|
|
803
|
-
this.performanceClient?.setPreQueueTime(
|
|
785
|
+
metadata = await invokeAsync(
|
|
786
|
+
this.getCloudDiscoveryMetadataFromNetwork.bind(this),
|
|
804
787
|
PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork,
|
|
788
|
+
this.logger,
|
|
789
|
+
this.performanceClient,
|
|
805
790
|
this.correlationId
|
|
806
|
-
);
|
|
807
|
-
metadata = await this.getCloudDiscoveryMetadataFromNetwork();
|
|
791
|
+
)();
|
|
808
792
|
|
|
809
793
|
if (metadata) {
|
|
810
|
-
this.logger.verbose(
|
|
811
|
-
"cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()"
|
|
812
|
-
);
|
|
813
794
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
814
795
|
return AuthorityMetadataSource.NETWORK;
|
|
815
796
|
}
|
|
816
797
|
|
|
817
798
|
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
818
|
-
|
|
819
|
-
|
|
799
|
+
throw createClientConfigurationError(
|
|
800
|
+
ClientConfigurationErrorCodes.untrustedAuthority
|
|
820
801
|
);
|
|
821
|
-
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
822
802
|
}
|
|
823
803
|
|
|
824
804
|
/**
|
|
@@ -867,7 +847,9 @@ export class Authority {
|
|
|
867
847
|
this.logger.verbose(
|
|
868
848
|
"Unable to parse the cloud discovery metadata. Throwing Invalid Cloud Discovery Metadata Error."
|
|
869
849
|
);
|
|
870
|
-
throw
|
|
850
|
+
throw createClientConfigurationError(
|
|
851
|
+
ClientConfigurationErrorCodes.invalidCloudDiscoveryMetadata
|
|
852
|
+
);
|
|
871
853
|
}
|
|
872
854
|
}
|
|
873
855
|
|
|
@@ -1090,8 +1072,8 @@ export class Authority {
|
|
|
1090
1072
|
if (this.discoveryComplete()) {
|
|
1091
1073
|
return this.metadata.preferred_cache;
|
|
1092
1074
|
} else {
|
|
1093
|
-
throw
|
|
1094
|
-
|
|
1075
|
+
throw createClientAuthError(
|
|
1076
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
1095
1077
|
);
|
|
1096
1078
|
}
|
|
1097
1079
|
}
|
|
@@ -4,14 +4,21 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Authority } from "./Authority";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createClientConfigurationError,
|
|
9
|
+
ClientConfigurationErrorCodes,
|
|
10
|
+
} from "../error/ClientConfigurationError";
|
|
8
11
|
import { INetworkModule } from "../network/INetworkModule";
|
|
9
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createClientAuthError,
|
|
14
|
+
ClientAuthErrorCodes,
|
|
15
|
+
} from "../error/ClientAuthError";
|
|
10
16
|
import { ICacheManager } from "../cache/interface/ICacheManager";
|
|
11
17
|
import { AuthorityOptions } from "./AuthorityOptions";
|
|
12
18
|
import { Logger } from "../logger/Logger";
|
|
13
19
|
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
14
20
|
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
21
|
+
import { invokeAsync } from "../utils/FunctionWrappers";
|
|
15
22
|
|
|
16
23
|
/** @internal */
|
|
17
24
|
export class AuthorityFactory {
|
|
@@ -55,16 +62,19 @@ export class AuthorityFactory {
|
|
|
55
62
|
);
|
|
56
63
|
|
|
57
64
|
try {
|
|
58
|
-
|
|
65
|
+
await invokeAsync(
|
|
66
|
+
acquireTokenAuthority.resolveEndpointsAsync.bind(
|
|
67
|
+
acquireTokenAuthority
|
|
68
|
+
),
|
|
59
69
|
PerformanceEvents.AuthorityResolveEndpointsAsync,
|
|
70
|
+
logger,
|
|
71
|
+
performanceClient,
|
|
60
72
|
correlationId
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
await acquireTokenAuthority.resolveEndpointsAsync();
|
|
73
|
+
)();
|
|
64
74
|
return acquireTokenAuthority;
|
|
65
75
|
} catch (e) {
|
|
66
|
-
throw
|
|
67
|
-
|
|
76
|
+
throw createClientAuthError(
|
|
77
|
+
ClientAuthErrorCodes.endpointResolutionError
|
|
68
78
|
);
|
|
69
79
|
}
|
|
70
80
|
}
|
|
@@ -90,7 +100,9 @@ export class AuthorityFactory {
|
|
|
90
100
|
): Authority {
|
|
91
101
|
// Throw error if authority url is empty
|
|
92
102
|
if (!authorityUrl) {
|
|
93
|
-
throw
|
|
103
|
+
throw createClientConfigurationError(
|
|
104
|
+
ClientConfigurationErrorCodes.urlEmptyError
|
|
105
|
+
);
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
return new Authority(
|
|
@@ -15,10 +15,14 @@ import { RegionDiscoveryMetadata } from "./RegionDiscoveryMetadata";
|
|
|
15
15
|
import { ImdsOptions } from "./ImdsOptions";
|
|
16
16
|
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
17
17
|
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
18
|
+
import { invokeAsync } from "../utils/FunctionWrappers";
|
|
19
|
+
import { Logger } from "../logger/Logger";
|
|
18
20
|
|
|
19
21
|
export class RegionDiscovery {
|
|
20
22
|
// Network interface to make requests with.
|
|
21
23
|
protected networkInterface: INetworkModule;
|
|
24
|
+
// Logger
|
|
25
|
+
private logger: Logger;
|
|
22
26
|
// Performance client
|
|
23
27
|
protected performanceClient: IPerformanceClient | undefined;
|
|
24
28
|
// CorrelationId
|
|
@@ -32,10 +36,12 @@ export class RegionDiscovery {
|
|
|
32
36
|
|
|
33
37
|
constructor(
|
|
34
38
|
networkInterface: INetworkModule,
|
|
39
|
+
logger: Logger,
|
|
35
40
|
performanceClient?: IPerformanceClient,
|
|
36
41
|
correlationId?: string
|
|
37
42
|
) {
|
|
38
43
|
this.networkInterface = networkInterface;
|
|
44
|
+
this.logger = logger;
|
|
39
45
|
this.performanceClient = performanceClient;
|
|
40
46
|
this.correlationId = correlationId;
|
|
41
47
|
}
|
|
@@ -62,14 +68,13 @@ export class RegionDiscovery {
|
|
|
62
68
|
const options = RegionDiscovery.IMDS_OPTIONS;
|
|
63
69
|
|
|
64
70
|
try {
|
|
65
|
-
|
|
71
|
+
const localIMDSVersionResponse = await invokeAsync(
|
|
72
|
+
this.getRegionFromIMDS.bind(this),
|
|
66
73
|
PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
|
|
74
|
+
this.logger,
|
|
75
|
+
this.performanceClient,
|
|
67
76
|
this.correlationId
|
|
68
|
-
);
|
|
69
|
-
const localIMDSVersionResponse = await this.getRegionFromIMDS(
|
|
70
|
-
Constants.IMDS_VERSION,
|
|
71
|
-
options
|
|
72
|
-
);
|
|
77
|
+
)(Constants.IMDS_VERSION, options);
|
|
73
78
|
if (
|
|
74
79
|
localIMDSVersionResponse.status ===
|
|
75
80
|
ResponseCodes.httpSuccess
|
|
@@ -84,28 +89,26 @@ export class RegionDiscovery {
|
|
|
84
89
|
localIMDSVersionResponse.status ===
|
|
85
90
|
ResponseCodes.httpBadRequest
|
|
86
91
|
) {
|
|
87
|
-
|
|
92
|
+
const currentIMDSVersion = await invokeAsync(
|
|
93
|
+
this.getCurrentVersion.bind(this),
|
|
88
94
|
PerformanceEvents.RegionDiscoveryGetCurrentVersion,
|
|
95
|
+
this.logger,
|
|
96
|
+
this.performanceClient,
|
|
89
97
|
this.correlationId
|
|
90
|
-
);
|
|
91
|
-
const currentIMDSVersion = await this.getCurrentVersion(
|
|
92
|
-
options
|
|
93
|
-
);
|
|
98
|
+
)(options);
|
|
94
99
|
if (!currentIMDSVersion) {
|
|
95
100
|
regionDiscoveryMetadata.region_source =
|
|
96
101
|
RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
97
102
|
return null;
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
|
|
105
|
+
const currentIMDSVersionResponse = await invokeAsync(
|
|
106
|
+
this.getRegionFromIMDS.bind(this),
|
|
101
107
|
PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
|
|
108
|
+
this.logger,
|
|
109
|
+
this.performanceClient,
|
|
102
110
|
this.correlationId
|
|
103
|
-
);
|
|
104
|
-
const currentIMDSVersionResponse =
|
|
105
|
-
await this.getRegionFromIMDS(
|
|
106
|
-
currentIMDSVersion,
|
|
107
|
-
options
|
|
108
|
-
);
|
|
111
|
+
)(currentIMDSVersion, options);
|
|
109
112
|
if (
|
|
110
113
|
currentIMDSVersionResponse.status ===
|
|
111
114
|
ResponseCodes.httpSuccess
|