@azure/msal-common 9.1.1 → 11.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/broker/nativeBroker/INativeBrokerPlugin.d.ts +16 -0
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -0
- package/dist/cache/CacheManager.js +2 -2
- 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 +31 -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 +3 -3
- 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.d.ts +16 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +21 -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 +952 -673
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -4
- 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.d.ts +11 -0
- package/dist/network/NetworkManager.d.ts.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/NativeRequest.d.ts +20 -0
- package/dist/request/NativeRequest.d.ts.map +1 -0
- package/dist/request/NativeSignOutRequest.d.ts +6 -0
- package/dist/request/NativeSignOutRequest.d.ts.map +1 -0
- 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 +4 -2
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +24 -16
- 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 +2 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +20 -2
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +68 -31
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +197 -160
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +129 -5
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +101 -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.d.ts +2 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +2 -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 v11.0.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -486,6 +486,7 @@ var JsonTypes;
|
|
|
486
486
|
(function (JsonTypes) {
|
|
487
487
|
JsonTypes["Jwt"] = "JWT";
|
|
488
488
|
JsonTypes["Jwk"] = "JWK";
|
|
489
|
+
JsonTypes["Pop"] = "pop";
|
|
489
490
|
})(JsonTypes || (JsonTypes = {}));
|
|
490
491
|
var ONE_DAY_IN_MS = 86400000;
|
|
491
492
|
|
|
@@ -818,6 +819,14 @@ var ClientAuthErrorMessage = {
|
|
|
818
819
|
keyIdMissing: {
|
|
819
820
|
code: "key_id_missing",
|
|
820
821
|
desc: "A keyId value is missing from the requested bound token's cache record and is required to match the token to it's stored binding key."
|
|
822
|
+
},
|
|
823
|
+
noNetworkConnectivity: {
|
|
824
|
+
code: "no_network_connectivity",
|
|
825
|
+
desc: "No network connectivity. Check your internet connection."
|
|
826
|
+
},
|
|
827
|
+
userCanceledError: {
|
|
828
|
+
code: "user_canceled",
|
|
829
|
+
desc: "User canceled the flow."
|
|
821
830
|
}
|
|
822
831
|
};
|
|
823
832
|
/**
|
|
@@ -1106,6 +1115,18 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1106
1115
|
ClientAuthError.createKeyIdMissingError = function () {
|
|
1107
1116
|
return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
|
|
1108
1117
|
};
|
|
1118
|
+
/**
|
|
1119
|
+
* Create an error when the client does not have network connectivity
|
|
1120
|
+
*/
|
|
1121
|
+
ClientAuthError.createNoNetworkConnectivityError = function () {
|
|
1122
|
+
return new ClientAuthError(ClientAuthErrorMessage.noNetworkConnectivity.code, ClientAuthErrorMessage.noNetworkConnectivity.desc);
|
|
1123
|
+
};
|
|
1124
|
+
/**
|
|
1125
|
+
* Create an error when the user cancels the flow
|
|
1126
|
+
*/
|
|
1127
|
+
ClientAuthError.createUserCanceledError = function () {
|
|
1128
|
+
return new ClientAuthError(ClientAuthErrorMessage.userCanceledError.code, ClientAuthErrorMessage.userCanceledError.desc);
|
|
1129
|
+
};
|
|
1109
1130
|
return ClientAuthError;
|
|
1110
1131
|
}(AuthError));
|
|
1111
1132
|
|
|
@@ -1422,7 +1443,7 @@ var Logger = /** @class */ (function () {
|
|
|
1422
1443
|
|
|
1423
1444
|
/* eslint-disable header/header */
|
|
1424
1445
|
var name = "@azure/msal-common";
|
|
1425
|
-
var version = "
|
|
1446
|
+
var version = "11.0.0";
|
|
1426
1447
|
|
|
1427
1448
|
/*
|
|
1428
1449
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1473,6 +1494,25 @@ exports.AzureCloudInstance = void 0;
|
|
|
1473
1494
|
var CredentialEntity = /** @class */ (function () {
|
|
1474
1495
|
function CredentialEntity() {
|
|
1475
1496
|
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Initializes a map with credential {CredentialType} regular expressions.
|
|
1499
|
+
*/
|
|
1500
|
+
CredentialEntity._initRegex = function () {
|
|
1501
|
+
var separator = Separators.CACHE_KEY_SEPARATOR;
|
|
1502
|
+
CredentialEntity.credentialRegexMap = new Map();
|
|
1503
|
+
for (var _i = 0, _a = Object.keys(exports.CredentialType); _i < _a.length; _i++) {
|
|
1504
|
+
var credKey = _a[_i];
|
|
1505
|
+
var credVal = exports.CredentialType[credKey].toLowerCase();
|
|
1506
|
+
try {
|
|
1507
|
+
// Verify credential type is preceded by a valid host name (environment) using lookbehind
|
|
1508
|
+
CredentialEntity.credentialRegexMap.set(exports.CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
|
|
1509
|
+
}
|
|
1510
|
+
catch (err) {
|
|
1511
|
+
// Lookbehind is not supported (Safari or older versions of IE) - removing it
|
|
1512
|
+
CredentialEntity.credentialRegexMap.set(exports.CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1476
1516
|
/**
|
|
1477
1517
|
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
1478
1518
|
*/
|
|
@@ -1519,14 +1559,10 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1519
1559
|
* @param key
|
|
1520
1560
|
*/
|
|
1521
1561
|
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) {
|
|
1562
|
+
var _a;
|
|
1563
|
+
for (var _i = 0, _b = Object.keys(exports.CredentialType); _i < _b.length; _i++) {
|
|
1564
|
+
var credKey = _b[_i];
|
|
1565
|
+
if ((_a = this.credentialRegexMap.get(exports.CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
|
|
1530
1566
|
return exports.CredentialType[credKey];
|
|
1531
1567
|
}
|
|
1532
1568
|
}
|
|
@@ -1595,8 +1631,14 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1595
1631
|
*/
|
|
1596
1632
|
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
1597
1633
|
};
|
|
1634
|
+
/*
|
|
1635
|
+
* Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000,
|
|
1636
|
+
* "login.microsoftonline.com/common", "login.microsoftonline.com:4000/common", etc
|
|
1637
|
+
*/
|
|
1638
|
+
CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?(\\/[\\w-]+)?";
|
|
1598
1639
|
return CredentialEntity;
|
|
1599
|
-
}());
|
|
1640
|
+
}());
|
|
1641
|
+
CredentialEntity._initRegex();
|
|
1600
1642
|
|
|
1601
1643
|
/*
|
|
1602
1644
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2871,7 +2913,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2871
2913
|
else if (accounts.length > 1) {
|
|
2872
2914
|
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
|
|
2873
2915
|
}
|
|
2874
|
-
return
|
|
2916
|
+
return accounts[0];
|
|
2875
2917
|
};
|
|
2876
2918
|
/**
|
|
2877
2919
|
* Retrieve IdTokenEntity from cache
|
|
@@ -3255,8 +3297,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
3255
3297
|
var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
3256
3298
|
var DEFAULT_SYSTEM_OPTIONS = {
|
|
3257
3299
|
tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
3258
|
-
preventCorsPreflight: false
|
|
3259
|
-
proxyUrl: Constants.EMPTY_STRING
|
|
3300
|
+
preventCorsPreflight: false
|
|
3260
3301
|
};
|
|
3261
3302
|
var DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
3262
3303
|
loggerCallback: function () {
|
|
@@ -3508,95 +3549,6 @@ exports.CcsCredentialType = void 0;
|
|
|
3508
3549
|
CcsCredentialType["UPN"] = "UPN";
|
|
3509
3550
|
})(exports.CcsCredentialType || (exports.CcsCredentialType = {}));
|
|
3510
3551
|
|
|
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
3552
|
/*
|
|
3601
3553
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3602
3554
|
* Licensed under the MIT License.
|
|
@@ -3663,7 +3615,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3663
3615
|
}
|
|
3664
3616
|
};
|
|
3665
3617
|
/**
|
|
3666
|
-
* Removes unnecessary
|
|
3618
|
+
* Removes unnecessary, duplicate, and empty string query parameters from extraQueryParameters
|
|
3667
3619
|
* @param request
|
|
3668
3620
|
*/
|
|
3669
3621
|
RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {
|
|
@@ -3676,7 +3628,12 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3676
3628
|
delete eQParams[key];
|
|
3677
3629
|
}
|
|
3678
3630
|
});
|
|
3679
|
-
|
|
3631
|
+
// remove empty string parameters
|
|
3632
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3633
|
+
return Object.fromEntries(Object.entries(eQParams).filter(function (_a) {
|
|
3634
|
+
_a[0]; var value = _a[1];
|
|
3635
|
+
return value !== "";
|
|
3636
|
+
}));
|
|
3680
3637
|
};
|
|
3681
3638
|
return RequestValidator;
|
|
3682
3639
|
}());
|
|
@@ -3956,13 +3913,13 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3956
3913
|
};
|
|
3957
3914
|
/**
|
|
3958
3915
|
* add extraQueryParams
|
|
3959
|
-
* @param
|
|
3916
|
+
* @param eQParams
|
|
3960
3917
|
*/
|
|
3961
|
-
RequestParameterBuilder.prototype.addExtraQueryParameters = function (
|
|
3918
|
+
RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQParams) {
|
|
3962
3919
|
var _this = this;
|
|
3963
|
-
RequestValidator.sanitizeEQParams(
|
|
3964
|
-
Object.keys(
|
|
3965
|
-
_this.parameters.set(key,
|
|
3920
|
+
var sanitizedEQParams = RequestValidator.sanitizeEQParams(eQParams, this.parameters);
|
|
3921
|
+
Object.keys(sanitizedEQParams).forEach(function (key) {
|
|
3922
|
+
_this.parameters.set(key, eQParams[key]);
|
|
3966
3923
|
});
|
|
3967
3924
|
};
|
|
3968
3925
|
RequestParameterBuilder.prototype.addClientCapabilitiesToClaims = function (claims, clientCapabilities) {
|
|
@@ -4057,6 +4014,106 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
4057
4014
|
return RequestParameterBuilder;
|
|
4058
4015
|
}());
|
|
4059
4016
|
|
|
4017
|
+
/*
|
|
4018
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4019
|
+
* Licensed under the MIT License.
|
|
4020
|
+
*/
|
|
4021
|
+
/**
|
|
4022
|
+
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
4023
|
+
*/
|
|
4024
|
+
var BaseClient = /** @class */ (function () {
|
|
4025
|
+
function BaseClient(configuration, performanceClient) {
|
|
4026
|
+
// Set the configuration
|
|
4027
|
+
this.config = buildClientConfiguration(configuration);
|
|
4028
|
+
// Initialize the logger
|
|
4029
|
+
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
4030
|
+
// Initialize crypto
|
|
4031
|
+
this.cryptoUtils = this.config.cryptoInterface;
|
|
4032
|
+
// Initialize storage interface
|
|
4033
|
+
this.cacheManager = this.config.storageInterface;
|
|
4034
|
+
// Set the network interface
|
|
4035
|
+
this.networkClient = this.config.networkInterface;
|
|
4036
|
+
// Set the NetworkManager
|
|
4037
|
+
this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
|
|
4038
|
+
// Set TelemetryManager
|
|
4039
|
+
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
4040
|
+
// set Authority
|
|
4041
|
+
this.authority = this.config.authOptions.authority;
|
|
4042
|
+
// set performance telemetry client
|
|
4043
|
+
this.performanceClient = performanceClient;
|
|
4044
|
+
}
|
|
4045
|
+
/**
|
|
4046
|
+
* Creates default headers for requests to token endpoint
|
|
4047
|
+
*/
|
|
4048
|
+
BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
|
|
4049
|
+
var headers = {};
|
|
4050
|
+
headers[exports.HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
4051
|
+
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
4052
|
+
switch (ccsCred.type) {
|
|
4053
|
+
case exports.CcsCredentialType.HOME_ACCOUNT_ID:
|
|
4054
|
+
try {
|
|
4055
|
+
var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
4056
|
+
headers[exports.HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
|
|
4057
|
+
}
|
|
4058
|
+
catch (e) {
|
|
4059
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
4060
|
+
}
|
|
4061
|
+
break;
|
|
4062
|
+
case exports.CcsCredentialType.UPN:
|
|
4063
|
+
headers[exports.HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
|
|
4064
|
+
break;
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
return headers;
|
|
4068
|
+
};
|
|
4069
|
+
/**
|
|
4070
|
+
* Http post to token endpoint
|
|
4071
|
+
* @param tokenEndpoint
|
|
4072
|
+
* @param queryString
|
|
4073
|
+
* @param headers
|
|
4074
|
+
* @param thumbprint
|
|
4075
|
+
*/
|
|
4076
|
+
BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
|
|
4077
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4078
|
+
var response;
|
|
4079
|
+
return __generator(this, function (_a) {
|
|
4080
|
+
switch (_a.label) {
|
|
4081
|
+
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
|
|
4082
|
+
case 1:
|
|
4083
|
+
response = _a.sent();
|
|
4084
|
+
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
4085
|
+
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
4086
|
+
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
4087
|
+
}
|
|
4088
|
+
return [2 /*return*/, response];
|
|
4089
|
+
}
|
|
4090
|
+
});
|
|
4091
|
+
});
|
|
4092
|
+
};
|
|
4093
|
+
/**
|
|
4094
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
4095
|
+
* @param updatedAuthority
|
|
4096
|
+
*/
|
|
4097
|
+
BaseClient.prototype.updateAuthority = function (updatedAuthority) {
|
|
4098
|
+
if (!updatedAuthority.discoveryComplete()) {
|
|
4099
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
|
|
4100
|
+
}
|
|
4101
|
+
this.authority = updatedAuthority;
|
|
4102
|
+
};
|
|
4103
|
+
/**
|
|
4104
|
+
* Creates query string for the /token request
|
|
4105
|
+
* @param request
|
|
4106
|
+
*/
|
|
4107
|
+
BaseClient.prototype.createTokenQueryParameters = function (request) {
|
|
4108
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
4109
|
+
if (request.tokenQueryParameters) {
|
|
4110
|
+
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
4111
|
+
}
|
|
4112
|
+
return parameterBuilder.createQueryString();
|
|
4113
|
+
};
|
|
4114
|
+
return BaseClient;
|
|
4115
|
+
}());
|
|
4116
|
+
|
|
4060
4117
|
/*
|
|
4061
4118
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4062
4119
|
* Licensed under the MIT License.
|
|
@@ -4382,10 +4439,14 @@ var InteractionRequiredAuthErrorMessage = {
|
|
|
4382
4439
|
*/
|
|
4383
4440
|
var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
4384
4441
|
__extends(InteractionRequiredAuthError, _super);
|
|
4385
|
-
function InteractionRequiredAuthError(errorCode, errorMessage, subError) {
|
|
4442
|
+
function InteractionRequiredAuthError(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims) {
|
|
4386
4443
|
var _this = _super.call(this, errorCode, errorMessage, subError) || this;
|
|
4387
|
-
_this.name = "InteractionRequiredAuthError";
|
|
4388
4444
|
Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
|
|
4445
|
+
_this.timestamp = timestamp || Constants.EMPTY_STRING;
|
|
4446
|
+
_this.traceId = traceId || Constants.EMPTY_STRING;
|
|
4447
|
+
_this.correlationId = correlationId || Constants.EMPTY_STRING;
|
|
4448
|
+
_this.claims = claims || Constants.EMPTY_STRING;
|
|
4449
|
+
_this.name = "InteractionRequiredAuthError";
|
|
4389
4450
|
return _this;
|
|
4390
4451
|
}
|
|
4391
4452
|
/**
|
|
@@ -4738,54 +4799,290 @@ var UrlString = /** @class */ (function () {
|
|
|
4738
4799
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4739
4800
|
* Licensed under the MIT License.
|
|
4740
4801
|
*/
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
}
|
|
4802
|
+
/**
|
|
4803
|
+
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
4804
|
+
*
|
|
4805
|
+
* @export
|
|
4806
|
+
* @enum {number}
|
|
4807
|
+
*/
|
|
4808
|
+
exports.PerformanceEvents = void 0;
|
|
4809
|
+
(function (PerformanceEvents) {
|
|
4750
4810
|
/**
|
|
4751
|
-
*
|
|
4752
|
-
*
|
|
4753
|
-
* @param request
|
|
4754
|
-
* @returns
|
|
4811
|
+
* acquireTokenByCode API (msal-browser and msal-node).
|
|
4812
|
+
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
4755
4813
|
*/
|
|
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
|
-
};
|
|
4814
|
+
PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
|
|
4776
4815
|
/**
|
|
4777
|
-
*
|
|
4778
|
-
*
|
|
4779
|
-
|
|
4816
|
+
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
4817
|
+
* Used to renew an access token using a refresh token against the token endpoint.
|
|
4818
|
+
*/
|
|
4819
|
+
PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
|
|
4820
|
+
/**
|
|
4821
|
+
* acquireTokenSilent API (msal-browser and msal-node).
|
|
4822
|
+
* Used to silently acquire a new access token (from the cache or the network).
|
|
4823
|
+
*/
|
|
4824
|
+
PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
|
|
4825
|
+
/**
|
|
4826
|
+
* acquireTokenSilentAsync (msal-browser).
|
|
4827
|
+
* Internal API for acquireTokenSilent.
|
|
4828
|
+
*/
|
|
4829
|
+
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
4830
|
+
/**
|
|
4831
|
+
* acquireTokenPopup (msal-browser).
|
|
4832
|
+
* Used to acquire a new access token interactively through pop ups
|
|
4833
|
+
*/
|
|
4834
|
+
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
4835
|
+
/**
|
|
4836
|
+
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
4837
|
+
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
4838
|
+
*/
|
|
4839
|
+
PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
|
|
4840
|
+
/**
|
|
4841
|
+
* signJwt API in CryptoOpts class (msal-browser).
|
|
4842
|
+
* Used to signed a pop token.
|
|
4843
|
+
*/
|
|
4844
|
+
PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
|
|
4845
|
+
/**
|
|
4846
|
+
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
4847
|
+
* Used to read access tokens from the cache.
|
|
4848
|
+
*/
|
|
4849
|
+
PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
|
|
4850
|
+
/**
|
|
4851
|
+
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
4852
|
+
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
4853
|
+
*/
|
|
4854
|
+
PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
|
|
4855
|
+
/**
|
|
4856
|
+
* acquireToken API in SilentRereshClient (msal-browser).
|
|
4857
|
+
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
4858
|
+
*/
|
|
4859
|
+
PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
|
|
4860
|
+
/**
|
|
4861
|
+
* ssoSilent API (msal-browser).
|
|
4862
|
+
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
4863
|
+
*/
|
|
4864
|
+
PerformanceEvents["SsoSilent"] = "ssoSilent";
|
|
4865
|
+
/**
|
|
4866
|
+
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
4867
|
+
* Used to load authority metadata for a request.
|
|
4868
|
+
*/
|
|
4869
|
+
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
4870
|
+
/**
|
|
4871
|
+
* acquireToken APIs in msal-browser.
|
|
4872
|
+
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
4873
|
+
*/
|
|
4874
|
+
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
4875
|
+
/**
|
|
4876
|
+
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
4877
|
+
* Used to acquire a token from Native component when native brokering is enabled.
|
|
4878
|
+
*/
|
|
4879
|
+
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
4880
|
+
/**
|
|
4881
|
+
* Time spent creating default headers for requests to token endpoint
|
|
4882
|
+
*/
|
|
4883
|
+
PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
|
|
4884
|
+
/**
|
|
4885
|
+
* Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
|
|
4886
|
+
*/
|
|
4887
|
+
PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
|
|
4888
|
+
/**
|
|
4889
|
+
* acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
|
|
4890
|
+
*/
|
|
4891
|
+
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
4892
|
+
/**
|
|
4893
|
+
* Time taken for token acquisition by broker
|
|
4894
|
+
*/
|
|
4895
|
+
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
4896
|
+
/**
|
|
4897
|
+
* Time spent on the network for refresh token acquisition
|
|
4898
|
+
*/
|
|
4899
|
+
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
4900
|
+
/**
|
|
4901
|
+
* Time taken for acquiring refresh token , records RT size
|
|
4902
|
+
*/
|
|
4903
|
+
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
4904
|
+
/**
|
|
4905
|
+
* Time taken for acquiring cached refresh token
|
|
4906
|
+
*/
|
|
4907
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
4908
|
+
/**
|
|
4909
|
+
* acquireTokenByRefreshToken API in RefreshTokenClient (msal-common).
|
|
4910
|
+
*/
|
|
4911
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenByRefreshToken"] = "refreshTokenClientAcquireTokenByRefreshToken";
|
|
4912
|
+
/**
|
|
4913
|
+
* Helper function to create token request body in RefreshTokenClient (msal-common).
|
|
4914
|
+
*/
|
|
4915
|
+
PerformanceEvents["RefreshTokenClientCreateTokenRequestBody"] = "refreshTokenClientCreateTokenRequestBody";
|
|
4916
|
+
/**
|
|
4917
|
+
* acquireTokenFromCache (msal-browser).
|
|
4918
|
+
* Internal API for acquiring token from cache
|
|
4919
|
+
*/
|
|
4920
|
+
PerformanceEvents["AcquireTokenFromCache"] = "acquireTokenFromCache";
|
|
4921
|
+
/**
|
|
4922
|
+
* acquireTokenBySilentIframe (msal-browser).
|
|
4923
|
+
* Internal API for acquiring token by silent Iframe
|
|
4924
|
+
*/
|
|
4925
|
+
PerformanceEvents["AcquireTokenBySilentIframe"] = "acquireTokenBySilentIframe";
|
|
4926
|
+
/**
|
|
4927
|
+
* Internal API for initializing base request in BaseInteractionClient (msal-browser)
|
|
4928
|
+
*/
|
|
4929
|
+
PerformanceEvents["InitializeBaseRequest"] = "initializeBaseRequest";
|
|
4930
|
+
/**
|
|
4931
|
+
* Internal API for initializing silent request in SilentCacheClient (msal-browser)
|
|
4932
|
+
*/
|
|
4933
|
+
PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
|
|
4934
|
+
PerformanceEvents["InitializeClientApplication"] = "initializeClientApplication";
|
|
4935
|
+
/**
|
|
4936
|
+
* Helper function in SilentIframeClient class (msal-browser).
|
|
4937
|
+
*/
|
|
4938
|
+
PerformanceEvents["SilentIframeClientTokenHelper"] = "silentIframeClientTokenHelper";
|
|
4939
|
+
/**
|
|
4940
|
+
* SilentHandler
|
|
4941
|
+
*/
|
|
4942
|
+
PerformanceEvents["SilentHandlerInitiateAuthRequest"] = "silentHandlerInitiateAuthRequest";
|
|
4943
|
+
PerformanceEvents["SilentHandlerMonitorIframeForHash"] = "silentHandlerMonitorIframeForHash";
|
|
4944
|
+
PerformanceEvents["SilentHandlerLoadFrame"] = "silentHandlerLoadFrame";
|
|
4945
|
+
/**
|
|
4946
|
+
* Helper functions in StandardInteractionClient class (msal-browser)
|
|
4947
|
+
*/
|
|
4948
|
+
PerformanceEvents["StandardInteractionClientCreateAuthCodeClient"] = "standardInteractionClientCreateAuthCodeClient";
|
|
4949
|
+
PerformanceEvents["StandardInteractionClientGetClientConfiguration"] = "standardInteractionClientGetClientConfiguration";
|
|
4950
|
+
PerformanceEvents["StandardInteractionClientInitializeAuthorizationRequest"] = "standardInteractionClientInitializeAuthorizationRequest";
|
|
4951
|
+
PerformanceEvents["StandardInteractionClientInitializeAuthorizationCodeRequest"] = "standardInteractionClientInitializeAuthorizationCodeRequest";
|
|
4952
|
+
/**
|
|
4953
|
+
* getAuthCodeUrl API (msal-browser and msal-node).
|
|
4954
|
+
*/
|
|
4955
|
+
PerformanceEvents["GetAuthCodeUrl"] = "getAuthCodeUrl";
|
|
4956
|
+
/**
|
|
4957
|
+
* Functions from InteractionHandler (msal-browser)
|
|
4958
|
+
*/
|
|
4959
|
+
PerformanceEvents["HandleCodeResponseFromServer"] = "handleCodeResponseFromServer";
|
|
4960
|
+
PerformanceEvents["HandleCodeResponseFromHash"] = "handleCodeResponseFromHash";
|
|
4961
|
+
PerformanceEvents["UpdateTokenEndpointAuthority"] = "updateTokenEndpointAuthority";
|
|
4962
|
+
/**
|
|
4963
|
+
* APIs in Authorization Code Client (msal-common)
|
|
4964
|
+
*/
|
|
4965
|
+
PerformanceEvents["AuthClientAcquireToken"] = "authClientAcquireToken";
|
|
4966
|
+
PerformanceEvents["AuthClientExecuteTokenRequest"] = "authClientExecuteTokenRequest";
|
|
4967
|
+
PerformanceEvents["AuthClientCreateTokenRequestBody"] = "authClientCreateTokenRequestBody";
|
|
4968
|
+
PerformanceEvents["AuthClientCreateQueryString"] = "authClientCreateQueryString";
|
|
4969
|
+
/**
|
|
4970
|
+
* Generate functions in PopTokenGenerator (msal-common)
|
|
4971
|
+
*/
|
|
4972
|
+
PerformanceEvents["PopTokenGenerateCnf"] = "popTokenGenerateCnf";
|
|
4973
|
+
PerformanceEvents["PopTokenGenerateKid"] = "popTokenGenerateKid";
|
|
4974
|
+
/**
|
|
4975
|
+
* handleServerTokenResponse API in ResponseHandler (msal-common)
|
|
4976
|
+
*/
|
|
4977
|
+
PerformanceEvents["HandleServerTokenResponse"] = "handleServerTokenResponse";
|
|
4978
|
+
/**
|
|
4979
|
+
* Authority functions
|
|
4980
|
+
*/
|
|
4981
|
+
PerformanceEvents["AuthorityFactoryCreateDiscoveredInstance"] = "authorityFactoryCreateDiscoveredInstance";
|
|
4982
|
+
PerformanceEvents["AuthorityResolveEndpointsAsync"] = "authorityResolveEndpointsAsync";
|
|
4983
|
+
PerformanceEvents["AuthorityGetCloudDiscoveryMetadataFromNetwork"] = "authorityGetCloudDiscoveryMetadataFromNetwork";
|
|
4984
|
+
PerformanceEvents["AuthorityUpdateCloudDiscoveryMetadata"] = "authorityUpdateCloudDiscoveryMetadata";
|
|
4985
|
+
PerformanceEvents["AuthorityGetEndpointMetadataFromNetwork"] = "authorityGetEndpointMetadataFromNetwork";
|
|
4986
|
+
PerformanceEvents["AuthorityUpdateEndpointMetadata"] = "authorityUpdateEndpointMetadata";
|
|
4987
|
+
PerformanceEvents["AuthorityUpdateMetadataWithRegionalInformation"] = "authorityUpdateMetadataWithRegionalInformation";
|
|
4988
|
+
/**
|
|
4989
|
+
* Region Discovery functions
|
|
4990
|
+
*/
|
|
4991
|
+
PerformanceEvents["RegionDiscoveryDetectRegion"] = "regionDiscoveryDetectRegion";
|
|
4992
|
+
PerformanceEvents["RegionDiscoveryGetRegionFromIMDS"] = "regionDiscoveryGetRegionFromIMDS";
|
|
4993
|
+
PerformanceEvents["RegionDiscoveryGetCurrentVersion"] = "regionDiscoveryGetCurrentVersion";
|
|
4994
|
+
PerformanceEvents["AcquireTokenByCodeAsync"] = "acquireTokenByCodeAsync";
|
|
4995
|
+
PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
|
|
4996
|
+
PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
|
|
4997
|
+
PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
|
|
4998
|
+
PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
|
|
4999
|
+
PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
|
|
5000
|
+
PerformanceEvents["NativeMessageHandlerHandshake"] = "nativeMessageHandlerHandshake";
|
|
5001
|
+
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5002
|
+
/**
|
|
5003
|
+
* State of the performance event.
|
|
5004
|
+
*
|
|
5005
|
+
* @export
|
|
5006
|
+
* @enum {number}
|
|
5007
|
+
*/
|
|
5008
|
+
exports.PerformanceEventStatus = void 0;
|
|
5009
|
+
(function (PerformanceEventStatus) {
|
|
5010
|
+
PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
|
|
5011
|
+
PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
|
|
5012
|
+
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
5013
|
+
})(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
|
|
5014
|
+
var IntFields = new Set([
|
|
5015
|
+
"accessTokenSize",
|
|
5016
|
+
"durationMs",
|
|
5017
|
+
"idTokenSize",
|
|
5018
|
+
"matsSilentStatus",
|
|
5019
|
+
"matsHttpStatus",
|
|
5020
|
+
"refreshTokenSize",
|
|
5021
|
+
"queuedTimeMs",
|
|
5022
|
+
"startTimeMs",
|
|
5023
|
+
"status",
|
|
5024
|
+
]);
|
|
5025
|
+
|
|
5026
|
+
/*
|
|
5027
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5028
|
+
* Licensed under the MIT License.
|
|
5029
|
+
*/
|
|
5030
|
+
var KeyLocation;
|
|
5031
|
+
(function (KeyLocation) {
|
|
5032
|
+
KeyLocation["SW"] = "sw";
|
|
5033
|
+
KeyLocation["UHW"] = "uhw";
|
|
5034
|
+
})(KeyLocation || (KeyLocation = {}));
|
|
5035
|
+
var PopTokenGenerator = /** @class */ (function () {
|
|
5036
|
+
function PopTokenGenerator(cryptoUtils, performanceClient) {
|
|
5037
|
+
this.cryptoUtils = cryptoUtils;
|
|
5038
|
+
this.performanceClient = performanceClient;
|
|
5039
|
+
}
|
|
5040
|
+
/**
|
|
5041
|
+
* Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
|
|
5042
|
+
* and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
|
|
5043
|
+
* @param request
|
|
5044
|
+
* @returns
|
|
5045
|
+
*/
|
|
5046
|
+
PopTokenGenerator.prototype.generateCnf = function (request) {
|
|
5047
|
+
var _a, _b;
|
|
5048
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5049
|
+
var reqCnf, reqCnfString, _c;
|
|
5050
|
+
return __generator(this, function (_d) {
|
|
5051
|
+
switch (_d.label) {
|
|
5052
|
+
case 0:
|
|
5053
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5054
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5055
|
+
return [4 /*yield*/, this.generateKid(request)];
|
|
5056
|
+
case 1:
|
|
5057
|
+
reqCnf = _d.sent();
|
|
5058
|
+
reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
|
|
5059
|
+
_c = {
|
|
5060
|
+
kid: reqCnf.kid,
|
|
5061
|
+
reqCnfString: reqCnfString
|
|
5062
|
+
};
|
|
5063
|
+
return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
|
|
5064
|
+
case 2: return [2 /*return*/, (_c.reqCnfHash = _d.sent(),
|
|
5065
|
+
_c)];
|
|
5066
|
+
}
|
|
5067
|
+
});
|
|
5068
|
+
});
|
|
5069
|
+
};
|
|
5070
|
+
/**
|
|
5071
|
+
* Generates key_id for a SHR token request
|
|
5072
|
+
* @param request
|
|
5073
|
+
* @returns
|
|
4780
5074
|
*/
|
|
4781
5075
|
PopTokenGenerator.prototype.generateKid = function (request) {
|
|
5076
|
+
var _a;
|
|
4782
5077
|
return __awaiter(this, void 0, void 0, function () {
|
|
4783
5078
|
var kidThumbprint;
|
|
4784
|
-
return __generator(this, function (
|
|
4785
|
-
switch (
|
|
4786
|
-
case 0:
|
|
5079
|
+
return __generator(this, function (_b) {
|
|
5080
|
+
switch (_b.label) {
|
|
5081
|
+
case 0:
|
|
5082
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5083
|
+
return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
|
|
4787
5084
|
case 1:
|
|
4788
|
-
kidThumbprint =
|
|
5085
|
+
kidThumbprint = _b.sent();
|
|
4789
5086
|
return [2 /*return*/, {
|
|
4790
5087
|
kid: kidThumbprint,
|
|
4791
5088
|
xms_ksl: KeyLocation.SW
|
|
@@ -4944,13 +5241,14 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4944
5241
|
* Class that handles response parsing.
|
|
4945
5242
|
*/
|
|
4946
5243
|
var ResponseHandler = /** @class */ (function () {
|
|
4947
|
-
function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin) {
|
|
5244
|
+
function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin, performanceClient) {
|
|
4948
5245
|
this.clientId = clientId;
|
|
4949
5246
|
this.cacheStorage = cacheStorage;
|
|
4950
5247
|
this.cryptoObj = cryptoObj;
|
|
4951
5248
|
this.logger = logger;
|
|
4952
5249
|
this.serializableCache = serializableCache;
|
|
4953
5250
|
this.persistencePlugin = persistencePlugin;
|
|
5251
|
+
this.performanceClient = performanceClient;
|
|
4954
5252
|
}
|
|
4955
5253
|
/**
|
|
4956
5254
|
* Function which validates server authorization code response.
|
|
@@ -4968,7 +5266,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4968
5266
|
// Check for error
|
|
4969
5267
|
if (serverResponseHash.error || serverResponseHash.error_description || serverResponseHash.suberror) {
|
|
4970
5268
|
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror)) {
|
|
4971
|
-
throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
5269
|
+
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
5270
|
}
|
|
4973
5271
|
throw new ServerError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
4974
5272
|
}
|
|
@@ -4984,7 +5282,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4984
5282
|
// Check for error
|
|
4985
5283
|
if (serverResponse.error || serverResponse.error_description || serverResponse.suberror) {
|
|
4986
5284
|
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
|
|
4987
|
-
throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror);
|
|
5285
|
+
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
5286
|
}
|
|
4989
5287
|
var errString = serverResponse.error_codes + " - [" + serverResponse.timestamp + "]: " + serverResponse.error_description + " - Correlation ID: " + serverResponse.correlation_id + " - Trace ID: " + serverResponse.trace_id;
|
|
4990
5288
|
throw new ServerError(serverResponse.error, errString, serverResponse.suberror);
|
|
@@ -4996,11 +5294,13 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4996
5294
|
* @param authority
|
|
4997
5295
|
*/
|
|
4998
5296
|
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
|
|
5297
|
+
var _a;
|
|
4999
5298
|
return __awaiter(this, void 0, void 0, function () {
|
|
5000
5299
|
var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
5001
|
-
return __generator(this, function (
|
|
5002
|
-
switch (
|
|
5300
|
+
return __generator(this, function (_b) {
|
|
5301
|
+
switch (_b.label) {
|
|
5003
5302
|
case 0:
|
|
5303
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.HandleServerTokenResponse, serverTokenResponse.correlation_id);
|
|
5004
5304
|
if (serverTokenResponse.id_token) {
|
|
5005
5305
|
idTokenObj = new AuthToken(serverTokenResponse.id_token || Constants.EMPTY_STRING, this.cryptoObj);
|
|
5006
5306
|
// token nonce check (TODO: Add a warning if no nonce is given?)
|
|
@@ -5026,16 +5326,16 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5026
5326
|
// Add keyId from request to serverTokenResponse if defined
|
|
5027
5327
|
serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
|
|
5028
5328
|
cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
|
|
5029
|
-
|
|
5329
|
+
_b.label = 1;
|
|
5030
5330
|
case 1:
|
|
5031
|
-
|
|
5331
|
+
_b.trys.push([1, , 5, 8]);
|
|
5032
5332
|
if (!(this.persistencePlugin && this.serializableCache)) return [3 /*break*/, 3];
|
|
5033
5333
|
this.logger.verbose("Persistence enabled, calling beforeCacheAccess");
|
|
5034
5334
|
cacheContext = new TokenCacheContext(this.serializableCache, true);
|
|
5035
5335
|
return [4 /*yield*/, this.persistencePlugin.beforeCacheAccess(cacheContext)];
|
|
5036
5336
|
case 2:
|
|
5037
|
-
|
|
5038
|
-
|
|
5337
|
+
_b.sent();
|
|
5338
|
+
_b.label = 3;
|
|
5039
5339
|
case 3:
|
|
5040
5340
|
/*
|
|
5041
5341
|
* When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
|
|
@@ -5053,17 +5353,17 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5053
5353
|
}
|
|
5054
5354
|
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
5055
5355
|
case 4:
|
|
5056
|
-
|
|
5356
|
+
_b.sent();
|
|
5057
5357
|
return [3 /*break*/, 8];
|
|
5058
5358
|
case 5:
|
|
5059
5359
|
if (!(this.persistencePlugin && this.serializableCache && cacheContext)) return [3 /*break*/, 7];
|
|
5060
5360
|
this.logger.verbose("Persistence enabled, calling afterCacheAccess");
|
|
5061
5361
|
return [4 /*yield*/, this.persistencePlugin.afterCacheAccess(cacheContext)];
|
|
5062
5362
|
case 6:
|
|
5063
|
-
|
|
5064
|
-
|
|
5363
|
+
_b.sent();
|
|
5364
|
+
_b.label = 7;
|
|
5065
5365
|
case 7: return [7 /*endfinally*/];
|
|
5066
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse
|
|
5366
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse, serverRequestId)];
|
|
5067
5367
|
}
|
|
5068
5368
|
});
|
|
5069
5369
|
});
|
|
@@ -5149,7 +5449,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5149
5449
|
* @param fromTokenCache
|
|
5150
5450
|
* @param stateString
|
|
5151
5451
|
*/
|
|
5152
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState,
|
|
5452
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, serverTokenResponse, requestId) {
|
|
5153
5453
|
var _a, _b, _c;
|
|
5154
5454
|
return __awaiter(this, void 0, void 0, function () {
|
|
5155
5455
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
@@ -5185,6 +5485,10 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5185
5485
|
}
|
|
5186
5486
|
uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
|
|
5187
5487
|
tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
|
|
5488
|
+
// for hybrid + native bridge enablement, send back the native account Id
|
|
5489
|
+
if ((serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid) && !!cacheRecord.account) {
|
|
5490
|
+
cacheRecord.account.nativeAccountId = serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid;
|
|
5491
|
+
}
|
|
5188
5492
|
return [2 /*return*/, {
|
|
5189
5493
|
authority: authority.canonicalAuthority,
|
|
5190
5494
|
uniqueId: uid,
|
|
@@ -5204,7 +5508,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5204
5508
|
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
5205
5509
|
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
5206
5510
|
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
5207
|
-
code:
|
|
5511
|
+
code: serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_code,
|
|
5208
5512
|
fromNativeBroker: false,
|
|
5209
5513
|
}];
|
|
5210
5514
|
}
|
|
@@ -5240,13 +5544,17 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5240
5544
|
* @param request
|
|
5241
5545
|
*/
|
|
5242
5546
|
AuthorizationCodeClient.prototype.getAuthCodeUrl = function (request) {
|
|
5547
|
+
var _a, _b;
|
|
5243
5548
|
return __awaiter(this, void 0, void 0, function () {
|
|
5244
5549
|
var queryString;
|
|
5245
|
-
return __generator(this, function (
|
|
5246
|
-
switch (
|
|
5247
|
-
case 0:
|
|
5550
|
+
return __generator(this, function (_c) {
|
|
5551
|
+
switch (_c.label) {
|
|
5552
|
+
case 0:
|
|
5553
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.GetAuthCodeUrl, request.correlationId);
|
|
5554
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5555
|
+
return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
|
|
5248
5556
|
case 1:
|
|
5249
|
-
queryString =
|
|
5557
|
+
queryString = _c.sent();
|
|
5250
5558
|
return [2 /*return*/, UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString)];
|
|
5251
5559
|
}
|
|
5252
5560
|
});
|
|
@@ -5258,32 +5566,35 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5258
5566
|
* @param request
|
|
5259
5567
|
*/
|
|
5260
5568
|
AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
|
|
5261
|
-
var _a, _b, _c;
|
|
5569
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5262
5570
|
return __awaiter(this, void 0, void 0, function () {
|
|
5263
5571
|
var atsMeasurement, reqTimestamp, response, requestId, httpVerAuthority, responseHandler;
|
|
5264
5572
|
var _this = this;
|
|
5265
|
-
return __generator(this, function (
|
|
5266
|
-
switch (
|
|
5573
|
+
return __generator(this, function (_g) {
|
|
5574
|
+
switch (_g.label) {
|
|
5267
5575
|
case 0:
|
|
5268
|
-
|
|
5269
|
-
this.logger.info("in acquireToken call in auth-code client");
|
|
5270
|
-
if (!request || StringUtils.isEmpty(request.code)) {
|
|
5576
|
+
if (!request || !request.code) {
|
|
5271
5577
|
throw ClientAuthError.createTokenRequestCannotBeMadeError();
|
|
5272
5578
|
}
|
|
5579
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientAcquireToken, request.correlationId);
|
|
5580
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement("AuthCodeClientAcquireToken", request.correlationId);
|
|
5581
|
+
this.logger.info("in acquireToken call in auth-code client");
|
|
5273
5582
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5583
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5274
5584
|
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
5275
5585
|
case 1:
|
|
5276
|
-
response =
|
|
5277
|
-
requestId = (
|
|
5278
|
-
httpVerAuthority = (
|
|
5586
|
+
response = _g.sent();
|
|
5587
|
+
requestId = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
5588
|
+
httpVerAuthority = (_e = response.headers) === null || _e === void 0 ? void 0 : _e[exports.HeaderNames.X_MS_HTTP_VERSION];
|
|
5279
5589
|
if (httpVerAuthority) {
|
|
5280
5590
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
5281
5591
|
httpVerAuthority: httpVerAuthority
|
|
5282
5592
|
});
|
|
5283
5593
|
}
|
|
5284
|
-
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5594
|
+
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin, this.performanceClient);
|
|
5285
5595
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
5286
5596
|
responseHandler.validateTokenResponse(response.body);
|
|
5597
|
+
(_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
5287
5598
|
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId).then(function (result) {
|
|
5288
5599
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
5289
5600
|
success: true
|
|
@@ -5345,26 +5656,19 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5345
5656
|
* @param request
|
|
5346
5657
|
*/
|
|
5347
5658
|
AuthorizationCodeClient.prototype.executeTokenRequest = function (authority, request) {
|
|
5659
|
+
var _a, _b;
|
|
5348
5660
|
return __awaiter(this, void 0, void 0, function () {
|
|
5349
|
-
var
|
|
5350
|
-
return __generator(this, function (
|
|
5351
|
-
switch (
|
|
5661
|
+
var queryParametersString, endpoint, requestBody, ccsCredential, clientInfo, headers, thumbprint;
|
|
5662
|
+
return __generator(this, function (_c) {
|
|
5663
|
+
switch (_c.label) {
|
|
5352
5664
|
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
|
-
};
|
|
5665
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5666
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5667
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
5668
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
5364
5669
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
5365
5670
|
case 1:
|
|
5366
|
-
requestBody =
|
|
5367
|
-
queryParameters = this.createTokenQueryParameters(request);
|
|
5671
|
+
requestBody = _c.sent();
|
|
5368
5672
|
ccsCredential = undefined;
|
|
5369
5673
|
if (request.clientInfo) {
|
|
5370
5674
|
try {
|
|
@@ -5379,34 +5683,35 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5379
5683
|
}
|
|
5380
5684
|
}
|
|
5381
5685
|
headers = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);
|
|
5382
|
-
|
|
5686
|
+
thumbprint = {
|
|
5687
|
+
clientId: this.config.authOptions.clientId,
|
|
5688
|
+
authority: authority.canonicalAuthority,
|
|
5689
|
+
scopes: request.scopes,
|
|
5690
|
+
claims: request.claims,
|
|
5691
|
+
authenticationScheme: request.authenticationScheme,
|
|
5692
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5693
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5694
|
+
shrClaims: request.shrClaims,
|
|
5695
|
+
sshKid: request.sshKid
|
|
5696
|
+
};
|
|
5383
5697
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
5384
5698
|
}
|
|
5385
5699
|
});
|
|
5386
5700
|
});
|
|
5387
5701
|
};
|
|
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
5702
|
/**
|
|
5400
5703
|
* Generates a map for all the params to be sent to the service
|
|
5401
5704
|
* @param request
|
|
5402
5705
|
*/
|
|
5403
5706
|
AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
|
|
5707
|
+
var _a, _b;
|
|
5404
5708
|
return __awaiter(this, void 0, void 0, function () {
|
|
5405
5709
|
var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
|
|
5406
|
-
var
|
|
5407
|
-
return __generator(this, function (
|
|
5408
|
-
switch (
|
|
5710
|
+
var _c;
|
|
5711
|
+
return __generator(this, function (_d) {
|
|
5712
|
+
switch (_d.label) {
|
|
5409
5713
|
case 0:
|
|
5714
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5410
5715
|
parameterBuilder = new RequestParameterBuilder();
|
|
5411
5716
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5412
5717
|
/*
|
|
@@ -5447,10 +5752,11 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5447
5752
|
parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
|
|
5448
5753
|
parameterBuilder.addClientInfo();
|
|
5449
5754
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
5450
|
-
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5755
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
5756
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5451
5757
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5452
5758
|
case 1:
|
|
5453
|
-
reqCnfData =
|
|
5759
|
+
reqCnfData = _d.sent();
|
|
5454
5760
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
5455
5761
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
5456
5762
|
return [3 /*break*/, 3];
|
|
@@ -5463,7 +5769,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5463
5769
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5464
5770
|
}
|
|
5465
5771
|
}
|
|
5466
|
-
|
|
5772
|
+
_d.label = 3;
|
|
5467
5773
|
case 3:
|
|
5468
5774
|
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
5469
5775
|
parameterBuilder.addCorrelationId(correlationId);
|
|
@@ -5508,9 +5814,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5508
5814
|
}
|
|
5509
5815
|
// Add hybrid spa parameters if not already provided
|
|
5510
5816
|
if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[exports.AADServerParamKeys.RETURN_SPA_CODE])) {
|
|
5511
|
-
parameterBuilder.addExtraQueryParameters((
|
|
5512
|
-
|
|
5513
|
-
|
|
5817
|
+
parameterBuilder.addExtraQueryParameters((_c = {},
|
|
5818
|
+
_c[exports.AADServerParamKeys.RETURN_SPA_CODE] = "1",
|
|
5819
|
+
_c));
|
|
5514
5820
|
}
|
|
5515
5821
|
return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5516
5822
|
}
|
|
@@ -5522,11 +5828,13 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5522
5828
|
* @param request
|
|
5523
5829
|
*/
|
|
5524
5830
|
AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
|
|
5831
|
+
var _a;
|
|
5525
5832
|
return __awaiter(this, void 0, void 0, function () {
|
|
5526
5833
|
var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
|
|
5527
|
-
return __generator(this, function (
|
|
5528
|
-
switch (
|
|
5834
|
+
return __generator(this, function (_b) {
|
|
5835
|
+
switch (_b.label) {
|
|
5529
5836
|
case 0:
|
|
5837
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5530
5838
|
parameterBuilder = new RequestParameterBuilder();
|
|
5531
5839
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5532
5840
|
requestScopes = __spreadArrays(request.scopes || [], request.extraScopesToConsent || []);
|
|
@@ -5637,9 +5945,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5637
5945
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5638
5946
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5639
5947
|
case 1:
|
|
5640
|
-
reqCnfData =
|
|
5948
|
+
reqCnfData = _b.sent();
|
|
5641
5949
|
parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
|
|
5642
|
-
|
|
5950
|
+
_b.label = 2;
|
|
5643
5951
|
case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5644
5952
|
}
|
|
5645
5953
|
});
|
|
@@ -5731,8 +6039,10 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5731
6039
|
*/
|
|
5732
6040
|
DeviceCodeClient.prototype.getDeviceCode = function (request) {
|
|
5733
6041
|
return __awaiter(this, void 0, void 0, function () {
|
|
5734
|
-
var queryString, headers, thumbprint;
|
|
6042
|
+
var queryParametersString, endpoint, queryString, headers, thumbprint;
|
|
5735
6043
|
return __generator(this, function (_a) {
|
|
6044
|
+
queryParametersString = this.createExtraQueryParameters(request);
|
|
6045
|
+
endpoint = UrlString.appendQueryString(this.authority.deviceCodeEndpoint, queryParametersString);
|
|
5736
6046
|
queryString = this.createQueryString(request);
|
|
5737
6047
|
headers = this.createTokenRequestHeaders();
|
|
5738
6048
|
thumbprint = {
|
|
@@ -5746,10 +6056,21 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5746
6056
|
shrClaims: request.shrClaims,
|
|
5747
6057
|
sshKid: request.sshKid
|
|
5748
6058
|
};
|
|
5749
|
-
return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(
|
|
6059
|
+
return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(endpoint, queryString, headers, thumbprint)];
|
|
5750
6060
|
});
|
|
5751
6061
|
});
|
|
5752
6062
|
};
|
|
6063
|
+
/**
|
|
6064
|
+
* Creates query string for the device code request
|
|
6065
|
+
* @param request
|
|
6066
|
+
*/
|
|
6067
|
+
DeviceCodeClient.prototype.createExtraQueryParameters = function (request) {
|
|
6068
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
6069
|
+
if (request.extraQueryParameters) {
|
|
6070
|
+
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
6071
|
+
}
|
|
6072
|
+
return parameterBuilder.createQueryString();
|
|
6073
|
+
};
|
|
5753
6074
|
/**
|
|
5754
6075
|
* Executes POST request to device code endpoint
|
|
5755
6076
|
* @param deviceCodeEndpoint
|
|
@@ -5763,8 +6084,7 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5763
6084
|
switch (_b.label) {
|
|
5764
6085
|
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, deviceCodeEndpoint, {
|
|
5765
6086
|
body: queryString,
|
|
5766
|
-
headers: headers
|
|
5767
|
-
proxyUrl: this.config.systemOptions.proxyUrl
|
|
6087
|
+
headers: headers
|
|
5768
6088
|
})];
|
|
5769
6089
|
case 1:
|
|
5770
6090
|
_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 +6107,9 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5787
6107
|
var parameterBuilder = new RequestParameterBuilder();
|
|
5788
6108
|
parameterBuilder.addScopes(request.scopes);
|
|
5789
6109
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6110
|
+
if (request.extraQueryParameters) {
|
|
6111
|
+
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
6112
|
+
}
|
|
5790
6113
|
if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5791
6114
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5792
6115
|
}
|
|
@@ -5823,10 +6146,12 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5823
6146
|
*/
|
|
5824
6147
|
DeviceCodeClient.prototype.acquireTokenWithDeviceCode = function (request, deviceCodeResponse) {
|
|
5825
6148
|
return __awaiter(this, void 0, void 0, function () {
|
|
5826
|
-
var requestBody, headers, userSpecifiedTimeout, deviceCodeExpirationTime, pollingIntervalMilli, thumbprint, response;
|
|
6149
|
+
var queryParametersString, endpoint, requestBody, headers, userSpecifiedTimeout, deviceCodeExpirationTime, pollingIntervalMilli, thumbprint, response;
|
|
5827
6150
|
return __generator(this, function (_a) {
|
|
5828
6151
|
switch (_a.label) {
|
|
5829
6152
|
case 0:
|
|
6153
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6154
|
+
endpoint = UrlString.appendQueryString(this.authority.tokenEndpoint, queryParametersString);
|
|
5830
6155
|
requestBody = this.createTokenRequestBody(request, deviceCodeResponse);
|
|
5831
6156
|
headers = this.createTokenRequestHeaders();
|
|
5832
6157
|
userSpecifiedTimeout = request.timeout ? TimeUtils.nowSeconds() + request.timeout : undefined;
|
|
@@ -5846,7 +6171,7 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5846
6171
|
shrClaims: request.shrClaims,
|
|
5847
6172
|
sshKid: request.sshKid
|
|
5848
6173
|
};
|
|
5849
|
-
return [4 /*yield*/, this.executePostToTokenEndpoint(
|
|
6174
|
+
return [4 /*yield*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
5850
6175
|
case 2:
|
|
5851
6176
|
response = _a.sent();
|
|
5852
6177
|
if (!(response.body && response.body.error)) return [3 /*break*/, 6];
|
|
@@ -5872,167 +6197,37 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5872
6197
|
*/
|
|
5873
6198
|
this.logger.error("Polling stopped for unknown reasons.");
|
|
5874
6199
|
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";
|
|
6013
|
-
/**
|
|
6014
|
-
* Time taken for acquiring cached refresh token
|
|
6015
|
-
*/
|
|
6016
|
-
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
6017
|
-
PerformanceEvents["AcquireTokenByCodeAsync"] = "acquireTokenByCodeAsync";
|
|
6018
|
-
PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
|
|
6019
|
-
PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
|
|
6020
|
-
PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
|
|
6021
|
-
PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
|
|
6022
|
-
PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
|
|
6023
|
-
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
6024
|
-
/**
|
|
6025
|
-
* State of the performance event.
|
|
6026
|
-
*
|
|
6027
|
-
* @export
|
|
6028
|
-
* @enum {number}
|
|
6029
|
-
*/
|
|
6030
|
-
exports.PerformanceEventStatus = void 0;
|
|
6031
|
-
(function (PerformanceEventStatus) {
|
|
6032
|
-
PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
|
|
6033
|
-
PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
|
|
6034
|
-
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
6035
|
-
})(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
|
|
6200
|
+
}
|
|
6201
|
+
});
|
|
6202
|
+
});
|
|
6203
|
+
};
|
|
6204
|
+
/**
|
|
6205
|
+
* Creates query parameters and converts to string.
|
|
6206
|
+
* @param request
|
|
6207
|
+
* @param deviceCodeResponse
|
|
6208
|
+
*/
|
|
6209
|
+
DeviceCodeClient.prototype.createTokenRequestBody = function (request, deviceCodeResponse) {
|
|
6210
|
+
var requestParameters = new RequestParameterBuilder();
|
|
6211
|
+
requestParameters.addScopes(request.scopes);
|
|
6212
|
+
requestParameters.addClientId(this.config.authOptions.clientId);
|
|
6213
|
+
requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);
|
|
6214
|
+
requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);
|
|
6215
|
+
var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
6216
|
+
requestParameters.addCorrelationId(correlationId);
|
|
6217
|
+
requestParameters.addClientInfo();
|
|
6218
|
+
requestParameters.addLibraryInfo(this.config.libraryInfo);
|
|
6219
|
+
requestParameters.addApplicationTelemetry(this.config.telemetry.application);
|
|
6220
|
+
requestParameters.addThrottling();
|
|
6221
|
+
if (this.serverTelemetryManager) {
|
|
6222
|
+
requestParameters.addServerTelemetry(this.serverTelemetryManager);
|
|
6223
|
+
}
|
|
6224
|
+
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
6225
|
+
requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
6226
|
+
}
|
|
6227
|
+
return requestParameters.createQueryString();
|
|
6228
|
+
};
|
|
6229
|
+
return DeviceCodeClient;
|
|
6230
|
+
}(BaseClient));
|
|
6036
6231
|
|
|
6037
6232
|
/*
|
|
6038
6233
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6047,31 +6242,34 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6047
6242
|
return _super.call(this, configuration, performanceClient) || this;
|
|
6048
6243
|
}
|
|
6049
6244
|
RefreshTokenClient.prototype.acquireToken = function (request) {
|
|
6050
|
-
var _a, _b, _c, _d;
|
|
6245
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6051
6246
|
return __awaiter(this, void 0, void 0, function () {
|
|
6052
6247
|
var atsMeasurement, reqTimestamp, response, httpVerToken, requestId, responseHandler;
|
|
6053
6248
|
var _this = this;
|
|
6054
|
-
return __generator(this, function (
|
|
6055
|
-
switch (
|
|
6249
|
+
return __generator(this, function (_h) {
|
|
6250
|
+
switch (_h.label) {
|
|
6056
6251
|
case 0:
|
|
6057
|
-
|
|
6252
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6253
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6058
6254
|
this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
|
|
6059
6255
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6256
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6060
6257
|
return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
6061
6258
|
case 1:
|
|
6062
|
-
response =
|
|
6063
|
-
httpVerToken = (
|
|
6259
|
+
response = _h.sent();
|
|
6260
|
+
httpVerToken = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[exports.HeaderNames.X_MS_HTTP_VERSION];
|
|
6064
6261
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
6065
|
-
refreshTokenSize: ((
|
|
6262
|
+
refreshTokenSize: ((_e = response.body.refresh_token) === null || _e === void 0 ? void 0 : _e.length) || 0,
|
|
6066
6263
|
});
|
|
6067
6264
|
if (httpVerToken) {
|
|
6068
6265
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
6069
6266
|
httpVerToken: httpVerToken,
|
|
6070
6267
|
});
|
|
6071
6268
|
}
|
|
6072
|
-
requestId = (
|
|
6269
|
+
requestId = (_f = response.headers) === null || _f === void 0 ? void 0 : _f[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
6073
6270
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
6074
6271
|
responseHandler.validateTokenResponse(response.body);
|
|
6272
|
+
(_g = this.performanceClient) === null || _g === void 0 ? void 0 : _g.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
6075
6273
|
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
|
|
6076
6274
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6077
6275
|
success: true
|
|
@@ -6096,13 +6294,15 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6096
6294
|
* @param request
|
|
6097
6295
|
*/
|
|
6098
6296
|
RefreshTokenClient.prototype.acquireTokenByRefreshToken = function (request) {
|
|
6297
|
+
var _a, _b, _c, _d;
|
|
6099
6298
|
return __awaiter(this, void 0, void 0, function () {
|
|
6100
6299
|
var isFOCI, noFamilyRTInCache, clientMismatchErrorWithFamilyRT;
|
|
6101
|
-
return __generator(this, function (
|
|
6300
|
+
return __generator(this, function (_e) {
|
|
6102
6301
|
// Cannot renew token if no request object is given.
|
|
6103
6302
|
if (!request) {
|
|
6104
6303
|
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
6105
6304
|
}
|
|
6305
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
|
|
6106
6306
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
6107
6307
|
if (!request.account) {
|
|
6108
6308
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -6111,6 +6311,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6111
6311
|
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
6112
6312
|
if (isFOCI) {
|
|
6113
6313
|
try {
|
|
6314
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6114
6315
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
|
|
6115
6316
|
}
|
|
6116
6317
|
catch (e) {
|
|
@@ -6118,6 +6319,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6118
6319
|
clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
|
|
6119
6320
|
// if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
|
|
6120
6321
|
if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
|
|
6322
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6121
6323
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
|
|
6122
6324
|
// throw in all other cases
|
|
6123
6325
|
}
|
|
@@ -6127,6 +6329,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6127
6329
|
}
|
|
6128
6330
|
}
|
|
6129
6331
|
// fall back to application refresh token acquisition
|
|
6332
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6130
6333
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
|
|
6131
6334
|
});
|
|
6132
6335
|
});
|
|
@@ -6136,11 +6339,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6136
6339
|
* @param request
|
|
6137
6340
|
*/
|
|
6138
6341
|
RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
|
|
6139
|
-
var _a;
|
|
6342
|
+
var _a, _b, _c;
|
|
6140
6343
|
return __awaiter(this, void 0, void 0, function () {
|
|
6141
6344
|
var atsMeasurement, refreshToken, refreshTokenRequest;
|
|
6142
|
-
return __generator(this, function (
|
|
6143
|
-
|
|
6345
|
+
return __generator(this, function (_d) {
|
|
6346
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6347
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6144
6348
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6145
6349
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
6146
6350
|
if (!refreshToken) {
|
|
@@ -6155,6 +6359,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6155
6359
|
credential: request.account.homeAccountId,
|
|
6156
6360
|
type: exports.CcsCredentialType.HOME_ACCOUNT_ID
|
|
6157
6361
|
} });
|
|
6362
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6158
6363
|
return [2 /*return*/, this.acquireToken(refreshTokenRequest)];
|
|
6159
6364
|
});
|
|
6160
6365
|
});
|
|
@@ -6165,17 +6370,20 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6165
6370
|
* @param authority
|
|
6166
6371
|
*/
|
|
6167
6372
|
RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
|
|
6168
|
-
var _a;
|
|
6373
|
+
var _a, _b, _c;
|
|
6169
6374
|
return __awaiter(this, void 0, void 0, function () {
|
|
6170
|
-
var acquireTokenMeasurement,
|
|
6171
|
-
return __generator(this, function (
|
|
6172
|
-
switch (
|
|
6375
|
+
var acquireTokenMeasurement, queryParametersString, endpoint, requestBody, headers, thumbprint;
|
|
6376
|
+
return __generator(this, function (_d) {
|
|
6377
|
+
switch (_d.label) {
|
|
6173
6378
|
case 0:
|
|
6174
|
-
|
|
6379
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6380
|
+
acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6381
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6382
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6383
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6175
6384
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
6176
6385
|
case 1:
|
|
6177
|
-
requestBody =
|
|
6178
|
-
queryParameters = this.createTokenQueryParameters(request);
|
|
6386
|
+
requestBody = _d.sent();
|
|
6179
6387
|
headers = this.createTokenRequestHeaders(request.ccsCredential);
|
|
6180
6388
|
thumbprint = {
|
|
6181
6389
|
clientId: this.config.authOptions.clientId,
|
|
@@ -6188,7 +6396,6 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6188
6396
|
shrClaims: request.shrClaims,
|
|
6189
6397
|
sshKid: request.sshKid
|
|
6190
6398
|
};
|
|
6191
|
-
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
|
|
6192
6399
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6193
6400
|
.then(function (result) {
|
|
6194
6401
|
acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
|
|
@@ -6206,30 +6413,20 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6206
6413
|
});
|
|
6207
6414
|
});
|
|
6208
6415
|
};
|
|
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
6416
|
/**
|
|
6221
6417
|
* Helper function to create the token request body
|
|
6222
6418
|
* @param request
|
|
6223
6419
|
*/
|
|
6224
6420
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
6225
|
-
var _a;
|
|
6421
|
+
var _a, _b, _c;
|
|
6226
6422
|
return __awaiter(this, void 0, void 0, function () {
|
|
6227
6423
|
var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
|
|
6228
|
-
return __generator(this, function (
|
|
6229
|
-
switch (
|
|
6424
|
+
return __generator(this, function (_d) {
|
|
6425
|
+
switch (_d.label) {
|
|
6230
6426
|
case 0:
|
|
6427
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6231
6428
|
correlationId = request.correlationId;
|
|
6232
|
-
acquireTokenMeasurement = (
|
|
6429
|
+
acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6233
6430
|
parameterBuilder = new RequestParameterBuilder();
|
|
6234
6431
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6235
6432
|
parameterBuilder.addScopes(request.scopes);
|
|
@@ -6252,10 +6449,11 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6252
6449
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
6253
6450
|
}
|
|
6254
6451
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
6255
|
-
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
6452
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
6453
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
6256
6454
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
6257
6455
|
case 1:
|
|
6258
|
-
reqCnfData =
|
|
6456
|
+
reqCnfData = _d.sent();
|
|
6259
6457
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
6260
6458
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
6261
6459
|
return [3 /*break*/, 3];
|
|
@@ -6271,7 +6469,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6271
6469
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
6272
6470
|
}
|
|
6273
6471
|
}
|
|
6274
|
-
|
|
6472
|
+
_d.label = 3;
|
|
6275
6473
|
case 3:
|
|
6276
6474
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
6277
6475
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
@@ -6403,7 +6601,7 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6403
6601
|
*/
|
|
6404
6602
|
ClientCredentialClient.prototype.executeTokenRequest = function (request, authority) {
|
|
6405
6603
|
return __awaiter(this, void 0, void 0, function () {
|
|
6406
|
-
var serverTokenResponse, reqTimestamp, appTokenPropviderParameters, appTokenProviderResult, requestBody, headers, thumbprint, response, responseHandler, tokenResponse;
|
|
6604
|
+
var serverTokenResponse, reqTimestamp, appTokenPropviderParameters, appTokenProviderResult, queryParametersString, endpoint, requestBody, headers, thumbprint, response, responseHandler, tokenResponse;
|
|
6407
6605
|
return __generator(this, function (_a) {
|
|
6408
6606
|
switch (_a.label) {
|
|
6409
6607
|
case 0:
|
|
@@ -6427,6 +6625,8 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6427
6625
|
};
|
|
6428
6626
|
return [3 /*break*/, 4];
|
|
6429
6627
|
case 2:
|
|
6628
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6629
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6430
6630
|
requestBody = this.createTokenRequestBody(request);
|
|
6431
6631
|
headers = this.createTokenRequestHeaders();
|
|
6432
6632
|
thumbprint = {
|
|
@@ -6441,7 +6641,7 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6441
6641
|
sshKid: request.sshKid
|
|
6442
6642
|
};
|
|
6443
6643
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6444
|
-
return [4 /*yield*/, this.executePostToTokenEndpoint(
|
|
6644
|
+
return [4 /*yield*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
6445
6645
|
case 3:
|
|
6446
6646
|
response = _a.sent();
|
|
6447
6647
|
serverTokenResponse = response.body;
|
|
@@ -6657,10 +6857,12 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
6657
6857
|
*/
|
|
6658
6858
|
OnBehalfOfClient.prototype.executeTokenRequest = function (request, authority, userAssertionHash) {
|
|
6659
6859
|
return __awaiter(this, void 0, void 0, function () {
|
|
6660
|
-
var requestBody, headers, thumbprint, reqTimestamp, response, responseHandler, tokenResponse;
|
|
6860
|
+
var queryParametersString, endpoint, requestBody, headers, thumbprint, reqTimestamp, response, responseHandler, tokenResponse;
|
|
6661
6861
|
return __generator(this, function (_a) {
|
|
6662
6862
|
switch (_a.label) {
|
|
6663
6863
|
case 0:
|
|
6864
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6865
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6664
6866
|
requestBody = this.createTokenRequestBody(request);
|
|
6665
6867
|
headers = this.createTokenRequestHeaders();
|
|
6666
6868
|
thumbprint = {
|
|
@@ -6675,7 +6877,7 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
6675
6877
|
sshKid: request.sshKid
|
|
6676
6878
|
};
|
|
6677
6879
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6678
|
-
return [4 /*yield*/, this.executePostToTokenEndpoint(
|
|
6880
|
+
return [4 /*yield*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
6679
6881
|
case 1:
|
|
6680
6882
|
response = _a.sent();
|
|
6681
6883
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
@@ -6897,8 +7099,15 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6897
7099
|
*/
|
|
6898
7100
|
UsernamePasswordClient.prototype.executeTokenRequest = function (authority, request) {
|
|
6899
7101
|
return __awaiter(this, void 0, void 0, function () {
|
|
6900
|
-
var
|
|
7102
|
+
var queryParametersString, endpoint, requestBody, headers, thumbprint;
|
|
6901
7103
|
return __generator(this, function (_a) {
|
|
7104
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
7105
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
7106
|
+
requestBody = this.createTokenRequestBody(request);
|
|
7107
|
+
headers = this.createTokenRequestHeaders({
|
|
7108
|
+
credential: request.username,
|
|
7109
|
+
type: exports.CcsCredentialType.UPN
|
|
7110
|
+
});
|
|
6902
7111
|
thumbprint = {
|
|
6903
7112
|
clientId: this.config.authOptions.clientId,
|
|
6904
7113
|
authority: authority.canonicalAuthority,
|
|
@@ -6910,12 +7119,7 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6910
7119
|
shrClaims: request.shrClaims,
|
|
6911
7120
|
sshKid: request.sshKid
|
|
6912
7121
|
};
|
|
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)];
|
|
7122
|
+
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
6919
7123
|
});
|
|
6920
7124
|
});
|
|
6921
7125
|
};
|
|
@@ -7089,61 +7293,65 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
7089
7293
|
* Licensed under the MIT License.
|
|
7090
7294
|
*/
|
|
7091
7295
|
var RegionDiscovery = /** @class */ (function () {
|
|
7092
|
-
function RegionDiscovery(networkInterface) {
|
|
7296
|
+
function RegionDiscovery(networkInterface, performanceClient, correlationId) {
|
|
7093
7297
|
this.networkInterface = networkInterface;
|
|
7298
|
+
this.performanceClient = performanceClient;
|
|
7299
|
+
this.correlationId = correlationId;
|
|
7094
7300
|
}
|
|
7095
7301
|
/**
|
|
7096
7302
|
* Detect the region from the application's environment.
|
|
7097
7303
|
*
|
|
7098
7304
|
* @returns Promise<string | null>
|
|
7099
7305
|
*/
|
|
7100
|
-
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata
|
|
7306
|
+
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
|
|
7307
|
+
var _a, _b, _c, _d;
|
|
7101
7308
|
return __awaiter(this, void 0, void 0, function () {
|
|
7102
7309
|
var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
|
|
7103
|
-
return __generator(this, function (
|
|
7104
|
-
switch (
|
|
7310
|
+
return __generator(this, function (_e) {
|
|
7311
|
+
switch (_e.label) {
|
|
7105
7312
|
case 0:
|
|
7313
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7106
7314
|
autodetectedRegionName = environmentRegion;
|
|
7107
7315
|
if (!!autodetectedRegionName) return [3 /*break*/, 8];
|
|
7108
7316
|
options = RegionDiscovery.IMDS_OPTIONS;
|
|
7109
|
-
|
|
7110
|
-
options.proxyUrl = proxyUrl;
|
|
7111
|
-
}
|
|
7112
|
-
_a.label = 1;
|
|
7317
|
+
_e.label = 1;
|
|
7113
7318
|
case 1:
|
|
7114
|
-
|
|
7319
|
+
_e.trys.push([1, 6, , 7]);
|
|
7320
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7115
7321
|
return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
|
|
7116
7322
|
case 2:
|
|
7117
|
-
localIMDSVersionResponse =
|
|
7323
|
+
localIMDSVersionResponse = _e.sent();
|
|
7118
7324
|
if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
7119
7325
|
autodetectedRegionName = localIMDSVersionResponse.body;
|
|
7120
7326
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
|
|
7121
7327
|
}
|
|
7122
7328
|
if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
|
|
7329
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
7123
7330
|
return [4 /*yield*/, this.getCurrentVersion(options)];
|
|
7124
7331
|
case 3:
|
|
7125
|
-
currentIMDSVersion =
|
|
7332
|
+
currentIMDSVersion = _e.sent();
|
|
7126
7333
|
if (!currentIMDSVersion) {
|
|
7127
7334
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
7128
7335
|
return [2 /*return*/, null];
|
|
7129
7336
|
}
|
|
7337
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7130
7338
|
return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
|
|
7131
7339
|
case 4:
|
|
7132
|
-
currentIMDSVersionResponse =
|
|
7340
|
+
currentIMDSVersionResponse = _e.sent();
|
|
7133
7341
|
if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
7134
7342
|
autodetectedRegionName = currentIMDSVersionResponse.body;
|
|
7135
7343
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
|
|
7136
7344
|
}
|
|
7137
|
-
|
|
7345
|
+
_e.label = 5;
|
|
7138
7346
|
case 5: return [3 /*break*/, 7];
|
|
7139
7347
|
case 6:
|
|
7140
|
-
|
|
7348
|
+
_e.sent();
|
|
7141
7349
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
7142
7350
|
return [2 /*return*/, null];
|
|
7143
7351
|
case 7: return [3 /*break*/, 9];
|
|
7144
7352
|
case 8:
|
|
7145
7353
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.ENVIRONMENT_VARIABLE;
|
|
7146
|
-
|
|
7354
|
+
_e.label = 9;
|
|
7147
7355
|
case 9:
|
|
7148
7356
|
// If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
|
|
7149
7357
|
if (!autodetectedRegionName) {
|
|
@@ -7161,8 +7369,10 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
7161
7369
|
* @returns Promise<NetworkResponse<string>>
|
|
7162
7370
|
*/
|
|
7163
7371
|
RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
|
|
7372
|
+
var _a;
|
|
7164
7373
|
return __awaiter(this, void 0, void 0, function () {
|
|
7165
|
-
return __generator(this, function (
|
|
7374
|
+
return __generator(this, function (_b) {
|
|
7375
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7166
7376
|
return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
|
|
7167
7377
|
});
|
|
7168
7378
|
});
|
|
@@ -7173,24 +7383,28 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
7173
7383
|
* @returns Promise<string | null>
|
|
7174
7384
|
*/
|
|
7175
7385
|
RegionDiscovery.prototype.getCurrentVersion = function (options) {
|
|
7386
|
+
var _a;
|
|
7176
7387
|
return __awaiter(this, void 0, void 0, function () {
|
|
7177
7388
|
var response;
|
|
7178
|
-
return __generator(this, function (
|
|
7179
|
-
switch (
|
|
7389
|
+
return __generator(this, function (_b) {
|
|
7390
|
+
switch (_b.label) {
|
|
7180
7391
|
case 0:
|
|
7181
|
-
_a.
|
|
7182
|
-
|
|
7392
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
7393
|
+
_b.label = 1;
|
|
7183
7394
|
case 1:
|
|
7184
|
-
|
|
7395
|
+
_b.trys.push([1, 3, , 4]);
|
|
7396
|
+
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
|
|
7397
|
+
case 2:
|
|
7398
|
+
response = _b.sent();
|
|
7185
7399
|
// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
|
|
7186
7400
|
if (response.status === ResponseCodes.httpBadRequest && response.body && response.body["newest-versions"] && response.body["newest-versions"].length > 0) {
|
|
7187
7401
|
return [2 /*return*/, response.body["newest-versions"][0]];
|
|
7188
7402
|
}
|
|
7189
7403
|
return [2 /*return*/, null];
|
|
7190
|
-
case
|
|
7191
|
-
|
|
7404
|
+
case 3:
|
|
7405
|
+
_b.sent();
|
|
7192
7406
|
return [2 /*return*/, null];
|
|
7193
|
-
case
|
|
7407
|
+
case 4: return [2 /*return*/];
|
|
7194
7408
|
}
|
|
7195
7409
|
});
|
|
7196
7410
|
});
|
|
@@ -7213,16 +7427,17 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
7213
7427
|
* endpoint. It will store the pertinent config data in this object for use during token calls.
|
|
7214
7428
|
*/
|
|
7215
7429
|
var Authority = /** @class */ (function () {
|
|
7216
|
-
function Authority(authority, networkInterface, cacheManager, authorityOptions, logger,
|
|
7430
|
+
function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7217
7431
|
this.canonicalAuthority = authority;
|
|
7218
7432
|
this._canonicalAuthority.validateAsUri();
|
|
7219
7433
|
this.networkInterface = networkInterface;
|
|
7220
7434
|
this.cacheManager = cacheManager;
|
|
7221
7435
|
this.authorityOptions = authorityOptions;
|
|
7222
|
-
this.regionDiscovery = new RegionDiscovery(networkInterface);
|
|
7223
7436
|
this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
|
|
7224
|
-
this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
|
|
7225
7437
|
this.logger = logger;
|
|
7438
|
+
this.performanceClient = performanceClient;
|
|
7439
|
+
this.correlationId = correlationId;
|
|
7440
|
+
this.regionDiscovery = new RegionDiscovery(networkInterface, this.performanceClient, this.correlationId);
|
|
7226
7441
|
}
|
|
7227
7442
|
Object.defineProperty(Authority.prototype, "authorityType", {
|
|
7228
7443
|
// See above for AuthorityType
|
|
@@ -7459,23 +7674,27 @@ var Authority = /** @class */ (function () {
|
|
|
7459
7674
|
* and the /authorize, /token and logout endpoints.
|
|
7460
7675
|
*/
|
|
7461
7676
|
Authority.prototype.resolveEndpointsAsync = function () {
|
|
7677
|
+
var _a, _b, _c;
|
|
7462
7678
|
return __awaiter(this, void 0, void 0, function () {
|
|
7463
7679
|
var metadataEntity, cloudDiscoverySource, endpointSource, cacheKey;
|
|
7464
|
-
return __generator(this, function (
|
|
7465
|
-
switch (
|
|
7680
|
+
return __generator(this, function (_d) {
|
|
7681
|
+
switch (_d.label) {
|
|
7466
7682
|
case 0:
|
|
7683
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, this.correlationId);
|
|
7467
7684
|
metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
|
|
7468
7685
|
if (!metadataEntity) {
|
|
7469
7686
|
metadataEntity = new AuthorityMetadataEntity();
|
|
7470
7687
|
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
7471
7688
|
}
|
|
7689
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7472
7690
|
return [4 /*yield*/, this.updateCloudDiscoveryMetadata(metadataEntity)];
|
|
7473
7691
|
case 1:
|
|
7474
|
-
cloudDiscoverySource =
|
|
7692
|
+
cloudDiscoverySource = _d.sent();
|
|
7475
7693
|
this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
|
|
7694
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7476
7695
|
return [4 /*yield*/, this.updateEndpointMetadata(metadataEntity)];
|
|
7477
7696
|
case 2:
|
|
7478
|
-
endpointSource =
|
|
7697
|
+
endpointSource = _d.sent();
|
|
7479
7698
|
if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {
|
|
7480
7699
|
// Reset the expiration time unless both values came from a successful cache lookup
|
|
7481
7700
|
metadataEntity.resetExpiresAt();
|
|
@@ -7494,12 +7713,13 @@ var Authority = /** @class */ (function () {
|
|
|
7494
7713
|
* @param metadataEntity
|
|
7495
7714
|
*/
|
|
7496
7715
|
Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
|
|
7497
|
-
var _a, _b;
|
|
7716
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7498
7717
|
return __awaiter(this, void 0, void 0, function () {
|
|
7499
7718
|
var metadata, harcodedMetadata;
|
|
7500
|
-
return __generator(this, function (
|
|
7501
|
-
switch (
|
|
7719
|
+
return __generator(this, function (_g) {
|
|
7720
|
+
switch (_g.label) {
|
|
7502
7721
|
case 0:
|
|
7722
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7503
7723
|
metadata = this.getEndpointMetadataFromConfig();
|
|
7504
7724
|
if (metadata) {
|
|
7505
7725
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
@@ -7510,25 +7730,28 @@ var Authority = /** @class */ (function () {
|
|
|
7510
7730
|
return [2 /*return*/, AuthorityMetadataSource.CACHE];
|
|
7511
7731
|
}
|
|
7512
7732
|
harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7733
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7513
7734
|
return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
|
|
7514
7735
|
case 1:
|
|
7515
|
-
metadata =
|
|
7736
|
+
metadata = _g.sent();
|
|
7516
7737
|
if (!metadata) return [3 /*break*/, 4];
|
|
7517
|
-
if (!((
|
|
7738
|
+
if (!((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion)) return [3 /*break*/, 3];
|
|
7739
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7518
7740
|
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
|
|
7519
7741
|
case 2:
|
|
7520
|
-
metadata =
|
|
7521
|
-
|
|
7742
|
+
metadata = _g.sent();
|
|
7743
|
+
_g.label = 3;
|
|
7522
7744
|
case 3:
|
|
7523
7745
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
7524
7746
|
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
|
|
7525
7747
|
case 4:
|
|
7526
7748
|
if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
|
|
7527
|
-
if (!((
|
|
7749
|
+
if (!((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion)) return [3 /*break*/, 6];
|
|
7750
|
+
(_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7528
7751
|
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
|
|
7529
7752
|
case 5:
|
|
7530
|
-
harcodedMetadata =
|
|
7531
|
-
|
|
7753
|
+
harcodedMetadata = _g.sent();
|
|
7754
|
+
_g.label = 6;
|
|
7532
7755
|
case 6:
|
|
7533
7756
|
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
7534
7757
|
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
|
|
@@ -7568,25 +7791,24 @@ var Authority = /** @class */ (function () {
|
|
|
7568
7791
|
* @param hasHardcodedMetadata boolean
|
|
7569
7792
|
*/
|
|
7570
7793
|
Authority.prototype.getEndpointMetadataFromNetwork = function () {
|
|
7794
|
+
var _a;
|
|
7571
7795
|
return __awaiter(this, void 0, void 0, function () {
|
|
7572
7796
|
var options, response;
|
|
7573
|
-
return __generator(this, function (
|
|
7574
|
-
switch (
|
|
7797
|
+
return __generator(this, function (_b) {
|
|
7798
|
+
switch (_b.label) {
|
|
7575
7799
|
case 0:
|
|
7800
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7576
7801
|
options = {};
|
|
7577
|
-
|
|
7578
|
-
options.proxyUrl = this.proxyUrl;
|
|
7579
|
-
}
|
|
7580
|
-
_a.label = 1;
|
|
7802
|
+
_b.label = 1;
|
|
7581
7803
|
case 1:
|
|
7582
|
-
|
|
7804
|
+
_b.trys.push([1, 3, , 4]);
|
|
7583
7805
|
return [4 /*yield*/, this.networkInterface.
|
|
7584
7806
|
sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
|
|
7585
7807
|
case 2:
|
|
7586
|
-
response =
|
|
7808
|
+
response = _b.sent();
|
|
7587
7809
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
7588
7810
|
case 3:
|
|
7589
|
-
|
|
7811
|
+
_b.sent();
|
|
7590
7812
|
return [2 /*return*/, null];
|
|
7591
7813
|
case 4: return [2 /*return*/];
|
|
7592
7814
|
}
|
|
@@ -7606,25 +7828,28 @@ var Authority = /** @class */ (function () {
|
|
|
7606
7828
|
* Update the retrieved metadata with regional information.
|
|
7607
7829
|
*/
|
|
7608
7830
|
Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
|
|
7609
|
-
var _a, _b, _c, _d, _e;
|
|
7831
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7610
7832
|
return __awaiter(this, void 0, void 0, function () {
|
|
7611
7833
|
var autodetectedRegionName, azureRegion;
|
|
7612
|
-
return __generator(this, function (
|
|
7613
|
-
switch (
|
|
7614
|
-
case 0:
|
|
7834
|
+
return __generator(this, function (_h) {
|
|
7835
|
+
switch (_h.label) {
|
|
7836
|
+
case 0:
|
|
7837
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7838
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7839
|
+
return [4 /*yield*/, this.regionDiscovery.detectRegion((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.environmentRegion, this.regionDiscoveryMetadata)];
|
|
7615
7840
|
case 1:
|
|
7616
|
-
autodetectedRegionName =
|
|
7617
|
-
azureRegion = ((
|
|
7841
|
+
autodetectedRegionName = _h.sent();
|
|
7842
|
+
azureRegion = ((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
|
|
7618
7843
|
? autodetectedRegionName
|
|
7619
|
-
: (
|
|
7620
|
-
if (((
|
|
7844
|
+
: (_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion;
|
|
7845
|
+
if (((_f = this.authorityOptions.azureRegionConfiguration) === null || _f === void 0 ? void 0 : _f.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7621
7846
|
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
|
|
7622
7847
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
|
|
7623
7848
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7624
7849
|
}
|
|
7625
7850
|
else {
|
|
7626
7851
|
if (autodetectedRegionName) {
|
|
7627
|
-
this.regionDiscoveryMetadata.region_outcome = (((
|
|
7852
|
+
this.regionDiscoveryMetadata.region_outcome = (((_g = this.authorityOptions.azureRegionConfiguration) === null || _g === void 0 ? void 0 : _g.azureRegion) === autodetectedRegionName) ?
|
|
7628
7853
|
RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
|
|
7629
7854
|
RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
7630
7855
|
}
|
|
@@ -7648,11 +7873,13 @@ var Authority = /** @class */ (function () {
|
|
|
7648
7873
|
* @param newMetadata
|
|
7649
7874
|
*/
|
|
7650
7875
|
Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
|
|
7876
|
+
var _a, _b;
|
|
7651
7877
|
return __awaiter(this, void 0, void 0, function () {
|
|
7652
7878
|
var metadata, metadataEntityExpired, harcodedMetadata;
|
|
7653
|
-
return __generator(this, function (
|
|
7654
|
-
switch (
|
|
7879
|
+
return __generator(this, function (_c) {
|
|
7880
|
+
switch (_c.label) {
|
|
7655
7881
|
case 0:
|
|
7882
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7656
7883
|
this.logger.verbose("Attempting to get cloud discovery metadata in the config");
|
|
7657
7884
|
this.logger.verbosePii("Known Authorities: " + (this.authorityOptions.knownAuthorities || Constants.NOT_APPLICABLE));
|
|
7658
7885
|
this.logger.verbosePii("Authority Metadata: " + (this.authorityOptions.authorityMetadata || Constants.NOT_APPLICABLE));
|
|
@@ -7675,9 +7902,10 @@ var Authority = /** @class */ (function () {
|
|
|
7675
7902
|
this.logger.verbose("The metadata entity is expired.");
|
|
7676
7903
|
}
|
|
7677
7904
|
this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
|
|
7905
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7678
7906
|
return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
|
|
7679
7907
|
case 1:
|
|
7680
|
-
metadata =
|
|
7908
|
+
metadata = _c.sent();
|
|
7681
7909
|
if (metadata) {
|
|
7682
7910
|
this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
|
|
7683
7911
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
@@ -7735,23 +7963,22 @@ var Authority = /** @class */ (function () {
|
|
|
7735
7963
|
* @param hasHardcodedMetadata boolean
|
|
7736
7964
|
*/
|
|
7737
7965
|
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
|
|
7966
|
+
var _a;
|
|
7738
7967
|
return __awaiter(this, void 0, void 0, function () {
|
|
7739
7968
|
var instanceDiscoveryEndpoint, options, match, response, typedResponseBody, metadata, error_1, typedError;
|
|
7740
|
-
return __generator(this, function (
|
|
7741
|
-
switch (
|
|
7969
|
+
return __generator(this, function (_b) {
|
|
7970
|
+
switch (_b.label) {
|
|
7742
7971
|
case 0:
|
|
7972
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7743
7973
|
instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
|
|
7744
7974
|
options = {};
|
|
7745
|
-
if (this.proxyUrl) {
|
|
7746
|
-
options.proxyUrl = this.proxyUrl;
|
|
7747
|
-
}
|
|
7748
7975
|
match = null;
|
|
7749
|
-
|
|
7976
|
+
_b.label = 1;
|
|
7750
7977
|
case 1:
|
|
7751
|
-
|
|
7978
|
+
_b.trys.push([1, 3, , 4]);
|
|
7752
7979
|
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
|
|
7753
7980
|
case 2:
|
|
7754
|
-
response =
|
|
7981
|
+
response = _b.sent();
|
|
7755
7982
|
typedResponseBody = void 0;
|
|
7756
7983
|
metadata = void 0;
|
|
7757
7984
|
if (isCloudInstanceDiscoveryResponse(response.body)) {
|
|
@@ -7779,7 +8006,7 @@ var Authority = /** @class */ (function () {
|
|
|
7779
8006
|
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
|
|
7780
8007
|
return [3 /*break*/, 4];
|
|
7781
8008
|
case 3:
|
|
7782
|
-
error_1 =
|
|
8009
|
+
error_1 = _b.sent();
|
|
7783
8010
|
if (error_1 instanceof AuthError) {
|
|
7784
8011
|
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
8012
|
}
|
|
@@ -7941,16 +8168,18 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
7941
8168
|
* @param networkClient
|
|
7942
8169
|
* @param protocolMode
|
|
7943
8170
|
*/
|
|
7944
|
-
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger,
|
|
8171
|
+
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7945
8172
|
return __awaiter(this, void 0, void 0, function () {
|
|
7946
8173
|
var acquireTokenAuthority, e_1;
|
|
7947
8174
|
return __generator(this, function (_a) {
|
|
7948
8175
|
switch (_a.label) {
|
|
7949
8176
|
case 0:
|
|
7950
|
-
|
|
8177
|
+
performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.addQueueMeasurement(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
|
|
8178
|
+
acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId);
|
|
7951
8179
|
_a.label = 1;
|
|
7952
8180
|
case 1:
|
|
7953
8181
|
_a.trys.push([1, 3, , 4]);
|
|
8182
|
+
performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, correlationId);
|
|
7954
8183
|
return [4 /*yield*/, acquireTokenAuthority.resolveEndpointsAsync()];
|
|
7955
8184
|
case 2:
|
|
7956
8185
|
_a.sent();
|
|
@@ -7973,12 +8202,12 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
7973
8202
|
* @param networkInterface
|
|
7974
8203
|
* @param protocolMode
|
|
7975
8204
|
*/
|
|
7976
|
-
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger,
|
|
8205
|
+
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7977
8206
|
// Throw error if authority url is empty
|
|
7978
8207
|
if (StringUtils.isEmpty(authorityUrl)) {
|
|
7979
8208
|
throw ClientConfigurationError.createUrlEmptyError();
|
|
7980
8209
|
}
|
|
7981
|
-
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger,
|
|
8210
|
+
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId);
|
|
7982
8211
|
};
|
|
7983
8212
|
return AuthorityFactory;
|
|
7984
8213
|
}());
|
|
@@ -8124,8 +8353,8 @@ var JoseHeader = /** @class */ (function () {
|
|
|
8124
8353
|
throw JoseHeaderError.createMissingAlgError();
|
|
8125
8354
|
}
|
|
8126
8355
|
var shrHeader = new JoseHeader({
|
|
8127
|
-
// Access Token PoP headers must have type
|
|
8128
|
-
typ: shrHeaderOptions.typ || JsonTypes.
|
|
8356
|
+
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
8357
|
+
typ: shrHeaderOptions.typ || JsonTypes.Pop,
|
|
8129
8358
|
kid: shrHeaderOptions.kid,
|
|
8130
8359
|
alg: shrHeaderOptions.alg
|
|
8131
8360
|
});
|
|
@@ -8376,9 +8605,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8376
8605
|
this.logger = logger;
|
|
8377
8606
|
this.callbacks = new Map();
|
|
8378
8607
|
this.eventsByCorrelationId = new Map();
|
|
8379
|
-
this.
|
|
8380
|
-
this.
|
|
8381
|
-
this.countersByCorrelationId = new Map();
|
|
8608
|
+
this.queueMeasurements = new Map();
|
|
8609
|
+
this.preQueueTimeByCorrelationId = new Map();
|
|
8382
8610
|
}
|
|
8383
8611
|
/**
|
|
8384
8612
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8404,6 +8632,93 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8404
8632
|
PerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
|
|
8405
8633
|
return {};
|
|
8406
8634
|
};
|
|
8635
|
+
/**
|
|
8636
|
+
* Get integral fields.
|
|
8637
|
+
* Override to change the set.
|
|
8638
|
+
*/
|
|
8639
|
+
PerformanceClient.prototype.getIntFields = function () {
|
|
8640
|
+
return IntFields;
|
|
8641
|
+
};
|
|
8642
|
+
/**
|
|
8643
|
+
* Gets map of pre-queue times by correlation Id
|
|
8644
|
+
*
|
|
8645
|
+
* @param {PerformanceEvents} eventName
|
|
8646
|
+
* @param {string} correlationId
|
|
8647
|
+
* @returns {number}
|
|
8648
|
+
*/
|
|
8649
|
+
PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
|
|
8650
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
8651
|
+
if (!preQueueEvent) {
|
|
8652
|
+
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
|
|
8653
|
+
return;
|
|
8654
|
+
}
|
|
8655
|
+
else if (preQueueEvent.name !== eventName) {
|
|
8656
|
+
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
|
|
8657
|
+
return;
|
|
8658
|
+
}
|
|
8659
|
+
return preQueueEvent.time;
|
|
8660
|
+
};
|
|
8661
|
+
/**
|
|
8662
|
+
* Calculates the difference between current time and time when function was queued.
|
|
8663
|
+
* Note: It is possible to have 0 as the queue time if the current time and the queued time was the same.
|
|
8664
|
+
*
|
|
8665
|
+
* @param {number} preQueueTime
|
|
8666
|
+
* @param {number} currentTime
|
|
8667
|
+
* @returns {number}
|
|
8668
|
+
*/
|
|
8669
|
+
PerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
|
|
8670
|
+
if (preQueueTime < 1) {
|
|
8671
|
+
this.logger.trace("PerformanceClient: preQueueTime should be a positive integer and not " + preQueueTime);
|
|
8672
|
+
return 0;
|
|
8673
|
+
}
|
|
8674
|
+
if (currentTime < 1) {
|
|
8675
|
+
this.logger.trace("PerformanceClient: currentTime should be a positive integer and not " + currentTime);
|
|
8676
|
+
return 0;
|
|
8677
|
+
}
|
|
8678
|
+
if (currentTime < preQueueTime) {
|
|
8679
|
+
this.logger.trace("PerformanceClient: currentTime is less than preQueueTime, check how time is being retrieved");
|
|
8680
|
+
return 0;
|
|
8681
|
+
}
|
|
8682
|
+
return currentTime - preQueueTime;
|
|
8683
|
+
};
|
|
8684
|
+
/**
|
|
8685
|
+
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
8686
|
+
*
|
|
8687
|
+
* @param {PerformanceEvents} eventName
|
|
8688
|
+
* @param {?string} correlationId
|
|
8689
|
+
* @param {?number} queueTime
|
|
8690
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
8691
|
+
* @returns
|
|
8692
|
+
*/
|
|
8693
|
+
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
8694
|
+
if (!correlationId) {
|
|
8695
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
|
|
8696
|
+
return;
|
|
8697
|
+
}
|
|
8698
|
+
if (queueTime === 0) {
|
|
8699
|
+
// Possible for there to be no queue time after calculation
|
|
8700
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: queue time provided for " + eventName + " is " + queueTime);
|
|
8701
|
+
}
|
|
8702
|
+
else if (!queueTime) {
|
|
8703
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
|
|
8704
|
+
return;
|
|
8705
|
+
}
|
|
8706
|
+
var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
|
|
8707
|
+
// Adds to existing correlation Id if present in queueMeasurements
|
|
8708
|
+
var existingMeasurements = this.queueMeasurements.get(correlationId);
|
|
8709
|
+
if (existingMeasurements) {
|
|
8710
|
+
existingMeasurements.push(queueMeasurement);
|
|
8711
|
+
this.queueMeasurements.set(correlationId, existingMeasurements);
|
|
8712
|
+
}
|
|
8713
|
+
else {
|
|
8714
|
+
// Sets new correlation Id if not present in queueMeasurements
|
|
8715
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: adding correlationId " + correlationId + " to queue measurements");
|
|
8716
|
+
var measurementArray = [queueMeasurement];
|
|
8717
|
+
this.queueMeasurements.set(correlationId, measurementArray);
|
|
8718
|
+
}
|
|
8719
|
+
// Delete processed pre-queue event.
|
|
8720
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8721
|
+
};
|
|
8407
8722
|
/**
|
|
8408
8723
|
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
8409
8724
|
*
|
|
@@ -8421,17 +8736,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8421
8736
|
}
|
|
8422
8737
|
// Duplicate code to address spelling error will be removed at the next major version bump.
|
|
8423
8738
|
this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
|
|
8424
|
-
var
|
|
8425
|
-
|
|
8426
|
-
if (performanceMeasuremeant.startMeasurement) {
|
|
8427
|
-
performanceMeasuremeant.startMeasurement();
|
|
8428
|
-
validMeasurement = performanceMeasuremeant;
|
|
8429
|
-
}
|
|
8430
|
-
else {
|
|
8431
|
-
var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
|
|
8432
|
-
performanceMeasurement.startMeasurement();
|
|
8433
|
-
validMeasurement = performanceMeasurement;
|
|
8434
|
-
}
|
|
8739
|
+
var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
|
|
8740
|
+
performanceMeasurement.startMeasurement();
|
|
8435
8741
|
var inProgressEvent = {
|
|
8436
8742
|
eventId: this.generateId(),
|
|
8437
8743
|
status: exports.PerformanceEventStatus.InProgress,
|
|
@@ -8442,27 +8748,15 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8442
8748
|
name: measureName,
|
|
8443
8749
|
startTimeMs: Date.now(),
|
|
8444
8750
|
correlationId: eventCorrelationId,
|
|
8445
|
-
};
|
|
8446
|
-
// Store in progress events so they can be discarded if not ended properly
|
|
8447
|
-
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8448
|
-
var staticFields = {
|
|
8449
8751
|
appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
|
|
8450
8752
|
appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
|
|
8451
8753
|
};
|
|
8452
|
-
|
|
8453
|
-
this.
|
|
8754
|
+
// Store in progress events so they can be discarded if not ended properly
|
|
8755
|
+
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8454
8756
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8455
8757
|
return {
|
|
8456
8758
|
endMeasurement: function (event) {
|
|
8457
|
-
|
|
8458
|
-
if (completedEvent) {
|
|
8459
|
-
// Cache event so that submeasurements can be added downstream
|
|
8460
|
-
_this.cacheEventByCorrelationId(completedEvent);
|
|
8461
|
-
}
|
|
8462
|
-
return completedEvent;
|
|
8463
|
-
},
|
|
8464
|
-
flushMeasurement: function () {
|
|
8465
|
-
return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
|
|
8759
|
+
return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
|
|
8466
8760
|
},
|
|
8467
8761
|
discardMeasurement: function () {
|
|
8468
8762
|
return _this.discardMeasurements(inProgressEvent.correlationId);
|
|
@@ -8473,40 +8767,66 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8473
8767
|
increment: function (counters) {
|
|
8474
8768
|
return _this.increment(counters, inProgressEvent.correlationId);
|
|
8475
8769
|
},
|
|
8476
|
-
measurement:
|
|
8770
|
+
measurement: performanceMeasurement,
|
|
8477
8771
|
event: inProgressEvent
|
|
8478
8772
|
};
|
|
8479
8773
|
};
|
|
8480
8774
|
/**
|
|
8481
8775
|
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
8482
8776
|
* as consumers should instead use the function returned by startMeasurement.
|
|
8777
|
+
* Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
|
|
8778
|
+
* otherwise.
|
|
8483
8779
|
*
|
|
8484
8780
|
* @param {PerformanceEvent} event
|
|
8781
|
+
* @param {IPerformanceMeasurement} measurement
|
|
8485
8782
|
* @returns {(PerformanceEvent | null)}
|
|
8486
8783
|
*/
|
|
8487
|
-
PerformanceClient.prototype.endMeasurement = function (event) {
|
|
8488
|
-
var
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
}
|
|
8784
|
+
PerformanceClient.prototype.endMeasurement = function (event, measurement) {
|
|
8785
|
+
var _this = this;
|
|
8786
|
+
var _a, _b;
|
|
8787
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8788
|
+
if (!rootEvent) {
|
|
8789
|
+
this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
|
|
8790
|
+
return null;
|
|
8791
|
+
}
|
|
8792
|
+
var isRoot = event.eventId === rootEvent.eventId;
|
|
8793
|
+
var queueInfo = {
|
|
8794
|
+
totalQueueTime: 0,
|
|
8795
|
+
totalQueueCount: 0,
|
|
8796
|
+
manuallyCompletedCount: 0
|
|
8797
|
+
};
|
|
8798
|
+
if (isRoot) {
|
|
8799
|
+
queueInfo = this.getQueueInfo(event.correlationId);
|
|
8800
|
+
this.discardCache(rootEvent.correlationId);
|
|
8505
8801
|
}
|
|
8506
8802
|
else {
|
|
8507
|
-
|
|
8803
|
+
(_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
|
|
8508
8804
|
}
|
|
8509
|
-
|
|
8805
|
+
measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
|
|
8806
|
+
var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
|
|
8807
|
+
// null indicates no measurement was taken (e.g. needed performance APIs not present)
|
|
8808
|
+
if (!durationMs) {
|
|
8809
|
+
this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
|
|
8810
|
+
return null;
|
|
8811
|
+
}
|
|
8812
|
+
this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
|
|
8813
|
+
// Add sub-measurement attribute to root event.
|
|
8814
|
+
if (!isRoot) {
|
|
8815
|
+
rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
|
|
8816
|
+
return __assign({}, rootEvent);
|
|
8817
|
+
}
|
|
8818
|
+
var finalEvent = __assign(__assign({}, rootEvent), event);
|
|
8819
|
+
var incompleteSubsCount = 0;
|
|
8820
|
+
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
8821
|
+
(_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
|
|
8822
|
+
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
|
|
8823
|
+
incompleteSubsCount++;
|
|
8824
|
+
});
|
|
8825
|
+
finalEvent.incompleteSubMeasurements = undefined;
|
|
8826
|
+
finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: exports.PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
|
|
8827
|
+
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
8828
|
+
this.emitEvents([finalEvent], event.correlationId);
|
|
8829
|
+
return finalEvent;
|
|
8510
8830
|
};
|
|
8511
8831
|
/**
|
|
8512
8832
|
* Saves extra information to be emitted when the measurements are flushed
|
|
@@ -8514,14 +8834,13 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8514
8834
|
* @param correlationId
|
|
8515
8835
|
*/
|
|
8516
8836
|
PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
this.
|
|
8837
|
+
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8838
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8839
|
+
if (event) {
|
|
8840
|
+
this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
|
|
8521
8841
|
}
|
|
8522
8842
|
else {
|
|
8523
|
-
this.logger.trace("PerformanceClient:
|
|
8524
|
-
this.staticFieldsByCorrelationId.set(correlationId, fields);
|
|
8843
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8525
8844
|
}
|
|
8526
8845
|
};
|
|
8527
8846
|
/**
|
|
@@ -8530,18 +8849,18 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8530
8849
|
* @param correlationId {string} correlation identifier
|
|
8531
8850
|
*/
|
|
8532
8851
|
PerformanceClient.prototype.increment = function (counters, correlationId) {
|
|
8533
|
-
var existing = this.countersByCorrelationId.get(correlationId);
|
|
8534
|
-
if (!existing) {
|
|
8535
|
-
this.logger.trace("PerformanceClient: Setting counters");
|
|
8536
|
-
this.countersByCorrelationId.set(correlationId, __assign({}, counters));
|
|
8537
|
-
return;
|
|
8538
|
-
}
|
|
8539
8852
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8853
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8854
|
+
if (event) {
|
|
8855
|
+
for (var counter in counters) {
|
|
8856
|
+
if (!event.hasOwnProperty(counter)) {
|
|
8857
|
+
event[counter] = 0;
|
|
8858
|
+
}
|
|
8859
|
+
event[counter] += counters[counter];
|
|
8543
8860
|
}
|
|
8544
|
-
|
|
8861
|
+
}
|
|
8862
|
+
else {
|
|
8863
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8545
8864
|
}
|
|
8546
8865
|
};
|
|
8547
8866
|
/**
|
|
@@ -8554,100 +8873,35 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8554
8873
|
* @param {PerformanceEvent} event
|
|
8555
8874
|
*/
|
|
8556
8875
|
PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
|
|
8557
|
-
var
|
|
8558
|
-
if (
|
|
8876
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8877
|
+
if (rootEvent) {
|
|
8559
8878
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
|
|
8560
|
-
|
|
8879
|
+
rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
|
|
8880
|
+
rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
|
|
8561
8881
|
}
|
|
8562
8882
|
else {
|
|
8563
8883
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
|
|
8564
|
-
this.eventsByCorrelationId.set(event.correlationId,
|
|
8884
|
+
this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
|
|
8565
8885
|
}
|
|
8566
8886
|
};
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
* @param {PerformanceEvent} event
|
|
8572
|
-
* @param {IPerformanceMeasurement} measurement
|
|
8573
|
-
*/
|
|
8574
|
-
PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
|
|
8575
|
-
this.measurementsById.set(event.eventId, measurement);
|
|
8576
|
-
};
|
|
8577
|
-
/**
|
|
8578
|
-
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
8579
|
-
*
|
|
8580
|
-
* @param {PerformanceEvents} measureName
|
|
8581
|
-
* @param {string} correlationId
|
|
8582
|
-
*/
|
|
8583
|
-
PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
|
|
8584
|
-
var _this = this;
|
|
8585
|
-
this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
|
|
8586
|
-
var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
|
|
8587
|
-
var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
|
|
8588
|
-
var counters = this.countersByCorrelationId.get(correlationId);
|
|
8589
|
-
if (eventsForCorrelationId) {
|
|
8590
|
-
this.discardCache(correlationId);
|
|
8591
|
-
/*
|
|
8592
|
-
* Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
|
|
8593
|
-
* Incomplete submeasurements are likely an instrumentation bug that should be fixed.
|
|
8594
|
-
* IE only supports Map.forEach.
|
|
8595
|
-
*/
|
|
8596
|
-
var completedEvents_1 = [];
|
|
8597
|
-
eventsForCorrelationId.forEach(function (event) {
|
|
8598
|
-
if (event.name !== measureName && event.status !== exports.PerformanceEventStatus.Completed) {
|
|
8599
|
-
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
|
|
8600
|
-
var completedEvent = _this.endMeasurement(event);
|
|
8601
|
-
if (completedEvent) {
|
|
8602
|
-
completedEvents_1.push(completedEvent);
|
|
8603
|
-
}
|
|
8604
|
-
}
|
|
8605
|
-
completedEvents_1.push(event);
|
|
8606
|
-
});
|
|
8607
|
-
// Sort events by start time (earliest first)
|
|
8608
|
-
var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
|
|
8609
|
-
// Take completed top level event and add completed submeasurements durations as properties
|
|
8610
|
-
var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === exports.PerformanceEventStatus.Completed; });
|
|
8611
|
-
if (topLevelEvents.length > 0) {
|
|
8612
|
-
/*
|
|
8613
|
-
* Only take the first top-level event if there are multiple events with the same correlation id.
|
|
8614
|
-
* This greatly simplifies logic for submeasurements.
|
|
8615
|
-
*/
|
|
8616
|
-
if (topLevelEvents.length > 1) {
|
|
8617
|
-
this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
|
|
8618
|
-
}
|
|
8619
|
-
var topLevelEvent = topLevelEvents[0];
|
|
8620
|
-
this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
|
|
8621
|
-
// Build event object with top level and sub measurements
|
|
8622
|
-
var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
|
|
8623
|
-
if (current.name !== measureName) {
|
|
8624
|
-
_this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
|
|
8625
|
-
// TODO: Emit additional properties for each subMeasurement
|
|
8626
|
-
var subMeasurementName = current.name + "DurationMs";
|
|
8627
|
-
/*
|
|
8628
|
-
* Some code paths, such as resolving an authority, can occur multiple times.
|
|
8629
|
-
* Only take the first measurement, since the second could be read from the cache,
|
|
8630
|
-
* or due to the same correlation id being used for two distinct requests.
|
|
8631
|
-
*/
|
|
8632
|
-
if (!previous[subMeasurementName]) {
|
|
8633
|
-
previous[subMeasurementName] = current.durationMs;
|
|
8634
|
-
}
|
|
8635
|
-
else {
|
|
8636
|
-
_this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
|
|
8637
|
-
}
|
|
8638
|
-
}
|
|
8639
|
-
return previous;
|
|
8640
|
-
}, topLevelEvent);
|
|
8641
|
-
var finalEvent = __assign(__assign(__assign({}, eventToEmit), staticFields), counters);
|
|
8642
|
-
this.emitEvents([finalEvent], eventToEmit.correlationId);
|
|
8643
|
-
}
|
|
8644
|
-
else {
|
|
8645
|
-
this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
|
|
8646
|
-
}
|
|
8647
|
-
}
|
|
8648
|
-
else {
|
|
8649
|
-
this.logger.verbose("PerformanceClient: No measurements found", correlationId);
|
|
8887
|
+
PerformanceClient.prototype.getQueueInfo = function (correlationId) {
|
|
8888
|
+
var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
|
|
8889
|
+
if (!queueMeasurementForCorrelationId) {
|
|
8890
|
+
this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
|
|
8650
8891
|
}
|
|
8892
|
+
var totalQueueTime = 0;
|
|
8893
|
+
var totalQueueCount = 0;
|
|
8894
|
+
var manuallyCompletedCount = 0;
|
|
8895
|
+
queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
|
|
8896
|
+
totalQueueTime += measurement.queueTime;
|
|
8897
|
+
totalQueueCount++;
|
|
8898
|
+
manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
|
|
8899
|
+
});
|
|
8900
|
+
return {
|
|
8901
|
+
totalQueueTime: totalQueueTime,
|
|
8902
|
+
totalQueueCount: totalQueueCount,
|
|
8903
|
+
manuallyCompletedCount: manuallyCompletedCount
|
|
8904
|
+
};
|
|
8651
8905
|
};
|
|
8652
8906
|
/**
|
|
8653
8907
|
* Removes measurements for a given correlation id.
|
|
@@ -8661,14 +8915,14 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8661
8915
|
/**
|
|
8662
8916
|
* Removes cache for a given correlation id.
|
|
8663
8917
|
*
|
|
8664
|
-
* @param {string} correlation identifier
|
|
8918
|
+
* @param {string} correlationId correlation identifier
|
|
8665
8919
|
*/
|
|
8666
8920
|
PerformanceClient.prototype.discardCache = function (correlationId) {
|
|
8667
8921
|
this.discardMeasurements(correlationId);
|
|
8668
|
-
this.logger.trace("PerformanceClient:
|
|
8669
|
-
this.
|
|
8670
|
-
this.logger.trace("PerformanceClient:
|
|
8671
|
-
this.
|
|
8922
|
+
this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
|
|
8923
|
+
this.queueMeasurements.delete(correlationId);
|
|
8924
|
+
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|
|
8925
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8672
8926
|
};
|
|
8673
8927
|
/**
|
|
8674
8928
|
* Registers a callback function to receive performance events.
|
|
@@ -8712,6 +8966,18 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8712
8966
|
callback.apply(null, [events]);
|
|
8713
8967
|
});
|
|
8714
8968
|
};
|
|
8969
|
+
/**
|
|
8970
|
+
* Enforce truncation of integral fields in performance event.
|
|
8971
|
+
* @param {PerformanceEvent} event performance event to update.
|
|
8972
|
+
* @param {Set<string>} intFields integral fields.
|
|
8973
|
+
*/
|
|
8974
|
+
PerformanceClient.prototype.truncateIntegralFields = function (event, intFields) {
|
|
8975
|
+
intFields.forEach(function (key) {
|
|
8976
|
+
if (key in event && typeof event[key] === "number") {
|
|
8977
|
+
event[key] = Math.floor(event[key]);
|
|
8978
|
+
}
|
|
8979
|
+
});
|
|
8980
|
+
};
|
|
8715
8981
|
return PerformanceClient;
|
|
8716
8982
|
}());
|
|
8717
8983
|
|
|
@@ -8745,6 +9011,18 @@ var StubPerformanceClient = /** @class */ (function (_super) {
|
|
|
8745
9011
|
StubPerformanceClient.prototype.startPerformanceMeasurement = function () {
|
|
8746
9012
|
return new StubPerformanceMeasurement();
|
|
8747
9013
|
};
|
|
9014
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
9015
|
+
StubPerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
|
|
9016
|
+
return 0;
|
|
9017
|
+
};
|
|
9018
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
9019
|
+
StubPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
|
|
9020
|
+
return;
|
|
9021
|
+
};
|
|
9022
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
9023
|
+
StubPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
|
|
9024
|
+
return;
|
|
9025
|
+
};
|
|
8748
9026
|
return StubPerformanceClient;
|
|
8749
9027
|
}(PerformanceClient));
|
|
8750
9028
|
|
|
@@ -8776,6 +9054,7 @@ exports.DeviceCodeClient = DeviceCodeClient;
|
|
|
8776
9054
|
exports.Errors = Errors;
|
|
8777
9055
|
exports.IdToken = AuthToken;
|
|
8778
9056
|
exports.IdTokenEntity = IdTokenEntity;
|
|
9057
|
+
exports.IntFields = IntFields;
|
|
8779
9058
|
exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
|
|
8780
9059
|
exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
|
|
8781
9060
|
exports.JoseHeader = JoseHeader;
|