Skip to content
Esc
navigateopen⌘Jpreview
Dashboard
On this page

supertokens-web-js/recipe/totp

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

Classes

default

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

Constructors

Constructor
new default(): default;
Returns

default

Methods

createDevice()
static createDevice(input?): Promise<
  | {
  deviceName: string;
  fetchResponse: Response;
  qrCodeString: string;
  secret: string;
  status: "OK";
}
  | {
  fetchResponse: Response;
  status: "DEVICE_ALREADY_EXISTS_ERROR";
}>;

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

Creates a new unverified device.

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

Promise< | { deviceName: string; fetchResponse: Response; qrCodeString: string; secret: string; status: "OK"; } | { fetchResponse: Response; status: "DEVICE_ALREADY_EXISTS_ERROR"; }>

{ status: "OK", ...} if successful along a description of the created device (secret, etc.)

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

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

Parameters
Parameter Type
config? UserInput
Returns

CreateRecipeFunction<PreAndPostAPIHookAction>

listDevices()
static listDevices(input?): Promise<{
  devices: object[];
  fetchResponse: Response;
  status: "OK";
}>;

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

Lists all TOTP devices of the current user

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

Promise<{ devices: object[]; fetchResponse: Response; status: "OK"; }>

{ status: "OK", ...} if successful with a list of devices in the devices prop

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

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

Removes a TOTP device

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

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

{ status: "OK", ...} if successful

verifyCode()
static verifyCode(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}>;

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

Verifies that the totp code belongs to a verified device of the current user

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

Promise< | { fetchResponse: Response; status: "OK"; } | { currentNumberOfFailedAttempts: number; fetchResponse: Response; maxNumberOfFailedAttempts: number; status: "INVALID_TOTP_ERROR"; } | { fetchResponse: Response; retryAfterMs: number; status: "LIMIT_REACHED_ERROR"; }>

{ status: "OK", ...} if successful

verifyDevice()
static verifyDevice(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  wasAlreadyVerified: boolean;
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  status: "UNKNOWN_DEVICE_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}>;

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

Verifies the totp device for the current user

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

Promise< | { fetchResponse: Response; status: "OK"; wasAlreadyVerified: boolean; } | { currentNumberOfFailedAttempts: number; fetchResponse: Response; maxNumberOfFailedAttempts: number; status: "INVALID_TOTP_ERROR"; } | { fetchResponse: Response; status: "UNKNOWN_DEVICE_ERROR"; } | { fetchResponse: Response; retryAfterMs: number; status: "LIMIT_REACHED_ERROR"; }>

{ status: "OK", ...} if successful

Variables

createDevice()

const createDevice: (input?) => Promise<
  | {
  deviceName: string;
  fetchResponse: Response;
  qrCodeString: string;
  secret: string;
  status: "OK";
}
  | {
  fetchResponse: Response;
  status: "DEVICE_ALREADY_EXISTS_ERROR";
}> = RecipeWrapper.createDevice;

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

Creates a new unverified device.

Parameters

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

Returns

Promise< | { deviceName: string; fetchResponse: Response; qrCodeString: string; secret: string; status: "OK"; } | { fetchResponse: Response; status: "DEVICE_ALREADY_EXISTS_ERROR"; }>

{ status: "OK", ...} if successful along a description of the created device (secret, etc.)


init()

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

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

Parameters

Parameter Type
config? UserInput

Returns

CreateRecipeFunction<PreAndPostAPIHookAction>


listDevices()

const listDevices: (input?) => Promise<{
  devices: object[];
  fetchResponse: Response;
  status: "OK";
}> = RecipeWrapper.listDevices;

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

Lists all TOTP devices of the current user

Parameters

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

Returns

Promise<{ devices: object[]; fetchResponse: Response; status: "OK"; }>

{ status: "OK", ...} if successful with a list of devices in the devices prop


removeDevice()

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

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

Removes a TOTP device

Parameters

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

Returns

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

{ status: "OK", ...} if successful


verifyCode()

const verifyCode: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}> = RecipeWrapper.verifyCode;

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

Verifies that the totp code belongs to a verified device of the current user

Parameters

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

Returns

Promise< | { fetchResponse: Response; status: "OK"; } | { currentNumberOfFailedAttempts: number; fetchResponse: Response; maxNumberOfFailedAttempts: number; status: "INVALID_TOTP_ERROR"; } | { fetchResponse: Response; retryAfterMs: number; status: "LIMIT_REACHED_ERROR"; }>

{ status: "OK", ...} if successful


verifyDevice()

const verifyDevice: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  wasAlreadyVerified: boolean;
}
  | {
  currentNumberOfFailedAttempts: number;
  fetchResponse: Response;
  maxNumberOfFailedAttempts: number;
  status: "INVALID_TOTP_ERROR";
}
  | {
  fetchResponse: Response;
  status: "UNKNOWN_DEVICE_ERROR";
}
  | {
  fetchResponse: Response;
  retryAfterMs: number;
  status: "LIMIT_REACHED_ERROR";
}> = RecipeWrapper.verifyDevice;

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

Verifies the totp device for the current user

Parameters

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

Returns

Promise< | { fetchResponse: Response; status: "OK"; wasAlreadyVerified: boolean; } | { currentNumberOfFailedAttempts: number; fetchResponse: Response; maxNumberOfFailedAttempts: number; status: "INVALID_TOTP_ERROR"; } | { fetchResponse: Response; status: "UNKNOWN_DEVICE_ERROR"; } | { fetchResponse: Response; retryAfterMs: number; status: "LIMIT_REACHED_ERROR"; }>

{ status: "OK", ...} if successful

References

DeviceInfo

Re-exports DeviceInfo


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