capjs-core 0.1.6 → 0.1.7
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 +5 -2
- package/package.json +5 -2
- package/src/agents.js +700 -0
- package/src/behavior.js +437 -0
- package/src/detect.js +189 -8
- package/src/hashwx-wasm.js +1 -5
- package/src/index.d.ts +198 -43
- package/src/index.js +298 -67
- package/src/instrumentation.js +742 -116
- package/src/rsw.js +13 -5
package/README.md
CHANGED
|
@@ -54,6 +54,9 @@ if (result.success) {
|
|
|
54
54
|
- `opts.extra` — optional object embedded in the JWT payload
|
|
55
55
|
- `opts.instrumentation` — `true` or `{ blockAutomatedBrowsers, obfuscationLevel }`
|
|
56
56
|
- `opts.instrumentationGenerator` — optional custom generator (escape hatch for offloading to a worker pool)
|
|
57
|
+
- `opts.behavior` is `true` or a policy object. It turns instrumentation on even when `opts.instrumentation` is off, because the trace is collected and bound by the script.
|
|
58
|
+
|
|
59
|
+
A custom generator should return what `generateInstrumentation(opts)` returns, including `binding`. A generator that returns `expectedVals` without a `binding` only has its state checked, so the server ignores any collected data and a challenge that asks for behavior fails with `behavior_missing`. If the result has neither, `generateChallenge` throws, so a generator written for 0.1.6 that copies `expectedVals` from `generateInstrumentation` fails when it issues a challenge instead of on every redeem. Return the whole result, or copy `binding` as well.
|
|
57
60
|
|
|
58
61
|
The `token` is a signed JWT containing the challenge config; `expires` is when it expires; `instrumentation` is the deflate+base64 client-side script (if requested).
|
|
59
62
|
|
|
@@ -62,7 +65,7 @@ The `token` is a signed JWT containing the challenge config; `expires` is when i
|
|
|
62
65
|
`body`:
|
|
63
66
|
- `token` — challenge token from `generateChallenge`
|
|
64
67
|
- `solutions` — number array (length = `challenge.c`)
|
|
65
|
-
- `instr` — instrumentation result (if enabled)
|
|
68
|
+
- `instr` — instrumentation result (if enabled), exactly `{ i, state, d }`. `d` is the canonical JSON of everything the script collected, and the script folds a seeded hash of `d` into `state`, so editing `d` breaks the state check. The server reads nothing about the browser from outside `d`.
|
|
66
69
|
- `instr_blocked`, `instr_timeout` — flags from the widget
|
|
67
70
|
|
|
68
71
|
`opts`:
|
|
@@ -123,7 +126,7 @@ Run `bun test/benchmark.js` to reproduce.
|
|
|
123
126
|
|
|
124
127
|
## Migrating from `@cap.js/server`
|
|
125
128
|
|
|
126
|
-
Unlike Cap's old server library, `capjs-core` does not include a token store. For most users we recommend [
|
|
129
|
+
Unlike Cap's old server library, `capjs-core` does not include a token store. For most users we recommend running [capd](https://trycap.dev/guide/capd/) (Docker, batteries included), but if you can't run Docker:
|
|
127
130
|
|
|
128
131
|
| `@cap.js/server` | `capjs-core` |
|
|
129
132
|
| --- | --- |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capjs-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Stateless server-side challenge generator and verifier for Cap, a lightweight, modern open-source CAPTCHA alternative. No storage, no filesystem - bring your own.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anti-abuse",
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
"src/index.d.ts",
|
|
49
49
|
"src/instrumentation.js",
|
|
50
50
|
"src/detect.js",
|
|
51
|
+
"src/agents.js",
|
|
52
|
+
"src/behavior.js",
|
|
51
53
|
"src/prng.js",
|
|
52
54
|
"src/crypto.js",
|
|
53
55
|
"src/rsw.js",
|
|
@@ -70,6 +72,7 @@
|
|
|
70
72
|
"javascript-obfuscator": "^4.2.2"
|
|
71
73
|
},
|
|
72
74
|
"devDependencies": {
|
|
73
|
-
"bun-types": "^1.3.12"
|
|
75
|
+
"bun-types": "^1.3.12",
|
|
76
|
+
"web-bot-auth": "^0.2.0"
|
|
74
77
|
}
|
|
75
78
|
}
|