Skip to content
Esc
navigateopen⌘Jpreview
Dashboard
On this page

supertokens-web-js/recipe/passwordless

References documentation for the supertokens-web-js/recipe/passwordless package

Classes

default

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Constructors

Constructor
new default(): default;
Returns

default

Methods

clearLoginAttemptInfo()
static clearLoginAttemptInfo(input?): Promise<void>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Clear any information about login attempts from storage

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

Promise<void>

consumeCode()
static consumeCode(input?): Promise<
  | {
  createdNewRecipeUser: boolean;
  fetchResponse: Response;
  status: "OK";
  user: User;
}
  | {
  failedCodeInputAttemptCount: number;
  fetchResponse: Response;
  maximumCodeInputAttempts: number;
  status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR";
}
  | {
  fetchResponse: Response;
  status: "RESTART_FLOW_ERROR";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_IN_UP_NOT_ALLOWED";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Log the user in using the input code or link code

Parameters
Parameter Type
input? | { options?: RecipeFunctionOptions; userContext?: any; userInputCode: string; } | { options?: RecipeFunctionOptions; userContext?: any; }
Returns

Promise< | { createdNewRecipeUser: boolean; fetchResponse: Response; status: "OK"; user: User; } | { failedCodeInputAttemptCount: number; fetchResponse: Response; maximumCodeInputAttempts: number; status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR"; } | { fetchResponse: Response; status: "RESTART_FLOW_ERROR"; } | { fetchResponse: Response; reason: string; status: "SIGN_IN_UP_NOT_ALLOWED"; }>

{status: "OK", user, createdNewRecipeUser: bool} if succesful

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

createCode()
static createCode(input): Promise<
  | {
  deviceId: string;
  fetchResponse: Response;
  flowType: PasswordlessFlowType;
  preAuthSessionId: string;
  status: "OK";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_IN_UP_NOT_ALLOWED";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Create and send a code to the user for passwordless auth

Parameters
Parameter Type
input | { email: string; options?: RecipeFunctionOptions; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; } | { options?: RecipeFunctionOptions; phoneNumber: string; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; }
Returns

Promise< | { deviceId: string; fetchResponse: Response; flowType: PasswordlessFlowType; preAuthSessionId: string; status: "OK"; } | { fetchResponse: Response; reason: string; status: "SIGN_IN_UP_NOT_ALLOWED"; }>

{status: "OK", deviceId, preAuthSessionId, flowType} If successful

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

doesEmailExist()
static doesEmailExist(input): Promise<{
  doesExist: boolean;
  fetchResponse: Response;
  status: "OK";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Check if a user with the given email exists

Parameters
Parameter Type
input { email: string; options?: RecipeFunctionOptions; userContext?: any; }
input.email string
input.options? RecipeFunctionOptions
input.userContext? any
Returns

Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK"; }>

{status: "OK", doesExist: boolean}

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

doesPhoneNumberExist()
static doesPhoneNumberExist(input): Promise<{
  doesExist: boolean;
  fetchResponse: Response;
  status: "OK";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Check if a user with the given phone number exists

Parameters
Parameter Type
input { options?: RecipeFunctionOptions; phoneNumber: string; userContext?: any; }
input.options? RecipeFunctionOptions
input.phoneNumber string
input.userContext? any
Returns

Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK"; }>

{status: "OK", doesExist: boolean}

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

getLinkCodeFromURL()
static getLinkCodeFromURL(input?): string;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Reads and returns the link code from the current URL

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

string

The hash (#) property of the current URL

getLoginAttemptInfo()
static getLoginAttemptInfo<CustomLoginAttemptInfoProperties>(input?): Promise<object & CustomLoginAttemptInfoProperties>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Get information about the current login attempt from storage

Type Parameters
Type Parameter
CustomLoginAttemptInfoProperties
Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

Promise<object & CustomLoginAttemptInfoProperties>

{deviceId, preAuthSessionId, flowType} if present, returns undefined otherwise

getPreAuthSessionIdFromURL()
static getPreAuthSessionIdFromURL(input?): string;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Reads and returns the pre auth session id from the current URL

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

string

The “preAuthSessionId” query parameter from the current URL

getTenantIdFromURL()
static getTenantIdFromURL(input?): string;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Reads and returns the tenant id from the current URL

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

string

The “tenantId” query parameter from the current location

init()
static init(config?): CreateRecipeFunction<PreAndPostAPIHookAction>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Parameters
Parameter Type
config? UserInput
Returns

CreateRecipeFunction<PreAndPostAPIHookAction>

resendCode()
static resendCode(input?): Promise<{
  fetchResponse: Response;
  status: "OK" | "RESTART_FLOW_ERROR";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Resend the code to the user

Parameters
Parameter Type
input? { options?: RecipeFunctionOptions; userContext?: any; }
input.options? RecipeFunctionOptions
input.userContext? any
Returns

Promise<{ fetchResponse: Response; status: "OK" | "RESTART_FLOW_ERROR"; }>

{status: "OK"} if succesful

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

setLoginAttemptInfo()
static setLoginAttemptInfo<CustomStateProperties>(input): Promise<void>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Set information about the current login attempt to storage

Type Parameters
Type Parameter
CustomStateProperties
Parameters
Parameter Type
input { attemptInfo: object & CustomStateProperties; userContext?: any; }
input.attemptInfo object & CustomStateProperties
input.userContext? any
Returns

Promise<void>

signOut()
static signOut(input?): Promise<void>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

Promise<void>

Variables

clearLoginAttemptInfo()

const clearLoginAttemptInfo: (input?) => Promise<void> = RecipeWrapper.clearLoginAttemptInfo;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Clear any information about login attempts from storage

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

Promise<void>


consumeCode()

const consumeCode: (input?) => Promise<
  | {
  createdNewRecipeUser: boolean;
  fetchResponse: Response;
  status: "OK";
  user: User;
}
  | {
  failedCodeInputAttemptCount: number;
  fetchResponse: Response;
  maximumCodeInputAttempts: number;
  status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR";
}
  | {
  fetchResponse: Response;
  status: "RESTART_FLOW_ERROR";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_IN_UP_NOT_ALLOWED";
}> = RecipeWrapper.consumeCode;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Log the user in using the input code or link code

Parameters

Parameter Type
input? | { options?: RecipeFunctionOptions; userContext?: any; userInputCode: string; } | { options?: RecipeFunctionOptions; userContext?: any; }

Returns

Promise< | { createdNewRecipeUser: boolean; fetchResponse: Response; status: "OK"; user: User; } | { failedCodeInputAttemptCount: number; fetchResponse: Response; maximumCodeInputAttempts: number; status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR"; } | { fetchResponse: Response; status: "RESTART_FLOW_ERROR"; } | { fetchResponse: Response; reason: string; status: "SIGN_IN_UP_NOT_ALLOWED"; }>

{status: "OK", user, createdNewRecipeUser: bool} if succesful

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


createCode()

const createCode: (input) => Promise<
  | {
  deviceId: string;
  fetchResponse: Response;
  flowType: PasswordlessFlowType;
  preAuthSessionId: string;
  status: "OK";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_IN_UP_NOT_ALLOWED";
}> = RecipeWrapper.createCode;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Create and send a code to the user for passwordless auth

Parameters

Parameter Type
input | { email: string; options?: RecipeFunctionOptions; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; } | { options?: RecipeFunctionOptions; phoneNumber: string; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; }

Returns

Promise< | { deviceId: string; fetchResponse: Response; flowType: PasswordlessFlowType; preAuthSessionId: string; status: "OK"; } | { fetchResponse: Response; reason: string; status: "SIGN_IN_UP_NOT_ALLOWED"; }>

{status: "OK", deviceId, preAuthSessionId, flowType} If successful

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


doesEmailExist()

const doesEmailExist: (input) => Promise<{
  doesExist: boolean;
  fetchResponse: Response;
  status: "OK";
}> = RecipeWrapper.doesEmailExist;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Check if a user with the given email exists

Parameters

Parameter Type
input { email: string; options?: RecipeFunctionOptions; userContext?: any; }
input.email string
input.options? RecipeFunctionOptions
input.userContext? any

Returns

Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK"; }>

{status: "OK", doesExist: boolean}

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


doesPhoneNumberExist()

const doesPhoneNumberExist: (input) => Promise<{
  doesExist: boolean;
  fetchResponse: Response;
  status: "OK";
}> = RecipeWrapper.doesPhoneNumberExist;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Check if a user with the given phone number exists

Parameters

Parameter Type
input { options?: RecipeFunctionOptions; phoneNumber: string; userContext?: any; }
input.options? RecipeFunctionOptions
input.phoneNumber string
input.userContext? any

Returns

Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK"; }>

{status: "OK", doesExist: boolean}

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


getLinkCodeFromURL()

const getLinkCodeFromURL: (input?) => string = RecipeWrapper.getLinkCodeFromURL;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Reads and returns the link code from the current URL

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

string

The hash (#) property of the current URL


getLoginAttemptInfo()

const getLoginAttemptInfo: <CustomLoginAttemptInfoProperties>(input?) => Promise<object & CustomLoginAttemptInfoProperties> = RecipeWrapper.getLoginAttemptInfo;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Get information about the current login attempt from storage

Type Parameters

Type Parameter
CustomLoginAttemptInfoProperties

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

Promise<object & CustomLoginAttemptInfoProperties>

{deviceId, preAuthSessionId, flowType} if present, returns undefined otherwise


getPreAuthSessionIdFromURL()

const getPreAuthSessionIdFromURL: (input?) => string = RecipeWrapper.getPreAuthSessionIdFromURL;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Reads and returns the pre auth session id from the current URL

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

string

The “preAuthSessionId” query parameter from the current URL


getTenantIdFromURL()

const getTenantIdFromURL: (input?) => string = RecipeWrapper.getTenantIdFromURL;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Reads and returns the tenant id from the current URL

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

string

The “tenantId” query parameter from the current location


init()

const init: (config?) => CreateRecipeFunction<PreAndPostAPIHookAction> = RecipeWrapper.init;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Parameters

Parameter Type
config? UserInput

Returns

CreateRecipeFunction<PreAndPostAPIHookAction>


resendCode()

const resendCode: (input?) => Promise<{
  fetchResponse: Response;
  status: "OK" | "RESTART_FLOW_ERROR";
}> = RecipeWrapper.resendCode;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Resend the code to the user

Parameters

Parameter Type
input? { options?: RecipeFunctionOptions; userContext?: any; }
input.options? RecipeFunctionOptions
input.userContext? any

Returns

Promise<{ fetchResponse: Response; status: "OK" | "RESTART_FLOW_ERROR"; }>

{status: "OK"} if succesful

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


setLoginAttemptInfo()

const setLoginAttemptInfo: <CustomStateProperties>(input) => Promise<void> = RecipeWrapper.setLoginAttemptInfo;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Set information about the current login attempt to storage

Type Parameters

Type Parameter
CustomStateProperties

Parameters

Parameter Type
input { attemptInfo: object & CustomStateProperties; userContext?: any; }
input.attemptInfo object & CustomStateProperties
input.userContext? any

Returns

Promise<void>


signOut()

const signOut: (input?) => Promise<void> = RecipeWrapper.signOut;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/passwordless/index.ts

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

Promise<void>

References

PostAPIHookContext

Re-exports PostAPIHookContext


PreAndPostAPIHookAction

Re-exports PreAndPostAPIHookAction


PreAPIHookContext

Re-exports PreAPIHookContext


RecipeFunctionOptions

Re-exports RecipeFunctionOptions


RecipeInterface

Re-exports RecipeInterface


UserInput

Re-exports UserInput

API reference

API schema and response details