@azure/msal-common
Version:
Microsoft Authentication Library for js
151 lines (148 loc) • 8.5 kB
JavaScript
/*! @azure/msal-common v15.9.0 2025-07-23 */
'use strict';
import { AuthError } from './AuthError.mjs';
import { invalidRequestMethodForEAR, invalidAuthorizePostBodyParameters, authorityMismatch, cannotAllowPlatformBroker, cannotSetOIDCOptions, invalidAuthenticationHeader, missingNonceAuthenticationHeader, missingSshKid, missingSshJwk, untrustedAuthority, invalidAuthorityMetadata, invalidCloudDiscoveryMetadata, pkceParamsMissing, invalidCodeChallengeMethod, logoutRequestEmpty, tokenRequestEmpty, invalidClaims, emptyInputScopesError, urlEmptyError, urlParseError, authorityUriInsecure, claimsRequestParsingError, redirectUriEmpty } from './ClientConfigurationErrorCodes.mjs';
import * as ClientConfigurationErrorCodes from './ClientConfigurationErrorCodes.mjs';
export { ClientConfigurationErrorCodes };
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const ClientConfigurationErrorMessages = {
[]: "A redirect URI is required for all calls, and none has been set.",
[]: "Could not parse the given claims request object.",
[]: "Authority URIs must use https. Please see here for valid authority configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options",
[]: "URL could not be parsed into appropriate segments.",
[]: "URL was empty or null.",
[]: "Scopes cannot be passed as null, undefined or empty array because they are required to obtain an access token.",
[]: "Given claims parameter must be a stringified JSON object.",
[]: "Token request was empty and not found in cache.",
[]: "The logout request was null or undefined.",
[]: 'code_challenge_method passed is invalid. Valid values are "plain" and "S256".',
[]: "Both params: code_challenge and code_challenge_method are to be passed if to be sent in the request",
[]: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields",
[]: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields.",
[]: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.",
[]: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme.",
[]: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme.",
[]: "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce.",
[]: "Invalid authentication header provided",
[]: "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
[]: "Cannot set allowPlatformBroker parameter to true when not in AAD protocol mode.",
[]: "Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority.",
[]: "Invalid authorize post body parameters provided. If you are using authorizePostBodyParameters, the request method must be POST. Please check the request method and parameters.",
[]: "Invalid request method for EAR protocol mode. The request method cannot be GET when using EAR protocol mode. Please change the request method to POST.",
};
/**
* ClientConfigurationErrorMessage class containing string constants used by error codes and messages.
* @deprecated Use ClientConfigurationErrorCodes instead
*/
const ClientConfigurationErrorMessage = {
redirectUriNotSet: {
code: redirectUriEmpty,
desc: ClientConfigurationErrorMessages[redirectUriEmpty],
},
claimsRequestParsingError: {
code: claimsRequestParsingError,
desc: ClientConfigurationErrorMessages[claimsRequestParsingError],
},
authorityUriInsecure: {
code: authorityUriInsecure,
desc: ClientConfigurationErrorMessages[authorityUriInsecure],
},
urlParseError: {
code: urlParseError,
desc: ClientConfigurationErrorMessages[urlParseError],
},
urlEmptyError: {
code: urlEmptyError,
desc: ClientConfigurationErrorMessages[urlEmptyError],
},
emptyScopesError: {
code: emptyInputScopesError,
desc: ClientConfigurationErrorMessages[emptyInputScopesError],
},
invalidClaimsRequest: {
code: invalidClaims,
desc: ClientConfigurationErrorMessages[invalidClaims],
},
tokenRequestEmptyError: {
code: tokenRequestEmpty,
desc: ClientConfigurationErrorMessages[tokenRequestEmpty],
},
logoutRequestEmptyError: {
code: logoutRequestEmpty,
desc: ClientConfigurationErrorMessages[logoutRequestEmpty],
},
invalidCodeChallengeMethod: {
code: invalidCodeChallengeMethod,
desc: ClientConfigurationErrorMessages[invalidCodeChallengeMethod],
},
invalidCodeChallengeParams: {
code: pkceParamsMissing,
desc: ClientConfigurationErrorMessages[pkceParamsMissing],
},
invalidCloudDiscoveryMetadata: {
code: invalidCloudDiscoveryMetadata,
desc: ClientConfigurationErrorMessages[invalidCloudDiscoveryMetadata],
},
invalidAuthorityMetadata: {
code: invalidAuthorityMetadata,
desc: ClientConfigurationErrorMessages[invalidAuthorityMetadata],
},
untrustedAuthority: {
code: untrustedAuthority,
desc: ClientConfigurationErrorMessages[untrustedAuthority],
},
missingSshJwk: {
code: missingSshJwk,
desc: ClientConfigurationErrorMessages[missingSshJwk],
},
missingSshKid: {
code: missingSshKid,
desc: ClientConfigurationErrorMessages[missingSshKid],
},
missingNonceAuthenticationHeader: {
code: missingNonceAuthenticationHeader,
desc: ClientConfigurationErrorMessages[missingNonceAuthenticationHeader],
},
invalidAuthenticationHeader: {
code: invalidAuthenticationHeader,
desc: ClientConfigurationErrorMessages[invalidAuthenticationHeader],
},
cannotSetOIDCOptions: {
code: cannotSetOIDCOptions,
desc: ClientConfigurationErrorMessages[cannotSetOIDCOptions],
},
cannotAllowPlatformBroker: {
code: cannotAllowPlatformBroker,
desc: ClientConfigurationErrorMessages[cannotAllowPlatformBroker],
},
authorityMismatch: {
code: authorityMismatch,
desc: ClientConfigurationErrorMessages[authorityMismatch],
},
invalidAuthorizePostBodyParameters: {
code: invalidAuthorizePostBodyParameters,
desc: ClientConfigurationErrorMessages[invalidAuthorizePostBodyParameters],
},
invalidRequestMethodForEAR: {
code: invalidRequestMethodForEAR,
desc: ClientConfigurationErrorMessages[invalidRequestMethodForEAR],
},
};
/**
* Error thrown when there is an error in configuration of the MSAL.js library.
*/
class ClientConfigurationError extends AuthError {
constructor(errorCode) {
super(errorCode, ClientConfigurationErrorMessages[errorCode]);
this.name = "ClientConfigurationError";
Object.setPrototypeOf(this, ClientConfigurationError.prototype);
}
}
function createClientConfigurationError(errorCode) {
return new ClientConfigurationError(errorCode);
}
export { ClientConfigurationError, ClientConfigurationErrorMessage, ClientConfigurationErrorMessages, createClientConfigurationError };
//# sourceMappingURL=ClientConfigurationError.mjs.map