@azure/msal-browser 2.19.0 → 2.19.1
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 +212 -212
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.js +1 -1
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.js +1 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.js +1 -1
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/AsyncMemoryStorage.js.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +5 -1
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +20 -1
- 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.js +1 -1
- 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.js +1 -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/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.js +1 -1
- package/dist/event/EventType.js.map +1 -1
- package/dist/index.cjs.js +2003 -1959
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.js +1 -1
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.js +1 -1
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +1 -1
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +1 -1
- 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.js +1 -1
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/dist/packageMetadata.js.map +1 -1
- package/dist/utils/BrowserConstants.js +1 -1
- 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.js +1 -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 +2003 -1959
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +22 -22
- package/package.json +95 -95
- package/CHANGELOG.json +0 -1613
- package/CHANGELOG.md +0 -510
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.19.
|
|
1
|
+
/*! @azure/msal-browser v2.19.1 2022-08-03 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -105,7 +105,7 @@ function __spread() {
|
|
|
105
105
|
return ar;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/*! @azure/msal-common v5.1.
|
|
108
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
109
109
|
/*! *****************************************************************************
|
|
110
110
|
Copyright (c) Microsoft Corporation.
|
|
111
111
|
|
|
@@ -192,7 +192,7 @@ function __spreadArrays() {
|
|
|
192
192
|
return r;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
/*! @azure/msal-common v5.1.
|
|
195
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
196
196
|
|
|
197
197
|
/*
|
|
198
198
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -553,7 +553,7 @@ var CacheOutcome;
|
|
|
553
553
|
CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
|
|
554
554
|
})(CacheOutcome || (CacheOutcome = {}));
|
|
555
555
|
|
|
556
|
-
/*! @azure/msal-common v5.1.
|
|
556
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
557
557
|
|
|
558
558
|
/*
|
|
559
559
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -597,7 +597,7 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
597
597
|
return AuthError;
|
|
598
598
|
}(Error));
|
|
599
599
|
|
|
600
|
-
/*! @azure/msal-common v5.1.
|
|
600
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
601
601
|
|
|
602
602
|
/*
|
|
603
603
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -663,7 +663,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
-
/*! @azure/msal-common v5.1.
|
|
666
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
667
667
|
|
|
668
668
|
/*
|
|
669
669
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1125,7 +1125,7 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1125
1125
|
return ClientAuthError;
|
|
1126
1126
|
}(AuthError));
|
|
1127
1127
|
|
|
1128
|
-
/*! @azure/msal-common v5.1.
|
|
1128
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
1129
1129
|
|
|
1130
1130
|
/*
|
|
1131
1131
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1250,7 +1250,7 @@ var StringUtils = /** @class */ (function () {
|
|
|
1250
1250
|
return StringUtils;
|
|
1251
1251
|
}());
|
|
1252
1252
|
|
|
1253
|
-
/*! @azure/msal-common v5.1.
|
|
1253
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
1254
1254
|
|
|
1255
1255
|
/*
|
|
1256
1256
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1430,12 +1430,12 @@ var Logger = /** @class */ (function () {
|
|
|
1430
1430
|
return Logger;
|
|
1431
1431
|
}());
|
|
1432
1432
|
|
|
1433
|
-
/*! @azure/msal-common v5.1.
|
|
1433
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
1434
1434
|
/* eslint-disable header/header */
|
|
1435
1435
|
var name$1 = "@azure/msal-common";
|
|
1436
1436
|
var version$1 = "5.1.0";
|
|
1437
1437
|
|
|
1438
|
-
/*! @azure/msal-common v5.1.
|
|
1438
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
1439
1439
|
|
|
1440
1440
|
/*
|
|
1441
1441
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1579,7 +1579,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1579
1579
|
return CredentialEntity;
|
|
1580
1580
|
}());
|
|
1581
1581
|
|
|
1582
|
-
/*! @azure/msal-common v5.1.
|
|
1582
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
1583
1583
|
|
|
1584
1584
|
/*
|
|
1585
1585
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1824,7 +1824,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1824
1824
|
return ClientConfigurationError;
|
|
1825
1825
|
}(ClientAuthError));
|
|
1826
1826
|
|
|
1827
|
-
/*! @azure/msal-common v5.1.
|
|
1827
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
1828
1828
|
|
|
1829
1829
|
/*
|
|
1830
1830
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2008,7 +2008,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
2008
2008
|
return ScopeSet;
|
|
2009
2009
|
}());
|
|
2010
2010
|
|
|
2011
|
-
/*! @azure/msal-common v5.1.
|
|
2011
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
2012
2012
|
|
|
2013
2013
|
/*
|
|
2014
2014
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2046,7 +2046,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
2046
2046
|
};
|
|
2047
2047
|
}
|
|
2048
2048
|
|
|
2049
|
-
/*! @azure/msal-common v5.1.
|
|
2049
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
2050
2050
|
/*
|
|
2051
2051
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2052
2052
|
* Licensed under the MIT License.
|
|
@@ -2060,7 +2060,7 @@ var AuthorityType;
|
|
|
2060
2060
|
AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
|
|
2061
2061
|
})(AuthorityType || (AuthorityType = {}));
|
|
2062
2062
|
|
|
2063
|
-
/*! @azure/msal-common v5.1.
|
|
2063
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
2064
2064
|
|
|
2065
2065
|
/*
|
|
2066
2066
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2294,7 +2294,7 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2294
2294
|
return AccountEntity;
|
|
2295
2295
|
}());
|
|
2296
2296
|
|
|
2297
|
-
/*! @azure/msal-common v5.1.
|
|
2297
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
2298
2298
|
|
|
2299
2299
|
/*
|
|
2300
2300
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2332,7 +2332,7 @@ var AuthToken = /** @class */ (function () {
|
|
|
2332
2332
|
return AuthToken;
|
|
2333
2333
|
}());
|
|
2334
2334
|
|
|
2335
|
-
/*! @azure/msal-common v5.1.
|
|
2335
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
2336
2336
|
|
|
2337
2337
|
/*
|
|
2338
2338
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2576,16 +2576,21 @@ var CacheManager = /** @class */ (function () {
|
|
|
2576
2576
|
break;
|
|
2577
2577
|
}
|
|
2578
2578
|
}
|
|
2579
|
+
/*
|
|
2580
|
+
* At this point, the entity matches the request, update cache key if key schema has changed
|
|
2581
|
+
* Migration code for forwards compatibility with new versions of the library in case of rollback.
|
|
2582
|
+
*/
|
|
2583
|
+
var updatedCacheKey = _this.updateCredentialCacheKey(cacheKey, entity);
|
|
2579
2584
|
switch (credType) {
|
|
2580
2585
|
case CredentialType.ID_TOKEN:
|
|
2581
|
-
matchingCredentials.idTokens[
|
|
2586
|
+
matchingCredentials.idTokens[updatedCacheKey] = entity;
|
|
2582
2587
|
break;
|
|
2583
2588
|
case CredentialType.ACCESS_TOKEN:
|
|
2584
2589
|
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
2585
|
-
matchingCredentials.accessTokens[
|
|
2590
|
+
matchingCredentials.accessTokens[updatedCacheKey] = entity;
|
|
2586
2591
|
break;
|
|
2587
2592
|
case CredentialType.REFRESH_TOKEN:
|
|
2588
|
-
matchingCredentials.refreshTokens[
|
|
2593
|
+
matchingCredentials.refreshTokens[updatedCacheKey] = entity;
|
|
2589
2594
|
break;
|
|
2590
2595
|
}
|
|
2591
2596
|
});
|
|
@@ -3161,10 +3166,14 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
3161
3166
|
});
|
|
3162
3167
|
});
|
|
3163
3168
|
};
|
|
3169
|
+
DefaultStorageClass.prototype.updateCredentialCacheKey = function () {
|
|
3170
|
+
var notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
|
|
3171
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3172
|
+
};
|
|
3164
3173
|
return DefaultStorageClass;
|
|
3165
3174
|
}(CacheManager));
|
|
3166
3175
|
|
|
3167
|
-
/*! @azure/msal-common v5.1.
|
|
3176
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3168
3177
|
|
|
3169
3178
|
/*
|
|
3170
3179
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3246,7 +3255,7 @@ function buildAuthOptions(authOptions) {
|
|
|
3246
3255
|
return __assign({ clientCapabilities: [] }, authOptions);
|
|
3247
3256
|
}
|
|
3248
3257
|
|
|
3249
|
-
/*! @azure/msal-common v5.1.
|
|
3258
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3250
3259
|
|
|
3251
3260
|
/*
|
|
3252
3261
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3266,7 +3275,7 @@ var ServerError = /** @class */ (function (_super) {
|
|
|
3266
3275
|
return ServerError;
|
|
3267
3276
|
}(AuthError));
|
|
3268
3277
|
|
|
3269
|
-
/*! @azure/msal-common v5.1.
|
|
3278
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3270
3279
|
|
|
3271
3280
|
/*
|
|
3272
3281
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3362,7 +3371,7 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
3362
3371
|
return ThrottlingUtils;
|
|
3363
3372
|
}());
|
|
3364
3373
|
|
|
3365
|
-
/*! @azure/msal-common v5.1.
|
|
3374
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3366
3375
|
|
|
3367
3376
|
/*
|
|
3368
3377
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3411,7 +3420,7 @@ var NetworkManager = /** @class */ (function () {
|
|
|
3411
3420
|
return NetworkManager;
|
|
3412
3421
|
}());
|
|
3413
3422
|
|
|
3414
|
-
/*! @azure/msal-common v5.1.
|
|
3423
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3415
3424
|
/*
|
|
3416
3425
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3417
3426
|
* Licensed under the MIT License.
|
|
@@ -3422,7 +3431,7 @@ var CcsCredentialType;
|
|
|
3422
3431
|
CcsCredentialType["UPN"] = "UPN";
|
|
3423
3432
|
})(CcsCredentialType || (CcsCredentialType = {}));
|
|
3424
3433
|
|
|
3425
|
-
/*! @azure/msal-common v5.1.
|
|
3434
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3426
3435
|
|
|
3427
3436
|
/*
|
|
3428
3437
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3511,7 +3520,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
3511
3520
|
return BaseClient;
|
|
3512
3521
|
}());
|
|
3513
3522
|
|
|
3514
|
-
/*! @azure/msal-common v5.1.
|
|
3523
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3515
3524
|
|
|
3516
3525
|
/*
|
|
3517
3526
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3597,7 +3606,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3597
3606
|
return RequestValidator;
|
|
3598
3607
|
}());
|
|
3599
3608
|
|
|
3600
|
-
/*! @azure/msal-common v5.1.
|
|
3609
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3601
3610
|
|
|
3602
3611
|
/*
|
|
3603
3612
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3937,7 +3946,7 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3937
3946
|
return RequestParameterBuilder;
|
|
3938
3947
|
}());
|
|
3939
3948
|
|
|
3940
|
-
/*! @azure/msal-common v5.1.
|
|
3949
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
3941
3950
|
|
|
3942
3951
|
/*
|
|
3943
3952
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4002,7 +4011,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
|
|
|
4002
4011
|
return IdTokenEntity;
|
|
4003
4012
|
}(CredentialEntity));
|
|
4004
4013
|
|
|
4005
|
-
/*! @azure/msal-common v5.1.
|
|
4014
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4006
4015
|
/*
|
|
4007
4016
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4008
4017
|
* Licensed under the MIT License.
|
|
@@ -4052,7 +4061,7 @@ var TimeUtils = /** @class */ (function () {
|
|
|
4052
4061
|
return TimeUtils;
|
|
4053
4062
|
}());
|
|
4054
4063
|
|
|
4055
|
-
/*! @azure/msal-common v5.1.
|
|
4064
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4056
4065
|
|
|
4057
4066
|
/*
|
|
4058
4067
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4159,7 +4168,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
4159
4168
|
return AccessTokenEntity;
|
|
4160
4169
|
}(CredentialEntity));
|
|
4161
4170
|
|
|
4162
|
-
/*! @azure/msal-common v5.1.
|
|
4171
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4163
4172
|
|
|
4164
4173
|
/*
|
|
4165
4174
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4226,7 +4235,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
|
|
|
4226
4235
|
return RefreshTokenEntity;
|
|
4227
4236
|
}(CredentialEntity));
|
|
4228
4237
|
|
|
4229
|
-
/*! @azure/msal-common v5.1.
|
|
4238
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4230
4239
|
|
|
4231
4240
|
/*
|
|
4232
4241
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4290,7 +4299,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
|
4290
4299
|
return InteractionRequiredAuthError;
|
|
4291
4300
|
}(AuthError));
|
|
4292
4301
|
|
|
4293
|
-
/*! @azure/msal-common v5.1.
|
|
4302
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4294
4303
|
/*
|
|
4295
4304
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4296
4305
|
* Licensed under the MIT License.
|
|
@@ -4306,7 +4315,7 @@ var CacheRecord = /** @class */ (function () {
|
|
|
4306
4315
|
return CacheRecord;
|
|
4307
4316
|
}());
|
|
4308
4317
|
|
|
4309
|
-
/*! @azure/msal-common v5.1.
|
|
4318
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4310
4319
|
|
|
4311
4320
|
/*
|
|
4312
4321
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4377,7 +4386,7 @@ var ProtocolUtils = /** @class */ (function () {
|
|
|
4377
4386
|
return ProtocolUtils;
|
|
4378
4387
|
}());
|
|
4379
4388
|
|
|
4380
|
-
/*! @azure/msal-common v5.1.
|
|
4389
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4381
4390
|
|
|
4382
4391
|
/*
|
|
4383
4392
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4578,7 +4587,7 @@ var UrlString = /** @class */ (function () {
|
|
|
4578
4587
|
return UrlString;
|
|
4579
4588
|
}());
|
|
4580
4589
|
|
|
4581
|
-
/*! @azure/msal-common v5.1.
|
|
4590
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4582
4591
|
|
|
4583
4592
|
/*
|
|
4584
4593
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4653,7 +4662,7 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4653
4662
|
return PopTokenGenerator;
|
|
4654
4663
|
}());
|
|
4655
4664
|
|
|
4656
|
-
/*! @azure/msal-common v5.1.
|
|
4665
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4657
4666
|
|
|
4658
4667
|
/*
|
|
4659
4668
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4723,7 +4732,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4723
4732
|
return AppMetadataEntity;
|
|
4724
4733
|
}());
|
|
4725
4734
|
|
|
4726
|
-
/*! @azure/msal-common v5.1.
|
|
4735
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4727
4736
|
/*
|
|
4728
4737
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4729
4738
|
* Licensed under the MIT License.
|
|
@@ -4759,7 +4768,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4759
4768
|
return TokenCacheContext;
|
|
4760
4769
|
}());
|
|
4761
4770
|
|
|
4762
|
-
/*! @azure/msal-common v5.1.
|
|
4771
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
4763
4772
|
|
|
4764
4773
|
/*
|
|
4765
4774
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5023,7 +5032,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5023
5032
|
return ResponseHandler;
|
|
5024
5033
|
}());
|
|
5025
5034
|
|
|
5026
|
-
/*! @azure/msal-common v5.1.
|
|
5035
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5027
5036
|
|
|
5028
5037
|
/*
|
|
5029
5038
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5307,7 +5316,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5307
5316
|
if (request.domainHint) {
|
|
5308
5317
|
parameterBuilder.addDomainHint(request.domainHint);
|
|
5309
5318
|
}
|
|
5310
|
-
// Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object
|
|
5319
|
+
// Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
|
|
5311
5320
|
if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
|
|
5312
5321
|
// AAD will throw if prompt=select_account is passed with an account hint
|
|
5313
5322
|
if (request.sid && request.prompt === PromptValue.NONE) {
|
|
@@ -5317,9 +5326,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5317
5326
|
}
|
|
5318
5327
|
else if (request.account) {
|
|
5319
5328
|
var accountSid = this.extractAccountSid(request.account);
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5329
|
+
var accountLoginHintClaim = this.extractLoginHint(request.account);
|
|
5330
|
+
// If login_hint claim is present, use it over sid/username
|
|
5331
|
+
if (accountLoginHintClaim) {
|
|
5332
|
+
this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
|
|
5333
|
+
parameterBuilder.addLoginHint(accountLoginHintClaim);
|
|
5334
|
+
try {
|
|
5335
|
+
var clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
5336
|
+
parameterBuilder.addCcsOid(clientInfo);
|
|
5337
|
+
}
|
|
5338
|
+
catch (e) {
|
|
5339
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
5340
|
+
}
|
|
5341
|
+
}
|
|
5342
|
+
else if (accountSid && request.prompt === PromptValue.NONE) {
|
|
5343
|
+
/*
|
|
5344
|
+
* If account and loginHint are provided, we will check account first for sid before adding loginHint
|
|
5345
|
+
* SessionId is only used in silent calls
|
|
5346
|
+
*/
|
|
5323
5347
|
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
|
|
5324
5348
|
parameterBuilder.addSid(accountSid);
|
|
5325
5349
|
try {
|
|
@@ -5327,7 +5351,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5327
5351
|
parameterBuilder.addCcsOid(clientInfo);
|
|
5328
5352
|
}
|
|
5329
5353
|
catch (e) {
|
|
5330
|
-
this.logger.verbose("Could not parse home account ID for CCS Header
|
|
5354
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
5331
5355
|
}
|
|
5332
5356
|
}
|
|
5333
5357
|
else if (request.loginHint) {
|
|
@@ -5344,7 +5368,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5344
5368
|
parameterBuilder.addCcsOid(clientInfo);
|
|
5345
5369
|
}
|
|
5346
5370
|
catch (e) {
|
|
5347
|
-
this.logger.verbose("Could not parse home account ID for CCS Header
|
|
5371
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
5348
5372
|
}
|
|
5349
5373
|
}
|
|
5350
5374
|
}
|
|
@@ -5399,16 +5423,17 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5399
5423
|
* @param account
|
|
5400
5424
|
*/
|
|
5401
5425
|
AuthorizationCodeClient.prototype.extractAccountSid = function (account) {
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5426
|
+
var _a;
|
|
5427
|
+
return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a["sid"]) || null;
|
|
5428
|
+
};
|
|
5429
|
+
AuthorizationCodeClient.prototype.extractLoginHint = function (account) {
|
|
5430
|
+
var _a;
|
|
5431
|
+
return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a["login_hint"]) || null;
|
|
5407
5432
|
};
|
|
5408
5433
|
return AuthorizationCodeClient;
|
|
5409
5434
|
}(BaseClient));
|
|
5410
5435
|
|
|
5411
|
-
/*! @azure/msal-common v5.1.
|
|
5436
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5412
5437
|
|
|
5413
5438
|
/*
|
|
5414
5439
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5619,7 +5644,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5619
5644
|
return RefreshTokenClient;
|
|
5620
5645
|
}(BaseClient));
|
|
5621
5646
|
|
|
5622
|
-
/*! @azure/msal-common v5.1.
|
|
5647
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5623
5648
|
|
|
5624
5649
|
/*
|
|
5625
5650
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5742,7 +5767,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5742
5767
|
return SilentFlowClient;
|
|
5743
5768
|
}(BaseClient));
|
|
5744
5769
|
|
|
5745
|
-
/*! @azure/msal-common v5.1.
|
|
5770
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5746
5771
|
/*
|
|
5747
5772
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5748
5773
|
* Licensed under the MIT License.
|
|
@@ -5753,7 +5778,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
5753
5778
|
response.hasOwnProperty("issuer"));
|
|
5754
5779
|
}
|
|
5755
5780
|
|
|
5756
|
-
/*! @azure/msal-common v5.1.
|
|
5781
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5757
5782
|
/*
|
|
5758
5783
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5759
5784
|
* Licensed under the MIT License.
|
|
@@ -5767,7 +5792,7 @@ exports.ProtocolMode = void 0;
|
|
|
5767
5792
|
ProtocolMode["OIDC"] = "OIDC";
|
|
5768
5793
|
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
5769
5794
|
|
|
5770
|
-
/*! @azure/msal-common v5.1.
|
|
5795
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5771
5796
|
|
|
5772
5797
|
/*
|
|
5773
5798
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5842,7 +5867,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
5842
5867
|
return AuthorityMetadataEntity;
|
|
5843
5868
|
}());
|
|
5844
5869
|
|
|
5845
|
-
/*! @azure/msal-common v5.1.
|
|
5870
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5846
5871
|
/*
|
|
5847
5872
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5848
5873
|
* Licensed under the MIT License.
|
|
@@ -5852,7 +5877,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
5852
5877
|
response.hasOwnProperty("metadata"));
|
|
5853
5878
|
}
|
|
5854
5879
|
|
|
5855
|
-
/*! @azure/msal-common v5.1.
|
|
5880
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5856
5881
|
|
|
5857
5882
|
/*
|
|
5858
5883
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5966,7 +5991,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
5966
5991
|
return RegionDiscovery;
|
|
5967
5992
|
}());
|
|
5968
5993
|
|
|
5969
|
-
/*! @azure/msal-common v5.1.
|
|
5994
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
5970
5995
|
|
|
5971
5996
|
/*
|
|
5972
5997
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6532,7 +6557,7 @@ var Authority = /** @class */ (function () {
|
|
|
6532
6557
|
return Authority;
|
|
6533
6558
|
}());
|
|
6534
6559
|
|
|
6535
|
-
/*! @azure/msal-common v5.1.
|
|
6560
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
6536
6561
|
|
|
6537
6562
|
/*
|
|
6538
6563
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6593,7 +6618,7 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
6593
6618
|
return AuthorityFactory;
|
|
6594
6619
|
}());
|
|
6595
6620
|
|
|
6596
|
-
/*! @azure/msal-common v5.1.
|
|
6621
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
6597
6622
|
|
|
6598
6623
|
/*
|
|
6599
6624
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6624,7 +6649,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
|
|
|
6624
6649
|
return ServerTelemetryEntity;
|
|
6625
6650
|
}());
|
|
6626
6651
|
|
|
6627
|
-
/*! @azure/msal-common v5.1.
|
|
6652
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
6628
6653
|
|
|
6629
6654
|
/*
|
|
6630
6655
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6652,7 +6677,7 @@ var ThrottlingEntity = /** @class */ (function () {
|
|
|
6652
6677
|
return ThrottlingEntity;
|
|
6653
6678
|
}());
|
|
6654
6679
|
|
|
6655
|
-
/*! @azure/msal-common v5.1.
|
|
6680
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
6656
6681
|
|
|
6657
6682
|
/*
|
|
6658
6683
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6669,7 +6694,7 @@ var StubbedNetworkModule = {
|
|
|
6669
6694
|
}
|
|
6670
6695
|
};
|
|
6671
6696
|
|
|
6672
|
-
/*! @azure/msal-common v5.1.
|
|
6697
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
6673
6698
|
|
|
6674
6699
|
/*
|
|
6675
6700
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6728,7 +6753,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
|
|
|
6728
6753
|
return AuthenticationHeaderParser;
|
|
6729
6754
|
}());
|
|
6730
6755
|
|
|
6731
|
-
/*! @azure/msal-common v5.1.
|
|
6756
|
+
/*! @azure/msal-common v5.1.1 2022-08-03 */
|
|
6732
6757
|
|
|
6733
6758
|
/*
|
|
6734
6759
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8172,246 +8197,258 @@ var BrowserCrypto = /** @class */ (function () {
|
|
|
8172
8197
|
* Licensed under the MIT License.
|
|
8173
8198
|
*/
|
|
8174
8199
|
/**
|
|
8175
|
-
*
|
|
8200
|
+
* This class implements the Fetch API for GET and POST requests. See more here: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
|
8176
8201
|
*/
|
|
8177
|
-
var
|
|
8178
|
-
function
|
|
8179
|
-
this.dbName = DB_NAME;
|
|
8180
|
-
this.version = DB_VERSION;
|
|
8181
|
-
this.tableName = DB_TABLE_NAME;
|
|
8182
|
-
this.dbOpen = false;
|
|
8202
|
+
var FetchClient = /** @class */ (function () {
|
|
8203
|
+
function FetchClient() {
|
|
8183
8204
|
}
|
|
8184
8205
|
/**
|
|
8185
|
-
*
|
|
8206
|
+
* Fetch Client for REST endpoints - Get request
|
|
8207
|
+
* @param url
|
|
8208
|
+
* @param headers
|
|
8209
|
+
* @param body
|
|
8186
8210
|
*/
|
|
8187
|
-
|
|
8211
|
+
FetchClient.prototype.sendGetRequestAsync = function (url, options) {
|
|
8188
8212
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
8189
|
-
var
|
|
8190
|
-
return __generator$1(this, function (
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8213
|
+
var response, e_1, _a;
|
|
8214
|
+
return __generator$1(this, function (_b) {
|
|
8215
|
+
switch (_b.label) {
|
|
8216
|
+
case 0:
|
|
8217
|
+
_b.trys.push([0, 2, , 3]);
|
|
8218
|
+
return [4 /*yield*/, fetch(url, {
|
|
8219
|
+
method: HTTP_REQUEST_TYPE.GET,
|
|
8220
|
+
headers: this.getFetchHeaders(options)
|
|
8221
|
+
})];
|
|
8222
|
+
case 1:
|
|
8223
|
+
response = _b.sent();
|
|
8224
|
+
return [3 /*break*/, 3];
|
|
8225
|
+
case 2:
|
|
8226
|
+
e_1 = _b.sent();
|
|
8227
|
+
if (window.navigator.onLine) {
|
|
8228
|
+
throw BrowserAuthError.createGetRequestFailedError(e_1, url);
|
|
8229
|
+
}
|
|
8230
|
+
else {
|
|
8231
|
+
throw BrowserAuthError.createNoNetworkConnectivityError();
|
|
8232
|
+
}
|
|
8233
|
+
case 3:
|
|
8234
|
+
_b.trys.push([3, 5, , 6]);
|
|
8235
|
+
_a = {
|
|
8236
|
+
headers: this.getHeaderDict(response.headers)
|
|
8237
|
+
};
|
|
8238
|
+
return [4 /*yield*/, response.json()];
|
|
8239
|
+
case 4: return [2 /*return*/, (_a.body = (_b.sent()),
|
|
8240
|
+
_a.status = response.status,
|
|
8241
|
+
_a)];
|
|
8242
|
+
case 5:
|
|
8243
|
+
_b.sent();
|
|
8244
|
+
throw BrowserAuthError.createFailedToParseNetworkResponseError(url);
|
|
8245
|
+
case 6: return [2 /*return*/];
|
|
8246
|
+
}
|
|
8205
8247
|
});
|
|
8206
8248
|
});
|
|
8207
8249
|
};
|
|
8208
8250
|
/**
|
|
8209
|
-
*
|
|
8251
|
+
* Fetch Client for REST endpoints - Post request
|
|
8252
|
+
* @param url
|
|
8253
|
+
* @param headers
|
|
8254
|
+
* @param body
|
|
8210
8255
|
*/
|
|
8211
|
-
|
|
8256
|
+
FetchClient.prototype.sendPostRequestAsync = function (url, options) {
|
|
8212
8257
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
8213
|
-
|
|
8214
|
-
|
|
8258
|
+
var reqBody, response, e_3, _a;
|
|
8259
|
+
return __generator$1(this, function (_b) {
|
|
8260
|
+
switch (_b.label) {
|
|
8215
8261
|
case 0:
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
case 1:
|
|
8219
|
-
|
|
8262
|
+
reqBody = (options && options.body) || "";
|
|
8263
|
+
_b.label = 1;
|
|
8264
|
+
case 1:
|
|
8265
|
+
_b.trys.push([1, 3, , 4]);
|
|
8266
|
+
return [4 /*yield*/, fetch(url, {
|
|
8267
|
+
method: HTTP_REQUEST_TYPE.POST,
|
|
8268
|
+
headers: this.getFetchHeaders(options),
|
|
8269
|
+
body: reqBody
|
|
8270
|
+
})];
|
|
8271
|
+
case 2:
|
|
8272
|
+
response = _b.sent();
|
|
8273
|
+
return [3 /*break*/, 4];
|
|
8274
|
+
case 3:
|
|
8275
|
+
e_3 = _b.sent();
|
|
8276
|
+
if (window.navigator.onLine) {
|
|
8277
|
+
throw BrowserAuthError.createPostRequestFailedError(e_3, url);
|
|
8278
|
+
}
|
|
8279
|
+
else {
|
|
8280
|
+
throw BrowserAuthError.createNoNetworkConnectivityError();
|
|
8281
|
+
}
|
|
8282
|
+
case 4:
|
|
8283
|
+
_b.trys.push([4, 6, , 7]);
|
|
8284
|
+
_a = {
|
|
8285
|
+
headers: this.getHeaderDict(response.headers)
|
|
8286
|
+
};
|
|
8287
|
+
return [4 /*yield*/, response.json()];
|
|
8288
|
+
case 5: return [2 /*return*/, (_a.body = (_b.sent()),
|
|
8289
|
+
_a.status = response.status,
|
|
8290
|
+
_a)];
|
|
8291
|
+
case 6:
|
|
8292
|
+
_b.sent();
|
|
8293
|
+
throw BrowserAuthError.createFailedToParseNetworkResponseError(url);
|
|
8294
|
+
case 7: return [2 /*return*/];
|
|
8220
8295
|
}
|
|
8221
8296
|
});
|
|
8222
8297
|
});
|
|
8223
8298
|
};
|
|
8224
8299
|
/**
|
|
8225
|
-
*
|
|
8226
|
-
* @param
|
|
8300
|
+
* Get Fetch API Headers object from string map
|
|
8301
|
+
* @param inputHeaders
|
|
8227
8302
|
*/
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
return
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
var dbGet = objectStore.get(key);
|
|
8244
|
-
dbGet.addEventListener("success", function (e) {
|
|
8245
|
-
var event = e;
|
|
8246
|
-
resolve(event.target.result);
|
|
8247
|
-
});
|
|
8248
|
-
dbGet.addEventListener("error", function (e) { return reject(e); });
|
|
8249
|
-
})];
|
|
8250
|
-
}
|
|
8251
|
-
});
|
|
8303
|
+
FetchClient.prototype.getFetchHeaders = function (options) {
|
|
8304
|
+
var headers = new Headers();
|
|
8305
|
+
if (!(options && options.headers)) {
|
|
8306
|
+
return headers;
|
|
8307
|
+
}
|
|
8308
|
+
var optionsHeaders = options.headers;
|
|
8309
|
+
Object.keys(optionsHeaders).forEach(function (key) {
|
|
8310
|
+
headers.append(key, optionsHeaders[key]);
|
|
8311
|
+
});
|
|
8312
|
+
return headers;
|
|
8313
|
+
};
|
|
8314
|
+
FetchClient.prototype.getHeaderDict = function (headers) {
|
|
8315
|
+
var headerDict = {};
|
|
8316
|
+
headers.forEach(function (value, key) {
|
|
8317
|
+
headerDict[key] = value;
|
|
8252
8318
|
});
|
|
8319
|
+
return headerDict;
|
|
8253
8320
|
};
|
|
8321
|
+
return FetchClient;
|
|
8322
|
+
}());
|
|
8323
|
+
|
|
8324
|
+
/*
|
|
8325
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8326
|
+
* Licensed under the MIT License.
|
|
8327
|
+
*/
|
|
8328
|
+
/**
|
|
8329
|
+
* This client implements the XMLHttpRequest class to send GET and POST requests.
|
|
8330
|
+
*/
|
|
8331
|
+
var XhrClient = /** @class */ (function () {
|
|
8332
|
+
function XhrClient() {
|
|
8333
|
+
}
|
|
8254
8334
|
/**
|
|
8255
|
-
*
|
|
8256
|
-
* @param
|
|
8257
|
-
* @param
|
|
8335
|
+
* XhrClient for REST endpoints - Get request
|
|
8336
|
+
* @param url
|
|
8337
|
+
* @param headers
|
|
8338
|
+
* @param body
|
|
8258
8339
|
*/
|
|
8259
|
-
|
|
8340
|
+
XhrClient.prototype.sendGetRequestAsync = function (url, options) {
|
|
8260
8341
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
8261
|
-
var _this = this;
|
|
8262
8342
|
return __generator$1(this, function (_a) {
|
|
8263
|
-
|
|
8264
|
-
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
8265
|
-
case 1:
|
|
8266
|
-
_a.sent();
|
|
8267
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
8268
|
-
// TODO: Add timeouts?
|
|
8269
|
-
if (!_this.db) {
|
|
8270
|
-
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
8271
|
-
}
|
|
8272
|
-
var transaction = _this.db.transaction([_this.tableName], "readwrite");
|
|
8273
|
-
var objectStore = transaction.objectStore(_this.tableName);
|
|
8274
|
-
var dbPut = objectStore.put(payload, key);
|
|
8275
|
-
dbPut.addEventListener("success", function () { return resolve(); });
|
|
8276
|
-
dbPut.addEventListener("error", function (e) { return reject(e); });
|
|
8277
|
-
})];
|
|
8278
|
-
}
|
|
8343
|
+
return [2 /*return*/, this.sendRequestAsync(url, HTTP_REQUEST_TYPE.GET, options)];
|
|
8279
8344
|
});
|
|
8280
8345
|
});
|
|
8281
8346
|
};
|
|
8282
8347
|
/**
|
|
8283
|
-
*
|
|
8284
|
-
* @param
|
|
8348
|
+
* XhrClient for REST endpoints - Post request
|
|
8349
|
+
* @param url
|
|
8350
|
+
* @param headers
|
|
8351
|
+
* @param body
|
|
8285
8352
|
*/
|
|
8286
|
-
|
|
8353
|
+
XhrClient.prototype.sendPostRequestAsync = function (url, options) {
|
|
8287
8354
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
8288
|
-
var _this = this;
|
|
8289
8355
|
return __generator$1(this, function (_a) {
|
|
8290
|
-
|
|
8291
|
-
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
8292
|
-
case 1:
|
|
8293
|
-
_a.sent();
|
|
8294
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
8295
|
-
if (!_this.db) {
|
|
8296
|
-
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
8297
|
-
}
|
|
8298
|
-
var transaction = _this.db.transaction([_this.tableName], "readwrite");
|
|
8299
|
-
var objectStore = transaction.objectStore(_this.tableName);
|
|
8300
|
-
var dbDelete = objectStore.delete(key);
|
|
8301
|
-
dbDelete.addEventListener("success", function () { return resolve(); });
|
|
8302
|
-
dbDelete.addEventListener("error", function (e) { return reject(e); });
|
|
8303
|
-
})];
|
|
8304
|
-
}
|
|
8356
|
+
return [2 /*return*/, this.sendRequestAsync(url, HTTP_REQUEST_TYPE.POST, options)];
|
|
8305
8357
|
});
|
|
8306
8358
|
});
|
|
8307
8359
|
};
|
|
8308
8360
|
/**
|
|
8309
|
-
*
|
|
8361
|
+
* Helper for XhrClient requests.
|
|
8362
|
+
* @param url
|
|
8363
|
+
* @param method
|
|
8364
|
+
* @param options
|
|
8310
8365
|
*/
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
var dbGetKeys = objectStore.getAllKeys();
|
|
8326
|
-
dbGetKeys.addEventListener("success", function (e) {
|
|
8327
|
-
var event = e;
|
|
8328
|
-
resolve(event.target.result);
|
|
8329
|
-
});
|
|
8330
|
-
dbGetKeys.addEventListener("error", function (e) { return reject(e); });
|
|
8331
|
-
})];
|
|
8366
|
+
XhrClient.prototype.sendRequestAsync = function (url, method, options) {
|
|
8367
|
+
var _this = this;
|
|
8368
|
+
return new Promise(function (resolve, reject) {
|
|
8369
|
+
var xhr = new XMLHttpRequest();
|
|
8370
|
+
xhr.open(method, url, /* async: */ true);
|
|
8371
|
+
_this.setXhrHeaders(xhr, options);
|
|
8372
|
+
xhr.onload = function () {
|
|
8373
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
8374
|
+
if (method === HTTP_REQUEST_TYPE.POST) {
|
|
8375
|
+
reject(BrowserAuthError.createPostRequestFailedError("Failed with status " + xhr.status, url));
|
|
8376
|
+
}
|
|
8377
|
+
else {
|
|
8378
|
+
reject(BrowserAuthError.createGetRequestFailedError("Failed with status " + xhr.status, url));
|
|
8379
|
+
}
|
|
8332
8380
|
}
|
|
8333
|
-
|
|
8381
|
+
try {
|
|
8382
|
+
var jsonResponse = JSON.parse(xhr.responseText);
|
|
8383
|
+
var networkResponse = {
|
|
8384
|
+
headers: _this.getHeaderDict(xhr),
|
|
8385
|
+
body: jsonResponse,
|
|
8386
|
+
status: xhr.status
|
|
8387
|
+
};
|
|
8388
|
+
resolve(networkResponse);
|
|
8389
|
+
}
|
|
8390
|
+
catch (e) {
|
|
8391
|
+
reject(BrowserAuthError.createFailedToParseNetworkResponseError(url));
|
|
8392
|
+
}
|
|
8393
|
+
};
|
|
8394
|
+
xhr.onerror = function () {
|
|
8395
|
+
if (window.navigator.onLine) {
|
|
8396
|
+
if (method === HTTP_REQUEST_TYPE.POST) {
|
|
8397
|
+
reject(BrowserAuthError.createPostRequestFailedError("Failed with status " + xhr.status, url));
|
|
8398
|
+
}
|
|
8399
|
+
else {
|
|
8400
|
+
reject(BrowserAuthError.createGetRequestFailedError("Failed with status " + xhr.status, url));
|
|
8401
|
+
}
|
|
8402
|
+
}
|
|
8403
|
+
else {
|
|
8404
|
+
reject(BrowserAuthError.createNoNetworkConnectivityError());
|
|
8405
|
+
}
|
|
8406
|
+
};
|
|
8407
|
+
if (method === HTTP_REQUEST_TYPE.POST && options && options.body) {
|
|
8408
|
+
xhr.send(options.body);
|
|
8409
|
+
}
|
|
8410
|
+
else if (method === HTTP_REQUEST_TYPE.GET) {
|
|
8411
|
+
xhr.send();
|
|
8412
|
+
}
|
|
8413
|
+
else {
|
|
8414
|
+
throw BrowserAuthError.createHttpMethodNotImplementedError(method);
|
|
8415
|
+
}
|
|
8334
8416
|
});
|
|
8335
8417
|
};
|
|
8336
8418
|
/**
|
|
8337
|
-
*
|
|
8338
|
-
*
|
|
8419
|
+
* Helper to set XHR headers for request.
|
|
8420
|
+
* @param xhr
|
|
8421
|
+
* @param options
|
|
8339
8422
|
*/
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
var
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
8346
|
-
case 1:
|
|
8347
|
-
_a.sent();
|
|
8348
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
8349
|
-
if (!_this.db) {
|
|
8350
|
-
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
8351
|
-
}
|
|
8352
|
-
var transaction = _this.db.transaction([_this.tableName], "readonly");
|
|
8353
|
-
var objectStore = transaction.objectStore(_this.tableName);
|
|
8354
|
-
var dbContainsKey = objectStore.count(key);
|
|
8355
|
-
dbContainsKey.addEventListener("success", function (e) {
|
|
8356
|
-
var event = e;
|
|
8357
|
-
resolve(event.target.result === 1);
|
|
8358
|
-
});
|
|
8359
|
-
dbContainsKey.addEventListener("error", function (e) { return reject(e); });
|
|
8360
|
-
})];
|
|
8361
|
-
}
|
|
8423
|
+
XhrClient.prototype.setXhrHeaders = function (xhr, options) {
|
|
8424
|
+
if (options && options.headers) {
|
|
8425
|
+
var headers_1 = options.headers;
|
|
8426
|
+
Object.keys(headers_1).forEach(function (key) {
|
|
8427
|
+
xhr.setRequestHeader(key, headers_1[key]);
|
|
8362
8428
|
});
|
|
8363
|
-
}
|
|
8429
|
+
}
|
|
8364
8430
|
};
|
|
8365
8431
|
/**
|
|
8366
|
-
*
|
|
8367
|
-
*
|
|
8368
|
-
*
|
|
8432
|
+
* Gets a string map of the headers received in the response.
|
|
8433
|
+
*
|
|
8434
|
+
* Algorithm comes from https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders
|
|
8435
|
+
* @param xhr
|
|
8369
8436
|
*/
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
return DatabaseStorage;
|
|
8382
|
-
}());
|
|
8383
|
-
|
|
8384
|
-
/*
|
|
8385
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8386
|
-
* Licensed under the MIT License.
|
|
8387
|
-
*/
|
|
8388
|
-
var MemoryStorage = /** @class */ (function () {
|
|
8389
|
-
function MemoryStorage() {
|
|
8390
|
-
this.cache = new Map();
|
|
8391
|
-
}
|
|
8392
|
-
MemoryStorage.prototype.getItem = function (key) {
|
|
8393
|
-
return this.cache.get(key) || null;
|
|
8394
|
-
};
|
|
8395
|
-
MemoryStorage.prototype.setItem = function (key, value) {
|
|
8396
|
-
this.cache.set(key, value);
|
|
8397
|
-
};
|
|
8398
|
-
MemoryStorage.prototype.removeItem = function (key) {
|
|
8399
|
-
this.cache.delete(key);
|
|
8400
|
-
};
|
|
8401
|
-
MemoryStorage.prototype.getKeys = function () {
|
|
8402
|
-
var cacheKeys = [];
|
|
8403
|
-
this.cache.forEach(function (value, key) {
|
|
8404
|
-
cacheKeys.push(key);
|
|
8437
|
+
XhrClient.prototype.getHeaderDict = function (xhr) {
|
|
8438
|
+
var headerString = xhr.getAllResponseHeaders();
|
|
8439
|
+
var headerArr = headerString.trim().split(/[\r\n]+/);
|
|
8440
|
+
var headerDict = {};
|
|
8441
|
+
headerArr.forEach(function (value) {
|
|
8442
|
+
var parts = value.split(": ");
|
|
8443
|
+
var headerName = parts.shift();
|
|
8444
|
+
var headerVal = parts.join(": ");
|
|
8445
|
+
if (headerName && headerVal) {
|
|
8446
|
+
headerDict[headerName] = headerVal;
|
|
8447
|
+
}
|
|
8405
8448
|
});
|
|
8406
|
-
return
|
|
8407
|
-
};
|
|
8408
|
-
MemoryStorage.prototype.containsKey = function (key) {
|
|
8409
|
-
return this.cache.has(key);
|
|
8410
|
-
};
|
|
8411
|
-
MemoryStorage.prototype.clear = function () {
|
|
8412
|
-
this.cache.clear();
|
|
8449
|
+
return headerDict;
|
|
8413
8450
|
};
|
|
8414
|
-
return
|
|
8451
|
+
return XhrClient;
|
|
8415
8452
|
}());
|
|
8416
8453
|
|
|
8417
8454
|
/*
|
|
@@ -8419,185 +8456,126 @@ var MemoryStorage = /** @class */ (function () {
|
|
|
8419
8456
|
* Licensed under the MIT License.
|
|
8420
8457
|
*/
|
|
8421
8458
|
/**
|
|
8422
|
-
*
|
|
8423
|
-
* backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
|
|
8459
|
+
* Utility class for browser specific functions
|
|
8424
8460
|
*/
|
|
8425
|
-
var
|
|
8426
|
-
function
|
|
8427
|
-
this.inMemoryCache = new MemoryStorage();
|
|
8428
|
-
this.indexedDBCache = new DatabaseStorage();
|
|
8429
|
-
this.logger = logger;
|
|
8461
|
+
var BrowserUtils = /** @class */ (function () {
|
|
8462
|
+
function BrowserUtils() {
|
|
8430
8463
|
}
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8464
|
+
// #region Window Navigation and URL management
|
|
8465
|
+
/**
|
|
8466
|
+
* Clears hash from window url.
|
|
8467
|
+
*/
|
|
8468
|
+
BrowserUtils.clearHash = function (contentWindow) {
|
|
8469
|
+
// Office.js sets history.replaceState to null
|
|
8470
|
+
contentWindow.location.hash = Constants.EMPTY_STRING;
|
|
8471
|
+
if (typeof contentWindow.history.replaceState === "function") {
|
|
8472
|
+
// Full removes "#" from url
|
|
8473
|
+
contentWindow.history.replaceState(null, Constants.EMPTY_STRING, "" + contentWindow.location.origin + contentWindow.location.pathname + contentWindow.location.search);
|
|
8434
8474
|
}
|
|
8435
8475
|
};
|
|
8436
8476
|
/**
|
|
8437
|
-
*
|
|
8438
|
-
* storage object if item isn't found in-memory.
|
|
8439
|
-
* @param key
|
|
8477
|
+
* Replaces current hash with hash from provided url
|
|
8440
8478
|
*/
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
switch (_a.label) {
|
|
8446
|
-
case 0:
|
|
8447
|
-
item = this.inMemoryCache.getItem(key);
|
|
8448
|
-
if (!!item) return [3 /*break*/, 4];
|
|
8449
|
-
_a.label = 1;
|
|
8450
|
-
case 1:
|
|
8451
|
-
_a.trys.push([1, 3, , 4]);
|
|
8452
|
-
this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage.");
|
|
8453
|
-
return [4 /*yield*/, this.indexedDBCache.getItem(key)];
|
|
8454
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
8455
|
-
case 3:
|
|
8456
|
-
e_1 = _a.sent();
|
|
8457
|
-
this.handleDatabaseAccessError(e_1);
|
|
8458
|
-
return [3 /*break*/, 4];
|
|
8459
|
-
case 4: return [2 /*return*/, item];
|
|
8460
|
-
}
|
|
8461
|
-
});
|
|
8462
|
-
});
|
|
8479
|
+
BrowserUtils.replaceHash = function (url) {
|
|
8480
|
+
var urlParts = url.split("#");
|
|
8481
|
+
urlParts.shift(); // Remove part before the hash
|
|
8482
|
+
window.location.hash = urlParts.length > 0 ? urlParts.join("#") : "";
|
|
8463
8483
|
};
|
|
8464
8484
|
/**
|
|
8465
|
-
*
|
|
8466
|
-
* storage object with the given key.
|
|
8467
|
-
* @param key
|
|
8468
|
-
* @param value
|
|
8485
|
+
* Returns boolean of whether the current window is in an iframe or not.
|
|
8469
8486
|
*/
|
|
8470
|
-
|
|
8471
|
-
return
|
|
8472
|
-
var e_2;
|
|
8473
|
-
return __generator$1(this, function (_a) {
|
|
8474
|
-
switch (_a.label) {
|
|
8475
|
-
case 0:
|
|
8476
|
-
this.inMemoryCache.setItem(key, value);
|
|
8477
|
-
_a.label = 1;
|
|
8478
|
-
case 1:
|
|
8479
|
-
_a.trys.push([1, 3, , 4]);
|
|
8480
|
-
return [4 /*yield*/, this.indexedDBCache.setItem(key, value)];
|
|
8481
|
-
case 2:
|
|
8482
|
-
_a.sent();
|
|
8483
|
-
return [3 /*break*/, 4];
|
|
8484
|
-
case 3:
|
|
8485
|
-
e_2 = _a.sent();
|
|
8486
|
-
this.handleDatabaseAccessError(e_2);
|
|
8487
|
-
return [3 /*break*/, 4];
|
|
8488
|
-
case 4: return [2 /*return*/];
|
|
8489
|
-
}
|
|
8490
|
-
});
|
|
8491
|
-
});
|
|
8487
|
+
BrowserUtils.isInIframe = function () {
|
|
8488
|
+
return window.parent !== window;
|
|
8492
8489
|
};
|
|
8493
8490
|
/**
|
|
8494
|
-
*
|
|
8495
|
-
* @param key
|
|
8491
|
+
* Returns boolean of whether or not the current window is a popup opened by msal
|
|
8496
8492
|
*/
|
|
8497
|
-
|
|
8498
|
-
return
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
case 0:
|
|
8503
|
-
this.inMemoryCache.removeItem(key);
|
|
8504
|
-
_a.label = 1;
|
|
8505
|
-
case 1:
|
|
8506
|
-
_a.trys.push([1, 3, , 4]);
|
|
8507
|
-
return [4 /*yield*/, this.indexedDBCache.removeItem(key)];
|
|
8508
|
-
case 2:
|
|
8509
|
-
_a.sent();
|
|
8510
|
-
return [3 /*break*/, 4];
|
|
8511
|
-
case 3:
|
|
8512
|
-
e_3 = _a.sent();
|
|
8513
|
-
this.handleDatabaseAccessError(e_3);
|
|
8514
|
-
return [3 /*break*/, 4];
|
|
8515
|
-
case 4: return [2 /*return*/];
|
|
8516
|
-
}
|
|
8517
|
-
});
|
|
8518
|
-
});
|
|
8493
|
+
BrowserUtils.isInPopup = function () {
|
|
8494
|
+
return typeof window !== "undefined" && !!window.opener &&
|
|
8495
|
+
window.opener !== window &&
|
|
8496
|
+
typeof window.name === "string" &&
|
|
8497
|
+
window.name.indexOf(BrowserConstants.POPUP_NAME_PREFIX + ".") === 0;
|
|
8519
8498
|
};
|
|
8499
|
+
// #endregion
|
|
8520
8500
|
/**
|
|
8521
|
-
*
|
|
8522
|
-
* asynchronous storage object.
|
|
8501
|
+
* Returns current window URL as redirect uri
|
|
8523
8502
|
*/
|
|
8524
|
-
|
|
8525
|
-
return
|
|
8526
|
-
var cacheKeys, e_4;
|
|
8527
|
-
return __generator$1(this, function (_a) {
|
|
8528
|
-
switch (_a.label) {
|
|
8529
|
-
case 0:
|
|
8530
|
-
cacheKeys = this.inMemoryCache.getKeys();
|
|
8531
|
-
if (!(cacheKeys.length === 0)) return [3 /*break*/, 4];
|
|
8532
|
-
_a.label = 1;
|
|
8533
|
-
case 1:
|
|
8534
|
-
_a.trys.push([1, 3, , 4]);
|
|
8535
|
-
this.logger.verbose("In-memory cache is empty, now querying persistent storage.");
|
|
8536
|
-
return [4 /*yield*/, this.indexedDBCache.getKeys()];
|
|
8537
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
8538
|
-
case 3:
|
|
8539
|
-
e_4 = _a.sent();
|
|
8540
|
-
this.handleDatabaseAccessError(e_4);
|
|
8541
|
-
return [3 /*break*/, 4];
|
|
8542
|
-
case 4: return [2 /*return*/, cacheKeys];
|
|
8543
|
-
}
|
|
8544
|
-
});
|
|
8545
|
-
});
|
|
8503
|
+
BrowserUtils.getCurrentUri = function () {
|
|
8504
|
+
return window.location.href.split("?")[0].split("#")[0];
|
|
8546
8505
|
};
|
|
8547
8506
|
/**
|
|
8548
|
-
*
|
|
8549
|
-
* @param key
|
|
8507
|
+
* Gets the homepage url for the current window location.
|
|
8550
8508
|
*/
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
switch (_a.label) {
|
|
8556
|
-
case 0:
|
|
8557
|
-
containsKey = this.inMemoryCache.containsKey(key);
|
|
8558
|
-
if (!!containsKey) return [3 /*break*/, 4];
|
|
8559
|
-
_a.label = 1;
|
|
8560
|
-
case 1:
|
|
8561
|
-
_a.trys.push([1, 3, , 4]);
|
|
8562
|
-
this.logger.verbose("Key not found in in-memory cache, now querying persistent storage.");
|
|
8563
|
-
return [4 /*yield*/, this.indexedDBCache.containsKey(key)];
|
|
8564
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
8565
|
-
case 3:
|
|
8566
|
-
e_5 = _a.sent();
|
|
8567
|
-
this.handleDatabaseAccessError(e_5);
|
|
8568
|
-
return [3 /*break*/, 4];
|
|
8569
|
-
case 4: return [2 /*return*/, containsKey];
|
|
8570
|
-
}
|
|
8571
|
-
});
|
|
8572
|
-
});
|
|
8509
|
+
BrowserUtils.getHomepage = function () {
|
|
8510
|
+
var currentUrl = new UrlString(window.location.href);
|
|
8511
|
+
var urlComponents = currentUrl.getUrlComponents();
|
|
8512
|
+
return urlComponents.Protocol + "//" + urlComponents.HostNameAndPort + "/";
|
|
8573
8513
|
};
|
|
8574
8514
|
/**
|
|
8575
|
-
*
|
|
8515
|
+
* Returns best compatible network client object.
|
|
8576
8516
|
*/
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
_a.label = 1;
|
|
8585
|
-
case 1:
|
|
8586
|
-
_a.trys.push([1, 3, , 4]);
|
|
8587
|
-
return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
|
|
8588
|
-
case 2:
|
|
8589
|
-
_a.sent();
|
|
8590
|
-
return [3 /*break*/, 4];
|
|
8591
|
-
case 3:
|
|
8592
|
-
e_6 = _a.sent();
|
|
8593
|
-
this.handleDatabaseAccessError(e_6);
|
|
8594
|
-
return [3 /*break*/, 4];
|
|
8595
|
-
case 4: return [2 /*return*/];
|
|
8596
|
-
}
|
|
8597
|
-
});
|
|
8598
|
-
});
|
|
8517
|
+
BrowserUtils.getBrowserNetworkClient = function () {
|
|
8518
|
+
if (window.fetch && window.Headers) {
|
|
8519
|
+
return new FetchClient();
|
|
8520
|
+
}
|
|
8521
|
+
else {
|
|
8522
|
+
return new XhrClient();
|
|
8523
|
+
}
|
|
8599
8524
|
};
|
|
8600
|
-
|
|
8525
|
+
/**
|
|
8526
|
+
* Throws error if we have completed an auth and are
|
|
8527
|
+
* attempting another auth request inside an iframe.
|
|
8528
|
+
*/
|
|
8529
|
+
BrowserUtils.blockReloadInHiddenIframes = function () {
|
|
8530
|
+
var isResponseHash = UrlString.hashContainsKnownProperties(window.location.hash);
|
|
8531
|
+
// return an error if called from the hidden iframe created by the msal js silent calls
|
|
8532
|
+
if (isResponseHash && BrowserUtils.isInIframe()) {
|
|
8533
|
+
throw BrowserAuthError.createBlockReloadInHiddenIframeError();
|
|
8534
|
+
}
|
|
8535
|
+
};
|
|
8536
|
+
/**
|
|
8537
|
+
* Block redirect operations in iframes unless explicitly allowed
|
|
8538
|
+
* @param interactionType Interaction type for the request
|
|
8539
|
+
* @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
|
|
8540
|
+
*/
|
|
8541
|
+
BrowserUtils.blockRedirectInIframe = function (interactionType, allowRedirectInIframe) {
|
|
8542
|
+
var isIframedApp = BrowserUtils.isInIframe();
|
|
8543
|
+
if (interactionType === exports.InteractionType.Redirect && isIframedApp && !allowRedirectInIframe) {
|
|
8544
|
+
// If we are not in top frame, we shouldn't redirect. This is also handled by the service.
|
|
8545
|
+
throw BrowserAuthError.createRedirectInIframeError(isIframedApp);
|
|
8546
|
+
}
|
|
8547
|
+
};
|
|
8548
|
+
/**
|
|
8549
|
+
* Block redirectUri loaded in popup from calling AcquireToken APIs
|
|
8550
|
+
*/
|
|
8551
|
+
BrowserUtils.blockAcquireTokenInPopups = function () {
|
|
8552
|
+
// Popups opened by msal popup APIs are given a name that starts with "msal."
|
|
8553
|
+
if (BrowserUtils.isInPopup()) {
|
|
8554
|
+
throw BrowserAuthError.createBlockAcquireTokenInPopupsError();
|
|
8555
|
+
}
|
|
8556
|
+
};
|
|
8557
|
+
/**
|
|
8558
|
+
* Throws error if token requests are made in non-browser environment
|
|
8559
|
+
* @param isBrowserEnvironment Flag indicating if environment is a browser.
|
|
8560
|
+
*/
|
|
8561
|
+
BrowserUtils.blockNonBrowserEnvironment = function (isBrowserEnvironment) {
|
|
8562
|
+
if (!isBrowserEnvironment) {
|
|
8563
|
+
throw BrowserAuthError.createNonBrowserEnvironmentError();
|
|
8564
|
+
}
|
|
8565
|
+
};
|
|
8566
|
+
/**
|
|
8567
|
+
* Returns boolean of whether current browser is an Internet Explorer or Edge browser.
|
|
8568
|
+
*/
|
|
8569
|
+
BrowserUtils.detectIEOrEdge = function () {
|
|
8570
|
+
var ua = window.navigator.userAgent;
|
|
8571
|
+
var msie = ua.indexOf("MSIE ");
|
|
8572
|
+
var msie11 = ua.indexOf("Trident/");
|
|
8573
|
+
var msedge = ua.indexOf("Edge/");
|
|
8574
|
+
var isIE = msie > 0 || msie11 > 0;
|
|
8575
|
+
var isEdge = msedge > 0;
|
|
8576
|
+
return isIE || isEdge;
|
|
8577
|
+
};
|
|
8578
|
+
return BrowserUtils;
|
|
8601
8579
|
}());
|
|
8602
8580
|
|
|
8603
8581
|
/*
|
|
@@ -8605,352 +8583,374 @@ var AsyncMemoryStorage = /** @class */ (function () {
|
|
|
8605
8583
|
* Licensed under the MIT License.
|
|
8606
8584
|
*/
|
|
8607
8585
|
/**
|
|
8608
|
-
*
|
|
8609
|
-
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
|
|
8586
|
+
* BrowserAuthErrorMessage class containing string constants used by error codes and messages.
|
|
8610
8587
|
*/
|
|
8611
|
-
var
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8588
|
+
var BrowserConfigurationAuthErrorMessage = {
|
|
8589
|
+
redirectUriNotSet: {
|
|
8590
|
+
code: "redirect_uri_empty",
|
|
8591
|
+
desc: "A redirect URI is required for all calls, and none has been set."
|
|
8592
|
+
},
|
|
8593
|
+
postLogoutUriNotSet: {
|
|
8594
|
+
code: "post_logout_uri_empty",
|
|
8595
|
+
desc: "A post logout redirect has not been set."
|
|
8596
|
+
},
|
|
8597
|
+
storageNotSupportedError: {
|
|
8598
|
+
code: "storage_not_supported",
|
|
8599
|
+
desc: "Given storage configuration option was not supported."
|
|
8600
|
+
},
|
|
8601
|
+
noRedirectCallbacksSet: {
|
|
8602
|
+
code: "no_redirect_callbacks",
|
|
8603
|
+
desc: "No redirect callbacks have been set. Please call setRedirectCallbacks() with the appropriate function arguments before continuing. " +
|
|
8604
|
+
"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
|
|
8605
|
+
},
|
|
8606
|
+
invalidCallbackObject: {
|
|
8607
|
+
code: "invalid_callback_object",
|
|
8608
|
+
desc: "The object passed for the callback was invalid. " +
|
|
8609
|
+
"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
|
|
8610
|
+
},
|
|
8611
|
+
stubPcaInstanceCalled: {
|
|
8612
|
+
code: "stubbed_public_client_application_called",
|
|
8613
|
+
desc: "Stub instance of Public Client Application was called. If using msal-react, please ensure context is not used without a provider. For more visit: aka.ms/msaljs/browser-errors"
|
|
8614
|
+
},
|
|
8615
|
+
inMemRedirectUnavailable: {
|
|
8616
|
+
code: "in_mem_redirect_unavailable",
|
|
8617
|
+
desc: "Redirect cannot be supported. In-memory storage was selected and storeAuthStateInCookie=false, which would cause the library to be unable to handle the incoming hash. If you would like to use the redirect API, please use session/localStorage or set storeAuthStateInCookie=true."
|
|
8618
|
+
}
|
|
8619
|
+
};
|
|
8620
|
+
/**
|
|
8621
|
+
* Browser library error class thrown by the MSAL.js library for SPAs
|
|
8622
|
+
*/
|
|
8623
|
+
var BrowserConfigurationAuthError = /** @class */ (function (_super) {
|
|
8624
|
+
__extends$1(BrowserConfigurationAuthError, _super);
|
|
8625
|
+
function BrowserConfigurationAuthError(errorCode, errorMessage) {
|
|
8626
|
+
var _this = _super.call(this, errorCode, errorMessage) || this;
|
|
8627
|
+
_this.name = "BrowserConfigurationAuthError";
|
|
8628
|
+
Object.setPrototypeOf(_this, BrowserConfigurationAuthError.prototype);
|
|
8629
|
+
return _this;
|
|
8624
8630
|
}
|
|
8625
8631
|
/**
|
|
8626
|
-
* Creates
|
|
8627
|
-
* @returns string (GUID)
|
|
8632
|
+
* Creates an error thrown when the redirect uri is empty (not set by caller)
|
|
8628
8633
|
*/
|
|
8629
|
-
|
|
8630
|
-
return
|
|
8634
|
+
BrowserConfigurationAuthError.createRedirectUriEmptyError = function () {
|
|
8635
|
+
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.redirectUriNotSet.code, BrowserConfigurationAuthErrorMessage.redirectUriNotSet.desc);
|
|
8631
8636
|
};
|
|
8632
8637
|
/**
|
|
8633
|
-
*
|
|
8634
|
-
* @param input
|
|
8638
|
+
* Creates an error thrown when the post-logout redirect uri is empty (not set by caller)
|
|
8635
8639
|
*/
|
|
8636
|
-
|
|
8637
|
-
return
|
|
8640
|
+
BrowserConfigurationAuthError.createPostLogoutRedirectUriEmptyError = function () {
|
|
8641
|
+
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.postLogoutUriNotSet.code, BrowserConfigurationAuthErrorMessage.postLogoutUriNotSet.desc);
|
|
8638
8642
|
};
|
|
8639
8643
|
/**
|
|
8640
|
-
*
|
|
8641
|
-
* @param
|
|
8644
|
+
* Creates error thrown when given storage location is not supported.
|
|
8645
|
+
* @param givenStorageLocation
|
|
8642
8646
|
*/
|
|
8643
|
-
|
|
8644
|
-
return
|
|
8647
|
+
BrowserConfigurationAuthError.createStorageNotSupportedError = function (givenStorageLocation) {
|
|
8648
|
+
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.storageNotSupportedError.code, BrowserConfigurationAuthErrorMessage.storageNotSupportedError.desc + " Given Location: " + givenStorageLocation);
|
|
8645
8649
|
};
|
|
8646
8650
|
/**
|
|
8647
|
-
*
|
|
8651
|
+
* Creates error thrown when redirect callbacks are not set before calling loginRedirect() or acquireTokenRedirect().
|
|
8648
8652
|
*/
|
|
8649
|
-
|
|
8650
|
-
return
|
|
8651
|
-
return __generator$1(this, function (_a) {
|
|
8652
|
-
return [2 /*return*/, this.pkceGenerator.generateCodes()];
|
|
8653
|
-
});
|
|
8654
|
-
});
|
|
8653
|
+
BrowserConfigurationAuthError.createRedirectCallbacksNotSetError = function () {
|
|
8654
|
+
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.noRedirectCallbacksSet.code, BrowserConfigurationAuthErrorMessage.noRedirectCallbacksSet.desc);
|
|
8655
8655
|
};
|
|
8656
8656
|
/**
|
|
8657
|
-
*
|
|
8658
|
-
* @param request
|
|
8657
|
+
* Creates error thrown when the stub instance of PublicClientApplication is called.
|
|
8659
8658
|
*/
|
|
8660
|
-
|
|
8661
|
-
return
|
|
8662
|
-
var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkBuffer, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
|
|
8663
|
-
return __generator$1(this, function (_a) {
|
|
8664
|
-
switch (_a.label) {
|
|
8665
|
-
case 0: return [4 /*yield*/, this.browserCrypto.generateKeyPair(CryptoOps.EXTRACTABLE, CryptoOps.POP_KEY_USAGES)];
|
|
8666
|
-
case 1:
|
|
8667
|
-
keyPair = _a.sent();
|
|
8668
|
-
return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.publicKey)];
|
|
8669
|
-
case 2:
|
|
8670
|
-
publicKeyJwk = _a.sent();
|
|
8671
|
-
pubKeyThumprintObj = {
|
|
8672
|
-
e: publicKeyJwk.e,
|
|
8673
|
-
kty: publicKeyJwk.kty,
|
|
8674
|
-
n: publicKeyJwk.n
|
|
8675
|
-
};
|
|
8676
|
-
publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
|
|
8677
|
-
return [4 /*yield*/, this.browserCrypto.sha256Digest(publicJwkString)];
|
|
8678
|
-
case 3:
|
|
8679
|
-
publicJwkBuffer = _a.sent();
|
|
8680
|
-
publicJwkHash = this.b64Encode.urlEncodeArr(new Uint8Array(publicJwkBuffer));
|
|
8681
|
-
return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.privateKey)];
|
|
8682
|
-
case 4:
|
|
8683
|
-
privateKeyJwk = _a.sent();
|
|
8684
|
-
return [4 /*yield*/, this.browserCrypto.importJwk(privateKeyJwk, false, ["sign"])];
|
|
8685
|
-
case 5:
|
|
8686
|
-
unextractablePrivateKey = _a.sent();
|
|
8687
|
-
// Store Keypair data in keystore
|
|
8688
|
-
return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
|
|
8689
|
-
privateKey: unextractablePrivateKey,
|
|
8690
|
-
publicKey: keyPair.publicKey,
|
|
8691
|
-
requestMethod: request.resourceRequestMethod,
|
|
8692
|
-
requestUri: request.resourceRequestUri
|
|
8693
|
-
})];
|
|
8694
|
-
case 6:
|
|
8695
|
-
// Store Keypair data in keystore
|
|
8696
|
-
_a.sent();
|
|
8697
|
-
return [2 /*return*/, publicJwkHash];
|
|
8698
|
-
}
|
|
8699
|
-
});
|
|
8700
|
-
});
|
|
8701
|
-
};
|
|
8702
|
-
/**
|
|
8703
|
-
* Removes cryptographic keypair from key store matching the keyId passed in
|
|
8704
|
-
* @param kid
|
|
8705
|
-
*/
|
|
8706
|
-
CryptoOps.prototype.removeTokenBindingKey = function (kid) {
|
|
8707
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
8708
|
-
var keyFound;
|
|
8709
|
-
return __generator$1(this, function (_a) {
|
|
8710
|
-
switch (_a.label) {
|
|
8711
|
-
case 0: return [4 /*yield*/, this.cache.asymmetricKeys.removeItem(kid)];
|
|
8712
|
-
case 1:
|
|
8713
|
-
_a.sent();
|
|
8714
|
-
return [4 /*yield*/, this.cache.asymmetricKeys.containsKey(kid)];
|
|
8715
|
-
case 2:
|
|
8716
|
-
keyFound = _a.sent();
|
|
8717
|
-
return [2 /*return*/, !keyFound];
|
|
8718
|
-
}
|
|
8719
|
-
});
|
|
8720
|
-
});
|
|
8721
|
-
};
|
|
8722
|
-
/**
|
|
8723
|
-
* Removes all cryptographic keys from IndexedDB storage
|
|
8724
|
-
*/
|
|
8725
|
-
CryptoOps.prototype.clearKeystore = function () {
|
|
8726
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
8727
|
-
var dataStoreNames, databaseStorage, _a;
|
|
8728
|
-
return __generator$1(this, function (_b) {
|
|
8729
|
-
switch (_b.label) {
|
|
8730
|
-
case 0:
|
|
8731
|
-
dataStoreNames = Object.keys(this.cache);
|
|
8732
|
-
databaseStorage = this.cache[dataStoreNames[0]];
|
|
8733
|
-
if (!databaseStorage) return [3 /*break*/, 2];
|
|
8734
|
-
return [4 /*yield*/, databaseStorage.deleteDatabase()];
|
|
8735
|
-
case 1:
|
|
8736
|
-
_a = _b.sent();
|
|
8737
|
-
return [3 /*break*/, 3];
|
|
8738
|
-
case 2:
|
|
8739
|
-
_a = false;
|
|
8740
|
-
_b.label = 3;
|
|
8741
|
-
case 3: return [2 /*return*/, _a];
|
|
8742
|
-
}
|
|
8743
|
-
});
|
|
8744
|
-
});
|
|
8659
|
+
BrowserConfigurationAuthError.createStubPcaInstanceCalledError = function () {
|
|
8660
|
+
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.stubPcaInstanceCalled.code, BrowserConfigurationAuthErrorMessage.stubPcaInstanceCalled.desc);
|
|
8745
8661
|
};
|
|
8746
|
-
|
|
8747
|
-
*
|
|
8748
|
-
* @param payload
|
|
8749
|
-
* @param kid
|
|
8662
|
+
/*
|
|
8663
|
+
* Create an error thrown when in-memory storage is used and storeAuthStateInCookie=false.
|
|
8750
8664
|
*/
|
|
8751
|
-
|
|
8752
|
-
return
|
|
8753
|
-
var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
|
|
8754
|
-
return __generator$1(this, function (_a) {
|
|
8755
|
-
switch (_a.label) {
|
|
8756
|
-
case 0: return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
|
|
8757
|
-
case 1:
|
|
8758
|
-
cachedKeyPair = _a.sent();
|
|
8759
|
-
if (!cachedKeyPair) {
|
|
8760
|
-
throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
|
|
8761
|
-
}
|
|
8762
|
-
return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
|
|
8763
|
-
case 2:
|
|
8764
|
-
publicKeyJwk = _a.sent();
|
|
8765
|
-
publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
|
|
8766
|
-
header = {
|
|
8767
|
-
alg: publicKeyJwk.alg,
|
|
8768
|
-
type: KEY_FORMAT_JWK
|
|
8769
|
-
};
|
|
8770
|
-
encodedHeader = this.b64Encode.urlEncode(JSON.stringify(header));
|
|
8771
|
-
// Generate payload
|
|
8772
|
-
payload.cnf = {
|
|
8773
|
-
jwk: JSON.parse(publicKeyJwkString)
|
|
8774
|
-
};
|
|
8775
|
-
encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
|
|
8776
|
-
tokenString = encodedHeader + "." + encodedPayload;
|
|
8777
|
-
tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
|
|
8778
|
-
return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
|
|
8779
|
-
case 3:
|
|
8780
|
-
signatureBuffer = _a.sent();
|
|
8781
|
-
encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
8782
|
-
return [2 /*return*/, tokenString + "." + encodedSignature];
|
|
8783
|
-
}
|
|
8784
|
-
});
|
|
8785
|
-
});
|
|
8665
|
+
BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError = function () {
|
|
8666
|
+
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.code, BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.desc);
|
|
8786
8667
|
};
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
return CryptoOps;
|
|
8790
|
-
}());
|
|
8668
|
+
return BrowserConfigurationAuthError;
|
|
8669
|
+
}(AuthError));
|
|
8791
8670
|
|
|
8792
8671
|
/*
|
|
8793
8672
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8794
8673
|
* Licensed under the MIT License.
|
|
8795
8674
|
*/
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
var BrowserConfigurationAuthErrorMessage = {
|
|
8800
|
-
redirectUriNotSet: {
|
|
8801
|
-
code: "redirect_uri_empty",
|
|
8802
|
-
desc: "A redirect URI is required for all calls, and none has been set."
|
|
8675
|
+
var stubbedPublicClientApplication = {
|
|
8676
|
+
acquireTokenPopup: function () {
|
|
8677
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8803
8678
|
},
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
desc: "A post logout redirect has not been set."
|
|
8679
|
+
acquireTokenRedirect: function () {
|
|
8680
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8807
8681
|
},
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
desc: "Given storage configuration option was not supported."
|
|
8682
|
+
acquireTokenSilent: function () {
|
|
8683
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8811
8684
|
},
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
desc: "No redirect callbacks have been set. Please call setRedirectCallbacks() with the appropriate function arguments before continuing. " +
|
|
8815
|
-
"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
|
|
8685
|
+
getAllAccounts: function () {
|
|
8686
|
+
return [];
|
|
8816
8687
|
},
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
desc: "The object passed for the callback was invalid. " +
|
|
8820
|
-
"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
|
|
8688
|
+
getAccountByHomeId: function () {
|
|
8689
|
+
return null;
|
|
8821
8690
|
},
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
desc: "Stub instance of Public Client Application was called. If using msal-react, please ensure context is not used without a provider. For more visit: aka.ms/msaljs/browser-errors"
|
|
8691
|
+
getAccountByUsername: function () {
|
|
8692
|
+
return null;
|
|
8825
8693
|
},
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8694
|
+
getAccountByLocalId: function () {
|
|
8695
|
+
return null;
|
|
8696
|
+
},
|
|
8697
|
+
handleRedirectPromise: function () {
|
|
8698
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8699
|
+
},
|
|
8700
|
+
loginPopup: function () {
|
|
8701
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8702
|
+
},
|
|
8703
|
+
loginRedirect: function () {
|
|
8704
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8705
|
+
},
|
|
8706
|
+
logout: function () {
|
|
8707
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8708
|
+
},
|
|
8709
|
+
logoutRedirect: function () {
|
|
8710
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8711
|
+
},
|
|
8712
|
+
logoutPopup: function () {
|
|
8713
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8714
|
+
},
|
|
8715
|
+
ssoSilent: function () {
|
|
8716
|
+
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
8717
|
+
},
|
|
8718
|
+
addEventCallback: function () {
|
|
8719
|
+
return null;
|
|
8720
|
+
},
|
|
8721
|
+
removeEventCallback: function () {
|
|
8722
|
+
return;
|
|
8723
|
+
},
|
|
8724
|
+
enableAccountStorageEvents: function () {
|
|
8725
|
+
return;
|
|
8726
|
+
},
|
|
8727
|
+
disableAccountStorageEvents: function () {
|
|
8728
|
+
return;
|
|
8729
|
+
},
|
|
8730
|
+
getTokenCache: function () {
|
|
8731
|
+
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
8732
|
+
},
|
|
8733
|
+
getLogger: function () {
|
|
8734
|
+
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
8735
|
+
},
|
|
8736
|
+
setLogger: function () {
|
|
8737
|
+
return;
|
|
8738
|
+
},
|
|
8739
|
+
setActiveAccount: function () {
|
|
8740
|
+
return;
|
|
8741
|
+
},
|
|
8742
|
+
getActiveAccount: function () {
|
|
8743
|
+
return null;
|
|
8744
|
+
},
|
|
8745
|
+
initializeWrapperLibrary: function () {
|
|
8746
|
+
return;
|
|
8747
|
+
},
|
|
8748
|
+
setNavigationClient: function () {
|
|
8749
|
+
return;
|
|
8750
|
+
},
|
|
8751
|
+
getConfiguration: function () {
|
|
8752
|
+
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
8829
8753
|
}
|
|
8830
|
-
};
|
|
8831
|
-
|
|
8832
|
-
|
|
8754
|
+
};
|
|
8755
|
+
|
|
8756
|
+
/*
|
|
8757
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8758
|
+
* Licensed under the MIT License.
|
|
8833
8759
|
*/
|
|
8834
|
-
var
|
|
8835
|
-
|
|
8836
|
-
function BrowserConfigurationAuthError(errorCode, errorMessage) {
|
|
8837
|
-
var _this = _super.call(this, errorCode, errorMessage) || this;
|
|
8838
|
-
_this.name = "BrowserConfigurationAuthError";
|
|
8839
|
-
Object.setPrototypeOf(_this, BrowserConfigurationAuthError.prototype);
|
|
8840
|
-
return _this;
|
|
8760
|
+
var NavigationClient = /** @class */ (function () {
|
|
8761
|
+
function NavigationClient() {
|
|
8841
8762
|
}
|
|
8842
8763
|
/**
|
|
8843
|
-
*
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.redirectUriNotSet.code, BrowserConfigurationAuthErrorMessage.redirectUriNotSet.desc);
|
|
8847
|
-
};
|
|
8848
|
-
/**
|
|
8849
|
-
* Creates an error thrown when the post-logout redirect uri is empty (not set by caller)
|
|
8850
|
-
*/
|
|
8851
|
-
BrowserConfigurationAuthError.createPostLogoutRedirectUriEmptyError = function () {
|
|
8852
|
-
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.postLogoutUriNotSet.code, BrowserConfigurationAuthErrorMessage.postLogoutUriNotSet.desc);
|
|
8853
|
-
};
|
|
8854
|
-
/**
|
|
8855
|
-
* Creates error thrown when given storage location is not supported.
|
|
8856
|
-
* @param givenStorageLocation
|
|
8764
|
+
* Navigates to other pages within the same web application
|
|
8765
|
+
* @param url
|
|
8766
|
+
* @param options
|
|
8857
8767
|
*/
|
|
8858
|
-
|
|
8859
|
-
return
|
|
8768
|
+
NavigationClient.prototype.navigateInternal = function (url, options) {
|
|
8769
|
+
return NavigationClient.defaultNavigateWindow(url, options);
|
|
8860
8770
|
};
|
|
8861
8771
|
/**
|
|
8862
|
-
*
|
|
8772
|
+
* Navigates to other pages outside the web application i.e. the Identity Provider
|
|
8773
|
+
* @param url
|
|
8774
|
+
* @param options
|
|
8863
8775
|
*/
|
|
8864
|
-
|
|
8865
|
-
return
|
|
8776
|
+
NavigationClient.prototype.navigateExternal = function (url, options) {
|
|
8777
|
+
return NavigationClient.defaultNavigateWindow(url, options);
|
|
8866
8778
|
};
|
|
8867
8779
|
/**
|
|
8868
|
-
*
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.stubPcaInstanceCalled.code, BrowserConfigurationAuthErrorMessage.stubPcaInstanceCalled.desc);
|
|
8872
|
-
};
|
|
8873
|
-
/*
|
|
8874
|
-
* Create an error thrown when in-memory storage is used and storeAuthStateInCookie=false.
|
|
8780
|
+
* Default navigation implementation invoked by the internal and external functions
|
|
8781
|
+
* @param url
|
|
8782
|
+
* @param options
|
|
8875
8783
|
*/
|
|
8876
|
-
|
|
8877
|
-
|
|
8784
|
+
NavigationClient.defaultNavigateWindow = function (url, options) {
|
|
8785
|
+
if (options.noHistory) {
|
|
8786
|
+
window.location.replace(url);
|
|
8787
|
+
}
|
|
8788
|
+
else {
|
|
8789
|
+
window.location.assign(url);
|
|
8790
|
+
}
|
|
8791
|
+
return new Promise(function (resolve) {
|
|
8792
|
+
setTimeout(function () {
|
|
8793
|
+
resolve(true);
|
|
8794
|
+
}, options.timeout);
|
|
8795
|
+
});
|
|
8878
8796
|
};
|
|
8879
|
-
return
|
|
8880
|
-
}(
|
|
8797
|
+
return NavigationClient;
|
|
8798
|
+
}());
|
|
8881
8799
|
|
|
8882
8800
|
/*
|
|
8883
8801
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8884
8802
|
* Licensed under the MIT License.
|
|
8885
8803
|
*/
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8804
|
+
exports.EventType = void 0;
|
|
8805
|
+
(function (EventType) {
|
|
8806
|
+
EventType["ACCOUNT_ADDED"] = "msal:accountAdded";
|
|
8807
|
+
EventType["ACCOUNT_REMOVED"] = "msal:accountRemoved";
|
|
8808
|
+
EventType["LOGIN_START"] = "msal:loginStart";
|
|
8809
|
+
EventType["LOGIN_SUCCESS"] = "msal:loginSuccess";
|
|
8810
|
+
EventType["LOGIN_FAILURE"] = "msal:loginFailure";
|
|
8811
|
+
EventType["ACQUIRE_TOKEN_START"] = "msal:acquireTokenStart";
|
|
8812
|
+
EventType["ACQUIRE_TOKEN_SUCCESS"] = "msal:acquireTokenSuccess";
|
|
8813
|
+
EventType["ACQUIRE_TOKEN_FAILURE"] = "msal:acquireTokenFailure";
|
|
8814
|
+
EventType["ACQUIRE_TOKEN_NETWORK_START"] = "msal:acquireTokenFromNetworkStart";
|
|
8815
|
+
EventType["SSO_SILENT_START"] = "msal:ssoSilentStart";
|
|
8816
|
+
EventType["SSO_SILENT_SUCCESS"] = "msal:ssoSilentSuccess";
|
|
8817
|
+
EventType["SSO_SILENT_FAILURE"] = "msal:ssoSilentFailure";
|
|
8818
|
+
EventType["HANDLE_REDIRECT_START"] = "msal:handleRedirectStart";
|
|
8819
|
+
EventType["HANDLE_REDIRECT_END"] = "msal:handleRedirectEnd";
|
|
8820
|
+
EventType["POPUP_OPENED"] = "msal:popupOpened";
|
|
8821
|
+
EventType["LOGOUT_START"] = "msal:logoutStart";
|
|
8822
|
+
EventType["LOGOUT_SUCCESS"] = "msal:logoutSuccess";
|
|
8823
|
+
EventType["LOGOUT_FAILURE"] = "msal:logoutFailure";
|
|
8824
|
+
EventType["LOGOUT_END"] = "msal:logoutEnd";
|
|
8825
|
+
})(exports.EventType || (exports.EventType = {}));
|
|
8826
|
+
|
|
8827
|
+
/*
|
|
8828
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8829
|
+
* Licensed under the MIT License.
|
|
8830
|
+
*/
|
|
8831
|
+
var EventMessageUtils = /** @class */ (function () {
|
|
8832
|
+
function EventMessageUtils() {
|
|
8890
8833
|
}
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8834
|
+
/**
|
|
8835
|
+
* Gets interaction status from event message
|
|
8836
|
+
* @param message
|
|
8837
|
+
* @param currentStatus
|
|
8838
|
+
*/
|
|
8839
|
+
EventMessageUtils.getInteractionStatusFromEvent = function (message, currentStatus) {
|
|
8840
|
+
switch (message.eventType) {
|
|
8841
|
+
case exports.EventType.LOGIN_START:
|
|
8842
|
+
return exports.InteractionStatus.Login;
|
|
8843
|
+
case exports.EventType.SSO_SILENT_START:
|
|
8844
|
+
return exports.InteractionStatus.SsoSilent;
|
|
8845
|
+
case exports.EventType.ACQUIRE_TOKEN_START:
|
|
8846
|
+
if (message.interactionType === exports.InteractionType.Redirect || message.interactionType === exports.InteractionType.Popup) {
|
|
8847
|
+
return exports.InteractionStatus.AcquireToken;
|
|
8848
|
+
}
|
|
8849
|
+
break;
|
|
8850
|
+
case exports.EventType.HANDLE_REDIRECT_START:
|
|
8851
|
+
return exports.InteractionStatus.HandleRedirect;
|
|
8852
|
+
case exports.EventType.LOGOUT_START:
|
|
8853
|
+
return exports.InteractionStatus.Logout;
|
|
8854
|
+
case exports.EventType.SSO_SILENT_SUCCESS:
|
|
8855
|
+
case exports.EventType.SSO_SILENT_FAILURE:
|
|
8856
|
+
if (currentStatus && currentStatus !== exports.InteractionStatus.SsoSilent) {
|
|
8857
|
+
// Prevent this event from clearing any status other than ssoSilent
|
|
8858
|
+
break;
|
|
8859
|
+
}
|
|
8860
|
+
return exports.InteractionStatus.None;
|
|
8861
|
+
case exports.EventType.LOGOUT_END:
|
|
8862
|
+
if (currentStatus && currentStatus !== exports.InteractionStatus.Logout) {
|
|
8863
|
+
// Prevent this event from clearing any status other than logout
|
|
8864
|
+
break;
|
|
8865
|
+
}
|
|
8866
|
+
return exports.InteractionStatus.None;
|
|
8867
|
+
case exports.EventType.HANDLE_REDIRECT_END:
|
|
8868
|
+
if (currentStatus && currentStatus !== exports.InteractionStatus.HandleRedirect) {
|
|
8869
|
+
// Prevent this event from clearing any status other than handleRedirect
|
|
8870
|
+
break;
|
|
8871
|
+
}
|
|
8872
|
+
return exports.InteractionStatus.None;
|
|
8873
|
+
case exports.EventType.LOGIN_SUCCESS:
|
|
8874
|
+
case exports.EventType.LOGIN_FAILURE:
|
|
8875
|
+
case exports.EventType.ACQUIRE_TOKEN_SUCCESS:
|
|
8876
|
+
case exports.EventType.ACQUIRE_TOKEN_FAILURE:
|
|
8877
|
+
if (message.interactionType === exports.InteractionType.Redirect || message.interactionType === exports.InteractionType.Popup) {
|
|
8878
|
+
if (currentStatus && currentStatus !== exports.InteractionStatus.Login && currentStatus !== exports.InteractionStatus.AcquireToken) {
|
|
8879
|
+
// Prevent this event from clearing any status other than login or acquireToken
|
|
8880
|
+
break;
|
|
8881
|
+
}
|
|
8882
|
+
return exports.InteractionStatus.None;
|
|
8883
|
+
}
|
|
8884
|
+
break;
|
|
8898
8885
|
}
|
|
8886
|
+
return null;
|
|
8899
8887
|
};
|
|
8900
|
-
|
|
8901
|
-
return this.windowStorage.getItem(key);
|
|
8902
|
-
};
|
|
8903
|
-
BrowserStorage.prototype.setItem = function (key, value) {
|
|
8904
|
-
this.windowStorage.setItem(key, value);
|
|
8905
|
-
};
|
|
8906
|
-
BrowserStorage.prototype.removeItem = function (key) {
|
|
8907
|
-
this.windowStorage.removeItem(key);
|
|
8908
|
-
};
|
|
8909
|
-
BrowserStorage.prototype.getKeys = function () {
|
|
8910
|
-
return Object.keys(this.windowStorage);
|
|
8911
|
-
};
|
|
8912
|
-
BrowserStorage.prototype.containsKey = function (key) {
|
|
8913
|
-
return this.windowStorage.hasOwnProperty(key);
|
|
8914
|
-
};
|
|
8915
|
-
return BrowserStorage;
|
|
8888
|
+
return EventMessageUtils;
|
|
8916
8889
|
}());
|
|
8917
8890
|
|
|
8891
|
+
/* eslint-disable header/header */
|
|
8892
|
+
var name = "@azure/msal-browser";
|
|
8893
|
+
var version = "2.19.0";
|
|
8894
|
+
|
|
8918
8895
|
/*
|
|
8919
8896
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8920
8897
|
* Licensed under the MIT License.
|
|
8921
8898
|
*/
|
|
8922
|
-
var
|
|
8923
|
-
function
|
|
8899
|
+
var SignedHttpRequest = /** @class */ (function () {
|
|
8900
|
+
function SignedHttpRequest(shrParameters, shrOptions) {
|
|
8901
|
+
var loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};
|
|
8902
|
+
this.logger = new Logger(loggerOptions, name, version);
|
|
8903
|
+
this.cryptoOps = new CryptoOps(this.logger);
|
|
8904
|
+
this.popTokenGenerator = new PopTokenGenerator(this.cryptoOps);
|
|
8905
|
+
this.shrParameters = shrParameters;
|
|
8924
8906
|
}
|
|
8925
8907
|
/**
|
|
8926
|
-
*
|
|
8927
|
-
* @
|
|
8928
|
-
* @param state
|
|
8908
|
+
* Generates and caches a keypair for the given request options.
|
|
8909
|
+
* @returns Public key digest, which should be sent to the token issuer.
|
|
8929
8910
|
*/
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8911
|
+
SignedHttpRequest.prototype.generatePublicKeyThumbprint = function () {
|
|
8912
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
8913
|
+
var kid;
|
|
8914
|
+
return __generator$1(this, function (_a) {
|
|
8915
|
+
switch (_a.label) {
|
|
8916
|
+
case 0: return [4 /*yield*/, this.popTokenGenerator.generateKid(this.shrParameters)];
|
|
8917
|
+
case 1:
|
|
8918
|
+
kid = (_a.sent()).kid;
|
|
8919
|
+
return [2 /*return*/, kid];
|
|
8920
|
+
}
|
|
8921
|
+
});
|
|
8922
|
+
});
|
|
8941
8923
|
};
|
|
8942
8924
|
/**
|
|
8943
|
-
*
|
|
8944
|
-
* @param
|
|
8925
|
+
* Generates a signed http request for the given payload with the given key.
|
|
8926
|
+
* @param payload Payload to sign (e.g. access token)
|
|
8927
|
+
* @param publicKeyThumbprint Public key digest (from generatePublicKeyThumbprint API)
|
|
8928
|
+
* @param claims Additional claims to include/override in the signed JWT
|
|
8929
|
+
* @returns Pop token signed with the corresponding private key
|
|
8945
8930
|
*/
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
return {
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8931
|
+
SignedHttpRequest.prototype.signRequest = function (payload, publicKeyThumbprint, claims) {
|
|
8932
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
8933
|
+
return __generator$1(this, function (_a) {
|
|
8934
|
+
return [2 /*return*/, this.popTokenGenerator.signPayload(payload, publicKeyThumbprint, this.shrParameters, claims)];
|
|
8935
|
+
});
|
|
8936
|
+
});
|
|
8937
|
+
};
|
|
8938
|
+
/**
|
|
8939
|
+
* Removes cached keys from browser for given public key thumbprint
|
|
8940
|
+
* @param publicKeyThumbprint Public key digest (from generatePublicKeyThumbprint API)
|
|
8941
|
+
* @returns If keys are properly deleted
|
|
8942
|
+
*/
|
|
8943
|
+
SignedHttpRequest.prototype.removeKeys = function (publicKeyThumbprint) {
|
|
8944
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
8945
|
+
return __generator$1(this, function (_a) {
|
|
8946
|
+
switch (_a.label) {
|
|
8947
|
+
case 0: return [4 /*yield*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
|
|
8948
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
8949
|
+
}
|
|
8950
|
+
});
|
|
8951
|
+
});
|
|
8952
8952
|
};
|
|
8953
|
-
return
|
|
8953
|
+
return SignedHttpRequest;
|
|
8954
8954
|
}());
|
|
8955
8955
|
|
|
8956
8956
|
/*
|
|
@@ -8958,1283 +8958,1568 @@ var BrowserProtocolUtils = /** @class */ (function () {
|
|
|
8958
8958
|
* Licensed under the MIT License.
|
|
8959
8959
|
*/
|
|
8960
8960
|
/**
|
|
8961
|
-
*
|
|
8962
|
-
* Cookies are only used if storeAuthStateInCookie is true, and are only used for
|
|
8963
|
-
* parameters such as state and nonce, generally.
|
|
8961
|
+
* Storage wrapper for IndexedDB storage in browsers: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
|
|
8964
8962
|
*/
|
|
8965
|
-
var
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
_this.cacheConfig = cacheConfig;
|
|
8972
|
-
_this.logger = logger;
|
|
8973
|
-
_this.internalStorage = new MemoryStorage();
|
|
8974
|
-
_this.browserStorage = _this.setupBrowserStorage(_this.cacheConfig.cacheLocation);
|
|
8975
|
-
_this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.cacheLocation);
|
|
8976
|
-
// Migrate any cache entries from older versions of MSAL.
|
|
8977
|
-
_this.migrateCacheEntries();
|
|
8978
|
-
return _this;
|
|
8963
|
+
var DatabaseStorage = /** @class */ (function () {
|
|
8964
|
+
function DatabaseStorage() {
|
|
8965
|
+
this.dbName = DB_NAME;
|
|
8966
|
+
this.version = DB_VERSION;
|
|
8967
|
+
this.tableName = DB_TABLE_NAME;
|
|
8968
|
+
this.dbOpen = false;
|
|
8979
8969
|
}
|
|
8980
8970
|
/**
|
|
8981
|
-
*
|
|
8982
|
-
* @param cacheLocation
|
|
8971
|
+
* Opens IndexedDB instance.
|
|
8983
8972
|
*/
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8973
|
+
DatabaseStorage.prototype.open = function () {
|
|
8974
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
8975
|
+
var _this = this;
|
|
8976
|
+
return __generator$1(this, function (_a) {
|
|
8977
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
8978
|
+
var openDB = window.indexedDB.open(_this.dbName, _this.version);
|
|
8979
|
+
openDB.addEventListener("upgradeneeded", function (e) {
|
|
8980
|
+
var event = e;
|
|
8981
|
+
event.target.result.createObjectStore(_this.tableName);
|
|
8982
|
+
});
|
|
8983
|
+
openDB.addEventListener("success", function (e) {
|
|
8984
|
+
var event = e;
|
|
8985
|
+
_this.db = event.target.result;
|
|
8986
|
+
_this.dbOpen = true;
|
|
8987
|
+
resolve();
|
|
8988
|
+
});
|
|
8989
|
+
openDB.addEventListener("error", function () { return reject(BrowserAuthError.createDatabaseUnavailableError()); });
|
|
8990
|
+
})];
|
|
8991
|
+
});
|
|
8992
|
+
});
|
|
8993
|
+
};
|
|
8994
|
+
/**
|
|
8995
|
+
* Opens database if it's not already open
|
|
8996
|
+
*/
|
|
8997
|
+
DatabaseStorage.prototype.validateDbIsOpen = function () {
|
|
8998
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
8999
|
+
return __generator$1(this, function (_a) {
|
|
9000
|
+
switch (_a.label) {
|
|
9001
|
+
case 0:
|
|
9002
|
+
if (!!this.dbOpen) return [3 /*break*/, 2];
|
|
9003
|
+
return [4 /*yield*/, this.open()];
|
|
9004
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
9005
|
+
case 2: return [2 /*return*/];
|
|
8995
9006
|
}
|
|
8996
|
-
|
|
8997
|
-
}
|
|
8998
|
-
this.cacheConfig.cacheLocation = exports.BrowserCacheLocation.MemoryStorage;
|
|
8999
|
-
return new MemoryStorage();
|
|
9007
|
+
});
|
|
9008
|
+
});
|
|
9000
9009
|
};
|
|
9001
9010
|
/**
|
|
9002
|
-
*
|
|
9003
|
-
* @param
|
|
9011
|
+
* Retrieves item from IndexedDB instance.
|
|
9012
|
+
* @param key
|
|
9004
9013
|
*/
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9014
|
+
DatabaseStorage.prototype.getItem = function (key) {
|
|
9015
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9016
|
+
var _this = this;
|
|
9017
|
+
return __generator$1(this, function (_a) {
|
|
9018
|
+
switch (_a.label) {
|
|
9019
|
+
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
9020
|
+
case 1:
|
|
9021
|
+
_a.sent();
|
|
9022
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
9023
|
+
// TODO: Add timeouts?
|
|
9024
|
+
if (!_this.db) {
|
|
9025
|
+
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
9026
|
+
}
|
|
9027
|
+
var transaction = _this.db.transaction([_this.tableName], "readonly");
|
|
9028
|
+
var objectStore = transaction.objectStore(_this.tableName);
|
|
9029
|
+
var dbGet = objectStore.get(key);
|
|
9030
|
+
dbGet.addEventListener("success", function (e) {
|
|
9031
|
+
var event = e;
|
|
9032
|
+
resolve(event.target.result);
|
|
9033
|
+
});
|
|
9034
|
+
dbGet.addEventListener("error", function (e) { return reject(e); });
|
|
9035
|
+
})];
|
|
9012
9036
|
}
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9037
|
+
});
|
|
9038
|
+
});
|
|
9039
|
+
};
|
|
9040
|
+
/**
|
|
9041
|
+
* Adds item to IndexedDB under given key
|
|
9042
|
+
* @param key
|
|
9043
|
+
* @param payload
|
|
9044
|
+
*/
|
|
9045
|
+
DatabaseStorage.prototype.setItem = function (key, payload) {
|
|
9046
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9047
|
+
var _this = this;
|
|
9048
|
+
return __generator$1(this, function (_a) {
|
|
9049
|
+
switch (_a.label) {
|
|
9050
|
+
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
9051
|
+
case 1:
|
|
9052
|
+
_a.sent();
|
|
9053
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
9054
|
+
// TODO: Add timeouts?
|
|
9055
|
+
if (!_this.db) {
|
|
9056
|
+
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
9057
|
+
}
|
|
9058
|
+
var transaction = _this.db.transaction([_this.tableName], "readwrite");
|
|
9059
|
+
var objectStore = transaction.objectStore(_this.tableName);
|
|
9060
|
+
var dbPut = objectStore.put(payload, key);
|
|
9061
|
+
dbPut.addEventListener("success", function () { return resolve(); });
|
|
9062
|
+
dbPut.addEventListener("error", function (e) { return reject(e); });
|
|
9063
|
+
})];
|
|
9016
9064
|
}
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
return this.internalStorage;
|
|
9020
|
-
}
|
|
9065
|
+
});
|
|
9066
|
+
});
|
|
9021
9067
|
};
|
|
9022
9068
|
/**
|
|
9023
|
-
*
|
|
9024
|
-
* @param
|
|
9069
|
+
* Removes item from IndexedDB under given key
|
|
9070
|
+
* @param key
|
|
9025
9071
|
*/
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9072
|
+
DatabaseStorage.prototype.removeItem = function (key) {
|
|
9073
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9074
|
+
var _this = this;
|
|
9075
|
+
return __generator$1(this, function (_a) {
|
|
9076
|
+
switch (_a.label) {
|
|
9077
|
+
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
9078
|
+
case 1:
|
|
9079
|
+
_a.sent();
|
|
9080
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
9081
|
+
if (!_this.db) {
|
|
9082
|
+
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
9083
|
+
}
|
|
9084
|
+
var transaction = _this.db.transaction([_this.tableName], "readwrite");
|
|
9085
|
+
var objectStore = transaction.objectStore(_this.tableName);
|
|
9086
|
+
var dbDelete = objectStore.delete(key);
|
|
9087
|
+
dbDelete.addEventListener("success", function () { return resolve(); });
|
|
9088
|
+
dbDelete.addEventListener("error", function (e) { return reject(e); });
|
|
9089
|
+
})];
|
|
9090
|
+
}
|
|
9091
|
+
});
|
|
9092
|
+
});
|
|
9039
9093
|
};
|
|
9040
9094
|
/**
|
|
9041
|
-
*
|
|
9042
|
-
* @param newKey
|
|
9043
|
-
* @param value
|
|
9044
|
-
* @param storeAuthStateInCookie
|
|
9095
|
+
* Get all the keys from the storage object as an iterable array of strings.
|
|
9045
9096
|
*/
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9097
|
+
DatabaseStorage.prototype.getKeys = function () {
|
|
9098
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9099
|
+
var _this = this;
|
|
9100
|
+
return __generator$1(this, function (_a) {
|
|
9101
|
+
switch (_a.label) {
|
|
9102
|
+
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
9103
|
+
case 1:
|
|
9104
|
+
_a.sent();
|
|
9105
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
9106
|
+
if (!_this.db) {
|
|
9107
|
+
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
9108
|
+
}
|
|
9109
|
+
var transaction = _this.db.transaction([_this.tableName], "readonly");
|
|
9110
|
+
var objectStore = transaction.objectStore(_this.tableName);
|
|
9111
|
+
var dbGetKeys = objectStore.getAllKeys();
|
|
9112
|
+
dbGetKeys.addEventListener("success", function (e) {
|
|
9113
|
+
var event = e;
|
|
9114
|
+
resolve(event.target.result);
|
|
9115
|
+
});
|
|
9116
|
+
dbGetKeys.addEventListener("error", function (e) { return reject(e); });
|
|
9117
|
+
})];
|
|
9118
|
+
}
|
|
9119
|
+
});
|
|
9120
|
+
});
|
|
9050
9121
|
};
|
|
9051
9122
|
/**
|
|
9052
|
-
*
|
|
9053
|
-
*
|
|
9123
|
+
*
|
|
9124
|
+
* Checks whether there is an object under the search key in the object store
|
|
9054
9125
|
*/
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
var
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9126
|
+
DatabaseStorage.prototype.containsKey = function (key) {
|
|
9127
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9128
|
+
var _this = this;
|
|
9129
|
+
return __generator$1(this, function (_a) {
|
|
9130
|
+
switch (_a.label) {
|
|
9131
|
+
case 0: return [4 /*yield*/, this.validateDbIsOpen()];
|
|
9132
|
+
case 1:
|
|
9133
|
+
_a.sent();
|
|
9134
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
9135
|
+
if (!_this.db) {
|
|
9136
|
+
return reject(BrowserAuthError.createDatabaseNotOpenError());
|
|
9137
|
+
}
|
|
9138
|
+
var transaction = _this.db.transaction([_this.tableName], "readonly");
|
|
9139
|
+
var objectStore = transaction.objectStore(_this.tableName);
|
|
9140
|
+
var dbContainsKey = objectStore.count(key);
|
|
9141
|
+
dbContainsKey.addEventListener("success", function (e) {
|
|
9142
|
+
var event = e;
|
|
9143
|
+
resolve(event.target.result === 1);
|
|
9144
|
+
});
|
|
9145
|
+
dbContainsKey.addEventListener("error", function (e) { return reject(e); });
|
|
9146
|
+
})];
|
|
9147
|
+
}
|
|
9148
|
+
});
|
|
9149
|
+
});
|
|
9069
9150
|
};
|
|
9070
9151
|
/**
|
|
9071
|
-
*
|
|
9072
|
-
*
|
|
9152
|
+
* Deletes the MSAL database. The database is deleted rather than cleared to make it possible
|
|
9153
|
+
* for client applications to downgrade to a previous MSAL version without worrying about forward compatibility issues
|
|
9154
|
+
* with IndexedDB database versions.
|
|
9073
9155
|
*/
|
|
9074
|
-
|
|
9075
|
-
return this
|
|
9156
|
+
DatabaseStorage.prototype.deleteDatabase = function () {
|
|
9157
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9158
|
+
return __generator$1(this, function (_a) {
|
|
9159
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
9160
|
+
var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
|
|
9161
|
+
deleteDbRequest.addEventListener("success", function () { return resolve(true); });
|
|
9162
|
+
deleteDbRequest.addEventListener("error", function () { return reject(false); });
|
|
9163
|
+
})];
|
|
9164
|
+
});
|
|
9165
|
+
});
|
|
9076
9166
|
};
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9167
|
+
return DatabaseStorage;
|
|
9168
|
+
}());
|
|
9169
|
+
|
|
9170
|
+
/*
|
|
9171
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9172
|
+
* Licensed under the MIT License.
|
|
9173
|
+
*/
|
|
9174
|
+
var MemoryStorage = /** @class */ (function () {
|
|
9175
|
+
function MemoryStorage() {
|
|
9176
|
+
this.cache = new Map();
|
|
9177
|
+
}
|
|
9178
|
+
MemoryStorage.prototype.getItem = function (key) {
|
|
9179
|
+
return this.cache.get(key) || null;
|
|
9084
9180
|
};
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
* @param accountKey
|
|
9088
|
-
*/
|
|
9089
|
-
BrowserCacheManager.prototype.getAccount = function (accountKey) {
|
|
9090
|
-
var account = this.getItem(accountKey);
|
|
9091
|
-
if (!account) {
|
|
9092
|
-
return null;
|
|
9093
|
-
}
|
|
9094
|
-
var parsedAccount = this.validateAndParseJson(account);
|
|
9095
|
-
if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
|
|
9096
|
-
return null;
|
|
9097
|
-
}
|
|
9098
|
-
return CacheManager.toObject(new AccountEntity(), parsedAccount);
|
|
9181
|
+
MemoryStorage.prototype.setItem = function (key, value) {
|
|
9182
|
+
this.cache.set(key, value);
|
|
9099
9183
|
};
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
* @param key
|
|
9103
|
-
* @param value
|
|
9104
|
-
*/
|
|
9105
|
-
BrowserCacheManager.prototype.setAccount = function (account) {
|
|
9106
|
-
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
9107
|
-
var key = account.generateAccountKey();
|
|
9108
|
-
this.setItem(key, JSON.stringify(account));
|
|
9184
|
+
MemoryStorage.prototype.removeItem = function (key) {
|
|
9185
|
+
this.cache.delete(key);
|
|
9109
9186
|
};
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
if (!value) {
|
|
9117
|
-
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9118
|
-
return null;
|
|
9119
|
-
}
|
|
9120
|
-
var parsedIdToken = this.validateAndParseJson(value);
|
|
9121
|
-
if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
|
|
9122
|
-
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9123
|
-
return null;
|
|
9124
|
-
}
|
|
9125
|
-
this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
|
|
9126
|
-
return CacheManager.toObject(new IdTokenEntity(), parsedIdToken);
|
|
9187
|
+
MemoryStorage.prototype.getKeys = function () {
|
|
9188
|
+
var cacheKeys = [];
|
|
9189
|
+
this.cache.forEach(function (value, key) {
|
|
9190
|
+
cacheKeys.push(key);
|
|
9191
|
+
});
|
|
9192
|
+
return cacheKeys;
|
|
9127
9193
|
};
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
* @param idToken
|
|
9131
|
-
*/
|
|
9132
|
-
BrowserCacheManager.prototype.setIdTokenCredential = function (idToken) {
|
|
9133
|
-
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
9134
|
-
var idTokenKey = idToken.generateCredentialKey();
|
|
9135
|
-
this.setItem(idTokenKey, JSON.stringify(idToken));
|
|
9194
|
+
MemoryStorage.prototype.containsKey = function (key) {
|
|
9195
|
+
return this.cache.has(key);
|
|
9136
9196
|
};
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
* @param key
|
|
9140
|
-
*/
|
|
9141
|
-
BrowserCacheManager.prototype.getAccessTokenCredential = function (accessTokenKey) {
|
|
9142
|
-
var value = this.getItem(accessTokenKey);
|
|
9143
|
-
if (!value) {
|
|
9144
|
-
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9145
|
-
return null;
|
|
9146
|
-
}
|
|
9147
|
-
var parsedAccessToken = this.validateAndParseJson(value);
|
|
9148
|
-
if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {
|
|
9149
|
-
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9150
|
-
return null;
|
|
9151
|
-
}
|
|
9152
|
-
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
|
|
9153
|
-
return CacheManager.toObject(new AccessTokenEntity(), parsedAccessToken);
|
|
9197
|
+
MemoryStorage.prototype.clear = function () {
|
|
9198
|
+
this.cache.clear();
|
|
9154
9199
|
};
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9200
|
+
return MemoryStorage;
|
|
9201
|
+
}());
|
|
9202
|
+
|
|
9203
|
+
/*
|
|
9204
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9205
|
+
* Licensed under the MIT License.
|
|
9206
|
+
*/
|
|
9207
|
+
/**
|
|
9208
|
+
* This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,
|
|
9209
|
+
* backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
|
|
9210
|
+
*/
|
|
9211
|
+
var AsyncMemoryStorage = /** @class */ (function () {
|
|
9212
|
+
function AsyncMemoryStorage(logger) {
|
|
9213
|
+
this.inMemoryCache = new MemoryStorage();
|
|
9214
|
+
this.indexedDBCache = new DatabaseStorage();
|
|
9215
|
+
this.logger = logger;
|
|
9216
|
+
}
|
|
9217
|
+
AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
|
|
9218
|
+
if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
|
|
9219
|
+
this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.");
|
|
9220
|
+
}
|
|
9163
9221
|
};
|
|
9164
9222
|
/**
|
|
9165
|
-
*
|
|
9166
|
-
*
|
|
9223
|
+
* Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
|
|
9224
|
+
* storage object if item isn't found in-memory.
|
|
9225
|
+
* @param key
|
|
9167
9226
|
*/
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
this
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9227
|
+
AsyncMemoryStorage.prototype.getItem = function (key) {
|
|
9228
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9229
|
+
var item, e_1;
|
|
9230
|
+
return __generator$1(this, function (_a) {
|
|
9231
|
+
switch (_a.label) {
|
|
9232
|
+
case 0:
|
|
9233
|
+
item = this.inMemoryCache.getItem(key);
|
|
9234
|
+
if (!!item) return [3 /*break*/, 4];
|
|
9235
|
+
_a.label = 1;
|
|
9236
|
+
case 1:
|
|
9237
|
+
_a.trys.push([1, 3, , 4]);
|
|
9238
|
+
this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage.");
|
|
9239
|
+
return [4 /*yield*/, this.indexedDBCache.getItem(key)];
|
|
9240
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
9241
|
+
case 3:
|
|
9242
|
+
e_1 = _a.sent();
|
|
9243
|
+
this.handleDatabaseAccessError(e_1);
|
|
9244
|
+
return [3 /*break*/, 4];
|
|
9245
|
+
case 4: return [2 /*return*/, item];
|
|
9246
|
+
}
|
|
9247
|
+
});
|
|
9248
|
+
});
|
|
9181
9249
|
};
|
|
9182
9250
|
/**
|
|
9183
|
-
*
|
|
9184
|
-
*
|
|
9251
|
+
* Sets the item in the in-memory cache and then tries to set it in the asynchronous
|
|
9252
|
+
* storage object with the given key.
|
|
9253
|
+
* @param key
|
|
9254
|
+
* @param value
|
|
9185
9255
|
*/
|
|
9186
|
-
|
|
9187
|
-
this
|
|
9188
|
-
|
|
9189
|
-
|
|
9256
|
+
AsyncMemoryStorage.prototype.setItem = function (key, value) {
|
|
9257
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9258
|
+
var e_2;
|
|
9259
|
+
return __generator$1(this, function (_a) {
|
|
9260
|
+
switch (_a.label) {
|
|
9261
|
+
case 0:
|
|
9262
|
+
this.inMemoryCache.setItem(key, value);
|
|
9263
|
+
_a.label = 1;
|
|
9264
|
+
case 1:
|
|
9265
|
+
_a.trys.push([1, 3, , 4]);
|
|
9266
|
+
return [4 /*yield*/, this.indexedDBCache.setItem(key, value)];
|
|
9267
|
+
case 2:
|
|
9268
|
+
_a.sent();
|
|
9269
|
+
return [3 /*break*/, 4];
|
|
9270
|
+
case 3:
|
|
9271
|
+
e_2 = _a.sent();
|
|
9272
|
+
this.handleDatabaseAccessError(e_2);
|
|
9273
|
+
return [3 /*break*/, 4];
|
|
9274
|
+
case 4: return [2 /*return*/];
|
|
9275
|
+
}
|
|
9276
|
+
});
|
|
9277
|
+
});
|
|
9190
9278
|
};
|
|
9191
9279
|
/**
|
|
9192
|
-
*
|
|
9193
|
-
* @param
|
|
9280
|
+
* Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
|
|
9281
|
+
* @param key
|
|
9194
9282
|
*/
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
this
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9283
|
+
AsyncMemoryStorage.prototype.removeItem = function (key) {
|
|
9284
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9285
|
+
var e_3;
|
|
9286
|
+
return __generator$1(this, function (_a) {
|
|
9287
|
+
switch (_a.label) {
|
|
9288
|
+
case 0:
|
|
9289
|
+
this.inMemoryCache.removeItem(key);
|
|
9290
|
+
_a.label = 1;
|
|
9291
|
+
case 1:
|
|
9292
|
+
_a.trys.push([1, 3, , 4]);
|
|
9293
|
+
return [4 /*yield*/, this.indexedDBCache.removeItem(key)];
|
|
9294
|
+
case 2:
|
|
9295
|
+
_a.sent();
|
|
9296
|
+
return [3 /*break*/, 4];
|
|
9297
|
+
case 3:
|
|
9298
|
+
e_3 = _a.sent();
|
|
9299
|
+
this.handleDatabaseAccessError(e_3);
|
|
9300
|
+
return [3 /*break*/, 4];
|
|
9301
|
+
case 4: return [2 /*return*/];
|
|
9302
|
+
}
|
|
9303
|
+
});
|
|
9304
|
+
});
|
|
9208
9305
|
};
|
|
9209
9306
|
/**
|
|
9210
|
-
*
|
|
9211
|
-
*
|
|
9307
|
+
* Get all the keys from the in-memory cache as an iterable array of strings. If no keys are found, query the keys in the
|
|
9308
|
+
* asynchronous storage object.
|
|
9212
9309
|
*/
|
|
9213
|
-
|
|
9214
|
-
this
|
|
9215
|
-
|
|
9216
|
-
|
|
9310
|
+
AsyncMemoryStorage.prototype.getKeys = function () {
|
|
9311
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9312
|
+
var cacheKeys, e_4;
|
|
9313
|
+
return __generator$1(this, function (_a) {
|
|
9314
|
+
switch (_a.label) {
|
|
9315
|
+
case 0:
|
|
9316
|
+
cacheKeys = this.inMemoryCache.getKeys();
|
|
9317
|
+
if (!(cacheKeys.length === 0)) return [3 /*break*/, 4];
|
|
9318
|
+
_a.label = 1;
|
|
9319
|
+
case 1:
|
|
9320
|
+
_a.trys.push([1, 3, , 4]);
|
|
9321
|
+
this.logger.verbose("In-memory cache is empty, now querying persistent storage.");
|
|
9322
|
+
return [4 /*yield*/, this.indexedDBCache.getKeys()];
|
|
9323
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
9324
|
+
case 3:
|
|
9325
|
+
e_4 = _a.sent();
|
|
9326
|
+
this.handleDatabaseAccessError(e_4);
|
|
9327
|
+
return [3 /*break*/, 4];
|
|
9328
|
+
case 4: return [2 /*return*/, cacheKeys];
|
|
9329
|
+
}
|
|
9330
|
+
});
|
|
9331
|
+
});
|
|
9217
9332
|
};
|
|
9218
9333
|
/**
|
|
9219
|
-
*
|
|
9220
|
-
* @param
|
|
9334
|
+
* Returns true or false if the given key is present in the cache.
|
|
9335
|
+
* @param key
|
|
9221
9336
|
*/
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
this
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9337
|
+
AsyncMemoryStorage.prototype.containsKey = function (key) {
|
|
9338
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9339
|
+
var containsKey, e_5;
|
|
9340
|
+
return __generator$1(this, function (_a) {
|
|
9341
|
+
switch (_a.label) {
|
|
9342
|
+
case 0:
|
|
9343
|
+
containsKey = this.inMemoryCache.containsKey(key);
|
|
9344
|
+
if (!!containsKey) return [3 /*break*/, 4];
|
|
9345
|
+
_a.label = 1;
|
|
9346
|
+
case 1:
|
|
9347
|
+
_a.trys.push([1, 3, , 4]);
|
|
9348
|
+
this.logger.verbose("Key not found in in-memory cache, now querying persistent storage.");
|
|
9349
|
+
return [4 /*yield*/, this.indexedDBCache.containsKey(key)];
|
|
9350
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
9351
|
+
case 3:
|
|
9352
|
+
e_5 = _a.sent();
|
|
9353
|
+
this.handleDatabaseAccessError(e_5);
|
|
9354
|
+
return [3 /*break*/, 4];
|
|
9355
|
+
case 4: return [2 /*return*/, containsKey];
|
|
9356
|
+
}
|
|
9357
|
+
});
|
|
9358
|
+
});
|
|
9235
9359
|
};
|
|
9236
9360
|
/**
|
|
9237
|
-
*
|
|
9238
|
-
* @param serverTelemetryKey
|
|
9239
|
-
* @param serverTelemetry
|
|
9361
|
+
* Clears in-memory Map and tries to delete the IndexedDB database.
|
|
9240
9362
|
*/
|
|
9241
|
-
|
|
9242
|
-
this
|
|
9243
|
-
|
|
9363
|
+
AsyncMemoryStorage.prototype.clear = function () {
|
|
9364
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9365
|
+
var e_6;
|
|
9366
|
+
return __generator$1(this, function (_a) {
|
|
9367
|
+
switch (_a.label) {
|
|
9368
|
+
case 0:
|
|
9369
|
+
this.inMemoryCache.clear();
|
|
9370
|
+
_a.label = 1;
|
|
9371
|
+
case 1:
|
|
9372
|
+
_a.trys.push([1, 3, , 4]);
|
|
9373
|
+
return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
|
|
9374
|
+
case 2:
|
|
9375
|
+
_a.sent();
|
|
9376
|
+
return [3 /*break*/, 4];
|
|
9377
|
+
case 3:
|
|
9378
|
+
e_6 = _a.sent();
|
|
9379
|
+
this.handleDatabaseAccessError(e_6);
|
|
9380
|
+
return [3 /*break*/, 4];
|
|
9381
|
+
case 4: return [2 /*return*/];
|
|
9382
|
+
}
|
|
9383
|
+
});
|
|
9384
|
+
});
|
|
9244
9385
|
};
|
|
9386
|
+
return AsyncMemoryStorage;
|
|
9387
|
+
}());
|
|
9388
|
+
|
|
9389
|
+
/*
|
|
9390
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9391
|
+
* Licensed under the MIT License.
|
|
9392
|
+
*/
|
|
9393
|
+
/**
|
|
9394
|
+
* This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
|
|
9395
|
+
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
|
|
9396
|
+
*/
|
|
9397
|
+
var CryptoOps = /** @class */ (function () {
|
|
9398
|
+
function CryptoOps(logger) {
|
|
9399
|
+
this.logger = logger;
|
|
9400
|
+
// Browser crypto needs to be validated first before any other classes can be set.
|
|
9401
|
+
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
9402
|
+
this.b64Encode = new Base64Encode();
|
|
9403
|
+
this.b64Decode = new Base64Decode();
|
|
9404
|
+
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
9405
|
+
this.pkceGenerator = new PkceGenerator(this.browserCrypto);
|
|
9406
|
+
this.cache = {
|
|
9407
|
+
asymmetricKeys: new AsyncMemoryStorage(this.logger),
|
|
9408
|
+
symmetricKeys: new AsyncMemoryStorage(this.logger)
|
|
9409
|
+
};
|
|
9410
|
+
}
|
|
9245
9411
|
/**
|
|
9246
|
-
*
|
|
9412
|
+
* Creates a new random GUID - used to populate state and nonce.
|
|
9413
|
+
* @returns string (GUID)
|
|
9247
9414
|
*/
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
if (!value) {
|
|
9251
|
-
this.logger.trace("BrowserCacheManager.getAuthorityMetadata: called, no cache hit");
|
|
9252
|
-
return null;
|
|
9253
|
-
}
|
|
9254
|
-
var parsedMetadata = this.validateAndParseJson(value);
|
|
9255
|
-
if (parsedMetadata && AuthorityMetadataEntity.isAuthorityMetadataEntity(key, parsedMetadata)) {
|
|
9256
|
-
this.logger.trace("BrowserCacheManager.getAuthorityMetadata: cache hit");
|
|
9257
|
-
return CacheManager.toObject(new AuthorityMetadataEntity(), parsedMetadata);
|
|
9258
|
-
}
|
|
9259
|
-
return null;
|
|
9415
|
+
CryptoOps.prototype.createNewGuid = function () {
|
|
9416
|
+
return this.guidGenerator.generateGuid();
|
|
9260
9417
|
};
|
|
9261
9418
|
/**
|
|
9262
|
-
*
|
|
9419
|
+
* Encodes input string to base64.
|
|
9420
|
+
* @param input
|
|
9263
9421
|
*/
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
var allKeys = this.internalStorage.getKeys();
|
|
9267
|
-
return allKeys.filter(function (key) {
|
|
9268
|
-
return _this.isAuthorityMetadata(key);
|
|
9269
|
-
});
|
|
9422
|
+
CryptoOps.prototype.base64Encode = function (input) {
|
|
9423
|
+
return this.b64Encode.encode(input);
|
|
9270
9424
|
};
|
|
9271
9425
|
/**
|
|
9272
|
-
*
|
|
9273
|
-
* @param
|
|
9274
|
-
* @param wrapperVersion
|
|
9426
|
+
* Decodes input string from base64.
|
|
9427
|
+
* @param input
|
|
9275
9428
|
*/
|
|
9276
|
-
|
|
9277
|
-
this.
|
|
9278
|
-
this.internalStorage.setItem(InMemoryCacheKeys.WRAPPER_VER, wrapperVersion);
|
|
9429
|
+
CryptoOps.prototype.base64Decode = function (input) {
|
|
9430
|
+
return this.b64Decode.decode(input);
|
|
9279
9431
|
};
|
|
9280
9432
|
/**
|
|
9281
|
-
*
|
|
9433
|
+
* Generates PKCE codes used in Authorization Code Flow.
|
|
9282
9434
|
*/
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9435
|
+
CryptoOps.prototype.generatePkceCodes = function () {
|
|
9436
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9437
|
+
return __generator$1(this, function (_a) {
|
|
9438
|
+
return [2 /*return*/, this.pkceGenerator.generateCodes()];
|
|
9439
|
+
});
|
|
9440
|
+
});
|
|
9287
9441
|
};
|
|
9288
9442
|
/**
|
|
9289
|
-
*
|
|
9290
|
-
* @param
|
|
9443
|
+
* Generates a keypair, stores it and returns a thumbprint
|
|
9444
|
+
* @param request
|
|
9291
9445
|
*/
|
|
9292
|
-
|
|
9293
|
-
this
|
|
9294
|
-
|
|
9446
|
+
CryptoOps.prototype.getPublicKeyThumbprint = function (request) {
|
|
9447
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9448
|
+
var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkBuffer, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
|
|
9449
|
+
return __generator$1(this, function (_a) {
|
|
9450
|
+
switch (_a.label) {
|
|
9451
|
+
case 0: return [4 /*yield*/, this.browserCrypto.generateKeyPair(CryptoOps.EXTRACTABLE, CryptoOps.POP_KEY_USAGES)];
|
|
9452
|
+
case 1:
|
|
9453
|
+
keyPair = _a.sent();
|
|
9454
|
+
return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.publicKey)];
|
|
9455
|
+
case 2:
|
|
9456
|
+
publicKeyJwk = _a.sent();
|
|
9457
|
+
pubKeyThumprintObj = {
|
|
9458
|
+
e: publicKeyJwk.e,
|
|
9459
|
+
kty: publicKeyJwk.kty,
|
|
9460
|
+
n: publicKeyJwk.n
|
|
9461
|
+
};
|
|
9462
|
+
publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
|
|
9463
|
+
return [4 /*yield*/, this.browserCrypto.sha256Digest(publicJwkString)];
|
|
9464
|
+
case 3:
|
|
9465
|
+
publicJwkBuffer = _a.sent();
|
|
9466
|
+
publicJwkHash = this.b64Encode.urlEncodeArr(new Uint8Array(publicJwkBuffer));
|
|
9467
|
+
return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.privateKey)];
|
|
9468
|
+
case 4:
|
|
9469
|
+
privateKeyJwk = _a.sent();
|
|
9470
|
+
return [4 /*yield*/, this.browserCrypto.importJwk(privateKeyJwk, false, ["sign"])];
|
|
9471
|
+
case 5:
|
|
9472
|
+
unextractablePrivateKey = _a.sent();
|
|
9473
|
+
// Store Keypair data in keystore
|
|
9474
|
+
return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
|
|
9475
|
+
privateKey: unextractablePrivateKey,
|
|
9476
|
+
publicKey: keyPair.publicKey,
|
|
9477
|
+
requestMethod: request.resourceRequestMethod,
|
|
9478
|
+
requestUri: request.resourceRequestUri
|
|
9479
|
+
})];
|
|
9480
|
+
case 6:
|
|
9481
|
+
// Store Keypair data in keystore
|
|
9482
|
+
_a.sent();
|
|
9483
|
+
return [2 /*return*/, publicJwkHash];
|
|
9484
|
+
}
|
|
9485
|
+
});
|
|
9486
|
+
});
|
|
9295
9487
|
};
|
|
9296
9488
|
/**
|
|
9297
|
-
*
|
|
9489
|
+
* Removes cryptographic keypair from key store matching the keyId passed in
|
|
9490
|
+
* @param kid
|
|
9298
9491
|
*/
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9492
|
+
CryptoOps.prototype.removeTokenBindingKey = function (kid) {
|
|
9493
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9494
|
+
var keyFound;
|
|
9495
|
+
return __generator$1(this, function (_a) {
|
|
9496
|
+
switch (_a.label) {
|
|
9497
|
+
case 0: return [4 /*yield*/, this.cache.asymmetricKeys.removeItem(kid)];
|
|
9498
|
+
case 1:
|
|
9499
|
+
_a.sent();
|
|
9500
|
+
return [4 /*yield*/, this.cache.asymmetricKeys.containsKey(kid)];
|
|
9501
|
+
case 2:
|
|
9502
|
+
keyFound = _a.sent();
|
|
9503
|
+
return [2 /*return*/, !keyFound];
|
|
9504
|
+
}
|
|
9505
|
+
});
|
|
9506
|
+
});
|
|
9306
9507
|
};
|
|
9307
9508
|
/**
|
|
9308
|
-
*
|
|
9309
|
-
* @param account
|
|
9509
|
+
* Removes all cryptographic keys from IndexedDB storage
|
|
9310
9510
|
*/
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
this
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9511
|
+
CryptoOps.prototype.clearKeystore = function () {
|
|
9512
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9513
|
+
var dataStoreNames, databaseStorage, _a;
|
|
9514
|
+
return __generator$1(this, function (_b) {
|
|
9515
|
+
switch (_b.label) {
|
|
9516
|
+
case 0:
|
|
9517
|
+
dataStoreNames = Object.keys(this.cache);
|
|
9518
|
+
databaseStorage = this.cache[dataStoreNames[0]];
|
|
9519
|
+
if (!databaseStorage) return [3 /*break*/, 2];
|
|
9520
|
+
return [4 /*yield*/, databaseStorage.deleteDatabase()];
|
|
9521
|
+
case 1:
|
|
9522
|
+
_a = _b.sent();
|
|
9523
|
+
return [3 /*break*/, 3];
|
|
9524
|
+
case 2:
|
|
9525
|
+
_a = false;
|
|
9526
|
+
_b.label = 3;
|
|
9527
|
+
case 3: return [2 /*return*/, _a];
|
|
9528
|
+
}
|
|
9529
|
+
});
|
|
9530
|
+
});
|
|
9321
9531
|
};
|
|
9322
9532
|
/**
|
|
9323
|
-
*
|
|
9324
|
-
* @param
|
|
9533
|
+
* Signs the given object as a jwt payload with private key retrieved by given kid.
|
|
9534
|
+
* @param payload
|
|
9535
|
+
* @param kid
|
|
9325
9536
|
*/
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9537
|
+
CryptoOps.prototype.signJwt = function (payload, kid) {
|
|
9538
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9539
|
+
var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
|
|
9540
|
+
return __generator$1(this, function (_a) {
|
|
9541
|
+
switch (_a.label) {
|
|
9542
|
+
case 0: return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
|
|
9543
|
+
case 1:
|
|
9544
|
+
cachedKeyPair = _a.sent();
|
|
9545
|
+
if (!cachedKeyPair) {
|
|
9546
|
+
throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
|
|
9547
|
+
}
|
|
9548
|
+
return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
|
|
9549
|
+
case 2:
|
|
9550
|
+
publicKeyJwk = _a.sent();
|
|
9551
|
+
publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
|
|
9552
|
+
header = {
|
|
9553
|
+
alg: publicKeyJwk.alg,
|
|
9554
|
+
type: KEY_FORMAT_JWK
|
|
9555
|
+
};
|
|
9556
|
+
encodedHeader = this.b64Encode.urlEncode(JSON.stringify(header));
|
|
9557
|
+
// Generate payload
|
|
9558
|
+
payload.cnf = {
|
|
9559
|
+
jwk: JSON.parse(publicKeyJwkString)
|
|
9560
|
+
};
|
|
9561
|
+
encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
|
|
9562
|
+
tokenString = encodedHeader + "." + encodedPayload;
|
|
9563
|
+
tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
|
|
9564
|
+
return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
|
|
9565
|
+
case 3:
|
|
9566
|
+
signatureBuffer = _a.sent();
|
|
9567
|
+
encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
9568
|
+
return [2 /*return*/, tokenString + "." + encodedSignature];
|
|
9569
|
+
}
|
|
9570
|
+
});
|
|
9345
9571
|
});
|
|
9346
9572
|
};
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9573
|
+
CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
|
|
9574
|
+
CryptoOps.EXTRACTABLE = true;
|
|
9575
|
+
return CryptoOps;
|
|
9576
|
+
}());
|
|
9577
|
+
|
|
9578
|
+
/*
|
|
9579
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9580
|
+
* Licensed under the MIT License.
|
|
9581
|
+
*/
|
|
9582
|
+
var BrowserStorage = /** @class */ (function () {
|
|
9583
|
+
function BrowserStorage(cacheLocation) {
|
|
9584
|
+
this.validateWindowStorage(cacheLocation);
|
|
9585
|
+
this.windowStorage = window[cacheLocation];
|
|
9586
|
+
}
|
|
9587
|
+
BrowserStorage.prototype.validateWindowStorage = function (cacheLocation) {
|
|
9588
|
+
if (cacheLocation !== exports.BrowserCacheLocation.LocalStorage && cacheLocation !== exports.BrowserCacheLocation.SessionStorage) {
|
|
9589
|
+
throw BrowserConfigurationAuthError.createStorageNotSupportedError(cacheLocation);
|
|
9356
9590
|
}
|
|
9357
|
-
var
|
|
9358
|
-
if (!
|
|
9359
|
-
|
|
9360
|
-
return null;
|
|
9591
|
+
var storageSupported = !!window[cacheLocation];
|
|
9592
|
+
if (!storageSupported) {
|
|
9593
|
+
throw BrowserConfigurationAuthError.createStorageNotSupportedError(cacheLocation);
|
|
9361
9594
|
}
|
|
9362
|
-
this.logger.trace("BrowserCacheManager.getThrottlingCache: cache hit");
|
|
9363
|
-
return CacheManager.toObject(new ThrottlingEntity(), parsedThrottlingCache);
|
|
9364
9595
|
};
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
this.
|
|
9596
|
+
BrowserStorage.prototype.getItem = function (key) {
|
|
9597
|
+
return this.windowStorage.getItem(key);
|
|
9598
|
+
};
|
|
9599
|
+
BrowserStorage.prototype.setItem = function (key, value) {
|
|
9600
|
+
this.windowStorage.setItem(key, value);
|
|
9601
|
+
};
|
|
9602
|
+
BrowserStorage.prototype.removeItem = function (key) {
|
|
9603
|
+
this.windowStorage.removeItem(key);
|
|
9604
|
+
};
|
|
9605
|
+
BrowserStorage.prototype.getKeys = function () {
|
|
9606
|
+
return Object.keys(this.windowStorage);
|
|
9607
|
+
};
|
|
9608
|
+
BrowserStorage.prototype.containsKey = function (key) {
|
|
9609
|
+
return this.windowStorage.hasOwnProperty(key);
|
|
9373
9610
|
};
|
|
9611
|
+
return BrowserStorage;
|
|
9612
|
+
}());
|
|
9613
|
+
|
|
9614
|
+
/*
|
|
9615
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9616
|
+
* Licensed under the MIT License.
|
|
9617
|
+
*/
|
|
9618
|
+
var BrowserProtocolUtils = /** @class */ (function () {
|
|
9619
|
+
function BrowserProtocolUtils() {
|
|
9620
|
+
}
|
|
9374
9621
|
/**
|
|
9375
|
-
*
|
|
9376
|
-
*
|
|
9377
|
-
* @param
|
|
9622
|
+
* Extracts the BrowserStateObject from the state string.
|
|
9623
|
+
* @param browserCrypto
|
|
9624
|
+
* @param state
|
|
9378
9625
|
*/
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
if (this.cacheConfig.storeAuthStateInCookie) {
|
|
9382
|
-
var itemCookie = this.getItemCookie(key);
|
|
9383
|
-
if (itemCookie) {
|
|
9384
|
-
this.logger.trace("BrowserCacheManager.getTemporaryCache: storeAuthStateInCookies set to true, retrieving from cookies");
|
|
9385
|
-
return itemCookie;
|
|
9386
|
-
}
|
|
9387
|
-
}
|
|
9388
|
-
var value = this.temporaryCacheStorage.getItem(key);
|
|
9389
|
-
if (!value) {
|
|
9390
|
-
// If temp cache item not found in session/memory, check local storage for items set by old versions
|
|
9391
|
-
if (this.cacheConfig.cacheLocation === exports.BrowserCacheLocation.LocalStorage) {
|
|
9392
|
-
var item = this.browserStorage.getItem(key);
|
|
9393
|
-
if (item) {
|
|
9394
|
-
this.logger.trace("BrowserCacheManager.getTemporaryCache: Temporary cache item found in local storage");
|
|
9395
|
-
return item;
|
|
9396
|
-
}
|
|
9397
|
-
}
|
|
9398
|
-
this.logger.trace("BrowserCacheManager.getTemporaryCache: No cache item found in local storage");
|
|
9626
|
+
BrowserProtocolUtils.extractBrowserRequestState = function (browserCrypto, state) {
|
|
9627
|
+
if (StringUtils.isEmpty(state)) {
|
|
9399
9628
|
return null;
|
|
9400
9629
|
}
|
|
9401
|
-
|
|
9402
|
-
|
|
9630
|
+
try {
|
|
9631
|
+
var requestStateObj = ProtocolUtils.parseRequestState(browserCrypto, state);
|
|
9632
|
+
return requestStateObj.libraryState.meta;
|
|
9633
|
+
}
|
|
9634
|
+
catch (e) {
|
|
9635
|
+
throw ClientAuthError.createInvalidStateError(state, e);
|
|
9636
|
+
}
|
|
9403
9637
|
};
|
|
9404
9638
|
/**
|
|
9405
|
-
*
|
|
9406
|
-
*
|
|
9407
|
-
* This can cause cookie overflow if used incorrectly.
|
|
9408
|
-
* @param key
|
|
9409
|
-
* @param value
|
|
9639
|
+
* Parses properties of server response from url hash
|
|
9640
|
+
* @param locationHash Hash from url
|
|
9410
9641
|
*/
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
if (this.cacheConfig.storeAuthStateInCookie) {
|
|
9415
|
-
this.logger.trace("BrowserCacheManager.setTemporaryCache: storeAuthStateInCookie set to true, setting item cookie");
|
|
9416
|
-
this.setItemCookie(key, value);
|
|
9642
|
+
BrowserProtocolUtils.parseServerResponseFromHash = function (locationHash) {
|
|
9643
|
+
if (!locationHash) {
|
|
9644
|
+
return {};
|
|
9417
9645
|
}
|
|
9646
|
+
var hashUrlString = new UrlString(locationHash);
|
|
9647
|
+
return UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
9418
9648
|
};
|
|
9649
|
+
return BrowserProtocolUtils;
|
|
9650
|
+
}());
|
|
9651
|
+
|
|
9652
|
+
/*
|
|
9653
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9654
|
+
* Licensed under the MIT License.
|
|
9655
|
+
*/
|
|
9656
|
+
/**
|
|
9657
|
+
* This class implements the cache storage interface for MSAL through browser local or session storage.
|
|
9658
|
+
* Cookies are only used if storeAuthStateInCookie is true, and are only used for
|
|
9659
|
+
* parameters such as state and nonce, generally.
|
|
9660
|
+
*/
|
|
9661
|
+
var BrowserCacheManager = /** @class */ (function (_super) {
|
|
9662
|
+
__extends$1(BrowserCacheManager, _super);
|
|
9663
|
+
function BrowserCacheManager(clientId, cacheConfig, cryptoImpl, logger) {
|
|
9664
|
+
var _this = _super.call(this, clientId, cryptoImpl) || this;
|
|
9665
|
+
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
9666
|
+
_this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
9667
|
+
_this.cacheConfig = cacheConfig;
|
|
9668
|
+
_this.logger = logger;
|
|
9669
|
+
_this.internalStorage = new MemoryStorage();
|
|
9670
|
+
_this.browserStorage = _this.setupBrowserStorage(_this.cacheConfig.cacheLocation);
|
|
9671
|
+
_this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.cacheLocation);
|
|
9672
|
+
// Migrate any cache entries from older versions of MSAL.
|
|
9673
|
+
_this.migrateCacheEntries();
|
|
9674
|
+
return _this;
|
|
9675
|
+
}
|
|
9419
9676
|
/**
|
|
9420
|
-
*
|
|
9421
|
-
*
|
|
9422
|
-
* @param key
|
|
9677
|
+
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
|
|
9678
|
+
* @param cacheLocation
|
|
9423
9679
|
*/
|
|
9424
|
-
BrowserCacheManager.prototype.
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9429
|
-
|
|
9680
|
+
BrowserCacheManager.prototype.setupBrowserStorage = function (cacheLocation) {
|
|
9681
|
+
switch (cacheLocation) {
|
|
9682
|
+
case exports.BrowserCacheLocation.LocalStorage:
|
|
9683
|
+
case exports.BrowserCacheLocation.SessionStorage:
|
|
9684
|
+
try {
|
|
9685
|
+
// Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
|
|
9686
|
+
return new BrowserStorage(cacheLocation);
|
|
9687
|
+
}
|
|
9688
|
+
catch (e) {
|
|
9689
|
+
this.logger.verbose(e);
|
|
9690
|
+
break;
|
|
9691
|
+
}
|
|
9692
|
+
case exports.BrowserCacheLocation.MemoryStorage:
|
|
9430
9693
|
}
|
|
9431
|
-
|
|
9694
|
+
this.cacheConfig.cacheLocation = exports.BrowserCacheLocation.MemoryStorage;
|
|
9695
|
+
return new MemoryStorage();
|
|
9432
9696
|
};
|
|
9433
9697
|
/**
|
|
9434
|
-
*
|
|
9435
|
-
* @param
|
|
9698
|
+
*
|
|
9699
|
+
* @param cacheLocation
|
|
9436
9700
|
*/
|
|
9437
|
-
BrowserCacheManager.prototype.
|
|
9438
|
-
|
|
9701
|
+
BrowserCacheManager.prototype.setupTemporaryCacheStorage = function (cacheLocation) {
|
|
9702
|
+
switch (cacheLocation) {
|
|
9703
|
+
case exports.BrowserCacheLocation.LocalStorage:
|
|
9704
|
+
case exports.BrowserCacheLocation.SessionStorage:
|
|
9705
|
+
try {
|
|
9706
|
+
// Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
|
|
9707
|
+
return new BrowserStorage(exports.BrowserCacheLocation.SessionStorage);
|
|
9708
|
+
}
|
|
9709
|
+
catch (e) {
|
|
9710
|
+
this.logger.verbose(e);
|
|
9711
|
+
return this.internalStorage;
|
|
9712
|
+
}
|
|
9713
|
+
case exports.BrowserCacheLocation.MemoryStorage:
|
|
9714
|
+
default:
|
|
9715
|
+
return this.internalStorage;
|
|
9716
|
+
}
|
|
9439
9717
|
};
|
|
9440
9718
|
/**
|
|
9441
|
-
*
|
|
9719
|
+
* Migrate all old cache entries to new schema. No rollback supported.
|
|
9720
|
+
* @param storeAuthStateInCookie
|
|
9442
9721
|
*/
|
|
9443
|
-
BrowserCacheManager.prototype.
|
|
9444
|
-
|
|
9722
|
+
BrowserCacheManager.prototype.migrateCacheEntries = function () {
|
|
9723
|
+
var _this = this;
|
|
9724
|
+
var idTokenKey = Constants.CACHE_PREFIX + "." + PersistentCacheKeys.ID_TOKEN;
|
|
9725
|
+
var clientInfoKey = Constants.CACHE_PREFIX + "." + PersistentCacheKeys.CLIENT_INFO;
|
|
9726
|
+
var errorKey = Constants.CACHE_PREFIX + "." + PersistentCacheKeys.ERROR;
|
|
9727
|
+
var errorDescKey = Constants.CACHE_PREFIX + "." + PersistentCacheKeys.ERROR_DESC;
|
|
9728
|
+
var idTokenValue = this.browserStorage.getItem(idTokenKey);
|
|
9729
|
+
var clientInfoValue = this.browserStorage.getItem(clientInfoKey);
|
|
9730
|
+
var errorValue = this.browserStorage.getItem(errorKey);
|
|
9731
|
+
var errorDescValue = this.browserStorage.getItem(errorDescKey);
|
|
9732
|
+
var values = [idTokenValue, clientInfoValue, errorValue, errorDescValue];
|
|
9733
|
+
var keysToMigrate = [PersistentCacheKeys.ID_TOKEN, PersistentCacheKeys.CLIENT_INFO, PersistentCacheKeys.ERROR, PersistentCacheKeys.ERROR_DESC];
|
|
9734
|
+
keysToMigrate.forEach(function (cacheKey, index) { return _this.migrateCacheEntry(cacheKey, values[index]); });
|
|
9445
9735
|
};
|
|
9446
9736
|
/**
|
|
9447
|
-
*
|
|
9737
|
+
* Utility function to help with migration.
|
|
9738
|
+
* @param newKey
|
|
9739
|
+
* @param value
|
|
9740
|
+
* @param storeAuthStateInCookie
|
|
9448
9741
|
*/
|
|
9449
|
-
BrowserCacheManager.prototype.
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
switch (_a.label) {
|
|
9454
|
-
case 0:
|
|
9455
|
-
// Removes all accounts and their credentials
|
|
9456
|
-
return [4 /*yield*/, this.removeAllAccounts()];
|
|
9457
|
-
case 1:
|
|
9458
|
-
// Removes all accounts and their credentials
|
|
9459
|
-
_a.sent();
|
|
9460
|
-
this.removeAppMetadata();
|
|
9461
|
-
// Removes all remaining MSAL cache items
|
|
9462
|
-
this.getKeys().forEach(function (cacheKey) {
|
|
9463
|
-
// Check if key contains msal prefix; For now, we are clearing all the cache items created by MSAL.js
|
|
9464
|
-
if ((_this.browserStorage.containsKey(cacheKey) || _this.temporaryCacheStorage.containsKey(cacheKey)) && ((cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1) || (cacheKey.indexOf(_this.clientId) !== -1))) {
|
|
9465
|
-
_this.removeItem(cacheKey);
|
|
9466
|
-
}
|
|
9467
|
-
});
|
|
9468
|
-
this.internalStorage.clear();
|
|
9469
|
-
return [2 /*return*/];
|
|
9470
|
-
}
|
|
9471
|
-
});
|
|
9472
|
-
});
|
|
9742
|
+
BrowserCacheManager.prototype.migrateCacheEntry = function (newKey, value) {
|
|
9743
|
+
if (value) {
|
|
9744
|
+
this.setTemporaryCache(newKey, value, true);
|
|
9745
|
+
}
|
|
9473
9746
|
};
|
|
9474
9747
|
/**
|
|
9475
|
-
*
|
|
9476
|
-
* @param
|
|
9477
|
-
* @param cookieValue
|
|
9478
|
-
* @param expires
|
|
9748
|
+
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
9749
|
+
* @param input
|
|
9479
9750
|
*/
|
|
9480
|
-
BrowserCacheManager.prototype.
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9751
|
+
BrowserCacheManager.prototype.validateAndParseJson = function (jsonValue) {
|
|
9752
|
+
try {
|
|
9753
|
+
var parsedJson = JSON.parse(jsonValue);
|
|
9754
|
+
/**
|
|
9755
|
+
* There are edge cases in which JSON.parse will successfully parse a non-valid JSON object
|
|
9756
|
+
* (e.g. JSON.parse will parse an escaped string into an unescaped string), so adding a type check
|
|
9757
|
+
* of the parsed value is necessary in order to be certain that the string represents a valid JSON object.
|
|
9758
|
+
*
|
|
9759
|
+
*/
|
|
9760
|
+
return (parsedJson && typeof parsedJson === "object") ? parsedJson : null;
|
|
9485
9761
|
}
|
|
9486
|
-
|
|
9487
|
-
|
|
9762
|
+
catch (error) {
|
|
9763
|
+
return null;
|
|
9488
9764
|
}
|
|
9489
|
-
document.cookie = cookieStr;
|
|
9490
9765
|
};
|
|
9491
9766
|
/**
|
|
9492
|
-
*
|
|
9493
|
-
* @param
|
|
9767
|
+
* fetches the entry from the browser storage based off the key
|
|
9768
|
+
* @param key
|
|
9494
9769
|
*/
|
|
9495
|
-
BrowserCacheManager.prototype.
|
|
9496
|
-
|
|
9497
|
-
var cookieList = document.cookie.split(";");
|
|
9498
|
-
for (var i = 0; i < cookieList.length; i++) {
|
|
9499
|
-
var cookie = cookieList[i];
|
|
9500
|
-
while (cookie.charAt(0) === " ") {
|
|
9501
|
-
cookie = cookie.substring(1);
|
|
9502
|
-
}
|
|
9503
|
-
if (cookie.indexOf(name) === 0) {
|
|
9504
|
-
return decodeURIComponent(cookie.substring(name.length, cookie.length));
|
|
9505
|
-
}
|
|
9506
|
-
}
|
|
9507
|
-
return "";
|
|
9770
|
+
BrowserCacheManager.prototype.getItem = function (key) {
|
|
9771
|
+
return this.browserStorage.getItem(key);
|
|
9508
9772
|
};
|
|
9509
9773
|
/**
|
|
9510
|
-
*
|
|
9774
|
+
* sets the entry in the browser storage
|
|
9775
|
+
* @param key
|
|
9776
|
+
* @param value
|
|
9511
9777
|
*/
|
|
9512
|
-
BrowserCacheManager.prototype.
|
|
9513
|
-
|
|
9514
|
-
var cookiePrefix = Constants.CACHE_PREFIX + "." + this.clientId;
|
|
9515
|
-
var cookieList = document.cookie.split(";");
|
|
9516
|
-
cookieList.forEach(function (cookie) {
|
|
9517
|
-
while (cookie.charAt(0) === " ") {
|
|
9518
|
-
// eslint-disable-next-line no-param-reassign
|
|
9519
|
-
cookie = cookie.substring(1);
|
|
9520
|
-
}
|
|
9521
|
-
if (cookie.indexOf(cookiePrefix) === 0) {
|
|
9522
|
-
var cookieKey = cookie.split("=")[0];
|
|
9523
|
-
_this.clearItemCookie(cookieKey);
|
|
9524
|
-
}
|
|
9525
|
-
});
|
|
9778
|
+
BrowserCacheManager.prototype.setItem = function (key, value) {
|
|
9779
|
+
this.browserStorage.setItem(key, value);
|
|
9526
9780
|
};
|
|
9527
9781
|
/**
|
|
9528
|
-
*
|
|
9529
|
-
* @param
|
|
9782
|
+
* fetch the account entity from the platform cache
|
|
9783
|
+
* @param accountKey
|
|
9530
9784
|
*/
|
|
9531
|
-
BrowserCacheManager.prototype.
|
|
9532
|
-
this.
|
|
9785
|
+
BrowserCacheManager.prototype.getAccount = function (accountKey) {
|
|
9786
|
+
var account = this.getItem(accountKey);
|
|
9787
|
+
if (!account) {
|
|
9788
|
+
return null;
|
|
9789
|
+
}
|
|
9790
|
+
var parsedAccount = this.validateAndParseJson(account);
|
|
9791
|
+
if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
|
|
9792
|
+
return null;
|
|
9793
|
+
}
|
|
9794
|
+
return CacheManager.toObject(new AccountEntity(), parsedAccount);
|
|
9533
9795
|
};
|
|
9534
9796
|
/**
|
|
9535
|
-
*
|
|
9536
|
-
* @param
|
|
9797
|
+
* set account entity in the platform cache
|
|
9798
|
+
* @param key
|
|
9799
|
+
* @param value
|
|
9537
9800
|
*/
|
|
9538
|
-
BrowserCacheManager.prototype.
|
|
9539
|
-
|
|
9540
|
-
var
|
|
9541
|
-
|
|
9801
|
+
BrowserCacheManager.prototype.setAccount = function (account) {
|
|
9802
|
+
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
9803
|
+
var key = account.generateAccountKey();
|
|
9804
|
+
this.setItem(key, JSON.stringify(account));
|
|
9542
9805
|
};
|
|
9543
9806
|
/**
|
|
9544
|
-
*
|
|
9807
|
+
* generates idToken entity from a string
|
|
9808
|
+
* @param idTokenKey
|
|
9545
9809
|
*/
|
|
9546
|
-
BrowserCacheManager.prototype.
|
|
9547
|
-
|
|
9810
|
+
BrowserCacheManager.prototype.getIdTokenCredential = function (idTokenKey) {
|
|
9811
|
+
var value = this.getItem(idTokenKey);
|
|
9812
|
+
if (!value) {
|
|
9813
|
+
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9814
|
+
return null;
|
|
9815
|
+
}
|
|
9816
|
+
var parsedIdToken = this.validateAndParseJson(value);
|
|
9817
|
+
if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
|
|
9818
|
+
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9819
|
+
return null;
|
|
9820
|
+
}
|
|
9821
|
+
this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
|
|
9822
|
+
return CacheManager.toObject(new IdTokenEntity(), parsedIdToken);
|
|
9548
9823
|
};
|
|
9549
9824
|
/**
|
|
9550
|
-
*
|
|
9825
|
+
* set IdToken credential to the platform cache
|
|
9826
|
+
* @param idToken
|
|
9551
9827
|
*/
|
|
9552
|
-
BrowserCacheManager.prototype.
|
|
9553
|
-
|
|
9828
|
+
BrowserCacheManager.prototype.setIdTokenCredential = function (idToken) {
|
|
9829
|
+
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
9830
|
+
var idTokenKey = idToken.generateCredentialKey();
|
|
9831
|
+
this.setItem(idTokenKey, JSON.stringify(idToken));
|
|
9554
9832
|
};
|
|
9555
9833
|
/**
|
|
9556
|
-
*
|
|
9834
|
+
* generates accessToken entity from a string
|
|
9557
9835
|
* @param key
|
|
9558
|
-
* @param addInstanceId
|
|
9559
9836
|
*/
|
|
9560
|
-
BrowserCacheManager.prototype.
|
|
9561
|
-
var
|
|
9562
|
-
if (!
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
}
|
|
9566
|
-
return Constants.CACHE_PREFIX + "." + this.clientId + "." + key;
|
|
9837
|
+
BrowserCacheManager.prototype.getAccessTokenCredential = function (accessTokenKey) {
|
|
9838
|
+
var value = this.getItem(accessTokenKey);
|
|
9839
|
+
if (!value) {
|
|
9840
|
+
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9841
|
+
return null;
|
|
9567
9842
|
}
|
|
9568
|
-
|
|
9843
|
+
var parsedAccessToken = this.validateAndParseJson(value);
|
|
9844
|
+
if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {
|
|
9845
|
+
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9846
|
+
return null;
|
|
9847
|
+
}
|
|
9848
|
+
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
|
|
9849
|
+
return CacheManager.toObject(new AccessTokenEntity(), parsedAccessToken);
|
|
9569
9850
|
};
|
|
9570
9851
|
/**
|
|
9571
|
-
*
|
|
9572
|
-
* @param
|
|
9852
|
+
* set accessToken credential to the platform cache
|
|
9853
|
+
* @param accessToken
|
|
9573
9854
|
*/
|
|
9574
|
-
BrowserCacheManager.prototype.
|
|
9575
|
-
|
|
9576
|
-
|
|
9855
|
+
BrowserCacheManager.prototype.setAccessTokenCredential = function (accessToken) {
|
|
9856
|
+
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
9857
|
+
var accessTokenKey = accessToken.generateCredentialKey();
|
|
9858
|
+
this.setItem(accessTokenKey, JSON.stringify(accessToken));
|
|
9577
9859
|
};
|
|
9578
9860
|
/**
|
|
9579
|
-
*
|
|
9580
|
-
* @param
|
|
9861
|
+
* generates refreshToken entity from a string
|
|
9862
|
+
* @param refreshTokenKey
|
|
9581
9863
|
*/
|
|
9582
|
-
BrowserCacheManager.prototype.
|
|
9583
|
-
var
|
|
9584
|
-
|
|
9864
|
+
BrowserCacheManager.prototype.getRefreshTokenCredential = function (refreshTokenKey) {
|
|
9865
|
+
var value = this.getItem(refreshTokenKey);
|
|
9866
|
+
if (!value) {
|
|
9867
|
+
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
9868
|
+
return null;
|
|
9869
|
+
}
|
|
9870
|
+
var parsedRefreshToken = this.validateAndParseJson(value);
|
|
9871
|
+
if (!parsedRefreshToken || !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)) {
|
|
9872
|
+
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
9873
|
+
return null;
|
|
9874
|
+
}
|
|
9875
|
+
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
|
|
9876
|
+
return CacheManager.toObject(new RefreshTokenEntity(), parsedRefreshToken);
|
|
9585
9877
|
};
|
|
9586
9878
|
/**
|
|
9587
|
-
*
|
|
9588
|
-
* @param
|
|
9879
|
+
* set refreshToken credential to the platform cache
|
|
9880
|
+
* @param refreshToken
|
|
9589
9881
|
*/
|
|
9590
|
-
BrowserCacheManager.prototype.
|
|
9591
|
-
|
|
9592
|
-
var
|
|
9593
|
-
|
|
9882
|
+
BrowserCacheManager.prototype.setRefreshTokenCredential = function (refreshToken) {
|
|
9883
|
+
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
9884
|
+
var refreshTokenKey = refreshToken.generateCredentialKey();
|
|
9885
|
+
this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
|
|
9594
9886
|
};
|
|
9595
9887
|
/**
|
|
9596
|
-
*
|
|
9888
|
+
* fetch appMetadata entity from the platform cache
|
|
9889
|
+
* @param appMetadataKey
|
|
9597
9890
|
*/
|
|
9598
|
-
BrowserCacheManager.prototype.
|
|
9599
|
-
var
|
|
9600
|
-
|
|
9601
|
-
|
|
9891
|
+
BrowserCacheManager.prototype.getAppMetadata = function (appMetadataKey) {
|
|
9892
|
+
var value = this.getItem(appMetadataKey);
|
|
9893
|
+
if (!value) {
|
|
9894
|
+
this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit");
|
|
9602
9895
|
return null;
|
|
9603
9896
|
}
|
|
9604
|
-
var
|
|
9605
|
-
|
|
9897
|
+
var parsedMetadata = this.validateAndParseJson(value);
|
|
9898
|
+
if (!parsedMetadata || !AppMetadataEntity.isAppMetadataEntity(appMetadataKey, parsedMetadata)) {
|
|
9899
|
+
this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit");
|
|
9900
|
+
return null;
|
|
9901
|
+
}
|
|
9902
|
+
this.logger.trace("BrowserCacheManager.getAppMetadata: cache hit");
|
|
9903
|
+
return CacheManager.toObject(new AppMetadataEntity(), parsedMetadata);
|
|
9606
9904
|
};
|
|
9607
9905
|
/**
|
|
9608
|
-
*
|
|
9609
|
-
* @param
|
|
9610
|
-
* @param account
|
|
9906
|
+
* set appMetadata entity to the platform cache
|
|
9907
|
+
* @param appMetadata
|
|
9611
9908
|
*/
|
|
9612
|
-
BrowserCacheManager.prototype.
|
|
9613
|
-
this.logger.trace("BrowserCacheManager.
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
this.setTemporaryCache(stateCacheKey, state, false);
|
|
9617
|
-
// Cache the nonce
|
|
9618
|
-
var nonceCacheKey = this.generateNonceKey(state);
|
|
9619
|
-
this.setTemporaryCache(nonceCacheKey, nonce, false);
|
|
9620
|
-
// Cache authorityKey
|
|
9621
|
-
var authorityCacheKey = this.generateAuthorityKey(state);
|
|
9622
|
-
this.setTemporaryCache(authorityCacheKey, authorityInstance, false);
|
|
9623
|
-
if (account) {
|
|
9624
|
-
var ccsCredential = {
|
|
9625
|
-
credential: account.homeAccountId,
|
|
9626
|
-
type: CcsCredentialType.HOME_ACCOUNT_ID
|
|
9627
|
-
};
|
|
9628
|
-
this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
|
|
9629
|
-
}
|
|
9630
|
-
else if (!StringUtils.isEmpty(loginHint)) {
|
|
9631
|
-
var ccsCredential = {
|
|
9632
|
-
credential: loginHint,
|
|
9633
|
-
type: CcsCredentialType.UPN
|
|
9634
|
-
};
|
|
9635
|
-
this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
|
|
9636
|
-
}
|
|
9909
|
+
BrowserCacheManager.prototype.setAppMetadata = function (appMetadata) {
|
|
9910
|
+
this.logger.trace("BrowserCacheManager.setAppMetadata called");
|
|
9911
|
+
var appMetadataKey = appMetadata.generateAppMetadataKey();
|
|
9912
|
+
this.setItem(appMetadataKey, JSON.stringify(appMetadata));
|
|
9637
9913
|
};
|
|
9638
9914
|
/**
|
|
9639
|
-
*
|
|
9640
|
-
* @param
|
|
9915
|
+
* fetch server telemetry entity from the platform cache
|
|
9916
|
+
* @param serverTelemetryKey
|
|
9641
9917
|
*/
|
|
9642
|
-
BrowserCacheManager.prototype.
|
|
9643
|
-
var
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
this.getKeys().forEach(function (key) {
|
|
9648
|
-
if (key.indexOf(state) !== -1) {
|
|
9649
|
-
_this.removeItem(key);
|
|
9650
|
-
}
|
|
9651
|
-
});
|
|
9918
|
+
BrowserCacheManager.prototype.getServerTelemetry = function (serverTelemetryKey) {
|
|
9919
|
+
var value = this.getItem(serverTelemetryKey);
|
|
9920
|
+
if (!value) {
|
|
9921
|
+
this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit");
|
|
9922
|
+
return null;
|
|
9652
9923
|
}
|
|
9653
|
-
|
|
9654
|
-
if (
|
|
9655
|
-
this.
|
|
9656
|
-
|
|
9657
|
-
this.removeItem(this.generateAuthorityKey(state));
|
|
9924
|
+
var parsedMetadata = this.validateAndParseJson(value);
|
|
9925
|
+
if (!parsedMetadata || !ServerTelemetryEntity.isServerTelemetryEntity(serverTelemetryKey, parsedMetadata)) {
|
|
9926
|
+
this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit");
|
|
9927
|
+
return null;
|
|
9658
9928
|
}
|
|
9659
|
-
this.
|
|
9660
|
-
|
|
9661
|
-
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
|
|
9662
|
-
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));
|
|
9663
|
-
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));
|
|
9664
|
-
this.setInteractionInProgress(false);
|
|
9929
|
+
this.logger.trace("BrowserCacheManager.getServerTelemetry: cache hit");
|
|
9930
|
+
return CacheManager.toObject(new ServerTelemetryEntity(), parsedMetadata);
|
|
9665
9931
|
};
|
|
9666
9932
|
/**
|
|
9667
|
-
*
|
|
9668
|
-
* @param
|
|
9933
|
+
* set server telemetry entity to the platform cache
|
|
9934
|
+
* @param serverTelemetryKey
|
|
9935
|
+
* @param serverTelemetry
|
|
9669
9936
|
*/
|
|
9670
|
-
BrowserCacheManager.prototype.
|
|
9671
|
-
this.logger.trace("BrowserCacheManager.
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9937
|
+
BrowserCacheManager.prototype.setServerTelemetry = function (serverTelemetryKey, serverTelemetry) {
|
|
9938
|
+
this.logger.trace("BrowserCacheManager.setServerTelemetry called");
|
|
9939
|
+
this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
|
|
9940
|
+
};
|
|
9941
|
+
/**
|
|
9942
|
+
*
|
|
9943
|
+
*/
|
|
9944
|
+
BrowserCacheManager.prototype.getAuthorityMetadata = function (key) {
|
|
9945
|
+
var value = this.internalStorage.getItem(key);
|
|
9946
|
+
if (!value) {
|
|
9947
|
+
this.logger.trace("BrowserCacheManager.getAuthorityMetadata: called, no cache hit");
|
|
9948
|
+
return null;
|
|
9678
9949
|
}
|
|
9679
|
-
this.
|
|
9950
|
+
var parsedMetadata = this.validateAndParseJson(value);
|
|
9951
|
+
if (parsedMetadata && AuthorityMetadataEntity.isAuthorityMetadataEntity(key, parsedMetadata)) {
|
|
9952
|
+
this.logger.trace("BrowserCacheManager.getAuthorityMetadata: cache hit");
|
|
9953
|
+
return CacheManager.toObject(new AuthorityMetadataEntity(), parsedMetadata);
|
|
9954
|
+
}
|
|
9955
|
+
return null;
|
|
9680
9956
|
};
|
|
9681
9957
|
/**
|
|
9682
|
-
*
|
|
9683
|
-
* Used in scenarios where temp cache needs to be cleaned but state is not known, such as clicking browser back button.
|
|
9684
|
-
* @param interactionType
|
|
9958
|
+
*
|
|
9685
9959
|
*/
|
|
9686
|
-
BrowserCacheManager.prototype.
|
|
9960
|
+
BrowserCacheManager.prototype.getAuthorityMetadataKeys = function () {
|
|
9687
9961
|
var _this = this;
|
|
9688
|
-
this.
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
// If this key is not the state key, move on
|
|
9692
|
-
if (key.indexOf(TemporaryCacheKeys.REQUEST_STATE) === -1) {
|
|
9693
|
-
return;
|
|
9694
|
-
}
|
|
9695
|
-
// Retrieve state value, return if not a valid value
|
|
9696
|
-
var stateValue = _this.temporaryCacheStorage.getItem(key);
|
|
9697
|
-
if (!stateValue) {
|
|
9698
|
-
return;
|
|
9699
|
-
}
|
|
9700
|
-
// Extract state and ensure it matches given InteractionType, then clean request cache
|
|
9701
|
-
var parsedState = BrowserProtocolUtils.extractBrowserRequestState(_this.cryptoImpl, stateValue);
|
|
9702
|
-
if (parsedState && parsedState.interactionType === interactionType) {
|
|
9703
|
-
_this.logger.infoPii("BrowserCacheManager.cleanRequestByInteractionType: Removing temporary cache items for state: " + stateValue);
|
|
9704
|
-
_this.resetRequestCache(stateValue);
|
|
9705
|
-
}
|
|
9962
|
+
var allKeys = this.internalStorage.getKeys();
|
|
9963
|
+
return allKeys.filter(function (key) {
|
|
9964
|
+
return _this.isAuthorityMetadata(key);
|
|
9706
9965
|
});
|
|
9707
|
-
this.clearMsalCookies();
|
|
9708
|
-
};
|
|
9709
|
-
BrowserCacheManager.prototype.cacheCodeRequest = function (authCodeRequest, browserCrypto) {
|
|
9710
|
-
this.logger.trace("BrowserCacheManager.cacheCodeRequest called");
|
|
9711
|
-
var encodedValue = browserCrypto.base64Encode(JSON.stringify(authCodeRequest));
|
|
9712
|
-
this.setTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, encodedValue, true);
|
|
9713
9966
|
};
|
|
9714
9967
|
/**
|
|
9715
|
-
*
|
|
9968
|
+
* Sets wrapper metadata in memory
|
|
9969
|
+
* @param wrapperSKU
|
|
9970
|
+
* @param wrapperVersion
|
|
9716
9971
|
*/
|
|
9717
|
-
BrowserCacheManager.prototype.
|
|
9718
|
-
this.
|
|
9719
|
-
|
|
9720
|
-
var encodedTokenRequest = this.getTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, true);
|
|
9721
|
-
if (!encodedTokenRequest) {
|
|
9722
|
-
throw BrowserAuthError.createNoTokenRequestCacheError();
|
|
9723
|
-
}
|
|
9724
|
-
var parsedRequest = this.validateAndParseJson(browserCrypto.base64Decode(encodedTokenRequest));
|
|
9725
|
-
if (!parsedRequest) {
|
|
9726
|
-
throw BrowserAuthError.createUnableToParseTokenRequestCacheError();
|
|
9727
|
-
}
|
|
9728
|
-
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
|
|
9729
|
-
// Get cached authority and use if no authority is cached with request.
|
|
9730
|
-
if (StringUtils.isEmpty(parsedRequest.authority)) {
|
|
9731
|
-
var authorityCacheKey = this.generateAuthorityKey(state);
|
|
9732
|
-
var cachedAuthority = this.getTemporaryCache(authorityCacheKey);
|
|
9733
|
-
if (!cachedAuthority) {
|
|
9734
|
-
throw BrowserAuthError.createNoCachedAuthorityError();
|
|
9735
|
-
}
|
|
9736
|
-
parsedRequest.authority = cachedAuthority;
|
|
9737
|
-
}
|
|
9738
|
-
return parsedRequest;
|
|
9972
|
+
BrowserCacheManager.prototype.setWrapperMetadata = function (wrapperSKU, wrapperVersion) {
|
|
9973
|
+
this.internalStorage.setItem(InMemoryCacheKeys.WRAPPER_SKU, wrapperSKU);
|
|
9974
|
+
this.internalStorage.setItem(InMemoryCacheKeys.WRAPPER_VER, wrapperVersion);
|
|
9739
9975
|
};
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
}
|
|
9976
|
+
/**
|
|
9977
|
+
* Returns wrapper metadata from in-memory storage
|
|
9978
|
+
*/
|
|
9979
|
+
BrowserCacheManager.prototype.getWrapperMetadata = function () {
|
|
9980
|
+
var sku = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_SKU) || "";
|
|
9981
|
+
var version = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_VER) || "";
|
|
9982
|
+
return [sku, version];
|
|
9748
9983
|
};
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9984
|
+
/**
|
|
9985
|
+
*
|
|
9986
|
+
* @param entity
|
|
9987
|
+
*/
|
|
9988
|
+
BrowserCacheManager.prototype.setAuthorityMetadata = function (key, entity) {
|
|
9989
|
+
this.logger.trace("BrowserCacheManager.setAuthorityMetadata called");
|
|
9990
|
+
this.internalStorage.setItem(key, JSON.stringify(entity));
|
|
9752
9991
|
};
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
else if (!inProgress && clientId === this.clientId) {
|
|
9762
|
-
this.removeItem(key);
|
|
9992
|
+
/**
|
|
9993
|
+
* Gets the active account
|
|
9994
|
+
*/
|
|
9995
|
+
BrowserCacheManager.prototype.getActiveAccount = function () {
|
|
9996
|
+
var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
9997
|
+
var activeAccountId = this.browserStorage.getItem(activeAccountIdKey);
|
|
9998
|
+
if (!activeAccountId) {
|
|
9999
|
+
return null;
|
|
9763
10000
|
}
|
|
10001
|
+
return this.getAccountInfoByFilter({ localAccountId: activeAccountId })[0] || null;
|
|
9764
10002
|
};
|
|
9765
10003
|
/**
|
|
9766
|
-
*
|
|
10004
|
+
* Sets the active account's localAccountId in cache
|
|
10005
|
+
* @param account
|
|
9767
10006
|
*/
|
|
9768
|
-
BrowserCacheManager.prototype.
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
this.browserStorage.
|
|
9773
|
-
this.logger.verbose("Cached ADAL id token retrieved.");
|
|
10007
|
+
BrowserCacheManager.prototype.setActiveAccount = function (account) {
|
|
10008
|
+
var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
|
|
10009
|
+
if (account) {
|
|
10010
|
+
this.logger.verbose("setActiveAccount: Active account set");
|
|
10011
|
+
this.browserStorage.setItem(activeAccountIdKey, account.localAccountId);
|
|
9774
10012
|
}
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
this.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
|
|
9779
|
-
this.logger.verbose("Cached MSAL.js v1 id token retrieved");
|
|
10013
|
+
else {
|
|
10014
|
+
this.logger.verbose("setActiveAccount: No account passed, active account not set");
|
|
10015
|
+
this.browserStorage.removeItem(activeAccountIdKey);
|
|
9780
10016
|
}
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
10017
|
+
};
|
|
10018
|
+
/**
|
|
10019
|
+
* Gets a list of accounts that match all of the filters provided
|
|
10020
|
+
* @param account
|
|
10021
|
+
*/
|
|
10022
|
+
BrowserCacheManager.prototype.getAccountInfoByFilter = function (accountFilter) {
|
|
10023
|
+
var allAccounts = this.getAllAccounts();
|
|
10024
|
+
return allAccounts.filter(function (accountObj) {
|
|
10025
|
+
if (accountFilter.username && accountFilter.username.toLowerCase() !== accountObj.username.toLowerCase()) {
|
|
10026
|
+
return false;
|
|
9787
10027
|
}
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
return cachedIdToken.claims.upn;
|
|
10028
|
+
if (accountFilter.homeAccountId && accountFilter.homeAccountId !== accountObj.homeAccountId) {
|
|
10029
|
+
return false;
|
|
9791
10030
|
}
|
|
9792
|
-
|
|
9793
|
-
|
|
10031
|
+
if (accountFilter.localAccountId && accountFilter.localAccountId !== accountObj.localAccountId) {
|
|
10032
|
+
return false;
|
|
9794
10033
|
}
|
|
9795
|
-
|
|
9796
|
-
|
|
10034
|
+
if (accountFilter.tenantId && accountFilter.tenantId !== accountObj.tenantId) {
|
|
10035
|
+
return false;
|
|
10036
|
+
}
|
|
10037
|
+
if (accountFilter.environment && accountFilter.environment !== accountObj.environment) {
|
|
10038
|
+
return false;
|
|
10039
|
+
}
|
|
10040
|
+
return true;
|
|
10041
|
+
});
|
|
9797
10042
|
};
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
10043
|
+
/**
|
|
10044
|
+
* fetch throttling entity from the platform cache
|
|
10045
|
+
* @param throttlingCacheKey
|
|
10046
|
+
*/
|
|
10047
|
+
BrowserCacheManager.prototype.getThrottlingCache = function (throttlingCacheKey) {
|
|
10048
|
+
var value = this.getItem(throttlingCacheKey);
|
|
10049
|
+
if (!value) {
|
|
10050
|
+
this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit");
|
|
10051
|
+
return null;
|
|
10052
|
+
}
|
|
10053
|
+
var parsedThrottlingCache = this.validateAndParseJson(value);
|
|
10054
|
+
if (!parsedThrottlingCache || !ThrottlingEntity.isThrottlingEntity(throttlingCacheKey, parsedThrottlingCache)) {
|
|
10055
|
+
this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit");
|
|
10056
|
+
return null;
|
|
10057
|
+
}
|
|
10058
|
+
this.logger.trace("BrowserCacheManager.getThrottlingCache: cache hit");
|
|
10059
|
+
return CacheManager.toObject(new ThrottlingEntity(), parsedThrottlingCache);
|
|
9805
10060
|
};
|
|
9806
|
-
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
9807
|
-
};
|
|
9808
|
-
|
|
9809
|
-
/*
|
|
9810
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9811
|
-
* Licensed under the MIT License.
|
|
9812
|
-
*/
|
|
9813
|
-
/**
|
|
9814
|
-
* This class implements the Fetch API for GET and POST requests. See more here: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
|
9815
|
-
*/
|
|
9816
|
-
var FetchClient = /** @class */ (function () {
|
|
9817
|
-
function FetchClient() {
|
|
9818
|
-
}
|
|
9819
10061
|
/**
|
|
9820
|
-
*
|
|
9821
|
-
* @param
|
|
9822
|
-
* @param
|
|
9823
|
-
* @param body
|
|
10062
|
+
* set throttling entity to the platform cache
|
|
10063
|
+
* @param throttlingCacheKey
|
|
10064
|
+
* @param throttlingCache
|
|
9824
10065
|
*/
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
return __generator$1(this, function (_b) {
|
|
9829
|
-
switch (_b.label) {
|
|
9830
|
-
case 0:
|
|
9831
|
-
_b.trys.push([0, 2, , 3]);
|
|
9832
|
-
return [4 /*yield*/, fetch(url, {
|
|
9833
|
-
method: HTTP_REQUEST_TYPE.GET,
|
|
9834
|
-
headers: this.getFetchHeaders(options)
|
|
9835
|
-
})];
|
|
9836
|
-
case 1:
|
|
9837
|
-
response = _b.sent();
|
|
9838
|
-
return [3 /*break*/, 3];
|
|
9839
|
-
case 2:
|
|
9840
|
-
e_1 = _b.sent();
|
|
9841
|
-
if (window.navigator.onLine) {
|
|
9842
|
-
throw BrowserAuthError.createGetRequestFailedError(e_1, url);
|
|
9843
|
-
}
|
|
9844
|
-
else {
|
|
9845
|
-
throw BrowserAuthError.createNoNetworkConnectivityError();
|
|
9846
|
-
}
|
|
9847
|
-
case 3:
|
|
9848
|
-
_b.trys.push([3, 5, , 6]);
|
|
9849
|
-
_a = {
|
|
9850
|
-
headers: this.getHeaderDict(response.headers)
|
|
9851
|
-
};
|
|
9852
|
-
return [4 /*yield*/, response.json()];
|
|
9853
|
-
case 4: return [2 /*return*/, (_a.body = (_b.sent()),
|
|
9854
|
-
_a.status = response.status,
|
|
9855
|
-
_a)];
|
|
9856
|
-
case 5:
|
|
9857
|
-
_b.sent();
|
|
9858
|
-
throw BrowserAuthError.createFailedToParseNetworkResponseError(url);
|
|
9859
|
-
case 6: return [2 /*return*/];
|
|
9860
|
-
}
|
|
9861
|
-
});
|
|
9862
|
-
});
|
|
10066
|
+
BrowserCacheManager.prototype.setThrottlingCache = function (throttlingCacheKey, throttlingCache) {
|
|
10067
|
+
this.logger.trace("BrowserCacheManager.setThrottlingCache called");
|
|
10068
|
+
this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
|
|
9863
10069
|
};
|
|
9864
10070
|
/**
|
|
9865
|
-
*
|
|
9866
|
-
*
|
|
9867
|
-
* @param
|
|
9868
|
-
* @param body
|
|
10071
|
+
* Gets cache item with given key.
|
|
10072
|
+
* Will retrieve from cookies if storeAuthStateInCookie is set to true.
|
|
10073
|
+
* @param key
|
|
9869
10074
|
*/
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
return [3 /*break*/, 4];
|
|
9888
|
-
case 3:
|
|
9889
|
-
e_3 = _b.sent();
|
|
9890
|
-
if (window.navigator.onLine) {
|
|
9891
|
-
throw BrowserAuthError.createPostRequestFailedError(e_3, url);
|
|
9892
|
-
}
|
|
9893
|
-
else {
|
|
9894
|
-
throw BrowserAuthError.createNoNetworkConnectivityError();
|
|
9895
|
-
}
|
|
9896
|
-
case 4:
|
|
9897
|
-
_b.trys.push([4, 6, , 7]);
|
|
9898
|
-
_a = {
|
|
9899
|
-
headers: this.getHeaderDict(response.headers)
|
|
9900
|
-
};
|
|
9901
|
-
return [4 /*yield*/, response.json()];
|
|
9902
|
-
case 5: return [2 /*return*/, (_a.body = (_b.sent()),
|
|
9903
|
-
_a.status = response.status,
|
|
9904
|
-
_a)];
|
|
9905
|
-
case 6:
|
|
9906
|
-
_b.sent();
|
|
9907
|
-
throw BrowserAuthError.createFailedToParseNetworkResponseError(url);
|
|
9908
|
-
case 7: return [2 /*return*/];
|
|
10075
|
+
BrowserCacheManager.prototype.getTemporaryCache = function (cacheKey, generateKey) {
|
|
10076
|
+
var key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;
|
|
10077
|
+
if (this.cacheConfig.storeAuthStateInCookie) {
|
|
10078
|
+
var itemCookie = this.getItemCookie(key);
|
|
10079
|
+
if (itemCookie) {
|
|
10080
|
+
this.logger.trace("BrowserCacheManager.getTemporaryCache: storeAuthStateInCookies set to true, retrieving from cookies");
|
|
10081
|
+
return itemCookie;
|
|
10082
|
+
}
|
|
10083
|
+
}
|
|
10084
|
+
var value = this.temporaryCacheStorage.getItem(key);
|
|
10085
|
+
if (!value) {
|
|
10086
|
+
// If temp cache item not found in session/memory, check local storage for items set by old versions
|
|
10087
|
+
if (this.cacheConfig.cacheLocation === exports.BrowserCacheLocation.LocalStorage) {
|
|
10088
|
+
var item = this.browserStorage.getItem(key);
|
|
10089
|
+
if (item) {
|
|
10090
|
+
this.logger.trace("BrowserCacheManager.getTemporaryCache: Temporary cache item found in local storage");
|
|
10091
|
+
return item;
|
|
9909
10092
|
}
|
|
9910
|
-
}
|
|
9911
|
-
|
|
10093
|
+
}
|
|
10094
|
+
this.logger.trace("BrowserCacheManager.getTemporaryCache: No cache item found in local storage");
|
|
10095
|
+
return null;
|
|
10096
|
+
}
|
|
10097
|
+
this.logger.trace("BrowserCacheManager.getTemporaryCache: Temporary cache item returned");
|
|
10098
|
+
return value;
|
|
9912
10099
|
};
|
|
9913
10100
|
/**
|
|
9914
|
-
*
|
|
9915
|
-
*
|
|
10101
|
+
* Sets the cache item with the key and value given.
|
|
10102
|
+
* Stores in cookie if storeAuthStateInCookie is set to true.
|
|
10103
|
+
* This can cause cookie overflow if used incorrectly.
|
|
10104
|
+
* @param key
|
|
10105
|
+
* @param value
|
|
9916
10106
|
*/
|
|
9917
|
-
|
|
9918
|
-
var
|
|
9919
|
-
|
|
9920
|
-
|
|
10107
|
+
BrowserCacheManager.prototype.setTemporaryCache = function (cacheKey, value, generateKey) {
|
|
10108
|
+
var key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;
|
|
10109
|
+
this.temporaryCacheStorage.setItem(key, value);
|
|
10110
|
+
if (this.cacheConfig.storeAuthStateInCookie) {
|
|
10111
|
+
this.logger.trace("BrowserCacheManager.setTemporaryCache: storeAuthStateInCookie set to true, setting item cookie");
|
|
10112
|
+
this.setItemCookie(key, value);
|
|
9921
10113
|
}
|
|
9922
|
-
var optionsHeaders = options.headers;
|
|
9923
|
-
Object.keys(optionsHeaders).forEach(function (key) {
|
|
9924
|
-
headers.append(key, optionsHeaders[key]);
|
|
9925
|
-
});
|
|
9926
|
-
return headers;
|
|
9927
10114
|
};
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
10115
|
+
/**
|
|
10116
|
+
* Removes the cache item with the given key.
|
|
10117
|
+
* Will also clear the cookie item if storeAuthStateInCookie is set to true.
|
|
10118
|
+
* @param key
|
|
10119
|
+
*/
|
|
10120
|
+
BrowserCacheManager.prototype.removeItem = function (key) {
|
|
10121
|
+
this.browserStorage.removeItem(key);
|
|
10122
|
+
this.temporaryCacheStorage.removeItem(key);
|
|
10123
|
+
if (this.cacheConfig.storeAuthStateInCookie) {
|
|
10124
|
+
this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
|
|
10125
|
+
this.clearItemCookie(key);
|
|
10126
|
+
}
|
|
10127
|
+
return true;
|
|
10128
|
+
};
|
|
10129
|
+
/**
|
|
10130
|
+
* Checks whether key is in cache.
|
|
10131
|
+
* @param key
|
|
10132
|
+
*/
|
|
10133
|
+
BrowserCacheManager.prototype.containsKey = function (key) {
|
|
10134
|
+
return this.browserStorage.containsKey(key) || this.temporaryCacheStorage.containsKey(key);
|
|
9934
10135
|
};
|
|
9935
|
-
return FetchClient;
|
|
9936
|
-
}());
|
|
9937
|
-
|
|
9938
|
-
/*
|
|
9939
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9940
|
-
* Licensed under the MIT License.
|
|
9941
|
-
*/
|
|
9942
|
-
/**
|
|
9943
|
-
* This client implements the XMLHttpRequest class to send GET and POST requests.
|
|
9944
|
-
*/
|
|
9945
|
-
var XhrClient = /** @class */ (function () {
|
|
9946
|
-
function XhrClient() {
|
|
9947
|
-
}
|
|
9948
10136
|
/**
|
|
9949
|
-
*
|
|
9950
|
-
* @param url
|
|
9951
|
-
* @param headers
|
|
9952
|
-
* @param body
|
|
10137
|
+
* Gets all keys in window.
|
|
9953
10138
|
*/
|
|
9954
|
-
|
|
9955
|
-
return
|
|
9956
|
-
return __generator$1(this, function (_a) {
|
|
9957
|
-
return [2 /*return*/, this.sendRequestAsync(url, HTTP_REQUEST_TYPE.GET, options)];
|
|
9958
|
-
});
|
|
9959
|
-
});
|
|
10139
|
+
BrowserCacheManager.prototype.getKeys = function () {
|
|
10140
|
+
return __spread(this.browserStorage.getKeys(), this.temporaryCacheStorage.getKeys());
|
|
9960
10141
|
};
|
|
9961
10142
|
/**
|
|
9962
|
-
*
|
|
9963
|
-
* @param url
|
|
9964
|
-
* @param headers
|
|
9965
|
-
* @param body
|
|
10143
|
+
* Clears all cache entries created by MSAL.
|
|
9966
10144
|
*/
|
|
9967
|
-
|
|
10145
|
+
BrowserCacheManager.prototype.clear = function () {
|
|
9968
10146
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
10147
|
+
var _this = this;
|
|
9969
10148
|
return __generator$1(this, function (_a) {
|
|
9970
|
-
|
|
10149
|
+
switch (_a.label) {
|
|
10150
|
+
case 0:
|
|
10151
|
+
// Removes all accounts and their credentials
|
|
10152
|
+
return [4 /*yield*/, this.removeAllAccounts()];
|
|
10153
|
+
case 1:
|
|
10154
|
+
// Removes all accounts and their credentials
|
|
10155
|
+
_a.sent();
|
|
10156
|
+
this.removeAppMetadata();
|
|
10157
|
+
// Removes all remaining MSAL cache items
|
|
10158
|
+
this.getKeys().forEach(function (cacheKey) {
|
|
10159
|
+
// Check if key contains msal prefix; For now, we are clearing all the cache items created by MSAL.js
|
|
10160
|
+
if ((_this.browserStorage.containsKey(cacheKey) || _this.temporaryCacheStorage.containsKey(cacheKey)) && ((cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1) || (cacheKey.indexOf(_this.clientId) !== -1))) {
|
|
10161
|
+
_this.removeItem(cacheKey);
|
|
10162
|
+
}
|
|
10163
|
+
});
|
|
10164
|
+
this.internalStorage.clear();
|
|
10165
|
+
return [2 /*return*/];
|
|
10166
|
+
}
|
|
9971
10167
|
});
|
|
9972
10168
|
});
|
|
9973
10169
|
};
|
|
9974
10170
|
/**
|
|
9975
|
-
*
|
|
9976
|
-
* @param
|
|
9977
|
-
* @param
|
|
9978
|
-
* @param
|
|
10171
|
+
* Add value to cookies
|
|
10172
|
+
* @param cookieName
|
|
10173
|
+
* @param cookieValue
|
|
10174
|
+
* @param expires
|
|
9979
10175
|
*/
|
|
9980
|
-
|
|
9981
|
-
var
|
|
9982
|
-
|
|
9983
|
-
var
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
}
|
|
9991
|
-
else {
|
|
9992
|
-
reject(BrowserAuthError.createGetRequestFailedError("Failed with status " + xhr.status, url));
|
|
9993
|
-
}
|
|
9994
|
-
}
|
|
9995
|
-
try {
|
|
9996
|
-
var jsonResponse = JSON.parse(xhr.responseText);
|
|
9997
|
-
var networkResponse = {
|
|
9998
|
-
headers: _this.getHeaderDict(xhr),
|
|
9999
|
-
body: jsonResponse,
|
|
10000
|
-
status: xhr.status
|
|
10001
|
-
};
|
|
10002
|
-
resolve(networkResponse);
|
|
10003
|
-
}
|
|
10004
|
-
catch (e) {
|
|
10005
|
-
reject(BrowserAuthError.createFailedToParseNetworkResponseError(url));
|
|
10006
|
-
}
|
|
10007
|
-
};
|
|
10008
|
-
xhr.onerror = function () {
|
|
10009
|
-
if (window.navigator.onLine) {
|
|
10010
|
-
if (method === HTTP_REQUEST_TYPE.POST) {
|
|
10011
|
-
reject(BrowserAuthError.createPostRequestFailedError("Failed with status " + xhr.status, url));
|
|
10012
|
-
}
|
|
10013
|
-
else {
|
|
10014
|
-
reject(BrowserAuthError.createGetRequestFailedError("Failed with status " + xhr.status, url));
|
|
10015
|
-
}
|
|
10016
|
-
}
|
|
10017
|
-
else {
|
|
10018
|
-
reject(BrowserAuthError.createNoNetworkConnectivityError());
|
|
10019
|
-
}
|
|
10020
|
-
};
|
|
10021
|
-
if (method === HTTP_REQUEST_TYPE.POST && options && options.body) {
|
|
10022
|
-
xhr.send(options.body);
|
|
10023
|
-
}
|
|
10024
|
-
else if (method === HTTP_REQUEST_TYPE.GET) {
|
|
10025
|
-
xhr.send();
|
|
10026
|
-
}
|
|
10027
|
-
else {
|
|
10028
|
-
throw BrowserAuthError.createHttpMethodNotImplementedError(method);
|
|
10029
|
-
}
|
|
10030
|
-
});
|
|
10176
|
+
BrowserCacheManager.prototype.setItemCookie = function (cookieName, cookieValue, expires) {
|
|
10177
|
+
var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;";
|
|
10178
|
+
if (expires) {
|
|
10179
|
+
var expireTime = this.getCookieExpirationTime(expires);
|
|
10180
|
+
cookieStr += "expires=" + expireTime + ";";
|
|
10181
|
+
}
|
|
10182
|
+
if (this.cacheConfig.secureCookies) {
|
|
10183
|
+
cookieStr += "Secure;";
|
|
10184
|
+
}
|
|
10185
|
+
document.cookie = cookieStr;
|
|
10031
10186
|
};
|
|
10032
10187
|
/**
|
|
10033
|
-
*
|
|
10034
|
-
* @param
|
|
10035
|
-
* @param options
|
|
10188
|
+
* Get one item by key from cookies
|
|
10189
|
+
* @param cookieName
|
|
10036
10190
|
*/
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10191
|
+
BrowserCacheManager.prototype.getItemCookie = function (cookieName) {
|
|
10192
|
+
var name = encodeURIComponent(cookieName) + "=";
|
|
10193
|
+
var cookieList = document.cookie.split(";");
|
|
10194
|
+
for (var i = 0; i < cookieList.length; i++) {
|
|
10195
|
+
var cookie = cookieList[i];
|
|
10196
|
+
while (cookie.charAt(0) === " ") {
|
|
10197
|
+
cookie = cookie.substring(1);
|
|
10198
|
+
}
|
|
10199
|
+
if (cookie.indexOf(name) === 0) {
|
|
10200
|
+
return decodeURIComponent(cookie.substring(name.length, cookie.length));
|
|
10201
|
+
}
|
|
10043
10202
|
}
|
|
10203
|
+
return "";
|
|
10044
10204
|
};
|
|
10045
10205
|
/**
|
|
10046
|
-
*
|
|
10047
|
-
*
|
|
10048
|
-
* Algorithm comes from https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders
|
|
10049
|
-
* @param xhr
|
|
10206
|
+
* Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
|
|
10050
10207
|
*/
|
|
10051
|
-
|
|
10052
|
-
var
|
|
10053
|
-
var
|
|
10054
|
-
var
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10208
|
+
BrowserCacheManager.prototype.clearMsalCookies = function () {
|
|
10209
|
+
var _this = this;
|
|
10210
|
+
var cookiePrefix = Constants.CACHE_PREFIX + "." + this.clientId;
|
|
10211
|
+
var cookieList = document.cookie.split(";");
|
|
10212
|
+
cookieList.forEach(function (cookie) {
|
|
10213
|
+
while (cookie.charAt(0) === " ") {
|
|
10214
|
+
// eslint-disable-next-line no-param-reassign
|
|
10215
|
+
cookie = cookie.substring(1);
|
|
10216
|
+
}
|
|
10217
|
+
if (cookie.indexOf(cookiePrefix) === 0) {
|
|
10218
|
+
var cookieKey = cookie.split("=")[0];
|
|
10219
|
+
_this.clearItemCookie(cookieKey);
|
|
10061
10220
|
}
|
|
10062
10221
|
});
|
|
10063
|
-
return headerDict;
|
|
10064
10222
|
};
|
|
10065
|
-
return XhrClient;
|
|
10066
|
-
}());
|
|
10067
|
-
|
|
10068
|
-
/*
|
|
10069
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10070
|
-
* Licensed under the MIT License.
|
|
10071
|
-
*/
|
|
10072
|
-
/**
|
|
10073
|
-
* Utility class for browser specific functions
|
|
10074
|
-
*/
|
|
10075
|
-
var BrowserUtils = /** @class */ (function () {
|
|
10076
|
-
function BrowserUtils() {
|
|
10077
|
-
}
|
|
10078
|
-
// #region Window Navigation and URL management
|
|
10079
10223
|
/**
|
|
10080
|
-
*
|
|
10224
|
+
* Clear an item in the cookies by key
|
|
10225
|
+
* @param cookieName
|
|
10081
10226
|
*/
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
contentWindow.location.hash = Constants.EMPTY_STRING;
|
|
10085
|
-
if (typeof contentWindow.history.replaceState === "function") {
|
|
10086
|
-
// Full removes "#" from url
|
|
10087
|
-
contentWindow.history.replaceState(null, Constants.EMPTY_STRING, "" + contentWindow.location.origin + contentWindow.location.pathname + contentWindow.location.search);
|
|
10088
|
-
}
|
|
10227
|
+
BrowserCacheManager.prototype.clearItemCookie = function (cookieName) {
|
|
10228
|
+
this.setItemCookie(cookieName, "", -1);
|
|
10089
10229
|
};
|
|
10090
10230
|
/**
|
|
10091
|
-
*
|
|
10231
|
+
* Get cookie expiration time
|
|
10232
|
+
* @param cookieLifeDays
|
|
10092
10233
|
*/
|
|
10093
|
-
|
|
10094
|
-
var
|
|
10095
|
-
|
|
10096
|
-
|
|
10234
|
+
BrowserCacheManager.prototype.getCookieExpirationTime = function (cookieLifeDays) {
|
|
10235
|
+
var today = new Date();
|
|
10236
|
+
var expr = new Date(today.getTime() + cookieLifeDays * this.COOKIE_LIFE_MULTIPLIER);
|
|
10237
|
+
return expr.toUTCString();
|
|
10097
10238
|
};
|
|
10098
10239
|
/**
|
|
10099
|
-
*
|
|
10240
|
+
* Gets the cache object referenced by the browser
|
|
10100
10241
|
*/
|
|
10101
|
-
|
|
10102
|
-
return
|
|
10242
|
+
BrowserCacheManager.prototype.getCache = function () {
|
|
10243
|
+
return this.browserStorage;
|
|
10103
10244
|
};
|
|
10104
10245
|
/**
|
|
10105
|
-
*
|
|
10246
|
+
* interface compat, we cannot overwrite browser cache; Functionality is supported by individual entities in browser
|
|
10106
10247
|
*/
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
window.opener !== window &&
|
|
10110
|
-
typeof window.name === "string" &&
|
|
10111
|
-
window.name.indexOf(BrowserConstants.POPUP_NAME_PREFIX + ".") === 0;
|
|
10248
|
+
BrowserCacheManager.prototype.setCache = function () {
|
|
10249
|
+
// sets nothing
|
|
10112
10250
|
};
|
|
10113
|
-
// #endregion
|
|
10114
10251
|
/**
|
|
10115
|
-
*
|
|
10252
|
+
* Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)
|
|
10253
|
+
* @param key
|
|
10254
|
+
* @param addInstanceId
|
|
10116
10255
|
*/
|
|
10117
|
-
|
|
10118
|
-
|
|
10256
|
+
BrowserCacheManager.prototype.generateCacheKey = function (key) {
|
|
10257
|
+
var generatedKey = this.validateAndParseJson(key);
|
|
10258
|
+
if (!generatedKey) {
|
|
10259
|
+
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX) || StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {
|
|
10260
|
+
return key;
|
|
10261
|
+
}
|
|
10262
|
+
return Constants.CACHE_PREFIX + "." + this.clientId + "." + key;
|
|
10263
|
+
}
|
|
10264
|
+
return JSON.stringify(key);
|
|
10119
10265
|
};
|
|
10120
10266
|
/**
|
|
10121
|
-
*
|
|
10267
|
+
* Create authorityKey to cache authority
|
|
10268
|
+
* @param state
|
|
10122
10269
|
*/
|
|
10123
|
-
|
|
10124
|
-
var
|
|
10125
|
-
|
|
10126
|
-
return urlComponents.Protocol + "//" + urlComponents.HostNameAndPort + "/";
|
|
10270
|
+
BrowserCacheManager.prototype.generateAuthorityKey = function (stateString) {
|
|
10271
|
+
var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
|
|
10272
|
+
return this.generateCacheKey(TemporaryCacheKeys.AUTHORITY + "." + stateId);
|
|
10127
10273
|
};
|
|
10128
10274
|
/**
|
|
10129
|
-
*
|
|
10275
|
+
* Create Nonce key to cache nonce
|
|
10276
|
+
* @param state
|
|
10130
10277
|
*/
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
}
|
|
10135
|
-
else {
|
|
10136
|
-
return new XhrClient();
|
|
10137
|
-
}
|
|
10278
|
+
BrowserCacheManager.prototype.generateNonceKey = function (stateString) {
|
|
10279
|
+
var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
|
|
10280
|
+
return this.generateCacheKey(TemporaryCacheKeys.NONCE_IDTOKEN + "." + stateId);
|
|
10138
10281
|
};
|
|
10139
10282
|
/**
|
|
10140
|
-
*
|
|
10141
|
-
*
|
|
10283
|
+
* Creates full cache key for the request state
|
|
10284
|
+
* @param stateString State string for the request
|
|
10142
10285
|
*/
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
throw BrowserAuthError.createBlockReloadInHiddenIframeError();
|
|
10148
|
-
}
|
|
10286
|
+
BrowserCacheManager.prototype.generateStateKey = function (stateString) {
|
|
10287
|
+
// Use the library state id to key temp storage for uniqueness for multiple concurrent requests
|
|
10288
|
+
var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
|
|
10289
|
+
return this.generateCacheKey(TemporaryCacheKeys.REQUEST_STATE + "." + stateId);
|
|
10149
10290
|
};
|
|
10150
10291
|
/**
|
|
10151
|
-
*
|
|
10152
|
-
* @param interactionType Interaction type for the request
|
|
10153
|
-
* @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
|
|
10292
|
+
* Gets the cached authority based on the cached state. Returns empty if no cached state found.
|
|
10154
10293
|
*/
|
|
10155
|
-
|
|
10156
|
-
var
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10294
|
+
BrowserCacheManager.prototype.getCachedAuthority = function (cachedState) {
|
|
10295
|
+
var stateCacheKey = this.generateStateKey(cachedState);
|
|
10296
|
+
var state = this.getTemporaryCache(stateCacheKey);
|
|
10297
|
+
if (!state) {
|
|
10298
|
+
return null;
|
|
10160
10299
|
}
|
|
10300
|
+
var authorityCacheKey = this.generateAuthorityKey(state);
|
|
10301
|
+
return this.getTemporaryCache(authorityCacheKey);
|
|
10161
10302
|
};
|
|
10162
10303
|
/**
|
|
10163
|
-
*
|
|
10304
|
+
* Updates account, authority, and state in cache
|
|
10305
|
+
* @param serverAuthenticationRequest
|
|
10306
|
+
* @param account
|
|
10164
10307
|
*/
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10308
|
+
BrowserCacheManager.prototype.updateCacheEntries = function (state, nonce, authorityInstance, loginHint, account) {
|
|
10309
|
+
this.logger.trace("BrowserCacheManager.updateCacheEntries called");
|
|
10310
|
+
// Cache the request state
|
|
10311
|
+
var stateCacheKey = this.generateStateKey(state);
|
|
10312
|
+
this.setTemporaryCache(stateCacheKey, state, false);
|
|
10313
|
+
// Cache the nonce
|
|
10314
|
+
var nonceCacheKey = this.generateNonceKey(state);
|
|
10315
|
+
this.setTemporaryCache(nonceCacheKey, nonce, false);
|
|
10316
|
+
// Cache authorityKey
|
|
10317
|
+
var authorityCacheKey = this.generateAuthorityKey(state);
|
|
10318
|
+
this.setTemporaryCache(authorityCacheKey, authorityInstance, false);
|
|
10319
|
+
if (account) {
|
|
10320
|
+
var ccsCredential = {
|
|
10321
|
+
credential: account.homeAccountId,
|
|
10322
|
+
type: CcsCredentialType.HOME_ACCOUNT_ID
|
|
10323
|
+
};
|
|
10324
|
+
this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
|
|
10325
|
+
}
|
|
10326
|
+
else if (!StringUtils.isEmpty(loginHint)) {
|
|
10327
|
+
var ccsCredential = {
|
|
10328
|
+
credential: loginHint,
|
|
10329
|
+
type: CcsCredentialType.UPN
|
|
10330
|
+
};
|
|
10331
|
+
this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
|
|
10169
10332
|
}
|
|
10170
10333
|
};
|
|
10171
10334
|
/**
|
|
10172
|
-
*
|
|
10173
|
-
* @param
|
|
10335
|
+
* Reset all temporary cache items
|
|
10336
|
+
* @param state
|
|
10174
10337
|
*/
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10338
|
+
BrowserCacheManager.prototype.resetRequestCache = function (state) {
|
|
10339
|
+
var _this = this;
|
|
10340
|
+
this.logger.trace("BrowserCacheManager.resetRequestCache called");
|
|
10341
|
+
// check state and remove associated cache items
|
|
10342
|
+
if (!StringUtils.isEmpty(state)) {
|
|
10343
|
+
this.getKeys().forEach(function (key) {
|
|
10344
|
+
if (key.indexOf(state) !== -1) {
|
|
10345
|
+
_this.removeItem(key);
|
|
10346
|
+
}
|
|
10347
|
+
});
|
|
10178
10348
|
}
|
|
10349
|
+
// delete generic interactive request parameters
|
|
10350
|
+
if (state) {
|
|
10351
|
+
this.removeItem(this.generateStateKey(state));
|
|
10352
|
+
this.removeItem(this.generateNonceKey(state));
|
|
10353
|
+
this.removeItem(this.generateAuthorityKey(state));
|
|
10354
|
+
}
|
|
10355
|
+
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
|
|
10356
|
+
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));
|
|
10357
|
+
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
|
|
10358
|
+
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));
|
|
10359
|
+
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));
|
|
10360
|
+
this.setInteractionInProgress(false);
|
|
10179
10361
|
};
|
|
10180
10362
|
/**
|
|
10181
|
-
*
|
|
10363
|
+
* Removes temporary cache for the provided state
|
|
10364
|
+
* @param stateString
|
|
10182
10365
|
*/
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10366
|
+
BrowserCacheManager.prototype.cleanRequestByState = function (stateString) {
|
|
10367
|
+
this.logger.trace("BrowserCacheManager.cleanRequestByState called");
|
|
10368
|
+
// Interaction is completed - remove interaction status.
|
|
10369
|
+
if (stateString) {
|
|
10370
|
+
var stateKey = this.generateStateKey(stateString);
|
|
10371
|
+
var cachedState = this.temporaryCacheStorage.getItem(stateKey);
|
|
10372
|
+
this.logger.infoPii("BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: " + cachedState);
|
|
10373
|
+
this.resetRequestCache(cachedState || "");
|
|
10374
|
+
}
|
|
10375
|
+
this.clearMsalCookies();
|
|
10191
10376
|
};
|
|
10192
|
-
return BrowserUtils;
|
|
10193
|
-
}());
|
|
10194
|
-
|
|
10195
|
-
/*
|
|
10196
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10197
|
-
* Licensed under the MIT License.
|
|
10198
|
-
*/
|
|
10199
|
-
var NavigationClient = /** @class */ (function () {
|
|
10200
|
-
function NavigationClient() {
|
|
10201
|
-
}
|
|
10202
10377
|
/**
|
|
10203
|
-
*
|
|
10204
|
-
*
|
|
10205
|
-
* @param
|
|
10378
|
+
* Looks in temporary cache for any state values with the provided interactionType and removes all temporary cache items for that state
|
|
10379
|
+
* Used in scenarios where temp cache needs to be cleaned but state is not known, such as clicking browser back button.
|
|
10380
|
+
* @param interactionType
|
|
10206
10381
|
*/
|
|
10207
|
-
|
|
10208
|
-
|
|
10382
|
+
BrowserCacheManager.prototype.cleanRequestByInteractionType = function (interactionType) {
|
|
10383
|
+
var _this = this;
|
|
10384
|
+
this.logger.trace("BrowserCacheManager.cleanRequestByInteractionType called");
|
|
10385
|
+
// Loop through all keys to find state key
|
|
10386
|
+
this.getKeys().forEach(function (key) {
|
|
10387
|
+
// If this key is not the state key, move on
|
|
10388
|
+
if (key.indexOf(TemporaryCacheKeys.REQUEST_STATE) === -1) {
|
|
10389
|
+
return;
|
|
10390
|
+
}
|
|
10391
|
+
// Retrieve state value, return if not a valid value
|
|
10392
|
+
var stateValue = _this.temporaryCacheStorage.getItem(key);
|
|
10393
|
+
if (!stateValue) {
|
|
10394
|
+
return;
|
|
10395
|
+
}
|
|
10396
|
+
// Extract state and ensure it matches given InteractionType, then clean request cache
|
|
10397
|
+
var parsedState = BrowserProtocolUtils.extractBrowserRequestState(_this.cryptoImpl, stateValue);
|
|
10398
|
+
if (parsedState && parsedState.interactionType === interactionType) {
|
|
10399
|
+
_this.logger.infoPii("BrowserCacheManager.cleanRequestByInteractionType: Removing temporary cache items for state: " + stateValue);
|
|
10400
|
+
_this.resetRequestCache(stateValue);
|
|
10401
|
+
}
|
|
10402
|
+
});
|
|
10403
|
+
this.clearMsalCookies();
|
|
10404
|
+
};
|
|
10405
|
+
BrowserCacheManager.prototype.cacheCodeRequest = function (authCodeRequest, browserCrypto) {
|
|
10406
|
+
this.logger.trace("BrowserCacheManager.cacheCodeRequest called");
|
|
10407
|
+
var encodedValue = browserCrypto.base64Encode(JSON.stringify(authCodeRequest));
|
|
10408
|
+
this.setTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, encodedValue, true);
|
|
10209
10409
|
};
|
|
10210
10410
|
/**
|
|
10211
|
-
*
|
|
10212
|
-
* @param url
|
|
10213
|
-
* @param options
|
|
10411
|
+
* Gets the token exchange parameters from the cache. Throws an error if nothing is found.
|
|
10214
10412
|
*/
|
|
10215
|
-
|
|
10216
|
-
|
|
10413
|
+
BrowserCacheManager.prototype.getCachedRequest = function (state, browserCrypto) {
|
|
10414
|
+
this.logger.trace("BrowserCacheManager.getCachedRequest called");
|
|
10415
|
+
// Get token request from cache and parse as TokenExchangeParameters.
|
|
10416
|
+
var encodedTokenRequest = this.getTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, true);
|
|
10417
|
+
if (!encodedTokenRequest) {
|
|
10418
|
+
throw BrowserAuthError.createNoTokenRequestCacheError();
|
|
10419
|
+
}
|
|
10420
|
+
var parsedRequest = this.validateAndParseJson(browserCrypto.base64Decode(encodedTokenRequest));
|
|
10421
|
+
if (!parsedRequest) {
|
|
10422
|
+
throw BrowserAuthError.createUnableToParseTokenRequestCacheError();
|
|
10423
|
+
}
|
|
10424
|
+
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
|
|
10425
|
+
// Get cached authority and use if no authority is cached with request.
|
|
10426
|
+
if (StringUtils.isEmpty(parsedRequest.authority)) {
|
|
10427
|
+
var authorityCacheKey = this.generateAuthorityKey(state);
|
|
10428
|
+
var cachedAuthority = this.getTemporaryCache(authorityCacheKey);
|
|
10429
|
+
if (!cachedAuthority) {
|
|
10430
|
+
throw BrowserAuthError.createNoCachedAuthorityError();
|
|
10431
|
+
}
|
|
10432
|
+
parsedRequest.authority = cachedAuthority;
|
|
10433
|
+
}
|
|
10434
|
+
return parsedRequest;
|
|
10435
|
+
};
|
|
10436
|
+
BrowserCacheManager.prototype.isInteractionInProgress = function (matchClientId) {
|
|
10437
|
+
var clientId = this.getInteractionInProgress();
|
|
10438
|
+
if (matchClientId) {
|
|
10439
|
+
return clientId === this.clientId;
|
|
10440
|
+
}
|
|
10441
|
+
else {
|
|
10442
|
+
return !!clientId;
|
|
10443
|
+
}
|
|
10444
|
+
};
|
|
10445
|
+
BrowserCacheManager.prototype.getInteractionInProgress = function () {
|
|
10446
|
+
var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
|
|
10447
|
+
return this.getTemporaryCache(key, false);
|
|
10448
|
+
};
|
|
10449
|
+
BrowserCacheManager.prototype.setInteractionInProgress = function (inProgress) {
|
|
10450
|
+
var clientId = this.getInteractionInProgress();
|
|
10451
|
+
// Ensure we don't overwrite interaction in progress for a different clientId
|
|
10452
|
+
var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
|
|
10453
|
+
if (inProgress && !clientId) {
|
|
10454
|
+
// No interaction is in progress
|
|
10455
|
+
this.setTemporaryCache(key, this.clientId, false);
|
|
10456
|
+
}
|
|
10457
|
+
else if (!inProgress && clientId === this.clientId) {
|
|
10458
|
+
this.removeItem(key);
|
|
10459
|
+
}
|
|
10217
10460
|
};
|
|
10218
10461
|
/**
|
|
10219
|
-
*
|
|
10220
|
-
* @param url
|
|
10221
|
-
* @param options
|
|
10462
|
+
* Returns username retrieved from ADAL or MSAL v1 idToken
|
|
10222
10463
|
*/
|
|
10223
|
-
|
|
10224
|
-
if
|
|
10225
|
-
|
|
10464
|
+
BrowserCacheManager.prototype.getLegacyLoginHint = function () {
|
|
10465
|
+
// Only check for adal/msal token if no SSO params are being used
|
|
10466
|
+
var adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
10467
|
+
if (adalIdTokenString) {
|
|
10468
|
+
this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
10469
|
+
this.logger.verbose("Cached ADAL id token retrieved.");
|
|
10226
10470
|
}
|
|
10227
|
-
|
|
10228
|
-
|
|
10471
|
+
// Check for cached MSAL v1 id token
|
|
10472
|
+
var msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
|
|
10473
|
+
if (msalIdTokenString) {
|
|
10474
|
+
this.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
|
|
10475
|
+
this.logger.verbose("Cached MSAL.js v1 id token retrieved");
|
|
10229
10476
|
}
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10477
|
+
var cachedIdTokenString = msalIdTokenString || adalIdTokenString;
|
|
10478
|
+
if (cachedIdTokenString) {
|
|
10479
|
+
var cachedIdToken = new AuthToken(cachedIdTokenString, this.cryptoImpl);
|
|
10480
|
+
if (cachedIdToken.claims && cachedIdToken.claims.preferred_username) {
|
|
10481
|
+
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
|
|
10482
|
+
return cachedIdToken.claims.preferred_username;
|
|
10483
|
+
}
|
|
10484
|
+
else if (cachedIdToken.claims && cachedIdToken.claims.upn) {
|
|
10485
|
+
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
|
|
10486
|
+
return cachedIdToken.claims.upn;
|
|
10487
|
+
}
|
|
10488
|
+
else {
|
|
10489
|
+
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO.");
|
|
10490
|
+
}
|
|
10491
|
+
}
|
|
10492
|
+
return null;
|
|
10493
|
+
};
|
|
10494
|
+
/**
|
|
10495
|
+
* Updates a credential's cache key if the current cache key is outdated
|
|
10496
|
+
*/
|
|
10497
|
+
BrowserCacheManager.prototype.updateCredentialCacheKey = function (currentCacheKey, credential) {
|
|
10498
|
+
var updatedCacheKey = credential.generateCredentialKey();
|
|
10499
|
+
if (currentCacheKey !== updatedCacheKey) {
|
|
10500
|
+
var cacheItem = this.getItem(currentCacheKey);
|
|
10501
|
+
if (cacheItem) {
|
|
10502
|
+
this.removeItem(currentCacheKey);
|
|
10503
|
+
this.setItem(updatedCacheKey, cacheItem);
|
|
10504
|
+
this.logger.verbose("Updated an outdated " + credential.credentialType + " cache key");
|
|
10505
|
+
return updatedCacheKey;
|
|
10506
|
+
}
|
|
10507
|
+
else {
|
|
10508
|
+
this.logger.error("Attempted to update an outdated " + credential.credentialType + " cache key but no item matching the outdated key was found in storage");
|
|
10509
|
+
}
|
|
10510
|
+
}
|
|
10511
|
+
return currentCacheKey;
|
|
10235
10512
|
};
|
|
10236
|
-
return
|
|
10237
|
-
}());
|
|
10513
|
+
return BrowserCacheManager;
|
|
10514
|
+
}(CacheManager));
|
|
10515
|
+
var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
|
|
10516
|
+
var cacheOptions = {
|
|
10517
|
+
cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
10518
|
+
storeAuthStateInCookie: false,
|
|
10519
|
+
secureCookies: false
|
|
10520
|
+
};
|
|
10521
|
+
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
10522
|
+
};
|
|
10238
10523
|
|
|
10239
10524
|
/*
|
|
10240
10525
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10293,37 +10578,6 @@ function buildConfiguration(_a, isBrowserEnvironment) {
|
|
|
10293
10578
|
return overlayedConfig;
|
|
10294
10579
|
}
|
|
10295
10580
|
|
|
10296
|
-
/* eslint-disable header/header */
|
|
10297
|
-
var name = "@azure/msal-browser";
|
|
10298
|
-
var version = "2.19.0";
|
|
10299
|
-
|
|
10300
|
-
/*
|
|
10301
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10302
|
-
* Licensed under the MIT License.
|
|
10303
|
-
*/
|
|
10304
|
-
exports.EventType = void 0;
|
|
10305
|
-
(function (EventType) {
|
|
10306
|
-
EventType["ACCOUNT_ADDED"] = "msal:accountAdded";
|
|
10307
|
-
EventType["ACCOUNT_REMOVED"] = "msal:accountRemoved";
|
|
10308
|
-
EventType["LOGIN_START"] = "msal:loginStart";
|
|
10309
|
-
EventType["LOGIN_SUCCESS"] = "msal:loginSuccess";
|
|
10310
|
-
EventType["LOGIN_FAILURE"] = "msal:loginFailure";
|
|
10311
|
-
EventType["ACQUIRE_TOKEN_START"] = "msal:acquireTokenStart";
|
|
10312
|
-
EventType["ACQUIRE_TOKEN_SUCCESS"] = "msal:acquireTokenSuccess";
|
|
10313
|
-
EventType["ACQUIRE_TOKEN_FAILURE"] = "msal:acquireTokenFailure";
|
|
10314
|
-
EventType["ACQUIRE_TOKEN_NETWORK_START"] = "msal:acquireTokenFromNetworkStart";
|
|
10315
|
-
EventType["SSO_SILENT_START"] = "msal:ssoSilentStart";
|
|
10316
|
-
EventType["SSO_SILENT_SUCCESS"] = "msal:ssoSilentSuccess";
|
|
10317
|
-
EventType["SSO_SILENT_FAILURE"] = "msal:ssoSilentFailure";
|
|
10318
|
-
EventType["HANDLE_REDIRECT_START"] = "msal:handleRedirectStart";
|
|
10319
|
-
EventType["HANDLE_REDIRECT_END"] = "msal:handleRedirectEnd";
|
|
10320
|
-
EventType["POPUP_OPENED"] = "msal:popupOpened";
|
|
10321
|
-
EventType["LOGOUT_START"] = "msal:logoutStart";
|
|
10322
|
-
EventType["LOGOUT_SUCCESS"] = "msal:logoutSuccess";
|
|
10323
|
-
EventType["LOGOUT_FAILURE"] = "msal:logoutFailure";
|
|
10324
|
-
EventType["LOGOUT_END"] = "msal:logoutEnd";
|
|
10325
|
-
})(exports.EventType || (exports.EventType = {}));
|
|
10326
|
-
|
|
10327
10581
|
/*
|
|
10328
10582
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10329
10583
|
* Licensed under the MIT License.
|
|
@@ -12946,216 +13200,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
12946
13200
|
return PublicClientApplication;
|
|
12947
13201
|
}(ClientApplication));
|
|
12948
13202
|
|
|
12949
|
-
/*
|
|
12950
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12951
|
-
* Licensed under the MIT License.
|
|
12952
|
-
*/
|
|
12953
|
-
var stubbedPublicClientApplication = {
|
|
12954
|
-
acquireTokenPopup: function () {
|
|
12955
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12956
|
-
},
|
|
12957
|
-
acquireTokenRedirect: function () {
|
|
12958
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12959
|
-
},
|
|
12960
|
-
acquireTokenSilent: function () {
|
|
12961
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12962
|
-
},
|
|
12963
|
-
getAllAccounts: function () {
|
|
12964
|
-
return [];
|
|
12965
|
-
},
|
|
12966
|
-
getAccountByHomeId: function () {
|
|
12967
|
-
return null;
|
|
12968
|
-
},
|
|
12969
|
-
getAccountByUsername: function () {
|
|
12970
|
-
return null;
|
|
12971
|
-
},
|
|
12972
|
-
getAccountByLocalId: function () {
|
|
12973
|
-
return null;
|
|
12974
|
-
},
|
|
12975
|
-
handleRedirectPromise: function () {
|
|
12976
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12977
|
-
},
|
|
12978
|
-
loginPopup: function () {
|
|
12979
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12980
|
-
},
|
|
12981
|
-
loginRedirect: function () {
|
|
12982
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12983
|
-
},
|
|
12984
|
-
logout: function () {
|
|
12985
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12986
|
-
},
|
|
12987
|
-
logoutRedirect: function () {
|
|
12988
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12989
|
-
},
|
|
12990
|
-
logoutPopup: function () {
|
|
12991
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12992
|
-
},
|
|
12993
|
-
ssoSilent: function () {
|
|
12994
|
-
return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
|
|
12995
|
-
},
|
|
12996
|
-
addEventCallback: function () {
|
|
12997
|
-
return null;
|
|
12998
|
-
},
|
|
12999
|
-
removeEventCallback: function () {
|
|
13000
|
-
return;
|
|
13001
|
-
},
|
|
13002
|
-
enableAccountStorageEvents: function () {
|
|
13003
|
-
return;
|
|
13004
|
-
},
|
|
13005
|
-
disableAccountStorageEvents: function () {
|
|
13006
|
-
return;
|
|
13007
|
-
},
|
|
13008
|
-
getTokenCache: function () {
|
|
13009
|
-
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
13010
|
-
},
|
|
13011
|
-
getLogger: function () {
|
|
13012
|
-
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
13013
|
-
},
|
|
13014
|
-
setLogger: function () {
|
|
13015
|
-
return;
|
|
13016
|
-
},
|
|
13017
|
-
setActiveAccount: function () {
|
|
13018
|
-
return;
|
|
13019
|
-
},
|
|
13020
|
-
getActiveAccount: function () {
|
|
13021
|
-
return null;
|
|
13022
|
-
},
|
|
13023
|
-
initializeWrapperLibrary: function () {
|
|
13024
|
-
return;
|
|
13025
|
-
},
|
|
13026
|
-
setNavigationClient: function () {
|
|
13027
|
-
return;
|
|
13028
|
-
},
|
|
13029
|
-
getConfiguration: function () {
|
|
13030
|
-
throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
|
|
13031
|
-
}
|
|
13032
|
-
};
|
|
13033
|
-
|
|
13034
|
-
/*
|
|
13035
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13036
|
-
* Licensed under the MIT License.
|
|
13037
|
-
*/
|
|
13038
|
-
var EventMessageUtils = /** @class */ (function () {
|
|
13039
|
-
function EventMessageUtils() {
|
|
13040
|
-
}
|
|
13041
|
-
/**
|
|
13042
|
-
* Gets interaction status from event message
|
|
13043
|
-
* @param message
|
|
13044
|
-
* @param currentStatus
|
|
13045
|
-
*/
|
|
13046
|
-
EventMessageUtils.getInteractionStatusFromEvent = function (message, currentStatus) {
|
|
13047
|
-
switch (message.eventType) {
|
|
13048
|
-
case exports.EventType.LOGIN_START:
|
|
13049
|
-
return exports.InteractionStatus.Login;
|
|
13050
|
-
case exports.EventType.SSO_SILENT_START:
|
|
13051
|
-
return exports.InteractionStatus.SsoSilent;
|
|
13052
|
-
case exports.EventType.ACQUIRE_TOKEN_START:
|
|
13053
|
-
if (message.interactionType === exports.InteractionType.Redirect || message.interactionType === exports.InteractionType.Popup) {
|
|
13054
|
-
return exports.InteractionStatus.AcquireToken;
|
|
13055
|
-
}
|
|
13056
|
-
break;
|
|
13057
|
-
case exports.EventType.HANDLE_REDIRECT_START:
|
|
13058
|
-
return exports.InteractionStatus.HandleRedirect;
|
|
13059
|
-
case exports.EventType.LOGOUT_START:
|
|
13060
|
-
return exports.InteractionStatus.Logout;
|
|
13061
|
-
case exports.EventType.SSO_SILENT_SUCCESS:
|
|
13062
|
-
case exports.EventType.SSO_SILENT_FAILURE:
|
|
13063
|
-
if (currentStatus && currentStatus !== exports.InteractionStatus.SsoSilent) {
|
|
13064
|
-
// Prevent this event from clearing any status other than ssoSilent
|
|
13065
|
-
break;
|
|
13066
|
-
}
|
|
13067
|
-
return exports.InteractionStatus.None;
|
|
13068
|
-
case exports.EventType.LOGOUT_END:
|
|
13069
|
-
if (currentStatus && currentStatus !== exports.InteractionStatus.Logout) {
|
|
13070
|
-
// Prevent this event from clearing any status other than logout
|
|
13071
|
-
break;
|
|
13072
|
-
}
|
|
13073
|
-
return exports.InteractionStatus.None;
|
|
13074
|
-
case exports.EventType.HANDLE_REDIRECT_END:
|
|
13075
|
-
if (currentStatus && currentStatus !== exports.InteractionStatus.HandleRedirect) {
|
|
13076
|
-
// Prevent this event from clearing any status other than handleRedirect
|
|
13077
|
-
break;
|
|
13078
|
-
}
|
|
13079
|
-
return exports.InteractionStatus.None;
|
|
13080
|
-
case exports.EventType.LOGIN_SUCCESS:
|
|
13081
|
-
case exports.EventType.LOGIN_FAILURE:
|
|
13082
|
-
case exports.EventType.ACQUIRE_TOKEN_SUCCESS:
|
|
13083
|
-
case exports.EventType.ACQUIRE_TOKEN_FAILURE:
|
|
13084
|
-
if (message.interactionType === exports.InteractionType.Redirect || message.interactionType === exports.InteractionType.Popup) {
|
|
13085
|
-
if (currentStatus && currentStatus !== exports.InteractionStatus.Login && currentStatus !== exports.InteractionStatus.AcquireToken) {
|
|
13086
|
-
// Prevent this event from clearing any status other than login or acquireToken
|
|
13087
|
-
break;
|
|
13088
|
-
}
|
|
13089
|
-
return exports.InteractionStatus.None;
|
|
13090
|
-
}
|
|
13091
|
-
break;
|
|
13092
|
-
}
|
|
13093
|
-
return null;
|
|
13094
|
-
};
|
|
13095
|
-
return EventMessageUtils;
|
|
13096
|
-
}());
|
|
13097
|
-
|
|
13098
|
-
/*
|
|
13099
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13100
|
-
* Licensed under the MIT License.
|
|
13101
|
-
*/
|
|
13102
|
-
var SignedHttpRequest = /** @class */ (function () {
|
|
13103
|
-
function SignedHttpRequest(shrParameters, shrOptions) {
|
|
13104
|
-
var loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};
|
|
13105
|
-
this.logger = new Logger(loggerOptions, name, version);
|
|
13106
|
-
this.cryptoOps = new CryptoOps(this.logger);
|
|
13107
|
-
this.popTokenGenerator = new PopTokenGenerator(this.cryptoOps);
|
|
13108
|
-
this.shrParameters = shrParameters;
|
|
13109
|
-
}
|
|
13110
|
-
/**
|
|
13111
|
-
* Generates and caches a keypair for the given request options.
|
|
13112
|
-
* @returns Public key digest, which should be sent to the token issuer.
|
|
13113
|
-
*/
|
|
13114
|
-
SignedHttpRequest.prototype.generatePublicKeyThumbprint = function () {
|
|
13115
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
13116
|
-
var kid;
|
|
13117
|
-
return __generator$1(this, function (_a) {
|
|
13118
|
-
switch (_a.label) {
|
|
13119
|
-
case 0: return [4 /*yield*/, this.popTokenGenerator.generateKid(this.shrParameters)];
|
|
13120
|
-
case 1:
|
|
13121
|
-
kid = (_a.sent()).kid;
|
|
13122
|
-
return [2 /*return*/, kid];
|
|
13123
|
-
}
|
|
13124
|
-
});
|
|
13125
|
-
});
|
|
13126
|
-
};
|
|
13127
|
-
/**
|
|
13128
|
-
* Generates a signed http request for the given payload with the given key.
|
|
13129
|
-
* @param payload Payload to sign (e.g. access token)
|
|
13130
|
-
* @param publicKeyThumbprint Public key digest (from generatePublicKeyThumbprint API)
|
|
13131
|
-
* @param claims Additional claims to include/override in the signed JWT
|
|
13132
|
-
* @returns Pop token signed with the corresponding private key
|
|
13133
|
-
*/
|
|
13134
|
-
SignedHttpRequest.prototype.signRequest = function (payload, publicKeyThumbprint, claims) {
|
|
13135
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
13136
|
-
return __generator$1(this, function (_a) {
|
|
13137
|
-
return [2 /*return*/, this.popTokenGenerator.signPayload(payload, publicKeyThumbprint, this.shrParameters, claims)];
|
|
13138
|
-
});
|
|
13139
|
-
});
|
|
13140
|
-
};
|
|
13141
|
-
/**
|
|
13142
|
-
* Removes cached keys from browser for given public key thumbprint
|
|
13143
|
-
* @param publicKeyThumbprint Public key digest (from generatePublicKeyThumbprint API)
|
|
13144
|
-
* @returns If keys are properly deleted
|
|
13145
|
-
*/
|
|
13146
|
-
SignedHttpRequest.prototype.removeKeys = function (publicKeyThumbprint) {
|
|
13147
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
13148
|
-
return __generator$1(this, function (_a) {
|
|
13149
|
-
switch (_a.label) {
|
|
13150
|
-
case 0: return [4 /*yield*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
|
|
13151
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
13152
|
-
}
|
|
13153
|
-
});
|
|
13154
|
-
});
|
|
13155
|
-
};
|
|
13156
|
-
return SignedHttpRequest;
|
|
13157
|
-
}());
|
|
13158
|
-
|
|
13159
13203
|
exports.AccountEntity = AccountEntity;
|
|
13160
13204
|
exports.AuthError = AuthError;
|
|
13161
13205
|
exports.AuthErrorMessage = AuthErrorMessage;
|