Skip to main content

@supertokens-plugins/captcha-react

Classes

Captcha

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:32

Constructors

Constructor
new Captcha(): Captcha;
Returns

Captcha

Properties

PropertyModifierTypeDefault valueDefined in
statepublic"uninitialised" | "initialised" | "loaded" | "rendered""uninitialised"supertokens-plugins/packages/captcha-react/src/captcha.ts:34

Methods

addEventListener()
addEventListener<T>(event: T, listener: CaptchaEventListener<T>): void;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:188

Type Parameters
Type Parameter
T extends "token-submitted" | "render-failed" | "get-token-failed"
Parameters
ParameterType
eventT
listenerCaptchaEventListener<T>
Returns

void

getInputContainer()
getInputContainer(): Promise<HTMLDivElement>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:66

Returns

Promise<HTMLDivElement>

getToken()
getToken(): Promise<string>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:151

Returns

Promise<string>

init()
init(config: SuperTokensPluginCaptchaConfig): void;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:44

Parameters
Returns

void

load()
load(): Promise<void>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:85

Returns

Promise<void>

removeEventListener()
removeEventListener<T>(event: T, listener: CaptchaEventListener<T>): void;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:192

Type Parameters
Type Parameter
T extends "token-submitted" | "render-failed" | "get-token-failed"
Parameters
ParameterType
eventT
listenerCaptchaEventListener<T>
Returns

void

render()
render(onSubmit?: (token: string) => void, onError?: (error: Error) => void): Promise<void>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:120

Renders the captcha provider. The function accepts two callbacks that enable the following behaviors:

  • Pass callbacks that update some UI state and move ahead with the rendering process. Used when you render the captcha from the start.
  • Wrap the call in a promise and pass resolve/reject as callbacks. This way you can block your function and wait for the token value. This is used when the captcha is rendered after the user has submitted the authentication form.
Parameters
ParameterTypeDescription
onSubmit?(token: string) => voidCalled when the captcha token has been generated by the provider.
onError?(error: Error) => voidCalled when an error occurs during the captcha rendering process.
Returns

Promise<void>

ReCAPTCHAv2Provider

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:213

Implements

Constructors

Constructor
new ReCAPTCHAv2Provider(config: Parameters): ReCAPTCHAv2Provider;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:216

Parameters
ParameterType
configParameters
Returns

ReCAPTCHAv2Provider

Methods

getToken()
getToken(): Promise<string>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:275

Returns

Promise<string>

Implementation of

CaptchaProvider.getToken

load()
load(): Promise<void>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:222

Returns

Promise<void>

Implementation of

CaptchaProvider.load

render()
render(
containerElement: HTMLDivElement,
onSubmit: (token: string) => void,
onError: (error: Error) => void): void;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:239

Parameters
ParameterType
containerElementHTMLDivElement
onSubmit(token: string) => void
onError(error: Error) => void
Returns

void

Implementation of

CaptchaProvider.render

setToken()
setToken(token: string): void;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:218

Parameters
ParameterType
tokenstring
Returns

void

ReCAPTCHAv3Provider

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:283

Implements

Constructors

Constructor
new ReCAPTCHAv3Provider(config: ReCAPTCHAv3Config): ReCAPTCHAv3Provider;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:284

Parameters
ParameterType
configReCAPTCHAv3Config
Returns

ReCAPTCHAv3Provider

Methods

getToken()
getToken(): Promise<string>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:294

Returns

Promise<string>

Implementation of

CaptchaProvider.getToken

load()
load(): Promise<void>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:286

Returns

Promise<void>

Implementation of

CaptchaProvider.load

TurnstileProvider

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:312

Implements

Constructors

Constructor
new TurnstileProvider(config: RenderParameters): TurnstileProvider;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:315

Parameters
ParameterType
configRenderParameters
Returns

TurnstileProvider

Methods

getToken()
getToken(): Promise<string>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:395

Returns

Promise<string>

Implementation of

CaptchaProvider.getToken

load()
load(): Promise<void>;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:321

Returns

Promise<void>

Implementation of

CaptchaProvider.load

render()
render(
container: HTMLDivElement,
onSubmit: (token: string) => void,
onError: (error: Error) => void): void;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:338

Parameters
ParameterType
containerHTMLDivElement
onSubmit(token: string) => void
onError(error: Error) => void
Returns

void

Implementation of

CaptchaProvider.render

setToken()
setToken(token: string): void;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:317

Parameters
ParameterType
tokenstring
Returns

void

Interfaces

CaptchaProvider

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:17

Properties

PropertyTypeDefined in
getToken() => Promise<string>supertokens-plugins/packages/captcha-react/src/types.ts:20
load(onLoad?: () => void) => Promise<void>supertokens-plugins/packages/captcha-react/src/types.ts:18
render?(container: HTMLDivElement, onSubmit: (token: string) => void, onError: (error: Error) => void) => voidsupertokens-plugins/packages/captcha-react/src/types.ts:19

Type Aliases

CaptchInputContainerProps

type CaptchInputContainerProps = {
form: | "EmailPasswordSignInForm"
| "EmailPasswordSignUpForm"
| "EmailPasswordResetPasswordEmail"
| "EmailPasswordSubmitNewPassword"
| "PasswordlessEmailForm"
| "PasswordlessPhoneForm"
| "PasswordlessEmailOrPhoneForm"
| "PasswordlessEPComboEmailForm"
| "PasswordlessEPComboEmailOrPhoneForm"
| "PasswordlessUserInputForm";
} & React.HTMLAttributes<HTMLDivElement>;

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:82

Type Declaration

NameTypeDefined in
form| "EmailPasswordSignInForm" | "EmailPasswordSignUpForm" | "EmailPasswordResetPasswordEmail" | "EmailPasswordSubmitNewPassword" | "PasswordlessEmailForm" | "PasswordlessPhoneForm" | "PasswordlessEmailOrPhoneForm" | "PasswordlessEPComboEmailForm" | "PasswordlessEPComboEmailOrPhoneForm" | "PasswordlessUserInputForm"supertokens-plugins/packages/captcha-react/src/types.ts:83

EmailPasswordCaptchaPreAndPostAPIHookActions

type EmailPasswordCaptchaPreAndPostAPIHookActions = Extract<BaseFormSection, 
| "EMAIL_PASSWORD_SIGN_UP"
| "EMAIL_PASSWORD_SIGN_IN"
| "SUBMIT_NEW_PASSWORD"
| "SEND_RESET_PASSWORD_EMAIL">;

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:50

PasswordlessCaptchaPreAndPostAPIHookActions

type PasswordlessCaptchaPreAndPostAPIHookActions = Extract<BaseFormSection, "PASSWORDLESS_CONSUME_CODE" | "PASSWORDLESS_CREATE_CODE">;

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:66

ReCAPTCHAv2Config

type ReCAPTCHAv2Config = ReCaptchaV2.Parameters;

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:23

ReCAPTCHAv3Config

type ReCAPTCHAv3Config = {
action?: string;
sitekey: string;
};

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:24

Properties

PropertyTypeDescriptionDefined in
action?stringThe name of the action. Actions may only contain alphanumeric characters and slashes, and must not be user-specific.supertokens-plugins/packages/captcha-react/src/types.ts:32
sitekeystringYour sitekey.supertokens-plugins/packages/captcha-react/src/types.ts:28

SuperTokensPluginCaptchaConfig

type SuperTokensPluginCaptchaConfig = CaptchaConfig & {
InputContainer?: React.ForwardRefExoticComponent<CaptchInputContainerProps & React.RefAttributes<HTMLDivElement>>;
inputContainerId?: | string
| () => Promise<string>;
};

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:77

Type Declaration

NameTypeDefined in
InputContainer?React.ForwardRefExoticComponent<CaptchInputContainerProps & React.RefAttributes<HTMLDivElement>>supertokens-plugins/packages/captcha-react/src/types.ts:78
inputContainerId?| string | () => Promise<string>supertokens-plugins/packages/captcha-react/src/types.ts:79

TurnstileConfig

type TurnstileConfig = Turnstile.RenderParameters;

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:34

Variables

captcha

const captcha: Captcha;

Defined in: supertokens-plugins/packages/captcha-react/src/captcha.ts:440

CAPTCHA_INPUT_CONTAINER_ID

const CAPTCHA_INPUT_CONTAINER_ID: "supertokens-captcha-container" = "supertokens-captcha-container";

Defined in: supertokens-plugins/packages/captcha-react/src/constants.ts:2

CAPTCHA_MODAL_INPUT_CONTAINER_ID

const CAPTCHA_MODAL_INPUT_CONTAINER_ID: "supertokens-captcha-modal-container" = "supertokens-captcha-modal-container";

Defined in: supertokens-plugins/packages/captcha-react/src/constants.ts:3

CaptchaInputContainer

const CaptchaInputContainer: ForwardRefExoticComponent<{
form: | "EmailPasswordSignInForm"
| "EmailPasswordSignUpForm"
| "EmailPasswordResetPasswordEmail"
| "EmailPasswordSubmitNewPassword"
| "PasswordlessEmailForm"
| "PasswordlessPhoneForm"
| "PasswordlessEmailOrPhoneForm"
| "PasswordlessEPComboEmailForm"
| "PasswordlessEPComboEmailOrPhoneForm"
| "PasswordlessUserInputForm";
} & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>;

Defined in: supertokens-plugins/packages/captcha-react/src/components/CaptchaInputContainer.tsx:10

default

default: {
init: (config: SuperTokensPluginCaptchaConfig) => SuperTokensPlugin;
};

Defined in: supertokens-plugins/packages/captcha-react/src/index.ts:6

Type Declaration

PLUGIN_ID

const PLUGIN_ID: "supertokens-plugin-captcha" = "supertokens-plugin-captcha";

Defined in: supertokens-plugins/packages/captcha-react/src/constants.ts:1

Functions

EmailPasswordResetPasswordEmail()

function EmailPasswordResetPasswordEmail(): EmailPasswordComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:31

Returns

EmailPasswordComponentOverrideMap

EmailPasswordSignInForm()

function EmailPasswordSignInForm(): EmailPasswordComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:6

Returns

EmailPasswordComponentOverrideMap

EmailPasswordSignUpForm()

function EmailPasswordSignUpForm(): EmailPasswordComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:18

Returns

EmailPasswordComponentOverrideMap

EmailPasswordSubmitNewPassword()

function EmailPasswordSubmitNewPassword(): EmailPasswordComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:48

Returns

EmailPasswordComponentOverrideMap

getPluginConfig()

function getPluginConfig(): SuperTokensPluginCaptchaConfig;

Defined in: supertokens-plugins/packages/captcha-react/src/config.ts:34

Returns

SuperTokensPluginCaptchaConfig

init()

function init(config: SuperTokensPluginCaptchaConfig): SuperTokensPlugin;

Defined in: supertokens-plugins/packages/captcha-react/src/plugin.ts:16

Parameters

Returns

SuperTokensPlugin

isEmailPasswordCaptchaPreAndPostAPIHookAction()

function isEmailPasswordCaptchaPreAndPostAPIHookAction(action: string): action is any;

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:55

Parameters

ParameterType
actionstring

Returns

action is any

isPasswordlessCaptchaPreAndPostAPIHookAction()

function isPasswordlessCaptchaPreAndPostAPIHookAction(action: string): action is any;

Defined in: supertokens-plugins/packages/captcha-react/src/types.ts:71

Parameters

ParameterType
actionstring

Returns

action is any

PasswordlessEmailForm()

function PasswordlessEmailForm(): PasswordlessComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:64

Returns

PasswordlessComponentOverrideMap

PasswordlessEmailOrPhoneForm()

function PasswordlessEmailOrPhoneForm(): PasswordlessComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:89

Returns

PasswordlessComponentOverrideMap

PasswordlessEPComboEmailForm()

function PasswordlessEPComboEmailForm(): PasswordlessComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:106

Returns

PasswordlessComponentOverrideMap

PasswordlessEPComboEmailOrPhoneForm()

function PasswordlessEPComboEmailOrPhoneForm(): PasswordlessComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:123

Returns

PasswordlessComponentOverrideMap

PasswordlessPhoneForm()

function PasswordlessPhoneForm(): PasswordlessComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:76

Returns

PasswordlessComponentOverrideMap

PasswordlessUserInputCodeForm()

function PasswordlessUserInputCodeForm(): PasswordlessComponentOverrideMap;

Defined in: supertokens-plugins/packages/captcha-react/src/components/ComponentOverrides.tsx:140

Returns

PasswordlessComponentOverrideMap

setPluginConfig()

function setPluginConfig(config: SuperTokensPluginCaptchaConfig): void;

Defined in: supertokens-plugins/packages/captcha-react/src/config.ts:8

Parameters

Returns

void

useCaptcha()

function useCaptcha(onError?: (error: string) => void): {
containerId: | string
| () => Promise<string>;
load: (configOverride: Partial<SuperTokensPluginCaptchaConfig>) => Promise<boolean>;
render: () => Promise<void>;
state: CaptchaState;
};

Defined in: supertokens-plugins/packages/captcha-react/src/hooks/useCaptcha.ts:8

Parameters

ParameterType
onError?(error: string) => void

Returns

{
containerId: | string
| () => Promise<string>;
load: (configOverride: Partial<SuperTokensPluginCaptchaConfig>) => Promise<boolean>;
render: () => Promise<void>;
state: CaptchaState;
}

useCaptchaInputContainer()

function useCaptchaInputContainer(): ForwardRefExoticComponent<{
form: | "EmailPasswordSignInForm"
| "EmailPasswordSignUpForm"
| "EmailPasswordResetPasswordEmail"
| "EmailPasswordSubmitNewPassword"
| "PasswordlessEmailForm"
| "PasswordlessPhoneForm"
| "PasswordlessEmailOrPhoneForm"
| "PasswordlessEPComboEmailForm"
| "PasswordlessEPComboEmailOrPhoneForm"
| "PasswordlessUserInputForm";
} & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>;

Defined in: supertokens-plugins/packages/captcha-react/src/hooks/useCaptchaInputContainer.ts:6

Returns

ForwardRefExoticComponent<{ form: | "EmailPasswordSignInForm" | "EmailPasswordSignUpForm" | "EmailPasswordResetPasswordEmail" | "EmailPasswordSubmitNewPassword" | "PasswordlessEmailForm" | "PasswordlessPhoneForm" | "PasswordlessEmailOrPhoneForm" | "PasswordlessEPComboEmailForm" | "PasswordlessEPComboEmailOrPhoneForm" | "PasswordlessUserInputForm"; } & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>

validatePublicConfig()

function validatePublicConfig(config: SuperTokensPublicConfig): void;

Defined in: supertokens-plugins/packages/captcha-react/src/config.ts:41

Parameters

ParameterType
configSuperTokensPublicConfig

Returns

void