Skip to content

Commit 51a71ea

Browse files
committed
Merge remote-tracking branch 'origin/main' into rok/2025-11-20-update-localization-docs
Conflicts: docs/guides/localization.md
2 parents ef2a383 + 67401bc commit 51a71ea

63 files changed

Lines changed: 3977 additions & 78 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/getting-started/install.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ To create widgets from Javascript code, [see **Option B** below](#option-b-progr
1616

1717
Add the following to your website's HTML:
1818
```html
19-
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/site.min.js" async defer></script>
20-
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/site.compat.min.js" async defer></script>
19+
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/site.min.js" async defer></script>
20+
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/site.compat.min.js" async defer></script>
2121
```
2222

2323
::::tip
24-
#### Using the scripts without a CDN
24+
#### Using the scripts without a CDN (i.e. self-hosting)
2525

26-
You can [download the latest release files](https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/) and serve them from your own server.
26+
Using `cdn.jsdelivr.net` is optional. If preferred, you can self-host the scripts. [Download the latest release files](https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/) and serve them from your own server.
2727
Remember to update these scripts regularly.
28+
29+
`cdn.jsdelivr.net` is blocked in some jurisdictions, like some parts of China. If your website needs to be reachable from these jurisdictions, we recommend that you self-host the scripts.
2830
::::
2931

3032

@@ -54,7 +56,7 @@ You can install our NPM package to create widgets programmatically.
5456
npm install @friendlycaptcha/sdk
5557

5658
# using yarn
57-
yan add @friendlycaptcha/sdk
59+
yarn add @friendlycaptcha/sdk
5860
```
5961

6062

docs/getting-started/verify.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The response body is a JSON object which has a `success` field that tells you wh
5959
"success": false,
6060
"error": {
6161
"error_code": "bad_request", // Error code, see the table below for possible values
62-
"detail": "..." // A textual description of what went wrong.
62+
"detail": "..." // Extra details (this is mainly intended for Friendly Captcha staff)
6363
},
6464
}
6565

docs/guides/automated-testing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ With this approach you can keep all other code in your application the same.
1313

1414
### IP or password-based gating
1515
If you perform automated end-to-end tests in production you may want to conditionally disable the captcha check for your test-runner.
16-
* If you know the IPs of the machines that run these tests you could whitelist those and skip the captcha check for those (or use the mocking approach above).
17-
* If you do not know the IP beforehand, you could have your test-runner put a secret in the form submission that you check for. In other words, you can specify a password that bypasses the captcha.
16+
17+
* If you know the IPs of the machines that run these tests you could skip [CAPTCHA verification](../getting-started/verify) by adding the IPs to an allowlist in your code or infrastructure.
18+
* If you do not know the IP beforehand, you could have your test-runner put a secret in the form submission that you check for. In other words, you can specify a password that your backend will accept for bypassing [CAPTCHA verification](../getting-started/verify).
1819

1920
### Dynamic button enabling
2021
Many websites that have a form protected using Friendly Captcha will only enable the submit button after the captcha widget is finished to prevent users from submitting without a valid captcha solution. When you are using a browser automation tool you may want to enable the button despite the captcha not being completed, we advice you achieve this by executing a snippet of Javascript (which is something you can do in all browser testing automation tools).

docs/guides/migrating-from-hcaptcha.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Instead you would replace the hCaptcha plugin and install a plugin that supports
3333
```
3434
with the hCAPTCHA-compatible Friendly Captcha scripts.
3535
```html
36-
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/contrib/hcaptcha-site.min.js"
36+
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/contrib/hcaptcha-site.min.js"
3737
async defer></script>
38-
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/contrib/hcaptcha-site.compat.min.js"
38+
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/contrib/hcaptcha-site.compat.min.js"
3939
async defer></script>
4040
```
4141

docs/guides/migrating-from-recaptcha.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Instead you would replace the reCAPTCHA plugin and install a plugin that support
3232
```
3333
with the reCAPTCHA-compatible Friendly Captcha scripts.
3434
```html
35-
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/contrib/recaptcha-site.min.js"
35+
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/contrib/recaptcha-site.min.js"
3636
async defer></script>
37-
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/contrib/recaptcha-site.compat.min.js"
37+
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/contrib/recaptcha-site.compat.min.js"
3838
async defer></script>
3939
```
4040

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Self-Hosted Endpoint
2+
3+
:::info
4+
5+
The Self-Hosted Endpoint feature is only available for Friendly Captcha v2.
6+
7+
:::
8+
9+
When a customer website or application loads a Friendly Captcha widget, the widget makes a number of requests to the Friendly Captcha API. The API endpoint is `global.frcapi.com`, or `eu.frcapi.com` for customers who use [the EU Endpoint](./eu-endpoint). Friendly Captcha offers the **Self-Hosted Endpoint** feature for customers who prefer to route all end-user traffic through their own infrastructure.
10+
11+
To use a Self-Hosted Endpoint, customers operate a proxy server that forwards widget requests to the Friendly Captcha API. Because the Friendly Captcha service depends on data sent by the widget, it is important to ensure that a Self-Hosted Endpoint correctly forwards that data.
12+
13+
## Setup
14+
15+
There are 3 steps to setting up a Self-Hosted Endpoint, explained in detail below.
16+
17+
1. [Generate a proxy key in the Friendly Captcha dashboard.](#1-generate-a-proxy-key)
18+
2. [Configure your web server to proxy widget requests to the Friendly Captcha API.](#2-configure-your-web-server)
19+
3. [Configure your widget to use your Self-Hosted Endpoint.](#3-configure-your-site-or-apps-widget)
20+
21+
### 1. Generate a proxy key
22+
23+
To verify that proxied widget requests come from your infrastructure, you must set a header that contains a proxy key. You can generate a key in the [Friendly Captcha dashboard](https://app.friendlycaptcha.eu/dashboard/accounts/-/keys/proxy). Make sure to generate a **Proxy Key**; API keys are not accepted. Store the generated key somewhere safe and retrievable&mdash;Friendly Captcha doesn't keep a copy of the key, so you will have to regenerate it if you lose it. You will use this proxy key in the next step.
24+
25+
### 2. Configure your web server
26+
27+
You need to configure your web server to forward the following requests to the Friendly Captcha API:
28+
29+
```
30+
GET /api/v2/captcha/agent
31+
GET /api/v2/captcha/widget
32+
GET /api/v2/captcha/ping
33+
POST /api/v2/captcha/activate
34+
POST /api/v2/captcha/quote
35+
POST /api/v2/captcha/redeem
36+
```
37+
38+
For these requests, your server should forward the request in its entirety, including all headers. Additionally, the forwarded requests should include two ***extra*** headers:
39+
40+
1. `X-Frc-Proxy-Key`: The proxy key you generated in the Friendly Captcha dashboard.
41+
2. `X-Frc-Proxy-Client-IP`: The original (source) IP address of the end user.
42+
43+
Forward the requests to this endpoint (i.e., the upstream server):
44+
45+
```
46+
https://global.proxy.frcapi.com
47+
```
48+
49+
If you have access to [the EU Endpoint](./eu-endpoint.md), you may alternatively forward the requests to this endpoint:
50+
51+
```
52+
https://eu.proxy.frcapi.com
53+
```
54+
55+
[See below](#example-routing-configurations) for examples of how to configure a server to correctly proxy the widget requests.
56+
57+
:::warning Note
58+
59+
If you don't forward the entire request and its headers, the widget may still be functional, but the service will operate in a degraded state. If you forget either of the additional proxy headers (`X-Frc-Proxy-Key` and `X-Frc-Proxy-Client-IP`), the widget will display an error message.
60+
61+
:::
62+
63+
### 3. Configure your site or app's widget
64+
65+
The final step is to configure your server's URL as the API endpoint for your widget. This will ensure that the widget sends its requests to your server (which will then forward them to the upstream Friendly Captcha API). If your server's URL is `https://example.com` and you configure the widget using HTML `data-` attributes, your markup will look something like this:
66+
67+
```html
68+
<div class="frc-captcha" data-sitekey="<my sitekey>" data-api-endpoint="https://example.com"></div>
69+
```
70+
71+
If you configure the widget using the JavaScript SDK, your code will look something like this:
72+
73+
```js
74+
import { FriendlyCaptchaSDK } from "@friendlycaptcha/sdk"
75+
const sdk = new FriendlyCaptchaSDK();
76+
77+
const mount = document.querySelector(".my-widget");
78+
const widget = sdk.createWidget({
79+
element: mount,
80+
sitekey: "<my sitekey>",
81+
apiEndpoint: "https://example.com",
82+
});
83+
```
84+
85+
For more documentation, see the page on [configuring the Friendly Captcha widget](../sdk/configuration.md).
86+
87+
## Example Routing Configurations
88+
89+
Provided below are some example Self-Hosted Endpoints configurations for popular web server technologies. If you copy and paste the configuration, make sure to replace `<% PROXY KEY %>` with your real proxy key, and verify that you're using the correct upstream Friendly Captcha API endpoint.
90+
91+
### Apache
92+
93+
```
94+
LoadModule proxy_module modules/mod_proxy.so
95+
LoadModule proxy_http_module modules/mod_proxy_http.so
96+
LoadModule headers_module modules/mod_headers.so
97+
98+
<LocationMatch "^/api/v2/captcha/(agent|widget|ping|activate|quote|redeem)(/.*)?$">
99+
RequestHeader set X-Frc-Proxy-Key "<% PROXY KEY %>"
100+
RequestHeader set X-Frc-Proxy-Client-IP expr=%{REMOTE_ADDR}
101+
102+
ProxyPass https://global.proxy.frcapi.com
103+
ProxyPassReverse https://global.proxy.frcapi.com
104+
</LocationMatch>
105+
```
106+
107+
### Caddy
108+
109+
```
110+
@captcha_paths path_regexp ^/api/v2/captcha/(agent|widget|ping|activate|quote|redeem)(/.*)?$
111+
112+
reverse_proxy @captcha_paths https://global.proxy.frcapi.com {
113+
header_up X-Frc-Proxy-Key "<% PROXY KEY %>"
114+
header_up X-Frc-Proxy-Client-IP {remote_host}
115+
}
116+
```
117+
118+
### HAProxy
119+
120+
```
121+
frontend http-in
122+
# other frontend configuration...
123+
124+
acl is_captcha_path path_reg ^/api/v2/captcha/(agent|widget|ping|activate|quote|redeem)(/.*)?$
125+
use_backend captcha_paths if is_captcha_path
126+
127+
backend captcha_paths
128+
mode http
129+
130+
http-request set-header X-Frc-Proxy-Key "<% PROXY KEY %>"
131+
http-request set-header X-Frc-Proxy-Client-IP %[src]
132+
133+
# Note: the path to the certificates file may be different for your OS.
134+
server frc_api global.proxy.frcapi.com:443 ssl verify required ca-file /etc/ssl/certs/ca-certificates.crt
135+
```
136+
137+
### NGINX
138+
139+
```
140+
location ~ ^/api/v2/captcha/(agent|widget|ping|activate|quote|redeem)(/.*)?$ {
141+
proxy_set_header X-Frc-Proxy-Key <% PROXY KEY %>;
142+
proxy_set_header X-Frc-Proxy-Client-IP $remote_addr;
143+
144+
proxy_pass https://global.proxy.frcapi.com;
145+
}
146+
```

docs/guides/upgrading-from-v1/script.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Replace the `friendly-challenge` scripts
1313
```
1414
with the new `@friendlycaptcha/sdk` scripts
1515
```html
16-
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/site.min.js"
16+
<script type="module" src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/site.min.js"
1717
async defer></script>
18-
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.23/site.compat.min.js"
18+
<script nomodule src="https://cdn.jsdelivr.net/npm/@friendlycaptcha/sdk@0.1.31/site.compat.min.js"
1919
async defer></script>
2020
```
2121
## 2. 🇪🇺 Update custom API endpoints

docs/introduction/v1-and-v2.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@ v1 will keep working! We will maintain it moving forward for multiple years.
2626

2727
At some point down the road we will not allow newly created apps to use v1, but existing apps will still continue to work.
2828

29-
## When can I upgrade?
30-
31-
You may already be eligible&mdash;accounts created after May 1, 2024 automatically have access to v2. You can find out if you do by navigating to the [Create New App](https://app.friendlycaptcha.eu/dashboard/accounts/-/apps/create) page. In the **Friendly Captcha Version** step, if you can select v2, you're all set.
32-
33-
Over the next 6 months, we will be rolling out v2 access to the rest of our customers. If you're ready to upgrade now, feel free to reach out using [**this form**](https://tally.so/r/n0MGDA) and a member of our team will help you get access.
34-
3529
## How do I upgrade?
3630

37-
After v2 is enabled for your account, you can [follow the upgrade guide](./guides/upgrading-from-v1).
31+
v2 is available to all customers and we highly recommend it. Please [follow the upgrade guide](/docs/v2/guides/upgrading-from-v1).
32+
33+
If you're an **Enterprise** customer, please [contact support](https://friendlycaptcha.com/support/) so that we can help you upgrade to v2!
3834

3935
## How can I tell if I'm using v1 or v2?
4036

docs/sdk/events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ You can listen to events using `HTMLElement.addEventListener` or `widget.addEven
2828
2929
myWidget.addEventListener("frc:widget.error", function(event) {
3030
console.error("Widget ran into an error:", event.detail.error);
31-
myButton.disabled = true;
31+
myButton.disabled = false;
3232
});
3333
3434
myWidget.addEventListener("frc:widget.expire", function(event) {

docs/sdk/lifecycle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The widget has a fixed set of states it can be in.
44

55
Usually the only states you have to care about are the following:
66
* `completed`: the captcha has been completed, you can enable the button to submit and verification should pass.
7-
* `error`: something went wrong. You should disable the submit button.
7+
* `error`: something went wrong. Enable the button to submit so that the error can be investigated.
88
* `expired`: the user waited too long and needs to restart. You should disable the submit button.
99
* `destroyed`: You called `destroy()` on the widget which cleans it up entirely, it can no longer be used.
1010

0 commit comments

Comments
 (0)