@azure/msal-browser 4.0.0-alpha.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/PublicClientApplication.mjs +4 -2
  4. package/dist/app/PublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientNext.mjs +1 -1
  6. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  7. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  8. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +8 -8
  9. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  10. package/dist/broker/nativeBroker/NativeResponse.d.ts +1 -1
  11. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  12. package/dist/cache/AccountManager.mjs +1 -1
  13. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  14. package/dist/cache/BrowserCacheManager.d.ts +10 -15
  15. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  16. package/dist/cache/BrowserCacheManager.mjs +42 -43
  17. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  18. package/dist/cache/CacheHelpers.mjs +1 -1
  19. package/dist/cache/CookieStorage.mjs +1 -1
  20. package/dist/cache/CookieStorage.mjs.map +1 -1
  21. package/dist/cache/DatabaseStorage.mjs +1 -1
  22. package/dist/cache/IWindowStorage.d.ts +2 -2
  23. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  24. package/dist/cache/LocalStorage.d.ts +7 -3
  25. package/dist/cache/LocalStorage.d.ts.map +1 -1
  26. package/dist/cache/LocalStorage.mjs +48 -34
  27. package/dist/cache/LocalStorage.mjs.map +1 -1
  28. package/dist/cache/MemoryStorage.mjs +1 -1
  29. package/dist/cache/SessionStorage.mjs +1 -1
  30. package/dist/cache/TokenCache.d.ts.map +1 -1
  31. package/dist/cache/TokenCache.mjs +15 -14
  32. package/dist/cache/TokenCache.mjs.map +1 -1
  33. package/dist/config/Configuration.d.ts +2 -2
  34. package/dist/config/Configuration.d.ts.map +1 -1
  35. package/dist/config/Configuration.mjs +5 -5
  36. package/dist/config/Configuration.mjs.map +1 -1
  37. package/dist/controllers/ControllerFactory.mjs +1 -1
  38. package/dist/controllers/NestedAppAuthController.d.ts +6 -3
  39. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  40. package/dist/controllers/NestedAppAuthController.mjs +34 -18
  41. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  42. package/dist/controllers/StandardController.d.ts +2 -2
  43. package/dist/controllers/StandardController.d.ts.map +1 -1
  44. package/dist/controllers/StandardController.mjs +27 -23
  45. package/dist/controllers/StandardController.mjs.map +1 -1
  46. package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
  47. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  48. package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
  49. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  50. package/dist/crypto/BrowserCrypto.d.ts +1 -1
  51. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  52. package/dist/crypto/BrowserCrypto.mjs +3 -3
  53. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  54. package/dist/crypto/CryptoOps.d.ts +1 -1
  55. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  56. package/dist/crypto/CryptoOps.mjs +3 -3
  57. package/dist/crypto/CryptoOps.mjs.map +1 -1
  58. package/dist/crypto/PkceGenerator.mjs +1 -1
  59. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  60. package/dist/encode/Base64Decode.mjs +1 -1
  61. package/dist/encode/Base64Encode.mjs +1 -1
  62. package/dist/error/BrowserAuthError.mjs +1 -1
  63. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  64. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  65. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  66. package/dist/error/NativeAuthError.mjs +1 -1
  67. package/dist/error/NativeAuthError.mjs.map +1 -1
  68. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  69. package/dist/error/NestedAppAuthError.mjs +1 -1
  70. package/dist/event/EventHandler.mjs +1 -1
  71. package/dist/event/EventMessage.mjs +1 -1
  72. package/dist/event/EventType.mjs +1 -1
  73. package/dist/index.mjs +1 -1
  74. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  75. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  76. package/dist/interaction_client/NativeInteractionClient.d.ts +2 -3
  77. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  78. package/dist/interaction_client/NativeInteractionClient.mjs +11 -9
  79. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  80. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  81. package/dist/interaction_client/PopupClient.mjs +4 -4
  82. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  83. package/dist/interaction_client/RedirectClient.mjs +2 -2
  84. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  85. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  86. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  87. package/dist/interaction_client/SilentIframeClient.mjs +2 -2
  88. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  89. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  90. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  91. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  92. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  93. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  94. package/dist/naa/BridgeError.mjs +1 -1
  95. package/dist/naa/BridgeProxy.mjs +1 -1
  96. package/dist/naa/BridgeStatusCode.mjs +1 -1
  97. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  98. package/dist/navigation/NavigationClient.mjs +1 -1
  99. package/dist/network/FetchClient.mjs +1 -1
  100. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  101. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  102. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  103. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  104. package/dist/packageMetadata.d.ts +1 -1
  105. package/dist/packageMetadata.d.ts.map +1 -1
  106. package/dist/packageMetadata.mjs +2 -2
  107. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  108. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  109. package/dist/request/PopupRequest.d.ts +1 -1
  110. package/dist/request/PopupRequest.d.ts.map +1 -1
  111. package/dist/request/RedirectRequest.d.ts +1 -1
  112. package/dist/request/RedirectRequest.d.ts.map +1 -1
  113. package/dist/request/RequestHelpers.mjs +1 -1
  114. package/dist/request/SsoSilentRequest.d.ts +1 -1
  115. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  116. package/dist/response/ResponseHandler.mjs +1 -1
  117. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  118. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  119. package/dist/utils/BrowserConstants.mjs +1 -1
  120. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  121. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  122. package/dist/utils/BrowserUtils.mjs +4 -2
  123. package/dist/utils/BrowserUtils.mjs.map +1 -1
  124. package/lib/msal-browser.cjs +298 -249
  125. package/lib/msal-browser.cjs.map +1 -1
  126. package/lib/msal-browser.js +298 -249
  127. package/lib/msal-browser.js.map +1 -1
  128. package/lib/msal-browser.min.js +63 -63
  129. package/lib/types/app/PublicClientApplication.d.ts.map +1 -1
  130. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  131. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  132. package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
  133. package/lib/types/cache/BrowserCacheManager.d.ts +10 -15
  134. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  135. package/lib/types/cache/IWindowStorage.d.ts +2 -2
  136. package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
  137. package/lib/types/cache/LocalStorage.d.ts +7 -3
  138. package/lib/types/cache/LocalStorage.d.ts.map +1 -1
  139. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  140. package/lib/types/config/Configuration.d.ts +2 -2
  141. package/lib/types/config/Configuration.d.ts.map +1 -1
  142. package/lib/types/controllers/NestedAppAuthController.d.ts +6 -3
  143. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  144. package/lib/types/controllers/StandardController.d.ts +2 -2
  145. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  146. package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
  147. package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  148. package/lib/types/crypto/BrowserCrypto.d.ts +1 -1
  149. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  150. package/lib/types/crypto/CryptoOps.d.ts +1 -1
  151. package/lib/types/crypto/CryptoOps.d.ts.map +1 -1
  152. package/lib/types/interaction_client/NativeInteractionClient.d.ts +2 -3
  153. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  154. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  155. package/lib/types/packageMetadata.d.ts +1 -1
  156. package/lib/types/packageMetadata.d.ts.map +1 -1
  157. package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
  158. package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
  159. package/lib/types/request/PopupRequest.d.ts +1 -1
  160. package/lib/types/request/PopupRequest.d.ts.map +1 -1
  161. package/lib/types/request/RedirectRequest.d.ts +1 -1
  162. package/lib/types/request/RedirectRequest.d.ts.map +1 -1
  163. package/lib/types/request/SsoSilentRequest.d.ts +1 -1
  164. package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
  165. package/lib/types/utils/BrowserUtils.d.ts.map +1 -1
  166. package/package.json +2 -2
  167. package/src/app/PublicClientApplication.ts +6 -1
  168. package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
  169. package/src/broker/nativeBroker/NativeResponse.ts +1 -1
  170. package/src/cache/BrowserCacheManager.ts +88 -57
  171. package/src/cache/IWindowStorage.ts +2 -2
  172. package/src/cache/LocalStorage.ts +142 -43
  173. package/src/cache/TokenCache.ts +28 -11
  174. package/src/config/Configuration.ts +6 -6
  175. package/src/controllers/NestedAppAuthController.ts +51 -23
  176. package/src/controllers/StandardController.ts +41 -24
  177. package/src/controllers/UnknownOperatingContextController.ts +6 -5
  178. package/src/crypto/BrowserCrypto.ts +4 -2
  179. package/src/crypto/CryptoOps.ts +8 -2
  180. package/src/interaction_client/NativeInteractionClient.ts +16 -16
  181. package/src/interaction_client/PopupClient.ts +9 -8
  182. package/src/interaction_client/RedirectClient.ts +1 -1
  183. package/src/interaction_client/SilentIframeClient.ts +1 -1
  184. package/src/packageMetadata.ts +1 -1
  185. package/src/request/AuthorizationUrlRequest.ts +1 -1
  186. package/src/request/PopupRequest.ts +1 -1
  187. package/src/request/RedirectRequest.ts +1 -1
  188. package/src/request/SsoSilentRequest.ts +1 -1
  189. package/src/utils/BrowserUtils.ts +3 -1
@@ -83,7 +83,6 @@ export class NativeInteractionClient extends BaseInteractionClient {
83
83
  protected silentCacheClient: SilentCacheClient;
84
84
  protected nativeStorageManager: BrowserCacheManager;
85
85
  protected skus: string;
86
- protected serverTelemetryManager: ServerTelemetryManager;
87
86
 
88
87
  constructor(
89
88
  config: BrowserConfiguration,
@@ -125,9 +124,6 @@ export class NativeInteractionClient extends BaseInteractionClient {
125
124
  provider,
126
125
  correlationId
127
126
  );
128
- this.serverTelemetryManager = this.initializeServerTelemetryManager(
129
- this.apiId
130
- );
131
127
 
132
128
  const extensionName =
133
129
  this.nativeMessageHandler.getExtensionId() ===
@@ -176,6 +172,9 @@ export class NativeInteractionClient extends BaseInteractionClient {
176
172
  );
177
173
  const reqTimestamp = TimeUtils.nowSeconds();
178
174
 
175
+ const serverTelemetryManager = this.initializeServerTelemetryManager(
176
+ this.apiId
177
+ );
179
178
  try {
180
179
  // initialize native request
181
180
  const nativeRequest = await this.initializeNativeRequest(request);
@@ -223,7 +222,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
223
222
  isNativeBroker: true,
224
223
  requestId: result.requestId,
225
224
  });
226
- this.serverTelemetryManager.clearNativeBrokerErrorCode();
225
+ serverTelemetryManager.clearNativeBrokerErrorCode();
227
226
  return result;
228
227
  })
229
228
  .catch((error: AuthError) => {
@@ -237,9 +236,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
237
236
  });
238
237
  } catch (e) {
239
238
  if (e instanceof NativeAuthError) {
240
- this.serverTelemetryManager.setNativeBrokerErrorCode(
241
- e.errorCode
242
- );
239
+ serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
243
240
  }
244
241
  throw e;
245
242
  }
@@ -346,9 +343,9 @@ export class NativeInteractionClient extends BaseInteractionClient {
346
343
  } catch (e) {
347
344
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
348
345
  if (e instanceof NativeAuthError) {
349
- this.serverTelemetryManager.setNativeBrokerErrorCode(
350
- e.errorCode
351
- );
346
+ const serverTelemetryManager =
347
+ this.initializeServerTelemetryManager(this.apiId);
348
+ serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
352
349
  if (isFatalNativeAuthError(e)) {
353
350
  throw e;
354
351
  }
@@ -443,7 +440,9 @@ export class NativeInteractionClient extends BaseInteractionClient {
443
440
  );
444
441
  this.browserStorage.setInteractionInProgress(false);
445
442
  const res = await result;
446
- this.serverTelemetryManager.clearNativeBrokerErrorCode();
443
+ const serverTelemetryManager =
444
+ this.initializeServerTelemetryManager(this.apiId);
445
+ serverTelemetryManager.clearNativeBrokerErrorCode();
447
446
  return res;
448
447
  } catch (e) {
449
448
  this.browserStorage.setInteractionInProgress(false);
@@ -530,7 +529,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
530
529
 
531
530
  // cache accounts and tokens in the appropriate storage
532
531
  await this.cacheAccount(baseAccount);
533
- this.cacheNativeTokens(
532
+ await this.cacheNativeTokens(
534
533
  response,
535
534
  request,
536
535
  homeAccountIdentifier,
@@ -724,7 +723,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
724
723
  */
725
724
  async cacheAccount(accountEntity: AccountEntity): Promise<void> {
726
725
  // Store the account info and hence `nativeAccountId` in browser cache
727
- await this.browserStorage.setAccount(accountEntity);
726
+ await this.browserStorage.setAccount(accountEntity, this.correlationId);
728
727
 
729
728
  // Remove any existing cached tokens for this account in browser storage
730
729
  this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
@@ -752,7 +751,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
752
751
  responseAccessToken: string,
753
752
  tenantId: string,
754
753
  reqTimestamp: number
755
- ): void {
754
+ ): Promise<void> {
756
755
  const cachedIdToken: IdTokenEntity | null =
757
756
  CacheHelpers.createIdTokenEntity(
758
757
  homeAccountIdentifier,
@@ -794,8 +793,9 @@ export class NativeInteractionClient extends BaseInteractionClient {
794
793
  accessToken: cachedAccessToken,
795
794
  };
796
795
 
797
- void this.nativeStorageManager.saveCacheRecord(
796
+ return this.nativeStorageManager.saveCacheRecord(
798
797
  nativeCacheRecord,
798
+ this.correlationId,
799
799
  request.storeInCache
800
800
  );
801
801
  }
@@ -227,15 +227,16 @@ export class PopupClient extends StandardInteractionClient {
227
227
  account: validRequest.account,
228
228
  });
229
229
 
230
- const isNativeBroker = NativeMessageHandler.isNativeAvailable(
231
- this.config,
232
- this.logger,
233
- this.nativeMessageHandler,
234
- request.authenticationScheme
235
- );
230
+ const isPlatformBroker =
231
+ NativeMessageHandler.isPlatformBrokerAvailable(
232
+ this.config,
233
+ this.logger,
234
+ this.nativeMessageHandler,
235
+ request.authenticationScheme
236
+ );
236
237
  // Start measurement for server calls with native brokering enabled
237
238
  let fetchNativeAccountIdMeasurement;
238
- if (isNativeBroker) {
239
+ if (isPlatformBroker) {
239
240
  fetchNativeAccountIdMeasurement =
240
241
  this.performanceClient.startMeasurement(
241
242
  PerformanceEvents.FetchAccountIdWithNativeBroker,
@@ -246,7 +247,7 @@ export class PopupClient extends StandardInteractionClient {
246
247
  // Create acquire token url.
247
248
  const navigateUrl = await authClient.getAuthCodeUrl({
248
249
  ...validRequest,
249
- nativeBroker: isNativeBroker,
250
+ platformBroker: isPlatformBroker,
250
251
  });
251
252
 
252
253
  // Create popup interaction handler.
@@ -170,7 +170,7 @@ export class RedirectClient extends StandardInteractionClient {
170
170
  // Create acquire token url.
171
171
  const navigateUrl = await authClient.getAuthCodeUrl({
172
172
  ...validRequest,
173
- nativeBroker: NativeMessageHandler.isNativeAvailable(
173
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(
174
174
  this.config,
175
175
  this.logger,
176
176
  this.nativeMessageHandler,
@@ -239,7 +239,7 @@ export class SilentIframeClient extends StandardInteractionClient {
239
239
  correlationId
240
240
  )({
241
241
  ...silentRequest,
242
- nativeBroker: NativeMessageHandler.isNativeAvailable(
242
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(
243
243
  this.config,
244
244
  this.logger,
245
245
  this.nativeMessageHandler,
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "4.0.0-alpha.0";
3
+ export const version = "4.0.2";
@@ -10,7 +10,7 @@ import { CommonAuthorizationUrlRequest } from "@azure/msal-common/browser";
10
10
  */
11
11
  export type AuthorizationUrlRequest = Omit<
12
12
  CommonAuthorizationUrlRequest,
13
- "state" | "nonce" | "requestedClaimsHash" | "nativeBroker"
13
+ "state" | "nonce" | "requestedClaimsHash" | "platformBroker"
14
14
  > & {
15
15
  state: string;
16
16
  nonce: string;
@@ -46,7 +46,7 @@ export type PopupRequest = Partial<
46
46
  | "codeChallenge"
47
47
  | "codeChallengeMethod"
48
48
  | "requestedClaimsHash"
49
- | "nativeBroker"
49
+ | "platformBroker"
50
50
  >
51
51
  > & {
52
52
  scopes: Array<string>;
@@ -44,7 +44,7 @@ export type RedirectRequest = Partial<
44
44
  | "codeChallenge"
45
45
  | "codeChallengeMethod"
46
46
  | "requestedClaimsHash"
47
- | "nativeBroker"
47
+ | "platformBroker"
48
48
  >
49
49
  > & {
50
50
  scopes: Array<string>;
@@ -40,7 +40,7 @@ export type SsoSilentRequest = Partial<
40
40
  | "codeChallenge"
41
41
  | "codeChallengeMethod"
42
42
  | "requestedClaimsHash"
43
- | "nativeBroker"
43
+ | "platformBroker"
44
44
  >
45
45
  > & {
46
46
  tokenBodyParameters?: StringDict;
@@ -67,7 +67,9 @@ export function isInPopup(): boolean {
67
67
  * Returns current window URL as redirect uri
68
68
  */
69
69
  export function getCurrentUri(): string {
70
- return window.location.href.split("?")[0].split("#")[0];
70
+ return typeof window !== "undefined" && window.location
71
+ ? window.location.href.split("?")[0].split("#")[0]
72
+ : "";
71
73
  }
72
74
 
73
75
  /**