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