@azure/msal-common 9.1.1 → 10.0.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/LICENSE +21 -21
- package/README.md +62 -62
- package/dist/_virtual/_tslib.js +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 +4 -2
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +62 -48
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts +3 -2
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.js +8 -5
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityMetadata.js +1 -1
- package/dist/authority/AuthorityMetadata.js.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/CloudInstanceDiscoveryErrorResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/ImdsOptions.d.ts +0 -1
- package/dist/authority/ImdsOptions.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.d.ts +5 -2
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.js +36 -25
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.js +1 -1
- 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.js +1 -1
- 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.d.ts +6 -0
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +28 -10
- 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/client/AuthorizationCodeClient.d.ts +0 -5
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +61 -56
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.d.ts +6 -0
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.js +14 -2
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +6 -3
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts +5 -0
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +25 -7
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.js +6 -3
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts +0 -5
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +42 -39
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +11 -8
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +0 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +2 -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.d.ts +3 -1
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +23 -14
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +1 -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 +19 -1
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +8 -3
- 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 +887 -556
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.d.ts +0 -1
- package/dist/network/INetworkModule.d.ts.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.d.ts.map +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/BaseAuthRequest.d.ts +3 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +4 -4
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +0 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts +1 -0
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts +4 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +1 -0
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/CommonOnBehalfOfRequest.d.ts +1 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +1 -2
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +3 -4
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/dist/request/CommonUsernamePasswordRequest.d.ts +1 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +2 -2
- package/dist/request/RequestParameterBuilder.js +6 -6
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.d.ts +1 -1
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.js +8 -3
- 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 +3 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +17 -13
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +4 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +16 -0
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +61 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +122 -3
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +105 -4
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +99 -3
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +4 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +13 -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.js +1 -1
- 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 +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v10.0.0 2023-02-06 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1422,7 +1422,7 @@ var Logger = /** @class */ (function () {
|
|
|
1422
1422
|
|
|
1423
1423
|
/* eslint-disable header/header */
|
|
1424
1424
|
var name = "@azure/msal-common";
|
|
1425
|
-
var version = "
|
|
1425
|
+
var version = "10.0.0";
|
|
1426
1426
|
|
|
1427
1427
|
/*
|
|
1428
1428
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1473,6 +1473,25 @@ exports.AzureCloudInstance = void 0;
|
|
|
1473
1473
|
var CredentialEntity = /** @class */ (function () {
|
|
1474
1474
|
function CredentialEntity() {
|
|
1475
1475
|
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Initializes a map with credential {CredentialType} regular expressions.
|
|
1478
|
+
*/
|
|
1479
|
+
CredentialEntity._initRegex = function () {
|
|
1480
|
+
var separator = Separators.CACHE_KEY_SEPARATOR;
|
|
1481
|
+
CredentialEntity.credentialRegexMap = new Map();
|
|
1482
|
+
for (var _i = 0, _a = Object.keys(exports.CredentialType); _i < _a.length; _i++) {
|
|
1483
|
+
var credKey = _a[_i];
|
|
1484
|
+
var credVal = exports.CredentialType[credKey].toLowerCase();
|
|
1485
|
+
try {
|
|
1486
|
+
// Verify credential type is preceded by a valid host name (environment) using lookbehind
|
|
1487
|
+
CredentialEntity.credentialRegexMap.set(exports.CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
|
|
1488
|
+
}
|
|
1489
|
+
catch (err) {
|
|
1490
|
+
// Lookbehind is not supported (Safari or older versions of IE) - removing it
|
|
1491
|
+
CredentialEntity.credentialRegexMap.set(exports.CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1476
1495
|
/**
|
|
1477
1496
|
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
1478
1497
|
*/
|
|
@@ -1519,14 +1538,10 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1519
1538
|
* @param key
|
|
1520
1539
|
*/
|
|
1521
1540
|
CredentialEntity.getCredentialType = function (key) {
|
|
1522
|
-
var
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
var credKey = _a[_i];
|
|
1527
|
-
var credVal = exports.CredentialType[credKey].toLowerCase();
|
|
1528
|
-
// Verify credential type is preceded by a valid host name (environment)
|
|
1529
|
-
if (key.toLowerCase().search("" + separator + domainRe + separator + credVal + separator) !== -1) {
|
|
1541
|
+
var _a;
|
|
1542
|
+
for (var _i = 0, _b = Object.keys(exports.CredentialType); _i < _b.length; _i++) {
|
|
1543
|
+
var credKey = _b[_i];
|
|
1544
|
+
if ((_a = this.credentialRegexMap.get(exports.CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
|
|
1530
1545
|
return exports.CredentialType[credKey];
|
|
1531
1546
|
}
|
|
1532
1547
|
}
|
|
@@ -1595,8 +1610,11 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1595
1610
|
*/
|
|
1596
1611
|
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
1597
1612
|
};
|
|
1613
|
+
// Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000, etc.
|
|
1614
|
+
CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?";
|
|
1598
1615
|
return CredentialEntity;
|
|
1599
|
-
}());
|
|
1616
|
+
}());
|
|
1617
|
+
CredentialEntity._initRegex();
|
|
1600
1618
|
|
|
1601
1619
|
/*
|
|
1602
1620
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3255,8 +3273,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
3255
3273
|
var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
3256
3274
|
var DEFAULT_SYSTEM_OPTIONS = {
|
|
3257
3275
|
tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
3258
|
-
preventCorsPreflight: false
|
|
3259
|
-
proxyUrl: Constants.EMPTY_STRING
|
|
3276
|
+
preventCorsPreflight: false
|
|
3260
3277
|
};
|
|
3261
3278
|
var DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
3262
3279
|
loggerCallback: function () {
|
|
@@ -3508,95 +3525,6 @@ exports.CcsCredentialType = void 0;
|
|
|
3508
3525
|
CcsCredentialType["UPN"] = "UPN";
|
|
3509
3526
|
})(exports.CcsCredentialType || (exports.CcsCredentialType = {}));
|
|
3510
3527
|
|
|
3511
|
-
/*
|
|
3512
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3513
|
-
* Licensed under the MIT License.
|
|
3514
|
-
*/
|
|
3515
|
-
/**
|
|
3516
|
-
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
3517
|
-
*/
|
|
3518
|
-
var BaseClient = /** @class */ (function () {
|
|
3519
|
-
function BaseClient(configuration, performanceClient) {
|
|
3520
|
-
// Set the configuration
|
|
3521
|
-
this.config = buildClientConfiguration(configuration);
|
|
3522
|
-
// Initialize the logger
|
|
3523
|
-
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
3524
|
-
// Initialize crypto
|
|
3525
|
-
this.cryptoUtils = this.config.cryptoInterface;
|
|
3526
|
-
// Initialize storage interface
|
|
3527
|
-
this.cacheManager = this.config.storageInterface;
|
|
3528
|
-
// Set the network interface
|
|
3529
|
-
this.networkClient = this.config.networkInterface;
|
|
3530
|
-
// Set the NetworkManager
|
|
3531
|
-
this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
|
|
3532
|
-
// Set TelemetryManager
|
|
3533
|
-
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
3534
|
-
// set Authority
|
|
3535
|
-
this.authority = this.config.authOptions.authority;
|
|
3536
|
-
// set performance telemetry client
|
|
3537
|
-
this.performanceClient = performanceClient;
|
|
3538
|
-
}
|
|
3539
|
-
/**
|
|
3540
|
-
* Creates default headers for requests to token endpoint
|
|
3541
|
-
*/
|
|
3542
|
-
BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
|
|
3543
|
-
var headers = {};
|
|
3544
|
-
headers[exports.HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
3545
|
-
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
3546
|
-
switch (ccsCred.type) {
|
|
3547
|
-
case exports.CcsCredentialType.HOME_ACCOUNT_ID:
|
|
3548
|
-
try {
|
|
3549
|
-
var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
3550
|
-
headers[exports.HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
|
|
3551
|
-
}
|
|
3552
|
-
catch (e) {
|
|
3553
|
-
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
3554
|
-
}
|
|
3555
|
-
break;
|
|
3556
|
-
case exports.CcsCredentialType.UPN:
|
|
3557
|
-
headers[exports.HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
|
|
3558
|
-
break;
|
|
3559
|
-
}
|
|
3560
|
-
}
|
|
3561
|
-
return headers;
|
|
3562
|
-
};
|
|
3563
|
-
/**
|
|
3564
|
-
* Http post to token endpoint
|
|
3565
|
-
* @param tokenEndpoint
|
|
3566
|
-
* @param queryString
|
|
3567
|
-
* @param headers
|
|
3568
|
-
* @param thumbprint
|
|
3569
|
-
*/
|
|
3570
|
-
BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
|
|
3571
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3572
|
-
var response;
|
|
3573
|
-
return __generator(this, function (_a) {
|
|
3574
|
-
switch (_a.label) {
|
|
3575
|
-
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
|
|
3576
|
-
case 1:
|
|
3577
|
-
response = _a.sent();
|
|
3578
|
-
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
3579
|
-
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
3580
|
-
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
3581
|
-
}
|
|
3582
|
-
return [2 /*return*/, response];
|
|
3583
|
-
}
|
|
3584
|
-
});
|
|
3585
|
-
});
|
|
3586
|
-
};
|
|
3587
|
-
/**
|
|
3588
|
-
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
3589
|
-
* @param updatedAuthority
|
|
3590
|
-
*/
|
|
3591
|
-
BaseClient.prototype.updateAuthority = function (updatedAuthority) {
|
|
3592
|
-
if (!updatedAuthority.discoveryComplete()) {
|
|
3593
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
|
|
3594
|
-
}
|
|
3595
|
-
this.authority = updatedAuthority;
|
|
3596
|
-
};
|
|
3597
|
-
return BaseClient;
|
|
3598
|
-
}());
|
|
3599
|
-
|
|
3600
3528
|
/*
|
|
3601
3529
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3602
3530
|
* Licensed under the MIT License.
|
|
@@ -3663,7 +3591,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3663
3591
|
}
|
|
3664
3592
|
};
|
|
3665
3593
|
/**
|
|
3666
|
-
* Removes unnecessary
|
|
3594
|
+
* Removes unnecessary, duplicate, and empty string query parameters from extraQueryParameters
|
|
3667
3595
|
* @param request
|
|
3668
3596
|
*/
|
|
3669
3597
|
RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {
|
|
@@ -3676,7 +3604,12 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3676
3604
|
delete eQParams[key];
|
|
3677
3605
|
}
|
|
3678
3606
|
});
|
|
3679
|
-
|
|
3607
|
+
// remove empty string parameters
|
|
3608
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3609
|
+
return Object.fromEntries(Object.entries(eQParams).filter(function (_a) {
|
|
3610
|
+
_a[0]; var value = _a[1];
|
|
3611
|
+
return value !== "";
|
|
3612
|
+
}));
|
|
3680
3613
|
};
|
|
3681
3614
|
return RequestValidator;
|
|
3682
3615
|
}());
|
|
@@ -3956,13 +3889,13 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3956
3889
|
};
|
|
3957
3890
|
/**
|
|
3958
3891
|
* add extraQueryParams
|
|
3959
|
-
* @param
|
|
3892
|
+
* @param eQParams
|
|
3960
3893
|
*/
|
|
3961
|
-
RequestParameterBuilder.prototype.addExtraQueryParameters = function (
|
|
3894
|
+
RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQParams) {
|
|
3962
3895
|
var _this = this;
|
|
3963
|
-
RequestValidator.sanitizeEQParams(
|
|
3964
|
-
Object.keys(
|
|
3965
|
-
_this.parameters.set(key,
|
|
3896
|
+
var sanitizedEQParams = RequestValidator.sanitizeEQParams(eQParams, this.parameters);
|
|
3897
|
+
Object.keys(sanitizedEQParams).forEach(function (key) {
|
|
3898
|
+
_this.parameters.set(key, eQParams[key]);
|
|
3966
3899
|
});
|
|
3967
3900
|
};
|
|
3968
3901
|
RequestParameterBuilder.prototype.addClientCapabilitiesToClaims = function (claims, clientCapabilities) {
|
|
@@ -4057,6 +3990,106 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
4057
3990
|
return RequestParameterBuilder;
|
|
4058
3991
|
}());
|
|
4059
3992
|
|
|
3993
|
+
/*
|
|
3994
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3995
|
+
* Licensed under the MIT License.
|
|
3996
|
+
*/
|
|
3997
|
+
/**
|
|
3998
|
+
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
3999
|
+
*/
|
|
4000
|
+
var BaseClient = /** @class */ (function () {
|
|
4001
|
+
function BaseClient(configuration, performanceClient) {
|
|
4002
|
+
// Set the configuration
|
|
4003
|
+
this.config = buildClientConfiguration(configuration);
|
|
4004
|
+
// Initialize the logger
|
|
4005
|
+
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
4006
|
+
// Initialize crypto
|
|
4007
|
+
this.cryptoUtils = this.config.cryptoInterface;
|
|
4008
|
+
// Initialize storage interface
|
|
4009
|
+
this.cacheManager = this.config.storageInterface;
|
|
4010
|
+
// Set the network interface
|
|
4011
|
+
this.networkClient = this.config.networkInterface;
|
|
4012
|
+
// Set the NetworkManager
|
|
4013
|
+
this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
|
|
4014
|
+
// Set TelemetryManager
|
|
4015
|
+
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
4016
|
+
// set Authority
|
|
4017
|
+
this.authority = this.config.authOptions.authority;
|
|
4018
|
+
// set performance telemetry client
|
|
4019
|
+
this.performanceClient = performanceClient;
|
|
4020
|
+
}
|
|
4021
|
+
/**
|
|
4022
|
+
* Creates default headers for requests to token endpoint
|
|
4023
|
+
*/
|
|
4024
|
+
BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
|
|
4025
|
+
var headers = {};
|
|
4026
|
+
headers[exports.HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
4027
|
+
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
4028
|
+
switch (ccsCred.type) {
|
|
4029
|
+
case exports.CcsCredentialType.HOME_ACCOUNT_ID:
|
|
4030
|
+
try {
|
|
4031
|
+
var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
4032
|
+
headers[exports.HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
|
|
4033
|
+
}
|
|
4034
|
+
catch (e) {
|
|
4035
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
4036
|
+
}
|
|
4037
|
+
break;
|
|
4038
|
+
case exports.CcsCredentialType.UPN:
|
|
4039
|
+
headers[exports.HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
|
|
4040
|
+
break;
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
return headers;
|
|
4044
|
+
};
|
|
4045
|
+
/**
|
|
4046
|
+
* Http post to token endpoint
|
|
4047
|
+
* @param tokenEndpoint
|
|
4048
|
+
* @param queryString
|
|
4049
|
+
* @param headers
|
|
4050
|
+
* @param thumbprint
|
|
4051
|
+
*/
|
|
4052
|
+
BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
|
|
4053
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4054
|
+
var response;
|
|
4055
|
+
return __generator(this, function (_a) {
|
|
4056
|
+
switch (_a.label) {
|
|
4057
|
+
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
|
|
4058
|
+
case 1:
|
|
4059
|
+
response = _a.sent();
|
|
4060
|
+
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
4061
|
+
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
4062
|
+
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
4063
|
+
}
|
|
4064
|
+
return [2 /*return*/, response];
|
|
4065
|
+
}
|
|
4066
|
+
});
|
|
4067
|
+
});
|
|
4068
|
+
};
|
|
4069
|
+
/**
|
|
4070
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
4071
|
+
* @param updatedAuthority
|
|
4072
|
+
*/
|
|
4073
|
+
BaseClient.prototype.updateAuthority = function (updatedAuthority) {
|
|
4074
|
+
if (!updatedAuthority.discoveryComplete()) {
|
|
4075
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
|
|
4076
|
+
}
|
|
4077
|
+
this.authority = updatedAuthority;
|
|
4078
|
+
};
|
|
4079
|
+
/**
|
|
4080
|
+
* Creates query string for the /token request
|
|
4081
|
+
* @param request
|
|
4082
|
+
*/
|
|
4083
|
+
BaseClient.prototype.createTokenQueryParameters = function (request) {
|
|
4084
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
4085
|
+
if (request.tokenQueryParameters) {
|
|
4086
|
+
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
4087
|
+
}
|
|
4088
|
+
return parameterBuilder.createQueryString();
|
|
4089
|
+
};
|
|
4090
|
+
return BaseClient;
|
|
4091
|
+
}());
|
|
4092
|
+
|
|
4060
4093
|
/*
|
|
4061
4094
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4062
4095
|
* Licensed under the MIT License.
|
|
@@ -4382,10 +4415,14 @@ var InteractionRequiredAuthErrorMessage = {
|
|
|
4382
4415
|
*/
|
|
4383
4416
|
var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
4384
4417
|
__extends(InteractionRequiredAuthError, _super);
|
|
4385
|
-
function InteractionRequiredAuthError(errorCode, errorMessage, subError) {
|
|
4418
|
+
function InteractionRequiredAuthError(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims) {
|
|
4386
4419
|
var _this = _super.call(this, errorCode, errorMessage, subError) || this;
|
|
4387
|
-
_this.name = "InteractionRequiredAuthError";
|
|
4388
4420
|
Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
|
|
4421
|
+
_this.timestamp = timestamp || Constants.EMPTY_STRING;
|
|
4422
|
+
_this.traceId = traceId || Constants.EMPTY_STRING;
|
|
4423
|
+
_this.correlationId = correlationId || Constants.EMPTY_STRING;
|
|
4424
|
+
_this.claims = claims || Constants.EMPTY_STRING;
|
|
4425
|
+
_this.name = "InteractionRequiredAuthError";
|
|
4389
4426
|
return _this;
|
|
4390
4427
|
}
|
|
4391
4428
|
/**
|
|
@@ -4738,56 +4775,290 @@ var UrlString = /** @class */ (function () {
|
|
|
4738
4775
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4739
4776
|
* Licensed under the MIT License.
|
|
4740
4777
|
*/
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
}
|
|
4778
|
+
/**
|
|
4779
|
+
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
4780
|
+
*
|
|
4781
|
+
* @export
|
|
4782
|
+
* @enum {number}
|
|
4783
|
+
*/
|
|
4784
|
+
exports.PerformanceEvents = void 0;
|
|
4785
|
+
(function (PerformanceEvents) {
|
|
4750
4786
|
/**
|
|
4751
|
-
*
|
|
4752
|
-
*
|
|
4753
|
-
* @param request
|
|
4754
|
-
* @returns
|
|
4787
|
+
* acquireTokenByCode API (msal-browser and msal-node).
|
|
4788
|
+
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
4755
4789
|
*/
|
|
4756
|
-
|
|
4757
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4758
|
-
var reqCnf, reqCnfString, _a;
|
|
4759
|
-
return __generator(this, function (_b) {
|
|
4760
|
-
switch (_b.label) {
|
|
4761
|
-
case 0: return [4 /*yield*/, this.generateKid(request)];
|
|
4762
|
-
case 1:
|
|
4763
|
-
reqCnf = _b.sent();
|
|
4764
|
-
reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
|
|
4765
|
-
_a = {
|
|
4766
|
-
kid: reqCnf.kid,
|
|
4767
|
-
reqCnfString: reqCnfString
|
|
4768
|
-
};
|
|
4769
|
-
return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
|
|
4770
|
-
case 2: return [2 /*return*/, (_a.reqCnfHash = _b.sent(),
|
|
4771
|
-
_a)];
|
|
4772
|
-
}
|
|
4773
|
-
});
|
|
4774
|
-
});
|
|
4775
|
-
};
|
|
4790
|
+
PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
|
|
4776
4791
|
/**
|
|
4777
|
-
*
|
|
4778
|
-
*
|
|
4779
|
-
* @returns
|
|
4792
|
+
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
4793
|
+
* Used to renew an access token using a refresh token against the token endpoint.
|
|
4780
4794
|
*/
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4795
|
+
PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
|
|
4796
|
+
/**
|
|
4797
|
+
* acquireTokenSilent API (msal-browser and msal-node).
|
|
4798
|
+
* Used to silently acquire a new access token (from the cache or the network).
|
|
4799
|
+
*/
|
|
4800
|
+
PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
|
|
4801
|
+
/**
|
|
4802
|
+
* acquireTokenSilentAsync (msal-browser).
|
|
4803
|
+
* Internal API for acquireTokenSilent.
|
|
4804
|
+
*/
|
|
4805
|
+
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
4806
|
+
/**
|
|
4807
|
+
* acquireTokenPopup (msal-browser).
|
|
4808
|
+
* Used to acquire a new access token interactively through pop ups
|
|
4809
|
+
*/
|
|
4810
|
+
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
4811
|
+
/**
|
|
4812
|
+
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
4813
|
+
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
4814
|
+
*/
|
|
4815
|
+
PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
|
|
4816
|
+
/**
|
|
4817
|
+
* signJwt API in CryptoOpts class (msal-browser).
|
|
4818
|
+
* Used to signed a pop token.
|
|
4819
|
+
*/
|
|
4820
|
+
PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
|
|
4821
|
+
/**
|
|
4822
|
+
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
4823
|
+
* Used to read access tokens from the cache.
|
|
4824
|
+
*/
|
|
4825
|
+
PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
|
|
4826
|
+
/**
|
|
4827
|
+
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
4828
|
+
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
4829
|
+
*/
|
|
4830
|
+
PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
|
|
4831
|
+
/**
|
|
4832
|
+
* acquireToken API in SilentRereshClient (msal-browser).
|
|
4833
|
+
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
4834
|
+
*/
|
|
4835
|
+
PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
|
|
4836
|
+
/**
|
|
4837
|
+
* ssoSilent API (msal-browser).
|
|
4838
|
+
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
4839
|
+
*/
|
|
4840
|
+
PerformanceEvents["SsoSilent"] = "ssoSilent";
|
|
4841
|
+
/**
|
|
4842
|
+
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
4843
|
+
* Used to load authority metadata for a request.
|
|
4844
|
+
*/
|
|
4845
|
+
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
4846
|
+
/**
|
|
4847
|
+
* acquireToken APIs in msal-browser.
|
|
4848
|
+
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
4849
|
+
*/
|
|
4850
|
+
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
4851
|
+
/**
|
|
4852
|
+
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
4853
|
+
* Used to acquire a token from Native component when native brokering is enabled.
|
|
4854
|
+
*/
|
|
4855
|
+
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
4856
|
+
/**
|
|
4857
|
+
* Time spent creating default headers for requests to token endpoint
|
|
4858
|
+
*/
|
|
4859
|
+
PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
|
|
4860
|
+
/**
|
|
4861
|
+
* Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
|
|
4862
|
+
*/
|
|
4863
|
+
PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
|
|
4864
|
+
/**
|
|
4865
|
+
* acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
|
|
4866
|
+
*/
|
|
4867
|
+
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
4868
|
+
/**
|
|
4869
|
+
* Time taken for token acquisition by broker
|
|
4870
|
+
*/
|
|
4871
|
+
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
4872
|
+
/**
|
|
4873
|
+
* Time spent on the network for refresh token acquisition
|
|
4874
|
+
*/
|
|
4875
|
+
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
4876
|
+
/**
|
|
4877
|
+
* Time taken for acquiring refresh token , records RT size
|
|
4878
|
+
*/
|
|
4879
|
+
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
4880
|
+
/**
|
|
4881
|
+
* Time taken for acquiring cached refresh token
|
|
4882
|
+
*/
|
|
4883
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
4884
|
+
/**
|
|
4885
|
+
* acquireTokenByRefreshToken API in RefreshTokenClient (msal-common).
|
|
4886
|
+
*/
|
|
4887
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenByRefreshToken"] = "refreshTokenClientAcquireTokenByRefreshToken";
|
|
4888
|
+
/**
|
|
4889
|
+
* Helper function to create token request body in RefreshTokenClient (msal-common).
|
|
4890
|
+
*/
|
|
4891
|
+
PerformanceEvents["RefreshTokenClientCreateTokenRequestBody"] = "refreshTokenClientCreateTokenRequestBody";
|
|
4892
|
+
/**
|
|
4893
|
+
* acquireTokenFromCache (msal-browser).
|
|
4894
|
+
* Internal API for acquiring token from cache
|
|
4895
|
+
*/
|
|
4896
|
+
PerformanceEvents["AcquireTokenFromCache"] = "acquireTokenFromCache";
|
|
4897
|
+
/**
|
|
4898
|
+
* acquireTokenBySilentIframe (msal-browser).
|
|
4899
|
+
* Internal API for acquiring token by silent Iframe
|
|
4900
|
+
*/
|
|
4901
|
+
PerformanceEvents["AcquireTokenBySilentIframe"] = "acquireTokenBySilentIframe";
|
|
4902
|
+
/**
|
|
4903
|
+
* Internal API for initializing base request in BaseInteractionClient (msal-browser)
|
|
4904
|
+
*/
|
|
4905
|
+
PerformanceEvents["InitializeBaseRequest"] = "initializeBaseRequest";
|
|
4906
|
+
/**
|
|
4907
|
+
* Internal API for initializing silent request in SilentCacheClient (msal-browser)
|
|
4908
|
+
*/
|
|
4909
|
+
PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
|
|
4910
|
+
/**
|
|
4911
|
+
* Helper function in SilentIframeClient class (msal-browser).
|
|
4912
|
+
*/
|
|
4913
|
+
PerformanceEvents["SilentIframeClientTokenHelper"] = "silentIframeClientTokenHelper";
|
|
4914
|
+
/**
|
|
4915
|
+
* SilentHandler
|
|
4916
|
+
*/
|
|
4917
|
+
PerformanceEvents["SilentHandlerInitiateAuthRequest"] = "silentHandlerInitiateAuthRequest";
|
|
4918
|
+
PerformanceEvents["SilentHandlerMonitorIframeForHash"] = "silentHandlerMonitorIframeForHash";
|
|
4919
|
+
PerformanceEvents["SilentHandlerLoadFrame"] = "silentHandlerLoadFrame";
|
|
4920
|
+
/**
|
|
4921
|
+
* Helper functions in StandardInteractionClient class (msal-browser)
|
|
4922
|
+
*/
|
|
4923
|
+
PerformanceEvents["StandardInteractionClientCreateAuthCodeClient"] = "standardInteractionClientCreateAuthCodeClient";
|
|
4924
|
+
PerformanceEvents["StandardInteractionClientGetClientConfiguration"] = "standardInteractionClientGetClientConfiguration";
|
|
4925
|
+
PerformanceEvents["StandardInteractionClientInitializeAuthorizationRequest"] = "standardInteractionClientInitializeAuthorizationRequest";
|
|
4926
|
+
PerformanceEvents["StandardInteractionClientInitializeAuthorizationCodeRequest"] = "standardInteractionClientInitializeAuthorizationCodeRequest";
|
|
4927
|
+
/**
|
|
4928
|
+
* getAuthCodeUrl API (msal-browser and msal-node).
|
|
4929
|
+
*/
|
|
4930
|
+
PerformanceEvents["GetAuthCodeUrl"] = "getAuthCodeUrl";
|
|
4931
|
+
/**
|
|
4932
|
+
* Functions from InteractionHandler (msal-browser)
|
|
4933
|
+
*/
|
|
4934
|
+
PerformanceEvents["HandleCodeResponseFromServer"] = "handleCodeResponseFromServer";
|
|
4935
|
+
PerformanceEvents["HandleCodeResponseFromHash"] = "handleCodeResponseFromHash";
|
|
4936
|
+
PerformanceEvents["UpdateTokenEndpointAuthority"] = "updateTokenEndpointAuthority";
|
|
4937
|
+
/**
|
|
4938
|
+
* APIs in Authorization Code Client (msal-common)
|
|
4939
|
+
*/
|
|
4940
|
+
PerformanceEvents["AuthClientAcquireToken"] = "authClientAcquireToken";
|
|
4941
|
+
PerformanceEvents["AuthClientExecuteTokenRequest"] = "authClientExecuteTokenRequest";
|
|
4942
|
+
PerformanceEvents["AuthClientCreateTokenRequestBody"] = "authClientCreateTokenRequestBody";
|
|
4943
|
+
PerformanceEvents["AuthClientCreateQueryString"] = "authClientCreateQueryString";
|
|
4944
|
+
/**
|
|
4945
|
+
* Generate functions in PopTokenGenerator (msal-common)
|
|
4946
|
+
*/
|
|
4947
|
+
PerformanceEvents["PopTokenGenerateCnf"] = "popTokenGenerateCnf";
|
|
4948
|
+
PerformanceEvents["PopTokenGenerateKid"] = "popTokenGenerateKid";
|
|
4949
|
+
/**
|
|
4950
|
+
* handleServerTokenResponse API in ResponseHandler (msal-common)
|
|
4951
|
+
*/
|
|
4952
|
+
PerformanceEvents["HandleServerTokenResponse"] = "handleServerTokenResponse";
|
|
4953
|
+
/**
|
|
4954
|
+
* Authority functions
|
|
4955
|
+
*/
|
|
4956
|
+
PerformanceEvents["AuthorityFactoryCreateDiscoveredInstance"] = "authorityFactoryCreateDiscoveredInstance";
|
|
4957
|
+
PerformanceEvents["AuthorityResolveEndpointsAsync"] = "authorityResolveEndpointsAsync";
|
|
4958
|
+
PerformanceEvents["AuthorityGetCloudDiscoveryMetadataFromNetwork"] = "authorityGetCloudDiscoveryMetadataFromNetwork";
|
|
4959
|
+
PerformanceEvents["AuthorityUpdateCloudDiscoveryMetadata"] = "authorityUpdateCloudDiscoveryMetadata";
|
|
4960
|
+
PerformanceEvents["AuthorityGetEndpointMetadataFromNetwork"] = "authorityGetEndpointMetadataFromNetwork";
|
|
4961
|
+
PerformanceEvents["AuthorityUpdateEndpointMetadata"] = "authorityUpdateEndpointMetadata";
|
|
4962
|
+
PerformanceEvents["AuthorityUpdateMetadataWithRegionalInformation"] = "authorityUpdateMetadataWithRegionalInformation";
|
|
4963
|
+
/**
|
|
4964
|
+
* Region Discovery functions
|
|
4965
|
+
*/
|
|
4966
|
+
PerformanceEvents["RegionDiscoveryDetectRegion"] = "regionDiscoveryDetectRegion";
|
|
4967
|
+
PerformanceEvents["RegionDiscoveryGetRegionFromIMDS"] = "regionDiscoveryGetRegionFromIMDS";
|
|
4968
|
+
PerformanceEvents["RegionDiscoveryGetCurrentVersion"] = "regionDiscoveryGetCurrentVersion";
|
|
4969
|
+
PerformanceEvents["AcquireTokenByCodeAsync"] = "acquireTokenByCodeAsync";
|
|
4970
|
+
PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
|
|
4971
|
+
PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
|
|
4972
|
+
PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
|
|
4973
|
+
PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
|
|
4974
|
+
PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
|
|
4975
|
+
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
4976
|
+
/**
|
|
4977
|
+
* State of the performance event.
|
|
4978
|
+
*
|
|
4979
|
+
* @export
|
|
4980
|
+
* @enum {number}
|
|
4981
|
+
*/
|
|
4982
|
+
exports.PerformanceEventStatus = void 0;
|
|
4983
|
+
(function (PerformanceEventStatus) {
|
|
4984
|
+
PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
|
|
4985
|
+
PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
|
|
4986
|
+
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
4987
|
+
})(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
|
|
4988
|
+
var IntFields = new Set([
|
|
4989
|
+
"accessTokenSize",
|
|
4990
|
+
"durationMs",
|
|
4991
|
+
"idTokenSize",
|
|
4992
|
+
"matsSilentStatus",
|
|
4993
|
+
"matsHttpStatus",
|
|
4994
|
+
"refreshTokenSize",
|
|
4995
|
+
"queuedTimeMs",
|
|
4996
|
+
"startTimeMs",
|
|
4997
|
+
"status",
|
|
4998
|
+
]);
|
|
4999
|
+
|
|
5000
|
+
/*
|
|
5001
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5002
|
+
* Licensed under the MIT License.
|
|
5003
|
+
*/
|
|
5004
|
+
var KeyLocation;
|
|
5005
|
+
(function (KeyLocation) {
|
|
5006
|
+
KeyLocation["SW"] = "sw";
|
|
5007
|
+
KeyLocation["UHW"] = "uhw";
|
|
5008
|
+
})(KeyLocation || (KeyLocation = {}));
|
|
5009
|
+
var PopTokenGenerator = /** @class */ (function () {
|
|
5010
|
+
function PopTokenGenerator(cryptoUtils, performanceClient) {
|
|
5011
|
+
this.cryptoUtils = cryptoUtils;
|
|
5012
|
+
this.performanceClient = performanceClient;
|
|
5013
|
+
}
|
|
5014
|
+
/**
|
|
5015
|
+
* Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
|
|
5016
|
+
* and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
|
|
5017
|
+
* @param request
|
|
5018
|
+
* @returns
|
|
5019
|
+
*/
|
|
5020
|
+
PopTokenGenerator.prototype.generateCnf = function (request) {
|
|
5021
|
+
var _a, _b;
|
|
5022
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5023
|
+
var reqCnf, reqCnfString, _c;
|
|
5024
|
+
return __generator(this, function (_d) {
|
|
5025
|
+
switch (_d.label) {
|
|
5026
|
+
case 0:
|
|
5027
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5028
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5029
|
+
return [4 /*yield*/, this.generateKid(request)];
|
|
5030
|
+
case 1:
|
|
5031
|
+
reqCnf = _d.sent();
|
|
5032
|
+
reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
|
|
5033
|
+
_c = {
|
|
5034
|
+
kid: reqCnf.kid,
|
|
5035
|
+
reqCnfString: reqCnfString
|
|
5036
|
+
};
|
|
5037
|
+
return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
|
|
5038
|
+
case 2: return [2 /*return*/, (_c.reqCnfHash = _d.sent(),
|
|
5039
|
+
_c)];
|
|
5040
|
+
}
|
|
5041
|
+
});
|
|
5042
|
+
});
|
|
5043
|
+
};
|
|
5044
|
+
/**
|
|
5045
|
+
* Generates key_id for a SHR token request
|
|
5046
|
+
* @param request
|
|
5047
|
+
* @returns
|
|
5048
|
+
*/
|
|
5049
|
+
PopTokenGenerator.prototype.generateKid = function (request) {
|
|
5050
|
+
var _a;
|
|
5051
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5052
|
+
var kidThumbprint;
|
|
5053
|
+
return __generator(this, function (_b) {
|
|
5054
|
+
switch (_b.label) {
|
|
5055
|
+
case 0:
|
|
5056
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5057
|
+
return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
|
|
5058
|
+
case 1:
|
|
5059
|
+
kidThumbprint = _b.sent();
|
|
5060
|
+
return [2 /*return*/, {
|
|
5061
|
+
kid: kidThumbprint,
|
|
4791
5062
|
xms_ksl: KeyLocation.SW
|
|
4792
5063
|
}];
|
|
4793
5064
|
}
|
|
@@ -4944,13 +5215,14 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4944
5215
|
* Class that handles response parsing.
|
|
4945
5216
|
*/
|
|
4946
5217
|
var ResponseHandler = /** @class */ (function () {
|
|
4947
|
-
function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin) {
|
|
5218
|
+
function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin, performanceClient) {
|
|
4948
5219
|
this.clientId = clientId;
|
|
4949
5220
|
this.cacheStorage = cacheStorage;
|
|
4950
5221
|
this.cryptoObj = cryptoObj;
|
|
4951
5222
|
this.logger = logger;
|
|
4952
5223
|
this.serializableCache = serializableCache;
|
|
4953
5224
|
this.persistencePlugin = persistencePlugin;
|
|
5225
|
+
this.performanceClient = performanceClient;
|
|
4954
5226
|
}
|
|
4955
5227
|
/**
|
|
4956
5228
|
* Function which validates server authorization code response.
|
|
@@ -4968,7 +5240,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4968
5240
|
// Check for error
|
|
4969
5241
|
if (serverResponseHash.error || serverResponseHash.error_description || serverResponseHash.suberror) {
|
|
4970
5242
|
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror)) {
|
|
4971
|
-
throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
5243
|
+
throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror, serverResponseHash.timestamp || Constants.EMPTY_STRING, serverResponseHash.trace_id || Constants.EMPTY_STRING, serverResponseHash.correlation_id || Constants.EMPTY_STRING, serverResponseHash.claims || Constants.EMPTY_STRING);
|
|
4972
5244
|
}
|
|
4973
5245
|
throw new ServerError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
4974
5246
|
}
|
|
@@ -4984,7 +5256,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4984
5256
|
// Check for error
|
|
4985
5257
|
if (serverResponse.error || serverResponse.error_description || serverResponse.suberror) {
|
|
4986
5258
|
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
|
|
4987
|
-
throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror);
|
|
5259
|
+
throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || Constants.EMPTY_STRING, serverResponse.trace_id || Constants.EMPTY_STRING, serverResponse.correlation_id || Constants.EMPTY_STRING, serverResponse.claims || Constants.EMPTY_STRING);
|
|
4988
5260
|
}
|
|
4989
5261
|
var errString = serverResponse.error_codes + " - [" + serverResponse.timestamp + "]: " + serverResponse.error_description + " - Correlation ID: " + serverResponse.correlation_id + " - Trace ID: " + serverResponse.trace_id;
|
|
4990
5262
|
throw new ServerError(serverResponse.error, errString, serverResponse.suberror);
|
|
@@ -4996,11 +5268,13 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4996
5268
|
* @param authority
|
|
4997
5269
|
*/
|
|
4998
5270
|
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
|
|
5271
|
+
var _a;
|
|
4999
5272
|
return __awaiter(this, void 0, void 0, function () {
|
|
5000
5273
|
var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
5001
|
-
return __generator(this, function (
|
|
5002
|
-
switch (
|
|
5274
|
+
return __generator(this, function (_b) {
|
|
5275
|
+
switch (_b.label) {
|
|
5003
5276
|
case 0:
|
|
5277
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.HandleServerTokenResponse, serverTokenResponse.correlation_id);
|
|
5004
5278
|
if (serverTokenResponse.id_token) {
|
|
5005
5279
|
idTokenObj = new AuthToken(serverTokenResponse.id_token || Constants.EMPTY_STRING, this.cryptoObj);
|
|
5006
5280
|
// token nonce check (TODO: Add a warning if no nonce is given?)
|
|
@@ -5026,16 +5300,16 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5026
5300
|
// Add keyId from request to serverTokenResponse if defined
|
|
5027
5301
|
serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
|
|
5028
5302
|
cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
|
|
5029
|
-
|
|
5303
|
+
_b.label = 1;
|
|
5030
5304
|
case 1:
|
|
5031
|
-
|
|
5305
|
+
_b.trys.push([1, , 5, 8]);
|
|
5032
5306
|
if (!(this.persistencePlugin && this.serializableCache)) return [3 /*break*/, 3];
|
|
5033
5307
|
this.logger.verbose("Persistence enabled, calling beforeCacheAccess");
|
|
5034
5308
|
cacheContext = new TokenCacheContext(this.serializableCache, true);
|
|
5035
5309
|
return [4 /*yield*/, this.persistencePlugin.beforeCacheAccess(cacheContext)];
|
|
5036
5310
|
case 2:
|
|
5037
|
-
|
|
5038
|
-
|
|
5311
|
+
_b.sent();
|
|
5312
|
+
_b.label = 3;
|
|
5039
5313
|
case 3:
|
|
5040
5314
|
/*
|
|
5041
5315
|
* When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
|
|
@@ -5053,15 +5327,15 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5053
5327
|
}
|
|
5054
5328
|
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
5055
5329
|
case 4:
|
|
5056
|
-
|
|
5330
|
+
_b.sent();
|
|
5057
5331
|
return [3 /*break*/, 8];
|
|
5058
5332
|
case 5:
|
|
5059
5333
|
if (!(this.persistencePlugin && this.serializableCache && cacheContext)) return [3 /*break*/, 7];
|
|
5060
5334
|
this.logger.verbose("Persistence enabled, calling afterCacheAccess");
|
|
5061
5335
|
return [4 /*yield*/, this.persistencePlugin.afterCacheAccess(cacheContext)];
|
|
5062
5336
|
case 6:
|
|
5063
|
-
|
|
5064
|
-
|
|
5337
|
+
_b.sent();
|
|
5338
|
+
_b.label = 7;
|
|
5065
5339
|
case 7: return [7 /*endfinally*/];
|
|
5066
5340
|
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
|
|
5067
5341
|
}
|
|
@@ -5240,13 +5514,17 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5240
5514
|
* @param request
|
|
5241
5515
|
*/
|
|
5242
5516
|
AuthorizationCodeClient.prototype.getAuthCodeUrl = function (request) {
|
|
5517
|
+
var _a, _b;
|
|
5243
5518
|
return __awaiter(this, void 0, void 0, function () {
|
|
5244
5519
|
var queryString;
|
|
5245
|
-
return __generator(this, function (
|
|
5246
|
-
switch (
|
|
5247
|
-
case 0:
|
|
5520
|
+
return __generator(this, function (_c) {
|
|
5521
|
+
switch (_c.label) {
|
|
5522
|
+
case 0:
|
|
5523
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.GetAuthCodeUrl, request.correlationId);
|
|
5524
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5525
|
+
return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
|
|
5248
5526
|
case 1:
|
|
5249
|
-
queryString =
|
|
5527
|
+
queryString = _c.sent();
|
|
5250
5528
|
return [2 /*return*/, UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString)];
|
|
5251
5529
|
}
|
|
5252
5530
|
});
|
|
@@ -5258,32 +5536,35 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5258
5536
|
* @param request
|
|
5259
5537
|
*/
|
|
5260
5538
|
AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
|
|
5261
|
-
var _a, _b, _c;
|
|
5539
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5262
5540
|
return __awaiter(this, void 0, void 0, function () {
|
|
5263
5541
|
var atsMeasurement, reqTimestamp, response, requestId, httpVerAuthority, responseHandler;
|
|
5264
5542
|
var _this = this;
|
|
5265
|
-
return __generator(this, function (
|
|
5266
|
-
switch (
|
|
5543
|
+
return __generator(this, function (_g) {
|
|
5544
|
+
switch (_g.label) {
|
|
5267
5545
|
case 0:
|
|
5268
|
-
|
|
5269
|
-
this.logger.info("in acquireToken call in auth-code client");
|
|
5270
|
-
if (!request || StringUtils.isEmpty(request.code)) {
|
|
5546
|
+
if (!request || !request.code) {
|
|
5271
5547
|
throw ClientAuthError.createTokenRequestCannotBeMadeError();
|
|
5272
5548
|
}
|
|
5549
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientAcquireToken, request.correlationId);
|
|
5550
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement("AuthCodeClientAcquireToken", request.correlationId);
|
|
5551
|
+
this.logger.info("in acquireToken call in auth-code client");
|
|
5273
5552
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5553
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5274
5554
|
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
5275
5555
|
case 1:
|
|
5276
|
-
response =
|
|
5277
|
-
requestId = (
|
|
5278
|
-
httpVerAuthority = (
|
|
5556
|
+
response = _g.sent();
|
|
5557
|
+
requestId = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
5558
|
+
httpVerAuthority = (_e = response.headers) === null || _e === void 0 ? void 0 : _e[exports.HeaderNames.X_MS_HTTP_VERSION];
|
|
5279
5559
|
if (httpVerAuthority) {
|
|
5280
5560
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
5281
5561
|
httpVerAuthority: httpVerAuthority
|
|
5282
5562
|
});
|
|
5283
5563
|
}
|
|
5284
|
-
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5564
|
+
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin, this.performanceClient);
|
|
5285
5565
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
5286
5566
|
responseHandler.validateTokenResponse(response.body);
|
|
5567
|
+
(_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
5287
5568
|
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId).then(function (result) {
|
|
5288
5569
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
5289
5570
|
success: true
|
|
@@ -5345,26 +5626,19 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5345
5626
|
* @param request
|
|
5346
5627
|
*/
|
|
5347
5628
|
AuthorizationCodeClient.prototype.executeTokenRequest = function (authority, request) {
|
|
5629
|
+
var _a, _b;
|
|
5348
5630
|
return __awaiter(this, void 0, void 0, function () {
|
|
5349
|
-
var
|
|
5350
|
-
return __generator(this, function (
|
|
5351
|
-
switch (
|
|
5631
|
+
var queryParametersString, endpoint, requestBody, ccsCredential, clientInfo, headers, thumbprint;
|
|
5632
|
+
return __generator(this, function (_c) {
|
|
5633
|
+
switch (_c.label) {
|
|
5352
5634
|
case 0:
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
claims: request.claims,
|
|
5358
|
-
authenticationScheme: request.authenticationScheme,
|
|
5359
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
5360
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
5361
|
-
shrClaims: request.shrClaims,
|
|
5362
|
-
sshKid: request.sshKid
|
|
5363
|
-
};
|
|
5635
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5636
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5637
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
5638
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
5364
5639
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
5365
5640
|
case 1:
|
|
5366
|
-
requestBody =
|
|
5367
|
-
queryParameters = this.createTokenQueryParameters(request);
|
|
5641
|
+
requestBody = _c.sent();
|
|
5368
5642
|
ccsCredential = undefined;
|
|
5369
5643
|
if (request.clientInfo) {
|
|
5370
5644
|
try {
|
|
@@ -5379,34 +5653,35 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5379
5653
|
}
|
|
5380
5654
|
}
|
|
5381
5655
|
headers = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);
|
|
5382
|
-
|
|
5656
|
+
thumbprint = {
|
|
5657
|
+
clientId: this.config.authOptions.clientId,
|
|
5658
|
+
authority: authority.canonicalAuthority,
|
|
5659
|
+
scopes: request.scopes,
|
|
5660
|
+
claims: request.claims,
|
|
5661
|
+
authenticationScheme: request.authenticationScheme,
|
|
5662
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5663
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5664
|
+
shrClaims: request.shrClaims,
|
|
5665
|
+
sshKid: request.sshKid
|
|
5666
|
+
};
|
|
5383
5667
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
5384
5668
|
}
|
|
5385
5669
|
});
|
|
5386
5670
|
});
|
|
5387
5671
|
};
|
|
5388
|
-
/**
|
|
5389
|
-
* Creates query string for the /token request
|
|
5390
|
-
* @param request
|
|
5391
|
-
*/
|
|
5392
|
-
AuthorizationCodeClient.prototype.createTokenQueryParameters = function (request) {
|
|
5393
|
-
var parameterBuilder = new RequestParameterBuilder();
|
|
5394
|
-
if (request.tokenQueryParameters) {
|
|
5395
|
-
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
5396
|
-
}
|
|
5397
|
-
return parameterBuilder.createQueryString();
|
|
5398
|
-
};
|
|
5399
5672
|
/**
|
|
5400
5673
|
* Generates a map for all the params to be sent to the service
|
|
5401
5674
|
* @param request
|
|
5402
5675
|
*/
|
|
5403
5676
|
AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
|
|
5677
|
+
var _a, _b;
|
|
5404
5678
|
return __awaiter(this, void 0, void 0, function () {
|
|
5405
5679
|
var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
|
|
5406
|
-
var
|
|
5407
|
-
return __generator(this, function (
|
|
5408
|
-
switch (
|
|
5680
|
+
var _c;
|
|
5681
|
+
return __generator(this, function (_d) {
|
|
5682
|
+
switch (_d.label) {
|
|
5409
5683
|
case 0:
|
|
5684
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5410
5685
|
parameterBuilder = new RequestParameterBuilder();
|
|
5411
5686
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5412
5687
|
/*
|
|
@@ -5447,10 +5722,11 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5447
5722
|
parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
|
|
5448
5723
|
parameterBuilder.addClientInfo();
|
|
5449
5724
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
5450
|
-
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5725
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
5726
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5451
5727
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5452
5728
|
case 1:
|
|
5453
|
-
reqCnfData =
|
|
5729
|
+
reqCnfData = _d.sent();
|
|
5454
5730
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
5455
5731
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
5456
5732
|
return [3 /*break*/, 3];
|
|
@@ -5463,7 +5739,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5463
5739
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5464
5740
|
}
|
|
5465
5741
|
}
|
|
5466
|
-
|
|
5742
|
+
_d.label = 3;
|
|
5467
5743
|
case 3:
|
|
5468
5744
|
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
5469
5745
|
parameterBuilder.addCorrelationId(correlationId);
|
|
@@ -5508,9 +5784,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5508
5784
|
}
|
|
5509
5785
|
// Add hybrid spa parameters if not already provided
|
|
5510
5786
|
if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[exports.AADServerParamKeys.RETURN_SPA_CODE])) {
|
|
5511
|
-
parameterBuilder.addExtraQueryParameters((
|
|
5512
|
-
|
|
5513
|
-
|
|
5787
|
+
parameterBuilder.addExtraQueryParameters((_c = {},
|
|
5788
|
+
_c[exports.AADServerParamKeys.RETURN_SPA_CODE] = "1",
|
|
5789
|
+
_c));
|
|
5514
5790
|
}
|
|
5515
5791
|
return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5516
5792
|
}
|
|
@@ -5522,11 +5798,13 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5522
5798
|
* @param request
|
|
5523
5799
|
*/
|
|
5524
5800
|
AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
|
|
5801
|
+
var _a;
|
|
5525
5802
|
return __awaiter(this, void 0, void 0, function () {
|
|
5526
5803
|
var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
|
|
5527
|
-
return __generator(this, function (
|
|
5528
|
-
switch (
|
|
5804
|
+
return __generator(this, function (_b) {
|
|
5805
|
+
switch (_b.label) {
|
|
5529
5806
|
case 0:
|
|
5807
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5530
5808
|
parameterBuilder = new RequestParameterBuilder();
|
|
5531
5809
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5532
5810
|
requestScopes = __spreadArrays(request.scopes || [], request.extraScopesToConsent || []);
|
|
@@ -5637,9 +5915,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5637
5915
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5638
5916
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5639
5917
|
case 1:
|
|
5640
|
-
reqCnfData =
|
|
5918
|
+
reqCnfData = _b.sent();
|
|
5641
5919
|
parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
|
|
5642
|
-
|
|
5920
|
+
_b.label = 2;
|
|
5643
5921
|
case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5644
5922
|
}
|
|
5645
5923
|
});
|
|
@@ -5731,8 +6009,10 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5731
6009
|
*/
|
|
5732
6010
|
DeviceCodeClient.prototype.getDeviceCode = function (request) {
|
|
5733
6011
|
return __awaiter(this, void 0, void 0, function () {
|
|
5734
|
-
var queryString, headers, thumbprint;
|
|
6012
|
+
var queryParametersString, endpoint, queryString, headers, thumbprint;
|
|
5735
6013
|
return __generator(this, function (_a) {
|
|
6014
|
+
queryParametersString = this.createExtraQueryParameters(request);
|
|
6015
|
+
endpoint = UrlString.appendQueryString(this.authority.deviceCodeEndpoint, queryParametersString);
|
|
5736
6016
|
queryString = this.createQueryString(request);
|
|
5737
6017
|
headers = this.createTokenRequestHeaders();
|
|
5738
6018
|
thumbprint = {
|
|
@@ -5746,10 +6026,21 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5746
6026
|
shrClaims: request.shrClaims,
|
|
5747
6027
|
sshKid: request.sshKid
|
|
5748
6028
|
};
|
|
5749
|
-
return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(
|
|
6029
|
+
return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(endpoint, queryString, headers, thumbprint)];
|
|
5750
6030
|
});
|
|
5751
6031
|
});
|
|
5752
6032
|
};
|
|
6033
|
+
/**
|
|
6034
|
+
* Creates query string for the device code request
|
|
6035
|
+
* @param request
|
|
6036
|
+
*/
|
|
6037
|
+
DeviceCodeClient.prototype.createExtraQueryParameters = function (request) {
|
|
6038
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
6039
|
+
if (request.extraQueryParameters) {
|
|
6040
|
+
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
6041
|
+
}
|
|
6042
|
+
return parameterBuilder.createQueryString();
|
|
6043
|
+
};
|
|
5753
6044
|
/**
|
|
5754
6045
|
* Executes POST request to device code endpoint
|
|
5755
6046
|
* @param deviceCodeEndpoint
|
|
@@ -5763,8 +6054,7 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5763
6054
|
switch (_b.label) {
|
|
5764
6055
|
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, deviceCodeEndpoint, {
|
|
5765
6056
|
body: queryString,
|
|
5766
|
-
headers: headers
|
|
5767
|
-
proxyUrl: this.config.systemOptions.proxyUrl
|
|
6057
|
+
headers: headers
|
|
5768
6058
|
})];
|
|
5769
6059
|
case 1:
|
|
5770
6060
|
_a = (_b.sent()).body, userCode = _a.user_code, deviceCode = _a.device_code, verificationUri = _a.verification_uri, expiresIn = _a.expires_in, interval = _a.interval, message = _a.message;
|
|
@@ -5787,6 +6077,9 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5787
6077
|
var parameterBuilder = new RequestParameterBuilder();
|
|
5788
6078
|
parameterBuilder.addScopes(request.scopes);
|
|
5789
6079
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6080
|
+
if (request.extraQueryParameters) {
|
|
6081
|
+
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
6082
|
+
}
|
|
5790
6083
|
if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5791
6084
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5792
6085
|
}
|
|
@@ -5823,216 +6116,88 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5823
6116
|
*/
|
|
5824
6117
|
DeviceCodeClient.prototype.acquireTokenWithDeviceCode = function (request, deviceCodeResponse) {
|
|
5825
6118
|
return __awaiter(this, void 0, void 0, function () {
|
|
5826
|
-
var requestBody, headers, userSpecifiedTimeout, deviceCodeExpirationTime, pollingIntervalMilli, thumbprint, response;
|
|
6119
|
+
var queryParametersString, endpoint, requestBody, headers, userSpecifiedTimeout, deviceCodeExpirationTime, pollingIntervalMilli, thumbprint, response;
|
|
5827
6120
|
return __generator(this, function (_a) {
|
|
5828
6121
|
switch (_a.label) {
|
|
5829
6122
|
case 0:
|
|
6123
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6124
|
+
endpoint = UrlString.appendQueryString(this.authority.tokenEndpoint, queryParametersString);
|
|
5830
6125
|
requestBody = this.createTokenRequestBody(request, deviceCodeResponse);
|
|
5831
6126
|
headers = this.createTokenRequestHeaders();
|
|
5832
|
-
userSpecifiedTimeout = request.timeout ? TimeUtils.nowSeconds() + request.timeout : undefined;
|
|
5833
|
-
deviceCodeExpirationTime = TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;
|
|
5834
|
-
pollingIntervalMilli = deviceCodeResponse.interval * 1000;
|
|
5835
|
-
_a.label = 1;
|
|
5836
|
-
case 1:
|
|
5837
|
-
if (!this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) return [3 /*break*/, 8];
|
|
5838
|
-
thumbprint = {
|
|
5839
|
-
clientId: this.config.authOptions.clientId,
|
|
5840
|
-
authority: request.authority,
|
|
5841
|
-
scopes: request.scopes,
|
|
5842
|
-
claims: request.claims,
|
|
5843
|
-
authenticationScheme: request.authenticationScheme,
|
|
5844
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
5845
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
5846
|
-
shrClaims: request.shrClaims,
|
|
5847
|
-
sshKid: request.sshKid
|
|
5848
|
-
};
|
|
5849
|
-
return [4 /*yield*/, this.executePostToTokenEndpoint(
|
|
5850
|
-
case 2:
|
|
5851
|
-
response = _a.sent();
|
|
5852
|
-
if (!(response.body && response.body.error)) return [3 /*break*/, 6];
|
|
5853
|
-
if (!(response.body.error === Constants.AUTHORIZATION_PENDING)) return [3 /*break*/, 4];
|
|
5854
|
-
this.logger.info("Authorization pending. Continue polling.");
|
|
5855
|
-
return [4 /*yield*/, TimeUtils.delay(pollingIntervalMilli)];
|
|
5856
|
-
case 3:
|
|
5857
|
-
_a.sent();
|
|
5858
|
-
return [3 /*break*/, 5];
|
|
5859
|
-
case 4:
|
|
5860
|
-
// for any other error, throw
|
|
5861
|
-
this.logger.info("Unexpected error in polling from the server");
|
|
5862
|
-
throw ServerError.createPostRequestFailed(response.body.error);
|
|
5863
|
-
case 5: return [3 /*break*/, 7];
|
|
5864
|
-
case 6:
|
|
5865
|
-
this.logger.verbose("Authorization completed successfully. Polling stopped.");
|
|
5866
|
-
return [2 /*return*/, response.body];
|
|
5867
|
-
case 7: return [3 /*break*/, 1];
|
|
5868
|
-
case 8:
|
|
5869
|
-
/*
|
|
5870
|
-
* The above code should've thrown by this point, but to satisfy TypeScript,
|
|
5871
|
-
* and in the rare case the conditionals in continuePolling() may not catch everything...
|
|
5872
|
-
*/
|
|
5873
|
-
this.logger.error("Polling stopped for unknown reasons.");
|
|
5874
|
-
throw ClientAuthError.createDeviceCodeUnknownError();
|
|
5875
|
-
}
|
|
5876
|
-
});
|
|
5877
|
-
});
|
|
5878
|
-
};
|
|
5879
|
-
/**
|
|
5880
|
-
* Creates query parameters and converts to string.
|
|
5881
|
-
* @param request
|
|
5882
|
-
* @param deviceCodeResponse
|
|
5883
|
-
*/
|
|
5884
|
-
DeviceCodeClient.prototype.createTokenRequestBody = function (request, deviceCodeResponse) {
|
|
5885
|
-
var requestParameters = new RequestParameterBuilder();
|
|
5886
|
-
requestParameters.addScopes(request.scopes);
|
|
5887
|
-
requestParameters.addClientId(this.config.authOptions.clientId);
|
|
5888
|
-
requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);
|
|
5889
|
-
requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);
|
|
5890
|
-
var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
5891
|
-
requestParameters.addCorrelationId(correlationId);
|
|
5892
|
-
requestParameters.addClientInfo();
|
|
5893
|
-
requestParameters.addLibraryInfo(this.config.libraryInfo);
|
|
5894
|
-
requestParameters.addApplicationTelemetry(this.config.telemetry.application);
|
|
5895
|
-
requestParameters.addThrottling();
|
|
5896
|
-
if (this.serverTelemetryManager) {
|
|
5897
|
-
requestParameters.addServerTelemetry(this.serverTelemetryManager);
|
|
5898
|
-
}
|
|
5899
|
-
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5900
|
-
requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5901
|
-
}
|
|
5902
|
-
return requestParameters.createQueryString();
|
|
5903
|
-
};
|
|
5904
|
-
return DeviceCodeClient;
|
|
5905
|
-
}(BaseClient));
|
|
5906
|
-
|
|
5907
|
-
/*
|
|
5908
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5909
|
-
* Licensed under the MIT License.
|
|
5910
|
-
*/
|
|
5911
|
-
/**
|
|
5912
|
-
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
5913
|
-
*
|
|
5914
|
-
* @export
|
|
5915
|
-
* @enum {number}
|
|
5916
|
-
*/
|
|
5917
|
-
exports.PerformanceEvents = void 0;
|
|
5918
|
-
(function (PerformanceEvents) {
|
|
5919
|
-
/**
|
|
5920
|
-
* acquireTokenByCode API (msal-browser and msal-node).
|
|
5921
|
-
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
5922
|
-
*/
|
|
5923
|
-
PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
|
|
5924
|
-
/**
|
|
5925
|
-
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
5926
|
-
* Used to renew an access token using a refresh token against the token endpoint.
|
|
5927
|
-
*/
|
|
5928
|
-
PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
|
|
5929
|
-
/**
|
|
5930
|
-
* acquireTokenSilent API (msal-browser and msal-node).
|
|
5931
|
-
* Used to silently acquire a new access token (from the cache or the network).
|
|
5932
|
-
*/
|
|
5933
|
-
PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
|
|
5934
|
-
/**
|
|
5935
|
-
* acquireTokenSilentAsync (msal-browser).
|
|
5936
|
-
* Internal API for acquireTokenSilent.
|
|
5937
|
-
*/
|
|
5938
|
-
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
5939
|
-
/**
|
|
5940
|
-
* acquireTokenPopup (msal-browser).
|
|
5941
|
-
* Used to acquire a new access token interactively through pop ups
|
|
5942
|
-
*/
|
|
5943
|
-
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
5944
|
-
/**
|
|
5945
|
-
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
5946
|
-
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
5947
|
-
*/
|
|
5948
|
-
PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
|
|
5949
|
-
/**
|
|
5950
|
-
* signJwt API in CryptoOpts class (msal-browser).
|
|
5951
|
-
* Used to signed a pop token.
|
|
5952
|
-
*/
|
|
5953
|
-
PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
|
|
5954
|
-
/**
|
|
5955
|
-
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
5956
|
-
* Used to read access tokens from the cache.
|
|
5957
|
-
*/
|
|
5958
|
-
PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
|
|
5959
|
-
/**
|
|
5960
|
-
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
5961
|
-
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
5962
|
-
*/
|
|
5963
|
-
PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
|
|
5964
|
-
/**
|
|
5965
|
-
* acquireToken API in SilentRereshClient (msal-browser).
|
|
5966
|
-
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
5967
|
-
*/
|
|
5968
|
-
PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
|
|
5969
|
-
/**
|
|
5970
|
-
* ssoSilent API (msal-browser).
|
|
5971
|
-
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
5972
|
-
*/
|
|
5973
|
-
PerformanceEvents["SsoSilent"] = "ssoSilent";
|
|
5974
|
-
/**
|
|
5975
|
-
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
5976
|
-
* Used to load authority metadata for a request.
|
|
5977
|
-
*/
|
|
5978
|
-
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
5979
|
-
/**
|
|
5980
|
-
* acquireToken APIs in msal-browser.
|
|
5981
|
-
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
5982
|
-
*/
|
|
5983
|
-
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
5984
|
-
/**
|
|
5985
|
-
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
5986
|
-
* Used to acquire a token from Native component when native brokering is enabled.
|
|
5987
|
-
*/
|
|
5988
|
-
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
5989
|
-
/**
|
|
5990
|
-
* Time spent creating default headers for requests to token endpoint
|
|
5991
|
-
*/
|
|
5992
|
-
PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
|
|
5993
|
-
/**
|
|
5994
|
-
* Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
|
|
5995
|
-
*/
|
|
5996
|
-
PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
|
|
5997
|
-
/**
|
|
5998
|
-
* acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
|
|
5999
|
-
*/
|
|
6000
|
-
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
6001
|
-
/**
|
|
6002
|
-
* Time taken for token acquisition by broker
|
|
6003
|
-
*/
|
|
6004
|
-
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
6005
|
-
/**
|
|
6006
|
-
* Time spent on the network for refresh token acquisition
|
|
6007
|
-
*/
|
|
6008
|
-
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
6009
|
-
/**
|
|
6010
|
-
* Time taken for acquiring refresh token , records RT size
|
|
6011
|
-
*/
|
|
6012
|
-
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
6127
|
+
userSpecifiedTimeout = request.timeout ? TimeUtils.nowSeconds() + request.timeout : undefined;
|
|
6128
|
+
deviceCodeExpirationTime = TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;
|
|
6129
|
+
pollingIntervalMilli = deviceCodeResponse.interval * 1000;
|
|
6130
|
+
_a.label = 1;
|
|
6131
|
+
case 1:
|
|
6132
|
+
if (!this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) return [3 /*break*/, 8];
|
|
6133
|
+
thumbprint = {
|
|
6134
|
+
clientId: this.config.authOptions.clientId,
|
|
6135
|
+
authority: request.authority,
|
|
6136
|
+
scopes: request.scopes,
|
|
6137
|
+
claims: request.claims,
|
|
6138
|
+
authenticationScheme: request.authenticationScheme,
|
|
6139
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
6140
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
6141
|
+
shrClaims: request.shrClaims,
|
|
6142
|
+
sshKid: request.sshKid
|
|
6143
|
+
};
|
|
6144
|
+
return [4 /*yield*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
6145
|
+
case 2:
|
|
6146
|
+
response = _a.sent();
|
|
6147
|
+
if (!(response.body && response.body.error)) return [3 /*break*/, 6];
|
|
6148
|
+
if (!(response.body.error === Constants.AUTHORIZATION_PENDING)) return [3 /*break*/, 4];
|
|
6149
|
+
this.logger.info("Authorization pending. Continue polling.");
|
|
6150
|
+
return [4 /*yield*/, TimeUtils.delay(pollingIntervalMilli)];
|
|
6151
|
+
case 3:
|
|
6152
|
+
_a.sent();
|
|
6153
|
+
return [3 /*break*/, 5];
|
|
6154
|
+
case 4:
|
|
6155
|
+
// for any other error, throw
|
|
6156
|
+
this.logger.info("Unexpected error in polling from the server");
|
|
6157
|
+
throw ServerError.createPostRequestFailed(response.body.error);
|
|
6158
|
+
case 5: return [3 /*break*/, 7];
|
|
6159
|
+
case 6:
|
|
6160
|
+
this.logger.verbose("Authorization completed successfully. Polling stopped.");
|
|
6161
|
+
return [2 /*return*/, response.body];
|
|
6162
|
+
case 7: return [3 /*break*/, 1];
|
|
6163
|
+
case 8:
|
|
6164
|
+
/*
|
|
6165
|
+
* The above code should've thrown by this point, but to satisfy TypeScript,
|
|
6166
|
+
* and in the rare case the conditionals in continuePolling() may not catch everything...
|
|
6167
|
+
*/
|
|
6168
|
+
this.logger.error("Polling stopped for unknown reasons.");
|
|
6169
|
+
throw ClientAuthError.createDeviceCodeUnknownError();
|
|
6170
|
+
}
|
|
6171
|
+
});
|
|
6172
|
+
});
|
|
6173
|
+
};
|
|
6013
6174
|
/**
|
|
6014
|
-
*
|
|
6175
|
+
* Creates query parameters and converts to string.
|
|
6176
|
+
* @param request
|
|
6177
|
+
* @param deviceCodeResponse
|
|
6015
6178
|
*/
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
}
|
|
6179
|
+
DeviceCodeClient.prototype.createTokenRequestBody = function (request, deviceCodeResponse) {
|
|
6180
|
+
var requestParameters = new RequestParameterBuilder();
|
|
6181
|
+
requestParameters.addScopes(request.scopes);
|
|
6182
|
+
requestParameters.addClientId(this.config.authOptions.clientId);
|
|
6183
|
+
requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);
|
|
6184
|
+
requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);
|
|
6185
|
+
var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
6186
|
+
requestParameters.addCorrelationId(correlationId);
|
|
6187
|
+
requestParameters.addClientInfo();
|
|
6188
|
+
requestParameters.addLibraryInfo(this.config.libraryInfo);
|
|
6189
|
+
requestParameters.addApplicationTelemetry(this.config.telemetry.application);
|
|
6190
|
+
requestParameters.addThrottling();
|
|
6191
|
+
if (this.serverTelemetryManager) {
|
|
6192
|
+
requestParameters.addServerTelemetry(this.serverTelemetryManager);
|
|
6193
|
+
}
|
|
6194
|
+
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
6195
|
+
requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
6196
|
+
}
|
|
6197
|
+
return requestParameters.createQueryString();
|
|
6198
|
+
};
|
|
6199
|
+
return DeviceCodeClient;
|
|
6200
|
+
}(BaseClient));
|
|
6036
6201
|
|
|
6037
6202
|
/*
|
|
6038
6203
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6047,31 +6212,34 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6047
6212
|
return _super.call(this, configuration, performanceClient) || this;
|
|
6048
6213
|
}
|
|
6049
6214
|
RefreshTokenClient.prototype.acquireToken = function (request) {
|
|
6050
|
-
var _a, _b, _c, _d;
|
|
6215
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6051
6216
|
return __awaiter(this, void 0, void 0, function () {
|
|
6052
6217
|
var atsMeasurement, reqTimestamp, response, httpVerToken, requestId, responseHandler;
|
|
6053
6218
|
var _this = this;
|
|
6054
|
-
return __generator(this, function (
|
|
6055
|
-
switch (
|
|
6219
|
+
return __generator(this, function (_h) {
|
|
6220
|
+
switch (_h.label) {
|
|
6056
6221
|
case 0:
|
|
6057
|
-
|
|
6222
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6223
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6058
6224
|
this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
|
|
6059
6225
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6226
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6060
6227
|
return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
6061
6228
|
case 1:
|
|
6062
|
-
response =
|
|
6063
|
-
httpVerToken = (
|
|
6229
|
+
response = _h.sent();
|
|
6230
|
+
httpVerToken = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[exports.HeaderNames.X_MS_HTTP_VERSION];
|
|
6064
6231
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
6065
|
-
refreshTokenSize: ((
|
|
6232
|
+
refreshTokenSize: ((_e = response.body.refresh_token) === null || _e === void 0 ? void 0 : _e.length) || 0,
|
|
6066
6233
|
});
|
|
6067
6234
|
if (httpVerToken) {
|
|
6068
6235
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
6069
6236
|
httpVerToken: httpVerToken,
|
|
6070
6237
|
});
|
|
6071
6238
|
}
|
|
6072
|
-
requestId = (
|
|
6239
|
+
requestId = (_f = response.headers) === null || _f === void 0 ? void 0 : _f[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
6073
6240
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
6074
6241
|
responseHandler.validateTokenResponse(response.body);
|
|
6242
|
+
(_g = this.performanceClient) === null || _g === void 0 ? void 0 : _g.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
6075
6243
|
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
|
|
6076
6244
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6077
6245
|
success: true
|
|
@@ -6096,13 +6264,15 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6096
6264
|
* @param request
|
|
6097
6265
|
*/
|
|
6098
6266
|
RefreshTokenClient.prototype.acquireTokenByRefreshToken = function (request) {
|
|
6267
|
+
var _a, _b, _c, _d;
|
|
6099
6268
|
return __awaiter(this, void 0, void 0, function () {
|
|
6100
6269
|
var isFOCI, noFamilyRTInCache, clientMismatchErrorWithFamilyRT;
|
|
6101
|
-
return __generator(this, function (
|
|
6270
|
+
return __generator(this, function (_e) {
|
|
6102
6271
|
// Cannot renew token if no request object is given.
|
|
6103
6272
|
if (!request) {
|
|
6104
6273
|
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
6105
6274
|
}
|
|
6275
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
|
|
6106
6276
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
6107
6277
|
if (!request.account) {
|
|
6108
6278
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -6111,6 +6281,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6111
6281
|
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
6112
6282
|
if (isFOCI) {
|
|
6113
6283
|
try {
|
|
6284
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6114
6285
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
|
|
6115
6286
|
}
|
|
6116
6287
|
catch (e) {
|
|
@@ -6118,6 +6289,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6118
6289
|
clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
|
|
6119
6290
|
// if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
|
|
6120
6291
|
if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
|
|
6292
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6121
6293
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
|
|
6122
6294
|
// throw in all other cases
|
|
6123
6295
|
}
|
|
@@ -6127,6 +6299,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6127
6299
|
}
|
|
6128
6300
|
}
|
|
6129
6301
|
// fall back to application refresh token acquisition
|
|
6302
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6130
6303
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
|
|
6131
6304
|
});
|
|
6132
6305
|
});
|
|
@@ -6136,11 +6309,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6136
6309
|
* @param request
|
|
6137
6310
|
*/
|
|
6138
6311
|
RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
|
|
6139
|
-
var _a;
|
|
6312
|
+
var _a, _b, _c;
|
|
6140
6313
|
return __awaiter(this, void 0, void 0, function () {
|
|
6141
6314
|
var atsMeasurement, refreshToken, refreshTokenRequest;
|
|
6142
|
-
return __generator(this, function (
|
|
6143
|
-
|
|
6315
|
+
return __generator(this, function (_d) {
|
|
6316
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6317
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6144
6318
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6145
6319
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
6146
6320
|
if (!refreshToken) {
|
|
@@ -6155,6 +6329,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6155
6329
|
credential: request.account.homeAccountId,
|
|
6156
6330
|
type: exports.CcsCredentialType.HOME_ACCOUNT_ID
|
|
6157
6331
|
} });
|
|
6332
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6158
6333
|
return [2 /*return*/, this.acquireToken(refreshTokenRequest)];
|
|
6159
6334
|
});
|
|
6160
6335
|
});
|
|
@@ -6165,17 +6340,20 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6165
6340
|
* @param authority
|
|
6166
6341
|
*/
|
|
6167
6342
|
RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
|
|
6168
|
-
var _a;
|
|
6343
|
+
var _a, _b, _c;
|
|
6169
6344
|
return __awaiter(this, void 0, void 0, function () {
|
|
6170
|
-
var acquireTokenMeasurement,
|
|
6171
|
-
return __generator(this, function (
|
|
6172
|
-
switch (
|
|
6345
|
+
var acquireTokenMeasurement, queryParametersString, endpoint, requestBody, headers, thumbprint;
|
|
6346
|
+
return __generator(this, function (_d) {
|
|
6347
|
+
switch (_d.label) {
|
|
6173
6348
|
case 0:
|
|
6174
|
-
|
|
6349
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6350
|
+
acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6351
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6352
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6353
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6175
6354
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
6176
6355
|
case 1:
|
|
6177
|
-
requestBody =
|
|
6178
|
-
queryParameters = this.createTokenQueryParameters(request);
|
|
6356
|
+
requestBody = _d.sent();
|
|
6179
6357
|
headers = this.createTokenRequestHeaders(request.ccsCredential);
|
|
6180
6358
|
thumbprint = {
|
|
6181
6359
|
clientId: this.config.authOptions.clientId,
|
|
@@ -6188,7 +6366,6 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6188
6366
|
shrClaims: request.shrClaims,
|
|
6189
6367
|
sshKid: request.sshKid
|
|
6190
6368
|
};
|
|
6191
|
-
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
|
|
6192
6369
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6193
6370
|
.then(function (result) {
|
|
6194
6371
|
acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
|
|
@@ -6206,30 +6383,20 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6206
6383
|
});
|
|
6207
6384
|
});
|
|
6208
6385
|
};
|
|
6209
|
-
/**
|
|
6210
|
-
* Creates query string for the /token request
|
|
6211
|
-
* @param request
|
|
6212
|
-
*/
|
|
6213
|
-
RefreshTokenClient.prototype.createTokenQueryParameters = function (request) {
|
|
6214
|
-
var parameterBuilder = new RequestParameterBuilder();
|
|
6215
|
-
if (request.tokenQueryParameters) {
|
|
6216
|
-
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
6217
|
-
}
|
|
6218
|
-
return parameterBuilder.createQueryString();
|
|
6219
|
-
};
|
|
6220
6386
|
/**
|
|
6221
6387
|
* Helper function to create the token request body
|
|
6222
6388
|
* @param request
|
|
6223
6389
|
*/
|
|
6224
6390
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
6225
|
-
var _a;
|
|
6391
|
+
var _a, _b, _c;
|
|
6226
6392
|
return __awaiter(this, void 0, void 0, function () {
|
|
6227
6393
|
var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
|
|
6228
|
-
return __generator(this, function (
|
|
6229
|
-
switch (
|
|
6394
|
+
return __generator(this, function (_d) {
|
|
6395
|
+
switch (_d.label) {
|
|
6230
6396
|
case 0:
|
|
6397
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6231
6398
|
correlationId = request.correlationId;
|
|
6232
|
-
acquireTokenMeasurement = (
|
|
6399
|
+
acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6233
6400
|
parameterBuilder = new RequestParameterBuilder();
|
|
6234
6401
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6235
6402
|
parameterBuilder.addScopes(request.scopes);
|
|
@@ -6252,10 +6419,11 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6252
6419
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
6253
6420
|
}
|
|
6254
6421
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
6255
|
-
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
6422
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
6423
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
6256
6424
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
6257
6425
|
case 1:
|
|
6258
|
-
reqCnfData =
|
|
6426
|
+
reqCnfData = _d.sent();
|
|
6259
6427
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
6260
6428
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
6261
6429
|
return [3 /*break*/, 3];
|
|
@@ -6271,7 +6439,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6271
6439
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
6272
6440
|
}
|
|
6273
6441
|
}
|
|
6274
|
-
|
|
6442
|
+
_d.label = 3;
|
|
6275
6443
|
case 3:
|
|
6276
6444
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
6277
6445
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
@@ -6403,7 +6571,7 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6403
6571
|
*/
|
|
6404
6572
|
ClientCredentialClient.prototype.executeTokenRequest = function (request, authority) {
|
|
6405
6573
|
return __awaiter(this, void 0, void 0, function () {
|
|
6406
|
-
var serverTokenResponse, reqTimestamp, appTokenPropviderParameters, appTokenProviderResult, requestBody, headers, thumbprint, response, responseHandler, tokenResponse;
|
|
6574
|
+
var serverTokenResponse, reqTimestamp, appTokenPropviderParameters, appTokenProviderResult, queryParametersString, endpoint, requestBody, headers, thumbprint, response, responseHandler, tokenResponse;
|
|
6407
6575
|
return __generator(this, function (_a) {
|
|
6408
6576
|
switch (_a.label) {
|
|
6409
6577
|
case 0:
|
|
@@ -6427,6 +6595,8 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6427
6595
|
};
|
|
6428
6596
|
return [3 /*break*/, 4];
|
|
6429
6597
|
case 2:
|
|
6598
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6599
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6430
6600
|
requestBody = this.createTokenRequestBody(request);
|
|
6431
6601
|
headers = this.createTokenRequestHeaders();
|
|
6432
6602
|
thumbprint = {
|
|
@@ -6441,7 +6611,7 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6441
6611
|
sshKid: request.sshKid
|
|
6442
6612
|
};
|
|
6443
6613
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6444
|
-
return [4 /*yield*/, this.executePostToTokenEndpoint(
|
|
6614
|
+
return [4 /*yield*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
6445
6615
|
case 3:
|
|
6446
6616
|
response = _a.sent();
|
|
6447
6617
|
serverTokenResponse = response.body;
|
|
@@ -6657,10 +6827,12 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
6657
6827
|
*/
|
|
6658
6828
|
OnBehalfOfClient.prototype.executeTokenRequest = function (request, authority, userAssertionHash) {
|
|
6659
6829
|
return __awaiter(this, void 0, void 0, function () {
|
|
6660
|
-
var requestBody, headers, thumbprint, reqTimestamp, response, responseHandler, tokenResponse;
|
|
6830
|
+
var queryParametersString, endpoint, requestBody, headers, thumbprint, reqTimestamp, response, responseHandler, tokenResponse;
|
|
6661
6831
|
return __generator(this, function (_a) {
|
|
6662
6832
|
switch (_a.label) {
|
|
6663
6833
|
case 0:
|
|
6834
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6835
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6664
6836
|
requestBody = this.createTokenRequestBody(request);
|
|
6665
6837
|
headers = this.createTokenRequestHeaders();
|
|
6666
6838
|
thumbprint = {
|
|
@@ -6675,7 +6847,7 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
6675
6847
|
sshKid: request.sshKid
|
|
6676
6848
|
};
|
|
6677
6849
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6678
|
-
return [4 /*yield*/, this.executePostToTokenEndpoint(
|
|
6850
|
+
return [4 /*yield*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
6679
6851
|
case 1:
|
|
6680
6852
|
response = _a.sent();
|
|
6681
6853
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
@@ -6897,8 +7069,15 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6897
7069
|
*/
|
|
6898
7070
|
UsernamePasswordClient.prototype.executeTokenRequest = function (authority, request) {
|
|
6899
7071
|
return __awaiter(this, void 0, void 0, function () {
|
|
6900
|
-
var
|
|
7072
|
+
var queryParametersString, endpoint, requestBody, headers, thumbprint;
|
|
6901
7073
|
return __generator(this, function (_a) {
|
|
7074
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
7075
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
7076
|
+
requestBody = this.createTokenRequestBody(request);
|
|
7077
|
+
headers = this.createTokenRequestHeaders({
|
|
7078
|
+
credential: request.username,
|
|
7079
|
+
type: exports.CcsCredentialType.UPN
|
|
7080
|
+
});
|
|
6902
7081
|
thumbprint = {
|
|
6903
7082
|
clientId: this.config.authOptions.clientId,
|
|
6904
7083
|
authority: authority.canonicalAuthority,
|
|
@@ -6910,12 +7089,7 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6910
7089
|
shrClaims: request.shrClaims,
|
|
6911
7090
|
sshKid: request.sshKid
|
|
6912
7091
|
};
|
|
6913
|
-
|
|
6914
|
-
headers = this.createTokenRequestHeaders({
|
|
6915
|
-
credential: request.username,
|
|
6916
|
-
type: exports.CcsCredentialType.UPN
|
|
6917
|
-
});
|
|
6918
|
-
return [2 /*return*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
7092
|
+
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
6919
7093
|
});
|
|
6920
7094
|
});
|
|
6921
7095
|
};
|
|
@@ -7089,61 +7263,65 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
7089
7263
|
* Licensed under the MIT License.
|
|
7090
7264
|
*/
|
|
7091
7265
|
var RegionDiscovery = /** @class */ (function () {
|
|
7092
|
-
function RegionDiscovery(networkInterface) {
|
|
7266
|
+
function RegionDiscovery(networkInterface, performanceClient, correlationId) {
|
|
7093
7267
|
this.networkInterface = networkInterface;
|
|
7268
|
+
this.performanceClient = performanceClient;
|
|
7269
|
+
this.correlationId = correlationId;
|
|
7094
7270
|
}
|
|
7095
7271
|
/**
|
|
7096
7272
|
* Detect the region from the application's environment.
|
|
7097
7273
|
*
|
|
7098
7274
|
* @returns Promise<string | null>
|
|
7099
7275
|
*/
|
|
7100
|
-
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata
|
|
7276
|
+
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
|
|
7277
|
+
var _a, _b, _c, _d;
|
|
7101
7278
|
return __awaiter(this, void 0, void 0, function () {
|
|
7102
7279
|
var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
|
|
7103
|
-
return __generator(this, function (
|
|
7104
|
-
switch (
|
|
7280
|
+
return __generator(this, function (_e) {
|
|
7281
|
+
switch (_e.label) {
|
|
7105
7282
|
case 0:
|
|
7283
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7106
7284
|
autodetectedRegionName = environmentRegion;
|
|
7107
7285
|
if (!!autodetectedRegionName) return [3 /*break*/, 8];
|
|
7108
7286
|
options = RegionDiscovery.IMDS_OPTIONS;
|
|
7109
|
-
|
|
7110
|
-
options.proxyUrl = proxyUrl;
|
|
7111
|
-
}
|
|
7112
|
-
_a.label = 1;
|
|
7287
|
+
_e.label = 1;
|
|
7113
7288
|
case 1:
|
|
7114
|
-
|
|
7289
|
+
_e.trys.push([1, 6, , 7]);
|
|
7290
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7115
7291
|
return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
|
|
7116
7292
|
case 2:
|
|
7117
|
-
localIMDSVersionResponse =
|
|
7293
|
+
localIMDSVersionResponse = _e.sent();
|
|
7118
7294
|
if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
7119
7295
|
autodetectedRegionName = localIMDSVersionResponse.body;
|
|
7120
7296
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
|
|
7121
7297
|
}
|
|
7122
7298
|
if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
|
|
7299
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
7123
7300
|
return [4 /*yield*/, this.getCurrentVersion(options)];
|
|
7124
7301
|
case 3:
|
|
7125
|
-
currentIMDSVersion =
|
|
7302
|
+
currentIMDSVersion = _e.sent();
|
|
7126
7303
|
if (!currentIMDSVersion) {
|
|
7127
7304
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
7128
7305
|
return [2 /*return*/, null];
|
|
7129
7306
|
}
|
|
7307
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7130
7308
|
return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
|
|
7131
7309
|
case 4:
|
|
7132
|
-
currentIMDSVersionResponse =
|
|
7310
|
+
currentIMDSVersionResponse = _e.sent();
|
|
7133
7311
|
if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
7134
7312
|
autodetectedRegionName = currentIMDSVersionResponse.body;
|
|
7135
7313
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
|
|
7136
7314
|
}
|
|
7137
|
-
|
|
7315
|
+
_e.label = 5;
|
|
7138
7316
|
case 5: return [3 /*break*/, 7];
|
|
7139
7317
|
case 6:
|
|
7140
|
-
|
|
7318
|
+
_e.sent();
|
|
7141
7319
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
7142
7320
|
return [2 /*return*/, null];
|
|
7143
7321
|
case 7: return [3 /*break*/, 9];
|
|
7144
7322
|
case 8:
|
|
7145
7323
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.ENVIRONMENT_VARIABLE;
|
|
7146
|
-
|
|
7324
|
+
_e.label = 9;
|
|
7147
7325
|
case 9:
|
|
7148
7326
|
// If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
|
|
7149
7327
|
if (!autodetectedRegionName) {
|
|
@@ -7161,8 +7339,10 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
7161
7339
|
* @returns Promise<NetworkResponse<string>>
|
|
7162
7340
|
*/
|
|
7163
7341
|
RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
|
|
7342
|
+
var _a;
|
|
7164
7343
|
return __awaiter(this, void 0, void 0, function () {
|
|
7165
|
-
return __generator(this, function (
|
|
7344
|
+
return __generator(this, function (_b) {
|
|
7345
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7166
7346
|
return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
|
|
7167
7347
|
});
|
|
7168
7348
|
});
|
|
@@ -7173,24 +7353,28 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
7173
7353
|
* @returns Promise<string | null>
|
|
7174
7354
|
*/
|
|
7175
7355
|
RegionDiscovery.prototype.getCurrentVersion = function (options) {
|
|
7356
|
+
var _a;
|
|
7176
7357
|
return __awaiter(this, void 0, void 0, function () {
|
|
7177
7358
|
var response;
|
|
7178
|
-
return __generator(this, function (
|
|
7179
|
-
switch (
|
|
7359
|
+
return __generator(this, function (_b) {
|
|
7360
|
+
switch (_b.label) {
|
|
7180
7361
|
case 0:
|
|
7181
|
-
_a.
|
|
7182
|
-
|
|
7362
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
7363
|
+
_b.label = 1;
|
|
7183
7364
|
case 1:
|
|
7184
|
-
|
|
7365
|
+
_b.trys.push([1, 3, , 4]);
|
|
7366
|
+
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
|
|
7367
|
+
case 2:
|
|
7368
|
+
response = _b.sent();
|
|
7185
7369
|
// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
|
|
7186
7370
|
if (response.status === ResponseCodes.httpBadRequest && response.body && response.body["newest-versions"] && response.body["newest-versions"].length > 0) {
|
|
7187
7371
|
return [2 /*return*/, response.body["newest-versions"][0]];
|
|
7188
7372
|
}
|
|
7189
7373
|
return [2 /*return*/, null];
|
|
7190
|
-
case
|
|
7191
|
-
|
|
7374
|
+
case 3:
|
|
7375
|
+
_b.sent();
|
|
7192
7376
|
return [2 /*return*/, null];
|
|
7193
|
-
case
|
|
7377
|
+
case 4: return [2 /*return*/];
|
|
7194
7378
|
}
|
|
7195
7379
|
});
|
|
7196
7380
|
});
|
|
@@ -7213,16 +7397,17 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
7213
7397
|
* endpoint. It will store the pertinent config data in this object for use during token calls.
|
|
7214
7398
|
*/
|
|
7215
7399
|
var Authority = /** @class */ (function () {
|
|
7216
|
-
function Authority(authority, networkInterface, cacheManager, authorityOptions, logger,
|
|
7400
|
+
function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7217
7401
|
this.canonicalAuthority = authority;
|
|
7218
7402
|
this._canonicalAuthority.validateAsUri();
|
|
7219
7403
|
this.networkInterface = networkInterface;
|
|
7220
7404
|
this.cacheManager = cacheManager;
|
|
7221
7405
|
this.authorityOptions = authorityOptions;
|
|
7222
|
-
this.regionDiscovery = new RegionDiscovery(networkInterface);
|
|
7223
7406
|
this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
|
|
7224
|
-
this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
|
|
7225
7407
|
this.logger = logger;
|
|
7408
|
+
this.performanceClient = performanceClient;
|
|
7409
|
+
this.correlationId = correlationId;
|
|
7410
|
+
this.regionDiscovery = new RegionDiscovery(networkInterface, this.performanceClient, this.correlationId);
|
|
7226
7411
|
}
|
|
7227
7412
|
Object.defineProperty(Authority.prototype, "authorityType", {
|
|
7228
7413
|
// See above for AuthorityType
|
|
@@ -7459,23 +7644,27 @@ var Authority = /** @class */ (function () {
|
|
|
7459
7644
|
* and the /authorize, /token and logout endpoints.
|
|
7460
7645
|
*/
|
|
7461
7646
|
Authority.prototype.resolveEndpointsAsync = function () {
|
|
7647
|
+
var _a, _b, _c;
|
|
7462
7648
|
return __awaiter(this, void 0, void 0, function () {
|
|
7463
7649
|
var metadataEntity, cloudDiscoverySource, endpointSource, cacheKey;
|
|
7464
|
-
return __generator(this, function (
|
|
7465
|
-
switch (
|
|
7650
|
+
return __generator(this, function (_d) {
|
|
7651
|
+
switch (_d.label) {
|
|
7466
7652
|
case 0:
|
|
7653
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, this.correlationId);
|
|
7467
7654
|
metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
|
|
7468
7655
|
if (!metadataEntity) {
|
|
7469
7656
|
metadataEntity = new AuthorityMetadataEntity();
|
|
7470
7657
|
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
7471
7658
|
}
|
|
7659
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7472
7660
|
return [4 /*yield*/, this.updateCloudDiscoveryMetadata(metadataEntity)];
|
|
7473
7661
|
case 1:
|
|
7474
|
-
cloudDiscoverySource =
|
|
7662
|
+
cloudDiscoverySource = _d.sent();
|
|
7475
7663
|
this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
|
|
7664
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7476
7665
|
return [4 /*yield*/, this.updateEndpointMetadata(metadataEntity)];
|
|
7477
7666
|
case 2:
|
|
7478
|
-
endpointSource =
|
|
7667
|
+
endpointSource = _d.sent();
|
|
7479
7668
|
if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {
|
|
7480
7669
|
// Reset the expiration time unless both values came from a successful cache lookup
|
|
7481
7670
|
metadataEntity.resetExpiresAt();
|
|
@@ -7494,12 +7683,13 @@ var Authority = /** @class */ (function () {
|
|
|
7494
7683
|
* @param metadataEntity
|
|
7495
7684
|
*/
|
|
7496
7685
|
Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
|
|
7497
|
-
var _a, _b;
|
|
7686
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7498
7687
|
return __awaiter(this, void 0, void 0, function () {
|
|
7499
7688
|
var metadata, harcodedMetadata;
|
|
7500
|
-
return __generator(this, function (
|
|
7501
|
-
switch (
|
|
7689
|
+
return __generator(this, function (_g) {
|
|
7690
|
+
switch (_g.label) {
|
|
7502
7691
|
case 0:
|
|
7692
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7503
7693
|
metadata = this.getEndpointMetadataFromConfig();
|
|
7504
7694
|
if (metadata) {
|
|
7505
7695
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
@@ -7510,25 +7700,28 @@ var Authority = /** @class */ (function () {
|
|
|
7510
7700
|
return [2 /*return*/, AuthorityMetadataSource.CACHE];
|
|
7511
7701
|
}
|
|
7512
7702
|
harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7703
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7513
7704
|
return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
|
|
7514
7705
|
case 1:
|
|
7515
|
-
metadata =
|
|
7706
|
+
metadata = _g.sent();
|
|
7516
7707
|
if (!metadata) return [3 /*break*/, 4];
|
|
7517
|
-
if (!((
|
|
7708
|
+
if (!((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion)) return [3 /*break*/, 3];
|
|
7709
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7518
7710
|
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
|
|
7519
7711
|
case 2:
|
|
7520
|
-
metadata =
|
|
7521
|
-
|
|
7712
|
+
metadata = _g.sent();
|
|
7713
|
+
_g.label = 3;
|
|
7522
7714
|
case 3:
|
|
7523
7715
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
7524
7716
|
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
|
|
7525
7717
|
case 4:
|
|
7526
7718
|
if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
|
|
7527
|
-
if (!((
|
|
7719
|
+
if (!((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion)) return [3 /*break*/, 6];
|
|
7720
|
+
(_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7528
7721
|
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
|
|
7529
7722
|
case 5:
|
|
7530
|
-
harcodedMetadata =
|
|
7531
|
-
|
|
7723
|
+
harcodedMetadata = _g.sent();
|
|
7724
|
+
_g.label = 6;
|
|
7532
7725
|
case 6:
|
|
7533
7726
|
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
7534
7727
|
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
|
|
@@ -7568,25 +7761,24 @@ var Authority = /** @class */ (function () {
|
|
|
7568
7761
|
* @param hasHardcodedMetadata boolean
|
|
7569
7762
|
*/
|
|
7570
7763
|
Authority.prototype.getEndpointMetadataFromNetwork = function () {
|
|
7764
|
+
var _a;
|
|
7571
7765
|
return __awaiter(this, void 0, void 0, function () {
|
|
7572
7766
|
var options, response;
|
|
7573
|
-
return __generator(this, function (
|
|
7574
|
-
switch (
|
|
7767
|
+
return __generator(this, function (_b) {
|
|
7768
|
+
switch (_b.label) {
|
|
7575
7769
|
case 0:
|
|
7770
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7576
7771
|
options = {};
|
|
7577
|
-
|
|
7578
|
-
options.proxyUrl = this.proxyUrl;
|
|
7579
|
-
}
|
|
7580
|
-
_a.label = 1;
|
|
7772
|
+
_b.label = 1;
|
|
7581
7773
|
case 1:
|
|
7582
|
-
|
|
7774
|
+
_b.trys.push([1, 3, , 4]);
|
|
7583
7775
|
return [4 /*yield*/, this.networkInterface.
|
|
7584
7776
|
sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
|
|
7585
7777
|
case 2:
|
|
7586
|
-
response =
|
|
7778
|
+
response = _b.sent();
|
|
7587
7779
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
7588
7780
|
case 3:
|
|
7589
|
-
|
|
7781
|
+
_b.sent();
|
|
7590
7782
|
return [2 /*return*/, null];
|
|
7591
7783
|
case 4: return [2 /*return*/];
|
|
7592
7784
|
}
|
|
@@ -7606,25 +7798,28 @@ var Authority = /** @class */ (function () {
|
|
|
7606
7798
|
* Update the retrieved metadata with regional information.
|
|
7607
7799
|
*/
|
|
7608
7800
|
Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
|
|
7609
|
-
var _a, _b, _c, _d, _e;
|
|
7801
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7610
7802
|
return __awaiter(this, void 0, void 0, function () {
|
|
7611
7803
|
var autodetectedRegionName, azureRegion;
|
|
7612
|
-
return __generator(this, function (
|
|
7613
|
-
switch (
|
|
7614
|
-
case 0:
|
|
7804
|
+
return __generator(this, function (_h) {
|
|
7805
|
+
switch (_h.label) {
|
|
7806
|
+
case 0:
|
|
7807
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7808
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7809
|
+
return [4 /*yield*/, this.regionDiscovery.detectRegion((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.environmentRegion, this.regionDiscoveryMetadata)];
|
|
7615
7810
|
case 1:
|
|
7616
|
-
autodetectedRegionName =
|
|
7617
|
-
azureRegion = ((
|
|
7811
|
+
autodetectedRegionName = _h.sent();
|
|
7812
|
+
azureRegion = ((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
|
|
7618
7813
|
? autodetectedRegionName
|
|
7619
|
-
: (
|
|
7620
|
-
if (((
|
|
7814
|
+
: (_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion;
|
|
7815
|
+
if (((_f = this.authorityOptions.azureRegionConfiguration) === null || _f === void 0 ? void 0 : _f.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7621
7816
|
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
|
|
7622
7817
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
|
|
7623
7818
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7624
7819
|
}
|
|
7625
7820
|
else {
|
|
7626
7821
|
if (autodetectedRegionName) {
|
|
7627
|
-
this.regionDiscoveryMetadata.region_outcome = (((
|
|
7822
|
+
this.regionDiscoveryMetadata.region_outcome = (((_g = this.authorityOptions.azureRegionConfiguration) === null || _g === void 0 ? void 0 : _g.azureRegion) === autodetectedRegionName) ?
|
|
7628
7823
|
RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
|
|
7629
7824
|
RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
7630
7825
|
}
|
|
@@ -7648,11 +7843,13 @@ var Authority = /** @class */ (function () {
|
|
|
7648
7843
|
* @param newMetadata
|
|
7649
7844
|
*/
|
|
7650
7845
|
Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
|
|
7846
|
+
var _a, _b;
|
|
7651
7847
|
return __awaiter(this, void 0, void 0, function () {
|
|
7652
7848
|
var metadata, metadataEntityExpired, harcodedMetadata;
|
|
7653
|
-
return __generator(this, function (
|
|
7654
|
-
switch (
|
|
7849
|
+
return __generator(this, function (_c) {
|
|
7850
|
+
switch (_c.label) {
|
|
7655
7851
|
case 0:
|
|
7852
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7656
7853
|
this.logger.verbose("Attempting to get cloud discovery metadata in the config");
|
|
7657
7854
|
this.logger.verbosePii("Known Authorities: " + (this.authorityOptions.knownAuthorities || Constants.NOT_APPLICABLE));
|
|
7658
7855
|
this.logger.verbosePii("Authority Metadata: " + (this.authorityOptions.authorityMetadata || Constants.NOT_APPLICABLE));
|
|
@@ -7675,9 +7872,10 @@ var Authority = /** @class */ (function () {
|
|
|
7675
7872
|
this.logger.verbose("The metadata entity is expired.");
|
|
7676
7873
|
}
|
|
7677
7874
|
this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
|
|
7875
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7678
7876
|
return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
|
|
7679
7877
|
case 1:
|
|
7680
|
-
metadata =
|
|
7878
|
+
metadata = _c.sent();
|
|
7681
7879
|
if (metadata) {
|
|
7682
7880
|
this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
|
|
7683
7881
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
@@ -7735,23 +7933,22 @@ var Authority = /** @class */ (function () {
|
|
|
7735
7933
|
* @param hasHardcodedMetadata boolean
|
|
7736
7934
|
*/
|
|
7737
7935
|
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
|
|
7936
|
+
var _a;
|
|
7738
7937
|
return __awaiter(this, void 0, void 0, function () {
|
|
7739
7938
|
var instanceDiscoveryEndpoint, options, match, response, typedResponseBody, metadata, error_1, typedError;
|
|
7740
|
-
return __generator(this, function (
|
|
7741
|
-
switch (
|
|
7939
|
+
return __generator(this, function (_b) {
|
|
7940
|
+
switch (_b.label) {
|
|
7742
7941
|
case 0:
|
|
7942
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7743
7943
|
instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
|
|
7744
7944
|
options = {};
|
|
7745
|
-
if (this.proxyUrl) {
|
|
7746
|
-
options.proxyUrl = this.proxyUrl;
|
|
7747
|
-
}
|
|
7748
7945
|
match = null;
|
|
7749
|
-
|
|
7946
|
+
_b.label = 1;
|
|
7750
7947
|
case 1:
|
|
7751
|
-
|
|
7948
|
+
_b.trys.push([1, 3, , 4]);
|
|
7752
7949
|
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
|
|
7753
7950
|
case 2:
|
|
7754
|
-
response =
|
|
7951
|
+
response = _b.sent();
|
|
7755
7952
|
typedResponseBody = void 0;
|
|
7756
7953
|
metadata = void 0;
|
|
7757
7954
|
if (isCloudInstanceDiscoveryResponse(response.body)) {
|
|
@@ -7779,7 +7976,7 @@ var Authority = /** @class */ (function () {
|
|
|
7779
7976
|
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
|
|
7780
7977
|
return [3 /*break*/, 4];
|
|
7781
7978
|
case 3:
|
|
7782
|
-
error_1 =
|
|
7979
|
+
error_1 = _b.sent();
|
|
7783
7980
|
if (error_1 instanceof AuthError) {
|
|
7784
7981
|
this.logger.error("There was a network error while attempting to get the cloud discovery instance metadata.\nError: " + error_1.errorCode + "\nError Description: " + error_1.errorMessage);
|
|
7785
7982
|
}
|
|
@@ -7941,16 +8138,18 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
7941
8138
|
* @param networkClient
|
|
7942
8139
|
* @param protocolMode
|
|
7943
8140
|
*/
|
|
7944
|
-
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger,
|
|
8141
|
+
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7945
8142
|
return __awaiter(this, void 0, void 0, function () {
|
|
7946
8143
|
var acquireTokenAuthority, e_1;
|
|
7947
8144
|
return __generator(this, function (_a) {
|
|
7948
8145
|
switch (_a.label) {
|
|
7949
8146
|
case 0:
|
|
7950
|
-
|
|
8147
|
+
performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.addQueueMeasurement(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
|
|
8148
|
+
acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId);
|
|
7951
8149
|
_a.label = 1;
|
|
7952
8150
|
case 1:
|
|
7953
8151
|
_a.trys.push([1, 3, , 4]);
|
|
8152
|
+
performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, correlationId);
|
|
7954
8153
|
return [4 /*yield*/, acquireTokenAuthority.resolveEndpointsAsync()];
|
|
7955
8154
|
case 2:
|
|
7956
8155
|
_a.sent();
|
|
@@ -7973,12 +8172,12 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
7973
8172
|
* @param networkInterface
|
|
7974
8173
|
* @param protocolMode
|
|
7975
8174
|
*/
|
|
7976
|
-
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger,
|
|
8175
|
+
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7977
8176
|
// Throw error if authority url is empty
|
|
7978
8177
|
if (StringUtils.isEmpty(authorityUrl)) {
|
|
7979
8178
|
throw ClientConfigurationError.createUrlEmptyError();
|
|
7980
8179
|
}
|
|
7981
|
-
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger,
|
|
8180
|
+
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId);
|
|
7982
8181
|
};
|
|
7983
8182
|
return AuthorityFactory;
|
|
7984
8183
|
}());
|
|
@@ -8378,6 +8577,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8378
8577
|
this.eventsByCorrelationId = new Map();
|
|
8379
8578
|
this.staticFieldsByCorrelationId = new Map();
|
|
8380
8579
|
this.measurementsById = new Map();
|
|
8580
|
+
this.queueMeasurements = new Map();
|
|
8581
|
+
this.preQueueTimeByCorrelationId = new Map();
|
|
8381
8582
|
this.countersByCorrelationId = new Map();
|
|
8382
8583
|
}
|
|
8383
8584
|
/**
|
|
@@ -8404,6 +8605,90 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8404
8605
|
PerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
|
|
8405
8606
|
return {};
|
|
8406
8607
|
};
|
|
8608
|
+
/**
|
|
8609
|
+
* Get integral fields.
|
|
8610
|
+
* Override to change the set.
|
|
8611
|
+
*/
|
|
8612
|
+
PerformanceClient.prototype.getIntFields = function () {
|
|
8613
|
+
return IntFields;
|
|
8614
|
+
};
|
|
8615
|
+
/**
|
|
8616
|
+
* Gets map of pre-queue times by correlation Id
|
|
8617
|
+
*
|
|
8618
|
+
* @param {PerformanceEvents} eventName
|
|
8619
|
+
* @param {string} correlationId
|
|
8620
|
+
* @returns {number}
|
|
8621
|
+
*/
|
|
8622
|
+
PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
|
|
8623
|
+
var preQueueTimesByEvents = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
8624
|
+
if (!preQueueTimesByEvents) {
|
|
8625
|
+
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
|
|
8626
|
+
return;
|
|
8627
|
+
}
|
|
8628
|
+
else if (!preQueueTimesByEvents.get(eventName)) {
|
|
8629
|
+
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
|
|
8630
|
+
return;
|
|
8631
|
+
}
|
|
8632
|
+
return preQueueTimesByEvents.get(eventName);
|
|
8633
|
+
};
|
|
8634
|
+
/**
|
|
8635
|
+
* Calculates the difference between current time and time when function was queued.
|
|
8636
|
+
* Note: It is possible to have 0 as the queue time if the current time and the queued time was the same.
|
|
8637
|
+
*
|
|
8638
|
+
* @param {number} preQueueTime
|
|
8639
|
+
* @param {number} currentTime
|
|
8640
|
+
* @returns {number}
|
|
8641
|
+
*/
|
|
8642
|
+
PerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
|
|
8643
|
+
if (preQueueTime < 1) {
|
|
8644
|
+
this.logger.trace("PerformanceClient: preQueueTime should be a positive integer and not " + preQueueTime);
|
|
8645
|
+
return 0;
|
|
8646
|
+
}
|
|
8647
|
+
if (currentTime < 1) {
|
|
8648
|
+
this.logger.trace("PerformanceClient: currentTime should be a positive integer and not " + currentTime);
|
|
8649
|
+
return 0;
|
|
8650
|
+
}
|
|
8651
|
+
if (currentTime < preQueueTime) {
|
|
8652
|
+
this.logger.trace("PerformanceClient: currentTime is less than preQueueTime, check how time is being retrieved");
|
|
8653
|
+
return 0;
|
|
8654
|
+
}
|
|
8655
|
+
return currentTime - preQueueTime;
|
|
8656
|
+
};
|
|
8657
|
+
/**
|
|
8658
|
+
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
8659
|
+
*
|
|
8660
|
+
* @param {PerformanceEvents} name
|
|
8661
|
+
* @param {?string} correlationId
|
|
8662
|
+
* @param {?number} time
|
|
8663
|
+
* @returns
|
|
8664
|
+
*/
|
|
8665
|
+
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
|
|
8666
|
+
if (!correlationId) {
|
|
8667
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
|
|
8668
|
+
return;
|
|
8669
|
+
}
|
|
8670
|
+
if (queueTime === 0) {
|
|
8671
|
+
// Possible for there to be no queue time after calculation
|
|
8672
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: queue time provided for " + eventName + " is " + queueTime);
|
|
8673
|
+
}
|
|
8674
|
+
else if (!queueTime) {
|
|
8675
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
|
|
8676
|
+
return;
|
|
8677
|
+
}
|
|
8678
|
+
var queueMeasurement = { eventName: eventName, queueTime: queueTime };
|
|
8679
|
+
// Adds to existing correlation Id if present in queueMeasurements
|
|
8680
|
+
var existingMeasurements = this.queueMeasurements.get(correlationId);
|
|
8681
|
+
if (existingMeasurements) {
|
|
8682
|
+
existingMeasurements.push(queueMeasurement);
|
|
8683
|
+
this.queueMeasurements.set(correlationId, existingMeasurements);
|
|
8684
|
+
}
|
|
8685
|
+
else {
|
|
8686
|
+
// Sets new correlation Id if not present in queueMeasurements
|
|
8687
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: adding correlationId " + correlationId + " to queue measurements");
|
|
8688
|
+
var measurementArray = [queueMeasurement];
|
|
8689
|
+
this.queueMeasurements.set(correlationId, measurementArray);
|
|
8690
|
+
}
|
|
8691
|
+
};
|
|
8407
8692
|
/**
|
|
8408
8693
|
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
8409
8694
|
*
|
|
@@ -8583,6 +8868,20 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8583
8868
|
PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
|
|
8584
8869
|
var _this = this;
|
|
8585
8870
|
this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
|
|
8871
|
+
/**
|
|
8872
|
+
* Adds all queue time and count measurements for given correlation ID
|
|
8873
|
+
* then deletes queue times for given correlation ID from queueMeasurements map.
|
|
8874
|
+
*/
|
|
8875
|
+
var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
|
|
8876
|
+
if (!queueMeasurementForCorrelationId) {
|
|
8877
|
+
this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
|
|
8878
|
+
}
|
|
8879
|
+
var totalQueueTime = 0;
|
|
8880
|
+
var totalQueueCount = 0;
|
|
8881
|
+
queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
|
|
8882
|
+
totalQueueTime += measurement.queueTime;
|
|
8883
|
+
totalQueueCount++;
|
|
8884
|
+
});
|
|
8586
8885
|
var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
|
|
8587
8886
|
var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
|
|
8588
8887
|
var counters = this.countersByCorrelationId.get(correlationId);
|
|
@@ -8594,9 +8893,11 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8594
8893
|
* IE only supports Map.forEach.
|
|
8595
8894
|
*/
|
|
8596
8895
|
var completedEvents_1 = [];
|
|
8896
|
+
var incompleteSubsCount_1 = 0;
|
|
8597
8897
|
eventsForCorrelationId.forEach(function (event) {
|
|
8598
8898
|
if (event.name !== measureName && event.status !== exports.PerformanceEventStatus.Completed) {
|
|
8599
8899
|
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
|
|
8900
|
+
incompleteSubsCount_1++;
|
|
8600
8901
|
var completedEvent = _this.endMeasurement(event);
|
|
8601
8902
|
if (completedEvent) {
|
|
8602
8903
|
completedEvents_1.push(completedEvent);
|
|
@@ -8638,7 +8939,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8638
8939
|
}
|
|
8639
8940
|
return previous;
|
|
8640
8941
|
}, topLevelEvent);
|
|
8641
|
-
var finalEvent = __assign(__assign(__assign({}, eventToEmit), staticFields), counters);
|
|
8942
|
+
var finalEvent = __assign(__assign(__assign(__assign({}, eventToEmit), staticFields), counters), { queuedTimeMs: totalQueueTime, queuedCount: totalQueueCount, incompleteSubsCount: incompleteSubsCount_1 });
|
|
8943
|
+
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
8642
8944
|
this.emitEvents([finalEvent], eventToEmit.correlationId);
|
|
8643
8945
|
}
|
|
8644
8946
|
else {
|
|
@@ -8669,6 +8971,10 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8669
8971
|
this.staticFieldsByCorrelationId.delete(correlationId);
|
|
8670
8972
|
this.logger.trace("PerformanceClient: Counters discarded", correlationId);
|
|
8671
8973
|
this.countersByCorrelationId.delete(correlationId);
|
|
8974
|
+
this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
|
|
8975
|
+
this.queueMeasurements.delete(correlationId);
|
|
8976
|
+
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|
|
8977
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8672
8978
|
};
|
|
8673
8979
|
/**
|
|
8674
8980
|
* Registers a callback function to receive performance events.
|
|
@@ -8712,6 +9018,18 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8712
9018
|
callback.apply(null, [events]);
|
|
8713
9019
|
});
|
|
8714
9020
|
};
|
|
9021
|
+
/**
|
|
9022
|
+
* Enforce truncation of integral fields in performance event.
|
|
9023
|
+
* @param {PerformanceEvent} event performance event to update.
|
|
9024
|
+
* @param {Set<string>} intFields integral fields.
|
|
9025
|
+
*/
|
|
9026
|
+
PerformanceClient.prototype.truncateIntegralFields = function (event, intFields) {
|
|
9027
|
+
intFields.forEach(function (key) {
|
|
9028
|
+
if (key in event && typeof event[key] === "number") {
|
|
9029
|
+
event[key] = Math.floor(event[key]);
|
|
9030
|
+
}
|
|
9031
|
+
});
|
|
9032
|
+
};
|
|
8715
9033
|
return PerformanceClient;
|
|
8716
9034
|
}());
|
|
8717
9035
|
|
|
@@ -8745,6 +9063,18 @@ var StubPerformanceClient = /** @class */ (function (_super) {
|
|
|
8745
9063
|
StubPerformanceClient.prototype.startPerformanceMeasurement = function () {
|
|
8746
9064
|
return new StubPerformanceMeasurement();
|
|
8747
9065
|
};
|
|
9066
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
9067
|
+
StubPerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
|
|
9068
|
+
return 0;
|
|
9069
|
+
};
|
|
9070
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
9071
|
+
StubPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
|
|
9072
|
+
return;
|
|
9073
|
+
};
|
|
9074
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
9075
|
+
StubPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
|
|
9076
|
+
return;
|
|
9077
|
+
};
|
|
8748
9078
|
return StubPerformanceClient;
|
|
8749
9079
|
}(PerformanceClient));
|
|
8750
9080
|
|
|
@@ -8776,6 +9106,7 @@ exports.DeviceCodeClient = DeviceCodeClient;
|
|
|
8776
9106
|
exports.Errors = Errors;
|
|
8777
9107
|
exports.IdToken = AuthToken;
|
|
8778
9108
|
exports.IdTokenEntity = IdTokenEntity;
|
|
9109
|
+
exports.IntFields = IntFields;
|
|
8779
9110
|
exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
|
|
8780
9111
|
exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
|
|
8781
9112
|
exports.JoseHeader = JoseHeader;
|