altcha 1.4.2 → 2.0.0-beta.2

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.
Files changed (114) hide show
  1. package/README.md +144 -156
  2. package/dist/altcha.d.ts +6 -0
  3. package/dist/altcha.js +1683 -1383
  4. package/dist/altcha.umd.cjs +10 -7
  5. package/dist_external/altcha.css +127 -13
  6. package/dist_external/altcha.d.ts +6 -0
  7. package/dist_external/altcha.js +1667 -1367
  8. package/dist_external/altcha.umd.cjs +9 -6
  9. package/dist_i18n/all.js +810 -0
  10. package/dist_i18n/all.umd.cjs +1 -0
  11. package/dist_i18n/americas.js +54 -0
  12. package/dist_i18n/americas.umd.cjs +1 -0
  13. package/dist_i18n/ar.js +21 -0
  14. package/dist_i18n/ar.umd.cjs +1 -0
  15. package/dist_i18n/asia.js +288 -0
  16. package/dist_i18n/asia.umd.cjs +1 -0
  17. package/dist_i18n/bg.js +21 -0
  18. package/dist_i18n/bg.umd.cjs +1 -0
  19. package/dist_i18n/bn.js +21 -0
  20. package/dist_i18n/bn.umd.cjs +1 -0
  21. package/dist_i18n/cs.js +21 -0
  22. package/dist_i18n/cs.umd.cjs +1 -0
  23. package/dist_i18n/da.js +21 -0
  24. package/dist_i18n/da.umd.cjs +1 -0
  25. package/dist_i18n/de.js +21 -0
  26. package/dist_i18n/de.umd.cjs +1 -0
  27. package/dist_i18n/el.js +21 -0
  28. package/dist_i18n/el.umd.cjs +1 -0
  29. package/dist_i18n/en.js +21 -0
  30. package/dist_i18n/en.umd.cjs +1 -0
  31. package/dist_i18n/es-419.js +21 -0
  32. package/dist_i18n/es-419.umd.cjs +1 -0
  33. package/dist_i18n/es-es.js +21 -0
  34. package/dist_i18n/es-es.umd.cjs +1 -0
  35. package/dist_i18n/et.js +21 -0
  36. package/dist_i18n/et.umd.cjs +1 -0
  37. package/dist_i18n/eu.js +21 -0
  38. package/dist_i18n/eu.umd.cjs +1 -0
  39. package/dist_i18n/europe.js +468 -0
  40. package/dist_i18n/europe.umd.cjs +1 -0
  41. package/dist_i18n/fi.js +21 -0
  42. package/dist_i18n/fi.umd.cjs +1 -0
  43. package/dist_i18n/fr-ca.js +21 -0
  44. package/dist_i18n/fr-ca.umd.cjs +1 -0
  45. package/dist_i18n/fr-fr.js +21 -0
  46. package/dist_i18n/fr-fr.umd.cjs +1 -0
  47. package/dist_i18n/ga.js +21 -0
  48. package/dist_i18n/ga.umd.cjs +1 -0
  49. package/dist_i18n/he.js +21 -0
  50. package/dist_i18n/he.umd.cjs +1 -0
  51. package/dist_i18n/hi.js +21 -0
  52. package/dist_i18n/hi.umd.cjs +1 -0
  53. package/dist_i18n/hr.js +21 -0
  54. package/dist_i18n/hr.umd.cjs +1 -0
  55. package/dist_i18n/hu.js +21 -0
  56. package/dist_i18n/hu.umd.cjs +1 -0
  57. package/dist_i18n/id.js +21 -0
  58. package/dist_i18n/id.umd.cjs +1 -0
  59. package/dist_i18n/it.js +21 -0
  60. package/dist_i18n/it.umd.cjs +1 -0
  61. package/dist_i18n/ja.js +21 -0
  62. package/dist_i18n/ja.umd.cjs +1 -0
  63. package/dist_i18n/ko.js +21 -0
  64. package/dist_i18n/ko.umd.cjs +1 -0
  65. package/dist_i18n/lt.js +21 -0
  66. package/dist_i18n/lt.umd.cjs +1 -0
  67. package/dist_i18n/lv.js +21 -0
  68. package/dist_i18n/lv.umd.cjs +1 -0
  69. package/dist_i18n/mr.js +21 -0
  70. package/dist_i18n/mr.umd.cjs +1 -0
  71. package/dist_i18n/mt.js +21 -0
  72. package/dist_i18n/mt.umd.cjs +1 -0
  73. package/dist_i18n/nl.js +21 -0
  74. package/dist_i18n/nl.umd.cjs +1 -0
  75. package/dist_i18n/pl.js +21 -0
  76. package/dist_i18n/pl.umd.cjs +1 -0
  77. package/dist_i18n/pt-br.js +21 -0
  78. package/dist_i18n/pt-br.umd.cjs +1 -0
  79. package/dist_i18n/pt-pt.js +21 -0
  80. package/dist_i18n/pt-pt.umd.cjs +1 -0
  81. package/dist_i18n/ro.js +21 -0
  82. package/dist_i18n/ro.umd.cjs +1 -0
  83. package/dist_i18n/ru.js +21 -0
  84. package/dist_i18n/ru.umd.cjs +1 -0
  85. package/dist_i18n/sk.js +21 -0
  86. package/dist_i18n/sk.umd.cjs +1 -0
  87. package/dist_i18n/sl.js +21 -0
  88. package/dist_i18n/sl.umd.cjs +1 -0
  89. package/dist_i18n/sv.js +21 -0
  90. package/dist_i18n/sv.umd.cjs +1 -0
  91. package/dist_i18n/ta.js +21 -0
  92. package/dist_i18n/ta.umd.cjs +1 -0
  93. package/dist_i18n/te.js +21 -0
  94. package/dist_i18n/te.umd.cjs +1 -0
  95. package/dist_i18n/th.js +21 -0
  96. package/dist_i18n/th.umd.cjs +1 -0
  97. package/dist_i18n/tr.js +21 -0
  98. package/dist_i18n/tr.umd.cjs +1 -0
  99. package/dist_i18n/uk.js +21 -0
  100. package/dist_i18n/uk.umd.cjs +1 -0
  101. package/dist_i18n/ur.js +21 -0
  102. package/dist_i18n/ur.umd.cjs +1 -0
  103. package/dist_i18n/vi.js +21 -0
  104. package/dist_i18n/vi.umd.cjs +1 -0
  105. package/dist_i18n/zh-cn.js +21 -0
  106. package/dist_i18n/zh-cn.umd.cjs +1 -0
  107. package/dist_i18n/zh-tw.js +21 -0
  108. package/dist_i18n/zh-tw.umd.cjs +1 -0
  109. package/dist_plugins/obfuscation.js +10 -10
  110. package/dist_plugins/obfuscation.umd.cjs +1 -1
  111. package/dist_plugins/upload.js +145 -133
  112. package/dist_plugins/upload.umd.cjs +4 -4
  113. package/package.json +12 -8
  114. package/postinstall.js +0 -10
package/README.md CHANGED
@@ -1,110 +1,143 @@
1
- # ALTCHA
1
+ # ALTCHA
2
2
 
3
- ALTCHA leverages a proof-of-work mechanism to safeguard your website, APIs, and online services from spam and abuse. Unlike traditional solutions, ALTCHA is self-hosted, does not rely on cookies or fingerprinting, and ensures complete user privacy. It is fully compliant with [GDPR](https://altcha.org/docs/gdpr/), [WCAG 2.2 AA-level](https://altcha.org/docs/wcag/), and the [European Accessibility Act](https://altcha.org/docs/european-accessibility-act-2025/).
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
- For more details, visit [ALTCHA](https://altcha.org).
5
+ ALTCHA is fully compliant with:
6
6
 
7
- ## Features
7
+ - **Global privacy regulations**: GDPR, HIPAA, CCPA, 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/)
8
9
 
9
- - **Frictionless Experience**: Utilizes proof-of-work (PoW) instead of visual puzzles, ensuring a seamless user experience.
10
- - **Cookie-Free Design**: Built to be GDPR-compliant by default, with no cookies or tracking.
11
- - **Fully Accessible**: Meets WCAG 2.2 AA-level standards and complies with the European Accessibility Act (EAA).
12
- - **Lightweight**: Minimal bundle size for fast page loads and optimal performance.
13
- - **Self-Hosted**: Operates independently without depending on third-party services.
14
- - **SaaS Option Available**: Get started quickly with the SaaS API at [altcha.org](https://altcha.org/).
10
+ For more details, visit [altcha.org](https://altcha.org).
15
11
 
16
- ## Examples
12
+ ## Features
17
13
 
18
- - [React](https://github.com/altcha-org/altcha-starter-react-ts)
19
- - [Vue](https://github.com/altcha-org/altcha-starter-vue-ts)
20
- - [Svelte](https://github.com/altcha-org/altcha-starter-svelte-ts)
21
- - [Solid](https://github.com/altcha-org/altcha-starter-solid-ts)
22
- - [Lit](https://github.com/altcha-org/altcha-starter-lit-ts)
23
- - [Angular](https://github.com/altcha-org/altcha-starter-angular)
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.
24
20
 
25
- ## Server Integrations
21
+ ## What’s New in v2
26
22
 
27
- - [TypeScript](https://github.com/altcha-org/altcha-lib)
28
- - [PHP](https://github.com/altcha-org/altcha-lib-php)
29
- - [Go](https://github.com/altcha-org/altcha-lib-go)
30
- - [Python](https://github.com/altcha-org/altcha-lib-py)
31
- - [Java](https://github.com/altcha-org/altcha-lib-java)
32
- - [Ruby](https://github.com/altcha-org/altcha-lib-rb)
33
- - [Elixir](https://github.com/altcha-org/altcha-lib-ex)
23
+ Version 2 introduces enhanced accessibility, expanded language support (42+ languages), and integration with **ALTCHA Sentinel**—a self-hosted anti-spam solution for websites, apps, and services.
34
24
 
35
- ## CMS
25
+ ### Key Improvements in v2
36
26
 
37
- - [WordPress plugin](https://github.com/altcha-org/wordpress-plugin)
38
- - [Other libraries and plugins](https://altcha.org/docs/integrations/)
27
+ - **Built-in Internationalization (i18n)** for 42+ languages
28
+ - **Improved RTL (right-to-left) language support**
29
+ - **Enhanced WCAG accessibility**
30
+ - **Support for accessible code challenges** (image + audio options)
39
31
 
40
- ## More anti-spam solutions
32
+ ## Examples
41
33
 
42
- - [Spam Filter](https://altcha.org/anti-spam) - stop sophisticated attacks and human-generated spam by classifying data.
34
+ Explore starter templates for popular frameworks:
43
35
 
44
- ## Usage
36
+ - [React](https://github.com/altcha-org/altcha-starter-react-ts)
37
+ - [Vue](https://github.com/altcha-org/altcha-starter-vue-ts)
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)
45
42
 
46
- 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).
43
+ ## Server Integrations
47
44
 
48
- ### 1. Install ALTCHA
45
+ - [TypeScript](https://github.com/altcha-org/altcha-lib)
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)
52
+
53
+ ## Plugins & CMS
54
+
55
+ - [Libraries and plugins](https://altcha.org/docs/integrations/)
56
+
57
+ ## Usage
58
+
59
+ 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).
60
+
61
+ ### 1. Install ALTCHA
49
62
 
50
63
  ```sh
51
64
  npm install altcha
52
65
  ```
53
66
 
54
- import `altcha` in your main file:
67
+ Import in your main file:
55
68
 
56
69
  ```js
57
70
  import 'altcha';
58
71
  ```
59
72
 
60
- or insert `<script>` tag to your website:
73
+ Or load via `<script>` tag:
61
74
 
62
75
  ```html
63
76
  <script async defer src="/altcha.js" type="module"></script>
64
77
  ```
65
78
 
66
- CDN: https://cdn.jsdelivr.net/gh/altcha-org/altcha@main/dist/altcha.min.js
79
+ **CDN**:
80
+ ```html
81
+ <script async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha@main/dist/altcha.min.js" type="module"></script>
82
+ ```
67
83
 
68
- ### 2. Use `<altcha-widget>` tag in your forms
84
+ ### 2. Add `<altcha-widget>` to Your Forms
69
85
 
70
86
  ```html
71
87
  <form>
72
- <altcha-widget
73
- challengeurl="https://..."
74
- ></altcha-widget>
88
+ <altcha-widget challengeurl="https://..."></altcha-widget>
75
89
  </form>
76
90
  ```
77
91
 
78
- See the [configuration](#configuration) below or visit the [website integration documentation](https://altcha.org/docs/website-integration).
92
+ See [configuration options](#configuration) or the [website integration docs](https://altcha.org/docs/website-integration).
93
+
94
+ ### 3. Integrate with Your Server
79
95
 
80
- ### 3. Integrate ALTCHA with your server
96
+ Refer to the [server documentation](https://altcha.org/docs/server-integration) for implementation details.
81
97
 
82
- See [server documentation](https://altcha.org/docs/server-integration) for more details.
98
+ ## Supported Browsers
83
99
 
84
- ## Bundle Size
100
+ ALTCHA works on modern browsers with **Web Crypto API** support (specifically `crypto.subtle` - [caniuse.com](https://caniuse.com/?search=subtle)).
85
101
 
86
- ALTCHA's default bundle is lightweight, combining all assets, including CSS and the JavaScript Web Worker, into a single file. When GZIPped, it totals only 17 kB, making ALTCHA’s widget 94% smaller than reCAPTCHA.
102
+ **Supported**:
87
103
 
88
- |Distribution|Size (GZIPped)|
89
- |---|---|
90
- |ALTCHA (v1.x)|17 kB|
91
- |hCaptcha|48+ kB|
92
- |reCAPTCHA|270+ kB|
104
+ - Chrome (desktop & Android)
105
+ - Edge
106
+ - Firefox (desktop & Android)
107
+ - Safari (macOS & iOS)
108
+ - Any browser supporting Web Components + Web Crypto
93
109
 
94
- ## Content Security Policy (CSP)
110
+ **Not Supported**:
95
111
 
96
- The default distribution bundle of the WebComponent includes styles and the worker in a single file. This might cause issues with strict CSP rules. If you require strict CSP compliance, consider using the scripts located in the `/dist_external` directory. For more details, please refer to the [documentation](https://altcha.org/docs/website-integration).
112
+ - Internet Explorer 11 (or older)
97
113
 
98
- ## Configuration
114
+ ## Bundle Size
115
+
116
+ ALTCHA is optimized for performance:
117
+
118
+ | Distribution | Size (GZIPped) |
119
+ |-------------------|----------------|
120
+ | ALTCHA (v2.x) | 26 kB |
121
+ | hCaptcha | 48+ kB |
122
+ | reCAPTCHA | 270+ kB |
123
+
124
+ When GZIPped, it totals about 26 kB, making ALTCHA’s widget about 90% smaller than reCAPTCHA.
125
+
126
+ ## Content Security Policy (CSP)
127
+
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).
129
+
130
+ ## Configuration
99
131
 
100
132
  Required options (at least one is required):
101
133
 
102
- - **challengeurl**: URL of your server to fetch the challenge from. Refer to [server integration](https://altcha.org/docs/server-integration).
103
- - **challengejson**: JSON-encoded challenge data. If avoiding an HTTP request to `challengeurl`, provide the data here.
134
+ - **challengeurl**: Server endpoint to fetch the challenge.
135
+ - **challengejson**: Preloaded JSON challenge data (avoids HTTP requests).
104
136
 
105
137
  Additional options:
106
138
 
107
139
  - **auto**: Automatically verify without user interaction (possible values: `off`, `onfocus`, `onload`, `onsubmit`).
140
+ - **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`).
108
141
  - **customfetch**: A custom `fetch` function for retrieving the challenge.
109
142
  Accepts `url: string` and `init: RequestInit` as arguments and must return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
110
143
  - **delay**: Artificial delay in milliseconds before verification (defaults to 0).
@@ -116,6 +149,7 @@ Additional options:
116
149
  - **hidefooter**: Hide the footer (ALTCHA link).
117
150
  - **hidelogo**: Hide the ALTCHA logo.
118
151
  - **id**: The checkbox `id` attribute. Useful for multiple instances of the widget on the same page.
152
+ - **language**: The ISO alpha-2 code of the language to use (the language file be imported from `altcha/i18n/*`).
119
153
  - **maxnumber**: Max number to iterate to (defaults to 1,000,000).
120
154
  - **name**: Name of the hidden field containing the payload (defaults to "altcha").
121
155
  - **strings**: JSON-encoded translation strings. Refer to [customization](https://altcha.org/docs/widget-customization).
@@ -123,12 +157,6 @@ Additional options:
123
157
  - **workers**: Number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`, max value `16`).
124
158
  - **workerurl**: URL of the Worker script (defaults to `./worker.js`, only works with `external` build).
125
159
 
126
- Spam Filter-related options:
127
-
128
- - **blockspam**: Only used with the `spamfilter` option. If enabled, it will block form submission and fail verification if the Spam Filter returns a negative classification. This prevents form submission.
129
- - **spamfilter**: Enable [Spam Filter](#spam-filter).
130
- - **verifyurl**: URL for server-side verification requests. This option is automatically configured when the `spamfilter` option is used. Override this setting only if using a custom server implementation.
131
-
132
160
  Data Obfuscation options:
133
161
 
134
162
  - **obfuscated**: The [obfuscated data](https://altcha.org/docs/obfuscation) provided as a base64-encoded string (requires `altcha/obfuscation` plugin). Use only without `challengeurl`/`challengejson`.
@@ -139,24 +167,48 @@ Development / Testing options:
139
167
  - **mockerror**: Causes verification to always fail with a "mock" error.
140
168
  - **test**: Generates a "mock" challenge within the widget, bypassing the request to `challengeurl`.
141
169
 
142
- ## Plugins
170
+ ## Internationalization (i18n)
143
171
 
144
- Version 0.9.x introduced _plugins_ that can be enabled by importing individual plugin scripts:
172
+ ALTCHA supports **42+ languages**. Import translations from `altcha/i18n/*`:
145
173
 
146
174
  ```js
147
- import 'altcha/obfuscation';
148
175
  import 'altcha';
176
+ import 'altcha/i18n/all'; // All languages
177
+ // Or import specific languages:
178
+ import 'altcha/i18n/de';
179
+ import 'altcha/i18n/fr';
180
+ ```
181
+
182
+ The widget auto-detects language from `<html lang="...">` or `navigator.languages`. Override with the `language` attribute:
183
+
184
+ ```html
185
+ <altcha-widget language="de"></altcha-widget>
186
+ ```
187
+
188
+ ## Code Challenges
189
+
190
+ For additional verification, ALTCHA supports **image/audio code challenges** (e.g., "Enter the code from the image"). This feature requires **ALTCHA Sentinel** or a custom server implementation.
191
+
192
+ ## Plugins
193
+
194
+ Extend functionality with plugins:
195
+
196
+ ```js
197
+ import 'altcha/obfuscation'; // Data obfuscation
198
+ import 'altcha/upload'; // File uploads
199
+ import 'altcha'; // Main package
149
200
  ```
150
201
 
151
- It is recommended to import plugins _before_ the main `altcha` package to ensure proper registration before any widget instance is created.
202
+ Enable plugins per widget:
152
203
 
153
- Available plugins built-in to the `altcha` package:
204
+ ```html
205
+ <altcha-widget plugins="upload,obfuscation"></altcha-widget>
206
+ ```
154
207
 
155
- - `altcha/analytics`: Enable analytics with [ALTCHA Forms](https://altcha.org/forms/). See [HTML submissions documentation](https://altcha.org/docs/forms/features/html-submissions).
156
- - `altcha/obfuscation`: Enable [obfuscation](https://altcha.org/docs/obfuscation) for sensitive data such as email addresses or phone numbers.
157
- - `altcha/upload`: Enable file upload from `type=file` fields to [ALTCHA Forms](https://altcha.org/forms/). See [HTML submissions documentation](https://altcha.org/docs/forms/features/html-submissions).
208
+ ### Available Plugins
158
209
 
159
- To enable specific plugins for a particular instance of the widget, use the `plugins` attribute in the widget tag. List the names of the plugins you want to enable, separated by commas, such as `plugins="analytics,obfuscation"`. Plugins still need to be imported as described above. The `plugins` attribute only specifies which plugins should be active for that instance, even if other plugins are already imported.
210
+ - **obfuscation**: Secure sensitive data (emails, phone numbers).
211
+ - **upload**: File uploads with ALTCHA Sentinel or a custom backend.
160
212
 
161
213
  ## Programmatic Configuration
162
214
 
@@ -182,6 +234,11 @@ Available configuration options:
182
234
  export interface Configure {
183
235
  auto?: 'off' | 'onfocus' | 'onload' | 'onsubmit';
184
236
  challenge?: {
237
+ codeChallenge?: {
238
+ audio?: string;
239
+ image: string;
240
+ length?: number;
241
+ };
185
242
  algorithm: string;
186
243
  challenge: string;
187
244
  maxnumber?: number;
@@ -189,6 +246,7 @@ export interface Configure {
189
246
  signature: string;
190
247
  };
191
248
  challengeurl?: string;
249
+ credentials?: 'omit' | 'same-origin' | 'include' | boolean;
192
250
  customfetch?: string | ((url: string, init?: RequestInit) => Promise<Response>);
193
251
  debug?: boolean;
194
252
  delay?: number;
@@ -204,12 +262,19 @@ export interface Configure {
204
262
  name?: string;
205
263
  obfuscated?: string;
206
264
  refetchonexpire?: boolean;
207
- spamfilter?: boolean | 'ipAddress' | SpamFilter;
265
+ spamfilter?: boolean | 'ipAddress' | SpamFilter; // deprecated
208
266
  strings?: {
267
+ ariaLinkLabel: strin;
268
+ enterCode: string;
269
+ enterCodeAria: string;
209
270
  error: string;
210
271
  expired: string;
211
272
  footer: string;
273
+ getAudioChallenge: string;
212
274
  label: string;
275
+ loading: string;
276
+ reload: strin;
277
+ verificationRequired: string;
213
278
  verified: string;
214
279
  verifying: string;
215
280
  waitAlert: string;
@@ -221,51 +286,18 @@ export interface Configure {
221
286
  }
222
287
  ```
223
288
 
224
- ## Custom `fetch` Function
225
-
226
- The widget does not send cookies (i.e., it does not use `credentials: 'include'`) when requesting the challenge from the server. To modify this behavior or add custom request headers, use the `customfetch` configuration option. This option lets you define a custom request function.
227
-
228
- The custom function must return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
229
-
230
- ### Sending Cookies
231
-
232
- To include cookies in the request, use `credentials: 'include'`:
233
-
234
- ```ts
235
- function altchaCustomFetch(url: string, init: RequestInit) {
236
- return fetch(url, {
237
- ...init,
238
- credentials: 'include', // Include cookies with the request
239
- });
240
- }
241
- ```
242
-
243
- For more details on possible request options, refer to the [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) documentation.
244
-
245
- ### Using `customfetch`
246
-
247
- The `customfetch` option can accept either:
248
- - A `string` (the name of a globally accessible function defined in the global context, such as `window`), or
249
- - A function itself.
250
-
251
- ### Example Usage
252
-
253
- ```html
254
- <altcha-widget
255
- challengeurl="https://example.com/challenge"
256
- customfetch="altchaCustomFetch"
257
- ></altcha-widget>
258
- ```
259
-
260
289
  ## Events
261
290
 
291
+ - **code** - Triggers when code-challenge verification is requested.
262
292
  - **load** - Triggers when the widget loads. The exported methods become available after this event.
263
- - **serververification** - Triggers upon a server verification (only in conjunction with `spamfilter`).
293
+ - **sentinelverification** - Triggers upon a verification with ALTCHA Sentinel.
294
+ - **serververification** - (Deprecated) Triggers upon a server verification (only in conjunction with `spamfilter`).
264
295
  - **statechange** - Triggers whenever an internal `state` changes.
265
296
  - **verified** - Triggers when the challenge is verified.
266
297
 
267
298
  ```ts
268
299
  enum State {
300
+ CODE = 'code',
269
301
  ERROR = 'error',
270
302
  VERIFIED = 'verified',
271
303
  VERIFYING = 'verifying',
@@ -286,58 +318,14 @@ document.querySelector('#altcha').addEventListener('statechange', (ev) => {
286
318
  > [!IMPORTANT]
287
319
  > Both programmatic configuration and event listeners have to called/attached after the ALTCHA script loads, such as within `window.addEventListener('load', ...)`.
288
320
 
289
- ## Spam Filter
321
+ ## Contributing
290
322
 
291
- The widget integrates with ALTCHA's [Anti-Spam solution](https://altcha.org/anti-spam) to allow checking submitted form data for potential spam.
292
-
293
- The Spam Filter API analyzes various signals in the submitted data to determine if it exhibits characteristics of spam. This non-invasive filtering helps reduce spam submissions without frustrating legitimate users.
294
-
295
- ### Spam Filter Configuration
296
-
297
- The Spam Filter can be enabled with default configuration by setting the `spamfilter` option to `true`, or `ipAddress` to verify only the IP address and the time zone, or it can be customized using the following configuration schema:
298
-
299
- ```ts
300
- interface SpamFilter {
301
- blockedCountries?: string[];
302
- classifier?: string;
303
- disableRules?: string[];
304
- email?: string | false;
305
- expectedCountries?: string[];
306
- expectedLanguages?: string[];
307
- fields?: string[] | false;
308
- ipAddress?: string | false;
309
- text?: string | string[];
310
- timeZone?: string | false;
311
- }
312
- ```
313
-
314
- SpamFilter configuration options:
315
-
316
- - **blockedCountries** - An array of country codes (ISO 3166 alpha-2) that you want to block.
317
- - **classifier** - Enforce a specific classifier.
318
- - **disableRules** - An array of rules to disable.
319
- - **email** - The name of the input field for the user's email. Disable email checking with `false`.
320
- - **expectedCountries** - An array of expected countries as 2-letter codes (ISO 3166-1 alpha-2).
321
- - **expectedLanguages** - An array of expected languages as 2-letter codes (ISO 639 alpha-2).
322
- - **fields** - An array of input names to send to the spam filter.
323
- - **ipAddress** - The user's IP is detected automatically but can be overridden or disabled with `false`.
324
- - **text** - The text to classify. An array of strings can also be submitted.
325
- - **timeZone** - The user's timezone is detected automatically but can be overridden or disabled with `false`.
326
-
327
- To include the email field into `fields` (for easier server-side verification), configure the list of input names using the `spamfilter.fields: string[]` option.
328
-
329
- ### Exclude Inputs from Spam Checking
330
-
331
- By default, all text inputs and textareas within the parent form are spam-checked. To exclude a specific input, add the `data-no-spamfilter` attribute. Alternatively, explicitly list the checked fields using the `fields` config option.
332
-
333
- ## Contributing
334
323
  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).
335
324
 
336
325
  ## Sponsorship
337
326
 
338
- 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.
339
-
340
- ## License
327
+ 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.
341
328
 
342
- MIT
329
+ ## License
343
330
 
331
+ **MIT**
package/dist/altcha.d.ts CHANGED
@@ -5,6 +5,9 @@ declare module 'altcha';
5
5
  declare global {
6
6
  var altchaCreateWorker: (url?: string) => Worker;
7
7
  var altchaPlugins: any[];
8
+ var altchaI18n: Record<string, any> & {
9
+ register: (language: string, translation: Record<string, string>) => void;
10
+ };
8
11
 
9
12
  type AltchaState = 'error' | 'expired' | 'verified' | 'verifying' | 'unverified';
10
13
 
@@ -24,6 +27,7 @@ declare global {
24
27
  blockspam?: boolean;
25
28
  challengeurl?: string;
26
29
  challengejson?: string;
30
+ credentials?: 'omit' | 'same-origin' | 'include' | boolean | undefined;
27
31
  customfetch?: string | ((url: string, init?: RequestInit) => Promise<Response>);
28
32
  debug?: boolean;
29
33
  delay?: number;
@@ -35,6 +39,7 @@ declare global {
35
39
  hidefooter?: boolean;
36
40
  hidelogo?: boolean;
37
41
  id?: string;
42
+ language?: string;
38
43
  maxnumber?: number;
39
44
  mockerror?: boolean;
40
45
  name?: string;
@@ -48,6 +53,7 @@ declare global {
48
53
  onuploadprogress?: (ev: CustomEvent) => void;
49
54
  plugins?: string;
50
55
  refetchonexpire?: boolean;
56
+ /** @deprecated */
51
57
  spamfilter?: boolean | 'ipAddress';
52
58
  strings?: string;
53
59
  test?: boolean | number;