@azure/msal-common 14.0.1 → 14.0.3
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/AuthToken.d.ts +14 -17
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.mjs +48 -39
- package/dist/account/AuthToken.mjs.map +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/CcsCredential.mjs.map +1 -1
- package/dist/account/ClientInfo.d.ts.map +1 -1
- package/dist/account/ClientInfo.mjs +3 -4
- package/dist/account/ClientInfo.mjs.map +1 -1
- package/dist/authority/Authority.d.ts +1 -0
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +4 -2
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts +1 -0
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +3 -3
- package/dist/authority/AuthorityFactory.mjs.map +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs.map +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs.map +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/AuthorityType.mjs.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs.map +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs.map +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs.map +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs.map +1 -1
- package/dist/cache/CacheManager.d.ts +2 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +7 -5
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.mjs +4 -7
- package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +1 -0
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +3 -4
- package/dist/cache/entities/AccountEntity.mjs.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.mjs +1 -1
- package/dist/cache/entities/AppMetadataEntity.mjs.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -0
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.mjs +2 -1
- package/dist/cache/entities/AuthorityMetadataEntity.mjs.map +1 -1
- package/dist/cache/entities/CacheRecord.d.ts +1 -0
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -1
- package/dist/cache/entities/CacheRecord.mjs +2 -1
- package/dist/cache/entities/CacheRecord.mjs.map +1 -1
- package/dist/cache/entities/CredentialEntity.mjs +1 -1
- package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
- package/dist/cache/entities/IdTokenEntity.mjs +1 -1
- package/dist/cache/entities/IdTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.mjs +1 -1
- package/dist/cache/entities/RefreshTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.mjs +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.mjs.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.mjs +1 -1
- package/dist/cache/entities/ThrottlingEntity.mjs.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +7 -0
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +1 -0
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +11 -39
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts +2 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +9 -2
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts +1 -0
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +3 -11
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +1 -0
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +8 -7
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +2 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/JoseHeader.d.ts +1 -0
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +2 -1
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +2 -1
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthError.mjs.map +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthError.mjs.map +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs.map +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/error/ServerError.mjs.map +1 -1
- package/dist/index.cjs +1926 -1826
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.mjs +2 -12
- package/dist/logger/Logger.mjs.map +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/INetworkModule.mjs.map +1 -1
- package/dist/network/NetworkManager.d.ts +1 -0
- package/dist/network/NetworkManager.d.ts.map +1 -1
- package/dist/network/NetworkManager.mjs +2 -1
- package/dist/network/NetworkManager.mjs.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts +1 -0
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +2 -1
- package/dist/network/ThrottlingUtils.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/packageMetadata.mjs.map +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +1 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +7 -7
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.mjs +4 -6
- package/dist/request/RequestValidator.mjs.map +1 -1
- package/dist/request/ScopeSet.mjs +4 -4
- package/dist/request/ScopeSet.mjs.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +3 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts +5 -3
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +58 -39
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +2 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +4 -4
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +2 -2
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +9 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +3 -3
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +23 -3
- package/dist/telemetry/performance/StubPerformanceClient.mjs.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +4 -4
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +10 -12
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +10 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +11 -2
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.d.ts +28 -0
- package/dist/utils/FunctionWrappers.d.ts.map +1 -0
- package/dist/utils/FunctionWrappers.mjs +90 -0
- package/dist/utils/FunctionWrappers.mjs.map +1 -0
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +4 -7
- package/dist/utils/ProtocolUtils.mjs.map +1 -1
- package/dist/utils/StringUtils.d.ts +0 -13
- package/dist/utils/StringUtils.d.ts.map +1 -1
- package/dist/utils/StringUtils.mjs +3 -34
- package/dist/utils/StringUtils.mjs.map +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs.map +1 -1
- package/package.json +6 -4
- package/src/account/AccountInfo.ts +44 -0
- package/src/account/AuthToken.ts +70 -0
- package/src/account/CcsCredential.ts +16 -0
- package/src/account/ClientCredentials.ts +20 -0
- package/src/account/ClientInfo.ts +64 -0
- package/src/account/TokenClaims.ts +70 -0
- package/src/authority/Authority.ts +1225 -0
- package/src/authority/AuthorityFactory.ts +106 -0
- package/src/authority/AuthorityMetadata.ts +953 -0
- package/src/authority/AuthorityOptions.ts +40 -0
- package/src/authority/AuthorityType.ts +15 -0
- package/src/authority/AzureRegion.ts +7 -0
- package/src/authority/AzureRegionConfiguration.ts +16 -0
- package/src/authority/CloudDiscoveryMetadata.ts +10 -0
- package/src/authority/CloudInstanceDiscoveryErrorResponse.ts +26 -0
- package/src/authority/CloudInstanceDiscoveryResponse.ts +21 -0
- package/src/authority/ImdsOptions.ts +10 -0
- package/src/authority/OIDCOptions.ts +14 -0
- package/src/authority/OpenIdConfigResponse.ts +24 -0
- package/src/authority/ProtocolMode.ts +13 -0
- package/src/authority/RegionDiscovery.ts +193 -0
- package/src/authority/RegionDiscoveryMetadata.ts +15 -0
- package/src/broker/nativeBroker/INativeBrokerPlugin.ts +29 -0
- package/src/cache/CacheManager.ts +1619 -0
- package/src/cache/entities/AccessTokenEntity.ts +162 -0
- package/src/cache/entities/AccountEntity.ts +309 -0
- package/src/cache/entities/AppMetadataEntity.ts +91 -0
- package/src/cache/entities/AuthorityMetadataEntity.ts +112 -0
- package/src/cache/entities/CacheRecord.ts +33 -0
- package/src/cache/entities/CredentialEntity.ts +215 -0
- package/src/cache/entities/IdTokenEntity.ts +74 -0
- package/src/cache/entities/RefreshTokenEntity.ts +78 -0
- package/src/cache/entities/ServerTelemetryEntity.ts +38 -0
- package/src/cache/entities/ThrottlingEntity.ts +36 -0
- package/src/cache/interface/ICacheManager.ts +218 -0
- package/src/cache/interface/ICachePlugin.ts +11 -0
- package/src/cache/interface/ISerializableTokenCache.ts +9 -0
- package/src/cache/persistence/TokenCacheContext.ts +39 -0
- package/src/cache/utils/CacheTypes.ts +93 -0
- package/src/client/AuthorizationCodeClient.ts +714 -0
- package/src/client/BaseClient.ts +205 -0
- package/src/client/RefreshTokenClient.ts +442 -0
- package/src/client/SilentFlowClient.ts +186 -0
- package/src/config/AppTokenProvider.ts +47 -0
- package/src/config/ClientConfiguration.ts +287 -0
- package/src/crypto/ICrypto.ts +127 -0
- package/src/crypto/IGuidGenerator.ts +9 -0
- package/src/crypto/JoseHeader.ts +55 -0
- package/src/crypto/PopTokenGenerator.ts +155 -0
- package/src/crypto/SignedHttpRequest.ts +16 -0
- package/src/error/AuthError.ts +85 -0
- package/src/error/ClientAuthError.ts +738 -0
- package/src/error/ClientConfigurationError.ts +396 -0
- package/src/error/InteractionRequiredAuthError.ts +134 -0
- package/src/error/JoseHeaderError.ts +52 -0
- package/src/error/ServerError.ts +18 -0
- package/src/index.ts +215 -0
- package/src/logger/Logger.ts +272 -0
- package/src/network/INetworkModule.ts +57 -0
- package/src/network/NetworkManager.ts +76 -0
- package/src/network/RequestThumbprint.ts +22 -0
- package/src/network/ThrottlingUtils.ts +156 -0
- package/src/packageMetadata.ts +3 -0
- package/src/request/AuthenticationHeaderParser.ts +89 -0
- package/src/request/BaseAuthRequest.ts +46 -0
- package/src/request/CommonAuthorizationCodeRequest.ts +33 -0
- package/src/request/CommonAuthorizationUrlRequest.ts +56 -0
- package/src/request/CommonClientCredentialRequest.ts +23 -0
- package/src/request/CommonDeviceCodeRequest.ts +31 -0
- package/src/request/CommonEndSessionRequest.ts +27 -0
- package/src/request/CommonOnBehalfOfRequest.ts +19 -0
- package/src/request/CommonRefreshTokenRequest.ts +25 -0
- package/src/request/CommonSilentFlowRequest.ts +24 -0
- package/src/request/CommonUsernamePasswordRequest.ts +23 -0
- package/src/request/NativeRequest.ts +25 -0
- package/src/request/NativeSignOutRequest.ts +10 -0
- package/src/request/RequestParameterBuilder.ts +606 -0
- package/src/request/RequestValidator.ts +103 -0
- package/src/request/ScopeSet.ts +230 -0
- package/src/request/StoreInCache.ts +16 -0
- package/src/response/AuthenticationResult.ts +47 -0
- package/src/response/AuthorizationCodePayload.ts +18 -0
- package/src/response/DeviceCodeResponse.ts +31 -0
- package/src/response/ExternalTokenResponse.ts +24 -0
- package/src/response/IMDSBadResponse.ts +9 -0
- package/src/response/ResponseHandler.ts +614 -0
- package/src/response/ServerAuthorizationCodeResponse.ts +33 -0
- package/src/response/ServerAuthorizationTokenResponse.ts +54 -0
- package/src/telemetry/performance/IPerformanceClient.ts +71 -0
- package/src/telemetry/performance/IPerformanceMeasurement.ts +10 -0
- package/src/telemetry/performance/PerformanceClient.ts +635 -0
- package/src/telemetry/performance/PerformanceEvent.ts +542 -0
- package/src/telemetry/performance/StubPerformanceClient.ts +101 -0
- package/src/telemetry/server/ServerTelemetryManager.ts +274 -0
- package/src/telemetry/server/ServerTelemetryRequest.ts +13 -0
- package/src/url/IUri.ts +17 -0
- package/src/url/UrlString.ts +363 -0
- package/src/utils/Constants.ts +436 -0
- package/src/utils/FunctionWrappers.ts +105 -0
- package/src/utils/MsalTypes.ts +9 -0
- package/src/utils/ProtocolUtils.ts +124 -0
- package/src/utils/StringUtils.ts +106 -0
- package/src/utils/TimeUtils.ts +51 -0
- package/dist/account/DecodedAuthToken.d.ts +0 -9
- package/dist/account/DecodedAuthToken.d.ts.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ProtocolMode } from "./ProtocolMode";
|
|
7
|
+
import { OIDCOptions } from "./OIDCOptions";
|
|
8
|
+
import { AzureRegionConfiguration } from "./AzureRegionConfiguration";
|
|
9
|
+
|
|
10
|
+
export type AuthorityOptions = {
|
|
11
|
+
protocolMode: ProtocolMode;
|
|
12
|
+
OIDCOptions?: OIDCOptions | null;
|
|
13
|
+
knownAuthorities: Array<string>;
|
|
14
|
+
cloudDiscoveryMetadata: string;
|
|
15
|
+
authorityMetadata: string;
|
|
16
|
+
skipAuthorityMetadataCache?: boolean;
|
|
17
|
+
azureRegionConfiguration?: AzureRegionConfiguration;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const AzureCloudInstance = {
|
|
21
|
+
// AzureCloudInstance is not specified.
|
|
22
|
+
None: "none",
|
|
23
|
+
|
|
24
|
+
// Microsoft Azure public cloud
|
|
25
|
+
AzurePublic: "https://login.microsoftonline.com",
|
|
26
|
+
|
|
27
|
+
// Microsoft PPE
|
|
28
|
+
AzurePpe: "https://login.windows-ppe.net",
|
|
29
|
+
|
|
30
|
+
// Microsoft Chinese national/regional cloud
|
|
31
|
+
AzureChina: "https://login.chinacloudapi.cn",
|
|
32
|
+
|
|
33
|
+
// Microsoft German national/regional cloud ("Black Forest")
|
|
34
|
+
AzureGermany: "https://login.microsoftonline.de",
|
|
35
|
+
|
|
36
|
+
// US Government cloud
|
|
37
|
+
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
38
|
+
} as const;
|
|
39
|
+
export type AzureCloudInstance =
|
|
40
|
+
(typeof AzureCloudInstance)[keyof typeof AzureCloudInstance];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Authority types supported by MSAL.
|
|
8
|
+
*/
|
|
9
|
+
export const AuthorityType = {
|
|
10
|
+
Default: 0,
|
|
11
|
+
Adfs: 1,
|
|
12
|
+
Dsts: 2,
|
|
13
|
+
Ciam: 3,
|
|
14
|
+
} as const;
|
|
15
|
+
export type AuthorityType = (typeof AuthorityType)[keyof typeof AuthorityType];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AzureRegion } from "./AzureRegion";
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* AzureRegionConfiguration
|
|
10
|
+
* - preferredAzureRegion - Preferred azure region from the user
|
|
11
|
+
* - environmentRegionFunc - Environment specific way of fetching the region from the environment
|
|
12
|
+
*/
|
|
13
|
+
export type AzureRegionConfiguration = {
|
|
14
|
+
azureRegion?: AzureRegion;
|
|
15
|
+
environmentRegion: string | undefined;
|
|
16
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The OpenID Configuration Endpoint Response type. Used by the authority class to get relevant OAuth endpoints.
|
|
8
|
+
*/
|
|
9
|
+
export type CloudInstanceDiscoveryErrorResponse = {
|
|
10
|
+
error: String;
|
|
11
|
+
error_description: String;
|
|
12
|
+
error_codes?: Array<Number>;
|
|
13
|
+
timestamp?: String;
|
|
14
|
+
trace_id?: String;
|
|
15
|
+
correlation_id?: String;
|
|
16
|
+
error_uri?: String;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function isCloudInstanceDiscoveryErrorResponse(
|
|
20
|
+
response: object
|
|
21
|
+
): boolean {
|
|
22
|
+
return (
|
|
23
|
+
response.hasOwnProperty("error") &&
|
|
24
|
+
response.hasOwnProperty("error_description")
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CloudDiscoveryMetadata } from "./CloudDiscoveryMetadata";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The OpenID Configuration Endpoint Response type. Used by the authority class to get relevant OAuth endpoints.
|
|
10
|
+
*/
|
|
11
|
+
export type CloudInstanceDiscoveryResponse = {
|
|
12
|
+
tenant_discovery_endpoint: string;
|
|
13
|
+
metadata: Array<CloudDiscoveryMetadata>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function isCloudInstanceDiscoveryResponse(response: object): boolean {
|
|
17
|
+
return (
|
|
18
|
+
response.hasOwnProperty("tenant_discovery_endpoint") &&
|
|
19
|
+
response.hasOwnProperty("metadata")
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ServerResponseType } from "../utils/Constants";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options for the OIDC protocol mode.
|
|
10
|
+
*/
|
|
11
|
+
export type OIDCOptions = {
|
|
12
|
+
serverResponseType?: ServerResponseType;
|
|
13
|
+
defaultScopes?: Array<string>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tenant Discovery Response which contains the relevant OAuth endpoints and data needed for authentication and authorization.
|
|
8
|
+
*/
|
|
9
|
+
export type OpenIdConfigResponse = {
|
|
10
|
+
authorization_endpoint: string;
|
|
11
|
+
token_endpoint: string;
|
|
12
|
+
end_session_endpoint?: string;
|
|
13
|
+
issuer: string;
|
|
14
|
+
jwks_uri: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function isOpenIdConfigResponse(response: object): boolean {
|
|
18
|
+
return (
|
|
19
|
+
response.hasOwnProperty("authorization_endpoint") &&
|
|
20
|
+
response.hasOwnProperty("token_endpoint") &&
|
|
21
|
+
response.hasOwnProperty("issuer") &&
|
|
22
|
+
response.hasOwnProperty("jwks_uri")
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Protocol modes supported by MSAL.
|
|
8
|
+
*/
|
|
9
|
+
export const ProtocolMode = {
|
|
10
|
+
AAD: "AAD",
|
|
11
|
+
OIDC: "OIDC",
|
|
12
|
+
} as const;
|
|
13
|
+
export type ProtocolMode = (typeof ProtocolMode)[keyof typeof ProtocolMode];
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { INetworkModule } from "../network/INetworkModule";
|
|
7
|
+
import { NetworkResponse } from "../network/NetworkManager";
|
|
8
|
+
import { IMDSBadResponse } from "../response/IMDSBadResponse";
|
|
9
|
+
import {
|
|
10
|
+
Constants,
|
|
11
|
+
RegionDiscoverySources,
|
|
12
|
+
ResponseCodes,
|
|
13
|
+
} from "../utils/Constants";
|
|
14
|
+
import { RegionDiscoveryMetadata } from "./RegionDiscoveryMetadata";
|
|
15
|
+
import { ImdsOptions } from "./ImdsOptions";
|
|
16
|
+
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
17
|
+
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
|
|
18
|
+
|
|
19
|
+
export class RegionDiscovery {
|
|
20
|
+
// Network interface to make requests with.
|
|
21
|
+
protected networkInterface: INetworkModule;
|
|
22
|
+
// Performance client
|
|
23
|
+
protected performanceClient: IPerformanceClient | undefined;
|
|
24
|
+
// CorrelationId
|
|
25
|
+
protected correlationId: string | undefined;
|
|
26
|
+
// Options for the IMDS endpoint request
|
|
27
|
+
protected static IMDS_OPTIONS: ImdsOptions = {
|
|
28
|
+
headers: {
|
|
29
|
+
Metadata: "true",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
networkInterface: INetworkModule,
|
|
35
|
+
performanceClient?: IPerformanceClient,
|
|
36
|
+
correlationId?: string
|
|
37
|
+
) {
|
|
38
|
+
this.networkInterface = networkInterface;
|
|
39
|
+
this.performanceClient = performanceClient;
|
|
40
|
+
this.correlationId = correlationId;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Detect the region from the application's environment.
|
|
45
|
+
*
|
|
46
|
+
* @returns Promise<string | null>
|
|
47
|
+
*/
|
|
48
|
+
public async detectRegion(
|
|
49
|
+
environmentRegion: string | undefined,
|
|
50
|
+
regionDiscoveryMetadata: RegionDiscoveryMetadata
|
|
51
|
+
): Promise<string | null> {
|
|
52
|
+
this.performanceClient?.addQueueMeasurement(
|
|
53
|
+
PerformanceEvents.RegionDiscoveryDetectRegion,
|
|
54
|
+
this.correlationId
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Initialize auto detected region with the region from the envrionment
|
|
58
|
+
let autodetectedRegionName = environmentRegion;
|
|
59
|
+
|
|
60
|
+
// Check if a region was detected from the environment, if not, attempt to get the region from IMDS
|
|
61
|
+
if (!autodetectedRegionName) {
|
|
62
|
+
const options = RegionDiscovery.IMDS_OPTIONS;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
this.performanceClient?.setPreQueueTime(
|
|
66
|
+
PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
|
|
67
|
+
this.correlationId
|
|
68
|
+
);
|
|
69
|
+
const localIMDSVersionResponse = await this.getRegionFromIMDS(
|
|
70
|
+
Constants.IMDS_VERSION,
|
|
71
|
+
options
|
|
72
|
+
);
|
|
73
|
+
if (
|
|
74
|
+
localIMDSVersionResponse.status ===
|
|
75
|
+
ResponseCodes.httpSuccess
|
|
76
|
+
) {
|
|
77
|
+
autodetectedRegionName = localIMDSVersionResponse.body;
|
|
78
|
+
regionDiscoveryMetadata.region_source =
|
|
79
|
+
RegionDiscoverySources.IMDS;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// If the response using the local IMDS version failed, try to fetch the current version of IMDS and retry.
|
|
83
|
+
if (
|
|
84
|
+
localIMDSVersionResponse.status ===
|
|
85
|
+
ResponseCodes.httpBadRequest
|
|
86
|
+
) {
|
|
87
|
+
this.performanceClient?.setPreQueueTime(
|
|
88
|
+
PerformanceEvents.RegionDiscoveryGetCurrentVersion,
|
|
89
|
+
this.correlationId
|
|
90
|
+
);
|
|
91
|
+
const currentIMDSVersion = await this.getCurrentVersion(
|
|
92
|
+
options
|
|
93
|
+
);
|
|
94
|
+
if (!currentIMDSVersion) {
|
|
95
|
+
regionDiscoveryMetadata.region_source =
|
|
96
|
+
RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.performanceClient?.setPreQueueTime(
|
|
101
|
+
PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
|
|
102
|
+
this.correlationId
|
|
103
|
+
);
|
|
104
|
+
const currentIMDSVersionResponse =
|
|
105
|
+
await this.getRegionFromIMDS(
|
|
106
|
+
currentIMDSVersion,
|
|
107
|
+
options
|
|
108
|
+
);
|
|
109
|
+
if (
|
|
110
|
+
currentIMDSVersionResponse.status ===
|
|
111
|
+
ResponseCodes.httpSuccess
|
|
112
|
+
) {
|
|
113
|
+
autodetectedRegionName =
|
|
114
|
+
currentIMDSVersionResponse.body;
|
|
115
|
+
regionDiscoveryMetadata.region_source =
|
|
116
|
+
RegionDiscoverySources.IMDS;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} catch (e) {
|
|
120
|
+
regionDiscoveryMetadata.region_source =
|
|
121
|
+
RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
regionDiscoveryMetadata.region_source =
|
|
126
|
+
RegionDiscoverySources.ENVIRONMENT_VARIABLE;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
|
|
130
|
+
if (!autodetectedRegionName) {
|
|
131
|
+
regionDiscoveryMetadata.region_source =
|
|
132
|
+
RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return autodetectedRegionName || null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Make the call to the IMDS endpoint
|
|
140
|
+
*
|
|
141
|
+
* @param imdsEndpointUrl
|
|
142
|
+
* @returns Promise<NetworkResponse<string>>
|
|
143
|
+
*/
|
|
144
|
+
private async getRegionFromIMDS(
|
|
145
|
+
version: string,
|
|
146
|
+
options: ImdsOptions
|
|
147
|
+
): Promise<NetworkResponse<string>> {
|
|
148
|
+
this.performanceClient?.addQueueMeasurement(
|
|
149
|
+
PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
|
|
150
|
+
this.correlationId
|
|
151
|
+
);
|
|
152
|
+
return this.networkInterface.sendGetRequestAsync<string>(
|
|
153
|
+
`${Constants.IMDS_ENDPOINT}?api-version=${version}&format=text`,
|
|
154
|
+
options,
|
|
155
|
+
Constants.IMDS_TIMEOUT
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get the most recent version of the IMDS endpoint available
|
|
161
|
+
*
|
|
162
|
+
* @returns Promise<string | null>
|
|
163
|
+
*/
|
|
164
|
+
private async getCurrentVersion(
|
|
165
|
+
options: ImdsOptions
|
|
166
|
+
): Promise<string | null> {
|
|
167
|
+
this.performanceClient?.addQueueMeasurement(
|
|
168
|
+
PerformanceEvents.RegionDiscoveryGetCurrentVersion,
|
|
169
|
+
this.correlationId
|
|
170
|
+
);
|
|
171
|
+
try {
|
|
172
|
+
const response =
|
|
173
|
+
await this.networkInterface.sendGetRequestAsync<IMDSBadResponse>(
|
|
174
|
+
`${Constants.IMDS_ENDPOINT}?format=json`,
|
|
175
|
+
options
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
|
|
179
|
+
if (
|
|
180
|
+
response.status === ResponseCodes.httpBadRequest &&
|
|
181
|
+
response.body &&
|
|
182
|
+
response.body["newest-versions"] &&
|
|
183
|
+
response.body["newest-versions"].length > 0
|
|
184
|
+
) {
|
|
185
|
+
return response.body["newest-versions"][0];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return null;
|
|
189
|
+
} catch (e) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
RegionDiscoveryOutcomes,
|
|
8
|
+
RegionDiscoverySources,
|
|
9
|
+
} from "../utils/Constants";
|
|
10
|
+
|
|
11
|
+
export type RegionDiscoveryMetadata = {
|
|
12
|
+
region_used?: string;
|
|
13
|
+
region_source?: RegionDiscoverySources;
|
|
14
|
+
region_outcome?: RegionDiscoveryOutcomes;
|
|
15
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AccountInfo } from "../../account/AccountInfo";
|
|
7
|
+
import { LoggerOptions } from "../../config/ClientConfiguration";
|
|
8
|
+
import { NativeRequest } from "../../request/NativeRequest";
|
|
9
|
+
import { NativeSignOutRequest } from "../../request/NativeSignOutRequest";
|
|
10
|
+
import { AuthenticationResult } from "../../response/AuthenticationResult";
|
|
11
|
+
|
|
12
|
+
export interface INativeBrokerPlugin {
|
|
13
|
+
isBrokerAvailable: boolean;
|
|
14
|
+
setLogger(loggerOptions: LoggerOptions): void;
|
|
15
|
+
getAccountById(
|
|
16
|
+
accountId: string,
|
|
17
|
+
correlationId: string
|
|
18
|
+
): Promise<AccountInfo>;
|
|
19
|
+
getAllAccounts(
|
|
20
|
+
clientId: string,
|
|
21
|
+
correlationId: string
|
|
22
|
+
): Promise<AccountInfo[]>;
|
|
23
|
+
acquireTokenSilent(request: NativeRequest): Promise<AuthenticationResult>;
|
|
24
|
+
acquireTokenInteractive(
|
|
25
|
+
request: NativeRequest,
|
|
26
|
+
windowHandle?: Buffer
|
|
27
|
+
): Promise<AuthenticationResult>;
|
|
28
|
+
signOut(request: NativeSignOutRequest): Promise<void>;
|
|
29
|
+
}
|