@azure/msal-browser 3.8.1-beta.0 → 3.10.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 (86) 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.mjs +1 -1
  17. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  18. package/dist/crypto/BrowserCrypto.mjs +1 -1
  19. package/dist/crypto/CryptoOps.mjs +1 -1
  20. package/dist/crypto/PkceGenerator.mjs +1 -1
  21. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  22. package/dist/encode/Base64Decode.mjs +1 -1
  23. package/dist/encode/Base64Encode.mjs +1 -1
  24. package/dist/error/BrowserAuthError.mjs +1 -1
  25. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  26. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  27. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  28. package/dist/error/NativeAuthError.mjs +1 -1
  29. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  30. package/dist/error/NestedAppAuthError.mjs +1 -1
  31. package/dist/event/EventHandler.mjs +1 -1
  32. package/dist/event/EventMessage.mjs +1 -1
  33. package/dist/event/EventType.mjs +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  36. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  37. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  38. package/dist/interaction_client/NativeInteractionClient.mjs +18 -6
  39. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  40. package/dist/interaction_client/PopupClient.mjs +1 -1
  41. package/dist/interaction_client/RedirectClient.mjs +1 -1
  42. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  43. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  44. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  45. package/dist/interaction_client/SilentIframeClient.mjs +14 -11
  46. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  47. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  48. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  49. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  50. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  51. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  52. package/dist/naa/BridgeError.mjs +1 -1
  53. package/dist/naa/BridgeProxy.mjs +1 -1
  54. package/dist/naa/BridgeStatusCode.mjs +1 -1
  55. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  56. package/dist/navigation/NavigationClient.mjs +1 -1
  57. package/dist/network/FetchClient.mjs +1 -1
  58. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  59. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  60. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  61. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  62. package/dist/packageMetadata.d.ts +1 -1
  63. package/dist/packageMetadata.d.ts.map +1 -1
  64. package/dist/packageMetadata.mjs +2 -2
  65. package/dist/response/ResponseHandler.mjs +1 -1
  66. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  67. package/dist/telemetry/BrowserPerformanceClient.mjs +3 -2
  68. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  69. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  70. package/dist/utils/BrowserConstants.mjs +1 -1
  71. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  72. package/dist/utils/BrowserUtils.d.ts +5 -0
  73. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  74. package/dist/utils/BrowserUtils.mjs +10 -2
  75. package/dist/utils/BrowserUtils.mjs.map +1 -1
  76. package/lib/msal-browser.cjs +252 -226
  77. package/lib/msal-browser.cjs.map +1 -1
  78. package/lib/msal-browser.js +252 -226
  79. package/lib/msal-browser.js.map +1 -1
  80. package/lib/msal-browser.min.js +58 -58
  81. package/package.json +2 -2
  82. package/src/interaction_client/NativeInteractionClient.ts +28 -9
  83. package/src/interaction_client/SilentIframeClient.ts +15 -16
  84. package/src/packageMetadata.ts +1 -1
  85. package/src/telemetry/BrowserPerformanceClient.ts +2 -1
  86. package/src/utils/BrowserUtils.ts +9 -0
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.8.1-beta.0",
13
+ "version": "3.10.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-beta.0"
104
+ "@azure/msal-common": "14.7.1"
105
105
  }
106
106
  }
@@ -262,6 +262,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
262
262
  const fullAccount = {
263
263
  ...account,
264
264
  idTokenClaims: result?.idTokenClaims as TokenClaims,
265
+ idToken: result?.idToken,
265
266
  };
266
267
 
267
268
  return {
@@ -416,24 +417,33 @@ export class NativeInteractionClient extends BaseInteractionClient {
416
417
  "NativeInteractionClient - handleNativeResponse called."
417
418
  );
418
419
 
419
- if (response.account.id !== request.accountId) {
420
- // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
421
- throw createNativeAuthError(NativeAuthErrorCodes.userSwitch);
422
- }
423
-
424
- // Get the preferred_cache domain for the given authority
425
- const authority = await this.getDiscoveredAuthority(request.authority);
426
-
427
420
  // generate identifiers
428
421
  const idTokenClaims = AuthToken.extractTokenClaims(
429
422
  response.id_token,
430
423
  base64Decode
431
424
  );
425
+
432
426
  const homeAccountIdentifier = this.createHomeAccountIdentifier(
433
427
  response,
434
428
  idTokenClaims
435
429
  );
436
430
 
431
+ const cachedhomeAccountId =
432
+ this.browserStorage.getAccountInfoFilteredBy({
433
+ nativeAccountId: request.accountId,
434
+ })?.homeAccountId;
435
+
436
+ if (
437
+ homeAccountIdentifier !== cachedhomeAccountId &&
438
+ response.account.id !== request.accountId
439
+ ) {
440
+ // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
441
+ throw createNativeAuthError(NativeAuthErrorCodes.userSwitch);
442
+ }
443
+
444
+ // Get the preferred_cache domain for the given authority
445
+ const authority = await this.getDiscoveredAuthority(request.authority);
446
+
437
447
  const baseAccount = buildAccountToCache(
438
448
  this.browserStorage,
439
449
  authority,
@@ -601,9 +611,18 @@ export class NativeInteractionClient extends BaseInteractionClient {
601
611
  const accountInfo: AccountInfo | null = updateAccountTenantProfileData(
602
612
  accountEntity.getAccountInfo(),
603
613
  undefined, // tenantProfile optional
604
- idTokenClaims
614
+ idTokenClaims,
615
+ response.id_token
605
616
  );
606
617
 
618
+ /**
619
+ * In pairwise broker flows, this check prevents the broker's native account id
620
+ * from being returned over the embedded app's account id.
621
+ */
622
+ if (accountInfo.nativeAccountId !== response.account.id) {
623
+ accountInfo.nativeAccountId = response.account.id;
624
+ }
625
+
607
626
  // generate PoP token as needed
608
627
  const responseAccessToken = await this.generatePopAccessToken(
609
628
  response,
@@ -93,15 +93,20 @@ export class SilentIframeClient extends StandardInteractionClient {
93
93
  );
94
94
  }
95
95
 
96
- // Check that prompt is set to none or no_session, throw error if it is set to anything else.
97
- if (
98
- request.prompt &&
99
- request.prompt !== PromptValue.NONE &&
100
- request.prompt !== PromptValue.NO_SESSION
101
- ) {
102
- throw createBrowserAuthError(
103
- BrowserAuthErrorCodes.silentPromptValueError
104
- );
96
+ // Check the prompt value
97
+ const inputRequest = { ...request };
98
+ if (inputRequest.prompt) {
99
+ if (
100
+ inputRequest.prompt !== PromptValue.NONE &&
101
+ inputRequest.prompt !== PromptValue.NO_SESSION
102
+ ) {
103
+ this.logger.warning(
104
+ `SilentIframeClient. Replacing invalid prompt ${inputRequest.prompt} with ${PromptValue.NONE}`
105
+ );
106
+ inputRequest.prompt = PromptValue.NONE;
107
+ }
108
+ } else {
109
+ inputRequest.prompt = PromptValue.NONE;
105
110
  }
106
111
 
107
112
  // Create silent request
@@ -111,13 +116,7 @@ export class SilentIframeClient extends StandardInteractionClient {
111
116
  this.logger,
112
117
  this.performanceClient,
113
118
  request.correlationId
114
- )(
115
- {
116
- ...request,
117
- prompt: request.prompt || PromptValue.NONE,
118
- },
119
- InteractionType.Silent
120
- );
119
+ )(inputRequest, InteractionType.Silent);
121
120
  BrowserUtils.preconnect(silentRequest.authority);
122
121
 
123
122
  const serverTelemetryManager = this.initializeServerTelemetryManager(
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.8.1-beta.0";
3
+ export const version = "3.10.0";
@@ -20,6 +20,7 @@ import {
20
20
  BROWSER_PERF_ENABLED_KEY,
21
21
  BrowserCacheLocation,
22
22
  } from "../utils/BrowserConstants";
23
+ import * as BrowserCrypto from "../crypto/BrowserCrypto";
23
24
 
24
25
  /**
25
26
  * Returns browser performance measurement module if session flag is enabled. Returns undefined otherwise.
@@ -88,7 +89,7 @@ export class BrowserPerformanceClient
88
89
  }
89
90
 
90
91
  generateId(): string {
91
- return window.crypto.randomUUID();
92
+ return BrowserCrypto.createNewGuid();
92
93
  }
93
94
 
94
95
  private getPageVisibility(): string | null {
@@ -9,6 +9,7 @@ import {
9
9
  BrowserAuthErrorCodes,
10
10
  } from "../error/BrowserAuthError";
11
11
  import { InteractionType, BrowserConstants } from "./BrowserConstants";
12
+ import * as BrowserCrypto from "../crypto/BrowserCrypto";
12
13
 
13
14
  /**
14
15
  * Clears hash from window url.
@@ -162,3 +163,11 @@ export function preconnect(authority: string): void {
162
163
  } catch {}
163
164
  }, 10000); // 10s Timeout
164
165
  }
166
+
167
+ /**
168
+ * Wrapper function that creates a UUID v7 from the current timestamp.
169
+ * @returns {string}
170
+ */
171
+ export function createGuid(): string {
172
+ return BrowserCrypto.createNewGuid();
173
+ }