@azure/msal-browser 3.0.0-alpha.1 → 3.0.0-alpha.2

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 (142) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +213 -213
  3. package/dist/app/IPublicClientApplication.d.ts +45 -45
  4. package/dist/app/IPublicClientApplication.js +96 -96
  5. package/dist/app/PublicClientApplication.d.ts +244 -244
  6. package/dist/app/PublicClientApplication.js +307 -307
  7. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +63 -63
  8. package/dist/broker/nativeBroker/NativeMessageHandler.js +255 -255
  9. package/dist/broker/nativeBroker/NativeRequest.d.ts +43 -43
  10. package/dist/broker/nativeBroker/NativeResponse.d.ts +48 -48
  11. package/dist/cache/AsyncMemoryStorage.d.ts +51 -51
  12. package/dist/cache/AsyncMemoryStorage.js +132 -132
  13. package/dist/cache/BrowserCacheManager.d.ts +377 -377
  14. package/dist/cache/BrowserCacheManager.js +1276 -1276
  15. package/dist/cache/BrowserStorage.d.ts +11 -11
  16. package/dist/cache/BrowserStorage.js +35 -35
  17. package/dist/cache/CryptoKeyStore.d.ts +17 -17
  18. package/dist/cache/CryptoKeyStore.js +41 -41
  19. package/dist/cache/DatabaseStorage.d.ts +56 -56
  20. package/dist/cache/DatabaseStorage.js +190 -190
  21. package/dist/cache/IAsyncMemoryStorage.d.ts +27 -27
  22. package/dist/cache/ITokenCache.d.ts +10 -10
  23. package/dist/cache/IWindowStorage.d.ts +27 -27
  24. package/dist/cache/MemoryStorage.d.ts +11 -11
  25. package/dist/cache/MemoryStorage.js +31 -31
  26. package/dist/cache/TokenCache.d.ts +76 -76
  27. package/dist/cache/TokenCache.js +225 -225
  28. package/dist/config/Configuration.d.ts +203 -203
  29. package/dist/config/Configuration.js +101 -101
  30. package/dist/controllers/ControllerFactory.d.ts +9 -9
  31. package/dist/controllers/ControllerFactory.js +37 -37
  32. package/dist/controllers/IController.d.ts +66 -66
  33. package/dist/controllers/StandardController.d.ts +413 -413
  34. package/dist/controllers/StandardController.js +1272 -1272
  35. package/dist/crypto/BrowserCrypto.d.ts +61 -61
  36. package/dist/crypto/BrowserCrypto.js +131 -131
  37. package/dist/crypto/CryptoOps.d.ts +73 -73
  38. package/dist/crypto/CryptoOps.js +150 -150
  39. package/dist/crypto/GuidGenerator.d.ts +12 -12
  40. package/dist/crypto/GuidGenerator.js +96 -96
  41. package/dist/crypto/ISubtleCrypto.d.ts +9 -9
  42. package/dist/crypto/ModernBrowserCrypto.d.ts +9 -9
  43. package/dist/crypto/ModernBrowserCrypto.js +24 -24
  44. package/dist/crypto/MsBrowserCrypto.d.ts +9 -9
  45. package/dist/crypto/MsBrowserCrypto.js +79 -79
  46. package/dist/crypto/MsrBrowserCrypto.d.ts +17 -17
  47. package/dist/crypto/MsrBrowserCrypto.js +28 -28
  48. package/dist/crypto/PkceGenerator.d.ts +24 -24
  49. package/dist/crypto/PkceGenerator.js +58 -58
  50. package/dist/crypto/SignedHttpRequest.d.ts +30 -30
  51. package/dist/crypto/SignedHttpRequest.js +39 -39
  52. package/dist/encode/Base64Decode.d.ts +22 -22
  53. package/dist/encode/Base64Decode.js +73 -73
  54. package/dist/encode/Base64Encode.d.ts +31 -31
  55. package/dist/encode/Base64Encode.js +79 -79
  56. package/dist/error/BrowserAuthError.d.ts +382 -382
  57. package/dist/error/BrowserAuthError.js +483 -483
  58. package/dist/error/BrowserConfigurationAuthError.d.ts +70 -70
  59. package/dist/error/BrowserConfigurationAuthError.js +96 -96
  60. package/dist/error/NativeAuthError.d.ts +56 -56
  61. package/dist/error/NativeAuthError.js +88 -88
  62. package/dist/event/EventHandler.d.ts +41 -41
  63. package/dist/event/EventHandler.js +119 -119
  64. package/dist/event/EventMessage.d.ts +25 -25
  65. package/dist/event/EventMessage.js +67 -67
  66. package/dist/event/EventType.d.ts +26 -26
  67. package/dist/event/EventType.js +31 -31
  68. package/dist/index.d.ts +35 -35
  69. package/dist/index.js +1 -1
  70. package/dist/interaction_client/BaseInteractionClient.d.ts +52 -52
  71. package/dist/interaction_client/BaseInteractionClient.js +138 -138
  72. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts +4 -4
  73. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +10 -10
  74. package/dist/interaction_client/NativeInteractionClient.d.ts +148 -148
  75. package/dist/interaction_client/NativeInteractionClient.js +516 -516
  76. package/dist/interaction_client/PopupClient.d.ts +111 -111
  77. package/dist/interaction_client/PopupClient.js +476 -476
  78. package/dist/interaction_client/RedirectClient.d.ts +48 -48
  79. package/dist/interaction_client/RedirectClient.js +290 -290
  80. package/dist/interaction_client/SilentAuthCodeClient.d.ts +22 -22
  81. package/dist/interaction_client/SilentAuthCodeClient.js +62 -62
  82. package/dist/interaction_client/SilentCacheClient.d.ts +21 -21
  83. package/dist/interaction_client/SilentCacheClient.js +67 -67
  84. package/dist/interaction_client/SilentIframeClient.d.ts +31 -31
  85. package/dist/interaction_client/SilentIframeClient.js +127 -127
  86. package/dist/interaction_client/SilentRefreshClient.d.ts +19 -19
  87. package/dist/interaction_client/SilentRefreshClient.js +62 -62
  88. package/dist/interaction_client/StandardInteractionClient.d.ts +59 -59
  89. package/dist/interaction_client/StandardInteractionClient.js +259 -259
  90. package/dist/interaction_handler/InteractionHandler.d.ts +39 -39
  91. package/dist/interaction_handler/InteractionHandler.js +127 -127
  92. package/dist/interaction_handler/RedirectHandler.d.ts +24 -24
  93. package/dist/interaction_handler/RedirectHandler.js +118 -118
  94. package/dist/interaction_handler/SilentHandler.d.ts +47 -47
  95. package/dist/interaction_handler/SilentHandler.js +162 -162
  96. package/dist/internals.d.ts +23 -23
  97. package/dist/internals.js +4 -4
  98. package/dist/navigation/INavigationClient.d.ts +16 -16
  99. package/dist/navigation/NavigationClient.d.ts +22 -22
  100. package/dist/navigation/NavigationClient.js +40 -40
  101. package/dist/navigation/NavigationOptions.d.ts +12 -12
  102. package/dist/network/FetchClient.d.ts +26 -26
  103. package/dist/network/FetchClient.js +99 -99
  104. package/dist/network/XhrClient.d.ts +40 -40
  105. package/dist/network/XhrClient.js +117 -117
  106. package/dist/operatingcontext/BaseOperatingContext.d.ts +40 -40
  107. package/dist/operatingcontext/BaseOperatingContext.js +44 -44
  108. package/dist/operatingcontext/StandardOperatingContext.d.ts +25 -25
  109. package/dist/operatingcontext/StandardOperatingContext.js +43 -43
  110. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +25 -25
  111. package/dist/operatingcontext/TeamsAppOperatingContext.js +42 -42
  112. package/dist/packageMetadata.d.ts +2 -2
  113. package/dist/packageMetadata.js +4 -4
  114. package/dist/request/AuthorizationCodeRequest.d.ts +8 -8
  115. package/dist/request/AuthorizationUrlRequest.d.ts +8 -8
  116. package/dist/request/EndSessionPopupRequest.d.ts +18 -18
  117. package/dist/request/EndSessionRequest.d.ts +15 -15
  118. package/dist/request/PopupRequest.d.ts +32 -32
  119. package/dist/request/PopupWindowAttributes.d.ts +15 -15
  120. package/dist/request/RedirectRequest.d.ts +33 -33
  121. package/dist/request/SilentRequest.d.ts +30 -30
  122. package/dist/request/SsoSilentRequest.d.ts +26 -26
  123. package/dist/telemetry/BrowserPerformanceClient.d.ts +38 -38
  124. package/dist/telemetry/BrowserPerformanceClient.js +124 -124
  125. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +21 -21
  126. package/dist/telemetry/BrowserPerformanceMeasurement.js +92 -92
  127. package/dist/utils/BrowserConstants.d.ts +166 -166
  128. package/dist/utils/BrowserConstants.js +214 -214
  129. package/dist/utils/BrowserProtocolUtils.d.ts +18 -18
  130. package/dist/utils/BrowserProtocolUtils.js +34 -34
  131. package/dist/utils/BrowserStringUtils.d.ts +26 -26
  132. package/dist/utils/BrowserStringUtils.js +149 -149
  133. package/dist/utils/BrowserUtils.d.ts +65 -65
  134. package/dist/utils/BrowserUtils.js +138 -138
  135. package/dist/utils/MathUtils.d.ts +11 -11
  136. package/dist/utils/MathUtils.js +21 -21
  137. package/lib/msal-browser.cjs.js +18383 -0
  138. package/lib/msal-browser.cjs.js.map +1 -0
  139. package/lib/msal-browser.js +18389 -0
  140. package/lib/msal-browser.js.map +1 -0
  141. package/lib/msal-browser.min.js +74 -0
  142. package/package.json +97 -95
@@ -1,489 +1,489 @@
1
- /*! @azure/msal-browser v3.0.0-alpha.1 2023-05-08 */
1
+ /*! @azure/msal-browser v3.0.0-alpha.2 2023-05-17 */
2
2
  'use strict';
3
3
  import { AuthError, StringUtils } from '@azure/msal-common';
4
4
 
5
- /*
6
- * Copyright (c) Microsoft Corporation. All rights reserved.
7
- * Licensed under the MIT License.
8
- */
9
- /**
10
- * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
11
- */
12
- const BrowserAuthErrorMessage = {
13
- pkceNotGenerated: {
14
- code: "pkce_not_created",
15
- desc: "The PKCE code challenge and verifier could not be generated.",
16
- },
17
- 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.",
24
- },
25
- emptyNavigateUriError: {
26
- code: "empty_navigate_uri",
27
- desc: "Navigation URI is empty. Please check stack trace for more info.",
28
- },
29
- 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.",
32
- },
33
- hashDoesNotContainStateError: {
34
- code: "no_state_in_hash",
35
- desc: "Hash does not contain state. Please verify that the request originated from msal.",
36
- },
37
- 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.",
40
- },
41
- unableToParseStateError: {
42
- code: "unable_to_parse_state",
43
- desc: "Unable to parse state. Please verify that the request originated from msal.",
44
- },
45
- stateInteractionTypeMismatchError: {
46
- code: "state_interaction_type_mismatch",
47
- desc: "Hash contains state but the interaction type does not match the caller.",
48
- },
49
- 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.",
52
- },
53
- 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.",
56
- },
57
- emptyWindowError: {
58
- code: "empty_window_error",
59
- desc: "window.open returned null or undefined window object.",
60
- },
61
- userCancelledError: {
62
- code: "user_cancelled",
63
- desc: "User cancelled the flow.",
64
- },
65
- monitorPopupTimeoutError: {
66
- code: "monitor_window_timeout",
67
- desc: "Token acquisition in popup failed due to timeout. For more visit: aka.ms/msaljs/browser-errors.",
68
- },
69
- monitorIframeTimeoutError: {
70
- code: "monitor_window_timeout",
71
- desc: "Token acquisition in iframe failed due to timeout. For more visit: aka.ms/msaljs/browser-errors.",
72
- },
73
- 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.",
76
- },
77
- 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",
80
- },
81
- blockAcquireTokenInPopupsError: {
82
- code: "block_nested_popups",
83
- desc: "Request was blocked inside a popup because MSAL detected it was running in a popup.",
84
- },
85
- iframeClosedPrematurelyError: {
86
- code: "iframe_closed_prematurely",
87
- desc: "The iframe being monitored was closed prematurely.",
88
- },
89
- silentLogoutUnsupportedError: {
90
- code: "silent_logout_unsupported",
91
- desc: "Silent logout not supported. Please call logoutRedirect or logoutPopup instead.",
92
- },
93
- 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.",
96
- },
97
- 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'.",
100
- },
101
- noTokenRequestCacheError: {
102
- code: "no_token_request_cache_error",
103
- desc: "No token request found in cache.",
104
- },
105
- unableToParseTokenRequestCacheError: {
106
- code: "unable_to_parse_token_request_cache_error",
107
- desc: "The cached token request could not be parsed.",
108
- },
109
- noCachedAuthorityError: {
110
- code: "no_cached_authority_error",
111
- desc: "No cached authority found.",
112
- },
113
- authRequestNotSet: {
114
- code: "auth_request_not_set_error",
115
- desc: "Auth Request not set. Please ensure initiateAuthRequest was called from the InteractionHandler",
116
- },
117
- invalidCacheType: {
118
- code: "invalid_cache_type",
119
- desc: "Invalid cache type",
120
- },
121
- notInBrowserEnvironment: {
122
- code: "non_browser_environment",
123
- desc: "Login and token requests are not supported in non-browser environments.",
124
- },
125
- databaseNotOpen: {
126
- code: "database_not_open",
127
- desc: "Database is not open!",
128
- },
129
- noNetworkConnectivity: {
130
- code: "no_network_connectivity",
131
- desc: "No network connectivity. Check your internet connection.",
132
- },
133
- 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'",
136
- },
137
- getRequestFailed: {
138
- code: "get_request_failed",
139
- desc: "Network request failed. Please check the network trace to determine root cause.",
140
- },
141
- failedToParseNetworkResponse: {
142
- code: "failed_to_parse_response",
143
- desc: "Failed to parse network response. Check network trace.",
144
- },
145
- unableToLoadTokenError: {
146
- code: "unable_to_load_token",
147
- desc: "Error loading token to cache.",
148
- },
149
- signingKeyNotFoundInStorage: {
150
- code: "crypto_key_not_found",
151
- desc: "Cryptographic Key or Keypair not found in browser storage.",
152
- },
153
- authCodeRequired: {
154
- code: "auth_code_required",
155
- desc: "An authorization code must be provided (as the `code` property on the request) to this flow.",
156
- },
157
- authCodeOrNativeAccountRequired: {
158
- code: "auth_code_or_nativeAccountId_required",
159
- desc: "An authorization code or nativeAccountId must be provided to this flow.",
160
- },
161
- spaCodeAndNativeAccountPresent: {
162
- code: "spa_code_and_nativeAccountId_present",
163
- desc: "Request cannot contain both spa code and native account id.",
164
- },
165
- 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.",
168
- },
169
- 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.",
172
- },
173
- nativeHandshakeTimeout: {
174
- code: "native_handshake_timeout",
175
- desc: "Timed out while attempting to establish connection to browser extension",
176
- },
177
- 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.",
180
- },
181
- 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.",
184
- },
185
- nativeBrokerCalledBeforeInitialize: {
186
- code: "native_broker_called_before_initialize",
187
- desc: "You must call and await the initialize function before attempting to call any other MSAL API when native brokering is enabled. For more please visit aka.ms/msaljs/browser-errors.",
188
- },
189
- 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.",
192
- },
193
- };
194
- /**
195
- * Browser library error class thrown by the MSAL.js library for SPAs
196
- */
197
- class BrowserAuthError extends AuthError {
198
- constructor(errorCode, errorMessage) {
199
- super(errorCode, errorMessage);
200
- Object.setPrototypeOf(this, BrowserAuthError.prototype);
201
- this.name = "BrowserAuthError";
202
- }
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 createNativeBrokerCalledBeforeInitialize() {
478
- return new BrowserAuthError(BrowserAuthErrorMessage.nativeBrokerCalledBeforeInitialize.code, BrowserAuthErrorMessage.nativeBrokerCalledBeforeInitialize.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
- }
5
+ /*
6
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7
+ * Licensed under the MIT License.
8
+ */
9
+ /**
10
+ * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
11
+ */
12
+ const BrowserAuthErrorMessage = {
13
+ pkceNotGenerated: {
14
+ code: "pkce_not_created",
15
+ desc: "The PKCE code challenge and verifier could not be generated.",
16
+ },
17
+ 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.",
24
+ },
25
+ emptyNavigateUriError: {
26
+ code: "empty_navigate_uri",
27
+ desc: "Navigation URI is empty. Please check stack trace for more info.",
28
+ },
29
+ 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.",
32
+ },
33
+ hashDoesNotContainStateError: {
34
+ code: "no_state_in_hash",
35
+ desc: "Hash does not contain state. Please verify that the request originated from msal.",
36
+ },
37
+ 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.",
40
+ },
41
+ unableToParseStateError: {
42
+ code: "unable_to_parse_state",
43
+ desc: "Unable to parse state. Please verify that the request originated from msal.",
44
+ },
45
+ stateInteractionTypeMismatchError: {
46
+ code: "state_interaction_type_mismatch",
47
+ desc: "Hash contains state but the interaction type does not match the caller.",
48
+ },
49
+ 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.",
52
+ },
53
+ 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.",
56
+ },
57
+ emptyWindowError: {
58
+ code: "empty_window_error",
59
+ desc: "window.open returned null or undefined window object.",
60
+ },
61
+ userCancelledError: {
62
+ code: "user_cancelled",
63
+ desc: "User cancelled the flow.",
64
+ },
65
+ monitorPopupTimeoutError: {
66
+ code: "monitor_window_timeout",
67
+ desc: "Token acquisition in popup failed due to timeout. For more visit: aka.ms/msaljs/browser-errors.",
68
+ },
69
+ monitorIframeTimeoutError: {
70
+ code: "monitor_window_timeout",
71
+ desc: "Token acquisition in iframe failed due to timeout. For more visit: aka.ms/msaljs/browser-errors.",
72
+ },
73
+ 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.",
76
+ },
77
+ 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",
80
+ },
81
+ blockAcquireTokenInPopupsError: {
82
+ code: "block_nested_popups",
83
+ desc: "Request was blocked inside a popup because MSAL detected it was running in a popup.",
84
+ },
85
+ iframeClosedPrematurelyError: {
86
+ code: "iframe_closed_prematurely",
87
+ desc: "The iframe being monitored was closed prematurely.",
88
+ },
89
+ silentLogoutUnsupportedError: {
90
+ code: "silent_logout_unsupported",
91
+ desc: "Silent logout not supported. Please call logoutRedirect or logoutPopup instead.",
92
+ },
93
+ 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.",
96
+ },
97
+ 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'.",
100
+ },
101
+ noTokenRequestCacheError: {
102
+ code: "no_token_request_cache_error",
103
+ desc: "No token request found in cache.",
104
+ },
105
+ unableToParseTokenRequestCacheError: {
106
+ code: "unable_to_parse_token_request_cache_error",
107
+ desc: "The cached token request could not be parsed.",
108
+ },
109
+ noCachedAuthorityError: {
110
+ code: "no_cached_authority_error",
111
+ desc: "No cached authority found.",
112
+ },
113
+ authRequestNotSet: {
114
+ code: "auth_request_not_set_error",
115
+ desc: "Auth Request not set. Please ensure initiateAuthRequest was called from the InteractionHandler",
116
+ },
117
+ invalidCacheType: {
118
+ code: "invalid_cache_type",
119
+ desc: "Invalid cache type",
120
+ },
121
+ notInBrowserEnvironment: {
122
+ code: "non_browser_environment",
123
+ desc: "Login and token requests are not supported in non-browser environments.",
124
+ },
125
+ databaseNotOpen: {
126
+ code: "database_not_open",
127
+ desc: "Database is not open!",
128
+ },
129
+ noNetworkConnectivity: {
130
+ code: "no_network_connectivity",
131
+ desc: "No network connectivity. Check your internet connection.",
132
+ },
133
+ 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'",
136
+ },
137
+ getRequestFailed: {
138
+ code: "get_request_failed",
139
+ desc: "Network request failed. Please check the network trace to determine root cause.",
140
+ },
141
+ failedToParseNetworkResponse: {
142
+ code: "failed_to_parse_response",
143
+ desc: "Failed to parse network response. Check network trace.",
144
+ },
145
+ unableToLoadTokenError: {
146
+ code: "unable_to_load_token",
147
+ desc: "Error loading token to cache.",
148
+ },
149
+ signingKeyNotFoundInStorage: {
150
+ code: "crypto_key_not_found",
151
+ desc: "Cryptographic Key or Keypair not found in browser storage.",
152
+ },
153
+ authCodeRequired: {
154
+ code: "auth_code_required",
155
+ desc: "An authorization code must be provided (as the `code` property on the request) to this flow.",
156
+ },
157
+ authCodeOrNativeAccountRequired: {
158
+ code: "auth_code_or_nativeAccountId_required",
159
+ desc: "An authorization code or nativeAccountId must be provided to this flow.",
160
+ },
161
+ spaCodeAndNativeAccountPresent: {
162
+ code: "spa_code_and_nativeAccountId_present",
163
+ desc: "Request cannot contain both spa code and native account id.",
164
+ },
165
+ 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.",
168
+ },
169
+ 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.",
172
+ },
173
+ nativeHandshakeTimeout: {
174
+ code: "native_handshake_timeout",
175
+ desc: "Timed out while attempting to establish connection to browser extension",
176
+ },
177
+ 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.",
180
+ },
181
+ 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.",
184
+ },
185
+ nativeBrokerCalledBeforeInitialize: {
186
+ code: "native_broker_called_before_initialize",
187
+ desc: "You must call and await the initialize function before attempting to call any other MSAL API when native brokering is enabled. For more please visit aka.ms/msaljs/browser-errors.",
188
+ },
189
+ 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.",
192
+ },
193
+ };
194
+ /**
195
+ * Browser library error class thrown by the MSAL.js library for SPAs
196
+ */
197
+ class BrowserAuthError extends AuthError {
198
+ constructor(errorCode, errorMessage) {
199
+ super(errorCode, errorMessage);
200
+ Object.setPrototypeOf(this, BrowserAuthError.prototype);
201
+ this.name = "BrowserAuthError";
202
+ }
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 createNativeBrokerCalledBeforeInitialize() {
478
+ return new BrowserAuthError(BrowserAuthErrorMessage.nativeBrokerCalledBeforeInitialize.code, BrowserAuthErrorMessage.nativeBrokerCalledBeforeInitialize.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
+ }
487
487
  }
488
488
 
489
489
  export { BrowserAuthError, BrowserAuthErrorMessage };