@azure/msal-browser 4.0.0-alpha.0 → 4.0.2
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/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +4 -2
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.mjs +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +8 -8
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeResponse.d.ts +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AccountManager.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +10 -15
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +42 -43
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/CacheHelpers.mjs +1 -1
- package/dist/cache/CookieStorage.mjs +1 -1
- package/dist/cache/CookieStorage.mjs.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/IWindowStorage.d.ts +2 -2
- package/dist/cache/IWindowStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.d.ts +7 -3
- package/dist/cache/LocalStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.mjs +48 -34
- package/dist/cache/LocalStorage.mjs.map +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/SessionStorage.mjs +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +15 -14
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +2 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +5 -5
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +6 -3
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +34 -18
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts +2 -2
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +27 -23
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +1 -1
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +3 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +3 -3
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthError.mjs.map +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.mjs +1 -1
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +2 -3
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +11 -9
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +4 -4
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +2 -2
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +2 -2
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.mjs +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +1 -1
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/RequestHelpers.mjs +1 -1
- package/dist/request/SsoSilentRequest.d.ts +1 -1
- package/dist/request/SsoSilentRequest.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +4 -2
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +298 -249
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +298 -249
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +63 -63
- package/lib/types/app/PublicClientApplication.d.ts.map +1 -1
- package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
- package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
- package/lib/types/cache/BrowserCacheManager.d.ts +10 -15
- package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/lib/types/cache/IWindowStorage.d.ts +2 -2
- package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
- package/lib/types/cache/LocalStorage.d.ts +7 -3
- package/lib/types/cache/LocalStorage.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts.map +1 -1
- package/lib/types/config/Configuration.d.ts +2 -2
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts +6 -3
- package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/lib/types/controllers/StandardController.d.ts +2 -2
- package/lib/types/controllers/StandardController.d.ts.map +1 -1
- package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
- package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
- package/lib/types/crypto/CryptoOps.d.ts +1 -1
- package/lib/types/crypto/CryptoOps.d.ts.map +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts +2 -3
- package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/packageMetadata.d.ts.map +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/lib/types/request/PopupRequest.d.ts +1 -1
- package/lib/types/request/PopupRequest.d.ts.map +1 -1
- package/lib/types/request/RedirectRequest.d.ts +1 -1
- package/lib/types/request/RedirectRequest.d.ts.map +1 -1
- package/lib/types/request/SsoSilentRequest.d.ts +1 -1
- package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
- package/lib/types/utils/BrowserUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +6 -1
- package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
- package/src/broker/nativeBroker/NativeResponse.ts +1 -1
- package/src/cache/BrowserCacheManager.ts +88 -57
- package/src/cache/IWindowStorage.ts +2 -2
- package/src/cache/LocalStorage.ts +142 -43
- package/src/cache/TokenCache.ts +28 -11
- package/src/config/Configuration.ts +6 -6
- package/src/controllers/NestedAppAuthController.ts +51 -23
- package/src/controllers/StandardController.ts +41 -24
- package/src/controllers/UnknownOperatingContextController.ts +6 -5
- package/src/crypto/BrowserCrypto.ts +4 -2
- package/src/crypto/CryptoOps.ts +8 -2
- package/src/interaction_client/NativeInteractionClient.ts +16 -16
- package/src/interaction_client/PopupClient.ts +9 -8
- package/src/interaction_client/RedirectClient.ts +1 -1
- package/src/interaction_client/SilentIframeClient.ts +1 -1
- package/src/packageMetadata.ts +1 -1
- package/src/request/AuthorizationUrlRequest.ts +1 -1
- package/src/request/PopupRequest.ts +1 -1
- package/src/request/RedirectRequest.ts +1 -1
- package/src/request/SsoSilentRequest.ts +1 -1
- package/src/utils/BrowserUtils.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SsoSilentRequest.d.ts","sourceRoot":"","sources":["../../../src/request/SsoSilentRequest.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,6BAA6B,EAC7B,UAAU,EACb,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAClC,IAAI,CACA,6BAA6B,EAC3B,cAAc,GACd,eAAe,GACf,qBAAqB,GACrB,qBAAqB,GACrB,
|
|
1
|
+
{"version":3,"file":"SsoSilentRequest.d.ts","sourceRoot":"","sources":["../../../src/request/SsoSilentRequest.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,6BAA6B,EAC7B,UAAU,EACb,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAClC,IAAI,CACA,6BAA6B,EAC3B,cAAc,GACd,eAAe,GACf,qBAAqB,GACrB,qBAAqB,GACrB,gBAAgB,CACrB,CACJ,GAAG;IACA,mBAAmB,CAAC,EAAE,UAAU,CAAC;CACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/BrowserUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,MAAM,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAW5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAWrD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI7C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAQnC;AAID;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"BrowserUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/BrowserUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,MAAM,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAW5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAWrD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI7C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAQnC;AAID;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAIpC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAQjD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,OAAO,GAAG,IAAI,CAK1E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAKhD;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAMjD;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAMxE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAYzD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAClC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,oBAAoB,GAC7B,IAAI,CAYN;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAalD;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
|
|
12
12
|
},
|
|
13
|
-
"version": "4.0.
|
|
13
|
+
"version": "4.0.2",
|
|
14
14
|
"description": "Microsoft Authentication Library for js",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"implicit",
|
|
@@ -103,6 +103,6 @@
|
|
|
103
103
|
"typescript": "^4.9.5"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@azure/msal-common": "15.0.
|
|
106
|
+
"@azure/msal-common": "15.0.2"
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -446,7 +446,12 @@ export async function createNestablePublicClientApplication(
|
|
|
446
446
|
|
|
447
447
|
if (nestedAppAuth.isAvailable()) {
|
|
448
448
|
const controller = new NestedAppAuthController(nestedAppAuth);
|
|
449
|
-
|
|
449
|
+
const nestablePCA = new PublicClientApplication(
|
|
450
|
+
configuration,
|
|
451
|
+
controller
|
|
452
|
+
);
|
|
453
|
+
await nestablePCA.initialize();
|
|
454
|
+
return nestablePCA;
|
|
450
455
|
}
|
|
451
456
|
|
|
452
457
|
return createStandardPublicClientApplication(configuration);
|
|
@@ -372,16 +372,16 @@ export class NativeMessageHandler {
|
|
|
372
372
|
* @param nativeExtensionProvider
|
|
373
373
|
* @param authenticationScheme
|
|
374
374
|
*/
|
|
375
|
-
static
|
|
375
|
+
static isPlatformBrokerAvailable(
|
|
376
376
|
config: BrowserConfiguration,
|
|
377
377
|
logger: Logger,
|
|
378
378
|
nativeExtensionProvider?: NativeMessageHandler,
|
|
379
379
|
authenticationScheme?: AuthenticationScheme
|
|
380
380
|
): boolean {
|
|
381
|
-
logger.trace("
|
|
382
|
-
if (!config.system.
|
|
381
|
+
logger.trace("isPlatformBrokerAvailable called");
|
|
382
|
+
if (!config.system.allowPlatformBroker) {
|
|
383
383
|
logger.trace(
|
|
384
|
-
"
|
|
384
|
+
"isPlatformBrokerAvailable: allowPlatformBroker is not enabled, returning false"
|
|
385
385
|
);
|
|
386
386
|
// Developer disabled WAM
|
|
387
387
|
return false;
|
|
@@ -389,7 +389,7 @@ export class NativeMessageHandler {
|
|
|
389
389
|
|
|
390
390
|
if (!nativeExtensionProvider) {
|
|
391
391
|
logger.trace(
|
|
392
|
-
"
|
|
392
|
+
"isPlatformBrokerAvailable: Platform extension provider is not initialized, returning false"
|
|
393
393
|
);
|
|
394
394
|
// Extension is not available
|
|
395
395
|
return false;
|
|
@@ -400,12 +400,12 @@ export class NativeMessageHandler {
|
|
|
400
400
|
case AuthenticationScheme.BEARER:
|
|
401
401
|
case AuthenticationScheme.POP:
|
|
402
402
|
logger.trace(
|
|
403
|
-
"
|
|
403
|
+
"isPlatformBrokerAvailable: authenticationScheme is supported, returning true"
|
|
404
404
|
);
|
|
405
405
|
return true;
|
|
406
406
|
default:
|
|
407
407
|
logger.trace(
|
|
408
|
-
"
|
|
408
|
+
"isPlatformBrokerAvailable: authenticationScheme is not supported, returning false"
|
|
409
409
|
);
|
|
410
410
|
return false;
|
|
411
411
|
}
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
CacheHelpers,
|
|
38
38
|
StoreInCache,
|
|
39
39
|
CacheError,
|
|
40
|
+
invokeAsync,
|
|
40
41
|
} from "@azure/msal-common/browser";
|
|
41
42
|
import { CacheOptions } from "../config/Configuration.js";
|
|
42
43
|
import {
|
|
@@ -85,57 +86,39 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
85
86
|
// Logger instance
|
|
86
87
|
protected logger: Logger;
|
|
87
88
|
// Telemetry perf client
|
|
88
|
-
protected performanceClient
|
|
89
|
+
protected performanceClient: IPerformanceClient;
|
|
89
90
|
|
|
90
91
|
constructor(
|
|
91
92
|
clientId: string,
|
|
92
93
|
cacheConfig: Required<CacheOptions>,
|
|
93
94
|
cryptoImpl: ICrypto,
|
|
94
95
|
logger: Logger,
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
performanceClient: IPerformanceClient,
|
|
97
|
+
staticAuthorityOptions?: StaticAuthorityOptions
|
|
97
98
|
) {
|
|
98
99
|
super(clientId, cryptoImpl, logger, staticAuthorityOptions);
|
|
99
100
|
this.cacheConfig = cacheConfig;
|
|
100
101
|
this.logger = logger;
|
|
101
102
|
this.internalStorage = new MemoryStorage();
|
|
102
|
-
this.browserStorage =
|
|
103
|
-
|
|
103
|
+
this.browserStorage = getStorageImplementation(
|
|
104
|
+
clientId,
|
|
105
|
+
cacheConfig.cacheLocation,
|
|
106
|
+
logger,
|
|
107
|
+
performanceClient
|
|
104
108
|
);
|
|
105
|
-
this.temporaryCacheStorage =
|
|
106
|
-
|
|
109
|
+
this.temporaryCacheStorage = getStorageImplementation(
|
|
110
|
+
clientId,
|
|
111
|
+
cacheConfig.temporaryCacheLocation,
|
|
112
|
+
logger,
|
|
113
|
+
performanceClient
|
|
107
114
|
);
|
|
108
115
|
this.cookieStorage = new CookieStorage();
|
|
109
116
|
|
|
110
117
|
this.performanceClient = performanceClient;
|
|
111
118
|
}
|
|
112
119
|
|
|
113
|
-
async initialize(): Promise<void> {
|
|
114
|
-
await this.browserStorage.initialize();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
|
|
119
|
-
* @param cacheLocation
|
|
120
|
-
*/
|
|
121
|
-
protected setupBrowserStorage(
|
|
122
|
-
cacheLocation: BrowserCacheLocation | string
|
|
123
|
-
): IWindowStorage<string> {
|
|
124
|
-
try {
|
|
125
|
-
switch (cacheLocation) {
|
|
126
|
-
case BrowserCacheLocation.LocalStorage:
|
|
127
|
-
return new LocalStorage(this.clientId);
|
|
128
|
-
case BrowserCacheLocation.SessionStorage:
|
|
129
|
-
return new SessionStorage();
|
|
130
|
-
case BrowserCacheLocation.MemoryStorage:
|
|
131
|
-
default:
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
} catch (e) {
|
|
135
|
-
this.logger.error(e as string);
|
|
136
|
-
}
|
|
137
|
-
this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
|
|
138
|
-
return new MemoryStorage();
|
|
120
|
+
async initialize(correlationId: string): Promise<void> {
|
|
121
|
+
await this.browserStorage.initialize(correlationId);
|
|
139
122
|
}
|
|
140
123
|
|
|
141
124
|
/**
|
|
@@ -189,10 +172,18 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
189
172
|
* set account entity in the platform cache
|
|
190
173
|
* @param account
|
|
191
174
|
*/
|
|
192
|
-
async setAccount(
|
|
175
|
+
async setAccount(
|
|
176
|
+
account: AccountEntity,
|
|
177
|
+
correlationId: string
|
|
178
|
+
): Promise<void> {
|
|
193
179
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
194
180
|
const key = account.generateAccountKey();
|
|
195
|
-
await
|
|
181
|
+
await invokeAsync(
|
|
182
|
+
this.browserStorage.setUserData.bind(this.browserStorage),
|
|
183
|
+
PerformanceEvents.SetUserData,
|
|
184
|
+
this.logger,
|
|
185
|
+
this.performanceClient
|
|
186
|
+
)(key, JSON.stringify(account), correlationId);
|
|
196
187
|
this.addAccountKeyToMap(key);
|
|
197
188
|
}
|
|
198
189
|
|
|
@@ -457,14 +448,19 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
457
448
|
* set IdToken credential to the platform cache
|
|
458
449
|
* @param idToken
|
|
459
450
|
*/
|
|
460
|
-
async setIdTokenCredential(
|
|
451
|
+
async setIdTokenCredential(
|
|
452
|
+
idToken: IdTokenEntity,
|
|
453
|
+
correlationId: string
|
|
454
|
+
): Promise<void> {
|
|
461
455
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
462
456
|
const idTokenKey = CacheHelpers.generateCredentialKey(idToken);
|
|
463
457
|
|
|
464
|
-
await
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
458
|
+
await invokeAsync(
|
|
459
|
+
this.browserStorage.setUserData.bind(this.browserStorage),
|
|
460
|
+
PerformanceEvents.SetUserData,
|
|
461
|
+
this.logger,
|
|
462
|
+
this.performanceClient
|
|
463
|
+
)(idTokenKey, JSON.stringify(idToken), correlationId);
|
|
468
464
|
|
|
469
465
|
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
470
466
|
}
|
|
@@ -505,16 +501,19 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
505
501
|
* @param accessToken
|
|
506
502
|
*/
|
|
507
503
|
async setAccessTokenCredential(
|
|
508
|
-
accessToken: AccessTokenEntity
|
|
504
|
+
accessToken: AccessTokenEntity,
|
|
505
|
+
correlationId: string
|
|
509
506
|
): Promise<void> {
|
|
510
507
|
this.logger.trace(
|
|
511
508
|
"BrowserCacheManager.setAccessTokenCredential called"
|
|
512
509
|
);
|
|
513
510
|
const accessTokenKey = CacheHelpers.generateCredentialKey(accessToken);
|
|
514
|
-
await
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
511
|
+
await invokeAsync(
|
|
512
|
+
this.browserStorage.setUserData.bind(this.browserStorage),
|
|
513
|
+
PerformanceEvents.SetUserData,
|
|
514
|
+
this.logger,
|
|
515
|
+
this.performanceClient
|
|
516
|
+
)(accessTokenKey, JSON.stringify(accessToken), correlationId);
|
|
518
517
|
|
|
519
518
|
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
520
519
|
}
|
|
@@ -557,17 +556,20 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
557
556
|
* @param refreshToken
|
|
558
557
|
*/
|
|
559
558
|
async setRefreshTokenCredential(
|
|
560
|
-
refreshToken: RefreshTokenEntity
|
|
559
|
+
refreshToken: RefreshTokenEntity,
|
|
560
|
+
correlationId: string
|
|
561
561
|
): Promise<void> {
|
|
562
562
|
this.logger.trace(
|
|
563
563
|
"BrowserCacheManager.setRefreshTokenCredential called"
|
|
564
564
|
);
|
|
565
565
|
const refreshTokenKey =
|
|
566
566
|
CacheHelpers.generateCredentialKey(refreshToken);
|
|
567
|
-
await
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
567
|
+
await invokeAsync(
|
|
568
|
+
this.browserStorage.setUserData.bind(this.browserStorage),
|
|
569
|
+
PerformanceEvents.SetUserData,
|
|
570
|
+
this.logger,
|
|
571
|
+
this.performanceClient
|
|
572
|
+
)(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
|
|
571
573
|
|
|
572
574
|
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
573
575
|
}
|
|
@@ -1404,7 +1406,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1404
1406
|
idToken: idTokenEntity,
|
|
1405
1407
|
accessToken: accessTokenEntity,
|
|
1406
1408
|
};
|
|
1407
|
-
return this.saveCacheRecord(cacheRecord);
|
|
1409
|
+
return this.saveCacheRecord(cacheRecord, result.correlationId);
|
|
1408
1410
|
}
|
|
1409
1411
|
|
|
1410
1412
|
/**
|
|
@@ -1415,14 +1417,14 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1415
1417
|
*/
|
|
1416
1418
|
async saveCacheRecord(
|
|
1417
1419
|
cacheRecord: CacheRecord,
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
+
correlationId: string,
|
|
1421
|
+
storeInCache?: StoreInCache
|
|
1420
1422
|
): Promise<void> {
|
|
1421
1423
|
try {
|
|
1422
1424
|
await super.saveCacheRecord(
|
|
1423
1425
|
cacheRecord,
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
+
correlationId,
|
|
1427
|
+
storeInCache
|
|
1426
1428
|
);
|
|
1427
1429
|
} catch (e) {
|
|
1428
1430
|
if (
|
|
@@ -1449,9 +1451,37 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1449
1451
|
}
|
|
1450
1452
|
}
|
|
1451
1453
|
|
|
1454
|
+
/**
|
|
1455
|
+
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
|
|
1456
|
+
* @param cacheLocation
|
|
1457
|
+
*/
|
|
1458
|
+
function getStorageImplementation(
|
|
1459
|
+
clientId: string,
|
|
1460
|
+
cacheLocation: BrowserCacheLocation | string,
|
|
1461
|
+
logger: Logger,
|
|
1462
|
+
performanceClient: IPerformanceClient
|
|
1463
|
+
): IWindowStorage<string> {
|
|
1464
|
+
try {
|
|
1465
|
+
switch (cacheLocation) {
|
|
1466
|
+
case BrowserCacheLocation.LocalStorage:
|
|
1467
|
+
return new LocalStorage(clientId, logger, performanceClient);
|
|
1468
|
+
case BrowserCacheLocation.SessionStorage:
|
|
1469
|
+
return new SessionStorage();
|
|
1470
|
+
case BrowserCacheLocation.MemoryStorage:
|
|
1471
|
+
default:
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
1474
|
+
} catch (e) {
|
|
1475
|
+
logger.error(e as string);
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
return new MemoryStorage();
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1452
1481
|
export const DEFAULT_BROWSER_CACHE_MANAGER = (
|
|
1453
1482
|
clientId: string,
|
|
1454
|
-
logger: Logger
|
|
1483
|
+
logger: Logger,
|
|
1484
|
+
performanceClient: IPerformanceClient
|
|
1455
1485
|
): BrowserCacheManager => {
|
|
1456
1486
|
const cacheOptions: Required<CacheOptions> = {
|
|
1457
1487
|
cacheLocation: BrowserCacheLocation.MemoryStorage,
|
|
@@ -1465,6 +1495,7 @@ export const DEFAULT_BROWSER_CACHE_MANAGER = (
|
|
|
1465
1495
|
clientId,
|
|
1466
1496
|
cacheOptions,
|
|
1467
1497
|
DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
1468
|
-
logger
|
|
1498
|
+
logger,
|
|
1499
|
+
performanceClient
|
|
1469
1500
|
);
|
|
1470
1501
|
};
|
|
@@ -7,7 +7,7 @@ export interface IWindowStorage<T> {
|
|
|
7
7
|
/**
|
|
8
8
|
* Async initializer
|
|
9
9
|
*/
|
|
10
|
-
initialize(): Promise<void>;
|
|
10
|
+
initialize(correlationId: string): Promise<void>;
|
|
11
11
|
/**
|
|
12
12
|
* Get the item from the window storage object matching the given key.
|
|
13
13
|
* @param key
|
|
@@ -29,7 +29,7 @@ export interface IWindowStorage<T> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Setter for sensitive data that may contain PII.
|
|
31
31
|
*/
|
|
32
|
-
setUserData(key: string, value: T): Promise<void>;
|
|
32
|
+
setUserData(key: string, value: T, correlationId: string): Promise<void>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Removes the item in the window storage object matching the given key.
|
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Constants,
|
|
8
|
+
TokenKeys,
|
|
9
|
+
IPerformanceClient,
|
|
10
|
+
invokeAsync,
|
|
11
|
+
PerformanceEvents,
|
|
12
|
+
Logger,
|
|
13
|
+
invoke,
|
|
14
|
+
} from "@azure/msal-common/browser";
|
|
7
15
|
import {
|
|
8
16
|
createNewGuid,
|
|
9
17
|
decrypt,
|
|
@@ -25,6 +33,7 @@ import { CookieStorage } from "./CookieStorage.js";
|
|
|
25
33
|
import { IWindowStorage } from "./IWindowStorage.js";
|
|
26
34
|
import { MemoryStorage } from "./MemoryStorage.js";
|
|
27
35
|
import { getAccountKeys, getTokenKeys } from "./CacheHelpers.js";
|
|
36
|
+
import { StaticCacheKeys } from "../utils/BrowserConstants.js";
|
|
28
37
|
|
|
29
38
|
const ENCRYPTION_KEY = "msal.cache.encryption";
|
|
30
39
|
|
|
@@ -43,9 +52,15 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
43
52
|
private clientId: string;
|
|
44
53
|
private initialized: boolean;
|
|
45
54
|
private memoryStorage: MemoryStorage<string>;
|
|
55
|
+
private performanceClient: IPerformanceClient;
|
|
56
|
+
private logger: Logger;
|
|
46
57
|
private encryptionCookie?: EncryptionCookie;
|
|
47
58
|
|
|
48
|
-
constructor(
|
|
59
|
+
constructor(
|
|
60
|
+
clientId: string,
|
|
61
|
+
logger: Logger,
|
|
62
|
+
performanceClient: IPerformanceClient
|
|
63
|
+
) {
|
|
49
64
|
if (!window.localStorage) {
|
|
50
65
|
throw createBrowserConfigurationAuthError(
|
|
51
66
|
BrowserConfigurationAuthErrorCodes.storageNotSupported
|
|
@@ -54,9 +69,11 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
54
69
|
this.memoryStorage = new MemoryStorage<string>();
|
|
55
70
|
this.initialized = false;
|
|
56
71
|
this.clientId = clientId;
|
|
72
|
+
this.logger = logger;
|
|
73
|
+
this.performanceClient = performanceClient;
|
|
57
74
|
}
|
|
58
75
|
|
|
59
|
-
async initialize(): Promise<void> {
|
|
76
|
+
async initialize(correlationId: string): Promise<void> {
|
|
60
77
|
this.initialized = true;
|
|
61
78
|
|
|
62
79
|
const cookies = new CookieStorage();
|
|
@@ -65,26 +82,61 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
65
82
|
if (cookieString) {
|
|
66
83
|
try {
|
|
67
84
|
parsedCookie = JSON.parse(cookieString);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
// TODO: Log telemetry but don't throw
|
|
70
|
-
}
|
|
85
|
+
} catch (e) {}
|
|
71
86
|
}
|
|
72
87
|
if (parsedCookie.key && parsedCookie.id) {
|
|
73
88
|
// Encryption key already exists, import
|
|
89
|
+
const baseKey = invoke(
|
|
90
|
+
base64DecToArr,
|
|
91
|
+
PerformanceEvents.Base64Decode,
|
|
92
|
+
this.logger,
|
|
93
|
+
this.performanceClient,
|
|
94
|
+
correlationId
|
|
95
|
+
)(parsedCookie.key);
|
|
74
96
|
this.encryptionCookie = {
|
|
75
97
|
id: parsedCookie.id,
|
|
76
|
-
key: await
|
|
98
|
+
key: await invokeAsync(
|
|
99
|
+
generateHKDF,
|
|
100
|
+
PerformanceEvents.GenerateHKDF,
|
|
101
|
+
this.logger,
|
|
102
|
+
this.performanceClient,
|
|
103
|
+
correlationId
|
|
104
|
+
)(baseKey),
|
|
77
105
|
};
|
|
78
|
-
await
|
|
106
|
+
await invokeAsync(
|
|
107
|
+
this.importExistingCache.bind(this),
|
|
108
|
+
PerformanceEvents.ImportExistingCache,
|
|
109
|
+
this.logger,
|
|
110
|
+
this.performanceClient,
|
|
111
|
+
correlationId
|
|
112
|
+
)(correlationId);
|
|
79
113
|
} else {
|
|
80
114
|
// Encryption key doesn't exist or is invalid, generate a new one and clear existing cache
|
|
81
115
|
this.clear();
|
|
82
116
|
const id = createNewGuid();
|
|
83
|
-
const baseKey = await
|
|
84
|
-
|
|
117
|
+
const baseKey = await invokeAsync(
|
|
118
|
+
generateBaseKey,
|
|
119
|
+
PerformanceEvents.GenerateBaseKey,
|
|
120
|
+
this.logger,
|
|
121
|
+
this.performanceClient,
|
|
122
|
+
correlationId
|
|
123
|
+
)();
|
|
124
|
+
const keyStr = invoke(
|
|
125
|
+
urlEncodeArr,
|
|
126
|
+
PerformanceEvents.UrlEncodeArr,
|
|
127
|
+
this.logger,
|
|
128
|
+
this.performanceClient,
|
|
129
|
+
correlationId
|
|
130
|
+
)(new Uint8Array(baseKey));
|
|
85
131
|
this.encryptionCookie = {
|
|
86
132
|
id: id,
|
|
87
|
-
key: await
|
|
133
|
+
key: await invokeAsync(
|
|
134
|
+
generateHKDF,
|
|
135
|
+
PerformanceEvents.GenerateHKDF,
|
|
136
|
+
this.logger,
|
|
137
|
+
this.performanceClient,
|
|
138
|
+
correlationId
|
|
139
|
+
)(baseKey),
|
|
88
140
|
};
|
|
89
141
|
|
|
90
142
|
const cookieData = {
|
|
@@ -112,18 +164,24 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
112
164
|
window.localStorage.setItem(key, value);
|
|
113
165
|
}
|
|
114
166
|
|
|
115
|
-
async setUserData(
|
|
167
|
+
async setUserData(
|
|
168
|
+
key: string,
|
|
169
|
+
value: string,
|
|
170
|
+
correlationId: string
|
|
171
|
+
): Promise<void> {
|
|
116
172
|
if (!this.initialized || !this.encryptionCookie) {
|
|
117
173
|
throw createBrowserAuthError(
|
|
118
174
|
BrowserAuthErrorCodes.uninitializedPublicClientApplication
|
|
119
175
|
);
|
|
120
176
|
}
|
|
121
177
|
|
|
122
|
-
const { data, nonce } = await
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.
|
|
126
|
-
|
|
178
|
+
const { data, nonce } = await invokeAsync(
|
|
179
|
+
encrypt,
|
|
180
|
+
PerformanceEvents.Encrypt,
|
|
181
|
+
this.logger,
|
|
182
|
+
this.performanceClient,
|
|
183
|
+
correlationId
|
|
184
|
+
)(this.encryptionCookie.key, value, this.getContext(key));
|
|
127
185
|
const encryptedData: EncryptedData = {
|
|
128
186
|
id: this.encryptionCookie.id,
|
|
129
187
|
nonce: nonce,
|
|
@@ -176,20 +234,34 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
176
234
|
* Helper to decrypt all known MSAL keys in localStorage and save them to inMemory storage
|
|
177
235
|
* @returns
|
|
178
236
|
*/
|
|
179
|
-
private async importExistingCache(): Promise<void> {
|
|
237
|
+
private async importExistingCache(correlationId: string): Promise<void> {
|
|
180
238
|
if (!this.encryptionCookie) {
|
|
181
239
|
return;
|
|
182
240
|
}
|
|
183
241
|
|
|
184
|
-
|
|
185
|
-
await this.importArray(accountKeys);
|
|
242
|
+
let accountKeys = getAccountKeys(this);
|
|
243
|
+
accountKeys = await this.importArray(accountKeys, correlationId);
|
|
244
|
+
// Write valid account keys back to map
|
|
245
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
186
246
|
|
|
187
247
|
const tokenKeys: TokenKeys = getTokenKeys(this.clientId, this);
|
|
188
|
-
await
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
248
|
+
tokenKeys.idToken = await this.importArray(
|
|
249
|
+
tokenKeys.idToken,
|
|
250
|
+
correlationId
|
|
251
|
+
);
|
|
252
|
+
tokenKeys.accessToken = await this.importArray(
|
|
253
|
+
tokenKeys.accessToken,
|
|
254
|
+
correlationId
|
|
255
|
+
);
|
|
256
|
+
tokenKeys.refreshToken = await this.importArray(
|
|
257
|
+
tokenKeys.refreshToken,
|
|
258
|
+
correlationId
|
|
259
|
+
);
|
|
260
|
+
// Write valid token keys back to map
|
|
261
|
+
this.setItem(
|
|
262
|
+
`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`,
|
|
263
|
+
JSON.stringify(tokenKeys)
|
|
264
|
+
);
|
|
193
265
|
}
|
|
194
266
|
|
|
195
267
|
/**
|
|
@@ -198,7 +270,8 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
198
270
|
* @returns
|
|
199
271
|
*/
|
|
200
272
|
private async getItemFromEncryptedCache(
|
|
201
|
-
key: string
|
|
273
|
+
key: string,
|
|
274
|
+
correlationId: string
|
|
202
275
|
): Promise<string | null> {
|
|
203
276
|
if (!this.encryptionCookie) {
|
|
204
277
|
return null;
|
|
@@ -212,21 +285,36 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
212
285
|
let encObj: EncryptedData;
|
|
213
286
|
try {
|
|
214
287
|
encObj = JSON.parse(rawCache);
|
|
215
|
-
if (!encObj.id || !encObj.nonce || !encObj.data) {
|
|
216
|
-
throw "Not encrypted!"; // TODO: Typed error
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (encObj.id !== this.encryptionCookie.id) {
|
|
220
|
-
throw "Old item!"; // TODO: Typed error
|
|
221
|
-
}
|
|
222
288
|
} catch (e) {
|
|
223
289
|
// Not a valid encrypted object, remove
|
|
224
|
-
this.removeItem(key);
|
|
225
|
-
// TODO: Log to telemetry
|
|
226
290
|
return null;
|
|
227
291
|
}
|
|
228
292
|
|
|
229
|
-
|
|
293
|
+
if (!encObj.id || !encObj.nonce || !encObj.data) {
|
|
294
|
+
// Data is not encrypted, likely from old version of MSAL. It must be removed because we don't know how old it is.
|
|
295
|
+
this.performanceClient.incrementFields(
|
|
296
|
+
{ unencryptedCacheCount: 1 },
|
|
297
|
+
correlationId
|
|
298
|
+
);
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (encObj.id !== this.encryptionCookie.id) {
|
|
303
|
+
// Data was encrypted with a different key. It must be removed because it is from a previous session.
|
|
304
|
+
this.performanceClient.incrementFields(
|
|
305
|
+
{ encryptedCacheExpiredCount: 1 },
|
|
306
|
+
correlationId
|
|
307
|
+
);
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return invokeAsync(
|
|
312
|
+
decrypt,
|
|
313
|
+
PerformanceEvents.Decrypt,
|
|
314
|
+
this.logger,
|
|
315
|
+
this.performanceClient,
|
|
316
|
+
correlationId
|
|
317
|
+
)(
|
|
230
318
|
this.encryptionCookie.key,
|
|
231
319
|
encObj.nonce,
|
|
232
320
|
this.getContext(key),
|
|
@@ -237,21 +325,32 @@ export class LocalStorage implements IWindowStorage<string> {
|
|
|
237
325
|
/**
|
|
238
326
|
* Helper to decrypt and save an array of cache keys
|
|
239
327
|
* @param arr
|
|
328
|
+
* @returns Array of keys successfully imported
|
|
240
329
|
*/
|
|
241
|
-
private async importArray(
|
|
330
|
+
private async importArray(
|
|
331
|
+
arr: Array<string>,
|
|
332
|
+
correlationId: string
|
|
333
|
+
): Promise<Array<string>> {
|
|
334
|
+
const importedArr: Array<string> = [];
|
|
242
335
|
const promiseArr: Array<Promise<void>> = [];
|
|
243
336
|
arr.forEach((key) => {
|
|
244
|
-
const promise = this.getItemFromEncryptedCache(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
337
|
+
const promise = this.getItemFromEncryptedCache(
|
|
338
|
+
key,
|
|
339
|
+
correlationId
|
|
340
|
+
).then((value) => {
|
|
341
|
+
if (value) {
|
|
342
|
+
this.memoryStorage.setItem(key, value);
|
|
343
|
+
importedArr.push(key);
|
|
344
|
+
} else {
|
|
345
|
+
// If value is empty, unencrypted or expired remove
|
|
346
|
+
this.removeItem(key);
|
|
249
347
|
}
|
|
250
|
-
);
|
|
348
|
+
});
|
|
251
349
|
promiseArr.push(promise);
|
|
252
350
|
});
|
|
253
351
|
|
|
254
352
|
await Promise.all(promiseArr);
|
|
353
|
+
return importedArr;
|
|
255
354
|
}
|
|
256
355
|
|
|
257
356
|
/**
|