@azure/msal-browser 3.28.1 → 4.0.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/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.mjs +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 +11 -51
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +42 -291
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/CacheHelpers.d.ts +16 -0
- package/dist/cache/CacheHelpers.d.ts.map +1 -0
- package/dist/cache/CacheHelpers.mjs +46 -0
- package/dist/cache/CacheHelpers.mjs.map +1 -0
- package/dist/cache/CookieStorage.d.ts +3 -0
- package/dist/cache/CookieStorage.d.ts.map +1 -1
- package/dist/cache/CookieStorage.mjs +12 -1
- package/dist/cache/CookieStorage.mjs.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/ITokenCache.d.ts +1 -1
- package/dist/cache/ITokenCache.d.ts.map +1 -1
- package/dist/cache/IWindowStorage.d.ts +12 -0
- package/dist/cache/IWindowStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.d.ts +38 -1
- package/dist/cache/LocalStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.mjs +183 -2
- package/dist/cache/LocalStorage.mjs.map +1 -1
- package/dist/cache/MemoryStorage.d.ts +3 -0
- package/dist/cache/MemoryStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.mjs +10 -1
- package/dist/cache/MemoryStorage.mjs.map +1 -1
- package/dist/cache/SessionStorage.d.ts +3 -0
- package/dist/cache/SessionStorage.d.ts.map +1 -1
- package/dist/cache/SessionStorage.mjs +10 -1
- package/dist/cache/SessionStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.d.ts +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +16 -15
- 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 +4 -3
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +8 -6
- 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 -22
- 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 +27 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +83 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.d.ts +5 -0
- package/dist/encode/Base64Decode.d.ts.map +1 -1
- package/dist/encode/Base64Decode.mjs +2 -2
- package/dist/encode/Base64Decode.mjs.map +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.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +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 -2
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +6 -6
- 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.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +1 -8
- package/dist/interaction_client/StandardInteractionClient.mjs.map +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.mjs +1 -1
- package/lib/msal-browser.cjs +630 -650
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +630 -650
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +65 -66
- 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 +11 -51
- package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/lib/types/cache/CacheHelpers.d.ts +16 -0
- package/lib/types/cache/CacheHelpers.d.ts.map +1 -0
- package/lib/types/cache/CookieStorage.d.ts +3 -0
- package/lib/types/cache/CookieStorage.d.ts.map +1 -1
- package/lib/types/cache/ITokenCache.d.ts +1 -1
- package/lib/types/cache/ITokenCache.d.ts.map +1 -1
- package/lib/types/cache/IWindowStorage.d.ts +12 -0
- package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
- package/lib/types/cache/LocalStorage.d.ts +38 -1
- package/lib/types/cache/LocalStorage.d.ts.map +1 -1
- package/lib/types/cache/MemoryStorage.d.ts +3 -0
- package/lib/types/cache/MemoryStorage.d.ts.map +1 -1
- package/lib/types/cache/SessionStorage.d.ts +3 -0
- package/lib/types/cache/SessionStorage.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts +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 +4 -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 +27 -0
- package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
- package/lib/types/encode/Base64Decode.d.ts +5 -0
- package/lib/types/encode/Base64Decode.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts +2 -2
- 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/interaction_client/StandardInteractionClient.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/package.json +2 -2
- package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
- package/src/broker/nativeBroker/NativeResponse.ts +1 -1
- package/src/cache/BrowserCacheManager.ts +95 -422
- package/src/cache/CacheHelpers.ts +52 -0
- package/src/cache/CookieStorage.ts +18 -0
- package/src/cache/ITokenCache.ts +1 -1
- package/src/cache/IWindowStorage.ts +14 -0
- package/src/cache/LocalStorage.ts +330 -1
- package/src/cache/MemoryStorage.ts +12 -0
- package/src/cache/SessionStorage.ts +12 -0
- package/src/cache/TokenCache.ts +42 -25
- package/src/config/Configuration.ts +6 -6
- package/src/controllers/NestedAppAuthController.ts +14 -6
- package/src/controllers/StandardController.ts +41 -22
- package/src/controllers/UnknownOperatingContextController.ts +6 -5
- package/src/crypto/BrowserCrypto.ts +120 -1
- package/src/encode/Base64Decode.ts +1 -1
- package/src/index.ts +0 -1
- package/src/interaction_client/NativeInteractionClient.ts +7 -6
- 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/interaction_client/StandardInteractionClient.ts +0 -8
- 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/dist/cache/BrowserStorage.d.ts +0 -14
- package/dist/cache/BrowserStorage.d.ts.map +0 -1
- package/dist/cache/BrowserStorage.mjs +0 -46
- package/dist/cache/BrowserStorage.mjs.map +0 -1
- package/lib/types/cache/BrowserStorage.d.ts +0 -14
- package/lib/types/cache/BrowserStorage.d.ts.map +0 -1
- package/src/cache/BrowserStorage.ts +0 -52
package/src/cache/TokenCache.ts
CHANGED
|
@@ -75,17 +75,20 @@ export class TokenCache implements ITokenCache {
|
|
|
75
75
|
* @param options
|
|
76
76
|
* @returns `AuthenticationResult` for the response that was loaded.
|
|
77
77
|
*/
|
|
78
|
-
loadExternalTokens(
|
|
78
|
+
async loadExternalTokens(
|
|
79
79
|
request: SilentRequest,
|
|
80
80
|
response: ExternalTokenResponse,
|
|
81
81
|
options: LoadTokenOptions
|
|
82
|
-
): AuthenticationResult {
|
|
82
|
+
): Promise<AuthenticationResult> {
|
|
83
83
|
if (!this.isBrowserEnvironment) {
|
|
84
84
|
throw createBrowserAuthError(
|
|
85
85
|
BrowserAuthErrorCodes.nonBrowserEnvironment
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
const correlationId =
|
|
90
|
+
request.correlationId || BrowserCrypto.createNewGuid();
|
|
91
|
+
|
|
89
92
|
const idTokenClaims = response.id_token
|
|
90
93
|
? AuthToken.extractTokenClaims(response.id_token, base64Decode)
|
|
91
94
|
: undefined;
|
|
@@ -112,33 +115,37 @@ export class TokenCache implements ITokenCache {
|
|
|
112
115
|
)
|
|
113
116
|
: undefined;
|
|
114
117
|
|
|
115
|
-
const cacheRecordAccount: AccountEntity = this.loadAccount(
|
|
118
|
+
const cacheRecordAccount: AccountEntity = await this.loadAccount(
|
|
116
119
|
request,
|
|
117
120
|
options.clientInfo || response.client_info || "",
|
|
121
|
+
correlationId,
|
|
118
122
|
idTokenClaims,
|
|
119
123
|
authority
|
|
120
124
|
);
|
|
121
125
|
|
|
122
|
-
const idToken = this.loadIdToken(
|
|
126
|
+
const idToken = await this.loadIdToken(
|
|
123
127
|
response,
|
|
124
128
|
cacheRecordAccount.homeAccountId,
|
|
125
129
|
cacheRecordAccount.environment,
|
|
126
|
-
cacheRecordAccount.realm
|
|
130
|
+
cacheRecordAccount.realm,
|
|
131
|
+
correlationId
|
|
127
132
|
);
|
|
128
133
|
|
|
129
|
-
const accessToken = this.loadAccessToken(
|
|
134
|
+
const accessToken = await this.loadAccessToken(
|
|
130
135
|
request,
|
|
131
136
|
response,
|
|
132
137
|
cacheRecordAccount.homeAccountId,
|
|
133
138
|
cacheRecordAccount.environment,
|
|
134
139
|
cacheRecordAccount.realm,
|
|
135
|
-
options
|
|
140
|
+
options,
|
|
141
|
+
correlationId
|
|
136
142
|
);
|
|
137
143
|
|
|
138
|
-
const refreshToken = this.loadRefreshToken(
|
|
144
|
+
const refreshToken = await this.loadRefreshToken(
|
|
139
145
|
response,
|
|
140
146
|
cacheRecordAccount.homeAccountId,
|
|
141
|
-
cacheRecordAccount.environment
|
|
147
|
+
cacheRecordAccount.environment,
|
|
148
|
+
correlationId
|
|
142
149
|
);
|
|
143
150
|
|
|
144
151
|
return this.generateAuthenticationResult(
|
|
@@ -163,19 +170,20 @@ export class TokenCache implements ITokenCache {
|
|
|
163
170
|
* @param requestHomeAccountId
|
|
164
171
|
* @returns `AccountEntity`
|
|
165
172
|
*/
|
|
166
|
-
private loadAccount(
|
|
173
|
+
private async loadAccount(
|
|
167
174
|
request: SilentRequest,
|
|
168
175
|
clientInfo: string,
|
|
176
|
+
correlationId: string,
|
|
169
177
|
idTokenClaims?: TokenClaims,
|
|
170
178
|
authority?: Authority
|
|
171
|
-
): AccountEntity {
|
|
179
|
+
): Promise<AccountEntity> {
|
|
172
180
|
this.logger.verbose("TokenCache - loading account");
|
|
173
181
|
|
|
174
182
|
if (request.account) {
|
|
175
183
|
const accountEntity = AccountEntity.createFromAccountInfo(
|
|
176
184
|
request.account
|
|
177
185
|
);
|
|
178
|
-
this.storage.setAccount(accountEntity);
|
|
186
|
+
await this.storage.setAccount(accountEntity, correlationId);
|
|
179
187
|
return accountEntity;
|
|
180
188
|
} else if (!authority || (!clientInfo && !idTokenClaims)) {
|
|
181
189
|
this.logger.error(
|
|
@@ -210,7 +218,7 @@ export class TokenCache implements ITokenCache {
|
|
|
210
218
|
this.logger
|
|
211
219
|
);
|
|
212
220
|
|
|
213
|
-
this.storage.setAccount(cachedAccount);
|
|
221
|
+
await this.storage.setAccount(cachedAccount, correlationId);
|
|
214
222
|
return cachedAccount;
|
|
215
223
|
}
|
|
216
224
|
|
|
@@ -222,12 +230,13 @@ export class TokenCache implements ITokenCache {
|
|
|
222
230
|
* @param tenantId
|
|
223
231
|
* @returns `IdTokenEntity`
|
|
224
232
|
*/
|
|
225
|
-
private loadIdToken(
|
|
233
|
+
private async loadIdToken(
|
|
226
234
|
response: ExternalTokenResponse,
|
|
227
235
|
homeAccountId: string,
|
|
228
236
|
environment: string,
|
|
229
|
-
tenantId: string
|
|
230
|
-
|
|
237
|
+
tenantId: string,
|
|
238
|
+
correlationId: string
|
|
239
|
+
): Promise<IdTokenEntity | null> {
|
|
231
240
|
if (!response.id_token) {
|
|
232
241
|
this.logger.verbose("TokenCache - no id token found in response");
|
|
233
242
|
return null;
|
|
@@ -242,7 +251,7 @@ export class TokenCache implements ITokenCache {
|
|
|
242
251
|
tenantId
|
|
243
252
|
);
|
|
244
253
|
|
|
245
|
-
this.storage.setIdTokenCredential(idTokenEntity);
|
|
254
|
+
await this.storage.setIdTokenCredential(idTokenEntity, correlationId);
|
|
246
255
|
return idTokenEntity;
|
|
247
256
|
}
|
|
248
257
|
|
|
@@ -255,14 +264,15 @@ export class TokenCache implements ITokenCache {
|
|
|
255
264
|
* @param tenantId
|
|
256
265
|
* @returns `AccessTokenEntity`
|
|
257
266
|
*/
|
|
258
|
-
private loadAccessToken(
|
|
267
|
+
private async loadAccessToken(
|
|
259
268
|
request: SilentRequest,
|
|
260
269
|
response: ExternalTokenResponse,
|
|
261
270
|
homeAccountId: string,
|
|
262
271
|
environment: string,
|
|
263
272
|
tenantId: string,
|
|
264
|
-
options: LoadTokenOptions
|
|
265
|
-
|
|
273
|
+
options: LoadTokenOptions,
|
|
274
|
+
correlationId: string
|
|
275
|
+
): Promise<AccessTokenEntity | null> {
|
|
266
276
|
if (!response.access_token) {
|
|
267
277
|
this.logger.verbose(
|
|
268
278
|
"TokenCache - no access token found in response"
|
|
@@ -309,7 +319,10 @@ export class TokenCache implements ITokenCache {
|
|
|
309
319
|
base64Decode
|
|
310
320
|
);
|
|
311
321
|
|
|
312
|
-
this.storage.setAccessTokenCredential(
|
|
322
|
+
await this.storage.setAccessTokenCredential(
|
|
323
|
+
accessTokenEntity,
|
|
324
|
+
correlationId
|
|
325
|
+
);
|
|
313
326
|
return accessTokenEntity;
|
|
314
327
|
}
|
|
315
328
|
|
|
@@ -321,11 +334,12 @@ export class TokenCache implements ITokenCache {
|
|
|
321
334
|
* @param environment
|
|
322
335
|
* @returns `RefreshTokenEntity`
|
|
323
336
|
*/
|
|
324
|
-
private loadRefreshToken(
|
|
337
|
+
private async loadRefreshToken(
|
|
325
338
|
response: ExternalTokenResponse,
|
|
326
339
|
homeAccountId: string,
|
|
327
|
-
environment: string
|
|
328
|
-
|
|
340
|
+
environment: string,
|
|
341
|
+
correlationId: string
|
|
342
|
+
): Promise<RefreshTokenEntity | null> {
|
|
329
343
|
if (!response.refresh_token) {
|
|
330
344
|
this.logger.verbose(
|
|
331
345
|
"TokenCache - no refresh token found in response"
|
|
@@ -344,7 +358,10 @@ export class TokenCache implements ITokenCache {
|
|
|
344
358
|
response.refresh_token_expires_in
|
|
345
359
|
);
|
|
346
360
|
|
|
347
|
-
this.storage.setRefreshTokenCredential(
|
|
361
|
+
await this.storage.setRefreshTokenCredential(
|
|
362
|
+
refreshTokenEntity,
|
|
363
|
+
correlationId
|
|
364
|
+
);
|
|
348
365
|
return refreshTokenEntity;
|
|
349
366
|
}
|
|
350
367
|
|
|
@@ -192,9 +192,9 @@ export type BrowserSystemOptions = SystemOptions & {
|
|
|
192
192
|
*/
|
|
193
193
|
allowRedirectInIframe?: boolean;
|
|
194
194
|
/**
|
|
195
|
-
* Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows)
|
|
195
|
+
* Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows, MacBroker on Mac)
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
allowPlatformBroker?: boolean;
|
|
198
198
|
/**
|
|
199
199
|
* Sets the timeout for waiting for the native broker handshake to resolve
|
|
200
200
|
*/
|
|
@@ -340,7 +340,7 @@ export function buildConfiguration(
|
|
|
340
340
|
redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
|
|
341
341
|
asyncPopups: false,
|
|
342
342
|
allowRedirectInIframe: false,
|
|
343
|
-
|
|
343
|
+
allowPlatformBroker: false,
|
|
344
344
|
nativeBrokerHandshakeTimeout:
|
|
345
345
|
userInputSystem?.nativeBrokerHandshakeTimeout ||
|
|
346
346
|
DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
|
|
@@ -376,14 +376,14 @@ export function buildConfiguration(
|
|
|
376
376
|
);
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
// Throw an error if user has set
|
|
379
|
+
// Throw an error if user has set allowPlatformBroker to true without being in AAD protocol mode
|
|
380
380
|
if (
|
|
381
381
|
userInputAuth?.protocolMode &&
|
|
382
382
|
userInputAuth.protocolMode !== ProtocolMode.AAD &&
|
|
383
|
-
providedSystemOptions?.
|
|
383
|
+
providedSystemOptions?.allowPlatformBroker
|
|
384
384
|
) {
|
|
385
385
|
throw createClientConfigurationError(
|
|
386
|
-
ClientConfigurationErrorCodes.
|
|
386
|
+
ClientConfigurationErrorCodes.cannotAllowPlatformBroker
|
|
387
387
|
);
|
|
388
388
|
}
|
|
389
389
|
|
|
@@ -53,6 +53,8 @@ import {
|
|
|
53
53
|
} from "../cache/BrowserCacheManager.js";
|
|
54
54
|
import { ClearCacheRequest } from "../request/ClearCacheRequest.js";
|
|
55
55
|
import * as AccountManager from "../cache/AccountManager.js";
|
|
56
|
+
import { InitializeApplicationRequest } from "../request/InitializeApplicationRequest.js";
|
|
57
|
+
import { createNewGuid } from "../crypto/BrowserCrypto.js";
|
|
56
58
|
|
|
57
59
|
export class NestedAppAuthController implements IController {
|
|
58
60
|
// OperatingContext
|
|
@@ -112,11 +114,13 @@ export class NestedAppAuthController implements IController {
|
|
|
112
114
|
this.config.cache,
|
|
113
115
|
this.browserCrypto,
|
|
114
116
|
this.logger,
|
|
117
|
+
this.performanceClient,
|
|
115
118
|
buildStaticAuthorityOptions(this.config.auth)
|
|
116
119
|
)
|
|
117
120
|
: DEFAULT_BROWSER_CACHE_MANAGER(
|
|
118
121
|
this.config.auth.clientId,
|
|
119
|
-
this.logger
|
|
122
|
+
this.logger,
|
|
123
|
+
this.performanceClient
|
|
120
124
|
);
|
|
121
125
|
|
|
122
126
|
this.eventHandler = new EventHandler(this.logger);
|
|
@@ -157,8 +161,9 @@ export class NestedAppAuthController implements IController {
|
|
|
157
161
|
* Specific implementation of initialize function for NestedAppAuthController
|
|
158
162
|
* @returns
|
|
159
163
|
*/
|
|
160
|
-
initialize(): Promise<void> {
|
|
161
|
-
|
|
164
|
+
async initialize(request?: InitializeApplicationRequest): Promise<void> {
|
|
165
|
+
const initCorrelationId = request?.correlationId || createNewGuid();
|
|
166
|
+
await this.browserStorage.initialize(initCorrelationId);
|
|
162
167
|
return Promise.resolve();
|
|
163
168
|
}
|
|
164
169
|
|
|
@@ -568,7 +573,7 @@ export class NestedAppAuthController implements IController {
|
|
|
568
573
|
| "responseMode"
|
|
569
574
|
| "codeChallenge"
|
|
570
575
|
| "codeChallengeMethod"
|
|
571
|
-
| "
|
|
576
|
+
| "platformBroker"
|
|
572
577
|
>
|
|
573
578
|
>
|
|
574
579
|
| PopupRequest,
|
|
@@ -761,7 +766,7 @@ export class NestedAppAuthController implements IController {
|
|
|
761
766
|
| "responseMode"
|
|
762
767
|
| "codeChallenge"
|
|
763
768
|
| "codeChallengeMethod"
|
|
764
|
-
| "
|
|
769
|
+
| "platformBroker"
|
|
765
770
|
>
|
|
766
771
|
>
|
|
767
772
|
): Promise<AuthenticationResult> {
|
|
@@ -842,7 +847,10 @@ export class NestedAppAuthController implements IController {
|
|
|
842
847
|
result.cloudGraphHostName,
|
|
843
848
|
result.msGraphHost
|
|
844
849
|
);
|
|
845
|
-
this.browserStorage.setAccount(
|
|
850
|
+
await this.browserStorage.setAccount(
|
|
851
|
+
accountEntity,
|
|
852
|
+
result.correlationId
|
|
853
|
+
);
|
|
846
854
|
return this.browserStorage.hydrateCache(result, request);
|
|
847
855
|
}
|
|
848
856
|
}
|
|
@@ -242,12 +242,13 @@ export class StandardController implements IController {
|
|
|
242
242
|
this.config.cache,
|
|
243
243
|
this.browserCrypto,
|
|
244
244
|
this.logger,
|
|
245
|
-
|
|
246
|
-
this.
|
|
245
|
+
this.performanceClient,
|
|
246
|
+
buildStaticAuthorityOptions(this.config.auth)
|
|
247
247
|
)
|
|
248
248
|
: DEFAULT_BROWSER_CACHE_MANAGER(
|
|
249
249
|
this.config.auth.clientId,
|
|
250
|
-
this.logger
|
|
250
|
+
this.logger,
|
|
251
|
+
this.performanceClient
|
|
251
252
|
);
|
|
252
253
|
|
|
253
254
|
// initialize in memory storage for native flows
|
|
@@ -264,7 +265,6 @@ export class StandardController implements IController {
|
|
|
264
265
|
nativeCacheOptions,
|
|
265
266
|
this.browserCrypto,
|
|
266
267
|
this.logger,
|
|
267
|
-
undefined,
|
|
268
268
|
this.performanceClient
|
|
269
269
|
);
|
|
270
270
|
|
|
@@ -333,14 +333,22 @@ export class StandardController implements IController {
|
|
|
333
333
|
|
|
334
334
|
const initCorrelationId =
|
|
335
335
|
request?.correlationId || this.getRequestCorrelationId();
|
|
336
|
-
const
|
|
336
|
+
const allowPlatformBroker = this.config.system.allowPlatformBroker;
|
|
337
337
|
const initMeasurement = this.performanceClient.startMeasurement(
|
|
338
338
|
PerformanceEvents.InitializeClientApplication,
|
|
339
339
|
initCorrelationId
|
|
340
340
|
);
|
|
341
341
|
this.eventHandler.emitEvent(EventType.INITIALIZE_START);
|
|
342
342
|
|
|
343
|
-
|
|
343
|
+
await invokeAsync(
|
|
344
|
+
this.browserStorage.initialize.bind(this.browserStorage),
|
|
345
|
+
PerformanceEvents.InitializeCache,
|
|
346
|
+
this.logger,
|
|
347
|
+
this.performanceClient,
|
|
348
|
+
initCorrelationId
|
|
349
|
+
)(initCorrelationId);
|
|
350
|
+
|
|
351
|
+
if (allowPlatformBroker) {
|
|
344
352
|
try {
|
|
345
353
|
this.nativeExtensionProvider =
|
|
346
354
|
await NativeMessageHandler.createProvider(
|
|
@@ -371,7 +379,10 @@ export class StandardController implements IController {
|
|
|
371
379
|
|
|
372
380
|
this.initialized = true;
|
|
373
381
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
374
|
-
initMeasurement.end({
|
|
382
|
+
initMeasurement.end({
|
|
383
|
+
allowPlatformBroker: allowPlatformBroker,
|
|
384
|
+
success: true,
|
|
385
|
+
});
|
|
375
386
|
}
|
|
376
387
|
|
|
377
388
|
// #region Redirect Flow
|
|
@@ -431,7 +442,7 @@ export class StandardController implements IController {
|
|
|
431
442
|
this.browserStorage.getCachedNativeRequest();
|
|
432
443
|
const useNative =
|
|
433
444
|
request &&
|
|
434
|
-
NativeMessageHandler.
|
|
445
|
+
NativeMessageHandler.isPlatformBrokerAvailable(
|
|
435
446
|
this.config,
|
|
436
447
|
this.logger,
|
|
437
448
|
this.nativeExtensionProvider
|
|
@@ -654,7 +665,10 @@ export class StandardController implements IController {
|
|
|
654
665
|
|
|
655
666
|
let result: Promise<void>;
|
|
656
667
|
|
|
657
|
-
if (
|
|
668
|
+
if (
|
|
669
|
+
this.nativeExtensionProvider &&
|
|
670
|
+
this.canUsePlatformBroker(request)
|
|
671
|
+
) {
|
|
658
672
|
const nativeClient = new NativeInteractionClient(
|
|
659
673
|
this.config,
|
|
660
674
|
this.browserStorage,
|
|
@@ -768,7 +782,7 @@ export class StandardController implements IController {
|
|
|
768
782
|
|
|
769
783
|
let result: Promise<AuthenticationResult>;
|
|
770
784
|
|
|
771
|
-
if (this.
|
|
785
|
+
if (this.canUsePlatformBroker(request)) {
|
|
772
786
|
result = this.acquireTokenNative(
|
|
773
787
|
{
|
|
774
788
|
...request,
|
|
@@ -937,7 +951,7 @@ export class StandardController implements IController {
|
|
|
937
951
|
|
|
938
952
|
let result: Promise<AuthenticationResult>;
|
|
939
953
|
|
|
940
|
-
if (this.
|
|
954
|
+
if (this.canUsePlatformBroker(validRequest)) {
|
|
941
955
|
result = this.acquireTokenNative(
|
|
942
956
|
validRequest,
|
|
943
957
|
ApiId.ssoSilent
|
|
@@ -1085,7 +1099,9 @@ export class StandardController implements IController {
|
|
|
1085
1099
|
}
|
|
1086
1100
|
return await response;
|
|
1087
1101
|
} else if (request.nativeAccountId) {
|
|
1088
|
-
if (
|
|
1102
|
+
if (
|
|
1103
|
+
this.canUsePlatformBroker(request, request.nativeAccountId)
|
|
1104
|
+
) {
|
|
1089
1105
|
const result = await this.acquireTokenNative(
|
|
1090
1106
|
{
|
|
1091
1107
|
...request,
|
|
@@ -1472,7 +1488,10 @@ export class StandardController implements IController {
|
|
|
1472
1488
|
result.cloudGraphHostName,
|
|
1473
1489
|
result.msGraphHost
|
|
1474
1490
|
);
|
|
1475
|
-
this.browserStorage.setAccount(
|
|
1491
|
+
await this.browserStorage.setAccount(
|
|
1492
|
+
accountEntity,
|
|
1493
|
+
result.correlationId
|
|
1494
|
+
);
|
|
1476
1495
|
|
|
1477
1496
|
if (result.fromNativeBroker) {
|
|
1478
1497
|
this.logger.verbose(
|
|
@@ -1522,16 +1541,16 @@ export class StandardController implements IController {
|
|
|
1522
1541
|
}
|
|
1523
1542
|
|
|
1524
1543
|
/**
|
|
1525
|
-
* Returns boolean indicating if this request can use the
|
|
1544
|
+
* Returns boolean indicating if this request can use the platform broker
|
|
1526
1545
|
* @param request
|
|
1527
1546
|
*/
|
|
1528
|
-
public
|
|
1547
|
+
public canUsePlatformBroker(
|
|
1529
1548
|
request: RedirectRequest | PopupRequest | SsoSilentRequest,
|
|
1530
1549
|
accountId?: string
|
|
1531
1550
|
): boolean {
|
|
1532
|
-
this.logger.trace("
|
|
1551
|
+
this.logger.trace("canUsePlatformBroker called");
|
|
1533
1552
|
if (
|
|
1534
|
-
!NativeMessageHandler.
|
|
1553
|
+
!NativeMessageHandler.isPlatformBrokerAvailable(
|
|
1535
1554
|
this.config,
|
|
1536
1555
|
this.logger,
|
|
1537
1556
|
this.nativeExtensionProvider,
|
|
@@ -1539,7 +1558,7 @@ export class StandardController implements IController {
|
|
|
1539
1558
|
)
|
|
1540
1559
|
) {
|
|
1541
1560
|
this.logger.trace(
|
|
1542
|
-
"
|
|
1561
|
+
"canUsePlatformBroker: isPlatformBrokerAvailable returned false, returning false"
|
|
1543
1562
|
);
|
|
1544
1563
|
return false;
|
|
1545
1564
|
}
|
|
@@ -1550,12 +1569,12 @@ export class StandardController implements IController {
|
|
|
1550
1569
|
case PromptValue.CONSENT:
|
|
1551
1570
|
case PromptValue.LOGIN:
|
|
1552
1571
|
this.logger.trace(
|
|
1553
|
-
"
|
|
1572
|
+
"canUsePlatformBroker: prompt is compatible with platform broker flow"
|
|
1554
1573
|
);
|
|
1555
1574
|
break;
|
|
1556
1575
|
default:
|
|
1557
1576
|
this.logger.trace(
|
|
1558
|
-
`
|
|
1577
|
+
`canUsePlatformBroker: prompt = ${request.prompt} is not compatible with platform broker flow, returning false`
|
|
1559
1578
|
);
|
|
1560
1579
|
return false;
|
|
1561
1580
|
}
|
|
@@ -1563,7 +1582,7 @@ export class StandardController implements IController {
|
|
|
1563
1582
|
|
|
1564
1583
|
if (!accountId && !this.getNativeAccountId(request)) {
|
|
1565
1584
|
this.logger.trace(
|
|
1566
|
-
"
|
|
1585
|
+
"canUsePlatformBroker: nativeAccountId is not available, returning false"
|
|
1567
1586
|
);
|
|
1568
1587
|
return false;
|
|
1569
1588
|
}
|
|
@@ -2252,7 +2271,7 @@ export class StandardController implements IController {
|
|
|
2252
2271
|
cacheLookupPolicy: CacheLookupPolicy
|
|
2253
2272
|
): Promise<AuthenticationResult> {
|
|
2254
2273
|
if (
|
|
2255
|
-
NativeMessageHandler.
|
|
2274
|
+
NativeMessageHandler.isPlatformBrokerAvailable(
|
|
2256
2275
|
this.config,
|
|
2257
2276
|
this.logger,
|
|
2258
2277
|
this.nativeExtensionProvider,
|
|
@@ -105,12 +105,13 @@ export class UnknownOperatingContextController implements IController {
|
|
|
105
105
|
this.config.cache,
|
|
106
106
|
this.browserCrypto,
|
|
107
107
|
this.logger,
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
this.performanceClient,
|
|
109
|
+
undefined
|
|
110
110
|
)
|
|
111
111
|
: DEFAULT_BROWSER_CACHE_MANAGER(
|
|
112
112
|
this.config.auth.clientId,
|
|
113
|
-
this.logger
|
|
113
|
+
this.logger,
|
|
114
|
+
this.performanceClient
|
|
114
115
|
);
|
|
115
116
|
}
|
|
116
117
|
getBrowserStorage(): BrowserCacheManager {
|
|
@@ -180,7 +181,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
180
181
|
| "codeChallenge"
|
|
181
182
|
| "codeChallengeMethod"
|
|
182
183
|
| "requestedClaimsHash"
|
|
183
|
-
| "
|
|
184
|
+
| "platformBroker"
|
|
184
185
|
>
|
|
185
186
|
>,
|
|
186
187
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -287,7 +288,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
287
288
|
| "codeChallenge"
|
|
288
289
|
| "codeChallengeMethod"
|
|
289
290
|
| "requestedClaimsHash"
|
|
290
|
-
| "
|
|
291
|
+
| "platformBroker"
|
|
291
292
|
>
|
|
292
293
|
>
|
|
293
294
|
): Promise<AuthenticationResult> {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "@azure/msal-common/browser";
|
|
14
14
|
import { KEY_FORMAT_JWK } from "../utils/BrowserConstants.js";
|
|
15
15
|
import { urlEncodeArr } from "../encode/Base64Encode.js";
|
|
16
|
+
import { base64DecToArr } from "../encode/Base64Decode.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* This file defines functions used by the browser library to perform cryptography operations such as
|
|
@@ -22,8 +23,10 @@ import { urlEncodeArr } from "../encode/Base64Encode.js";
|
|
|
22
23
|
/**
|
|
23
24
|
* See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
|
|
24
25
|
*/
|
|
25
|
-
//
|
|
26
|
+
// Algorithms
|
|
26
27
|
const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
|
|
28
|
+
const AES_GCM = "AES-GCM";
|
|
29
|
+
const HKDF = "HKDF";
|
|
27
30
|
// SHA-256 hashing algorithm
|
|
28
31
|
const S256_HASH_ALG = "SHA-256";
|
|
29
32
|
// MOD length for PoP tokens
|
|
@@ -35,6 +38,14 @@ const UUID_CHARS = "0123456789abcdef";
|
|
|
35
38
|
// Array to store UINT32 random value
|
|
36
39
|
const UINT32_ARR = new Uint32Array(1);
|
|
37
40
|
|
|
41
|
+
// Key Format
|
|
42
|
+
const RAW = "raw";
|
|
43
|
+
// Key Usages
|
|
44
|
+
const ENCRYPT = "encrypt";
|
|
45
|
+
const DECRYPT = "decrypt";
|
|
46
|
+
const DERIVE_KEY = "deriveKey";
|
|
47
|
+
|
|
48
|
+
// Suberror
|
|
38
49
|
const SUBTLE_SUBERROR = "crypto_subtle_undefined";
|
|
39
50
|
|
|
40
51
|
const keygenAlgorithmOptions: RsaHashedKeyGenParams = {
|
|
@@ -215,6 +226,114 @@ export async function sign(
|
|
|
215
226
|
) as Promise<ArrayBuffer>;
|
|
216
227
|
}
|
|
217
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Generates symmetric base encryption key. This may be stored as all encryption/decryption keys will be derived from this one.
|
|
231
|
+
*/
|
|
232
|
+
export async function generateBaseKey(): Promise<ArrayBuffer> {
|
|
233
|
+
const key = await window.crypto.subtle.generateKey(
|
|
234
|
+
{
|
|
235
|
+
name: AES_GCM,
|
|
236
|
+
length: 256,
|
|
237
|
+
},
|
|
238
|
+
true,
|
|
239
|
+
[ENCRYPT, DECRYPT]
|
|
240
|
+
);
|
|
241
|
+
return window.crypto.subtle.exportKey(RAW, key);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Returns the raw key to be passed into the key derivation function
|
|
246
|
+
* @param baseKey
|
|
247
|
+
* @returns
|
|
248
|
+
*/
|
|
249
|
+
export async function generateHKDF(baseKey: ArrayBuffer): Promise<CryptoKey> {
|
|
250
|
+
return window.crypto.subtle.importKey(RAW, baseKey, HKDF, false, [
|
|
251
|
+
DERIVE_KEY,
|
|
252
|
+
]);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Given a base key and a nonce generates a derived key to be used in encryption and decryption.
|
|
257
|
+
* Note: every time we encrypt a new key is derived
|
|
258
|
+
* @param baseKey
|
|
259
|
+
* @param nonce
|
|
260
|
+
* @returns
|
|
261
|
+
*/
|
|
262
|
+
async function deriveKey(
|
|
263
|
+
baseKey: CryptoKey,
|
|
264
|
+
nonce: ArrayBuffer,
|
|
265
|
+
context: string
|
|
266
|
+
): Promise<CryptoKey> {
|
|
267
|
+
return window.crypto.subtle.deriveKey(
|
|
268
|
+
{
|
|
269
|
+
name: HKDF,
|
|
270
|
+
salt: nonce,
|
|
271
|
+
hash: S256_HASH_ALG,
|
|
272
|
+
info: new TextEncoder().encode(context),
|
|
273
|
+
},
|
|
274
|
+
baseKey,
|
|
275
|
+
{ name: AES_GCM, length: 256 },
|
|
276
|
+
false,
|
|
277
|
+
[ENCRYPT, DECRYPT]
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Encrypt the given data given a base key. Returns encrypted data and a nonce that must be provided during decryption
|
|
283
|
+
* @param key
|
|
284
|
+
* @param rawData
|
|
285
|
+
*/
|
|
286
|
+
export async function encrypt(
|
|
287
|
+
baseKey: CryptoKey,
|
|
288
|
+
rawData: string,
|
|
289
|
+
context: string
|
|
290
|
+
): Promise<{ data: string; nonce: string }> {
|
|
291
|
+
const encodedData = new TextEncoder().encode(rawData);
|
|
292
|
+
// The nonce must never be reused with a given key.
|
|
293
|
+
const nonce = window.crypto.getRandomValues(new Uint8Array(16));
|
|
294
|
+
const derivedKey = await deriveKey(baseKey, nonce, context);
|
|
295
|
+
const encryptedData = await window.crypto.subtle.encrypt(
|
|
296
|
+
{
|
|
297
|
+
name: AES_GCM,
|
|
298
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
299
|
+
},
|
|
300
|
+
derivedKey,
|
|
301
|
+
encodedData
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
return {
|
|
305
|
+
data: urlEncodeArr(new Uint8Array(encryptedData)),
|
|
306
|
+
nonce: urlEncodeArr(nonce),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Decrypt data with the given key and nonce
|
|
312
|
+
* @param key
|
|
313
|
+
* @param nonce
|
|
314
|
+
* @param encryptedData
|
|
315
|
+
* @returns
|
|
316
|
+
*/
|
|
317
|
+
export async function decrypt(
|
|
318
|
+
baseKey: CryptoKey,
|
|
319
|
+
nonce: string,
|
|
320
|
+
context: string,
|
|
321
|
+
encryptedData: string
|
|
322
|
+
): Promise<string> {
|
|
323
|
+
const encodedData = base64DecToArr(encryptedData);
|
|
324
|
+
const derivedKey = await deriveKey(baseKey, base64DecToArr(nonce), context);
|
|
325
|
+
const decryptedData = await window.crypto.subtle.decrypt(
|
|
326
|
+
{
|
|
327
|
+
name: AES_GCM,
|
|
328
|
+
iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
|
|
329
|
+
},
|
|
330
|
+
derivedKey,
|
|
331
|
+
encodedData
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
return new TextDecoder().decode(decryptedData);
|
|
335
|
+
}
|
|
336
|
+
|
|
218
337
|
/**
|
|
219
338
|
* Returns the SHA-256 hash of an input string
|
|
220
339
|
* @param plainText
|
|
@@ -25,7 +25,7 @@ export function base64Decode(input: string): string {
|
|
|
25
25
|
* Decodes base64 into Uint8Array
|
|
26
26
|
* @param base64String
|
|
27
27
|
*/
|
|
28
|
-
function base64DecToArr(base64String: string): Uint8Array {
|
|
28
|
+
export function base64DecToArr(base64String: string): Uint8Array {
|
|
29
29
|
let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
30
30
|
switch (encodedString.length % 4) {
|
|
31
31
|
case 0:
|
package/src/index.ts
CHANGED
|
@@ -74,7 +74,6 @@ export { ITokenCache } from "./cache/ITokenCache.js";
|
|
|
74
74
|
|
|
75
75
|
// Storage
|
|
76
76
|
export { MemoryStorage } from "./cache/MemoryStorage.js";
|
|
77
|
-
export { BrowserStorage } from "./cache/BrowserStorage.js";
|
|
78
77
|
export { LocalStorage } from "./cache/LocalStorage.js";
|
|
79
78
|
export { SessionStorage } from "./cache/SessionStorage.js";
|
|
80
79
|
export { IWindowStorage } from "./cache/IWindowStorage.js";
|