@azure/msal-browser 3.10.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.d.ts +2 -3
- package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +4 -5
- package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +8 -27
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +48 -75
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/DatabaseStorage.d.ts +1 -1
- package/dist/cache/DatabaseStorage.d.ts.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +14 -4
- package/dist/cache/DatabaseStorage.mjs.map +1 -1
- package/dist/cache/{IAsyncMemoryStorage.d.ts → IAsyncStorage.d.ts} +1 -1
- package/dist/cache/IAsyncStorage.d.ts.map +1 -0
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/IController.d.ts +1 -3
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +2 -3
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +21 -19
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts +5 -23
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +47 -127
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +1 -2
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +28 -36
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +5 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +12 -2
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +28 -12
- 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/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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/interaction_client/BaseInteractionClient.d.ts +1 -6
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +2 -43
- package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +1 -1
- package/dist/interaction_client/PopupClient.mjs +1 -1
- package/dist/interaction_client/RedirectClient.mjs +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts +1 -9
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +3 -22
- package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +3 -2
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
- 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.d.ts +3 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +4 -3
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +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/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/RequestHelpers.d.ts +14 -0
- package/dist/request/RequestHelpers.d.ts.map +1 -0
- package/dist/request/RequestHelpers.mjs +61 -0
- package/dist/request/RequestHelpers.mjs.map +1 -0
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +5 -5
- package/dist/telemetry/BrowserPerformanceClient.mjs.map +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 +14 -3
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +37 -10
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +866 -584
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +866 -584
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -66
- package/package.json +2 -2
- package/src/cache/AsyncMemoryStorage.ts +4 -6
- package/src/cache/BrowserCacheManager.ts +54 -90
- package/src/cache/DatabaseStorage.ts +14 -4
- package/src/controllers/IController.ts +1 -7
- package/src/controllers/NestedAppAuthController.ts +38 -23
- package/src/controllers/StandardController.ts +107 -179
- package/src/controllers/UnknownOperatingContextController.ts +28 -37
- package/src/crypto/BrowserCrypto.ts +11 -0
- package/src/crypto/CryptoOps.ts +31 -13
- package/src/index.ts +2 -0
- package/src/interaction_client/BaseInteractionClient.ts +0 -66
- package/src/interaction_client/SilentCacheClient.ts +11 -51
- package/src/interaction_client/SilentRefreshClient.ts +3 -2
- package/src/interaction_client/StandardInteractionClient.ts +8 -2
- package/src/naa/mapping/NestedAppAuthAdapter.ts +10 -2
- package/src/packageMetadata.ts +1 -1
- package/src/request/RequestHelpers.ts +112 -0
- package/src/telemetry/BrowserPerformanceClient.ts +18 -9
- package/src/utils/BrowserUtils.ts +50 -15
- package/dist/cache/CryptoKeyStore.d.ts +0 -19
- package/dist/cache/CryptoKeyStore.d.ts.map +0 -1
- package/dist/cache/CryptoKeyStore.mjs +0 -47
- package/dist/cache/CryptoKeyStore.mjs.map +0 -1
- package/dist/cache/IAsyncMemoryStorage.d.ts.map +0 -1
- package/src/cache/CryptoKeyStore.ts +0 -63
- /package/src/cache/{IAsyncMemoryStorage.ts → IAsyncStorage.ts} +0 -0
|
@@ -29,7 +29,7 @@ import { RedirectRequest } from "../request/RedirectRequest";
|
|
|
29
29
|
import { SilentRequest } from "../request/SilentRequest";
|
|
30
30
|
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
31
31
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
32
|
-
import { ApiId, WrapperSKU
|
|
32
|
+
import { ApiId, WrapperSKU } from "../utils/BrowserConstants";
|
|
33
33
|
import { IController } from "./IController";
|
|
34
34
|
import { UnknownOperatingContext } from "../operatingcontext/UnknownOperatingContext";
|
|
35
35
|
import { CryptoOps } from "../crypto/CryptoOps";
|
|
@@ -149,13 +149,13 @@ export class UnknownOperatingContextController implements IController {
|
|
|
149
149
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
150
150
|
acquireTokenPopup(request: PopupRequest): Promise<AuthenticationResult> {
|
|
151
151
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
152
|
-
blockNonBrowserEnvironment(
|
|
152
|
+
blockNonBrowserEnvironment();
|
|
153
153
|
return {} as Promise<AuthenticationResult>;
|
|
154
154
|
}
|
|
155
155
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
156
|
acquireTokenRedirect(request: RedirectRequest): Promise<void> {
|
|
157
157
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
158
|
-
blockNonBrowserEnvironment(
|
|
158
|
+
blockNonBrowserEnvironment();
|
|
159
159
|
return Promise.resolve();
|
|
160
160
|
}
|
|
161
161
|
acquireTokenSilent(
|
|
@@ -163,7 +163,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
163
163
|
silentRequest: SilentRequest
|
|
164
164
|
): Promise<AuthenticationResult> {
|
|
165
165
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
166
|
-
blockNonBrowserEnvironment(
|
|
166
|
+
blockNonBrowserEnvironment();
|
|
167
167
|
return {} as Promise<AuthenticationResult>;
|
|
168
168
|
}
|
|
169
169
|
acquireTokenByCode(
|
|
@@ -171,7 +171,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
171
171
|
request: AuthorizationCodeRequest
|
|
172
172
|
): Promise<AuthenticationResult> {
|
|
173
173
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
174
|
-
blockNonBrowserEnvironment(
|
|
174
|
+
blockNonBrowserEnvironment();
|
|
175
175
|
return {} as Promise<AuthenticationResult>;
|
|
176
176
|
}
|
|
177
177
|
acquireTokenNative(
|
|
@@ -195,7 +195,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
195
195
|
accountId?: string | undefined
|
|
196
196
|
): Promise<AuthenticationResult> {
|
|
197
197
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
198
|
-
blockNonBrowserEnvironment(
|
|
198
|
+
blockNonBrowserEnvironment();
|
|
199
199
|
return {} as Promise<AuthenticationResult>;
|
|
200
200
|
}
|
|
201
201
|
acquireTokenByRefreshToken(
|
|
@@ -205,7 +205,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
205
205
|
silentRequest: SilentRequest
|
|
206
206
|
): Promise<AuthenticationResult> {
|
|
207
207
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
208
|
-
blockNonBrowserEnvironment(
|
|
208
|
+
blockNonBrowserEnvironment();
|
|
209
209
|
return {} as Promise<AuthenticationResult>;
|
|
210
210
|
}
|
|
211
211
|
addEventCallback(callback: EventCallbackFunction): string | null {
|
|
@@ -217,22 +217,22 @@ export class UnknownOperatingContextController implements IController {
|
|
|
217
217
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
218
218
|
addPerformanceCallback(callback: PerformanceCallbackFunction): string {
|
|
219
219
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
220
|
-
blockNonBrowserEnvironment(
|
|
220
|
+
blockNonBrowserEnvironment();
|
|
221
221
|
return "";
|
|
222
222
|
}
|
|
223
223
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
224
224
|
removePerformanceCallback(callbackId: string): boolean {
|
|
225
225
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
226
|
-
blockNonBrowserEnvironment(
|
|
226
|
+
blockNonBrowserEnvironment();
|
|
227
227
|
return true;
|
|
228
228
|
}
|
|
229
229
|
enableAccountStorageEvents(): void {
|
|
230
230
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
231
|
-
blockNonBrowserEnvironment(
|
|
231
|
+
blockNonBrowserEnvironment();
|
|
232
232
|
}
|
|
233
233
|
disableAccountStorageEvents(): void {
|
|
234
234
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
235
|
-
blockNonBrowserEnvironment(
|
|
235
|
+
blockNonBrowserEnvironment();
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
handleRedirectPromise(
|
|
@@ -247,19 +247,19 @@ export class UnknownOperatingContextController implements IController {
|
|
|
247
247
|
request?: PopupRequest | undefined
|
|
248
248
|
): Promise<AuthenticationResult> {
|
|
249
249
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
250
|
-
blockNonBrowserEnvironment(
|
|
250
|
+
blockNonBrowserEnvironment();
|
|
251
251
|
return {} as Promise<AuthenticationResult>;
|
|
252
252
|
}
|
|
253
253
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
254
254
|
loginRedirect(request?: RedirectRequest | undefined): Promise<void> {
|
|
255
255
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
256
|
-
blockNonBrowserEnvironment(
|
|
256
|
+
blockNonBrowserEnvironment();
|
|
257
257
|
return {} as Promise<void>;
|
|
258
258
|
}
|
|
259
259
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
260
260
|
logout(logoutRequest?: EndSessionRequest | undefined): Promise<void> {
|
|
261
261
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
262
|
-
blockNonBrowserEnvironment(
|
|
262
|
+
blockNonBrowserEnvironment();
|
|
263
263
|
return {} as Promise<void>;
|
|
264
264
|
}
|
|
265
265
|
logoutRedirect(
|
|
@@ -267,7 +267,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
267
267
|
logoutRequest?: EndSessionRequest | undefined
|
|
268
268
|
): Promise<void> {
|
|
269
269
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
270
|
-
blockNonBrowserEnvironment(
|
|
270
|
+
blockNonBrowserEnvironment();
|
|
271
271
|
return {} as Promise<void>;
|
|
272
272
|
}
|
|
273
273
|
logoutPopup(
|
|
@@ -275,7 +275,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
275
275
|
logoutRequest?: EndSessionPopupRequest | undefined
|
|
276
276
|
): Promise<void> {
|
|
277
277
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
278
|
-
blockNonBrowserEnvironment(
|
|
278
|
+
blockNonBrowserEnvironment();
|
|
279
279
|
return {} as Promise<void>;
|
|
280
280
|
}
|
|
281
281
|
ssoSilent(
|
|
@@ -292,12 +292,12 @@ export class UnknownOperatingContextController implements IController {
|
|
|
292
292
|
>
|
|
293
293
|
): Promise<AuthenticationResult> {
|
|
294
294
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
295
|
-
blockNonBrowserEnvironment(
|
|
295
|
+
blockNonBrowserEnvironment();
|
|
296
296
|
return {} as Promise<AuthenticationResult>;
|
|
297
297
|
}
|
|
298
298
|
getTokenCache(): ITokenCache {
|
|
299
299
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
300
|
-
blockNonBrowserEnvironment(
|
|
300
|
+
blockNonBrowserEnvironment();
|
|
301
301
|
return {} as ITokenCache;
|
|
302
302
|
}
|
|
303
303
|
getLogger(): Logger {
|
|
@@ -306,16 +306,16 @@ export class UnknownOperatingContextController implements IController {
|
|
|
306
306
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
307
307
|
setLogger(logger: Logger): void {
|
|
308
308
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
309
|
-
blockNonBrowserEnvironment(
|
|
309
|
+
blockNonBrowserEnvironment();
|
|
310
310
|
}
|
|
311
311
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
312
312
|
setActiveAccount(account: AccountInfo | null): void {
|
|
313
313
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
314
|
-
blockNonBrowserEnvironment(
|
|
314
|
+
blockNonBrowserEnvironment();
|
|
315
315
|
}
|
|
316
316
|
getActiveAccount(): AccountInfo | null {
|
|
317
317
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
318
|
-
blockNonBrowserEnvironment(
|
|
318
|
+
blockNonBrowserEnvironment();
|
|
319
319
|
return null;
|
|
320
320
|
}
|
|
321
321
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -325,45 +325,36 @@ export class UnknownOperatingContextController implements IController {
|
|
|
325
325
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
326
326
|
setNavigationClient(navigationClient: INavigationClient): void {
|
|
327
327
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
328
|
-
blockNonBrowserEnvironment(
|
|
328
|
+
blockNonBrowserEnvironment();
|
|
329
329
|
}
|
|
330
330
|
getConfiguration(): BrowserConfiguration {
|
|
331
331
|
return this.config;
|
|
332
332
|
}
|
|
333
333
|
isBrowserEnv(): boolean {
|
|
334
334
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
335
|
-
blockNonBrowserEnvironment(
|
|
335
|
+
blockNonBrowserEnvironment();
|
|
336
336
|
return true;
|
|
337
337
|
}
|
|
338
338
|
getBrowserCrypto(): ICrypto {
|
|
339
339
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
340
|
-
blockNonBrowserEnvironment(
|
|
340
|
+
blockNonBrowserEnvironment();
|
|
341
341
|
return {} as ICrypto;
|
|
342
342
|
}
|
|
343
343
|
getPerformanceClient(): IPerformanceClient {
|
|
344
344
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
345
|
-
blockNonBrowserEnvironment(
|
|
345
|
+
blockNonBrowserEnvironment();
|
|
346
346
|
return {} as IPerformanceClient;
|
|
347
347
|
}
|
|
348
348
|
getRedirectResponse(): Map<string, Promise<AuthenticationResult | null>> {
|
|
349
349
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
350
|
-
blockNonBrowserEnvironment(
|
|
350
|
+
blockNonBrowserEnvironment();
|
|
351
351
|
return {} as Map<string, Promise<AuthenticationResult | null>>;
|
|
352
352
|
}
|
|
353
|
-
preflightBrowserEnvironmentCheck(
|
|
354
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
355
|
-
interactionType: InteractionType,
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
357
|
-
isAppEmbedded?: boolean | undefined
|
|
358
|
-
): void {
|
|
359
|
-
blockAPICallsBeforeInitialize(this.initialized);
|
|
360
|
-
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
361
|
-
}
|
|
362
353
|
|
|
363
354
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
364
355
|
async clearCache(logoutRequest?: ClearCacheRequest): Promise<void> {
|
|
365
356
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
366
|
-
blockNonBrowserEnvironment(
|
|
357
|
+
blockNonBrowserEnvironment();
|
|
367
358
|
}
|
|
368
359
|
|
|
369
360
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -378,6 +369,6 @@ export class UnknownOperatingContextController implements IController {
|
|
|
378
369
|
| PopupRequest
|
|
379
370
|
): Promise<void> {
|
|
380
371
|
blockAPICallsBeforeInitialize(this.initialized);
|
|
381
|
-
blockNonBrowserEnvironment(
|
|
372
|
+
blockNonBrowserEnvironment();
|
|
382
373
|
}
|
|
383
374
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
PerformanceEvents,
|
|
14
14
|
} from "@azure/msal-common";
|
|
15
15
|
import { KEY_FORMAT_JWK } from "../utils/BrowserConstants";
|
|
16
|
+
import { urlEncodeArr } from "../encode/Base64Encode";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* This file defines functions used by the browser library to perform cryptography operations such as
|
|
@@ -202,3 +203,13 @@ export async function sign(
|
|
|
202
203
|
data
|
|
203
204
|
) as Promise<ArrayBuffer>;
|
|
204
205
|
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Returns the SHA-256 hash of an input string
|
|
209
|
+
* @param plainText
|
|
210
|
+
*/
|
|
211
|
+
export async function hashString(plainText: string): Promise<string> {
|
|
212
|
+
const hashBuffer: ArrayBuffer = await sha256Digest(plainText);
|
|
213
|
+
const hashBytes = new Uint8Array(hashBuffer);
|
|
214
|
+
return urlEncodeArr(hashBytes);
|
|
215
|
+
}
|
package/src/crypto/CryptoOps.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
createBrowserAuthError,
|
|
21
21
|
BrowserAuthErrorCodes,
|
|
22
22
|
} from "../error/BrowserAuthError";
|
|
23
|
-
import {
|
|
23
|
+
import { AsyncMemoryStorage } from "../cache/AsyncMemoryStorage";
|
|
24
24
|
|
|
25
25
|
export type CachedKeyPair = {
|
|
26
26
|
publicKey: CryptoKey;
|
|
@@ -44,13 +44,13 @@ export class CryptoOps implements ICrypto {
|
|
|
44
44
|
|
|
45
45
|
private static POP_KEY_USAGES: Array<KeyUsage> = ["sign", "verify"];
|
|
46
46
|
private static EXTRACTABLE: boolean = true;
|
|
47
|
-
private cache:
|
|
47
|
+
private cache: AsyncMemoryStorage<CachedKeyPair>;
|
|
48
48
|
|
|
49
49
|
constructor(logger: Logger, performanceClient?: IPerformanceClient) {
|
|
50
50
|
this.logger = logger;
|
|
51
51
|
// Browser crypto needs to be validated first before any other classes can be set.
|
|
52
52
|
BrowserCrypto.validateCryptoAvailable(logger);
|
|
53
|
-
this.cache = new
|
|
53
|
+
this.cache = new AsyncMemoryStorage<CachedKeyPair>(this.logger);
|
|
54
54
|
this.performanceClient = performanceClient;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -121,7 +121,7 @@ export class CryptoOps implements ICrypto {
|
|
|
121
121
|
await BrowserCrypto.importJwk(privateKeyJwk, false, ["sign"]);
|
|
122
122
|
|
|
123
123
|
// Store Keypair data in keystore
|
|
124
|
-
await this.cache.
|
|
124
|
+
await this.cache.setItem(publicJwkHash, {
|
|
125
125
|
privateKey: unextractablePrivateKey,
|
|
126
126
|
publicKey: keyPair.publicKey,
|
|
127
127
|
requestMethod: request.resourceRequestMethod,
|
|
@@ -142,8 +142,8 @@ export class CryptoOps implements ICrypto {
|
|
|
142
142
|
* @param kid
|
|
143
143
|
*/
|
|
144
144
|
async removeTokenBindingKey(kid: string): Promise<boolean> {
|
|
145
|
-
await this.cache.
|
|
146
|
-
const keyFound = await this.cache.
|
|
145
|
+
await this.cache.removeItem(kid);
|
|
146
|
+
const keyFound = await this.cache.containsKey(kid);
|
|
147
147
|
return !keyFound;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -151,7 +151,29 @@ export class CryptoOps implements ICrypto {
|
|
|
151
151
|
* Removes all cryptographic keys from IndexedDB storage
|
|
152
152
|
*/
|
|
153
153
|
async clearKeystore(): Promise<boolean> {
|
|
154
|
-
|
|
154
|
+
// Delete in-memory keystores
|
|
155
|
+
this.cache.clearInMemory();
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* There is only one database, so calling clearPersistent on asymmetric keystore takes care of
|
|
159
|
+
* every persistent keystore
|
|
160
|
+
*/
|
|
161
|
+
try {
|
|
162
|
+
await this.cache.clearPersistent();
|
|
163
|
+
return true;
|
|
164
|
+
} catch (e) {
|
|
165
|
+
if (e instanceof Error) {
|
|
166
|
+
this.logger.error(
|
|
167
|
+
`Clearing keystore failed with error: ${e.message}`
|
|
168
|
+
);
|
|
169
|
+
} else {
|
|
170
|
+
this.logger.error(
|
|
171
|
+
"Clearing keystore failed with unknown error"
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
155
177
|
}
|
|
156
178
|
|
|
157
179
|
/**
|
|
@@ -169,7 +191,7 @@ export class CryptoOps implements ICrypto {
|
|
|
169
191
|
PerformanceEvents.CryptoOptsSignJwt,
|
|
170
192
|
correlationId
|
|
171
193
|
);
|
|
172
|
-
const cachedKeyPair = await this.cache.
|
|
194
|
+
const cachedKeyPair = await this.cache.getItem(kid);
|
|
173
195
|
|
|
174
196
|
if (!cachedKeyPair) {
|
|
175
197
|
throw createBrowserAuthError(
|
|
@@ -227,11 +249,7 @@ export class CryptoOps implements ICrypto {
|
|
|
227
249
|
* @param plainText
|
|
228
250
|
*/
|
|
229
251
|
async hashString(plainText: string): Promise<string> {
|
|
230
|
-
|
|
231
|
-
plainText
|
|
232
|
-
);
|
|
233
|
-
const hashBytes = new Uint8Array(hashBuffer);
|
|
234
|
-
return urlEncodeArr(hashBytes);
|
|
252
|
+
return BrowserCrypto.hashString(plainText);
|
|
235
253
|
}
|
|
236
254
|
}
|
|
237
255
|
|
package/src/index.ts
CHANGED
|
@@ -9,8 +9,6 @@ import {
|
|
|
9
9
|
Logger,
|
|
10
10
|
AccountInfo,
|
|
11
11
|
AccountEntity,
|
|
12
|
-
BaseAuthRequest,
|
|
13
|
-
AuthenticationScheme,
|
|
14
12
|
UrlString,
|
|
15
13
|
ServerTelemetryManager,
|
|
16
14
|
ServerTelemetryRequest,
|
|
@@ -21,7 +19,6 @@ import {
|
|
|
21
19
|
AuthorityFactory,
|
|
22
20
|
IPerformanceClient,
|
|
23
21
|
PerformanceEvents,
|
|
24
|
-
StringUtils,
|
|
25
22
|
AzureCloudOptions,
|
|
26
23
|
invokeAsync,
|
|
27
24
|
} from "@azure/msal-common";
|
|
@@ -133,69 +130,6 @@ export abstract class BaseInteractionClient {
|
|
|
133
130
|
}
|
|
134
131
|
}
|
|
135
132
|
|
|
136
|
-
/**
|
|
137
|
-
* Initializer function for all request APIs
|
|
138
|
-
* @param request
|
|
139
|
-
*/
|
|
140
|
-
protected async initializeBaseRequest(
|
|
141
|
-
request: Partial<BaseAuthRequest>
|
|
142
|
-
): Promise<BaseAuthRequest> {
|
|
143
|
-
this.performanceClient.addQueueMeasurement(
|
|
144
|
-
PerformanceEvents.InitializeBaseRequest,
|
|
145
|
-
this.correlationId
|
|
146
|
-
);
|
|
147
|
-
const authority = request.authority || this.config.auth.authority;
|
|
148
|
-
|
|
149
|
-
const scopes = [...((request && request.scopes) || [])];
|
|
150
|
-
|
|
151
|
-
const validatedRequest: BaseAuthRequest = {
|
|
152
|
-
...request,
|
|
153
|
-
correlationId: this.correlationId,
|
|
154
|
-
authority,
|
|
155
|
-
scopes,
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// Set authenticationScheme to BEARER if not explicitly set in the request
|
|
159
|
-
if (!validatedRequest.authenticationScheme) {
|
|
160
|
-
validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;
|
|
161
|
-
this.logger.verbose(
|
|
162
|
-
'Authentication Scheme wasn\'t explicitly set in request, defaulting to "Bearer" request'
|
|
163
|
-
);
|
|
164
|
-
} else {
|
|
165
|
-
if (
|
|
166
|
-
validatedRequest.authenticationScheme ===
|
|
167
|
-
AuthenticationScheme.SSH
|
|
168
|
-
) {
|
|
169
|
-
if (!request.sshJwk) {
|
|
170
|
-
throw createClientConfigurationError(
|
|
171
|
-
ClientConfigurationErrorCodes.missingSshJwk
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
if (!request.sshKid) {
|
|
175
|
-
throw createClientConfigurationError(
|
|
176
|
-
ClientConfigurationErrorCodes.missingSshKid
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
this.logger.verbose(
|
|
181
|
-
`Authentication Scheme set to "${validatedRequest.authenticationScheme}" as configured in Auth request`
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Set requested claims hash if claims-based caching is enabled and claims were requested
|
|
186
|
-
if (
|
|
187
|
-
this.config.cache.claimsBasedCachingEnabled &&
|
|
188
|
-
request.claims &&
|
|
189
|
-
// Checks for empty stringified object "{}" which doesn't qualify as requested claims
|
|
190
|
-
!StringUtils.isEmptyObj(request.claims)
|
|
191
|
-
) {
|
|
192
|
-
validatedRequest.requestedClaimsHash =
|
|
193
|
-
await this.browserCrypto.hashString(request.claims);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return validatedRequest;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
133
|
/**
|
|
200
134
|
*
|
|
201
135
|
* Use to get the redirect uri configured in MSAL or null.
|
|
@@ -7,13 +7,9 @@ import { StandardInteractionClient } from "./StandardInteractionClient";
|
|
|
7
7
|
import {
|
|
8
8
|
CommonSilentFlowRequest,
|
|
9
9
|
SilentFlowClient,
|
|
10
|
-
ServerTelemetryManager,
|
|
11
|
-
AccountInfo,
|
|
12
|
-
AzureCloudOptions,
|
|
13
10
|
PerformanceEvents,
|
|
14
11
|
invokeAsync,
|
|
15
12
|
} from "@azure/msal-common";
|
|
16
|
-
import { SilentRequest } from "../request/SilentRequest";
|
|
17
13
|
import { ApiId } from "../utils/BrowserConstants";
|
|
18
14
|
import {
|
|
19
15
|
BrowserAuthError,
|
|
@@ -39,12 +35,22 @@ export class SilentCacheClient extends StandardInteractionClient {
|
|
|
39
35
|
ApiId.acquireTokenSilent_silentFlow
|
|
40
36
|
);
|
|
41
37
|
|
|
42
|
-
const
|
|
38
|
+
const clientConfig = await invokeAsync(
|
|
39
|
+
this.getClientConfiguration.bind(this),
|
|
40
|
+
PerformanceEvents.StandardInteractionClientGetClientConfiguration,
|
|
41
|
+
this.logger,
|
|
42
|
+
this.performanceClient,
|
|
43
|
+
this.correlationId
|
|
44
|
+
)(
|
|
43
45
|
serverTelemetryManager,
|
|
44
46
|
silentRequest.authority,
|
|
45
47
|
silentRequest.azureCloudOptions,
|
|
46
48
|
silentRequest.account
|
|
47
49
|
);
|
|
50
|
+
const silentAuthClient = new SilentFlowClient(
|
|
51
|
+
clientConfig,
|
|
52
|
+
this.performanceClient
|
|
53
|
+
);
|
|
48
54
|
this.logger.verbose("Silent auth client created");
|
|
49
55
|
|
|
50
56
|
try {
|
|
@@ -86,50 +92,4 @@ export class SilentCacheClient extends StandardInteractionClient {
|
|
|
86
92
|
const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
|
|
87
93
|
return this.clearCacheOnLogout(validLogoutRequest?.account);
|
|
88
94
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Creates an Silent Flow Client with the given authority, or the default authority.
|
|
92
|
-
* @param serverTelemetryManager
|
|
93
|
-
* @param authorityUrl
|
|
94
|
-
*/
|
|
95
|
-
protected async createSilentFlowClient(
|
|
96
|
-
serverTelemetryManager: ServerTelemetryManager,
|
|
97
|
-
authorityUrl?: string,
|
|
98
|
-
azureCloudOptions?: AzureCloudOptions,
|
|
99
|
-
account?: AccountInfo
|
|
100
|
-
): Promise<SilentFlowClient> {
|
|
101
|
-
// Create auth module.
|
|
102
|
-
const clientConfig = await invokeAsync(
|
|
103
|
-
this.getClientConfiguration.bind(this),
|
|
104
|
-
PerformanceEvents.StandardInteractionClientGetClientConfiguration,
|
|
105
|
-
this.logger,
|
|
106
|
-
this.performanceClient,
|
|
107
|
-
this.correlationId
|
|
108
|
-
)(serverTelemetryManager, authorityUrl, azureCloudOptions, account);
|
|
109
|
-
return new SilentFlowClient(clientConfig, this.performanceClient);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async initializeSilentRequest(
|
|
113
|
-
request: SilentRequest,
|
|
114
|
-
account: AccountInfo
|
|
115
|
-
): Promise<CommonSilentFlowRequest> {
|
|
116
|
-
this.performanceClient.addQueueMeasurement(
|
|
117
|
-
PerformanceEvents.InitializeSilentRequest,
|
|
118
|
-
this.correlationId
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const baseRequest = await invokeAsync(
|
|
122
|
-
this.initializeBaseRequest.bind(this),
|
|
123
|
-
PerformanceEvents.InitializeBaseRequest,
|
|
124
|
-
this.logger,
|
|
125
|
-
this.performanceClient,
|
|
126
|
-
this.correlationId
|
|
127
|
-
)(request);
|
|
128
|
-
return {
|
|
129
|
-
...request,
|
|
130
|
-
...baseRequest,
|
|
131
|
-
account: account,
|
|
132
|
-
forceRefresh: request.forceRefresh || false,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
95
|
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
BrowserAuthErrorCodes,
|
|
21
21
|
} from "../error/BrowserAuthError";
|
|
22
22
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
23
|
+
import { initializeBaseRequest } from "../request/RequestHelpers";
|
|
23
24
|
|
|
24
25
|
export class SilentRefreshClient extends StandardInteractionClient {
|
|
25
26
|
/**
|
|
@@ -35,12 +36,12 @@ export class SilentRefreshClient extends StandardInteractionClient {
|
|
|
35
36
|
);
|
|
36
37
|
|
|
37
38
|
const baseRequest = await invokeAsync(
|
|
38
|
-
|
|
39
|
+
initializeBaseRequest,
|
|
39
40
|
PerformanceEvents.InitializeBaseRequest,
|
|
40
41
|
this.logger,
|
|
41
42
|
this.performanceClient,
|
|
42
43
|
request.correlationId
|
|
43
|
-
)(request);
|
|
44
|
+
)(request, this.config, this.performanceClient, this.logger);
|
|
44
45
|
const silentRequest: CommonSilentFlowRequest = {
|
|
45
46
|
...request,
|
|
46
47
|
...baseRequest,
|
|
@@ -32,6 +32,7 @@ import { PopupRequest } from "../request/PopupRequest";
|
|
|
32
32
|
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
33
33
|
import { generatePkceCodes } from "../crypto/PkceGenerator";
|
|
34
34
|
import { createNewGuid } from "../crypto/BrowserCrypto";
|
|
35
|
+
import { initializeBaseRequest } from "../request/RequestHelpers";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Defines the class structure and helper functions used by the "standard", non-brokered auth flows (popup, redirect, silent (RT), silent (iframe))
|
|
@@ -315,12 +316,17 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
|
|
|
315
316
|
);
|
|
316
317
|
|
|
317
318
|
const baseRequest: BaseAuthRequest = await invokeAsync(
|
|
318
|
-
|
|
319
|
+
initializeBaseRequest,
|
|
319
320
|
PerformanceEvents.InitializeBaseRequest,
|
|
320
321
|
this.logger,
|
|
321
322
|
this.performanceClient,
|
|
322
323
|
this.correlationId
|
|
323
|
-
)(
|
|
324
|
+
)(
|
|
325
|
+
{ ...request, correlationId: this.correlationId },
|
|
326
|
+
this.config,
|
|
327
|
+
this.performanceClient,
|
|
328
|
+
this.logger
|
|
329
|
+
);
|
|
324
330
|
|
|
325
331
|
const validatedRequest: AuthorizationUrlRequest = {
|
|
326
332
|
...baseRequest,
|
|
@@ -23,12 +23,15 @@ import {
|
|
|
23
23
|
RequestParameterBuilder,
|
|
24
24
|
StringUtils,
|
|
25
25
|
createClientAuthError,
|
|
26
|
+
OIDC_DEFAULT_SCOPES,
|
|
26
27
|
} from "@azure/msal-common";
|
|
27
28
|
import { isBridgeError } from "../BridgeError";
|
|
28
29
|
import { BridgeStatusCode } from "../BridgeStatusCode";
|
|
29
30
|
import { AuthenticationResult } from "../../response/AuthenticationResult";
|
|
30
31
|
import {} from "../../error/BrowserAuthErrorCodes";
|
|
31
32
|
import { AuthResult } from "../AuthResult";
|
|
33
|
+
import { SsoSilentRequest } from "../../request/SsoSilentRequest";
|
|
34
|
+
import { SilentRequest } from "../../request/SilentRequest";
|
|
32
35
|
|
|
33
36
|
export class NestedAppAuthAdapter {
|
|
34
37
|
protected crypto: ICrypto;
|
|
@@ -49,7 +52,11 @@ export class NestedAppAuthAdapter {
|
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
public toNaaTokenRequest(
|
|
52
|
-
request:
|
|
55
|
+
request:
|
|
56
|
+
| PopupRequest
|
|
57
|
+
| RedirectRequest
|
|
58
|
+
| SilentRequest
|
|
59
|
+
| SsoSilentRequest
|
|
53
60
|
): TokenRequest {
|
|
54
61
|
let extraParams: Map<string, string>;
|
|
55
62
|
if (request.extraQueryParameters === undefined) {
|
|
@@ -65,11 +72,12 @@ export class NestedAppAuthAdapter {
|
|
|
65
72
|
request.claims,
|
|
66
73
|
this.clientCapabilities
|
|
67
74
|
);
|
|
75
|
+
const scopes = request.scopes || OIDC_DEFAULT_SCOPES;
|
|
68
76
|
const tokenRequest: TokenRequest = {
|
|
69
77
|
platformBrokerId: request.account?.homeAccountId,
|
|
70
78
|
clientId: this.clientId,
|
|
71
79
|
authority: request.authority,
|
|
72
|
-
scope:
|
|
80
|
+
scope: scopes.join(" "),
|
|
73
81
|
correlationId:
|
|
74
82
|
request.correlationId !== undefined
|
|
75
83
|
? request.correlationId
|
package/src/packageMetadata.ts
CHANGED