UNPKG

@hcaptcha/react-native-hcaptcha

Version:

hCaptcha Library for React Native (both Android and iOS)

102 lines (98 loc) 3.06 kB
import React from 'react'; import { StyleProp, ViewStyle } from 'react-native'; import { WebViewMessageEvent } from 'react-native-webview'; type HcaptchaProps = { /** * The callback function that runs after receiving a response, error, or when user cancels. */ onMessage?: (event: CustomWebViewMessageEvent) => void; /** * The size of the checkbox. */ size: 'invisible' | 'normal' | 'compact'; /** * The hCaptcha siteKey */ siteKey: string; /** * The webview style */ style?: StyleProp<ViewStyle> /** * The url domain defined on your hCaptcha. You generally will not need to change this. */ url?: string; /** * Default language for hCaptcha; overrides phone defaults. * A complete list of supported languages and their codes can be found [here](https://docs.hcaptcha.com/languages/) */ languageCode?: string; /** * Whether to show a loading indicator while the hCaptcha web content loads */ showLoading?: boolean; /** * Allow user to cancel hcaptcha during loading by touch loader overlay */ closableLoading?: boolean; /** * Color of the ActivityIndicator */ loadingIndicatorColor?: string; /** * The background color code that will be applied to the main HTML element */ backgroundColor?: string; /** * The theme can be 'light', 'dark', 'contrast' or a custom theme object (see Enterprise docs) */ theme?: 'light' | 'dark' | 'contrast' | Object; /** * Hcaptcha execution options (see Enterprise docs) */ rqdata?: string; /** * Enable / Disable sentry error reporting. */ sentry?: boolean; /** * The url of api.js * Default: https://js.hcaptcha.com/1/api.js (Override only if using first-party hosting feature.) */ jsSrc?: string; /** * Point hCaptcha JS Ajax Requests to alternative API Endpoint. * Default: https://api.hcaptcha.com (Override only if using first-party hosting feature.) */ endpoint?: string; /** * Point hCaptcha Bug Reporting Request to alternative API Endpoint. * Default: https://accounts.hcaptcha.com (Override only if using first-party hosting feature.) */ reportapi?: string; /** * Points loaded hCaptcha assets to a user defined asset location, used for proxies. * Default: https://newassets.hcaptcha.com (Override only if using first-party hosting feature.) */ assethost?: string; /** * Points loaded hCaptcha challenge images to a user defined image location, used for proxies. * Default: https://imgs.hcaptcha.com (Override only if using first-party hosting feature.) */ imghost?: string; /** * hCaptcha SDK host identifier. null value means that it will be generated by SDK */ host?: string; /** * The orientation of the challenge. * Default: portrait */ orientation?: 'portrait' | 'landscape'; } interface CustomWebViewMessageEvent extends WebViewMessageEvent { success: boolean; reset: () => void; markUsed?: () => void; } export default class Hcaptcha extends React.Component<HcaptchaProps> {}