altcha 2.0.0-beta.8 → 2.0.0

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 (181) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +142 -93
  3. package/dist/altcha.d.ts +5 -2
  4. package/dist/altcha.i18n.d.ts +158 -0
  5. package/dist/altcha.i18n.js +4017 -0
  6. package/dist/altcha.i18n.umd.js +4 -0
  7. package/dist/altcha.js +1888 -1763
  8. package/dist/altcha.umd.cjs +4 -14
  9. package/dist_external/altcha.css +1 -255
  10. package/dist_external/altcha.d.ts +5 -2
  11. package/dist_external/altcha.js +1844 -1728
  12. package/dist_external/altcha.umd.cjs +3 -13
  13. package/dist_i18n/af.d.ts +1 -0
  14. package/dist_i18n/af.js +76 -3
  15. package/dist_i18n/af.umd.cjs +1 -1
  16. package/dist_i18n/all.d.ts +1 -0
  17. package/dist_i18n/all.js +178 -105
  18. package/dist_i18n/all.umd.cjs +1 -1
  19. package/dist_i18n/americas.d.ts +1 -0
  20. package/dist_i18n/americas.js +80 -7
  21. package/dist_i18n/americas.umd.cjs +1 -1
  22. package/dist_i18n/ar.d.ts +1 -0
  23. package/dist_i18n/ar.js +76 -3
  24. package/dist_i18n/ar.umd.cjs +1 -1
  25. package/dist_i18n/asia.d.ts +1 -0
  26. package/dist_i18n/asia.js +105 -32
  27. package/dist_i18n/asia.umd.cjs +1 -1
  28. package/dist_i18n/bg.d.ts +1 -0
  29. package/dist_i18n/bg.js +76 -3
  30. package/dist_i18n/bg.umd.cjs +1 -1
  31. package/dist_i18n/bn.d.ts +1 -0
  32. package/dist_i18n/bn.js +76 -3
  33. package/dist_i18n/bn.umd.cjs +1 -1
  34. package/dist_i18n/bs.d.ts +1 -0
  35. package/dist_i18n/bs.js +76 -3
  36. package/dist_i18n/bs.umd.cjs +1 -1
  37. package/dist_i18n/ca.d.ts +1 -0
  38. package/dist_i18n/ca.js +76 -3
  39. package/dist_i18n/ca.umd.cjs +1 -1
  40. package/dist_i18n/cs.d.ts +1 -0
  41. package/dist_i18n/cs.js +76 -3
  42. package/dist_i18n/cs.umd.cjs +1 -1
  43. package/dist_i18n/da.d.ts +1 -0
  44. package/dist_i18n/da.js +76 -3
  45. package/dist_i18n/da.umd.cjs +1 -1
  46. package/dist_i18n/de.d.ts +1 -0
  47. package/dist_i18n/de.js +76 -3
  48. package/dist_i18n/de.umd.cjs +1 -1
  49. package/dist_i18n/el.d.ts +1 -0
  50. package/dist_i18n/el.js +76 -3
  51. package/dist_i18n/el.umd.cjs +1 -1
  52. package/dist_i18n/en.d.ts +1 -0
  53. package/dist_i18n/en.js +76 -3
  54. package/dist_i18n/en.umd.cjs +1 -1
  55. package/dist_i18n/es-419.d.ts +1 -0
  56. package/dist_i18n/es-419.js +76 -3
  57. package/dist_i18n/es-419.umd.cjs +1 -1
  58. package/dist_i18n/es-es.d.ts +1 -0
  59. package/dist_i18n/es-es.js +76 -3
  60. package/dist_i18n/es-es.umd.cjs +1 -1
  61. package/dist_i18n/et.d.ts +1 -0
  62. package/dist_i18n/et.js +76 -3
  63. package/dist_i18n/et.umd.cjs +1 -1
  64. package/dist_i18n/eu.d.ts +1 -0
  65. package/dist_i18n/eu.js +76 -3
  66. package/dist_i18n/eu.umd.cjs +1 -1
  67. package/dist_i18n/europe.d.ts +1 -0
  68. package/dist_i18n/europe.js +139 -66
  69. package/dist_i18n/europe.umd.cjs +1 -1
  70. package/dist_i18n/fi.d.ts +1 -0
  71. package/dist_i18n/fi.js +76 -3
  72. package/dist_i18n/fi.umd.cjs +1 -1
  73. package/dist_i18n/fr-ca.d.ts +1 -0
  74. package/dist_i18n/fr-ca.js +77 -4
  75. package/dist_i18n/fr-ca.umd.cjs +1 -1
  76. package/dist_i18n/fr-fr.d.ts +1 -0
  77. package/dist_i18n/fr-fr.js +77 -4
  78. package/dist_i18n/fr-fr.umd.cjs +1 -1
  79. package/dist_i18n/ga.d.ts +1 -0
  80. package/dist_i18n/ga.js +76 -3
  81. package/dist_i18n/ga.umd.cjs +1 -1
  82. package/dist_i18n/he.d.ts +1 -0
  83. package/dist_i18n/he.js +76 -3
  84. package/dist_i18n/he.umd.cjs +1 -1
  85. package/dist_i18n/hi.d.ts +1 -0
  86. package/dist_i18n/hi.js +76 -3
  87. package/dist_i18n/hi.umd.cjs +1 -1
  88. package/dist_i18n/hr.d.ts +1 -0
  89. package/dist_i18n/hr.js +76 -3
  90. package/dist_i18n/hr.umd.cjs +1 -1
  91. package/dist_i18n/hu.d.ts +1 -0
  92. package/dist_i18n/hu.js +76 -3
  93. package/dist_i18n/hu.umd.cjs +1 -1
  94. package/dist_i18n/id.d.ts +1 -0
  95. package/dist_i18n/id.js +76 -3
  96. package/dist_i18n/id.umd.cjs +1 -1
  97. package/dist_i18n/is.d.ts +1 -0
  98. package/dist_i18n/is.js +76 -3
  99. package/dist_i18n/is.umd.cjs +1 -1
  100. package/dist_i18n/it.d.ts +1 -0
  101. package/dist_i18n/it.js +76 -3
  102. package/dist_i18n/it.umd.cjs +1 -1
  103. package/dist_i18n/ja.d.ts +1 -0
  104. package/dist_i18n/ja.js +76 -3
  105. package/dist_i18n/ja.umd.cjs +1 -1
  106. package/dist_i18n/ko.d.ts +1 -0
  107. package/dist_i18n/ko.js +76 -3
  108. package/dist_i18n/ko.umd.cjs +1 -1
  109. package/dist_i18n/lt.d.ts +1 -0
  110. package/dist_i18n/lt.js +76 -3
  111. package/dist_i18n/lt.umd.cjs +1 -1
  112. package/dist_i18n/lv.d.ts +1 -0
  113. package/dist_i18n/lv.js +76 -3
  114. package/dist_i18n/lv.umd.cjs +1 -1
  115. package/dist_i18n/mr.d.ts +1 -0
  116. package/dist_i18n/mr.js +76 -3
  117. package/dist_i18n/mr.umd.cjs +1 -1
  118. package/dist_i18n/mt.d.ts +1 -0
  119. package/dist_i18n/mt.js +76 -3
  120. package/dist_i18n/mt.umd.cjs +1 -1
  121. package/dist_i18n/nb.d.ts +1 -0
  122. package/dist_i18n/nb.js +77 -4
  123. package/dist_i18n/nb.umd.cjs +1 -1
  124. package/dist_i18n/nl.d.ts +1 -0
  125. package/dist_i18n/nl.js +76 -3
  126. package/dist_i18n/nl.umd.cjs +1 -1
  127. package/dist_i18n/pl.d.ts +1 -0
  128. package/dist_i18n/pl.js +76 -3
  129. package/dist_i18n/pl.umd.cjs +1 -1
  130. package/dist_i18n/pt-br.d.ts +1 -0
  131. package/dist_i18n/pt-br.js +76 -3
  132. package/dist_i18n/pt-br.umd.cjs +1 -1
  133. package/dist_i18n/pt-pt.d.ts +1 -0
  134. package/dist_i18n/pt-pt.js +76 -3
  135. package/dist_i18n/pt-pt.umd.cjs +1 -1
  136. package/dist_i18n/ro.d.ts +1 -0
  137. package/dist_i18n/ro.js +76 -3
  138. package/dist_i18n/ro.umd.cjs +1 -1
  139. package/dist_i18n/ru.d.ts +1 -0
  140. package/dist_i18n/ru.js +76 -3
  141. package/dist_i18n/ru.umd.cjs +1 -1
  142. package/dist_i18n/sk.d.ts +1 -0
  143. package/dist_i18n/sk.js +76 -3
  144. package/dist_i18n/sk.umd.cjs +1 -1
  145. package/dist_i18n/sl.d.ts +1 -0
  146. package/dist_i18n/sl.js +76 -3
  147. package/dist_i18n/sl.umd.cjs +1 -1
  148. package/dist_i18n/sr.d.ts +1 -0
  149. package/dist_i18n/sr.js +76 -3
  150. package/dist_i18n/sr.umd.cjs +1 -1
  151. package/dist_i18n/sv.d.ts +1 -0
  152. package/dist_i18n/sv.js +76 -3
  153. package/dist_i18n/sv.umd.cjs +1 -1
  154. package/dist_i18n/ta.d.ts +1 -0
  155. package/dist_i18n/ta.js +76 -3
  156. package/dist_i18n/ta.umd.cjs +1 -1
  157. package/dist_i18n/te.d.ts +1 -0
  158. package/dist_i18n/te.js +76 -3
  159. package/dist_i18n/te.umd.cjs +1 -1
  160. package/dist_i18n/th.d.ts +1 -0
  161. package/dist_i18n/th.js +76 -3
  162. package/dist_i18n/th.umd.cjs +1 -1
  163. package/dist_i18n/tr.d.ts +1 -0
  164. package/dist_i18n/tr.js +76 -3
  165. package/dist_i18n/tr.umd.cjs +1 -1
  166. package/dist_i18n/uk.d.ts +1 -0
  167. package/dist_i18n/uk.js +76 -3
  168. package/dist_i18n/uk.umd.cjs +1 -1
  169. package/dist_i18n/ur.d.ts +1 -0
  170. package/dist_i18n/ur.js +76 -3
  171. package/dist_i18n/ur.umd.cjs +1 -1
  172. package/dist_i18n/vi.d.ts +1 -0
  173. package/dist_i18n/vi.js +76 -3
  174. package/dist_i18n/vi.umd.cjs +1 -1
  175. package/dist_i18n/zh-cn.d.ts +1 -0
  176. package/dist_i18n/zh-cn.js +76 -3
  177. package/dist_i18n/zh-cn.umd.cjs +1 -1
  178. package/dist_i18n/zh-tw.d.ts +1 -0
  179. package/dist_i18n/zh-tw.js +76 -3
  180. package/dist_i18n/zh-tw.umd.cjs +1 -1
  181. package/package.json +13 -7
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Daniel Regeci
3
+ Copyright (c) 2023 Daniel Regeci, BAU Software s.r.o.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
7
+ - **Global privacy regulations**: GDPR, HIPAA, CCPA, PIPEDA/CPPA, LGPD, DPDPA, and PIPL
8
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/)
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
- ## Examples
32
+ ### Migrating from v1
33
33
 
34
- Explore starter templates for popular frameworks:
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
- - [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)
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
- ## Server Integrations
39
+ ## Examples
44
40
 
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)
41
+ Explore starter templates for popular frameworks:
52
42
 
53
- ## Plugins & CMS
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
- - [Libraries and plugins](https://altcha.org/docs/integrations/)
50
+ ## Server Integrations
56
51
 
57
- ## Usage
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
- 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
+ ## Plugins & CMS
60
61
 
61
- ### 1. Install ALTCHA
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 async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha@main/dist/altcha.min.js" type="module"></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 | Size (GZIPped) |
119
- |-------------------|----------------|
120
- | ALTCHA (v2.x) | 26+ kB |
121
- | hCaptcha | 48+ kB |
122
- | reCAPTCHA | 270+ kB |
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 26 kB, making ALTCHA’s widget about 90% smaller than reCAPTCHA.
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.
@@ -168,47 +182,80 @@ Development / Testing options:
168
182
  - **mockerror**: Causes verification to always fail with a "mock" error.
169
183
  - **test**: Generates a "mock" challenge within the widget, bypassing the request to `challengeurl`.
170
184
 
171
- ## Internationalization (i18n)
185
+ ## Internationalization (i18n)
172
186
 
173
- ALTCHA supports **48+ languages**. Import translations from `altcha/i18n/*`:
187
+ ALTCHA supports **48+ languages**. You can import individual language translations or a bundle that includes all of them.
188
+
189
+ ### Importing Translations
190
+
191
+ To import all translations:
192
+
193
+ ```js
194
+ import 'altcha/i18n/all';
195
+ ```
196
+
197
+ To import specific languages only:
174
198
 
175
199
  ```js
176
- import 'altcha';
177
- import 'altcha/i18n/all'; // All languages
178
- // Or import specific languages:
179
200
  import 'altcha/i18n/de';
180
201
  import 'altcha/i18n/fr-fr';
181
202
  ```
182
203
 
183
- The widget auto-detects language from `<html lang="...">` or `navigator.languages`. Override with the `language` attribute:
204
+ Alternatively, you can import the combined bundle, which includes both the widget and all translations:
205
+
206
+ ```js
207
+ import 'altcha/i18n';
208
+ ```
209
+
210
+ ### Language Detection
211
+
212
+ The widget automatically detects the language from:
213
+
214
+ - The `<html lang="...">` attribute
215
+ - The user's browser settings (`navigator.languages`)
216
+
217
+ To override the language manually, use the `language` attribute:
184
218
 
185
219
  ```html
186
220
  <altcha-widget language="de"></altcha-widget>
187
221
  ```
188
222
 
189
- ## Code Challenges
223
+ ### Customizing Translations
224
+
225
+ You can override default translations by updating the global `altchaI18n` registry (`globalThis.altchaI18n` or `window.altchaI18n`):
226
+
227
+ ```js
228
+ import 'altcha/i18n/de';
229
+
230
+ globalThis.altchaI18n.set('de', {
231
+ ...globalThis.altchaI18n.get('de'),
232
+ label: 'Ich bin ein Mensch', // Custom label
233
+ });
234
+ ```
235
+
236
+ ## Code Challenges
190
237
 
191
- 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.
238
+ 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
239
 
193
- ## Plugins
240
+ ## Plugins
194
241
 
195
- Extend functionality with plugins:
242
+ Extend functionality with plugins:
196
243
 
197
244
  ```js
198
245
  import 'altcha/obfuscation'; // Data obfuscation
199
- import 'altcha/upload'; // File uploads
200
- import 'altcha'; // Main package
246
+ import 'altcha/upload'; // File uploads
247
+ import 'altcha'; // Main package
201
248
  ```
202
249
 
203
- Enable plugins per widget:
250
+ Enable plugins per widget:
204
251
 
205
252
  ```html
206
253
  <altcha-widget plugins="upload,obfuscation"></altcha-widget>
207
254
  ```
208
255
 
209
- ### Available Plugins
256
+ ### Available Plugins
210
257
 
211
- - **obfuscation**: Secure sensitive data (emails, phone numbers).
258
+ - **obfuscation**: Secure sensitive data (emails, phone numbers).
212
259
  - **upload**: File uploads with ALTCHA Sentinel or a custom backend.
213
260
 
214
261
  ## Programmatic Configuration
@@ -229,7 +276,7 @@ document.querySelector('#altcha').configure({
229
276
  });
230
277
  ```
231
278
 
232
- Available configuration options:
279
+ Available configuration options:
233
280
 
234
281
  ```ts
235
282
  export interface Configure {
@@ -248,7 +295,9 @@ export interface Configure {
248
295
  };
249
296
  challengeurl?: string;
250
297
  credentials?: 'omit' | 'same-origin' | 'include' | boolean;
251
- customfetch?: string | ((url: string, init?: RequestInit) => Promise<Response>);
298
+ customfetch?:
299
+ | string
300
+ | ((url: string, init?: RequestInit) => Promise<Response>);
252
301
  debug?: boolean;
253
302
  delay?: number;
254
303
  disableautofocus?: boolean;
@@ -280,7 +329,7 @@ export interface Configure {
280
329
  verified: string;
281
330
  verifying: string;
282
331
  waitAlert: string;
283
- }
332
+ };
284
333
  test?: boolean | number | 'delay';
285
334
  verifyurl?: string;
286
335
  workers?: number;
@@ -305,7 +354,7 @@ enum State {
305
354
  VERIFYING = 'verifying',
306
355
  UNVERIFIED = 'unverified',
307
356
  EXPIRED = 'expired',
308
- };
357
+ }
309
358
  ```
310
359
 
311
360
  Using events:
@@ -320,14 +369,14 @@ document.querySelector('#altcha').addEventListener('statechange', (ev) => {
320
369
  > [!IMPORTANT]
321
370
  > Both programmatic configuration and event listeners have to called/attached after the ALTCHA script loads, such as within `window.addEventListener('load', ...)`.
322
371
 
323
- ## Contributing
372
+ ## Contributing
324
373
 
325
374
  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
375
 
327
- ## Sponsorship
376
+ ## Sponsorship
328
377
 
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.
378
+ 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
379
 
331
- ## License
380
+ ## License
332
381
 
333
- **MIT**
382
+ **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: Record<string, any> & {
9
- register: (language: string, translation: Record<string, string>) => void;
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
+ }