@azure/msal-browser 4.11.1 → 4.13.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 (222) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.d.ts +1 -0
  3. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  4. package/dist/app/PublicClientApplication.mjs +3 -2
  5. package/dist/app/PublicClientApplication.mjs.map +1 -1
  6. package/dist/app/PublicClientNext.mjs +1 -1
  7. package/dist/broker/nativeBroker/IPlatformAuthHandler.d.ts +12 -0
  8. package/dist/broker/nativeBroker/IPlatformAuthHandler.d.ts.map +1 -0
  9. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  10. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.d.ts +30 -0
  11. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -0
  12. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +143 -0
  13. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map +1 -0
  14. package/dist/broker/nativeBroker/{NativeMessageHandler.d.ts → PlatformAuthExtensionHandler.d.ts} +16 -16
  15. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -0
  16. package/dist/broker/nativeBroker/{NativeMessageHandler.mjs → PlatformAuthExtensionHandler.mjs} +66 -58
  17. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map +1 -0
  18. package/dist/broker/nativeBroker/PlatformAuthProvider.d.ts +26 -0
  19. package/dist/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -0
  20. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +108 -0
  21. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -0
  22. package/dist/broker/nativeBroker/{NativeRequest.d.ts → PlatformAuthRequest.d.ts} +34 -3
  23. package/dist/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -0
  24. package/dist/broker/nativeBroker/{NativeResponse.d.ts → PlatformAuthResponse.d.ts} +24 -2
  25. package/dist/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -0
  26. package/dist/cache/AccountManager.mjs +1 -1
  27. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  28. package/dist/cache/BrowserCacheManager.d.ts +6 -2
  29. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  30. package/dist/cache/BrowserCacheManager.mjs +29 -3
  31. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  32. package/dist/cache/CacheHelpers.mjs +1 -1
  33. package/dist/cache/CookieStorage.mjs +1 -1
  34. package/dist/cache/DatabaseStorage.mjs +1 -1
  35. package/dist/cache/LocalStorage.mjs +1 -1
  36. package/dist/cache/MemoryStorage.mjs +1 -1
  37. package/dist/cache/SessionStorage.mjs +1 -1
  38. package/dist/cache/TokenCache.mjs +1 -1
  39. package/dist/config/Configuration.mjs +1 -1
  40. package/dist/controllers/ControllerFactory.mjs +1 -1
  41. package/dist/controllers/IController.d.ts +1 -1
  42. package/dist/controllers/IController.d.ts.map +1 -1
  43. package/dist/controllers/NestedAppAuthController.d.ts +1 -1
  44. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  45. package/dist/controllers/NestedAppAuthController.mjs +4 -2
  46. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  47. package/dist/controllers/StandardController.d.ts +4 -3
  48. package/dist/controllers/StandardController.d.ts.map +1 -1
  49. package/dist/controllers/StandardController.mjs +56 -30
  50. package/dist/controllers/StandardController.mjs.map +1 -1
  51. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  52. package/dist/crypto/BrowserCrypto.mjs +1 -1
  53. package/dist/crypto/CryptoOps.mjs +1 -1
  54. package/dist/crypto/PkceGenerator.mjs +1 -1
  55. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  56. package/dist/encode/Base64Decode.mjs +1 -1
  57. package/dist/encode/Base64Encode.mjs +1 -1
  58. package/dist/error/BrowserAuthError.mjs +1 -1
  59. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  60. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  61. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  62. package/dist/error/NativeAuthError.mjs +1 -1
  63. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  64. package/dist/error/NestedAppAuthError.mjs +1 -1
  65. package/dist/event/EventHandler.mjs +1 -1
  66. package/dist/event/EventMessage.d.ts +10 -1
  67. package/dist/event/EventMessage.d.ts.map +1 -1
  68. package/dist/event/EventMessage.mjs +1 -1
  69. package/dist/event/EventMessage.mjs.map +1 -1
  70. package/dist/event/EventType.d.ts +1 -0
  71. package/dist/event/EventType.d.ts.map +1 -1
  72. package/dist/event/EventType.mjs +2 -1
  73. package/dist/event/EventType.mjs.map +1 -1
  74. package/dist/index.d.ts +2 -1
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.mjs +2 -1
  77. package/dist/index.mjs.map +1 -1
  78. package/dist/interaction_client/BaseInteractionClient.d.ts +3 -3
  79. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  80. package/dist/interaction_client/BaseInteractionClient.mjs +3 -3
  81. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  82. package/dist/interaction_client/{NativeInteractionClient.d.ts → PlatformAuthInteractionClient.d.ts} +21 -23
  83. package/dist/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -0
  84. package/dist/interaction_client/{NativeInteractionClient.mjs → PlatformAuthInteractionClient.mjs} +80 -111
  85. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -0
  86. package/dist/interaction_client/PopupClient.d.ts +2 -2
  87. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  88. package/dist/interaction_client/PopupClient.mjs +7 -7
  89. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  90. package/dist/interaction_client/RedirectClient.d.ts +2 -2
  91. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  92. package/dist/interaction_client/RedirectClient.mjs +7 -8
  93. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  94. package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  95. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  96. package/dist/interaction_client/SilentAuthCodeClient.mjs +3 -3
  97. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  98. package/dist/interaction_client/SilentIframeClient.d.ts +2 -2
  99. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  100. package/dist/interaction_client/SilentIframeClient.mjs +7 -8
  101. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  102. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  103. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  104. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  105. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  106. package/dist/naa/BridgeError.mjs +1 -1
  107. package/dist/naa/BridgeProxy.mjs +1 -1
  108. package/dist/naa/BridgeStatusCode.mjs +1 -1
  109. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  110. package/dist/navigation/NavigationClient.mjs +1 -1
  111. package/dist/network/FetchClient.mjs +1 -1
  112. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  113. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  114. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  115. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  116. package/dist/packageMetadata.d.ts +1 -1
  117. package/dist/packageMetadata.mjs +2 -2
  118. package/dist/protocol/Authorize.d.ts +4 -4
  119. package/dist/protocol/Authorize.d.ts.map +1 -1
  120. package/dist/protocol/Authorize.mjs +10 -9
  121. package/dist/protocol/Authorize.mjs.map +1 -1
  122. package/dist/request/RequestHelpers.mjs +1 -1
  123. package/dist/response/ResponseHandler.mjs +1 -1
  124. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  125. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  126. package/dist/utils/BrowserConstants.d.ts +8 -1
  127. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  128. package/dist/utils/BrowserConstants.mjs +11 -4
  129. package/dist/utils/BrowserConstants.mjs.map +1 -1
  130. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  131. package/dist/utils/BrowserUtils.mjs +1 -1
  132. package/dist/utils/MsalFrameStatsUtils.d.ts +3 -0
  133. package/dist/utils/MsalFrameStatsUtils.d.ts.map +1 -0
  134. package/dist/utils/MsalFrameStatsUtils.mjs +23 -0
  135. package/dist/utils/MsalFrameStatsUtils.mjs.map +1 -0
  136. package/lib/msal-browser.cjs +1600 -1323
  137. package/lib/msal-browser.cjs.map +1 -1
  138. package/lib/msal-browser.js +1600 -1323
  139. package/lib/msal-browser.js.map +1 -1
  140. package/lib/msal-browser.min.js +66 -66
  141. package/lib/types/app/PublicClientApplication.d.ts +1 -0
  142. package/lib/types/app/PublicClientApplication.d.ts.map +1 -1
  143. package/lib/types/broker/nativeBroker/IPlatformAuthHandler.d.ts +12 -0
  144. package/lib/types/broker/nativeBroker/IPlatformAuthHandler.d.ts.map +1 -0
  145. package/lib/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts +30 -0
  146. package/lib/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -0
  147. package/lib/types/broker/nativeBroker/{NativeMessageHandler.d.ts → PlatformAuthExtensionHandler.d.ts} +16 -16
  148. package/lib/types/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -0
  149. package/lib/types/broker/nativeBroker/PlatformAuthProvider.d.ts +26 -0
  150. package/lib/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -0
  151. package/lib/types/broker/nativeBroker/{NativeRequest.d.ts → PlatformAuthRequest.d.ts} +34 -3
  152. package/lib/types/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -0
  153. package/lib/types/broker/nativeBroker/{NativeResponse.d.ts → PlatformAuthResponse.d.ts} +24 -2
  154. package/lib/types/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -0
  155. package/lib/types/cache/BrowserCacheManager.d.ts +6 -2
  156. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  157. package/lib/types/controllers/IController.d.ts +1 -1
  158. package/lib/types/controllers/IController.d.ts.map +1 -1
  159. package/lib/types/controllers/NestedAppAuthController.d.ts +1 -1
  160. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  161. package/lib/types/controllers/StandardController.d.ts +4 -3
  162. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  163. package/lib/types/event/EventMessage.d.ts +10 -1
  164. package/lib/types/event/EventMessage.d.ts.map +1 -1
  165. package/lib/types/event/EventType.d.ts +1 -0
  166. package/lib/types/event/EventType.d.ts.map +1 -1
  167. package/lib/types/index.d.ts +2 -1
  168. package/lib/types/index.d.ts.map +1 -1
  169. package/lib/types/interaction_client/BaseInteractionClient.d.ts +3 -3
  170. package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  171. package/lib/types/interaction_client/{NativeInteractionClient.d.ts → PlatformAuthInteractionClient.d.ts} +21 -23
  172. package/lib/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -0
  173. package/lib/types/interaction_client/PopupClient.d.ts +2 -2
  174. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  175. package/lib/types/interaction_client/RedirectClient.d.ts +2 -2
  176. package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
  177. package/lib/types/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  178. package/lib/types/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  179. package/lib/types/interaction_client/SilentIframeClient.d.ts +2 -2
  180. package/lib/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  181. package/lib/types/packageMetadata.d.ts +1 -1
  182. package/lib/types/protocol/Authorize.d.ts +4 -4
  183. package/lib/types/protocol/Authorize.d.ts.map +1 -1
  184. package/lib/types/utils/BrowserConstants.d.ts +8 -1
  185. package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
  186. package/lib/types/utils/MsalFrameStatsUtils.d.ts +3 -0
  187. package/lib/types/utils/MsalFrameStatsUtils.d.ts.map +1 -0
  188. package/package.json +3 -2
  189. package/src/app/PublicClientApplication.ts +2 -1
  190. package/src/broker/nativeBroker/IPlatformAuthHandler.ts +17 -0
  191. package/src/broker/nativeBroker/PlatformAuthDOMHandler.ts +248 -0
  192. package/src/broker/nativeBroker/{NativeMessageHandler.ts → PlatformAuthExtensionHandler.ts} +90 -79
  193. package/src/broker/nativeBroker/PlatformAuthProvider.ts +164 -0
  194. package/src/broker/nativeBroker/{NativeRequest.ts → PlatformAuthRequest.ts} +41 -2
  195. package/src/broker/nativeBroker/{NativeResponse.ts → PlatformAuthResponse.ts} +25 -1
  196. package/src/cache/BrowserCacheManager.ts +40 -4
  197. package/src/controllers/IController.ts +4 -1
  198. package/src/controllers/NestedAppAuthController.ts +5 -1
  199. package/src/controllers/StandardController.ts +87 -46
  200. package/src/event/EventMessage.ts +11 -0
  201. package/src/event/EventType.ts +1 -0
  202. package/src/index.ts +3 -0
  203. package/src/interaction_client/BaseInteractionClient.ts +4 -4
  204. package/src/interaction_client/{NativeInteractionClient.ts → PlatformAuthInteractionClient.ts} +136 -167
  205. package/src/interaction_client/PopupClient.ts +8 -7
  206. package/src/interaction_client/RedirectClient.ts +12 -12
  207. package/src/interaction_client/SilentAuthCodeClient.ts +3 -3
  208. package/src/interaction_client/SilentIframeClient.ts +12 -12
  209. package/src/packageMetadata.ts +1 -1
  210. package/src/protocol/Authorize.ts +12 -10
  211. package/src/utils/BrowserConstants.ts +9 -1
  212. package/src/utils/MsalFrameStatsUtils.ts +32 -0
  213. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +0 -1
  214. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +0 -1
  215. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +0 -1
  216. package/dist/broker/nativeBroker/NativeResponse.d.ts.map +0 -1
  217. package/dist/interaction_client/NativeInteractionClient.d.ts.map +0 -1
  218. package/dist/interaction_client/NativeInteractionClient.mjs.map +0 -1
  219. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +0 -1
  220. package/lib/types/broker/nativeBroker/NativeRequest.d.ts.map +0 -1
  221. package/lib/types/broker/nativeBroker/NativeResponse.d.ts.map +0 -1
  222. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +0 -1
@@ -0,0 +1,164 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ LoggerOptions,
8
+ IPerformanceClient,
9
+ Logger,
10
+ AuthenticationScheme,
11
+ StubPerformanceClient,
12
+ } from "@azure/msal-common/browser";
13
+ import { name, version } from "../../packageMetadata.js";
14
+ import {
15
+ BrowserConfiguration,
16
+ DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
17
+ } from "../../config/Configuration.js";
18
+ import { PlatformAuthExtensionHandler } from "./PlatformAuthExtensionHandler.js";
19
+ import { IPlatformAuthHandler } from "./IPlatformAuthHandler.js";
20
+ import { PlatformAuthDOMHandler } from "./PlatformAuthDOMHandler.js";
21
+ import { createNewGuid } from "../../crypto/BrowserCrypto.js";
22
+ import {
23
+ BrowserCacheLocation,
24
+ PLATFORM_AUTH_DOM_SUPPORT,
25
+ } from "../../utils/BrowserConstants.js";
26
+
27
+ /**
28
+ * Checks if the platform broker is available in the current environment.
29
+ * @param loggerOptions
30
+ * @param perfClient
31
+ * @returns
32
+ */
33
+ export async function isPlatformBrokerAvailable(
34
+ loggerOptions?: LoggerOptions,
35
+ perfClient?: IPerformanceClient,
36
+ correlationId?: string
37
+ ): Promise<boolean> {
38
+ const logger = new Logger(loggerOptions || {}, name, version);
39
+
40
+ logger.trace("isPlatformBrokerAvailable called");
41
+
42
+ const performanceClient = perfClient || new StubPerformanceClient();
43
+
44
+ if (typeof window === "undefined") {
45
+ logger.trace("Non-browser environment detected, returning false");
46
+ return false;
47
+ }
48
+
49
+ return !!(await getPlatformAuthProvider(
50
+ logger,
51
+ performanceClient,
52
+ correlationId || createNewGuid()
53
+ ));
54
+ }
55
+
56
+ export async function getPlatformAuthProvider(
57
+ logger: Logger,
58
+ performanceClient: IPerformanceClient,
59
+ correlationId: string,
60
+ nativeBrokerHandshakeTimeout?: number
61
+ ): Promise<IPlatformAuthHandler | undefined> {
62
+ logger.trace("getPlatformAuthProvider called", correlationId);
63
+
64
+ const enablePlatformBrokerDOMSupport = isDomEnabledForPlatformAuth();
65
+
66
+ logger.trace(
67
+ "Has client allowed platform auth via DOM API: " +
68
+ enablePlatformBrokerDOMSupport
69
+ );
70
+ let platformAuthProvider: IPlatformAuthHandler | undefined;
71
+ try {
72
+ if (enablePlatformBrokerDOMSupport) {
73
+ // Check if DOM platform API is supported first
74
+ platformAuthProvider = await PlatformAuthDOMHandler.createProvider(
75
+ logger,
76
+ performanceClient,
77
+ correlationId
78
+ );
79
+ }
80
+ if (!platformAuthProvider) {
81
+ logger.trace(
82
+ "Platform auth via DOM API not available, checking for extension"
83
+ );
84
+ /*
85
+ * If DOM APIs are not available, check if browser extension is available.
86
+ * Platform authentication via DOM APIs is preferred over extension APIs.
87
+ */
88
+ platformAuthProvider =
89
+ await PlatformAuthExtensionHandler.createProvider(
90
+ logger,
91
+ nativeBrokerHandshakeTimeout ||
92
+ DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
93
+ performanceClient
94
+ );
95
+ }
96
+ } catch (e) {
97
+ logger.trace("Platform auth not available", e as string);
98
+ }
99
+ return platformAuthProvider;
100
+ }
101
+
102
+ /**
103
+ * Returns true if the DOM API support for platform auth is enabled in session storage
104
+ * @returns boolean
105
+ * @deprecated
106
+ */
107
+ export function isDomEnabledForPlatformAuth(): boolean {
108
+ let sessionStorage: Storage | undefined;
109
+ try {
110
+ sessionStorage = window[BrowserCacheLocation.SessionStorage];
111
+ // Mute errors if it's a non-browser environment or cookies are blocked.
112
+ return sessionStorage?.getItem(PLATFORM_AUTH_DOM_SUPPORT) === "true";
113
+ } catch (e) {
114
+ return false;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Returns boolean indicating whether or not the request should attempt to use native broker
120
+ * @param logger
121
+ * @param config
122
+ * @param platformAuthProvider
123
+ * @param authenticationScheme
124
+ */
125
+ export function isPlatformAuthAllowed(
126
+ config: BrowserConfiguration,
127
+ logger: Logger,
128
+ platformAuthProvider?: IPlatformAuthHandler,
129
+ authenticationScheme?: AuthenticationScheme
130
+ ): boolean {
131
+ logger.trace("isBrokerAvailable called");
132
+ if (!config.system.allowPlatformBroker) {
133
+ logger.trace(
134
+ "isBrokerAvailable: allowPlatformBroker is not enabled, returning false"
135
+ );
136
+ // Developer disabled WAM
137
+ return false;
138
+ }
139
+
140
+ if (!platformAuthProvider) {
141
+ logger.trace(
142
+ "isBrokerAvailable: Platform auth provider is not initialized, returning false"
143
+ );
144
+ // Platform broker auth providers are not available
145
+ return false;
146
+ }
147
+
148
+ if (authenticationScheme) {
149
+ switch (authenticationScheme) {
150
+ case AuthenticationScheme.BEARER:
151
+ case AuthenticationScheme.POP:
152
+ logger.trace(
153
+ "isBrokerAvailable: authenticationScheme is supported, returning true"
154
+ );
155
+ return true;
156
+ default:
157
+ logger.trace(
158
+ "isBrokerAvailable: authenticationScheme is not supported, returning false"
159
+ );
160
+ return false;
161
+ }
162
+ }
163
+ return true;
164
+ }
@@ -9,7 +9,7 @@ import { StoreInCache, StringDict } from "@azure/msal-common/browser";
9
9
  /**
10
10
  * Token request which native broker will use to acquire tokens
11
11
  */
12
- export type NativeTokenRequest = {
12
+ export type PlatformAuthRequest = {
13
13
  accountId: string; // WAM specific account id used for identification of WAM account. This can be any broker-id eventually
14
14
  clientId: string;
15
15
  authority: string;
@@ -40,7 +40,7 @@ export type NativeTokenRequest = {
40
40
  */
41
41
  export type NativeExtensionRequestBody = {
42
42
  method: NativeExtensionMethod;
43
- request?: NativeTokenRequest;
43
+ request?: PlatformAuthRequest;
44
44
  };
45
45
 
46
46
  /**
@@ -52,3 +52,42 @@ export type NativeExtensionRequest = {
52
52
  extensionId?: string;
53
53
  body: NativeExtensionRequestBody;
54
54
  };
55
+
56
+ export type PlatformDOMTokenRequest = {
57
+ brokerId: string;
58
+ accountId?: string;
59
+ clientId: string;
60
+ authority: string;
61
+ scope: string;
62
+ redirectUri: string;
63
+ correlationId: string;
64
+ isSecurityTokenService: boolean;
65
+ state?: string;
66
+ /*
67
+ * Known optional parameters will go into extraQueryParameters.
68
+ * List of known parameters is:
69
+ * "prompt", "nonce", "claims", "loginHint", "instanceAware", "windowTitleSubstring", "extendedExpiryToken", "storeInCache",
70
+ * ProofOfPossessionParams: "reqCnf", "keyId", "tokenType", "shrClaims", "shrNonce", "resourceRequestMethod", "resourceRequestUri", "signPopToken"
71
+ */
72
+ extraParameters?: DOMExtraParameters;
73
+ embeddedClientId?: string;
74
+ storeInCache?: StoreInCache; // Object of booleans indicating whether to store tokens in the cache or not (default is true)
75
+ };
76
+
77
+ export type DOMExtraParameters = StringDict & {
78
+ prompt?: string;
79
+ nonce?: string;
80
+ claims?: string;
81
+ loginHint?: string;
82
+ instanceAware?: string;
83
+ windowTitleSubstring?: string;
84
+ extendedExpiryToken?: string;
85
+ reqCnf?: string;
86
+ keyId?: string;
87
+ tokenType?: string;
88
+ shrClaims?: string;
89
+ shrNonce?: string;
90
+ resourceRequestMethod?: string;
91
+ resourceRequestUri?: string;
92
+ signPopToken?: string; // Set to true only if token request deos not contain a PoP keyId
93
+ };
@@ -15,7 +15,7 @@ export type NativeAccountInfo = {
15
15
  /**
16
16
  * Token response returned by Native Platform
17
17
  */
18
- export type NativeResponse = {
18
+ export type PlatformAuthResponse = {
19
19
  access_token: string;
20
20
  account: NativeAccountInfo;
21
21
  client_info: string;
@@ -54,3 +54,27 @@ export type MATS = {
54
54
  http_status?: number;
55
55
  http_event_count?: number;
56
56
  };
57
+
58
+ export type PlatformDOMTokenResponse = {
59
+ isSuccess: boolean;
60
+ state?: string;
61
+ accessToken: string;
62
+ expiresIn: number;
63
+ account: NativeAccountInfo;
64
+ clientInfo: string;
65
+ idToken: string;
66
+ scopes: string;
67
+ proofOfPossessionPayload?: string;
68
+ extendedLifetimeToken?: boolean;
69
+ error: ErrorResult;
70
+ properties?: Record<string, string>;
71
+ };
72
+
73
+ export type ErrorResult = {
74
+ code: string;
75
+ description?: string;
76
+ errorCode: string;
77
+ protocolError?: string;
78
+ status: string;
79
+ properties?: object;
80
+ };
@@ -53,7 +53,7 @@ import { LocalStorage } from "./LocalStorage.js";
53
53
  import { SessionStorage } from "./SessionStorage.js";
54
54
  import { MemoryStorage } from "./MemoryStorage.js";
55
55
  import { IWindowStorage } from "./IWindowStorage.js";
56
- import { NativeTokenRequest } from "../broker/nativeBroker/NativeRequest.js";
56
+ import { PlatformAuthRequest } from "../broker/nativeBroker/PlatformAuthRequest.js";
57
57
  import { AuthenticationResult } from "../response/AuthenticationResult.js";
58
58
  import { SilentRequest } from "../request/SilentRequest.js";
59
59
  import { SsoSilentRequest } from "../request/SsoSilentRequest.js";
@@ -65,6 +65,8 @@ import { CookieStorage } from "./CookieStorage.js";
65
65
  import { getAccountKeys, getTokenKeys } from "./CacheHelpers.js";
66
66
  import { EventType } from "../event/EventType.js";
67
67
  import { EventHandler } from "../event/EventHandler.js";
68
+ import { clearHash } from "../utils/BrowserUtils.js";
69
+ import { version } from "../packageMetadata.js";
68
70
 
69
71
  /**
70
72
  * This class implements the cache storage interface for MSAL through browser local or session storage.
@@ -122,6 +124,29 @@ export class BrowserCacheManager extends CacheManager {
122
124
 
123
125
  async initialize(correlationId: string): Promise<void> {
124
126
  await this.browserStorage.initialize(correlationId);
127
+ this.trackVersionChanges(correlationId);
128
+ }
129
+
130
+ /**
131
+ * Tracks upgrades and downgrades for telemetry and debugging purposes
132
+ */
133
+ private trackVersionChanges(correlationId: string): void {
134
+ const previousVersion = this.browserStorage.getItem(
135
+ StaticCacheKeys.VERSION
136
+ );
137
+ if (previousVersion) {
138
+ this.logger.info(
139
+ `MSAL.js was last initialized by version: ${previousVersion}`
140
+ );
141
+ this.performanceClient.addFields(
142
+ { previousLibraryVersion: previousVersion },
143
+ correlationId
144
+ );
145
+ }
146
+
147
+ if (previousVersion !== version) {
148
+ this.browserStorage.setItem(StaticCacheKeys.VERSION, version);
149
+ }
125
150
  }
126
151
 
127
152
  /**
@@ -1161,7 +1186,7 @@ export class BrowserCacheManager extends CacheManager {
1161
1186
  /**
1162
1187
  * Gets cached native request for redirect flows
1163
1188
  */
1164
- getCachedNativeRequest(): NativeTokenRequest | null {
1189
+ getCachedNativeRequest(): PlatformAuthRequest | null {
1165
1190
  this.logger.trace("BrowserCacheManager.getCachedNativeRequest called");
1166
1191
  const cachedRequest = this.getTemporaryCache(
1167
1192
  TemporaryCacheKeys.NATIVE_REQUEST,
@@ -1176,7 +1201,7 @@ export class BrowserCacheManager extends CacheManager {
1176
1201
 
1177
1202
  const parsedRequest = this.validateAndParseJson(
1178
1203
  cachedRequest
1179
- ) as NativeTokenRequest;
1204
+ ) as PlatformAuthRequest;
1180
1205
  if (!parsedRequest) {
1181
1206
  this.logger.error(
1182
1207
  "BrowserCacheManager.getCachedNativeRequest: Unable to parse native request"
@@ -1203,7 +1228,18 @@ export class BrowserCacheManager extends CacheManager {
1203
1228
  } | null {
1204
1229
  const key = `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;
1205
1230
  const value = this.getTemporaryCache(key, false);
1206
- return value ? JSON.parse(value) : null;
1231
+ try {
1232
+ return value ? JSON.parse(value) : null;
1233
+ } catch (e) {
1234
+ // Remove interaction and other temp keys if interaction status can't be parsed
1235
+ this.logger.error(
1236
+ `Cannot parse interaction status. Removing temporary cache items and clearing url hash. Retrying interaction should fix the error`
1237
+ );
1238
+ this.removeTemporaryItem(key);
1239
+ this.resetRequestCache();
1240
+ clearHash(window);
1241
+ return null;
1242
+ }
1207
1243
  }
1208
1244
 
1209
1245
  setInteractionInProgress(
@@ -29,7 +29,10 @@ import { EventType } from "../event/EventType.js";
29
29
 
30
30
  export interface IController {
31
31
  // TODO: Make request mandatory in the next major version?
32
- initialize(request?: InitializeApplicationRequest): Promise<void>;
32
+ initialize(
33
+ request?: InitializeApplicationRequest,
34
+ isBroker?: boolean
35
+ ): Promise<void>;
33
36
 
34
37
  acquireTokenPopup(request: PopupRequest): Promise<AuthenticationResult>;
35
38
 
@@ -159,7 +159,11 @@ export class NestedAppAuthController implements IController {
159
159
  * Specific implementation of initialize function for NestedAppAuthController
160
160
  * @returns
161
161
  */
162
- async initialize(request?: InitializeApplicationRequest): Promise<void> {
162
+ async initialize(
163
+ request?: InitializeApplicationRequest,
164
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
165
+ isBroker?: boolean
166
+ ): Promise<void> {
163
167
  const initCorrelationId = request?.correlationId || createNewGuid();
164
168
  await this.browserStorage.initialize(initCorrelationId);
165
169
  return Promise.resolve();