@tansy/captcha-turnstile 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/index.d.ts +9 -0
- package/index.js +30 -0
- package/package.json +26 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
What changed in each release of `@tansy/captcha-turnstile`. Releases up to 0.1.0 went out with every other package
|
|
4
|
+
on one version and are described in [tansy's changelog](../../CHANGELOG.md).
|
|
5
|
+
|
|
6
|
+
## 0.1.1 — 2026-11-22
|
|
7
|
+
|
|
8
|
+
No changes of its own. Released beside `tansy` 0.1.1, from which every package moves on its own
|
|
9
|
+
version, and it now requires it: the `tansy` peer range is ^0.1.1.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohamed Salah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- Generated by scripts/package-metadata.mjs. Change that script, not this file. -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tansy/captcha-turnstile
|
|
4
|
+
|
|
5
|
+
Cloudflare Turnstile for @tansy/captcha.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tansy/captcha-turnstile
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Add it to `tansy.config.ts`. See [the captcha plugin documentation](https://github.com/mhmdsalahsebai/tansy/blob/main/docs/plugins/captcha.md) for what it adds and the options it takes.
|
|
12
|
+
|
|
13
|
+
A first-party plugin for [tansy](https://github.com/mhmdsalahsebai/tansy), a self-hosted, runtime-schema CMS for Next.js. MIT licensed.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface TurnstileOptions {
|
|
2
|
+
/** The site key until one is saved in the settings. It's public. */
|
|
3
|
+
siteKey?: string;
|
|
4
|
+
/** For tests: where answers are checked instead of Cloudflare. */
|
|
5
|
+
verifyUrl?: string;
|
|
6
|
+
fetcher?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
/** Cloudflare Turnstile. Usually needs no puzzle at all. */
|
|
9
|
+
export declare const turnstile: ({ siteKey: defaultKey, verifyUrl, fetcher }?: TurnstileOptions) => import("@tansy/captcha/provider").CaptchaProvider;
|
package/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineCaptchaProvider, siteVerify, str } from "@tansy/captcha/provider";
|
|
2
|
+
const secret = (settings) => str(settings.turnstileSecretKey);
|
|
3
|
+
const siteKey = (settings) => str(settings.turnstileSiteKey);
|
|
4
|
+
/** Cloudflare Turnstile. Usually needs no puzzle at all. */
|
|
5
|
+
export const turnstile = ({ siteKey: defaultKey = "", verifyUrl = "https://challenges.cloudflare.com/turnstile/v0/siteverify", fetcher } = {}) => defineCaptchaProvider({
|
|
6
|
+
id: "turnstile",
|
|
7
|
+
label: "Cloudflare Turnstile",
|
|
8
|
+
// Its settings in other interface languages. English is each setting's own label and description.
|
|
9
|
+
messages: {
|
|
10
|
+
ar: {
|
|
11
|
+
settings: {
|
|
12
|
+
turnstileSiteKey: {
|
|
13
|
+
label: "مفتاح موقع Turnstile",
|
|
14
|
+
description: "من Cloudflare ← Turnstile، لعنصر يضم نطاق هذا الموقع. عام: يظهر لكل زائر."
|
|
15
|
+
},
|
|
16
|
+
turnstileSecretKey: {
|
|
17
|
+
label: "المفتاح السري لـ Turnstile"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
settings: () => [
|
|
23
|
+
{ name: "turnstileSiteKey", type: "text", default: defaultKey, maxLength: 200, label: "Turnstile site key", description: "From Cloudflare → Turnstile, for a widget that lists this site's domain. Public: it's shown to every visitor." },
|
|
24
|
+
{ name: "turnstileSecretKey", type: "secret", env: "TURNSTILE_SECRET_KEY", label: "Turnstile secret key" },
|
|
25
|
+
],
|
|
26
|
+
ready: (settings) => Boolean(siteKey(settings) && secret(settings)),
|
|
27
|
+
widget: (settings) => ({ script: "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", global: "turnstile", siteKey: siteKey(settings) }),
|
|
28
|
+
verify: (answer, { ip }, settings) => siteVerify(verifyUrl, { secret: secret(settings), response: answer, remoteip: ip }, fetcher),
|
|
29
|
+
csp: { frame: ["https://challenges.cloudflare.com"] },
|
|
30
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tansy/captcha-turnstile",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Cloudflare Turnstile for @tansy/captcha.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tansy",
|
|
7
|
+
"tansy-captcha-provider"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Mohamed Salah <mohamedsalahsebai@gmail.com>",
|
|
11
|
+
"homepage": "https://github.com/mhmdsalahsebai/tansy",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/mhmdsalahsebai/tansy.git",
|
|
15
|
+
"directory": "plugins/captcha-turnstile"
|
|
16
|
+
},
|
|
17
|
+
"bugs": "https://github.com/mhmdsalahsebai/tansy/issues",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./index.d.ts",
|
|
21
|
+
"default": "./index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@tansy/captcha": "^0.1.1",
|
|
26
|
+
"tansy": "^0.1.1"
|
|
27
|
+
}
|
|
28
|
+
}
|