altcha 2.0.0-beta.9 → 2.0.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/LICENSE.txt +1 -1
- package/README.md +144 -94
- package/dist/altcha.d.ts +5 -2
- package/dist/altcha.i18n.d.ts +158 -0
- package/dist/altcha.i18n.js +4017 -0
- package/dist/altcha.i18n.umd.js +4 -0
- package/dist/altcha.js +1723 -1573
- package/dist/altcha.umd.cjs +4 -4
- package/dist_external/altcha.css +1 -1
- package/dist_external/altcha.d.ts +5 -2
- package/dist_external/altcha.js +1794 -1645
- package/dist_external/altcha.umd.cjs +3 -3
- package/dist_i18n/af.d.ts +1 -0
- package/dist_i18n/af.js +76 -3
- package/dist_i18n/af.umd.cjs +1 -1
- package/dist_i18n/all.d.ts +1 -0
- package/dist_i18n/all.js +178 -105
- package/dist_i18n/all.umd.cjs +1 -1
- package/dist_i18n/americas.d.ts +1 -0
- package/dist_i18n/americas.js +80 -7
- package/dist_i18n/americas.umd.cjs +1 -1
- package/dist_i18n/ar.d.ts +1 -0
- package/dist_i18n/ar.js +76 -3
- package/dist_i18n/ar.umd.cjs +1 -1
- package/dist_i18n/asia.d.ts +1 -0
- package/dist_i18n/asia.js +105 -32
- package/dist_i18n/asia.umd.cjs +1 -1
- package/dist_i18n/bg.d.ts +1 -0
- package/dist_i18n/bg.js +76 -3
- package/dist_i18n/bg.umd.cjs +1 -1
- package/dist_i18n/bn.d.ts +1 -0
- package/dist_i18n/bn.js +76 -3
- package/dist_i18n/bn.umd.cjs +1 -1
- package/dist_i18n/bs.d.ts +1 -0
- package/dist_i18n/bs.js +76 -3
- package/dist_i18n/bs.umd.cjs +1 -1
- package/dist_i18n/ca.d.ts +1 -0
- package/dist_i18n/ca.js +76 -3
- package/dist_i18n/ca.umd.cjs +1 -1
- package/dist_i18n/cs.d.ts +1 -0
- package/dist_i18n/cs.js +76 -3
- package/dist_i18n/cs.umd.cjs +1 -1
- package/dist_i18n/da.d.ts +1 -0
- package/dist_i18n/da.js +76 -3
- package/dist_i18n/da.umd.cjs +1 -1
- package/dist_i18n/de.d.ts +1 -0
- package/dist_i18n/de.js +76 -3
- package/dist_i18n/de.umd.cjs +1 -1
- package/dist_i18n/el.d.ts +1 -0
- package/dist_i18n/el.js +76 -3
- package/dist_i18n/el.umd.cjs +1 -1
- package/dist_i18n/en.d.ts +1 -0
- package/dist_i18n/en.js +76 -3
- package/dist_i18n/en.umd.cjs +1 -1
- package/dist_i18n/es-419.d.ts +1 -0
- package/dist_i18n/es-419.js +76 -3
- package/dist_i18n/es-419.umd.cjs +1 -1
- package/dist_i18n/es-es.d.ts +1 -0
- package/dist_i18n/es-es.js +76 -3
- package/dist_i18n/es-es.umd.cjs +1 -1
- package/dist_i18n/et.d.ts +1 -0
- package/dist_i18n/et.js +76 -3
- package/dist_i18n/et.umd.cjs +1 -1
- package/dist_i18n/eu.d.ts +1 -0
- package/dist_i18n/eu.js +76 -3
- package/dist_i18n/eu.umd.cjs +1 -1
- package/dist_i18n/europe.d.ts +1 -0
- package/dist_i18n/europe.js +139 -66
- package/dist_i18n/europe.umd.cjs +1 -1
- package/dist_i18n/fi.d.ts +1 -0
- package/dist_i18n/fi.js +76 -3
- package/dist_i18n/fi.umd.cjs +1 -1
- package/dist_i18n/fr-ca.d.ts +1 -0
- package/dist_i18n/fr-ca.js +77 -4
- package/dist_i18n/fr-ca.umd.cjs +1 -1
- package/dist_i18n/fr-fr.d.ts +1 -0
- package/dist_i18n/fr-fr.js +77 -4
- package/dist_i18n/fr-fr.umd.cjs +1 -1
- package/dist_i18n/ga.d.ts +1 -0
- package/dist_i18n/ga.js +76 -3
- package/dist_i18n/ga.umd.cjs +1 -1
- package/dist_i18n/he.d.ts +1 -0
- package/dist_i18n/he.js +76 -3
- package/dist_i18n/he.umd.cjs +1 -1
- package/dist_i18n/hi.d.ts +1 -0
- package/dist_i18n/hi.js +76 -3
- package/dist_i18n/hi.umd.cjs +1 -1
- package/dist_i18n/hr.d.ts +1 -0
- package/dist_i18n/hr.js +76 -3
- package/dist_i18n/hr.umd.cjs +1 -1
- package/dist_i18n/hu.d.ts +1 -0
- package/dist_i18n/hu.js +76 -3
- package/dist_i18n/hu.umd.cjs +1 -1
- package/dist_i18n/id.d.ts +1 -0
- package/dist_i18n/id.js +76 -3
- package/dist_i18n/id.umd.cjs +1 -1
- package/dist_i18n/is.d.ts +1 -0
- package/dist_i18n/is.js +76 -3
- package/dist_i18n/is.umd.cjs +1 -1
- package/dist_i18n/it.d.ts +1 -0
- package/dist_i18n/it.js +76 -3
- package/dist_i18n/it.umd.cjs +1 -1
- package/dist_i18n/ja.d.ts +1 -0
- package/dist_i18n/ja.js +76 -3
- package/dist_i18n/ja.umd.cjs +1 -1
- package/dist_i18n/ko.d.ts +1 -0
- package/dist_i18n/ko.js +76 -3
- package/dist_i18n/ko.umd.cjs +1 -1
- package/dist_i18n/lt.d.ts +1 -0
- package/dist_i18n/lt.js +76 -3
- package/dist_i18n/lt.umd.cjs +1 -1
- package/dist_i18n/lv.d.ts +1 -0
- package/dist_i18n/lv.js +76 -3
- package/dist_i18n/lv.umd.cjs +1 -1
- package/dist_i18n/mr.d.ts +1 -0
- package/dist_i18n/mr.js +76 -3
- package/dist_i18n/mr.umd.cjs +1 -1
- package/dist_i18n/mt.d.ts +1 -0
- package/dist_i18n/mt.js +76 -3
- package/dist_i18n/mt.umd.cjs +1 -1
- package/dist_i18n/nb.d.ts +1 -0
- package/dist_i18n/nb.js +77 -4
- package/dist_i18n/nb.umd.cjs +1 -1
- package/dist_i18n/nl.d.ts +1 -0
- package/dist_i18n/nl.js +76 -3
- package/dist_i18n/nl.umd.cjs +1 -1
- package/dist_i18n/pl.d.ts +1 -0
- package/dist_i18n/pl.js +76 -3
- package/dist_i18n/pl.umd.cjs +1 -1
- package/dist_i18n/pt-br.d.ts +1 -0
- package/dist_i18n/pt-br.js +76 -3
- package/dist_i18n/pt-br.umd.cjs +1 -1
- package/dist_i18n/pt-pt.d.ts +1 -0
- package/dist_i18n/pt-pt.js +76 -3
- package/dist_i18n/pt-pt.umd.cjs +1 -1
- package/dist_i18n/ro.d.ts +1 -0
- package/dist_i18n/ro.js +76 -3
- package/dist_i18n/ro.umd.cjs +1 -1
- package/dist_i18n/ru.d.ts +1 -0
- package/dist_i18n/ru.js +76 -3
- package/dist_i18n/ru.umd.cjs +1 -1
- package/dist_i18n/sk.d.ts +1 -0
- package/dist_i18n/sk.js +76 -3
- package/dist_i18n/sk.umd.cjs +1 -1
- package/dist_i18n/sl.d.ts +1 -0
- package/dist_i18n/sl.js +76 -3
- package/dist_i18n/sl.umd.cjs +1 -1
- package/dist_i18n/sr.d.ts +1 -0
- package/dist_i18n/sr.js +76 -3
- package/dist_i18n/sr.umd.cjs +1 -1
- package/dist_i18n/sv.d.ts +1 -0
- package/dist_i18n/sv.js +76 -3
- package/dist_i18n/sv.umd.cjs +1 -1
- package/dist_i18n/ta.d.ts +1 -0
- package/dist_i18n/ta.js +76 -3
- package/dist_i18n/ta.umd.cjs +1 -1
- package/dist_i18n/te.d.ts +1 -0
- package/dist_i18n/te.js +76 -3
- package/dist_i18n/te.umd.cjs +1 -1
- package/dist_i18n/th.d.ts +1 -0
- package/dist_i18n/th.js +76 -3
- package/dist_i18n/th.umd.cjs +1 -1
- package/dist_i18n/tr.d.ts +1 -0
- package/dist_i18n/tr.js +76 -3
- package/dist_i18n/tr.umd.cjs +1 -1
- package/dist_i18n/uk.d.ts +1 -0
- package/dist_i18n/uk.js +76 -3
- package/dist_i18n/uk.umd.cjs +1 -1
- package/dist_i18n/ur.d.ts +1 -0
- package/dist_i18n/ur.js +76 -3
- package/dist_i18n/ur.umd.cjs +1 -1
- package/dist_i18n/vi.d.ts +1 -0
- package/dist_i18n/vi.js +76 -3
- package/dist_i18n/vi.umd.cjs +1 -1
- package/dist_i18n/zh-cn.d.ts +1 -0
- package/dist_i18n/zh-cn.js +76 -3
- package/dist_i18n/zh-cn.umd.cjs +1 -1
- package/dist_i18n/zh-tw.d.ts +1 -0
- package/dist_i18n/zh-tw.js +76 -3
- package/dist_i18n/zh-tw.umd.cjs +1 -1
- package/package.json +11 -6
package/LICENSE.txt
CHANGED
package/README.md
CHANGED
|
@@ -1,87 +1,100 @@
|
|
|
1
|
-
# ALTCHA
|
|
1
|
+
# ALTCHA
|
|
2
2
|
|
|
3
3
|
ALTCHA is a self-hosted, privacy-first security solution that protects your websites, APIs, and online services from spam and abuse through an innovative proof-of-work mechanism. Unlike traditional CAPTCHAs that depend on intrusive methods like cookies or fingerprinting, ALTCHA delivers robust protection while respecting user privacy.
|
|
4
4
|
|
|
5
5
|
ALTCHA is fully compliant with:
|
|
6
6
|
|
|
7
|
-
- **Global privacy regulations**: GDPR, HIPAA, CCPA, PIPEDA/CPPA, LGPD, and PIPL
|
|
8
|
-
- **Accessibility standards**: [WCAG 2.2 AA-level](https://altcha.org/docs/wcag/) and the [European Accessibility Act](https://altcha.org/docs/european-accessibility-act-2025/)
|
|
7
|
+
- **Global privacy regulations**: GDPR, HIPAA, CCPA, PIPEDA/CPPA, LGPD, DPDPA, and PIPL
|
|
8
|
+
- **Accessibility standards**: [WCAG 2.2 AA-level](https://altcha.org/docs/v2/compliance/wcag/) and the [European Accessibility Act](https://altcha.org/docs/v2/compliance/european-accessibility-act-2025/)
|
|
9
9
|
|
|
10
|
-
For more details, visit [altcha.org](https://altcha.org).
|
|
10
|
+
For more details, visit [altcha.org](https://altcha.org).
|
|
11
11
|
|
|
12
|
-
## Features
|
|
12
|
+
## Features
|
|
13
13
|
|
|
14
|
-
- **Frictionless Experience**: Uses proof-of-work (PoW) instead of visual puzzles for a seamless user experience.
|
|
15
|
-
- **Code Challenge (New in v2)**: Supports accessible code challenges ("enter code from image") with an audio option.
|
|
16
|
-
- **Cookie-Free Design**: GDPR-compliant by default—no cookies or tracking.
|
|
17
|
-
- **Fully Accessible**: Meets WCAG 2.2 AA-level standards and complies with the European Accessibility Act (EAA).
|
|
18
|
-
- **Lightweight**: Minimal bundle size for fast page loads and optimal performance.
|
|
19
|
-
- **Self-Hosted**: No dependency on third-party services.
|
|
14
|
+
- **Frictionless Experience**: Uses proof-of-work (PoW) instead of visual puzzles for a seamless user experience.
|
|
15
|
+
- **Code Challenge (New in v2)**: Supports accessible code challenges ("enter code from image") with an audio option.
|
|
16
|
+
- **Cookie-Free Design**: GDPR-compliant by default—no cookies or tracking.
|
|
17
|
+
- **Fully Accessible**: Meets WCAG 2.2 AA-level standards and complies with the European Accessibility Act (EAA).
|
|
18
|
+
- **Lightweight**: Minimal bundle size for fast page loads and optimal performance.
|
|
19
|
+
- **Self-Hosted**: No dependency on third-party services.
|
|
20
20
|
|
|
21
|
-
## What’s New in v2
|
|
21
|
+
## What’s New in v2
|
|
22
22
|
|
|
23
|
-
Version 2 introduces enhanced accessibility, expanded language support, and integration with **ALTCHA Sentinel**—a self-hosted anti-spam solution for websites, apps, and services.
|
|
23
|
+
Version 2 introduces enhanced accessibility, expanded language support, and integration with **ALTCHA Sentinel**—a self-hosted anti-spam solution for websites, apps, and services.
|
|
24
24
|
|
|
25
|
-
### Key Improvements in v2
|
|
25
|
+
### Key Improvements in v2
|
|
26
26
|
|
|
27
|
-
- **Built-in Internationalization (i18n)** for 48+ languages
|
|
28
|
-
- **Improved RTL (right-to-left) language support**
|
|
29
|
-
- **Enhanced WCAG accessibility**
|
|
30
|
-
- **Support for accessible code challenges** (image + audio options)
|
|
27
|
+
- **Built-in Internationalization (i18n)** for 48+ languages
|
|
28
|
+
- **Improved RTL (right-to-left) language support**
|
|
29
|
+
- **Enhanced WCAG accessibility**
|
|
30
|
+
- **Support for accessible code challenges** (image + audio options)
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
### Migrating from v1
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Version 2 (v2) is fully compatible with v1, and minimal migration steps are required. However, be sure to test your integration after updating.
|
|
35
35
|
|
|
36
|
-
- [
|
|
37
|
-
- [
|
|
38
|
-
- [Svelte](https://github.com/altcha-org/altcha-starter-svelte-ts)
|
|
39
|
-
- [Solid](https://github.com/altcha-org/altcha-starter-solid-ts)
|
|
40
|
-
- [Lit](https://github.com/altcha-org/altcha-starter-lit-ts)
|
|
41
|
-
- [Angular](https://github.com/altcha-org/altcha-starter-angular)
|
|
36
|
+
- Translations: v2 introduces a new [built-in internationalization (i18n) system](#internationalization-i18n). The use of the `strings` attribute is now discouraged in favor of this new system.
|
|
37
|
+
- [ALTCHA Sentinel](https://altcha.org/docs/v2/sentinel): Sentinel is a new self-hosted solution that replaces the previous SaaS services and the SpamFilter. We recommend migrating to Sentinel for better compliance, enhanced security, unlimited verifications, and an adaptive Captcha with code-challenge support.
|
|
42
38
|
|
|
43
|
-
##
|
|
39
|
+
## Examples
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
- [PHP](https://github.com/altcha-org/altcha-lib-php)
|
|
47
|
-
- [Go](https://github.com/altcha-org/altcha-lib-go)
|
|
48
|
-
- [Python](https://github.com/altcha-org/altcha-lib-py)
|
|
49
|
-
- [Java](https://github.com/altcha-org/altcha-lib-java)
|
|
50
|
-
- [Ruby](https://github.com/altcha-org/altcha-lib-rb)
|
|
51
|
-
- [Elixir](https://github.com/altcha-org/altcha-lib-ex)
|
|
41
|
+
Explore starter templates for popular frameworks:
|
|
52
42
|
|
|
53
|
-
|
|
43
|
+
- [React](https://github.com/altcha-org/altcha-starter-react-ts)
|
|
44
|
+
- [Vue](https://github.com/altcha-org/altcha-starter-vue-ts)
|
|
45
|
+
- [Svelte](https://github.com/altcha-org/altcha-starter-svelte-ts)
|
|
46
|
+
- [Solid](https://github.com/altcha-org/altcha-starter-solid-ts)
|
|
47
|
+
- [Lit](https://github.com/altcha-org/altcha-starter-lit-ts)
|
|
48
|
+
- [Angular](https://github.com/altcha-org/altcha-starter-angular)
|
|
54
49
|
|
|
55
|
-
|
|
50
|
+
## Server Integrations
|
|
56
51
|
|
|
57
|
-
|
|
52
|
+
- [TypeScript](https://github.com/altcha-org/altcha-lib)
|
|
53
|
+
- [PHP](https://github.com/altcha-org/altcha-lib-php)
|
|
54
|
+
- [Go](https://github.com/altcha-org/altcha-lib-go)
|
|
55
|
+
- [Python](https://github.com/altcha-org/altcha-lib-py)
|
|
56
|
+
- [Java](https://github.com/altcha-org/altcha-lib-java)
|
|
57
|
+
- [Ruby](https://github.com/altcha-org/altcha-lib-rb)
|
|
58
|
+
- [Elixir](https://github.com/altcha-org/altcha-lib-ex)
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
## Plugins & CMS
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
- [Libraries and plugins](https://altcha.org/docs/integrations/)
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
The ALTCHA widget is distributed as a **Web Component** and [supports all modern browsers](https://developer.mozilla.org/en-US/docs/Web/API/Web_components#browser_compatibility).
|
|
67
|
+
|
|
68
|
+
### 1. Install ALTCHA
|
|
62
69
|
|
|
63
70
|
```sh
|
|
64
71
|
npm install altcha
|
|
65
72
|
```
|
|
66
73
|
|
|
67
|
-
Import in your main file:
|
|
74
|
+
Import in your main file:
|
|
68
75
|
|
|
69
76
|
```js
|
|
70
77
|
import 'altcha';
|
|
71
78
|
```
|
|
72
79
|
|
|
73
|
-
Or load via `<script>` tag:
|
|
80
|
+
Or load via `<script>` tag:
|
|
74
81
|
|
|
75
82
|
```html
|
|
76
83
|
<script async defer src="/altcha.js" type="module"></script>
|
|
77
84
|
```
|
|
78
85
|
|
|
79
|
-
**CDN**:
|
|
86
|
+
**CDN**:
|
|
87
|
+
|
|
80
88
|
```html
|
|
81
|
-
<script
|
|
89
|
+
<script
|
|
90
|
+
async
|
|
91
|
+
defer
|
|
92
|
+
src="https://cdn.jsdelivr.net/gh/altcha-org/altcha@main/dist/altcha.min.js"
|
|
93
|
+
type="module"
|
|
94
|
+
></script>
|
|
82
95
|
```
|
|
83
96
|
|
|
84
|
-
### 2. Add `<altcha-widget>` to Your Forms
|
|
97
|
+
### 2. Add `<altcha-widget>` to Your Forms
|
|
85
98
|
|
|
86
99
|
```html
|
|
87
100
|
<form>
|
|
@@ -89,57 +102,58 @@ Or load via `<script>` tag:
|
|
|
89
102
|
</form>
|
|
90
103
|
```
|
|
91
104
|
|
|
92
|
-
See [configuration options](#configuration) or the [website integration docs](https://altcha.org/docs/website-integration).
|
|
105
|
+
See [configuration options](#configuration) or the [website integration docs](https://altcha.org/docs/website-integration).
|
|
93
106
|
|
|
94
|
-
### 3. Integrate with Your Server
|
|
107
|
+
### 3. Integrate with Your Server
|
|
95
108
|
|
|
96
|
-
Refer to the [server documentation](https://altcha.org/docs/server-integration) for implementation details.
|
|
109
|
+
Refer to the [server documentation](https://altcha.org/docs/server-integration) for implementation details.
|
|
97
110
|
|
|
98
|
-
## Supported Browsers
|
|
111
|
+
## Supported Browsers
|
|
99
112
|
|
|
100
|
-
ALTCHA works on modern browsers with **Web Crypto API** support (specifically `crypto.subtle` - [caniuse.com](https://caniuse.com/?search=subtle)).
|
|
113
|
+
ALTCHA works on modern browsers with **Web Crypto API** support (specifically `crypto.subtle` - [caniuse.com](https://caniuse.com/?search=subtle)).
|
|
101
114
|
|
|
102
|
-
**Supported**:
|
|
115
|
+
**Supported**:
|
|
103
116
|
|
|
104
|
-
- Chrome (desktop & Android)
|
|
105
|
-
- Edge
|
|
106
|
-
- Firefox (desktop & Android)
|
|
107
|
-
- Safari (macOS & iOS)
|
|
108
|
-
- Any browser supporting Web Components + Web Crypto
|
|
117
|
+
- Chrome 67+ (desktop & Android)
|
|
118
|
+
- Edge 79+
|
|
119
|
+
- Firefox 63+ (desktop & Android)
|
|
120
|
+
- Safari 11+ (macOS & iOS)
|
|
121
|
+
- Any browser supporting Web Components + Web Crypto
|
|
109
122
|
|
|
110
|
-
**Not Supported**:
|
|
123
|
+
**Not Supported**:
|
|
111
124
|
|
|
112
125
|
- Internet Explorer 11 (or older)
|
|
113
126
|
|
|
114
|
-
## Bundle Size
|
|
127
|
+
## Bundle Size
|
|
115
128
|
|
|
116
|
-
ALTCHA is optimized for performance:
|
|
129
|
+
ALTCHA is optimized for performance:
|
|
117
130
|
|
|
118
|
-
| Distribution
|
|
119
|
-
|
|
120
|
-
| ALTCHA
|
|
121
|
-
|
|
|
122
|
-
|
|
|
131
|
+
| Distribution | Size (GZIPped) |
|
|
132
|
+
| ---------------------------- | -------------- |
|
|
133
|
+
| ALTCHA | 29+ kB |
|
|
134
|
+
| ALTCHA with all translations | 42+ kB |
|
|
135
|
+
| hCaptcha | 48+ kB |
|
|
136
|
+
| reCAPTCHA | 270+ kB |
|
|
123
137
|
|
|
124
|
-
When GZIPped, it totals about
|
|
138
|
+
When GZIPped, it totals about 29 kB, making ALTCHA’s widget about 90% smaller than reCAPTCHA.
|
|
125
139
|
|
|
126
|
-
## Content Security Policy (CSP)
|
|
140
|
+
## Content Security Policy (CSP)
|
|
127
141
|
|
|
128
|
-
The default bundle includes styles and workers in a single file. For strict CSP compliance, use scripts from `/dist_external`. Learn more in the [documentation](https://altcha.org/docs/website-integration).
|
|
142
|
+
The default bundle includes styles and workers in a single file. For strict CSP compliance, use scripts from `/dist_external`. Learn more in the [documentation](https://altcha.org/docs/website-integration).
|
|
129
143
|
|
|
130
|
-
## Configuration
|
|
144
|
+
## Configuration
|
|
131
145
|
|
|
132
146
|
Required options (at least one is required):
|
|
133
147
|
|
|
134
|
-
- **challengeurl**: Server endpoint to fetch the challenge.
|
|
135
|
-
- **challengejson**: Preloaded JSON challenge data (avoids HTTP requests).
|
|
148
|
+
- **challengeurl**: Server endpoint to fetch the challenge.
|
|
149
|
+
- **challengejson**: Preloaded JSON challenge data (avoids HTTP requests).
|
|
136
150
|
|
|
137
151
|
Additional options:
|
|
138
152
|
|
|
139
153
|
- **auto**: Automatically verify without user interaction (possible values: `off`, `onfocus`, `onload`, `onsubmit`).
|
|
140
154
|
- **credentials**: Whether to include [credentials](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit#credentials) with the challenge request (possible values: `omit`, `same-origin`, `include`).
|
|
141
155
|
- **customfetch**: A custom `fetch` function for retrieving the challenge.
|
|
142
|
-
Accepts `url: string` and `init: RequestInit` as arguments and must return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
156
|
+
Accepts `url: string` and `init: RequestInit` as arguments and must return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
143
157
|
- **delay**: Artificial delay in milliseconds before verification (defaults to 0).
|
|
144
158
|
- **disableautofocus**: If true, prevents the code-challenge input from automatically receiving focus on render (defaults to `false`).
|
|
145
159
|
- **expire**: Challenge expiration duration in milliseconds.
|
|
@@ -155,6 +169,7 @@ Additional options:
|
|
|
155
169
|
- **name**: Name of the hidden field containing the payload (defaults to "altcha").
|
|
156
170
|
- **strings**: JSON-encoded translation strings. Refer to [customization](https://altcha.org/docs/widget-customization).
|
|
157
171
|
- **refetchonexpire**: Automatically re-fetch and re-validate when the challenge expires (defaults to true).
|
|
172
|
+
- **verifyurl**: URL for server-side verification requests. This option is automatically configured with Sentinel. Override this setting only if using a custom server implementation. Supports `fn:function_name` format to call a global JS function instead.
|
|
158
173
|
- **workers**: Number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`, max value `16`).
|
|
159
174
|
- **workerurl**: URL of the Worker script (defaults to `./worker.js`, only works with `external` build).
|
|
160
175
|
|
|
@@ -168,47 +183,80 @@ Development / Testing options:
|
|
|
168
183
|
- **mockerror**: Causes verification to always fail with a "mock" error.
|
|
169
184
|
- **test**: Generates a "mock" challenge within the widget, bypassing the request to `challengeurl`.
|
|
170
185
|
|
|
171
|
-
## Internationalization (i18n)
|
|
186
|
+
## Internationalization (i18n)
|
|
172
187
|
|
|
173
|
-
ALTCHA supports **48+ languages**.
|
|
188
|
+
ALTCHA supports **48+ languages**. You can import individual language translations or a bundle that includes all of them.
|
|
189
|
+
|
|
190
|
+
### Importing Translations
|
|
191
|
+
|
|
192
|
+
To import all translations:
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
import 'altcha/i18n/all';
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
To import specific languages only:
|
|
174
199
|
|
|
175
200
|
```js
|
|
176
|
-
import 'altcha';
|
|
177
|
-
import 'altcha/i18n/all'; // All languages
|
|
178
|
-
// Or import specific languages:
|
|
179
201
|
import 'altcha/i18n/de';
|
|
180
202
|
import 'altcha/i18n/fr-fr';
|
|
181
203
|
```
|
|
182
204
|
|
|
183
|
-
|
|
205
|
+
Alternatively, you can import the combined bundle, which includes both the widget and all translations:
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
import 'altcha/i18n';
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Language Detection
|
|
212
|
+
|
|
213
|
+
The widget automatically detects the language from:
|
|
214
|
+
|
|
215
|
+
- The `<html lang="...">` attribute
|
|
216
|
+
- The user's browser settings (`navigator.languages`)
|
|
217
|
+
|
|
218
|
+
To override the language manually, use the `language` attribute:
|
|
184
219
|
|
|
185
220
|
```html
|
|
186
221
|
<altcha-widget language="de"></altcha-widget>
|
|
187
222
|
```
|
|
188
223
|
|
|
189
|
-
|
|
224
|
+
### Customizing Translations
|
|
225
|
+
|
|
226
|
+
You can override default translations by updating the global `altchaI18n` registry (`globalThis.altchaI18n` or `window.altchaI18n`):
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
import 'altcha/i18n/de';
|
|
230
|
+
|
|
231
|
+
globalThis.altchaI18n.set('de', {
|
|
232
|
+
...globalThis.altchaI18n.get('de'),
|
|
233
|
+
label: 'Ich bin ein Mensch', // Custom label
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Code Challenges
|
|
190
238
|
|
|
191
|
-
For additional verification, ALTCHA supports **image/audio code challenges** (e.g., "Enter the code from the image"). This feature requires
|
|
239
|
+
For additional verification, ALTCHA supports **image/audio code challenges** (e.g., "Enter the code from the image"). This feature requires [ALTCHA Sentinel](https://altcha.org/docs/v2/sentinel) or a custom server implementation.
|
|
192
240
|
|
|
193
|
-
## Plugins
|
|
241
|
+
## Plugins
|
|
194
242
|
|
|
195
|
-
Extend functionality with plugins:
|
|
243
|
+
Extend functionality with plugins:
|
|
196
244
|
|
|
197
245
|
```js
|
|
198
246
|
import 'altcha/obfuscation'; // Data obfuscation
|
|
199
|
-
import 'altcha/upload';
|
|
200
|
-
import 'altcha';
|
|
247
|
+
import 'altcha/upload'; // File uploads
|
|
248
|
+
import 'altcha'; // Main package
|
|
201
249
|
```
|
|
202
250
|
|
|
203
|
-
Enable plugins per widget:
|
|
251
|
+
Enable plugins per widget:
|
|
204
252
|
|
|
205
253
|
```html
|
|
206
254
|
<altcha-widget plugins="upload,obfuscation"></altcha-widget>
|
|
207
255
|
```
|
|
208
256
|
|
|
209
|
-
### Available Plugins
|
|
257
|
+
### Available Plugins
|
|
210
258
|
|
|
211
|
-
- **obfuscation**: Secure sensitive data (emails, phone numbers).
|
|
259
|
+
- **obfuscation**: Secure sensitive data (emails, phone numbers).
|
|
212
260
|
- **upload**: File uploads with ALTCHA Sentinel or a custom backend.
|
|
213
261
|
|
|
214
262
|
## Programmatic Configuration
|
|
@@ -229,7 +277,7 @@ document.querySelector('#altcha').configure({
|
|
|
229
277
|
});
|
|
230
278
|
```
|
|
231
279
|
|
|
232
|
-
Available configuration options:
|
|
280
|
+
Available configuration options:
|
|
233
281
|
|
|
234
282
|
```ts
|
|
235
283
|
export interface Configure {
|
|
@@ -248,7 +296,9 @@ export interface Configure {
|
|
|
248
296
|
};
|
|
249
297
|
challengeurl?: string;
|
|
250
298
|
credentials?: 'omit' | 'same-origin' | 'include' | boolean;
|
|
251
|
-
customfetch?:
|
|
299
|
+
customfetch?:
|
|
300
|
+
| string
|
|
301
|
+
| ((url: string, init?: RequestInit) => Promise<Response>);
|
|
252
302
|
debug?: boolean;
|
|
253
303
|
delay?: number;
|
|
254
304
|
disableautofocus?: boolean;
|
|
@@ -280,7 +330,7 @@ export interface Configure {
|
|
|
280
330
|
verified: string;
|
|
281
331
|
verifying: string;
|
|
282
332
|
waitAlert: string;
|
|
283
|
-
}
|
|
333
|
+
};
|
|
284
334
|
test?: boolean | number | 'delay';
|
|
285
335
|
verifyurl?: string;
|
|
286
336
|
workers?: number;
|
|
@@ -305,7 +355,7 @@ enum State {
|
|
|
305
355
|
VERIFYING = 'verifying',
|
|
306
356
|
UNVERIFIED = 'unverified',
|
|
307
357
|
EXPIRED = 'expired',
|
|
308
|
-
}
|
|
358
|
+
}
|
|
309
359
|
```
|
|
310
360
|
|
|
311
361
|
Using events:
|
|
@@ -320,14 +370,14 @@ document.querySelector('#altcha').addEventListener('statechange', (ev) => {
|
|
|
320
370
|
> [!IMPORTANT]
|
|
321
371
|
> Both programmatic configuration and event listeners have to called/attached after the ALTCHA script loads, such as within `window.addEventListener('load', ...)`.
|
|
322
372
|
|
|
323
|
-
## Contributing
|
|
373
|
+
## Contributing
|
|
324
374
|
|
|
325
375
|
See [Contributing Guide](https://github.com/altcha-org/altcha/blob/main/CONTRIBUTING.md) and please follow our [Code of Conduct](https://github.com/altcha-org/altcha/blob/main/CODE_OF_CONDUCT.md).
|
|
326
376
|
|
|
327
|
-
## Sponsorship
|
|
377
|
+
## Sponsorship
|
|
328
378
|
|
|
329
|
-
This project is sponsored by [BAUSW.com - Digital Construction Site Diary](https://bausw.com/digital-construction-diary/), promoting transparency and trust in construction projects with real-time documentation.
|
|
379
|
+
This project is sponsored by [BAUSW.com - Digital Construction Site Diary](https://bausw.com/digital-construction-diary/), promoting transparency and trust in construction projects with real-time documentation.
|
|
330
380
|
|
|
331
|
-
## License
|
|
381
|
+
## License
|
|
332
382
|
|
|
333
|
-
**MIT**
|
|
383
|
+
**MIT**
|
package/dist/altcha.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Writable } from 'svelte/store';
|
|
1
2
|
export {};
|
|
2
3
|
|
|
3
4
|
declare module 'altcha';
|
|
@@ -5,8 +6,10 @@ declare module 'altcha';
|
|
|
5
6
|
declare global {
|
|
6
7
|
var altchaCreateWorker: (url?: string) => Worker;
|
|
7
8
|
var altchaPlugins: any[];
|
|
8
|
-
var altchaI18n:
|
|
9
|
-
|
|
9
|
+
var altchaI18n: {
|
|
10
|
+
get: (language: string) => Record<string, string>;
|
|
11
|
+
set: (language: string, translation: Record<string, string>) => void;
|
|
12
|
+
store: Writable<Record<string, Record<string, string>>>;
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
type AltchaState = 'error' | 'expired' | 'verified' | 'verifying' | 'unverified';
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { Writable } from 'svelte/store';
|
|
2
|
+
export {};
|
|
3
|
+
|
|
4
|
+
declare module 'altcha';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
var altchaCreateWorker: (url?: string) => Worker;
|
|
8
|
+
var altchaPlugins: any[];
|
|
9
|
+
var altchaI18n: {
|
|
10
|
+
get: (language: string) => Record<string, string>;
|
|
11
|
+
set: (language: string, translation: Record<string, string>) => void;
|
|
12
|
+
store: Writable<Record<string, Record<string, string>>>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type AltchaState = 'error' | 'expired' | 'verified' | 'verifying' | 'unverified';
|
|
16
|
+
|
|
17
|
+
interface AltchaStateChangeEvent extends CustomEvent<{
|
|
18
|
+
payload?: string;
|
|
19
|
+
state: AltchaState;
|
|
20
|
+
}> {}
|
|
21
|
+
|
|
22
|
+
interface AltchaVerifiedEvent extends CustomEvent<{
|
|
23
|
+
payload: string;
|
|
24
|
+
}> {}
|
|
25
|
+
|
|
26
|
+
interface AltchaServerVerificationEvent extends CustomEvent<Record<string, unknown>> {}
|
|
27
|
+
|
|
28
|
+
interface AltchaWidgetOptions {
|
|
29
|
+
auto?: 'off' | 'onfocus' | 'onload' | 'onsubmit';
|
|
30
|
+
/** @deprecated */
|
|
31
|
+
blockspam?: boolean;
|
|
32
|
+
challengeurl?: string;
|
|
33
|
+
challengejson?: string;
|
|
34
|
+
credentials?: 'omit' | 'same-origin' | 'include' | boolean | undefined;
|
|
35
|
+
customfetch?: string | ((url: string, init?: RequestInit) => Promise<Response>);
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
delay?: number;
|
|
38
|
+
disableautofocus?: boolean;
|
|
39
|
+
expire?: number;
|
|
40
|
+
floating?: 'auto' | 'top' | 'bottom' | 'false' | '' | boolean;
|
|
41
|
+
floatinganchor?: string;
|
|
42
|
+
floatingoffset?: number;
|
|
43
|
+
floatingpersist?: 'focus' | boolean;
|
|
44
|
+
hidefooter?: boolean;
|
|
45
|
+
hidelogo?: boolean;
|
|
46
|
+
id?: string;
|
|
47
|
+
language?: string;
|
|
48
|
+
maxnumber?: number;
|
|
49
|
+
mockerror?: boolean;
|
|
50
|
+
name?: string;
|
|
51
|
+
obfuscated?: string;
|
|
52
|
+
oncleartext?: (ev: CustomEvent) => void;
|
|
53
|
+
onload?: (ev: CustomEvent) => void;
|
|
54
|
+
onstatechange?: (ev: CustomEvent) => void;
|
|
55
|
+
onverified?: (ev: CustomEvent) => void;
|
|
56
|
+
onserververification?: (ev: CustomEvent) => void;
|
|
57
|
+
onupload?: (ev: CustomEvent) => void;
|
|
58
|
+
onuploadprogress?: (ev: CustomEvent) => void;
|
|
59
|
+
plugins?: string;
|
|
60
|
+
refetchonexpire?: boolean;
|
|
61
|
+
/** @deprecated */
|
|
62
|
+
spamfilter?: boolean | 'ipAddress';
|
|
63
|
+
strings?: string;
|
|
64
|
+
test?: boolean | number;
|
|
65
|
+
verifyurl?: string;
|
|
66
|
+
workers?: number;
|
|
67
|
+
workerurl?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface AltchaWidgetMethods {
|
|
71
|
+
configure: (options: AltchaWidgetOptions) => void;
|
|
72
|
+
clarify: () => Promise<void>;
|
|
73
|
+
getConfiguration: () => AltchaWidgetOptions;
|
|
74
|
+
getFloatingAnchor: () => HTMLElement | null;
|
|
75
|
+
getPlugin: <T = unknown>(name: string) => T;
|
|
76
|
+
getState: () => AltchaState;
|
|
77
|
+
hide: () => void;
|
|
78
|
+
repositionFloating: (viewportOffset?: number) => void;
|
|
79
|
+
reset: (newState?: AltchaState, err?: string | null) => void;
|
|
80
|
+
setFloatingAnchor: (el: HTMLElement) => void;
|
|
81
|
+
setState: (newState: AltchaState, err?: string | null) => void;
|
|
82
|
+
show: () => void;
|
|
83
|
+
verify: () => Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface AltchaWidget extends AltchaWidgetOptions {
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface AltchaWidgetCSSProperties extends Partial<CSSStyleDeclaration> {
|
|
90
|
+
'--altcha-border-width'?: string;
|
|
91
|
+
'--altcha-border-radius'?: string;
|
|
92
|
+
'--altcha-color-base'?: string;
|
|
93
|
+
'--altcha-color-border'?: string;
|
|
94
|
+
'--altcha-color-text'?: string;
|
|
95
|
+
'--altcha-color-border-focus'?: string;
|
|
96
|
+
'--altcha-color-error-text'?: string;
|
|
97
|
+
'--altcha-color-footer-bg'?: string;
|
|
98
|
+
'--altcha-max-width'?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface AltchaWidgetReactRefObject<T> {
|
|
102
|
+
current: T | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface AltchaWidgetReact extends AltchaWidget {
|
|
106
|
+
children?: string | number | Node | DocumentFragment;
|
|
107
|
+
ref?: AltchaWidgetReactRefObject<HTMLElement>;
|
|
108
|
+
style?: AltchaWidgetCSSProperties;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
namespace JSX {
|
|
112
|
+
interface IntrinsicElements {
|
|
113
|
+
'altcha-widget': AltchaWidgetReact;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
namespace React {
|
|
118
|
+
namespace JSX {
|
|
119
|
+
interface IntrinsicElements {
|
|
120
|
+
'altcha-widget': AltchaWidgetReact;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
namespace svelteHTML {
|
|
126
|
+
interface IntrinsicElements {
|
|
127
|
+
'altcha-widget': AltchaWidgetSvelte;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface AltchaWidgetSvelte extends AltchaWidget {
|
|
131
|
+
style?: string;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare module "react" {
|
|
137
|
+
namespace JSX {
|
|
138
|
+
interface IntrinsicElements {
|
|
139
|
+
'altcha-widget': AltchaWidgetReact;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare module "react/jsx-runtime" {
|
|
145
|
+
namespace JSX {
|
|
146
|
+
interface IntrinsicElements {
|
|
147
|
+
'altcha-widget': AltchaWidgetReact;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
declare module "react/jsx-dev-runtime" {
|
|
153
|
+
namespace JSX {
|
|
154
|
+
interface IntrinsicElements {
|
|
155
|
+
'altcha-widget': AltchaWidgetReact;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|