@azure/msal-browser 3.1.0 → 3.3.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 (282) hide show
  1. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  2. package/dist/app/IPublicClientApplication.mjs +20 -19
  3. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  4. package/dist/app/PublicClientApplication.d.ts +14 -6
  5. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  6. package/dist/app/PublicClientApplication.mjs +18 -8
  7. package/dist/app/PublicClientApplication.mjs.map +1 -1
  8. package/dist/app/PublicClientNext.d.ts +274 -0
  9. package/dist/app/PublicClientNext.d.ts.map +1 -0
  10. package/dist/app/PublicClientNext.mjs +362 -0
  11. package/dist/app/PublicClientNext.mjs.map +1 -0
  12. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
  13. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  14. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +13 -13
  15. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  16. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
  17. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
  18. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
  19. package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
  20. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  21. package/dist/cache/BrowserCacheManager.d.ts +4 -15
  22. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  23. package/dist/cache/BrowserCacheManager.mjs +13 -69
  24. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  25. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  26. package/dist/cache/BrowserStorage.mjs +7 -9
  27. package/dist/cache/BrowserStorage.mjs.map +1 -1
  28. package/dist/cache/CryptoKeyStore.mjs +1 -1
  29. package/dist/cache/DatabaseStorage.mjs +1 -1
  30. package/dist/cache/MemoryStorage.mjs +1 -1
  31. package/dist/cache/TokenCache.mjs +1 -1
  32. package/dist/config/Configuration.d.ts +4 -0
  33. package/dist/config/Configuration.d.ts.map +1 -1
  34. package/dist/config/Configuration.mjs +8 -7
  35. package/dist/config/Configuration.mjs.map +1 -1
  36. package/dist/controllers/ControllerFactory.d.ts +2 -1
  37. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  38. package/dist/controllers/ControllerFactory.mjs +26 -19
  39. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  40. package/dist/controllers/IController.d.ts +3 -2
  41. package/dist/controllers/IController.d.ts.map +1 -1
  42. package/dist/controllers/NestedAppAuthController.d.ts +96 -0
  43. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
  44. package/dist/controllers/NestedAppAuthController.mjs +345 -0
  45. package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
  46. package/dist/controllers/StandardController.d.ts +11 -6
  47. package/dist/controllers/StandardController.d.ts.map +1 -1
  48. package/dist/controllers/StandardController.mjs +67 -45
  49. package/dist/controllers/StandardController.mjs.map +1 -1
  50. package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
  51. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
  52. package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
  53. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
  54. package/dist/crypto/BrowserCrypto.d.ts +44 -49
  55. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  56. package/dist/crypto/BrowserCrypto.mjs +77 -77
  57. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  58. package/dist/crypto/CryptoOps.d.ts +1 -7
  59. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  60. package/dist/crypto/CryptoOps.mjs +18 -23
  61. package/dist/crypto/CryptoOps.mjs.map +1 -1
  62. package/dist/crypto/PkceGenerator.d.ts +6 -21
  63. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  64. package/dist/crypto/PkceGenerator.mjs +45 -46
  65. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  66. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  67. package/dist/encode/Base64Decode.d.ts.map +1 -1
  68. package/dist/encode/Base64Decode.mjs +18 -2
  69. package/dist/encode/Base64Decode.mjs.map +1 -1
  70. package/dist/encode/Base64Encode.mjs +1 -1
  71. package/dist/error/BrowserAuthError.d.ts +10 -1
  72. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  73. package/dist/error/BrowserAuthError.mjs +12 -3
  74. package/dist/error/BrowserAuthError.mjs.map +1 -1
  75. package/dist/error/BrowserAuthErrorCodes.d.ts +1 -0
  76. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  77. package/dist/error/BrowserAuthErrorCodes.mjs +3 -2
  78. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  79. package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
  80. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  81. package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
  82. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  83. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
  84. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
  85. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
  86. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
  87. package/dist/error/NativeAuthError.d.ts +17 -45
  88. package/dist/error/NativeAuthError.d.ts.map +1 -1
  89. package/dist/error/NativeAuthError.mjs +47 -78
  90. package/dist/error/NativeAuthError.mjs.map +1 -1
  91. package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
  92. package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
  93. package/dist/error/NativeAuthErrorCodes.mjs +11 -0
  94. package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
  95. package/dist/error/NestedAppAuthError.d.ts +15 -0
  96. package/dist/error/NestedAppAuthError.d.ts.map +1 -0
  97. package/dist/error/NestedAppAuthError.mjs +30 -0
  98. package/dist/error/NestedAppAuthError.mjs.map +1 -0
  99. package/dist/event/EventHandler.d.ts.map +1 -1
  100. package/dist/event/EventHandler.mjs +3 -2
  101. package/dist/event/EventHandler.mjs.map +1 -1
  102. package/dist/event/EventMessage.mjs +1 -1
  103. package/dist/event/EventType.mjs +1 -1
  104. package/dist/index.d.ts +5 -7
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.mjs +7 -3
  107. package/dist/index.mjs.map +1 -1
  108. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  109. package/dist/interaction_client/BaseInteractionClient.mjs +10 -11
  110. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  111. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  112. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  113. package/dist/interaction_client/NativeInteractionClient.mjs +26 -13
  114. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  115. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  116. package/dist/interaction_client/PopupClient.mjs +5 -4
  117. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  118. package/dist/interaction_client/RedirectClient.mjs +7 -7
  119. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  120. package/dist/interaction_client/SilentAuthCodeClient.mjs +7 -10
  121. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  122. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  123. package/dist/interaction_client/SilentCacheClient.mjs +11 -18
  124. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  125. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  126. package/dist/interaction_client/SilentIframeClient.mjs +27 -13
  127. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  128. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  129. package/dist/interaction_client/SilentRefreshClient.mjs +8 -18
  130. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  131. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  132. package/dist/interaction_client/StandardInteractionClient.mjs +16 -37
  133. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  134. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  135. package/dist/interaction_handler/InteractionHandler.mjs +6 -9
  136. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  137. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  138. package/dist/interaction_handler/RedirectHandler.mjs +3 -3
  139. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  140. package/dist/interaction_handler/SilentHandler.d.ts +13 -47
  141. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  142. package/dist/interaction_handler/SilentHandler.mjs +120 -156
  143. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  144. package/dist/naa/AccountInfo.d.ts +13 -0
  145. package/dist/naa/AccountInfo.d.ts.map +1 -0
  146. package/dist/naa/AccountRequests.d.ts +10 -0
  147. package/dist/naa/AccountRequests.d.ts.map +1 -0
  148. package/dist/naa/AuthBridge.d.ts +6 -0
  149. package/dist/naa/AuthBridge.d.ts.map +1 -0
  150. package/dist/naa/BridgeCapabilities.d.ts +4 -0
  151. package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
  152. package/dist/naa/BridgeError.d.ts +10 -0
  153. package/dist/naa/BridgeError.d.ts.map +1 -0
  154. package/dist/naa/BridgeError.mjs +12 -0
  155. package/dist/naa/BridgeError.mjs.map +1 -0
  156. package/dist/naa/BridgeProxy.d.ts +72 -0
  157. package/dist/naa/BridgeProxy.d.ts.map +1 -0
  158. package/dist/naa/BridgeProxy.mjs +154 -0
  159. package/dist/naa/BridgeProxy.mjs.map +1 -0
  160. package/dist/naa/BridgeRequest.d.ts +7 -0
  161. package/dist/naa/BridgeRequest.d.ts.map +1 -0
  162. package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
  163. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
  164. package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
  165. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
  166. package/dist/naa/BridgeStatusCode.d.ts +11 -0
  167. package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
  168. package/dist/naa/BridgeStatusCode.mjs +20 -0
  169. package/dist/naa/BridgeStatusCode.mjs.map +1 -0
  170. package/dist/naa/IBridgeProxy.d.ts +11 -0
  171. package/dist/naa/IBridgeProxy.d.ts.map +1 -0
  172. package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
  173. package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
  174. package/dist/naa/TokenRequest.d.ts +22 -0
  175. package/dist/naa/TokenRequest.d.ts.map +1 -0
  176. package/dist/naa/TokenResponse.d.ts +17 -0
  177. package/dist/naa/TokenResponse.d.ts.map +1 -0
  178. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
  179. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
  180. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
  181. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
  182. package/dist/navigation/NavigationClient.mjs +1 -1
  183. package/dist/network/FetchClient.mjs +1 -1
  184. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  185. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  186. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
  187. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  188. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
  189. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  190. package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
  191. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
  192. package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
  193. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
  194. package/dist/packageMetadata.d.ts +1 -1
  195. package/dist/packageMetadata.mjs +2 -2
  196. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  197. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  198. package/dist/utils/BrowserConstants.mjs +1 -1
  199. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  200. package/dist/utils/BrowserProtocolUtils.mjs +3 -3
  201. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  202. package/dist/utils/BrowserUtils.d.ts +54 -53
  203. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  204. package/dist/utils/BrowserUtils.mjs +114 -102
  205. package/dist/utils/BrowserUtils.mjs.map +1 -1
  206. package/lib/msal-browser.cjs +61 -18042
  207. package/lib/msal-browser.cjs.map +1 -1
  208. package/lib/msal-browser.js +13593 -12505
  209. package/lib/msal-browser.js.map +1 -1
  210. package/lib/msal-browser.min.js +66 -65
  211. package/package.json +2 -2
  212. package/src/app/IPublicClientApplication.ts +55 -18
  213. package/src/app/PublicClientApplication.ts +19 -7
  214. package/src/app/PublicClientNext.ts +442 -0
  215. package/src/broker/nativeBroker/NativeMessageHandler.ts +12 -15
  216. package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
  217. package/src/cache/BrowserCacheManager.ts +29 -103
  218. package/src/cache/BrowserStorage.ts +9 -11
  219. package/src/config/Configuration.ts +21 -8
  220. package/src/controllers/ControllerFactory.ts +36 -25
  221. package/src/controllers/IController.ts +4 -1
  222. package/src/controllers/NestedAppAuthController.ts +525 -0
  223. package/src/controllers/StandardController.ts +163 -98
  224. package/src/controllers/UnknownOperatingContextController.ts +383 -0
  225. package/src/crypto/BrowserCrypto.ts +119 -103
  226. package/src/crypto/CryptoOps.ts +18 -27
  227. package/src/crypto/PkceGenerator.ts +93 -54
  228. package/src/encode/Base64Decode.ts +21 -1
  229. package/src/error/BrowserAuthError.ts +13 -1
  230. package/src/error/BrowserAuthErrorCodes.ts +1 -0
  231. package/src/error/BrowserConfigurationAuthError.ts +33 -102
  232. package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
  233. package/src/error/NativeAuthError.ts +73 -101
  234. package/src/error/NativeAuthErrorCodes.ts +7 -0
  235. package/src/error/NestedAppAuthError.ts +32 -0
  236. package/src/event/EventHandler.ts +2 -1
  237. package/src/index.ts +8 -10
  238. package/src/interaction_client/BaseInteractionClient.ts +14 -8
  239. package/src/interaction_client/NativeInteractionClient.ts +48 -14
  240. package/src/interaction_client/PopupClient.ts +2 -1
  241. package/src/interaction_client/RedirectClient.ts +1 -1
  242. package/src/interaction_client/SilentAuthCodeClient.ts +22 -19
  243. package/src/interaction_client/SilentCacheClient.ts +28 -28
  244. package/src/interaction_client/SilentIframeClient.ts +54 -18
  245. package/src/interaction_client/SilentRefreshClient.ts +26 -28
  246. package/src/interaction_client/StandardInteractionClient.ts +37 -68
  247. package/src/interaction_handler/InteractionHandler.ts +20 -15
  248. package/src/interaction_handler/RedirectHandler.ts +6 -2
  249. package/src/interaction_handler/SilentHandler.ts +177 -230
  250. package/src/naa/AccountInfo.ts +17 -0
  251. package/src/naa/AccountRequests.ts +16 -0
  252. package/src/naa/AuthBridge.ts +16 -0
  253. package/src/naa/BridgeCapabilities.ts +8 -0
  254. package/src/naa/BridgeError.ts +18 -0
  255. package/src/naa/BridgeProxy.ts +230 -0
  256. package/src/naa/BridgeRequest.ts +12 -0
  257. package/src/naa/BridgeRequestEnvelope.ts +46 -0
  258. package/src/naa/BridgeResponseEnvelope.ts +21 -0
  259. package/src/naa/BridgeStatusCode.ts +15 -0
  260. package/src/naa/IBridgeProxy.ts +25 -0
  261. package/src/naa/InitializeBridgeResponse.ts +12 -0
  262. package/src/naa/TokenRequest.ts +26 -0
  263. package/src/naa/TokenResponse.ts +61 -0
  264. package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
  265. package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
  266. package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
  267. package/src/packageMetadata.ts +1 -1
  268. package/src/utils/BrowserProtocolUtils.ts +3 -2
  269. package/src/utils/BrowserUtils.ts +133 -125
  270. package/dist/crypto/ISubtleCrypto.d.ts +0 -10
  271. package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
  272. package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
  273. package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
  274. package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
  275. package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
  276. package/dist/utils/BrowserStringUtils.d.ts +0 -22
  277. package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
  278. package/dist/utils/BrowserStringUtils.mjs +0 -144
  279. package/dist/utils/BrowserStringUtils.mjs.map +0 -1
  280. package/src/crypto/ISubtleCrypto.ts +0 -30
  281. package/src/crypto/ModernBrowserCrypto.ts +0 -69
  282. package/src/utils/BrowserStringUtils.ts +0 -143
@@ -19,7 +19,6 @@ import {
19
19
  IPerformanceClient,
20
20
  BaseAuthRequest,
21
21
  PromptValue,
22
- ClientAuthError,
23
22
  InProgressPerformanceEvent,
24
23
  RequestThumbprint,
25
24
  ServerError,
@@ -27,6 +26,10 @@ import {
27
26
  ServerResponseType,
28
27
  UrlString,
29
28
  invokeAsync,
29
+ createClientAuthError,
30
+ ClientAuthErrorCodes,
31
+ AccountFilter,
32
+ buildStaticAuthorityOptions,
30
33
  } from "@azure/msal-common";
31
34
  import {
32
35
  BrowserCacheManager,
@@ -43,14 +46,17 @@ import {
43
46
  DEFAULT_REQUEST,
44
47
  BrowserConstants,
45
48
  } from "../utils/BrowserConstants";
46
- import { BrowserUtils } from "../utils/BrowserUtils";
49
+ import * as BrowserUtils from "../utils/BrowserUtils";
47
50
  import { RedirectRequest } from "../request/RedirectRequest";
48
51
  import { PopupRequest } from "../request/PopupRequest";
49
52
  import { SsoSilentRequest } from "../request/SsoSilentRequest";
50
53
  import { EventCallbackFunction, EventError } from "../event/EventMessage";
51
54
  import { EventType } from "../event/EventType";
52
55
  import { EndSessionRequest } from "../request/EndSessionRequest";
53
- import { BrowserConfigurationAuthError } from "../error/BrowserConfigurationAuthError";
56
+ import {
57
+ BrowserConfigurationAuthErrorCodes,
58
+ createBrowserConfigurationAuthError,
59
+ } from "../error/BrowserConfigurationAuthError";
54
60
  import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
55
61
  import { INavigationClient } from "../navigation/INavigationClient";
56
62
  import { EventHandler } from "../event/EventHandler";
@@ -63,7 +69,10 @@ import { ITokenCache } from "../cache/ITokenCache";
63
69
  import { NativeInteractionClient } from "../interaction_client/NativeInteractionClient";
64
70
  import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
65
71
  import { SilentRequest } from "../request/SilentRequest";
66
- import { NativeAuthError } from "../error/NativeAuthError";
72
+ import {
73
+ NativeAuthError,
74
+ isFatalNativeAuthError,
75
+ } from "../error/NativeAuthError";
67
76
  import { SilentCacheClient } from "../interaction_client/SilentCacheClient";
68
77
  import { SilentAuthCodeClient } from "../interaction_client/SilentAuthCodeClient";
69
78
  import {
@@ -77,6 +86,7 @@ import { BaseOperatingContext } from "../operatingcontext/BaseOperatingContext";
77
86
  import { IController } from "./IController";
78
87
  import { AuthenticationResult } from "../response/AuthenticationResult";
79
88
  import { ClearCacheRequest } from "../request/ClearCacheRequest";
89
+ import { createNewGuid } from "../crypto/BrowserCrypto";
80
90
 
81
91
  export class StandardController implements IController {
82
92
  // OperatingContext
@@ -198,7 +208,8 @@ export class StandardController implements IController {
198
208
  this.config.auth.clientId,
199
209
  this.config.cache,
200
210
  this.browserCrypto,
201
- this.logger
211
+ this.logger,
212
+ buildStaticAuthorityOptions(this.config.auth)
202
213
  )
203
214
  : DEFAULT_BROWSER_CACHE_MANAGER(
204
215
  this.config.auth.clientId,
@@ -281,8 +292,7 @@ export class StandardController implements IController {
281
292
  await NativeMessageHandler.createProvider(
282
293
  this.logger,
283
294
  this.config.system.nativeBrokerHandshakeTimeout,
284
- this.performanceClient,
285
- this.browserCrypto
295
+ this.performanceClient
286
296
  );
287
297
  } catch (e) {
288
298
  this.logger.verbose(e as string);
@@ -301,7 +311,7 @@ export class StandardController implements IController {
301
311
  PerformanceEvents.ClearTokensAndKeysWithClaims,
302
312
  this.logger,
303
313
  this.performanceClient
304
- )();
314
+ )(this.performanceClient);
305
315
  }
306
316
 
307
317
  this.initialized = true;
@@ -528,7 +538,10 @@ export class StandardController implements IController {
528
538
  result = nativeClient
529
539
  .acquireTokenRedirect(request)
530
540
  .catch((e: AuthError) => {
531
- if (e instanceof NativeAuthError && e.isFatal()) {
541
+ if (
542
+ e instanceof NativeAuthError &&
543
+ isFatalNativeAuthError(e)
544
+ ) {
532
545
  this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
533
546
  const redirectClient = this.createRedirectClient(
534
547
  request.correlationId
@@ -630,7 +643,10 @@ export class StandardController implements IController {
630
643
  return response;
631
644
  })
632
645
  .catch((e: AuthError) => {
633
- if (e instanceof NativeAuthError && e.isFatal()) {
646
+ if (
647
+ e instanceof NativeAuthError &&
648
+ isFatalNativeAuthError(e)
649
+ ) {
634
650
  this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
635
651
  const popupClient = this.createPopupClient(
636
652
  request.correlationId
@@ -781,7 +797,7 @@ export class StandardController implements IController {
781
797
  ApiId.ssoSilent
782
798
  ).catch((e: AuthError) => {
783
799
  // If native token acquisition fails for availability reasons fallback to standard flow
784
- if (e instanceof NativeAuthError && e.isFatal()) {
800
+ if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
785
801
  this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
786
802
  const silentIframeClient = this.createSilentIframeClient(
787
803
  validRequest.correlationId
@@ -931,7 +947,10 @@ export class StandardController implements IController {
931
947
  request.nativeAccountId
932
948
  ).catch((e: AuthError) => {
933
949
  // If native token acquisition fails for availability reasons fallback to standard flow
934
- if (e instanceof NativeAuthError && e.isFatal()) {
950
+ if (
951
+ e instanceof NativeAuthError &&
952
+ isFatalNativeAuthError(e)
953
+ ) {
935
954
  this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
936
955
  }
937
956
  throw e;
@@ -1038,9 +1057,17 @@ export class StandardController implements IController {
1038
1057
  case CacheLookupPolicy.Default:
1039
1058
  case CacheLookupPolicy.AccessToken:
1040
1059
  case CacheLookupPolicy.AccessTokenAndRefreshToken:
1041
- return silentCacheClient.acquireToken(commonRequest);
1060
+ return invokeAsync(
1061
+ silentCacheClient.acquireToken.bind(silentCacheClient),
1062
+ PerformanceEvents.SilentCacheClientAcquireToken,
1063
+ this.logger,
1064
+ this.performanceClient,
1065
+ commonRequest.correlationId
1066
+ )(commonRequest);
1042
1067
  default:
1043
- throw ClientAuthError.createRefreshRequiredError();
1068
+ throw createClientAuthError(
1069
+ ClientAuthErrorCodes.tokenRefreshRequired
1070
+ );
1044
1071
  }
1045
1072
  }
1046
1073
 
@@ -1067,13 +1094,17 @@ export class StandardController implements IController {
1067
1094
  commonRequest.correlationId
1068
1095
  );
1069
1096
 
1070
- this.performanceClient.setPreQueueTime(
1097
+ return invokeAsync(
1098
+ silentRefreshClient.acquireToken.bind(silentRefreshClient),
1071
1099
  PerformanceEvents.SilentRefreshClientAcquireToken,
1100
+ this.logger,
1101
+ this.performanceClient,
1072
1102
  commonRequest.correlationId
1073
- );
1074
- return silentRefreshClient.acquireToken(commonRequest);
1103
+ )(commonRequest);
1075
1104
  default:
1076
- throw ClientAuthError.createRefreshRequiredError();
1105
+ throw createClientAuthError(
1106
+ ClientAuthErrorCodes.tokenRefreshRequired
1107
+ );
1077
1108
  }
1078
1109
  }
1079
1110
 
@@ -1168,18 +1199,45 @@ export class StandardController implements IController {
1168
1199
  // #region Account APIs
1169
1200
 
1170
1201
  /**
1171
- * Returns all accounts that MSAL currently has data for.
1172
- * (the account object is created at the time of successful login)
1173
- * or empty array when no accounts are found
1174
- * @returns Array of account objects in cache
1202
+ * Returns all the accounts in the cache that match the optional filter. If no filter is provided, all accounts are returned.
1203
+ * @param accountFilter - (Optional) filter to narrow down the accounts returned
1204
+ * @returns Array of AccountInfo objects in cache
1175
1205
  */
1176
- getAllAccounts(): AccountInfo[] {
1206
+ getAllAccounts(accountFilter?: AccountFilter): AccountInfo[] {
1177
1207
  this.logger.verbose("getAllAccounts called");
1178
1208
  return this.isBrowserEnvironment
1179
- ? this.browserStorage.getAllAccounts()
1209
+ ? this.browserStorage.getAllAccounts(accountFilter)
1180
1210
  : [];
1181
1211
  }
1182
1212
 
1213
+ /**
1214
+ * Returns the first account found in the cache that matches the account filter passed in.
1215
+ * @param accountFilter
1216
+ * @returns The first account found in the cache matching the provided filter or null if no account could be found.
1217
+ */
1218
+ getAccount(accountFilter: AccountFilter): AccountInfo | null {
1219
+ this.logger.trace("getAccount called");
1220
+ if (Object.keys(accountFilter).length === 0) {
1221
+ this.logger.warning("getAccount: No accountFilter provided");
1222
+ return null;
1223
+ }
1224
+
1225
+ const account: AccountInfo | null =
1226
+ this.browserStorage.getAccountInfoFilteredBy(accountFilter);
1227
+
1228
+ if (account) {
1229
+ this.logger.verbose(
1230
+ "getAccount: Account matching provided filter found, returning"
1231
+ );
1232
+ return account;
1233
+ } else {
1234
+ this.logger.verbose(
1235
+ "getAccount: No matching account found, returning null"
1236
+ );
1237
+ return null;
1238
+ }
1239
+ }
1240
+
1183
1241
  /**
1184
1242
  * Returns the signed in account matching username.
1185
1243
  * (the account object is created at the time of successful login)
@@ -1375,7 +1433,9 @@ export class StandardController implements IController {
1375
1433
  BrowserCacheLocation.MemoryStorage &&
1376
1434
  !this.config.cache.storeAuthStateInCookie
1377
1435
  ) {
1378
- throw BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError();
1436
+ throw createBrowserConfigurationAuthError(
1437
+ BrowserConfigurationAuthErrorCodes.inMemRedirectUnavailable
1438
+ );
1379
1439
  }
1380
1440
 
1381
1441
  if (
@@ -1501,10 +1561,10 @@ export class StandardController implements IController {
1501
1561
  ): string {
1502
1562
  const account =
1503
1563
  request.account ||
1504
- this.browserStorage.getAccountInfoByHints(
1505
- request.loginHint,
1506
- request.sid
1507
- ) ||
1564
+ this.browserStorage.getAccountInfoFilteredBy({
1565
+ loginHint: request.loginHint,
1566
+ sid: request.sid,
1567
+ }) ||
1508
1568
  this.getActiveAccount();
1509
1569
 
1510
1570
  return (account && account.nativeAccountId) || "";
@@ -1768,7 +1828,7 @@ export class StandardController implements IController {
1768
1828
  }
1769
1829
 
1770
1830
  if (this.isBrowserEnvironment) {
1771
- return this.browserCrypto.createNewGuid();
1831
+ return createNewGuid();
1772
1832
  }
1773
1833
 
1774
1834
  /*
@@ -1862,11 +1922,13 @@ export class StandardController implements IController {
1862
1922
  correlationId
1863
1923
  );
1864
1924
 
1865
- this.performanceClient.setPreQueueTime(
1925
+ const response = invokeAsync(
1926
+ this.acquireTokenSilentAsync.bind(this),
1866
1927
  PerformanceEvents.AcquireTokenSilentAsync,
1928
+ this.logger,
1929
+ this.performanceClient,
1867
1930
  correlationId
1868
- );
1869
- const response = this.acquireTokenSilentAsync(
1931
+ )(
1870
1932
  {
1871
1933
  ...request,
1872
1934
  correlationId,
@@ -1960,7 +2022,7 @@ export class StandardController implements IController {
1960
2022
  ApiId.acquireTokenSilent_silentFlow
1961
2023
  ).catch(async (e: AuthError) => {
1962
2024
  // If native token acquisition fails for availability reasons fallback to web flow
1963
- if (e instanceof NativeAuthError && e.isFatal()) {
2025
+ if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
1964
2026
  this.logger.verbose(
1965
2027
  "acquireTokenSilent - native platform unavailable, falling back to web flow"
1966
2028
  );
@@ -1983,15 +2045,15 @@ export class StandardController implements IController {
1983
2045
  request.correlationId
1984
2046
  );
1985
2047
 
1986
- this.performanceClient.setPreQueueTime(
2048
+ const silentRequest = await invokeAsync(
2049
+ silentCacheClient.initializeSilentRequest.bind(
2050
+ silentCacheClient
2051
+ ),
1987
2052
  PerformanceEvents.InitializeSilentRequest,
2053
+ this.logger,
2054
+ this.performanceClient,
1988
2055
  request.correlationId
1989
- );
1990
- const silentRequest =
1991
- await silentCacheClient.initializeSilentRequest(
1992
- request,
1993
- account
1994
- );
2056
+ )(request, account);
1995
2057
 
1996
2058
  const requestWithCLP = {
1997
2059
  ...request,
@@ -2000,72 +2062,75 @@ export class StandardController implements IController {
2000
2062
  request.cacheLookupPolicy || CacheLookupPolicy.Default,
2001
2063
  };
2002
2064
 
2003
- this.performanceClient.setPreQueueTime(
2065
+ result = invokeAsync(
2066
+ this.acquireTokenFromCache.bind(this),
2004
2067
  PerformanceEvents.AcquireTokenFromCache,
2068
+ this.logger,
2069
+ this.performanceClient,
2005
2070
  silentRequest.correlationId
2006
- );
2007
- result = this.acquireTokenFromCache(
2008
- silentCacheClient,
2009
- silentRequest,
2010
- requestWithCLP
2011
- ).catch((cacheError: AuthError) => {
2012
- if (
2013
- requestWithCLP.cacheLookupPolicy ===
2014
- CacheLookupPolicy.AccessToken
2015
- ) {
2016
- throw cacheError;
2017
- }
2018
-
2019
- // block the reload if it occurred inside a hidden iframe
2020
- BrowserUtils.blockReloadInHiddenIframes();
2021
- this.eventHandler.emitEvent(
2022
- EventType.ACQUIRE_TOKEN_NETWORK_START,
2023
- InteractionType.Silent,
2024
- silentRequest
2025
- );
2026
-
2027
- this.performanceClient.setPreQueueTime(
2028
- PerformanceEvents.AcquireTokenByRefreshToken,
2029
- silentRequest.correlationId
2030
- );
2031
- return this.acquireTokenByRefreshToken(
2032
- silentRequest,
2033
- requestWithCLP
2034
- ).catch((refreshTokenError: AuthError) => {
2035
- const isServerError =
2036
- refreshTokenError instanceof ServerError;
2037
- const isInteractionRequiredError =
2038
- refreshTokenError instanceof
2039
- InteractionRequiredAuthError;
2040
- const isInvalidGrantError =
2041
- refreshTokenError.errorCode ===
2042
- BrowserConstants.INVALID_GRANT_ERROR;
2043
-
2071
+ )(silentCacheClient, silentRequest, requestWithCLP).catch(
2072
+ (cacheError: AuthError) => {
2044
2073
  if (
2045
- (!isServerError ||
2046
- !isInvalidGrantError ||
2047
- isInteractionRequiredError ||
2048
- requestWithCLP.cacheLookupPolicy ===
2049
- CacheLookupPolicy.AccessTokenAndRefreshToken ||
2050
- requestWithCLP.cacheLookupPolicy ===
2051
- CacheLookupPolicy.RefreshToken) &&
2052
- requestWithCLP.cacheLookupPolicy !==
2053
- CacheLookupPolicy.Skip
2074
+ requestWithCLP.cacheLookupPolicy ===
2075
+ CacheLookupPolicy.AccessToken
2054
2076
  ) {
2055
- throw refreshTokenError;
2077
+ throw cacheError;
2056
2078
  }
2057
2079
 
2058
- this.logger.verbose(
2059
- "Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.",
2060
- request.correlationId
2080
+ // block the reload if it occurred inside a hidden iframe
2081
+ BrowserUtils.blockReloadInHiddenIframes();
2082
+ this.eventHandler.emitEvent(
2083
+ EventType.ACQUIRE_TOKEN_NETWORK_START,
2084
+ InteractionType.Silent,
2085
+ silentRequest
2061
2086
  );
2062
- this.performanceClient.setPreQueueTime(
2063
- PerformanceEvents.AcquireTokenBySilentIframe,
2087
+
2088
+ return invokeAsync(
2089
+ this.acquireTokenByRefreshToken.bind(this),
2090
+ PerformanceEvents.AcquireTokenByRefreshToken,
2091
+ this.logger,
2092
+ this.performanceClient,
2064
2093
  silentRequest.correlationId
2094
+ )(silentRequest, requestWithCLP).catch(
2095
+ (refreshTokenError: AuthError) => {
2096
+ const isServerError =
2097
+ refreshTokenError instanceof ServerError;
2098
+ const isInteractionRequiredError =
2099
+ refreshTokenError instanceof
2100
+ InteractionRequiredAuthError;
2101
+ const isInvalidGrantError =
2102
+ refreshTokenError.errorCode ===
2103
+ BrowserConstants.INVALID_GRANT_ERROR;
2104
+
2105
+ if (
2106
+ (!isServerError ||
2107
+ !isInvalidGrantError ||
2108
+ isInteractionRequiredError ||
2109
+ requestWithCLP.cacheLookupPolicy ===
2110
+ CacheLookupPolicy.AccessTokenAndRefreshToken ||
2111
+ requestWithCLP.cacheLookupPolicy ===
2112
+ CacheLookupPolicy.RefreshToken) &&
2113
+ requestWithCLP.cacheLookupPolicy !==
2114
+ CacheLookupPolicy.Skip
2115
+ ) {
2116
+ throw refreshTokenError;
2117
+ }
2118
+
2119
+ this.logger.verbose(
2120
+ "Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.",
2121
+ request.correlationId
2122
+ );
2123
+ return invokeAsync(
2124
+ this.acquireTokenBySilentIframe.bind(this),
2125
+ PerformanceEvents.AcquireTokenBySilentIframe,
2126
+ this.logger,
2127
+ this.performanceClient,
2128
+ silentRequest.correlationId
2129
+ )(silentRequest);
2130
+ }
2065
2131
  );
2066
- return this.acquireTokenBySilentIframe(silentRequest);
2067
- });
2068
- });
2132
+ }
2133
+ );
2069
2134
  }
2070
2135
 
2071
2136
  return result