Skip to main content
Version: v2

@friendlycaptcha/sdk

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.

RiskIntelligenceHandle

This provides a handle for configuring and managing a Risk Intelligence request via an HTML element.

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

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.
FRCRiskIntelligenceCompleteEventDataPayload of the "frc:riskintelligence.complete" event.
FRCRiskIntelligenceErrorEventDataPayload of the "frc:riskintelligence.error" event.
FRCRiskIntelligenceExpireEventDataPayload of the "frc:riskintelligence.expire" event.
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.
RiskIntelligenceClearOptionsOptions for clearing cached Risk Intelligence tokens.
RiskIntelligenceErrorDataError data returned by a failed Risk Intelligence request.
RiskIntelligenceGenerateDataData returned by the Risk Intelligence API request.
RiskIntelligenceOptionsOptions for configuring a Risk Intelligence request.
WidgetErrorData
WidgetResetOptionsThe options object you can pass to the widget.reset() method.

Variables

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

Type Aliases

Type AliasDescription
APIEndpointWhich API endpoint to use for the SDK. Typically "eu" or "global", but a URL can be used to specify a custom endpoint. Defaults to "global".
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.
FRCRiskIntelligenceCompleteEventEvent that gets dispatched when a Risk Intelligence token has been successfully generated.
FRCRiskIntelligenceErrorEventEvent that gets dispatched when the Risk Intelligence request fails.
FRCRiskIntelligenceExpireEventEvent that gets dispatched when a Risk Intelligence token expires.
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.
RiskIntelligenceErrorCode

Error codes that can be returned by the Risk Intelligence request.

See WidgetErrorCode for the list of possible error codes.

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 get activated automatically at all, the user needs to press the widget (or .start() gets called using the Javascript API).

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.

WidgetModeThe mode of the widget. * "interactive" (default): the widget is interactive: the user needs to click the checkbox to finalize the captcha. This mode offers the best anti-bot protection. * "noninteractive": the widget is non-interactive: the captcha is solved without any user interaction required.
WidgetResetTriggerWhat caused the widget to reset. * root: Code on the root page (= your website code or plugin) caused the reset. * widget: The reset came from the widget. The user likely clicked the reset button within the widget. * agent: The reset came from the agent - this currently does not happen but may in the future.
WidgetStateThe state the widget is in. See the widget lifecycle docs for more information.