@azure/msal-browser 2.28.3 → 2.30.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 +19 -10
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +67 -66
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.js +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +35 -10
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js +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/ITokenCache.d.ts +6 -3
- package/dist/cache/ITokenCache.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/TokenCache.d.ts +33 -5
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.js +121 -20
- package/dist/cache/TokenCache.js.map +1 -1
- package/dist/config/Configuration.d.ts +20 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +6 -3
- package/dist/config/Configuration.js.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +19 -59
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.js +65 -180
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +2 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.js +5 -5
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/ISubtleCrypto.d.ts +10 -0
- package/dist/crypto/ISubtleCrypto.d.ts.map +1 -0
- package/dist/crypto/ModernBrowserCrypto.d.ts +10 -0
- package/dist/crypto/ModernBrowserCrypto.d.ts.map +1 -0
- package/dist/crypto/ModernBrowserCrypto.js +55 -0
- package/dist/crypto/ModernBrowserCrypto.js.map +1 -0
- package/dist/crypto/MsBrowserCrypto.d.ts +10 -0
- package/dist/crypto/MsBrowserCrypto.d.ts.map +1 -0
- package/dist/crypto/MsBrowserCrypto.js +112 -0
- package/dist/crypto/MsBrowserCrypto.js.map +1 -0
- package/dist/crypto/MsrBrowserCrypto.d.ts +18 -0
- package/dist/crypto/MsrBrowserCrypto.d.ts.map +1 -0
- package/dist/crypto/MsrBrowserCrypto.js +59 -0
- package/dist/crypto/MsrBrowserCrypto.js.map +1 -0
- 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.js +2 -2
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.d.ts +8 -0
- package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +11 -1
- package/dist/error/BrowserConfigurationAuthError.js.map +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 +767 -376
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/interaction_client/BaseInteractionClient.js +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +3 -2
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.js +4 -4
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.js +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +2 -2
- 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 +1 -1
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +9 -8
- 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 +3 -2
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +1 -1
- package/dist/interaction_handler/InteractionHandler.js +1 -1
- package/dist/interaction_handler/RedirectHandler.js +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +3 -1
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +5 -5
- package/dist/interaction_handler/SilentHandler.js.map +1 -1
- package/dist/internals.js +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/PopupRequest.d.ts +1 -0
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +1 -0
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/SilentRequest.d.ts +9 -2
- package/dist/request/SilentRequest.d.ts.map +1 -1
- package/dist/request/SsoSilentRequest.d.ts +1 -0
- package/dist/request/SsoSilentRequest.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +2 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +3 -3
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
- package/dist/utils/BrowserConstants.d.ts +9 -1
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +41 -4
- package/dist/utils/BrowserConstants.js.map +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.d.ts +5 -0
- package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
- package/dist/utils/BrowserStringUtils.js +8 -1
- package/dist/utils/BrowserStringUtils.js.map +1 -1
- package/dist/utils/BrowserUtils.js +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/lib/msal-browser.js +767 -376
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +37 -37
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.30.0 2022-10-10 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -117,7 +117,7 @@ function __spread() {
|
|
|
117
117
|
return ar;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
/*! @azure/msal-common v7.
|
|
120
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
121
121
|
/*! *****************************************************************************
|
|
122
122
|
Copyright (c) Microsoft Corporation.
|
|
123
123
|
|
|
@@ -204,7 +204,7 @@ function __spreadArrays() {
|
|
|
204
204
|
return r;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
/*! @azure/msal-common v7.
|
|
207
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
208
208
|
|
|
209
209
|
/*
|
|
210
210
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -221,6 +221,7 @@ var Constants = {
|
|
|
221
221
|
DEFAULT_COMMON_TENANT: "common",
|
|
222
222
|
// ADFS String
|
|
223
223
|
ADFS: "adfs",
|
|
224
|
+
DSTS: "dstsv2",
|
|
224
225
|
// Default AAD Instance Discovery Endpoint
|
|
225
226
|
AAD_INSTANCE_DISCOVERY_ENDPT: "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=",
|
|
226
227
|
// Resource delimiter - used for certain cache entries
|
|
@@ -252,6 +253,7 @@ var Constants = {
|
|
|
252
253
|
IMDS_TIMEOUT: 2000,
|
|
253
254
|
AZURE_REGION_AUTO_DISCOVER_FLAG: "TryAutoDetect",
|
|
254
255
|
REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
|
|
256
|
+
REGIONAL_AUTH_NON_MSI_QUERY_STRING: "allowestsrnonmsi=true",
|
|
255
257
|
KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
|
|
256
258
|
TOKEN_RESPONSE_TYPE: "token",
|
|
257
259
|
ID_TOKEN_RESPONSE_TYPE: "id_token",
|
|
@@ -275,6 +277,7 @@ var HeaderNames;
|
|
|
275
277
|
HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
|
|
276
278
|
HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
|
|
277
279
|
HeaderNames["AuthenticationInfo"] = "Authentication-Info";
|
|
280
|
+
HeaderNames["X_MS_REQUEST_ID"] = "x-ms-request-id";
|
|
278
281
|
})(HeaderNames || (HeaderNames = {}));
|
|
279
282
|
/**
|
|
280
283
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
@@ -370,7 +373,8 @@ var PromptValue = {
|
|
|
370
373
|
SELECT_ACCOUNT: "select_account",
|
|
371
374
|
CONSENT: "consent",
|
|
372
375
|
NONE: "none",
|
|
373
|
-
CREATE: "create"
|
|
376
|
+
CREATE: "create",
|
|
377
|
+
NO_SESSION: "no_session"
|
|
374
378
|
};
|
|
375
379
|
/**
|
|
376
380
|
* SSO Types - generated to populate hints
|
|
@@ -581,7 +585,7 @@ var JsonTypes;
|
|
|
581
585
|
JsonTypes["Jwk"] = "JWK";
|
|
582
586
|
})(JsonTypes || (JsonTypes = {}));
|
|
583
587
|
|
|
584
|
-
/*! @azure/msal-common v7.
|
|
588
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
585
589
|
|
|
586
590
|
/*
|
|
587
591
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -637,7 +641,7 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
637
641
|
return AuthError;
|
|
638
642
|
}(Error));
|
|
639
643
|
|
|
640
|
-
/*! @azure/msal-common v7.
|
|
644
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
641
645
|
|
|
642
646
|
/*
|
|
643
647
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -712,7 +716,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
712
716
|
}
|
|
713
717
|
};
|
|
714
718
|
|
|
715
|
-
/*! @azure/msal-common v7.
|
|
719
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
716
720
|
|
|
717
721
|
/*
|
|
718
722
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -778,6 +782,16 @@ var ClientAuthErrorMessage = {
|
|
|
778
782
|
code: "nonce_not_found",
|
|
779
783
|
desc: "nonce not found"
|
|
780
784
|
},
|
|
785
|
+
authTimeNotFoundError: {
|
|
786
|
+
code: "auth_time_not_found",
|
|
787
|
+
desc: "Max Age was requested and the ID token is missing the auth_time variable." +
|
|
788
|
+
" auth_time is an optional claim and is not enabled by default - it must be enabled." +
|
|
789
|
+
" See https://aka.ms/msaljs/optional-claims for more information."
|
|
790
|
+
},
|
|
791
|
+
maxAgeTranspiredError: {
|
|
792
|
+
code: "max_age_transpired",
|
|
793
|
+
desc: "Max Age is set to 0, or too much time has elapsed since the last end-user authentication."
|
|
794
|
+
},
|
|
781
795
|
noTokensFoundError: {
|
|
782
796
|
code: "no_tokens_found",
|
|
783
797
|
desc: "No tokens were found for the given scopes, and no authorization code was passed to acquireToken. You must retrieve an authorization code before making a call to acquireToken()."
|
|
@@ -998,6 +1012,19 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
998
1012
|
ClientAuthError.createNonceMismatchError = function () {
|
|
999
1013
|
return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code, ClientAuthErrorMessage.nonceMismatchError.desc);
|
|
1000
1014
|
};
|
|
1015
|
+
/**
|
|
1016
|
+
* Creates an error thrown when max_age was provided in the request, but auth_time is not in the token claims
|
|
1017
|
+
* @param missingNonce
|
|
1018
|
+
*/
|
|
1019
|
+
ClientAuthError.createAuthTimeNotFoundError = function () {
|
|
1020
|
+
return new ClientAuthError(ClientAuthErrorMessage.authTimeNotFoundError.code, ClientAuthErrorMessage.authTimeNotFoundError.desc);
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Creates an error thrown when too much time has elapsed since the last end-user authentication
|
|
1024
|
+
*/
|
|
1025
|
+
ClientAuthError.createMaxAgeTranspiredError = function () {
|
|
1026
|
+
return new ClientAuthError(ClientAuthErrorMessage.maxAgeTranspiredError.code, ClientAuthErrorMessage.maxAgeTranspiredError.desc);
|
|
1027
|
+
};
|
|
1001
1028
|
/**
|
|
1002
1029
|
* Creates an error thrown when the mnonce is not present
|
|
1003
1030
|
* @param missingNonce
|
|
@@ -1184,7 +1211,7 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1184
1211
|
return ClientAuthError;
|
|
1185
1212
|
}(AuthError));
|
|
1186
1213
|
|
|
1187
|
-
/*! @azure/msal-common v7.
|
|
1214
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
1188
1215
|
|
|
1189
1216
|
/*
|
|
1190
1217
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1309,7 +1336,7 @@ var StringUtils = /** @class */ (function () {
|
|
|
1309
1336
|
return StringUtils;
|
|
1310
1337
|
}());
|
|
1311
1338
|
|
|
1312
|
-
/*! @azure/msal-common v7.
|
|
1339
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
1313
1340
|
|
|
1314
1341
|
/*
|
|
1315
1342
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1489,12 +1516,12 @@ var Logger = /** @class */ (function () {
|
|
|
1489
1516
|
return Logger;
|
|
1490
1517
|
}());
|
|
1491
1518
|
|
|
1492
|
-
/*! @azure/msal-common v7.
|
|
1519
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
1493
1520
|
/* eslint-disable header/header */
|
|
1494
1521
|
var name$1 = "@azure/msal-common";
|
|
1495
|
-
var version$1 = "7.
|
|
1522
|
+
var version$1 = "7.6.0";
|
|
1496
1523
|
|
|
1497
|
-
/*! @azure/msal-common v7.
|
|
1524
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
1498
1525
|
/*
|
|
1499
1526
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1500
1527
|
* Licensed under the MIT License.
|
|
@@ -1515,7 +1542,7 @@ exports.AzureCloudInstance = void 0;
|
|
|
1515
1542
|
AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
|
|
1516
1543
|
})(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
|
|
1517
1544
|
|
|
1518
|
-
/*! @azure/msal-common v7.
|
|
1545
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
1519
1546
|
|
|
1520
1547
|
/*
|
|
1521
1548
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1674,7 +1701,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1674
1701
|
return CredentialEntity;
|
|
1675
1702
|
}());
|
|
1676
1703
|
|
|
1677
|
-
/*! @azure/msal-common v7.
|
|
1704
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
1678
1705
|
|
|
1679
1706
|
/*
|
|
1680
1707
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1722,7 +1749,7 @@ var ClientConfigurationErrorMessage = {
|
|
|
1722
1749
|
},
|
|
1723
1750
|
invalidPrompt: {
|
|
1724
1751
|
code: "invalid_prompt_value",
|
|
1725
|
-
desc: "Supported prompt values are 'login', 'select_account', 'consent', 'create' and '
|
|
1752
|
+
desc: "Supported prompt values are 'login', 'select_account', 'consent', 'create', 'none' and 'no_session'. Please see here for valid configuration options: https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#commonauthorizationurlrequest",
|
|
1726
1753
|
},
|
|
1727
1754
|
invalidClaimsRequest: {
|
|
1728
1755
|
code: "invalid_claims",
|
|
@@ -1929,7 +1956,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1929
1956
|
return ClientConfigurationError;
|
|
1930
1957
|
}(ClientAuthError));
|
|
1931
1958
|
|
|
1932
|
-
/*! @azure/msal-common v7.
|
|
1959
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
1933
1960
|
|
|
1934
1961
|
/*
|
|
1935
1962
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2113,7 +2140,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
2113
2140
|
return ScopeSet;
|
|
2114
2141
|
}());
|
|
2115
2142
|
|
|
2116
|
-
/*! @azure/msal-common v7.
|
|
2143
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
2117
2144
|
|
|
2118
2145
|
/*
|
|
2119
2146
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2151,7 +2178,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
2151
2178
|
};
|
|
2152
2179
|
}
|
|
2153
2180
|
|
|
2154
|
-
/*! @azure/msal-common v7.
|
|
2181
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
2155
2182
|
/*
|
|
2156
2183
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2157
2184
|
* Licensed under the MIT License.
|
|
@@ -2163,9 +2190,10 @@ var AuthorityType;
|
|
|
2163
2190
|
(function (AuthorityType) {
|
|
2164
2191
|
AuthorityType[AuthorityType["Default"] = 0] = "Default";
|
|
2165
2192
|
AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
|
|
2193
|
+
AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
|
|
2166
2194
|
})(AuthorityType || (AuthorityType = {}));
|
|
2167
2195
|
|
|
2168
|
-
/*! @azure/msal-common v7.
|
|
2196
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
2169
2197
|
|
|
2170
2198
|
/*
|
|
2171
2199
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2287,10 +2315,13 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2287
2315
|
// How do you account for MSA CID here?
|
|
2288
2316
|
account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) || Constants.EMPTY_STRING;
|
|
2289
2317
|
/*
|
|
2290
|
-
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
2291
|
-
* This field should not be relied upon if a custom
|
|
2318
|
+
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
2319
|
+
* In most cases it will contain a single email. This field should not be relied upon if a custom
|
|
2320
|
+
* policy is configured to return more than 1 email.
|
|
2292
2321
|
*/
|
|
2293
|
-
|
|
2322
|
+
var preferredUsername = (_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username;
|
|
2323
|
+
var email = ((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : null;
|
|
2324
|
+
account.username = preferredUsername || email || Constants.EMPTY_STRING;
|
|
2294
2325
|
account.name = (_f = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _f === void 0 ? void 0 : _f.name;
|
|
2295
2326
|
}
|
|
2296
2327
|
account.cloudGraphHostName = cloudGraphHostName;
|
|
@@ -2305,7 +2336,8 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2305
2336
|
AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
|
|
2306
2337
|
var _a, _b, _c, _d;
|
|
2307
2338
|
var account = new AccountEntity();
|
|
2308
|
-
account.authorityType = (authority &&
|
|
2339
|
+
account.authorityType = (authority &&
|
|
2340
|
+
authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
2309
2341
|
account.homeAccountId = homeAccountId;
|
|
2310
2342
|
// non AAD scenarios can have empty realm
|
|
2311
2343
|
account.realm = Constants.EMPTY_STRING;
|
|
@@ -2339,7 +2371,7 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2339
2371
|
var _a;
|
|
2340
2372
|
var accountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.sub) ? idToken.claims.sub : Constants.EMPTY_STRING;
|
|
2341
2373
|
// since ADFS does not have tid and does not set client_info
|
|
2342
|
-
if (authType === AuthorityType.Adfs) {
|
|
2374
|
+
if (authType === AuthorityType.Adfs || authType === AuthorityType.Dsts) {
|
|
2343
2375
|
return accountId;
|
|
2344
2376
|
}
|
|
2345
2377
|
// for cases where there is clientInfo
|
|
@@ -2400,7 +2432,7 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2400
2432
|
return AccountEntity;
|
|
2401
2433
|
}());
|
|
2402
2434
|
|
|
2403
|
-
/*! @azure/msal-common v7.
|
|
2435
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
2404
2436
|
|
|
2405
2437
|
/*
|
|
2406
2438
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2435,10 +2467,24 @@ var AuthToken = /** @class */ (function () {
|
|
|
2435
2467
|
throw ClientAuthError.createTokenParsingError(err);
|
|
2436
2468
|
}
|
|
2437
2469
|
};
|
|
2470
|
+
/**
|
|
2471
|
+
* Determine if the token's max_age has transpired
|
|
2472
|
+
*/
|
|
2473
|
+
AuthToken.checkMaxAge = function (authTime, maxAge) {
|
|
2474
|
+
/*
|
|
2475
|
+
* per https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
|
|
2476
|
+
* To force an immediate re-authentication: If an app requires that a user re-authenticate prior to access,
|
|
2477
|
+
* provide a value of 0 for the max_age parameter and the AS will force a fresh login.
|
|
2478
|
+
*/
|
|
2479
|
+
var fiveMinuteSkew = 300000; // five minutes in milliseconds
|
|
2480
|
+
if ((maxAge === 0) || ((Date.now() - fiveMinuteSkew) > (authTime + maxAge))) {
|
|
2481
|
+
throw ClientAuthError.createMaxAgeTranspiredError();
|
|
2482
|
+
}
|
|
2483
|
+
};
|
|
2438
2484
|
return AuthToken;
|
|
2439
2485
|
}());
|
|
2440
2486
|
|
|
2441
|
-
/*! @azure/msal-common v7.
|
|
2487
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
2442
2488
|
|
|
2443
2489
|
/*
|
|
2444
2490
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2640,7 +2686,11 @@ var CacheManager = /** @class */ (function () {
|
|
|
2640
2686
|
if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
|
|
2641
2687
|
return;
|
|
2642
2688
|
}
|
|
2643
|
-
|
|
2689
|
+
/*
|
|
2690
|
+
* homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of ""
|
|
2691
|
+
* because we don't want a client_credential request to return a cached token that has a homeAccountId
|
|
2692
|
+
*/
|
|
2693
|
+
if ((typeof homeAccountId === "string") && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2644
2694
|
return;
|
|
2645
2695
|
}
|
|
2646
2696
|
if (!!environment && !_this.matchEnvironment(entity, environment)) {
|
|
@@ -3059,7 +3109,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
3059
3109
|
* @param homeAccountId
|
|
3060
3110
|
*/
|
|
3061
3111
|
CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
|
|
3062
|
-
return !!(entity.homeAccountId && homeAccountId === entity.homeAccountId);
|
|
3112
|
+
return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
|
|
3063
3113
|
};
|
|
3064
3114
|
/**
|
|
3065
3115
|
* helper to match assertion
|
|
@@ -3313,7 +3363,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
3313
3363
|
return DefaultStorageClass;
|
|
3314
3364
|
}(CacheManager));
|
|
3315
3365
|
|
|
3316
|
-
/*! @azure/msal-common v7.
|
|
3366
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3317
3367
|
|
|
3318
3368
|
/*
|
|
3319
3369
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3407,7 +3457,7 @@ function buildAuthOptions(authOptions) {
|
|
|
3407
3457
|
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
|
|
3408
3458
|
}
|
|
3409
3459
|
|
|
3410
|
-
/*! @azure/msal-common v7.
|
|
3460
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3411
3461
|
|
|
3412
3462
|
/*
|
|
3413
3463
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3427,7 +3477,7 @@ var ServerError = /** @class */ (function (_super) {
|
|
|
3427
3477
|
return ServerError;
|
|
3428
3478
|
}(AuthError));
|
|
3429
3479
|
|
|
3430
|
-
/*! @azure/msal-common v7.
|
|
3480
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3431
3481
|
|
|
3432
3482
|
/*
|
|
3433
3483
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3523,7 +3573,7 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
3523
3573
|
return ThrottlingUtils;
|
|
3524
3574
|
}());
|
|
3525
3575
|
|
|
3526
|
-
/*! @azure/msal-common v7.
|
|
3576
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3527
3577
|
|
|
3528
3578
|
/*
|
|
3529
3579
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3572,7 +3622,7 @@ var NetworkManager = /** @class */ (function () {
|
|
|
3572
3622
|
return NetworkManager;
|
|
3573
3623
|
}());
|
|
3574
3624
|
|
|
3575
|
-
/*! @azure/msal-common v7.
|
|
3625
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3576
3626
|
/*
|
|
3577
3627
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3578
3628
|
* Licensed under the MIT License.
|
|
@@ -3583,7 +3633,7 @@ var CcsCredentialType;
|
|
|
3583
3633
|
CcsCredentialType["UPN"] = "UPN";
|
|
3584
3634
|
})(CcsCredentialType || (CcsCredentialType = {}));
|
|
3585
3635
|
|
|
3586
|
-
/*! @azure/msal-common v7.
|
|
3636
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3587
3637
|
|
|
3588
3638
|
/*
|
|
3589
3639
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3674,7 +3724,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
3674
3724
|
return BaseClient;
|
|
3675
3725
|
}());
|
|
3676
3726
|
|
|
3677
|
-
/*! @azure/msal-common v7.
|
|
3727
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3678
3728
|
|
|
3679
3729
|
/*
|
|
3680
3730
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3760,7 +3810,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3760
3810
|
return RequestValidator;
|
|
3761
3811
|
}());
|
|
3762
3812
|
|
|
3763
|
-
/*! @azure/msal-common v7.
|
|
3813
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
3764
3814
|
|
|
3765
3815
|
/*
|
|
3766
3816
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4138,7 +4188,7 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
4138
4188
|
return RequestParameterBuilder;
|
|
4139
4189
|
}());
|
|
4140
4190
|
|
|
4141
|
-
/*! @azure/msal-common v7.
|
|
4191
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4142
4192
|
|
|
4143
4193
|
/*
|
|
4144
4194
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4202,7 +4252,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
|
|
|
4202
4252
|
return IdTokenEntity;
|
|
4203
4253
|
}(CredentialEntity));
|
|
4204
4254
|
|
|
4205
|
-
/*! @azure/msal-common v7.
|
|
4255
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4206
4256
|
/*
|
|
4207
4257
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4208
4258
|
* Licensed under the MIT License.
|
|
@@ -4252,7 +4302,7 @@ var TimeUtils = /** @class */ (function () {
|
|
|
4252
4302
|
return TimeUtils;
|
|
4253
4303
|
}());
|
|
4254
4304
|
|
|
4255
|
-
/*! @azure/msal-common v7.
|
|
4305
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4256
4306
|
|
|
4257
4307
|
/*
|
|
4258
4308
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4366,7 +4416,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
4366
4416
|
return AccessTokenEntity;
|
|
4367
4417
|
}(CredentialEntity));
|
|
4368
4418
|
|
|
4369
|
-
/*! @azure/msal-common v7.
|
|
4419
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4370
4420
|
|
|
4371
4421
|
/*
|
|
4372
4422
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4433,7 +4483,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
|
|
|
4433
4483
|
return RefreshTokenEntity;
|
|
4434
4484
|
}(CredentialEntity));
|
|
4435
4485
|
|
|
4436
|
-
/*! @azure/msal-common v7.
|
|
4486
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4437
4487
|
|
|
4438
4488
|
/*
|
|
4439
4489
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4508,7 +4558,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
|
4508
4558
|
return InteractionRequiredAuthError;
|
|
4509
4559
|
}(AuthError));
|
|
4510
4560
|
|
|
4511
|
-
/*! @azure/msal-common v7.
|
|
4561
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4512
4562
|
/*
|
|
4513
4563
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4514
4564
|
* Licensed under the MIT License.
|
|
@@ -4524,7 +4574,7 @@ var CacheRecord = /** @class */ (function () {
|
|
|
4524
4574
|
return CacheRecord;
|
|
4525
4575
|
}());
|
|
4526
4576
|
|
|
4527
|
-
/*! @azure/msal-common v7.
|
|
4577
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4528
4578
|
|
|
4529
4579
|
/*
|
|
4530
4580
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4595,7 +4645,7 @@ var ProtocolUtils = /** @class */ (function () {
|
|
|
4595
4645
|
return ProtocolUtils;
|
|
4596
4646
|
}());
|
|
4597
4647
|
|
|
4598
|
-
/*! @azure/msal-common v7.
|
|
4648
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4599
4649
|
|
|
4600
4650
|
/*
|
|
4601
4651
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4829,7 +4879,7 @@ var UrlString = /** @class */ (function () {
|
|
|
4829
4879
|
return UrlString;
|
|
4830
4880
|
}());
|
|
4831
4881
|
|
|
4832
|
-
/*! @azure/msal-common v7.
|
|
4882
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4833
4883
|
|
|
4834
4884
|
/*
|
|
4835
4885
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4930,7 +4980,7 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4930
4980
|
return PopTokenGenerator;
|
|
4931
4981
|
}());
|
|
4932
4982
|
|
|
4933
|
-
/*! @azure/msal-common v7.
|
|
4983
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
4934
4984
|
|
|
4935
4985
|
/*
|
|
4936
4986
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5000,7 +5050,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
5000
5050
|
return AppMetadataEntity;
|
|
5001
5051
|
}());
|
|
5002
5052
|
|
|
5003
|
-
/*! @azure/msal-common v7.
|
|
5053
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
5004
5054
|
/*
|
|
5005
5055
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5006
5056
|
* Licensed under the MIT License.
|
|
@@ -5036,7 +5086,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
5036
5086
|
return TokenCacheContext;
|
|
5037
5087
|
}());
|
|
5038
5088
|
|
|
5039
|
-
/*! @azure/msal-common v7.
|
|
5089
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
5040
5090
|
|
|
5041
5091
|
/*
|
|
5042
5092
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5097,9 +5147,9 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5097
5147
|
* @param serverTokenResponse
|
|
5098
5148
|
* @param authority
|
|
5099
5149
|
*/
|
|
5100
|
-
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
|
|
5150
|
+
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
|
|
5101
5151
|
return __awaiter(this, void 0, void 0, function () {
|
|
5102
|
-
var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
5152
|
+
var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
5103
5153
|
return __generator(this, function (_a) {
|
|
5104
5154
|
switch (_a.label) {
|
|
5105
5155
|
case 0:
|
|
@@ -5111,6 +5161,14 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5111
5161
|
throw ClientAuthError.createNonceMismatchError();
|
|
5112
5162
|
}
|
|
5113
5163
|
}
|
|
5164
|
+
// token max_age check
|
|
5165
|
+
if (request.maxAge || (request.maxAge === 0)) {
|
|
5166
|
+
authTime = idTokenObj.claims.auth_time;
|
|
5167
|
+
if (!authTime) {
|
|
5168
|
+
throw ClientAuthError.createAuthTimeNotFoundError();
|
|
5169
|
+
}
|
|
5170
|
+
AuthToken.checkMaxAge(authTime, request.maxAge);
|
|
5171
|
+
}
|
|
5114
5172
|
}
|
|
5115
5173
|
// generate homeAccountId
|
|
5116
5174
|
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
|
|
@@ -5142,7 +5200,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5142
5200
|
account = this.cacheStorage.getAccount(key);
|
|
5143
5201
|
if (!account) {
|
|
5144
5202
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
5145
|
-
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
|
|
5203
|
+
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId)];
|
|
5146
5204
|
}
|
|
5147
5205
|
}
|
|
5148
5206
|
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
@@ -5157,7 +5215,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5157
5215
|
_a.sent();
|
|
5158
5216
|
_a.label = 7;
|
|
5159
5217
|
case 7: return [7 /*endfinally*/];
|
|
5160
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
|
|
5218
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
|
|
5161
5219
|
}
|
|
5162
5220
|
});
|
|
5163
5221
|
});
|
|
@@ -5243,7 +5301,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5243
5301
|
* @param fromTokenCache
|
|
5244
5302
|
* @param stateString
|
|
5245
5303
|
*/
|
|
5246
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
|
|
5304
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code, requestId) {
|
|
5247
5305
|
var _a, _b, _c;
|
|
5248
5306
|
return __awaiter(this, void 0, void 0, function () {
|
|
5249
5307
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
@@ -5291,6 +5349,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5291
5349
|
fromCache: fromTokenCache,
|
|
5292
5350
|
expiresOn: expiresOn,
|
|
5293
5351
|
correlationId: request.correlationId,
|
|
5352
|
+
requestId: requestId || Constants.EMPTY_STRING,
|
|
5294
5353
|
extExpiresOn: extExpiresOn,
|
|
5295
5354
|
familyId: familyId,
|
|
5296
5355
|
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
@@ -5307,7 +5366,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5307
5366
|
return ResponseHandler;
|
|
5308
5367
|
}());
|
|
5309
5368
|
|
|
5310
|
-
/*! @azure/msal-common v7.
|
|
5369
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
5311
5370
|
|
|
5312
5371
|
/*
|
|
5313
5372
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5353,10 +5412,11 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5353
5412
|
* @param request
|
|
5354
5413
|
*/
|
|
5355
5414
|
AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
|
|
5415
|
+
var _a;
|
|
5356
5416
|
return __awaiter(this, void 0, void 0, function () {
|
|
5357
|
-
var reqTimestamp, response, responseHandler;
|
|
5358
|
-
return __generator(this, function (
|
|
5359
|
-
switch (
|
|
5417
|
+
var reqTimestamp, response, requestId, responseHandler;
|
|
5418
|
+
return __generator(this, function (_b) {
|
|
5419
|
+
switch (_b.label) {
|
|
5360
5420
|
case 0:
|
|
5361
5421
|
this.logger.info("in acquireToken call");
|
|
5362
5422
|
if (!request || StringUtils.isEmpty(request.code)) {
|
|
@@ -5365,12 +5425,13 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5365
5425
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5366
5426
|
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
5367
5427
|
case 1:
|
|
5368
|
-
response =
|
|
5428
|
+
response = _b.sent();
|
|
5429
|
+
requestId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a[HeaderNames.X_MS_REQUEST_ID];
|
|
5369
5430
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5370
5431
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
5371
5432
|
responseHandler.validateTokenResponse(response.body);
|
|
5372
|
-
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload)];
|
|
5373
|
-
case 2: return [2 /*return*/,
|
|
5433
|
+
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)];
|
|
5434
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
5374
5435
|
}
|
|
5375
5436
|
});
|
|
5376
5437
|
});
|
|
@@ -5758,7 +5819,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5758
5819
|
return AuthorizationCodeClient;
|
|
5759
5820
|
}(BaseClient));
|
|
5760
5821
|
|
|
5761
|
-
/*! @azure/msal-common v7.
|
|
5822
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
5762
5823
|
/*
|
|
5763
5824
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5764
5825
|
* Licensed under the MIT License.
|
|
@@ -5841,10 +5902,6 @@ exports.PerformanceEvents = void 0;
|
|
|
5841
5902
|
* Used to acquire a token from Native component when native brokering is enabled.
|
|
5842
5903
|
*/
|
|
5843
5904
|
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
5844
|
-
/**
|
|
5845
|
-
* Time spent on the network for refresh token acquisition
|
|
5846
|
-
*/
|
|
5847
|
-
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5848
5905
|
/**
|
|
5849
5906
|
* Time spent creating default headers for requests to token endpoint
|
|
5850
5907
|
*/
|
|
@@ -5858,10 +5915,21 @@ exports.PerformanceEvents = void 0;
|
|
|
5858
5915
|
*/
|
|
5859
5916
|
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
5860
5917
|
/**
|
|
5861
|
-
*
|
|
5862
|
-
* Used to acquire a token on behalf of the embedded application (PW-Broker).
|
|
5918
|
+
* Time taken for token acquisition by broker
|
|
5863
5919
|
*/
|
|
5864
5920
|
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
5921
|
+
/**
|
|
5922
|
+
* Time spent on the network for refresh token acquisition
|
|
5923
|
+
*/
|
|
5924
|
+
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5925
|
+
/**
|
|
5926
|
+
* Time taken for acquiring refresh token , records RT size
|
|
5927
|
+
*/
|
|
5928
|
+
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
5929
|
+
/**
|
|
5930
|
+
* Time taken for acquiring cached refresh token
|
|
5931
|
+
*/
|
|
5932
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
5865
5933
|
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5866
5934
|
/**
|
|
5867
5935
|
* State of the performance event.
|
|
@@ -5876,7 +5944,7 @@ var PerformanceEventStatus;
|
|
|
5876
5944
|
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
5877
5945
|
})(PerformanceEventStatus || (PerformanceEventStatus = {}));
|
|
5878
5946
|
|
|
5879
|
-
/*! @azure/msal-common v7.
|
|
5947
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
5880
5948
|
|
|
5881
5949
|
/*
|
|
5882
5950
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5891,18 +5959,40 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5891
5959
|
return _super.call(this, configuration, performanceClient) || this;
|
|
5892
5960
|
}
|
|
5893
5961
|
RefreshTokenClient.prototype.acquireToken = function (request) {
|
|
5962
|
+
var _a, _b;
|
|
5894
5963
|
return __awaiter(this, void 0, void 0, function () {
|
|
5895
|
-
var reqTimestamp, response, responseHandler;
|
|
5896
|
-
|
|
5897
|
-
|
|
5964
|
+
var atsMeasurement, reqTimestamp, response, requestId, responseHandler;
|
|
5965
|
+
var _this = this;
|
|
5966
|
+
return __generator(this, function (_c) {
|
|
5967
|
+
switch (_c.label) {
|
|
5898
5968
|
case 0:
|
|
5969
|
+
atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
5970
|
+
this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
|
|
5899
5971
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5900
5972
|
return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
5901
5973
|
case 1:
|
|
5902
|
-
response =
|
|
5974
|
+
response = _c.sent();
|
|
5975
|
+
requestId = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[HeaderNames.X_MS_REQUEST_ID];
|
|
5903
5976
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5904
5977
|
responseHandler.validateTokenResponse(response.body);
|
|
5905
|
-
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)
|
|
5978
|
+
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
|
|
5979
|
+
var _a;
|
|
5980
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
5981
|
+
success: true,
|
|
5982
|
+
refreshTokenSize: ((_a = response.body.refresh_token) === null || _a === void 0 ? void 0 : _a.length) || 0
|
|
5983
|
+
});
|
|
5984
|
+
return result;
|
|
5985
|
+
})
|
|
5986
|
+
.catch(function (error) {
|
|
5987
|
+
_this.logger.verbose("Error in fetching refresh token", request.correlationId);
|
|
5988
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
5989
|
+
errorCode: error.errorCode,
|
|
5990
|
+
subErrorCode: error.subError,
|
|
5991
|
+
success: false,
|
|
5992
|
+
refreshTokenSize: undefined
|
|
5993
|
+
});
|
|
5994
|
+
throw error;
|
|
5995
|
+
})];
|
|
5906
5996
|
}
|
|
5907
5997
|
});
|
|
5908
5998
|
});
|
|
@@ -5952,14 +6042,21 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5952
6042
|
* @param request
|
|
5953
6043
|
*/
|
|
5954
6044
|
RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
|
|
6045
|
+
var _a;
|
|
5955
6046
|
return __awaiter(this, void 0, void 0, function () {
|
|
5956
|
-
var refreshToken, refreshTokenRequest;
|
|
5957
|
-
return __generator(this, function (
|
|
6047
|
+
var atsMeasurement, refreshToken, refreshTokenRequest;
|
|
6048
|
+
return __generator(this, function (_b) {
|
|
6049
|
+
atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6050
|
+
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
5958
6051
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
5959
|
-
// no refresh Token
|
|
5960
6052
|
if (!refreshToken) {
|
|
6053
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
|
|
5961
6054
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
5962
6055
|
}
|
|
6056
|
+
// attach cached RT size to the current measurement
|
|
6057
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6058
|
+
success: true
|
|
6059
|
+
});
|
|
5963
6060
|
refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
|
|
5964
6061
|
credential: request.account.homeAccountId,
|
|
5965
6062
|
type: CcsCredentialType.HOME_ACCOUNT_ID
|
|
@@ -6112,7 +6209,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6112
6209
|
return RefreshTokenClient;
|
|
6113
6210
|
}(BaseClient));
|
|
6114
6211
|
|
|
6115
|
-
/*! @azure/msal-common v7.
|
|
6212
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6116
6213
|
|
|
6117
6214
|
/*
|
|
6118
6215
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6212,13 +6309,21 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
6212
6309
|
*/
|
|
6213
6310
|
SilentFlowClient.prototype.generateResultFromCacheRecord = function (cacheRecord, request) {
|
|
6214
6311
|
return __awaiter(this, void 0, void 0, function () {
|
|
6215
|
-
var idTokenObj;
|
|
6312
|
+
var idTokenObj, authTime;
|
|
6216
6313
|
return __generator(this, function (_a) {
|
|
6217
6314
|
switch (_a.label) {
|
|
6218
6315
|
case 0:
|
|
6219
6316
|
if (cacheRecord.idToken) {
|
|
6220
6317
|
idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);
|
|
6221
6318
|
}
|
|
6319
|
+
// token max_age check
|
|
6320
|
+
if (request.maxAge || (request.maxAge === 0)) {
|
|
6321
|
+
authTime = idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.auth_time;
|
|
6322
|
+
if (!authTime) {
|
|
6323
|
+
throw ClientAuthError.createAuthTimeNotFoundError();
|
|
6324
|
+
}
|
|
6325
|
+
AuthToken.checkMaxAge(authTime, request.maxAge);
|
|
6326
|
+
}
|
|
6222
6327
|
return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, cacheRecord, true, request, idTokenObj)];
|
|
6223
6328
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6224
6329
|
}
|
|
@@ -6228,7 +6333,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
6228
6333
|
return SilentFlowClient;
|
|
6229
6334
|
}(BaseClient));
|
|
6230
6335
|
|
|
6231
|
-
/*! @azure/msal-common v7.
|
|
6336
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6232
6337
|
/*
|
|
6233
6338
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6234
6339
|
* Licensed under the MIT License.
|
|
@@ -6240,7 +6345,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
6240
6345
|
response.hasOwnProperty("jwks_uri"));
|
|
6241
6346
|
}
|
|
6242
6347
|
|
|
6243
|
-
/*! @azure/msal-common v7.
|
|
6348
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6244
6349
|
/*
|
|
6245
6350
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6246
6351
|
* Licensed under the MIT License.
|
|
@@ -6249,7 +6354,7 @@ var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/
|
|
|
6249
6354
|
var EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
6250
6355
|
var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
6251
6356
|
|
|
6252
|
-
/*! @azure/msal-common v7.
|
|
6357
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6253
6358
|
/*
|
|
6254
6359
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6255
6360
|
* Licensed under the MIT License.
|
|
@@ -6263,7 +6368,7 @@ exports.ProtocolMode = void 0;
|
|
|
6263
6368
|
ProtocolMode["OIDC"] = "OIDC";
|
|
6264
6369
|
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
6265
6370
|
|
|
6266
|
-
/*! @azure/msal-common v7.
|
|
6371
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6267
6372
|
|
|
6268
6373
|
/*
|
|
6269
6374
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6340,7 +6445,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
6340
6445
|
return AuthorityMetadataEntity;
|
|
6341
6446
|
}());
|
|
6342
6447
|
|
|
6343
|
-
/*! @azure/msal-common v7.
|
|
6448
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6344
6449
|
/*
|
|
6345
6450
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6346
6451
|
* Licensed under the MIT License.
|
|
@@ -6350,7 +6455,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
6350
6455
|
response.hasOwnProperty("metadata"));
|
|
6351
6456
|
}
|
|
6352
6457
|
|
|
6353
|
-
/*! @azure/msal-common v7.
|
|
6458
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6354
6459
|
|
|
6355
6460
|
/*
|
|
6356
6461
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6472,7 +6577,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6472
6577
|
return RegionDiscovery;
|
|
6473
6578
|
}());
|
|
6474
6579
|
|
|
6475
|
-
/*! @azure/msal-common v7.
|
|
6580
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
6476
6581
|
|
|
6477
6582
|
/*
|
|
6478
6583
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6497,8 +6602,13 @@ var Authority = /** @class */ (function () {
|
|
|
6497
6602
|
// See above for AuthorityType
|
|
6498
6603
|
get: function () {
|
|
6499
6604
|
var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
6500
|
-
if (pathSegments.length
|
|
6501
|
-
|
|
6605
|
+
if (pathSegments.length) {
|
|
6606
|
+
switch (pathSegments[0].toLowerCase()) {
|
|
6607
|
+
case Constants.ADFS:
|
|
6608
|
+
return AuthorityType.Adfs;
|
|
6609
|
+
case Constants.DSTS:
|
|
6610
|
+
return AuthorityType.Dsts;
|
|
6611
|
+
}
|
|
6502
6612
|
}
|
|
6503
6613
|
return AuthorityType.Default;
|
|
6504
6614
|
},
|
|
@@ -6702,7 +6812,9 @@ var Authority = /** @class */ (function () {
|
|
|
6702
6812
|
* The default open id configuration endpoint for any canonical authority.
|
|
6703
6813
|
*/
|
|
6704
6814
|
get: function () {
|
|
6705
|
-
if (this.authorityType === AuthorityType.Adfs ||
|
|
6815
|
+
if (this.authorityType === AuthorityType.Adfs ||
|
|
6816
|
+
this.authorityType === AuthorityType.Dsts ||
|
|
6817
|
+
this.protocolMode === exports.ProtocolMode.OIDC) {
|
|
6706
6818
|
return this.canonicalAuthority + ".well-known/openid-configuration";
|
|
6707
6819
|
}
|
|
6708
6820
|
return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
|
|
@@ -6800,8 +6912,9 @@ var Authority = /** @class */ (function () {
|
|
|
6800
6912
|
});
|
|
6801
6913
|
};
|
|
6802
6914
|
/**
|
|
6803
|
-
* Compares the number of url components after the domain to determine if the cached
|
|
6804
|
-
*
|
|
6915
|
+
* Compares the number of url components after the domain to determine if the cached
|
|
6916
|
+
* authority metadata can be used for the requested authority. Protects against same domain different
|
|
6917
|
+
* authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
|
|
6805
6918
|
* @param metadataEntity
|
|
6806
6919
|
*/
|
|
6807
6920
|
Authority.prototype.isAuthoritySameType = function (metadataEntity) {
|
|
@@ -6841,7 +6954,8 @@ var Authority = /** @class */ (function () {
|
|
|
6841
6954
|
_a.label = 1;
|
|
6842
6955
|
case 1:
|
|
6843
6956
|
_a.trys.push([1, 3, , 4]);
|
|
6844
|
-
return [4 /*yield*/, this.networkInterface.
|
|
6957
|
+
return [4 /*yield*/, this.networkInterface.
|
|
6958
|
+
sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
|
|
6845
6959
|
case 2:
|
|
6846
6960
|
response = _a.sent();
|
|
6847
6961
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
@@ -6902,7 +7016,8 @@ var Authority = /** @class */ (function () {
|
|
|
6902
7016
|
});
|
|
6903
7017
|
};
|
|
6904
7018
|
/**
|
|
6905
|
-
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
|
|
7019
|
+
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
|
|
7020
|
+
* and returns where the information was retrieved from
|
|
6906
7021
|
* @param cachedMetadata
|
|
6907
7022
|
* @param newMetadata
|
|
6908
7023
|
*/
|
|
@@ -7125,7 +7240,7 @@ var Authority = /** @class */ (function () {
|
|
|
7125
7240
|
Authority.replaceWithRegionalInformation = function (metadata, azureRegion) {
|
|
7126
7241
|
metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
|
|
7127
7242
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
7128
|
-
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion,
|
|
7243
|
+
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
|
|
7129
7244
|
if (metadata.end_session_endpoint) {
|
|
7130
7245
|
metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
|
|
7131
7246
|
}
|
|
@@ -7134,7 +7249,7 @@ var Authority = /** @class */ (function () {
|
|
|
7134
7249
|
return Authority;
|
|
7135
7250
|
}());
|
|
7136
7251
|
|
|
7137
|
-
/*! @azure/msal-common v7.
|
|
7252
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7138
7253
|
|
|
7139
7254
|
/*
|
|
7140
7255
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7195,7 +7310,7 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
7195
7310
|
return AuthorityFactory;
|
|
7196
7311
|
}());
|
|
7197
7312
|
|
|
7198
|
-
/*! @azure/msal-common v7.
|
|
7313
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7199
7314
|
|
|
7200
7315
|
/*
|
|
7201
7316
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7226,7 +7341,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
|
|
|
7226
7341
|
return ServerTelemetryEntity;
|
|
7227
7342
|
}());
|
|
7228
7343
|
|
|
7229
|
-
/*! @azure/msal-common v7.
|
|
7344
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7230
7345
|
|
|
7231
7346
|
/*
|
|
7232
7347
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7254,7 +7369,7 @@ var ThrottlingEntity = /** @class */ (function () {
|
|
|
7254
7369
|
return ThrottlingEntity;
|
|
7255
7370
|
}());
|
|
7256
7371
|
|
|
7257
|
-
/*! @azure/msal-common v7.
|
|
7372
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7258
7373
|
|
|
7259
7374
|
/*
|
|
7260
7375
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7271,7 +7386,7 @@ var StubbedNetworkModule = {
|
|
|
7271
7386
|
}
|
|
7272
7387
|
};
|
|
7273
7388
|
|
|
7274
|
-
/*! @azure/msal-common v7.
|
|
7389
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7275
7390
|
|
|
7276
7391
|
/*
|
|
7277
7392
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7316,7 +7431,7 @@ var JoseHeaderError = /** @class */ (function (_super) {
|
|
|
7316
7431
|
return JoseHeaderError;
|
|
7317
7432
|
}(AuthError));
|
|
7318
7433
|
|
|
7319
|
-
/*! @azure/msal-common v7.
|
|
7434
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7320
7435
|
|
|
7321
7436
|
/*
|
|
7322
7437
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7356,7 +7471,7 @@ var JoseHeader = /** @class */ (function () {
|
|
|
7356
7471
|
return JoseHeader;
|
|
7357
7472
|
}());
|
|
7358
7473
|
|
|
7359
|
-
/*! @azure/msal-common v7.
|
|
7474
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7360
7475
|
|
|
7361
7476
|
/*
|
|
7362
7477
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7415,7 +7530,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
|
|
|
7415
7530
|
return AuthenticationHeaderParser;
|
|
7416
7531
|
}());
|
|
7417
7532
|
|
|
7418
|
-
/*! @azure/msal-common v7.
|
|
7533
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7419
7534
|
|
|
7420
7535
|
/*
|
|
7421
7536
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7577,7 +7692,7 @@ var ServerTelemetryManager = /** @class */ (function () {
|
|
|
7577
7692
|
return ServerTelemetryManager;
|
|
7578
7693
|
}());
|
|
7579
7694
|
|
|
7580
|
-
/*! @azure/msal-common v7.
|
|
7695
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7581
7696
|
|
|
7582
7697
|
/*
|
|
7583
7698
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7786,6 +7901,9 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
7786
7901
|
if (current.idTokenSize) {
|
|
7787
7902
|
previous.idTokenSize = current.idTokenSize;
|
|
7788
7903
|
}
|
|
7904
|
+
if (current.refreshTokenSize) {
|
|
7905
|
+
previous.refreshTokenSize = current.refreshTokenSize;
|
|
7906
|
+
}
|
|
7789
7907
|
}
|
|
7790
7908
|
return previous;
|
|
7791
7909
|
}, topLevelEvent);
|
|
@@ -7853,7 +7971,7 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
7853
7971
|
return PerformanceClient;
|
|
7854
7972
|
}());
|
|
7855
7973
|
|
|
7856
|
-
/*! @azure/msal-common v7.
|
|
7974
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
7857
7975
|
|
|
7858
7976
|
/*
|
|
7859
7977
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7979,7 +8097,7 @@ var BrowserAuthErrorMessage = {
|
|
|
7979
8097
|
},
|
|
7980
8098
|
silentPromptValueError: {
|
|
7981
8099
|
code: "silent_prompt_value_error",
|
|
7982
|
-
desc: "The value given for the prompt value is not valid for silent requests - must be set to 'none'."
|
|
8100
|
+
desc: "The value given for the prompt value is not valid for silent requests - must be set to 'none' or 'no_session'."
|
|
7983
8101
|
},
|
|
7984
8102
|
noTokenRequestCacheError: {
|
|
7985
8103
|
code: "no_token_request_cache_error",
|
|
@@ -8391,7 +8509,7 @@ var BrowserConstants = {
|
|
|
8391
8509
|
/**
|
|
8392
8510
|
* Default popup monitor poll interval in milliseconds
|
|
8393
8511
|
*/
|
|
8394
|
-
|
|
8512
|
+
DEFAULT_POLL_INTERVAL_MS: 30,
|
|
8395
8513
|
/**
|
|
8396
8514
|
* Msal-browser SKU
|
|
8397
8515
|
*/
|
|
@@ -8530,7 +8648,44 @@ exports.WrapperSKU = void 0;
|
|
|
8530
8648
|
// DatabaseStorage Constants
|
|
8531
8649
|
var DB_NAME = "msal.db";
|
|
8532
8650
|
var DB_VERSION = 1;
|
|
8533
|
-
var DB_TABLE_NAME = DB_NAME + ".keys";
|
|
8651
|
+
var DB_TABLE_NAME = DB_NAME + ".keys";
|
|
8652
|
+
exports.CacheLookupPolicy = void 0;
|
|
8653
|
+
(function (CacheLookupPolicy) {
|
|
8654
|
+
/*
|
|
8655
|
+
* acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired
|
|
8656
|
+
* or cannot be found the refresh token will be used to acquire a new one. Finally, if the refresh token
|
|
8657
|
+
* is expired acquireTokenSilent will attempt to acquire new access and refresh tokens.
|
|
8658
|
+
*/
|
|
8659
|
+
CacheLookupPolicy[CacheLookupPolicy["Default"] = 0] = "Default";
|
|
8660
|
+
/*
|
|
8661
|
+
* acquireTokenSilent will only look for access tokens in the cache. It will not attempt to renew access or
|
|
8662
|
+
* refresh tokens.
|
|
8663
|
+
*/
|
|
8664
|
+
CacheLookupPolicy[CacheLookupPolicy["AccessToken"] = 1] = "AccessToken";
|
|
8665
|
+
/*
|
|
8666
|
+
* acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired or
|
|
8667
|
+
* cannot be found, the refresh token will be used to acquire a new one. If the refresh token is expired, it
|
|
8668
|
+
* will not be renewed and acquireTokenSilent will fail.
|
|
8669
|
+
*/
|
|
8670
|
+
CacheLookupPolicy[CacheLookupPolicy["AccessTokenAndRefreshToken"] = 2] = "AccessTokenAndRefreshToken";
|
|
8671
|
+
/*
|
|
8672
|
+
* acquireTokenSilent will not attempt to retrieve access tokens from the cache and will instead attempt to
|
|
8673
|
+
* exchange the cached refresh token for a new access token. If the refresh token is expired, it will not be
|
|
8674
|
+
* renewed and acquireTokenSilent will fail.
|
|
8675
|
+
*/
|
|
8676
|
+
CacheLookupPolicy[CacheLookupPolicy["RefreshToken"] = 3] = "RefreshToken";
|
|
8677
|
+
/*
|
|
8678
|
+
* acquireTokenSilent will not look in the cache for the access token. It will go directly to network with the
|
|
8679
|
+
* cached refresh token. If the refresh token is expired an attempt will be made to renew it. This is equivalent to
|
|
8680
|
+
* setting "forceRefresh: true".
|
|
8681
|
+
*/
|
|
8682
|
+
CacheLookupPolicy[CacheLookupPolicy["RefreshTokenAndNetwork"] = 4] = "RefreshTokenAndNetwork";
|
|
8683
|
+
/*
|
|
8684
|
+
* acquireTokenSilent will attempt to renew both access and refresh tokens. It will not look in the cache. This will
|
|
8685
|
+
* always fail if 3rd party cookies are blocked by the browser.
|
|
8686
|
+
*/
|
|
8687
|
+
CacheLookupPolicy[CacheLookupPolicy["Skip"] = 5] = "Skip";
|
|
8688
|
+
})(exports.CacheLookupPolicy || (exports.CacheLookupPolicy = {}));
|
|
8534
8689
|
|
|
8535
8690
|
/*
|
|
8536
8691
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8569,6 +8724,10 @@ var BrowserConfigurationAuthErrorMessage = {
|
|
|
8569
8724
|
inMemRedirectUnavailable: {
|
|
8570
8725
|
code: "in_mem_redirect_unavailable",
|
|
8571
8726
|
desc: "Redirect cannot be supported. In-memory storage was selected and storeAuthStateInCookie=false, which would cause the library to be unable to handle the incoming hash. If you would like to use the redirect API, please use session/localStorage or set storeAuthStateInCookie=true."
|
|
8727
|
+
},
|
|
8728
|
+
entropyNotProvided: {
|
|
8729
|
+
code: "entropy_not_provided",
|
|
8730
|
+
desc: "The available browser crypto interface requires entropy set via system.cryptoOptions.entropy configuration option."
|
|
8572
8731
|
}
|
|
8573
8732
|
};
|
|
8574
8733
|
/**
|
|
@@ -8619,6 +8778,12 @@ var BrowserConfigurationAuthError = /** @class */ (function (_super) {
|
|
|
8619
8778
|
BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError = function () {
|
|
8620
8779
|
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.code, BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.desc);
|
|
8621
8780
|
};
|
|
8781
|
+
/**
|
|
8782
|
+
* Creates an error thrown when a crypto interface that requires entropy is initialized without entropy
|
|
8783
|
+
*/
|
|
8784
|
+
BrowserConfigurationAuthError.createEntropyNotProvided = function () {
|
|
8785
|
+
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.entropyNotProvided.code, BrowserConfigurationAuthErrorMessage.entropyNotProvided.desc);
|
|
8786
|
+
};
|
|
8622
8787
|
return BrowserConfigurationAuthError;
|
|
8623
8788
|
}(AuthError));
|
|
8624
8789
|
|
|
@@ -9681,7 +9846,7 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
|
|
|
9681
9846
|
|
|
9682
9847
|
/* eslint-disable header/header */
|
|
9683
9848
|
var name = "@azure/msal-browser";
|
|
9684
|
-
var version = "2.
|
|
9849
|
+
var version = "2.30.0";
|
|
9685
9850
|
|
|
9686
9851
|
/*
|
|
9687
9852
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11084,7 +11249,8 @@ var NativeInteractionClient = /** @class */ (function (_super) {
|
|
|
11084
11249
|
.then(function (result) {
|
|
11085
11250
|
nativeATMeasurement.endMeasurement({
|
|
11086
11251
|
success: true,
|
|
11087
|
-
isNativeBroker: true
|
|
11252
|
+
isNativeBroker: true,
|
|
11253
|
+
requestId: result.requestId
|
|
11088
11254
|
});
|
|
11089
11255
|
return result;
|
|
11090
11256
|
})
|
|
@@ -12300,7 +12466,7 @@ var PopupClient = /** @class */ (function (_super) {
|
|
|
12300
12466
|
* Polling for popups needs to be tick-based,
|
|
12301
12467
|
* since a non-trivial amount of time can be spent on interaction (which should not count against the timeout).
|
|
12302
12468
|
*/
|
|
12303
|
-
var maxTicks = _this.config.system.windowHashTimeout /
|
|
12469
|
+
var maxTicks = _this.config.system.windowHashTimeout / _this.config.system.pollIntervalMilliseconds;
|
|
12304
12470
|
var ticks = 0;
|
|
12305
12471
|
_this.logger.verbose("PopupHandler.monitorPopupForHash - polling started");
|
|
12306
12472
|
var intervalId = setInterval(function () {
|
|
@@ -12353,7 +12519,7 @@ var PopupClient = /** @class */ (function (_super) {
|
|
|
12353
12519
|
clearInterval(intervalId);
|
|
12354
12520
|
reject(BrowserAuthError.createMonitorPopupTimeoutError());
|
|
12355
12521
|
}
|
|
12356
|
-
},
|
|
12522
|
+
}, _this.config.system.pollIntervalMilliseconds);
|
|
12357
12523
|
});
|
|
12358
12524
|
};
|
|
12359
12525
|
/**
|
|
@@ -12391,7 +12557,7 @@ var PopupClient = /** @class */ (function (_super) {
|
|
|
12391
12557
|
clearInterval(intervalId);
|
|
12392
12558
|
_this.cleanPopup(popupWindow);
|
|
12393
12559
|
resolve();
|
|
12394
|
-
},
|
|
12560
|
+
}, _this.config.system.pollIntervalMilliseconds);
|
|
12395
12561
|
});
|
|
12396
12562
|
};
|
|
12397
12563
|
/**
|
|
@@ -12624,7 +12790,10 @@ function buildConfiguration(_a, isBrowserEnvironment) {
|
|
|
12624
12790
|
// Default system options for browser
|
|
12625
12791
|
var DEFAULT_BROWSER_SYSTEM_OPTIONS = __assign$1(__assign$1({}, DEFAULT_SYSTEM_OPTIONS), { loggerOptions: DEFAULT_LOGGER_OPTIONS, networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule, navigationClient: new NavigationClient(), loadFrameTimeout: 0,
|
|
12626
12792
|
// If loadFrameTimeout is provided, use that as default.
|
|
12627
|
-
windowHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS, navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0, redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS, asyncPopups: false, allowRedirectInIframe: false, allowNativeBroker: false, nativeBrokerHandshakeTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.nativeBrokerHandshakeTimeout) || DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS
|
|
12793
|
+
windowHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS, navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0, redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS, asyncPopups: false, allowRedirectInIframe: false, allowNativeBroker: false, nativeBrokerHandshakeTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.nativeBrokerHandshakeTimeout) || DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS, pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS, cryptoOptions: {
|
|
12794
|
+
useMsrCrypto: false,
|
|
12795
|
+
entropy: undefined
|
|
12796
|
+
} });
|
|
12628
12797
|
var DEFAULT_TELEMETRY_OPTIONS = {
|
|
12629
12798
|
application: {
|
|
12630
12799
|
appName: Constants.EMPTY_STRING,
|
|
@@ -12646,9 +12815,10 @@ function buildConfiguration(_a, isBrowserEnvironment) {
|
|
|
12646
12815
|
*/
|
|
12647
12816
|
var SilentHandler = /** @class */ (function (_super) {
|
|
12648
12817
|
__extends$1(SilentHandler, _super);
|
|
12649
|
-
function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger,
|
|
12818
|
+
function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions) {
|
|
12650
12819
|
var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
|
|
12651
|
-
_this.navigateFrameWait = navigateFrameWait;
|
|
12820
|
+
_this.navigateFrameWait = systemOptions.navigateFrameWait;
|
|
12821
|
+
_this.pollIntervalMilliseconds = systemOptions.pollIntervalMilliseconds;
|
|
12652
12822
|
return _this;
|
|
12653
12823
|
}
|
|
12654
12824
|
/**
|
|
@@ -12726,7 +12896,7 @@ var SilentHandler = /** @class */ (function (_super) {
|
|
|
12726
12896
|
resolve(contentHash);
|
|
12727
12897
|
return;
|
|
12728
12898
|
}
|
|
12729
|
-
},
|
|
12899
|
+
}, _this.pollIntervalMilliseconds);
|
|
12730
12900
|
});
|
|
12731
12901
|
};
|
|
12732
12902
|
/**
|
|
@@ -12805,7 +12975,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12805
12975
|
return _this;
|
|
12806
12976
|
}
|
|
12807
12977
|
/**
|
|
12808
|
-
* Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none
|
|
12978
|
+
* Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none or prompt=no_session
|
|
12809
12979
|
* @param request
|
|
12810
12980
|
*/
|
|
12811
12981
|
SilentIframeClient.prototype.acquireToken = function (request) {
|
|
@@ -12820,14 +12990,14 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12820
12990
|
if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {
|
|
12821
12991
|
this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
|
|
12822
12992
|
}
|
|
12823
|
-
// Check that prompt is set to none, throw error if it is set to anything else.
|
|
12824
|
-
if (request.prompt && request.prompt !== PromptValue.NONE) {
|
|
12993
|
+
// Check that prompt is set to none or no_session, throw error if it is set to anything else.
|
|
12994
|
+
if (request.prompt && (request.prompt !== PromptValue.NONE) && (request.prompt !== PromptValue.NO_SESSION)) {
|
|
12825
12995
|
acquireTokenMeasurement.endMeasurement({
|
|
12826
12996
|
success: false
|
|
12827
12997
|
});
|
|
12828
12998
|
throw BrowserAuthError.createSilentPromptValueError(request.prompt);
|
|
12829
12999
|
}
|
|
12830
|
-
return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent)];
|
|
13000
|
+
return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: request.prompt || PromptValue.NONE }), exports.InteractionType.Silent)];
|
|
12831
13001
|
case 1:
|
|
12832
13002
|
silentRequest = _a.sent();
|
|
12833
13003
|
this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || Constants.EMPTY_STRING, silentRequest.account || null);
|
|
@@ -12842,7 +13012,8 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12842
13012
|
return [4 /*yield*/, this.silentTokenHelper(authClient, silentRequest).then(function (result) {
|
|
12843
13013
|
acquireTokenMeasurement.endMeasurement({
|
|
12844
13014
|
success: true,
|
|
12845
|
-
fromCache: false
|
|
13015
|
+
fromCache: false,
|
|
13016
|
+
requestId: result.requestId
|
|
12846
13017
|
});
|
|
12847
13018
|
return result;
|
|
12848
13019
|
})];
|
|
@@ -12890,7 +13061,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12890
13061
|
return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, silentRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme) }))];
|
|
12891
13062
|
case 2:
|
|
12892
13063
|
navigateUrl = _a.sent();
|
|
12893
|
-
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system
|
|
13064
|
+
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
|
|
12894
13065
|
return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
|
|
12895
13066
|
case 3:
|
|
12896
13067
|
msalFrame = _a.sent();
|
|
@@ -12906,7 +13077,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12906
13077
|
}
|
|
12907
13078
|
nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.apiId, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.browserStorage, this.correlationId);
|
|
12908
13079
|
userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
|
|
12909
|
-
return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
|
|
13080
|
+
return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: silentRequest.prompt || PromptValue.NONE })).finally(function () {
|
|
12910
13081
|
_this.browserStorage.cleanRequestByState(state);
|
|
12911
13082
|
})];
|
|
12912
13083
|
}
|
|
@@ -12954,7 +13125,8 @@ var SilentRefreshClient = /** @class */ (function (_super) {
|
|
|
12954
13125
|
.then(function (result) {
|
|
12955
13126
|
acquireTokenMeasurement.endMeasurement({
|
|
12956
13127
|
success: true,
|
|
12957
|
-
fromCache: result.fromCache
|
|
13128
|
+
fromCache: result.fromCache,
|
|
13129
|
+
requestId: result.requestId
|
|
12958
13130
|
});
|
|
12959
13131
|
return result;
|
|
12960
13132
|
})
|
|
@@ -13360,6 +13532,13 @@ var BrowserStringUtils = /** @class */ (function () {
|
|
|
13360
13532
|
}
|
|
13361
13533
|
return sView;
|
|
13362
13534
|
};
|
|
13535
|
+
/**
|
|
13536
|
+
* Returns stringified jwk.
|
|
13537
|
+
* @param jwk
|
|
13538
|
+
*/
|
|
13539
|
+
BrowserStringUtils.getSortedObjectString = function (obj) {
|
|
13540
|
+
return JSON.stringify(obj, Object.keys(obj).sort());
|
|
13541
|
+
};
|
|
13363
13542
|
return BrowserStringUtils;
|
|
13364
13543
|
}());
|
|
13365
13544
|
|
|
@@ -13602,178 +13781,117 @@ var PkceGenerator = /** @class */ (function () {
|
|
|
13602
13781
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13603
13782
|
* Licensed under the MIT License.
|
|
13604
13783
|
*/
|
|
13605
|
-
/**
|
|
13606
|
-
|
|
13607
|
-
*/
|
|
13608
|
-
// RSA KeyGen Algorithm
|
|
13609
|
-
var PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
|
|
13610
|
-
// SHA-256 hashing algorithm
|
|
13611
|
-
var S256_HASH_ALG = "SHA-256";
|
|
13612
|
-
// MOD length for PoP tokens
|
|
13613
|
-
var MODULUS_LENGTH = 2048;
|
|
13614
|
-
// Public Exponent
|
|
13615
|
-
var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
|
|
13616
|
-
/**
|
|
13617
|
-
* This class implements functions used by the browser library to perform cryptography operations such as
|
|
13618
|
-
* hashing and encoding. It also has helper functions to validate the availability of specific APIs.
|
|
13619
|
-
*/
|
|
13620
|
-
var BrowserCrypto = /** @class */ (function () {
|
|
13621
|
-
function BrowserCrypto(logger) {
|
|
13622
|
-
this.logger = logger;
|
|
13623
|
-
if (!(this.hasCryptoAPI())) {
|
|
13624
|
-
throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");
|
|
13625
|
-
}
|
|
13626
|
-
this._keygenAlgorithmOptions = {
|
|
13627
|
-
name: PKCS1_V15_KEYGEN_ALG,
|
|
13628
|
-
hash: S256_HASH_ALG,
|
|
13629
|
-
modulusLength: MODULUS_LENGTH,
|
|
13630
|
-
publicExponent: PUBLIC_EXPONENT
|
|
13631
|
-
};
|
|
13784
|
+
var ModernBrowserCrypto = /** @class */ (function () {
|
|
13785
|
+
function ModernBrowserCrypto() {
|
|
13632
13786
|
}
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
BrowserCrypto.prototype.sha256Digest = function (dataString) {
|
|
13787
|
+
ModernBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
|
|
13788
|
+
return window.crypto.getRandomValues(dataBuffer);
|
|
13789
|
+
};
|
|
13790
|
+
ModernBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
|
|
13638
13791
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13639
|
-
var data;
|
|
13640
13792
|
return __generator$1(this, function (_a) {
|
|
13641
|
-
|
|
13642
|
-
return [2 /*return*/, this.hasIECrypto() ? this.getMSCryptoDigest(S256_HASH_ALG, data) : this.getSubtleCryptoDigest(S256_HASH_ALG, data)];
|
|
13793
|
+
return [2 /*return*/, window.crypto.subtle.generateKey(algorithm, extractable, keyUsages)];
|
|
13643
13794
|
});
|
|
13644
13795
|
});
|
|
13645
13796
|
};
|
|
13646
|
-
|
|
13647
|
-
* Populates buffer with cryptographically random values.
|
|
13648
|
-
* @param dataBuffer
|
|
13649
|
-
*/
|
|
13650
|
-
BrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
|
|
13651
|
-
var cryptoObj = window["msCrypto"] || window.crypto;
|
|
13652
|
-
if (!cryptoObj.getRandomValues) {
|
|
13653
|
-
throw BrowserAuthError.createCryptoNotAvailableError("getRandomValues does not exist.");
|
|
13654
|
-
}
|
|
13655
|
-
cryptoObj.getRandomValues(dataBuffer);
|
|
13656
|
-
};
|
|
13657
|
-
/**
|
|
13658
|
-
* Generates a keypair based on current keygen algorithm config.
|
|
13659
|
-
* @param extractable
|
|
13660
|
-
* @param usages
|
|
13661
|
-
*/
|
|
13662
|
-
BrowserCrypto.prototype.generateKeyPair = function (extractable, usages) {
|
|
13797
|
+
ModernBrowserCrypto.prototype.exportKey = function (key) {
|
|
13663
13798
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13664
13799
|
return __generator$1(this, function (_a) {
|
|
13665
|
-
return [2 /*return*/,
|
|
13666
|
-
this.msCryptoGenerateKey(extractable, usages)
|
|
13667
|
-
: window.crypto.subtle.generateKey(this._keygenAlgorithmOptions, extractable, usages))];
|
|
13800
|
+
return [2 /*return*/, window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
|
|
13668
13801
|
});
|
|
13669
13802
|
});
|
|
13670
13803
|
};
|
|
13671
|
-
|
|
13672
|
-
* Export key as Json Web Key (JWK)
|
|
13673
|
-
* @param key
|
|
13674
|
-
* @param format
|
|
13675
|
-
*/
|
|
13676
|
-
BrowserCrypto.prototype.exportJwk = function (key) {
|
|
13804
|
+
ModernBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
|
|
13677
13805
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13678
13806
|
return __generator$1(this, function (_a) {
|
|
13679
|
-
return [2 /*return*/,
|
|
13807
|
+
return [2 /*return*/, window.crypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages)];
|
|
13680
13808
|
});
|
|
13681
13809
|
});
|
|
13682
13810
|
};
|
|
13683
|
-
|
|
13684
|
-
* Imports key as Json Web Key (JWK), can set extractable and usages.
|
|
13685
|
-
* @param key
|
|
13686
|
-
* @param format
|
|
13687
|
-
* @param extractable
|
|
13688
|
-
* @param usages
|
|
13689
|
-
*/
|
|
13690
|
-
BrowserCrypto.prototype.importJwk = function (key, extractable, usages) {
|
|
13811
|
+
ModernBrowserCrypto.prototype.sign = function (algorithm, key, data) {
|
|
13691
13812
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13692
|
-
var keyString, keyBuffer;
|
|
13693
13813
|
return __generator$1(this, function (_a) {
|
|
13694
|
-
|
|
13695
|
-
keyBuffer = BrowserStringUtils.stringToArrayBuffer(keyString);
|
|
13696
|
-
return [2 /*return*/, this.hasIECrypto() ?
|
|
13697
|
-
this.msCryptoImportKey(keyBuffer, extractable, usages)
|
|
13698
|
-
: window.crypto.subtle.importKey(KEY_FORMAT_JWK, key, this._keygenAlgorithmOptions, extractable, usages)];
|
|
13814
|
+
return [2 /*return*/, window.crypto.subtle.sign(algorithm, key, data)];
|
|
13699
13815
|
});
|
|
13700
13816
|
});
|
|
13701
13817
|
};
|
|
13702
|
-
|
|
13703
|
-
* Signs given data with given key
|
|
13704
|
-
* @param key
|
|
13705
|
-
* @param data
|
|
13706
|
-
*/
|
|
13707
|
-
BrowserCrypto.prototype.sign = function (key, data) {
|
|
13818
|
+
ModernBrowserCrypto.prototype.digest = function (algorithm, data) {
|
|
13708
13819
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13709
13820
|
return __generator$1(this, function (_a) {
|
|
13710
|
-
return [2 /*return*/,
|
|
13711
|
-
this.msCryptoSign(key, data)
|
|
13712
|
-
: window.crypto.subtle.sign(this._keygenAlgorithmOptions, key, data)];
|
|
13821
|
+
return [2 /*return*/, window.crypto.subtle.digest(algorithm, data)];
|
|
13713
13822
|
});
|
|
13714
13823
|
});
|
|
13715
13824
|
};
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13825
|
+
return ModernBrowserCrypto;
|
|
13826
|
+
}());
|
|
13827
|
+
|
|
13828
|
+
/*
|
|
13829
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13830
|
+
* Licensed under the MIT License.
|
|
13831
|
+
*/
|
|
13832
|
+
var MsrBrowserCrypto = /** @class */ (function () {
|
|
13833
|
+
function MsrBrowserCrypto() {
|
|
13834
|
+
}
|
|
13835
|
+
MsrBrowserCrypto.prototype.initPrng = function (entropy) {
|
|
13836
|
+
// Turn into array, as initPrng seems to not always like Uint8Array (even though it should support both)
|
|
13837
|
+
return window.msrCrypto.initPrng(__spread(entropy));
|
|
13721
13838
|
};
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
*/
|
|
13725
|
-
BrowserCrypto.prototype.hasIECrypto = function () {
|
|
13726
|
-
return "msCrypto" in window;
|
|
13839
|
+
MsrBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
|
|
13840
|
+
return window.msrCrypto.getRandomValues(dataBuffer);
|
|
13727
13841
|
};
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13842
|
+
MsrBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
|
|
13843
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
13844
|
+
return __generator$1(this, function (_a) {
|
|
13845
|
+
return [2 /*return*/, window.msrCrypto.subtle.generateKey(algorithm, extractable, keyUsages)];
|
|
13846
|
+
});
|
|
13847
|
+
});
|
|
13733
13848
|
};
|
|
13734
|
-
|
|
13735
|
-
* Helper function for SHA digest.
|
|
13736
|
-
* @param algorithm
|
|
13737
|
-
* @param data
|
|
13738
|
-
*/
|
|
13739
|
-
BrowserCrypto.prototype.getSubtleCryptoDigest = function (algorithm, data) {
|
|
13849
|
+
MsrBrowserCrypto.prototype.exportKey = function (key) {
|
|
13740
13850
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13741
13851
|
return __generator$1(this, function (_a) {
|
|
13742
|
-
return [2 /*return*/, window.
|
|
13852
|
+
return [2 /*return*/, window.msrCrypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
|
|
13743
13853
|
});
|
|
13744
13854
|
});
|
|
13745
13855
|
};
|
|
13746
|
-
|
|
13747
|
-
* IE Helper function for SHA digest.
|
|
13748
|
-
* @param algorithm
|
|
13749
|
-
* @param data
|
|
13750
|
-
*/
|
|
13751
|
-
BrowserCrypto.prototype.getMSCryptoDigest = function (algorithm, data) {
|
|
13856
|
+
MsrBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
|
|
13752
13857
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13753
13858
|
return __generator$1(this, function (_a) {
|
|
13754
|
-
return [2 /*return*/,
|
|
13755
|
-
var digestOperation = window["msCrypto"].subtle.digest(algorithm, data.buffer);
|
|
13756
|
-
digestOperation.addEventListener("complete", function (e) {
|
|
13757
|
-
resolve(e.target.result);
|
|
13758
|
-
});
|
|
13759
|
-
digestOperation.addEventListener("error", function (error) {
|
|
13760
|
-
reject(error);
|
|
13761
|
-
});
|
|
13762
|
-
})];
|
|
13859
|
+
return [2 /*return*/, window.msrCrypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages)];
|
|
13763
13860
|
});
|
|
13764
13861
|
});
|
|
13765
13862
|
};
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13863
|
+
MsrBrowserCrypto.prototype.sign = function (algorithm, key, data) {
|
|
13864
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
13865
|
+
return __generator$1(this, function (_a) {
|
|
13866
|
+
return [2 /*return*/, window.msrCrypto.subtle.sign(algorithm, key, data)];
|
|
13867
|
+
});
|
|
13868
|
+
});
|
|
13869
|
+
};
|
|
13870
|
+
MsrBrowserCrypto.prototype.digest = function (algorithm, data) {
|
|
13871
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
13872
|
+
return __generator$1(this, function (_a) {
|
|
13873
|
+
return [2 /*return*/, window.msrCrypto.subtle.digest(algorithm, data)];
|
|
13874
|
+
});
|
|
13875
|
+
});
|
|
13876
|
+
};
|
|
13877
|
+
return MsrBrowserCrypto;
|
|
13878
|
+
}());
|
|
13879
|
+
|
|
13880
|
+
/*
|
|
13881
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13882
|
+
* Licensed under the MIT License.
|
|
13883
|
+
*/
|
|
13884
|
+
var MsBrowserCrypto = /** @class */ (function () {
|
|
13885
|
+
function MsBrowserCrypto() {
|
|
13886
|
+
}
|
|
13887
|
+
MsBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
|
|
13888
|
+
return window["msCrypto"].getRandomValues(dataBuffer);
|
|
13889
|
+
};
|
|
13890
|
+
MsBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
|
|
13772
13891
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13773
|
-
var _this = this;
|
|
13774
13892
|
return __generator$1(this, function (_a) {
|
|
13775
13893
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
13776
|
-
var msGenerateKey = window["msCrypto"].subtle.generateKey(
|
|
13894
|
+
var msGenerateKey = window["msCrypto"].subtle.generateKey(algorithm, extractable, keyUsages);
|
|
13777
13895
|
msGenerateKey.addEventListener("complete", function (e) {
|
|
13778
13896
|
resolve(e.target.result);
|
|
13779
13897
|
});
|
|
@@ -13784,12 +13902,7 @@ var BrowserCrypto = /** @class */ (function () {
|
|
|
13784
13902
|
});
|
|
13785
13903
|
});
|
|
13786
13904
|
};
|
|
13787
|
-
|
|
13788
|
-
* IE Helper function for exportKey
|
|
13789
|
-
* @param key
|
|
13790
|
-
* @param format
|
|
13791
|
-
*/
|
|
13792
|
-
BrowserCrypto.prototype.msCryptoExportJwk = function (key) {
|
|
13905
|
+
MsBrowserCrypto.prototype.exportKey = function (key) {
|
|
13793
13906
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13794
13907
|
return __generator$1(this, function (_a) {
|
|
13795
13908
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
@@ -13816,19 +13929,14 @@ var BrowserCrypto = /** @class */ (function () {
|
|
|
13816
13929
|
});
|
|
13817
13930
|
});
|
|
13818
13931
|
};
|
|
13819
|
-
|
|
13820
|
-
* IE Helper function for importKey
|
|
13821
|
-
* @param key
|
|
13822
|
-
* @param format
|
|
13823
|
-
* @param extractable
|
|
13824
|
-
* @param usages
|
|
13825
|
-
*/
|
|
13826
|
-
BrowserCrypto.prototype.msCryptoImportKey = function (keyBuffer, extractable, usages) {
|
|
13932
|
+
MsBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
|
|
13827
13933
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13828
|
-
var
|
|
13934
|
+
var keyString, keyBuffer;
|
|
13829
13935
|
return __generator$1(this, function (_a) {
|
|
13936
|
+
keyString = BrowserStringUtils.getSortedObjectString(keyData);
|
|
13937
|
+
keyBuffer = BrowserStringUtils.stringToArrayBuffer(keyString);
|
|
13830
13938
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
13831
|
-
var msImportKey = window["msCrypto"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer,
|
|
13939
|
+
var msImportKey = window["msCrypto"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer, algorithm, extractable, keyUsages);
|
|
13832
13940
|
msImportKey.addEventListener("complete", function (e) {
|
|
13833
13941
|
resolve(e.target.result);
|
|
13834
13942
|
});
|
|
@@ -13839,17 +13947,11 @@ var BrowserCrypto = /** @class */ (function () {
|
|
|
13839
13947
|
});
|
|
13840
13948
|
});
|
|
13841
13949
|
};
|
|
13842
|
-
|
|
13843
|
-
* IE Helper function for sign JWT
|
|
13844
|
-
* @param key
|
|
13845
|
-
* @param data
|
|
13846
|
-
*/
|
|
13847
|
-
BrowserCrypto.prototype.msCryptoSign = function (key, data) {
|
|
13950
|
+
MsBrowserCrypto.prototype.sign = function (algorithm, key, data) {
|
|
13848
13951
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13849
|
-
var _this = this;
|
|
13850
13952
|
return __generator$1(this, function (_a) {
|
|
13851
13953
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
13852
|
-
var msSign = window["msCrypto"].subtle.sign(
|
|
13954
|
+
var msSign = window["msCrypto"].subtle.sign(algorithm, key, data);
|
|
13853
13955
|
msSign.addEventListener("complete", function (e) {
|
|
13854
13956
|
resolve(e.target.result);
|
|
13855
13957
|
});
|
|
@@ -13860,12 +13962,175 @@ var BrowserCrypto = /** @class */ (function () {
|
|
|
13860
13962
|
});
|
|
13861
13963
|
});
|
|
13862
13964
|
};
|
|
13965
|
+
MsBrowserCrypto.prototype.digest = function (algorithm, data) {
|
|
13966
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
13967
|
+
return __generator$1(this, function (_a) {
|
|
13968
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
13969
|
+
var digestOperation = window["msCrypto"].subtle.digest(algorithm, data.buffer);
|
|
13970
|
+
digestOperation.addEventListener("complete", function (e) {
|
|
13971
|
+
resolve(e.target.result);
|
|
13972
|
+
});
|
|
13973
|
+
digestOperation.addEventListener("error", function (error) {
|
|
13974
|
+
reject(error);
|
|
13975
|
+
});
|
|
13976
|
+
})];
|
|
13977
|
+
});
|
|
13978
|
+
});
|
|
13979
|
+
};
|
|
13980
|
+
return MsBrowserCrypto;
|
|
13981
|
+
}());
|
|
13982
|
+
|
|
13983
|
+
/*
|
|
13984
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13985
|
+
* Licensed under the MIT License.
|
|
13986
|
+
*/
|
|
13987
|
+
/**
|
|
13988
|
+
* See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
|
|
13989
|
+
*/
|
|
13990
|
+
// RSA KeyGen Algorithm
|
|
13991
|
+
var PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
|
|
13992
|
+
// SHA-256 hashing algorithm
|
|
13993
|
+
var S256_HASH_ALG = "SHA-256";
|
|
13994
|
+
// MOD length for PoP tokens
|
|
13995
|
+
var MODULUS_LENGTH = 2048;
|
|
13996
|
+
// Public Exponent
|
|
13997
|
+
var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
|
|
13998
|
+
/**
|
|
13999
|
+
* This class implements functions used by the browser library to perform cryptography operations such as
|
|
14000
|
+
* hashing and encoding. It also has helper functions to validate the availability of specific APIs.
|
|
14001
|
+
*/
|
|
14002
|
+
var BrowserCrypto = /** @class */ (function () {
|
|
14003
|
+
function BrowserCrypto(logger, cryptoOptions) {
|
|
14004
|
+
var _a, _b;
|
|
14005
|
+
this.logger = logger;
|
|
14006
|
+
this.cryptoOptions = cryptoOptions;
|
|
14007
|
+
if (this.hasBrowserCrypto()) {
|
|
14008
|
+
// Use standard modern web crypto if available
|
|
14009
|
+
this.logger.verbose("BrowserCrypto: modern crypto interface available");
|
|
14010
|
+
this.subtleCrypto = new ModernBrowserCrypto();
|
|
14011
|
+
}
|
|
14012
|
+
else if (this.hasIECrypto()) {
|
|
14013
|
+
// For IE11, use msCrypto interface
|
|
14014
|
+
this.logger.verbose("BrowserCrypto: MS crypto interface available");
|
|
14015
|
+
this.subtleCrypto = new MsBrowserCrypto();
|
|
14016
|
+
}
|
|
14017
|
+
else if (this.hasMsrCrypto() && ((_a = this.cryptoOptions) === null || _a === void 0 ? void 0 : _a.useMsrCrypto)) {
|
|
14018
|
+
// For other browsers, use MSR Crypto if found
|
|
14019
|
+
this.logger.verbose("BrowserCrypto: MSR crypto interface available");
|
|
14020
|
+
this.subtleCrypto = new MsrBrowserCrypto();
|
|
14021
|
+
}
|
|
14022
|
+
else {
|
|
14023
|
+
if (this.hasMsrCrypto()) {
|
|
14024
|
+
this.logger.info("BrowserCrypto: MSR Crypto interface available but system.cryptoOptions.useMsrCrypto not enabled");
|
|
14025
|
+
}
|
|
14026
|
+
this.logger.error("BrowserCrypto: No crypto interfaces available.");
|
|
14027
|
+
throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto, msCrypto, or msrCrypto interfaces not available.");
|
|
14028
|
+
}
|
|
14029
|
+
// Mainly needed for MSR Crypto: https://github.com/microsoft/MSR-JavaScript-Crypto#random-number-generator-prng
|
|
14030
|
+
if (this.subtleCrypto.initPrng) {
|
|
14031
|
+
this.logger.verbose("BrowserCrypto: Interface requires entropy");
|
|
14032
|
+
if (!((_b = this.cryptoOptions) === null || _b === void 0 ? void 0 : _b.entropy)) {
|
|
14033
|
+
this.logger.error("BrowserCrypto: Interface requires entropy but none provided.");
|
|
14034
|
+
throw BrowserConfigurationAuthError.createEntropyNotProvided();
|
|
14035
|
+
}
|
|
14036
|
+
this.logger.verbose("BrowserCrypto: Entropy provided");
|
|
14037
|
+
this.subtleCrypto.initPrng(this.cryptoOptions.entropy);
|
|
14038
|
+
}
|
|
14039
|
+
this.keygenAlgorithmOptions = {
|
|
14040
|
+
name: PKCS1_V15_KEYGEN_ALG,
|
|
14041
|
+
hash: S256_HASH_ALG,
|
|
14042
|
+
modulusLength: MODULUS_LENGTH,
|
|
14043
|
+
publicExponent: PUBLIC_EXPONENT
|
|
14044
|
+
};
|
|
14045
|
+
}
|
|
13863
14046
|
/**
|
|
13864
|
-
*
|
|
13865
|
-
|
|
14047
|
+
* Check whether IE crypto or other browser cryptography is available.
|
|
14048
|
+
*/
|
|
14049
|
+
BrowserCrypto.prototype.hasIECrypto = function () {
|
|
14050
|
+
return "msCrypto" in window;
|
|
14051
|
+
};
|
|
14052
|
+
/**
|
|
14053
|
+
* Check whether browser crypto is available.
|
|
14054
|
+
*/
|
|
14055
|
+
BrowserCrypto.prototype.hasBrowserCrypto = function () {
|
|
14056
|
+
return "crypto" in window;
|
|
14057
|
+
};
|
|
14058
|
+
/**
|
|
14059
|
+
* Check whether MSR crypto polyfill is available
|
|
14060
|
+
*/
|
|
14061
|
+
BrowserCrypto.prototype.hasMsrCrypto = function () {
|
|
14062
|
+
return "msrCrypto" in window;
|
|
14063
|
+
};
|
|
14064
|
+
/**
|
|
14065
|
+
* Returns a sha-256 hash of the given dataString as an ArrayBuffer.
|
|
14066
|
+
* @param dataString
|
|
14067
|
+
*/
|
|
14068
|
+
BrowserCrypto.prototype.sha256Digest = function (dataString) {
|
|
14069
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14070
|
+
var data;
|
|
14071
|
+
return __generator$1(this, function (_a) {
|
|
14072
|
+
data = BrowserStringUtils.stringToUtf8Arr(dataString);
|
|
14073
|
+
// MSR Crypto wants object with name property, instead of string
|
|
14074
|
+
return [2 /*return*/, this.subtleCrypto.digest({ name: S256_HASH_ALG }, data)];
|
|
14075
|
+
});
|
|
14076
|
+
});
|
|
14077
|
+
};
|
|
14078
|
+
/**
|
|
14079
|
+
* Populates buffer with cryptographically random values.
|
|
14080
|
+
* @param dataBuffer
|
|
14081
|
+
*/
|
|
14082
|
+
BrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
|
|
14083
|
+
return this.subtleCrypto.getRandomValues(dataBuffer);
|
|
14084
|
+
};
|
|
14085
|
+
/**
|
|
14086
|
+
* Generates a keypair based on current keygen algorithm config.
|
|
14087
|
+
* @param extractable
|
|
14088
|
+
* @param usages
|
|
14089
|
+
*/
|
|
14090
|
+
BrowserCrypto.prototype.generateKeyPair = function (extractable, usages) {
|
|
14091
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14092
|
+
return __generator$1(this, function (_a) {
|
|
14093
|
+
return [2 /*return*/, this.subtleCrypto.generateKey(this.keygenAlgorithmOptions, extractable, usages)];
|
|
14094
|
+
});
|
|
14095
|
+
});
|
|
14096
|
+
};
|
|
14097
|
+
/**
|
|
14098
|
+
* Export key as Json Web Key (JWK)
|
|
14099
|
+
* @param key
|
|
14100
|
+
* @param format
|
|
14101
|
+
*/
|
|
14102
|
+
BrowserCrypto.prototype.exportJwk = function (key) {
|
|
14103
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14104
|
+
return __generator$1(this, function (_a) {
|
|
14105
|
+
return [2 /*return*/, this.subtleCrypto.exportKey(key)];
|
|
14106
|
+
});
|
|
14107
|
+
});
|
|
14108
|
+
};
|
|
14109
|
+
/**
|
|
14110
|
+
* Imports key as Json Web Key (JWK), can set extractable and usages.
|
|
14111
|
+
* @param key
|
|
14112
|
+
* @param format
|
|
14113
|
+
* @param extractable
|
|
14114
|
+
* @param usages
|
|
14115
|
+
*/
|
|
14116
|
+
BrowserCrypto.prototype.importJwk = function (key, extractable, usages) {
|
|
14117
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14118
|
+
return __generator$1(this, function (_a) {
|
|
14119
|
+
return [2 /*return*/, this.subtleCrypto.importKey(key, this.keygenAlgorithmOptions, extractable, usages)];
|
|
14120
|
+
});
|
|
14121
|
+
});
|
|
14122
|
+
};
|
|
14123
|
+
/**
|
|
14124
|
+
* Signs given data with given key
|
|
14125
|
+
* @param key
|
|
14126
|
+
* @param data
|
|
13866
14127
|
*/
|
|
13867
|
-
BrowserCrypto.
|
|
13868
|
-
return
|
|
14128
|
+
BrowserCrypto.prototype.sign = function (key, data) {
|
|
14129
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14130
|
+
return __generator$1(this, function (_a) {
|
|
14131
|
+
return [2 /*return*/, this.subtleCrypto.sign(this.keygenAlgorithmOptions, key, data)];
|
|
14132
|
+
});
|
|
14133
|
+
});
|
|
13869
14134
|
};
|
|
13870
14135
|
return BrowserCrypto;
|
|
13871
14136
|
}());
|
|
@@ -14385,10 +14650,10 @@ var CryptoKeyStore = /** @class */ (function () {
|
|
|
14385
14650
|
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
|
|
14386
14651
|
*/
|
|
14387
14652
|
var CryptoOps = /** @class */ (function () {
|
|
14388
|
-
function CryptoOps(logger, performanceClient) {
|
|
14653
|
+
function CryptoOps(logger, performanceClient, cryptoConfig) {
|
|
14389
14654
|
this.logger = logger;
|
|
14390
14655
|
// Browser crypto needs to be validated first before any other classes can be set.
|
|
14391
|
-
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
14656
|
+
this.browserCrypto = new BrowserCrypto(this.logger, cryptoConfig);
|
|
14392
14657
|
this.b64Encode = new Base64Encode();
|
|
14393
14658
|
this.b64Decode = new Base64Decode();
|
|
14394
14659
|
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
@@ -14450,7 +14715,7 @@ var CryptoOps = /** @class */ (function () {
|
|
|
14450
14715
|
kty: publicKeyJwk.kty,
|
|
14451
14716
|
n: publicKeyJwk.n
|
|
14452
14717
|
};
|
|
14453
|
-
publicJwkString =
|
|
14718
|
+
publicJwkString = BrowserStringUtils.getSortedObjectString(pubKeyThumprintObj);
|
|
14454
14719
|
return [4 /*yield*/, this.hashString(publicJwkString)];
|
|
14455
14720
|
case 3:
|
|
14456
14721
|
publicJwkHash = _b.sent();
|
|
@@ -14535,7 +14800,7 @@ var CryptoOps = /** @class */ (function () {
|
|
|
14535
14800
|
return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
|
|
14536
14801
|
case 2:
|
|
14537
14802
|
publicKeyJwk = _b.sent();
|
|
14538
|
-
publicKeyJwkString =
|
|
14803
|
+
publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
|
|
14539
14804
|
encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
|
|
14540
14805
|
shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
|
|
14541
14806
|
encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
|
|
@@ -14605,15 +14870,19 @@ var TokenCache = /** @class */ (function () {
|
|
|
14605
14870
|
* @param request
|
|
14606
14871
|
* @param response
|
|
14607
14872
|
* @param options
|
|
14873
|
+
* @returns `AuthenticationResult` for the response that was loaded.
|
|
14608
14874
|
*/
|
|
14609
14875
|
TokenCache.prototype.loadExternalTokens = function (request, response, options) {
|
|
14610
14876
|
this.logger.info("TokenCache - loadExternalTokens called");
|
|
14611
14877
|
if (!response.id_token) {
|
|
14612
14878
|
throw BrowserAuthError.createUnableToLoadTokenError("Please ensure server response includes id token.");
|
|
14613
14879
|
}
|
|
14880
|
+
var idToken = new AuthToken(response.id_token, this.cryptoObj);
|
|
14881
|
+
var cacheRecord;
|
|
14882
|
+
var authority;
|
|
14614
14883
|
if (request.account) {
|
|
14615
|
-
this.
|
|
14616
|
-
this.loadAccessToken(request, response,
|
|
14884
|
+
var cacheRecordAccount = this.loadAccount(idToken, request.account.environment, undefined, undefined, request.account.homeAccountId);
|
|
14885
|
+
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment));
|
|
14617
14886
|
}
|
|
14618
14887
|
else if (request.authority) {
|
|
14619
14888
|
var authorityUrl = Authority.generateAuthority(request.authority, request.azureCloudOptions);
|
|
@@ -14624,17 +14893,17 @@ var TokenCache = /** @class */ (function () {
|
|
|
14624
14893
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
14625
14894
|
skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
|
|
14626
14895
|
};
|
|
14627
|
-
|
|
14896
|
+
authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
|
|
14628
14897
|
// "clientInfo" from options takes precedence over "clientInfo" in response
|
|
14629
14898
|
if (options.clientInfo) {
|
|
14630
14899
|
this.logger.trace("TokenCache - homeAccountId from options");
|
|
14631
|
-
this.
|
|
14632
|
-
this.loadAccessToken(request, response,
|
|
14900
|
+
var cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, options.clientInfo, authority.authorityType);
|
|
14901
|
+
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
|
|
14633
14902
|
}
|
|
14634
14903
|
else if (response.client_info) {
|
|
14635
14904
|
this.logger.trace("TokenCache - homeAccountId from response");
|
|
14636
|
-
this.
|
|
14637
|
-
this.loadAccessToken(request, response,
|
|
14905
|
+
var cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, response.client_info, authority.authorityType);
|
|
14906
|
+
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
|
|
14638
14907
|
}
|
|
14639
14908
|
else {
|
|
14640
14909
|
throw BrowserAuthError.createUnableToLoadTokenError("Please provide clientInfo in the response or options.");
|
|
@@ -14643,6 +14912,39 @@ var TokenCache = /** @class */ (function () {
|
|
|
14643
14912
|
else {
|
|
14644
14913
|
throw BrowserAuthError.createUnableToLoadTokenError("Please provide a request with an account or a request with authority.");
|
|
14645
14914
|
}
|
|
14915
|
+
return this.generateAuthenticationResult(request, idToken, cacheRecord, authority);
|
|
14916
|
+
};
|
|
14917
|
+
/**
|
|
14918
|
+
* Helper function to load account to msal-browser cache
|
|
14919
|
+
* @param idToken
|
|
14920
|
+
* @param environment
|
|
14921
|
+
* @param clientInfo
|
|
14922
|
+
* @param authorityType
|
|
14923
|
+
* @param requestHomeAccountId
|
|
14924
|
+
* @returns `AccountEntity`
|
|
14925
|
+
*/
|
|
14926
|
+
TokenCache.prototype.loadAccount = function (idToken, environment, clientInfo, authorityType, requestHomeAccountId) {
|
|
14927
|
+
var homeAccountId;
|
|
14928
|
+
if (requestHomeAccountId) {
|
|
14929
|
+
homeAccountId = requestHomeAccountId;
|
|
14930
|
+
}
|
|
14931
|
+
else if (authorityType !== undefined && clientInfo) {
|
|
14932
|
+
homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authorityType, this.logger, this.cryptoObj, idToken);
|
|
14933
|
+
}
|
|
14934
|
+
if (!homeAccountId) {
|
|
14935
|
+
throw BrowserAuthError.createUnableToLoadTokenError("Unexpected missing homeAccountId");
|
|
14936
|
+
}
|
|
14937
|
+
var accountEntity = clientInfo ?
|
|
14938
|
+
AccountEntity.createAccount(clientInfo, homeAccountId, idToken, undefined, undefined, undefined, environment) :
|
|
14939
|
+
AccountEntity.createGenericAccount(homeAccountId, idToken, undefined, undefined, undefined, environment);
|
|
14940
|
+
if (this.isBrowserEnvironment) {
|
|
14941
|
+
this.logger.verbose("TokenCache - loading account");
|
|
14942
|
+
this.storage.setAccount(accountEntity);
|
|
14943
|
+
return accountEntity;
|
|
14944
|
+
}
|
|
14945
|
+
else {
|
|
14946
|
+
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
|
|
14947
|
+
}
|
|
14646
14948
|
};
|
|
14647
14949
|
/**
|
|
14648
14950
|
* Helper function to load id tokens to msal-browser cache
|
|
@@ -14650,18 +14952,14 @@ var TokenCache = /** @class */ (function () {
|
|
|
14650
14952
|
* @param homeAccountId
|
|
14651
14953
|
* @param environment
|
|
14652
14954
|
* @param tenantId
|
|
14653
|
-
* @
|
|
14955
|
+
* @returns `IdTokenEntity`
|
|
14654
14956
|
*/
|
|
14655
|
-
TokenCache.prototype.loadIdToken = function (idToken, homeAccountId, environment, tenantId
|
|
14656
|
-
var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken, this.config.auth.clientId, tenantId);
|
|
14657
|
-
var idAuthToken = new AuthToken(idToken, this.cryptoObj);
|
|
14658
|
-
var accountEntity = options.clientInfo ?
|
|
14659
|
-
AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, environment) :
|
|
14660
|
-
AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, environment);
|
|
14957
|
+
TokenCache.prototype.loadIdToken = function (idToken, homeAccountId, environment, tenantId) {
|
|
14958
|
+
var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken.rawToken, this.config.auth.clientId, tenantId);
|
|
14661
14959
|
if (this.isBrowserEnvironment) {
|
|
14662
14960
|
this.logger.verbose("TokenCache - loading id token");
|
|
14663
|
-
this.storage.setAccount(accountEntity);
|
|
14664
14961
|
this.storage.setIdTokenCredential(idTokenEntity);
|
|
14962
|
+
return idTokenEntity;
|
|
14665
14963
|
}
|
|
14666
14964
|
else {
|
|
14667
14965
|
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
|
|
@@ -14671,16 +14969,15 @@ var TokenCache = /** @class */ (function () {
|
|
|
14671
14969
|
* Helper function to load access tokens to msal-browser cache
|
|
14672
14970
|
* @param request
|
|
14673
14971
|
* @param response
|
|
14674
|
-
* @param options
|
|
14675
14972
|
* @param homeAccountId
|
|
14676
14973
|
* @param environment
|
|
14677
14974
|
* @param tenantId
|
|
14678
|
-
* @returns
|
|
14975
|
+
* @returns `AccessTokenEntity`
|
|
14679
14976
|
*/
|
|
14680
14977
|
TokenCache.prototype.loadAccessToken = function (request, response, homeAccountId, environment, tenantId, options) {
|
|
14681
14978
|
if (!response.access_token) {
|
|
14682
14979
|
this.logger.verbose("TokenCache - No access token provided for caching");
|
|
14683
|
-
return;
|
|
14980
|
+
return null;
|
|
14684
14981
|
}
|
|
14685
14982
|
if (!response.expires_in) {
|
|
14686
14983
|
throw BrowserAuthError.createUnableToLoadTokenError("Please ensure server response includes expires_in value.");
|
|
@@ -14695,11 +14992,80 @@ var TokenCache = /** @class */ (function () {
|
|
|
14695
14992
|
if (this.isBrowserEnvironment) {
|
|
14696
14993
|
this.logger.verbose("TokenCache - loading access token");
|
|
14697
14994
|
this.storage.setAccessTokenCredential(accessTokenEntity);
|
|
14995
|
+
return accessTokenEntity;
|
|
14698
14996
|
}
|
|
14699
14997
|
else {
|
|
14700
14998
|
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
|
|
14701
14999
|
}
|
|
14702
15000
|
};
|
|
15001
|
+
/**
|
|
15002
|
+
* Helper function to load refresh tokens to msal-browser cache
|
|
15003
|
+
* @param request
|
|
15004
|
+
* @param response
|
|
15005
|
+
* @param homeAccountId
|
|
15006
|
+
* @param environment
|
|
15007
|
+
* @returns `RefreshTokenEntity`
|
|
15008
|
+
*/
|
|
15009
|
+
TokenCache.prototype.loadRefreshToken = function (request, response, homeAccountId, environment) {
|
|
15010
|
+
if (!response.refresh_token) {
|
|
15011
|
+
this.logger.verbose("TokenCache - No refresh token provided for caching");
|
|
15012
|
+
return null;
|
|
15013
|
+
}
|
|
15014
|
+
var refreshTokenEntity = RefreshTokenEntity.createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId);
|
|
15015
|
+
if (this.isBrowserEnvironment) {
|
|
15016
|
+
this.logger.verbose("TokenCache - loading refresh token");
|
|
15017
|
+
this.storage.setRefreshTokenCredential(refreshTokenEntity);
|
|
15018
|
+
return refreshTokenEntity;
|
|
15019
|
+
}
|
|
15020
|
+
else {
|
|
15021
|
+
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
|
|
15022
|
+
}
|
|
15023
|
+
};
|
|
15024
|
+
/**
|
|
15025
|
+
* Helper function to generate an `AuthenticationResult` for the result.
|
|
15026
|
+
* @param request
|
|
15027
|
+
* @param idTokenObj
|
|
15028
|
+
* @param cacheRecord
|
|
15029
|
+
* @param authority
|
|
15030
|
+
* @returns `AuthenticationResult`
|
|
15031
|
+
*/
|
|
15032
|
+
TokenCache.prototype.generateAuthenticationResult = function (request, idTokenObj, cacheRecord, authority) {
|
|
15033
|
+
var _a, _b, _c;
|
|
15034
|
+
var accessToken = Constants.EMPTY_STRING;
|
|
15035
|
+
var responseScopes = [];
|
|
15036
|
+
var expiresOn = null;
|
|
15037
|
+
var extExpiresOn;
|
|
15038
|
+
if (cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.accessToken) {
|
|
15039
|
+
accessToken = cacheRecord.accessToken.secret;
|
|
15040
|
+
responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
|
|
15041
|
+
expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
|
|
15042
|
+
extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
|
|
15043
|
+
}
|
|
15044
|
+
var uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
|
|
15045
|
+
var tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
|
|
15046
|
+
return {
|
|
15047
|
+
authority: authority ? authority.canonicalAuthority : Constants.EMPTY_STRING,
|
|
15048
|
+
uniqueId: uid,
|
|
15049
|
+
tenantId: tid,
|
|
15050
|
+
scopes: responseScopes,
|
|
15051
|
+
account: (cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) ? cacheRecord.account.getAccountInfo() : null,
|
|
15052
|
+
idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,
|
|
15053
|
+
idTokenClaims: idTokenObj ? idTokenObj.claims : {},
|
|
15054
|
+
accessToken: accessToken,
|
|
15055
|
+
fromCache: true,
|
|
15056
|
+
expiresOn: expiresOn,
|
|
15057
|
+
correlationId: request.correlationId || Constants.EMPTY_STRING,
|
|
15058
|
+
requestId: Constants.EMPTY_STRING,
|
|
15059
|
+
extExpiresOn: extExpiresOn,
|
|
15060
|
+
familyId: Constants.EMPTY_STRING,
|
|
15061
|
+
tokenType: ((_a = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
15062
|
+
state: Constants.EMPTY_STRING,
|
|
15063
|
+
cloudGraphHostName: ((_b = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
15064
|
+
msGraphHost: ((_c = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
15065
|
+
code: undefined,
|
|
15066
|
+
fromNativeBroker: false
|
|
15067
|
+
};
|
|
15068
|
+
};
|
|
14703
15069
|
return TokenCache;
|
|
14704
15070
|
}());
|
|
14705
15071
|
|
|
@@ -14757,7 +15123,7 @@ var SilentAuthCodeClient = /** @class */ (function (_super) {
|
|
|
14757
15123
|
clientConfig = _a.sent();
|
|
14758
15124
|
authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
|
|
14759
15125
|
this.logger.verbose("Auth code client created");
|
|
14760
|
-
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system
|
|
15126
|
+
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
|
|
14761
15127
|
// Handle auth code parameters from request
|
|
14762
15128
|
return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
|
|
14763
15129
|
code: request.code,
|
|
@@ -14856,9 +15222,9 @@ var BrowserPerformanceMeasurement = /** @class */ (function () {
|
|
|
14856
15222
|
*/
|
|
14857
15223
|
var BrowserPerformanceClient = /** @class */ (function (_super) {
|
|
14858
15224
|
__extends$1(BrowserPerformanceClient, _super);
|
|
14859
|
-
function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
15225
|
+
function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
|
|
14860
15226
|
var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
|
|
14861
|
-
_this.browserCrypto = new BrowserCrypto(_this.logger);
|
|
15227
|
+
_this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
|
|
14862
15228
|
_this.guidGenerator = new GuidGenerator(_this.browserCrypto);
|
|
14863
15229
|
return _this;
|
|
14864
15230
|
}
|
|
@@ -14940,10 +15306,10 @@ var ClientApplication = /** @class */ (function () {
|
|
|
14940
15306
|
this.hybridAuthCodeResponses = new Map();
|
|
14941
15307
|
// Initialize performance client
|
|
14942
15308
|
this.performanceClient = this.isBrowserEnvironment ?
|
|
14943
|
-
new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application) :
|
|
15309
|
+
new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application, this.config.system.cryptoOptions) :
|
|
14944
15310
|
new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
|
|
14945
15311
|
// Initialize the crypto class.
|
|
14946
|
-
this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient) : DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
15312
|
+
this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient, this.config.system.cryptoOptions) : DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
14947
15313
|
this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
|
|
14948
15314
|
// Initialize the browser storage class.
|
|
14949
15315
|
this.browserStorage = this.isBrowserEnvironment ?
|
|
@@ -15165,6 +15531,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
15165
15531
|
isNativeBroker: true,
|
|
15166
15532
|
accessTokenSize: response.accessToken.length,
|
|
15167
15533
|
idTokenSize: response.idToken.length,
|
|
15534
|
+
requestId: response.requestId
|
|
15168
15535
|
});
|
|
15169
15536
|
atPopupMeasurement.flushMeasurement();
|
|
15170
15537
|
return response;
|
|
@@ -15202,6 +15569,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
15202
15569
|
success: true,
|
|
15203
15570
|
accessTokenSize: result.accessToken.length,
|
|
15204
15571
|
idTokenSize: result.idToken.length,
|
|
15572
|
+
requestId: result.requestId
|
|
15205
15573
|
});
|
|
15206
15574
|
atPopupMeasurement.flushMeasurement();
|
|
15207
15575
|
return result;
|
|
@@ -15245,7 +15613,9 @@ var ClientApplication = /** @class */ (function () {
|
|
|
15245
15613
|
var _this = this;
|
|
15246
15614
|
return __generator$1(this, function (_a) {
|
|
15247
15615
|
correlationId = this.getRequestCorrelationId(request);
|
|
15248
|
-
validRequest = __assign$1(__assign$1({}, request), {
|
|
15616
|
+
validRequest = __assign$1(__assign$1({}, request), {
|
|
15617
|
+
// will be PromptValue.NONE or PromptValue.NO_SESSION
|
|
15618
|
+
prompt: request.prompt, correlationId: correlationId });
|
|
15249
15619
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
|
|
15250
15620
|
ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
|
|
15251
15621
|
this.logger.verbose("ssoSilent called", correlationId);
|
|
@@ -15271,7 +15641,8 @@ var ClientApplication = /** @class */ (function () {
|
|
|
15271
15641
|
success: true,
|
|
15272
15642
|
isNativeBroker: response.fromNativeBroker,
|
|
15273
15643
|
accessTokenSize: response.accessToken.length,
|
|
15274
|
-
idTokenSize: response.idToken.length
|
|
15644
|
+
idTokenSize: response.idToken.length,
|
|
15645
|
+
requestId: response.requestId
|
|
15275
15646
|
});
|
|
15276
15647
|
ssoSilentMeasurement.flushMeasurement();
|
|
15277
15648
|
return response;
|
|
@@ -15322,7 +15693,8 @@ var ClientApplication = /** @class */ (function () {
|
|
|
15322
15693
|
success: true,
|
|
15323
15694
|
accessTokenSize: result.accessToken.length,
|
|
15324
15695
|
idTokenSize: result.idToken.length,
|
|
15325
|
-
isNativeBroker: result.fromNativeBroker
|
|
15696
|
+
isNativeBroker: result.fromNativeBroker,
|
|
15697
|
+
requestId: result.requestId
|
|
15326
15698
|
});
|
|
15327
15699
|
atbcMeasurement.flushMeasurement();
|
|
15328
15700
|
return result;
|
|
@@ -15402,67 +15774,62 @@ var ClientApplication = /** @class */ (function () {
|
|
|
15402
15774
|
});
|
|
15403
15775
|
};
|
|
15404
15776
|
/**
|
|
15405
|
-
*
|
|
15406
|
-
*
|
|
15407
|
-
*
|
|
15408
|
-
*
|
|
15409
|
-
*
|
|
15410
|
-
* @param {@link SilentRequest}
|
|
15411
|
-
*
|
|
15412
|
-
* To renew idToken, please pass clientId as the only scope in the Authentication Parameters
|
|
15413
|
-
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
|
|
15777
|
+
* Attempt to acquire an access token from the cache
|
|
15778
|
+
* @param silentCacheClient SilentCacheClient
|
|
15779
|
+
* @param commonRequest CommonSilentFlowRequest
|
|
15780
|
+
* @param silentRequest SilentRequest
|
|
15781
|
+
* @returns A promise that, when resolved, returns the access token
|
|
15414
15782
|
*/
|
|
15415
|
-
ClientApplication.prototype.
|
|
15783
|
+
ClientApplication.prototype.acquireTokenFromCache = function (silentCacheClient, commonRequest, silentRequest) {
|
|
15416
15784
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
15417
|
-
var atbrtMeasurement, silentRefreshClient;
|
|
15418
|
-
var _this = this;
|
|
15419
15785
|
return __generator$1(this, function (_a) {
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
.
|
|
15427
|
-
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
|
|
15461
|
-
|
|
15462
|
-
|
|
15463
|
-
|
|
15464
|
-
|
|
15465
|
-
|
|
15786
|
+
switch (silentRequest.cacheLookupPolicy) {
|
|
15787
|
+
case exports.CacheLookupPolicy.Default:
|
|
15788
|
+
case exports.CacheLookupPolicy.AccessToken:
|
|
15789
|
+
case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
|
|
15790
|
+
return [2 /*return*/, silentCacheClient.acquireToken(commonRequest)];
|
|
15791
|
+
default:
|
|
15792
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
15793
|
+
}
|
|
15794
|
+
return [2 /*return*/];
|
|
15795
|
+
});
|
|
15796
|
+
});
|
|
15797
|
+
};
|
|
15798
|
+
/**
|
|
15799
|
+
* Attempt to acquire an access token via a refresh token
|
|
15800
|
+
* @param commonRequest CommonSilentFlowRequest
|
|
15801
|
+
* @param silentRequest SilentRequest
|
|
15802
|
+
* @returns A promise that, when resolved, returns the access token
|
|
15803
|
+
*/
|
|
15804
|
+
ClientApplication.prototype.acquireTokenByRefreshToken = function (commonRequest, silentRequest) {
|
|
15805
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
15806
|
+
var silentRefreshClient;
|
|
15807
|
+
return __generator$1(this, function (_a) {
|
|
15808
|
+
switch (silentRequest.cacheLookupPolicy) {
|
|
15809
|
+
case exports.CacheLookupPolicy.Default:
|
|
15810
|
+
case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
|
|
15811
|
+
case exports.CacheLookupPolicy.RefreshToken:
|
|
15812
|
+
case exports.CacheLookupPolicy.RefreshTokenAndNetwork:
|
|
15813
|
+
silentRefreshClient = this.createSilentRefreshClient(commonRequest.correlationId);
|
|
15814
|
+
return [2 /*return*/, silentRefreshClient.acquireToken(commonRequest)];
|
|
15815
|
+
default:
|
|
15816
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
15817
|
+
}
|
|
15818
|
+
return [2 /*return*/];
|
|
15819
|
+
});
|
|
15820
|
+
});
|
|
15821
|
+
};
|
|
15822
|
+
/**
|
|
15823
|
+
* Attempt to acquire an access token via an iframe
|
|
15824
|
+
* @param request CommonSilentFlowRequest
|
|
15825
|
+
* @returns A promise that, when resolved, returns the access token
|
|
15826
|
+
*/
|
|
15827
|
+
ClientApplication.prototype.acquireTokenBySilentIframe = function (request) {
|
|
15828
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
15829
|
+
var silentIframeClient;
|
|
15830
|
+
return __generator$1(this, function (_a) {
|
|
15831
|
+
silentIframeClient = this.createSilentIframeClient(request.correlationId);
|
|
15832
|
+
return [2 /*return*/, silentIframeClient.acquireToken(request)];
|
|
15466
15833
|
});
|
|
15467
15834
|
});
|
|
15468
15835
|
};
|
|
@@ -15956,7 +16323,9 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
15956
16323
|
fromCache: result.fromCache,
|
|
15957
16324
|
accessTokenSize: result.accessToken.length,
|
|
15958
16325
|
idTokenSize: result.idToken.length,
|
|
15959
|
-
isNativeBroker: result.fromNativeBroker
|
|
16326
|
+
isNativeBroker: result.fromNativeBroker,
|
|
16327
|
+
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
16328
|
+
requestId: result.requestId
|
|
15960
16329
|
});
|
|
15961
16330
|
atsMeasurement.flushMeasurement();
|
|
15962
16331
|
return result;
|
|
@@ -15994,7 +16363,7 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
15994
16363
|
*/
|
|
15995
16364
|
PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
|
|
15996
16365
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
15997
|
-
var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1;
|
|
16366
|
+
var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
|
|
15998
16367
|
var _this = this;
|
|
15999
16368
|
return __generator$1(this, function (_a) {
|
|
16000
16369
|
switch (_a.label) {
|
|
@@ -16024,11 +16393,32 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
16024
16393
|
return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
|
|
16025
16394
|
case 2:
|
|
16026
16395
|
silentRequest_1 = _a.sent();
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16396
|
+
requestWithCLP_1 = __assign$1(__assign$1({}, request), {
|
|
16397
|
+
// set the request's CacheLookupPolicy to Default if it was not optionally passed in
|
|
16398
|
+
cacheLookupPolicy: request.cacheLookupPolicy || exports.CacheLookupPolicy.Default });
|
|
16399
|
+
result = this.acquireTokenFromCache(silentCacheClient, silentRequest_1, requestWithCLP_1).catch(function (cacheError) {
|
|
16400
|
+
if (requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessToken) {
|
|
16401
|
+
throw cacheError;
|
|
16402
|
+
}
|
|
16403
|
+
// block the reload if it occurred inside a hidden iframe
|
|
16404
|
+
BrowserUtils.blockReloadInHiddenIframes();
|
|
16405
|
+
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest_1);
|
|
16406
|
+
return _this.acquireTokenByRefreshToken(silentRequest_1, requestWithCLP_1).catch(function (refreshTokenError) {
|
|
16407
|
+
var isServerError = refreshTokenError instanceof ServerError;
|
|
16408
|
+
var isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;
|
|
16409
|
+
var isInvalidGrantError = (refreshTokenError.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
|
|
16410
|
+
if ((!isServerError ||
|
|
16411
|
+
!isInvalidGrantError ||
|
|
16412
|
+
isInteractionRequiredError ||
|
|
16413
|
+
requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessTokenAndRefreshToken ||
|
|
16414
|
+
requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.RefreshToken)
|
|
16415
|
+
&& (requestWithCLP_1.cacheLookupPolicy !== exports.CacheLookupPolicy.Skip)) {
|
|
16416
|
+
throw refreshTokenError;
|
|
16417
|
+
}
|
|
16418
|
+
_this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", request.correlationId);
|
|
16419
|
+
return _this.acquireTokenBySilentIframe(silentRequest_1);
|
|
16030
16420
|
});
|
|
16031
|
-
});
|
|
16421
|
+
});
|
|
16032
16422
|
_a.label = 3;
|
|
16033
16423
|
case 3: return [2 /*return*/, result.then(function (response) {
|
|
16034
16424
|
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
|
|
@@ -16037,7 +16427,8 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
16037
16427
|
fromCache: response.fromCache,
|
|
16038
16428
|
accessTokenSize: response.accessToken.length,
|
|
16039
16429
|
idTokenSize: response.idToken.length,
|
|
16040
|
-
isNativeBroker: response.fromNativeBroker
|
|
16430
|
+
isNativeBroker: response.fromNativeBroker,
|
|
16431
|
+
requestId: response.requestId
|
|
16041
16432
|
});
|
|
16042
16433
|
return response;
|
|
16043
16434
|
}).catch(function (tokenRenewalError) {
|