@azure/msal-common 14.1.0-alpha.0 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AccountInfo.d.ts +31 -32
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.d.ts +17 -17
- package/dist/account/AuthToken.mjs +58 -58
- 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.mjs +37 -37
- package/dist/account/TokenClaims.d.ts +65 -65
- package/dist/authority/Authority.d.ts +249 -235
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +791 -740
- 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 +48 -48
- package/dist/authority/AuthorityMetadata.d.ts +646 -623
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
- package/dist/authority/AuthorityMetadata.mjs +941 -885
- package/dist/authority/AuthorityMetadata.mjs.map +1 -1
- package/dist/authority/AuthorityOptions.d.ts +27 -21
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.mjs +18 -18
- package/dist/authority/AuthorityOptions.mjs.map +1 -1
- 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 -32
- package/dist/authority/RegionDiscovery.mjs +106 -106
- package/dist/authority/RegionDiscoveryMetadata.d.ts +6 -6
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +15 -15
- package/dist/cache/CacheManager.d.ts +480 -446
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +1086 -998
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +56 -56
- package/dist/cache/entities/AccessTokenEntity.mjs +109 -109
- 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 +218 -220
- 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.mjs +136 -136
- 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 +67 -69
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +73 -73
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +408 -407
- 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 +188 -180
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +27 -26
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +118 -125
- 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.mjs +97 -97
- package/dist/crypto/ICrypto.d.ts +58 -62
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.mjs +30 -33
- 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.mjs +37 -37
- package/dist/crypto/PopTokenGenerator.d.ts +60 -60
- package/dist/crypto/PopTokenGenerator.mjs +82 -82
- package/dist/crypto/SignedHttpRequest.d.ts +11 -11
- package/dist/error/AuthError.d.ts +44 -44
- package/dist/error/AuthError.mjs +46 -46
- package/dist/error/AuthErrorCodes.d.ts +5 -5
- package/dist/error/AuthErrorCodes.mjs +9 -9
- package/dist/error/ClientAuthError.d.ts +237 -232
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.mjs +250 -245
- package/dist/error/ClientAuthError.mjs.map +1 -1
- package/dist/error/ClientAuthErrorCodes.d.ts +44 -43
- package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +49 -48
- package/dist/error/ClientAuthErrorCodes.mjs.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts +128 -128
- package/dist/error/ClientConfigurationError.mjs +135 -135
- package/dist/error/ClientConfigurationErrorCodes.d.ts +22 -22
- package/dist/error/ClientConfigurationErrorCodes.mjs +26 -26
- package/dist/error/InteractionRequiredAuthError.d.ts +57 -57
- package/dist/error/InteractionRequiredAuthError.mjs +76 -76
- package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +5 -5
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +11 -11
- package/dist/error/JoseHeaderError.d.ts +15 -15
- package/dist/error/JoseHeaderError.mjs +22 -22
- package/dist/error/JoseHeaderErrorCodes.d.ts +2 -2
- package/dist/error/JoseHeaderErrorCodes.mjs +6 -6
- package/dist/error/ServerError.d.ts +7 -7
- package/dist/error/ServerError.mjs +14 -14
- package/dist/index.cjs +8830 -8612
- 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 +2 -2
- 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.mjs +12 -12
- package/dist/network/NetworkManager.d.ts +33 -33
- package/dist/network/NetworkManager.mjs +34 -34
- 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 +4 -4
- package/dist/request/AuthenticationHeaderParser.d.ts +19 -19
- package/dist/request/AuthenticationHeaderParser.mjs +55 -55
- 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 +22 -19
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +20 -18
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- 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.mjs +381 -381
- package/dist/request/RequestValidator.d.ts +33 -33
- package/dist/request/RequestValidator.mjs +81 -81
- package/dist/request/ScopeSet.d.ts +88 -88
- package/dist/request/ScopeSet.mjs +197 -197
- 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 +315 -311
- 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.mjs +409 -409
- package/dist/telemetry/performance/PerformanceEvent.d.ts +457 -433
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +249 -234
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- 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.mjs +197 -197
- 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.mjs +279 -279
- package/dist/utils/Constants.d.ts +366 -366
- package/dist/utils/Constants.mjs +376 -376
- package/dist/utils/FunctionWrappers.d.ts +27 -27
- package/dist/utils/FunctionWrappers.d.ts.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +84 -85
- package/dist/utils/FunctionWrappers.mjs.map +1 -1
- package/dist/utils/MsalTypes.d.ts +6 -6
- package/dist/utils/ProtocolUtils.d.ts +42 -42
- package/dist/utils/ProtocolUtils.mjs +69 -69
- 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/AccountInfo.ts +0 -1
- package/src/authority/Authority.ts +207 -127
- package/src/authority/AuthorityFactory.ts +4 -4
- package/src/authority/AuthorityMetadata.ts +87 -0
- package/src/authority/AuthorityOptions.ts +9 -0
- package/src/cache/CacheManager.ts +187 -46
- package/src/cache/entities/AccountEntity.ts +0 -3
- package/src/cache/utils/CacheTypes.ts +7 -6
- package/src/client/AuthorizationCodeClient.ts +12 -3
- package/src/client/BaseClient.ts +9 -6
- package/src/client/RefreshTokenClient.ts +36 -9
- package/src/client/SilentFlowClient.ts +49 -49
- package/src/crypto/ICrypto.ts +0 -7
- package/src/error/ClientAuthError.ts +8 -0
- package/src/error/ClientAuthErrorCodes.ts +1 -0
- package/src/index.ts +7 -1
- package/src/packageMetadata.ts +1 -1
- package/src/request/CommonRefreshTokenRequest.ts +3 -0
- package/src/request/CommonSilentFlowRequest.ts +2 -0
- package/src/response/ResponseHandler.ts +9 -3
- package/src/telemetry/performance/PerformanceEvent.ts +33 -2
- package/src/utils/FunctionWrappers.ts +0 -1
|
@@ -23,7 +23,8 @@ import {
|
|
|
23
23
|
} from "../utils/Constants";
|
|
24
24
|
import {
|
|
25
25
|
EndpointMetadata,
|
|
26
|
-
|
|
26
|
+
getCloudDiscoveryMetadataFromHardcodedValues,
|
|
27
|
+
getCloudDiscoveryMetadataFromNetworkResponse,
|
|
27
28
|
InstanceDiscoveryMetadataAliases,
|
|
28
29
|
} from "./AuthorityMetadata";
|
|
29
30
|
import {
|
|
@@ -33,7 +34,11 @@ import {
|
|
|
33
34
|
import { ProtocolMode } from "./ProtocolMode";
|
|
34
35
|
import { ICacheManager } from "../cache/interface/ICacheManager";
|
|
35
36
|
import { AuthorityMetadataEntity } from "../cache/entities/AuthorityMetadataEntity";
|
|
36
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
AuthorityOptions,
|
|
39
|
+
AzureCloudInstance,
|
|
40
|
+
StaticAuthorityOptions,
|
|
41
|
+
} from "./AuthorityOptions";
|
|
37
42
|
import {
|
|
38
43
|
CloudInstanceDiscoveryResponse,
|
|
39
44
|
isCloudInstanceDiscoveryResponse,
|
|
@@ -393,14 +398,7 @@ export class Authority {
|
|
|
393
398
|
this.correlationId
|
|
394
399
|
);
|
|
395
400
|
|
|
396
|
-
|
|
397
|
-
this.hostnameAndPort
|
|
398
|
-
);
|
|
399
|
-
|
|
400
|
-
if (!metadataEntity) {
|
|
401
|
-
metadataEntity = new AuthorityMetadataEntity();
|
|
402
|
-
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
403
|
-
}
|
|
401
|
+
const metadataEntity = this.getCurrentMetadataEntity();
|
|
404
402
|
|
|
405
403
|
const cloudDiscoverySource = await invokeAsync(
|
|
406
404
|
this.updateCloudDiscoveryMetadata.bind(this),
|
|
@@ -420,10 +418,46 @@ export class Authority {
|
|
|
420
418
|
this.performanceClient,
|
|
421
419
|
this.correlationId
|
|
422
420
|
)(metadataEntity);
|
|
421
|
+
this.updateCachedMetadata(metadataEntity, cloudDiscoverySource, {
|
|
422
|
+
source: endpointSource,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Returns metadata entity from cache if it exists, otherwiser returns a new metadata entity built
|
|
428
|
+
* from the configured canonical authority
|
|
429
|
+
* @returns
|
|
430
|
+
*/
|
|
431
|
+
private getCurrentMetadataEntity(): AuthorityMetadataEntity {
|
|
432
|
+
let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(
|
|
433
|
+
this.hostnameAndPort
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
if (!metadataEntity) {
|
|
437
|
+
metadataEntity = new AuthorityMetadataEntity();
|
|
438
|
+
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
439
|
+
}
|
|
440
|
+
return metadataEntity;
|
|
441
|
+
}
|
|
423
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Updates cached metadata based on metadata source and sets the instance's metadata
|
|
445
|
+
* property to the same value
|
|
446
|
+
* @param metadataEntity
|
|
447
|
+
* @param cloudDiscoverySource
|
|
448
|
+
* @param endpointMetadataResult
|
|
449
|
+
*/
|
|
450
|
+
private updateCachedMetadata(
|
|
451
|
+
metadataEntity: AuthorityMetadataEntity,
|
|
452
|
+
cloudDiscoverySource: AuthorityMetadataSource | null,
|
|
453
|
+
endpointMetadataResult: {
|
|
454
|
+
source: AuthorityMetadataSource;
|
|
455
|
+
metadata?: OpenIdConfigResponse;
|
|
456
|
+
} | null
|
|
457
|
+
): void {
|
|
424
458
|
if (
|
|
425
459
|
cloudDiscoverySource !== AuthorityMetadataSource.CACHE &&
|
|
426
|
-
|
|
460
|
+
endpointMetadataResult?.source !== AuthorityMetadataSource.CACHE
|
|
427
461
|
) {
|
|
428
462
|
// Reset the expiration time unless both values came from a successful cache lookup
|
|
429
463
|
metadataEntity.resetExpiresAt();
|
|
@@ -448,16 +482,95 @@ export class Authority {
|
|
|
448
482
|
PerformanceEvents.AuthorityUpdateEndpointMetadata,
|
|
449
483
|
this.correlationId
|
|
450
484
|
);
|
|
485
|
+
|
|
486
|
+
const localMetadata =
|
|
487
|
+
this.updateEndpointMetadataFromLocalSources(metadataEntity);
|
|
488
|
+
|
|
489
|
+
// Further update may be required for hardcoded metadata if regional metadata is preferred
|
|
490
|
+
if (localMetadata) {
|
|
491
|
+
if (
|
|
492
|
+
localMetadata.source ===
|
|
493
|
+
AuthorityMetadataSource.HARDCODED_VALUES
|
|
494
|
+
) {
|
|
495
|
+
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
496
|
+
if (
|
|
497
|
+
this.authorityOptions.azureRegionConfiguration?.azureRegion
|
|
498
|
+
) {
|
|
499
|
+
if (localMetadata.metadata) {
|
|
500
|
+
const hardcodedMetadata = await invokeAsync(
|
|
501
|
+
this.updateMetadataWithRegionalInformation.bind(
|
|
502
|
+
this
|
|
503
|
+
),
|
|
504
|
+
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
505
|
+
this.logger,
|
|
506
|
+
this.performanceClient,
|
|
507
|
+
this.correlationId
|
|
508
|
+
)(localMetadata.metadata);
|
|
509
|
+
metadataEntity.updateEndpointMetadata(
|
|
510
|
+
hardcodedMetadata,
|
|
511
|
+
false
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return localMetadata.source;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Get metadata from network if local sources aren't available
|
|
520
|
+
let metadata = await invokeAsync(
|
|
521
|
+
this.getEndpointMetadataFromNetwork.bind(this),
|
|
522
|
+
PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork,
|
|
523
|
+
this.logger,
|
|
524
|
+
this.performanceClient,
|
|
525
|
+
this.correlationId
|
|
526
|
+
)();
|
|
527
|
+
if (metadata) {
|
|
528
|
+
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
529
|
+
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
530
|
+
metadata = await invokeAsync(
|
|
531
|
+
this.updateMetadataWithRegionalInformation.bind(this),
|
|
532
|
+
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
533
|
+
this.logger,
|
|
534
|
+
this.performanceClient,
|
|
535
|
+
this.correlationId
|
|
536
|
+
)(metadata);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
540
|
+
return AuthorityMetadataSource.NETWORK;
|
|
541
|
+
} else {
|
|
542
|
+
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
543
|
+
throw createClientAuthError(
|
|
544
|
+
ClientAuthErrorCodes.openIdConfigError,
|
|
545
|
+
this.defaultOpenIdConfigurationEndpoint
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Updates endpoint metadata from local sources and returns where the information was retrieved from and the metadata config
|
|
552
|
+
* response if the source is hardcoded metadata
|
|
553
|
+
* @param metadataEntity
|
|
554
|
+
* @returns
|
|
555
|
+
*/
|
|
556
|
+
private updateEndpointMetadataFromLocalSources(
|
|
557
|
+
metadataEntity: AuthorityMetadataEntity
|
|
558
|
+
): {
|
|
559
|
+
source: AuthorityMetadataSource;
|
|
560
|
+
metadata?: OpenIdConfigResponse;
|
|
561
|
+
} | null {
|
|
451
562
|
this.logger.verbose(
|
|
452
563
|
"Attempting to get endpoint metadata from authority configuration"
|
|
453
564
|
);
|
|
454
|
-
|
|
455
|
-
if (
|
|
565
|
+
const configMetadata = this.getEndpointMetadataFromConfig();
|
|
566
|
+
if (configMetadata) {
|
|
456
567
|
this.logger.verbose(
|
|
457
568
|
"Found endpoint metadata in authority configuration"
|
|
458
569
|
);
|
|
459
|
-
metadataEntity.updateEndpointMetadata(
|
|
460
|
-
return
|
|
570
|
+
metadataEntity.updateEndpointMetadata(configMetadata, false);
|
|
571
|
+
return {
|
|
572
|
+
source: AuthorityMetadataSource.CONFIG,
|
|
573
|
+
};
|
|
461
574
|
}
|
|
462
575
|
|
|
463
576
|
this.logger.verbose(
|
|
@@ -470,27 +583,14 @@ export class Authority {
|
|
|
470
583
|
"Skipping hardcoded metadata cache since skipAuthorityMetadataCache is set to true. Attempting to get endpoint metadata from the network metadata cache."
|
|
471
584
|
);
|
|
472
585
|
} else {
|
|
473
|
-
|
|
586
|
+
const hardcodedMetadata =
|
|
474
587
|
this.getEndpointMetadataFromHardcodedValues();
|
|
475
588
|
if (hardcodedMetadata) {
|
|
476
|
-
this.logger.verbose(
|
|
477
|
-
"Found endpoint metadata from hardcoded values."
|
|
478
|
-
);
|
|
479
|
-
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
480
|
-
if (
|
|
481
|
-
this.authorityOptions.azureRegionConfiguration?.azureRegion
|
|
482
|
-
) {
|
|
483
|
-
hardcodedMetadata = await invokeAsync(
|
|
484
|
-
this.updateMetadataWithRegionalInformation.bind(this),
|
|
485
|
-
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
486
|
-
this.logger,
|
|
487
|
-
this.performanceClient,
|
|
488
|
-
this.correlationId
|
|
489
|
-
)(hardcodedMetadata);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
589
|
metadataEntity.updateEndpointMetadata(hardcodedMetadata, false);
|
|
493
|
-
return
|
|
590
|
+
return {
|
|
591
|
+
source: AuthorityMetadataSource.HARDCODED_VALUES,
|
|
592
|
+
metadata: hardcodedMetadata,
|
|
593
|
+
};
|
|
494
594
|
} else {
|
|
495
595
|
this.logger.verbose(
|
|
496
596
|
"Did not find endpoint metadata in hardcoded values... Attempting to get endpoint metadata from the network metadata cache."
|
|
@@ -507,39 +607,12 @@ export class Authority {
|
|
|
507
607
|
) {
|
|
508
608
|
// No need to update
|
|
509
609
|
this.logger.verbose("Found endpoint metadata in the cache.");
|
|
510
|
-
return AuthorityMetadataSource.CACHE;
|
|
610
|
+
return { source: AuthorityMetadataSource.CACHE };
|
|
511
611
|
} else if (metadataEntityExpired) {
|
|
512
612
|
this.logger.verbose("The metadata entity is expired.");
|
|
513
613
|
}
|
|
514
614
|
|
|
515
|
-
|
|
516
|
-
this.getEndpointMetadataFromNetwork.bind(this),
|
|
517
|
-
PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork,
|
|
518
|
-
this.logger,
|
|
519
|
-
this.performanceClient,
|
|
520
|
-
this.correlationId
|
|
521
|
-
)();
|
|
522
|
-
if (metadata) {
|
|
523
|
-
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
524
|
-
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
525
|
-
metadata = await invokeAsync(
|
|
526
|
-
this.updateMetadataWithRegionalInformation.bind(this),
|
|
527
|
-
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
528
|
-
this.logger,
|
|
529
|
-
this.performanceClient,
|
|
530
|
-
this.correlationId
|
|
531
|
-
)(metadata);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
535
|
-
return AuthorityMetadataSource.NETWORK;
|
|
536
|
-
} else {
|
|
537
|
-
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
538
|
-
throw createClientAuthError(
|
|
539
|
-
ClientAuthErrorCodes.openIdConfigError,
|
|
540
|
-
this.defaultOpenIdConfigurationEndpoint
|
|
541
|
-
);
|
|
542
|
-
}
|
|
615
|
+
return null;
|
|
543
616
|
}
|
|
544
617
|
|
|
545
618
|
/**
|
|
@@ -712,6 +785,35 @@ export class Authority {
|
|
|
712
785
|
PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata,
|
|
713
786
|
this.correlationId
|
|
714
787
|
);
|
|
788
|
+
const localMetadataSource =
|
|
789
|
+
this.updateCloudDiscoveryMetadataFromLocalSources(metadataEntity);
|
|
790
|
+
if (localMetadataSource) {
|
|
791
|
+
return localMetadataSource;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// Fallback to network as metadata source
|
|
795
|
+
const metadata = await invokeAsync(
|
|
796
|
+
this.getCloudDiscoveryMetadataFromNetwork.bind(this),
|
|
797
|
+
PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork,
|
|
798
|
+
this.logger,
|
|
799
|
+
this.performanceClient,
|
|
800
|
+
this.correlationId
|
|
801
|
+
)();
|
|
802
|
+
|
|
803
|
+
if (metadata) {
|
|
804
|
+
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
805
|
+
return AuthorityMetadataSource.NETWORK;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
809
|
+
throw createClientConfigurationError(
|
|
810
|
+
ClientConfigurationErrorCodes.untrustedAuthority
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
private updateCloudDiscoveryMetadataFromLocalSources(
|
|
815
|
+
metadataEntity: AuthorityMetadataEntity
|
|
816
|
+
): AuthorityMetadataSource | null {
|
|
715
817
|
this.logger.verbose(
|
|
716
818
|
"Attempting to get cloud discovery metadata from authority configuration"
|
|
717
819
|
);
|
|
@@ -732,7 +834,7 @@ export class Authority {
|
|
|
732
834
|
metadataEntity.canonical_authority || Constants.NOT_APPLICABLE
|
|
733
835
|
}`
|
|
734
836
|
);
|
|
735
|
-
|
|
837
|
+
const metadata = this.getCloudDiscoveryMetadataFromConfig();
|
|
736
838
|
if (metadata) {
|
|
737
839
|
this.logger.verbose(
|
|
738
840
|
"Found cloud discovery metadata in authority configuration"
|
|
@@ -752,7 +854,9 @@ export class Authority {
|
|
|
752
854
|
);
|
|
753
855
|
} else {
|
|
754
856
|
const hardcodedMetadata =
|
|
755
|
-
|
|
857
|
+
getCloudDiscoveryMetadataFromHardcodedValues(
|
|
858
|
+
this.canonicalAuthority
|
|
859
|
+
);
|
|
756
860
|
if (hardcodedMetadata) {
|
|
757
861
|
this.logger.verbose(
|
|
758
862
|
"Found cloud discovery metadata from hardcoded values."
|
|
@@ -782,23 +886,7 @@ export class Authority {
|
|
|
782
886
|
this.logger.verbose("The metadata entity is expired.");
|
|
783
887
|
}
|
|
784
888
|
|
|
785
|
-
|
|
786
|
-
this.getCloudDiscoveryMetadataFromNetwork.bind(this),
|
|
787
|
-
PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork,
|
|
788
|
-
this.logger,
|
|
789
|
-
this.performanceClient,
|
|
790
|
-
this.correlationId
|
|
791
|
-
)();
|
|
792
|
-
|
|
793
|
-
if (metadata) {
|
|
794
|
-
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
795
|
-
return AuthorityMetadataSource.NETWORK;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// Metadata could not be obtained from the config, cache, network or hardcoded values
|
|
799
|
-
throw createClientConfigurationError(
|
|
800
|
-
ClientConfigurationErrorCodes.untrustedAuthority
|
|
801
|
-
);
|
|
889
|
+
return null;
|
|
802
890
|
}
|
|
803
891
|
|
|
804
892
|
/**
|
|
@@ -827,11 +915,10 @@ export class Authority {
|
|
|
827
915
|
const parsedResponse = JSON.parse(
|
|
828
916
|
this.authorityOptions.cloudDiscoveryMetadata
|
|
829
917
|
) as CloudInstanceDiscoveryResponse;
|
|
830
|
-
const metadata =
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
);
|
|
918
|
+
const metadata = getCloudDiscoveryMetadataFromNetworkResponse(
|
|
919
|
+
parsedResponse.metadata,
|
|
920
|
+
this.hostnameAndPort
|
|
921
|
+
);
|
|
835
922
|
this.logger.verbose("Parsed the cloud discovery metadata.");
|
|
836
923
|
if (metadata) {
|
|
837
924
|
this.logger.verbose(
|
|
@@ -937,7 +1024,7 @@ export class Authority {
|
|
|
937
1024
|
this.logger.verbose(
|
|
938
1025
|
"Attempting to find a match between the developer's authority and the CloudInstanceDiscoveryMetadata returned from the network request."
|
|
939
1026
|
);
|
|
940
|
-
match =
|
|
1027
|
+
match = getCloudDiscoveryMetadataFromNetworkResponse(
|
|
941
1028
|
metadata,
|
|
942
1029
|
this.hostnameAndPort
|
|
943
1030
|
);
|
|
@@ -972,24 +1059,6 @@ export class Authority {
|
|
|
972
1059
|
return match;
|
|
973
1060
|
}
|
|
974
1061
|
|
|
975
|
-
/**
|
|
976
|
-
* Get cloud discovery metadata for common authorities
|
|
977
|
-
*/
|
|
978
|
-
private getCloudDiscoveryMetadataFromHardcodedValues(): CloudDiscoveryMetadata | null {
|
|
979
|
-
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
980
|
-
const hardcodedMetadataResponse =
|
|
981
|
-
InstanceDiscoveryMetadata[this.canonicalAuthority];
|
|
982
|
-
const metadata =
|
|
983
|
-
Authority.getCloudDiscoveryMetadataFromNetworkResponse(
|
|
984
|
-
hardcodedMetadataResponse.metadata,
|
|
985
|
-
this.hostnameAndPort
|
|
986
|
-
);
|
|
987
|
-
return metadata;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
return null;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
1062
|
/**
|
|
994
1063
|
* Helper function to determine if this host is included in the knownAuthorities config option
|
|
995
1064
|
*/
|
|
@@ -1046,25 +1115,6 @@ export class Authority {
|
|
|
1046
1115
|
};
|
|
1047
1116
|
}
|
|
1048
1117
|
|
|
1049
|
-
/**
|
|
1050
|
-
* Searches instance discovery network response for the entry that contains the host in the aliases list
|
|
1051
|
-
* @param response
|
|
1052
|
-
* @param authority
|
|
1053
|
-
*/
|
|
1054
|
-
static getCloudDiscoveryMetadataFromNetworkResponse(
|
|
1055
|
-
response: CloudDiscoveryMetadata[],
|
|
1056
|
-
authority: string
|
|
1057
|
-
): CloudDiscoveryMetadata | null {
|
|
1058
|
-
for (let i = 0; i < response.length; i++) {
|
|
1059
|
-
const metadata = response[i];
|
|
1060
|
-
if (metadata.aliases.indexOf(authority) > -1) {
|
|
1061
|
-
return metadata;
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
return null;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
1118
|
/**
|
|
1069
1119
|
* helper function to generate environment from authority object
|
|
1070
1120
|
*/
|
|
@@ -1184,9 +1234,7 @@ export class Authority {
|
|
|
1184
1234
|
* @param authority
|
|
1185
1235
|
*/
|
|
1186
1236
|
static transformCIAMAuthority(authority: string): string {
|
|
1187
|
-
let ciamAuthority = authority
|
|
1188
|
-
? authority
|
|
1189
|
-
: `${authority}${Constants.FORWARD_SLASH}`;
|
|
1237
|
+
let ciamAuthority = authority;
|
|
1190
1238
|
const authorityUrl = new UrlString(authority);
|
|
1191
1239
|
const authorityUrlComponents = authorityUrl.getUrlComponents();
|
|
1192
1240
|
|
|
@@ -1205,3 +1253,35 @@ export class Authority {
|
|
|
1205
1253
|
return ciamAuthority;
|
|
1206
1254
|
}
|
|
1207
1255
|
}
|
|
1256
|
+
|
|
1257
|
+
export function formatAuthorityUri(authorityUri: string): string {
|
|
1258
|
+
return authorityUri.endsWith(Constants.FORWARD_SLASH)
|
|
1259
|
+
? authorityUri
|
|
1260
|
+
: `${authorityUri}${Constants.FORWARD_SLASH}`;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
export function buildStaticAuthorityOptions(
|
|
1264
|
+
authOptions: Partial<AuthorityOptions>
|
|
1265
|
+
): StaticAuthorityOptions {
|
|
1266
|
+
const rawCloudDiscoveryMetadata = authOptions.cloudDiscoveryMetadata;
|
|
1267
|
+
let cloudDiscoveryMetadata: CloudDiscoveryMetadata[] | undefined =
|
|
1268
|
+
undefined;
|
|
1269
|
+
if (rawCloudDiscoveryMetadata) {
|
|
1270
|
+
try {
|
|
1271
|
+
cloudDiscoveryMetadata = JSON.parse(
|
|
1272
|
+
rawCloudDiscoveryMetadata
|
|
1273
|
+
).metadata;
|
|
1274
|
+
} catch (e) {
|
|
1275
|
+
throw createClientConfigurationError(
|
|
1276
|
+
ClientConfigurationErrorCodes.invalidCloudDiscoveryMetadata
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return {
|
|
1281
|
+
canonicalAuthority: authOptions.authority
|
|
1282
|
+
? formatAuthorityUri(authOptions.authority)
|
|
1283
|
+
: undefined,
|
|
1284
|
+
knownAuthorities: authOptions.knownAuthorities,
|
|
1285
|
+
cloudDiscoveryMetadata: cloudDiscoveryMetadata,
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Authority } from "./Authority";
|
|
6
|
+
import { Authority, formatAuthorityUri } from "./Authority";
|
|
7
7
|
import {
|
|
8
8
|
createClientConfigurationError,
|
|
9
9
|
ClientConfigurationErrorCodes,
|
|
@@ -45,9 +45,9 @@ export class AuthorityFactory {
|
|
|
45
45
|
PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance,
|
|
46
46
|
correlationId
|
|
47
47
|
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const authorityUriFinal = Authority.transformCIAMAuthority(
|
|
49
|
+
formatAuthorityUri(authorityUri)
|
|
50
|
+
);
|
|
51
51
|
|
|
52
52
|
// Initialize authority and perform discovery endpoint check.
|
|
53
53
|
const acquireTokenAuthority: Authority =
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { UrlString } from "../url/UrlString";
|
|
7
|
+
import { CloudDiscoveryMetadata } from "./CloudDiscoveryMetadata";
|
|
8
|
+
|
|
6
9
|
export const rawMetdataJSON = {
|
|
7
10
|
endpointMetadata: {
|
|
8
11
|
"https://login.microsoftonline.com/common/": {
|
|
@@ -951,3 +954,87 @@ for (const key in InstanceDiscoveryMetadata) {
|
|
|
951
954
|
}
|
|
952
955
|
}
|
|
953
956
|
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Returns aliases for the given canonical authority if found in hardcoded Instance Discovery Metadata or null if not found
|
|
960
|
+
* @param canonicalAuthority
|
|
961
|
+
* @returns
|
|
962
|
+
*/
|
|
963
|
+
export function getHardcodedAliasesForCanonicalAuthority(
|
|
964
|
+
canonicalAuthority?: string
|
|
965
|
+
): string[] | null {
|
|
966
|
+
if (canonicalAuthority) {
|
|
967
|
+
const instanceDiscoveryMetadata =
|
|
968
|
+
getCloudDiscoveryMetadataFromHardcodedValues(canonicalAuthority);
|
|
969
|
+
if (instanceDiscoveryMetadata) {
|
|
970
|
+
return instanceDiscoveryMetadata.aliases;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
return null;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Returns aliases for from the raw cloud discovery metadata given in configuration or null if no configuration was provided
|
|
978
|
+
* @param rawCloudDiscoveryMetadata
|
|
979
|
+
* @returns
|
|
980
|
+
*/
|
|
981
|
+
export function getAliasesFromConfigMetadata(
|
|
982
|
+
canonicalAuthority?: string,
|
|
983
|
+
cloudDiscoveryMetadata?: CloudDiscoveryMetadata[]
|
|
984
|
+
): string[] | null {
|
|
985
|
+
if (canonicalAuthority && cloudDiscoveryMetadata) {
|
|
986
|
+
const canonicalAuthorityUrlComponents = new UrlString(
|
|
987
|
+
canonicalAuthority
|
|
988
|
+
).getUrlComponents();
|
|
989
|
+
const metadata = getCloudDiscoveryMetadataFromNetworkResponse(
|
|
990
|
+
cloudDiscoveryMetadata,
|
|
991
|
+
canonicalAuthorityUrlComponents.HostNameAndPort
|
|
992
|
+
);
|
|
993
|
+
|
|
994
|
+
if (metadata) {
|
|
995
|
+
return metadata.aliases;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
return null;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Searches instance discovery network response for the entry that contains the host in the aliases list
|
|
1004
|
+
* @param response
|
|
1005
|
+
* @param authority
|
|
1006
|
+
*/
|
|
1007
|
+
export function getCloudDiscoveryMetadataFromNetworkResponse(
|
|
1008
|
+
response: CloudDiscoveryMetadata[],
|
|
1009
|
+
authority: string
|
|
1010
|
+
): CloudDiscoveryMetadata | null {
|
|
1011
|
+
for (let i = 0; i < response.length; i++) {
|
|
1012
|
+
const metadata = response[i];
|
|
1013
|
+
if (metadata.aliases.includes(authority)) {
|
|
1014
|
+
return metadata;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
return null;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Get cloud discovery metadata for common authorities
|
|
1023
|
+
*/
|
|
1024
|
+
export function getCloudDiscoveryMetadataFromHardcodedValues(
|
|
1025
|
+
canonicalAuthority: string
|
|
1026
|
+
): CloudDiscoveryMetadata | null {
|
|
1027
|
+
const canonicalAuthorityUrlComponents = new UrlString(
|
|
1028
|
+
canonicalAuthority
|
|
1029
|
+
).getUrlComponents();
|
|
1030
|
+
|
|
1031
|
+
if (canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
1032
|
+
const metadata = getCloudDiscoveryMetadataFromNetworkResponse(
|
|
1033
|
+
InstanceDiscoveryMetadata[canonicalAuthority].metadata,
|
|
1034
|
+
canonicalAuthorityUrlComponents.HostNameAndPort
|
|
1035
|
+
);
|
|
1036
|
+
return metadata;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
return null;
|
|
1040
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { ProtocolMode } from "./ProtocolMode";
|
|
7
7
|
import { OIDCOptions } from "./OIDCOptions";
|
|
8
8
|
import { AzureRegionConfiguration } from "./AzureRegionConfiguration";
|
|
9
|
+
import { CloudDiscoveryMetadata } from "./CloudDiscoveryMetadata";
|
|
9
10
|
|
|
10
11
|
export type AuthorityOptions = {
|
|
11
12
|
protocolMode: ProtocolMode;
|
|
@@ -15,6 +16,14 @@ export type AuthorityOptions = {
|
|
|
15
16
|
authorityMetadata: string;
|
|
16
17
|
skipAuthorityMetadataCache?: boolean;
|
|
17
18
|
azureRegionConfiguration?: AzureRegionConfiguration;
|
|
19
|
+
authority?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type StaticAuthorityOptions = Partial<
|
|
23
|
+
Pick<AuthorityOptions, "knownAuthorities">
|
|
24
|
+
> & {
|
|
25
|
+
canonicalAuthority?: string;
|
|
26
|
+
cloudDiscoveryMetadata?: CloudDiscoveryMetadata[];
|
|
18
27
|
};
|
|
19
28
|
|
|
20
29
|
export const AzureCloudInstance = {
|