@azure/msal-browser 3.9.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.
Files changed (155) 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.d.ts +2 -3
  7. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  8. package/dist/cache/AsyncMemoryStorage.mjs +4 -5
  9. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  10. package/dist/cache/BrowserCacheManager.d.ts +8 -27
  11. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  12. package/dist/cache/BrowserCacheManager.mjs +48 -75
  13. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  14. package/dist/cache/BrowserStorage.mjs +1 -1
  15. package/dist/cache/DatabaseStorage.d.ts +1 -1
  16. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +14 -4
  18. package/dist/cache/DatabaseStorage.mjs.map +1 -1
  19. package/dist/cache/{IAsyncMemoryStorage.d.ts → IAsyncStorage.d.ts} +1 -1
  20. package/dist/cache/IAsyncStorage.d.ts.map +1 -0
  21. package/dist/cache/MemoryStorage.mjs +1 -1
  22. package/dist/cache/TokenCache.mjs +1 -1
  23. package/dist/config/Configuration.mjs +1 -1
  24. package/dist/controllers/ControllerFactory.mjs +1 -1
  25. package/dist/controllers/IController.d.ts +1 -3
  26. package/dist/controllers/IController.d.ts.map +1 -1
  27. package/dist/controllers/NestedAppAuthController.d.ts +2 -3
  28. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  29. package/dist/controllers/NestedAppAuthController.mjs +21 -19
  30. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  31. package/dist/controllers/StandardController.d.ts +5 -23
  32. package/dist/controllers/StandardController.d.ts.map +1 -1
  33. package/dist/controllers/StandardController.mjs +47 -127
  34. package/dist/controllers/StandardController.mjs.map +1 -1
  35. package/dist/controllers/UnknownOperatingContextController.d.ts +1 -2
  36. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  37. package/dist/controllers/UnknownOperatingContextController.mjs +28 -36
  38. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  39. package/dist/crypto/BrowserCrypto.d.ts +5 -0
  40. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  41. package/dist/crypto/BrowserCrypto.mjs +12 -2
  42. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  43. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  44. package/dist/crypto/CryptoOps.mjs +28 -12
  45. package/dist/crypto/CryptoOps.mjs.map +1 -1
  46. package/dist/crypto/PkceGenerator.mjs +1 -1
  47. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  48. package/dist/encode/Base64Decode.mjs +1 -1
  49. package/dist/encode/Base64Encode.mjs +1 -1
  50. package/dist/error/BrowserAuthError.mjs +1 -1
  51. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  52. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  53. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  54. package/dist/error/NativeAuthError.mjs +1 -1
  55. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  56. package/dist/error/NestedAppAuthError.mjs +1 -1
  57. package/dist/event/EventHandler.mjs +1 -1
  58. package/dist/event/EventMessage.mjs +1 -1
  59. package/dist/event/EventType.mjs +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.mjs +2 -2
  63. package/dist/interaction_client/BaseInteractionClient.d.ts +1 -6
  64. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  65. package/dist/interaction_client/BaseInteractionClient.mjs +2 -43
  66. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  67. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  68. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  69. package/dist/interaction_client/NativeInteractionClient.mjs +18 -6
  70. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  71. package/dist/interaction_client/PopupClient.mjs +1 -1
  72. package/dist/interaction_client/RedirectClient.mjs +1 -1
  73. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  74. package/dist/interaction_client/SilentCacheClient.d.ts +1 -9
  75. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  76. package/dist/interaction_client/SilentCacheClient.mjs +3 -22
  77. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  78. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  79. package/dist/interaction_client/SilentIframeClient.mjs +14 -11
  80. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  81. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  82. package/dist/interaction_client/SilentRefreshClient.mjs +3 -2
  83. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  84. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  85. package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
  86. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  87. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  88. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  89. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  90. package/dist/naa/BridgeError.mjs +1 -1
  91. package/dist/naa/BridgeProxy.mjs +1 -1
  92. package/dist/naa/BridgeStatusCode.mjs +1 -1
  93. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +3 -1
  94. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  95. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +4 -3
  96. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  97. package/dist/navigation/NavigationClient.mjs +1 -1
  98. package/dist/network/FetchClient.mjs +1 -1
  99. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  100. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  101. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  102. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  103. package/dist/packageMetadata.d.ts +1 -1
  104. package/dist/packageMetadata.d.ts.map +1 -1
  105. package/dist/packageMetadata.mjs +2 -2
  106. package/dist/request/RequestHelpers.d.ts +14 -0
  107. package/dist/request/RequestHelpers.d.ts.map +1 -0
  108. package/dist/request/RequestHelpers.mjs +61 -0
  109. package/dist/request/RequestHelpers.mjs.map +1 -0
  110. package/dist/response/ResponseHandler.mjs +1 -1
  111. package/dist/telemetry/BrowserPerformanceClient.d.ts +1 -1
  112. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  113. package/dist/telemetry/BrowserPerformanceClient.mjs +7 -6
  114. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  115. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  116. package/dist/utils/BrowserConstants.mjs +1 -1
  117. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  118. package/dist/utils/BrowserUtils.d.ts +19 -3
  119. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  120. package/dist/utils/BrowserUtils.mjs +45 -10
  121. package/dist/utils/BrowserUtils.mjs.map +1 -1
  122. package/lib/msal-browser.cjs +1116 -808
  123. package/lib/msal-browser.cjs.map +1 -1
  124. package/lib/msal-browser.js +1116 -808
  125. package/lib/msal-browser.js.map +1 -1
  126. package/lib/msal-browser.min.js +66 -66
  127. package/package.json +2 -2
  128. package/src/cache/AsyncMemoryStorage.ts +4 -6
  129. package/src/cache/BrowserCacheManager.ts +54 -90
  130. package/src/cache/DatabaseStorage.ts +14 -4
  131. package/src/controllers/IController.ts +1 -7
  132. package/src/controllers/NestedAppAuthController.ts +38 -23
  133. package/src/controllers/StandardController.ts +107 -179
  134. package/src/controllers/UnknownOperatingContextController.ts +28 -37
  135. package/src/crypto/BrowserCrypto.ts +11 -0
  136. package/src/crypto/CryptoOps.ts +31 -13
  137. package/src/index.ts +2 -0
  138. package/src/interaction_client/BaseInteractionClient.ts +0 -66
  139. package/src/interaction_client/NativeInteractionClient.ts +28 -9
  140. package/src/interaction_client/SilentCacheClient.ts +11 -51
  141. package/src/interaction_client/SilentIframeClient.ts +15 -16
  142. package/src/interaction_client/SilentRefreshClient.ts +3 -2
  143. package/src/interaction_client/StandardInteractionClient.ts +8 -2
  144. package/src/naa/mapping/NestedAppAuthAdapter.ts +10 -2
  145. package/src/packageMetadata.ts +1 -1
  146. package/src/request/RequestHelpers.ts +112 -0
  147. package/src/telemetry/BrowserPerformanceClient.ts +20 -10
  148. package/src/utils/BrowserUtils.ts +59 -15
  149. package/dist/cache/CryptoKeyStore.d.ts +0 -19
  150. package/dist/cache/CryptoKeyStore.d.ts.map +0 -1
  151. package/dist/cache/CryptoKeyStore.mjs +0 -47
  152. package/dist/cache/CryptoKeyStore.mjs.map +0 -1
  153. package/dist/cache/IAsyncMemoryStorage.d.ts.map +0 -1
  154. package/src/cache/CryptoKeyStore.ts +0 -63
  155. /package/src/cache/{IAsyncMemoryStorage.ts → IAsyncStorage.ts} +0 -0
@@ -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
- this.initializeBaseRequest.bind(this),
319
+ initializeBaseRequest,
319
320
  PerformanceEvents.InitializeBaseRequest,
320
321
  this.logger,
321
322
  this.performanceClient,
322
323
  this.correlationId
323
- )(request);
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: PopupRequest | RedirectRequest
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: request.scopes.join(" "),
80
+ scope: scopes.join(" "),
73
81
  correlationId:
74
82
  request.correlationId !== undefined
75
83
  ? request.correlationId
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.9.0";
3
+ export const version = "3.11.0";
@@ -0,0 +1,112 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ AccountInfo,
8
+ AuthenticationScheme,
9
+ BaseAuthRequest,
10
+ ClientConfigurationErrorCodes,
11
+ CommonSilentFlowRequest,
12
+ IPerformanceClient,
13
+ Logger,
14
+ PerformanceEvents,
15
+ StringUtils,
16
+ createClientConfigurationError,
17
+ invokeAsync,
18
+ } from "@azure/msal-common";
19
+ import { BrowserConfiguration } from "../config/Configuration";
20
+ import { SilentRequest } from "./SilentRequest";
21
+ import { hashString } from "../crypto/BrowserCrypto";
22
+
23
+ /**
24
+ * Initializer function for all request APIs
25
+ * @param request
26
+ */
27
+ export async function initializeBaseRequest(
28
+ request: Partial<BaseAuthRequest> & { correlationId: string },
29
+ config: BrowserConfiguration,
30
+ performanceClient: IPerformanceClient,
31
+ logger: Logger
32
+ ): Promise<BaseAuthRequest> {
33
+ performanceClient.addQueueMeasurement(
34
+ PerformanceEvents.InitializeBaseRequest,
35
+ request.correlationId
36
+ );
37
+ const authority = request.authority || config.auth.authority;
38
+
39
+ const scopes = [...((request && request.scopes) || [])];
40
+
41
+ const validatedRequest: BaseAuthRequest = {
42
+ ...request,
43
+ correlationId: request.correlationId,
44
+ authority,
45
+ scopes,
46
+ };
47
+
48
+ // Set authenticationScheme to BEARER if not explicitly set in the request
49
+ if (!validatedRequest.authenticationScheme) {
50
+ validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;
51
+ logger.verbose(
52
+ 'Authentication Scheme wasn\'t explicitly set in request, defaulting to "Bearer" request'
53
+ );
54
+ } else {
55
+ if (
56
+ validatedRequest.authenticationScheme === AuthenticationScheme.SSH
57
+ ) {
58
+ if (!request.sshJwk) {
59
+ throw createClientConfigurationError(
60
+ ClientConfigurationErrorCodes.missingSshJwk
61
+ );
62
+ }
63
+ if (!request.sshKid) {
64
+ throw createClientConfigurationError(
65
+ ClientConfigurationErrorCodes.missingSshKid
66
+ );
67
+ }
68
+ }
69
+ logger.verbose(
70
+ `Authentication Scheme set to "${validatedRequest.authenticationScheme}" as configured in Auth request`
71
+ );
72
+ }
73
+
74
+ // Set requested claims hash if claims-based caching is enabled and claims were requested
75
+ if (
76
+ config.cache.claimsBasedCachingEnabled &&
77
+ request.claims &&
78
+ // Checks for empty stringified object "{}" which doesn't qualify as requested claims
79
+ !StringUtils.isEmptyObj(request.claims)
80
+ ) {
81
+ validatedRequest.requestedClaimsHash = await hashString(request.claims);
82
+ }
83
+
84
+ return validatedRequest;
85
+ }
86
+
87
+ export async function initializeSilentRequest(
88
+ request: SilentRequest & { correlationId: string },
89
+ account: AccountInfo,
90
+ config: BrowserConfiguration,
91
+ performanceClient: IPerformanceClient,
92
+ logger: Logger
93
+ ): Promise<CommonSilentFlowRequest> {
94
+ performanceClient.addQueueMeasurement(
95
+ PerformanceEvents.InitializeSilentRequest,
96
+ request.correlationId
97
+ );
98
+
99
+ const baseRequest = await invokeAsync(
100
+ initializeBaseRequest,
101
+ PerformanceEvents.InitializeBaseRequest,
102
+ logger,
103
+ performanceClient,
104
+ request.correlationId
105
+ )(request, config, performanceClient, logger);
106
+ return {
107
+ ...request,
108
+ ...baseRequest,
109
+ account: account,
110
+ forceRefresh: request.forceRefresh || false,
111
+ };
112
+ }
@@ -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.
@@ -68,7 +69,11 @@ export class BrowserPerformanceClient
68
69
  extends PerformanceClient
69
70
  implements IPerformanceClient
70
71
  {
71
- constructor(configuration: Configuration, intFields?: Set<string>) {
72
+ constructor(
73
+ configuration: Configuration,
74
+ intFields?: Set<string>,
75
+ abbreviations?: Map<string, string>
76
+ ) {
72
77
  super(
73
78
  configuration.auth.clientId,
74
79
  configuration.auth.authority || `${Constants.DEFAULT_AUTHORITY}`,
@@ -83,12 +88,13 @@ export class BrowserPerformanceClient
83
88
  appName: "",
84
89
  appVersion: "",
85
90
  },
86
- intFields
91
+ intFields,
92
+ abbreviations
87
93
  );
88
94
  }
89
95
 
90
96
  generateId(): string {
91
- return window.crypto.randomUUID();
97
+ return BrowserCrypto.createNewGuid();
92
98
  }
93
99
 
94
100
  private getPageVisibility(): string | null {
@@ -158,14 +164,18 @@ export class BrowserPerformanceClient
158
164
  return {
159
165
  ...inProgressEvent,
160
166
  end: (
161
- event?: Partial<PerformanceEvent>
167
+ event?: Partial<PerformanceEvent>,
168
+ error?: unknown
162
169
  ): PerformanceEvent | null => {
163
- const res = inProgressEvent.end({
164
- ...event,
165
- startPageVisibility,
166
- endPageVisibility: this.getPageVisibility(),
167
- durationMs: getPerfDurationMs(startTime),
168
- });
170
+ const res = inProgressEvent.end(
171
+ {
172
+ ...event,
173
+ startPageVisibility,
174
+ endPageVisibility: this.getPageVisibility(),
175
+ durationMs: getPerfDurationMs(startTime),
176
+ },
177
+ error
178
+ );
169
179
  void browserMeasurement?.then((measurement) =>
170
180
  measurement.endMeasurement()
171
181
  );
@@ -8,7 +8,13 @@ import {
8
8
  createBrowserAuthError,
9
9
  BrowserAuthErrorCodes,
10
10
  } from "../error/BrowserAuthError";
11
- import { InteractionType, BrowserConstants } from "./BrowserConstants";
11
+ import { BrowserConstants, BrowserCacheLocation } from "./BrowserConstants";
12
+ import * as BrowserCrypto from "../crypto/BrowserCrypto";
13
+ import {
14
+ BrowserConfigurationAuthErrorCodes,
15
+ createBrowserConfigurationAuthError,
16
+ } from "../error/BrowserConfigurationAuthError";
17
+ import { BrowserConfiguration } from "../config/Configuration";
12
18
 
13
19
  /**
14
20
  * Clears hash from window url.
@@ -92,16 +98,8 @@ export function blockReloadInHiddenIframes(): void {
92
98
  * @param interactionType Interaction type for the request
93
99
  * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
94
100
  */
95
- export function blockRedirectInIframe(
96
- interactionType: InteractionType,
97
- allowRedirectInIframe: boolean
98
- ): void {
99
- const isIframedApp = isInIframe();
100
- if (
101
- interactionType === InteractionType.Redirect &&
102
- isIframedApp &&
103
- !allowRedirectInIframe
104
- ) {
101
+ export function blockRedirectInIframe(allowRedirectInIframe: boolean): void {
102
+ if (isInIframe() && !allowRedirectInIframe) {
105
103
  // If we are not in top frame, we shouldn't redirect. This is also handled by the service.
106
104
  throw createBrowserAuthError(BrowserAuthErrorCodes.redirectInIframe);
107
105
  }
@@ -121,10 +119,8 @@ export function blockAcquireTokenInPopups(): void {
121
119
  * Throws error if token requests are made in non-browser environment
122
120
  * @param isBrowserEnvironment Flag indicating if environment is a browser.
123
121
  */
124
- export function blockNonBrowserEnvironment(
125
- isBrowserEnvironment: boolean
126
- ): void {
127
- if (!isBrowserEnvironment) {
122
+ export function blockNonBrowserEnvironment(): void {
123
+ if (typeof window === "undefined") {
128
124
  throw createBrowserAuthError(
129
125
  BrowserAuthErrorCodes.nonBrowserEnvironment
130
126
  );
@@ -143,6 +139,46 @@ export function blockAPICallsBeforeInitialize(initialized: boolean): void {
143
139
  }
144
140
  }
145
141
 
142
+ /**
143
+ * Helper to validate app environment before making an auth request
144
+ * @param initialized
145
+ */
146
+ export function preflightCheck(initialized: boolean): void {
147
+ // Block request if not in browser environment
148
+ blockNonBrowserEnvironment();
149
+
150
+ // Block auth requests inside a hidden iframe
151
+ blockReloadInHiddenIframes();
152
+
153
+ // Block redirectUri opened in a popup from calling MSAL APIs
154
+ blockAcquireTokenInPopups();
155
+
156
+ // Block token acquisition before initialize has been called
157
+ blockAPICallsBeforeInitialize(initialized);
158
+ }
159
+
160
+ /**
161
+ * Helper to validate app enviornment before making redirect request
162
+ * @param initialized
163
+ * @param config
164
+ */
165
+ export function redirectPreflightCheck(
166
+ initialized: boolean,
167
+ config: BrowserConfiguration
168
+ ): void {
169
+ preflightCheck(initialized);
170
+ blockRedirectInIframe(config.system.allowRedirectInIframe);
171
+ // Block redirects if memory storage is enabled but storeAuthStateInCookie is not
172
+ if (
173
+ config.cache.cacheLocation === BrowserCacheLocation.MemoryStorage &&
174
+ !config.cache.storeAuthStateInCookie
175
+ ) {
176
+ throw createBrowserConfigurationAuthError(
177
+ BrowserConfigurationAuthErrorCodes.inMemRedirectUnavailable
178
+ );
179
+ }
180
+ }
181
+
146
182
  /**
147
183
  * Adds a preconnect link element to the header which begins DNS resolution and SSL connection in anticipation of the /token request
148
184
  * @param loginDomain Authority domain, including https protocol e.g. https://login.microsoftonline.com
@@ -162,3 +198,11 @@ export function preconnect(authority: string): void {
162
198
  } catch {}
163
199
  }, 10000); // 10s Timeout
164
200
  }
201
+
202
+ /**
203
+ * Wrapper function that creates a UUID v7 from the current timestamp.
204
+ * @returns {string}
205
+ */
206
+ export function createGuid(): string {
207
+ return BrowserCrypto.createNewGuid();
208
+ }
@@ -1,19 +0,0 @@
1
- import { Logger } from "@azure/msal-common";
2
- import { CachedKeyPair } from "../crypto/CryptoOps";
3
- import { AsyncMemoryStorage } from "./AsyncMemoryStorage";
4
- export declare const CryptoKeyStoreNames: {
5
- readonly asymmetricKeys: "asymmetricKeys";
6
- readonly symmetricKeys: "symmetricKeys";
7
- };
8
- export type CryptoKeyStoreNames = (typeof CryptoKeyStoreNames)[keyof typeof CryptoKeyStoreNames];
9
- /**
10
- * MSAL CryptoKeyStore DB Version 2
11
- */
12
- export declare class CryptoKeyStore {
13
- asymmetricKeys: AsyncMemoryStorage<CachedKeyPair>;
14
- symmetricKeys: AsyncMemoryStorage<CryptoKey>;
15
- logger: Logger;
16
- constructor(logger: Logger);
17
- clear(): Promise<boolean>;
18
- }
19
- //# sourceMappingURL=CryptoKeyStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CryptoKeyStore.d.ts","sourceRoot":"","sources":["../../src/cache/CryptoKeyStore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AACX,MAAM,MAAM,mBAAmB,GAC3B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEnE;;GAEG;AACH,qBAAa,cAAc;IAChB,cAAc,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAClD,aAAa,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,MAAM;IAYpB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;CA0BlC"}
@@ -1,47 +0,0 @@
1
- /*! @azure/msal-browser v3.9.0 2024-02-07 */
2
- 'use strict';
3
- import { AsyncMemoryStorage } from './AsyncMemoryStorage.mjs';
4
-
5
- /*
6
- * Copyright (c) Microsoft Corporation. All rights reserved.
7
- * Licensed under the MIT License.
8
- */
9
- const CryptoKeyStoreNames = {
10
- asymmetricKeys: "asymmetricKeys",
11
- symmetricKeys: "symmetricKeys",
12
- };
13
- /**
14
- * MSAL CryptoKeyStore DB Version 2
15
- */
16
- class CryptoKeyStore {
17
- constructor(logger) {
18
- this.logger = logger;
19
- this.asymmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys);
20
- this.symmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys);
21
- }
22
- async clear() {
23
- // Delete in-memory keystores
24
- this.asymmetricKeys.clearInMemory();
25
- this.symmetricKeys.clearInMemory();
26
- /**
27
- * There is only one database, so calling clearPersistent on asymmetric keystore takes care of
28
- * every persistent keystore
29
- */
30
- try {
31
- await this.asymmetricKeys.clearPersistent();
32
- return true;
33
- }
34
- catch (e) {
35
- if (e instanceof Error) {
36
- this.logger.error(`Clearing keystore failed with error: ${e.message}`);
37
- }
38
- else {
39
- this.logger.error("Clearing keystore failed with unknown error");
40
- }
41
- return false;
42
- }
43
- }
44
- }
45
-
46
- export { CryptoKeyStore, CryptoKeyStoreNames };
47
- //# sourceMappingURL=CryptoKeyStore.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CryptoKeyStore.mjs","sources":["../../src/cache/CryptoKeyStore.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMU,MAAA,mBAAmB,GAAG;AAC/B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,aAAa,EAAE,eAAe;EACvB;AAIX;;AAEG;MACU,cAAc,CAAA;AAKvB,IAAA,WAAA,CAAY,MAAc,EAAA;AACtB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,QAAA,IAAI,CAAC,cAAc,GAAG,IAAI,kBAAkB,CACxC,IAAI,CAAC,MAAM,EACX,mBAAmB,CAAC,cAAc,CACrC,CAAC;AACF,QAAA,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CACvC,IAAI,CAAC,MAAM,EACX,mBAAmB,CAAC,aAAa,CACpC,CAAC;KACL;AAED,IAAA,MAAM,KAAK,GAAA;;AAEP,QAAA,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;AACpC,QAAA,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;AAEnC;;;AAGG;QACH,IAAI;AACA,YAAA,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;AAC5C,YAAA,OAAO,IAAI,CAAC;AACf,SAAA;AAAC,QAAA,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,YAAY,KAAK,EAAE;gBACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,CAAwC,qCAAA,EAAA,CAAC,CAAC,OAAO,CAAE,CAAA,CACtD,CAAC;AACL,aAAA;AAAM,iBAAA;AACH,gBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,6CAA6C,CAChD,CAAC;AACL,aAAA;AAED,YAAA,OAAO,KAAK,CAAC;AAChB,SAAA;KACJ;AACJ;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAsyncMemoryStorage.d.ts","sourceRoot":"","sources":["../../src/cache/IAsyncMemoryStorage.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa,CAAC,CAAC;IAC5B;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAExC;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7B;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C"}
@@ -1,63 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { Logger } from "@azure/msal-common";
7
- import { CachedKeyPair } from "../crypto/CryptoOps";
8
- import { AsyncMemoryStorage } from "./AsyncMemoryStorage";
9
-
10
- export const CryptoKeyStoreNames = {
11
- asymmetricKeys: "asymmetricKeys",
12
- symmetricKeys: "symmetricKeys",
13
- } as const;
14
- export type CryptoKeyStoreNames =
15
- (typeof CryptoKeyStoreNames)[keyof typeof CryptoKeyStoreNames];
16
-
17
- /**
18
- * MSAL CryptoKeyStore DB Version 2
19
- */
20
- export class CryptoKeyStore {
21
- public asymmetricKeys: AsyncMemoryStorage<CachedKeyPair>;
22
- public symmetricKeys: AsyncMemoryStorage<CryptoKey>;
23
- public logger: Logger;
24
-
25
- constructor(logger: Logger) {
26
- this.logger = logger;
27
- this.asymmetricKeys = new AsyncMemoryStorage<CachedKeyPair>(
28
- this.logger,
29
- CryptoKeyStoreNames.asymmetricKeys
30
- );
31
- this.symmetricKeys = new AsyncMemoryStorage<CryptoKey>(
32
- this.logger,
33
- CryptoKeyStoreNames.symmetricKeys
34
- );
35
- }
36
-
37
- async clear(): Promise<boolean> {
38
- // Delete in-memory keystores
39
- this.asymmetricKeys.clearInMemory();
40
- this.symmetricKeys.clearInMemory();
41
-
42
- /**
43
- * There is only one database, so calling clearPersistent on asymmetric keystore takes care of
44
- * every persistent keystore
45
- */
46
- try {
47
- await this.asymmetricKeys.clearPersistent();
48
- return true;
49
- } catch (e) {
50
- if (e instanceof Error) {
51
- this.logger.error(
52
- `Clearing keystore failed with error: ${e.message}`
53
- );
54
- } else {
55
- this.logger.error(
56
- "Clearing keystore failed with unknown error"
57
- );
58
- }
59
-
60
- return false;
61
- }
62
- }
63
- }