Skip to main content

friendly-captcha-sdk package

A library for integrating Friendly Captcha into your website. This SDK allows you to create captcha widgets, respond to their changes, and interact with them programmatically.

Classes

ClassDescription
FriendlyCaptchaSDK

Main entry point for V2 of the Friendly Captcha SDK. This class keeps track of widgets and allows you to create widgets programmatically.

Generally there should only be one instance of this SDK in your website.

WidgetHandle

This provides an API stub that provides the end-user JS API for a widget.

This class is only instantiated by the SDK - do not create a handle yourself.

Interfaces

InterfaceDescription
CreateWidgetOptionsOptions when creating a widget programmatically.
FRCEventMapA DOM event map for all events that can be dispatched by a widget.
FRCWidgetCompleteEventDataPayload of the "frc:widget.complete" event.
FRCWidgetErrorEventDataPayload of the "frc:widget.error" event.
FRCWidgetExpireEventDataPayload of the "frc:widget.expire" event.
FRCWidgetResetEventDataPayload of the "frc:widget.reset" event.
FRCWidgetStateChangeEventDataPayload of the "frc:widget.statechange" event.
FriendlyCaptchaSDKOptionsOptions when creating a new SDK instance.
WidgetErrorData

Variables

VariableDescription
FRCWidgetCompleteEventName"frc:widget.complete"
FRCWidgetErrorEventName"frc:widget.error"
FRCWidgetExpireEventName"frc:widget.expire"
FRCWidgetResetEventName"frc:widget.reset"
FRCWidgetStateChangeEventName"frc:widget.statechange"

Type Aliases

Type AliasDescription
FRCEventDataPayloads of any of the events that can be dispatched by a widget.
FRCEventNameNames of any of the events that can be dispatched by a widget.
FRCWidgetCompleteEventEvent that gets dispatched when the widget is completed. This happens when the user's browser has succesfully passed the captcha challenge.
FRCWidgetStateChangeEventEvent that gets dispatched when the widget enters a new state.
FRCWidgetWidgetErrorEventEvent that gets dispatched when something goes wrong in the widget.
FRCWidgetWidgetExpireEventEvent that gets dispatched when the widget expires. This happens when the user takes too long to submit the captcha after it is solved.
FRCWidgetWidgetResetEventEvent that gets dispatched when something goes wrong in the widget.
SentinelResponseResponse values used in the hidden input field when no valid solution is present, these tell you something about the state of the widget.
StartMode

The start mode of the widget.

* "auto": the widget gets activated as soon as it is created. * "focus": the widget gets activated as soon as the form above it is focused. * "none": The widget does not start automatically at all, the user needs to press the widget.

WidgetErrorCode

Error codes that can be returned by the widget.

* "network_error": The user's browser could not connect to the Friendly Captcha API. * "sitekey_invalid": The sitekey is invalid. * "sitekey_missing": The sitekey is missing. * "other": Some other error occurred.

In all cases it's the best practice to enable the "submit" button when the widget errors, so that the user can still perform the action despite not having solved the captcha.

WidgetStateThe state the widget is in. See the [widget lifecycle](../lifecycle) docs for more information.