@azure/msal-browser 2.23.0 → 2.24.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +214 -214
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +58 -1
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +290 -75
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.d.ts +1 -0
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.js +4 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +48 -42
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +49 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.js +246 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -0
- package/dist/broker/nativeBroker/NativeRequest.d.ts +43 -0
- package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -0
- package/dist/broker/nativeBroker/NativeResponse.d.ts +24 -0
- package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -0
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/AsyncMemoryStorage.js.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +11 -0
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +44 -2
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/BrowserStorage.js.map +1 -1
- package/dist/cache/DatabaseStorage.js +1 -1
- package/dist/cache/DatabaseStorage.js.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/MemoryStorage.js.map +1 -1
- package/dist/cache/TokenCache.js +1 -1
- package/dist/cache/TokenCache.js.map +1 -1
- package/dist/config/Configuration.d.ts +99 -38
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +4 -3
- package/dist/config/Configuration.js.map +1 -1
- package/dist/crypto/BrowserCrypto.js +1 -1
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.js +1 -1
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/GuidGenerator.js.map +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/PkceGenerator.js.map +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/crypto/SignedHttpRequest.js.map +1 -1
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Decode.js.map +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/encode/Base64Encode.js.map +1 -1
- package/dist/error/BrowserAuthError.d.ts +58 -0
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +73 -1
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
- package/dist/error/NativeAuthError.d.ts +46 -0
- package/dist/error/NativeAuthError.d.ts.map +1 -0
- package/dist/error/NativeAuthError.js +82 -0
- package/dist/error/NativeAuthError.js.map +1 -0
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventHandler.js.map +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventMessage.js.map +1 -1
- package/dist/event/EventType.d.ts +2 -0
- package/dist/event/EventType.d.ts.map +1 -1
- package/dist/event/EventType.js +3 -1
- package/dist/event/EventType.js.map +1 -1
- package/dist/index.cjs.js +1633 -449
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +12 -2
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +35 -3
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +57 -0
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -0
- package/dist/interaction_client/NativeInteractionClient.js +334 -0
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -0
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +36 -7
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.js +26 -8
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +3 -3
- package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +2 -4
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts +5 -3
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +38 -25
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +1 -1
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts +2 -8
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +5 -9
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +15 -4
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/PopupHandler.js +1 -1
- package/dist/interaction_handler/PopupHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +16 -9
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +1 -1
- package/dist/interaction_handler/SilentHandler.js.map +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/navigation/NavigationClient.js.map +1 -1
- package/dist/network/FetchClient.js +1 -1
- package/dist/network/FetchClient.js.map +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/network/XhrClient.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +2 -1
- package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +1 -1
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/SsoSilentRequest.d.ts +1 -1
- package/dist/request/SsoSilentRequest.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
- package/dist/utils/BrowserConstants.d.ts +12 -1
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +14 -2
- package/dist/utils/BrowserConstants.js.map +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserProtocolUtils.js.map +1 -1
- package/dist/utils/BrowserStringUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.js.map +1 -1
- package/dist/utils/BrowserUtils.d.ts +6 -0
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.js +11 -1
- package/dist/utils/BrowserUtils.js.map +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/dist/utils/MathUtils.js.map +1 -1
- package/dist/utils/PopupUtils.js +1 -1
- package/dist/utils/PopupUtils.js.map +1 -1
- package/lib/msal-browser.js +1633 -449
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +38 -38
- 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.24.0-beta.0 2022-04-27 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -105,7 +105,7 @@ function __spread() {
|
|
|
105
105
|
return ar;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/*! @azure/msal-common v6.
|
|
108
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
109
109
|
/*! *****************************************************************************
|
|
110
110
|
Copyright (c) Microsoft Corporation.
|
|
111
111
|
|
|
@@ -192,7 +192,7 @@ function __spreadArrays() {
|
|
|
192
192
|
return r;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
/*! @azure/msal-common v6.
|
|
195
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
196
196
|
|
|
197
197
|
/*
|
|
198
198
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -240,7 +240,9 @@ var Constants = {
|
|
|
240
240
|
IMDS_TIMEOUT: 2000,
|
|
241
241
|
AZURE_REGION_AUTO_DISCOVER_FLAG: "TryAutoDetect",
|
|
242
242
|
REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
|
|
243
|
-
KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"]
|
|
243
|
+
KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
|
|
244
|
+
TOKEN_RESPONSE_TYPE: "token",
|
|
245
|
+
ID_TOKEN_RESPONSE_TYPE: "id_token"
|
|
244
246
|
};
|
|
245
247
|
var OIDC_DEFAULT_SCOPES = [
|
|
246
248
|
Constants.OPENID_SCOPE,
|
|
@@ -333,6 +335,7 @@ var AADServerParamKeys;
|
|
|
333
335
|
AADServerParamKeys["FOCI"] = "foci";
|
|
334
336
|
AADServerParamKeys["CCS_HEADER"] = "X-AnchorMailbox";
|
|
335
337
|
AADServerParamKeys["RETURN_SPA_CODE"] = "return_spa_code";
|
|
338
|
+
AADServerParamKeys["NATIVE_BROKER"] = "nativebroker";
|
|
336
339
|
AADServerParamKeys["LOGOUT_HINT"] = "logout_hint";
|
|
337
340
|
})(AADServerParamKeys || (AADServerParamKeys = {}));
|
|
338
341
|
/**
|
|
@@ -558,7 +561,7 @@ var CacheOutcome;
|
|
|
558
561
|
CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
|
|
559
562
|
})(CacheOutcome || (CacheOutcome = {}));
|
|
560
563
|
|
|
561
|
-
/*! @azure/msal-common v6.
|
|
564
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
562
565
|
|
|
563
566
|
/*
|
|
564
567
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -602,7 +605,7 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
602
605
|
return AuthError;
|
|
603
606
|
}(Error));
|
|
604
607
|
|
|
605
|
-
/*! @azure/msal-common v6.
|
|
608
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
606
609
|
|
|
607
610
|
/*
|
|
608
611
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -677,7 +680,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
677
680
|
}
|
|
678
681
|
};
|
|
679
682
|
|
|
680
|
-
/*! @azure/msal-common v6.
|
|
683
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
681
684
|
|
|
682
685
|
/*
|
|
683
686
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1139,7 +1142,7 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1139
1142
|
return ClientAuthError;
|
|
1140
1143
|
}(AuthError));
|
|
1141
1144
|
|
|
1142
|
-
/*! @azure/msal-common v6.
|
|
1145
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
1143
1146
|
|
|
1144
1147
|
/*
|
|
1145
1148
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1264,7 +1267,7 @@ var StringUtils = /** @class */ (function () {
|
|
|
1264
1267
|
return StringUtils;
|
|
1265
1268
|
}());
|
|
1266
1269
|
|
|
1267
|
-
/*! @azure/msal-common v6.
|
|
1270
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
1268
1271
|
|
|
1269
1272
|
/*
|
|
1270
1273
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1444,12 +1447,12 @@ var Logger = /** @class */ (function () {
|
|
|
1444
1447
|
return Logger;
|
|
1445
1448
|
}());
|
|
1446
1449
|
|
|
1447
|
-
/*! @azure/msal-common v6.
|
|
1450
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
1448
1451
|
/* eslint-disable header/header */
|
|
1449
1452
|
var name$1 = "@azure/msal-common";
|
|
1450
|
-
var version$1 = "6.
|
|
1453
|
+
var version$1 = "6.3.0-beta.0";
|
|
1451
1454
|
|
|
1452
|
-
/*! @azure/msal-common v6.
|
|
1455
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
1453
1456
|
/*
|
|
1454
1457
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1455
1458
|
* Licensed under the MIT License.
|
|
@@ -1470,7 +1473,7 @@ exports.AzureCloudInstance = void 0;
|
|
|
1470
1473
|
AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
|
|
1471
1474
|
})(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
|
|
1472
1475
|
|
|
1473
|
-
/*! @azure/msal-common v6.
|
|
1476
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
1474
1477
|
|
|
1475
1478
|
/*
|
|
1476
1479
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1629,7 +1632,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1629
1632
|
return CredentialEntity;
|
|
1630
1633
|
}());
|
|
1631
1634
|
|
|
1632
|
-
/*! @azure/msal-common v6.
|
|
1635
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
1633
1636
|
|
|
1634
1637
|
/*
|
|
1635
1638
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1884,7 +1887,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1884
1887
|
return ClientConfigurationError;
|
|
1885
1888
|
}(ClientAuthError));
|
|
1886
1889
|
|
|
1887
|
-
/*! @azure/msal-common v6.
|
|
1890
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
1888
1891
|
|
|
1889
1892
|
/*
|
|
1890
1893
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2068,7 +2071,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
2068
2071
|
return ScopeSet;
|
|
2069
2072
|
}());
|
|
2070
2073
|
|
|
2071
|
-
/*! @azure/msal-common v6.
|
|
2074
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
2072
2075
|
|
|
2073
2076
|
/*
|
|
2074
2077
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2106,7 +2109,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
2106
2109
|
};
|
|
2107
2110
|
}
|
|
2108
2111
|
|
|
2109
|
-
/*! @azure/msal-common v6.
|
|
2112
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
2110
2113
|
/*
|
|
2111
2114
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2112
2115
|
* Licensed under the MIT License.
|
|
@@ -2120,7 +2123,7 @@ var AuthorityType;
|
|
|
2120
2123
|
AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
|
|
2121
2124
|
})(AuthorityType || (AuthorityType = {}));
|
|
2122
2125
|
|
|
2123
|
-
/*! @azure/msal-common v6.
|
|
2126
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
2124
2127
|
|
|
2125
2128
|
/*
|
|
2126
2129
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2147,6 +2150,7 @@ var AuthorityType;
|
|
|
2147
2150
|
* lastModificationApp:
|
|
2148
2151
|
* oboAssertion: access token passed in as part of OBO request
|
|
2149
2152
|
* idTokenClaims: Object containing claims parsed from ID token
|
|
2153
|
+
* nativeAccountId: Account identifier on the native device
|
|
2150
2154
|
* }
|
|
2151
2155
|
*/
|
|
2152
2156
|
var AccountEntity = /** @class */ (function () {
|
|
@@ -2200,7 +2204,8 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2200
2204
|
username: this.username,
|
|
2201
2205
|
localAccountId: this.localAccountId,
|
|
2202
2206
|
name: this.name,
|
|
2203
|
-
idTokenClaims: this.idTokenClaims
|
|
2207
|
+
idTokenClaims: this.idTokenClaims,
|
|
2208
|
+
nativeAccountId: this.nativeAccountId
|
|
2204
2209
|
};
|
|
2205
2210
|
};
|
|
2206
2211
|
/**
|
|
@@ -2222,12 +2227,13 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2222
2227
|
* @param idToken
|
|
2223
2228
|
* @param policy
|
|
2224
2229
|
*/
|
|
2225
|
-
AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment) {
|
|
2230
|
+
AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
|
|
2226
2231
|
var _a, _b, _c, _d, _e, _f;
|
|
2227
2232
|
var account = new AccountEntity();
|
|
2228
2233
|
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
2229
2234
|
account.clientInfo = clientInfo;
|
|
2230
2235
|
account.homeAccountId = homeAccountId;
|
|
2236
|
+
account.nativeAccountId = nativeAccountId;
|
|
2231
2237
|
var env = environment || (authority && authority.getPreferredCache());
|
|
2232
2238
|
if (!env) {
|
|
2233
2239
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
@@ -2349,12 +2355,13 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2349
2355
|
(accountA.username === accountB.username) &&
|
|
2350
2356
|
(accountA.tenantId === accountB.tenantId) &&
|
|
2351
2357
|
(accountA.environment === accountB.environment) &&
|
|
2358
|
+
(accountA.nativeAccountId === accountB.nativeAccountId) &&
|
|
2352
2359
|
claimsMatch;
|
|
2353
2360
|
};
|
|
2354
2361
|
return AccountEntity;
|
|
2355
2362
|
}());
|
|
2356
2363
|
|
|
2357
|
-
/*! @azure/msal-common v6.
|
|
2364
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
2358
2365
|
|
|
2359
2366
|
/*
|
|
2360
2367
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2392,7 +2399,7 @@ var AuthToken = /** @class */ (function () {
|
|
|
2392
2399
|
return AuthToken;
|
|
2393
2400
|
}());
|
|
2394
2401
|
|
|
2395
|
-
/*! @azure/msal-common v6.
|
|
2402
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
2396
2403
|
|
|
2397
2404
|
/*
|
|
2398
2405
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2760,7 +2767,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2760
2767
|
});
|
|
2761
2768
|
};
|
|
2762
2769
|
/**
|
|
2763
|
-
*
|
|
2770
|
+
* Removes credentials associated with the provided account
|
|
2764
2771
|
* @param account
|
|
2765
2772
|
*/
|
|
2766
2773
|
CacheManager.prototype.removeAccountContext = function (account) {
|
|
@@ -3234,7 +3241,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
3234
3241
|
return DefaultStorageClass;
|
|
3235
3242
|
}(CacheManager));
|
|
3236
3243
|
|
|
3237
|
-
/*! @azure/msal-common v6.
|
|
3244
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3238
3245
|
|
|
3239
3246
|
/*
|
|
3240
3247
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3328,7 +3335,7 @@ function buildAuthOptions(authOptions) {
|
|
|
3328
3335
|
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
|
|
3329
3336
|
}
|
|
3330
3337
|
|
|
3331
|
-
/*! @azure/msal-common v6.
|
|
3338
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3332
3339
|
|
|
3333
3340
|
/*
|
|
3334
3341
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3348,7 +3355,7 @@ var ServerError = /** @class */ (function (_super) {
|
|
|
3348
3355
|
return ServerError;
|
|
3349
3356
|
}(AuthError));
|
|
3350
3357
|
|
|
3351
|
-
/*! @azure/msal-common v6.
|
|
3358
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3352
3359
|
|
|
3353
3360
|
/*
|
|
3354
3361
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3444,7 +3451,7 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
3444
3451
|
return ThrottlingUtils;
|
|
3445
3452
|
}());
|
|
3446
3453
|
|
|
3447
|
-
/*! @azure/msal-common v6.
|
|
3454
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3448
3455
|
|
|
3449
3456
|
/*
|
|
3450
3457
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3493,7 +3500,7 @@ var NetworkManager = /** @class */ (function () {
|
|
|
3493
3500
|
return NetworkManager;
|
|
3494
3501
|
}());
|
|
3495
3502
|
|
|
3496
|
-
/*! @azure/msal-common v6.
|
|
3503
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3497
3504
|
/*
|
|
3498
3505
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3499
3506
|
* Licensed under the MIT License.
|
|
@@ -3504,7 +3511,7 @@ var CcsCredentialType;
|
|
|
3504
3511
|
CcsCredentialType["UPN"] = "UPN";
|
|
3505
3512
|
})(CcsCredentialType || (CcsCredentialType = {}));
|
|
3506
3513
|
|
|
3507
|
-
/*! @azure/msal-common v6.
|
|
3514
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3508
3515
|
|
|
3509
3516
|
/*
|
|
3510
3517
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3593,7 +3600,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
3593
3600
|
return BaseClient;
|
|
3594
3601
|
}());
|
|
3595
3602
|
|
|
3596
|
-
/*! @azure/msal-common v6.
|
|
3603
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3597
3604
|
|
|
3598
3605
|
/*
|
|
3599
3606
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3679,7 +3686,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3679
3686
|
return RequestValidator;
|
|
3680
3687
|
}());
|
|
3681
3688
|
|
|
3682
|
-
/*! @azure/msal-common v6.
|
|
3689
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
3683
3690
|
|
|
3684
3691
|
/*
|
|
3685
3692
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3695,6 +3702,12 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3695
3702
|
RequestParameterBuilder.prototype.addResponseTypeCode = function () {
|
|
3696
3703
|
this.parameters.set(AADServerParamKeys.RESPONSE_TYPE, encodeURIComponent(Constants.CODE_RESPONSE_TYPE));
|
|
3697
3704
|
};
|
|
3705
|
+
/**
|
|
3706
|
+
* add response_type = token id_token
|
|
3707
|
+
*/
|
|
3708
|
+
RequestParameterBuilder.prototype.addResponseTypeForTokenAndIdToken = function () {
|
|
3709
|
+
this.parameters.set(AADServerParamKeys.RESPONSE_TYPE, encodeURIComponent(Constants.TOKEN_RESPONSE_TYPE + " " + Constants.ID_TOKEN_RESPONSE_TYPE));
|
|
3710
|
+
};
|
|
3698
3711
|
/**
|
|
3699
3712
|
* add response_mode. defaults to query.
|
|
3700
3713
|
* @param responseMode
|
|
@@ -3702,6 +3715,12 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3702
3715
|
RequestParameterBuilder.prototype.addResponseMode = function (responseMode) {
|
|
3703
3716
|
this.parameters.set(AADServerParamKeys.RESPONSE_MODE, encodeURIComponent((responseMode) ? responseMode : ResponseMode.QUERY));
|
|
3704
3717
|
};
|
|
3718
|
+
/**
|
|
3719
|
+
* Add flag to indicate STS should attempt to use WAM if available
|
|
3720
|
+
*/
|
|
3721
|
+
RequestParameterBuilder.prototype.addNativeBroker = function () {
|
|
3722
|
+
this.parameters.set(AADServerParamKeys.NATIVE_BROKER, encodeURIComponent("1"));
|
|
3723
|
+
};
|
|
3705
3724
|
/**
|
|
3706
3725
|
* add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios
|
|
3707
3726
|
* @param scopeSet
|
|
@@ -4041,7 +4060,7 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
4041
4060
|
return RequestParameterBuilder;
|
|
4042
4061
|
}());
|
|
4043
4062
|
|
|
4044
|
-
/*! @azure/msal-common v6.
|
|
4063
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4045
4064
|
|
|
4046
4065
|
/*
|
|
4047
4066
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4106,7 +4125,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
|
|
|
4106
4125
|
return IdTokenEntity;
|
|
4107
4126
|
}(CredentialEntity));
|
|
4108
4127
|
|
|
4109
|
-
/*! @azure/msal-common v6.
|
|
4128
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4110
4129
|
/*
|
|
4111
4130
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4112
4131
|
* Licensed under the MIT License.
|
|
@@ -4156,7 +4175,7 @@ var TimeUtils = /** @class */ (function () {
|
|
|
4156
4175
|
return TimeUtils;
|
|
4157
4176
|
}());
|
|
4158
4177
|
|
|
4159
|
-
/*! @azure/msal-common v6.
|
|
4178
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4160
4179
|
|
|
4161
4180
|
/*
|
|
4162
4181
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4270,7 +4289,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
4270
4289
|
return AccessTokenEntity;
|
|
4271
4290
|
}(CredentialEntity));
|
|
4272
4291
|
|
|
4273
|
-
/*! @azure/msal-common v6.
|
|
4292
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4274
4293
|
|
|
4275
4294
|
/*
|
|
4276
4295
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4337,7 +4356,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
|
|
|
4337
4356
|
return RefreshTokenEntity;
|
|
4338
4357
|
}(CredentialEntity));
|
|
4339
4358
|
|
|
4340
|
-
/*! @azure/msal-common v6.
|
|
4359
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4341
4360
|
|
|
4342
4361
|
/*
|
|
4343
4362
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4401,7 +4420,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
|
4401
4420
|
return InteractionRequiredAuthError;
|
|
4402
4421
|
}(AuthError));
|
|
4403
4422
|
|
|
4404
|
-
/*! @azure/msal-common v6.
|
|
4423
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4405
4424
|
/*
|
|
4406
4425
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4407
4426
|
* Licensed under the MIT License.
|
|
@@ -4417,7 +4436,7 @@ var CacheRecord = /** @class */ (function () {
|
|
|
4417
4436
|
return CacheRecord;
|
|
4418
4437
|
}());
|
|
4419
4438
|
|
|
4420
|
-
/*! @azure/msal-common v6.
|
|
4439
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4421
4440
|
|
|
4422
4441
|
/*
|
|
4423
4442
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4488,7 +4507,7 @@ var ProtocolUtils = /** @class */ (function () {
|
|
|
4488
4507
|
return ProtocolUtils;
|
|
4489
4508
|
}());
|
|
4490
4509
|
|
|
4491
|
-
/*! @azure/msal-common v6.
|
|
4510
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4492
4511
|
|
|
4493
4512
|
/*
|
|
4494
4513
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4689,7 +4708,7 @@ var UrlString = /** @class */ (function () {
|
|
|
4689
4708
|
return UrlString;
|
|
4690
4709
|
}());
|
|
4691
4710
|
|
|
4692
|
-
/*! @azure/msal-common v6.
|
|
4711
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4693
4712
|
|
|
4694
4713
|
/*
|
|
4695
4714
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4704,6 +4723,11 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4704
4723
|
function PopTokenGenerator(cryptoUtils) {
|
|
4705
4724
|
this.cryptoUtils = cryptoUtils;
|
|
4706
4725
|
}
|
|
4726
|
+
/**
|
|
4727
|
+
* Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
|
|
4728
|
+
* @param request
|
|
4729
|
+
* @returns
|
|
4730
|
+
*/
|
|
4707
4731
|
PopTokenGenerator.prototype.generateCnf = function (request) {
|
|
4708
4732
|
return __awaiter(this, void 0, void 0, function () {
|
|
4709
4733
|
var reqCnf;
|
|
@@ -4717,6 +4741,23 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4717
4741
|
});
|
|
4718
4742
|
});
|
|
4719
4743
|
};
|
|
4744
|
+
/**
|
|
4745
|
+
* Generates the hash of the req_cnf
|
|
4746
|
+
* @param cnf
|
|
4747
|
+
* @returns
|
|
4748
|
+
*/
|
|
4749
|
+
PopTokenGenerator.prototype.generateCnfHash = function (cnf) {
|
|
4750
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4751
|
+
return __generator(this, function (_a) {
|
|
4752
|
+
return [2 /*return*/, this.cryptoUtils.hashString(cnf)];
|
|
4753
|
+
});
|
|
4754
|
+
});
|
|
4755
|
+
};
|
|
4756
|
+
/**
|
|
4757
|
+
* Generates key_id for a SHR token request
|
|
4758
|
+
* @param request
|
|
4759
|
+
* @returns
|
|
4760
|
+
*/
|
|
4720
4761
|
PopTokenGenerator.prototype.generateKid = function (request) {
|
|
4721
4762
|
return __awaiter(this, void 0, void 0, function () {
|
|
4722
4763
|
var kidThumbprint;
|
|
@@ -4733,6 +4774,12 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4733
4774
|
});
|
|
4734
4775
|
});
|
|
4735
4776
|
};
|
|
4777
|
+
/**
|
|
4778
|
+
* Signs the POP access_token with the local generated key-pair
|
|
4779
|
+
* @param accessToken
|
|
4780
|
+
* @param request
|
|
4781
|
+
* @returns
|
|
4782
|
+
*/
|
|
4736
4783
|
PopTokenGenerator.prototype.signPopToken = function (accessToken, request) {
|
|
4737
4784
|
var _a;
|
|
4738
4785
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -4746,6 +4793,14 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4746
4793
|
});
|
|
4747
4794
|
});
|
|
4748
4795
|
};
|
|
4796
|
+
/**
|
|
4797
|
+
* Utility function to generate the signed JWT for an access_token
|
|
4798
|
+
* @param payload
|
|
4799
|
+
* @param kid
|
|
4800
|
+
* @param request
|
|
4801
|
+
* @param claims
|
|
4802
|
+
* @returns
|
|
4803
|
+
*/
|
|
4749
4804
|
PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
|
|
4750
4805
|
return __awaiter(this, void 0, void 0, function () {
|
|
4751
4806
|
var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
|
|
@@ -4764,7 +4819,7 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4764
4819
|
return PopTokenGenerator;
|
|
4765
4820
|
}());
|
|
4766
4821
|
|
|
4767
|
-
/*! @azure/msal-common v6.
|
|
4822
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4768
4823
|
|
|
4769
4824
|
/*
|
|
4770
4825
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4834,7 +4889,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4834
4889
|
return AppMetadataEntity;
|
|
4835
4890
|
}());
|
|
4836
4891
|
|
|
4837
|
-
/*! @azure/msal-common v6.
|
|
4892
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4838
4893
|
/*
|
|
4839
4894
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4840
4895
|
* Licensed under the MIT License.
|
|
@@ -4870,7 +4925,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4870
4925
|
return TokenCacheContext;
|
|
4871
4926
|
}());
|
|
4872
4927
|
|
|
4873
|
-
/*! @azure/msal-common v6.
|
|
4928
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
4874
4929
|
|
|
4875
4930
|
/*
|
|
4876
4931
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5126,7 +5181,8 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5126
5181
|
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
5127
5182
|
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
5128
5183
|
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
5129
|
-
code: code
|
|
5184
|
+
code: code,
|
|
5185
|
+
fromNativeBroker: false
|
|
5130
5186
|
}];
|
|
5131
5187
|
}
|
|
5132
5188
|
});
|
|
@@ -5135,7 +5191,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5135
5191
|
return ResponseHandler;
|
|
5136
5192
|
}());
|
|
5137
5193
|
|
|
5138
|
-
/*! @azure/msal-common v6.
|
|
5194
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5139
5195
|
|
|
5140
5196
|
/*
|
|
5141
5197
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5166,8 +5222,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5166
5222
|
return __awaiter(this, void 0, void 0, function () {
|
|
5167
5223
|
var queryString;
|
|
5168
5224
|
return __generator(this, function (_a) {
|
|
5169
|
-
|
|
5170
|
-
|
|
5225
|
+
switch (_a.label) {
|
|
5226
|
+
case 0: return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
|
|
5227
|
+
case 1:
|
|
5228
|
+
queryString = _a.sent();
|
|
5229
|
+
return [2 /*return*/, UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString)];
|
|
5230
|
+
}
|
|
5171
5231
|
});
|
|
5172
5232
|
});
|
|
5173
5233
|
};
|
|
@@ -5417,96 +5477,116 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5417
5477
|
* @param request
|
|
5418
5478
|
*/
|
|
5419
5479
|
AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5480
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5481
|
+
var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, cnf, cnfHash;
|
|
5482
|
+
return __generator(this, function (_a) {
|
|
5483
|
+
switch (_a.label) {
|
|
5484
|
+
case 0:
|
|
5485
|
+
parameterBuilder = new RequestParameterBuilder();
|
|
5486
|
+
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5487
|
+
requestScopes = __spreadArrays(request.scopes || [], request.extraScopesToConsent || []);
|
|
5488
|
+
parameterBuilder.addScopes(requestScopes);
|
|
5489
|
+
// validate the redirectUri (to be a non null value)
|
|
5490
|
+
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
5491
|
+
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
5492
|
+
parameterBuilder.addCorrelationId(correlationId);
|
|
5493
|
+
// add response_mode. If not passed in it defaults to query.
|
|
5494
|
+
parameterBuilder.addResponseMode(request.responseMode);
|
|
5495
|
+
// add response_type = code
|
|
5496
|
+
parameterBuilder.addResponseTypeCode();
|
|
5497
|
+
// add library info parameters
|
|
5498
|
+
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
5499
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
5500
|
+
// add client_info=1
|
|
5501
|
+
parameterBuilder.addClientInfo();
|
|
5502
|
+
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
5503
|
+
parameterBuilder.addCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);
|
|
5504
|
+
}
|
|
5505
|
+
if (request.prompt) {
|
|
5506
|
+
parameterBuilder.addPrompt(request.prompt);
|
|
5507
|
+
}
|
|
5508
|
+
if (request.domainHint) {
|
|
5509
|
+
parameterBuilder.addDomainHint(request.domainHint);
|
|
5510
|
+
}
|
|
5511
|
+
// Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object
|
|
5512
|
+
if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
|
|
5513
|
+
// AAD will throw if prompt=select_account is passed with an account hint
|
|
5514
|
+
if (request.sid && request.prompt === PromptValue.NONE) {
|
|
5515
|
+
// SessionID is only used in silent calls
|
|
5516
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request");
|
|
5517
|
+
parameterBuilder.addSid(request.sid);
|
|
5518
|
+
}
|
|
5519
|
+
else if (request.account) {
|
|
5520
|
+
accountSid = this.extractAccountSid(request.account);
|
|
5521
|
+
// If account and loginHint are provided, we will check account first for sid before adding loginHint
|
|
5522
|
+
if (accountSid && request.prompt === PromptValue.NONE) {
|
|
5523
|
+
// SessionId is only used in silent calls
|
|
5524
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
|
|
5525
|
+
parameterBuilder.addSid(accountSid);
|
|
5526
|
+
try {
|
|
5527
|
+
clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
5528
|
+
parameterBuilder.addCcsOid(clientInfo);
|
|
5529
|
+
}
|
|
5530
|
+
catch (e) {
|
|
5531
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
5532
|
+
}
|
|
5533
|
+
}
|
|
5534
|
+
else if (request.loginHint) {
|
|
5535
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request");
|
|
5536
|
+
parameterBuilder.addLoginHint(request.loginHint);
|
|
5537
|
+
parameterBuilder.addCcsUpn(request.loginHint);
|
|
5538
|
+
}
|
|
5539
|
+
else if (request.account.username) {
|
|
5540
|
+
// Fallback to account username if provided
|
|
5541
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
|
|
5542
|
+
parameterBuilder.addLoginHint(request.account.username);
|
|
5543
|
+
try {
|
|
5544
|
+
clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
5545
|
+
parameterBuilder.addCcsOid(clientInfo);
|
|
5546
|
+
}
|
|
5547
|
+
catch (e) {
|
|
5548
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
5549
|
+
}
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
else if (request.loginHint) {
|
|
5553
|
+
this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
|
|
5554
|
+
parameterBuilder.addLoginHint(request.loginHint);
|
|
5555
|
+
parameterBuilder.addCcsUpn(request.loginHint);
|
|
5556
|
+
}
|
|
5557
|
+
}
|
|
5558
|
+
else {
|
|
5559
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
|
|
5560
|
+
}
|
|
5561
|
+
if (request.nonce) {
|
|
5562
|
+
parameterBuilder.addNonce(request.nonce);
|
|
5563
|
+
}
|
|
5564
|
+
if (request.state) {
|
|
5565
|
+
parameterBuilder.addState(request.state);
|
|
5566
|
+
}
|
|
5567
|
+
if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5568
|
+
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5569
|
+
}
|
|
5570
|
+
if (request.extraQueryParameters) {
|
|
5571
|
+
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
5572
|
+
}
|
|
5573
|
+
if (!request.nativeBroker) return [3 /*break*/, 3];
|
|
5574
|
+
// signal ests that this is a WAM call
|
|
5575
|
+
parameterBuilder.addNativeBroker();
|
|
5576
|
+
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
|
|
5577
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5578
|
+
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5579
|
+
case 1:
|
|
5580
|
+
cnf = _a.sent();
|
|
5581
|
+
return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
|
|
5582
|
+
case 2:
|
|
5583
|
+
cnfHash = _a.sent();
|
|
5584
|
+
parameterBuilder.addPopToken(cnfHash);
|
|
5585
|
+
_a.label = 3;
|
|
5586
|
+
case 3: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5486
5587
|
}
|
|
5487
|
-
}
|
|
5488
|
-
|
|
5489
|
-
this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
|
|
5490
|
-
parameterBuilder.addLoginHint(request.loginHint);
|
|
5491
|
-
parameterBuilder.addCcsUpn(request.loginHint);
|
|
5492
|
-
}
|
|
5493
|
-
}
|
|
5494
|
-
else {
|
|
5495
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
|
|
5496
|
-
}
|
|
5497
|
-
if (request.nonce) {
|
|
5498
|
-
parameterBuilder.addNonce(request.nonce);
|
|
5499
|
-
}
|
|
5500
|
-
if (request.state) {
|
|
5501
|
-
parameterBuilder.addState(request.state);
|
|
5502
|
-
}
|
|
5503
|
-
if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5504
|
-
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5505
|
-
}
|
|
5506
|
-
if (request.extraQueryParameters) {
|
|
5507
|
-
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
5508
|
-
}
|
|
5509
|
-
return parameterBuilder.createQueryString();
|
|
5588
|
+
});
|
|
5589
|
+
});
|
|
5510
5590
|
};
|
|
5511
5591
|
/**
|
|
5512
5592
|
* This API validates the `EndSessionRequest` and creates a URL
|
|
@@ -5548,7 +5628,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5548
5628
|
return AuthorizationCodeClient;
|
|
5549
5629
|
}(BaseClient));
|
|
5550
5630
|
|
|
5551
|
-
/*! @azure/msal-common v6.
|
|
5631
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5552
5632
|
|
|
5553
5633
|
/*
|
|
5554
5634
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5760,7 +5840,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5760
5840
|
return RefreshTokenClient;
|
|
5761
5841
|
}(BaseClient));
|
|
5762
5842
|
|
|
5763
|
-
/*! @azure/msal-common v6.
|
|
5843
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5764
5844
|
|
|
5765
5845
|
/*
|
|
5766
5846
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5876,7 +5956,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5876
5956
|
return SilentFlowClient;
|
|
5877
5957
|
}(BaseClient));
|
|
5878
5958
|
|
|
5879
|
-
/*! @azure/msal-common v6.
|
|
5959
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5880
5960
|
/*
|
|
5881
5961
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5882
5962
|
* Licensed under the MIT License.
|
|
@@ -5887,7 +5967,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
5887
5967
|
response.hasOwnProperty("issuer"));
|
|
5888
5968
|
}
|
|
5889
5969
|
|
|
5890
|
-
/*! @azure/msal-common v6.
|
|
5970
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5891
5971
|
/*
|
|
5892
5972
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5893
5973
|
* Licensed under the MIT License.
|
|
@@ -5901,7 +5981,7 @@ exports.ProtocolMode = void 0;
|
|
|
5901
5981
|
ProtocolMode["OIDC"] = "OIDC";
|
|
5902
5982
|
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
5903
5983
|
|
|
5904
|
-
/*! @azure/msal-common v6.
|
|
5984
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5905
5985
|
|
|
5906
5986
|
/*
|
|
5907
5987
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5976,7 +6056,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
5976
6056
|
return AuthorityMetadataEntity;
|
|
5977
6057
|
}());
|
|
5978
6058
|
|
|
5979
|
-
/*! @azure/msal-common v6.
|
|
6059
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5980
6060
|
/*
|
|
5981
6061
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5982
6062
|
* Licensed under the MIT License.
|
|
@@ -5986,7 +6066,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
5986
6066
|
response.hasOwnProperty("metadata"));
|
|
5987
6067
|
}
|
|
5988
6068
|
|
|
5989
|
-
/*! @azure/msal-common v6.
|
|
6069
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
5990
6070
|
|
|
5991
6071
|
/*
|
|
5992
6072
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6108,7 +6188,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6108
6188
|
return RegionDiscovery;
|
|
6109
6189
|
}());
|
|
6110
6190
|
|
|
6111
|
-
/*! @azure/msal-common v6.
|
|
6191
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
6112
6192
|
|
|
6113
6193
|
/*
|
|
6114
6194
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6698,7 +6778,7 @@ var Authority = /** @class */ (function () {
|
|
|
6698
6778
|
return Authority;
|
|
6699
6779
|
}());
|
|
6700
6780
|
|
|
6701
|
-
/*! @azure/msal-common v6.
|
|
6781
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
6702
6782
|
|
|
6703
6783
|
/*
|
|
6704
6784
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6759,7 +6839,7 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
6759
6839
|
return AuthorityFactory;
|
|
6760
6840
|
}());
|
|
6761
6841
|
|
|
6762
|
-
/*! @azure/msal-common v6.
|
|
6842
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
6763
6843
|
|
|
6764
6844
|
/*
|
|
6765
6845
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6790,7 +6870,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
|
|
|
6790
6870
|
return ServerTelemetryEntity;
|
|
6791
6871
|
}());
|
|
6792
6872
|
|
|
6793
|
-
/*! @azure/msal-common v6.
|
|
6873
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
6794
6874
|
|
|
6795
6875
|
/*
|
|
6796
6876
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6818,7 +6898,7 @@ var ThrottlingEntity = /** @class */ (function () {
|
|
|
6818
6898
|
return ThrottlingEntity;
|
|
6819
6899
|
}());
|
|
6820
6900
|
|
|
6821
|
-
/*! @azure/msal-common v6.
|
|
6901
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
6822
6902
|
|
|
6823
6903
|
/*
|
|
6824
6904
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6835,7 +6915,7 @@ var StubbedNetworkModule = {
|
|
|
6835
6915
|
}
|
|
6836
6916
|
};
|
|
6837
6917
|
|
|
6838
|
-
/*! @azure/msal-common v6.
|
|
6918
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
6839
6919
|
|
|
6840
6920
|
/*
|
|
6841
6921
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6894,7 +6974,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
|
|
|
6894
6974
|
return AuthenticationHeaderParser;
|
|
6895
6975
|
}());
|
|
6896
6976
|
|
|
6897
|
-
/*! @azure/msal-common v6.
|
|
6977
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
6898
6978
|
|
|
6899
6979
|
/*
|
|
6900
6980
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7056,7 +7136,7 @@ var ServerTelemetryManager = /** @class */ (function () {
|
|
|
7056
7136
|
return ServerTelemetryManager;
|
|
7057
7137
|
}());
|
|
7058
7138
|
|
|
7059
|
-
/*! @azure/msal-common v6.
|
|
7139
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
7060
7140
|
/*
|
|
7061
7141
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7062
7142
|
* Licensed under the MIT License.
|
|
@@ -7089,6 +7169,11 @@ exports.PerformanceEvents = void 0;
|
|
|
7089
7169
|
* Internal API for acquireTokenSilent.
|
|
7090
7170
|
*/
|
|
7091
7171
|
PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
|
|
7172
|
+
/**
|
|
7173
|
+
* acquireTokenPopup (msal-browser).
|
|
7174
|
+
* Used to acquire a new access token interactively through pop ups
|
|
7175
|
+
*/
|
|
7176
|
+
PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
|
|
7092
7177
|
/**
|
|
7093
7178
|
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
7094
7179
|
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
@@ -7124,6 +7209,16 @@ exports.PerformanceEvents = void 0;
|
|
|
7124
7209
|
* Used to load authority metadata for a request.
|
|
7125
7210
|
*/
|
|
7126
7211
|
PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
|
|
7212
|
+
/**
|
|
7213
|
+
* acquireToken APIs in msal-browser.
|
|
7214
|
+
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
7215
|
+
*/
|
|
7216
|
+
PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
|
|
7217
|
+
/**
|
|
7218
|
+
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
7219
|
+
* Used to acquire a token from Native component when native brokering is enabled.
|
|
7220
|
+
*/
|
|
7221
|
+
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
7127
7222
|
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
7128
7223
|
/**
|
|
7129
7224
|
* State of the performance event.
|
|
@@ -7138,7 +7233,7 @@ var PerformanceEventStatus;
|
|
|
7138
7233
|
PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
|
|
7139
7234
|
})(PerformanceEventStatus || (PerformanceEventStatus = {}));
|
|
7140
7235
|
|
|
7141
|
-
/*! @azure/msal-common v6.
|
|
7236
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
7142
7237
|
|
|
7143
7238
|
/*
|
|
7144
7239
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7408,7 +7503,7 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
7408
7503
|
return PerformanceClient;
|
|
7409
7504
|
}());
|
|
7410
7505
|
|
|
7411
|
-
/*! @azure/msal-common v6.
|
|
7506
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
7412
7507
|
|
|
7413
7508
|
/*
|
|
7414
7509
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7477,6 +7572,17 @@ var BrowserConstants = {
|
|
|
7477
7572
|
*/
|
|
7478
7573
|
MSAL_SKU: "msal.js.browser",
|
|
7479
7574
|
};
|
|
7575
|
+
var NativeConstants = {
|
|
7576
|
+
CHANNEL_ID: "53ee284d-920a-4b59-9d30-a60315b26836",
|
|
7577
|
+
PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji"
|
|
7578
|
+
};
|
|
7579
|
+
var NativeExtensionMethod;
|
|
7580
|
+
(function (NativeExtensionMethod) {
|
|
7581
|
+
NativeExtensionMethod["HandshakeRequest"] = "Handshake";
|
|
7582
|
+
NativeExtensionMethod["HandshakeResponse"] = "HandshakeResponse";
|
|
7583
|
+
NativeExtensionMethod["GetToken"] = "GetToken";
|
|
7584
|
+
NativeExtensionMethod["Response"] = "Response";
|
|
7585
|
+
})(NativeExtensionMethod || (NativeExtensionMethod = {}));
|
|
7480
7586
|
exports.BrowserCacheLocation = void 0;
|
|
7481
7587
|
(function (BrowserCacheLocation) {
|
|
7482
7588
|
BrowserCacheLocation["LocalStorage"] = "localStorage";
|
|
@@ -7509,6 +7615,7 @@ exports.TemporaryCacheKeys = void 0;
|
|
|
7509
7615
|
TemporaryCacheKeys["INTERACTION_STATUS_KEY"] = "interaction.status";
|
|
7510
7616
|
TemporaryCacheKeys["CCS_CREDENTIAL"] = "ccs.credential";
|
|
7511
7617
|
TemporaryCacheKeys["CORRELATION_ID"] = "request.correlationId";
|
|
7618
|
+
TemporaryCacheKeys["NATIVE_REQUEST"] = "request.native";
|
|
7512
7619
|
})(exports.TemporaryCacheKeys || (exports.TemporaryCacheKeys = {}));
|
|
7513
7620
|
/**
|
|
7514
7621
|
* Cache keys stored in-memory
|
|
@@ -8127,9 +8234,37 @@ var BrowserAuthErrorMessage = {
|
|
|
8127
8234
|
code: "auth_code_required",
|
|
8128
8235
|
desc: "An authorization code must be provided (as the `code` property on the request) to this flow."
|
|
8129
8236
|
},
|
|
8237
|
+
authCodeOrNativeAccountRequired: {
|
|
8238
|
+
code: "auth_code_or_nativeAccountId_required",
|
|
8239
|
+
desc: "An authorization code or nativeAccountId must be provided to this flow."
|
|
8240
|
+
},
|
|
8130
8241
|
databaseUnavailable: {
|
|
8131
8242
|
code: "database_unavailable",
|
|
8132
8243
|
desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
|
|
8244
|
+
},
|
|
8245
|
+
unableToAcquireTokenFromNativePlatform: {
|
|
8246
|
+
code: "unable_to_acquire_token_from_native_platform",
|
|
8247
|
+
desc: "Unable to acquire token from native platform. For a list of possible reasons visit aka.ms/msaljs/browser-errors."
|
|
8248
|
+
},
|
|
8249
|
+
nativeHandshakeTimeout: {
|
|
8250
|
+
code: "native_handshake_timeout",
|
|
8251
|
+
desc: "Timed out while attempting to establish connection to browser extension"
|
|
8252
|
+
},
|
|
8253
|
+
nativeExtensionNotInstalled: {
|
|
8254
|
+
code: "native_extension_not_installed",
|
|
8255
|
+
desc: "Native extension is not installed. If you think this is a mistake call the initialize function."
|
|
8256
|
+
},
|
|
8257
|
+
nativeConnectionNotEstablished: {
|
|
8258
|
+
code: "native_connection_not_established",
|
|
8259
|
+
desc: "Connection to native platform has not been established. Please install a compatible browser extension and run initialize(). For more please visit aka.ms/msaljs/browser-errors."
|
|
8260
|
+
},
|
|
8261
|
+
nativeBrokerCalledBeforeInitialize: {
|
|
8262
|
+
code: "native_broker_called_before_initialize",
|
|
8263
|
+
desc: "You must call and await the initialize function before attempting to call any other MSAL API when native brokering is enabled. For more please visit aka.ms/msaljs/browser-errors."
|
|
8264
|
+
},
|
|
8265
|
+
nativePromptNotSupported: {
|
|
8266
|
+
code: "native_prompt_not_supported",
|
|
8267
|
+
desc: "The provided prompt is not supported by the native platform. This request should be routed to the web based flow."
|
|
8133
8268
|
}
|
|
8134
8269
|
};
|
|
8135
8270
|
/**
|
|
@@ -8369,12 +8504,56 @@ var BrowserAuthError = /** @class */ (function (_super) {
|
|
|
8369
8504
|
BrowserAuthError.createAuthCodeRequiredError = function () {
|
|
8370
8505
|
return new BrowserAuthError(BrowserAuthErrorMessage.authCodeRequired.code, BrowserAuthErrorMessage.authCodeRequired.desc);
|
|
8371
8506
|
};
|
|
8507
|
+
/**
|
|
8508
|
+
* Create an error when an authorization code or native account ID is required but not provided
|
|
8509
|
+
*/
|
|
8510
|
+
BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError = function () {
|
|
8511
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
|
|
8512
|
+
};
|
|
8372
8513
|
/**
|
|
8373
8514
|
* Create an error when IndexedDB is unavailable
|
|
8374
8515
|
*/
|
|
8375
8516
|
BrowserAuthError.createDatabaseUnavailableError = function () {
|
|
8376
8517
|
return new BrowserAuthError(BrowserAuthErrorMessage.databaseUnavailable.code, BrowserAuthErrorMessage.databaseUnavailable.desc);
|
|
8377
8518
|
};
|
|
8519
|
+
/**
|
|
8520
|
+
* Create an error when native token acquisition is not possible
|
|
8521
|
+
*/
|
|
8522
|
+
BrowserAuthError.createUnableToAcquireTokenFromNativePlatformError = function () {
|
|
8523
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.unableToAcquireTokenFromNativePlatform.code, BrowserAuthErrorMessage.unableToAcquireTokenFromNativePlatform.desc);
|
|
8524
|
+
};
|
|
8525
|
+
/**
|
|
8526
|
+
* Create an error thrown when Handshake with browser extension times out
|
|
8527
|
+
*/
|
|
8528
|
+
BrowserAuthError.createNativeHandshakeTimeoutError = function () {
|
|
8529
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.nativeHandshakeTimeout.code, BrowserAuthErrorMessage.nativeHandshakeTimeout.desc);
|
|
8530
|
+
};
|
|
8531
|
+
/**
|
|
8532
|
+
* Create an error thrown when browser extension is not installed
|
|
8533
|
+
*/
|
|
8534
|
+
BrowserAuthError.createNativeExtensionNotInstalledError = function () {
|
|
8535
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.nativeExtensionNotInstalled.code, BrowserAuthErrorMessage.nativeExtensionNotInstalled.desc);
|
|
8536
|
+
};
|
|
8537
|
+
/**
|
|
8538
|
+
* Create an error when native connection has not been established
|
|
8539
|
+
* @returns
|
|
8540
|
+
*/
|
|
8541
|
+
BrowserAuthError.createNativeConnectionNotEstablishedError = function () {
|
|
8542
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.nativeConnectionNotEstablished.code, BrowserAuthErrorMessage.nativeConnectionNotEstablished.desc);
|
|
8543
|
+
};
|
|
8544
|
+
/**
|
|
8545
|
+
* Create an error thrown when the initialize function hasn't been called
|
|
8546
|
+
*/
|
|
8547
|
+
BrowserAuthError.createNativeBrokerCalledBeforeInitialize = function () {
|
|
8548
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.nativeBrokerCalledBeforeInitialize.code, BrowserAuthErrorMessage.nativeBrokerCalledBeforeInitialize.desc);
|
|
8549
|
+
};
|
|
8550
|
+
/**
|
|
8551
|
+
* Create an error thrown when requesting a token directly from the native platform with an unsupported prompt parameter e.g. select_account, login or create
|
|
8552
|
+
* These requests must go through eSTS to ensure eSTS is aware of the new account
|
|
8553
|
+
*/
|
|
8554
|
+
BrowserAuthError.createNativePromptParameterNotSupportedError = function () {
|
|
8555
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.nativePromptNotSupported.code, BrowserAuthErrorMessage.nativePromptNotSupported.desc);
|
|
8556
|
+
};
|
|
8378
8557
|
return BrowserAuthError;
|
|
8379
8558
|
}(AuthError));
|
|
8380
8559
|
|
|
@@ -10020,6 +10199,30 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
10020
10199
|
return true;
|
|
10021
10200
|
});
|
|
10022
10201
|
};
|
|
10202
|
+
/**
|
|
10203
|
+
* Checks the cache for accounts matching loginHint or SID
|
|
10204
|
+
* @param loginHint
|
|
10205
|
+
* @param sid
|
|
10206
|
+
*/
|
|
10207
|
+
BrowserCacheManager.prototype.getAccountInfoByHints = function (loginHint, sid) {
|
|
10208
|
+
var matchingAccounts = this.getAllAccounts().filter(function (accountInfo) {
|
|
10209
|
+
if (sid) {
|
|
10210
|
+
var accountSid = accountInfo.idTokenClaims && accountInfo.idTokenClaims["sid"];
|
|
10211
|
+
return sid === accountSid;
|
|
10212
|
+
}
|
|
10213
|
+
if (loginHint) {
|
|
10214
|
+
return loginHint === accountInfo.username;
|
|
10215
|
+
}
|
|
10216
|
+
return false;
|
|
10217
|
+
});
|
|
10218
|
+
if (matchingAccounts.length === 1) {
|
|
10219
|
+
return matchingAccounts[0];
|
|
10220
|
+
}
|
|
10221
|
+
else if (matchingAccounts.length > 1) {
|
|
10222
|
+
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
|
|
10223
|
+
}
|
|
10224
|
+
return null;
|
|
10225
|
+
};
|
|
10023
10226
|
/**
|
|
10024
10227
|
* fetch throttling entity from the platform cache
|
|
10025
10228
|
* @param throttlingCacheKey
|
|
@@ -10337,6 +10540,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
10337
10540
|
this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.URL_HASH));
|
|
10338
10541
|
this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.CORRELATION_ID));
|
|
10339
10542
|
this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.CCS_CREDENTIAL));
|
|
10543
|
+
this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.NATIVE_REQUEST));
|
|
10340
10544
|
this.setInteractionInProgress(false);
|
|
10341
10545
|
};
|
|
10342
10546
|
/**
|
|
@@ -10414,6 +10618,23 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
10414
10618
|
}
|
|
10415
10619
|
return parsedRequest;
|
|
10416
10620
|
};
|
|
10621
|
+
/**
|
|
10622
|
+
* Gets cached native request for redirect flows
|
|
10623
|
+
*/
|
|
10624
|
+
BrowserCacheManager.prototype.getCachedNativeRequest = function () {
|
|
10625
|
+
this.logger.trace("BrowserCacheManager.getCachedNativeRequest called");
|
|
10626
|
+
var cachedRequest = this.getTemporaryCache(exports.TemporaryCacheKeys.NATIVE_REQUEST, true);
|
|
10627
|
+
if (!cachedRequest) {
|
|
10628
|
+
this.logger.trace("BrowserCacheManager.getCachedNativeRequest: No cached native request found");
|
|
10629
|
+
return null;
|
|
10630
|
+
}
|
|
10631
|
+
var parsedRequest = this.validateAndParseJson(cachedRequest);
|
|
10632
|
+
if (!parsedRequest) {
|
|
10633
|
+
this.logger.error("BrowserCacheManager.getCachedNativeRequest: Unable to parse native request");
|
|
10634
|
+
return null;
|
|
10635
|
+
}
|
|
10636
|
+
return parsedRequest;
|
|
10637
|
+
};
|
|
10417
10638
|
BrowserCacheManager.prototype.isInteractionInProgress = function (matchClientId) {
|
|
10418
10639
|
var clientId = this.getInteractionInProgress();
|
|
10419
10640
|
if (matchClientId) {
|
|
@@ -10877,6 +11098,16 @@ var BrowserUtils = /** @class */ (function () {
|
|
|
10877
11098
|
throw BrowserAuthError.createNonBrowserEnvironmentError();
|
|
10878
11099
|
}
|
|
10879
11100
|
};
|
|
11101
|
+
/**
|
|
11102
|
+
* Throws error if native brokering is enabled but initialize hasn't been called
|
|
11103
|
+
* @param allowNativeBroker
|
|
11104
|
+
* @param initialized
|
|
11105
|
+
*/
|
|
11106
|
+
BrowserUtils.blockNativeBrokerCalledBeforeInitialized = function (allowNativeBroker, initialized) {
|
|
11107
|
+
if (allowNativeBroker && !initialized) {
|
|
11108
|
+
throw BrowserAuthError.createNativeBrokerCalledBeforeInitialize();
|
|
11109
|
+
}
|
|
11110
|
+
};
|
|
10880
11111
|
/**
|
|
10881
11112
|
* Returns boolean of whether current browser is an Internet Explorer or Edge browser.
|
|
10882
11113
|
*/
|
|
@@ -10944,6 +11175,7 @@ var NavigationClient = /** @class */ (function () {
|
|
|
10944
11175
|
var DEFAULT_POPUP_TIMEOUT_MS = 60000;
|
|
10945
11176
|
var DEFAULT_IFRAME_TIMEOUT_MS = 6000;
|
|
10946
11177
|
var DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
|
|
11178
|
+
var DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;
|
|
10947
11179
|
/**
|
|
10948
11180
|
* MSAL function that sets the default options when not explicitly configured from app developer
|
|
10949
11181
|
*
|
|
@@ -10988,7 +11220,7 @@ function buildConfiguration(_a, isBrowserEnvironment) {
|
|
|
10988
11220
|
// Default system options for browser
|
|
10989
11221
|
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,
|
|
10990
11222
|
// If loadFrameTimeout is provided, use that as default.
|
|
10991
|
-
windowHashTimeout: (userInputSystem
|
|
11223
|
+
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 });
|
|
10992
11224
|
var DEFAULT_TELEMETRY_OPTIONS = {
|
|
10993
11225
|
application: {
|
|
10994
11226
|
appName: Constants.EMPTY_STRING,
|
|
@@ -11006,7 +11238,7 @@ function buildConfiguration(_a, isBrowserEnvironment) {
|
|
|
11006
11238
|
|
|
11007
11239
|
/* eslint-disable header/header */
|
|
11008
11240
|
var name = "@azure/msal-browser";
|
|
11009
|
-
var version = "2.
|
|
11241
|
+
var version = "2.24.0-beta.0";
|
|
11010
11242
|
|
|
11011
11243
|
/*
|
|
11012
11244
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11014,6 +11246,8 @@ var version = "2.23.0";
|
|
|
11014
11246
|
*/
|
|
11015
11247
|
exports.EventType = void 0;
|
|
11016
11248
|
(function (EventType) {
|
|
11249
|
+
EventType["INITIALIZE_START"] = "msal:initializeStart";
|
|
11250
|
+
EventType["INITIALIZE_END"] = "msal:initializeEnd";
|
|
11017
11251
|
EventType["ACCOUNT_ADDED"] = "msal:accountAdded";
|
|
11018
11252
|
EventType["ACCOUNT_REMOVED"] = "msal:accountRemoved";
|
|
11019
11253
|
EventType["LOGIN_START"] = "msal:loginStart";
|
|
@@ -11163,12 +11397,14 @@ var EventHandler = /** @class */ (function () {
|
|
|
11163
11397
|
* Licensed under the MIT License.
|
|
11164
11398
|
*/
|
|
11165
11399
|
var BaseInteractionClient = /** @class */ (function () {
|
|
11166
|
-
function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, performanceClient, correlationId) {
|
|
11400
|
+
function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
|
|
11167
11401
|
this.config = config;
|
|
11168
11402
|
this.browserStorage = storageImpl;
|
|
11169
11403
|
this.browserCrypto = browserCrypto;
|
|
11170
11404
|
this.networkClient = this.config.system.networkClient;
|
|
11171
11405
|
this.eventHandler = eventHandler;
|
|
11406
|
+
this.navigationClient = navigationClient;
|
|
11407
|
+
this.nativeMessageHandler = nativeMessageHandler;
|
|
11172
11408
|
this.correlationId = correlationId || this.browserCrypto.createNewGuid();
|
|
11173
11409
|
this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);
|
|
11174
11410
|
this.performanceClient = performanceClient;
|
|
@@ -11291,6 +11527,36 @@ var BaseInteractionClient = /** @class */ (function () {
|
|
|
11291
11527
|
};
|
|
11292
11528
|
return new ServerTelemetryManager(telemetryPayload, this.browserStorage);
|
|
11293
11529
|
};
|
|
11530
|
+
/**
|
|
11531
|
+
* Used to get a discovered version of the default authority.
|
|
11532
|
+
* @param requestAuthority
|
|
11533
|
+
* @param requestCorrelationId
|
|
11534
|
+
*/
|
|
11535
|
+
BaseInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority) {
|
|
11536
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
11537
|
+
var authorityOptions;
|
|
11538
|
+
return __generator$1(this, function (_a) {
|
|
11539
|
+
switch (_a.label) {
|
|
11540
|
+
case 0:
|
|
11541
|
+
this.logger.verbose("getDiscoveredAuthority called");
|
|
11542
|
+
authorityOptions = {
|
|
11543
|
+
protocolMode: this.config.auth.protocolMode,
|
|
11544
|
+
knownAuthorities: this.config.auth.knownAuthorities,
|
|
11545
|
+
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
11546
|
+
authorityMetadata: this.config.auth.authorityMetadata
|
|
11547
|
+
};
|
|
11548
|
+
if (!requestAuthority) return [3 /*break*/, 2];
|
|
11549
|
+
this.logger.verbose("Creating discovered authority with request authority");
|
|
11550
|
+
return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
|
|
11551
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11552
|
+
case 2:
|
|
11553
|
+
this.logger.verbose("Creating discovered authority with configured authority");
|
|
11554
|
+
return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
|
|
11555
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
11556
|
+
}
|
|
11557
|
+
});
|
|
11558
|
+
});
|
|
11559
|
+
};
|
|
11294
11560
|
return BaseInteractionClient;
|
|
11295
11561
|
}());
|
|
11296
11562
|
|
|
@@ -11303,10 +11569,8 @@ var BaseInteractionClient = /** @class */ (function () {
|
|
|
11303
11569
|
*/
|
|
11304
11570
|
var StandardInteractionClient = /** @class */ (function (_super) {
|
|
11305
11571
|
__extends$1(StandardInteractionClient, _super);
|
|
11306
|
-
function StandardInteractionClient(
|
|
11307
|
-
|
|
11308
|
-
_this.navigationClient = navigationClient;
|
|
11309
|
-
return _this;
|
|
11572
|
+
function StandardInteractionClient() {
|
|
11573
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
11310
11574
|
}
|
|
11311
11575
|
/**
|
|
11312
11576
|
* Generates an auth code request tied to the url request.
|
|
@@ -11336,7 +11600,7 @@ var StandardInteractionClient = /** @class */ (function (_super) {
|
|
|
11336
11600
|
*/
|
|
11337
11601
|
StandardInteractionClient.prototype.initializeLogoutRequest = function (logoutRequest) {
|
|
11338
11602
|
this.logger.verbose("initializeLogoutRequest called", logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
|
|
11339
|
-
var validLogoutRequest = __assign$1({ correlationId: this.browserCrypto.createNewGuid() }, logoutRequest);
|
|
11603
|
+
var validLogoutRequest = __assign$1({ correlationId: this.correlationId || this.browserCrypto.createNewGuid() }, logoutRequest);
|
|
11340
11604
|
/**
|
|
11341
11605
|
* Set logout_hint to be login_hint from ID Token Claims if present
|
|
11342
11606
|
* and logoutHint attribute wasn't manually set in logout request
|
|
@@ -11478,10 +11742,8 @@ var StandardInteractionClient = /** @class */ (function (_super) {
|
|
|
11478
11742
|
* @param hash
|
|
11479
11743
|
* @param interactionType
|
|
11480
11744
|
*/
|
|
11481
|
-
StandardInteractionClient.prototype.validateAndExtractStateFromHash = function (
|
|
11745
|
+
StandardInteractionClient.prototype.validateAndExtractStateFromHash = function (serverParams, interactionType, requestCorrelationId) {
|
|
11482
11746
|
this.logger.verbose("validateAndExtractStateFromHash called", requestCorrelationId);
|
|
11483
|
-
// Deserialize hash fragment response parameters.
|
|
11484
|
-
var serverParams = UrlString.getDeserializedHash(hash);
|
|
11485
11747
|
if (!serverParams.state) {
|
|
11486
11748
|
throw BrowserAuthError.createHashDoesNotContainStateError();
|
|
11487
11749
|
}
|
|
@@ -11786,7 +12048,18 @@ var InteractionHandler = /** @class */ (function () {
|
|
|
11786
12048
|
if (!requestState) {
|
|
11787
12049
|
throw ClientAuthError.createStateNotFoundError("Cached State");
|
|
11788
12050
|
}
|
|
11789
|
-
|
|
12051
|
+
try {
|
|
12052
|
+
authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);
|
|
12053
|
+
}
|
|
12054
|
+
catch (e) {
|
|
12055
|
+
if (e instanceof ServerError && e.subError === BrowserAuthErrorMessage.userCancelledError.code) {
|
|
12056
|
+
// Translate server error caused by user closing native prompt to corresponding first class MSAL error
|
|
12057
|
+
throw BrowserAuthError.createUserCancelledError();
|
|
12058
|
+
}
|
|
12059
|
+
else {
|
|
12060
|
+
throw e;
|
|
12061
|
+
}
|
|
12062
|
+
}
|
|
11790
12063
|
return [2 /*return*/, this.handleCodeResponseFromServer(authCodeResponse, state, authority, networkModule)];
|
|
11791
12064
|
});
|
|
11792
12065
|
});
|
|
@@ -11950,56 +12223,689 @@ var PopupHandler = /** @class */ (function (_super) {
|
|
|
11950
12223
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11951
12224
|
* Licensed under the MIT License.
|
|
11952
12225
|
*/
|
|
11953
|
-
var
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
|
|
12226
|
+
var NativeStatusCode;
|
|
12227
|
+
(function (NativeStatusCode) {
|
|
12228
|
+
NativeStatusCode["USER_INTERACTION_REQUIRED"] = "USER_INTERACTION_REQUIRED";
|
|
12229
|
+
NativeStatusCode["USER_CANCEL"] = "USER_CANCEL";
|
|
12230
|
+
NativeStatusCode["NO_NETWORK"] = "NO_NETWORK";
|
|
12231
|
+
NativeStatusCode["TRANSIENT_ERROR"] = "TRANSIENT_ERROR";
|
|
12232
|
+
NativeStatusCode["PERSISTENT_ERROR"] = "PERSISTENT_ERROR";
|
|
12233
|
+
})(NativeStatusCode || (NativeStatusCode = {}));
|
|
12234
|
+
var NativeAuthErrorMessage = {
|
|
12235
|
+
extensionError: {
|
|
12236
|
+
code: "ContentError"
|
|
12237
|
+
},
|
|
12238
|
+
userSwitch: {
|
|
12239
|
+
code: "user_switch",
|
|
12240
|
+
desc: "User attempted to switch accounts in the native broker, which is not allowed. All new accounts must sign-in through the standard web flow first, please try again."
|
|
12241
|
+
}
|
|
12242
|
+
};
|
|
12243
|
+
var NativeAuthError = /** @class */ (function (_super) {
|
|
12244
|
+
__extends$1(NativeAuthError, _super);
|
|
12245
|
+
function NativeAuthError(errorCode, description, ext) {
|
|
12246
|
+
var _this = _super.call(this, errorCode, description) || this;
|
|
12247
|
+
Object.setPrototypeOf(_this, NativeAuthError.prototype);
|
|
12248
|
+
_this.name = "NativeAuthError";
|
|
12249
|
+
_this.ext = ext;
|
|
12250
|
+
return _this;
|
|
11957
12251
|
}
|
|
11958
12252
|
/**
|
|
11959
|
-
*
|
|
11960
|
-
* @param request
|
|
12253
|
+
* These errors should result in a fallback to the 'standard' browser based auth flow.
|
|
11961
12254
|
*/
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
var popupWindowAttributes = request.popupWindowAttributes || {};
|
|
11966
|
-
// asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
|
|
11967
|
-
if (this.config.system.asyncPopups) {
|
|
11968
|
-
this.logger.verbose("asyncPopups set to true, acquiring token");
|
|
11969
|
-
// Passes on popup position and dimensions if in request
|
|
11970
|
-
return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes);
|
|
11971
|
-
}
|
|
11972
|
-
else {
|
|
11973
|
-
// asyncPopups flag is set to false. Opens popup before acquiring token.
|
|
11974
|
-
this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
|
|
11975
|
-
var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
|
|
11976
|
-
return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
|
|
11977
|
-
}
|
|
12255
|
+
NativeAuthError.prototype.isFatal = function () {
|
|
12256
|
+
if (this.ext && this.ext.status && this.ext.status === NativeStatusCode.PERSISTENT_ERROR) {
|
|
12257
|
+
return true;
|
|
11978
12258
|
}
|
|
11979
|
-
|
|
11980
|
-
|
|
12259
|
+
switch (this.errorCode) {
|
|
12260
|
+
case NativeAuthErrorMessage.extensionError.code:
|
|
12261
|
+
return true;
|
|
12262
|
+
default:
|
|
12263
|
+
return false;
|
|
11981
12264
|
}
|
|
11982
12265
|
};
|
|
11983
12266
|
/**
|
|
11984
|
-
*
|
|
11985
|
-
* @param
|
|
12267
|
+
* Create the appropriate error object based on the WAM status code.
|
|
12268
|
+
* @param code
|
|
12269
|
+
* @param description
|
|
12270
|
+
* @param ext
|
|
12271
|
+
* @returns
|
|
11986
12272
|
*/
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
if (this.config.system.asyncPopups) {
|
|
11997
|
-
this.logger.verbose("asyncPopups set to true");
|
|
11998
|
-
// Passes on popup position and dimensions if in request
|
|
11999
|
-
return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, undefined, mainWindowRedirectUri);
|
|
12273
|
+
NativeAuthError.createError = function (code, description, ext) {
|
|
12274
|
+
if (ext && ext.status) {
|
|
12275
|
+
switch (ext.status) {
|
|
12276
|
+
case NativeStatusCode.USER_INTERACTION_REQUIRED:
|
|
12277
|
+
return new InteractionRequiredAuthError(code, description);
|
|
12278
|
+
case NativeStatusCode.USER_CANCEL:
|
|
12279
|
+
return BrowserAuthError.createUserCancelledError();
|
|
12280
|
+
case NativeStatusCode.NO_NETWORK:
|
|
12281
|
+
return BrowserAuthError.createNoNetworkConnectivityError();
|
|
12000
12282
|
}
|
|
12001
|
-
|
|
12002
|
-
|
|
12283
|
+
}
|
|
12284
|
+
return new NativeAuthError(code, description, ext);
|
|
12285
|
+
};
|
|
12286
|
+
/**
|
|
12287
|
+
* Creates user switch error when the user chooses a different account in the native broker prompt
|
|
12288
|
+
* @returns
|
|
12289
|
+
*/
|
|
12290
|
+
NativeAuthError.createUserSwitchError = function () {
|
|
12291
|
+
return new NativeAuthError(NativeAuthErrorMessage.userSwitch.code, NativeAuthErrorMessage.userSwitch.desc);
|
|
12292
|
+
};
|
|
12293
|
+
return NativeAuthError;
|
|
12294
|
+
}(AuthError));
|
|
12295
|
+
|
|
12296
|
+
/*
|
|
12297
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12298
|
+
* Licensed under the MIT License.
|
|
12299
|
+
*/
|
|
12300
|
+
var NativeInteractionClient = /** @class */ (function (_super) {
|
|
12301
|
+
__extends$1(NativeInteractionClient, _super);
|
|
12302
|
+
function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
|
|
12303
|
+
var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
|
|
12304
|
+
_this.apiId = apiId;
|
|
12305
|
+
_this.accountId = accountId;
|
|
12306
|
+
_this.nativeMessageHandler = provider;
|
|
12307
|
+
return _this;
|
|
12308
|
+
}
|
|
12309
|
+
/**
|
|
12310
|
+
* Acquire token from native platform via browser extension
|
|
12311
|
+
* @param request
|
|
12312
|
+
*/
|
|
12313
|
+
NativeInteractionClient.prototype.acquireToken = function (request) {
|
|
12314
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12315
|
+
var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
|
|
12316
|
+
return __generator$1(this, function (_a) {
|
|
12317
|
+
switch (_a.label) {
|
|
12318
|
+
case 0:
|
|
12319
|
+
this.logger.trace("NativeInteractionClient - acquireToken called.");
|
|
12320
|
+
nativeATMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
|
|
12321
|
+
return [4 /*yield*/, this.initializeNativeRequest(request)];
|
|
12322
|
+
case 1:
|
|
12323
|
+
nativeRequest = _a.sent();
|
|
12324
|
+
messageBody = {
|
|
12325
|
+
method: NativeExtensionMethod.GetToken,
|
|
12326
|
+
request: nativeRequest
|
|
12327
|
+
};
|
|
12328
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
12329
|
+
return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
|
|
12330
|
+
case 2:
|
|
12331
|
+
response = _a.sent();
|
|
12332
|
+
validatedResponse = this.validateNativeResponse(response);
|
|
12333
|
+
return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
|
|
12334
|
+
.then(function (result) {
|
|
12335
|
+
nativeATMeasurement.endMeasurement({
|
|
12336
|
+
success: true,
|
|
12337
|
+
isNativeBroker: true
|
|
12338
|
+
});
|
|
12339
|
+
return result;
|
|
12340
|
+
})
|
|
12341
|
+
.catch(function (error) {
|
|
12342
|
+
nativeATMeasurement.endMeasurement({
|
|
12343
|
+
success: false,
|
|
12344
|
+
isNativeBroker: true
|
|
12345
|
+
});
|
|
12346
|
+
throw error;
|
|
12347
|
+
})];
|
|
12348
|
+
}
|
|
12349
|
+
});
|
|
12350
|
+
});
|
|
12351
|
+
};
|
|
12352
|
+
/**
|
|
12353
|
+
* Acquires a token from native platform then redirects to the redirectUri instead of returning the response
|
|
12354
|
+
* @param request
|
|
12355
|
+
*/
|
|
12356
|
+
NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
|
|
12357
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12358
|
+
var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
|
|
12359
|
+
return __generator$1(this, function (_a) {
|
|
12360
|
+
switch (_a.label) {
|
|
12361
|
+
case 0:
|
|
12362
|
+
this.logger.trace("NativeInteractionClient - acquireTokenRedirect called.");
|
|
12363
|
+
return [4 /*yield*/, this.initializeNativeRequest(request)];
|
|
12364
|
+
case 1:
|
|
12365
|
+
nativeRequest = _a.sent();
|
|
12366
|
+
messageBody = {
|
|
12367
|
+
method: NativeExtensionMethod.GetToken,
|
|
12368
|
+
request: nativeRequest
|
|
12369
|
+
};
|
|
12370
|
+
_a.label = 2;
|
|
12371
|
+
case 2:
|
|
12372
|
+
_a.trys.push([2, 4, , 5]);
|
|
12373
|
+
return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
|
|
12374
|
+
case 3:
|
|
12375
|
+
response = _a.sent();
|
|
12376
|
+
this.validateNativeResponse(response);
|
|
12377
|
+
return [3 /*break*/, 5];
|
|
12378
|
+
case 4:
|
|
12379
|
+
e_1 = _a.sent();
|
|
12380
|
+
// Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
|
|
12381
|
+
if (e_1 instanceof NativeAuthError && e_1.isFatal()) {
|
|
12382
|
+
throw e_1;
|
|
12383
|
+
}
|
|
12384
|
+
return [3 /*break*/, 5];
|
|
12385
|
+
case 5:
|
|
12386
|
+
this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.NATIVE_REQUEST, JSON.stringify(nativeRequest), true);
|
|
12387
|
+
navigationOptions = {
|
|
12388
|
+
apiId: exports.ApiId.acquireTokenRedirect,
|
|
12389
|
+
timeout: this.config.system.redirectNavigationTimeout,
|
|
12390
|
+
noHistory: false
|
|
12391
|
+
};
|
|
12392
|
+
redirectUri = this.config.auth.navigateToLoginRequestUrl ? window.location.href : this.getRedirectUri(request.redirectUri);
|
|
12393
|
+
return [4 /*yield*/, this.navigationClient.navigateExternal(redirectUri, navigationOptions)];
|
|
12394
|
+
case 6:
|
|
12395
|
+
_a.sent(); // Need to treat this as external to ensure handleRedirectPromise is run again
|
|
12396
|
+
return [2 /*return*/];
|
|
12397
|
+
}
|
|
12398
|
+
});
|
|
12399
|
+
});
|
|
12400
|
+
};
|
|
12401
|
+
/**
|
|
12402
|
+
* If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
|
|
12403
|
+
*/
|
|
12404
|
+
NativeInteractionClient.prototype.handleRedirectPromise = function () {
|
|
12405
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12406
|
+
var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
|
|
12407
|
+
return __generator$1(this, function (_a) {
|
|
12408
|
+
switch (_a.label) {
|
|
12409
|
+
case 0:
|
|
12410
|
+
this.logger.trace("NativeInteractionClient - handleRedirectPromise called.");
|
|
12411
|
+
if (!this.browserStorage.isInteractionInProgress(true)) {
|
|
12412
|
+
this.logger.info("handleRedirectPromise called but there is no interaction in progress, returning null.");
|
|
12413
|
+
return [2 /*return*/, null];
|
|
12414
|
+
}
|
|
12415
|
+
cachedRequest = this.browserStorage.getCachedNativeRequest();
|
|
12416
|
+
if (!cachedRequest) {
|
|
12417
|
+
this.logger.verbose("NativeInteractionClient - handleRedirectPromise called but there is no cached request, returning null.");
|
|
12418
|
+
return [2 /*return*/, null];
|
|
12419
|
+
}
|
|
12420
|
+
this.browserStorage.removeItem(this.browserStorage.generateCacheKey(exports.TemporaryCacheKeys.NATIVE_REQUEST));
|
|
12421
|
+
messageBody = {
|
|
12422
|
+
method: NativeExtensionMethod.GetToken,
|
|
12423
|
+
request: cachedRequest
|
|
12424
|
+
};
|
|
12425
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
12426
|
+
_a.label = 1;
|
|
12427
|
+
case 1:
|
|
12428
|
+
_a.trys.push([1, 3, , 4]);
|
|
12429
|
+
this.logger.verbose("NativeInteractionClient - handleRedirectPromise sending message to native broker.");
|
|
12430
|
+
return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
|
|
12431
|
+
case 2:
|
|
12432
|
+
response = _a.sent();
|
|
12433
|
+
this.validateNativeResponse(response);
|
|
12434
|
+
result = this.handleNativeResponse(response, cachedRequest, reqTimestamp);
|
|
12435
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
12436
|
+
return [2 /*return*/, result];
|
|
12437
|
+
case 3:
|
|
12438
|
+
e_2 = _a.sent();
|
|
12439
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
12440
|
+
throw e_2;
|
|
12441
|
+
case 4: return [2 /*return*/];
|
|
12442
|
+
}
|
|
12443
|
+
});
|
|
12444
|
+
});
|
|
12445
|
+
};
|
|
12446
|
+
/**
|
|
12447
|
+
* Logout from native platform via browser extension
|
|
12448
|
+
* @param request
|
|
12449
|
+
*/
|
|
12450
|
+
NativeInteractionClient.prototype.logout = function () {
|
|
12451
|
+
this.logger.trace("NativeInteractionClient - logout called.");
|
|
12452
|
+
return Promise.reject("Logout not implemented yet");
|
|
12453
|
+
};
|
|
12454
|
+
/**
|
|
12455
|
+
* Transform response from native platform into AuthenticationResult object which will be returned to the end user
|
|
12456
|
+
* @param response
|
|
12457
|
+
* @param request
|
|
12458
|
+
* @param reqTimestamp
|
|
12459
|
+
*/
|
|
12460
|
+
NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
|
|
12461
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12462
|
+
var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result;
|
|
12463
|
+
var _this = this;
|
|
12464
|
+
return __generator$1(this, function (_b) {
|
|
12465
|
+
switch (_b.label) {
|
|
12466
|
+
case 0:
|
|
12467
|
+
this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
|
|
12468
|
+
if (response.account.id !== request.accountId) {
|
|
12469
|
+
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
12470
|
+
throw NativeAuthError.createUserSwitchError();
|
|
12471
|
+
}
|
|
12472
|
+
idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
12473
|
+
return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
|
|
12474
|
+
case 1:
|
|
12475
|
+
authority = _b.sent();
|
|
12476
|
+
authorityPreferredCache = authority.getPreferredCache();
|
|
12477
|
+
homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
12478
|
+
accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
|
|
12479
|
+
this.browserStorage.setAccount(accountEntity);
|
|
12480
|
+
responseScopes = response.scopes ? ScopeSet.fromString(response.scopes) : ScopeSet.fromString(request.scopes);
|
|
12481
|
+
accountProperties = response.account.properties || {};
|
|
12482
|
+
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
12483
|
+
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
12484
|
+
responseTokenType = exports.AuthenticationScheme.BEARER;
|
|
12485
|
+
_a = request.token_type;
|
|
12486
|
+
switch (_a) {
|
|
12487
|
+
case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
|
|
12488
|
+
}
|
|
12489
|
+
return [3 /*break*/, 4];
|
|
12490
|
+
case 2:
|
|
12491
|
+
// Set the token type to POP in the response
|
|
12492
|
+
responseTokenType = exports.AuthenticationScheme.POP;
|
|
12493
|
+
// Check if native layer returned an SHR token
|
|
12494
|
+
if (response.shr) {
|
|
12495
|
+
this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
|
|
12496
|
+
responseAccessToken = response.shr;
|
|
12497
|
+
return [3 /*break*/, 5];
|
|
12498
|
+
}
|
|
12499
|
+
popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
12500
|
+
shrParameters = {
|
|
12501
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
12502
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
12503
|
+
shrClaims: request.shrClaims,
|
|
12504
|
+
shrNonce: request.shrNonce
|
|
12505
|
+
};
|
|
12506
|
+
return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, shrParameters)];
|
|
12507
|
+
case 3:
|
|
12508
|
+
responseAccessToken = _b.sent();
|
|
12509
|
+
return [3 /*break*/, 5];
|
|
12510
|
+
case 4:
|
|
12511
|
+
{
|
|
12512
|
+
responseAccessToken = response.access_token;
|
|
12513
|
+
}
|
|
12514
|
+
_b.label = 5;
|
|
12515
|
+
case 5:
|
|
12516
|
+
result = {
|
|
12517
|
+
authority: authority.canonicalAuthority,
|
|
12518
|
+
uniqueId: uid,
|
|
12519
|
+
tenantId: tid,
|
|
12520
|
+
scopes: responseScopes.asArray(),
|
|
12521
|
+
account: accountEntity.getAccountInfo(),
|
|
12522
|
+
idToken: response.id_token,
|
|
12523
|
+
idTokenClaims: idTokenObj.claims,
|
|
12524
|
+
accessToken: responseAccessToken,
|
|
12525
|
+
fromCache: false,
|
|
12526
|
+
expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
|
|
12527
|
+
tokenType: responseTokenType,
|
|
12528
|
+
correlationId: this.correlationId,
|
|
12529
|
+
state: response.state,
|
|
12530
|
+
fromNativeBroker: true
|
|
12531
|
+
};
|
|
12532
|
+
// Remove any existing cached tokens for this account
|
|
12533
|
+
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
12534
|
+
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
12535
|
+
});
|
|
12536
|
+
return [2 /*return*/, result];
|
|
12537
|
+
}
|
|
12538
|
+
});
|
|
12539
|
+
});
|
|
12540
|
+
};
|
|
12541
|
+
/**
|
|
12542
|
+
* Validates native platform response before processing
|
|
12543
|
+
* @param response
|
|
12544
|
+
*/
|
|
12545
|
+
NativeInteractionClient.prototype.validateNativeResponse = function (response) {
|
|
12546
|
+
if (response.hasOwnProperty("access_token") &&
|
|
12547
|
+
response.hasOwnProperty("id_token") &&
|
|
12548
|
+
response.hasOwnProperty("client_info") &&
|
|
12549
|
+
response.hasOwnProperty("account") &&
|
|
12550
|
+
response.hasOwnProperty("scopes") &&
|
|
12551
|
+
response.hasOwnProperty("expires_in")) {
|
|
12552
|
+
return response;
|
|
12553
|
+
}
|
|
12554
|
+
else {
|
|
12555
|
+
throw NativeAuthError.createUnexpectedError("Response missing expected properties.");
|
|
12556
|
+
}
|
|
12557
|
+
};
|
|
12558
|
+
/**
|
|
12559
|
+
* Translates developer provided request object into NativeRequest object
|
|
12560
|
+
* @param request
|
|
12561
|
+
*/
|
|
12562
|
+
NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
|
|
12563
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12564
|
+
var authority, canonicalAuthority, scopes, scopeSet, instanceAware, validatedRequest, shrParameters, popTokenGenerator, cnf, _a;
|
|
12565
|
+
return __generator$1(this, function (_b) {
|
|
12566
|
+
switch (_b.label) {
|
|
12567
|
+
case 0:
|
|
12568
|
+
this.logger.trace("NativeInteractionClient - initializeNativeRequest called");
|
|
12569
|
+
authority = request.authority || this.config.auth.authority;
|
|
12570
|
+
canonicalAuthority = new UrlString(authority);
|
|
12571
|
+
canonicalAuthority.validateAsUri();
|
|
12572
|
+
scopes = request && request.scopes || [];
|
|
12573
|
+
scopeSet = new ScopeSet(scopes);
|
|
12574
|
+
scopeSet.appendScopes(OIDC_DEFAULT_SCOPES);
|
|
12575
|
+
if (request.prompt) {
|
|
12576
|
+
switch (request.prompt) {
|
|
12577
|
+
case PromptValue.NONE:
|
|
12578
|
+
case PromptValue.CONSENT:
|
|
12579
|
+
this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
|
|
12580
|
+
break;
|
|
12581
|
+
default:
|
|
12582
|
+
this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
|
|
12583
|
+
throw BrowserAuthError.createNativePromptParameterNotSupportedError();
|
|
12584
|
+
}
|
|
12585
|
+
}
|
|
12586
|
+
instanceAware = !!(request.extraQueryParameters && request.extraQueryParameters.instance_aware);
|
|
12587
|
+
validatedRequest = __assign$1(__assign$1({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), correlationId: this.correlationId, instance_aware: instanceAware, token_type: request.authenticationScheme, extraParameters: __assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), extendedExpiryToken: false // Make this configurable?
|
|
12588
|
+
});
|
|
12589
|
+
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
|
|
12590
|
+
shrParameters = {
|
|
12591
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
12592
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
12593
|
+
shrClaims: request.shrClaims,
|
|
12594
|
+
shrNonce: request.shrNonce
|
|
12595
|
+
};
|
|
12596
|
+
popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
12597
|
+
return [4 /*yield*/, popTokenGenerator.generateCnf(shrParameters)];
|
|
12598
|
+
case 1:
|
|
12599
|
+
cnf = _b.sent();
|
|
12600
|
+
// to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
|
|
12601
|
+
_a = validatedRequest;
|
|
12602
|
+
return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
|
|
12603
|
+
case 2:
|
|
12604
|
+
// to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
|
|
12605
|
+
_a.req_cnf = _b.sent();
|
|
12606
|
+
_b.label = 3;
|
|
12607
|
+
case 3:
|
|
12608
|
+
if (this.apiId === exports.ApiId.ssoSilent || this.apiId === exports.ApiId.acquireTokenSilent_silentFlow) {
|
|
12609
|
+
validatedRequest.prompt = PromptValue.NONE;
|
|
12610
|
+
}
|
|
12611
|
+
return [2 /*return*/, validatedRequest];
|
|
12612
|
+
}
|
|
12613
|
+
});
|
|
12614
|
+
});
|
|
12615
|
+
};
|
|
12616
|
+
return NativeInteractionClient;
|
|
12617
|
+
}(BaseInteractionClient));
|
|
12618
|
+
|
|
12619
|
+
/*
|
|
12620
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12621
|
+
* Licensed under the MIT License.
|
|
12622
|
+
*/
|
|
12623
|
+
var NativeMessageHandler = /** @class */ (function () {
|
|
12624
|
+
function NativeMessageHandler(logger, handshakeTimeoutMs, extensionId) {
|
|
12625
|
+
this.logger = logger;
|
|
12626
|
+
this.handshakeTimeoutMs = handshakeTimeoutMs;
|
|
12627
|
+
this.extensionId = extensionId;
|
|
12628
|
+
this.resolvers = new Map(); // Used for non-handshake messages
|
|
12629
|
+
this.handshakeResolvers = new Map(); // Used for handshake messages
|
|
12630
|
+
this.responseId = 0;
|
|
12631
|
+
this.messageChannel = new MessageChannel();
|
|
12632
|
+
this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
|
|
12633
|
+
}
|
|
12634
|
+
/**
|
|
12635
|
+
* Sends a given message to the extension and resolves with the extension response
|
|
12636
|
+
* @param body
|
|
12637
|
+
*/
|
|
12638
|
+
NativeMessageHandler.prototype.sendMessage = function (body) {
|
|
12639
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12640
|
+
var req;
|
|
12641
|
+
var _this = this;
|
|
12642
|
+
return __generator$1(this, function (_a) {
|
|
12643
|
+
this.logger.trace("NativeMessageHandler - sendMessage called.");
|
|
12644
|
+
req = {
|
|
12645
|
+
channel: NativeConstants.CHANNEL_ID,
|
|
12646
|
+
extensionId: this.extensionId,
|
|
12647
|
+
responseId: this.responseId++,
|
|
12648
|
+
body: body
|
|
12649
|
+
};
|
|
12650
|
+
this.logger.trace("NativeMessageHandler - Sending request to browser extension");
|
|
12651
|
+
this.logger.tracePii("NativeMessageHandler - Sending request to browser extension: " + JSON.stringify(req));
|
|
12652
|
+
this.messageChannel.port1.postMessage(req);
|
|
12653
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
12654
|
+
_this.resolvers.set(req.responseId, { resolve: resolve, reject: reject });
|
|
12655
|
+
})];
|
|
12656
|
+
});
|
|
12657
|
+
});
|
|
12658
|
+
};
|
|
12659
|
+
/**
|
|
12660
|
+
* Returns an instance of the MessageHandler that has successfully established a connection with an extension
|
|
12661
|
+
* @param logger
|
|
12662
|
+
* @param handshakeTimeoutMs
|
|
12663
|
+
*/
|
|
12664
|
+
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs) {
|
|
12665
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12666
|
+
var preferredProvider, backupProvider;
|
|
12667
|
+
return __generator$1(this, function (_a) {
|
|
12668
|
+
switch (_a.label) {
|
|
12669
|
+
case 0:
|
|
12670
|
+
logger.trace("NativeMessageHandler - createProvider called.");
|
|
12671
|
+
_a.label = 1;
|
|
12672
|
+
case 1:
|
|
12673
|
+
_a.trys.push([1, 3, , 5]);
|
|
12674
|
+
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
12675
|
+
return [4 /*yield*/, preferredProvider.sendHandshakeRequest()];
|
|
12676
|
+
case 2:
|
|
12677
|
+
_a.sent();
|
|
12678
|
+
return [2 /*return*/, preferredProvider];
|
|
12679
|
+
case 3:
|
|
12680
|
+
_a.sent();
|
|
12681
|
+
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);
|
|
12682
|
+
return [4 /*yield*/, backupProvider.sendHandshakeRequest()];
|
|
12683
|
+
case 4:
|
|
12684
|
+
_a.sent();
|
|
12685
|
+
return [2 /*return*/, backupProvider];
|
|
12686
|
+
case 5: return [2 /*return*/];
|
|
12687
|
+
}
|
|
12688
|
+
});
|
|
12689
|
+
});
|
|
12690
|
+
};
|
|
12691
|
+
/**
|
|
12692
|
+
* Send handshake request helper.
|
|
12693
|
+
*/
|
|
12694
|
+
NativeMessageHandler.prototype.sendHandshakeRequest = function () {
|
|
12695
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12696
|
+
var req;
|
|
12697
|
+
var _this = this;
|
|
12698
|
+
return __generator$1(this, function (_a) {
|
|
12699
|
+
this.logger.trace("NativeMessageHandler - sendHandshakeRequest called.");
|
|
12700
|
+
// Register this event listener before sending handshake
|
|
12701
|
+
window.addEventListener("message", this.windowListener, false); // false is important, because content script message processing should work first
|
|
12702
|
+
req = {
|
|
12703
|
+
channel: NativeConstants.CHANNEL_ID,
|
|
12704
|
+
extensionId: this.extensionId,
|
|
12705
|
+
responseId: this.responseId++,
|
|
12706
|
+
body: {
|
|
12707
|
+
method: NativeExtensionMethod.HandshakeRequest
|
|
12708
|
+
}
|
|
12709
|
+
};
|
|
12710
|
+
this.messageChannel.port1.onmessage = function (event) {
|
|
12711
|
+
_this.onChannelMessage(event);
|
|
12712
|
+
};
|
|
12713
|
+
window.postMessage(req, window.origin, [this.messageChannel.port2]);
|
|
12714
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
12715
|
+
_this.handshakeResolvers.set(req.responseId, { resolve: resolve, reject: reject });
|
|
12716
|
+
_this.timeoutId = window.setTimeout(function () {
|
|
12717
|
+
/*
|
|
12718
|
+
* Throw an error if neither HandshakeResponse nor original Handshake request are received in a reasonable timeframe.
|
|
12719
|
+
* This typically suggests an event handler stopped propagation of the Handshake request but did not respond to it on the MessageChannel port
|
|
12720
|
+
*/
|
|
12721
|
+
window.removeEventListener("message", _this.windowListener, false);
|
|
12722
|
+
_this.messageChannel.port1.close();
|
|
12723
|
+
_this.messageChannel.port2.close();
|
|
12724
|
+
reject(BrowserAuthError.createNativeHandshakeTimeoutError());
|
|
12725
|
+
_this.handshakeResolvers.delete(req.responseId);
|
|
12726
|
+
}, _this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
|
|
12727
|
+
})];
|
|
12728
|
+
});
|
|
12729
|
+
});
|
|
12730
|
+
};
|
|
12731
|
+
/**
|
|
12732
|
+
* Invoked when a message is posted to the window. If a handshake request is received it means the extension is not installed.
|
|
12733
|
+
* @param event
|
|
12734
|
+
*/
|
|
12735
|
+
NativeMessageHandler.prototype.onWindowMessage = function (event) {
|
|
12736
|
+
this.logger.trace("NativeMessageHandler - onWindowMessage called");
|
|
12737
|
+
// We only accept messages from ourselves
|
|
12738
|
+
if (event.source !== window) {
|
|
12739
|
+
return;
|
|
12740
|
+
}
|
|
12741
|
+
var request = event.data;
|
|
12742
|
+
if (!request.channel || request.channel !== NativeConstants.CHANNEL_ID) {
|
|
12743
|
+
return;
|
|
12744
|
+
}
|
|
12745
|
+
if (request.extensionId && request.extensionId !== this.extensionId) {
|
|
12746
|
+
return;
|
|
12747
|
+
}
|
|
12748
|
+
if (request.body.method === NativeExtensionMethod.HandshakeRequest) {
|
|
12749
|
+
// If we receive this message back it means no extension intercepted the request, meaning no extension supporting handshake protocol is installed
|
|
12750
|
+
this.logger.verbose(request.extensionId ? "Extension with id: " + request.extensionId + " not installed" : "No extension installed");
|
|
12751
|
+
clearTimeout(this.timeoutId);
|
|
12752
|
+
this.messageChannel.port1.close();
|
|
12753
|
+
this.messageChannel.port2.close();
|
|
12754
|
+
window.removeEventListener("message", this.windowListener, false);
|
|
12755
|
+
var handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
|
12756
|
+
if (handshakeResolver) {
|
|
12757
|
+
handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());
|
|
12758
|
+
}
|
|
12759
|
+
}
|
|
12760
|
+
};
|
|
12761
|
+
/**
|
|
12762
|
+
* Invoked when a message is received from the extension on the MessageChannel port
|
|
12763
|
+
* @param event
|
|
12764
|
+
*/
|
|
12765
|
+
NativeMessageHandler.prototype.onChannelMessage = function (event) {
|
|
12766
|
+
this.logger.trace("NativeMessageHandler - onChannelMessage called.");
|
|
12767
|
+
var request = event.data;
|
|
12768
|
+
var resolver = this.resolvers.get(request.responseId);
|
|
12769
|
+
var handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
|
12770
|
+
try {
|
|
12771
|
+
var method = request.body.method;
|
|
12772
|
+
if (method === NativeExtensionMethod.Response) {
|
|
12773
|
+
if (!resolver) {
|
|
12774
|
+
return;
|
|
12775
|
+
}
|
|
12776
|
+
var response = request.body.response;
|
|
12777
|
+
this.logger.trace("NativeMessageHandler - Received response from browser extension");
|
|
12778
|
+
this.logger.tracePii("NativeMessageHandler - Received response from browser extension: " + JSON.stringify(response));
|
|
12779
|
+
if (response.status !== "Success") {
|
|
12780
|
+
resolver.reject(NativeAuthError.createError(response.code, response.description, response.ext));
|
|
12781
|
+
}
|
|
12782
|
+
else if (response.result) {
|
|
12783
|
+
if (response.result["code"] && response.result["description"]) {
|
|
12784
|
+
resolver.reject(NativeAuthError.createError(response.result["code"], response.result["description"], response.result["ext"]));
|
|
12785
|
+
}
|
|
12786
|
+
else {
|
|
12787
|
+
resolver.resolve(response.result);
|
|
12788
|
+
}
|
|
12789
|
+
}
|
|
12790
|
+
else {
|
|
12791
|
+
throw AuthError.createUnexpectedError("Event does not contain result.");
|
|
12792
|
+
}
|
|
12793
|
+
this.resolvers.delete(request.responseId);
|
|
12794
|
+
}
|
|
12795
|
+
else if (method === NativeExtensionMethod.HandshakeResponse) {
|
|
12796
|
+
if (!handshakeResolver) {
|
|
12797
|
+
return;
|
|
12798
|
+
}
|
|
12799
|
+
clearTimeout(this.timeoutId); // Clear setTimeout
|
|
12800
|
+
window.removeEventListener("message", this.windowListener, false); // Remove 'No extension' listener
|
|
12801
|
+
this.extensionId = request.extensionId;
|
|
12802
|
+
this.logger.verbose("NativeMessageHandler - Received HandshakeResponse from extension: " + this.extensionId);
|
|
12803
|
+
handshakeResolver.resolve();
|
|
12804
|
+
this.handshakeResolvers.delete(request.responseId);
|
|
12805
|
+
}
|
|
12806
|
+
// Do nothing if method is not Response or HandshakeResponse
|
|
12807
|
+
}
|
|
12808
|
+
catch (err) {
|
|
12809
|
+
this.logger.error("Error parsing response from WAM Extension");
|
|
12810
|
+
this.logger.errorPii("Error parsing response from WAM Extension: " + err.toString());
|
|
12811
|
+
this.logger.errorPii("Unable to parse " + event);
|
|
12812
|
+
if (resolver) {
|
|
12813
|
+
resolver.reject(err);
|
|
12814
|
+
}
|
|
12815
|
+
else if (handshakeResolver) {
|
|
12816
|
+
handshakeResolver.reject(err);
|
|
12817
|
+
}
|
|
12818
|
+
}
|
|
12819
|
+
};
|
|
12820
|
+
/**
|
|
12821
|
+
* Returns boolean indicating whether or not the request should attempt to use native broker
|
|
12822
|
+
* @param logger
|
|
12823
|
+
* @param config
|
|
12824
|
+
* @param nativeExtensionProvider
|
|
12825
|
+
* @param authenticationScheme
|
|
12826
|
+
*/
|
|
12827
|
+
NativeMessageHandler.isNativeAvailable = function (config, logger, nativeExtensionProvider, authenticationScheme) {
|
|
12828
|
+
logger.trace("isNativeAvailable called");
|
|
12829
|
+
if (!config.system.allowNativeBroker) {
|
|
12830
|
+
logger.trace("isNativeAvailable: allowNativeBroker is not enabled, returning false");
|
|
12831
|
+
// Developer disabled WAM
|
|
12832
|
+
return false;
|
|
12833
|
+
}
|
|
12834
|
+
if (!nativeExtensionProvider) {
|
|
12835
|
+
logger.trace("isNativeAvailable: WAM extension provider is not initialized, returning false");
|
|
12836
|
+
// Extension is not available
|
|
12837
|
+
return false;
|
|
12838
|
+
}
|
|
12839
|
+
if (authenticationScheme) {
|
|
12840
|
+
switch (authenticationScheme) {
|
|
12841
|
+
case exports.AuthenticationScheme.BEARER:
|
|
12842
|
+
case exports.AuthenticationScheme.POP:
|
|
12843
|
+
logger.trace("isNativeAvailable: authenticationScheme is supported, returning true");
|
|
12844
|
+
return true;
|
|
12845
|
+
default:
|
|
12846
|
+
logger.trace("isNativeAvailable: authenticationScheme is not supported, returning false");
|
|
12847
|
+
return false;
|
|
12848
|
+
}
|
|
12849
|
+
}
|
|
12850
|
+
return true;
|
|
12851
|
+
};
|
|
12852
|
+
return NativeMessageHandler;
|
|
12853
|
+
}());
|
|
12854
|
+
|
|
12855
|
+
/*
|
|
12856
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12857
|
+
* Licensed under the MIT License.
|
|
12858
|
+
*/
|
|
12859
|
+
var PopupClient = /** @class */ (function (_super) {
|
|
12860
|
+
__extends$1(PopupClient, _super);
|
|
12861
|
+
function PopupClient() {
|
|
12862
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
12863
|
+
}
|
|
12864
|
+
/**
|
|
12865
|
+
* Acquires tokens by opening a popup window to the /authorize endpoint of the authority
|
|
12866
|
+
* @param request
|
|
12867
|
+
*/
|
|
12868
|
+
PopupClient.prototype.acquireToken = function (request) {
|
|
12869
|
+
try {
|
|
12870
|
+
var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority, this.correlationId);
|
|
12871
|
+
var popupWindowAttributes = request.popupWindowAttributes || {};
|
|
12872
|
+
// asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
|
|
12873
|
+
if (this.config.system.asyncPopups) {
|
|
12874
|
+
this.logger.verbose("asyncPopups set to true, acquiring token");
|
|
12875
|
+
// Passes on popup position and dimensions if in request
|
|
12876
|
+
return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes);
|
|
12877
|
+
}
|
|
12878
|
+
else {
|
|
12879
|
+
// asyncPopups flag is set to false. Opens popup before acquiring token.
|
|
12880
|
+
this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
|
|
12881
|
+
var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
|
|
12882
|
+
return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
|
|
12883
|
+
}
|
|
12884
|
+
}
|
|
12885
|
+
catch (e) {
|
|
12886
|
+
return Promise.reject(e);
|
|
12887
|
+
}
|
|
12888
|
+
};
|
|
12889
|
+
/**
|
|
12890
|
+
* Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server
|
|
12891
|
+
* @param logoutRequest
|
|
12892
|
+
*/
|
|
12893
|
+
PopupClient.prototype.logout = function (logoutRequest) {
|
|
12894
|
+
try {
|
|
12895
|
+
this.logger.verbose("logoutPopup called");
|
|
12896
|
+
var validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
|
|
12897
|
+
var popupName = PopupUtils.generateLogoutPopupName(this.config.auth.clientId, validLogoutRequest);
|
|
12898
|
+
var authority = logoutRequest && logoutRequest.authority;
|
|
12899
|
+
var mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
|
|
12900
|
+
var popupWindowAttributes = (logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.popupWindowAttributes) || {};
|
|
12901
|
+
// asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
|
|
12902
|
+
if (this.config.system.asyncPopups) {
|
|
12903
|
+
this.logger.verbose("asyncPopups set to true");
|
|
12904
|
+
// Passes on popup position and dimensions if in request
|
|
12905
|
+
return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, undefined, mainWindowRedirectUri);
|
|
12906
|
+
}
|
|
12907
|
+
else {
|
|
12908
|
+
// asyncPopups flag is set to false. Opens popup before logging out.
|
|
12003
12909
|
this.logger.verbose("asyncPopup set to false, opening popup");
|
|
12004
12910
|
var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
|
|
12005
12911
|
return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, popup, mainWindowRedirectUri);
|
|
@@ -12021,7 +12927,8 @@ var PopupClient = /** @class */ (function (_super) {
|
|
|
12021
12927
|
*/
|
|
12022
12928
|
PopupClient.prototype.acquireTokenPopupAsync = function (request, popupName, popupWindowAttributes, popup) {
|
|
12023
12929
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12024
|
-
var serverTelemetryManager, validRequest, authCodeRequest, authClient, navigateUrl, interactionHandler, popupParameters, popupWindow, hash,
|
|
12930
|
+
var serverTelemetryManager, validRequest, authCodeRequest, authClient, isNativeBroker, fetchNativeAccountIdMeasurement, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, serverParams, state_1, nativeInteractionClient, userRequestState, result, e_1;
|
|
12931
|
+
var _this = this;
|
|
12025
12932
|
return __generator$1(this, function (_a) {
|
|
12026
12933
|
switch (_a.label) {
|
|
12027
12934
|
case 0:
|
|
@@ -12041,7 +12948,12 @@ var PopupClient = /** @class */ (function (_super) {
|
|
|
12041
12948
|
case 4:
|
|
12042
12949
|
authClient = _a.sent();
|
|
12043
12950
|
this.logger.verbose("Auth code client created");
|
|
12044
|
-
|
|
12951
|
+
isNativeBroker = NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
|
|
12952
|
+
fetchNativeAccountIdMeasurement = void 0;
|
|
12953
|
+
if (isNativeBroker) {
|
|
12954
|
+
fetchNativeAccountIdMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.FetchAccountIdWithNativeBroker, request.correlationId);
|
|
12955
|
+
}
|
|
12956
|
+
return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: isNativeBroker }))];
|
|
12045
12957
|
case 5:
|
|
12046
12958
|
navigateUrl = _a.sent();
|
|
12047
12959
|
interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
|
|
@@ -12055,10 +12967,30 @@ var PopupClient = /** @class */ (function (_super) {
|
|
|
12055
12967
|
return [4 /*yield*/, interactionHandler.monitorPopupForHash(popupWindow)];
|
|
12056
12968
|
case 6:
|
|
12057
12969
|
hash = _a.sent();
|
|
12058
|
-
|
|
12970
|
+
serverParams = UrlString.getDeserializedHash(hash);
|
|
12971
|
+
state_1 = this.validateAndExtractStateFromHash(serverParams, exports.InteractionType.Popup, validRequest.correlationId);
|
|
12059
12972
|
// Remove throttle if it exists
|
|
12060
12973
|
ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);
|
|
12061
|
-
|
|
12974
|
+
if (serverParams.accountId) {
|
|
12975
|
+
this.logger.verbose("Account id found in hash, calling WAM for token");
|
|
12976
|
+
// end measurement for server call with native brokering enabled
|
|
12977
|
+
if (fetchNativeAccountIdMeasurement) {
|
|
12978
|
+
fetchNativeAccountIdMeasurement.endMeasurement({
|
|
12979
|
+
success: true,
|
|
12980
|
+
isNativeBroker: true
|
|
12981
|
+
});
|
|
12982
|
+
}
|
|
12983
|
+
if (!this.nativeMessageHandler) {
|
|
12984
|
+
throw BrowserAuthError.createNativeConnectionNotEstablishedError();
|
|
12985
|
+
}
|
|
12986
|
+
nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, validRequest.correlationId);
|
|
12987
|
+
userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
|
|
12988
|
+
return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, validRequest), { state: userRequestState, prompt: undefined // Server should handle the prompt, ideally native broker can do this part silently
|
|
12989
|
+
})).finally(function () {
|
|
12990
|
+
_this.browserStorage.cleanRequestByState(state_1);
|
|
12991
|
+
})];
|
|
12992
|
+
}
|
|
12993
|
+
return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state_1, authClient.authority, this.networkClient)];
|
|
12062
12994
|
case 7:
|
|
12063
12995
|
result = _a.sent();
|
|
12064
12996
|
return [2 /*return*/, result];
|
|
@@ -12240,7 +13172,7 @@ var RedirectHandler = /** @class */ (function (_super) {
|
|
|
12240
13172
|
* Handle authorization code response in the window.
|
|
12241
13173
|
* @param hash
|
|
12242
13174
|
*/
|
|
12243
|
-
RedirectHandler.prototype.handleCodeResponseFromHash = function (locationHash, state, authority, networkModule
|
|
13175
|
+
RedirectHandler.prototype.handleCodeResponseFromHash = function (locationHash, state, authority, networkModule) {
|
|
12244
13176
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12245
13177
|
var stateKey, requestState, authCodeResponse, nonceKey, cachedNonce, cachedCcsCred, tokenResponse;
|
|
12246
13178
|
return __generator$1(this, function (_a) {
|
|
@@ -12258,7 +13190,18 @@ var RedirectHandler = /** @class */ (function (_super) {
|
|
|
12258
13190
|
if (!requestState) {
|
|
12259
13191
|
throw ClientAuthError.createStateNotFoundError("Cached State");
|
|
12260
13192
|
}
|
|
12261
|
-
|
|
13193
|
+
try {
|
|
13194
|
+
authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);
|
|
13195
|
+
}
|
|
13196
|
+
catch (e) {
|
|
13197
|
+
if (e instanceof ServerError && e.subError === BrowserAuthErrorMessage.userCancelledError.code) {
|
|
13198
|
+
// Translate server error caused by user closing native prompt to corresponding first class MSAL error
|
|
13199
|
+
throw BrowserAuthError.createUserCancelledError();
|
|
13200
|
+
}
|
|
13201
|
+
else {
|
|
13202
|
+
throw e;
|
|
13203
|
+
}
|
|
13204
|
+
}
|
|
12262
13205
|
nonceKey = this.browserStorage.generateNonceKey(requestState);
|
|
12263
13206
|
cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);
|
|
12264
13207
|
// Assign code to request
|
|
@@ -12281,10 +13224,6 @@ var RedirectHandler = /** @class */ (function (_super) {
|
|
|
12281
13224
|
this.authCodeRequest.ccsCredential = cachedCcsCred;
|
|
12282
13225
|
}
|
|
12283
13226
|
}
|
|
12284
|
-
// Remove throttle if it exists
|
|
12285
|
-
if (clientId) {
|
|
12286
|
-
ThrottlingUtils.removeThrottle(this.browserStorage, clientId, this.authCodeRequest);
|
|
12287
|
-
}
|
|
12288
13227
|
return [4 /*yield*/, this.authModule.acquireToken(this.authCodeRequest, authCodeResponse)];
|
|
12289
13228
|
case 3:
|
|
12290
13229
|
tokenResponse = _a.sent();
|
|
@@ -12339,7 +13278,7 @@ var RedirectClient = /** @class */ (function (_super) {
|
|
|
12339
13278
|
authClient = _a.sent();
|
|
12340
13279
|
this.logger.verbose("Auth code client created");
|
|
12341
13280
|
interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);
|
|
12342
|
-
return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];
|
|
13281
|
+
return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme) }))];
|
|
12343
13282
|
case 5:
|
|
12344
13283
|
navigateUrl = _a.sent();
|
|
12345
13284
|
redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
|
|
@@ -12377,7 +13316,7 @@ var RedirectClient = /** @class */ (function (_super) {
|
|
|
12377
13316
|
*/
|
|
12378
13317
|
RedirectClient.prototype.handleRedirectPromise = function (hash) {
|
|
12379
13318
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12380
|
-
var serverTelemetryManager, responseHash, state, loginRequestUrl, loginRequestUrlNormalized, currentUrlNormalized, handleHashResult, navigationOptions, processHashOnRedirect, homepage, e_2;
|
|
13319
|
+
var serverTelemetryManager, responseHash, state, serverParams, loginRequestUrl, loginRequestUrlNormalized, currentUrlNormalized, handleHashResult, navigationOptions, processHashOnRedirect, homepage, e_2;
|
|
12381
13320
|
return __generator$1(this, function (_a) {
|
|
12382
13321
|
switch (_a.label) {
|
|
12383
13322
|
case 0:
|
|
@@ -12398,7 +13337,8 @@ var RedirectClient = /** @class */ (function (_super) {
|
|
|
12398
13337
|
}
|
|
12399
13338
|
state = void 0;
|
|
12400
13339
|
try {
|
|
12401
|
-
|
|
13340
|
+
serverParams = UrlString.getDeserializedHash(responseHash);
|
|
13341
|
+
state = this.validateAndExtractStateFromHash(serverParams, exports.InteractionType.Redirect);
|
|
12402
13342
|
this.logger.verbose("State extracted from hash");
|
|
12403
13343
|
}
|
|
12404
13344
|
catch (e) {
|
|
@@ -12499,12 +13439,26 @@ var RedirectClient = /** @class */ (function (_super) {
|
|
|
12499
13439
|
*/
|
|
12500
13440
|
RedirectClient.prototype.handleHash = function (hash, state, serverTelemetryManager) {
|
|
12501
13441
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12502
|
-
var cachedRequest, currentAuthority, authClient, interactionHandler;
|
|
13442
|
+
var cachedRequest, serverParams, nativeInteractionClient, userRequestState, currentAuthority, authClient, interactionHandler;
|
|
13443
|
+
var _this = this;
|
|
12503
13444
|
return __generator$1(this, function (_a) {
|
|
12504
13445
|
switch (_a.label) {
|
|
12505
13446
|
case 0:
|
|
12506
13447
|
cachedRequest = this.browserStorage.getCachedRequest(state, this.browserCrypto);
|
|
12507
13448
|
this.logger.verbose("handleHash called, retrieved cached request");
|
|
13449
|
+
serverParams = UrlString.getDeserializedHash(hash);
|
|
13450
|
+
if (serverParams.accountId) {
|
|
13451
|
+
this.logger.verbose("Account id found in hash, calling WAM for token");
|
|
13452
|
+
if (!this.nativeMessageHandler) {
|
|
13453
|
+
throw BrowserAuthError.createNativeConnectionNotEstablishedError();
|
|
13454
|
+
}
|
|
13455
|
+
nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, cachedRequest.correlationId);
|
|
13456
|
+
userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
|
|
13457
|
+
return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, cachedRequest), { state: userRequestState, prompt: undefined // Server should handle the prompt, ideally native broker can do this part silently
|
|
13458
|
+
})).finally(function () {
|
|
13459
|
+
_this.browserStorage.cleanRequestByState(state);
|
|
13460
|
+
})];
|
|
13461
|
+
}
|
|
12508
13462
|
currentAuthority = this.browserStorage.getCachedAuthority(state);
|
|
12509
13463
|
if (!currentAuthority) {
|
|
12510
13464
|
throw BrowserAuthError.createNoCachedAuthorityError();
|
|
@@ -12513,8 +13467,9 @@ var RedirectClient = /** @class */ (function (_super) {
|
|
|
12513
13467
|
case 1:
|
|
12514
13468
|
authClient = _a.sent();
|
|
12515
13469
|
this.logger.verbose("Auth code client created");
|
|
13470
|
+
ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, cachedRequest);
|
|
12516
13471
|
interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);
|
|
12517
|
-
return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient
|
|
13472
|
+
return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
|
|
12518
13473
|
case 2: return [2 /*return*/, _a.sent()];
|
|
12519
13474
|
}
|
|
12520
13475
|
});
|
|
@@ -12756,8 +13711,8 @@ var SilentHandler = /** @class */ (function (_super) {
|
|
|
12756
13711
|
*/
|
|
12757
13712
|
var SilentIframeClient = /** @class */ (function (_super) {
|
|
12758
13713
|
__extends$1(SilentIframeClient, _super);
|
|
12759
|
-
function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, correlationId) {
|
|
12760
|
-
var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId) || this;
|
|
13714
|
+
function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
|
|
13715
|
+
var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
|
|
12761
13716
|
_this.apiId = apiId;
|
|
12762
13717
|
return _this;
|
|
12763
13718
|
}
|
|
@@ -12767,7 +13722,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12767
13722
|
*/
|
|
12768
13723
|
SilentIframeClient.prototype.acquireToken = function (request) {
|
|
12769
13724
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12770
|
-
var acquireTokenMeasurement, silentRequest, serverTelemetryManager,
|
|
13725
|
+
var acquireTokenMeasurement, silentRequest, serverTelemetryManager, authClient, e_1;
|
|
12771
13726
|
return __generator$1(this, function (_a) {
|
|
12772
13727
|
switch (_a.label) {
|
|
12773
13728
|
case 0:
|
|
@@ -12791,27 +13746,20 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12791
13746
|
serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
|
|
12792
13747
|
_a.label = 2;
|
|
12793
13748
|
case 2:
|
|
12794
|
-
_a.trys.push([2,
|
|
12795
|
-
return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
|
|
12796
|
-
case 3:
|
|
12797
|
-
authCodeRequest = _a.sent();
|
|
13749
|
+
_a.trys.push([2, 5, , 6]);
|
|
12798
13750
|
return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
|
|
12799
|
-
case
|
|
13751
|
+
case 3:
|
|
12800
13752
|
authClient = _a.sent();
|
|
12801
13753
|
this.logger.verbose("Auth code client created");
|
|
12802
|
-
return [4 /*yield*/,
|
|
12803
|
-
case 5:
|
|
12804
|
-
navigateUrl = _a.sent();
|
|
12805
|
-
return [4 /*yield*/, this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger)
|
|
12806
|
-
.then(function (result) {
|
|
13754
|
+
return [4 /*yield*/, this.silentTokenHelper(authClient, silentRequest).then(function (result) {
|
|
12807
13755
|
acquireTokenMeasurement.endMeasurement({
|
|
12808
13756
|
success: true,
|
|
12809
13757
|
fromCache: false
|
|
12810
13758
|
});
|
|
12811
13759
|
return result;
|
|
12812
13760
|
})];
|
|
12813
|
-
case
|
|
12814
|
-
case
|
|
13761
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
13762
|
+
case 5:
|
|
12815
13763
|
e_1 = _a.sent();
|
|
12816
13764
|
if (e_1 instanceof AuthError) {
|
|
12817
13765
|
e_1.setCorrelationId(this.correlationId);
|
|
@@ -12822,7 +13770,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12822
13770
|
success: false
|
|
12823
13771
|
});
|
|
12824
13772
|
throw e_1;
|
|
12825
|
-
case
|
|
13773
|
+
case 6: return [2 /*return*/];
|
|
12826
13774
|
}
|
|
12827
13775
|
});
|
|
12828
13776
|
});
|
|
@@ -12840,20 +13788,38 @@ var SilentIframeClient = /** @class */ (function (_super) {
|
|
|
12840
13788
|
* @param navigateUrl
|
|
12841
13789
|
* @param userRequestScopes
|
|
12842
13790
|
*/
|
|
12843
|
-
SilentIframeClient.prototype.silentTokenHelper = function (
|
|
13791
|
+
SilentIframeClient.prototype.silentTokenHelper = function (authClient, silentRequest) {
|
|
12844
13792
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12845
|
-
var silentHandler, msalFrame, hash, state;
|
|
13793
|
+
var authCodeRequest, navigateUrl, silentHandler, msalFrame, hash, serverParams, state, nativeInteractionClient, userRequestState;
|
|
13794
|
+
var _this = this;
|
|
12846
13795
|
return __generator$1(this, function (_a) {
|
|
12847
13796
|
switch (_a.label) {
|
|
12848
|
-
case 0:
|
|
12849
|
-
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, browserRequestLogger, this.config.system.navigateFrameWait);
|
|
12850
|
-
return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
|
|
13797
|
+
case 0: return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
|
|
12851
13798
|
case 1:
|
|
13799
|
+
authCodeRequest = _a.sent();
|
|
13800
|
+
return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, silentRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme) }))];
|
|
13801
|
+
case 2:
|
|
13802
|
+
navigateUrl = _a.sent();
|
|
13803
|
+
silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system.navigateFrameWait);
|
|
13804
|
+
return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
|
|
13805
|
+
case 3:
|
|
12852
13806
|
msalFrame = _a.sent();
|
|
12853
13807
|
return [4 /*yield*/, silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout)];
|
|
12854
|
-
case
|
|
13808
|
+
case 4:
|
|
12855
13809
|
hash = _a.sent();
|
|
12856
|
-
|
|
13810
|
+
serverParams = UrlString.getDeserializedHash(hash);
|
|
13811
|
+
state = this.validateAndExtractStateFromHash(serverParams, exports.InteractionType.Silent, authCodeRequest.correlationId);
|
|
13812
|
+
if (serverParams.accountId) {
|
|
13813
|
+
this.logger.verbose("Account id found in hash, calling WAM for token");
|
|
13814
|
+
if (!this.nativeMessageHandler) {
|
|
13815
|
+
throw BrowserAuthError.createNativeConnectionNotEstablishedError();
|
|
13816
|
+
}
|
|
13817
|
+
nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.apiId, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.correlationId);
|
|
13818
|
+
userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
|
|
13819
|
+
return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
|
|
13820
|
+
_this.browserStorage.cleanRequestByState(state);
|
|
13821
|
+
})];
|
|
13822
|
+
}
|
|
12857
13823
|
// Handle response from hash string
|
|
12858
13824
|
return [2 /*return*/, silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
|
|
12859
13825
|
}
|
|
@@ -13062,6 +14028,97 @@ var TokenCache = /** @class */ (function () {
|
|
|
13062
14028
|
return TokenCache;
|
|
13063
14029
|
}());
|
|
13064
14030
|
|
|
14031
|
+
/*
|
|
14032
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
14033
|
+
* Licensed under the MIT License.
|
|
14034
|
+
*/
|
|
14035
|
+
var SilentCacheClient = /** @class */ (function (_super) {
|
|
14036
|
+
__extends$1(SilentCacheClient, _super);
|
|
14037
|
+
function SilentCacheClient() {
|
|
14038
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14039
|
+
}
|
|
14040
|
+
/**
|
|
14041
|
+
* Returns unexpired tokens from the cache, if available
|
|
14042
|
+
* @param silentRequest
|
|
14043
|
+
*/
|
|
14044
|
+
SilentCacheClient.prototype.acquireToken = function (silentRequest) {
|
|
14045
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14046
|
+
var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
|
|
14047
|
+
return __generator$1(this, function (_a) {
|
|
14048
|
+
switch (_a.label) {
|
|
14049
|
+
case 0:
|
|
14050
|
+
acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
|
|
14051
|
+
serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
|
|
14052
|
+
return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
|
|
14053
|
+
case 1:
|
|
14054
|
+
silentAuthClient = _a.sent();
|
|
14055
|
+
this.logger.verbose("Silent auth client created");
|
|
14056
|
+
_a.label = 2;
|
|
14057
|
+
case 2:
|
|
14058
|
+
_a.trys.push([2, 4, , 5]);
|
|
14059
|
+
return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
|
|
14060
|
+
case 3:
|
|
14061
|
+
cachedToken = _a.sent();
|
|
14062
|
+
acquireTokenMeasurement.endMeasurement({
|
|
14063
|
+
success: true,
|
|
14064
|
+
fromCache: true
|
|
14065
|
+
});
|
|
14066
|
+
return [2 /*return*/, cachedToken];
|
|
14067
|
+
case 4:
|
|
14068
|
+
error_1 = _a.sent();
|
|
14069
|
+
if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
|
|
14070
|
+
this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
|
|
14071
|
+
}
|
|
14072
|
+
acquireTokenMeasurement.endMeasurement({
|
|
14073
|
+
success: false
|
|
14074
|
+
});
|
|
14075
|
+
throw error_1;
|
|
14076
|
+
case 5: return [2 /*return*/];
|
|
14077
|
+
}
|
|
14078
|
+
});
|
|
14079
|
+
});
|
|
14080
|
+
};
|
|
14081
|
+
/**
|
|
14082
|
+
* Currently Unsupported
|
|
14083
|
+
*/
|
|
14084
|
+
SilentCacheClient.prototype.logout = function () {
|
|
14085
|
+
// Synchronous so we must reject
|
|
14086
|
+
return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
|
|
14087
|
+
};
|
|
14088
|
+
/**
|
|
14089
|
+
* Creates an Silent Flow Client with the given authority, or the default authority.
|
|
14090
|
+
* @param serverTelemetryManager
|
|
14091
|
+
* @param authorityUrl
|
|
14092
|
+
*/
|
|
14093
|
+
SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
|
|
14094
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14095
|
+
var clientConfig;
|
|
14096
|
+
return __generator$1(this, function (_a) {
|
|
14097
|
+
switch (_a.label) {
|
|
14098
|
+
case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
|
|
14099
|
+
case 1:
|
|
14100
|
+
clientConfig = _a.sent();
|
|
14101
|
+
return [2 /*return*/, new SilentFlowClient(clientConfig)];
|
|
14102
|
+
}
|
|
14103
|
+
});
|
|
14104
|
+
});
|
|
14105
|
+
};
|
|
14106
|
+
SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
|
|
14107
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14108
|
+
var _a;
|
|
14109
|
+
return __generator$1(this, function (_b) {
|
|
14110
|
+
switch (_b.label) {
|
|
14111
|
+
case 0:
|
|
14112
|
+
_a = [__assign$1({}, request)];
|
|
14113
|
+
return [4 /*yield*/, this.initializeBaseRequest(request)];
|
|
14114
|
+
case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
|
|
14115
|
+
}
|
|
14116
|
+
});
|
|
14117
|
+
});
|
|
14118
|
+
};
|
|
14119
|
+
return SilentCacheClient;
|
|
14120
|
+
}(StandardInteractionClient));
|
|
14121
|
+
|
|
13065
14122
|
/*
|
|
13066
14123
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13067
14124
|
* Licensed under the MIT License.
|
|
@@ -13082,8 +14139,8 @@ var HybridSpaAuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
13082
14139
|
*/
|
|
13083
14140
|
var SilentAuthCodeClient = /** @class */ (function (_super) {
|
|
13084
14141
|
__extends$1(SilentAuthCodeClient, _super);
|
|
13085
|
-
function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, correlationId) {
|
|
13086
|
-
var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId) || this;
|
|
14142
|
+
function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
|
|
14143
|
+
var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
|
|
13087
14144
|
_this.apiId = apiId;
|
|
13088
14145
|
return _this;
|
|
13089
14146
|
}
|
|
@@ -13286,6 +14343,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13286
14343
|
this.isBrowserEnvironment = typeof window !== "undefined";
|
|
13287
14344
|
// Set the configuration.
|
|
13288
14345
|
this.config = buildConfiguration(configuration, this.isBrowserEnvironment);
|
|
14346
|
+
this.initialized = false;
|
|
13289
14347
|
// Initialize logger
|
|
13290
14348
|
this.logger = new Logger(this.config.system.loggerOptions, name, version);
|
|
13291
14349
|
// Initialize the network module class.
|
|
@@ -13310,6 +14368,42 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13310
14368
|
// Initialize the token cache
|
|
13311
14369
|
this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
|
|
13312
14370
|
}
|
|
14371
|
+
/**
|
|
14372
|
+
* Initializer function to perform async startup tasks such as connecting to WAM extension
|
|
14373
|
+
*/
|
|
14374
|
+
ClientApplication.prototype.initialize = function () {
|
|
14375
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
14376
|
+
var _a, e_1;
|
|
14377
|
+
return __generator$1(this, function (_b) {
|
|
14378
|
+
switch (_b.label) {
|
|
14379
|
+
case 0:
|
|
14380
|
+
this.logger.trace("initialize called");
|
|
14381
|
+
if (this.initialized) {
|
|
14382
|
+
this.logger.warning("initialize has already been called. This function only needs to be run once.");
|
|
14383
|
+
return [2 /*return*/];
|
|
14384
|
+
}
|
|
14385
|
+
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);
|
|
14386
|
+
if (!this.config.system.allowNativeBroker) return [3 /*break*/, 4];
|
|
14387
|
+
_b.label = 1;
|
|
14388
|
+
case 1:
|
|
14389
|
+
_b.trys.push([1, 3, , 4]);
|
|
14390
|
+
_a = this;
|
|
14391
|
+
return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout)];
|
|
14392
|
+
case 2:
|
|
14393
|
+
_a.nativeExtensionProvider = _b.sent();
|
|
14394
|
+
return [3 /*break*/, 4];
|
|
14395
|
+
case 3:
|
|
14396
|
+
e_1 = _b.sent();
|
|
14397
|
+
this.logger.verbose(e_1);
|
|
14398
|
+
return [3 /*break*/, 4];
|
|
14399
|
+
case 4:
|
|
14400
|
+
this.initialized = true;
|
|
14401
|
+
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_END);
|
|
14402
|
+
return [2 /*return*/];
|
|
14403
|
+
}
|
|
14404
|
+
});
|
|
14405
|
+
});
|
|
14406
|
+
};
|
|
13313
14407
|
// #region Redirect Flow
|
|
13314
14408
|
/**
|
|
13315
14409
|
* Event handler function which allows users to fire events after the PublicClientApplication object
|
|
@@ -13320,10 +14414,12 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13320
14414
|
*/
|
|
13321
14415
|
ClientApplication.prototype.handleRedirectPromise = function (hash) {
|
|
13322
14416
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13323
|
-
var loggedInAccounts, redirectResponseKey, response, correlationId, redirectClient;
|
|
14417
|
+
var loggedInAccounts, redirectResponseKey, response, request, redirectResponse, nativeClient, correlationId, redirectClient;
|
|
13324
14418
|
var _this = this;
|
|
13325
14419
|
return __generator$1(this, function (_a) {
|
|
13326
14420
|
this.logger.verbose("handleRedirectPromise called");
|
|
14421
|
+
// Block token acquisition before initialize has been called if native brokering is enabled
|
|
14422
|
+
BrowserUtils.blockNativeBrokerCalledBeforeInitialized(this.config.system.allowNativeBroker, this.initialized);
|
|
13327
14423
|
loggedInAccounts = this.getAllAccounts();
|
|
13328
14424
|
if (this.isBrowserEnvironment) {
|
|
13329
14425
|
redirectResponseKey = hash || Constants.EMPTY_STRING;
|
|
@@ -13331,10 +14427,20 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13331
14427
|
if (typeof response === "undefined") {
|
|
13332
14428
|
this.eventHandler.emitEvent(exports.EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
|
|
13333
14429
|
this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise");
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
.
|
|
14430
|
+
request = this.browserStorage.getCachedNativeRequest();
|
|
14431
|
+
redirectResponse = void 0;
|
|
14432
|
+
if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
|
|
14433
|
+
this.logger.trace("handleRedirectPromise - acquiring token from native platform");
|
|
14434
|
+
nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, request.correlationId);
|
|
14435
|
+
redirectResponse = nativeClient.handleRedirectPromise();
|
|
14436
|
+
}
|
|
14437
|
+
else {
|
|
14438
|
+
this.logger.trace("handleRedirectPromise - acquiring token from web flow");
|
|
14439
|
+
correlationId = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.CORRELATION_ID, true) || Constants.EMPTY_STRING;
|
|
14440
|
+
redirectClient = this.createRedirectClient(correlationId);
|
|
14441
|
+
redirectResponse = redirectClient.handleRedirectPromise(hash);
|
|
14442
|
+
}
|
|
14443
|
+
response = redirectResponse.then(function (result) {
|
|
13338
14444
|
if (result) {
|
|
13339
14445
|
// Emit login event if number of accounts change
|
|
13340
14446
|
var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
|
|
@@ -13349,8 +14455,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13349
14455
|
}
|
|
13350
14456
|
_this.eventHandler.emitEvent(exports.EventType.HANDLE_REDIRECT_END, exports.InteractionType.Redirect);
|
|
13351
14457
|
return result;
|
|
13352
|
-
})
|
|
13353
|
-
.catch(function (e) {
|
|
14458
|
+
}).catch(function (e) {
|
|
13354
14459
|
// Emit login event if there is an account
|
|
13355
14460
|
if (loggedInAccounts.length > 0) {
|
|
13356
14461
|
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Redirect, null, e);
|
|
@@ -13384,7 +14489,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13384
14489
|
*/
|
|
13385
14490
|
ClientApplication.prototype.acquireTokenRedirect = function (request) {
|
|
13386
14491
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13387
|
-
var correlationId, isLoggedIn, redirectClient;
|
|
14492
|
+
var correlationId, isLoggedIn, result, nativeClient, redirectClient;
|
|
13388
14493
|
var _this = this;
|
|
13389
14494
|
return __generator$1(this, function (_a) {
|
|
13390
14495
|
correlationId = this.getRequestCorrelationId(request);
|
|
@@ -13397,8 +14502,22 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13397
14502
|
else {
|
|
13398
14503
|
this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
|
|
13399
14504
|
}
|
|
13400
|
-
|
|
13401
|
-
|
|
14505
|
+
if (this.nativeExtensionProvider && this.canUseNative(request)) {
|
|
14506
|
+
nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), request.correlationId);
|
|
14507
|
+
result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
|
|
14508
|
+
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
14509
|
+
_this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
14510
|
+
var redirectClient = _this.createRedirectClient(request.correlationId);
|
|
14511
|
+
return redirectClient.acquireToken(request);
|
|
14512
|
+
}
|
|
14513
|
+
throw e;
|
|
14514
|
+
});
|
|
14515
|
+
}
|
|
14516
|
+
else {
|
|
14517
|
+
redirectClient = this.createRedirectClient(request.correlationId);
|
|
14518
|
+
result = redirectClient.acquireToken(request);
|
|
14519
|
+
}
|
|
14520
|
+
return [2 /*return*/, result.catch(function (e) {
|
|
13402
14521
|
// If logged in, emit acquire token events
|
|
13403
14522
|
if (isLoggedIn) {
|
|
13404
14523
|
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Redirect, null, e);
|
|
@@ -13423,6 +14542,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13423
14542
|
ClientApplication.prototype.acquireTokenPopup = function (request) {
|
|
13424
14543
|
var _this = this;
|
|
13425
14544
|
var correlationId = this.getRequestCorrelationId(request);
|
|
14545
|
+
var atPopupMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenPopup, correlationId);
|
|
13426
14546
|
try {
|
|
13427
14547
|
this.logger.verbose("acquireTokenPopup called", correlationId);
|
|
13428
14548
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
|
|
@@ -13439,8 +14559,30 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13439
14559
|
else {
|
|
13440
14560
|
this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Popup, request);
|
|
13441
14561
|
}
|
|
13442
|
-
var
|
|
13443
|
-
|
|
14562
|
+
var result;
|
|
14563
|
+
if (this.canUseNative(request)) {
|
|
14564
|
+
result = this.acquireTokenNative(request, exports.ApiId.acquireTokenPopup).then(function (response) {
|
|
14565
|
+
_this.browserStorage.setInteractionInProgress(false);
|
|
14566
|
+
atPopupMeasurement.endMeasurement({
|
|
14567
|
+
success: true,
|
|
14568
|
+
isNativeBroker: true
|
|
14569
|
+
});
|
|
14570
|
+
atPopupMeasurement.flushMeasurement();
|
|
14571
|
+
return response;
|
|
14572
|
+
}).catch(function (e) {
|
|
14573
|
+
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
14574
|
+
_this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
14575
|
+
var popupClient = _this.createPopupClient(request.correlationId);
|
|
14576
|
+
return popupClient.acquireToken(request);
|
|
14577
|
+
}
|
|
14578
|
+
throw e;
|
|
14579
|
+
});
|
|
14580
|
+
}
|
|
14581
|
+
else {
|
|
14582
|
+
var popupClient = this.createPopupClient(request.correlationId);
|
|
14583
|
+
result = popupClient.acquireToken(request);
|
|
14584
|
+
}
|
|
14585
|
+
return result.then(function (result) {
|
|
13444
14586
|
// If logged in, emit acquire token events
|
|
13445
14587
|
var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
|
|
13446
14588
|
if (isLoggingIn) {
|
|
@@ -13449,6 +14591,10 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13449
14591
|
else {
|
|
13450
14592
|
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
|
|
13451
14593
|
}
|
|
14594
|
+
atPopupMeasurement.endMeasurement({
|
|
14595
|
+
success: true
|
|
14596
|
+
});
|
|
14597
|
+
atPopupMeasurement.flushMeasurement();
|
|
13452
14598
|
return result;
|
|
13453
14599
|
}).catch(function (e) {
|
|
13454
14600
|
if (loggedInAccounts.length > 0) {
|
|
@@ -13457,6 +14603,10 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13457
14603
|
else {
|
|
13458
14604
|
_this.eventHandler.emitEvent(exports.EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
|
|
13459
14605
|
}
|
|
14606
|
+
atPopupMeasurement.endMeasurement({
|
|
14607
|
+
success: false
|
|
14608
|
+
});
|
|
14609
|
+
atPopupMeasurement.flushMeasurement();
|
|
13460
14610
|
// Since this function is syncronous we need to reject
|
|
13461
14611
|
return Promise.reject(e);
|
|
13462
14612
|
});
|
|
@@ -13480,38 +14630,45 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13480
14630
|
*/
|
|
13481
14631
|
ClientApplication.prototype.ssoSilent = function (request) {
|
|
13482
14632
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13483
|
-
var correlationId,
|
|
14633
|
+
var correlationId, validRequest, ssoSilentMeasurement, result, silentIframeClient;
|
|
14634
|
+
var _this = this;
|
|
13484
14635
|
return __generator$1(this, function (_a) {
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
14636
|
+
correlationId = this.getRequestCorrelationId(request);
|
|
14637
|
+
validRequest = __assign$1(__assign$1({}, request), { prompt: PromptValue.NONE, correlationId: correlationId });
|
|
14638
|
+
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
|
|
14639
|
+
ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
|
|
14640
|
+
this.logger.verbose("ssoSilent called", correlationId);
|
|
14641
|
+
this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
|
|
14642
|
+
if (this.canUseNative(validRequest)) {
|
|
14643
|
+
result = this.acquireTokenNative(validRequest, exports.ApiId.ssoSilent).catch(function (e) {
|
|
14644
|
+
// If native token acquisition fails for availability reasons fallback to standard flow
|
|
14645
|
+
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
14646
|
+
_this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
14647
|
+
var silentIframeClient = _this.createSilentIframeClient(validRequest.correlationId);
|
|
14648
|
+
return silentIframeClient.acquireToken(validRequest);
|
|
14649
|
+
}
|
|
14650
|
+
throw e;
|
|
14651
|
+
});
|
|
14652
|
+
}
|
|
14653
|
+
else {
|
|
14654
|
+
silentIframeClient = this.createSilentIframeClient(validRequest.correlationId);
|
|
14655
|
+
result = silentIframeClient.acquireToken(validRequest);
|
|
14656
|
+
}
|
|
14657
|
+
return [2 /*return*/, result.then(function (response) {
|
|
14658
|
+
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
|
|
13500
14659
|
ssoSilentMeasurement.endMeasurement({
|
|
13501
14660
|
success: true
|
|
13502
14661
|
});
|
|
13503
14662
|
ssoSilentMeasurement.flushMeasurement();
|
|
13504
|
-
return
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e_1);
|
|
14663
|
+
return response;
|
|
14664
|
+
}).catch(function (e) {
|
|
14665
|
+
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
|
|
13508
14666
|
ssoSilentMeasurement.endMeasurement({
|
|
13509
14667
|
success: false
|
|
13510
14668
|
});
|
|
13511
14669
|
ssoSilentMeasurement.flushMeasurement();
|
|
13512
|
-
throw
|
|
13513
|
-
|
|
13514
|
-
}
|
|
14670
|
+
throw e;
|
|
14671
|
+
})];
|
|
13515
14672
|
});
|
|
13516
14673
|
});
|
|
13517
14674
|
};
|
|
@@ -13527,7 +14684,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13527
14684
|
*/
|
|
13528
14685
|
ClientApplication.prototype.acquireTokenByCode = function (request) {
|
|
13529
14686
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
13530
|
-
var correlationId, atbcMeasurement, response;
|
|
14687
|
+
var correlationId, atbcMeasurement, hybridAuthCode_1, response;
|
|
13531
14688
|
var _this = this;
|
|
13532
14689
|
return __generator$1(this, function (_a) {
|
|
13533
14690
|
correlationId = this.getRequestCorrelationId(request);
|
|
@@ -13536,41 +14693,58 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13536
14693
|
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
|
|
13537
14694
|
atbcMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCode, request.correlationId);
|
|
13538
14695
|
try {
|
|
13539
|
-
if (
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
14696
|
+
if (request.code) {
|
|
14697
|
+
hybridAuthCode_1 = request.code;
|
|
14698
|
+
response = this.hybridAuthCodeResponses.get(hybridAuthCode_1);
|
|
14699
|
+
if (!response) {
|
|
14700
|
+
this.logger.verbose("Initiating new acquireTokenByCode request", correlationId);
|
|
14701
|
+
response = this.acquireTokenByCodeAsync(__assign$1(__assign$1({}, request), { correlationId: correlationId }))
|
|
14702
|
+
.then(function (result) {
|
|
14703
|
+
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
|
|
14704
|
+
_this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
|
|
14705
|
+
atbcMeasurement.endMeasurement({
|
|
14706
|
+
success: true
|
|
14707
|
+
});
|
|
14708
|
+
atbcMeasurement.flushMeasurement();
|
|
14709
|
+
return result;
|
|
14710
|
+
})
|
|
14711
|
+
.catch(function (error) {
|
|
14712
|
+
_this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
|
|
14713
|
+
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
|
|
14714
|
+
atbcMeasurement.endMeasurement({
|
|
14715
|
+
success: false
|
|
14716
|
+
});
|
|
14717
|
+
atbcMeasurement.flushMeasurement();
|
|
14718
|
+
throw error;
|
|
13551
14719
|
});
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
.
|
|
13556
|
-
_this.hybridAuthCodeResponses.delete(request.code);
|
|
13557
|
-
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
|
|
14720
|
+
this.hybridAuthCodeResponses.set(hybridAuthCode_1, response);
|
|
14721
|
+
}
|
|
14722
|
+
else {
|
|
14723
|
+
this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
|
|
13558
14724
|
atbcMeasurement.endMeasurement({
|
|
13559
|
-
success:
|
|
14725
|
+
success: true
|
|
13560
14726
|
});
|
|
13561
|
-
atbcMeasurement.
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
14727
|
+
atbcMeasurement.discardMeasurement();
|
|
14728
|
+
}
|
|
14729
|
+
return [2 /*return*/, response];
|
|
14730
|
+
}
|
|
14731
|
+
else if (request.nativeAccountId) {
|
|
14732
|
+
if (this.canUseNative(request, request.nativeAccountId)) {
|
|
14733
|
+
return [2 /*return*/, this.acquireTokenNative(request, exports.ApiId.acquireTokenByCode, request.nativeAccountId).catch(function (e) {
|
|
14734
|
+
// If native token acquisition fails for availability reasons fallback to standard flow
|
|
14735
|
+
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
14736
|
+
_this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
14737
|
+
}
|
|
14738
|
+
throw e;
|
|
14739
|
+
})];
|
|
14740
|
+
}
|
|
14741
|
+
else {
|
|
14742
|
+
throw BrowserAuthError.createUnableToAcquireTokenFromNativePlatformError();
|
|
14743
|
+
}
|
|
13565
14744
|
}
|
|
13566
14745
|
else {
|
|
13567
|
-
|
|
13568
|
-
atbcMeasurement.endMeasurement({
|
|
13569
|
-
success: true
|
|
13570
|
-
});
|
|
13571
|
-
atbcMeasurement.discardMeasurement();
|
|
14746
|
+
throw BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError();
|
|
13572
14747
|
}
|
|
13573
|
-
return [2 /*return*/, response];
|
|
13574
14748
|
}
|
|
13575
14749
|
catch (e) {
|
|
13576
14750
|
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
|
|
@@ -13595,7 +14769,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13595
14769
|
switch (_a.label) {
|
|
13596
14770
|
case 0:
|
|
13597
14771
|
this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
|
|
13598
|
-
silentAuthCodeClient =
|
|
14772
|
+
silentAuthCodeClient = this.createSilentAuthCodeClient(request.correlationId);
|
|
13599
14773
|
return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
|
|
13600
14774
|
case 1:
|
|
13601
14775
|
silentTokenResult = _a.sent();
|
|
@@ -13624,7 +14798,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13624
14798
|
BrowserUtils.blockReloadInHiddenIframes();
|
|
13625
14799
|
atbrtMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByRefreshToken, request.correlationId);
|
|
13626
14800
|
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, request);
|
|
13627
|
-
silentRefreshClient =
|
|
14801
|
+
silentRefreshClient = this.createSilentRefreshClient(request.correlationId);
|
|
13628
14802
|
return [2 /*return*/, silentRefreshClient.acquireToken(request)
|
|
13629
14803
|
.then(function (result) {
|
|
13630
14804
|
atbrtMeasurement.endMeasurement({
|
|
@@ -13639,7 +14813,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13639
14813
|
var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
|
|
13640
14814
|
if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
|
|
13641
14815
|
_this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
|
|
13642
|
-
var silentIframeClient =
|
|
14816
|
+
var silentIframeClient = _this.createSilentIframeClient(request.correlationId);
|
|
13643
14817
|
return silentIframeClient.acquireToken(request)
|
|
13644
14818
|
.then(function (result) {
|
|
13645
14819
|
atbrtMeasurement.endMeasurement({
|
|
@@ -13691,8 +14865,8 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13691
14865
|
return __generator$1(this, function (_a) {
|
|
13692
14866
|
correlationId = this.getRequestCorrelationId(logoutRequest);
|
|
13693
14867
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
|
|
13694
|
-
redirectClient =
|
|
13695
|
-
return [2 /*return*/, redirectClient.logout(
|
|
14868
|
+
redirectClient = this.createRedirectClient(correlationId);
|
|
14869
|
+
return [2 /*return*/, redirectClient.logout(logoutRequest)];
|
|
13696
14870
|
});
|
|
13697
14871
|
});
|
|
13698
14872
|
};
|
|
@@ -13704,8 +14878,8 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13704
14878
|
try {
|
|
13705
14879
|
var correlationId = this.getRequestCorrelationId(logoutRequest);
|
|
13706
14880
|
this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
|
|
13707
|
-
var popupClient =
|
|
13708
|
-
return popupClient.logout(
|
|
14881
|
+
var popupClient = this.createPopupClient(correlationId);
|
|
14882
|
+
return popupClient.logout(logoutRequest);
|
|
13709
14883
|
}
|
|
13710
14884
|
catch (e) {
|
|
13711
14885
|
// Since this function is syncronous we need to reject
|
|
@@ -13811,6 +14985,8 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13811
14985
|
BrowserUtils.blockReloadInHiddenIframes();
|
|
13812
14986
|
// Block redirectUri opened in a popup from calling MSAL APIs
|
|
13813
14987
|
BrowserUtils.blockAcquireTokenInPopups();
|
|
14988
|
+
// Block token acquisition before initialize has been called if native brokering is enabled
|
|
14989
|
+
BrowserUtils.blockNativeBrokerCalledBeforeInitialized(this.config.system.allowNativeBroker, this.initialized);
|
|
13814
14990
|
// Block redirects if memory storage is enabled but storeAuthStateInCookie is not
|
|
13815
14991
|
if (interactionType === exports.InteractionType.Redirect &&
|
|
13816
14992
|
this.config.cache.cacheLocation === exports.BrowserCacheLocation.MemoryStorage &&
|
|
@@ -13833,6 +15009,98 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13833
15009
|
// Set interaction in progress temporary cache or throw if alread set.
|
|
13834
15010
|
this.browserStorage.setInteractionInProgress(true);
|
|
13835
15011
|
};
|
|
15012
|
+
/**
|
|
15013
|
+
* Acquire a token from native device (e.g. WAM)
|
|
15014
|
+
* @param request
|
|
15015
|
+
*/
|
|
15016
|
+
ClientApplication.prototype.acquireTokenNative = function (request, apiId, accountId) {
|
|
15017
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
15018
|
+
var nativeClient;
|
|
15019
|
+
return __generator$1(this, function (_a) {
|
|
15020
|
+
this.logger.trace("acquireTokenNative called");
|
|
15021
|
+
if (!this.nativeExtensionProvider) {
|
|
15022
|
+
throw BrowserAuthError.createNativeConnectionNotEstablishedError();
|
|
15023
|
+
}
|
|
15024
|
+
nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, apiId, this.performanceClient, this.nativeExtensionProvider, accountId || this.getNativeAccountId(request), request.correlationId);
|
|
15025
|
+
return [2 /*return*/, nativeClient.acquireToken(request)];
|
|
15026
|
+
});
|
|
15027
|
+
});
|
|
15028
|
+
};
|
|
15029
|
+
/**
|
|
15030
|
+
* Returns boolean indicating if this request can use the native broker
|
|
15031
|
+
* @param request
|
|
15032
|
+
*/
|
|
15033
|
+
ClientApplication.prototype.canUseNative = function (request, accountId) {
|
|
15034
|
+
this.logger.trace("canUseNative called");
|
|
15035
|
+
if (!NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme)) {
|
|
15036
|
+
this.logger.trace("canUseNative: isNativeAvailable returned false, returning false");
|
|
15037
|
+
return false;
|
|
15038
|
+
}
|
|
15039
|
+
if (request.prompt) {
|
|
15040
|
+
switch (request.prompt) {
|
|
15041
|
+
case PromptValue.NONE:
|
|
15042
|
+
case PromptValue.CONSENT:
|
|
15043
|
+
this.logger.trace("canUseNative: prompt is compatible with native flow");
|
|
15044
|
+
break;
|
|
15045
|
+
default:
|
|
15046
|
+
this.logger.trace("canUseNative: prompt = " + request.prompt + " is not compatible with native flow, returning false");
|
|
15047
|
+
return false;
|
|
15048
|
+
}
|
|
15049
|
+
}
|
|
15050
|
+
if (!accountId && !this.getNativeAccountId(request)) {
|
|
15051
|
+
this.logger.trace("canUseNative: nativeAccountId is not available, returning false");
|
|
15052
|
+
return false;
|
|
15053
|
+
}
|
|
15054
|
+
return true;
|
|
15055
|
+
};
|
|
15056
|
+
/**
|
|
15057
|
+
* Get the native accountId from the account
|
|
15058
|
+
* @param request
|
|
15059
|
+
* @returns
|
|
15060
|
+
*/
|
|
15061
|
+
ClientApplication.prototype.getNativeAccountId = function (request) {
|
|
15062
|
+
var account = request.account || this.browserStorage.getAccountInfoByHints(request.loginHint, request.sid) || this.getActiveAccount();
|
|
15063
|
+
return account && account.nativeAccountId || "";
|
|
15064
|
+
};
|
|
15065
|
+
/**
|
|
15066
|
+
* Returns new instance of the Popup Interaction Client
|
|
15067
|
+
* @param correlationId
|
|
15068
|
+
*/
|
|
15069
|
+
ClientApplication.prototype.createPopupClient = function (correlationId) {
|
|
15070
|
+
return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
|
|
15071
|
+
};
|
|
15072
|
+
/**
|
|
15073
|
+
* Returns new instance of the Popup Interaction Client
|
|
15074
|
+
* @param correlationId
|
|
15075
|
+
*/
|
|
15076
|
+
ClientApplication.prototype.createRedirectClient = function (correlationId) {
|
|
15077
|
+
return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
|
|
15078
|
+
};
|
|
15079
|
+
/**
|
|
15080
|
+
* Returns new instance of the Silent Iframe Interaction Client
|
|
15081
|
+
* @param correlationId
|
|
15082
|
+
*/
|
|
15083
|
+
ClientApplication.prototype.createSilentIframeClient = function (correlationId) {
|
|
15084
|
+
return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeExtensionProvider, correlationId);
|
|
15085
|
+
};
|
|
15086
|
+
/**
|
|
15087
|
+
* Returns new instance of the Silent Cache Interaction Client
|
|
15088
|
+
*/
|
|
15089
|
+
ClientApplication.prototype.createSilentCacheClient = function (correlationId) {
|
|
15090
|
+
return new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
|
|
15091
|
+
};
|
|
15092
|
+
/**
|
|
15093
|
+
* Returns new instance of the Silent Refresh Interaction Client
|
|
15094
|
+
*/
|
|
15095
|
+
ClientApplication.prototype.createSilentRefreshClient = function (correlationId) {
|
|
15096
|
+
return new SilentRefreshClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
|
|
15097
|
+
};
|
|
15098
|
+
/**
|
|
15099
|
+
* Returns new instance of the Silent AuthCode Interaction Client
|
|
15100
|
+
*/
|
|
15101
|
+
ClientApplication.prototype.createSilentAuthCodeClient = function (correlationId) {
|
|
15102
|
+
return new SilentAuthCodeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenByCode, this.performanceClient, this.nativeExtensionProvider, correlationId);
|
|
15103
|
+
};
|
|
13836
15104
|
/**
|
|
13837
15105
|
* Adds event callbacks to array
|
|
13838
15106
|
* @param callback
|
|
@@ -13941,98 +15209,6 @@ var ClientApplication = /** @class */ (function () {
|
|
|
13941
15209
|
return ClientApplication;
|
|
13942
15210
|
}());
|
|
13943
15211
|
|
|
13944
|
-
/*
|
|
13945
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13946
|
-
* Licensed under the MIT License.
|
|
13947
|
-
*/
|
|
13948
|
-
var SilentCacheClient = /** @class */ (function (_super) {
|
|
13949
|
-
__extends$1(SilentCacheClient, _super);
|
|
13950
|
-
function SilentCacheClient() {
|
|
13951
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
13952
|
-
}
|
|
13953
|
-
/**
|
|
13954
|
-
* Returns unexpired tokens from the cache, if available
|
|
13955
|
-
* @param silentRequest
|
|
13956
|
-
*/
|
|
13957
|
-
SilentCacheClient.prototype.acquireToken = function (silentRequest) {
|
|
13958
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
13959
|
-
var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
|
|
13960
|
-
return __generator$1(this, function (_a) {
|
|
13961
|
-
switch (_a.label) {
|
|
13962
|
-
case 0:
|
|
13963
|
-
acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
|
|
13964
|
-
serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
|
|
13965
|
-
return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
|
|
13966
|
-
case 1:
|
|
13967
|
-
silentAuthClient = _a.sent();
|
|
13968
|
-
this.logger.verbose("Silent auth client created");
|
|
13969
|
-
_a.label = 2;
|
|
13970
|
-
case 2:
|
|
13971
|
-
_a.trys.push([2, 4, , 5]);
|
|
13972
|
-
return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
|
|
13973
|
-
case 3:
|
|
13974
|
-
cachedToken = _a.sent();
|
|
13975
|
-
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, cachedToken);
|
|
13976
|
-
acquireTokenMeasurement.endMeasurement({
|
|
13977
|
-
success: true,
|
|
13978
|
-
fromCache: true
|
|
13979
|
-
});
|
|
13980
|
-
return [2 /*return*/, cachedToken];
|
|
13981
|
-
case 4:
|
|
13982
|
-
error_1 = _a.sent();
|
|
13983
|
-
if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
|
|
13984
|
-
this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
|
|
13985
|
-
}
|
|
13986
|
-
acquireTokenMeasurement.endMeasurement({
|
|
13987
|
-
success: false
|
|
13988
|
-
});
|
|
13989
|
-
throw error_1;
|
|
13990
|
-
case 5: return [2 /*return*/];
|
|
13991
|
-
}
|
|
13992
|
-
});
|
|
13993
|
-
});
|
|
13994
|
-
};
|
|
13995
|
-
/**
|
|
13996
|
-
* Currently Unsupported
|
|
13997
|
-
*/
|
|
13998
|
-
SilentCacheClient.prototype.logout = function () {
|
|
13999
|
-
// Synchronous so we must reject
|
|
14000
|
-
return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
|
|
14001
|
-
};
|
|
14002
|
-
/**
|
|
14003
|
-
* Creates an Silent Flow Client with the given authority, or the default authority.
|
|
14004
|
-
* @param serverTelemetryManager
|
|
14005
|
-
* @param authorityUrl
|
|
14006
|
-
*/
|
|
14007
|
-
SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
|
|
14008
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
14009
|
-
var clientConfig;
|
|
14010
|
-
return __generator$1(this, function (_a) {
|
|
14011
|
-
switch (_a.label) {
|
|
14012
|
-
case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
|
|
14013
|
-
case 1:
|
|
14014
|
-
clientConfig = _a.sent();
|
|
14015
|
-
return [2 /*return*/, new SilentFlowClient(clientConfig)];
|
|
14016
|
-
}
|
|
14017
|
-
});
|
|
14018
|
-
});
|
|
14019
|
-
};
|
|
14020
|
-
SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
|
|
14021
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
14022
|
-
var _a;
|
|
14023
|
-
return __generator$1(this, function (_b) {
|
|
14024
|
-
switch (_b.label) {
|
|
14025
|
-
case 0:
|
|
14026
|
-
_a = [__assign$1({}, request)];
|
|
14027
|
-
return [4 /*yield*/, this.initializeBaseRequest(request)];
|
|
14028
|
-
case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
|
|
14029
|
-
}
|
|
14030
|
-
});
|
|
14031
|
-
});
|
|
14032
|
-
};
|
|
14033
|
-
return SilentCacheClient;
|
|
14034
|
-
}(StandardInteractionClient));
|
|
14035
|
-
|
|
14036
15212
|
/*
|
|
14037
15213
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
14038
15214
|
* Licensed under the MIT License.
|
|
@@ -14176,51 +15352,56 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
14176
15352
|
*/
|
|
14177
15353
|
PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
|
|
14178
15354
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
14179
|
-
var astsAsyncMeasurement, silentCacheClient,
|
|
15355
|
+
var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1;
|
|
14180
15356
|
var _this = this;
|
|
14181
15357
|
return __generator$1(this, function (_a) {
|
|
14182
15358
|
switch (_a.label) {
|
|
14183
15359
|
case 0:
|
|
15360
|
+
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
|
|
14184
15361
|
astsAsyncMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
|
|
14185
|
-
|
|
14186
|
-
|
|
15362
|
+
if (!(NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) && account.nativeAccountId)) return [3 /*break*/, 1];
|
|
15363
|
+
this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
|
|
15364
|
+
silentRequest = __assign$1(__assign$1({}, request), { account: account });
|
|
15365
|
+
result = this.acquireTokenNative(silentRequest, exports.ApiId.acquireTokenSilent_silentFlow).catch(function (e) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
15366
|
+
var silentIframeClient;
|
|
15367
|
+
return __generator$1(this, function (_a) {
|
|
15368
|
+
// If native token acquisition fails for availability reasons fallback to web flow
|
|
15369
|
+
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
15370
|
+
this.logger.verbose("acquireTokenSilent - native platform unavailable, falling back to web flow");
|
|
15371
|
+
this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
|
|
15372
|
+
silentIframeClient = this.createSilentIframeClient(request.correlationId);
|
|
15373
|
+
return [2 /*return*/, silentIframeClient.acquireToken(request)];
|
|
15374
|
+
}
|
|
15375
|
+
throw e;
|
|
15376
|
+
});
|
|
15377
|
+
}); });
|
|
15378
|
+
return [3 /*break*/, 3];
|
|
14187
15379
|
case 1:
|
|
14188
|
-
|
|
14189
|
-
this.
|
|
14190
|
-
return [
|
|
14191
|
-
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
case 2:
|
|
14214
|
-
tokenRenewalError_1 = _a.sent();
|
|
14215
|
-
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError_1);
|
|
14216
|
-
astsAsyncMeasurement.endMeasurement({
|
|
14217
|
-
success: false
|
|
14218
|
-
});
|
|
14219
|
-
throw tokenRenewalError_1;
|
|
14220
|
-
case 3: return [2 /*return*/];
|
|
14221
|
-
}
|
|
14222
|
-
});
|
|
14223
|
-
}); })];
|
|
15380
|
+
this.logger.verbose("acquireTokenSilent - attempting to acquire token from web flow");
|
|
15381
|
+
silentCacheClient = this.createSilentCacheClient(request.correlationId);
|
|
15382
|
+
return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
|
|
15383
|
+
case 2:
|
|
15384
|
+
silentRequest_1 = _a.sent();
|
|
15385
|
+
result = silentCacheClient.acquireToken(silentRequest_1).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
15386
|
+
return __generator$1(this, function (_a) {
|
|
15387
|
+
return [2 /*return*/, this.acquireTokenByRefreshToken(silentRequest_1)];
|
|
15388
|
+
});
|
|
15389
|
+
}); });
|
|
15390
|
+
_a.label = 3;
|
|
15391
|
+
case 3: return [2 /*return*/, result.then(function (response) {
|
|
15392
|
+
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
|
|
15393
|
+
astsAsyncMeasurement.endMeasurement({
|
|
15394
|
+
success: true,
|
|
15395
|
+
fromCache: response.fromCache
|
|
15396
|
+
});
|
|
15397
|
+
return response;
|
|
15398
|
+
}).catch(function (tokenRenewalError) {
|
|
15399
|
+
_this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
|
|
15400
|
+
astsAsyncMeasurement.endMeasurement({
|
|
15401
|
+
success: false
|
|
15402
|
+
});
|
|
15403
|
+
throw tokenRenewalError;
|
|
15404
|
+
})];
|
|
14224
15405
|
}
|
|
14225
15406
|
});
|
|
14226
15407
|
});
|
|
@@ -14233,6 +15414,9 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
14233
15414
|
* Licensed under the MIT License.
|
|
14234
15415
|
*/
|
|
14235
15416
|
var stubbedPublicClientApplication = {
|
|
15417
|
+
initialize: function () {
|
|
15418
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
15419
|
+
},
|
|
14236
15420
|
acquireTokenPopup: function () {
|
|
14237
15421
|
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
14238
15422
|
},
|