@azure/msal-common 7.0.0 → 7.3.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/_virtual/_tslib.js +1 -1
- package/dist/account/AccountInfo.d.ts +4 -0
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/authority/Authority.d.ts +20 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +108 -35
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityMetadata.d.ts +623 -0
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -0
- package/dist/authority/AuthorityMetadata.js +12 -0
- package/dist/authority/AuthorityMetadata.js.map +1 -0
- package/dist/authority/AuthorityOptions.d.ts +1 -0
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +1 -1
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts +1 -0
- package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +3 -2
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +13 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +35 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -0
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +4 -2
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +1 -1
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +1 -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.js +30 -14
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.d.ts +3 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.js +4 -2
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts +3 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +34 -9
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +13 -7
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.js +1 -1
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts +2 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +40 -16
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +2 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +4 -4
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.js +1 -1
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/AppTokenProvider.d.ts +39 -0
- package/dist/config/AppTokenProvider.d.ts.map +1 -0
- package/dist/config/ClientConfiguration.d.ts +3 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +3 -3
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/JoseHeader.js +1 -1
- package/dist/crypto/JoseHeader.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +1 -1
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.d.ts +10 -0
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.js +13 -1
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.js +1 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.js +1 -1
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts +9 -0
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +12 -1
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/JoseHeaderError.js +1 -1
- package/dist/error/JoseHeaderError.js.map +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +429 -189
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/ThrottlingUtils.js +1 -1
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +1 -1
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +4 -2
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +1 -1
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/ResponseHandler.d.ts +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +6 -5
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +8 -2
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +35 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +22 -1
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +5 -2
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +5 -2
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +10 -8
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v7.
|
|
1
|
+
/*! @azure/msal-common v7.3.0 2022-08-01 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -138,7 +138,8 @@ var Constants = {
|
|
|
138
138
|
REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
|
|
139
139
|
KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
|
|
140
140
|
TOKEN_RESPONSE_TYPE: "token",
|
|
141
|
-
ID_TOKEN_RESPONSE_TYPE: "id_token"
|
|
141
|
+
ID_TOKEN_RESPONSE_TYPE: "id_token",
|
|
142
|
+
SHR_NONCE_VALIDITY: 240,
|
|
142
143
|
};
|
|
143
144
|
var OIDC_DEFAULT_SCOPES = [
|
|
144
145
|
Constants.OPENID_SCOPE,
|
|
@@ -170,6 +171,7 @@ exports.PersistentCacheKeys = void 0;
|
|
|
170
171
|
PersistentCacheKeys["ERROR"] = "error";
|
|
171
172
|
PersistentCacheKeys["ERROR_DESC"] = "error.description";
|
|
172
173
|
PersistentCacheKeys["ACTIVE_ACCOUNT"] = "active-account";
|
|
174
|
+
PersistentCacheKeys["ACTIVE_ACCOUNT_FILTERS"] = "active-account-filters"; // new cache entry for active_account for a more robust version for browser
|
|
173
175
|
})(exports.PersistentCacheKeys || (exports.PersistentCacheKeys = {}));
|
|
174
176
|
/**
|
|
175
177
|
* String constants related to AAD Authority
|
|
@@ -379,6 +381,7 @@ var AuthorityMetadataSource;
|
|
|
379
381
|
AuthorityMetadataSource["CONFIG"] = "config";
|
|
380
382
|
AuthorityMetadataSource["CACHE"] = "cache";
|
|
381
383
|
AuthorityMetadataSource["NETWORK"] = "network";
|
|
384
|
+
AuthorityMetadataSource["HARDCODED_VALUES"] = "hardcoded_values";
|
|
382
385
|
})(AuthorityMetadataSource || (AuthorityMetadataSource = {}));
|
|
383
386
|
var SERVER_TELEM_CONSTANTS = {
|
|
384
387
|
SCHEMA_VERSION: 5,
|
|
@@ -480,6 +483,10 @@ var AuthErrorMessage = {
|
|
|
480
483
|
unexpectedError: {
|
|
481
484
|
code: "unexpected_error",
|
|
482
485
|
desc: "Unexpected error in authentication."
|
|
486
|
+
},
|
|
487
|
+
postRequestFailed: {
|
|
488
|
+
code: "post_request_failed",
|
|
489
|
+
desc: "Post request failed from the network, could be a 4xx/5xx or a network unavailability. Please check the exact error code for details."
|
|
483
490
|
}
|
|
484
491
|
};
|
|
485
492
|
/**
|
|
@@ -508,6 +515,14 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
508
515
|
AuthError.createUnexpectedError = function (errDesc) {
|
|
509
516
|
return new AuthError(AuthErrorMessage.unexpectedError.code, AuthErrorMessage.unexpectedError.desc + ": " + errDesc);
|
|
510
517
|
};
|
|
518
|
+
/**
|
|
519
|
+
* Creates an error for post request failures.
|
|
520
|
+
* @param errDesc
|
|
521
|
+
* @returns
|
|
522
|
+
*/
|
|
523
|
+
AuthError.createPostRequestFailed = function (errDesc) {
|
|
524
|
+
return new AuthError(AuthErrorMessage.postRequestFailed.code, AuthErrorMessage.postRequestFailed.desc + ": " + errDesc);
|
|
525
|
+
};
|
|
511
526
|
return AuthError;
|
|
512
527
|
}(Error));
|
|
513
528
|
|
|
@@ -1357,7 +1372,7 @@ var Logger = /** @class */ (function () {
|
|
|
1357
1372
|
|
|
1358
1373
|
/* eslint-disable header/header */
|
|
1359
1374
|
var name = "@azure/msal-common";
|
|
1360
|
-
var version = "7.
|
|
1375
|
+
var version = "7.3.0";
|
|
1361
1376
|
|
|
1362
1377
|
/*
|
|
1363
1378
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2409,7 +2424,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2409
2424
|
* @param realm
|
|
2410
2425
|
*/
|
|
2411
2426
|
CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
|
|
2412
|
-
return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING);
|
|
2427
|
+
return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING, accountFilter ? accountFilter.nativeAccountId : Constants.EMPTY_STRING);
|
|
2413
2428
|
};
|
|
2414
2429
|
/**
|
|
2415
2430
|
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
|
|
@@ -2418,7 +2433,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2418
2433
|
* @param environment
|
|
2419
2434
|
* @param realm
|
|
2420
2435
|
*/
|
|
2421
|
-
CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {
|
|
2436
|
+
CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
|
|
2422
2437
|
var _this = this;
|
|
2423
2438
|
var allCacheKeys = this.getKeys();
|
|
2424
2439
|
var matchingAccounts = {};
|
|
@@ -2436,6 +2451,9 @@ var CacheManager = /** @class */ (function () {
|
|
|
2436
2451
|
if (!!realm && !_this.matchRealm(entity, realm)) {
|
|
2437
2452
|
return;
|
|
2438
2453
|
}
|
|
2454
|
+
if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
|
|
2455
|
+
return;
|
|
2456
|
+
}
|
|
2439
2457
|
matchingAccounts[cacheKey] = entity;
|
|
2440
2458
|
});
|
|
2441
2459
|
return matchingAccounts;
|
|
@@ -2764,6 +2782,26 @@ var CacheManager = /** @class */ (function () {
|
|
|
2764
2782
|
var accountKey = AccountEntity.generateAccountCacheKey(account);
|
|
2765
2783
|
return this.getAccount(accountKey);
|
|
2766
2784
|
};
|
|
2785
|
+
/**
|
|
2786
|
+
* Retrieve AccountEntity from cache
|
|
2787
|
+
* @param nativeAccountId
|
|
2788
|
+
* @returns AccountEntity or Null
|
|
2789
|
+
*/
|
|
2790
|
+
CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
|
|
2791
|
+
// fetch account from memory
|
|
2792
|
+
var accountFilter = {
|
|
2793
|
+
nativeAccountId: nativeAccountId
|
|
2794
|
+
};
|
|
2795
|
+
var accountCache = this.getAccountsFilteredBy(accountFilter);
|
|
2796
|
+
var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
|
|
2797
|
+
if (accounts.length < 1) {
|
|
2798
|
+
return null;
|
|
2799
|
+
}
|
|
2800
|
+
else if (accounts.length > 1) {
|
|
2801
|
+
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
|
|
2802
|
+
}
|
|
2803
|
+
return accountCache[0];
|
|
2804
|
+
};
|
|
2767
2805
|
/**
|
|
2768
2806
|
* Retrieve IdTokenEntity from cache
|
|
2769
2807
|
* @param clientId
|
|
@@ -2938,6 +2976,15 @@ var CacheManager = /** @class */ (function () {
|
|
|
2938
2976
|
CacheManager.prototype.matchRealm = function (entity, realm) {
|
|
2939
2977
|
return !!(entity.realm && realm === entity.realm);
|
|
2940
2978
|
};
|
|
2979
|
+
/**
|
|
2980
|
+
* helper to match nativeAccountId
|
|
2981
|
+
* @param entity
|
|
2982
|
+
* @param nativeAccountId
|
|
2983
|
+
* @returns boolean indicating the match result
|
|
2984
|
+
*/
|
|
2985
|
+
CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
|
|
2986
|
+
return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
|
|
2987
|
+
};
|
|
2941
2988
|
/**
|
|
2942
2989
|
* Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
|
|
2943
2990
|
* @param entity
|
|
@@ -3210,7 +3257,7 @@ function buildClientConfiguration(_a) {
|
|
|
3210
3257
|
telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
|
|
3211
3258
|
serverTelemetryManager: serverTelemetryManager || null,
|
|
3212
3259
|
persistencePlugin: persistencePlugin || null,
|
|
3213
|
-
serializableCache: serializableCache || null
|
|
3260
|
+
serializableCache: serializableCache || null,
|
|
3214
3261
|
};
|
|
3215
3262
|
}
|
|
3216
3263
|
/**
|
|
@@ -3218,7 +3265,7 @@ function buildClientConfiguration(_a) {
|
|
|
3218
3265
|
* @param authOptions
|
|
3219
3266
|
*/
|
|
3220
3267
|
function buildAuthOptions(authOptions) {
|
|
3221
|
-
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
|
|
3268
|
+
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
|
|
3222
3269
|
}
|
|
3223
3270
|
|
|
3224
3271
|
/*
|
|
@@ -3398,7 +3445,7 @@ exports.CcsCredentialType = void 0;
|
|
|
3398
3445
|
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
3399
3446
|
*/
|
|
3400
3447
|
var BaseClient = /** @class */ (function () {
|
|
3401
|
-
function BaseClient(configuration) {
|
|
3448
|
+
function BaseClient(configuration, performanceClient) {
|
|
3402
3449
|
// Set the configuration
|
|
3403
3450
|
this.config = buildClientConfiguration(configuration);
|
|
3404
3451
|
// Initialize the logger
|
|
@@ -3415,6 +3462,8 @@ var BaseClient = /** @class */ (function () {
|
|
|
3415
3462
|
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
3416
3463
|
// set Authority
|
|
3417
3464
|
this.authority = this.config.authOptions.authority;
|
|
3465
|
+
// set performance telemetry client
|
|
3466
|
+
this.performanceClient = performanceClient;
|
|
3418
3467
|
}
|
|
3419
3468
|
/**
|
|
3420
3469
|
* Creates default headers for requests to token endpoint
|
|
@@ -4251,6 +4300,10 @@ var InteractionRequiredAuthErrorMessage = {
|
|
|
4251
4300
|
noTokensFoundError: {
|
|
4252
4301
|
code: "no_tokens_found",
|
|
4253
4302
|
desc: "No refresh token found in the cache. Please sign-in."
|
|
4303
|
+
},
|
|
4304
|
+
native_account_unavailable: {
|
|
4305
|
+
code: "native_account_unavailable",
|
|
4306
|
+
desc: "The requested account is not available in the native broker. It may have been deleted or logged out. Please sign-in again using an interactive API."
|
|
4254
4307
|
}
|
|
4255
4308
|
};
|
|
4256
4309
|
/**
|
|
@@ -4284,6 +4337,13 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
|
4284
4337
|
InteractionRequiredAuthError.createNoTokensFoundError = function () {
|
|
4285
4338
|
return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
|
|
4286
4339
|
};
|
|
4340
|
+
/**
|
|
4341
|
+
* Creates an error thrown when the native broker returns ACCOUNT_UNAVAILABLE status, indicating that the account was removed and interactive sign-in is required
|
|
4342
|
+
* @returns
|
|
4343
|
+
*/
|
|
4344
|
+
InteractionRequiredAuthError.createNativeAccountUnavailableError = function () {
|
|
4345
|
+
return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.native_account_unavailable.code, InteractionRequiredAuthErrorMessage.native_account_unavailable.desc);
|
|
4346
|
+
};
|
|
4287
4347
|
return InteractionRequiredAuthError;
|
|
4288
4348
|
}(AuthError));
|
|
4289
4349
|
|
|
@@ -4831,7 +4891,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4831
4891
|
* @param serverTokenResponse
|
|
4832
4892
|
* @param authority
|
|
4833
4893
|
*/
|
|
4834
|
-
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse) {
|
|
4894
|
+
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
|
|
4835
4895
|
return __awaiter(this, void 0, void 0, function () {
|
|
4836
4896
|
var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
4837
4897
|
return __generator(this, function (_a) {
|
|
@@ -4868,14 +4928,15 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4868
4928
|
/*
|
|
4869
4929
|
* When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
|
|
4870
4930
|
* If not present, we should return null, as it's the case that another application called removeAccount in between
|
|
4871
|
-
* the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal
|
|
4931
|
+
* the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
|
|
4932
|
+
* the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
|
|
4872
4933
|
*/
|
|
4873
|
-
if (handlingRefreshTokenResponse && cacheRecord.account) {
|
|
4934
|
+
if (handlingRefreshTokenResponse && !forceCacheRefreshTokenResponse && cacheRecord.account) {
|
|
4874
4935
|
key = cacheRecord.account.generateAccountKey();
|
|
4875
4936
|
account = this.cacheStorage.getAccount(key);
|
|
4876
4937
|
if (!account) {
|
|
4877
4938
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
4878
|
-
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
|
|
4939
|
+
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
|
|
4879
4940
|
}
|
|
4880
4941
|
}
|
|
4881
4942
|
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
@@ -5139,7 +5200,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5139
5200
|
throw ClientConfigurationError.createEmptyLogoutRequestError();
|
|
5140
5201
|
}
|
|
5141
5202
|
var queryString = this.createLogoutUrlQueryString(logoutRequest);
|
|
5142
|
-
// Construct logout URI
|
|
5203
|
+
// Construct logout URI
|
|
5143
5204
|
return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
|
|
5144
5205
|
};
|
|
5145
5206
|
/**
|
|
@@ -5326,7 +5387,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5326
5387
|
*/
|
|
5327
5388
|
AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
|
|
5328
5389
|
return __awaiter(this, void 0, void 0, function () {
|
|
5329
|
-
var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
|
|
5390
|
+
var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
|
|
5330
5391
|
return __generator(this, function (_a) {
|
|
5331
5392
|
switch (_a.label) {
|
|
5332
5393
|
case 0:
|
|
@@ -5356,7 +5417,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5356
5417
|
if (request.domainHint) {
|
|
5357
5418
|
parameterBuilder.addDomainHint(request.domainHint);
|
|
5358
5419
|
}
|
|
5359
|
-
// Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object
|
|
5420
|
+
// Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
|
|
5360
5421
|
if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
|
|
5361
5422
|
// AAD will throw if prompt=select_account is passed with an account hint
|
|
5362
5423
|
if (request.sid && request.prompt === PromptValue.NONE) {
|
|
@@ -5366,9 +5427,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5366
5427
|
}
|
|
5367
5428
|
else if (request.account) {
|
|
5368
5429
|
accountSid = this.extractAccountSid(request.account);
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5430
|
+
accountLoginHintClaim = this.extractLoginHint(request.account);
|
|
5431
|
+
// If login_hint claim is present, use it over sid/username
|
|
5432
|
+
if (accountLoginHintClaim) {
|
|
5433
|
+
this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
|
|
5434
|
+
parameterBuilder.addLoginHint(accountLoginHintClaim);
|
|
5435
|
+
try {
|
|
5436
|
+
clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
5437
|
+
parameterBuilder.addCcsOid(clientInfo);
|
|
5438
|
+
}
|
|
5439
|
+
catch (e) {
|
|
5440
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
else if (accountSid && request.prompt === PromptValue.NONE) {
|
|
5444
|
+
/*
|
|
5445
|
+
* If account and loginHint are provided, we will check account first for sid before adding loginHint
|
|
5446
|
+
* SessionId is only used in silent calls
|
|
5447
|
+
*/
|
|
5372
5448
|
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
|
|
5373
5449
|
parameterBuilder.addSid(accountSid);
|
|
5374
5450
|
try {
|
|
@@ -5376,7 +5452,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5376
5452
|
parameterBuilder.addCcsOid(clientInfo);
|
|
5377
5453
|
}
|
|
5378
5454
|
catch (e) {
|
|
5379
|
-
this.logger.verbose("Could not parse home account ID for CCS Header
|
|
5455
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
5380
5456
|
}
|
|
5381
5457
|
}
|
|
5382
5458
|
else if (request.loginHint) {
|
|
@@ -5393,7 +5469,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5393
5469
|
parameterBuilder.addCcsOid(clientInfo);
|
|
5394
5470
|
}
|
|
5395
5471
|
catch (e) {
|
|
5396
|
-
this.logger.verbose("Could not parse home account ID for CCS Header
|
|
5472
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
5397
5473
|
}
|
|
5398
5474
|
}
|
|
5399
5475
|
}
|
|
@@ -5464,11 +5540,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5464
5540
|
* @param account
|
|
5465
5541
|
*/
|
|
5466
5542
|
AuthorizationCodeClient.prototype.extractAccountSid = function (account) {
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5543
|
+
var _a;
|
|
5544
|
+
return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.sid) || null;
|
|
5545
|
+
};
|
|
5546
|
+
AuthorizationCodeClient.prototype.extractLoginHint = function (account) {
|
|
5547
|
+
var _a;
|
|
5548
|
+
return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.login_hint) || null;
|
|
5472
5549
|
};
|
|
5473
5550
|
return AuthorizationCodeClient;
|
|
5474
5551
|
}(BaseClient));
|
|
@@ -5621,7 +5698,7 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5621
5698
|
pollingIntervalMilli = deviceCodeResponse.interval * 1000;
|
|
5622
5699
|
_a.label = 1;
|
|
5623
5700
|
case 1:
|
|
5624
|
-
if (!this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) return [3 /*break*/,
|
|
5701
|
+
if (!this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) return [3 /*break*/, 8];
|
|
5625
5702
|
thumbprint = {
|
|
5626
5703
|
clientId: this.config.authOptions.clientId,
|
|
5627
5704
|
authority: request.authority,
|
|
@@ -5636,18 +5713,23 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5636
5713
|
return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
5637
5714
|
case 2:
|
|
5638
5715
|
response = _a.sent();
|
|
5639
|
-
if (!(response.body && response.body.error
|
|
5640
|
-
|
|
5641
|
-
this.logger.info(
|
|
5716
|
+
if (!(response.body && response.body.error)) return [3 /*break*/, 6];
|
|
5717
|
+
if (!(response.body.error === Constants.AUTHORIZATION_PENDING)) return [3 /*break*/, 4];
|
|
5718
|
+
this.logger.info("Authorization pending. Continue polling.");
|
|
5642
5719
|
return [4 /*yield*/, TimeUtils.delay(pollingIntervalMilli)];
|
|
5643
5720
|
case 3:
|
|
5644
5721
|
_a.sent();
|
|
5645
5722
|
return [3 /*break*/, 5];
|
|
5646
5723
|
case 4:
|
|
5724
|
+
// for any other error, throw
|
|
5725
|
+
this.logger.info("Unexpected error in polling from the server");
|
|
5726
|
+
throw ServerError.createPostRequestFailed(response.body.error);
|
|
5727
|
+
case 5: return [3 /*break*/, 7];
|
|
5728
|
+
case 6:
|
|
5647
5729
|
this.logger.verbose("Authorization completed successfully. Polling stopped.");
|
|
5648
5730
|
return [2 /*return*/, response.body];
|
|
5649
|
-
case
|
|
5650
|
-
case
|
|
5731
|
+
case 7: return [3 /*break*/, 1];
|
|
5732
|
+
case 8:
|
|
5651
5733
|
/*
|
|
5652
5734
|
* The above code should've thrown by this point, but to satisfy TypeScript,
|
|
5653
5735
|
* and in the rare case the conditionals in continuePolling() may not catch everything...
|
|
@@ -5686,6 +5768,123 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5686
5768
|
return DeviceCodeClient;
|
|
5687
5769
|
}(BaseClient));
|
|
5688
5770
|
|
|
5771
|
+
/*
|
|
5772
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5773
|
+
* Licensed under the MIT License.
|
|
5774
|
+
*/
|
|
5775
|
+
/**
|
|
5776
|
+
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
5777
|
+
*
|
|
5778
|
+
* @export
|
|
5779
|
+
* @enum {number}
|
|
5780
|
+
*/
|
|
5781
|
+
exports.PerformanceEvents = void 0;
|
|
5782
|
+
(function (PerformanceEvents) {
|
|
5783
|
+
/**
|
|
5784
|
+
* acquireTokenByCode API (msal-browser and msal-node).
|
|
5785
|
+
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
5786
|
+
*/
|
|
5787
|
+
PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
|
|
5788
|
+
/**
|
|
5789
|
+
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
5790
|
+
* Used to renew an access token using a refresh token against the token endpoint.
|
|
5791
|
+
*/
|
|
5792
|
+
PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
|
|
5793
|
+
/**
|
|
5794
|
+
* acquireTokenSilent API (msal-browser and msal-node).
|
|
5795
|
+
* Used to silently acquire a new access token (from the cache or the network).
|
|
5796
|
+
*/
|
|
5797
|
+
PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
|
|
5798
|
+
/**
|
|
5799
|
+
* acquireTokenSilentAsync (msal-browser).
|
|
5800
|
+
* Internal API for acquireTokenSilent.
|
|
5801
|
+
*/
|
|
5802
|
+
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
5803
|
+
/**
|
|
5804
|
+
* acquireTokenPopup (msal-browser).
|
|
5805
|
+
* Used to acquire a new access token interactively through pop ups
|
|
5806
|
+
*/
|
|
5807
|
+
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
5808
|
+
/**
|
|
5809
|
+
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
5810
|
+
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
5811
|
+
*/
|
|
5812
|
+
PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
|
|
5813
|
+
/**
|
|
5814
|
+
* signJwt API in CryptoOpts class (msal-browser).
|
|
5815
|
+
* Used to signed a pop token.
|
|
5816
|
+
*/
|
|
5817
|
+
PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
|
|
5818
|
+
/**
|
|
5819
|
+
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
5820
|
+
* Used to read access tokens from the cache.
|
|
5821
|
+
*/
|
|
5822
|
+
PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
|
|
5823
|
+
/**
|
|
5824
|
+
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
5825
|
+
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
5826
|
+
*/
|
|
5827
|
+
PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
|
|
5828
|
+
/**
|
|
5829
|
+
* acquireToken API in SilentRereshClient (msal-browser).
|
|
5830
|
+
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
5831
|
+
*/
|
|
5832
|
+
PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
|
|
5833
|
+
/**
|
|
5834
|
+
* ssoSilent API (msal-browser).
|
|
5835
|
+
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
5836
|
+
*/
|
|
5837
|
+
PerformanceEvents["SsoSilent"] = "ssoSilent";
|
|
5838
|
+
/**
|
|
5839
|
+
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
5840
|
+
* Used to load authority metadata for a request.
|
|
5841
|
+
*/
|
|
5842
|
+
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
5843
|
+
/**
|
|
5844
|
+
* acquireToken APIs in msal-browser.
|
|
5845
|
+
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
5846
|
+
*/
|
|
5847
|
+
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
5848
|
+
/**
|
|
5849
|
+
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
5850
|
+
* Used to acquire a token from Native component when native brokering is enabled.
|
|
5851
|
+
*/
|
|
5852
|
+
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
5853
|
+
/**
|
|
5854
|
+
* Time spent on the network for refresh token acquisition
|
|
5855
|
+
*/
|
|
5856
|
+
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5857
|
+
/**
|
|
5858
|
+
* Time spent creating default headers for requests to token endpoint
|
|
5859
|
+
*/
|
|
5860
|
+
PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
|
|
5861
|
+
/**
|
|
5862
|
+
* Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
|
|
5863
|
+
*/
|
|
5864
|
+
PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
|
|
5865
|
+
/**
|
|
5866
|
+
* acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
|
|
5867
|
+
*/
|
|
5868
|
+
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
5869
|
+
/**
|
|
5870
|
+
* acquireToken API in BrokerClientApplication.
|
|
5871
|
+
* Used to acquire a token on behalf of the embedded application (PW-Broker).
|
|
5872
|
+
*/
|
|
5873
|
+
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
5874
|
+
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5875
|
+
/**
|
|
5876
|
+
* State of the performance event.
|
|
5877
|
+
*
|
|
5878
|
+
* @export
|
|
5879
|
+
* @enum {number}
|
|
5880
|
+
*/
|
|
5881
|
+
exports.PerformanceEventStatus = void 0;
|
|
5882
|
+
(function (PerformanceEventStatus) {
|
|
5883
|
+
PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
|
|
5884
|
+
PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
|
|
5885
|
+
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
5886
|
+
})(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
|
|
5887
|
+
|
|
5689
5888
|
/*
|
|
5690
5889
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5691
5890
|
* Licensed under the MIT License.
|
|
@@ -5695,8 +5894,8 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5695
5894
|
*/
|
|
5696
5895
|
var RefreshTokenClient = /** @class */ (function (_super) {
|
|
5697
5896
|
__extends(RefreshTokenClient, _super);
|
|
5698
|
-
function RefreshTokenClient(configuration) {
|
|
5699
|
-
return _super.call(this, configuration) || this;
|
|
5897
|
+
function RefreshTokenClient(configuration, performanceClient) {
|
|
5898
|
+
return _super.call(this, configuration, performanceClient) || this;
|
|
5700
5899
|
}
|
|
5701
5900
|
RefreshTokenClient.prototype.acquireToken = function (request) {
|
|
5702
5901
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -5710,7 +5909,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5710
5909
|
response = _a.sent();
|
|
5711
5910
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5712
5911
|
responseHandler.validateTokenResponse(response.body);
|
|
5713
|
-
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true)];
|
|
5912
|
+
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
|
|
5714
5913
|
}
|
|
5715
5914
|
});
|
|
5716
5915
|
});
|
|
@@ -5782,13 +5981,16 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5782
5981
|
* @param authority
|
|
5783
5982
|
*/
|
|
5784
5983
|
RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
|
|
5984
|
+
var _a;
|
|
5785
5985
|
return __awaiter(this, void 0, void 0, function () {
|
|
5786
|
-
var requestBody, queryParameters, headers, thumbprint, endpoint;
|
|
5787
|
-
return __generator(this, function (
|
|
5788
|
-
switch (
|
|
5789
|
-
case 0:
|
|
5986
|
+
var acquireTokenMeasurement, requestBody, queryParameters, headers, thumbprint, endpoint;
|
|
5987
|
+
return __generator(this, function (_b) {
|
|
5988
|
+
switch (_b.label) {
|
|
5989
|
+
case 0:
|
|
5990
|
+
acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
5991
|
+
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
5790
5992
|
case 1:
|
|
5791
|
-
requestBody =
|
|
5993
|
+
requestBody = _b.sent();
|
|
5792
5994
|
queryParameters = this.createTokenQueryParameters(request);
|
|
5793
5995
|
headers = this.createTokenRequestHeaders(request.ccsCredential);
|
|
5794
5996
|
thumbprint = {
|
|
@@ -5803,7 +6005,19 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5803
6005
|
sshKid: request.sshKid
|
|
5804
6006
|
};
|
|
5805
6007
|
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
|
|
5806
|
-
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6008
|
+
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6009
|
+
.then(function (result) {
|
|
6010
|
+
acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
|
|
6011
|
+
success: true
|
|
6012
|
+
});
|
|
6013
|
+
return result;
|
|
6014
|
+
})
|
|
6015
|
+
.catch(function (error) {
|
|
6016
|
+
acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
|
|
6017
|
+
success: false
|
|
6018
|
+
});
|
|
6019
|
+
throw error;
|
|
6020
|
+
})];
|
|
5807
6021
|
}
|
|
5808
6022
|
});
|
|
5809
6023
|
});
|
|
@@ -5824,11 +6038,14 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5824
6038
|
* @param request
|
|
5825
6039
|
*/
|
|
5826
6040
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
6041
|
+
var _a;
|
|
5827
6042
|
return __awaiter(this, void 0, void 0, function () {
|
|
5828
|
-
var
|
|
5829
|
-
return __generator(this, function (
|
|
5830
|
-
switch (
|
|
6043
|
+
var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
|
|
6044
|
+
return __generator(this, function (_b) {
|
|
6045
|
+
switch (_b.label) {
|
|
5831
6046
|
case 0:
|
|
6047
|
+
correlationId = request.correlationId;
|
|
6048
|
+
acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
5832
6049
|
parameterBuilder = new RequestParameterBuilder();
|
|
5833
6050
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5834
6051
|
parameterBuilder.addScopes(request.scopes);
|
|
@@ -5840,7 +6057,6 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5840
6057
|
if (this.serverTelemetryManager) {
|
|
5841
6058
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
5842
6059
|
}
|
|
5843
|
-
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
5844
6060
|
parameterBuilder.addCorrelationId(correlationId);
|
|
5845
6061
|
parameterBuilder.addRefreshToken(request.refreshToken);
|
|
5846
6062
|
if (this.config.clientCredentials.clientSecret) {
|
|
@@ -5855,7 +6071,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5855
6071
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5856
6072
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5857
6073
|
case 1:
|
|
5858
|
-
reqCnfData =
|
|
6074
|
+
reqCnfData = _b.sent();
|
|
5859
6075
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
5860
6076
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
5861
6077
|
return [3 /*break*/, 3];
|
|
@@ -5865,10 +6081,13 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5865
6081
|
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5866
6082
|
}
|
|
5867
6083
|
else {
|
|
6084
|
+
acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
|
|
6085
|
+
success: false
|
|
6086
|
+
});
|
|
5868
6087
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5869
6088
|
}
|
|
5870
6089
|
}
|
|
5871
|
-
|
|
6090
|
+
_b.label = 3;
|
|
5872
6091
|
case 3:
|
|
5873
6092
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5874
6093
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
@@ -5889,6 +6108,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5889
6108
|
break;
|
|
5890
6109
|
}
|
|
5891
6110
|
}
|
|
6111
|
+
acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
|
|
6112
|
+
success: true
|
|
6113
|
+
});
|
|
5892
6114
|
return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5893
6115
|
}
|
|
5894
6116
|
});
|
|
@@ -5906,8 +6128,10 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5906
6128
|
*/
|
|
5907
6129
|
var ClientCredentialClient = /** @class */ (function (_super) {
|
|
5908
6130
|
__extends(ClientCredentialClient, _super);
|
|
5909
|
-
function ClientCredentialClient(configuration) {
|
|
5910
|
-
|
|
6131
|
+
function ClientCredentialClient(configuration, appTokenProvider) {
|
|
6132
|
+
var _this = _super.call(this, configuration) || this;
|
|
6133
|
+
_this.appTokenProvider = appTokenProvider;
|
|
6134
|
+
return _this;
|
|
5911
6135
|
}
|
|
5912
6136
|
/**
|
|
5913
6137
|
* Public API to acquire a token with ClientCredential Flow for Confidential clients
|
|
@@ -5995,10 +6219,30 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
5995
6219
|
*/
|
|
5996
6220
|
ClientCredentialClient.prototype.executeTokenRequest = function (request, authority) {
|
|
5997
6221
|
return __awaiter(this, void 0, void 0, function () {
|
|
5998
|
-
var requestBody, headers, thumbprint,
|
|
6222
|
+
var serverTokenResponse, reqTimestamp, appTokenPropviderParameters, appTokenProviderResult, requestBody, headers, thumbprint, response, responseHandler, tokenResponse;
|
|
5999
6223
|
return __generator(this, function (_a) {
|
|
6000
6224
|
switch (_a.label) {
|
|
6001
6225
|
case 0:
|
|
6226
|
+
if (!this.appTokenProvider) return [3 /*break*/, 2];
|
|
6227
|
+
this.logger.info("Using appTokenProvider extensibility.");
|
|
6228
|
+
appTokenPropviderParameters = {
|
|
6229
|
+
correlationId: request.correlationId,
|
|
6230
|
+
tenantId: this.config.authOptions.authority.tenant,
|
|
6231
|
+
scopes: request.scopes,
|
|
6232
|
+
claims: request.claims,
|
|
6233
|
+
};
|
|
6234
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
6235
|
+
return [4 /*yield*/, this.appTokenProvider(appTokenPropviderParameters)];
|
|
6236
|
+
case 1:
|
|
6237
|
+
appTokenProviderResult = _a.sent();
|
|
6238
|
+
serverTokenResponse = {
|
|
6239
|
+
access_token: appTokenProviderResult.accessToken,
|
|
6240
|
+
expires_in: appTokenProviderResult.expiresInSeconds,
|
|
6241
|
+
refresh_in: appTokenProviderResult.refreshInSeconds,
|
|
6242
|
+
token_type: exports.AuthenticationScheme.BEARER
|
|
6243
|
+
};
|
|
6244
|
+
return [3 /*break*/, 4];
|
|
6245
|
+
case 2:
|
|
6002
6246
|
requestBody = this.createTokenRequestBody(request);
|
|
6003
6247
|
headers = this.createTokenRequestHeaders();
|
|
6004
6248
|
thumbprint = {
|
|
@@ -6014,12 +6258,15 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6014
6258
|
};
|
|
6015
6259
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6016
6260
|
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
6017
|
-
case
|
|
6261
|
+
case 3:
|
|
6018
6262
|
response = _a.sent();
|
|
6263
|
+
serverTokenResponse = response.body;
|
|
6264
|
+
_a.label = 4;
|
|
6265
|
+
case 4:
|
|
6019
6266
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
6020
|
-
responseHandler.validateTokenResponse(
|
|
6021
|
-
return [4 /*yield*/, responseHandler.handleServerTokenResponse(
|
|
6022
|
-
case
|
|
6267
|
+
responseHandler.validateTokenResponse(serverTokenResponse);
|
|
6268
|
+
return [4 /*yield*/, responseHandler.handleServerTokenResponse(serverTokenResponse, this.authority, reqTimestamp, request)];
|
|
6269
|
+
case 5:
|
|
6023
6270
|
tokenResponse = _a.sent();
|
|
6024
6271
|
return [2 /*return*/, tokenResponse];
|
|
6025
6272
|
}
|
|
@@ -6296,8 +6543,8 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
6296
6543
|
*/
|
|
6297
6544
|
var SilentFlowClient = /** @class */ (function (_super) {
|
|
6298
6545
|
__extends(SilentFlowClient, _super);
|
|
6299
|
-
function SilentFlowClient(configuration) {
|
|
6300
|
-
return _super.call(this, configuration) || this;
|
|
6546
|
+
function SilentFlowClient(configuration, performanceClient) {
|
|
6547
|
+
return _super.call(this, configuration, performanceClient) || this;
|
|
6301
6548
|
}
|
|
6302
6549
|
/**
|
|
6303
6550
|
* Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew
|
|
@@ -6316,7 +6563,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
6316
6563
|
case 2:
|
|
6317
6564
|
e_1 = _a.sent();
|
|
6318
6565
|
if (e_1 instanceof ClientAuthError && e_1.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {
|
|
6319
|
-
refreshTokenClient = new RefreshTokenClient(this.config);
|
|
6566
|
+
refreshTokenClient = new RefreshTokenClient(this.config, this.performanceClient);
|
|
6320
6567
|
return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(request)];
|
|
6321
6568
|
}
|
|
6322
6569
|
else {
|
|
@@ -6518,9 +6765,18 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6518
6765
|
function isOpenIdConfigResponse(response) {
|
|
6519
6766
|
return (response.hasOwnProperty("authorization_endpoint") &&
|
|
6520
6767
|
response.hasOwnProperty("token_endpoint") &&
|
|
6521
|
-
response.hasOwnProperty("issuer")
|
|
6768
|
+
response.hasOwnProperty("issuer") &&
|
|
6769
|
+
response.hasOwnProperty("jwks_uri"));
|
|
6522
6770
|
}
|
|
6523
6771
|
|
|
6772
|
+
/*
|
|
6773
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6774
|
+
* Licensed under the MIT License.
|
|
6775
|
+
*/
|
|
6776
|
+
var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/common/": { "token_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/common/": { "token_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/common/": { "token_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" }, "https://login.microsoftonline.com/consumers/": { "token_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/consumers/": { "token_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/consumers/": { "token_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" }, "https://login.microsoftonline.com/organizations/": { "token_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/organizations/": { "token_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/organizations/": { "token_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" } }, "instanceDiscoveryMetadata": { "https://login.microsoftonline.com/common/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/common/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/common/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.com/consumers/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/consumers/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/consumers/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.com/organizations/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/organizations/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/organizations/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] } } };
|
|
6777
|
+
var EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
6778
|
+
var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
6779
|
+
|
|
6524
6780
|
/*
|
|
6525
6781
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6526
6782
|
* Licensed under the MIT License.
|
|
@@ -6564,6 +6820,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
6564
6820
|
this.end_session_endpoint = metadata.end_session_endpoint;
|
|
6565
6821
|
this.issuer = metadata.issuer;
|
|
6566
6822
|
this.endpointsFromNetwork = fromNetwork;
|
|
6823
|
+
this.jwks_uri = metadata.jwks_uri;
|
|
6567
6824
|
};
|
|
6568
6825
|
/**
|
|
6569
6826
|
* Save the authority that was used to create this cache entry
|
|
@@ -6602,7 +6859,8 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
6602
6859
|
entity.hasOwnProperty("issuer") &&
|
|
6603
6860
|
entity.hasOwnProperty("aliasesFromNetwork") &&
|
|
6604
6861
|
entity.hasOwnProperty("endpointsFromNetwork") &&
|
|
6605
|
-
entity.hasOwnProperty("expiresAt")
|
|
6862
|
+
entity.hasOwnProperty("expiresAt") &&
|
|
6863
|
+
entity.hasOwnProperty("jwks_uri"));
|
|
6606
6864
|
};
|
|
6607
6865
|
return AuthorityMetadataEntity;
|
|
6608
6866
|
}());
|
|
@@ -6919,6 +7177,22 @@ var Authority = /** @class */ (function () {
|
|
|
6919
7177
|
enumerable: false,
|
|
6920
7178
|
configurable: true
|
|
6921
7179
|
});
|
|
7180
|
+
Object.defineProperty(Authority.prototype, "jwksUri", {
|
|
7181
|
+
/**
|
|
7182
|
+
* Jwks_uri for token signing keys
|
|
7183
|
+
*/
|
|
7184
|
+
get: function () {
|
|
7185
|
+
if (this.discoveryComplete()) {
|
|
7186
|
+
var endpoint = this.replacePath(this.metadata.jwks_uri);
|
|
7187
|
+
return this.replaceTenant(endpoint);
|
|
7188
|
+
}
|
|
7189
|
+
else {
|
|
7190
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
7191
|
+
}
|
|
7192
|
+
},
|
|
7193
|
+
enumerable: false,
|
|
7194
|
+
configurable: true
|
|
7195
|
+
});
|
|
6922
7196
|
/**
|
|
6923
7197
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
6924
7198
|
* @param urlString
|
|
@@ -7002,11 +7276,11 @@ var Authority = /** @class */ (function () {
|
|
|
7002
7276
|
* @param metadataEntity
|
|
7003
7277
|
*/
|
|
7004
7278
|
Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
|
|
7005
|
-
var _a;
|
|
7279
|
+
var _a, _b;
|
|
7006
7280
|
return __awaiter(this, void 0, void 0, function () {
|
|
7007
|
-
var metadata,
|
|
7008
|
-
return __generator(this, function (
|
|
7009
|
-
switch (
|
|
7281
|
+
var metadata, harcodedMetadata;
|
|
7282
|
+
return __generator(this, function (_c) {
|
|
7283
|
+
switch (_c.label) {
|
|
7010
7284
|
case 0:
|
|
7011
7285
|
metadata = this.getEndpointMetadataFromConfig();
|
|
7012
7286
|
if (metadata) {
|
|
@@ -7017,41 +7291,30 @@ var Authority = /** @class */ (function () {
|
|
|
7017
7291
|
// No need to update
|
|
7018
7292
|
return [2 /*return*/, AuthorityMetadataSource.CACHE];
|
|
7019
7293
|
}
|
|
7294
|
+
harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7020
7295
|
return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
|
|
7021
7296
|
case 1:
|
|
7022
|
-
metadata =
|
|
7297
|
+
metadata = _c.sent();
|
|
7023
7298
|
if (!metadata) return [3 /*break*/, 4];
|
|
7024
7299
|
if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
|
|
7025
|
-
return [4 /*yield*/, this.
|
|
7300
|
+
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
|
|
7026
7301
|
case 2:
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
? autodetectedRegionName
|
|
7030
|
-
: this.authorityOptions.azureRegionConfiguration.azureRegion;
|
|
7031
|
-
if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7032
|
-
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
|
|
7033
|
-
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
|
|
7034
|
-
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7035
|
-
}
|
|
7036
|
-
else {
|
|
7037
|
-
if (autodetectedRegionName) {
|
|
7038
|
-
this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration.azureRegion === autodetectedRegionName) ?
|
|
7039
|
-
RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
|
|
7040
|
-
RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
7041
|
-
}
|
|
7042
|
-
else {
|
|
7043
|
-
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7044
|
-
}
|
|
7045
|
-
}
|
|
7046
|
-
if (azureRegion) {
|
|
7047
|
-
this.regionDiscoveryMetadata.region_used = azureRegion;
|
|
7048
|
-
metadata = Authority.replaceWithRegionalInformation(metadata, azureRegion);
|
|
7049
|
-
}
|
|
7050
|
-
_b.label = 3;
|
|
7302
|
+
metadata = _c.sent();
|
|
7303
|
+
_c.label = 3;
|
|
7051
7304
|
case 3:
|
|
7052
7305
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
7053
7306
|
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
|
|
7054
|
-
case 4:
|
|
7307
|
+
case 4:
|
|
7308
|
+
if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
|
|
7309
|
+
if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
|
|
7310
|
+
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
|
|
7311
|
+
case 5:
|
|
7312
|
+
harcodedMetadata = _c.sent();
|
|
7313
|
+
_c.label = 6;
|
|
7314
|
+
case 6:
|
|
7315
|
+
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
7316
|
+
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
|
|
7317
|
+
case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
7055
7318
|
}
|
|
7056
7319
|
});
|
|
7057
7320
|
});
|
|
@@ -7082,6 +7345,8 @@ var Authority = /** @class */ (function () {
|
|
|
7082
7345
|
};
|
|
7083
7346
|
/**
|
|
7084
7347
|
* Gets OAuth endpoints from the given OpenID configuration endpoint.
|
|
7348
|
+
*
|
|
7349
|
+
* @param hasHardcodedMetadata boolean
|
|
7085
7350
|
*/
|
|
7086
7351
|
Authority.prototype.getEndpointMetadataFromNetwork = function () {
|
|
7087
7352
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -7108,6 +7373,54 @@ var Authority = /** @class */ (function () {
|
|
|
7108
7373
|
});
|
|
7109
7374
|
});
|
|
7110
7375
|
};
|
|
7376
|
+
/**
|
|
7377
|
+
* Get OAuth endpoints for common authorities.
|
|
7378
|
+
*/
|
|
7379
|
+
Authority.prototype.getEndpointMetadataFromHardcodedValues = function () {
|
|
7380
|
+
if (this.canonicalAuthority in EndpointMetadata) {
|
|
7381
|
+
return EndpointMetadata[this.canonicalAuthority];
|
|
7382
|
+
}
|
|
7383
|
+
return null;
|
|
7384
|
+
};
|
|
7385
|
+
/**
|
|
7386
|
+
* Update the retrieved metadata with regional information.
|
|
7387
|
+
*/
|
|
7388
|
+
Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
|
|
7389
|
+
var _a, _b, _c, _d, _e;
|
|
7390
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7391
|
+
var autodetectedRegionName, azureRegion;
|
|
7392
|
+
return __generator(this, function (_f) {
|
|
7393
|
+
switch (_f.label) {
|
|
7394
|
+
case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
|
|
7395
|
+
case 1:
|
|
7396
|
+
autodetectedRegionName = _f.sent();
|
|
7397
|
+
azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
|
|
7398
|
+
? autodetectedRegionName
|
|
7399
|
+
: (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
|
|
7400
|
+
if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7401
|
+
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
|
|
7402
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
|
|
7403
|
+
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7404
|
+
}
|
|
7405
|
+
else {
|
|
7406
|
+
if (autodetectedRegionName) {
|
|
7407
|
+
this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
|
|
7408
|
+
RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
|
|
7409
|
+
RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
7410
|
+
}
|
|
7411
|
+
else {
|
|
7412
|
+
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7413
|
+
}
|
|
7414
|
+
}
|
|
7415
|
+
if (azureRegion) {
|
|
7416
|
+
this.regionDiscoveryMetadata.region_used = azureRegion;
|
|
7417
|
+
return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, azureRegion)];
|
|
7418
|
+
}
|
|
7419
|
+
return [2 /*return*/, metadata];
|
|
7420
|
+
}
|
|
7421
|
+
});
|
|
7422
|
+
});
|
|
7423
|
+
};
|
|
7111
7424
|
/**
|
|
7112
7425
|
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
|
|
7113
7426
|
* @param cachedMetadata
|
|
@@ -7115,7 +7428,7 @@ var Authority = /** @class */ (function () {
|
|
|
7115
7428
|
*/
|
|
7116
7429
|
Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
|
|
7117
7430
|
return __awaiter(this, void 0, void 0, function () {
|
|
7118
|
-
var metadata;
|
|
7431
|
+
var metadata, harcodedMetadata;
|
|
7119
7432
|
return __generator(this, function (_a) {
|
|
7120
7433
|
switch (_a.label) {
|
|
7121
7434
|
case 0:
|
|
@@ -7129,6 +7442,7 @@ var Authority = /** @class */ (function () {
|
|
|
7129
7442
|
// No need to update
|
|
7130
7443
|
return [2 /*return*/, AuthorityMetadataSource.CACHE];
|
|
7131
7444
|
}
|
|
7445
|
+
harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
|
|
7132
7446
|
return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
|
|
7133
7447
|
case 1:
|
|
7134
7448
|
metadata = _a.sent();
|
|
@@ -7136,6 +7450,10 @@ var Authority = /** @class */ (function () {
|
|
|
7136
7450
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
7137
7451
|
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
|
|
7138
7452
|
}
|
|
7453
|
+
if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
|
|
7454
|
+
metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
|
|
7455
|
+
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
|
|
7456
|
+
}
|
|
7139
7457
|
else {
|
|
7140
7458
|
// Metadata could not be obtained from config, cache or network
|
|
7141
7459
|
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
@@ -7169,7 +7487,8 @@ var Authority = /** @class */ (function () {
|
|
|
7169
7487
|
};
|
|
7170
7488
|
/**
|
|
7171
7489
|
* Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
|
|
7172
|
-
*
|
|
7490
|
+
*
|
|
7491
|
+
* @param hasHardcodedMetadata boolean
|
|
7173
7492
|
*/
|
|
7174
7493
|
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
|
|
7175
7494
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -7189,7 +7508,9 @@ var Authority = /** @class */ (function () {
|
|
|
7189
7508
|
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
|
|
7190
7509
|
case 2:
|
|
7191
7510
|
response = _a.sent();
|
|
7192
|
-
metadata = isCloudInstanceDiscoveryResponse(response.body)
|
|
7511
|
+
metadata = isCloudInstanceDiscoveryResponse(response.body)
|
|
7512
|
+
? response.body.metadata
|
|
7513
|
+
: [];
|
|
7193
7514
|
if (metadata.length === 0) {
|
|
7194
7515
|
// If no metadata is returned, authority is untrusted
|
|
7195
7516
|
return [2 /*return*/, null];
|
|
@@ -7209,6 +7530,15 @@ var Authority = /** @class */ (function () {
|
|
|
7209
7530
|
});
|
|
7210
7531
|
});
|
|
7211
7532
|
};
|
|
7533
|
+
/**
|
|
7534
|
+
* Get cloud discovery metadata for common authorities
|
|
7535
|
+
*/
|
|
7536
|
+
Authority.prototype.getCloudDiscoveryMetadataFromHarcodedValues = function () {
|
|
7537
|
+
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
|
|
7538
|
+
return InstanceDiscoveryMetadata[this.canonicalAuthority];
|
|
7539
|
+
}
|
|
7540
|
+
return null;
|
|
7541
|
+
};
|
|
7212
7542
|
/**
|
|
7213
7543
|
* Helper function to determine if this host is included in the knownAuthorities config option
|
|
7214
7544
|
*/
|
|
@@ -7751,102 +8081,6 @@ var ServerTelemetryManager = /** @class */ (function () {
|
|
|
7751
8081
|
return ServerTelemetryManager;
|
|
7752
8082
|
}());
|
|
7753
8083
|
|
|
7754
|
-
/*
|
|
7755
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7756
|
-
* Licensed under the MIT License.
|
|
7757
|
-
*/
|
|
7758
|
-
/**
|
|
7759
|
-
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
7760
|
-
*
|
|
7761
|
-
* @export
|
|
7762
|
-
* @enum {number}
|
|
7763
|
-
*/
|
|
7764
|
-
exports.PerformanceEvents = void 0;
|
|
7765
|
-
(function (PerformanceEvents) {
|
|
7766
|
-
/**
|
|
7767
|
-
* acquireTokenByCode API (msal-browser and msal-node).
|
|
7768
|
-
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
7769
|
-
*/
|
|
7770
|
-
PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
|
|
7771
|
-
/**
|
|
7772
|
-
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
7773
|
-
* Used to renew an access token using a refresh token against the token endpoint.
|
|
7774
|
-
*/
|
|
7775
|
-
PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
|
|
7776
|
-
/**
|
|
7777
|
-
* acquireTokenSilent API (msal-browser and msal-node).
|
|
7778
|
-
* Used to silently acquire a new access token (from the cache or the network).
|
|
7779
|
-
*/
|
|
7780
|
-
PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
|
|
7781
|
-
/**
|
|
7782
|
-
* acquireTokenSilentAsync (msal-browser).
|
|
7783
|
-
* Internal API for acquireTokenSilent.
|
|
7784
|
-
*/
|
|
7785
|
-
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
7786
|
-
/**
|
|
7787
|
-
* acquireTokenPopup (msal-browser).
|
|
7788
|
-
* Used to acquire a new access token interactively through pop ups
|
|
7789
|
-
*/
|
|
7790
|
-
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
7791
|
-
/**
|
|
7792
|
-
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
7793
|
-
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
7794
|
-
*/
|
|
7795
|
-
PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
|
|
7796
|
-
/**
|
|
7797
|
-
* signJwt API in CryptoOpts class (msal-browser).
|
|
7798
|
-
* Used to signed a pop token.
|
|
7799
|
-
*/
|
|
7800
|
-
PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
|
|
7801
|
-
/**
|
|
7802
|
-
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
7803
|
-
* Used to read access tokens from the cache.
|
|
7804
|
-
*/
|
|
7805
|
-
PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
|
|
7806
|
-
/**
|
|
7807
|
-
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
7808
|
-
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
7809
|
-
*/
|
|
7810
|
-
PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
|
|
7811
|
-
/**
|
|
7812
|
-
* acquireToken API in SilentRereshClient (msal-browser).
|
|
7813
|
-
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
7814
|
-
*/
|
|
7815
|
-
PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
|
|
7816
|
-
/**
|
|
7817
|
-
* ssoSilent API (msal-browser).
|
|
7818
|
-
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
7819
|
-
*/
|
|
7820
|
-
PerformanceEvents["SsoSilent"] = "ssoSilent";
|
|
7821
|
-
/**
|
|
7822
|
-
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
7823
|
-
* Used to load authority metadata for a request.
|
|
7824
|
-
*/
|
|
7825
|
-
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
7826
|
-
/**
|
|
7827
|
-
* acquireToken APIs in msal-browser.
|
|
7828
|
-
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
7829
|
-
*/
|
|
7830
|
-
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
7831
|
-
/**
|
|
7832
|
-
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
7833
|
-
* Used to acquire a token from Native component when native brokering is enabled.
|
|
7834
|
-
*/
|
|
7835
|
-
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
7836
|
-
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
7837
|
-
/**
|
|
7838
|
-
* State of the performance event.
|
|
7839
|
-
*
|
|
7840
|
-
* @export
|
|
7841
|
-
* @enum {number}
|
|
7842
|
-
*/
|
|
7843
|
-
exports.PerformanceEventStatus = void 0;
|
|
7844
|
-
(function (PerformanceEventStatus) {
|
|
7845
|
-
PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
|
|
7846
|
-
PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
|
|
7847
|
-
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
7848
|
-
})(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
|
|
7849
|
-
|
|
7850
8084
|
/*
|
|
7851
8085
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7852
8086
|
* Licensed under the MIT License.
|
|
@@ -7903,7 +8137,7 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
7903
8137
|
clientId: this.clientId,
|
|
7904
8138
|
name: measureName,
|
|
7905
8139
|
startTimeMs: Date.now(),
|
|
7906
|
-
correlationId: eventCorrelationId
|
|
8140
|
+
correlationId: eventCorrelationId,
|
|
7907
8141
|
};
|
|
7908
8142
|
// Store in progress events so they can be discarded if not ended properly
|
|
7909
8143
|
this.cacheEventByCorrelationId(inProgressEvent);
|
|
@@ -8048,6 +8282,12 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8048
8282
|
else {
|
|
8049
8283
|
_this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
|
|
8050
8284
|
}
|
|
8285
|
+
if (current.accessTokenSize) {
|
|
8286
|
+
previous.accessTokenSize = current.accessTokenSize;
|
|
8287
|
+
}
|
|
8288
|
+
if (current.idTokenSize) {
|
|
8289
|
+
previous.idTokenSize = current.idTokenSize;
|
|
8290
|
+
}
|
|
8051
8291
|
}
|
|
8052
8292
|
return previous;
|
|
8053
8293
|
}, topLevelEvent);
|