{"id":20046268,"url":"https://github.com/chataize/captcha","last_synced_at":"2025-07-10T09:34:30.343Z","repository":{"id":262181766,"uuid":"886403469","full_name":"chataize/captcha","owner":"chataize","description":"C# .NET 9.0 Blazor server component for hCaptcha.","archived":false,"fork":false,"pushed_at":"2024-12-18T09:43:24.000Z","size":150,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-18T10:36:27.814Z","etag":null,"topics":["app","asp-net-core","blazor","bot","captcha","chataize","component","control","csharp","dotnet","hcaptcha","human","interactive","lib","library","protection","razor","server","verification","web"],"latest_commit_sha":null,"homepage":"https://www.chataize.com","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chataize.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2024-11-10T22:34:21.000Z","updated_at":"2024-12-18T09:42:28.000Z","dependencies_parsed_at":"2024-12-18T10:30:56.096Z","dependency_job_id":"62bc16b5-b1bf-4b95-999f-105848bbfc34","html_url":"https://github.com/chataize/captcha","commit_stats":null,"previous_names":["chataize/captcha"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chataize%2Fcaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chataize%2Fcaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chataize%2Fcaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chataize%2Fcaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chataize","download_url":"https://codeload.github.com/chataize/captcha/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233655325,"owners_count":18709260,"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":["app","asp-net-core","blazor","bot","captcha","chataize","component","control","csharp","dotnet","hcaptcha","human","interactive","lib","library","protection","razor","server","verification","web"],"created_at":"2024-11-13T11:22:24.971Z","updated_at":"2025-01-12T20:11:54.645Z","avatar_url":"https://github.com/chataize.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CAPTCHA\nC# .NET 9.0 Blazor server component for [hCaptcha](https://www.hcaptcha.com).\n\n\u003e [!WARNING]\n\u003e This library is designed to be used in a Blazor server app with interactive rendering enabled. It does **NOT** support Blazor WebAssembly.\n\n## Installation\n### NuGet Package\n#### NuGet CLI\n```bash\ndotnet add package ChatAIze.Captcha\n```\n#### Package Manager Console\n```powershell\nInstall-Package ChatAIze.Captcha\n```\n### Service (Program.cs)\n```cs\nbuilder.Services.AddCaptcha(o =\u003e\n{\n    o.SiteKey = builder.Configuration[\"Captcha:SiteKey\"]!;\n    o.Secret = builder.Configuration[\"Captcha:Secret\"]!;\n    o.VerifyIpAddresses = false; // optional, default is false\n    o.IsConnectionProxied = false; // optional, default is false\n});\n```\n\u003e [!NOTE]\n\u003e If users are connecting to your app via a reverse proxy like [Cloudflare](https://www.cloudflare.com), `IsConnectionProxied` should be set to `true`.\n\u003e In such a case, the `X-Forwarded-For` header will be used to determine the client's IP address.\n### Middleware (Program.cs)\n```cs\napp.UseCaptcha();\n```\n### Javascript (App.razor)\n```html\n\u003chead\u003e\n  \u003c!-- ... --\u003e\n  \u003cscript src=\"https://js.hcaptcha.com/1/api.js\" async defer\u003e\u003c/script\u003e\n  \u003c!-- ... --\u003e\n\u003c/head\u003e\n```\n### Using (_Imports.razor)\n```razor\n@using ChatAIze.Captcha\n```\n\n## Usage\n```razor\n\u003cCaptcha @bind-IsVerified=\"_isVerified\" /\u003e\n\u003ch1\u003eVerified: @_isVerified\u003c/h1\u003e\n\n@code {\n    private bool _isVerified;\n}\n```\n\u003e [!TIP]\n\u003e Make sure that the component containing the CAPTCHA has **interactive rendering** enabled.\n\u003e ```razor\n\u003e @rendermode InteractiveServer\n\u003e ```\n### Properties\n- **SiteKey**: Overrides service settings\n- **Secret**: Overrides service settings\n```razor\n\u003cCaptcha @bind-IsVerified=\"_isVerified\" SiteKey=\"\" Secret=\"\" /\u003e\n```\n- **Theme**: Auto - Light - Dark\n- **Size**: Normal - Compact\n```razor\n\u003cCaptcha @bind-IsVerified=\"_isVerified\" Theme=\"CaptchaTheme.Auto\" Size=\"CaptchaSize.Normal\" /\u003e\n```\n### Events\n- **Opened**: Called when the user display of a challenge starts.\n- **Closed**: Called when the user dismisses a challenge.\n- **Succeeded**: Called when the user submits a successful response.\n- **Expired**: Called when the passcode response expires and the user must re-verify.\n- **ChallengeExpired**: Called when the user display of a challenge times out with no answer.\n- **Error**: Called when hCaptcha encounters an error and cannot continue.\n```razor\n\u003cCaptcha @bind-IsVerified=\"_isVerified\" SiteKey=\"\" Secret=\"\" Theme=\"CaptchaTheme.Auto\" Size=\"CaptchaSize.Normal\" Opened=\"OnOpened\" Closed=\"OnClosed\" Succeeded=\"OnSucceeded\" Expired=\"OnExpired\" ChallengeExpired=\"OnChallengeExpired\" Error=\"OnError\" /\u003e\n\n@code {\n    private bool _isVerified;\n\n    private void OnOpened() { }\n\n    private void OnClosed() { }\n\n    private void OnSucceeded() { }\n\n    private void OnExpired() { }\n\n    private void OnChallengeExpired() { }\n\n    private void OnError(string code) { }\n}\n```\n### Errors\n| Code                  | Description                                                                                  |\n|-----------------------|----------------------------------------------------------------------------------------------|\n| **rate-limited**      | User has sent too many requests                                                              |\n| **network-error**     | There are network connection issues (e.g., offline). hCaptcha will automatically retry.      |\n| **invalid-data**      | Invalid data is not accepted by endpoints                                                    |\n| **challenge-error**   | Challenge encountered error on setup. User may need to select the checkbox or call execute.  |\n| **challenge-closed**  | User closed the challenge                                                                    |\n| **challenge-expired** | Time limit to answer challenge has expired                                                   |\n| **missing-captcha**   | No captcha was found. Verify hCaptcha was properly setup and a captcha was rendered.         |\n| **invalid-captcha-id**| Captcha does not exist for ID provided. Check that the captcha rendered matches the stored ID. |\n| **internal-error**    | hCaptcha client encountered an internal error. User may need to select the checkbox or call execute. |\n| **script-error**      | hCaptcha JS SDK could not be loaded. User may be behind a firewall blocking api.js.          |\n\nSource: https://docs.hcaptcha.com/configuration#error-codes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchataize%2Fcaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchataize%2Fcaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchataize%2Fcaptcha/lists"}