@azure/msal-browser
Version:
Microsoft Authentication Library for js
83 lines (80 loc) • 7.84 kB
JavaScript
/*! @azure/msal-browser v4.21.0 2025-08-19 */
'use strict';
import { AuthError } from '@azure/msal-common/browser';
import { timedOut, failedToDecryptEarResponse, failedToParseHeaders, failedToBuildHeaders, invalidPopTokenRequest, invalidBase64String, nativePromptNotSupported, uninitializedPublicClientApplication, nativeConnectionNotEstablished, nativeExtensionNotInstalled, nativeHandshakeTimeout, unableToAcquireTokenFromNativePlatform, databaseUnavailable, spaCodeAndNativeAccountIdPresent, authCodeOrNativeAccountIdRequired, authCodeRequired, cryptoKeyNotFound, unableToLoadToken, failedToParseResponse, getRequestFailed, postRequestFailed, noNetworkConnectivity, databaseNotOpen, nonBrowserEnvironment, invalidCacheType, authRequestNotSetError, unableToParseTokenRequestCacheError, noTokenRequestCacheError, silentPromptValueError, noAccountError, silentLogoutUnsupported, iframeClosedPrematurely, blockNestedPopups, blockIframeReload, redirectInIframe, monitorWindowTimeout, monitorPopupTimeout, userCancelled, emptyWindowError, popupWindowError, interactionInProgress, stateInteractionTypeMismatch, unableToParseState, hashDoesNotContainKnownProperties, noStateInHash, hashEmptyError, emptyNavigateUri, cryptoNonExistent, earJweEmpty, earJwkEmpty, pkceNotCreated } from './BrowserAuthErrorCodes.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const ErrorLink = "For more visit: aka.ms/msaljs/browser-errors";
/**
* BrowserAuthErrorMessage class containing string constants used by error codes and messages.
*/
const BrowserAuthErrorMessages = {
[ ]: "The PKCE code challenge and verifier could not be generated.",
[ ]: "No EAR encryption key provided. This is unexpected.",
[ ]: "Server response does not contain ear_jwe property. This is unexpected.",
[ ]: "The crypto object or function is not available.",
[ ]: "Navigation URI is empty. Please check stack trace for more info.",
[ ]: `Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash. ${ErrorLink}`,
[ ]: "Hash does not contain state. Please verify that the request originated from msal.",
[ ]: `Hash does not contain known properites. Please verify that your redirectUri is not changing the hash. ${ErrorLink}`,
[ ]: "Unable to parse state. Please verify that the request originated from msal.",
[ ]: "Hash contains state but the interaction type does not match the caller.",
[ ]: `Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. ${ErrorLink}`,
[ ]: "Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser.",
[ ]: "window.open returned null or undefined window object.",
[ ]: "User cancelled the flow.",
[ ]: `Token acquisition in popup failed due to timeout. ${ErrorLink}`,
[ ]: `Token acquisition in iframe failed due to timeout. ${ErrorLink}`,
[ ]: "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.",
[ ]: `Request was blocked inside an iframe because MSAL detected an authentication response. ${ErrorLink}`,
[ ]: "Request was blocked inside a popup because MSAL detected it was running in a popup.",
[ ]: "The iframe being monitored was closed prematurely.",
[ ]: "Silent logout not supported. Please call logoutRedirect or logoutPopup instead.",
[ ]: "No account object provided to acquireTokenSilent and no active account has been set. Please call setActiveAccount or provide an account on the request.",
[ ]: "The value given for the prompt value is not valid for silent requests - must be set to 'none' or 'no_session'.",
[ ]: "No token request found in cache.",
[ ]: "The cached token request could not be parsed.",
[ ]: "Auth Request not set. Please ensure initiateAuthRequest was called from the InteractionHandler",
[ ]: "Invalid cache type",
[ ]: "Login and token requests are not supported in non-browser environments.",
[ ]: "Database is not open!",
[ ]: "No network connectivity. Check your internet connection.",
[ ]: "Network request failed: If the browser threw a CORS error, check that the redirectUri is registered in the Azure App Portal as type 'SPA'",
[ ]: "Network request failed. Please check the network trace to determine root cause.",
[ ]: "Failed to parse network response. Check network trace.",
[ ]: "Error loading token to cache.",
[ ]: "Cryptographic Key or Keypair not found in browser storage.",
[ ]: "An authorization code must be provided (as the `code` property on the request) to this flow.",
[ ]: "An authorization code or nativeAccountId must be provided to this flow.",
[ ]: "Request cannot contain both spa code and native account id.",
[ ]: "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.",
[ ]: `Unable to acquire token from native platform. ${ErrorLink}`,
[ ]: "Timed out while attempting to establish connection to browser extension",
[ ]: "Native extension is not installed. If you think this is a mistake call the initialize function.",
[ ]: `Connection to native platform has not been established. Please install a compatible browser extension and run initialize(). ${ErrorLink}`,
[ ]: `You must call and await the initialize function before attempting to call any other MSAL API. ${ErrorLink}`,
[ ]: "The provided prompt is not supported by the native platform. This request should be routed to the web based flow.",
[ ]: "Invalid base64 encoded string.",
[ ]: "Invalid PoP token request. The request should not have both a popKid value and signPopToken set to true.",
[ ]: "Failed to build request headers object.",
[ ]: "Failed to parse response headers",
[ ]: "Failed to decrypt ear response",
[ ]: "The request timed out.",
};
/**
* Browser library error class thrown by the MSAL.js library for SPAs
*/
class BrowserAuthError extends AuthError {
constructor(errorCode, subError) {
super(errorCode, BrowserAuthErrorMessages[errorCode], subError);
Object.setPrototypeOf(this, BrowserAuthError.prototype);
this.name = "BrowserAuthError";
}
}
function createBrowserAuthError(errorCode, subError) {
return new BrowserAuthError(errorCode, subError);
}
export { BrowserAuthError, BrowserAuthErrorMessages, createBrowserAuthError };
//# sourceMappingURL=BrowserAuthError.mjs.map