altcha 1.0.7 → 1.1.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.
- package/README.md +43 -0
- package/dist/altcha.d.ts +9 -0
- package/dist/altcha.js +2295 -1421
- package/dist/altcha.umd.cjs +9 -2
- package/dist_external/altcha.d.ts +9 -0
- package/dist_external/altcha.js +2287 -1387
- package/dist_external/altcha.umd.cjs +9 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -104,6 +104,8 @@ Required options (at least one is required):
|
|
|
104
104
|
Additional options:
|
|
105
105
|
|
|
106
106
|
- **auto**: Automatically verify without user interaction (possible values: `off`, `onfocus`, `onload`, `onsubmit`).
|
|
107
|
+
- **customfetch**: A custom `fetch` function for retrieving the challenge.
|
|
108
|
+
Accepts `url: string` and `init: RequestInit` as arguments and must return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
107
109
|
- **delay**: Artificial delay in milliseconds before verification (defaults to 0).
|
|
108
110
|
- **expire**: Challenge expiration duration in milliseconds.
|
|
109
111
|
- **floating**: Enable floating UI (possible values: `auto`, `top`, `bottom`).
|
|
@@ -184,6 +186,7 @@ export interface Configure {
|
|
|
184
186
|
signature: string;
|
|
185
187
|
};
|
|
186
188
|
challengeurl?: string;
|
|
189
|
+
customfetch?: string | ((url: string, init?: RequestInit) => Promise<Response>);
|
|
187
190
|
debug?: boolean;
|
|
188
191
|
delay?: number;
|
|
189
192
|
expire?: number;
|
|
@@ -215,6 +218,42 @@ export interface Configure {
|
|
|
215
218
|
}
|
|
216
219
|
```
|
|
217
220
|
|
|
221
|
+
## Custom `fetch` Function
|
|
222
|
+
|
|
223
|
+
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.
|
|
224
|
+
|
|
225
|
+
The custom function must return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
|
|
226
|
+
|
|
227
|
+
### Sending Cookies
|
|
228
|
+
|
|
229
|
+
To include cookies in the request, use `credentials: 'include'`:
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
function altchaCustomFetch(url: string, init: RequestInit) {
|
|
233
|
+
return fetch(url, {
|
|
234
|
+
...init,
|
|
235
|
+
credentials: 'include', // Include cookies with the request
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
For more details on possible request options, refer to the [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) documentation.
|
|
241
|
+
|
|
242
|
+
### Using `customfetch`
|
|
243
|
+
|
|
244
|
+
The `customfetch` option can accept either:
|
|
245
|
+
- A `string` (the name of a globally accessible function defined in the global context, such as `window`), or
|
|
246
|
+
- A function itself.
|
|
247
|
+
|
|
248
|
+
### Example Usage
|
|
249
|
+
|
|
250
|
+
```html
|
|
251
|
+
<altcha-widget
|
|
252
|
+
challengeurl="https://example.com/challenge"
|
|
253
|
+
customfetch="altchaCustomFetch"
|
|
254
|
+
></altcha-widget>
|
|
255
|
+
```
|
|
256
|
+
|
|
218
257
|
## Events
|
|
219
258
|
|
|
220
259
|
- **load** - Triggers when the widget loads. The exported methods become available after this event.
|
|
@@ -291,6 +330,10 @@ By default, all text inputs and textareas within the parent form are spam-checke
|
|
|
291
330
|
## Contributing
|
|
292
331
|
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).
|
|
293
332
|
|
|
333
|
+
## Sponsorship
|
|
334
|
+
|
|
335
|
+
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.
|
|
336
|
+
|
|
294
337
|
## License
|
|
295
338
|
|
|
296
339
|
MIT
|
package/dist/altcha.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare global {
|
|
|
24
24
|
blockspam?: boolean;
|
|
25
25
|
challengeurl?: string;
|
|
26
26
|
challengejson?: string;
|
|
27
|
+
customfetch?: string | ((url: string, init?: RequestInit) => Promise<Response>);
|
|
27
28
|
debug?: boolean;
|
|
28
29
|
delay?: number;
|
|
29
30
|
expire?: number;
|
|
@@ -36,6 +37,14 @@ declare global {
|
|
|
36
37
|
mockerror?: boolean;
|
|
37
38
|
name?: string;
|
|
38
39
|
obfuscated?: string;
|
|
40
|
+
oncleartext?: (ev: CustomEvent) => void;
|
|
41
|
+
onload?: (ev: CustomEvent) => void;
|
|
42
|
+
onstatechange?: (ev: CustomEvent) => void;
|
|
43
|
+
onverified?: (ev: CustomEvent) => void;
|
|
44
|
+
onserververification?: (ev: CustomEvent) => void;
|
|
45
|
+
onupload?: (ev: CustomEvent) => void;
|
|
46
|
+
onuploadprogress?: (ev: CustomEvent) => void;
|
|
47
|
+
plugins?: string;
|
|
39
48
|
refetchonexpire?: boolean;
|
|
40
49
|
spamfilter?: boolean | 'ipAddress';
|
|
41
50
|
strings?: string;
|