@azure/msal-browser 3.7.2-alpha.3 → 3.9.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.
Files changed (84) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/app/PublicClientNext.mjs +1 -1
  4. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  5. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  6. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  7. package/dist/cache/BrowserCacheManager.mjs +1 -1
  8. package/dist/cache/BrowserStorage.mjs +1 -1
  9. package/dist/cache/CryptoKeyStore.mjs +1 -1
  10. package/dist/cache/DatabaseStorage.mjs +1 -1
  11. package/dist/cache/MemoryStorage.mjs +1 -1
  12. package/dist/cache/TokenCache.mjs +1 -1
  13. package/dist/config/Configuration.mjs +1 -1
  14. package/dist/controllers/ControllerFactory.mjs +1 -1
  15. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  16. package/dist/controllers/StandardController.d.ts.map +1 -1
  17. package/dist/controllers/StandardController.mjs +32 -14
  18. package/dist/controllers/StandardController.mjs.map +1 -1
  19. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  20. package/dist/crypto/BrowserCrypto.mjs +1 -1
  21. package/dist/crypto/CryptoOps.mjs +1 -1
  22. package/dist/crypto/PkceGenerator.mjs +1 -1
  23. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  24. package/dist/encode/Base64Decode.mjs +1 -1
  25. package/dist/encode/Base64Encode.mjs +1 -1
  26. package/dist/error/BrowserAuthError.mjs +1 -1
  27. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  28. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  29. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  30. package/dist/error/NativeAuthError.mjs +1 -1
  31. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  32. package/dist/error/NestedAppAuthError.mjs +1 -1
  33. package/dist/event/EventHandler.mjs +1 -1
  34. package/dist/event/EventMessage.mjs +1 -1
  35. package/dist/event/EventType.mjs +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  38. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  39. package/dist/interaction_client/NativeInteractionClient.d.ts +3 -1
  40. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  41. package/dist/interaction_client/NativeInteractionClient.mjs +7 -2
  42. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  43. package/dist/interaction_client/PopupClient.mjs +1 -1
  44. package/dist/interaction_client/RedirectClient.d.ts +4 -2
  45. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  46. package/dist/interaction_client/RedirectClient.mjs +8 -3
  47. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  48. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  49. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  50. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  51. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  52. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  53. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  54. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  55. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  56. package/dist/naa/BridgeError.mjs +1 -1
  57. package/dist/naa/BridgeProxy.mjs +1 -1
  58. package/dist/naa/BridgeStatusCode.mjs +1 -1
  59. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  60. package/dist/navigation/NavigationClient.mjs +1 -1
  61. package/dist/network/FetchClient.mjs +1 -1
  62. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  63. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  64. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  65. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  66. package/dist/packageMetadata.d.ts +1 -1
  67. package/dist/packageMetadata.d.ts.map +1 -1
  68. package/dist/packageMetadata.mjs +2 -2
  69. package/dist/response/ResponseHandler.mjs +1 -1
  70. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  71. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  72. package/dist/utils/BrowserConstants.mjs +1 -1
  73. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  74. package/dist/utils/BrowserUtils.mjs +1 -1
  75. package/lib/msal-browser.cjs +113 -79
  76. package/lib/msal-browser.cjs.map +1 -1
  77. package/lib/msal-browser.js +113 -79
  78. package/lib/msal-browser.js.map +1 -1
  79. package/lib/msal-browser.min.js +62 -62
  80. package/package.json +2 -2
  81. package/src/controllers/StandardController.ts +61 -22
  82. package/src/interaction_client/NativeInteractionClient.ts +12 -1
  83. package/src/interaction_client/RedirectClient.ts +12 -2
  84. package/src/packageMetadata.ts +1 -1
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": "3.7.2-alpha.3",
13
+ "version": "3.9.0",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -101,6 +101,6 @@
101
101
  "typescript": "^4.9.5"
102
102
  },
103
103
  "dependencies": {
104
- "@azure/msal-common": "14.6.2-alpha.3"
104
+ "@azure/msal-common": "14.7.0"
105
105
  }
106
106
  }
@@ -345,18 +345,9 @@ export class StandardController implements IController {
345
345
  const redirectResponseKey = hash || "";
346
346
  let response = this.redirectResponse.get(redirectResponseKey);
347
347
  if (typeof response === "undefined") {
348
- this.eventHandler.emitEvent(
349
- EventType.HANDLE_REDIRECT_START,
350
- InteractionType.Redirect
351
- );
352
- this.logger.verbose(
353
- "handleRedirectPromise has been called for the first time, storing the promise"
354
- );
355
-
356
348
  const request: NativeTokenRequest | null =
357
349
  this.browserStorage.getCachedNativeRequest();
358
- let redirectResponse: Promise<AuthenticationResult | null>;
359
- if (
350
+ const useNative =
360
351
  request &&
361
352
  NativeMessageHandler.isNativeAvailable(
362
353
  this.config,
@@ -364,8 +355,26 @@ export class StandardController implements IController {
364
355
  this.nativeExtensionProvider
365
356
  ) &&
366
357
  this.nativeExtensionProvider &&
367
- !hash
368
- ) {
358
+ !hash;
359
+ const correlationId = useNative
360
+ ? request?.correlationId
361
+ : this.browserStorage.getTemporaryCache(
362
+ TemporaryCacheKeys.CORRELATION_ID,
363
+ true
364
+ ) || "";
365
+ const rootMeasurement = this.performanceClient.startMeasurement(
366
+ "acquireTokenRedirect",
367
+ correlationId
368
+ );
369
+ this.eventHandler.emitEvent(
370
+ EventType.HANDLE_REDIRECT_START,
371
+ InteractionType.Redirect
372
+ );
373
+ this.logger.verbose(
374
+ "handleRedirectPromise has been called for the first time, storing the promise"
375
+ );
376
+ let redirectResponse: Promise<AuthenticationResult | null>;
377
+ if (useNative && this.nativeExtensionProvider) {
369
378
  this.logger.trace(
370
379
  "handleRedirectPromise - acquiring token from native platform"
371
380
  );
@@ -383,20 +392,36 @@ export class StandardController implements IController {
383
392
  this.nativeInternalStorage,
384
393
  request.correlationId
385
394
  );
386
- redirectResponse = nativeClient.handleRedirectPromise();
395
+
396
+ redirectResponse = invokeAsync(
397
+ nativeClient.handleRedirectPromise.bind(nativeClient),
398
+ PerformanceEvents.HandleNativeRedirectPromiseMeasurement,
399
+ this.logger,
400
+ this.performanceClient,
401
+ rootMeasurement.event.correlationId
402
+ )(
403
+ this.performanceClient,
404
+ rootMeasurement.event.correlationId
405
+ );
387
406
  } else {
388
407
  this.logger.trace(
389
408
  "handleRedirectPromise - acquiring token from web flow"
390
409
  );
391
- const correlationId =
392
- this.browserStorage.getTemporaryCache(
393
- TemporaryCacheKeys.CORRELATION_ID,
394
- true
395
- ) || Constants.EMPTY_STRING;
396
410
  const redirectClient =
397
411
  this.createRedirectClient(correlationId);
398
- redirectResponse =
399
- redirectClient.handleRedirectPromise(hash);
412
+ redirectResponse = invokeAsync(
413
+ redirectClient.handleRedirectPromise.bind(
414
+ redirectClient
415
+ ),
416
+ PerformanceEvents.HandleRedirectPromiseMeasurement,
417
+ this.logger,
418
+ this.performanceClient,
419
+ rootMeasurement.event.correlationId
420
+ )(
421
+ hash,
422
+ this.performanceClient,
423
+ rootMeasurement.event.correlationId
424
+ );
400
425
  }
401
426
 
402
427
  response = redirectResponse
@@ -426,35 +451,49 @@ export class StandardController implements IController {
426
451
  "handleRedirectResponse returned result, acquire token success"
427
452
  );
428
453
  }
454
+ rootMeasurement.end({ success: true });
429
455
  }
430
456
  this.eventHandler.emitEvent(
431
457
  EventType.HANDLE_REDIRECT_END,
432
458
  InteractionType.Redirect
433
459
  );
460
+ rootMeasurement.end({ success: false });
434
461
 
435
462
  return result;
436
463
  })
437
464
  .catch((e) => {
465
+ const eventError = e as EventError;
438
466
  // Emit login event if there is an account
439
467
  if (loggedInAccounts.length > 0) {
440
468
  this.eventHandler.emitEvent(
441
469
  EventType.ACQUIRE_TOKEN_FAILURE,
442
470
  InteractionType.Redirect,
443
471
  null,
444
- e as EventError
472
+ eventError
445
473
  );
446
474
  } else {
447
475
  this.eventHandler.emitEvent(
448
476
  EventType.LOGIN_FAILURE,
449
477
  InteractionType.Redirect,
450
478
  null,
451
- e as EventError
479
+ eventError
452
480
  );
453
481
  }
454
482
  this.eventHandler.emitEvent(
455
483
  EventType.HANDLE_REDIRECT_END,
456
484
  InteractionType.Redirect
457
485
  );
486
+ if (eventError instanceof AuthError) {
487
+ rootMeasurement.end({
488
+ success: false,
489
+ errorCode: eventError.errorCode,
490
+ subErrorCode: eventError.subError,
491
+ });
492
+ } else {
493
+ rootMeasurement.end({
494
+ success: false,
495
+ });
496
+ }
458
497
 
459
498
  throw e;
460
499
  });
@@ -320,8 +320,13 @@ export class NativeInteractionClient extends BaseInteractionClient {
320
320
 
321
321
  /**
322
322
  * If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
323
+ * @param performanceClient {IPerformanceClient?}
324
+ * @param correlationId {string?} correlation identifier
323
325
  */
324
- async handleRedirectPromise(): Promise<AuthenticationResult | null> {
326
+ async handleRedirectPromise(
327
+ performanceClient?: IPerformanceClient,
328
+ correlationId?: string
329
+ ): Promise<AuthenticationResult | null> {
325
330
  this.logger.trace(
326
331
  "NativeInteractionClient - handleRedirectPromise called."
327
332
  );
@@ -338,6 +343,12 @@ export class NativeInteractionClient extends BaseInteractionClient {
338
343
  this.logger.verbose(
339
344
  "NativeInteractionClient - handleRedirectPromise called but there is no cached request, returning null."
340
345
  );
346
+ if (performanceClient && correlationId) {
347
+ performanceClient?.addFields(
348
+ { errorCode: "no_cached_request" },
349
+ correlationId
350
+ );
351
+ }
341
352
  return null;
342
353
  }
343
354
 
@@ -190,10 +190,14 @@ export class RedirectClient extends StandardInteractionClient {
190
190
  * Checks if navigateToLoginRequestUrl is set, and:
191
191
  * - if true, performs logic to cache and navigate
192
192
  * - if false, handles hash string and parses response
193
- * @param hash
193
+ * @param hash {string?} url hash
194
+ * @param performanceClient {IPerformanceClient?}
195
+ * @param correlationId {string?} correlation identifier
194
196
  */
195
197
  async handleRedirectPromise(
196
- hash?: string
198
+ hash?: string,
199
+ performanceClient?: IPerformanceClient,
200
+ correlationId?: string
197
201
  ): Promise<AuthenticationResult | null> {
198
202
  const serverTelemetryManager = this.initializeServerTelemetryManager(
199
203
  ApiId.handleRedirectPromise
@@ -216,6 +220,12 @@ export class RedirectClient extends StandardInteractionClient {
216
220
  this.browserStorage.cleanRequestByInteractionType(
217
221
  InteractionType.Redirect
218
222
  );
223
+ if (performanceClient && correlationId) {
224
+ performanceClient?.addFields(
225
+ { errorCode: "no_server_response" },
226
+ correlationId
227
+ );
228
+ }
219
229
  return null;
220
230
  }
221
231
 
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.7.2-alpha.3";
3
+ export const version = "3.9.0";