@azure/msal-browser 2.32.2 → 2.34.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/README.md +1 -1
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +3 -0
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +75 -26
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.js +1 -1
- package/dist/app/PublicClientApplication.d.ts +2 -0
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +37 -15
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +10 -7
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js +18 -8
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/BrowserCacheManager.js +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/CryptoKeyStore.js +1 -1
- package/dist/cache/DatabaseStorage.js +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/TokenCache.js +1 -1
- package/dist/config/Configuration.js +1 -1
- package/dist/crypto/BrowserCrypto.js +1 -1
- package/dist/crypto/CryptoOps.js +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/ModernBrowserCrypto.js +1 -1
- package/dist/crypto/MsBrowserCrypto.js +1 -1
- package/dist/crypto/MsrBrowserCrypto.js +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/error/BrowserAuthError.d.ts +8 -0
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +11 -1
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/error/NativeAuthError.js +1 -1
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventType.js +1 -1
- package/dist/index.cjs.js +1683 -979
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +3 -2
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +66 -3
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +174 -68
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +9 -2
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.js +13 -5
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +7 -3
- package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +7 -2
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +21 -4
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +9 -3
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +16 -5
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts +3 -2
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +12 -4
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +2 -2
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +3 -3
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +2 -2
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +13 -15
- package/dist/interaction_handler/SilentHandler.js.map +1 -1
- package/dist/internals.d.ts +5 -0
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +4 -1
- package/dist/internals.js.map +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/network/FetchClient.js +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/EndSessionPopupRequest.d.ts +1 -1
- package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
- package/dist/request/EndSessionRequest.d.ts +1 -1
- package/dist/request/EndSessionRequest.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +20 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +80 -3
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +14 -5
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +36 -4
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
- package/dist/utils/BrowserConstants.js +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.js +1 -1
- package/dist/utils/BrowserUtils.js +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/lib/msal-browser.js +1683 -979
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +43 -44
- package/package.json +2 -2
package/lib/msal-browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.34.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
return ar;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/*! @azure/msal-common
|
|
122
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
123
123
|
/*! *****************************************************************************
|
|
124
124
|
Copyright (c) Microsoft Corporation.
|
|
125
125
|
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
return r;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
/*! @azure/msal-common
|
|
209
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
210
210
|
|
|
211
211
|
/*
|
|
212
212
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -588,9 +588,10 @@
|
|
|
588
588
|
(function (JsonTypes) {
|
|
589
589
|
JsonTypes["Jwt"] = "JWT";
|
|
590
590
|
JsonTypes["Jwk"] = "JWK";
|
|
591
|
+
JsonTypes["Pop"] = "pop";
|
|
591
592
|
})(JsonTypes || (JsonTypes = {}));
|
|
592
593
|
|
|
593
|
-
/*! @azure/msal-common
|
|
594
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
594
595
|
|
|
595
596
|
/*
|
|
596
597
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -646,7 +647,7 @@
|
|
|
646
647
|
return AuthError;
|
|
647
648
|
}(Error));
|
|
648
649
|
|
|
649
|
-
/*! @azure/msal-common
|
|
650
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
650
651
|
|
|
651
652
|
/*
|
|
652
653
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -721,7 +722,7 @@
|
|
|
721
722
|
}
|
|
722
723
|
};
|
|
723
724
|
|
|
724
|
-
/*! @azure/msal-common
|
|
725
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
725
726
|
|
|
726
727
|
/*
|
|
727
728
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -925,6 +926,14 @@
|
|
|
925
926
|
keyIdMissing: {
|
|
926
927
|
code: "key_id_missing",
|
|
927
928
|
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."
|
|
929
|
+
},
|
|
930
|
+
noNetworkConnectivity: {
|
|
931
|
+
code: "no_network_connectivity",
|
|
932
|
+
desc: "No network connectivity. Check your internet connection."
|
|
933
|
+
},
|
|
934
|
+
userCanceledError: {
|
|
935
|
+
code: "user_canceled",
|
|
936
|
+
desc: "User canceled the flow."
|
|
928
937
|
}
|
|
929
938
|
};
|
|
930
939
|
/**
|
|
@@ -1213,10 +1222,22 @@
|
|
|
1213
1222
|
ClientAuthError.createKeyIdMissingError = function () {
|
|
1214
1223
|
return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
|
|
1215
1224
|
};
|
|
1225
|
+
/**
|
|
1226
|
+
* Create an error when the client does not have network connectivity
|
|
1227
|
+
*/
|
|
1228
|
+
ClientAuthError.createNoNetworkConnectivityError = function () {
|
|
1229
|
+
return new ClientAuthError(ClientAuthErrorMessage.noNetworkConnectivity.code, ClientAuthErrorMessage.noNetworkConnectivity.desc);
|
|
1230
|
+
};
|
|
1231
|
+
/**
|
|
1232
|
+
* Create an error when the user cancels the flow
|
|
1233
|
+
*/
|
|
1234
|
+
ClientAuthError.createUserCanceledError = function () {
|
|
1235
|
+
return new ClientAuthError(ClientAuthErrorMessage.userCanceledError.code, ClientAuthErrorMessage.userCanceledError.desc);
|
|
1236
|
+
};
|
|
1216
1237
|
return ClientAuthError;
|
|
1217
1238
|
}(AuthError));
|
|
1218
1239
|
|
|
1219
|
-
/*! @azure/msal-common
|
|
1240
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1220
1241
|
|
|
1221
1242
|
/*
|
|
1222
1243
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1341,7 +1362,7 @@
|
|
|
1341
1362
|
return StringUtils;
|
|
1342
1363
|
}());
|
|
1343
1364
|
|
|
1344
|
-
/*! @azure/msal-common
|
|
1365
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1345
1366
|
|
|
1346
1367
|
/*
|
|
1347
1368
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1531,12 +1552,12 @@
|
|
|
1531
1552
|
return Logger;
|
|
1532
1553
|
}());
|
|
1533
1554
|
|
|
1534
|
-
/*! @azure/msal-common
|
|
1555
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1535
1556
|
/* eslint-disable header/header */
|
|
1536
1557
|
var name$1 = "@azure/msal-common";
|
|
1537
|
-
var version$1 = "
|
|
1558
|
+
var version$1 = "11.0.0";
|
|
1538
1559
|
|
|
1539
|
-
/*! @azure/msal-common
|
|
1560
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1540
1561
|
/*
|
|
1541
1562
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1542
1563
|
* Licensed under the MIT License.
|
|
@@ -1557,7 +1578,7 @@
|
|
|
1557
1578
|
AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
|
|
1558
1579
|
})(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
|
|
1559
1580
|
|
|
1560
|
-
/*! @azure/msal-common
|
|
1581
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1561
1582
|
|
|
1562
1583
|
/*
|
|
1563
1584
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1588,6 +1609,25 @@
|
|
|
1588
1609
|
var CredentialEntity = /** @class */ (function () {
|
|
1589
1610
|
function CredentialEntity() {
|
|
1590
1611
|
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Initializes a map with credential {CredentialType} regular expressions.
|
|
1614
|
+
*/
|
|
1615
|
+
CredentialEntity._initRegex = function () {
|
|
1616
|
+
var separator = Separators.CACHE_KEY_SEPARATOR;
|
|
1617
|
+
CredentialEntity.credentialRegexMap = new Map();
|
|
1618
|
+
for (var _i = 0, _a = Object.keys(CredentialType); _i < _a.length; _i++) {
|
|
1619
|
+
var credKey = _a[_i];
|
|
1620
|
+
var credVal = CredentialType[credKey].toLowerCase();
|
|
1621
|
+
try {
|
|
1622
|
+
// Verify credential type is preceded by a valid host name (environment) using lookbehind
|
|
1623
|
+
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
|
|
1624
|
+
}
|
|
1625
|
+
catch (err) {
|
|
1626
|
+
// Lookbehind is not supported (Safari or older versions of IE) - removing it
|
|
1627
|
+
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1591
1631
|
/**
|
|
1592
1632
|
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
1593
1633
|
*/
|
|
@@ -1634,14 +1674,10 @@
|
|
|
1634
1674
|
* @param key
|
|
1635
1675
|
*/
|
|
1636
1676
|
CredentialEntity.getCredentialType = function (key) {
|
|
1637
|
-
var
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
var credKey = _a[_i];
|
|
1642
|
-
var credVal = CredentialType[credKey].toLowerCase();
|
|
1643
|
-
// Verify credential type is preceded by a valid host name (environment)
|
|
1644
|
-
if (key.toLowerCase().search("(?<=" + separator + domainRe + ")" + separator + credVal + separator) !== -1) {
|
|
1677
|
+
var _a;
|
|
1678
|
+
for (var _i = 0, _b = Object.keys(CredentialType); _i < _b.length; _i++) {
|
|
1679
|
+
var credKey = _b[_i];
|
|
1680
|
+
if ((_a = this.credentialRegexMap.get(CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
|
|
1645
1681
|
return CredentialType[credKey];
|
|
1646
1682
|
}
|
|
1647
1683
|
}
|
|
@@ -1710,10 +1746,16 @@
|
|
|
1710
1746
|
*/
|
|
1711
1747
|
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
1712
1748
|
};
|
|
1749
|
+
/*
|
|
1750
|
+
* Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000,
|
|
1751
|
+
* "login.microsoftonline.com/common", "login.microsoftonline.com:4000/common", etc
|
|
1752
|
+
*/
|
|
1753
|
+
CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?(\\/[\\w-]+)?";
|
|
1713
1754
|
return CredentialEntity;
|
|
1714
|
-
}());
|
|
1755
|
+
}());
|
|
1756
|
+
CredentialEntity._initRegex();
|
|
1715
1757
|
|
|
1716
|
-
/*! @azure/msal-common
|
|
1758
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1717
1759
|
|
|
1718
1760
|
/*
|
|
1719
1761
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1968,7 +2010,7 @@
|
|
|
1968
2010
|
return ClientConfigurationError;
|
|
1969
2011
|
}(ClientAuthError));
|
|
1970
2012
|
|
|
1971
|
-
/*! @azure/msal-common
|
|
2013
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1972
2014
|
|
|
1973
2015
|
/*
|
|
1974
2016
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2152,7 +2194,7 @@
|
|
|
2152
2194
|
return ScopeSet;
|
|
2153
2195
|
}());
|
|
2154
2196
|
|
|
2155
|
-
/*! @azure/msal-common
|
|
2197
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
2156
2198
|
|
|
2157
2199
|
/*
|
|
2158
2200
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2190,7 +2232,7 @@
|
|
|
2190
2232
|
};
|
|
2191
2233
|
}
|
|
2192
2234
|
|
|
2193
|
-
/*! @azure/msal-common
|
|
2235
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
2194
2236
|
/*
|
|
2195
2237
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2196
2238
|
* Licensed under the MIT License.
|
|
@@ -2205,7 +2247,7 @@
|
|
|
2205
2247
|
AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
|
|
2206
2248
|
})(AuthorityType || (AuthorityType = {}));
|
|
2207
2249
|
|
|
2208
|
-
/*! @azure/msal-common
|
|
2250
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
2209
2251
|
|
|
2210
2252
|
/*
|
|
2211
2253
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2444,7 +2486,7 @@
|
|
|
2444
2486
|
return AccountEntity;
|
|
2445
2487
|
}());
|
|
2446
2488
|
|
|
2447
|
-
/*! @azure/msal-common
|
|
2489
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
2448
2490
|
|
|
2449
2491
|
/*
|
|
2450
2492
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2496,7 +2538,7 @@
|
|
|
2496
2538
|
return AuthToken;
|
|
2497
2539
|
}());
|
|
2498
2540
|
|
|
2499
|
-
/*! @azure/msal-common
|
|
2541
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
2500
2542
|
|
|
2501
2543
|
/*
|
|
2502
2544
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2999,7 +3041,7 @@
|
|
|
2999
3041
|
else if (accounts.length > 1) {
|
|
3000
3042
|
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
|
|
3001
3043
|
}
|
|
3002
|
-
return
|
|
3044
|
+
return accounts[0];
|
|
3003
3045
|
};
|
|
3004
3046
|
/**
|
|
3005
3047
|
* Retrieve IdTokenEntity from cache
|
|
@@ -3375,7 +3417,7 @@
|
|
|
3375
3417
|
return DefaultStorageClass;
|
|
3376
3418
|
}(CacheManager));
|
|
3377
3419
|
|
|
3378
|
-
/*! @azure/msal-common
|
|
3420
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
3379
3421
|
|
|
3380
3422
|
/*
|
|
3381
3423
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3385,8 +3427,7 @@
|
|
|
3385
3427
|
var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
3386
3428
|
var DEFAULT_SYSTEM_OPTIONS = {
|
|
3387
3429
|
tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
3388
|
-
preventCorsPreflight: false
|
|
3389
|
-
proxyUrl: Constants.EMPTY_STRING
|
|
3430
|
+
preventCorsPreflight: false
|
|
3390
3431
|
};
|
|
3391
3432
|
var DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
3392
3433
|
loggerCallback: function () {
|
|
@@ -3469,7 +3510,7 @@
|
|
|
3469
3510
|
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
|
|
3470
3511
|
}
|
|
3471
3512
|
|
|
3472
|
-
/*! @azure/msal-common
|
|
3513
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
3473
3514
|
|
|
3474
3515
|
/*
|
|
3475
3516
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3489,7 +3530,7 @@
|
|
|
3489
3530
|
return ServerError;
|
|
3490
3531
|
}(AuthError));
|
|
3491
3532
|
|
|
3492
|
-
/*! @azure/msal-common
|
|
3533
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
3493
3534
|
|
|
3494
3535
|
/*
|
|
3495
3536
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3585,7 +3626,7 @@
|
|
|
3585
3626
|
return ThrottlingUtils;
|
|
3586
3627
|
}());
|
|
3587
3628
|
|
|
3588
|
-
/*! @azure/msal-common
|
|
3629
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
3589
3630
|
|
|
3590
3631
|
/*
|
|
3591
3632
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3634,7 +3675,7 @@
|
|
|
3634
3675
|
return NetworkManager;
|
|
3635
3676
|
}());
|
|
3636
3677
|
|
|
3637
|
-
/*! @azure/msal-common
|
|
3678
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
3638
3679
|
/*
|
|
3639
3680
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3640
3681
|
* Licensed under the MIT License.
|
|
@@ -3645,98 +3686,7 @@
|
|
|
3645
3686
|
CcsCredentialType["UPN"] = "UPN";
|
|
3646
3687
|
})(CcsCredentialType || (CcsCredentialType = {}));
|
|
3647
3688
|
|
|
3648
|
-
/*! @azure/msal-common
|
|
3649
|
-
|
|
3650
|
-
/*
|
|
3651
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3652
|
-
* Licensed under the MIT License.
|
|
3653
|
-
*/
|
|
3654
|
-
/**
|
|
3655
|
-
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
3656
|
-
*/
|
|
3657
|
-
var BaseClient = /** @class */ (function () {
|
|
3658
|
-
function BaseClient(configuration, performanceClient) {
|
|
3659
|
-
// Set the configuration
|
|
3660
|
-
this.config = buildClientConfiguration(configuration);
|
|
3661
|
-
// Initialize the logger
|
|
3662
|
-
this.logger = new Logger(this.config.loggerOptions, name$1, version$1);
|
|
3663
|
-
// Initialize crypto
|
|
3664
|
-
this.cryptoUtils = this.config.cryptoInterface;
|
|
3665
|
-
// Initialize storage interface
|
|
3666
|
-
this.cacheManager = this.config.storageInterface;
|
|
3667
|
-
// Set the network interface
|
|
3668
|
-
this.networkClient = this.config.networkInterface;
|
|
3669
|
-
// Set the NetworkManager
|
|
3670
|
-
this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
|
|
3671
|
-
// Set TelemetryManager
|
|
3672
|
-
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
3673
|
-
// set Authority
|
|
3674
|
-
this.authority = this.config.authOptions.authority;
|
|
3675
|
-
// set performance telemetry client
|
|
3676
|
-
this.performanceClient = performanceClient;
|
|
3677
|
-
}
|
|
3678
|
-
/**
|
|
3679
|
-
* Creates default headers for requests to token endpoint
|
|
3680
|
-
*/
|
|
3681
|
-
BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
|
|
3682
|
-
var headers = {};
|
|
3683
|
-
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
3684
|
-
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
3685
|
-
switch (ccsCred.type) {
|
|
3686
|
-
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
3687
|
-
try {
|
|
3688
|
-
var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
3689
|
-
headers[HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
|
|
3690
|
-
}
|
|
3691
|
-
catch (e) {
|
|
3692
|
-
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
3693
|
-
}
|
|
3694
|
-
break;
|
|
3695
|
-
case CcsCredentialType.UPN:
|
|
3696
|
-
headers[HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
|
|
3697
|
-
break;
|
|
3698
|
-
}
|
|
3699
|
-
}
|
|
3700
|
-
return headers;
|
|
3701
|
-
};
|
|
3702
|
-
/**
|
|
3703
|
-
* Http post to token endpoint
|
|
3704
|
-
* @param tokenEndpoint
|
|
3705
|
-
* @param queryString
|
|
3706
|
-
* @param headers
|
|
3707
|
-
* @param thumbprint
|
|
3708
|
-
*/
|
|
3709
|
-
BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
|
|
3710
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3711
|
-
var response;
|
|
3712
|
-
return __generator(this, function (_a) {
|
|
3713
|
-
switch (_a.label) {
|
|
3714
|
-
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
|
|
3715
|
-
case 1:
|
|
3716
|
-
response = _a.sent();
|
|
3717
|
-
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
3718
|
-
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
3719
|
-
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
3720
|
-
}
|
|
3721
|
-
return [2 /*return*/, response];
|
|
3722
|
-
}
|
|
3723
|
-
});
|
|
3724
|
-
});
|
|
3725
|
-
};
|
|
3726
|
-
/**
|
|
3727
|
-
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
3728
|
-
* @param updatedAuthority
|
|
3729
|
-
*/
|
|
3730
|
-
BaseClient.prototype.updateAuthority = function (updatedAuthority) {
|
|
3731
|
-
if (!updatedAuthority.discoveryComplete()) {
|
|
3732
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
|
|
3733
|
-
}
|
|
3734
|
-
this.authority = updatedAuthority;
|
|
3735
|
-
};
|
|
3736
|
-
return BaseClient;
|
|
3737
|
-
}());
|
|
3738
|
-
|
|
3739
|
-
/*! @azure/msal-common v9.0.2 2023-01-10 */
|
|
3689
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
3740
3690
|
|
|
3741
3691
|
/*
|
|
3742
3692
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3804,7 +3754,7 @@
|
|
|
3804
3754
|
}
|
|
3805
3755
|
};
|
|
3806
3756
|
/**
|
|
3807
|
-
* Removes unnecessary
|
|
3757
|
+
* Removes unnecessary, duplicate, and empty string query parameters from extraQueryParameters
|
|
3808
3758
|
* @param request
|
|
3809
3759
|
*/
|
|
3810
3760
|
RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {
|
|
@@ -3817,12 +3767,17 @@
|
|
|
3817
3767
|
delete eQParams[key];
|
|
3818
3768
|
}
|
|
3819
3769
|
});
|
|
3820
|
-
|
|
3770
|
+
// remove empty string parameters
|
|
3771
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3772
|
+
return Object.fromEntries(Object.entries(eQParams).filter(function (_a) {
|
|
3773
|
+
var value = _a[1];
|
|
3774
|
+
return value !== "";
|
|
3775
|
+
}));
|
|
3821
3776
|
};
|
|
3822
3777
|
return RequestValidator;
|
|
3823
3778
|
}());
|
|
3824
3779
|
|
|
3825
|
-
/*! @azure/msal-common
|
|
3780
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
3826
3781
|
|
|
3827
3782
|
/*
|
|
3828
3783
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4099,13 +4054,13 @@
|
|
|
4099
4054
|
};
|
|
4100
4055
|
/**
|
|
4101
4056
|
* add extraQueryParams
|
|
4102
|
-
* @param
|
|
4057
|
+
* @param eQParams
|
|
4103
4058
|
*/
|
|
4104
|
-
RequestParameterBuilder.prototype.addExtraQueryParameters = function (
|
|
4059
|
+
RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQParams) {
|
|
4105
4060
|
var _this = this;
|
|
4106
|
-
RequestValidator.sanitizeEQParams(
|
|
4107
|
-
Object.keys(
|
|
4108
|
-
_this.parameters.set(key,
|
|
4061
|
+
var sanitizedEQParams = RequestValidator.sanitizeEQParams(eQParams, this.parameters);
|
|
4062
|
+
Object.keys(sanitizedEQParams).forEach(function (key) {
|
|
4063
|
+
_this.parameters.set(key, eQParams[key]);
|
|
4109
4064
|
});
|
|
4110
4065
|
};
|
|
4111
4066
|
RequestParameterBuilder.prototype.addClientCapabilitiesToClaims = function (claims, clientCapabilities) {
|
|
@@ -4200,7 +4155,109 @@
|
|
|
4200
4155
|
return RequestParameterBuilder;
|
|
4201
4156
|
}());
|
|
4202
4157
|
|
|
4203
|
-
/*! @azure/msal-common
|
|
4158
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4159
|
+
|
|
4160
|
+
/*
|
|
4161
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4162
|
+
* Licensed under the MIT License.
|
|
4163
|
+
*/
|
|
4164
|
+
/**
|
|
4165
|
+
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
4166
|
+
*/
|
|
4167
|
+
var BaseClient = /** @class */ (function () {
|
|
4168
|
+
function BaseClient(configuration, performanceClient) {
|
|
4169
|
+
// Set the configuration
|
|
4170
|
+
this.config = buildClientConfiguration(configuration);
|
|
4171
|
+
// Initialize the logger
|
|
4172
|
+
this.logger = new Logger(this.config.loggerOptions, name$1, version$1);
|
|
4173
|
+
// Initialize crypto
|
|
4174
|
+
this.cryptoUtils = this.config.cryptoInterface;
|
|
4175
|
+
// Initialize storage interface
|
|
4176
|
+
this.cacheManager = this.config.storageInterface;
|
|
4177
|
+
// Set the network interface
|
|
4178
|
+
this.networkClient = this.config.networkInterface;
|
|
4179
|
+
// Set the NetworkManager
|
|
4180
|
+
this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
|
|
4181
|
+
// Set TelemetryManager
|
|
4182
|
+
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
4183
|
+
// set Authority
|
|
4184
|
+
this.authority = this.config.authOptions.authority;
|
|
4185
|
+
// set performance telemetry client
|
|
4186
|
+
this.performanceClient = performanceClient;
|
|
4187
|
+
}
|
|
4188
|
+
/**
|
|
4189
|
+
* Creates default headers for requests to token endpoint
|
|
4190
|
+
*/
|
|
4191
|
+
BaseClient.prototype.createTokenRequestHeaders = function (ccsCred) {
|
|
4192
|
+
var headers = {};
|
|
4193
|
+
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
4194
|
+
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
4195
|
+
switch (ccsCred.type) {
|
|
4196
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
4197
|
+
try {
|
|
4198
|
+
var clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
4199
|
+
headers[HeaderNames.CCS_HEADER] = "Oid:" + clientInfo.uid + "@" + clientInfo.utid;
|
|
4200
|
+
}
|
|
4201
|
+
catch (e) {
|
|
4202
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
4203
|
+
}
|
|
4204
|
+
break;
|
|
4205
|
+
case CcsCredentialType.UPN:
|
|
4206
|
+
headers[HeaderNames.CCS_HEADER] = "UPN: " + ccsCred.credential;
|
|
4207
|
+
break;
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
return headers;
|
|
4211
|
+
};
|
|
4212
|
+
/**
|
|
4213
|
+
* Http post to token endpoint
|
|
4214
|
+
* @param tokenEndpoint
|
|
4215
|
+
* @param queryString
|
|
4216
|
+
* @param headers
|
|
4217
|
+
* @param thumbprint
|
|
4218
|
+
*/
|
|
4219
|
+
BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
|
|
4220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4221
|
+
var response;
|
|
4222
|
+
return __generator(this, function (_a) {
|
|
4223
|
+
switch (_a.label) {
|
|
4224
|
+
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
|
|
4225
|
+
case 1:
|
|
4226
|
+
response = _a.sent();
|
|
4227
|
+
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
4228
|
+
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
4229
|
+
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
4230
|
+
}
|
|
4231
|
+
return [2 /*return*/, response];
|
|
4232
|
+
}
|
|
4233
|
+
});
|
|
4234
|
+
});
|
|
4235
|
+
};
|
|
4236
|
+
/**
|
|
4237
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
4238
|
+
* @param updatedAuthority
|
|
4239
|
+
*/
|
|
4240
|
+
BaseClient.prototype.updateAuthority = function (updatedAuthority) {
|
|
4241
|
+
if (!updatedAuthority.discoveryComplete()) {
|
|
4242
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
|
|
4243
|
+
}
|
|
4244
|
+
this.authority = updatedAuthority;
|
|
4245
|
+
};
|
|
4246
|
+
/**
|
|
4247
|
+
* Creates query string for the /token request
|
|
4248
|
+
* @param request
|
|
4249
|
+
*/
|
|
4250
|
+
BaseClient.prototype.createTokenQueryParameters = function (request) {
|
|
4251
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
4252
|
+
if (request.tokenQueryParameters) {
|
|
4253
|
+
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
4254
|
+
}
|
|
4255
|
+
return parameterBuilder.createQueryString();
|
|
4256
|
+
};
|
|
4257
|
+
return BaseClient;
|
|
4258
|
+
}());
|
|
4259
|
+
|
|
4260
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4204
4261
|
|
|
4205
4262
|
/*
|
|
4206
4263
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4264,7 +4321,7 @@
|
|
|
4264
4321
|
return IdTokenEntity;
|
|
4265
4322
|
}(CredentialEntity));
|
|
4266
4323
|
|
|
4267
|
-
/*! @azure/msal-common
|
|
4324
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4268
4325
|
/*
|
|
4269
4326
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4270
4327
|
* Licensed under the MIT License.
|
|
@@ -4314,7 +4371,7 @@
|
|
|
4314
4371
|
return TimeUtils;
|
|
4315
4372
|
}());
|
|
4316
4373
|
|
|
4317
|
-
/*! @azure/msal-common
|
|
4374
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4318
4375
|
|
|
4319
4376
|
/*
|
|
4320
4377
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4428,7 +4485,7 @@
|
|
|
4428
4485
|
return AccessTokenEntity;
|
|
4429
4486
|
}(CredentialEntity));
|
|
4430
4487
|
|
|
4431
|
-
/*! @azure/msal-common
|
|
4488
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4432
4489
|
|
|
4433
4490
|
/*
|
|
4434
4491
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4495,7 +4552,7 @@
|
|
|
4495
4552
|
return RefreshTokenEntity;
|
|
4496
4553
|
}(CredentialEntity));
|
|
4497
4554
|
|
|
4498
|
-
/*! @azure/msal-common
|
|
4555
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4499
4556
|
|
|
4500
4557
|
/*
|
|
4501
4558
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4534,10 +4591,14 @@
|
|
|
4534
4591
|
*/
|
|
4535
4592
|
var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
4536
4593
|
__extends(InteractionRequiredAuthError, _super);
|
|
4537
|
-
function InteractionRequiredAuthError(errorCode, errorMessage, subError) {
|
|
4594
|
+
function InteractionRequiredAuthError(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims) {
|
|
4538
4595
|
var _this = _super.call(this, errorCode, errorMessage, subError) || this;
|
|
4539
|
-
_this.name = "InteractionRequiredAuthError";
|
|
4540
4596
|
Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
|
|
4597
|
+
_this.timestamp = timestamp || Constants.EMPTY_STRING;
|
|
4598
|
+
_this.traceId = traceId || Constants.EMPTY_STRING;
|
|
4599
|
+
_this.correlationId = correlationId || Constants.EMPTY_STRING;
|
|
4600
|
+
_this.claims = claims || Constants.EMPTY_STRING;
|
|
4601
|
+
_this.name = "InteractionRequiredAuthError";
|
|
4541
4602
|
return _this;
|
|
4542
4603
|
}
|
|
4543
4604
|
/**
|
|
@@ -4570,7 +4631,7 @@
|
|
|
4570
4631
|
return InteractionRequiredAuthError;
|
|
4571
4632
|
}(AuthError));
|
|
4572
4633
|
|
|
4573
|
-
/*! @azure/msal-common
|
|
4634
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4574
4635
|
/*
|
|
4575
4636
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4576
4637
|
* Licensed under the MIT License.
|
|
@@ -4586,7 +4647,7 @@
|
|
|
4586
4647
|
return CacheRecord;
|
|
4587
4648
|
}());
|
|
4588
4649
|
|
|
4589
|
-
/*! @azure/msal-common
|
|
4650
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4590
4651
|
|
|
4591
4652
|
/*
|
|
4592
4653
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4657,7 +4718,7 @@
|
|
|
4657
4718
|
return ProtocolUtils;
|
|
4658
4719
|
}());
|
|
4659
4720
|
|
|
4660
|
-
/*! @azure/msal-common
|
|
4721
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4661
4722
|
|
|
4662
4723
|
/*
|
|
4663
4724
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4891,43 +4952,277 @@
|
|
|
4891
4952
|
return UrlString;
|
|
4892
4953
|
}());
|
|
4893
4954
|
|
|
4894
|
-
/*! @azure/msal-common
|
|
4895
|
-
|
|
4955
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4896
4956
|
/*
|
|
4897
4957
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4898
4958
|
* Licensed under the MIT License.
|
|
4899
4959
|
*/
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
}
|
|
4960
|
+
/**
|
|
4961
|
+
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
4962
|
+
*
|
|
4963
|
+
* @export
|
|
4964
|
+
* @enum {number}
|
|
4965
|
+
*/
|
|
4966
|
+
exports.PerformanceEvents = void 0;
|
|
4967
|
+
(function (PerformanceEvents) {
|
|
4909
4968
|
/**
|
|
4910
|
-
*
|
|
4911
|
-
*
|
|
4912
|
-
* @param request
|
|
4913
|
-
* @returns
|
|
4969
|
+
* acquireTokenByCode API (msal-browser and msal-node).
|
|
4970
|
+
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
4914
4971
|
*/
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4972
|
+
PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
|
|
4973
|
+
/**
|
|
4974
|
+
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
4975
|
+
* Used to renew an access token using a refresh token against the token endpoint.
|
|
4976
|
+
*/
|
|
4977
|
+
PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
|
|
4978
|
+
/**
|
|
4979
|
+
* acquireTokenSilent API (msal-browser and msal-node).
|
|
4980
|
+
* Used to silently acquire a new access token (from the cache or the network).
|
|
4981
|
+
*/
|
|
4982
|
+
PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
|
|
4983
|
+
/**
|
|
4984
|
+
* acquireTokenSilentAsync (msal-browser).
|
|
4985
|
+
* Internal API for acquireTokenSilent.
|
|
4986
|
+
*/
|
|
4987
|
+
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
4988
|
+
/**
|
|
4989
|
+
* acquireTokenPopup (msal-browser).
|
|
4990
|
+
* Used to acquire a new access token interactively through pop ups
|
|
4991
|
+
*/
|
|
4992
|
+
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
4993
|
+
/**
|
|
4994
|
+
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
4995
|
+
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
4996
|
+
*/
|
|
4997
|
+
PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
|
|
4998
|
+
/**
|
|
4999
|
+
* signJwt API in CryptoOpts class (msal-browser).
|
|
5000
|
+
* Used to signed a pop token.
|
|
5001
|
+
*/
|
|
5002
|
+
PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
|
|
5003
|
+
/**
|
|
5004
|
+
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
5005
|
+
* Used to read access tokens from the cache.
|
|
5006
|
+
*/
|
|
5007
|
+
PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
|
|
5008
|
+
/**
|
|
5009
|
+
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
5010
|
+
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
5011
|
+
*/
|
|
5012
|
+
PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
|
|
5013
|
+
/**
|
|
5014
|
+
* acquireToken API in SilentRereshClient (msal-browser).
|
|
5015
|
+
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
5016
|
+
*/
|
|
5017
|
+
PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
|
|
5018
|
+
/**
|
|
5019
|
+
* ssoSilent API (msal-browser).
|
|
5020
|
+
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
5021
|
+
*/
|
|
5022
|
+
PerformanceEvents["SsoSilent"] = "ssoSilent";
|
|
5023
|
+
/**
|
|
5024
|
+
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
5025
|
+
* Used to load authority metadata for a request.
|
|
5026
|
+
*/
|
|
5027
|
+
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
5028
|
+
/**
|
|
5029
|
+
* acquireToken APIs in msal-browser.
|
|
5030
|
+
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
5031
|
+
*/
|
|
5032
|
+
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
5033
|
+
/**
|
|
5034
|
+
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
5035
|
+
* Used to acquire a token from Native component when native brokering is enabled.
|
|
5036
|
+
*/
|
|
5037
|
+
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
5038
|
+
/**
|
|
5039
|
+
* Time spent creating default headers for requests to token endpoint
|
|
5040
|
+
*/
|
|
5041
|
+
PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
|
|
5042
|
+
/**
|
|
5043
|
+
* Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
|
|
5044
|
+
*/
|
|
5045
|
+
PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
|
|
5046
|
+
/**
|
|
5047
|
+
* acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
|
|
5048
|
+
*/
|
|
5049
|
+
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
5050
|
+
/**
|
|
5051
|
+
* Time taken for token acquisition by broker
|
|
5052
|
+
*/
|
|
5053
|
+
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
5054
|
+
/**
|
|
5055
|
+
* Time spent on the network for refresh token acquisition
|
|
5056
|
+
*/
|
|
5057
|
+
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5058
|
+
/**
|
|
5059
|
+
* Time taken for acquiring refresh token , records RT size
|
|
5060
|
+
*/
|
|
5061
|
+
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
5062
|
+
/**
|
|
5063
|
+
* Time taken for acquiring cached refresh token
|
|
5064
|
+
*/
|
|
5065
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
5066
|
+
/**
|
|
5067
|
+
* acquireTokenByRefreshToken API in RefreshTokenClient (msal-common).
|
|
5068
|
+
*/
|
|
5069
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenByRefreshToken"] = "refreshTokenClientAcquireTokenByRefreshToken";
|
|
5070
|
+
/**
|
|
5071
|
+
* Helper function to create token request body in RefreshTokenClient (msal-common).
|
|
5072
|
+
*/
|
|
5073
|
+
PerformanceEvents["RefreshTokenClientCreateTokenRequestBody"] = "refreshTokenClientCreateTokenRequestBody";
|
|
5074
|
+
/**
|
|
5075
|
+
* acquireTokenFromCache (msal-browser).
|
|
5076
|
+
* Internal API for acquiring token from cache
|
|
5077
|
+
*/
|
|
5078
|
+
PerformanceEvents["AcquireTokenFromCache"] = "acquireTokenFromCache";
|
|
5079
|
+
/**
|
|
5080
|
+
* acquireTokenBySilentIframe (msal-browser).
|
|
5081
|
+
* Internal API for acquiring token by silent Iframe
|
|
5082
|
+
*/
|
|
5083
|
+
PerformanceEvents["AcquireTokenBySilentIframe"] = "acquireTokenBySilentIframe";
|
|
5084
|
+
/**
|
|
5085
|
+
* Internal API for initializing base request in BaseInteractionClient (msal-browser)
|
|
5086
|
+
*/
|
|
5087
|
+
PerformanceEvents["InitializeBaseRequest"] = "initializeBaseRequest";
|
|
5088
|
+
/**
|
|
5089
|
+
* Internal API for initializing silent request in SilentCacheClient (msal-browser)
|
|
5090
|
+
*/
|
|
5091
|
+
PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
|
|
5092
|
+
PerformanceEvents["InitializeClientApplication"] = "initializeClientApplication";
|
|
5093
|
+
/**
|
|
5094
|
+
* Helper function in SilentIframeClient class (msal-browser).
|
|
5095
|
+
*/
|
|
5096
|
+
PerformanceEvents["SilentIframeClientTokenHelper"] = "silentIframeClientTokenHelper";
|
|
5097
|
+
/**
|
|
5098
|
+
* SilentHandler
|
|
5099
|
+
*/
|
|
5100
|
+
PerformanceEvents["SilentHandlerInitiateAuthRequest"] = "silentHandlerInitiateAuthRequest";
|
|
5101
|
+
PerformanceEvents["SilentHandlerMonitorIframeForHash"] = "silentHandlerMonitorIframeForHash";
|
|
5102
|
+
PerformanceEvents["SilentHandlerLoadFrame"] = "silentHandlerLoadFrame";
|
|
5103
|
+
/**
|
|
5104
|
+
* Helper functions in StandardInteractionClient class (msal-browser)
|
|
5105
|
+
*/
|
|
5106
|
+
PerformanceEvents["StandardInteractionClientCreateAuthCodeClient"] = "standardInteractionClientCreateAuthCodeClient";
|
|
5107
|
+
PerformanceEvents["StandardInteractionClientGetClientConfiguration"] = "standardInteractionClientGetClientConfiguration";
|
|
5108
|
+
PerformanceEvents["StandardInteractionClientInitializeAuthorizationRequest"] = "standardInteractionClientInitializeAuthorizationRequest";
|
|
5109
|
+
PerformanceEvents["StandardInteractionClientInitializeAuthorizationCodeRequest"] = "standardInteractionClientInitializeAuthorizationCodeRequest";
|
|
5110
|
+
/**
|
|
5111
|
+
* getAuthCodeUrl API (msal-browser and msal-node).
|
|
5112
|
+
*/
|
|
5113
|
+
PerformanceEvents["GetAuthCodeUrl"] = "getAuthCodeUrl";
|
|
5114
|
+
/**
|
|
5115
|
+
* Functions from InteractionHandler (msal-browser)
|
|
5116
|
+
*/
|
|
5117
|
+
PerformanceEvents["HandleCodeResponseFromServer"] = "handleCodeResponseFromServer";
|
|
5118
|
+
PerformanceEvents["HandleCodeResponseFromHash"] = "handleCodeResponseFromHash";
|
|
5119
|
+
PerformanceEvents["UpdateTokenEndpointAuthority"] = "updateTokenEndpointAuthority";
|
|
5120
|
+
/**
|
|
5121
|
+
* APIs in Authorization Code Client (msal-common)
|
|
5122
|
+
*/
|
|
5123
|
+
PerformanceEvents["AuthClientAcquireToken"] = "authClientAcquireToken";
|
|
5124
|
+
PerformanceEvents["AuthClientExecuteTokenRequest"] = "authClientExecuteTokenRequest";
|
|
5125
|
+
PerformanceEvents["AuthClientCreateTokenRequestBody"] = "authClientCreateTokenRequestBody";
|
|
5126
|
+
PerformanceEvents["AuthClientCreateQueryString"] = "authClientCreateQueryString";
|
|
5127
|
+
/**
|
|
5128
|
+
* Generate functions in PopTokenGenerator (msal-common)
|
|
5129
|
+
*/
|
|
5130
|
+
PerformanceEvents["PopTokenGenerateCnf"] = "popTokenGenerateCnf";
|
|
5131
|
+
PerformanceEvents["PopTokenGenerateKid"] = "popTokenGenerateKid";
|
|
5132
|
+
/**
|
|
5133
|
+
* handleServerTokenResponse API in ResponseHandler (msal-common)
|
|
5134
|
+
*/
|
|
5135
|
+
PerformanceEvents["HandleServerTokenResponse"] = "handleServerTokenResponse";
|
|
5136
|
+
/**
|
|
5137
|
+
* Authority functions
|
|
5138
|
+
*/
|
|
5139
|
+
PerformanceEvents["AuthorityFactoryCreateDiscoveredInstance"] = "authorityFactoryCreateDiscoveredInstance";
|
|
5140
|
+
PerformanceEvents["AuthorityResolveEndpointsAsync"] = "authorityResolveEndpointsAsync";
|
|
5141
|
+
PerformanceEvents["AuthorityGetCloudDiscoveryMetadataFromNetwork"] = "authorityGetCloudDiscoveryMetadataFromNetwork";
|
|
5142
|
+
PerformanceEvents["AuthorityUpdateCloudDiscoveryMetadata"] = "authorityUpdateCloudDiscoveryMetadata";
|
|
5143
|
+
PerformanceEvents["AuthorityGetEndpointMetadataFromNetwork"] = "authorityGetEndpointMetadataFromNetwork";
|
|
5144
|
+
PerformanceEvents["AuthorityUpdateEndpointMetadata"] = "authorityUpdateEndpointMetadata";
|
|
5145
|
+
PerformanceEvents["AuthorityUpdateMetadataWithRegionalInformation"] = "authorityUpdateMetadataWithRegionalInformation";
|
|
5146
|
+
/**
|
|
5147
|
+
* Region Discovery functions
|
|
5148
|
+
*/
|
|
5149
|
+
PerformanceEvents["RegionDiscoveryDetectRegion"] = "regionDiscoveryDetectRegion";
|
|
5150
|
+
PerformanceEvents["RegionDiscoveryGetRegionFromIMDS"] = "regionDiscoveryGetRegionFromIMDS";
|
|
5151
|
+
PerformanceEvents["RegionDiscoveryGetCurrentVersion"] = "regionDiscoveryGetCurrentVersion";
|
|
5152
|
+
PerformanceEvents["AcquireTokenByCodeAsync"] = "acquireTokenByCodeAsync";
|
|
5153
|
+
PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
|
|
5154
|
+
PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
|
|
5155
|
+
PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
|
|
5156
|
+
PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
|
|
5157
|
+
PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
|
|
5158
|
+
PerformanceEvents["NativeMessageHandlerHandshake"] = "nativeMessageHandlerHandshake";
|
|
5159
|
+
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5160
|
+
/**
|
|
5161
|
+
* State of the performance event.
|
|
5162
|
+
*
|
|
5163
|
+
* @export
|
|
5164
|
+
* @enum {number}
|
|
5165
|
+
*/
|
|
5166
|
+
var PerformanceEventStatus;
|
|
5167
|
+
(function (PerformanceEventStatus) {
|
|
5168
|
+
PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
|
|
5169
|
+
PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
|
|
5170
|
+
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
5171
|
+
})(PerformanceEventStatus || (PerformanceEventStatus = {}));
|
|
5172
|
+
var IntFields = new Set([
|
|
5173
|
+
"accessTokenSize",
|
|
5174
|
+
"durationMs",
|
|
5175
|
+
"idTokenSize",
|
|
5176
|
+
"matsSilentStatus",
|
|
5177
|
+
"matsHttpStatus",
|
|
5178
|
+
"refreshTokenSize",
|
|
5179
|
+
"queuedTimeMs",
|
|
5180
|
+
"startTimeMs",
|
|
5181
|
+
"status",
|
|
5182
|
+
]);
|
|
5183
|
+
|
|
5184
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
5185
|
+
|
|
5186
|
+
/*
|
|
5187
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5188
|
+
* Licensed under the MIT License.
|
|
5189
|
+
*/
|
|
5190
|
+
var KeyLocation;
|
|
5191
|
+
(function (KeyLocation) {
|
|
5192
|
+
KeyLocation["SW"] = "sw";
|
|
5193
|
+
KeyLocation["UHW"] = "uhw";
|
|
5194
|
+
})(KeyLocation || (KeyLocation = {}));
|
|
5195
|
+
var PopTokenGenerator = /** @class */ (function () {
|
|
5196
|
+
function PopTokenGenerator(cryptoUtils, performanceClient) {
|
|
5197
|
+
this.cryptoUtils = cryptoUtils;
|
|
5198
|
+
this.performanceClient = performanceClient;
|
|
5199
|
+
}
|
|
5200
|
+
/**
|
|
5201
|
+
* Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
|
|
5202
|
+
* and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
|
|
5203
|
+
* @param request
|
|
5204
|
+
* @returns
|
|
5205
|
+
*/
|
|
5206
|
+
PopTokenGenerator.prototype.generateCnf = function (request) {
|
|
5207
|
+
var _a, _b;
|
|
5208
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5209
|
+
var reqCnf, reqCnfString, _c;
|
|
5210
|
+
return __generator(this, function (_d) {
|
|
5211
|
+
switch (_d.label) {
|
|
5212
|
+
case 0:
|
|
5213
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5214
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5215
|
+
return [4 /*yield*/, this.generateKid(request)];
|
|
5216
|
+
case 1:
|
|
5217
|
+
reqCnf = _d.sent();
|
|
5218
|
+
reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
|
|
5219
|
+
_c = {
|
|
5220
|
+
kid: reqCnf.kid,
|
|
5221
|
+
reqCnfString: reqCnfString
|
|
5222
|
+
};
|
|
5223
|
+
return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
|
|
5224
|
+
case 2: return [2 /*return*/, (_c.reqCnfHash = _d.sent(),
|
|
5225
|
+
_c)];
|
|
4931
5226
|
}
|
|
4932
5227
|
});
|
|
4933
5228
|
});
|
|
@@ -4938,13 +5233,16 @@
|
|
|
4938
5233
|
* @returns
|
|
4939
5234
|
*/
|
|
4940
5235
|
PopTokenGenerator.prototype.generateKid = function (request) {
|
|
5236
|
+
var _a;
|
|
4941
5237
|
return __awaiter(this, void 0, void 0, function () {
|
|
4942
5238
|
var kidThumbprint;
|
|
4943
|
-
return __generator(this, function (
|
|
4944
|
-
switch (
|
|
4945
|
-
case 0:
|
|
5239
|
+
return __generator(this, function (_b) {
|
|
5240
|
+
switch (_b.label) {
|
|
5241
|
+
case 0:
|
|
5242
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5243
|
+
return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
|
|
4946
5244
|
case 1:
|
|
4947
|
-
kidThumbprint =
|
|
5245
|
+
kidThumbprint = _b.sent();
|
|
4948
5246
|
return [2 /*return*/, {
|
|
4949
5247
|
kid: kidThumbprint,
|
|
4950
5248
|
xms_ksl: KeyLocation.SW
|
|
@@ -4992,7 +5290,7 @@
|
|
|
4992
5290
|
return PopTokenGenerator;
|
|
4993
5291
|
}());
|
|
4994
5292
|
|
|
4995
|
-
/*! @azure/msal-common
|
|
5293
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
4996
5294
|
|
|
4997
5295
|
/*
|
|
4998
5296
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5062,7 +5360,7 @@
|
|
|
5062
5360
|
return AppMetadataEntity;
|
|
5063
5361
|
}());
|
|
5064
5362
|
|
|
5065
|
-
/*! @azure/msal-common
|
|
5363
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
5066
5364
|
/*
|
|
5067
5365
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5068
5366
|
* Licensed under the MIT License.
|
|
@@ -5098,7 +5396,7 @@
|
|
|
5098
5396
|
return TokenCacheContext;
|
|
5099
5397
|
}());
|
|
5100
5398
|
|
|
5101
|
-
/*! @azure/msal-common
|
|
5399
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
5102
5400
|
|
|
5103
5401
|
/*
|
|
5104
5402
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5108,13 +5406,14 @@
|
|
|
5108
5406
|
* Class that handles response parsing.
|
|
5109
5407
|
*/
|
|
5110
5408
|
var ResponseHandler = /** @class */ (function () {
|
|
5111
|
-
function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin) {
|
|
5409
|
+
function ResponseHandler(clientId, cacheStorage, cryptoObj, logger, serializableCache, persistencePlugin, performanceClient) {
|
|
5112
5410
|
this.clientId = clientId;
|
|
5113
5411
|
this.cacheStorage = cacheStorage;
|
|
5114
5412
|
this.cryptoObj = cryptoObj;
|
|
5115
5413
|
this.logger = logger;
|
|
5116
5414
|
this.serializableCache = serializableCache;
|
|
5117
5415
|
this.persistencePlugin = persistencePlugin;
|
|
5416
|
+
this.performanceClient = performanceClient;
|
|
5118
5417
|
}
|
|
5119
5418
|
/**
|
|
5120
5419
|
* Function which validates server authorization code response.
|
|
@@ -5132,7 +5431,7 @@
|
|
|
5132
5431
|
// Check for error
|
|
5133
5432
|
if (serverResponseHash.error || serverResponseHash.error_description || serverResponseHash.suberror) {
|
|
5134
5433
|
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror)) {
|
|
5135
|
-
throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
5434
|
+
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);
|
|
5136
5435
|
}
|
|
5137
5436
|
throw new ServerError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
5138
5437
|
}
|
|
@@ -5148,7 +5447,7 @@
|
|
|
5148
5447
|
// Check for error
|
|
5149
5448
|
if (serverResponse.error || serverResponse.error_description || serverResponse.suberror) {
|
|
5150
5449
|
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
|
|
5151
|
-
throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror);
|
|
5450
|
+
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);
|
|
5152
5451
|
}
|
|
5153
5452
|
var errString = serverResponse.error_codes + " - [" + serverResponse.timestamp + "]: " + serverResponse.error_description + " - Correlation ID: " + serverResponse.correlation_id + " - Trace ID: " + serverResponse.trace_id;
|
|
5154
5453
|
throw new ServerError(serverResponse.error, errString, serverResponse.suberror);
|
|
@@ -5160,11 +5459,13 @@
|
|
|
5160
5459
|
* @param authority
|
|
5161
5460
|
*/
|
|
5162
5461
|
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
|
|
5462
|
+
var _a;
|
|
5163
5463
|
return __awaiter(this, void 0, void 0, function () {
|
|
5164
5464
|
var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
5165
|
-
return __generator(this, function (
|
|
5166
|
-
switch (
|
|
5465
|
+
return __generator(this, function (_b) {
|
|
5466
|
+
switch (_b.label) {
|
|
5167
5467
|
case 0:
|
|
5468
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.HandleServerTokenResponse, serverTokenResponse.correlation_id);
|
|
5168
5469
|
if (serverTokenResponse.id_token) {
|
|
5169
5470
|
idTokenObj = new AuthToken(serverTokenResponse.id_token || Constants.EMPTY_STRING, this.cryptoObj);
|
|
5170
5471
|
// token nonce check (TODO: Add a warning if no nonce is given?)
|
|
@@ -5190,16 +5491,16 @@
|
|
|
5190
5491
|
// Add keyId from request to serverTokenResponse if defined
|
|
5191
5492
|
serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
|
|
5192
5493
|
cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
|
|
5193
|
-
|
|
5494
|
+
_b.label = 1;
|
|
5194
5495
|
case 1:
|
|
5195
|
-
|
|
5496
|
+
_b.trys.push([1, , 5, 8]);
|
|
5196
5497
|
if (!(this.persistencePlugin && this.serializableCache)) return [3 /*break*/, 3];
|
|
5197
5498
|
this.logger.verbose("Persistence enabled, calling beforeCacheAccess");
|
|
5198
5499
|
cacheContext = new TokenCacheContext(this.serializableCache, true);
|
|
5199
5500
|
return [4 /*yield*/, this.persistencePlugin.beforeCacheAccess(cacheContext)];
|
|
5200
5501
|
case 2:
|
|
5201
|
-
|
|
5202
|
-
|
|
5502
|
+
_b.sent();
|
|
5503
|
+
_b.label = 3;
|
|
5203
5504
|
case 3:
|
|
5204
5505
|
/*
|
|
5205
5506
|
* When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
|
|
@@ -5217,17 +5518,17 @@
|
|
|
5217
5518
|
}
|
|
5218
5519
|
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
5219
5520
|
case 4:
|
|
5220
|
-
|
|
5521
|
+
_b.sent();
|
|
5221
5522
|
return [3 /*break*/, 8];
|
|
5222
5523
|
case 5:
|
|
5223
5524
|
if (!(this.persistencePlugin && this.serializableCache && cacheContext)) return [3 /*break*/, 7];
|
|
5224
5525
|
this.logger.verbose("Persistence enabled, calling afterCacheAccess");
|
|
5225
5526
|
return [4 /*yield*/, this.persistencePlugin.afterCacheAccess(cacheContext)];
|
|
5226
5527
|
case 6:
|
|
5227
|
-
|
|
5228
|
-
|
|
5528
|
+
_b.sent();
|
|
5529
|
+
_b.label = 7;
|
|
5229
5530
|
case 7: return [7 /*endfinally*/];
|
|
5230
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse
|
|
5531
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse, serverRequestId)];
|
|
5231
5532
|
}
|
|
5232
5533
|
});
|
|
5233
5534
|
});
|
|
@@ -5313,7 +5614,7 @@
|
|
|
5313
5614
|
* @param fromTokenCache
|
|
5314
5615
|
* @param stateString
|
|
5315
5616
|
*/
|
|
5316
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState,
|
|
5617
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, serverTokenResponse, requestId) {
|
|
5317
5618
|
var _a, _b, _c;
|
|
5318
5619
|
return __awaiter(this, void 0, void 0, function () {
|
|
5319
5620
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
@@ -5349,6 +5650,10 @@
|
|
|
5349
5650
|
}
|
|
5350
5651
|
uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
|
|
5351
5652
|
tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
|
|
5653
|
+
// for hybrid + native bridge enablement, send back the native account Id
|
|
5654
|
+
if ((serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid) && !!cacheRecord.account) {
|
|
5655
|
+
cacheRecord.account.nativeAccountId = serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid;
|
|
5656
|
+
}
|
|
5352
5657
|
return [2 /*return*/, {
|
|
5353
5658
|
authority: authority.canonicalAuthority,
|
|
5354
5659
|
uniqueId: uid,
|
|
@@ -5368,7 +5673,7 @@
|
|
|
5368
5673
|
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
5369
5674
|
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
5370
5675
|
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
5371
|
-
code:
|
|
5676
|
+
code: serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_code,
|
|
5372
5677
|
fromNativeBroker: false,
|
|
5373
5678
|
}];
|
|
5374
5679
|
}
|
|
@@ -5378,7 +5683,7 @@
|
|
|
5378
5683
|
return ResponseHandler;
|
|
5379
5684
|
}());
|
|
5380
5685
|
|
|
5381
|
-
/*! @azure/msal-common
|
|
5686
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
5382
5687
|
|
|
5383
5688
|
/*
|
|
5384
5689
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5406,13 +5711,17 @@
|
|
|
5406
5711
|
* @param request
|
|
5407
5712
|
*/
|
|
5408
5713
|
AuthorizationCodeClient.prototype.getAuthCodeUrl = function (request) {
|
|
5714
|
+
var _a, _b;
|
|
5409
5715
|
return __awaiter(this, void 0, void 0, function () {
|
|
5410
5716
|
var queryString;
|
|
5411
|
-
return __generator(this, function (
|
|
5412
|
-
switch (
|
|
5413
|
-
case 0:
|
|
5717
|
+
return __generator(this, function (_c) {
|
|
5718
|
+
switch (_c.label) {
|
|
5719
|
+
case 0:
|
|
5720
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.GetAuthCodeUrl, request.correlationId);
|
|
5721
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5722
|
+
return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
|
|
5414
5723
|
case 1:
|
|
5415
|
-
queryString =
|
|
5724
|
+
queryString = _c.sent();
|
|
5416
5725
|
return [2 /*return*/, UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString)];
|
|
5417
5726
|
}
|
|
5418
5727
|
});
|
|
@@ -5424,32 +5733,35 @@
|
|
|
5424
5733
|
* @param request
|
|
5425
5734
|
*/
|
|
5426
5735
|
AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
|
|
5427
|
-
var _a, _b, _c;
|
|
5736
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5428
5737
|
return __awaiter(this, void 0, void 0, function () {
|
|
5429
5738
|
var atsMeasurement, reqTimestamp, response, requestId, httpVerAuthority, responseHandler;
|
|
5430
5739
|
var _this = this;
|
|
5431
|
-
return __generator(this, function (
|
|
5432
|
-
switch (
|
|
5740
|
+
return __generator(this, function (_g) {
|
|
5741
|
+
switch (_g.label) {
|
|
5433
5742
|
case 0:
|
|
5434
|
-
|
|
5435
|
-
this.logger.info("in acquireToken call in auth-code client");
|
|
5436
|
-
if (!request || StringUtils.isEmpty(request.code)) {
|
|
5743
|
+
if (!request || !request.code) {
|
|
5437
5744
|
throw ClientAuthError.createTokenRequestCannotBeMadeError();
|
|
5438
5745
|
}
|
|
5746
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientAcquireToken, request.correlationId);
|
|
5747
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement("AuthCodeClientAcquireToken", request.correlationId);
|
|
5748
|
+
this.logger.info("in acquireToken call in auth-code client");
|
|
5439
5749
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5750
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5440
5751
|
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
5441
5752
|
case 1:
|
|
5442
|
-
response =
|
|
5443
|
-
requestId = (
|
|
5444
|
-
httpVerAuthority = (
|
|
5753
|
+
response = _g.sent();
|
|
5754
|
+
requestId = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[HeaderNames.X_MS_REQUEST_ID];
|
|
5755
|
+
httpVerAuthority = (_e = response.headers) === null || _e === void 0 ? void 0 : _e[HeaderNames.X_MS_HTTP_VERSION];
|
|
5445
5756
|
if (httpVerAuthority) {
|
|
5446
5757
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
5447
5758
|
httpVerAuthority: httpVerAuthority
|
|
5448
5759
|
});
|
|
5449
5760
|
}
|
|
5450
|
-
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5761
|
+
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin, this.performanceClient);
|
|
5451
5762
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
5452
5763
|
responseHandler.validateTokenResponse(response.body);
|
|
5764
|
+
(_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
5453
5765
|
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId).then(function (result) {
|
|
5454
5766
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
5455
5767
|
success: true
|
|
@@ -5511,26 +5823,19 @@
|
|
|
5511
5823
|
* @param request
|
|
5512
5824
|
*/
|
|
5513
5825
|
AuthorizationCodeClient.prototype.executeTokenRequest = function (authority, request) {
|
|
5826
|
+
var _a, _b;
|
|
5514
5827
|
return __awaiter(this, void 0, void 0, function () {
|
|
5515
|
-
var
|
|
5516
|
-
return __generator(this, function (
|
|
5517
|
-
switch (
|
|
5828
|
+
var queryParametersString, endpoint, requestBody, ccsCredential, clientInfo, headers, thumbprint;
|
|
5829
|
+
return __generator(this, function (_c) {
|
|
5830
|
+
switch (_c.label) {
|
|
5518
5831
|
case 0:
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
claims: request.claims,
|
|
5524
|
-
authenticationScheme: request.authenticationScheme,
|
|
5525
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
5526
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
5527
|
-
shrClaims: request.shrClaims,
|
|
5528
|
-
sshKid: request.sshKid
|
|
5529
|
-
};
|
|
5832
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5833
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5834
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
5835
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
5530
5836
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
5531
5837
|
case 1:
|
|
5532
|
-
requestBody =
|
|
5533
|
-
queryParameters = this.createTokenQueryParameters(request);
|
|
5838
|
+
requestBody = _c.sent();
|
|
5534
5839
|
ccsCredential = undefined;
|
|
5535
5840
|
if (request.clientInfo) {
|
|
5536
5841
|
try {
|
|
@@ -5545,34 +5850,35 @@
|
|
|
5545
5850
|
}
|
|
5546
5851
|
}
|
|
5547
5852
|
headers = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);
|
|
5548
|
-
|
|
5853
|
+
thumbprint = {
|
|
5854
|
+
clientId: this.config.authOptions.clientId,
|
|
5855
|
+
authority: authority.canonicalAuthority,
|
|
5856
|
+
scopes: request.scopes,
|
|
5857
|
+
claims: request.claims,
|
|
5858
|
+
authenticationScheme: request.authenticationScheme,
|
|
5859
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5860
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5861
|
+
shrClaims: request.shrClaims,
|
|
5862
|
+
sshKid: request.sshKid
|
|
5863
|
+
};
|
|
5549
5864
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
5550
5865
|
}
|
|
5551
5866
|
});
|
|
5552
5867
|
});
|
|
5553
5868
|
};
|
|
5554
|
-
/**
|
|
5555
|
-
* Creates query string for the /token request
|
|
5556
|
-
* @param request
|
|
5557
|
-
*/
|
|
5558
|
-
AuthorizationCodeClient.prototype.createTokenQueryParameters = function (request) {
|
|
5559
|
-
var parameterBuilder = new RequestParameterBuilder();
|
|
5560
|
-
if (request.tokenQueryParameters) {
|
|
5561
|
-
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
5562
|
-
}
|
|
5563
|
-
return parameterBuilder.createQueryString();
|
|
5564
|
-
};
|
|
5565
5869
|
/**
|
|
5566
5870
|
* Generates a map for all the params to be sent to the service
|
|
5567
5871
|
* @param request
|
|
5568
5872
|
*/
|
|
5569
5873
|
AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
|
|
5874
|
+
var _a, _b;
|
|
5570
5875
|
return __awaiter(this, void 0, void 0, function () {
|
|
5571
5876
|
var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
|
|
5572
|
-
var
|
|
5573
|
-
return __generator(this, function (
|
|
5574
|
-
switch (
|
|
5877
|
+
var _c;
|
|
5878
|
+
return __generator(this, function (_d) {
|
|
5879
|
+
switch (_d.label) {
|
|
5575
5880
|
case 0:
|
|
5881
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5576
5882
|
parameterBuilder = new RequestParameterBuilder();
|
|
5577
5883
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5578
5884
|
/*
|
|
@@ -5613,10 +5919,11 @@
|
|
|
5613
5919
|
parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
|
|
5614
5920
|
parameterBuilder.addClientInfo();
|
|
5615
5921
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
5616
|
-
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5922
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
5923
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5617
5924
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5618
5925
|
case 1:
|
|
5619
|
-
reqCnfData =
|
|
5926
|
+
reqCnfData = _d.sent();
|
|
5620
5927
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
5621
5928
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
5622
5929
|
return [3 /*break*/, 3];
|
|
@@ -5629,7 +5936,7 @@
|
|
|
5629
5936
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5630
5937
|
}
|
|
5631
5938
|
}
|
|
5632
|
-
|
|
5939
|
+
_d.label = 3;
|
|
5633
5940
|
case 3:
|
|
5634
5941
|
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
5635
5942
|
parameterBuilder.addCorrelationId(correlationId);
|
|
@@ -5674,9 +5981,9 @@
|
|
|
5674
5981
|
}
|
|
5675
5982
|
// Add hybrid spa parameters if not already provided
|
|
5676
5983
|
if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
|
|
5677
|
-
parameterBuilder.addExtraQueryParameters((
|
|
5678
|
-
|
|
5679
|
-
|
|
5984
|
+
parameterBuilder.addExtraQueryParameters((_c = {},
|
|
5985
|
+
_c[AADServerParamKeys.RETURN_SPA_CODE] = "1",
|
|
5986
|
+
_c));
|
|
5680
5987
|
}
|
|
5681
5988
|
return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5682
5989
|
}
|
|
@@ -5688,11 +5995,13 @@
|
|
|
5688
5995
|
* @param request
|
|
5689
5996
|
*/
|
|
5690
5997
|
AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
|
|
5998
|
+
var _a;
|
|
5691
5999
|
return __awaiter(this, void 0, void 0, function () {
|
|
5692
6000
|
var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
|
|
5693
|
-
return __generator(this, function (
|
|
5694
|
-
switch (
|
|
6001
|
+
return __generator(this, function (_b) {
|
|
6002
|
+
switch (_b.label) {
|
|
5695
6003
|
case 0:
|
|
6004
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5696
6005
|
parameterBuilder = new RequestParameterBuilder();
|
|
5697
6006
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5698
6007
|
requestScopes = __spreadArrays(request.scopes || [], request.extraScopesToConsent || []);
|
|
@@ -5803,9 +6112,9 @@
|
|
|
5803
6112
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5804
6113
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5805
6114
|
case 1:
|
|
5806
|
-
reqCnfData =
|
|
6115
|
+
reqCnfData = _b.sent();
|
|
5807
6116
|
parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
|
|
5808
|
-
|
|
6117
|
+
_b.label = 2;
|
|
5809
6118
|
case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5810
6119
|
}
|
|
5811
6120
|
});
|
|
@@ -5852,137 +6161,7 @@
|
|
|
5852
6161
|
return AuthorizationCodeClient;
|
|
5853
6162
|
}(BaseClient));
|
|
5854
6163
|
|
|
5855
|
-
/*! @azure/msal-common
|
|
5856
|
-
/*
|
|
5857
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5858
|
-
* Licensed under the MIT License.
|
|
5859
|
-
*/
|
|
5860
|
-
/**
|
|
5861
|
-
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
5862
|
-
*
|
|
5863
|
-
* @export
|
|
5864
|
-
* @enum {number}
|
|
5865
|
-
*/
|
|
5866
|
-
exports.PerformanceEvents = void 0;
|
|
5867
|
-
(function (PerformanceEvents) {
|
|
5868
|
-
/**
|
|
5869
|
-
* acquireTokenByCode API (msal-browser and msal-node).
|
|
5870
|
-
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
5871
|
-
*/
|
|
5872
|
-
PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
|
|
5873
|
-
/**
|
|
5874
|
-
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
5875
|
-
* Used to renew an access token using a refresh token against the token endpoint.
|
|
5876
|
-
*/
|
|
5877
|
-
PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
|
|
5878
|
-
/**
|
|
5879
|
-
* acquireTokenSilent API (msal-browser and msal-node).
|
|
5880
|
-
* Used to silently acquire a new access token (from the cache or the network).
|
|
5881
|
-
*/
|
|
5882
|
-
PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
|
|
5883
|
-
/**
|
|
5884
|
-
* acquireTokenSilentAsync (msal-browser).
|
|
5885
|
-
* Internal API for acquireTokenSilent.
|
|
5886
|
-
*/
|
|
5887
|
-
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
5888
|
-
/**
|
|
5889
|
-
* acquireTokenPopup (msal-browser).
|
|
5890
|
-
* Used to acquire a new access token interactively through pop ups
|
|
5891
|
-
*/
|
|
5892
|
-
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
5893
|
-
/**
|
|
5894
|
-
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
5895
|
-
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
5896
|
-
*/
|
|
5897
|
-
PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
|
|
5898
|
-
/**
|
|
5899
|
-
* signJwt API in CryptoOpts class (msal-browser).
|
|
5900
|
-
* Used to signed a pop token.
|
|
5901
|
-
*/
|
|
5902
|
-
PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
|
|
5903
|
-
/**
|
|
5904
|
-
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
5905
|
-
* Used to read access tokens from the cache.
|
|
5906
|
-
*/
|
|
5907
|
-
PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
|
|
5908
|
-
/**
|
|
5909
|
-
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
5910
|
-
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
5911
|
-
*/
|
|
5912
|
-
PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
|
|
5913
|
-
/**
|
|
5914
|
-
* acquireToken API in SilentRereshClient (msal-browser).
|
|
5915
|
-
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
5916
|
-
*/
|
|
5917
|
-
PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
|
|
5918
|
-
/**
|
|
5919
|
-
* ssoSilent API (msal-browser).
|
|
5920
|
-
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
5921
|
-
*/
|
|
5922
|
-
PerformanceEvents["SsoSilent"] = "ssoSilent";
|
|
5923
|
-
/**
|
|
5924
|
-
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
5925
|
-
* Used to load authority metadata for a request.
|
|
5926
|
-
*/
|
|
5927
|
-
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
5928
|
-
/**
|
|
5929
|
-
* acquireToken APIs in msal-browser.
|
|
5930
|
-
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
5931
|
-
*/
|
|
5932
|
-
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
5933
|
-
/**
|
|
5934
|
-
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
5935
|
-
* Used to acquire a token from Native component when native brokering is enabled.
|
|
5936
|
-
*/
|
|
5937
|
-
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
5938
|
-
/**
|
|
5939
|
-
* Time spent creating default headers for requests to token endpoint
|
|
5940
|
-
*/
|
|
5941
|
-
PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
|
|
5942
|
-
/**
|
|
5943
|
-
* Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
|
|
5944
|
-
*/
|
|
5945
|
-
PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
|
|
5946
|
-
/**
|
|
5947
|
-
* acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
|
|
5948
|
-
*/
|
|
5949
|
-
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
5950
|
-
/**
|
|
5951
|
-
* Time taken for token acquisition by broker
|
|
5952
|
-
*/
|
|
5953
|
-
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
5954
|
-
/**
|
|
5955
|
-
* Time spent on the network for refresh token acquisition
|
|
5956
|
-
*/
|
|
5957
|
-
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5958
|
-
/**
|
|
5959
|
-
* Time taken for acquiring refresh token , records RT size
|
|
5960
|
-
*/
|
|
5961
|
-
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
5962
|
-
/**
|
|
5963
|
-
* Time taken for acquiring cached refresh token
|
|
5964
|
-
*/
|
|
5965
|
-
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
5966
|
-
PerformanceEvents["GetEndpointMetadataFromNetwork"] = "getEndpointMetadataFromNetwork";
|
|
5967
|
-
PerformanceEvents["GetCloudDiscoveryMetadataFromNetworkMeasurement"] = "getCloudDiscoveryMetadataFromNetworkMeasurement";
|
|
5968
|
-
PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
|
|
5969
|
-
PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
|
|
5970
|
-
PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
|
|
5971
|
-
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5972
|
-
/**
|
|
5973
|
-
* State of the performance event.
|
|
5974
|
-
*
|
|
5975
|
-
* @export
|
|
5976
|
-
* @enum {number}
|
|
5977
|
-
*/
|
|
5978
|
-
var PerformanceEventStatus;
|
|
5979
|
-
(function (PerformanceEventStatus) {
|
|
5980
|
-
PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
|
|
5981
|
-
PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
|
|
5982
|
-
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
5983
|
-
})(PerformanceEventStatus || (PerformanceEventStatus = {}));
|
|
5984
|
-
|
|
5985
|
-
/*! @azure/msal-common v9.0.2 2023-01-10 */
|
|
6164
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
5986
6165
|
|
|
5987
6166
|
/*
|
|
5988
6167
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5997,31 +6176,34 @@
|
|
|
5997
6176
|
return _super.call(this, configuration, performanceClient) || this;
|
|
5998
6177
|
}
|
|
5999
6178
|
RefreshTokenClient.prototype.acquireToken = function (request) {
|
|
6000
|
-
var _a, _b, _c, _d;
|
|
6179
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6001
6180
|
return __awaiter(this, void 0, void 0, function () {
|
|
6002
6181
|
var atsMeasurement, reqTimestamp, response, httpVerToken, requestId, responseHandler;
|
|
6003
6182
|
var _this = this;
|
|
6004
|
-
return __generator(this, function (
|
|
6005
|
-
switch (
|
|
6183
|
+
return __generator(this, function (_h) {
|
|
6184
|
+
switch (_h.label) {
|
|
6006
6185
|
case 0:
|
|
6007
|
-
|
|
6186
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6187
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6008
6188
|
this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
|
|
6009
6189
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
6190
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6010
6191
|
return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
6011
6192
|
case 1:
|
|
6012
|
-
response =
|
|
6013
|
-
httpVerToken = (
|
|
6193
|
+
response = _h.sent();
|
|
6194
|
+
httpVerToken = (_d = response.headers) === null || _d === void 0 ? void 0 : _d[HeaderNames.X_MS_HTTP_VERSION];
|
|
6014
6195
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
6015
|
-
refreshTokenSize: ((
|
|
6196
|
+
refreshTokenSize: ((_e = response.body.refresh_token) === null || _e === void 0 ? void 0 : _e.length) || 0,
|
|
6016
6197
|
});
|
|
6017
6198
|
if (httpVerToken) {
|
|
6018
6199
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.addStaticFields({
|
|
6019
6200
|
httpVerToken: httpVerToken,
|
|
6020
6201
|
});
|
|
6021
6202
|
}
|
|
6022
|
-
requestId = (
|
|
6203
|
+
requestId = (_f = response.headers) === null || _f === void 0 ? void 0 : _f[HeaderNames.X_MS_REQUEST_ID];
|
|
6023
6204
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
6024
6205
|
responseHandler.validateTokenResponse(response.body);
|
|
6206
|
+
(_g = this.performanceClient) === null || _g === void 0 ? void 0 : _g.setPreQueueTime(exports.PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
6025
6207
|
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
|
|
6026
6208
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6027
6209
|
success: true
|
|
@@ -6046,13 +6228,15 @@
|
|
|
6046
6228
|
* @param request
|
|
6047
6229
|
*/
|
|
6048
6230
|
RefreshTokenClient.prototype.acquireTokenByRefreshToken = function (request) {
|
|
6231
|
+
var _a, _b, _c, _d;
|
|
6049
6232
|
return __awaiter(this, void 0, void 0, function () {
|
|
6050
6233
|
var isFOCI, noFamilyRTInCache, clientMismatchErrorWithFamilyRT;
|
|
6051
|
-
return __generator(this, function (
|
|
6234
|
+
return __generator(this, function (_e) {
|
|
6052
6235
|
// Cannot renew token if no request object is given.
|
|
6053
6236
|
if (!request) {
|
|
6054
6237
|
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
6055
6238
|
}
|
|
6239
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
|
|
6056
6240
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
6057
6241
|
if (!request.account) {
|
|
6058
6242
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -6061,6 +6245,7 @@
|
|
|
6061
6245
|
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
6062
6246
|
if (isFOCI) {
|
|
6063
6247
|
try {
|
|
6248
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6064
6249
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
|
|
6065
6250
|
}
|
|
6066
6251
|
catch (e) {
|
|
@@ -6068,6 +6253,7 @@
|
|
|
6068
6253
|
clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
|
|
6069
6254
|
// if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
|
|
6070
6255
|
if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
|
|
6256
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6071
6257
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
|
|
6072
6258
|
// throw in all other cases
|
|
6073
6259
|
}
|
|
@@ -6077,6 +6263,7 @@
|
|
|
6077
6263
|
}
|
|
6078
6264
|
}
|
|
6079
6265
|
// fall back to application refresh token acquisition
|
|
6266
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6080
6267
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, false)];
|
|
6081
6268
|
});
|
|
6082
6269
|
});
|
|
@@ -6086,11 +6273,12 @@
|
|
|
6086
6273
|
* @param request
|
|
6087
6274
|
*/
|
|
6088
6275
|
RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
|
|
6089
|
-
var _a;
|
|
6276
|
+
var _a, _b, _c;
|
|
6090
6277
|
return __awaiter(this, void 0, void 0, function () {
|
|
6091
6278
|
var atsMeasurement, refreshToken, refreshTokenRequest;
|
|
6092
|
-
return __generator(this, function (
|
|
6093
|
-
|
|
6279
|
+
return __generator(this, function (_d) {
|
|
6280
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6281
|
+
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6094
6282
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6095
6283
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
6096
6284
|
if (!refreshToken) {
|
|
@@ -6105,6 +6293,7 @@
|
|
|
6105
6293
|
credential: request.account.homeAccountId,
|
|
6106
6294
|
type: CcsCredentialType.HOME_ACCOUNT_ID
|
|
6107
6295
|
} });
|
|
6296
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6108
6297
|
return [2 /*return*/, this.acquireToken(refreshTokenRequest)];
|
|
6109
6298
|
});
|
|
6110
6299
|
});
|
|
@@ -6115,17 +6304,20 @@
|
|
|
6115
6304
|
* @param authority
|
|
6116
6305
|
*/
|
|
6117
6306
|
RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
|
|
6118
|
-
var _a;
|
|
6307
|
+
var _a, _b, _c;
|
|
6119
6308
|
return __awaiter(this, void 0, void 0, function () {
|
|
6120
|
-
var acquireTokenMeasurement,
|
|
6121
|
-
return __generator(this, function (
|
|
6122
|
-
switch (
|
|
6309
|
+
var acquireTokenMeasurement, queryParametersString, endpoint, requestBody, headers, thumbprint;
|
|
6310
|
+
return __generator(this, function (_d) {
|
|
6311
|
+
switch (_d.label) {
|
|
6123
6312
|
case 0:
|
|
6124
|
-
|
|
6313
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6314
|
+
acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6315
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6316
|
+
queryParametersString = this.createTokenQueryParameters(request);
|
|
6317
|
+
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6125
6318
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
6126
6319
|
case 1:
|
|
6127
|
-
requestBody =
|
|
6128
|
-
queryParameters = this.createTokenQueryParameters(request);
|
|
6320
|
+
requestBody = _d.sent();
|
|
6129
6321
|
headers = this.createTokenRequestHeaders(request.ccsCredential);
|
|
6130
6322
|
thumbprint = {
|
|
6131
6323
|
clientId: this.config.authOptions.clientId,
|
|
@@ -6138,7 +6330,6 @@
|
|
|
6138
6330
|
shrClaims: request.shrClaims,
|
|
6139
6331
|
sshKid: request.sshKid
|
|
6140
6332
|
};
|
|
6141
|
-
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
|
|
6142
6333
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
|
|
6143
6334
|
.then(function (result) {
|
|
6144
6335
|
acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
|
|
@@ -6156,30 +6347,20 @@
|
|
|
6156
6347
|
});
|
|
6157
6348
|
});
|
|
6158
6349
|
};
|
|
6159
|
-
/**
|
|
6160
|
-
* Creates query string for the /token request
|
|
6161
|
-
* @param request
|
|
6162
|
-
*/
|
|
6163
|
-
RefreshTokenClient.prototype.createTokenQueryParameters = function (request) {
|
|
6164
|
-
var parameterBuilder = new RequestParameterBuilder();
|
|
6165
|
-
if (request.tokenQueryParameters) {
|
|
6166
|
-
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
6167
|
-
}
|
|
6168
|
-
return parameterBuilder.createQueryString();
|
|
6169
|
-
};
|
|
6170
6350
|
/**
|
|
6171
6351
|
* Helper function to create the token request body
|
|
6172
6352
|
* @param request
|
|
6173
6353
|
*/
|
|
6174
6354
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
6175
|
-
var _a;
|
|
6355
|
+
var _a, _b, _c;
|
|
6176
6356
|
return __awaiter(this, void 0, void 0, function () {
|
|
6177
6357
|
var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
|
|
6178
|
-
return __generator(this, function (
|
|
6179
|
-
switch (
|
|
6358
|
+
return __generator(this, function (_d) {
|
|
6359
|
+
switch (_d.label) {
|
|
6180
6360
|
case 0:
|
|
6361
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6181
6362
|
correlationId = request.correlationId;
|
|
6182
|
-
acquireTokenMeasurement = (
|
|
6363
|
+
acquireTokenMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6183
6364
|
parameterBuilder = new RequestParameterBuilder();
|
|
6184
6365
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6185
6366
|
parameterBuilder.addScopes(request.scopes);
|
|
@@ -6202,10 +6383,11 @@
|
|
|
6202
6383
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
6203
6384
|
}
|
|
6204
6385
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
6205
|
-
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
6386
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
6387
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
6206
6388
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
6207
6389
|
case 1:
|
|
6208
|
-
reqCnfData =
|
|
6390
|
+
reqCnfData = _d.sent();
|
|
6209
6391
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
6210
6392
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
6211
6393
|
return [3 /*break*/, 3];
|
|
@@ -6221,7 +6403,7 @@
|
|
|
6221
6403
|
throw ClientConfigurationError.createMissingSshJwkError();
|
|
6222
6404
|
}
|
|
6223
6405
|
}
|
|
6224
|
-
|
|
6406
|
+
_d.label = 3;
|
|
6225
6407
|
case 3:
|
|
6226
6408
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
6227
6409
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
@@ -6253,7 +6435,7 @@
|
|
|
6253
6435
|
return RefreshTokenClient;
|
|
6254
6436
|
}(BaseClient));
|
|
6255
6437
|
|
|
6256
|
-
/*! @azure/msal-common
|
|
6438
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6257
6439
|
|
|
6258
6440
|
/*
|
|
6259
6441
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6377,7 +6559,7 @@
|
|
|
6377
6559
|
return SilentFlowClient;
|
|
6378
6560
|
}(BaseClient));
|
|
6379
6561
|
|
|
6380
|
-
/*! @azure/msal-common
|
|
6562
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6381
6563
|
/*
|
|
6382
6564
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6383
6565
|
* Licensed under the MIT License.
|
|
@@ -6389,7 +6571,7 @@
|
|
|
6389
6571
|
response.hasOwnProperty("jwks_uri"));
|
|
6390
6572
|
}
|
|
6391
6573
|
|
|
6392
|
-
/*! @azure/msal-common
|
|
6574
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6393
6575
|
/*
|
|
6394
6576
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6395
6577
|
* Licensed under the MIT License.
|
|
@@ -6398,7 +6580,7 @@
|
|
|
6398
6580
|
var EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
6399
6581
|
var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
6400
6582
|
|
|
6401
|
-
/*! @azure/msal-common
|
|
6583
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6402
6584
|
/*
|
|
6403
6585
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6404
6586
|
* Licensed under the MIT License.
|
|
@@ -6412,7 +6594,7 @@
|
|
|
6412
6594
|
ProtocolMode["OIDC"] = "OIDC";
|
|
6413
6595
|
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
6414
6596
|
|
|
6415
|
-
/*! @azure/msal-common
|
|
6597
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6416
6598
|
|
|
6417
6599
|
/*
|
|
6418
6600
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6489,7 +6671,7 @@
|
|
|
6489
6671
|
return AuthorityMetadataEntity;
|
|
6490
6672
|
}());
|
|
6491
6673
|
|
|
6492
|
-
/*! @azure/msal-common
|
|
6674
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6493
6675
|
/*
|
|
6494
6676
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6495
6677
|
* Licensed under the MIT License.
|
|
@@ -6499,7 +6681,7 @@
|
|
|
6499
6681
|
response.hasOwnProperty("metadata"));
|
|
6500
6682
|
}
|
|
6501
6683
|
|
|
6502
|
-
/*! @azure/msal-common
|
|
6684
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6503
6685
|
/*
|
|
6504
6686
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6505
6687
|
* Licensed under the MIT License.
|
|
@@ -6509,68 +6691,72 @@
|
|
|
6509
6691
|
response.hasOwnProperty("error_description"));
|
|
6510
6692
|
}
|
|
6511
6693
|
|
|
6512
|
-
/*! @azure/msal-common
|
|
6694
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6513
6695
|
|
|
6514
6696
|
/*
|
|
6515
6697
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6516
6698
|
* Licensed under the MIT License.
|
|
6517
6699
|
*/
|
|
6518
6700
|
var RegionDiscovery = /** @class */ (function () {
|
|
6519
|
-
function RegionDiscovery(networkInterface) {
|
|
6701
|
+
function RegionDiscovery(networkInterface, performanceClient, correlationId) {
|
|
6520
6702
|
this.networkInterface = networkInterface;
|
|
6703
|
+
this.performanceClient = performanceClient;
|
|
6704
|
+
this.correlationId = correlationId;
|
|
6521
6705
|
}
|
|
6522
6706
|
/**
|
|
6523
6707
|
* Detect the region from the application's environment.
|
|
6524
6708
|
*
|
|
6525
6709
|
* @returns Promise<string | null>
|
|
6526
6710
|
*/
|
|
6527
|
-
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata
|
|
6711
|
+
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
|
|
6712
|
+
var _a, _b, _c, _d;
|
|
6528
6713
|
return __awaiter(this, void 0, void 0, function () {
|
|
6529
6714
|
var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
|
|
6530
|
-
return __generator(this, function (
|
|
6531
|
-
switch (
|
|
6715
|
+
return __generator(this, function (_e) {
|
|
6716
|
+
switch (_e.label) {
|
|
6532
6717
|
case 0:
|
|
6718
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
6533
6719
|
autodetectedRegionName = environmentRegion;
|
|
6534
6720
|
if (!!autodetectedRegionName) return [3 /*break*/, 8];
|
|
6535
6721
|
options = RegionDiscovery.IMDS_OPTIONS;
|
|
6536
|
-
|
|
6537
|
-
options.proxyUrl = proxyUrl;
|
|
6538
|
-
}
|
|
6539
|
-
_a.label = 1;
|
|
6722
|
+
_e.label = 1;
|
|
6540
6723
|
case 1:
|
|
6541
|
-
|
|
6724
|
+
_e.trys.push([1, 6, , 7]);
|
|
6725
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
6542
6726
|
return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
|
|
6543
6727
|
case 2:
|
|
6544
|
-
localIMDSVersionResponse =
|
|
6728
|
+
localIMDSVersionResponse = _e.sent();
|
|
6545
6729
|
if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
6546
6730
|
autodetectedRegionName = localIMDSVersionResponse.body;
|
|
6547
6731
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
|
|
6548
6732
|
}
|
|
6549
6733
|
if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
|
|
6734
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
6550
6735
|
return [4 /*yield*/, this.getCurrentVersion(options)];
|
|
6551
6736
|
case 3:
|
|
6552
|
-
currentIMDSVersion =
|
|
6737
|
+
currentIMDSVersion = _e.sent();
|
|
6553
6738
|
if (!currentIMDSVersion) {
|
|
6554
6739
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
6555
6740
|
return [2 /*return*/, null];
|
|
6556
6741
|
}
|
|
6742
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
6557
6743
|
return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
|
|
6558
6744
|
case 4:
|
|
6559
|
-
currentIMDSVersionResponse =
|
|
6745
|
+
currentIMDSVersionResponse = _e.sent();
|
|
6560
6746
|
if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
|
|
6561
6747
|
autodetectedRegionName = currentIMDSVersionResponse.body;
|
|
6562
6748
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
|
|
6563
6749
|
}
|
|
6564
|
-
|
|
6750
|
+
_e.label = 5;
|
|
6565
6751
|
case 5: return [3 /*break*/, 7];
|
|
6566
6752
|
case 6:
|
|
6567
|
-
|
|
6753
|
+
_e.sent();
|
|
6568
6754
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
6569
6755
|
return [2 /*return*/, null];
|
|
6570
6756
|
case 7: return [3 /*break*/, 9];
|
|
6571
6757
|
case 8:
|
|
6572
6758
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.ENVIRONMENT_VARIABLE;
|
|
6573
|
-
|
|
6759
|
+
_e.label = 9;
|
|
6574
6760
|
case 9:
|
|
6575
6761
|
// If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
|
|
6576
6762
|
if (!autodetectedRegionName) {
|
|
@@ -6588,8 +6774,10 @@
|
|
|
6588
6774
|
* @returns Promise<NetworkResponse<string>>
|
|
6589
6775
|
*/
|
|
6590
6776
|
RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
|
|
6777
|
+
var _a;
|
|
6591
6778
|
return __awaiter(this, void 0, void 0, function () {
|
|
6592
|
-
return __generator(this, function (
|
|
6779
|
+
return __generator(this, function (_b) {
|
|
6780
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
6593
6781
|
return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
|
|
6594
6782
|
});
|
|
6595
6783
|
});
|
|
@@ -6600,24 +6788,28 @@
|
|
|
6600
6788
|
* @returns Promise<string | null>
|
|
6601
6789
|
*/
|
|
6602
6790
|
RegionDiscovery.prototype.getCurrentVersion = function (options) {
|
|
6791
|
+
var _a;
|
|
6603
6792
|
return __awaiter(this, void 0, void 0, function () {
|
|
6604
6793
|
var response;
|
|
6605
|
-
return __generator(this, function (
|
|
6606
|
-
switch (
|
|
6794
|
+
return __generator(this, function (_b) {
|
|
6795
|
+
switch (_b.label) {
|
|
6607
6796
|
case 0:
|
|
6608
|
-
_a.
|
|
6609
|
-
|
|
6797
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
6798
|
+
_b.label = 1;
|
|
6610
6799
|
case 1:
|
|
6611
|
-
|
|
6800
|
+
_b.trys.push([1, 3, , 4]);
|
|
6801
|
+
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
|
|
6802
|
+
case 2:
|
|
6803
|
+
response = _b.sent();
|
|
6612
6804
|
// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
|
|
6613
6805
|
if (response.status === ResponseCodes.httpBadRequest && response.body && response.body["newest-versions"] && response.body["newest-versions"].length > 0) {
|
|
6614
6806
|
return [2 /*return*/, response.body["newest-versions"][0]];
|
|
6615
6807
|
}
|
|
6616
6808
|
return [2 /*return*/, null];
|
|
6617
|
-
case
|
|
6618
|
-
|
|
6809
|
+
case 3:
|
|
6810
|
+
_b.sent();
|
|
6619
6811
|
return [2 /*return*/, null];
|
|
6620
|
-
case
|
|
6812
|
+
case 4: return [2 /*return*/];
|
|
6621
6813
|
}
|
|
6622
6814
|
});
|
|
6623
6815
|
});
|
|
@@ -6631,7 +6823,7 @@
|
|
|
6631
6823
|
return RegionDiscovery;
|
|
6632
6824
|
}());
|
|
6633
6825
|
|
|
6634
|
-
/*! @azure/msal-common
|
|
6826
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
6635
6827
|
|
|
6636
6828
|
/*
|
|
6637
6829
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6642,16 +6834,17 @@
|
|
|
6642
6834
|
* endpoint. It will store the pertinent config data in this object for use during token calls.
|
|
6643
6835
|
*/
|
|
6644
6836
|
var Authority = /** @class */ (function () {
|
|
6645
|
-
function Authority(authority, networkInterface, cacheManager, authorityOptions, logger,
|
|
6837
|
+
function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
6646
6838
|
this.canonicalAuthority = authority;
|
|
6647
6839
|
this._canonicalAuthority.validateAsUri();
|
|
6648
6840
|
this.networkInterface = networkInterface;
|
|
6649
6841
|
this.cacheManager = cacheManager;
|
|
6650
6842
|
this.authorityOptions = authorityOptions;
|
|
6651
|
-
this.regionDiscovery = new RegionDiscovery(networkInterface);
|
|
6652
6843
|
this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
|
|
6653
|
-
this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
|
|
6654
6844
|
this.logger = logger;
|
|
6845
|
+
this.performanceClient = performanceClient;
|
|
6846
|
+
this.correlationId = correlationId;
|
|
6847
|
+
this.regionDiscovery = new RegionDiscovery(networkInterface, this.performanceClient, this.correlationId);
|
|
6655
6848
|
}
|
|
6656
6849
|
Object.defineProperty(Authority.prototype, "authorityType", {
|
|
6657
6850
|
// See above for AuthorityType
|
|
@@ -6888,23 +7081,27 @@
|
|
|
6888
7081
|
* and the /authorize, /token and logout endpoints.
|
|
6889
7082
|
*/
|
|
6890
7083
|
Authority.prototype.resolveEndpointsAsync = function () {
|
|
7084
|
+
var _a, _b, _c;
|
|
6891
7085
|
return __awaiter(this, void 0, void 0, function () {
|
|
6892
7086
|
var metadataEntity, cloudDiscoverySource, endpointSource, cacheKey;
|
|
6893
|
-
return __generator(this, function (
|
|
6894
|
-
switch (
|
|
7087
|
+
return __generator(this, function (_d) {
|
|
7088
|
+
switch (_d.label) {
|
|
6895
7089
|
case 0:
|
|
7090
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, this.correlationId);
|
|
6896
7091
|
metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
|
|
6897
7092
|
if (!metadataEntity) {
|
|
6898
7093
|
metadataEntity = new AuthorityMetadataEntity();
|
|
6899
7094
|
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
6900
7095
|
}
|
|
7096
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
6901
7097
|
return [4 /*yield*/, this.updateCloudDiscoveryMetadata(metadataEntity)];
|
|
6902
7098
|
case 1:
|
|
6903
|
-
cloudDiscoverySource =
|
|
7099
|
+
cloudDiscoverySource = _d.sent();
|
|
6904
7100
|
this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
|
|
7101
|
+
(_c = this.performanceClient) === null || _c === void 0 ? void 0 : _c.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
6905
7102
|
return [4 /*yield*/, this.updateEndpointMetadata(metadataEntity)];
|
|
6906
7103
|
case 2:
|
|
6907
|
-
endpointSource =
|
|
7104
|
+
endpointSource = _d.sent();
|
|
6908
7105
|
if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {
|
|
6909
7106
|
// Reset the expiration time unless both values came from a successful cache lookup
|
|
6910
7107
|
metadataEntity.resetExpiresAt();
|
|
@@ -6923,12 +7120,13 @@
|
|
|
6923
7120
|
* @param metadataEntity
|
|
6924
7121
|
*/
|
|
6925
7122
|
Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
|
|
6926
|
-
var _a, _b;
|
|
7123
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6927
7124
|
return __awaiter(this, void 0, void 0, function () {
|
|
6928
7125
|
var metadata, harcodedMetadata;
|
|
6929
|
-
return __generator(this, function (
|
|
6930
|
-
switch (
|
|
7126
|
+
return __generator(this, function (_g) {
|
|
7127
|
+
switch (_g.label) {
|
|
6931
7128
|
case 0:
|
|
7129
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
6932
7130
|
metadata = this.getEndpointMetadataFromConfig();
|
|
6933
7131
|
if (metadata) {
|
|
6934
7132
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
@@ -6939,25 +7137,28 @@
|
|
|
6939
7137
|
return [2 /*return*/, AuthorityMetadataSource.CACHE];
|
|
6940
7138
|
}
|
|
6941
7139
|
harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
|
|
7140
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
6942
7141
|
return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
|
|
6943
7142
|
case 1:
|
|
6944
|
-
metadata =
|
|
7143
|
+
metadata = _g.sent();
|
|
6945
7144
|
if (!metadata) return [3 /*break*/, 4];
|
|
6946
|
-
if (!((
|
|
7145
|
+
if (!((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion)) return [3 /*break*/, 3];
|
|
7146
|
+
(_d = this.performanceClient) === null || _d === void 0 ? void 0 : _d.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
6947
7147
|
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
|
|
6948
7148
|
case 2:
|
|
6949
|
-
metadata =
|
|
6950
|
-
|
|
7149
|
+
metadata = _g.sent();
|
|
7150
|
+
_g.label = 3;
|
|
6951
7151
|
case 3:
|
|
6952
7152
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
6953
7153
|
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
|
|
6954
7154
|
case 4:
|
|
6955
7155
|
if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
|
|
6956
|
-
if (!((
|
|
7156
|
+
if (!((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion)) return [3 /*break*/, 6];
|
|
7157
|
+
(_f = this.performanceClient) === null || _f === void 0 ? void 0 : _f.setPreQueueTime(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
6957
7158
|
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
|
|
6958
7159
|
case 5:
|
|
6959
|
-
harcodedMetadata =
|
|
6960
|
-
|
|
7160
|
+
harcodedMetadata = _g.sent();
|
|
7161
|
+
_g.label = 6;
|
|
6961
7162
|
case 6:
|
|
6962
7163
|
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
|
|
6963
7164
|
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
|
|
@@ -6997,25 +7198,24 @@
|
|
|
6997
7198
|
* @param hasHardcodedMetadata boolean
|
|
6998
7199
|
*/
|
|
6999
7200
|
Authority.prototype.getEndpointMetadataFromNetwork = function () {
|
|
7201
|
+
var _a;
|
|
7000
7202
|
return __awaiter(this, void 0, void 0, function () {
|
|
7001
7203
|
var options, response;
|
|
7002
|
-
return __generator(this, function (
|
|
7003
|
-
switch (
|
|
7204
|
+
return __generator(this, function (_b) {
|
|
7205
|
+
switch (_b.label) {
|
|
7004
7206
|
case 0:
|
|
7207
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7005
7208
|
options = {};
|
|
7006
|
-
|
|
7007
|
-
options.proxyUrl = this.proxyUrl;
|
|
7008
|
-
}
|
|
7009
|
-
_a.label = 1;
|
|
7209
|
+
_b.label = 1;
|
|
7010
7210
|
case 1:
|
|
7011
|
-
|
|
7211
|
+
_b.trys.push([1, 3, , 4]);
|
|
7012
7212
|
return [4 /*yield*/, this.networkInterface.
|
|
7013
7213
|
sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
|
|
7014
7214
|
case 2:
|
|
7015
|
-
response =
|
|
7215
|
+
response = _b.sent();
|
|
7016
7216
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
7017
7217
|
case 3:
|
|
7018
|
-
|
|
7218
|
+
_b.sent();
|
|
7019
7219
|
return [2 /*return*/, null];
|
|
7020
7220
|
case 4: return [2 /*return*/];
|
|
7021
7221
|
}
|
|
@@ -7035,25 +7235,28 @@
|
|
|
7035
7235
|
* Update the retrieved metadata with regional information.
|
|
7036
7236
|
*/
|
|
7037
7237
|
Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
|
|
7038
|
-
var _a, _b, _c, _d, _e;
|
|
7238
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7039
7239
|
return __awaiter(this, void 0, void 0, function () {
|
|
7040
7240
|
var autodetectedRegionName, azureRegion;
|
|
7041
|
-
return __generator(this, function (
|
|
7042
|
-
switch (
|
|
7043
|
-
case 0:
|
|
7241
|
+
return __generator(this, function (_h) {
|
|
7242
|
+
switch (_h.label) {
|
|
7243
|
+
case 0:
|
|
7244
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7245
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7246
|
+
return [4 /*yield*/, this.regionDiscovery.detectRegion((_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.environmentRegion, this.regionDiscoveryMetadata)];
|
|
7044
7247
|
case 1:
|
|
7045
|
-
autodetectedRegionName =
|
|
7046
|
-
azureRegion = ((
|
|
7248
|
+
autodetectedRegionName = _h.sent();
|
|
7249
|
+
azureRegion = ((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
|
|
7047
7250
|
? autodetectedRegionName
|
|
7048
|
-
: (
|
|
7049
|
-
if (((
|
|
7251
|
+
: (_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion;
|
|
7252
|
+
if (((_f = this.authorityOptions.azureRegionConfiguration) === null || _f === void 0 ? void 0 : _f.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7050
7253
|
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
|
|
7051
7254
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
|
|
7052
7255
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7053
7256
|
}
|
|
7054
7257
|
else {
|
|
7055
7258
|
if (autodetectedRegionName) {
|
|
7056
|
-
this.regionDiscoveryMetadata.region_outcome = (((
|
|
7259
|
+
this.regionDiscoveryMetadata.region_outcome = (((_g = this.authorityOptions.azureRegionConfiguration) === null || _g === void 0 ? void 0 : _g.azureRegion) === autodetectedRegionName) ?
|
|
7057
7260
|
RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
|
|
7058
7261
|
RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
7059
7262
|
}
|
|
@@ -7077,11 +7280,13 @@
|
|
|
7077
7280
|
* @param newMetadata
|
|
7078
7281
|
*/
|
|
7079
7282
|
Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
|
|
7283
|
+
var _a, _b;
|
|
7080
7284
|
return __awaiter(this, void 0, void 0, function () {
|
|
7081
7285
|
var metadata, metadataEntityExpired, harcodedMetadata;
|
|
7082
|
-
return __generator(this, function (
|
|
7083
|
-
switch (
|
|
7286
|
+
return __generator(this, function (_c) {
|
|
7287
|
+
switch (_c.label) {
|
|
7084
7288
|
case 0:
|
|
7289
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7085
7290
|
this.logger.verbose("Attempting to get cloud discovery metadata in the config");
|
|
7086
7291
|
this.logger.verbosePii("Known Authorities: " + (this.authorityOptions.knownAuthorities || Constants.NOT_APPLICABLE));
|
|
7087
7292
|
this.logger.verbosePii("Authority Metadata: " + (this.authorityOptions.authorityMetadata || Constants.NOT_APPLICABLE));
|
|
@@ -7104,9 +7309,10 @@
|
|
|
7104
7309
|
this.logger.verbose("The metadata entity is expired.");
|
|
7105
7310
|
}
|
|
7106
7311
|
this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
|
|
7312
|
+
(_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.setPreQueueTime(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7107
7313
|
return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
|
|
7108
7314
|
case 1:
|
|
7109
|
-
metadata =
|
|
7315
|
+
metadata = _c.sent();
|
|
7110
7316
|
if (metadata) {
|
|
7111
7317
|
this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
|
|
7112
7318
|
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
|
|
@@ -7164,23 +7370,22 @@
|
|
|
7164
7370
|
* @param hasHardcodedMetadata boolean
|
|
7165
7371
|
*/
|
|
7166
7372
|
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
|
|
7373
|
+
var _a;
|
|
7167
7374
|
return __awaiter(this, void 0, void 0, function () {
|
|
7168
7375
|
var instanceDiscoveryEndpoint, options, match, response, typedResponseBody, metadata, error_1, typedError;
|
|
7169
|
-
return __generator(this, function (
|
|
7170
|
-
switch (
|
|
7376
|
+
return __generator(this, function (_b) {
|
|
7377
|
+
switch (_b.label) {
|
|
7171
7378
|
case 0:
|
|
7379
|
+
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7172
7380
|
instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
|
|
7173
7381
|
options = {};
|
|
7174
|
-
if (this.proxyUrl) {
|
|
7175
|
-
options.proxyUrl = this.proxyUrl;
|
|
7176
|
-
}
|
|
7177
7382
|
match = null;
|
|
7178
|
-
|
|
7383
|
+
_b.label = 1;
|
|
7179
7384
|
case 1:
|
|
7180
|
-
|
|
7385
|
+
_b.trys.push([1, 3, , 4]);
|
|
7181
7386
|
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
|
|
7182
7387
|
case 2:
|
|
7183
|
-
response =
|
|
7388
|
+
response = _b.sent();
|
|
7184
7389
|
typedResponseBody = void 0;
|
|
7185
7390
|
metadata = void 0;
|
|
7186
7391
|
if (isCloudInstanceDiscoveryResponse(response.body)) {
|
|
@@ -7208,7 +7413,7 @@
|
|
|
7208
7413
|
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
|
|
7209
7414
|
return [3 /*break*/, 4];
|
|
7210
7415
|
case 3:
|
|
7211
|
-
error_1 =
|
|
7416
|
+
error_1 = _b.sent();
|
|
7212
7417
|
if (error_1 instanceof AuthError) {
|
|
7213
7418
|
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);
|
|
7214
7419
|
}
|
|
@@ -7353,7 +7558,7 @@
|
|
|
7353
7558
|
return Authority;
|
|
7354
7559
|
}());
|
|
7355
7560
|
|
|
7356
|
-
/*! @azure/msal-common
|
|
7561
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7357
7562
|
|
|
7358
7563
|
/*
|
|
7359
7564
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7372,16 +7577,18 @@
|
|
|
7372
7577
|
* @param networkClient
|
|
7373
7578
|
* @param protocolMode
|
|
7374
7579
|
*/
|
|
7375
|
-
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger,
|
|
7580
|
+
AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7376
7581
|
return __awaiter(this, void 0, void 0, function () {
|
|
7377
7582
|
var acquireTokenAuthority, e_1;
|
|
7378
7583
|
return __generator(this, function (_a) {
|
|
7379
7584
|
switch (_a.label) {
|
|
7380
7585
|
case 0:
|
|
7381
|
-
|
|
7586
|
+
performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.addQueueMeasurement(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
|
|
7587
|
+
acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId);
|
|
7382
7588
|
_a.label = 1;
|
|
7383
7589
|
case 1:
|
|
7384
7590
|
_a.trys.push([1, 3, , 4]);
|
|
7591
|
+
performanceClient === null || performanceClient === void 0 ? void 0 : performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityResolveEndpointsAsync, correlationId);
|
|
7385
7592
|
return [4 /*yield*/, acquireTokenAuthority.resolveEndpointsAsync()];
|
|
7386
7593
|
case 2:
|
|
7387
7594
|
_a.sent();
|
|
@@ -7404,17 +7611,17 @@
|
|
|
7404
7611
|
* @param networkInterface
|
|
7405
7612
|
* @param protocolMode
|
|
7406
7613
|
*/
|
|
7407
|
-
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger,
|
|
7614
|
+
AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
7408
7615
|
// Throw error if authority url is empty
|
|
7409
7616
|
if (StringUtils.isEmpty(authorityUrl)) {
|
|
7410
7617
|
throw ClientConfigurationError.createUrlEmptyError();
|
|
7411
7618
|
}
|
|
7412
|
-
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger,
|
|
7619
|
+
return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, logger, performanceClient, correlationId);
|
|
7413
7620
|
};
|
|
7414
7621
|
return AuthorityFactory;
|
|
7415
7622
|
}());
|
|
7416
7623
|
|
|
7417
|
-
/*! @azure/msal-common
|
|
7624
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7418
7625
|
|
|
7419
7626
|
/*
|
|
7420
7627
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7445,7 +7652,7 @@
|
|
|
7445
7652
|
return ServerTelemetryEntity;
|
|
7446
7653
|
}());
|
|
7447
7654
|
|
|
7448
|
-
/*! @azure/msal-common
|
|
7655
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7449
7656
|
|
|
7450
7657
|
/*
|
|
7451
7658
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7473,7 +7680,7 @@
|
|
|
7473
7680
|
return ThrottlingEntity;
|
|
7474
7681
|
}());
|
|
7475
7682
|
|
|
7476
|
-
/*! @azure/msal-common
|
|
7683
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7477
7684
|
|
|
7478
7685
|
/*
|
|
7479
7686
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7490,7 +7697,7 @@
|
|
|
7490
7697
|
}
|
|
7491
7698
|
};
|
|
7492
7699
|
|
|
7493
|
-
/*! @azure/msal-common
|
|
7700
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7494
7701
|
|
|
7495
7702
|
/*
|
|
7496
7703
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7535,7 +7742,7 @@
|
|
|
7535
7742
|
return JoseHeaderError;
|
|
7536
7743
|
}(AuthError));
|
|
7537
7744
|
|
|
7538
|
-
/*! @azure/msal-common
|
|
7745
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7539
7746
|
|
|
7540
7747
|
/*
|
|
7541
7748
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7565,8 +7772,8 @@
|
|
|
7565
7772
|
throw JoseHeaderError.createMissingAlgError();
|
|
7566
7773
|
}
|
|
7567
7774
|
var shrHeader = new JoseHeader({
|
|
7568
|
-
// Access Token PoP headers must have type
|
|
7569
|
-
typ: shrHeaderOptions.typ || JsonTypes.
|
|
7775
|
+
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
7776
|
+
typ: shrHeaderOptions.typ || JsonTypes.Pop,
|
|
7570
7777
|
kid: shrHeaderOptions.kid,
|
|
7571
7778
|
alg: shrHeaderOptions.alg
|
|
7572
7779
|
});
|
|
@@ -7575,7 +7782,7 @@
|
|
|
7575
7782
|
return JoseHeader;
|
|
7576
7783
|
}());
|
|
7577
7784
|
|
|
7578
|
-
/*! @azure/msal-common
|
|
7785
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7579
7786
|
|
|
7580
7787
|
/*
|
|
7581
7788
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7634,7 +7841,7 @@
|
|
|
7634
7841
|
return AuthenticationHeaderParser;
|
|
7635
7842
|
}());
|
|
7636
7843
|
|
|
7637
|
-
/*! @azure/msal-common
|
|
7844
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7638
7845
|
|
|
7639
7846
|
/*
|
|
7640
7847
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7796,7 +8003,7 @@
|
|
|
7796
8003
|
return ServerTelemetryManager;
|
|
7797
8004
|
}());
|
|
7798
8005
|
|
|
7799
|
-
/*! @azure/msal-common
|
|
8006
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
7800
8007
|
|
|
7801
8008
|
/*
|
|
7802
8009
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7823,9 +8030,120 @@
|
|
|
7823
8030
|
this.logger = logger;
|
|
7824
8031
|
this.callbacks = new Map();
|
|
7825
8032
|
this.eventsByCorrelationId = new Map();
|
|
7826
|
-
this.
|
|
7827
|
-
this.
|
|
8033
|
+
this.queueMeasurements = new Map();
|
|
8034
|
+
this.preQueueTimeByCorrelationId = new Map();
|
|
7828
8035
|
}
|
|
8036
|
+
/**
|
|
8037
|
+
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
8038
|
+
* Note: this function can be changed to abstract at the next major version bump.
|
|
8039
|
+
*
|
|
8040
|
+
* @param {string} measureName
|
|
8041
|
+
* @param {string} correlationId
|
|
8042
|
+
* @returns {IPerformanceMeasurement}
|
|
8043
|
+
*/
|
|
8044
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
8045
|
+
PerformanceClient.prototype.startPerformanceMeasurement = function (measureName, correlationId) {
|
|
8046
|
+
return {};
|
|
8047
|
+
};
|
|
8048
|
+
/**
|
|
8049
|
+
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
8050
|
+
* Note: this incorrectly-named function will be removed at the next major version bump.
|
|
8051
|
+
*
|
|
8052
|
+
* @param {string} measureName
|
|
8053
|
+
* @param {string} correlationId
|
|
8054
|
+
* @returns {IPerformanceMeasurement}
|
|
8055
|
+
*/
|
|
8056
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
8057
|
+
PerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
|
|
8058
|
+
return {};
|
|
8059
|
+
};
|
|
8060
|
+
/**
|
|
8061
|
+
* Get integral fields.
|
|
8062
|
+
* Override to change the set.
|
|
8063
|
+
*/
|
|
8064
|
+
PerformanceClient.prototype.getIntFields = function () {
|
|
8065
|
+
return IntFields;
|
|
8066
|
+
};
|
|
8067
|
+
/**
|
|
8068
|
+
* Gets map of pre-queue times by correlation Id
|
|
8069
|
+
*
|
|
8070
|
+
* @param {PerformanceEvents} eventName
|
|
8071
|
+
* @param {string} correlationId
|
|
8072
|
+
* @returns {number}
|
|
8073
|
+
*/
|
|
8074
|
+
PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
|
|
8075
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
8076
|
+
if (!preQueueEvent) {
|
|
8077
|
+
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
|
|
8078
|
+
return;
|
|
8079
|
+
}
|
|
8080
|
+
else if (preQueueEvent.name !== eventName) {
|
|
8081
|
+
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
|
|
8082
|
+
return;
|
|
8083
|
+
}
|
|
8084
|
+
return preQueueEvent.time;
|
|
8085
|
+
};
|
|
8086
|
+
/**
|
|
8087
|
+
* Calculates the difference between current time and time when function was queued.
|
|
8088
|
+
* Note: It is possible to have 0 as the queue time if the current time and the queued time was the same.
|
|
8089
|
+
*
|
|
8090
|
+
* @param {number} preQueueTime
|
|
8091
|
+
* @param {number} currentTime
|
|
8092
|
+
* @returns {number}
|
|
8093
|
+
*/
|
|
8094
|
+
PerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
|
|
8095
|
+
if (preQueueTime < 1) {
|
|
8096
|
+
this.logger.trace("PerformanceClient: preQueueTime should be a positive integer and not " + preQueueTime);
|
|
8097
|
+
return 0;
|
|
8098
|
+
}
|
|
8099
|
+
if (currentTime < 1) {
|
|
8100
|
+
this.logger.trace("PerformanceClient: currentTime should be a positive integer and not " + currentTime);
|
|
8101
|
+
return 0;
|
|
8102
|
+
}
|
|
8103
|
+
if (currentTime < preQueueTime) {
|
|
8104
|
+
this.logger.trace("PerformanceClient: currentTime is less than preQueueTime, check how time is being retrieved");
|
|
8105
|
+
return 0;
|
|
8106
|
+
}
|
|
8107
|
+
return currentTime - preQueueTime;
|
|
8108
|
+
};
|
|
8109
|
+
/**
|
|
8110
|
+
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
8111
|
+
*
|
|
8112
|
+
* @param {PerformanceEvents} eventName
|
|
8113
|
+
* @param {?string} correlationId
|
|
8114
|
+
* @param {?number} queueTime
|
|
8115
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
8116
|
+
* @returns
|
|
8117
|
+
*/
|
|
8118
|
+
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
8119
|
+
if (!correlationId) {
|
|
8120
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
|
|
8121
|
+
return;
|
|
8122
|
+
}
|
|
8123
|
+
if (queueTime === 0) {
|
|
8124
|
+
// Possible for there to be no queue time after calculation
|
|
8125
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: queue time provided for " + eventName + " is " + queueTime);
|
|
8126
|
+
}
|
|
8127
|
+
else if (!queueTime) {
|
|
8128
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
|
|
8129
|
+
return;
|
|
8130
|
+
}
|
|
8131
|
+
var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
|
|
8132
|
+
// Adds to existing correlation Id if present in queueMeasurements
|
|
8133
|
+
var existingMeasurements = this.queueMeasurements.get(correlationId);
|
|
8134
|
+
if (existingMeasurements) {
|
|
8135
|
+
existingMeasurements.push(queueMeasurement);
|
|
8136
|
+
this.queueMeasurements.set(correlationId, existingMeasurements);
|
|
8137
|
+
}
|
|
8138
|
+
else {
|
|
8139
|
+
// Sets new correlation Id if not present in queueMeasurements
|
|
8140
|
+
this.logger.trace("PerformanceClient.addQueueMeasurement: adding correlationId " + correlationId + " to queue measurements");
|
|
8141
|
+
var measurementArray = [queueMeasurement];
|
|
8142
|
+
this.queueMeasurements.set(correlationId, measurementArray);
|
|
8143
|
+
}
|
|
8144
|
+
// Delete processed pre-queue event.
|
|
8145
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8146
|
+
};
|
|
7829
8147
|
/**
|
|
7830
8148
|
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
7831
8149
|
*
|
|
@@ -7841,8 +8159,9 @@
|
|
|
7841
8159
|
if (!correlationId) {
|
|
7842
8160
|
this.logger.info("PerformanceClient: No correlation id provided for " + measureName + ", generating", eventCorrelationId);
|
|
7843
8161
|
}
|
|
8162
|
+
// Duplicate code to address spelling error will be removed at the next major version bump.
|
|
7844
8163
|
this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
|
|
7845
|
-
var performanceMeasurement = this.
|
|
8164
|
+
var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
|
|
7846
8165
|
performanceMeasurement.startMeasurement();
|
|
7847
8166
|
var inProgressEvent = {
|
|
7848
8167
|
eventId: this.generateId(),
|
|
@@ -7854,27 +8173,15 @@
|
|
|
7854
8173
|
name: measureName,
|
|
7855
8174
|
startTimeMs: Date.now(),
|
|
7856
8175
|
correlationId: eventCorrelationId,
|
|
7857
|
-
};
|
|
7858
|
-
// Store in progress events so they can be discarded if not ended properly
|
|
7859
|
-
this.cacheEventByCorrelationId(inProgressEvent);
|
|
7860
|
-
var staticFields = {
|
|
7861
8176
|
appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
|
|
7862
8177
|
appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
|
|
7863
8178
|
};
|
|
7864
|
-
|
|
7865
|
-
this.
|
|
8179
|
+
// Store in progress events so they can be discarded if not ended properly
|
|
8180
|
+
this.cacheEventByCorrelationId(inProgressEvent);
|
|
7866
8181
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
7867
8182
|
return {
|
|
7868
8183
|
endMeasurement: function (event) {
|
|
7869
|
-
|
|
7870
|
-
if (completedEvent) {
|
|
7871
|
-
// Cache event so that submeasurements can be added downstream
|
|
7872
|
-
_this.cacheEventByCorrelationId(completedEvent);
|
|
7873
|
-
}
|
|
7874
|
-
return completedEvent;
|
|
7875
|
-
},
|
|
7876
|
-
flushMeasurement: function () {
|
|
7877
|
-
return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
|
|
8184
|
+
return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
|
|
7878
8185
|
},
|
|
7879
8186
|
discardMeasurement: function () {
|
|
7880
8187
|
return _this.discardMeasurements(inProgressEvent.correlationId);
|
|
@@ -7882,6 +8189,9 @@
|
|
|
7882
8189
|
addStaticFields: function (fields) {
|
|
7883
8190
|
return _this.addStaticFields(fields, inProgressEvent.correlationId);
|
|
7884
8191
|
},
|
|
8192
|
+
increment: function (counters) {
|
|
8193
|
+
return _this.increment(counters, inProgressEvent.correlationId);
|
|
8194
|
+
},
|
|
7885
8195
|
measurement: performanceMeasurement,
|
|
7886
8196
|
event: inProgressEvent
|
|
7887
8197
|
};
|
|
@@ -7889,33 +8199,59 @@
|
|
|
7889
8199
|
/**
|
|
7890
8200
|
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
7891
8201
|
* as consumers should instead use the function returned by startMeasurement.
|
|
8202
|
+
* Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
|
|
8203
|
+
* otherwise.
|
|
7892
8204
|
*
|
|
7893
8205
|
* @param {PerformanceEvent} event
|
|
8206
|
+
* @param {IPerformanceMeasurement} measurement
|
|
7894
8207
|
* @returns {(PerformanceEvent | null)}
|
|
7895
8208
|
*/
|
|
7896
|
-
PerformanceClient.prototype.endMeasurement = function (event) {
|
|
7897
|
-
var
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
}
|
|
8209
|
+
PerformanceClient.prototype.endMeasurement = function (event, measurement) {
|
|
8210
|
+
var _this = this;
|
|
8211
|
+
var _a, _b;
|
|
8212
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8213
|
+
if (!rootEvent) {
|
|
8214
|
+
this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
|
|
8215
|
+
return null;
|
|
8216
|
+
}
|
|
8217
|
+
var isRoot = event.eventId === rootEvent.eventId;
|
|
8218
|
+
var queueInfo = {
|
|
8219
|
+
totalQueueTime: 0,
|
|
8220
|
+
totalQueueCount: 0,
|
|
8221
|
+
manuallyCompletedCount: 0
|
|
8222
|
+
};
|
|
8223
|
+
if (isRoot) {
|
|
8224
|
+
queueInfo = this.getQueueInfo(event.correlationId);
|
|
8225
|
+
this.discardCache(rootEvent.correlationId);
|
|
7914
8226
|
}
|
|
7915
8227
|
else {
|
|
7916
|
-
|
|
8228
|
+
(_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
|
|
7917
8229
|
}
|
|
7918
|
-
|
|
8230
|
+
measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
|
|
8231
|
+
var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
|
|
8232
|
+
// null indicates no measurement was taken (e.g. needed performance APIs not present)
|
|
8233
|
+
if (!durationMs) {
|
|
8234
|
+
this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
|
|
8235
|
+
return null;
|
|
8236
|
+
}
|
|
8237
|
+
this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
|
|
8238
|
+
// Add sub-measurement attribute to root event.
|
|
8239
|
+
if (!isRoot) {
|
|
8240
|
+
rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
|
|
8241
|
+
return __assign({}, rootEvent);
|
|
8242
|
+
}
|
|
8243
|
+
var finalEvent = __assign(__assign({}, rootEvent), event);
|
|
8244
|
+
var incompleteSubsCount = 0;
|
|
8245
|
+
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
8246
|
+
(_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
|
|
8247
|
+
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
|
|
8248
|
+
incompleteSubsCount++;
|
|
8249
|
+
});
|
|
8250
|
+
finalEvent.incompleteSubMeasurements = undefined;
|
|
8251
|
+
finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
|
|
8252
|
+
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
8253
|
+
this.emitEvents([finalEvent], event.correlationId);
|
|
8254
|
+
return finalEvent;
|
|
7919
8255
|
};
|
|
7920
8256
|
/**
|
|
7921
8257
|
* Saves extra information to be emitted when the measurements are flushed
|
|
@@ -7923,14 +8259,33 @@
|
|
|
7923
8259
|
* @param correlationId
|
|
7924
8260
|
*/
|
|
7925
8261
|
PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
this.
|
|
8262
|
+
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8263
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8264
|
+
if (event) {
|
|
8265
|
+
this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
|
|
8266
|
+
}
|
|
8267
|
+
else {
|
|
8268
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8269
|
+
}
|
|
8270
|
+
};
|
|
8271
|
+
/**
|
|
8272
|
+
* Increment counters to be emitted when the measurements are flushed
|
|
8273
|
+
* @param counters {Counters}
|
|
8274
|
+
* @param correlationId {string} correlation identifier
|
|
8275
|
+
*/
|
|
8276
|
+
PerformanceClient.prototype.increment = function (counters, correlationId) {
|
|
8277
|
+
this.logger.trace("PerformanceClient: Updating counters");
|
|
8278
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8279
|
+
if (event) {
|
|
8280
|
+
for (var counter in counters) {
|
|
8281
|
+
if (!event.hasOwnProperty(counter)) {
|
|
8282
|
+
event[counter] = 0;
|
|
8283
|
+
}
|
|
8284
|
+
event[counter] += counters[counter];
|
|
8285
|
+
}
|
|
7930
8286
|
}
|
|
7931
8287
|
else {
|
|
7932
|
-
this.logger.trace("PerformanceClient:
|
|
7933
|
-
this.staticFieldsByCorrelationId.set(correlationId, fields);
|
|
8288
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
7934
8289
|
}
|
|
7935
8290
|
};
|
|
7936
8291
|
/**
|
|
@@ -7943,99 +8298,35 @@
|
|
|
7943
8298
|
* @param {PerformanceEvent} event
|
|
7944
8299
|
*/
|
|
7945
8300
|
PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
|
|
7946
|
-
var
|
|
7947
|
-
if (
|
|
8301
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8302
|
+
if (rootEvent) {
|
|
7948
8303
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
|
|
7949
|
-
|
|
8304
|
+
rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
|
|
8305
|
+
rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
|
|
7950
8306
|
}
|
|
7951
8307
|
else {
|
|
7952
8308
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
|
|
7953
|
-
this.eventsByCorrelationId.set(event.correlationId,
|
|
8309
|
+
this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
|
|
7954
8310
|
}
|
|
7955
8311
|
};
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
* @param {PerformanceEvent} event
|
|
7961
|
-
* @param {IPerformanceMeasurement} measurement
|
|
7962
|
-
*/
|
|
7963
|
-
PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
|
|
7964
|
-
this.measurementsById.set(event.eventId, measurement);
|
|
7965
|
-
};
|
|
7966
|
-
/**
|
|
7967
|
-
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
7968
|
-
*
|
|
7969
|
-
* @param {PerformanceEvents} measureName
|
|
7970
|
-
* @param {string} correlationId
|
|
7971
|
-
*/
|
|
7972
|
-
PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
|
|
7973
|
-
var _this = this;
|
|
7974
|
-
this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
|
|
7975
|
-
var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
|
|
7976
|
-
if (eventsForCorrelationId) {
|
|
7977
|
-
this.discardMeasurements(correlationId);
|
|
7978
|
-
/*
|
|
7979
|
-
* Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
|
|
7980
|
-
* Incomplete submeasurements are likely an instrumentation bug that should be fixed.
|
|
7981
|
-
* IE only supports Map.forEach.
|
|
7982
|
-
*/
|
|
7983
|
-
var completedEvents_1 = [];
|
|
7984
|
-
eventsForCorrelationId.forEach(function (event) {
|
|
7985
|
-
if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
|
|
7986
|
-
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
|
|
7987
|
-
var completedEvent = _this.endMeasurement(event);
|
|
7988
|
-
if (completedEvent) {
|
|
7989
|
-
completedEvents_1.push(completedEvent);
|
|
7990
|
-
}
|
|
7991
|
-
}
|
|
7992
|
-
completedEvents_1.push(event);
|
|
7993
|
-
});
|
|
7994
|
-
// Sort events by start time (earliest first)
|
|
7995
|
-
var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
|
|
7996
|
-
// Take completed top level event and add completed submeasurements durations as properties
|
|
7997
|
-
var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
|
|
7998
|
-
if (topLevelEvents.length > 0) {
|
|
7999
|
-
/*
|
|
8000
|
-
* Only take the first top-level event if there are multiple events with the same correlation id.
|
|
8001
|
-
* This greatly simplifies logic for submeasurements.
|
|
8002
|
-
*/
|
|
8003
|
-
if (topLevelEvents.length > 1) {
|
|
8004
|
-
this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
|
|
8005
|
-
}
|
|
8006
|
-
var topLevelEvent = topLevelEvents[0];
|
|
8007
|
-
this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
|
|
8008
|
-
// Build event object with top level and sub measurements
|
|
8009
|
-
var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
|
|
8010
|
-
if (current.name !== measureName) {
|
|
8011
|
-
_this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
|
|
8012
|
-
// TODO: Emit additional properties for each subMeasurement
|
|
8013
|
-
var subMeasurementName = current.name + "DurationMs";
|
|
8014
|
-
/*
|
|
8015
|
-
* Some code paths, such as resolving an authority, can occur multiple times.
|
|
8016
|
-
* Only take the first measurement, since the second could be read from the cache,
|
|
8017
|
-
* or due to the same correlation id being used for two distinct requests.
|
|
8018
|
-
*/
|
|
8019
|
-
if (!previous[subMeasurementName]) {
|
|
8020
|
-
previous[subMeasurementName] = current.durationMs;
|
|
8021
|
-
}
|
|
8022
|
-
else {
|
|
8023
|
-
_this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
|
|
8024
|
-
}
|
|
8025
|
-
}
|
|
8026
|
-
return previous;
|
|
8027
|
-
}, topLevelEvent);
|
|
8028
|
-
var staticFields = this.staticFieldsByCorrelationId.get(correlationId);
|
|
8029
|
-
var finalEvent = __assign(__assign({}, eventToEmit), staticFields);
|
|
8030
|
-
this.emitEvents([finalEvent], eventToEmit.correlationId);
|
|
8031
|
-
}
|
|
8032
|
-
else {
|
|
8033
|
-
this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
|
|
8034
|
-
}
|
|
8035
|
-
}
|
|
8036
|
-
else {
|
|
8037
|
-
this.logger.verbose("PerformanceClient: No measurements found", correlationId);
|
|
8312
|
+
PerformanceClient.prototype.getQueueInfo = function (correlationId) {
|
|
8313
|
+
var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
|
|
8314
|
+
if (!queueMeasurementForCorrelationId) {
|
|
8315
|
+
this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
|
|
8038
8316
|
}
|
|
8317
|
+
var totalQueueTime = 0;
|
|
8318
|
+
var totalQueueCount = 0;
|
|
8319
|
+
var manuallyCompletedCount = 0;
|
|
8320
|
+
queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
|
|
8321
|
+
totalQueueTime += measurement.queueTime;
|
|
8322
|
+
totalQueueCount++;
|
|
8323
|
+
manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
|
|
8324
|
+
});
|
|
8325
|
+
return {
|
|
8326
|
+
totalQueueTime: totalQueueTime,
|
|
8327
|
+
totalQueueCount: totalQueueCount,
|
|
8328
|
+
manuallyCompletedCount: manuallyCompletedCount
|
|
8329
|
+
};
|
|
8039
8330
|
};
|
|
8040
8331
|
/**
|
|
8041
8332
|
* Removes measurements for a given correlation id.
|
|
@@ -8046,6 +8337,18 @@
|
|
|
8046
8337
|
this.logger.trace("PerformanceClient: Performance measurements discarded", correlationId);
|
|
8047
8338
|
this.eventsByCorrelationId.delete(correlationId);
|
|
8048
8339
|
};
|
|
8340
|
+
/**
|
|
8341
|
+
* Removes cache for a given correlation id.
|
|
8342
|
+
*
|
|
8343
|
+
* @param {string} correlationId correlation identifier
|
|
8344
|
+
*/
|
|
8345
|
+
PerformanceClient.prototype.discardCache = function (correlationId) {
|
|
8346
|
+
this.discardMeasurements(correlationId);
|
|
8347
|
+
this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
|
|
8348
|
+
this.queueMeasurements.delete(correlationId);
|
|
8349
|
+
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|
|
8350
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8351
|
+
};
|
|
8049
8352
|
/**
|
|
8050
8353
|
* Registers a callback function to receive performance events.
|
|
8051
8354
|
*
|
|
@@ -8088,10 +8391,22 @@
|
|
|
8088
8391
|
callback.apply(null, [events]);
|
|
8089
8392
|
});
|
|
8090
8393
|
};
|
|
8394
|
+
/**
|
|
8395
|
+
* Enforce truncation of integral fields in performance event.
|
|
8396
|
+
* @param {PerformanceEvent} event performance event to update.
|
|
8397
|
+
* @param {Set<string>} intFields integral fields.
|
|
8398
|
+
*/
|
|
8399
|
+
PerformanceClient.prototype.truncateIntegralFields = function (event, intFields) {
|
|
8400
|
+
intFields.forEach(function (key) {
|
|
8401
|
+
if (key in event && typeof event[key] === "number") {
|
|
8402
|
+
event[key] = Math.floor(event[key]);
|
|
8403
|
+
}
|
|
8404
|
+
});
|
|
8405
|
+
};
|
|
8091
8406
|
return PerformanceClient;
|
|
8092
8407
|
}());
|
|
8093
8408
|
|
|
8094
|
-
/*! @azure/msal-common
|
|
8409
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
8095
8410
|
|
|
8096
8411
|
/*
|
|
8097
8412
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8117,9 +8432,24 @@
|
|
|
8117
8432
|
StubPerformanceClient.prototype.generateId = function () {
|
|
8118
8433
|
return "callback-id";
|
|
8119
8434
|
};
|
|
8435
|
+
StubPerformanceClient.prototype.startPerformanceMeasuremeant = function () {
|
|
8436
|
+
return new StubPerformanceMeasurement();
|
|
8437
|
+
};
|
|
8120
8438
|
StubPerformanceClient.prototype.startPerformanceMeasurement = function () {
|
|
8121
8439
|
return new StubPerformanceMeasurement();
|
|
8122
8440
|
};
|
|
8441
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
8442
|
+
StubPerformanceClient.prototype.calculateQueuedTime = function (preQueueTime, currentTime) {
|
|
8443
|
+
return 0;
|
|
8444
|
+
};
|
|
8445
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
8446
|
+
StubPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
|
|
8447
|
+
return;
|
|
8448
|
+
};
|
|
8449
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
8450
|
+
StubPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
|
|
8451
|
+
return;
|
|
8452
|
+
};
|
|
8123
8453
|
return StubPerformanceClient;
|
|
8124
8454
|
}(PerformanceClient));
|
|
8125
8455
|
|
|
@@ -8279,6 +8609,10 @@
|
|
|
8279
8609
|
code: "auth_code_or_nativeAccountId_required",
|
|
8280
8610
|
desc: "An authorization code or nativeAccountId must be provided to this flow."
|
|
8281
8611
|
},
|
|
8612
|
+
spaCodeAndNativeAccountPresent: {
|
|
8613
|
+
code: "spa_code_and_nativeAccountId_present",
|
|
8614
|
+
desc: "Request cannot contain both spa code and native account id."
|
|
8615
|
+
},
|
|
8282
8616
|
databaseUnavailable: {
|
|
8283
8617
|
code: "database_unavailable",
|
|
8284
8618
|
desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
|
|
@@ -8551,6 +8885,12 @@
|
|
|
8551
8885
|
BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError = function () {
|
|
8552
8886
|
return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
|
|
8553
8887
|
};
|
|
8888
|
+
/**
|
|
8889
|
+
* Create an error when both authorization code and native account ID are provided
|
|
8890
|
+
*/
|
|
8891
|
+
BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError = function () {
|
|
8892
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.code, BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.desc);
|
|
8893
|
+
};
|
|
8554
8894
|
/**
|
|
8555
8895
|
* Create an error when IndexedDB is unavailable
|
|
8556
8896
|
*/
|
|
@@ -9981,7 +10321,7 @@
|
|
|
9981
10321
|
|
|
9982
10322
|
/* eslint-disable header/header */
|
|
9983
10323
|
var name = "@azure/msal-browser";
|
|
9984
|
-
var version = "2.
|
|
10324
|
+
var version = "2.34.0";
|
|
9985
10325
|
|
|
9986
10326
|
/*
|
|
9987
10327
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10452,6 +10792,7 @@
|
|
|
10452
10792
|
return __generator$1(this, function (_b) {
|
|
10453
10793
|
switch (_b.label) {
|
|
10454
10794
|
case 0:
|
|
10795
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.InitializeBaseRequest, request.correlationId);
|
|
10455
10796
|
this.logger.verbose("Initializing BaseAuthRequest");
|
|
10456
10797
|
authority = request.authority || this.config.auth.authority;
|
|
10457
10798
|
scopes = __spread(((request && request.scopes) || []));
|
|
@@ -10569,6 +10910,7 @@
|
|
|
10569
10910
|
return __generator$1(this, function (_a) {
|
|
10570
10911
|
switch (_a.label) {
|
|
10571
10912
|
case 0:
|
|
10913
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
|
|
10572
10914
|
this.logger.verbose("initializeAuthorizationRequest called", request.correlationId);
|
|
10573
10915
|
return [4 /*yield*/, this.browserCrypto.generatePkceCodes()];
|
|
10574
10916
|
case 1:
|
|
@@ -10669,10 +11011,14 @@
|
|
|
10669
11011
|
var clientConfig;
|
|
10670
11012
|
return __generator$1(this, function (_a) {
|
|
10671
11013
|
switch (_a.label) {
|
|
10672
|
-
case 0:
|
|
11014
|
+
case 0:
|
|
11015
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, this.correlationId);
|
|
11016
|
+
// Create auth module.
|
|
11017
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
|
|
11018
|
+
return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, requestAzureCloudOptions)];
|
|
10673
11019
|
case 1:
|
|
10674
11020
|
clientConfig = _a.sent();
|
|
10675
|
-
return [2 /*return*/, new AuthorizationCodeClient(clientConfig)];
|
|
11021
|
+
return [2 /*return*/, new AuthorizationCodeClient(clientConfig, this.performanceClient)];
|
|
10676
11022
|
}
|
|
10677
11023
|
});
|
|
10678
11024
|
});
|
|
@@ -10689,7 +11035,9 @@
|
|
|
10689
11035
|
return __generator$1(this, function (_a) {
|
|
10690
11036
|
switch (_a.label) {
|
|
10691
11037
|
case 0:
|
|
11038
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
|
|
10692
11039
|
this.logger.verbose("getClientConfiguration called", this.correlationId);
|
|
11040
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
|
|
10693
11041
|
return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority, requestAzureCloudOptions)];
|
|
10694
11042
|
case 1:
|
|
10695
11043
|
discoveredAuthority = _a.sent();
|
|
@@ -10757,6 +11105,7 @@
|
|
|
10757
11105
|
return __generator$1(this, function (_b) {
|
|
10758
11106
|
switch (_b.label) {
|
|
10759
11107
|
case 0:
|
|
11108
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
|
|
10760
11109
|
this.logger.verbose("getDiscoveredAuthority called", this.correlationId);
|
|
10761
11110
|
getAuthorityMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority, this.correlationId);
|
|
10762
11111
|
authorityOptions = {
|
|
@@ -10769,7 +11118,8 @@
|
|
|
10769
11118
|
userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
|
|
10770
11119
|
builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
|
|
10771
11120
|
this.logger.verbose("Creating discovered authority with configured authority", this.correlationId);
|
|
10772
|
-
|
|
11121
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, this.correlationId);
|
|
11122
|
+
return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger, this.performanceClient, this.correlationId)
|
|
10773
11123
|
.then(function (result) {
|
|
10774
11124
|
getAuthorityMeasurement.endMeasurement({
|
|
10775
11125
|
success: true,
|
|
@@ -10800,12 +11150,14 @@
|
|
|
10800
11150
|
return __generator$1(this, function (_b) {
|
|
10801
11151
|
switch (_b.label) {
|
|
10802
11152
|
case 0:
|
|
11153
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, this.correlationId);
|
|
10803
11154
|
this.logger.verbose("initializeAuthorizationRequest called", this.correlationId);
|
|
10804
11155
|
redirectUri = this.getRedirectUri(request.redirectUri);
|
|
10805
11156
|
browserState = {
|
|
10806
11157
|
interactionType: interactionType
|
|
10807
11158
|
};
|
|
10808
11159
|
state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || Constants.EMPTY_STRING, browserState);
|
|
11160
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, this.correlationId);
|
|
10809
11161
|
_a = [{}];
|
|
10810
11162
|
return [4 /*yield*/, this.initializeBaseRequest(request)];
|
|
10811
11163
|
case 1:
|
|
@@ -10839,11 +11191,12 @@
|
|
|
10839
11191
|
* Abstract class which defines operations for a browser interaction handling class.
|
|
10840
11192
|
*/
|
|
10841
11193
|
var InteractionHandler = /** @class */ (function () {
|
|
10842
|
-
function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger) {
|
|
11194
|
+
function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) {
|
|
10843
11195
|
this.authModule = authCodeModule;
|
|
10844
11196
|
this.browserStorage = storageImpl;
|
|
10845
11197
|
this.authCodeRequest = authCodeRequest;
|
|
10846
11198
|
this.logger = logger;
|
|
11199
|
+
this.performanceClient = performanceClient;
|
|
10847
11200
|
}
|
|
10848
11201
|
/**
|
|
10849
11202
|
* Function to handle response parameters from hash.
|
|
@@ -10853,6 +11206,7 @@
|
|
|
10853
11206
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
10854
11207
|
var stateKey, requestState, authCodeResponse;
|
|
10855
11208
|
return __generator$1(this, function (_a) {
|
|
11209
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.HandleCodeResponseFromHash, this.authCodeRequest.correlationId);
|
|
10856
11210
|
this.logger.verbose("InteractionHandler.handleCodeResponse called");
|
|
10857
11211
|
// Check that location hash isn't empty.
|
|
10858
11212
|
if (StringUtils.isEmpty(locationHash)) {
|
|
@@ -10875,6 +11229,7 @@
|
|
|
10875
11229
|
throw e;
|
|
10876
11230
|
}
|
|
10877
11231
|
}
|
|
11232
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.HandleCodeResponseFromServer, this.authCodeRequest.correlationId);
|
|
10878
11233
|
return [2 /*return*/, this.handleCodeResponseFromServer(authCodeResponse, state, authority, networkModule)];
|
|
10879
11234
|
});
|
|
10880
11235
|
});
|
|
@@ -10894,6 +11249,7 @@
|
|
|
10894
11249
|
return __generator$1(this, function (_a) {
|
|
10895
11250
|
switch (_a.label) {
|
|
10896
11251
|
case 0:
|
|
11252
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.HandleCodeResponseFromServer, this.authCodeRequest.correlationId);
|
|
10897
11253
|
this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
|
|
10898
11254
|
stateKey = this.browserStorage.generateStateKey(state);
|
|
10899
11255
|
requestState = this.browserStorage.getTemporaryCache(stateKey);
|
|
@@ -10905,6 +11261,7 @@
|
|
|
10905
11261
|
// Assign code to request
|
|
10906
11262
|
this.authCodeRequest.code = authCodeResponse.code;
|
|
10907
11263
|
if (!authCodeResponse.cloud_instance_host_name) return [3 /*break*/, 2];
|
|
11264
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
|
|
10908
11265
|
return [4 /*yield*/, this.updateTokenEndpointAuthority(authCodeResponse.cloud_instance_host_name, authority, networkModule)];
|
|
10909
11266
|
case 1:
|
|
10910
11267
|
_a.sent();
|
|
@@ -10925,6 +11282,8 @@
|
|
|
10925
11282
|
this.authCodeRequest.ccsCredential = cachedCcsCred;
|
|
10926
11283
|
}
|
|
10927
11284
|
}
|
|
11285
|
+
// Acquire token with retrieved code.
|
|
11286
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AuthClientAcquireToken, this.authCodeRequest.correlationId);
|
|
10928
11287
|
return [4 /*yield*/, this.authModule.acquireToken(this.authCodeRequest, authCodeResponse)];
|
|
10929
11288
|
case 3:
|
|
10930
11289
|
tokenResponse = _a.sent();
|
|
@@ -10946,8 +11305,9 @@
|
|
|
10946
11305
|
return __generator$1(this, function (_a) {
|
|
10947
11306
|
switch (_a.label) {
|
|
10948
11307
|
case 0:
|
|
11308
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
|
|
10949
11309
|
cloudInstanceAuthorityUri = "https://" + cloudInstanceHostname + "/" + authority.tenant + "/";
|
|
10950
|
-
return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger)];
|
|
11310
|
+
return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger, this.performanceClient, this.authCodeRequest.correlationId)];
|
|
10951
11311
|
case 1:
|
|
10952
11312
|
cloudInstanceAuthority = _a.sent();
|
|
10953
11313
|
this.authModule.updateAuthority(cloudInstanceAuthority);
|
|
@@ -10982,8 +11342,8 @@
|
|
|
10982
11342
|
*/
|
|
10983
11343
|
var RedirectHandler = /** @class */ (function (_super) {
|
|
10984
11344
|
__extends$1(RedirectHandler, _super);
|
|
10985
|
-
function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto) {
|
|
10986
|
-
var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
|
|
11345
|
+
function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto, performanceClient) {
|
|
11346
|
+
var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) || this;
|
|
10987
11347
|
_this.browserCrypto = browserCrypto;
|
|
10988
11348
|
return _this;
|
|
10989
11349
|
}
|
|
@@ -11301,7 +11661,10 @@
|
|
|
11301
11661
|
var clientConfig;
|
|
11302
11662
|
return __generator$1(this, function (_a) {
|
|
11303
11663
|
switch (_a.label) {
|
|
11304
|
-
case 0:
|
|
11664
|
+
case 0:
|
|
11665
|
+
// Create auth module.
|
|
11666
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
|
|
11667
|
+
return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
|
|
11305
11668
|
case 1:
|
|
11306
11669
|
clientConfig = _a.sent();
|
|
11307
11670
|
return [2 /*return*/, new SilentFlowClient(clientConfig, this.performanceClient)];
|
|
@@ -11315,6 +11678,8 @@
|
|
|
11315
11678
|
return __generator$1(this, function (_b) {
|
|
11316
11679
|
switch (_b.label) {
|
|
11317
11680
|
case 0:
|
|
11681
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.InitializeSilentRequest, this.correlationId);
|
|
11682
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, this.correlationId);
|
|
11318
11683
|
_a = [__assign$1({}, request)];
|
|
11319
11684
|
return [4 /*yield*/, this.initializeBaseRequest(request)];
|
|
11320
11685
|
case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
|
|
@@ -11566,60 +11931,96 @@
|
|
|
11566
11931
|
*/
|
|
11567
11932
|
NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
|
|
11568
11933
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
11569
|
-
var
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11934
|
+
var authority, authorityPreferredCache, idTokenObj, homeAccountIdentifier, accountEntity, result;
|
|
11935
|
+
return __generator$1(this, function (_a) {
|
|
11936
|
+
switch (_a.label) {
|
|
11937
|
+
case 0:
|
|
11938
|
+
this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
|
|
11939
|
+
if (response.account.id !== request.accountId) {
|
|
11940
|
+
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
11941
|
+
throw NativeAuthError.createUserSwitchError();
|
|
11942
|
+
}
|
|
11943
|
+
if (response.account.id !== request.accountId) {
|
|
11944
|
+
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
11945
|
+
throw NativeAuthError.createUserSwitchError();
|
|
11946
|
+
}
|
|
11947
|
+
return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
|
|
11948
|
+
case 1:
|
|
11949
|
+
authority = _a.sent();
|
|
11950
|
+
authorityPreferredCache = authority.getPreferredCache();
|
|
11951
|
+
idTokenObj = this.createIdTokenObj(response);
|
|
11952
|
+
homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
|
|
11953
|
+
accountEntity = this.createAccountEntity(response, homeAccountIdentifier, idTokenObj, authorityPreferredCache);
|
|
11954
|
+
return [4 /*yield*/, this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp)];
|
|
11955
|
+
case 2:
|
|
11956
|
+
result = _a.sent();
|
|
11957
|
+
// cache accounts and tokens in the appropriate storage
|
|
11958
|
+
this.cacheAccount(accountEntity);
|
|
11959
|
+
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
|
|
11960
|
+
return [2 /*return*/, result];
|
|
11961
|
+
}
|
|
11962
|
+
});
|
|
11963
|
+
});
|
|
11964
|
+
};
|
|
11965
|
+
/**
|
|
11966
|
+
* Create an idToken Object (not entity)
|
|
11967
|
+
* @param response
|
|
11968
|
+
* @returns
|
|
11969
|
+
*/
|
|
11970
|
+
NativeInteractionClient.prototype.createIdTokenObj = function (response) {
|
|
11971
|
+
return new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
11972
|
+
};
|
|
11973
|
+
/**
|
|
11974
|
+
* creates an homeAccountIdentifier for the account
|
|
11975
|
+
* @param response
|
|
11976
|
+
* @param idTokenObj
|
|
11977
|
+
* @returns
|
|
11978
|
+
*/
|
|
11979
|
+
NativeInteractionClient.prototype.createHomeAccountIdentifier = function (response, idTokenObj) {
|
|
11980
|
+
// Save account in browser storage
|
|
11981
|
+
var homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
11982
|
+
return homeAccountIdentifier;
|
|
11983
|
+
};
|
|
11984
|
+
/**
|
|
11985
|
+
* Creates account entity
|
|
11986
|
+
* @param response
|
|
11987
|
+
* @param homeAccountIdentifier
|
|
11988
|
+
* @param idTokenObj
|
|
11989
|
+
* @param authority
|
|
11990
|
+
* @returns
|
|
11991
|
+
*/
|
|
11992
|
+
NativeInteractionClient.prototype.createAccountEntity = function (response, homeAccountIdentifier, idTokenObj, authority) {
|
|
11993
|
+
return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
|
|
11994
|
+
};
|
|
11995
|
+
/**
|
|
11996
|
+
* Helper to generate scopes
|
|
11997
|
+
* @param response
|
|
11998
|
+
* @param request
|
|
11999
|
+
* @returns
|
|
12000
|
+
*/
|
|
12001
|
+
NativeInteractionClient.prototype.generateScopes = function (response, request) {
|
|
12002
|
+
return response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
|
|
12003
|
+
};
|
|
12004
|
+
/**
|
|
12005
|
+
* If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
|
|
12006
|
+
* @param request
|
|
12007
|
+
* @param response
|
|
12008
|
+
*/
|
|
12009
|
+
NativeInteractionClient.prototype.generatePopAccessToken = function (response, request) {
|
|
12010
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12011
|
+
var popTokenGenerator, shrParameters;
|
|
12012
|
+
return __generator$1(this, function (_a) {
|
|
12013
|
+
switch (_a.label) {
|
|
11573
12014
|
case 0:
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
matsBrokerVersion: mats ? mats.broker_version : undefined,
|
|
11580
|
-
matsAccountJoinOnStart: mats ? mats.account_join_on_start : undefined,
|
|
11581
|
-
matsAccountJoinOnEnd: mats ? mats.account_join_on_end : undefined,
|
|
11582
|
-
matsDeviceJoin: mats ? mats.device_join : undefined,
|
|
11583
|
-
matsPromptBehavior: mats ? mats.prompt_behavior : undefined,
|
|
11584
|
-
matsApiErrorCode: mats ? mats.api_error_code : undefined,
|
|
11585
|
-
matsUiVisible: mats ? mats.ui_visible : undefined,
|
|
11586
|
-
matsSilentCode: mats ? mats.silent_code : undefined,
|
|
11587
|
-
matsSilentBiSubCode: mats ? mats.silent_bi_sub_code : undefined,
|
|
11588
|
-
matsSilentMessage: mats ? mats.silent_message : undefined,
|
|
11589
|
-
matsSilentStatus: mats ? mats.silent_status : undefined,
|
|
11590
|
-
matsHttpStatus: mats ? mats.http_status : undefined,
|
|
11591
|
-
matsHttpEventCount: mats ? mats.http_event_count : undefined
|
|
11592
|
-
}, this.correlationId);
|
|
11593
|
-
if (response.account.id !== request.accountId) {
|
|
11594
|
-
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
11595
|
-
throw NativeAuthError.createUserSwitchError();
|
|
11596
|
-
}
|
|
11597
|
-
idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
11598
|
-
return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
|
|
11599
|
-
case 1:
|
|
11600
|
-
authority = _b.sent();
|
|
11601
|
-
authorityPreferredCache = authority.getPreferredCache();
|
|
11602
|
-
homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
11603
|
-
accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
|
|
11604
|
-
this.browserStorage.setAccount(accountEntity);
|
|
11605
|
-
responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
|
|
11606
|
-
accountProperties = response.account.properties || {};
|
|
11607
|
-
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
11608
|
-
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
11609
|
-
responseTokenType = exports.AuthenticationScheme.BEARER;
|
|
11610
|
-
_a = request.tokenType;
|
|
11611
|
-
switch (_a) {
|
|
11612
|
-
case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
|
|
11613
|
-
}
|
|
11614
|
-
return [3 /*break*/, 4];
|
|
11615
|
-
case 2:
|
|
11616
|
-
// Set the token type to POP in the response
|
|
11617
|
-
responseTokenType = exports.AuthenticationScheme.POP;
|
|
12015
|
+
if (!(request.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
12016
|
+
/**
|
|
12017
|
+
* This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
|
|
12018
|
+
* is still received, SHR is calculated locally
|
|
12019
|
+
*/
|
|
11618
12020
|
// Check if native layer returned an SHR token
|
|
11619
12021
|
if (response.shr) {
|
|
11620
12022
|
this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
|
|
11621
|
-
|
|
11622
|
-
return [3 /*break*/, 5];
|
|
12023
|
+
return [2 /*return*/, response.shr];
|
|
11623
12024
|
}
|
|
11624
12025
|
popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
11625
12026
|
shrParameters = {
|
|
@@ -11636,17 +12037,39 @@
|
|
|
11636
12037
|
throw ClientAuthError.createKeyIdMissingError();
|
|
11637
12038
|
}
|
|
11638
12039
|
return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
|
|
11639
|
-
case
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
12040
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
12041
|
+
case 2: return [2 /*return*/, response.access_token];
|
|
12042
|
+
}
|
|
12043
|
+
});
|
|
12044
|
+
});
|
|
12045
|
+
};
|
|
12046
|
+
/**
|
|
12047
|
+
* Generates authentication result
|
|
12048
|
+
* @param response
|
|
12049
|
+
* @param request
|
|
12050
|
+
* @param idTokenObj
|
|
12051
|
+
* @param accountEntity
|
|
12052
|
+
* @param authority
|
|
12053
|
+
* @param reqTimestamp
|
|
12054
|
+
* @returns
|
|
12055
|
+
*/
|
|
12056
|
+
NativeInteractionClient.prototype.generateAuthenticationResult = function (response, request, idTokenObj, accountEntity, authority, reqTimestamp) {
|
|
12057
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12058
|
+
var mats, responseScopes, accountProperties, uid, tid, responseAccessToken, tokenType, result;
|
|
12059
|
+
return __generator$1(this, function (_a) {
|
|
12060
|
+
switch (_a.label) {
|
|
12061
|
+
case 0:
|
|
12062
|
+
mats = this.addTelemetryFromNativeResponse(response);
|
|
12063
|
+
responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
|
|
12064
|
+
accountProperties = response.account.properties || {};
|
|
12065
|
+
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
12066
|
+
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
12067
|
+
return [4 /*yield*/, this.generatePopAccessToken(response, request)];
|
|
12068
|
+
case 1:
|
|
12069
|
+
responseAccessToken = _a.sent();
|
|
12070
|
+
tokenType = (request.tokenType === exports.AuthenticationScheme.POP) ? exports.AuthenticationScheme.POP : exports.AuthenticationScheme.BEARER;
|
|
11648
12071
|
result = {
|
|
11649
|
-
authority: authority
|
|
12072
|
+
authority: authority,
|
|
11650
12073
|
uniqueId: uid,
|
|
11651
12074
|
tenantId: tid,
|
|
11652
12075
|
scopes: responseScopes.asArray(),
|
|
@@ -11656,30 +12079,78 @@
|
|
|
11656
12079
|
accessToken: responseAccessToken,
|
|
11657
12080
|
fromCache: mats ? this.isResponseFromCache(mats) : false,
|
|
11658
12081
|
expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
|
|
11659
|
-
tokenType:
|
|
12082
|
+
tokenType: tokenType,
|
|
11660
12083
|
correlationId: this.correlationId,
|
|
11661
12084
|
state: response.state,
|
|
11662
12085
|
fromNativeBroker: true
|
|
11663
12086
|
};
|
|
11664
|
-
idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
11665
|
-
this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
|
|
11666
|
-
expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
|
|
11667
|
-
? Constants.SHR_NONCE_VALIDITY
|
|
11668
|
-
: (typeof response.expires_in === "string"
|
|
11669
|
-
? parseInt(response.expires_in, 10)
|
|
11670
|
-
: response.expires_in) || 0;
|
|
11671
|
-
tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
11672
|
-
accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
11673
|
-
this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
|
|
11674
|
-
// Remove any existing cached tokens for this account in browser storage
|
|
11675
|
-
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
11676
|
-
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
11677
|
-
});
|
|
11678
12087
|
return [2 /*return*/, result];
|
|
11679
12088
|
}
|
|
11680
12089
|
});
|
|
11681
12090
|
});
|
|
11682
12091
|
};
|
|
12092
|
+
/**
|
|
12093
|
+
* cache the account entity in browser storage
|
|
12094
|
+
* @param accountEntity
|
|
12095
|
+
*/
|
|
12096
|
+
NativeInteractionClient.prototype.cacheAccount = function (accountEntity) {
|
|
12097
|
+
var _this = this;
|
|
12098
|
+
// Store the account info and hence `nativeAccountId` in browser cache
|
|
12099
|
+
this.browserStorage.setAccount(accountEntity);
|
|
12100
|
+
// Remove any existing cached tokens for this account in browser storage
|
|
12101
|
+
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
12102
|
+
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
12103
|
+
});
|
|
12104
|
+
};
|
|
12105
|
+
/**
|
|
12106
|
+
* Stores the access_token and id_token in inmemory storage
|
|
12107
|
+
* @param response
|
|
12108
|
+
* @param request
|
|
12109
|
+
* @param homeAccountIdentifier
|
|
12110
|
+
* @param idTokenObj
|
|
12111
|
+
* @param responseAccessToken
|
|
12112
|
+
* @param tenantId
|
|
12113
|
+
* @param reqTimestamp
|
|
12114
|
+
*/
|
|
12115
|
+
NativeInteractionClient.prototype.cacheNativeTokens = function (response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
|
|
12116
|
+
// cache idToken in inmemory storage
|
|
12117
|
+
var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12118
|
+
this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
|
|
12119
|
+
// cache accessToken in inmemory storage
|
|
12120
|
+
var expiresIn = (request.tokenType === exports.AuthenticationScheme.POP)
|
|
12121
|
+
? Constants.SHR_NONCE_VALIDITY
|
|
12122
|
+
: (typeof response.expires_in === "string"
|
|
12123
|
+
? parseInt(response.expires_in, 10)
|
|
12124
|
+
: response.expires_in) || 0;
|
|
12125
|
+
var tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
12126
|
+
var responseScopes = this.generateScopes(response, request);
|
|
12127
|
+
var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12128
|
+
this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
|
|
12129
|
+
};
|
|
12130
|
+
NativeInteractionClient.prototype.addTelemetryFromNativeResponse = function (response) {
|
|
12131
|
+
var mats = this.getMATSFromResponse(response);
|
|
12132
|
+
if (!mats) {
|
|
12133
|
+
return null;
|
|
12134
|
+
}
|
|
12135
|
+
this.performanceClient.addStaticFields({
|
|
12136
|
+
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
12137
|
+
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
12138
|
+
matsBrokerVersion: mats.broker_version,
|
|
12139
|
+
matsAccountJoinOnStart: mats.account_join_on_start,
|
|
12140
|
+
matsAccountJoinOnEnd: mats.account_join_on_end,
|
|
12141
|
+
matsDeviceJoin: mats.device_join,
|
|
12142
|
+
matsPromptBehavior: mats.prompt_behavior,
|
|
12143
|
+
matsApiErrorCode: mats.api_error_code,
|
|
12144
|
+
matsUiVisible: mats.ui_visible,
|
|
12145
|
+
matsSilentCode: mats.silent_code,
|
|
12146
|
+
matsSilentBiSubCode: mats.silent_bi_sub_code,
|
|
12147
|
+
matsSilentMessage: mats.silent_message,
|
|
12148
|
+
matsSilentStatus: mats.silent_status,
|
|
12149
|
+
matsHttpStatus: mats.http_status,
|
|
12150
|
+
matsHttpEventCount: mats.http_event_count
|
|
12151
|
+
}, this.correlationId);
|
|
12152
|
+
return mats;
|
|
12153
|
+
};
|
|
11683
12154
|
/**
|
|
11684
12155
|
* Validates native platform response before processing
|
|
11685
12156
|
* @param response
|
|
@@ -11798,7 +12269,7 @@
|
|
|
11798
12269
|
* Licensed under the MIT License.
|
|
11799
12270
|
*/
|
|
11800
12271
|
var NativeMessageHandler = /** @class */ (function () {
|
|
11801
|
-
function NativeMessageHandler(logger, handshakeTimeoutMs, extensionId) {
|
|
12272
|
+
function NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, extensionId) {
|
|
11802
12273
|
this.logger = logger;
|
|
11803
12274
|
this.handshakeTimeoutMs = handshakeTimeoutMs;
|
|
11804
12275
|
this.extensionId = extensionId;
|
|
@@ -11807,6 +12278,8 @@
|
|
|
11807
12278
|
this.responseId = 0;
|
|
11808
12279
|
this.messageChannel = new MessageChannel();
|
|
11809
12280
|
this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
|
|
12281
|
+
this.performanceClient = performanceClient;
|
|
12282
|
+
this.handshakeEvent = performanceClient.startMeasurement(exports.PerformanceEvents.NativeMessageHandlerHandshake);
|
|
11810
12283
|
}
|
|
11811
12284
|
/**
|
|
11812
12285
|
* Sends a given message to the extension and resolves with the extension response
|
|
@@ -11835,10 +12308,11 @@
|
|
|
11835
12308
|
};
|
|
11836
12309
|
/**
|
|
11837
12310
|
* Returns an instance of the MessageHandler that has successfully established a connection with an extension
|
|
11838
|
-
* @param logger
|
|
11839
|
-
* @param handshakeTimeoutMs
|
|
12311
|
+
* @param {Logger} logger
|
|
12312
|
+
* @param {number} handshakeTimeoutMs
|
|
12313
|
+
* @param {IPerformanceClient} performanceClient
|
|
11840
12314
|
*/
|
|
11841
|
-
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs) {
|
|
12315
|
+
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs, performanceClient) {
|
|
11842
12316
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
11843
12317
|
var preferredProvider, backupProvider;
|
|
11844
12318
|
return __generator$1(this, function (_a) {
|
|
@@ -11848,14 +12322,14 @@
|
|
|
11848
12322
|
_a.label = 1;
|
|
11849
12323
|
case 1:
|
|
11850
12324
|
_a.trys.push([1, 3, , 5]);
|
|
11851
|
-
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
12325
|
+
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
11852
12326
|
return [4 /*yield*/, preferredProvider.sendHandshakeRequest()];
|
|
11853
12327
|
case 2:
|
|
11854
12328
|
_a.sent();
|
|
11855
12329
|
return [2 /*return*/, preferredProvider];
|
|
11856
12330
|
case 3:
|
|
11857
12331
|
_a.sent();
|
|
11858
|
-
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);
|
|
12332
|
+
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient);
|
|
11859
12333
|
return [4 /*yield*/, backupProvider.sendHandshakeRequest()];
|
|
11860
12334
|
case 4:
|
|
11861
12335
|
_a.sent();
|
|
@@ -11884,6 +12358,10 @@
|
|
|
11884
12358
|
method: NativeExtensionMethod.HandshakeRequest
|
|
11885
12359
|
}
|
|
11886
12360
|
};
|
|
12361
|
+
this.handshakeEvent.addStaticFields({
|
|
12362
|
+
extensionId: this.extensionId,
|
|
12363
|
+
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs
|
|
12364
|
+
});
|
|
11887
12365
|
this.messageChannel.port1.onmessage = function (event) {
|
|
11888
12366
|
_this.onChannelMessage(event);
|
|
11889
12367
|
};
|
|
@@ -11898,6 +12376,7 @@
|
|
|
11898
12376
|
window.removeEventListener("message", _this.windowListener, false);
|
|
11899
12377
|
_this.messageChannel.port1.close();
|
|
11900
12378
|
_this.messageChannel.port2.close();
|
|
12379
|
+
_this.handshakeEvent.endMeasurement({ extensionHandshakeTimedOut: true, success: false });
|
|
11901
12380
|
reject(BrowserAuthError.createNativeHandshakeTimeoutError());
|
|
11902
12381
|
_this.handshakeResolvers.delete(req.responseId);
|
|
11903
12382
|
}, _this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
|
|
@@ -11931,6 +12410,7 @@
|
|
|
11931
12410
|
window.removeEventListener("message", this.windowListener, false);
|
|
11932
12411
|
var handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
|
11933
12412
|
if (handshakeResolver) {
|
|
12413
|
+
this.handshakeEvent.endMeasurement({ success: false, extensionInstalled: false });
|
|
11934
12414
|
handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());
|
|
11935
12415
|
}
|
|
11936
12416
|
}
|
|
@@ -11978,6 +12458,7 @@
|
|
|
11978
12458
|
this.extensionId = request.extensionId;
|
|
11979
12459
|
this.extensionVersion = request.body.version;
|
|
11980
12460
|
this.logger.verbose("NativeMessageHandler - Received HandshakeResponse from extension: " + this.extensionId);
|
|
12461
|
+
this.handshakeEvent.endMeasurement({ extensionInstalled: true, success: true });
|
|
11981
12462
|
handshakeResolver.resolve();
|
|
11982
12463
|
this.handshakeResolvers.delete(request.responseId);
|
|
11983
12464
|
}
|
|
@@ -12065,7 +12546,9 @@
|
|
|
12065
12546
|
var _this = this;
|
|
12066
12547
|
return __generator$1(this, function (_a) {
|
|
12067
12548
|
switch (_a.label) {
|
|
12068
|
-
case 0:
|
|
12549
|
+
case 0:
|
|
12550
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
|
|
12551
|
+
return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
|
|
12069
12552
|
case 1:
|
|
12070
12553
|
validRequest = _a.sent();
|
|
12071
12554
|
this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
|
|
@@ -12080,14 +12563,18 @@
|
|
|
12080
12563
|
_a.label = 2;
|
|
12081
12564
|
case 2:
|
|
12082
12565
|
_a.trys.push([2, 7, , 8]);
|
|
12566
|
+
// Create auth code request and generate PKCE params
|
|
12567
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
|
|
12083
12568
|
return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
|
|
12084
12569
|
case 3:
|
|
12085
12570
|
authCodeRequest = _a.sent();
|
|
12571
|
+
// Initialize the client
|
|
12572
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
|
|
12086
12573
|
return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
|
|
12087
12574
|
case 4:
|
|
12088
12575
|
authClient = _a.sent();
|
|
12089
12576
|
this.logger.verbose("Auth code client created");
|
|
12090
|
-
interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);
|
|
12577
|
+
interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto, this.performanceClient);
|
|
12091
12578
|
return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme) }))];
|
|
12092
12579
|
case 5:
|
|
12093
12580
|
navigateUrl = _a.sent();
|
|
@@ -12273,12 +12760,13 @@
|
|
|
12273
12760
|
if (!currentAuthority) {
|
|
12274
12761
|
throw BrowserAuthError.createNoCachedAuthorityError();
|
|
12275
12762
|
}
|
|
12763
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, cachedRequest.correlationId);
|
|
12276
12764
|
return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, currentAuthority)];
|
|
12277
12765
|
case 1:
|
|
12278
12766
|
authClient = _a.sent();
|
|
12279
12767
|
this.logger.verbose("Auth code client created");
|
|
12280
12768
|
ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, cachedRequest);
|
|
12281
|
-
interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);
|
|
12769
|
+
interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto, this.performanceClient);
|
|
12282
12770
|
return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
|
|
12283
12771
|
case 2: return [2 /*return*/, _a.sent()];
|
|
12284
12772
|
}
|
|
@@ -12313,6 +12801,7 @@
|
|
|
12313
12801
|
timeout: this.config.system.redirectNavigationTimeout,
|
|
12314
12802
|
noHistory: false
|
|
12315
12803
|
};
|
|
12804
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validLogoutRequest.correlationId);
|
|
12316
12805
|
return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority)];
|
|
12317
12806
|
case 3:
|
|
12318
12807
|
authClient = _a.sent();
|
|
@@ -12460,6 +12949,7 @@
|
|
|
12460
12949
|
case 0:
|
|
12461
12950
|
this.logger.verbose("acquireTokenPopupAsync called");
|
|
12462
12951
|
serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenPopup);
|
|
12952
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
|
|
12463
12953
|
return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Popup)];
|
|
12464
12954
|
case 1:
|
|
12465
12955
|
validRequest = _a.sent();
|
|
@@ -12467,9 +12957,13 @@
|
|
|
12467
12957
|
_a.label = 2;
|
|
12468
12958
|
case 2:
|
|
12469
12959
|
_a.trys.push([2, 8, , 9]);
|
|
12960
|
+
// Create auth code request and generate PKCE params
|
|
12961
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
|
|
12470
12962
|
return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
|
|
12471
12963
|
case 3:
|
|
12472
12964
|
authCodeRequest = _a.sent();
|
|
12965
|
+
// Initialize the client
|
|
12966
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
|
|
12473
12967
|
return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
|
|
12474
12968
|
case 4:
|
|
12475
12969
|
authClient = _a.sent();
|
|
@@ -12482,7 +12976,7 @@
|
|
|
12482
12976
|
return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: isNativeBroker }))];
|
|
12483
12977
|
case 5:
|
|
12484
12978
|
navigateUrl = _a.sent();
|
|
12485
|
-
interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
|
|
12979
|
+
interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
|
|
12486
12980
|
popupParameters = {
|
|
12487
12981
|
popup: popup,
|
|
12488
12982
|
popupName: popupName,
|
|
@@ -12563,6 +13057,8 @@
|
|
|
12563
13057
|
case 2:
|
|
12564
13058
|
// Clear cache on logout
|
|
12565
13059
|
_a.sent();
|
|
13060
|
+
// Initialize the client
|
|
13061
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
|
|
12566
13062
|
return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, requestAuthority)];
|
|
12567
13063
|
case 3:
|
|
12568
13064
|
authClient = _a.sent();
|
|
@@ -12991,8 +13487,8 @@
|
|
|
12991
13487
|
*/
|
|
12992
13488
|
var SilentHandler = /** @class */ (function (_super) {
|
|
12993
13489
|
__extends$1(SilentHandler, _super);
|
|
12994
|
-
function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions) {
|
|
12995
|
-
var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
|
|
13490
|
+
function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions, performanceClient) {
|
|
13491
|
+
var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) || this;
|
|
12996
13492
|
_this.navigateFrameWait = systemOptions.navigateFrameWait;
|
|
12997
13493
|
_this.pollIntervalMilliseconds = systemOptions.pollIntervalMilliseconds;
|
|
12998
13494
|
return _this;
|
|
@@ -13004,24 +13500,20 @@
|
|
|
13004
13500
|
*/
|
|
13005
13501
|
SilentHandler.prototype.initiateAuthRequest = function (requestUrl) {
|
|
13006
13502
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
switch (_b.label) {
|
|
13503
|
+
return __generator$1(this, function (_a) {
|
|
13504
|
+
switch (_a.label) {
|
|
13010
13505
|
case 0:
|
|
13506
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerInitiateAuthRequest, this.authCodeRequest.correlationId);
|
|
13011
13507
|
if (StringUtils.isEmpty(requestUrl)) {
|
|
13012
13508
|
// Throw error if request URL is empty.
|
|
13013
13509
|
this.logger.info("Navigate url is empty");
|
|
13014
13510
|
throw BrowserAuthError.createEmptyNavigationUriError();
|
|
13015
13511
|
}
|
|
13016
13512
|
if (!this.navigateFrameWait) return [3 /*break*/, 2];
|
|
13513
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerLoadFrame, this.authCodeRequest.correlationId);
|
|
13017
13514
|
return [4 /*yield*/, this.loadFrame(requestUrl)];
|
|
13018
|
-
case 1:
|
|
13019
|
-
|
|
13020
|
-
return [3 /*break*/, 3];
|
|
13021
|
-
case 2:
|
|
13022
|
-
_a = this.loadFrameSync(requestUrl);
|
|
13023
|
-
_b.label = 3;
|
|
13024
|
-
case 3: return [2 /*return*/, _a];
|
|
13515
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13516
|
+
case 2: return [2 /*return*/, this.loadFrameSync(requestUrl)];
|
|
13025
13517
|
}
|
|
13026
13518
|
});
|
|
13027
13519
|
});
|
|
@@ -13033,6 +13525,7 @@
|
|
|
13033
13525
|
*/
|
|
13034
13526
|
SilentHandler.prototype.monitorIframeForHash = function (iframe, timeout) {
|
|
13035
13527
|
var _this = this;
|
|
13528
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerMonitorIframeForHash, this.authCodeRequest.correlationId);
|
|
13036
13529
|
return new Promise(function (resolve, reject) {
|
|
13037
13530
|
if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
|
|
13038
13531
|
_this.logger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower (" + timeout + "ms) than the default (" + DEFAULT_IFRAME_TIMEOUT_MS + "ms). This may result in timeouts.");
|
|
@@ -13081,11 +13574,12 @@
|
|
|
13081
13574
|
* @ignore
|
|
13082
13575
|
*/
|
|
13083
13576
|
SilentHandler.prototype.loadFrame = function (urlNavigate) {
|
|
13577
|
+
var _this = this;
|
|
13578
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentHandlerLoadFrame, this.authCodeRequest.correlationId);
|
|
13084
13579
|
/*
|
|
13085
13580
|
* This trick overcomes iframe navigation in IE
|
|
13086
13581
|
* IE does not load the page consistently in iframe
|
|
13087
13582
|
*/
|
|
13088
|
-
var _this = this;
|
|
13089
13583
|
return new Promise(function (resolve, reject) {
|
|
13090
13584
|
var frameHandle = _this.createHiddenIframe();
|
|
13091
13585
|
setTimeout(function () {
|
|
@@ -13160,6 +13654,7 @@
|
|
|
13160
13654
|
return __generator$1(this, function (_a) {
|
|
13161
13655
|
switch (_a.label) {
|
|
13162
13656
|
case 0:
|
|
13657
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
|
|
13163
13658
|
this.logger.verbose("acquireTokenByIframe called");
|
|
13164
13659
|
acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
|
|
13165
13660
|
// Check that we have some SSO data
|
|
@@ -13173,6 +13668,8 @@
|
|
|
13173
13668
|
});
|
|
13174
13669
|
throw BrowserAuthError.createSilentPromptValueError(request.prompt);
|
|
13175
13670
|
}
|
|
13671
|
+
// Create silent request
|
|
13672
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
|
|
13176
13673
|
return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: request.prompt || PromptValue.NONE }), exports.InteractionType.Silent)];
|
|
13177
13674
|
case 1:
|
|
13178
13675
|
silentRequest = _a.sent();
|
|
@@ -13181,10 +13678,13 @@
|
|
|
13181
13678
|
_a.label = 2;
|
|
13182
13679
|
case 2:
|
|
13183
13680
|
_a.trys.push([2, 5, , 6]);
|
|
13681
|
+
// Initialize the client
|
|
13682
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
|
|
13184
13683
|
return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
|
|
13185
13684
|
case 3:
|
|
13186
13685
|
authClient = _a.sent();
|
|
13187
13686
|
this.logger.verbose("Auth code client created");
|
|
13687
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentIframeClientTokenHelper, request.correlationId);
|
|
13188
13688
|
return [4 /*yield*/, this.silentTokenHelper(authClient, silentRequest).then(function (result) {
|
|
13189
13689
|
acquireTokenMeasurement.endMeasurement({
|
|
13190
13690
|
success: true,
|
|
@@ -13231,16 +13731,26 @@
|
|
|
13231
13731
|
var _this = this;
|
|
13232
13732
|
return __generator$1(this, function (_a) {
|
|
13233
13733
|
switch (_a.label) {
|
|
13234
|
-
case 0:
|
|
13734
|
+
case 0:
|
|
13735
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentIframeClientTokenHelper, silentRequest.correlationId);
|
|
13736
|
+
// Create auth code request and generate PKCE params
|
|
13737
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, silentRequest.correlationId);
|
|
13738
|
+
return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
|
|
13235
13739
|
case 1:
|
|
13236
13740
|
authCodeRequest = _a.sent();
|
|
13741
|
+
// Create authorize request url
|
|
13742
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.GetAuthCodeUrl, silentRequest.correlationId);
|
|
13237
13743
|
return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, silentRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme) }))];
|
|
13238
13744
|
case 2:
|
|
13239
13745
|
navigateUrl = _a.sent();
|
|
13240
|
-
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
|
|
13746
|
+
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system, this.performanceClient);
|
|
13747
|
+
// Get the frame handle for the silent request
|
|
13748
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerInitiateAuthRequest, silentRequest.correlationId);
|
|
13241
13749
|
return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
|
|
13242
13750
|
case 3:
|
|
13243
13751
|
msalFrame = _a.sent();
|
|
13752
|
+
// Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
|
|
13753
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentHandlerMonitorIframeForHash, silentRequest.correlationId);
|
|
13244
13754
|
return [4 /*yield*/, silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout)];
|
|
13245
13755
|
case 4:
|
|
13246
13756
|
hash = _a.sent();
|
|
@@ -13258,6 +13768,7 @@
|
|
|
13258
13768
|
})];
|
|
13259
13769
|
}
|
|
13260
13770
|
// Handle response from hash string
|
|
13771
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.HandleCodeResponseFromHash, silentRequest.correlationId);
|
|
13261
13772
|
return [2 /*return*/, silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
|
|
13262
13773
|
}
|
|
13263
13774
|
});
|
|
@@ -13286,6 +13797,8 @@
|
|
|
13286
13797
|
return __generator$1(this, function (_b) {
|
|
13287
13798
|
switch (_b.label) {
|
|
13288
13799
|
case 0:
|
|
13800
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.SilentRefreshClientAcquireToken, request.correlationId);
|
|
13801
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeBaseRequest, request.correlationId);
|
|
13289
13802
|
_a = [__assign$1({}, request)];
|
|
13290
13803
|
return [4 /*yield*/, this.initializeBaseRequest(request)];
|
|
13291
13804
|
case 1:
|
|
@@ -13297,6 +13810,7 @@
|
|
|
13297
13810
|
refreshTokenClient = _b.sent();
|
|
13298
13811
|
this.logger.verbose("Refresh token client created");
|
|
13299
13812
|
// Send request to renew token. Auth module will throw errors if token cannot be renewed.
|
|
13813
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
|
|
13300
13814
|
return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest)
|
|
13301
13815
|
.then(function (result) {
|
|
13302
13816
|
acquireTokenMeasurement.endMeasurement({
|
|
@@ -13339,7 +13853,10 @@
|
|
|
13339
13853
|
var clientConfig;
|
|
13340
13854
|
return __generator$1(this, function (_a) {
|
|
13341
13855
|
switch (_a.label) {
|
|
13342
|
-
case 0:
|
|
13856
|
+
case 0:
|
|
13857
|
+
// Create auth module.
|
|
13858
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.correlationId);
|
|
13859
|
+
return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
|
|
13343
13860
|
case 1:
|
|
13344
13861
|
clientConfig = _a.sent();
|
|
13345
13862
|
return [2 /*return*/, new RefreshTokenClient(clientConfig, this.performanceClient)];
|
|
@@ -14918,91 +15435,304 @@
|
|
|
14918
15435
|
return [2 /*return*/, !keyFound];
|
|
14919
15436
|
}
|
|
14920
15437
|
});
|
|
14921
|
-
});
|
|
15438
|
+
});
|
|
15439
|
+
};
|
|
15440
|
+
/**
|
|
15441
|
+
* Removes all cryptographic keys from IndexedDB storage
|
|
15442
|
+
*/
|
|
15443
|
+
CryptoOps.prototype.clearKeystore = function () {
|
|
15444
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
15445
|
+
return __generator$1(this, function (_a) {
|
|
15446
|
+
switch (_a.label) {
|
|
15447
|
+
case 0: return [4 /*yield*/, this.cache.clear()];
|
|
15448
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
15449
|
+
}
|
|
15450
|
+
});
|
|
15451
|
+
});
|
|
15452
|
+
};
|
|
15453
|
+
/**
|
|
15454
|
+
* Signs the given object as a jwt payload with private key retrieved by given kid.
|
|
15455
|
+
* @param payload
|
|
15456
|
+
* @param kid
|
|
15457
|
+
*/
|
|
15458
|
+
CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
|
|
15459
|
+
var _a;
|
|
15460
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
15461
|
+
var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
|
|
15462
|
+
return __generator$1(this, function (_b) {
|
|
15463
|
+
switch (_b.label) {
|
|
15464
|
+
case 0:
|
|
15465
|
+
signJwtMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.CryptoOptsSignJwt, correlationId);
|
|
15466
|
+
return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
|
|
15467
|
+
case 1:
|
|
15468
|
+
cachedKeyPair = _b.sent();
|
|
15469
|
+
if (!cachedKeyPair) {
|
|
15470
|
+
throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
|
|
15471
|
+
}
|
|
15472
|
+
return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
|
|
15473
|
+
case 2:
|
|
15474
|
+
publicKeyJwk = _b.sent();
|
|
15475
|
+
publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
|
|
15476
|
+
encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
|
|
15477
|
+
shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
|
|
15478
|
+
encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
|
|
15479
|
+
// Generate payload
|
|
15480
|
+
payload.cnf = {
|
|
15481
|
+
jwk: JSON.parse(publicKeyJwkString)
|
|
15482
|
+
};
|
|
15483
|
+
encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
|
|
15484
|
+
tokenString = encodedShrHeader + "." + encodedPayload;
|
|
15485
|
+
tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
|
|
15486
|
+
return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
|
|
15487
|
+
case 3:
|
|
15488
|
+
signatureBuffer = _b.sent();
|
|
15489
|
+
encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
15490
|
+
signedJwt = tokenString + "." + encodedSignature;
|
|
15491
|
+
if (signJwtMeasurement) {
|
|
15492
|
+
signJwtMeasurement.endMeasurement({
|
|
15493
|
+
success: true
|
|
15494
|
+
});
|
|
15495
|
+
}
|
|
15496
|
+
return [2 /*return*/, signedJwt];
|
|
15497
|
+
}
|
|
15498
|
+
});
|
|
15499
|
+
});
|
|
15500
|
+
};
|
|
15501
|
+
/**
|
|
15502
|
+
* Returns the SHA-256 hash of an input string
|
|
15503
|
+
* @param plainText
|
|
15504
|
+
*/
|
|
15505
|
+
CryptoOps.prototype.hashString = function (plainText) {
|
|
15506
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
15507
|
+
var hashBuffer, hashBytes;
|
|
15508
|
+
return __generator$1(this, function (_a) {
|
|
15509
|
+
switch (_a.label) {
|
|
15510
|
+
case 0: return [4 /*yield*/, this.browserCrypto.sha256Digest(plainText)];
|
|
15511
|
+
case 1:
|
|
15512
|
+
hashBuffer = _a.sent();
|
|
15513
|
+
hashBytes = new Uint8Array(hashBuffer);
|
|
15514
|
+
return [2 /*return*/, this.b64Encode.urlEncodeArr(hashBytes)];
|
|
15515
|
+
}
|
|
15516
|
+
});
|
|
15517
|
+
});
|
|
15518
|
+
};
|
|
15519
|
+
CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
|
|
15520
|
+
CryptoOps.EXTRACTABLE = true;
|
|
15521
|
+
return CryptoOps;
|
|
15522
|
+
}());
|
|
15523
|
+
|
|
15524
|
+
/*
|
|
15525
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15526
|
+
* Licensed under the MIT License.
|
|
15527
|
+
*/
|
|
15528
|
+
var BrowserPerformanceMeasurement = /** @class */ (function () {
|
|
15529
|
+
function BrowserPerformanceMeasurement(name, correlationId) {
|
|
15530
|
+
this.correlationId = correlationId;
|
|
15531
|
+
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
15532
|
+
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
15533
|
+
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
15534
|
+
}
|
|
15535
|
+
BrowserPerformanceMeasurement.makeMeasureName = function (name, correlationId) {
|
|
15536
|
+
return "msal.measure." + name + "." + correlationId;
|
|
15537
|
+
};
|
|
15538
|
+
BrowserPerformanceMeasurement.makeStartMark = function (name, correlationId) {
|
|
15539
|
+
return "msal.start." + name + "." + correlationId;
|
|
15540
|
+
};
|
|
15541
|
+
BrowserPerformanceMeasurement.makeEndMark = function (name, correlationId) {
|
|
15542
|
+
return "msal.end." + name + "." + correlationId;
|
|
15543
|
+
};
|
|
15544
|
+
BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
|
|
15545
|
+
return typeof window !== "undefined" &&
|
|
15546
|
+
typeof window.performance !== "undefined" &&
|
|
15547
|
+
typeof window.performance.mark === "function" &&
|
|
15548
|
+
typeof window.performance.measure === "function" &&
|
|
15549
|
+
typeof window.performance.clearMarks === "function" &&
|
|
15550
|
+
typeof window.performance.clearMeasures === "function" &&
|
|
15551
|
+
typeof window.performance.getEntriesByName === "function";
|
|
15552
|
+
};
|
|
15553
|
+
/**
|
|
15554
|
+
* Flush browser marks and measurements.
|
|
15555
|
+
* @param {string} correlationId
|
|
15556
|
+
* @param {SubMeasurement} measurements
|
|
15557
|
+
*/
|
|
15558
|
+
BrowserPerformanceMeasurement.flushMeasurements = function (correlationId, measurements) {
|
|
15559
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15560
|
+
try {
|
|
15561
|
+
measurements.forEach(function (measurement) {
|
|
15562
|
+
var measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
15563
|
+
var entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
15564
|
+
if (entriesForMeasurement.length > 0) {
|
|
15565
|
+
window.performance.clearMeasures(measureName);
|
|
15566
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
15567
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
15568
|
+
}
|
|
15569
|
+
});
|
|
15570
|
+
}
|
|
15571
|
+
catch (e) {
|
|
15572
|
+
// Silently catch and return null
|
|
15573
|
+
}
|
|
15574
|
+
}
|
|
15575
|
+
};
|
|
15576
|
+
BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
|
|
15577
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15578
|
+
try {
|
|
15579
|
+
window.performance.mark(this.startMark);
|
|
15580
|
+
}
|
|
15581
|
+
catch (e) {
|
|
15582
|
+
// Silently catch
|
|
15583
|
+
}
|
|
15584
|
+
}
|
|
15585
|
+
};
|
|
15586
|
+
BrowserPerformanceMeasurement.prototype.endMeasurement = function () {
|
|
15587
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15588
|
+
try {
|
|
15589
|
+
window.performance.mark(this.endMark);
|
|
15590
|
+
window.performance.measure(this.measureName, this.startMark, this.endMark);
|
|
15591
|
+
}
|
|
15592
|
+
catch (e) {
|
|
15593
|
+
// Silently catch
|
|
15594
|
+
}
|
|
15595
|
+
}
|
|
15596
|
+
};
|
|
15597
|
+
BrowserPerformanceMeasurement.prototype.flushMeasurement = function () {
|
|
15598
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15599
|
+
try {
|
|
15600
|
+
var entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
|
|
15601
|
+
if (entriesForMeasurement.length > 0) {
|
|
15602
|
+
var durationMs = entriesForMeasurement[0].duration;
|
|
15603
|
+
window.performance.clearMeasures(this.measureName);
|
|
15604
|
+
window.performance.clearMarks(this.startMark);
|
|
15605
|
+
window.performance.clearMarks(this.endMark);
|
|
15606
|
+
return durationMs;
|
|
15607
|
+
}
|
|
15608
|
+
}
|
|
15609
|
+
catch (e) {
|
|
15610
|
+
// Silently catch and return null
|
|
15611
|
+
}
|
|
15612
|
+
}
|
|
15613
|
+
return null;
|
|
15614
|
+
};
|
|
15615
|
+
return BrowserPerformanceMeasurement;
|
|
15616
|
+
}());
|
|
15617
|
+
|
|
15618
|
+
/*
|
|
15619
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15620
|
+
* Licensed under the MIT License.
|
|
15621
|
+
*/
|
|
15622
|
+
var BrowserPerformanceClient = /** @class */ (function (_super) {
|
|
15623
|
+
__extends$1(BrowserPerformanceClient, _super);
|
|
15624
|
+
function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
|
|
15625
|
+
var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
|
|
15626
|
+
_this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
|
|
15627
|
+
_this.guidGenerator = new GuidGenerator(_this.browserCrypto);
|
|
15628
|
+
return _this;
|
|
15629
|
+
}
|
|
15630
|
+
BrowserPerformanceClient.prototype.startPerformanceMeasuremeant = function (measureName, correlationId) {
|
|
15631
|
+
return new BrowserPerformanceMeasurement(measureName, correlationId);
|
|
15632
|
+
};
|
|
15633
|
+
BrowserPerformanceClient.prototype.generateId = function () {
|
|
15634
|
+
return this.guidGenerator.generateGuid();
|
|
15635
|
+
};
|
|
15636
|
+
BrowserPerformanceClient.prototype.getPageVisibility = function () {
|
|
15637
|
+
var _a;
|
|
15638
|
+
return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
|
|
15639
|
+
};
|
|
15640
|
+
BrowserPerformanceClient.prototype.deleteIncompleteSubMeasurements = function (inProgressEvent) {
|
|
15641
|
+
var rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
15642
|
+
var isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
15643
|
+
var incompleteMeasurements = [];
|
|
15644
|
+
if (isRootEvent && (rootEvent === null || rootEvent === void 0 ? void 0 : rootEvent.incompleteSubMeasurements)) {
|
|
15645
|
+
rootEvent.incompleteSubMeasurements.forEach(function (subMeasurement) {
|
|
15646
|
+
incompleteMeasurements.push(__assign$1({}, subMeasurement));
|
|
15647
|
+
});
|
|
15648
|
+
}
|
|
15649
|
+
// Clean up remaining marks for incomplete sub-measurements
|
|
15650
|
+
if (incompleteMeasurements.length > 0) {
|
|
15651
|
+
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
15652
|
+
}
|
|
15653
|
+
};
|
|
15654
|
+
BrowserPerformanceClient.prototype.supportsBrowserPerformanceNow = function () {
|
|
15655
|
+
return typeof window !== "undefined" &&
|
|
15656
|
+
typeof window.performance !== "undefined" &&
|
|
15657
|
+
typeof window.performance.now === "function";
|
|
14922
15658
|
};
|
|
14923
15659
|
/**
|
|
14924
|
-
*
|
|
15660
|
+
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
15661
|
+
* Also captures browser page visibilityState.
|
|
15662
|
+
*
|
|
15663
|
+
* @param {PerformanceEvents} measureName
|
|
15664
|
+
* @param {?string} [correlationId]
|
|
15665
|
+
* @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
|
|
14925
15666
|
*/
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
}
|
|
14933
|
-
|
|
14934
|
-
|
|
15667
|
+
BrowserPerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
|
|
15668
|
+
var _this = this;
|
|
15669
|
+
// Capture page visibilityState and then invoke start/end measurement
|
|
15670
|
+
var startPageVisibility = this.getPageVisibility();
|
|
15671
|
+
var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
|
|
15672
|
+
return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
|
|
15673
|
+
var res = inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
|
|
15674
|
+
_this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15675
|
+
return res;
|
|
15676
|
+
}, discardMeasurement: function () {
|
|
15677
|
+
inProgressEvent.discardMeasurement();
|
|
15678
|
+
_this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
15679
|
+
inProgressEvent.measurement.flushMeasurement();
|
|
15680
|
+
} });
|
|
14935
15681
|
};
|
|
14936
15682
|
/**
|
|
14937
|
-
*
|
|
14938
|
-
* @param
|
|
14939
|
-
* @param
|
|
15683
|
+
* Adds pre-queue time to preQueueTimeByCorrelationId map.
|
|
15684
|
+
* @param {PerformanceEvents} eventName
|
|
15685
|
+
* @param {?string} correlationId
|
|
15686
|
+
* @returns
|
|
14940
15687
|
*/
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
|
|
14961
|
-
encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
|
|
14962
|
-
// Generate payload
|
|
14963
|
-
payload.cnf = {
|
|
14964
|
-
jwk: JSON.parse(publicKeyJwkString)
|
|
14965
|
-
};
|
|
14966
|
-
encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
|
|
14967
|
-
tokenString = encodedShrHeader + "." + encodedPayload;
|
|
14968
|
-
tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
|
|
14969
|
-
return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
|
|
14970
|
-
case 3:
|
|
14971
|
-
signatureBuffer = _b.sent();
|
|
14972
|
-
encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
14973
|
-
signedJwt = tokenString + "." + encodedSignature;
|
|
14974
|
-
if (signJwtMeasurement) {
|
|
14975
|
-
signJwtMeasurement.endMeasurement({
|
|
14976
|
-
success: true
|
|
14977
|
-
});
|
|
14978
|
-
}
|
|
14979
|
-
return [2 /*return*/, signedJwt];
|
|
14980
|
-
}
|
|
14981
|
-
});
|
|
14982
|
-
});
|
|
15688
|
+
BrowserPerformanceClient.prototype.setPreQueueTime = function (eventName, correlationId) {
|
|
15689
|
+
if (!this.supportsBrowserPerformanceNow()) {
|
|
15690
|
+
this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for " + eventName);
|
|
15691
|
+
return;
|
|
15692
|
+
}
|
|
15693
|
+
if (!correlationId) {
|
|
15694
|
+
this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to set telemetry queue time");
|
|
15695
|
+
return;
|
|
15696
|
+
}
|
|
15697
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
15698
|
+
/**
|
|
15699
|
+
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
15700
|
+
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
15701
|
+
*/
|
|
15702
|
+
if (preQueueEvent) {
|
|
15703
|
+
this.logger.trace("BrowserPerformanceClient: Incomplete pre-queue " + preQueueEvent.name + " found", correlationId);
|
|
15704
|
+
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
15705
|
+
}
|
|
15706
|
+
this.preQueueTimeByCorrelationId.set(eventName, { name: eventName, time: window.performance.now() });
|
|
14983
15707
|
};
|
|
14984
15708
|
/**
|
|
14985
|
-
*
|
|
14986
|
-
*
|
|
15709
|
+
* Calculates and adds queue time measurement for given performance event.
|
|
15710
|
+
*
|
|
15711
|
+
* @param {PerformanceEvents} eventName
|
|
15712
|
+
* @param {?string} correlationId
|
|
15713
|
+
* @param {?number} queueTime
|
|
15714
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
15715
|
+
* @returns
|
|
14987
15716
|
*/
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
return
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
}
|
|
15717
|
+
BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
15718
|
+
if (!this.supportsBrowserPerformanceNow()) {
|
|
15719
|
+
this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to add queue measurement for " + eventName);
|
|
15720
|
+
return;
|
|
15721
|
+
}
|
|
15722
|
+
if (!correlationId) {
|
|
15723
|
+
this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to add queue measurement");
|
|
15724
|
+
return;
|
|
15725
|
+
}
|
|
15726
|
+
var preQueueTime = _super.prototype.getPreQueueTime.call(this, eventName, correlationId);
|
|
15727
|
+
if (!preQueueTime) {
|
|
15728
|
+
return;
|
|
15729
|
+
}
|
|
15730
|
+
var currentTime = window.performance.now();
|
|
15731
|
+
var resQueueTime = queueTime || _super.prototype.calculateQueuedTime.call(this, preQueueTime, currentTime);
|
|
15732
|
+
return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
15001
15733
|
};
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
return CryptoOps;
|
|
15005
|
-
}());
|
|
15734
|
+
return BrowserPerformanceClient;
|
|
15735
|
+
}(PerformanceClient));
|
|
15006
15736
|
|
|
15007
15737
|
/*
|
|
15008
15738
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -15018,13 +15748,16 @@
|
|
|
15018
15748
|
SilentIframeClient: SilentIframeClient,
|
|
15019
15749
|
SilentCacheClient: SilentCacheClient,
|
|
15020
15750
|
SilentRefreshClient: SilentRefreshClient,
|
|
15751
|
+
NativeInteractionClient: NativeInteractionClient,
|
|
15021
15752
|
RedirectHandler: RedirectHandler,
|
|
15022
15753
|
EventHandler: EventHandler,
|
|
15023
15754
|
NativeMessageHandler: NativeMessageHandler,
|
|
15024
15755
|
BrowserConstants: BrowserConstants,
|
|
15025
15756
|
get TemporaryCacheKeys () { return TemporaryCacheKeys; },
|
|
15026
15757
|
CryptoOps: CryptoOps,
|
|
15027
|
-
NativeAuthError: NativeAuthError
|
|
15758
|
+
NativeAuthError: NativeAuthError,
|
|
15759
|
+
BrowserPerformanceClient: BrowserPerformanceClient,
|
|
15760
|
+
BrowserPerformanceMeasurement: BrowserPerformanceMeasurement
|
|
15028
15761
|
});
|
|
15029
15762
|
|
|
15030
15763
|
/*
|
|
@@ -15287,6 +16020,8 @@
|
|
|
15287
16020
|
if (!request.code) {
|
|
15288
16021
|
throw BrowserAuthError.createAuthCodeRequiredError();
|
|
15289
16022
|
}
|
|
16023
|
+
// Create silent request
|
|
16024
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
|
|
15290
16025
|
return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Silent)];
|
|
15291
16026
|
case 1:
|
|
15292
16027
|
silentRequest = _a.sent();
|
|
@@ -15296,12 +16031,14 @@
|
|
|
15296
16031
|
case 2:
|
|
15297
16032
|
_a.trys.push([2, 4, , 5]);
|
|
15298
16033
|
authCodeRequest = __assign$1(__assign$1({}, silentRequest), { code: request.code });
|
|
16034
|
+
// Initialize the client
|
|
16035
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.StandardInteractionClientGetClientConfiguration, request.correlationId);
|
|
15299
16036
|
return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, silentRequest.authority)];
|
|
15300
16037
|
case 3:
|
|
15301
16038
|
clientConfig = _a.sent();
|
|
15302
16039
|
authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
|
|
15303
16040
|
this.logger.verbose("Auth code client created");
|
|
15304
|
-
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
|
|
16041
|
+
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system, this.performanceClient);
|
|
15305
16042
|
// Handle auth code parameters from request
|
|
15306
16043
|
return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
|
|
15307
16044
|
code: request.code,
|
|
@@ -15332,110 +16069,6 @@
|
|
|
15332
16069
|
return SilentAuthCodeClient;
|
|
15333
16070
|
}(StandardInteractionClient));
|
|
15334
16071
|
|
|
15335
|
-
/*
|
|
15336
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15337
|
-
* Licensed under the MIT License.
|
|
15338
|
-
*/
|
|
15339
|
-
var BrowserPerformanceMeasurement = /** @class */ (function () {
|
|
15340
|
-
function BrowserPerformanceMeasurement(name, correlationId) {
|
|
15341
|
-
this.correlationId = correlationId;
|
|
15342
|
-
this.measureName = "msal.measure." + name + "." + this.correlationId;
|
|
15343
|
-
this.startMark = "msal.start." + name + "." + this.correlationId;
|
|
15344
|
-
this.endMark = "msal.end." + name + "." + this.correlationId;
|
|
15345
|
-
}
|
|
15346
|
-
BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
|
|
15347
|
-
return typeof window !== "undefined" &&
|
|
15348
|
-
typeof window.performance !== "undefined" &&
|
|
15349
|
-
typeof window.performance.mark === "function" &&
|
|
15350
|
-
typeof window.performance.measure === "function" &&
|
|
15351
|
-
typeof window.performance.clearMarks === "function" &&
|
|
15352
|
-
typeof window.performance.clearMeasures === "function" &&
|
|
15353
|
-
typeof window.performance.getEntriesByName === "function";
|
|
15354
|
-
};
|
|
15355
|
-
BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
|
|
15356
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15357
|
-
try {
|
|
15358
|
-
window.performance.mark(this.startMark);
|
|
15359
|
-
}
|
|
15360
|
-
catch (e) {
|
|
15361
|
-
// Silently catch
|
|
15362
|
-
}
|
|
15363
|
-
}
|
|
15364
|
-
};
|
|
15365
|
-
BrowserPerformanceMeasurement.prototype.endMeasurement = function () {
|
|
15366
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15367
|
-
try {
|
|
15368
|
-
window.performance.mark(this.endMark);
|
|
15369
|
-
window.performance.measure(this.measureName, this.startMark, this.endMark);
|
|
15370
|
-
}
|
|
15371
|
-
catch (e) {
|
|
15372
|
-
// Silently catch
|
|
15373
|
-
}
|
|
15374
|
-
}
|
|
15375
|
-
};
|
|
15376
|
-
BrowserPerformanceMeasurement.prototype.flushMeasurement = function () {
|
|
15377
|
-
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15378
|
-
try {
|
|
15379
|
-
var entriesForMeasurement = window.performance.getEntriesByName(this.measureName, "measure");
|
|
15380
|
-
if (entriesForMeasurement.length > 0) {
|
|
15381
|
-
var durationMs = entriesForMeasurement[0].duration;
|
|
15382
|
-
window.performance.clearMeasures(this.measureName);
|
|
15383
|
-
window.performance.clearMarks(this.startMark);
|
|
15384
|
-
window.performance.clearMarks(this.endMark);
|
|
15385
|
-
return durationMs;
|
|
15386
|
-
}
|
|
15387
|
-
}
|
|
15388
|
-
catch (e) {
|
|
15389
|
-
// Silently catch and return null
|
|
15390
|
-
}
|
|
15391
|
-
}
|
|
15392
|
-
return null;
|
|
15393
|
-
};
|
|
15394
|
-
return BrowserPerformanceMeasurement;
|
|
15395
|
-
}());
|
|
15396
|
-
|
|
15397
|
-
/*
|
|
15398
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15399
|
-
* Licensed under the MIT License.
|
|
15400
|
-
*/
|
|
15401
|
-
var BrowserPerformanceClient = /** @class */ (function (_super) {
|
|
15402
|
-
__extends$1(BrowserPerformanceClient, _super);
|
|
15403
|
-
function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
|
|
15404
|
-
var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
|
|
15405
|
-
_this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
|
|
15406
|
-
_this.guidGenerator = new GuidGenerator(_this.browserCrypto);
|
|
15407
|
-
return _this;
|
|
15408
|
-
}
|
|
15409
|
-
BrowserPerformanceClient.prototype.startPerformanceMeasurement = function (measureName, correlationId) {
|
|
15410
|
-
return new BrowserPerformanceMeasurement(measureName, correlationId);
|
|
15411
|
-
};
|
|
15412
|
-
BrowserPerformanceClient.prototype.generateId = function () {
|
|
15413
|
-
return this.guidGenerator.generateGuid();
|
|
15414
|
-
};
|
|
15415
|
-
BrowserPerformanceClient.prototype.getPageVisibility = function () {
|
|
15416
|
-
var _a;
|
|
15417
|
-
return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
|
|
15418
|
-
};
|
|
15419
|
-
/**
|
|
15420
|
-
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
15421
|
-
* Also captures browser page visibilityState.
|
|
15422
|
-
*
|
|
15423
|
-
* @param {PerformanceEvents} measureName
|
|
15424
|
-
* @param {?string} [correlationId]
|
|
15425
|
-
* @returns {((event?: Partial<PerformanceEvent>) => PerformanceEvent| null)}
|
|
15426
|
-
*/
|
|
15427
|
-
BrowserPerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
|
|
15428
|
-
var _this = this;
|
|
15429
|
-
// Capture page visibilityState and then invoke start/end measurement
|
|
15430
|
-
var startPageVisibility = this.getPageVisibility();
|
|
15431
|
-
var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
|
|
15432
|
-
return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
|
|
15433
|
-
return inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
|
|
15434
|
-
} });
|
|
15435
|
-
};
|
|
15436
|
-
return BrowserPerformanceClient;
|
|
15437
|
-
}(PerformanceClient));
|
|
15438
|
-
|
|
15439
16072
|
/*
|
|
15440
16073
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15441
16074
|
* Licensed under the MIT License.
|
|
@@ -15502,13 +16135,15 @@
|
|
|
15502
16135
|
this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
|
|
15503
16136
|
// Initialize the token cache
|
|
15504
16137
|
this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
|
|
16138
|
+
// Register listener functions
|
|
16139
|
+
this.trackPageVisibilityWithMeasurement = this.trackPageVisibilityWithMeasurement.bind(this);
|
|
15505
16140
|
}
|
|
15506
16141
|
/**
|
|
15507
16142
|
* Initializer function to perform async startup tasks such as connecting to WAM extension
|
|
15508
16143
|
*/
|
|
15509
16144
|
ClientApplication.prototype.initialize = function () {
|
|
15510
16145
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
15511
|
-
var _a, e_1;
|
|
16146
|
+
var allowNativeBroker, initMeasurement, _a, e_1;
|
|
15512
16147
|
return __generator$1(this, function (_b) {
|
|
15513
16148
|
switch (_b.label) {
|
|
15514
16149
|
case 0:
|
|
@@ -15517,13 +16152,15 @@
|
|
|
15517
16152
|
this.logger.info("initialize has already been called, exiting early.");
|
|
15518
16153
|
return [2 /*return*/];
|
|
15519
16154
|
}
|
|
16155
|
+
allowNativeBroker = this.config.system.allowNativeBroker;
|
|
16156
|
+
initMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.InitializeClientApplication);
|
|
15520
16157
|
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);
|
|
15521
|
-
if (!
|
|
16158
|
+
if (!allowNativeBroker) return [3 /*break*/, 4];
|
|
15522
16159
|
_b.label = 1;
|
|
15523
16160
|
case 1:
|
|
15524
16161
|
_b.trys.push([1, 3, , 4]);
|
|
15525
16162
|
_a = this;
|
|
15526
|
-
return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout)];
|
|
16163
|
+
return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient)];
|
|
15527
16164
|
case 2:
|
|
15528
16165
|
_a.nativeExtensionProvider = _b.sent();
|
|
15529
16166
|
return [3 /*break*/, 4];
|
|
@@ -15534,6 +16171,7 @@
|
|
|
15534
16171
|
case 4:
|
|
15535
16172
|
this.initialized = true;
|
|
15536
16173
|
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_END);
|
|
16174
|
+
initMeasurement.endMeasurement({ allowNativeBroker: allowNativeBroker, success: true });
|
|
15537
16175
|
return [2 /*return*/];
|
|
15538
16176
|
}
|
|
15539
16177
|
});
|
|
@@ -15709,7 +16347,6 @@
|
|
|
15709
16347
|
isNativeBroker: true,
|
|
15710
16348
|
requestId: response.requestId
|
|
15711
16349
|
});
|
|
15712
|
-
atPopupMeasurement.flushMeasurement();
|
|
15713
16350
|
return response;
|
|
15714
16351
|
}).catch(function (e) {
|
|
15715
16352
|
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
@@ -15749,7 +16386,6 @@
|
|
|
15749
16386
|
success: true,
|
|
15750
16387
|
requestId: result.requestId
|
|
15751
16388
|
});
|
|
15752
|
-
atPopupMeasurement.flushMeasurement();
|
|
15753
16389
|
return result;
|
|
15754
16390
|
}).catch(function (e) {
|
|
15755
16391
|
if (loggedInAccounts.length > 0) {
|
|
@@ -15763,11 +16399,20 @@
|
|
|
15763
16399
|
subErrorCode: e.subError,
|
|
15764
16400
|
success: false
|
|
15765
16401
|
});
|
|
15766
|
-
atPopupMeasurement.flushMeasurement();
|
|
15767
16402
|
// Since this function is syncronous we need to reject
|
|
15768
16403
|
return Promise.reject(e);
|
|
15769
16404
|
});
|
|
15770
16405
|
};
|
|
16406
|
+
ClientApplication.prototype.trackPageVisibilityWithMeasurement = function () {
|
|
16407
|
+
var measurement = this.ssoSilentMeasurement || this.acquireTokenByCodeAsyncMeasurement;
|
|
16408
|
+
if (!measurement) {
|
|
16409
|
+
return;
|
|
16410
|
+
}
|
|
16411
|
+
this.logger.info("Perf: Visibility change detected in ", measurement.event.name);
|
|
16412
|
+
measurement.increment({
|
|
16413
|
+
visibilityChangeCount: 1,
|
|
16414
|
+
});
|
|
16415
|
+
};
|
|
15771
16416
|
// #endregion
|
|
15772
16417
|
// #region Silent Flow
|
|
15773
16418
|
/**
|
|
@@ -15786,16 +16431,21 @@
|
|
|
15786
16431
|
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
|
|
15787
16432
|
*/
|
|
15788
16433
|
ClientApplication.prototype.ssoSilent = function (request) {
|
|
16434
|
+
var _a;
|
|
15789
16435
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
15790
|
-
var correlationId, validRequest,
|
|
16436
|
+
var correlationId, validRequest, result, silentIframeClient;
|
|
15791
16437
|
var _this = this;
|
|
15792
|
-
return __generator$1(this, function (
|
|
16438
|
+
return __generator$1(this, function (_b) {
|
|
15793
16439
|
correlationId = this.getRequestCorrelationId(request);
|
|
15794
16440
|
validRequest = __assign$1(__assign$1({}, request), {
|
|
15795
16441
|
// will be PromptValue.NONE or PromptValue.NO_SESSION
|
|
15796
16442
|
prompt: request.prompt, correlationId: correlationId });
|
|
15797
16443
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
|
|
15798
|
-
ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
|
|
16444
|
+
this.ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
|
|
16445
|
+
(_a = this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
|
|
16446
|
+
visibilityChangeCount: 0
|
|
16447
|
+
});
|
|
16448
|
+
document.addEventListener("visibilitychange", this.trackPageVisibilityWithMeasurement);
|
|
15799
16449
|
this.logger.verbose("ssoSilent called", correlationId);
|
|
15800
16450
|
this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
|
|
15801
16451
|
if (this.canUseNative(validRequest)) {
|
|
@@ -15814,27 +16464,29 @@
|
|
|
15814
16464
|
result = silentIframeClient.acquireToken(validRequest);
|
|
15815
16465
|
}
|
|
15816
16466
|
return [2 /*return*/, result.then(function (response) {
|
|
16467
|
+
var _a, _b;
|
|
15817
16468
|
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
|
|
15818
|
-
ssoSilentMeasurement.addStaticFields({
|
|
16469
|
+
(_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.addStaticFields({
|
|
15819
16470
|
accessTokenSize: response.accessToken.length,
|
|
15820
16471
|
idTokenSize: response.idToken.length
|
|
15821
16472
|
});
|
|
15822
|
-
ssoSilentMeasurement.endMeasurement({
|
|
16473
|
+
(_b = _this.ssoSilentMeasurement) === null || _b === void 0 ? void 0 : _b.endMeasurement({
|
|
15823
16474
|
success: true,
|
|
15824
16475
|
isNativeBroker: response.fromNativeBroker,
|
|
15825
16476
|
requestId: response.requestId
|
|
15826
16477
|
});
|
|
15827
|
-
ssoSilentMeasurement.flushMeasurement();
|
|
15828
16478
|
return response;
|
|
15829
16479
|
}).catch(function (e) {
|
|
16480
|
+
var _a;
|
|
15830
16481
|
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
|
|
15831
|
-
ssoSilentMeasurement.endMeasurement({
|
|
16482
|
+
(_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
|
|
15832
16483
|
errorCode: e.errorCode,
|
|
15833
16484
|
subErrorCode: e.subError,
|
|
15834
16485
|
success: false
|
|
15835
16486
|
});
|
|
15836
|
-
ssoSilentMeasurement.flushMeasurement();
|
|
15837
16487
|
throw e;
|
|
16488
|
+
}).finally(function () {
|
|
16489
|
+
document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
|
|
15838
16490
|
})];
|
|
15839
16491
|
});
|
|
15840
16492
|
});
|
|
@@ -15860,7 +16512,11 @@
|
|
|
15860
16512
|
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
|
|
15861
16513
|
atbcMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCode, request.correlationId);
|
|
15862
16514
|
try {
|
|
15863
|
-
if (request.code) {
|
|
16515
|
+
if (request.code && request.nativeAccountId) {
|
|
16516
|
+
// Throw error in case server returns both spa_code and spa_accountid in exchange for auth code.
|
|
16517
|
+
throw BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError();
|
|
16518
|
+
}
|
|
16519
|
+
else if (request.code) {
|
|
15864
16520
|
hybridAuthCode_1 = request.code;
|
|
15865
16521
|
response = this.hybridAuthCodeResponses.get(hybridAuthCode_1);
|
|
15866
16522
|
if (!response) {
|
|
@@ -15878,7 +16534,6 @@
|
|
|
15878
16534
|
isNativeBroker: result.fromNativeBroker,
|
|
15879
16535
|
requestId: result.requestId
|
|
15880
16536
|
});
|
|
15881
|
-
atbcMeasurement.flushMeasurement();
|
|
15882
16537
|
return result;
|
|
15883
16538
|
})
|
|
15884
16539
|
.catch(function (error) {
|
|
@@ -15889,16 +16544,12 @@
|
|
|
15889
16544
|
subErrorCode: error.subError,
|
|
15890
16545
|
success: false
|
|
15891
16546
|
});
|
|
15892
|
-
atbcMeasurement.flushMeasurement();
|
|
15893
16547
|
throw error;
|
|
15894
16548
|
});
|
|
15895
16549
|
this.hybridAuthCodeResponses.set(hybridAuthCode_1, response);
|
|
15896
16550
|
}
|
|
15897
16551
|
else {
|
|
15898
16552
|
this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
|
|
15899
|
-
atbcMeasurement.endMeasurement({
|
|
15900
|
-
success: true
|
|
15901
|
-
});
|
|
15902
16553
|
atbcMeasurement.discardMeasurement();
|
|
15903
16554
|
}
|
|
15904
16555
|
return [2 /*return*/, response];
|
|
@@ -15940,16 +16591,42 @@
|
|
|
15940
16591
|
* @returns Result of the operation to redeem the authorization code
|
|
15941
16592
|
*/
|
|
15942
16593
|
ClientApplication.prototype.acquireTokenByCodeAsync = function (request) {
|
|
16594
|
+
var _a;
|
|
15943
16595
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
15944
16596
|
var silentAuthCodeClient, silentTokenResult;
|
|
15945
|
-
|
|
15946
|
-
|
|
16597
|
+
var _this = this;
|
|
16598
|
+
return __generator$1(this, function (_b) {
|
|
16599
|
+
switch (_b.label) {
|
|
15947
16600
|
case 0:
|
|
15948
16601
|
this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
|
|
16602
|
+
this.acquireTokenByCodeAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCodeAsync, request.correlationId);
|
|
16603
|
+
(_a = this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
|
|
16604
|
+
visibilityChangeCount: 0
|
|
16605
|
+
});
|
|
16606
|
+
document.addEventListener("visibilitychange", this.trackPageVisibilityWithMeasurement);
|
|
15949
16607
|
silentAuthCodeClient = this.createSilentAuthCodeClient(request.correlationId);
|
|
15950
|
-
return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)
|
|
16608
|
+
return [4 /*yield*/, silentAuthCodeClient.acquireToken(request).then(function (response) {
|
|
16609
|
+
var _a;
|
|
16610
|
+
(_a = _this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
|
|
16611
|
+
success: true,
|
|
16612
|
+
fromCache: response.fromCache,
|
|
16613
|
+
isNativeBroker: response.fromNativeBroker,
|
|
16614
|
+
requestId: response.requestId
|
|
16615
|
+
});
|
|
16616
|
+
return response;
|
|
16617
|
+
}).catch(function (tokenRenewalError) {
|
|
16618
|
+
var _a;
|
|
16619
|
+
(_a = _this.acquireTokenByCodeAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
|
|
16620
|
+
errorCode: tokenRenewalError.errorCode,
|
|
16621
|
+
subErrorCode: tokenRenewalError.subError,
|
|
16622
|
+
success: false
|
|
16623
|
+
});
|
|
16624
|
+
throw tokenRenewalError;
|
|
16625
|
+
}).finally(function () {
|
|
16626
|
+
document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
|
|
16627
|
+
})];
|
|
15951
16628
|
case 1:
|
|
15952
|
-
silentTokenResult =
|
|
16629
|
+
silentTokenResult = _b.sent();
|
|
15953
16630
|
return [2 /*return*/, silentTokenResult];
|
|
15954
16631
|
}
|
|
15955
16632
|
});
|
|
@@ -15965,6 +16642,7 @@
|
|
|
15965
16642
|
ClientApplication.prototype.acquireTokenFromCache = function (silentCacheClient, commonRequest, silentRequest) {
|
|
15966
16643
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
15967
16644
|
return __generator$1(this, function (_a) {
|
|
16645
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenFromCache, commonRequest.correlationId);
|
|
15968
16646
|
switch (silentRequest.cacheLookupPolicy) {
|
|
15969
16647
|
case exports.CacheLookupPolicy.Default:
|
|
15970
16648
|
case exports.CacheLookupPolicy.AccessToken:
|
|
@@ -15987,12 +16665,14 @@
|
|
|
15987
16665
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
15988
16666
|
var silentRefreshClient;
|
|
15989
16667
|
return __generator$1(this, function (_a) {
|
|
16668
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenByRefreshToken, commonRequest.correlationId);
|
|
15990
16669
|
switch (silentRequest.cacheLookupPolicy) {
|
|
15991
16670
|
case exports.CacheLookupPolicy.Default:
|
|
15992
16671
|
case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
|
|
15993
16672
|
case exports.CacheLookupPolicy.RefreshToken:
|
|
15994
16673
|
case exports.CacheLookupPolicy.RefreshTokenAndNetwork:
|
|
15995
16674
|
silentRefreshClient = this.createSilentRefreshClient(commonRequest.correlationId);
|
|
16675
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentRefreshClientAcquireToken, commonRequest.correlationId);
|
|
15996
16676
|
return [2 /*return*/, silentRefreshClient.acquireToken(commonRequest)];
|
|
15997
16677
|
default:
|
|
15998
16678
|
throw ClientAuthError.createRefreshRequiredError();
|
|
@@ -16010,7 +16690,9 @@
|
|
|
16010
16690
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
16011
16691
|
var silentIframeClient;
|
|
16012
16692
|
return __generator$1(this, function (_a) {
|
|
16693
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenBySilentIframe, request.correlationId);
|
|
16013
16694
|
silentIframeClient = this.createSilentIframeClient(request.correlationId);
|
|
16695
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.SilentIframeClientAcquireToken, request.correlationId);
|
|
16014
16696
|
return [2 /*return*/, silentIframeClient.acquireToken(request)];
|
|
16015
16697
|
});
|
|
16016
16698
|
});
|
|
@@ -16428,7 +17110,10 @@
|
|
|
16428
17110
|
*/
|
|
16429
17111
|
function PublicClientApplication(configuration) {
|
|
16430
17112
|
var _this = _super.call(this, configuration) || this;
|
|
17113
|
+
_this.astsAsyncMeasurement = undefined;
|
|
16431
17114
|
_this.activeSilentTokenRequests = new Map();
|
|
17115
|
+
// Register listener functions
|
|
17116
|
+
_this.trackPageVisibility = _this.trackPageVisibility.bind(_this);
|
|
16432
17117
|
return _this;
|
|
16433
17118
|
}
|
|
16434
17119
|
/**
|
|
@@ -16500,6 +17185,7 @@
|
|
|
16500
17185
|
cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
|
|
16501
17186
|
if (typeof cachedResponse === "undefined") {
|
|
16502
17187
|
this.logger.verbose("acquireTokenSilent called for the first time, storing active request", correlationId);
|
|
17188
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenSilentAsync, correlationId);
|
|
16503
17189
|
response = this.acquireTokenSilentAsync(__assign$1(__assign$1({}, request), { correlationId: correlationId }), account)
|
|
16504
17190
|
.then(function (result) {
|
|
16505
17191
|
_this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
@@ -16514,7 +17200,6 @@
|
|
|
16514
17200
|
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
16515
17201
|
requestId: result.requestId,
|
|
16516
17202
|
});
|
|
16517
|
-
atsMeasurement.flushMeasurement();
|
|
16518
17203
|
return result;
|
|
16519
17204
|
})
|
|
16520
17205
|
.catch(function (error) {
|
|
@@ -16524,7 +17209,6 @@
|
|
|
16524
17209
|
subErrorCode: error.subError,
|
|
16525
17210
|
success: false
|
|
16526
17211
|
});
|
|
16527
|
-
atsMeasurement.flushMeasurement();
|
|
16528
17212
|
throw error;
|
|
16529
17213
|
});
|
|
16530
17214
|
this.activeSilentTokenRequests.set(silentRequestKey, response);
|
|
@@ -16532,9 +17216,6 @@
|
|
|
16532
17216
|
}
|
|
16533
17217
|
else {
|
|
16534
17218
|
this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
|
|
16535
|
-
atsMeasurement.endMeasurement({
|
|
16536
|
-
success: true
|
|
16537
|
-
});
|
|
16538
17219
|
// Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
|
|
16539
17220
|
atsMeasurement.discardMeasurement();
|
|
16540
17221
|
return [2 /*return*/, cachedResponse];
|
|
@@ -16542,6 +17223,15 @@
|
|
|
16542
17223
|
});
|
|
16543
17224
|
});
|
|
16544
17225
|
};
|
|
17226
|
+
PublicClientApplication.prototype.trackPageVisibility = function () {
|
|
17227
|
+
if (!this.astsAsyncMeasurement) {
|
|
17228
|
+
return;
|
|
17229
|
+
}
|
|
17230
|
+
this.logger.info("Perf: Visibility change detected");
|
|
17231
|
+
this.astsAsyncMeasurement.increment({
|
|
17232
|
+
visibilityChangeCount: 1,
|
|
17233
|
+
});
|
|
17234
|
+
};
|
|
16545
17235
|
/**
|
|
16546
17236
|
* Silently acquire an access token for a given set of scopes. Will use cached token if available, otherwise will attempt to acquire a new token from the network via refresh token.
|
|
16547
17237
|
* @param {@link (SilentRequest:type)}
|
|
@@ -16549,14 +17239,20 @@
|
|
|
16549
17239
|
* @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse}
|
|
16550
17240
|
*/
|
|
16551
17241
|
PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
|
|
17242
|
+
var _a;
|
|
16552
17243
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
16553
|
-
var
|
|
17244
|
+
var result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
|
|
16554
17245
|
var _this = this;
|
|
16555
|
-
return __generator$1(this, function (
|
|
16556
|
-
switch (
|
|
17246
|
+
return __generator$1(this, function (_b) {
|
|
17247
|
+
switch (_b.label) {
|
|
16557
17248
|
case 0:
|
|
17249
|
+
this.performanceClient.addQueueMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
|
|
16558
17250
|
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
|
|
16559
|
-
|
|
17251
|
+
this.astsAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
|
|
17252
|
+
(_a = this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.increment({
|
|
17253
|
+
visibilityChangeCount: 0
|
|
17254
|
+
});
|
|
17255
|
+
document.addEventListener("visibilitychange", this.trackPageVisibility);
|
|
16560
17256
|
if (!(NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) && account.nativeAccountId)) return [3 /*break*/, 1];
|
|
16561
17257
|
this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
|
|
16562
17258
|
silentRequest = __assign$1(__assign$1({}, request), { account: account });
|
|
@@ -16566,7 +17262,7 @@
|
|
|
16566
17262
|
// If native token acquisition fails for availability reasons fallback to web flow
|
|
16567
17263
|
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
16568
17264
|
this.logger.verbose("acquireTokenSilent - native platform unavailable, falling back to web flow");
|
|
16569
|
-
this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
|
|
17265
|
+
this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
|
|
16570
17266
|
silentIframeClient = this.createSilentIframeClient(request.correlationId);
|
|
16571
17267
|
return [2 /*return*/, silentIframeClient.acquireToken(request)];
|
|
16572
17268
|
}
|
|
@@ -16577,12 +17273,14 @@
|
|
|
16577
17273
|
case 1:
|
|
16578
17274
|
this.logger.verbose("acquireTokenSilent - attempting to acquire token from web flow");
|
|
16579
17275
|
silentCacheClient = this.createSilentCacheClient(request.correlationId);
|
|
17276
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.InitializeSilentRequest, request.correlationId);
|
|
16580
17277
|
return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
|
|
16581
17278
|
case 2:
|
|
16582
|
-
silentRequest_1 =
|
|
17279
|
+
silentRequest_1 = _b.sent();
|
|
16583
17280
|
requestWithCLP_1 = __assign$1(__assign$1({}, request), {
|
|
16584
17281
|
// set the request's CacheLookupPolicy to Default if it was not optionally passed in
|
|
16585
17282
|
cacheLookupPolicy: request.cacheLookupPolicy || exports.CacheLookupPolicy.Default });
|
|
17283
|
+
this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenFromCache, silentRequest_1.correlationId);
|
|
16586
17284
|
result = this.acquireTokenFromCache(silentCacheClient, silentRequest_1, requestWithCLP_1).catch(function (cacheError) {
|
|
16587
17285
|
if (requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessToken) {
|
|
16588
17286
|
throw cacheError;
|
|
@@ -16590,6 +17288,7 @@
|
|
|
16590
17288
|
// block the reload if it occurred inside a hidden iframe
|
|
16591
17289
|
BrowserUtils.blockReloadInHiddenIframes();
|
|
16592
17290
|
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest_1);
|
|
17291
|
+
_this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenByRefreshToken, silentRequest_1.correlationId);
|
|
16593
17292
|
return _this.acquireTokenByRefreshToken(silentRequest_1, requestWithCLP_1).catch(function (refreshTokenError) {
|
|
16594
17293
|
var isServerError = refreshTokenError instanceof ServerError;
|
|
16595
17294
|
var isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;
|
|
@@ -16603,13 +17302,15 @@
|
|
|
16603
17302
|
throw refreshTokenError;
|
|
16604
17303
|
}
|
|
16605
17304
|
_this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", request.correlationId);
|
|
17305
|
+
_this.performanceClient.setPreQueueTime(exports.PerformanceEvents.AcquireTokenBySilentIframe, silentRequest_1.correlationId);
|
|
16606
17306
|
return _this.acquireTokenBySilentIframe(silentRequest_1);
|
|
16607
17307
|
});
|
|
16608
17308
|
});
|
|
16609
|
-
|
|
17309
|
+
_b.label = 3;
|
|
16610
17310
|
case 3: return [2 /*return*/, result.then(function (response) {
|
|
17311
|
+
var _a;
|
|
16611
17312
|
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
|
|
16612
|
-
|
|
17313
|
+
(_a = _this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
|
|
16613
17314
|
success: true,
|
|
16614
17315
|
fromCache: response.fromCache,
|
|
16615
17316
|
isNativeBroker: response.fromNativeBroker,
|
|
@@ -16617,13 +17318,16 @@
|
|
|
16617
17318
|
});
|
|
16618
17319
|
return response;
|
|
16619
17320
|
}).catch(function (tokenRenewalError) {
|
|
17321
|
+
var _a;
|
|
16620
17322
|
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
|
|
16621
|
-
|
|
17323
|
+
(_a = _this.astsAsyncMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
|
|
16622
17324
|
errorCode: tokenRenewalError.errorCode,
|
|
16623
17325
|
subErrorCode: tokenRenewalError.subError,
|
|
16624
17326
|
success: false
|
|
16625
17327
|
});
|
|
16626
17328
|
throw tokenRenewalError;
|
|
17329
|
+
}).finally(function () {
|
|
17330
|
+
document.removeEventListener("visibilitychange", _this.trackPageVisibility);
|
|
16627
17331
|
})];
|
|
16628
17332
|
}
|
|
16629
17333
|
});
|