@azure/msal-browser 3.0.1 → 3.1.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 (257) hide show
  1. package/README.md +5 -5
  2. package/dist/app/IPublicClientApplication.d.ts +6 -2
  3. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  4. package/dist/app/IPublicClientApplication.mjs +4 -1
  5. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  6. package/dist/app/PublicClientApplication.d.ts +11 -3
  7. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  8. package/dist/app/PublicClientApplication.mjs +10 -2
  9. package/dist/app/PublicClientApplication.mjs.map +1 -1
  10. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +5 -4
  12. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  13. package/dist/cache/AsyncMemoryStorage.mjs +4 -3
  14. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  15. package/dist/cache/BrowserCacheManager.d.ts +13 -3
  16. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  17. package/dist/cache/BrowserCacheManager.mjs +54 -26
  18. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  19. package/dist/cache/BrowserStorage.mjs +1 -1
  20. package/dist/cache/BrowserStorage.mjs.map +1 -1
  21. package/dist/cache/CryptoKeyStore.mjs +1 -1
  22. package/dist/cache/CryptoKeyStore.mjs.map +1 -1
  23. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  24. package/dist/cache/DatabaseStorage.mjs +9 -8
  25. package/dist/cache/DatabaseStorage.mjs.map +1 -1
  26. package/dist/cache/MemoryStorage.mjs +1 -1
  27. package/dist/cache/MemoryStorage.mjs.map +1 -1
  28. package/dist/cache/TokenCache.d.ts.map +1 -1
  29. package/dist/cache/TokenCache.mjs +30 -30
  30. package/dist/cache/TokenCache.mjs.map +1 -1
  31. package/dist/config/Configuration.d.ts +3 -0
  32. package/dist/config/Configuration.d.ts.map +1 -1
  33. package/dist/config/Configuration.mjs +7 -11
  34. package/dist/config/Configuration.mjs.map +1 -1
  35. package/dist/controllers/ControllerFactory.mjs +1 -1
  36. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  37. package/dist/controllers/IController.d.ts +11 -18
  38. package/dist/controllers/IController.d.ts.map +1 -1
  39. package/dist/controllers/StandardController.d.ts +7 -26
  40. package/dist/controllers/StandardController.d.ts.map +1 -1
  41. package/dist/controllers/StandardController.mjs +28 -52
  42. package/dist/controllers/StandardController.mjs.map +1 -1
  43. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  44. package/dist/crypto/BrowserCrypto.mjs +4 -3
  45. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  46. package/dist/crypto/CryptoOps.d.ts +0 -3
  47. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  48. package/dist/crypto/CryptoOps.mjs +14 -17
  49. package/dist/crypto/CryptoOps.mjs.map +1 -1
  50. package/dist/crypto/ModernBrowserCrypto.mjs +1 -1
  51. package/dist/crypto/ModernBrowserCrypto.mjs.map +1 -1
  52. package/dist/crypto/PkceGenerator.d.ts +0 -1
  53. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  54. package/dist/crypto/PkceGenerator.mjs +8 -8
  55. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  56. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  57. package/dist/crypto/SignedHttpRequest.mjs.map +1 -1
  58. package/dist/encode/Base64Decode.d.ts +6 -19
  59. package/dist/encode/Base64Decode.d.ts.map +1 -1
  60. package/dist/encode/Base64Decode.mjs +17 -70
  61. package/dist/encode/Base64Decode.mjs.map +1 -1
  62. package/dist/encode/Base64Encode.d.ts +15 -27
  63. package/dist/encode/Base64Encode.d.ts.map +1 -1
  64. package/dist/encode/Base64Encode.mjs +36 -75
  65. package/dist/encode/Base64Encode.mjs.map +1 -1
  66. package/dist/error/BrowserAuthError.d.ts +54 -195
  67. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  68. package/dist/error/BrowserAuthError.mjs +150 -381
  69. package/dist/error/BrowserAuthError.mjs.map +1 -1
  70. package/dist/error/BrowserAuthErrorCodes.d.ts +45 -0
  71. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -0
  72. package/dist/error/BrowserAuthErrorCodes.mjs +53 -0
  73. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -0
  74. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  75. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  76. package/dist/error/NativeAuthError.d.ts.map +1 -1
  77. package/dist/error/NativeAuthError.mjs +5 -4
  78. package/dist/error/NativeAuthError.mjs.map +1 -1
  79. package/dist/event/EventHandler.mjs +1 -1
  80. package/dist/event/EventHandler.mjs.map +1 -1
  81. package/dist/event/EventMessage.mjs +1 -1
  82. package/dist/event/EventMessage.mjs.map +1 -1
  83. package/dist/event/EventType.mjs +1 -1
  84. package/dist/event/EventType.mjs.map +1 -1
  85. package/dist/index.d.ts +9 -6
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.mjs +5 -3
  88. package/dist/index.mjs.map +1 -1
  89. package/dist/interaction_client/BaseInteractionClient.d.ts +2 -1
  90. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  91. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  92. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  93. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  94. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs.map +1 -1
  95. package/dist/interaction_client/NativeInteractionClient.d.ts +4 -10
  96. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  97. package/dist/interaction_client/NativeInteractionClient.mjs +22 -30
  98. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  99. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  100. package/dist/interaction_client/PopupClient.mjs +16 -15
  101. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  102. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  103. package/dist/interaction_client/RedirectClient.mjs +7 -6
  104. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  105. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  106. package/dist/interaction_client/SilentAuthCodeClient.mjs +5 -4
  107. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  108. package/dist/interaction_client/SilentCacheClient.d.ts +4 -2
  109. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  110. package/dist/interaction_client/SilentCacheClient.mjs +10 -8
  111. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  112. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  113. package/dist/interaction_client/SilentIframeClient.mjs +20 -47
  114. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  115. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  116. package/dist/interaction_client/SilentRefreshClient.mjs +4 -3
  117. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  118. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  119. package/dist/interaction_client/StandardInteractionClient.mjs +8 -7
  120. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  121. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  122. package/dist/interaction_handler/InteractionHandler.mjs +9 -9
  123. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  124. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  125. package/dist/interaction_handler/RedirectHandler.mjs +11 -10
  126. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  127. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  128. package/dist/interaction_handler/SilentHandler.mjs +10 -9
  129. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  130. package/dist/navigation/NavigationClient.mjs +1 -1
  131. package/dist/navigation/NavigationClient.mjs.map +1 -1
  132. package/dist/network/FetchClient.d.ts.map +1 -1
  133. package/dist/network/FetchClient.mjs +9 -8
  134. package/dist/network/FetchClient.mjs.map +1 -1
  135. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  136. package/dist/operatingcontext/BaseOperatingContext.mjs.map +1 -1
  137. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  138. package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
  139. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  140. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  141. package/dist/packageMetadata.d.ts +1 -1
  142. package/dist/packageMetadata.mjs +2 -2
  143. package/dist/packageMetadata.mjs.map +1 -1
  144. package/dist/request/ClearCacheRequest.d.ts +11 -0
  145. package/dist/request/ClearCacheRequest.d.ts.map +1 -0
  146. package/dist/telemetry/BrowserPerformanceClient.d.ts +2 -4
  147. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  148. package/dist/telemetry/BrowserPerformanceClient.mjs +2 -6
  149. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  150. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  151. package/dist/telemetry/BrowserPerformanceMeasurement.mjs.map +1 -1
  152. package/dist/utils/BrowserConstants.mjs +1 -1
  153. package/dist/utils/BrowserConstants.mjs.map +1 -1
  154. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  155. package/dist/utils/BrowserProtocolUtils.mjs +3 -3
  156. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  157. package/dist/utils/BrowserStringUtils.mjs +1 -1
  158. package/dist/utils/BrowserStringUtils.mjs.map +1 -1
  159. package/dist/utils/BrowserUtils.d.ts +0 -9
  160. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  161. package/dist/utils/BrowserUtils.mjs +8 -33
  162. package/dist/utils/BrowserUtils.mjs.map +1 -1
  163. package/lib/msal-browser.cjs +6601 -7104
  164. package/lib/msal-browser.cjs.map +1 -1
  165. package/lib/msal-browser.js +6601 -7104
  166. package/lib/msal-browser.js.map +1 -1
  167. package/lib/msal-browser.min.js +65 -62
  168. package/package.json +7 -5
  169. package/src/app/IPublicClientApplication.ts +199 -0
  170. package/src/app/PublicClientApplication.ts +405 -0
  171. package/src/broker/nativeBroker/NativeMessageHandler.ts +419 -0
  172. package/src/broker/nativeBroker/NativeRequest.ts +52 -0
  173. package/src/broker/nativeBroker/NativeResponse.ts +56 -0
  174. package/src/cache/AsyncMemoryStorage.ts +158 -0
  175. package/src/cache/BrowserCacheManager.ts +1994 -0
  176. package/src/cache/BrowserStorage.ts +54 -0
  177. package/src/cache/CryptoKeyStore.ts +63 -0
  178. package/src/cache/DatabaseStorage.ts +287 -0
  179. package/src/cache/IAsyncMemoryStorage.ts +36 -0
  180. package/src/cache/ITokenCache.ts +21 -0
  181. package/src/cache/IWindowStorage.ts +36 -0
  182. package/src/cache/MemoryStorage.ts +42 -0
  183. package/src/cache/TokenCache.ts +484 -0
  184. package/src/config/Configuration.ts +375 -0
  185. package/src/controllers/ControllerFactory.ts +55 -0
  186. package/src/controllers/IController.ts +131 -0
  187. package/src/controllers/StandardController.ts +2107 -0
  188. package/src/crypto/BrowserCrypto.ts +135 -0
  189. package/src/crypto/CryptoOps.ts +247 -0
  190. package/src/crypto/ISubtleCrypto.ts +30 -0
  191. package/src/crypto/ModernBrowserCrypto.ts +69 -0
  192. package/src/crypto/PkceGenerator.ts +76 -0
  193. package/src/crypto/SignedHttpRequest.ts +76 -0
  194. package/src/encode/Base64Decode.ts +26 -0
  195. package/src/encode/Base64Encode.ts +52 -0
  196. package/src/error/BrowserAuthError.ts +340 -0
  197. package/src/error/BrowserAuthErrorCodes.ts +56 -0
  198. package/src/error/BrowserConfigurationAuthError.ts +133 -0
  199. package/src/error/NativeAuthError.ts +141 -0
  200. package/src/event/EventHandler.ts +176 -0
  201. package/src/event/EventMessage.ts +125 -0
  202. package/src/event/EventType.ts +33 -0
  203. package/src/index.ts +152 -0
  204. package/src/interaction_client/BaseInteractionClient.ts +301 -0
  205. package/src/interaction_client/HybridSpaAuthorizationCodeClient.ts +16 -0
  206. package/src/interaction_client/NativeInteractionClient.ts +907 -0
  207. package/src/interaction_client/PopupClient.ts +926 -0
  208. package/src/interaction_client/RedirectClient.ts +616 -0
  209. package/src/interaction_client/SilentAuthCodeClient.ts +163 -0
  210. package/src/interaction_client/SilentCacheClient.ts +133 -0
  211. package/src/interaction_client/SilentIframeClient.ts +301 -0
  212. package/src/interaction_client/SilentRefreshClient.ts +120 -0
  213. package/src/interaction_client/StandardInteractionClient.ts +481 -0
  214. package/src/interaction_handler/InteractionHandler.ts +246 -0
  215. package/src/interaction_handler/RedirectHandler.ts +225 -0
  216. package/src/interaction_handler/SilentHandler.ts +266 -0
  217. package/src/navigation/INavigationClient.ts +23 -0
  218. package/src/navigation/NavigationClient.ts +55 -0
  219. package/src/navigation/NavigationOptions.ts +18 -0
  220. package/src/network/FetchClient.ts +130 -0
  221. package/src/operatingcontext/BaseOperatingContext.ts +82 -0
  222. package/src/operatingcontext/StandardOperatingContext.ts +49 -0
  223. package/src/operatingcontext/TeamsAppOperatingContext.ts +48 -0
  224. package/src/packageMetadata.ts +3 -0
  225. package/src/request/AuthorizationCodeRequest.ts +19 -0
  226. package/src/request/AuthorizationUrlRequest.ts +17 -0
  227. package/src/request/ClearCacheRequest.ts +16 -0
  228. package/src/request/EndSessionPopupRequest.ts +26 -0
  229. package/src/request/EndSessionRequest.ts +23 -0
  230. package/src/request/PopupRequest.ts +51 -0
  231. package/src/request/PopupWindowAttributes.ts +22 -0
  232. package/src/request/RedirectRequest.ts +51 -0
  233. package/src/request/SilentRequest.ts +49 -0
  234. package/src/request/SsoSilentRequest.ts +44 -0
  235. package/src/response/AuthenticationResult.ts +13 -0
  236. package/src/telemetry/BrowserPerformanceClient.ts +226 -0
  237. package/src/telemetry/BrowserPerformanceMeasurement.ts +144 -0
  238. package/src/utils/BrowserConstants.ts +241 -0
  239. package/src/utils/BrowserProtocolUtils.ts +57 -0
  240. package/src/utils/BrowserStringUtils.ts +143 -0
  241. package/src/utils/BrowserUtils.ts +156 -0
  242. package/dist/crypto/GuidGenerator.d.ts +0 -13
  243. package/dist/crypto/GuidGenerator.d.ts.map +0 -1
  244. package/dist/crypto/GuidGenerator.mjs +0 -104
  245. package/dist/crypto/GuidGenerator.mjs.map +0 -1
  246. package/dist/internals.d.ts +0 -23
  247. package/dist/internals.d.ts.map +0 -1
  248. package/dist/internals.mjs +0 -28
  249. package/dist/internals.mjs.map +0 -1
  250. package/dist/network/XhrClient.d.ts +0 -41
  251. package/dist/network/XhrClient.d.ts.map +0 -1
  252. package/dist/network/XhrClient.mjs +0 -125
  253. package/dist/network/XhrClient.mjs.map +0 -1
  254. package/dist/utils/MathUtils.d.ts +0 -12
  255. package/dist/utils/MathUtils.d.ts.map +0 -1
  256. package/dist/utils/MathUtils.mjs +0 -26
  257. package/dist/utils/MathUtils.mjs.map +0 -1
@@ -1,490 +1,259 @@
1
- /*! @azure/msal-browser v3.0.1 2023-08-11 */
1
+ /*! @azure/msal-browser v3.1.0 2023-09-05 */
2
2
  'use strict';
3
- import { AuthError, StringUtils } from '@azure/msal-common';
3
+ import { AuthError } from '@azure/msal-common';
4
+ import { pkceNotCreated, cryptoNonExistent, emptyNavigateUri, hashEmptyError, noStateInHash, hashDoesNotContainKnownProperties, unableToParseState, stateInteractionTypeMismatch, interactionInProgress, popupWindowError, emptyWindowError, userCancelled, monitorPopupTimeout, monitorWindowTimeout, redirectInIframe, blockIframeReload, blockNestedPopups, iframeClosedPrematurely, silentLogoutUnsupported, noAccountError, silentPromptValueError, noTokenRequestCacheError, unableToParseTokenRequestCacheError, noCachedAuthorityError, authRequestNotSetError, invalidCacheType, nonBrowserEnvironment, databaseNotOpen, noNetworkConnectivity, postRequestFailed, getRequestFailed, failedToParseResponse, unableToLoadToken, cryptoKeyNotFound, authCodeRequired, authCodeOrNativeAccountIdRequired, spaCodeAndNativeAccountIdPresent, databaseUnavailable, unableToAcquireTokenFromNativePlatform, nativeHandshakeTimeout, nativeExtensionNotInstalled, nativeConnectionNotEstablished, uninitializedPublicClientApplication, nativePromptNotSupported } from './BrowserAuthErrorCodes.mjs';
5
+ import * as BrowserAuthErrorCodes from './BrowserAuthErrorCodes.mjs';
6
+ export { BrowserAuthErrorCodes };
4
7
 
5
8
  /*
6
9
  * Copyright (c) Microsoft Corporation. All rights reserved.
7
10
  * Licensed under the MIT License.
8
11
  */
12
+ const ErrorLink = "For more visit: aka.ms/msaljs/browser-errors";
9
13
  /**
10
14
  * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
11
15
  */
16
+ const BrowserAuthErrorMessages = {
17
+ [pkceNotCreated]: "The PKCE code challenge and verifier could not be generated.",
18
+ [cryptoNonExistent]: "The crypto object or function is not available.",
19
+ [emptyNavigateUri]: "Navigation URI is empty. Please check stack trace for more info.",
20
+ [hashEmptyError]: `Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash. ${ErrorLink}`,
21
+ [noStateInHash]: "Hash does not contain state. Please verify that the request originated from msal.",
22
+ [hashDoesNotContainKnownProperties]: `Hash does not contain known properites. Please verify that your redirectUri is not changing the hash. ${ErrorLink}`,
23
+ [unableToParseState]: "Unable to parse state. Please verify that the request originated from msal.",
24
+ [stateInteractionTypeMismatch]: "Hash contains state but the interaction type does not match the caller.",
25
+ [interactionInProgress]: `Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. ${ErrorLink}`,
26
+ [popupWindowError]: "Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser.",
27
+ [emptyWindowError]: "window.open returned null or undefined window object.",
28
+ [userCancelled]: "User cancelled the flow.",
29
+ [monitorPopupTimeout]: `Token acquisition in popup failed due to timeout. ${ErrorLink}`,
30
+ [monitorWindowTimeout]: `Token acquisition in iframe failed due to timeout. ${ErrorLink}`,
31
+ [redirectInIframe]: "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.",
32
+ [blockIframeReload]: `Request was blocked inside an iframe because MSAL detected an authentication response. ${ErrorLink}`,
33
+ [blockNestedPopups]: "Request was blocked inside a popup because MSAL detected it was running in a popup.",
34
+ [iframeClosedPrematurely]: "The iframe being monitored was closed prematurely.",
35
+ [silentLogoutUnsupported]: "Silent logout not supported. Please call logoutRedirect or logoutPopup instead.",
36
+ [noAccountError]: "No account object provided to acquireTokenSilent and no active account has been set. Please call setActiveAccount or provide an account on the request.",
37
+ [silentPromptValueError]: "The value given for the prompt value is not valid for silent requests - must be set to 'none' or 'no_session'.",
38
+ [noTokenRequestCacheError]: "No token request found in cache.",
39
+ [unableToParseTokenRequestCacheError]: "The cached token request could not be parsed.",
40
+ [noCachedAuthorityError]: "No cached authority found.",
41
+ [authRequestNotSetError]: "Auth Request not set. Please ensure initiateAuthRequest was called from the InteractionHandler",
42
+ [invalidCacheType]: "Invalid cache type",
43
+ [nonBrowserEnvironment]: "Login and token requests are not supported in non-browser environments.",
44
+ [databaseNotOpen]: "Database is not open!",
45
+ [noNetworkConnectivity]: "No network connectivity. Check your internet connection.",
46
+ [postRequestFailed]: "Network request failed: If the browser threw a CORS error, check that the redirectUri is registered in the Azure App Portal as type 'SPA'",
47
+ [getRequestFailed]: "Network request failed. Please check the network trace to determine root cause.",
48
+ [failedToParseResponse]: "Failed to parse network response. Check network trace.",
49
+ [unableToLoadToken]: "Error loading token to cache.",
50
+ [cryptoKeyNotFound]: "Cryptographic Key or Keypair not found in browser storage.",
51
+ [authCodeRequired]: "An authorization code must be provided (as the `code` property on the request) to this flow.",
52
+ [authCodeOrNativeAccountIdRequired]: "An authorization code or nativeAccountId must be provided to this flow.",
53
+ [spaCodeAndNativeAccountIdPresent]: "Request cannot contain both spa code and native account id.",
54
+ [databaseUnavailable]: "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.",
55
+ [unableToAcquireTokenFromNativePlatform]: `Unable to acquire token from native platform. ${ErrorLink}`,
56
+ [nativeHandshakeTimeout]: "Timed out while attempting to establish connection to browser extension",
57
+ [nativeExtensionNotInstalled]: "Native extension is not installed. If you think this is a mistake call the initialize function.",
58
+ [nativeConnectionNotEstablished]: `Connection to native platform has not been established. Please install a compatible browser extension and run initialize(). ${ErrorLink}`,
59
+ [uninitializedPublicClientApplication]: `You must call and await the initialize function before attempting to call any other MSAL API. ${ErrorLink}`,
60
+ [nativePromptNotSupported]: "The provided prompt is not supported by the native platform. This request should be routed to the web based flow.",
61
+ };
62
+ /**
63
+ * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
64
+ * @deprecated Use BrowserAuthBrowserAuthErrorCodes instead
65
+ */
12
66
  const BrowserAuthErrorMessage = {
13
67
  pkceNotGenerated: {
14
- code: "pkce_not_created",
15
- desc: "The PKCE code challenge and verifier could not be generated.",
68
+ code: pkceNotCreated,
69
+ desc: BrowserAuthErrorMessages[pkceNotCreated],
16
70
  },
17
71
  cryptoDoesNotExist: {
18
- code: "crypto_nonexistent",
19
- desc: "The crypto object or function is not available.",
20
- },
21
- httpMethodNotImplementedError: {
22
- code: "http_method_not_implemented",
23
- desc: "The HTTP method given has not been implemented in this library.",
72
+ code: cryptoNonExistent,
73
+ desc: BrowserAuthErrorMessages[cryptoNonExistent],
24
74
  },
25
75
  emptyNavigateUriError: {
26
- code: "empty_navigate_uri",
27
- desc: "Navigation URI is empty. Please check stack trace for more info.",
76
+ code: emptyNavigateUri,
77
+ desc: BrowserAuthErrorMessages[emptyNavigateUri],
28
78
  },
29
79
  hashEmptyError: {
30
- code: "hash_empty_error",
31
- desc: "Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash. For more visit: aka.ms/msaljs/browser-errors.",
80
+ code: hashEmptyError,
81
+ desc: BrowserAuthErrorMessages[hashEmptyError],
32
82
  },
33
83
  hashDoesNotContainStateError: {
34
- code: "no_state_in_hash",
35
- desc: "Hash does not contain state. Please verify that the request originated from msal.",
84
+ code: noStateInHash,
85
+ desc: BrowserAuthErrorMessages[noStateInHash],
36
86
  },
37
87
  hashDoesNotContainKnownPropertiesError: {
38
- code: "hash_does_not_contain_known_properties",
39
- desc: "Hash does not contain known properites. Please verify that your redirectUri is not changing the hash. For more visit: aka.ms/msaljs/browser-errors.",
88
+ code: hashDoesNotContainKnownProperties,
89
+ desc: BrowserAuthErrorMessages[hashDoesNotContainKnownProperties],
40
90
  },
41
91
  unableToParseStateError: {
42
- code: "unable_to_parse_state",
43
- desc: "Unable to parse state. Please verify that the request originated from msal.",
92
+ code: unableToParseState,
93
+ desc: BrowserAuthErrorMessages[unableToParseState],
44
94
  },
45
95
  stateInteractionTypeMismatchError: {
46
- code: "state_interaction_type_mismatch",
47
- desc: "Hash contains state but the interaction type does not match the caller.",
96
+ code: stateInteractionTypeMismatch,
97
+ desc: BrowserAuthErrorMessages[stateInteractionTypeMismatch],
48
98
  },
49
99
  interactionInProgress: {
50
- code: "interaction_in_progress",
51
- desc: "Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. For more visit: aka.ms/msaljs/browser-errors.",
100
+ code: interactionInProgress,
101
+ desc: BrowserAuthErrorMessages[interactionInProgress],
52
102
  },
53
103
  popupWindowError: {
54
- code: "popup_window_error",
55
- desc: "Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser.",
104
+ code: popupWindowError,
105
+ desc: BrowserAuthErrorMessages[popupWindowError],
56
106
  },
57
107
  emptyWindowError: {
58
- code: "empty_window_error",
59
- desc: "window.open returned null or undefined window object.",
108
+ code: emptyWindowError,
109
+ desc: BrowserAuthErrorMessages[emptyWindowError],
60
110
  },
61
111
  userCancelledError: {
62
- code: "user_cancelled",
63
- desc: "User cancelled the flow.",
112
+ code: userCancelled,
113
+ desc: BrowserAuthErrorMessages[userCancelled],
64
114
  },
65
115
  monitorPopupTimeoutError: {
66
- code: "monitor_window_timeout",
67
- desc: "Token acquisition in popup failed due to timeout. For more visit: aka.ms/msaljs/browser-errors.",
116
+ code: monitorPopupTimeout,
117
+ desc: BrowserAuthErrorMessages[monitorPopupTimeout],
68
118
  },
69
119
  monitorIframeTimeoutError: {
70
- code: "monitor_window_timeout",
71
- desc: "Token acquisition in iframe failed due to timeout. For more visit: aka.ms/msaljs/browser-errors.",
120
+ code: monitorWindowTimeout,
121
+ desc: BrowserAuthErrorMessages[monitorWindowTimeout],
72
122
  },
73
123
  redirectInIframeError: {
74
- code: "redirect_in_iframe",
75
- desc: "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.",
124
+ code: redirectInIframe,
125
+ desc: BrowserAuthErrorMessages[redirectInIframe],
76
126
  },
77
127
  blockTokenRequestsInHiddenIframeError: {
78
- code: "block_iframe_reload",
79
- desc: "Request was blocked inside an iframe because MSAL detected an authentication response. For more visit: aka.ms/msaljs/browser-errors",
128
+ code: blockIframeReload,
129
+ desc: BrowserAuthErrorMessages[blockIframeReload],
80
130
  },
81
131
  blockAcquireTokenInPopupsError: {
82
- code: "block_nested_popups",
83
- desc: "Request was blocked inside a popup because MSAL detected it was running in a popup.",
132
+ code: blockNestedPopups,
133
+ desc: BrowserAuthErrorMessages[blockNestedPopups],
84
134
  },
85
135
  iframeClosedPrematurelyError: {
86
- code: "iframe_closed_prematurely",
87
- desc: "The iframe being monitored was closed prematurely.",
136
+ code: iframeClosedPrematurely,
137
+ desc: BrowserAuthErrorMessages[iframeClosedPrematurely],
88
138
  },
89
139
  silentLogoutUnsupportedError: {
90
- code: "silent_logout_unsupported",
91
- desc: "Silent logout not supported. Please call logoutRedirect or logoutPopup instead.",
140
+ code: silentLogoutUnsupported,
141
+ desc: BrowserAuthErrorMessages[silentLogoutUnsupported],
92
142
  },
93
143
  noAccountError: {
94
- code: "no_account_error",
95
- desc: "No account object provided to acquireTokenSilent and no active account has been set. Please call setActiveAccount or provide an account on the request.",
144
+ code: noAccountError,
145
+ desc: BrowserAuthErrorMessages[noAccountError],
96
146
  },
97
147
  silentPromptValueError: {
98
- code: "silent_prompt_value_error",
99
- desc: "The value given for the prompt value is not valid for silent requests - must be set to 'none' or 'no_session'.",
148
+ code: silentPromptValueError,
149
+ desc: BrowserAuthErrorMessages[silentPromptValueError],
100
150
  },
101
151
  noTokenRequestCacheError: {
102
- code: "no_token_request_cache_error",
103
- desc: "No token request found in cache.",
152
+ code: noTokenRequestCacheError,
153
+ desc: BrowserAuthErrorMessages[noTokenRequestCacheError],
104
154
  },
105
155
  unableToParseTokenRequestCacheError: {
106
- code: "unable_to_parse_token_request_cache_error",
107
- desc: "The cached token request could not be parsed.",
156
+ code: unableToParseTokenRequestCacheError,
157
+ desc: BrowserAuthErrorMessages[unableToParseTokenRequestCacheError],
108
158
  },
109
159
  noCachedAuthorityError: {
110
- code: "no_cached_authority_error",
111
- desc: "No cached authority found.",
160
+ code: noCachedAuthorityError,
161
+ desc: BrowserAuthErrorMessages[noCachedAuthorityError],
112
162
  },
113
163
  authRequestNotSet: {
114
- code: "auth_request_not_set_error",
115
- desc: "Auth Request not set. Please ensure initiateAuthRequest was called from the InteractionHandler",
164
+ code: authRequestNotSetError,
165
+ desc: BrowserAuthErrorMessages[authRequestNotSetError],
116
166
  },
117
167
  invalidCacheType: {
118
- code: "invalid_cache_type",
119
- desc: "Invalid cache type",
168
+ code: invalidCacheType,
169
+ desc: BrowserAuthErrorMessages[invalidCacheType],
120
170
  },
121
171
  notInBrowserEnvironment: {
122
- code: "non_browser_environment",
123
- desc: "Login and token requests are not supported in non-browser environments.",
172
+ code: nonBrowserEnvironment,
173
+ desc: BrowserAuthErrorMessages[nonBrowserEnvironment],
124
174
  },
125
175
  databaseNotOpen: {
126
- code: "database_not_open",
127
- desc: "Database is not open!",
176
+ code: databaseNotOpen,
177
+ desc: BrowserAuthErrorMessages[databaseNotOpen],
128
178
  },
129
179
  noNetworkConnectivity: {
130
- code: "no_network_connectivity",
131
- desc: "No network connectivity. Check your internet connection.",
180
+ code: noNetworkConnectivity,
181
+ desc: BrowserAuthErrorMessages[noNetworkConnectivity],
132
182
  },
133
183
  postRequestFailed: {
134
- code: "post_request_failed",
135
- desc: "Network request failed: If the browser threw a CORS error, check that the redirectUri is registered in the Azure App Portal as type 'SPA'",
184
+ code: postRequestFailed,
185
+ desc: BrowserAuthErrorMessages[postRequestFailed],
136
186
  },
137
187
  getRequestFailed: {
138
- code: "get_request_failed",
139
- desc: "Network request failed. Please check the network trace to determine root cause.",
188
+ code: getRequestFailed,
189
+ desc: BrowserAuthErrorMessages[getRequestFailed],
140
190
  },
141
191
  failedToParseNetworkResponse: {
142
- code: "failed_to_parse_response",
143
- desc: "Failed to parse network response. Check network trace.",
192
+ code: failedToParseResponse,
193
+ desc: BrowserAuthErrorMessages[failedToParseResponse],
144
194
  },
145
195
  unableToLoadTokenError: {
146
- code: "unable_to_load_token",
147
- desc: "Error loading token to cache.",
196
+ code: unableToLoadToken,
197
+ desc: BrowserAuthErrorMessages[unableToLoadToken],
148
198
  },
149
199
  signingKeyNotFoundInStorage: {
150
- code: "crypto_key_not_found",
151
- desc: "Cryptographic Key or Keypair not found in browser storage.",
200
+ code: cryptoKeyNotFound,
201
+ desc: BrowserAuthErrorMessages[cryptoKeyNotFound],
152
202
  },
153
203
  authCodeRequired: {
154
- code: "auth_code_required",
155
- desc: "An authorization code must be provided (as the `code` property on the request) to this flow.",
204
+ code: authCodeRequired,
205
+ desc: BrowserAuthErrorMessages[authCodeRequired],
156
206
  },
157
207
  authCodeOrNativeAccountRequired: {
158
- code: "auth_code_or_nativeAccountId_required",
159
- desc: "An authorization code or nativeAccountId must be provided to this flow.",
208
+ code: authCodeOrNativeAccountIdRequired,
209
+ desc: BrowserAuthErrorMessages[authCodeOrNativeAccountIdRequired],
160
210
  },
161
211
  spaCodeAndNativeAccountPresent: {
162
- code: "spa_code_and_nativeAccountId_present",
163
- desc: "Request cannot contain both spa code and native account id.",
212
+ code: spaCodeAndNativeAccountIdPresent,
213
+ desc: BrowserAuthErrorMessages[spaCodeAndNativeAccountIdPresent],
164
214
  },
165
215
  databaseUnavailable: {
166
- code: "database_unavailable",
167
- desc: "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.",
216
+ code: databaseUnavailable,
217
+ desc: BrowserAuthErrorMessages[databaseUnavailable],
168
218
  },
169
219
  unableToAcquireTokenFromNativePlatform: {
170
- code: "unable_to_acquire_token_from_native_platform",
171
- desc: "Unable to acquire token from native platform. For a list of possible reasons visit aka.ms/msaljs/browser-errors.",
220
+ code: unableToAcquireTokenFromNativePlatform,
221
+ desc: BrowserAuthErrorMessages[unableToAcquireTokenFromNativePlatform],
172
222
  },
173
223
  nativeHandshakeTimeout: {
174
- code: "native_handshake_timeout",
175
- desc: "Timed out while attempting to establish connection to browser extension",
224
+ code: nativeHandshakeTimeout,
225
+ desc: BrowserAuthErrorMessages[nativeHandshakeTimeout],
176
226
  },
177
227
  nativeExtensionNotInstalled: {
178
- code: "native_extension_not_installed",
179
- desc: "Native extension is not installed. If you think this is a mistake call the initialize function.",
228
+ code: nativeExtensionNotInstalled,
229
+ desc: BrowserAuthErrorMessages[nativeExtensionNotInstalled],
180
230
  },
181
231
  nativeConnectionNotEstablished: {
182
- code: "native_connection_not_established",
183
- desc: "Connection to native platform has not been established. Please install a compatible browser extension and run initialize(). For more please visit aka.ms/msaljs/browser-errors.",
232
+ code: nativeConnectionNotEstablished,
233
+ desc: BrowserAuthErrorMessages[nativeConnectionNotEstablished],
184
234
  },
185
235
  uninitializedPublicClientApplication: {
186
- code: "uninitialized_public_client_application",
187
- desc: "You must call and await the initialize function before attempting to call any other MSAL API. For more please visit aka.ms/msaljs/browser-errors.",
236
+ code: uninitializedPublicClientApplication,
237
+ desc: BrowserAuthErrorMessages[uninitializedPublicClientApplication],
188
238
  },
189
239
  nativePromptNotSupported: {
190
- code: "native_prompt_not_supported",
191
- desc: "The provided prompt is not supported by the native platform. This request should be routed to the web based flow.",
240
+ code: nativePromptNotSupported,
241
+ desc: BrowserAuthErrorMessages[nativePromptNotSupported],
192
242
  },
193
243
  };
194
244
  /**
195
245
  * Browser library error class thrown by the MSAL.js library for SPAs
196
246
  */
197
247
  class BrowserAuthError extends AuthError {
198
- constructor(errorCode, errorMessage) {
199
- super(errorCode, errorMessage);
248
+ constructor(errorCode) {
249
+ super(errorCode, BrowserAuthErrorMessages[errorCode]);
200
250
  Object.setPrototypeOf(this, BrowserAuthError.prototype);
201
251
  this.name = "BrowserAuthError";
202
252
  }
203
- /**
204
- * Creates an error thrown when PKCE is not implemented.
205
- * @param errDetail
206
- */
207
- static createPkceNotGeneratedError(errDetail) {
208
- return new BrowserAuthError(BrowserAuthErrorMessage.pkceNotGenerated.code, `${BrowserAuthErrorMessage.pkceNotGenerated.desc} Detail:${errDetail}`);
209
- }
210
- /**
211
- * Creates an error thrown when the crypto object is unavailable.
212
- * @param errDetail
213
- */
214
- static createCryptoNotAvailableError(errDetail) {
215
- return new BrowserAuthError(BrowserAuthErrorMessage.cryptoDoesNotExist.code, `${BrowserAuthErrorMessage.cryptoDoesNotExist.desc} Detail:${errDetail}`);
216
- }
217
- /**
218
- * Creates an error thrown when an HTTP method hasn't been implemented by the browser class.
219
- * @param method
220
- */
221
- static createHttpMethodNotImplementedError(method) {
222
- return new BrowserAuthError(BrowserAuthErrorMessage.httpMethodNotImplementedError.code, `${BrowserAuthErrorMessage.httpMethodNotImplementedError.desc} Given Method: ${method}`);
223
- }
224
- /**
225
- * Creates an error thrown when the navigation URI is empty.
226
- */
227
- static createEmptyNavigationUriError() {
228
- return new BrowserAuthError(BrowserAuthErrorMessage.emptyNavigateUriError.code, BrowserAuthErrorMessage.emptyNavigateUriError.desc);
229
- }
230
- /**
231
- * Creates an error thrown when the hash string value is unexpectedly empty.
232
- * @param hashValue
233
- */
234
- static createEmptyHashError() {
235
- return new BrowserAuthError(BrowserAuthErrorMessage.hashEmptyError.code, `${BrowserAuthErrorMessage.hashEmptyError.desc}`);
236
- }
237
- /**
238
- * Creates an error thrown when the hash string value is unexpectedly empty.
239
- */
240
- static createHashDoesNotContainStateError() {
241
- return new BrowserAuthError(BrowserAuthErrorMessage.hashDoesNotContainStateError.code, BrowserAuthErrorMessage.hashDoesNotContainStateError.desc);
242
- }
243
- /**
244
- * Creates an error thrown when the hash string value does not contain known properties
245
- */
246
- static createHashDoesNotContainKnownPropertiesError() {
247
- return new BrowserAuthError(BrowserAuthErrorMessage.hashDoesNotContainKnownPropertiesError.code, BrowserAuthErrorMessage.hashDoesNotContainKnownPropertiesError.desc);
248
- }
249
- /**
250
- * Creates an error thrown when the hash string value is unexpectedly empty.
251
- */
252
- static createUnableToParseStateError() {
253
- return new BrowserAuthError(BrowserAuthErrorMessage.unableToParseStateError.code, BrowserAuthErrorMessage.unableToParseStateError.desc);
254
- }
255
- /**
256
- * Creates an error thrown when the state value in the hash does not match the interaction type of the API attempting to consume it.
257
- */
258
- static createStateInteractionTypeMismatchError() {
259
- return new BrowserAuthError(BrowserAuthErrorMessage.stateInteractionTypeMismatchError.code, BrowserAuthErrorMessage.stateInteractionTypeMismatchError.desc);
260
- }
261
- /**
262
- * Creates an error thrown when a browser interaction (redirect or popup) is in progress.
263
- */
264
- static createInteractionInProgressError() {
265
- return new BrowserAuthError(BrowserAuthErrorMessage.interactionInProgress.code, BrowserAuthErrorMessage.interactionInProgress.desc);
266
- }
267
- /**
268
- * Creates an error thrown when the popup window could not be opened.
269
- * @param errDetail
270
- */
271
- static createPopupWindowError(errDetail) {
272
- let errorMessage = BrowserAuthErrorMessage.popupWindowError.desc;
273
- errorMessage = !StringUtils.isEmpty(errDetail)
274
- ? `${errorMessage} Details: ${errDetail}`
275
- : errorMessage;
276
- return new BrowserAuthError(BrowserAuthErrorMessage.popupWindowError.code, errorMessage);
277
- }
278
- /**
279
- * Creates an error thrown when window.open returns an empty window object.
280
- * @param errDetail
281
- */
282
- static createEmptyWindowCreatedError() {
283
- return new BrowserAuthError(BrowserAuthErrorMessage.emptyWindowError.code, BrowserAuthErrorMessage.emptyWindowError.desc);
284
- }
285
- /**
286
- * Creates an error thrown when the user closes a popup.
287
- */
288
- static createUserCancelledError() {
289
- return new BrowserAuthError(BrowserAuthErrorMessage.userCancelledError.code, BrowserAuthErrorMessage.userCancelledError.desc);
290
- }
291
- /**
292
- * Creates an error thrown when monitorPopupFromHash times out for a given popup.
293
- */
294
- static createMonitorPopupTimeoutError() {
295
- return new BrowserAuthError(BrowserAuthErrorMessage.monitorPopupTimeoutError.code, BrowserAuthErrorMessage.monitorPopupTimeoutError.desc);
296
- }
297
- /**
298
- * Creates an error thrown when monitorIframeFromHash times out for a given iframe.
299
- */
300
- static createMonitorIframeTimeoutError() {
301
- return new BrowserAuthError(BrowserAuthErrorMessage.monitorIframeTimeoutError.code, BrowserAuthErrorMessage.monitorIframeTimeoutError.desc);
302
- }
303
- /**
304
- * Creates an error thrown when navigateWindow is called inside an iframe or brokered applications.
305
- * @param windowParentCheck
306
- */
307
- static createRedirectInIframeError(windowParentCheck) {
308
- return new BrowserAuthError(BrowserAuthErrorMessage.redirectInIframeError.code, `${BrowserAuthErrorMessage.redirectInIframeError.desc} (window.parent !== window) => ${windowParentCheck}`);
309
- }
310
- /**
311
- * Creates an error thrown when an auth reload is done inside an iframe.
312
- */
313
- static createBlockReloadInHiddenIframeError() {
314
- return new BrowserAuthError(BrowserAuthErrorMessage.blockTokenRequestsInHiddenIframeError.code, BrowserAuthErrorMessage.blockTokenRequestsInHiddenIframeError.desc);
315
- }
316
- /**
317
- * Creates an error thrown when a popup attempts to call an acquireToken API
318
- * @returns
319
- */
320
- static createBlockAcquireTokenInPopupsError() {
321
- return new BrowserAuthError(BrowserAuthErrorMessage.blockAcquireTokenInPopupsError.code, BrowserAuthErrorMessage.blockAcquireTokenInPopupsError.desc);
322
- }
323
- /**
324
- * Creates an error thrown when an iframe is found to be closed before the timeout is reached.
325
- */
326
- static createIframeClosedPrematurelyError() {
327
- return new BrowserAuthError(BrowserAuthErrorMessage.iframeClosedPrematurelyError.code, BrowserAuthErrorMessage.iframeClosedPrematurelyError.desc);
328
- }
329
- /**
330
- * Creates an error thrown when the logout API is called on any of the silent interaction clients
331
- */
332
- static createSilentLogoutUnsupportedError() {
333
- return new BrowserAuthError(BrowserAuthErrorMessage.silentLogoutUnsupportedError.code, BrowserAuthErrorMessage.silentLogoutUnsupportedError.desc);
334
- }
335
- /**
336
- * Creates an error thrown when the account object is not provided in the acquireTokenSilent API.
337
- */
338
- static createNoAccountError() {
339
- return new BrowserAuthError(BrowserAuthErrorMessage.noAccountError.code, BrowserAuthErrorMessage.noAccountError.desc);
340
- }
341
- /**
342
- * Creates an error thrown when a given prompt value is invalid for silent requests.
343
- */
344
- static createSilentPromptValueError(givenPrompt) {
345
- return new BrowserAuthError(BrowserAuthErrorMessage.silentPromptValueError.code, `${BrowserAuthErrorMessage.silentPromptValueError.desc} Given value: ${givenPrompt}`);
346
- }
347
- /**
348
- * Creates an error thrown when the cached token request could not be retrieved from the cache
349
- */
350
- static createUnableToParseTokenRequestCacheError() {
351
- return new BrowserAuthError(BrowserAuthErrorMessage.unableToParseTokenRequestCacheError.code, BrowserAuthErrorMessage.unableToParseTokenRequestCacheError.desc);
352
- }
353
- /**
354
- * Creates an error thrown when the token request could not be retrieved from the cache
355
- */
356
- static createNoTokenRequestCacheError() {
357
- return new BrowserAuthError(BrowserAuthErrorMessage.noTokenRequestCacheError.code, BrowserAuthErrorMessage.noTokenRequestCacheError.desc);
358
- }
359
- /**
360
- * Creates an error thrown when handleCodeResponse is called before initiateAuthRequest (InteractionHandler)
361
- */
362
- static createAuthRequestNotSetError() {
363
- return new BrowserAuthError(BrowserAuthErrorMessage.authRequestNotSet.code, BrowserAuthErrorMessage.authRequestNotSet.desc);
364
- }
365
- /**
366
- * Creates an error thrown when the authority could not be retrieved from the cache
367
- */
368
- static createNoCachedAuthorityError() {
369
- return new BrowserAuthError(BrowserAuthErrorMessage.noCachedAuthorityError.code, BrowserAuthErrorMessage.noCachedAuthorityError.desc);
370
- }
371
- /**
372
- * Creates an error thrown if cache type is invalid.
373
- */
374
- static createInvalidCacheTypeError() {
375
- return new BrowserAuthError(BrowserAuthErrorMessage.invalidCacheType.code, `${BrowserAuthErrorMessage.invalidCacheType.desc}`);
376
- }
377
- /**
378
- * Create an error thrown when login and token requests are made from a non-browser environment
379
- */
380
- static createNonBrowserEnvironmentError() {
381
- return new BrowserAuthError(BrowserAuthErrorMessage.notInBrowserEnvironment.code, BrowserAuthErrorMessage.notInBrowserEnvironment.desc);
382
- }
383
- /**
384
- * Create an error thrown when indexDB database is not open
385
- */
386
- static createDatabaseNotOpenError() {
387
- return new BrowserAuthError(BrowserAuthErrorMessage.databaseNotOpen.code, BrowserAuthErrorMessage.databaseNotOpen.desc);
388
- }
389
- /**
390
- * Create an error thrown when token fetch fails due to no internet
391
- */
392
- static createNoNetworkConnectivityError() {
393
- return new BrowserAuthError(BrowserAuthErrorMessage.noNetworkConnectivity.code, BrowserAuthErrorMessage.noNetworkConnectivity.desc);
394
- }
395
- /**
396
- * Create an error thrown when token fetch fails due to reasons other than internet connectivity
397
- */
398
- static createPostRequestFailedError(errorDesc, endpoint) {
399
- return new BrowserAuthError(BrowserAuthErrorMessage.postRequestFailed.code, `${BrowserAuthErrorMessage.postRequestFailed.desc} | Network client threw: ${errorDesc} | Attempted to reach: ${endpoint.split("?")[0]}`);
400
- }
401
- /**
402
- * Create an error thrown when get request fails due to reasons other than internet connectivity
403
- */
404
- static createGetRequestFailedError(errorDesc, endpoint) {
405
- return new BrowserAuthError(BrowserAuthErrorMessage.getRequestFailed.code, `${BrowserAuthErrorMessage.getRequestFailed.desc} | Network client threw: ${errorDesc} | Attempted to reach: ${endpoint.split("?")[0]}`);
406
- }
407
- /**
408
- * Create an error thrown when network client fails to parse network response
409
- */
410
- static createFailedToParseNetworkResponseError(endpoint) {
411
- return new BrowserAuthError(BrowserAuthErrorMessage.failedToParseNetworkResponse.code, `${BrowserAuthErrorMessage.failedToParseNetworkResponse.desc} | Attempted to reach: ${endpoint.split("?")[0]}`);
412
- }
413
- /**
414
- * Create an error thrown when the necessary information is not available to sideload tokens
415
- */
416
- static createUnableToLoadTokenError(errorDetail) {
417
- return new BrowserAuthError(BrowserAuthErrorMessage.unableToLoadTokenError.code, `${BrowserAuthErrorMessage.unableToLoadTokenError.desc} | ${errorDetail}`);
418
- }
419
- /**
420
- * Create an error thrown when the queried cryptographic key is not found in IndexedDB
421
- */
422
- static createSigningKeyNotFoundInStorageError(keyId) {
423
- return new BrowserAuthError(BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code, `${BrowserAuthErrorMessage.signingKeyNotFoundInStorage.desc} | No match found for KeyId: ${keyId}`);
424
- }
425
- /**
426
- * Create an error when an authorization code is required but not provided
427
- */
428
- static createAuthCodeRequiredError() {
429
- return new BrowserAuthError(BrowserAuthErrorMessage.authCodeRequired.code, BrowserAuthErrorMessage.authCodeRequired.desc);
430
- }
431
- /**
432
- * Create an error when an authorization code or native account ID is required but not provided
433
- */
434
- static createAuthCodeOrNativeAccountIdRequiredError() {
435
- return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
436
- }
437
- /**
438
- * Create an error when both authorization code and native account ID are provided
439
- */
440
- static createSpaCodeAndNativeAccountIdPresentError() {
441
- return new BrowserAuthError(BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.code, BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.desc);
442
- }
443
- /**
444
- * Create an error when IndexedDB is unavailable
445
- */
446
- static createDatabaseUnavailableError() {
447
- return new BrowserAuthError(BrowserAuthErrorMessage.databaseUnavailable.code, BrowserAuthErrorMessage.databaseUnavailable.desc);
448
- }
449
- /**
450
- * Create an error when native token acquisition is not possible
451
- */
452
- static createUnableToAcquireTokenFromNativePlatformError() {
453
- return new BrowserAuthError(BrowserAuthErrorMessage.unableToAcquireTokenFromNativePlatform.code, BrowserAuthErrorMessage.unableToAcquireTokenFromNativePlatform.desc);
454
- }
455
- /**
456
- * Create an error thrown when Handshake with browser extension times out
457
- */
458
- static createNativeHandshakeTimeoutError() {
459
- return new BrowserAuthError(BrowserAuthErrorMessage.nativeHandshakeTimeout.code, BrowserAuthErrorMessage.nativeHandshakeTimeout.desc);
460
- }
461
- /**
462
- * Create an error thrown when browser extension is not installed
463
- */
464
- static createNativeExtensionNotInstalledError() {
465
- return new BrowserAuthError(BrowserAuthErrorMessage.nativeExtensionNotInstalled.code, BrowserAuthErrorMessage.nativeExtensionNotInstalled.desc);
466
- }
467
- /**
468
- * Create an error when native connection has not been established
469
- * @returns
470
- */
471
- static createNativeConnectionNotEstablishedError() {
472
- return new BrowserAuthError(BrowserAuthErrorMessage.nativeConnectionNotEstablished.code, BrowserAuthErrorMessage.nativeConnectionNotEstablished.desc);
473
- }
474
- /**
475
- * Create an error thrown when the initialize function hasn't been called
476
- */
477
- static createUninitializedPublicClientApplication() {
478
- return new BrowserAuthError(BrowserAuthErrorMessage.uninitializedPublicClientApplication.code, BrowserAuthErrorMessage.uninitializedPublicClientApplication.desc);
479
- }
480
- /**
481
- * Create an error thrown when requesting a token directly from the native platform with an unsupported prompt parameter e.g. select_account, login or create
482
- * These requests must go through eSTS to ensure eSTS is aware of the new account
483
- */
484
- static createNativePromptParameterNotSupportedError() {
485
- return new BrowserAuthError(BrowserAuthErrorMessage.nativePromptNotSupported.code, BrowserAuthErrorMessage.nativePromptNotSupported.desc);
486
- }
253
+ }
254
+ function createBrowserAuthError(errorCode) {
255
+ return new BrowserAuthError(errorCode);
487
256
  }
488
257
 
489
- export { BrowserAuthError, BrowserAuthErrorMessage };
258
+ export { BrowserAuthError, BrowserAuthErrorMessage, BrowserAuthErrorMessages, createBrowserAuthError };
490
259
  //# sourceMappingURL=BrowserAuthError.mjs.map