Skip to content

Commit

Permalink
update readme, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ovx committed Mar 8, 2024
1 parent fce54bd commit 49f6e9f
Show file tree
Hide file tree
Showing 14 changed files with 449 additions and 347 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ci
on:
push:
branches: [main, next]
pull_request:
branches: ['*']

jobs:
tests:
name: 'Tests'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-node@v4
with:
bun-version: 20.x
- run: npm install
- run: npm run test
- run: npm run test:e2e
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npm run build
git add dist
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ Required options (at least one is required):
Additional options:

- __auto__ - Automatically verify without user interaction (possible values: `onload`, `onsubmit`).
- __expire__ - The challenge expiration (duration in milliseconds).
- __hidefooter__ - Hide the footer (ALTCHA link).
- __hidelogo__ - Hide the ALTCHA logo.
- __maxnumber__ - The max. number to iterate to (defaults to 10,000,000).
- __maxnumber__ - The max. number to iterate to (defaults to 1,000,000).
- __name__ - The name of the hidden field containing the payload (defaults to "altcha").
- __strings__ - JSON-encoded translation strings. Refer to [customization](/docs/widget-customization).
- __workers__ - The number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`).

Development / testing options:

Expand Down Expand Up @@ -102,6 +104,7 @@ export interface Configure {
signature: string;
};
debug?: boolean;
expire?: number;
hidefooter?: boolean;
hidelogo?: boolean;
maxnumber?: number;
Expand All @@ -116,6 +119,7 @@ export interface Configure {
waitAlert?: string;
};
test?: boolean;
workers?: number;
}
```

Expand All @@ -124,11 +128,21 @@ export interface Configure {
- __statechange__ - Triggers whenever an internal `state` changes.
- __verified__ - Triggers when the challenge is verified.

```ts
enum State {
ERROR = 'error',
VERIFIED = 'verified',
VERIFYING = 'verifying',
UNVERIFIED = 'unverified',
EXPIRED = 'expired',
};
```

Using events:

```js
document.querySelector('#altcha').addEventListener('statechange', (ev) => {
// state can be: unverified, verifying, verified, error
// See enum State above
console.log('state:', ev.detail.state);
});
```
Expand Down
2 changes: 1 addition & 1 deletion dist/altcha.iife.js

Large diffs are not rendered by default.

Loading

0 comments on commit 49f6e9f

Please sign in to comment.