@azure/msal-browser 3.0.2 → 3.2.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 (280) hide show
  1. package/dist/app/IPublicClientApplication.d.ts +2 -0
  2. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/IPublicClientApplication.mjs +22 -18
  4. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientApplication.d.ts +20 -6
  6. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  7. package/dist/app/PublicClientApplication.mjs +24 -7
  8. package/dist/app/PublicClientApplication.mjs.map +1 -1
  9. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
  10. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +17 -16
  12. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  13. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
  14. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
  15. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
  16. package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
  17. package/dist/cache/AsyncMemoryStorage.mjs +4 -3
  18. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  19. package/dist/cache/BrowserCacheManager.d.ts +10 -3
  20. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  21. package/dist/cache/BrowserCacheManager.mjs +58 -29
  22. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  23. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  24. package/dist/cache/BrowserStorage.mjs +7 -9
  25. package/dist/cache/BrowserStorage.mjs.map +1 -1
  26. package/dist/cache/CryptoKeyStore.mjs +1 -1
  27. package/dist/cache/CryptoKeyStore.mjs.map +1 -1
  28. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  29. package/dist/cache/DatabaseStorage.mjs +9 -8
  30. package/dist/cache/DatabaseStorage.mjs.map +1 -1
  31. package/dist/cache/MemoryStorage.mjs +1 -1
  32. package/dist/cache/MemoryStorage.mjs.map +1 -1
  33. package/dist/cache/TokenCache.d.ts.map +1 -1
  34. package/dist/cache/TokenCache.mjs +30 -30
  35. package/dist/cache/TokenCache.mjs.map +1 -1
  36. package/dist/config/Configuration.d.ts +1 -0
  37. package/dist/config/Configuration.d.ts.map +1 -1
  38. package/dist/config/Configuration.mjs +12 -16
  39. package/dist/config/Configuration.mjs.map +1 -1
  40. package/dist/controllers/ControllerFactory.mjs +1 -1
  41. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  42. package/dist/controllers/IController.d.ts +5 -28
  43. package/dist/controllers/IController.d.ts.map +1 -1
  44. package/dist/controllers/StandardController.d.ts +17 -31
  45. package/dist/controllers/StandardController.d.ts.map +1 -1
  46. package/dist/controllers/StandardController.mjs +78 -83
  47. package/dist/controllers/StandardController.mjs.map +1 -1
  48. package/dist/crypto/BrowserCrypto.d.ts +44 -49
  49. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  50. package/dist/crypto/BrowserCrypto.mjs +78 -77
  51. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  52. package/dist/crypto/CryptoOps.d.ts +1 -10
  53. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  54. package/dist/crypto/CryptoOps.mjs +23 -34
  55. package/dist/crypto/CryptoOps.mjs.map +1 -1
  56. package/dist/crypto/PkceGenerator.d.ts +6 -22
  57. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  58. package/dist/crypto/PkceGenerator.mjs +48 -49
  59. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  60. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  61. package/dist/crypto/SignedHttpRequest.mjs.map +1 -1
  62. package/dist/encode/Base64Decode.d.ts +6 -19
  63. package/dist/encode/Base64Decode.d.ts.map +1 -1
  64. package/dist/encode/Base64Decode.mjs +31 -68
  65. package/dist/encode/Base64Decode.mjs.map +1 -1
  66. package/dist/encode/Base64Encode.d.ts +15 -27
  67. package/dist/encode/Base64Encode.d.ts.map +1 -1
  68. package/dist/encode/Base64Encode.mjs +36 -75
  69. package/dist/encode/Base64Encode.mjs.map +1 -1
  70. package/dist/error/BrowserAuthError.d.ts +63 -195
  71. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  72. package/dist/error/BrowserAuthError.mjs +159 -381
  73. package/dist/error/BrowserAuthError.mjs.map +1 -1
  74. package/dist/error/BrowserAuthErrorCodes.d.ts +46 -0
  75. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -0
  76. package/dist/error/BrowserAuthErrorCodes.mjs +54 -0
  77. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -0
  78. package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
  79. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  80. package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
  81. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  82. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
  83. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
  84. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
  85. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
  86. package/dist/error/NativeAuthError.d.ts +17 -45
  87. package/dist/error/NativeAuthError.d.ts.map +1 -1
  88. package/dist/error/NativeAuthError.mjs +49 -79
  89. package/dist/error/NativeAuthError.mjs.map +1 -1
  90. package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
  91. package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
  92. package/dist/error/NativeAuthErrorCodes.mjs +11 -0
  93. package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
  94. package/dist/event/EventHandler.d.ts.map +1 -1
  95. package/dist/event/EventHandler.mjs +3 -2
  96. package/dist/event/EventHandler.mjs.map +1 -1
  97. package/dist/event/EventMessage.mjs +1 -1
  98. package/dist/event/EventMessage.mjs.map +1 -1
  99. package/dist/event/EventType.mjs +1 -1
  100. package/dist/event/EventType.mjs.map +1 -1
  101. package/dist/index.d.ts +6 -6
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.mjs +8 -4
  104. package/dist/index.mjs.map +1 -1
  105. package/dist/interaction_client/BaseInteractionClient.d.ts +2 -1
  106. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  107. package/dist/interaction_client/BaseInteractionClient.mjs +7 -8
  108. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  109. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  110. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs.map +1 -1
  111. package/dist/interaction_client/NativeInteractionClient.d.ts +4 -10
  112. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  113. package/dist/interaction_client/NativeInteractionClient.mjs +32 -38
  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 +16 -15
  117. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  118. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  119. package/dist/interaction_client/RedirectClient.mjs +7 -6
  120. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  121. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  122. package/dist/interaction_client/SilentAuthCodeClient.mjs +9 -11
  123. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  124. package/dist/interaction_client/SilentCacheClient.d.ts +4 -2
  125. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  126. package/dist/interaction_client/SilentCacheClient.mjs +19 -25
  127. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  128. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  129. package/dist/interaction_client/SilentIframeClient.mjs +20 -47
  130. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  131. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  132. package/dist/interaction_client/SilentRefreshClient.mjs +11 -20
  133. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  134. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  135. package/dist/interaction_client/StandardInteractionClient.mjs +18 -38
  136. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  137. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  138. package/dist/interaction_handler/InteractionHandler.mjs +13 -16
  139. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  140. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  141. package/dist/interaction_handler/RedirectHandler.mjs +12 -11
  142. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  143. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  144. package/dist/interaction_handler/SilentHandler.mjs +11 -11
  145. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  146. package/dist/navigation/NavigationClient.mjs +1 -1
  147. package/dist/navigation/NavigationClient.mjs.map +1 -1
  148. package/dist/network/FetchClient.d.ts.map +1 -1
  149. package/dist/network/FetchClient.mjs +9 -8
  150. package/dist/network/FetchClient.mjs.map +1 -1
  151. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  152. package/dist/operatingcontext/BaseOperatingContext.mjs.map +1 -1
  153. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  154. package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
  155. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  156. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  157. package/dist/packageMetadata.d.ts +1 -1
  158. package/dist/packageMetadata.mjs +2 -2
  159. package/dist/packageMetadata.mjs.map +1 -1
  160. package/dist/request/ClearCacheRequest.d.ts +11 -0
  161. package/dist/request/ClearCacheRequest.d.ts.map +1 -0
  162. package/dist/telemetry/BrowserPerformanceClient.d.ts +2 -4
  163. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  164. package/dist/telemetry/BrowserPerformanceClient.mjs +2 -6
  165. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  166. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  167. package/dist/telemetry/BrowserPerformanceMeasurement.mjs.map +1 -1
  168. package/dist/utils/BrowserConstants.mjs +1 -1
  169. package/dist/utils/BrowserConstants.mjs.map +1 -1
  170. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  171. package/dist/utils/BrowserProtocolUtils.mjs +4 -4
  172. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  173. package/dist/utils/BrowserStringUtils.mjs +1 -1
  174. package/dist/utils/BrowserStringUtils.mjs.map +1 -1
  175. package/dist/utils/BrowserUtils.d.ts +0 -9
  176. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  177. package/dist/utils/BrowserUtils.mjs +8 -33
  178. package/dist/utils/BrowserUtils.mjs.map +1 -1
  179. package/lib/msal-browser.cjs +8729 -9566
  180. package/lib/msal-browser.cjs.map +1 -1
  181. package/lib/msal-browser.js +8729 -9566
  182. package/lib/msal-browser.js.map +1 -1
  183. package/lib/msal-browser.min.js +68 -62
  184. package/package.json +7 -5
  185. package/src/app/IPublicClientApplication.ts +236 -0
  186. package/src/app/PublicClientApplication.ts +417 -0
  187. package/src/broker/nativeBroker/NativeMessageHandler.ts +416 -0
  188. package/src/broker/nativeBroker/NativeRequest.ts +52 -0
  189. package/src/broker/nativeBroker/NativeResponse.ts +56 -0
  190. package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
  191. package/src/cache/AsyncMemoryStorage.ts +158 -0
  192. package/src/cache/BrowserCacheManager.ts +2009 -0
  193. package/src/cache/BrowserStorage.ts +52 -0
  194. package/src/cache/CryptoKeyStore.ts +63 -0
  195. package/src/cache/DatabaseStorage.ts +287 -0
  196. package/src/cache/IAsyncMemoryStorage.ts +36 -0
  197. package/src/cache/ITokenCache.ts +21 -0
  198. package/src/cache/IWindowStorage.ts +36 -0
  199. package/src/cache/MemoryStorage.ts +42 -0
  200. package/src/cache/TokenCache.ts +484 -0
  201. package/src/config/Configuration.ts +383 -0
  202. package/src/controllers/ControllerFactory.ts +55 -0
  203. package/src/controllers/IController.ts +134 -0
  204. package/src/controllers/StandardController.ts +2170 -0
  205. package/src/crypto/BrowserCrypto.ts +151 -0
  206. package/src/crypto/CryptoOps.ts +235 -0
  207. package/src/crypto/PkceGenerator.ts +115 -0
  208. package/src/crypto/SignedHttpRequest.ts +76 -0
  209. package/src/encode/Base64Decode.ts +46 -0
  210. package/src/encode/Base64Encode.ts +52 -0
  211. package/src/error/BrowserAuthError.ts +352 -0
  212. package/src/error/BrowserAuthErrorCodes.ts +57 -0
  213. package/src/error/BrowserConfigurationAuthError.ts +64 -0
  214. package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
  215. package/src/error/NativeAuthError.ts +113 -0
  216. package/src/error/NativeAuthErrorCodes.ts +7 -0
  217. package/src/event/EventHandler.ts +177 -0
  218. package/src/event/EventMessage.ts +125 -0
  219. package/src/event/EventType.ts +33 -0
  220. package/src/index.ts +157 -0
  221. package/src/interaction_client/BaseInteractionClient.ts +307 -0
  222. package/src/interaction_client/HybridSpaAuthorizationCodeClient.ts +16 -0
  223. package/src/interaction_client/NativeInteractionClient.ts +925 -0
  224. package/src/interaction_client/PopupClient.ts +926 -0
  225. package/src/interaction_client/RedirectClient.ts +616 -0
  226. package/src/interaction_client/SilentAuthCodeClient.ts +165 -0
  227. package/src/interaction_client/SilentCacheClient.ts +125 -0
  228. package/src/interaction_client/SilentIframeClient.ts +301 -0
  229. package/src/interaction_client/SilentRefreshClient.ts +118 -0
  230. package/src/interaction_client/StandardInteractionClient.ts +450 -0
  231. package/src/interaction_handler/InteractionHandler.ts +251 -0
  232. package/src/interaction_handler/RedirectHandler.ts +229 -0
  233. package/src/interaction_handler/SilentHandler.ts +269 -0
  234. package/src/navigation/INavigationClient.ts +23 -0
  235. package/src/navigation/NavigationClient.ts +55 -0
  236. package/src/navigation/NavigationOptions.ts +18 -0
  237. package/src/network/FetchClient.ts +130 -0
  238. package/src/operatingcontext/BaseOperatingContext.ts +82 -0
  239. package/src/operatingcontext/StandardOperatingContext.ts +49 -0
  240. package/src/operatingcontext/TeamsAppOperatingContext.ts +48 -0
  241. package/src/packageMetadata.ts +3 -0
  242. package/src/request/AuthorizationCodeRequest.ts +19 -0
  243. package/src/request/AuthorizationUrlRequest.ts +17 -0
  244. package/src/request/ClearCacheRequest.ts +16 -0
  245. package/src/request/EndSessionPopupRequest.ts +26 -0
  246. package/src/request/EndSessionRequest.ts +23 -0
  247. package/src/request/PopupRequest.ts +51 -0
  248. package/src/request/PopupWindowAttributes.ts +22 -0
  249. package/src/request/RedirectRequest.ts +51 -0
  250. package/src/request/SilentRequest.ts +49 -0
  251. package/src/request/SsoSilentRequest.ts +44 -0
  252. package/src/response/AuthenticationResult.ts +13 -0
  253. package/src/telemetry/BrowserPerformanceClient.ts +226 -0
  254. package/src/telemetry/BrowserPerformanceMeasurement.ts +144 -0
  255. package/src/utils/BrowserConstants.ts +241 -0
  256. package/src/utils/BrowserProtocolUtils.ts +58 -0
  257. package/src/utils/BrowserStringUtils.ts +143 -0
  258. package/src/utils/BrowserUtils.ts +156 -0
  259. package/dist/crypto/GuidGenerator.d.ts +0 -13
  260. package/dist/crypto/GuidGenerator.d.ts.map +0 -1
  261. package/dist/crypto/GuidGenerator.mjs +0 -104
  262. package/dist/crypto/GuidGenerator.mjs.map +0 -1
  263. package/dist/crypto/ISubtleCrypto.d.ts +0 -10
  264. package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
  265. package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
  266. package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
  267. package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
  268. package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
  269. package/dist/internals.d.ts +0 -23
  270. package/dist/internals.d.ts.map +0 -1
  271. package/dist/internals.mjs +0 -28
  272. package/dist/internals.mjs.map +0 -1
  273. package/dist/network/XhrClient.d.ts +0 -41
  274. package/dist/network/XhrClient.d.ts.map +0 -1
  275. package/dist/network/XhrClient.mjs +0 -125
  276. package/dist/network/XhrClient.mjs.map +0 -1
  277. package/dist/utils/MathUtils.d.ts +0 -12
  278. package/dist/utils/MathUtils.d.ts.map +0 -1
  279. package/dist/utils/MathUtils.mjs +0 -26
  280. package/dist/utils/MathUtils.mjs.map +0 -1
@@ -0,0 +1,352 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AuthError } from "@azure/msal-common";
7
+ import * as BrowserAuthErrorCodes from "./BrowserAuthErrorCodes";
8
+ export { BrowserAuthErrorCodes }; // Allow importing as "BrowserAuthErrorCodes"
9
+
10
+ const ErrorLink = "For more visit: aka.ms/msaljs/browser-errors";
11
+
12
+ /**
13
+ * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
14
+ */
15
+ export const BrowserAuthErrorMessages = {
16
+ [BrowserAuthErrorCodes.pkceNotCreated]:
17
+ "The PKCE code challenge and verifier could not be generated.",
18
+ [BrowserAuthErrorCodes.cryptoNonExistent]:
19
+ "The crypto object or function is not available.",
20
+ [BrowserAuthErrorCodes.emptyNavigateUri]:
21
+ "Navigation URI is empty. Please check stack trace for more info.",
22
+ [BrowserAuthErrorCodes.hashEmptyError]: `Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash. ${ErrorLink}`,
23
+ [BrowserAuthErrorCodes.noStateInHash]:
24
+ "Hash does not contain state. Please verify that the request originated from msal.",
25
+ [BrowserAuthErrorCodes.hashDoesNotContainKnownProperties]: `Hash does not contain known properites. Please verify that your redirectUri is not changing the hash. ${ErrorLink}`,
26
+ [BrowserAuthErrorCodes.unableToParseState]:
27
+ "Unable to parse state. Please verify that the request originated from msal.",
28
+ [BrowserAuthErrorCodes.stateInteractionTypeMismatch]:
29
+ "Hash contains state but the interaction type does not match the caller.",
30
+ [BrowserAuthErrorCodes.interactionInProgress]: `Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. ${ErrorLink}`,
31
+ [BrowserAuthErrorCodes.popupWindowError]:
32
+ "Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser.",
33
+ [BrowserAuthErrorCodes.emptyWindowError]:
34
+ "window.open returned null or undefined window object.",
35
+ [BrowserAuthErrorCodes.userCancelled]: "User cancelled the flow.",
36
+ [BrowserAuthErrorCodes.monitorPopupTimeout]: `Token acquisition in popup failed due to timeout. ${ErrorLink}`,
37
+ [BrowserAuthErrorCodes.monitorWindowTimeout]: `Token acquisition in iframe failed due to timeout. ${ErrorLink}`,
38
+ [BrowserAuthErrorCodes.redirectInIframe]:
39
+ "Redirects are not supported for iframed or brokered applications. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs.",
40
+ [BrowserAuthErrorCodes.blockIframeReload]: `Request was blocked inside an iframe because MSAL detected an authentication response. ${ErrorLink}`,
41
+ [BrowserAuthErrorCodes.blockNestedPopups]:
42
+ "Request was blocked inside a popup because MSAL detected it was running in a popup.",
43
+ [BrowserAuthErrorCodes.iframeClosedPrematurely]:
44
+ "The iframe being monitored was closed prematurely.",
45
+ [BrowserAuthErrorCodes.silentLogoutUnsupported]:
46
+ "Silent logout not supported. Please call logoutRedirect or logoutPopup instead.",
47
+ [BrowserAuthErrorCodes.noAccountError]:
48
+ "No account object provided to acquireTokenSilent and no active account has been set. Please call setActiveAccount or provide an account on the request.",
49
+ [BrowserAuthErrorCodes.silentPromptValueError]:
50
+ "The value given for the prompt value is not valid for silent requests - must be set to 'none' or 'no_session'.",
51
+ [BrowserAuthErrorCodes.noTokenRequestCacheError]:
52
+ "No token request found in cache.",
53
+ [BrowserAuthErrorCodes.unableToParseTokenRequestCacheError]:
54
+ "The cached token request could not be parsed.",
55
+ [BrowserAuthErrorCodes.noCachedAuthorityError]:
56
+ "No cached authority found.",
57
+ [BrowserAuthErrorCodes.authRequestNotSetError]:
58
+ "Auth Request not set. Please ensure initiateAuthRequest was called from the InteractionHandler",
59
+ [BrowserAuthErrorCodes.invalidCacheType]: "Invalid cache type",
60
+ [BrowserAuthErrorCodes.nonBrowserEnvironment]:
61
+ "Login and token requests are not supported in non-browser environments.",
62
+ [BrowserAuthErrorCodes.databaseNotOpen]: "Database is not open!",
63
+ [BrowserAuthErrorCodes.noNetworkConnectivity]:
64
+ "No network connectivity. Check your internet connection.",
65
+ [BrowserAuthErrorCodes.postRequestFailed]:
66
+ "Network request failed: If the browser threw a CORS error, check that the redirectUri is registered in the Azure App Portal as type 'SPA'",
67
+ [BrowserAuthErrorCodes.getRequestFailed]:
68
+ "Network request failed. Please check the network trace to determine root cause.",
69
+ [BrowserAuthErrorCodes.failedToParseResponse]:
70
+ "Failed to parse network response. Check network trace.",
71
+ [BrowserAuthErrorCodes.unableToLoadToken]: "Error loading token to cache.",
72
+ [BrowserAuthErrorCodes.cryptoKeyNotFound]:
73
+ "Cryptographic Key or Keypair not found in browser storage.",
74
+ [BrowserAuthErrorCodes.authCodeRequired]:
75
+ "An authorization code must be provided (as the `code` property on the request) to this flow.",
76
+ [BrowserAuthErrorCodes.authCodeOrNativeAccountIdRequired]:
77
+ "An authorization code or nativeAccountId must be provided to this flow.",
78
+ [BrowserAuthErrorCodes.spaCodeAndNativeAccountIdPresent]:
79
+ "Request cannot contain both spa code and native account id.",
80
+ [BrowserAuthErrorCodes.databaseUnavailable]:
81
+ "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts.",
82
+ [BrowserAuthErrorCodes.unableToAcquireTokenFromNativePlatform]: `Unable to acquire token from native platform. ${ErrorLink}`,
83
+ [BrowserAuthErrorCodes.nativeHandshakeTimeout]:
84
+ "Timed out while attempting to establish connection to browser extension",
85
+ [BrowserAuthErrorCodes.nativeExtensionNotInstalled]:
86
+ "Native extension is not installed. If you think this is a mistake call the initialize function.",
87
+ [BrowserAuthErrorCodes.nativeConnectionNotEstablished]: `Connection to native platform has not been established. Please install a compatible browser extension and run initialize(). ${ErrorLink}`,
88
+ [BrowserAuthErrorCodes.uninitializedPublicClientApplication]: `You must call and await the initialize function before attempting to call any other MSAL API. ${ErrorLink}`,
89
+ [BrowserAuthErrorCodes.nativePromptNotSupported]:
90
+ "The provided prompt is not supported by the native platform. This request should be routed to the web based flow.",
91
+ [BrowserAuthErrorCodes.invalidBase64String]:
92
+ "Invalid base64 encoded string.",
93
+ };
94
+
95
+ /**
96
+ * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
97
+ * @deprecated Use exported BrowserAuthErrorCodes instead.
98
+ * In your app you can do :
99
+ * ```
100
+ * import { BrowserAuthErrorCodes } from "@azure/msal-browser";
101
+ * ```
102
+ */
103
+ export const BrowserAuthErrorMessage = {
104
+ pkceNotGenerated: {
105
+ code: BrowserAuthErrorCodes.pkceNotCreated,
106
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.pkceNotCreated],
107
+ },
108
+ cryptoDoesNotExist: {
109
+ code: BrowserAuthErrorCodes.cryptoNonExistent,
110
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.cryptoNonExistent],
111
+ },
112
+ emptyNavigateUriError: {
113
+ code: BrowserAuthErrorCodes.emptyNavigateUri,
114
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.emptyNavigateUri],
115
+ },
116
+ hashEmptyError: {
117
+ code: BrowserAuthErrorCodes.hashEmptyError,
118
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.hashEmptyError],
119
+ },
120
+ hashDoesNotContainStateError: {
121
+ code: BrowserAuthErrorCodes.noStateInHash,
122
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.noStateInHash],
123
+ },
124
+ hashDoesNotContainKnownPropertiesError: {
125
+ code: BrowserAuthErrorCodes.hashDoesNotContainKnownProperties,
126
+ desc: BrowserAuthErrorMessages[
127
+ BrowserAuthErrorCodes.hashDoesNotContainKnownProperties
128
+ ],
129
+ },
130
+ unableToParseStateError: {
131
+ code: BrowserAuthErrorCodes.unableToParseState,
132
+ desc: BrowserAuthErrorMessages[
133
+ BrowserAuthErrorCodes.unableToParseState
134
+ ],
135
+ },
136
+ stateInteractionTypeMismatchError: {
137
+ code: BrowserAuthErrorCodes.stateInteractionTypeMismatch,
138
+ desc: BrowserAuthErrorMessages[
139
+ BrowserAuthErrorCodes.stateInteractionTypeMismatch
140
+ ],
141
+ },
142
+ interactionInProgress: {
143
+ code: BrowserAuthErrorCodes.interactionInProgress,
144
+ desc: BrowserAuthErrorMessages[
145
+ BrowserAuthErrorCodes.interactionInProgress
146
+ ],
147
+ },
148
+ popupWindowError: {
149
+ code: BrowserAuthErrorCodes.popupWindowError,
150
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.popupWindowError],
151
+ },
152
+ emptyWindowError: {
153
+ code: BrowserAuthErrorCodes.emptyWindowError,
154
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.emptyWindowError],
155
+ },
156
+ userCancelledError: {
157
+ code: BrowserAuthErrorCodes.userCancelled,
158
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.userCancelled],
159
+ },
160
+ monitorPopupTimeoutError: {
161
+ code: BrowserAuthErrorCodes.monitorPopupTimeout,
162
+ desc: BrowserAuthErrorMessages[
163
+ BrowserAuthErrorCodes.monitorPopupTimeout
164
+ ],
165
+ },
166
+ monitorIframeTimeoutError: {
167
+ code: BrowserAuthErrorCodes.monitorWindowTimeout,
168
+ desc: BrowserAuthErrorMessages[
169
+ BrowserAuthErrorCodes.monitorWindowTimeout
170
+ ],
171
+ },
172
+ redirectInIframeError: {
173
+ code: BrowserAuthErrorCodes.redirectInIframe,
174
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.redirectInIframe],
175
+ },
176
+ blockTokenRequestsInHiddenIframeError: {
177
+ code: BrowserAuthErrorCodes.blockIframeReload,
178
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.blockIframeReload],
179
+ },
180
+ blockAcquireTokenInPopupsError: {
181
+ code: BrowserAuthErrorCodes.blockNestedPopups,
182
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.blockNestedPopups],
183
+ },
184
+ iframeClosedPrematurelyError: {
185
+ code: BrowserAuthErrorCodes.iframeClosedPrematurely,
186
+ desc: BrowserAuthErrorMessages[
187
+ BrowserAuthErrorCodes.iframeClosedPrematurely
188
+ ],
189
+ },
190
+ silentLogoutUnsupportedError: {
191
+ code: BrowserAuthErrorCodes.silentLogoutUnsupported,
192
+ desc: BrowserAuthErrorMessages[
193
+ BrowserAuthErrorCodes.silentLogoutUnsupported
194
+ ],
195
+ },
196
+ noAccountError: {
197
+ code: BrowserAuthErrorCodes.noAccountError,
198
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.noAccountError],
199
+ },
200
+ silentPromptValueError: {
201
+ code: BrowserAuthErrorCodes.silentPromptValueError,
202
+ desc: BrowserAuthErrorMessages[
203
+ BrowserAuthErrorCodes.silentPromptValueError
204
+ ],
205
+ },
206
+ noTokenRequestCacheError: {
207
+ code: BrowserAuthErrorCodes.noTokenRequestCacheError,
208
+ desc: BrowserAuthErrorMessages[
209
+ BrowserAuthErrorCodes.noTokenRequestCacheError
210
+ ],
211
+ },
212
+ unableToParseTokenRequestCacheError: {
213
+ code: BrowserAuthErrorCodes.unableToParseTokenRequestCacheError,
214
+ desc: BrowserAuthErrorMessages[
215
+ BrowserAuthErrorCodes.unableToParseTokenRequestCacheError
216
+ ],
217
+ },
218
+ noCachedAuthorityError: {
219
+ code: BrowserAuthErrorCodes.noCachedAuthorityError,
220
+ desc: BrowserAuthErrorMessages[
221
+ BrowserAuthErrorCodes.noCachedAuthorityError
222
+ ],
223
+ },
224
+ authRequestNotSet: {
225
+ code: BrowserAuthErrorCodes.authRequestNotSetError,
226
+ desc: BrowserAuthErrorMessages[
227
+ BrowserAuthErrorCodes.authRequestNotSetError
228
+ ],
229
+ },
230
+ invalidCacheType: {
231
+ code: BrowserAuthErrorCodes.invalidCacheType,
232
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.invalidCacheType],
233
+ },
234
+ notInBrowserEnvironment: {
235
+ code: BrowserAuthErrorCodes.nonBrowserEnvironment,
236
+ desc: BrowserAuthErrorMessages[
237
+ BrowserAuthErrorCodes.nonBrowserEnvironment
238
+ ],
239
+ },
240
+ databaseNotOpen: {
241
+ code: BrowserAuthErrorCodes.databaseNotOpen,
242
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.databaseNotOpen],
243
+ },
244
+ noNetworkConnectivity: {
245
+ code: BrowserAuthErrorCodes.noNetworkConnectivity,
246
+ desc: BrowserAuthErrorMessages[
247
+ BrowserAuthErrorCodes.noNetworkConnectivity
248
+ ],
249
+ },
250
+ postRequestFailed: {
251
+ code: BrowserAuthErrorCodes.postRequestFailed,
252
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.postRequestFailed],
253
+ },
254
+ getRequestFailed: {
255
+ code: BrowserAuthErrorCodes.getRequestFailed,
256
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.getRequestFailed],
257
+ },
258
+ failedToParseNetworkResponse: {
259
+ code: BrowserAuthErrorCodes.failedToParseResponse,
260
+ desc: BrowserAuthErrorMessages[
261
+ BrowserAuthErrorCodes.failedToParseResponse
262
+ ],
263
+ },
264
+ unableToLoadTokenError: {
265
+ code: BrowserAuthErrorCodes.unableToLoadToken,
266
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.unableToLoadToken],
267
+ },
268
+ signingKeyNotFoundInStorage: {
269
+ code: BrowserAuthErrorCodes.cryptoKeyNotFound,
270
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.cryptoKeyNotFound],
271
+ },
272
+ authCodeRequired: {
273
+ code: BrowserAuthErrorCodes.authCodeRequired,
274
+ desc: BrowserAuthErrorMessages[BrowserAuthErrorCodes.authCodeRequired],
275
+ },
276
+ authCodeOrNativeAccountRequired: {
277
+ code: BrowserAuthErrorCodes.authCodeOrNativeAccountIdRequired,
278
+ desc: BrowserAuthErrorMessages[
279
+ BrowserAuthErrorCodes.authCodeOrNativeAccountIdRequired
280
+ ],
281
+ },
282
+ spaCodeAndNativeAccountPresent: {
283
+ code: BrowserAuthErrorCodes.spaCodeAndNativeAccountIdPresent,
284
+ desc: BrowserAuthErrorMessages[
285
+ BrowserAuthErrorCodes.spaCodeAndNativeAccountIdPresent
286
+ ],
287
+ },
288
+ databaseUnavailable: {
289
+ code: BrowserAuthErrorCodes.databaseUnavailable,
290
+ desc: BrowserAuthErrorMessages[
291
+ BrowserAuthErrorCodes.databaseUnavailable
292
+ ],
293
+ },
294
+ unableToAcquireTokenFromNativePlatform: {
295
+ code: BrowserAuthErrorCodes.unableToAcquireTokenFromNativePlatform,
296
+ desc: BrowserAuthErrorMessages[
297
+ BrowserAuthErrorCodes.unableToAcquireTokenFromNativePlatform
298
+ ],
299
+ },
300
+ nativeHandshakeTimeout: {
301
+ code: BrowserAuthErrorCodes.nativeHandshakeTimeout,
302
+ desc: BrowserAuthErrorMessages[
303
+ BrowserAuthErrorCodes.nativeHandshakeTimeout
304
+ ],
305
+ },
306
+ nativeExtensionNotInstalled: {
307
+ code: BrowserAuthErrorCodes.nativeExtensionNotInstalled,
308
+ desc: BrowserAuthErrorMessages[
309
+ BrowserAuthErrorCodes.nativeExtensionNotInstalled
310
+ ],
311
+ },
312
+ nativeConnectionNotEstablished: {
313
+ code: BrowserAuthErrorCodes.nativeConnectionNotEstablished,
314
+ desc: BrowserAuthErrorMessages[
315
+ BrowserAuthErrorCodes.nativeConnectionNotEstablished
316
+ ],
317
+ },
318
+ uninitializedPublicClientApplication: {
319
+ code: BrowserAuthErrorCodes.uninitializedPublicClientApplication,
320
+ desc: BrowserAuthErrorMessages[
321
+ BrowserAuthErrorCodes.uninitializedPublicClientApplication
322
+ ],
323
+ },
324
+ nativePromptNotSupported: {
325
+ code: BrowserAuthErrorCodes.nativePromptNotSupported,
326
+ desc: BrowserAuthErrorMessages[
327
+ BrowserAuthErrorCodes.nativePromptNotSupported
328
+ ],
329
+ },
330
+ invalidBase64StringError: {
331
+ code: BrowserAuthErrorCodes.invalidBase64String,
332
+ desc: BrowserAuthErrorMessages[
333
+ BrowserAuthErrorCodes.invalidBase64String
334
+ ],
335
+ },
336
+ };
337
+
338
+ /**
339
+ * Browser library error class thrown by the MSAL.js library for SPAs
340
+ */
341
+ export class BrowserAuthError extends AuthError {
342
+ constructor(errorCode: string) {
343
+ super(errorCode, BrowserAuthErrorMessages[errorCode]);
344
+
345
+ Object.setPrototypeOf(this, BrowserAuthError.prototype);
346
+ this.name = "BrowserAuthError";
347
+ }
348
+ }
349
+
350
+ export function createBrowserAuthError(errorCode: string): BrowserAuthError {
351
+ return new BrowserAuthError(errorCode);
352
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export const pkceNotCreated = "pkce_not_created";
7
+ export const cryptoNonExistent = "crypto_nonexistent";
8
+ export const emptyNavigateUri = "empty_navigate_uri";
9
+ export const hashEmptyError = "hash_empty_error";
10
+ export const noStateInHash = "no_state_in_hash";
11
+ export const hashDoesNotContainKnownProperties =
12
+ "hash_does_not_contain_known_properties";
13
+ export const unableToParseState = "unable_to_parse_state";
14
+ export const stateInteractionTypeMismatch = "state_interaction_type_mismatch";
15
+ export const interactionInProgress = "interaction_in_progress";
16
+ export const popupWindowError = "popup_window_error";
17
+ export const emptyWindowError = "empty_window_error";
18
+ export const userCancelled = "user_cancelled";
19
+ export const monitorPopupTimeout = "monitor_popup_timeout";
20
+ export const monitorWindowTimeout = "monitor_window_timeout";
21
+ export const redirectInIframe = "redirect_in_iframe";
22
+ export const blockIframeReload = "block_iframe_reload";
23
+ export const blockNestedPopups = "block_nested_popups";
24
+ export const iframeClosedPrematurely = "iframe_closed_prematurely";
25
+ export const silentLogoutUnsupported = "silent_logout_unsupported";
26
+ export const noAccountError = "no_account_error";
27
+ export const silentPromptValueError = "silent_prompt_value_error";
28
+ export const noTokenRequestCacheError = "no_token_request_cache_error";
29
+ export const unableToParseTokenRequestCacheError =
30
+ "unable_to_parse_token_request_cache_error";
31
+ export const noCachedAuthorityError = "no_cached_authority_error";
32
+ export const authRequestNotSetError = "auth_request_not_set_error";
33
+ export const invalidCacheType = "invalid_cache_type";
34
+ export const nonBrowserEnvironment = "non_browser_environment";
35
+ export const databaseNotOpen = "database_not_open";
36
+ export const noNetworkConnectivity = "no_network_connectivity";
37
+ export const postRequestFailed = "post_request_failed";
38
+ export const getRequestFailed = "get_request_failed";
39
+ export const failedToParseResponse = "failed_to_parse_response";
40
+ export const unableToLoadToken = "unable_to_load_token";
41
+ export const cryptoKeyNotFound = "crypto_key_not_found";
42
+ export const authCodeRequired = "auth_code_required";
43
+ export const authCodeOrNativeAccountIdRequired =
44
+ "auth_code_or_nativeAccountId_required";
45
+ export const spaCodeAndNativeAccountIdPresent =
46
+ "spa_code_and_nativeAccountId_present";
47
+ export const databaseUnavailable = "database_unavailable";
48
+ export const unableToAcquireTokenFromNativePlatform =
49
+ "unable_to_acquire_token_from_native_platform";
50
+ export const nativeHandshakeTimeout = "native_handshake_timeout";
51
+ export const nativeExtensionNotInstalled = "native_extension_not_installed";
52
+ export const nativeConnectionNotEstablished =
53
+ "native_connection_not_established";
54
+ export const uninitializedPublicClientApplication =
55
+ "uninitialized_public_client_application";
56
+ export const nativePromptNotSupported = "native_prompt_not_supported";
57
+ export const invalidBase64String = "invalid_base64_string";
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AuthError } from "@azure/msal-common";
7
+ import * as BrowserConfigurationAuthErrorCodes from "./BrowserConfigurationAuthErrorCodes";
8
+ export { BrowserConfigurationAuthErrorCodes };
9
+
10
+ export const BrowserConfigurationAuthErrorMessages = {
11
+ [BrowserConfigurationAuthErrorCodes.storageNotSupported]:
12
+ "Given storage configuration option was not supported.",
13
+ [BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled]:
14
+ "Stub instance of Public Client Application was called. If using msal-react, please ensure context is not used without a provider. For more visit: aka.ms/msaljs/browser-errors",
15
+ [BrowserConfigurationAuthErrorCodes.inMemRedirectUnavailable]:
16
+ "Redirect cannot be supported. In-memory storage was selected and storeAuthStateInCookie=false, which would cause the library to be unable to handle the incoming hash. If you would like to use the redirect API, please use session/localStorage or set storeAuthStateInCookie=true.",
17
+ };
18
+
19
+ /**
20
+ * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
21
+ * @deprecated Use BrowserAuthErrorCodes instead
22
+ */
23
+ export const BrowserConfigurationAuthErrorMessage = {
24
+ storageNotSupportedError: {
25
+ code: BrowserConfigurationAuthErrorCodes.storageNotSupported,
26
+ desc: BrowserConfigurationAuthErrorMessages[
27
+ BrowserConfigurationAuthErrorCodes.storageNotSupported
28
+ ],
29
+ },
30
+ stubPcaInstanceCalled: {
31
+ code: BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled,
32
+ desc: BrowserConfigurationAuthErrorMessages[
33
+ BrowserConfigurationAuthErrorCodes
34
+ .stubbedPublicClientApplicationCalled
35
+ ],
36
+ },
37
+ inMemRedirectUnavailable: {
38
+ code: BrowserConfigurationAuthErrorCodes.inMemRedirectUnavailable,
39
+ desc: BrowserConfigurationAuthErrorMessages[
40
+ BrowserConfigurationAuthErrorCodes.inMemRedirectUnavailable
41
+ ],
42
+ },
43
+ };
44
+
45
+ /**
46
+ * Browser library error class thrown by the MSAL.js library for SPAs
47
+ */
48
+ export class BrowserConfigurationAuthError extends AuthError {
49
+ constructor(errorCode: string, errorMessage?: string) {
50
+ super(errorCode, errorMessage);
51
+ this.name = "BrowserConfigurationAuthError";
52
+
53
+ Object.setPrototypeOf(this, BrowserConfigurationAuthError.prototype);
54
+ }
55
+ }
56
+
57
+ export function createBrowserConfigurationAuthError(
58
+ errorCode: string
59
+ ): BrowserConfigurationAuthError {
60
+ return new BrowserConfigurationAuthError(
61
+ errorCode,
62
+ BrowserConfigurationAuthErrorMessages[errorCode]
63
+ );
64
+ }
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export const storageNotSupported = "storage_not_supported";
7
+ export const stubbedPublicClientApplicationCalled =
8
+ "stubbed_public_client_application_called";
9
+ export const inMemRedirectUnavailable = "in_mem_redirect_unavailable";
@@ -0,0 +1,113 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ AuthError,
8
+ InteractionRequiredAuthError,
9
+ InteractionRequiredAuthErrorCodes,
10
+ createInteractionRequiredAuthError,
11
+ } from "@azure/msal-common";
12
+ import {
13
+ createBrowserAuthError,
14
+ BrowserAuthErrorCodes,
15
+ } from "./BrowserAuthError";
16
+
17
+ import * as NativeAuthErrorCodes from "./NativeAuthErrorCodes";
18
+ import * as NativeStatusCodes from "../broker/nativeBroker/NativeStatusCodes";
19
+ export { NativeAuthErrorCodes };
20
+
21
+ export type OSError = {
22
+ error?: number;
23
+ protocol_error?: string;
24
+ properties?: object;
25
+ status?: string;
26
+ retryable?: boolean;
27
+ };
28
+
29
+ const INVALID_METHOD_ERROR = -2147186943;
30
+
31
+ export const NativeAuthErrorMessages = {
32
+ [NativeAuthErrorCodes.userSwitch]:
33
+ "User attempted to switch accounts in the native broker, which is not allowed. All new accounts must sign-in through the standard web flow first, please try again.",
34
+ };
35
+
36
+ export class NativeAuthError extends AuthError {
37
+ ext: OSError | undefined;
38
+
39
+ constructor(errorCode: string, description?: string, ext?: OSError) {
40
+ super(errorCode, description);
41
+
42
+ Object.setPrototypeOf(this, NativeAuthError.prototype);
43
+ this.name = "NativeAuthError";
44
+ this.ext = ext;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * These errors should result in a fallback to the 'standard' browser based auth flow.
50
+ */
51
+ export function isFatalNativeAuthError(error: NativeAuthError): boolean {
52
+ if (
53
+ error.ext &&
54
+ error.ext.status &&
55
+ (error.ext.status === NativeStatusCodes.PERSISTENT_ERROR ||
56
+ error.ext.status === NativeStatusCodes.DISABLED)
57
+ ) {
58
+ return true;
59
+ }
60
+
61
+ if (
62
+ error.ext &&
63
+ error.ext.error &&
64
+ error.ext.error === INVALID_METHOD_ERROR
65
+ ) {
66
+ return true;
67
+ }
68
+
69
+ switch (error.errorCode) {
70
+ case NativeAuthErrorCodes.contentError:
71
+ return true;
72
+ default:
73
+ return false;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Create the appropriate error object based on the WAM status code.
79
+ * @param code
80
+ * @param description
81
+ * @param ext
82
+ * @returns
83
+ */
84
+ export function createNativeAuthError(
85
+ code: string,
86
+ description?: string,
87
+ ext?: OSError
88
+ ): AuthError {
89
+ if (ext && ext.status) {
90
+ switch (ext.status) {
91
+ case NativeStatusCodes.ACCOUNT_UNAVAILABLE:
92
+ return createInteractionRequiredAuthError(
93
+ InteractionRequiredAuthErrorCodes.nativeAccountUnavailable
94
+ );
95
+ case NativeStatusCodes.USER_INTERACTION_REQUIRED:
96
+ return new InteractionRequiredAuthError(code, description);
97
+ case NativeStatusCodes.USER_CANCEL:
98
+ return createBrowserAuthError(
99
+ BrowserAuthErrorCodes.userCancelled
100
+ );
101
+ case NativeStatusCodes.NO_NETWORK:
102
+ return createBrowserAuthError(
103
+ BrowserAuthErrorCodes.noNetworkConnectivity
104
+ );
105
+ }
106
+ }
107
+
108
+ return new NativeAuthError(
109
+ code,
110
+ NativeAuthErrorMessages[code] || description,
111
+ ext
112
+ );
113
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export const contentError = "ContentError";
7
+ export const userSwitch = "user_switch";