{"id":21448786,"url":"https://github.com/aacn/use-friendly-captcha","last_synced_at":"2025-07-14T20:31:27.306Z","repository":{"id":63725605,"uuid":"528610575","full_name":"aacn/use-friendly-captcha","owner":"aacn","description":"React Hook Component and Verification Handler for https://friendlycaptcha.com/","archived":false,"fork":false,"pushed_at":"2024-02-20T13:36:41.000Z","size":630,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T02:07:21.195Z","etag":null,"topics":["anti-bot","anti-spam","captcha","customizable","gdpr-compliant","library","privacy","proof-of-work","react","react-hooks","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"https://aacn.eu","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aacn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"aacn"}},"created_at":"2022-08-24T22:11:53.000Z","updated_at":"2025-02-27T14:35:21.000Z","dependencies_parsed_at":"2024-02-20T14:47:24.059Z","dependency_job_id":null,"html_url":"https://github.com/aacn/use-friendly-captcha","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.2666666666666667,"last_synced_commit":"2b86a41594471873f9e53d5d6608cda1049cf2a3"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aacn/use-friendly-captcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aacn%2Fuse-friendly-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aacn%2Fuse-friendly-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aacn%2Fuse-friendly-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aacn%2Fuse-friendly-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aacn","download_url":"https://codeload.github.com/aacn/use-friendly-captcha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aacn%2Fuse-friendly-captcha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265344828,"owners_count":23750566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anti-bot","anti-spam","captcha","customizable","gdpr-compliant","library","privacy","proof-of-work","react","react-hooks","typescript","typescript-library"],"created_at":"2024-11-23T03:16:44.900Z","updated_at":"2025-07-14T20:31:26.893Z","avatar_url":"https://github.com/aacn.png","language":"TypeScript","funding_links":["https://github.com/sponsors/aacn"],"categories":[],"sub_categories":[],"readme":"# Use Friendly Captcha hook\n## Usage\nThe library has functions for both frontend and backend. Both of them work independent of each other.\n\n### Frontend\nInclude the `useCaptchaHook()` in your selected file. From there you can then query the widget\nand state from the hook, for you to manage and use in your form.\n\nPlease be aware that the `friendly-challenge` library is a necessary peer dependency since version 1.2.0\n\n\u003cb\u003eThe hook expects the following properties:\u003c/b\u003e\u003cbr/\u003e\n```\nsiteKey: string;\nendpoint?: FC_PUZZLE_EP; enum for the currently available endpoints (EU \u0026 global)\nlanguage?: keyof typeof localizations | Localization;\nstartMode?: \"auto\" | \"focus\" | \"none\";\nshowAttribution: boolean;\n```\n\u003cbr/\u003e\n\u003cb\u003eThe hook provides the following parameters:\u003c/b\u003e\u003cbr/\u003e\n- `CaptchaWidget` returns the HTML authentification widget.\n- `captchaStatus.solution` is used to determine if the puzzle was already solved (`string`) or not (`null`)\n- `captchaStatus.error` is used to determine if an error occured while solving (`string`) or not (`null`)\n\n\u003cbr/\u003e\u003cb\u003eCaptchaWidget custom props\u003c/b\u003e\u003cbr/\u003e\nWhen the `CaptchaWidget` gets rendered, you can add additional properties:\u003cbr/\u003e\u003cbr/\u003e\n`props: HTMLAttributes` This includes all possible html attributes. Therefor this is the entry point to add the `className` attribute,\nto add custom styling to the outer captcha container. Here can you either directly add TailwindCSS classes or define a custom class for\nfuture styling in the .css file of the project.\n\u003cbr/\u003e\u003cbr/\u003e\n`customWidgetStyle` allows up to three attributes for specific stylings that are directly applied to the components:\n- `icon` The icon of the widget\n- `button` The submit button of the widget\n- `text` All text elements that appear inside the widget\n\u003cbr/\u003eThese attributes are all optional and if used, they expect a css object like the following example:\n```js\nCustomWidgetStyle = { icon: {color: \"green\", background: \"yellow\"}, text: {color: \"blue\"} }\n```\n\n### Backend\nbackend wise this library provides a function that uses the FriendlyCaptcha verification\nAPI to check if the submitted puzzle solution is valid or not. It returns a boolean for further\nhandling in your own code.\n\n\u003cb\u003eThe function expects the following properties:\u003c/b\u003e\u003cbr/\u003e\n```\nendpoint?: FC_VERIFICATION_EP; enum for the currently available endpoints (EU \u0026 global)\nsolution: string;\nsecret: string;\nsitekey?: string;\nhttpPostFetcher: (see further down)\n```\n\n### httpPostFetcher\nThe backend expects a fetcher function as parameter. This function is provided by the user\nand is used to send a http post request to the fc verification server. It should match the following design:\n```\nfunction fetcherExample(\n    endpoint: string,\n    requestBody: { solution: string; secret: string; siteKey: string },\n    headers: { 'Content-Type': 'application/json'; 'Accept': 'application/json'; }\n) =\u003e Promise\u003c{ success: boolean; errors: any; } | null\u003e\n```\n\n### Examples\nWe provided basic examples in the `/examples` folder, on how to use this library in [React](https://github.com/aacn/use-friendly-captcha/tree/main/examples/react-example) and [Nextjs](https://github.com/aacn/use-friendly-captcha/tree/main/examples/nextjs).\nBoth examples are written in TypeScript and are kept simple to focus on easy readability and presenting the utility of the function from this library.\nIf you want to run the examples on your machine, make sure to read the respective README files,\nto add all requirements that are needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faacn%2Fuse-friendly-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faacn%2Fuse-friendly-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faacn%2Fuse-friendly-captcha/lists"}