@auth0/auth0-spa-js
Version:
Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE
156 lines (155 loc) • 5.04 kB
TypeScript
/**
* MFA requirements from an mfa_required error response
*
* @category Errors
*/
export interface MfaRequirements {
/** Required enrollment types */
enroll?: Array<{
type: string;
}>;
/** Required challenge types */
challenge?: Array<{
type: string;
}>;
}
/**
* Thrown when network requests to the Auth server fail.
*
* @category Errors
*/
export declare class GenericError extends Error {
error: string;
error_description: string;
data?: Record<string, any> | undefined;
/**
* @param error - The `error` code from the server response.
* @param error_description - The `error_description` from the server response.
* @param data - Any other fields from the server's error response (for example `auth_session`).
*/
constructor(error: string, error_description: string, data?: Record<string, any> | undefined);
static fromPayload({ error, error_description }: {
error: string;
error_description: string;
}): GenericError;
}
/**
* Thrown at construction time for an invalid option combination (e.g.
* `refreshTokenMode: 'online'` without `useDpop: true`). The `suggestion` names the fix.
*
* @category Errors
*/
export declare class InvalidConfigurationError extends GenericError {
suggestion: string;
constructor(message: string, suggestion: string);
}
/**
* Thrown when handling the redirect callback fails, will be one of Auth0's
* Authentication API's Standard Error Responses: https://auth0.com/docs/api/authentication?javascript#standard-error-responses
*
* @category Errors
*/
export declare class AuthenticationError extends GenericError {
state: string;
appState: any;
constructor(error: string, error_description: string, state: string, appState?: any);
}
/**
* Thrown when handling the redirect callback for the connect flow fails, will be one of Auth0's
* Authentication API's Standard Error Responses: https://auth0.com/docs/api/authentication?javascript#standard-error-responses
*
* @category Errors
*/
export declare class ConnectError extends GenericError {
connection: string;
state: string;
appState: any;
constructor(error: string, error_description: string, connection: string, state: string, appState?: any);
}
/**
* Thrown when silent auth times out (usually due to a configuration issue) or
* when network requests to the Auth server timeout.
*
* @category Errors
*/
export declare class TimeoutError extends GenericError {
constructor();
}
/**
* Error thrown when the login popup times out (if the user does not complete auth)
*
* @category Errors
*/
export declare class PopupTimeoutError extends TimeoutError {
popup: Window;
constructor(popup: Window);
}
/**
* Error thrown when the login popup is closed before auth completes.
*
* @category Errors
*/
export declare class PopupCancelledError extends GenericError {
popup: Window;
constructor(popup: Window);
}
/**
* Error thrown when a popup cannot be opened (`window.open` returned `null`).
*
* @category Errors
*/
export declare class PopupOpenError extends GenericError {
constructor();
}
/**
* Error thrown when the token exchange results in a `mfa_required` error
*
* @category Errors
*/
export declare class MfaRequiredError extends GenericError {
mfa_token: string;
mfa_requirements: MfaRequirements;
constructor(error: string, error_description: string, mfa_token: string, mfa_requirements: MfaRequirements);
}
/**
* Thrown by `signup()` when the server requires identifier verification before
* passkey creation. Catch this error, collect OTP codes for each identifier in
* `verificationRequired`, then call `passkey.continueSignup(codes)` to complete
* the flow. The SDK retains the auth session internally — you do not need to
* pass it yourself.
*
* @category Errors
*/
export declare class PasskeyVerificationRequiredError extends GenericError {
readonly verificationRequired: Array<'email' | 'phone'>;
constructor(verificationRequired: Array<'email' | 'phone'>);
}
/**
* Error thrown when there is no refresh token to use
*
* @category Errors
*/
export declare class MissingRefreshTokenError extends GenericError {
audience: string;
scope: string;
constructor(audience: string, scope: string);
}
/**
* Error thrown when there are missing scopes after refreshing a token
*
* @category Errors
*/
export declare class MissingScopesError extends GenericError {
audience: string;
scope: string;
constructor(audience: string, scope: string);
}
/**
* Error thrown when the wrong DPoP nonce is used and a potential subsequent retry wasn't able to fix it.
*
* @category Errors
*/
export declare class UseDpopNonceError extends GenericError {
newDpopNonce: string | undefined;
constructor(newDpopNonce: string | undefined);
}