@nopwdio/sdk-js
Version:
Nopwd JS SDK
40 lines (39 loc) • 1.63 kB
TypeScript
/**
* Starts a magic link authentification
*
* @param params the authentication request parameters
* @param params.email the user's email to authenticate
* @param signal a way to abord the request (clientside) if needed
*
* @returns the request expiration date (posix)
*
* @throws {AbortError} when the authentication flow has been canceled (using signal)
* @throws {MissingEmailError} when the email parameter is missing
* @throws {InvalidEmailError} when the email parameter is malformed
* @throws {QuotaError} when too many auth attempts have been made
* @throws {UnexpectedError} when an unexpected error occured
* @throws {NetworkError} when a connection error occured
*/
export declare const request: (params: {
email: string;
pkce?: boolean;
}, signal?: AbortSignal) => Promise<number>;
/**
* Verifies if the actual page has an authorization code
*
* @returns true if the page contains an authorization code, false otherwise
*/
export declare const hasCallbackCode: () => boolean;
/**
* Exchange the authorization code in the url to an access token
* The authorization code will be removed from the url
*
* @returns the access token
*
* @throws {AbortError} when the authentication flow has been canceled (using signal)
* @throws {NetworkError} when a connection error occured
* @throws {MissingCodeParameterError} when the code parameter is missing
* @throws {InvalidCodeParameterError} when the code parameter is malformed or has expired
* @throws {UnexpectedError} when an unexpected error occured
*/
export declare const handleCallbackCode: (signal?: AbortSignal) => Promise<string>;