@statewalker/webrun-biscuit 0.2.1 → 0.2.3
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 +32 -33
- package/dist/authorizer.d.ts.map +1 -1
- package/dist/builder.d.ts +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/authorizer.ts +9 -2
- package/src/builder.ts +1 -1
- package/src/crypto.ts +10 -2
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# @statewalker/webrun-biscuit
|
|
2
2
|
|
|
3
|
+
## What it is
|
|
4
|
+
|
|
3
5
|
[Biscuit](https://biscuitsec.org) authorization tokens in pure TypeScript: the protobuf codec, the
|
|
4
6
|
signature chain, the Datalog engine, the text parser, the authorizer and the token builder. No WASM,
|
|
5
|
-
no Node built-ins in `src/`, two runtime dependencies. It runs
|
|
6
|
-
|
|
7
|
+
no Node built-ins in `src/`, two runtime dependencies. It runs in Node, browsers, Workers and Durable
|
|
8
|
+
Objects. It mints, attenuates, seals, verifies and authorizes tokens, and evaluates Datalog with or
|
|
9
|
+
without a token.
|
|
7
10
|
|
|
8
|
-
## Why
|
|
11
|
+
## Why it exists
|
|
9
12
|
|
|
10
13
|
There is no other pure JS/TS Biscuit implementation. npm carries `@biscuit-auth/biscuit-wasm` — the
|
|
11
14
|
Rust crate compiled to WebAssembly — and a web-components package built on it. Nothing else.
|
|
@@ -18,10 +21,10 @@ megabyte of WebAssembly to do so.
|
|
|
18
21
|
So this is a reimplementation, and the entire testing strategy below exists because a reimplementation
|
|
19
22
|
of a security primitive is only worth having if you can show it agrees with the original.
|
|
20
23
|
|
|
21
|
-
##
|
|
24
|
+
## How to use
|
|
22
25
|
|
|
23
26
|
```sh
|
|
24
|
-
|
|
27
|
+
pnpm add @statewalker/webrun-biscuit
|
|
25
28
|
```
|
|
26
29
|
|
|
27
30
|
Two runtime dependencies, both external to the published bundle:
|
|
@@ -49,6 +52,8 @@ const result = verified.authorize('operation("read"); allow if user("alice");');
|
|
|
49
52
|
type system then prevents authorizing a token whose signature chain was never checked, which is the
|
|
50
53
|
mistake worth designing against.
|
|
51
54
|
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
52
57
|
### Parameters: never splice a value into Datalog
|
|
53
58
|
|
|
54
59
|
Anything that did not come from you — a user id, a request path, a role name —
|
|
@@ -75,9 +80,9 @@ block and authorizer facts) unless it says `trusting`, so an attenuation block c
|
|
|
75
80
|
inject what it reads:
|
|
76
81
|
|
|
77
82
|
```ts
|
|
78
|
-
const ev = verified.evaluate("allow if true;
|
|
83
|
+
const ev = verified.evaluate('operation("read"); allow if true;');
|
|
79
84
|
ev.result; // { kind: "ok", policy: 0 }
|
|
80
|
-
ev.query("claim($s) <-
|
|
85
|
+
ev.query("claim($s) <- user($s)"); // [{ name: "claim", terms: [{ t: "str", v: "alice" }] }]
|
|
81
86
|
```
|
|
82
87
|
|
|
83
88
|
Pass `null` instead of a token to decide from the authorizer's own facts and rules:
|
|
@@ -102,7 +107,7 @@ consume one list of signature checks, so neither can skip a check the other make
|
|
|
102
107
|
const verified = await Biscuit.fromBase64(token).verifyAsync(root.publicKey);
|
|
103
108
|
```
|
|
104
109
|
|
|
105
|
-
###
|
|
110
|
+
### secp256r1, key ids and third-party blocks
|
|
106
111
|
|
|
107
112
|
secp256r1 works the same way, with the algorithm passed at both ends:
|
|
108
113
|
|
|
@@ -121,7 +126,8 @@ import { peekRootKeyId } from "@statewalker/webrun-biscuit";
|
|
|
121
126
|
const key = roots[peekRootKeyId(bytes) ?? 0];
|
|
122
127
|
```
|
|
123
128
|
|
|
124
|
-
A third party can sign a block without ever holding the token
|
|
129
|
+
A third party can sign a block without ever holding the token. The token must not be sealed —
|
|
130
|
+
`appendThirdParty` on a sealed token throws `BuilderError`:
|
|
125
131
|
|
|
126
132
|
```ts
|
|
127
133
|
const request = Biscuit.fromBase64(token).thirdPartyRequest();
|
|
@@ -174,7 +180,7 @@ millisecond, which is unreachably tight for a cold JS engine; this one defaults
|
|
|
174
180
|
exposed to untrusted tokens should lower it deliberately rather than treat the default as a
|
|
175
181
|
denial-of-service bound. The limit is enforced where the work happens — inside the join, for rules,
|
|
176
182
|
checks and policies alike — so it bounds a single combinatorial rule, not only the number of
|
|
177
|
-
iterations
|
|
183
|
+
iterations.
|
|
178
184
|
|
|
179
185
|
### The corpus is fetched, not vendored
|
|
180
186
|
|
|
@@ -198,11 +204,13 @@ not to change the verdict.
|
|
|
198
204
|
|
|
199
205
|
### A green suite is not the claim; a suite that can fail is
|
|
200
206
|
|
|
207
|
+
Run from `packages/webrun-biscuit` (or prefix with `pnpm --filter @statewalker/webrun-biscuit`):
|
|
208
|
+
|
|
201
209
|
```sh
|
|
202
|
-
pnpm test # the main suite
|
|
203
|
-
pnpm test:cross # against the reference implementation
|
|
210
|
+
pnpm test # the main suite (fetches the corpus first)
|
|
211
|
+
pnpm test:cross # against the reference implementation
|
|
204
212
|
pnpm test:all # both
|
|
205
|
-
pnpm mutate # inject
|
|
213
|
+
pnpm mutate # inject known defects, require the suite to catch each
|
|
206
214
|
pnpm build # dist/ plus declarations
|
|
207
215
|
```
|
|
208
216
|
|
|
@@ -221,13 +229,13 @@ pnpm build # dist/ plus declarations
|
|
|
221
229
|
| `11-parameters` | `{name}` binding, hostile strings, unbound and unused parameters |
|
|
222
230
|
| `12-evaluate` | queries, their scope, token-less evaluation, failed-check rule text |
|
|
223
231
|
|
|
224
|
-
`scripts/mutate.mjs` is the check on all of it. It injects
|
|
232
|
+
`scripts/mutate.mjs` is the check on all of it. It injects seventeen defects — a lenient protobuf decoder,
|
|
225
233
|
wrapping i64 arithmetic, `check all` degraded to `check if`, a universally trusting authorizer, `deny`
|
|
226
234
|
treated as `allow`, unchecked seal signatures, an async verifier that ignores WebCrypto's verdict, a
|
|
227
235
|
query that can read an attenuation block's facts, silently ignored parameters, zero-term predicates, non-ASCII names, missing version bounds,
|
|
228
236
|
and more — and requires each to break at least one test. A surviving mutation is a hole in the tests,
|
|
229
|
-
not a success. All
|
|
230
|
-
|
|
237
|
+
not a success. All of them are caught; the forged-seal and matching-`deny` mutations are the ones a
|
|
238
|
+
suite without `06-builder`'s negative cases would miss.
|
|
231
239
|
|
|
232
240
|
Each mutation's `find` string is a literal excerpt of the source, and must match exactly once. That is
|
|
233
241
|
why a reformat of `src/` makes the harness fail loudly rather than quietly stop testing anything.
|
|
@@ -254,7 +262,7 @@ because uniform sampling produces mostly `noMatchingPolicy`, where the engine ba
|
|
|
254
262
|
That suite is kept out of `pnpm test` on purpose, and it skips gracefully when the reference is not
|
|
255
263
|
installed, so it never becomes a hard dependency of the main suite.
|
|
256
264
|
|
|
257
|
-
|
|
265
|
+
### What will surprise you
|
|
258
266
|
|
|
259
267
|
**The reference build's first `authorize` call reports a timeout that is not real.** Every fresh
|
|
260
268
|
Authorizer reports a `RunLimit` timeout on its first call even with a 60-second budget; later calls on
|
|
@@ -275,25 +283,23 @@ reliable accessor.
|
|
|
275
283
|
walking up to `node_modules`, reads the `.wasm`, and supplies its imports by hand. Running Node with
|
|
276
284
|
`--experimental-wasm-modules` does work, but needing a flag for `pnpm test` is worse.
|
|
277
285
|
|
|
278
|
-
**
|
|
279
|
-
|
|
280
|
-
fetch
|
|
281
|
-
files
|
|
282
|
-
are also pooled at six with retries, because `raw.githubusercontent.com` resets connections when
|
|
286
|
+
**An interrupted corpus download must not look complete.** `scripts/fetch-samples.mjs` writes the
|
|
287
|
+
`samples.json` manifest last, and its "already fetched" guard checks every file the manifest names;
|
|
288
|
+
otherwise an interrupted fetch would leave a directory every later run skips, and the tests would fail
|
|
289
|
+
on missing files. Downloads are pooled at six with retries, because `raw.githubusercontent.com` resets connections when
|
|
283
290
|
several dozen requests arrive at once and surfaces it as a bare `TypeError: fetch failed`.
|
|
284
291
|
|
|
285
292
|
**`pnpm test` fetches the corpus explicitly, not through `pretest`.** pnpm does not run `pre`/`post`
|
|
286
293
|
scripts by default, so a `pretest` hook would silently never fire and the suite would fail on a clean
|
|
287
294
|
checkout with missing samples.
|
|
288
295
|
|
|
289
|
-
|
|
296
|
+
### Known deviations from the reference
|
|
290
297
|
|
|
291
298
|
**Names follow the reference parser, not the specification's prose.** A predicate or variable name
|
|
292
299
|
is one or more of `[A-Za-z0-9_:]`, ASCII, with any of them first — so `_m`, `1a` and `::` are names
|
|
293
300
|
and `ärger` is not — and a predicate takes at least one term. That is what
|
|
294
301
|
`@biscuit-auth/biscuit-wasm` accepts; `tests/grammar-cases.ts` records it and `05-grammar` re-asks the
|
|
295
|
-
reference, including for generated names.
|
|
296
|
-
accepted `f()`.
|
|
302
|
+
reference, including for generated names.
|
|
297
303
|
|
|
298
304
|
**Regex uses JS `RegExp`, not RE2.** Every corpus pattern matches, but backreferences and lookaround
|
|
299
305
|
are accepted where Rust would reject them. Documented, not enforced.
|
|
@@ -319,13 +325,6 @@ third-party flow works and is tested, but the cross-implementation one does not.
|
|
|
319
325
|
Semi-naive evaluation is not implemented either. The fixpoint re-derives every fact each round; the
|
|
320
326
|
index makes that cheap at token scale, but not at request scale with large fact sets.
|
|
321
327
|
|
|
322
|
-
## Design notes
|
|
323
|
-
|
|
324
|
-
`docs/webrun-biscuit/` in this repository carries the working documents from the implementation
|
|
325
|
-
sessions: how the reference actually works, why `mapbox/pbf` was rejected for the protobuf layer, what
|
|
326
|
-
the red-green cycle caught, the corpus findings, and what it took to make random differential testing
|
|
327
|
-
actually detect a defect.
|
|
328
|
-
|
|
329
328
|
## License
|
|
330
329
|
|
|
331
|
-
MIT
|
|
330
|
+
MIT
|
package/dist/authorizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorizer.d.ts","sourceRoot":"","sources":["../src/authorizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEL,KAAK,KAAK,EAGV,KAAK,QAA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
6
6
|
import { generateKeypair } from "./crypto.js";
|
|
7
7
|
import type { Check, Predicate, Rule, Scope } from "./datalog.js";
|
|
8
|
-
import { type BlockMsg, type PublicKeyMsg } from "./proto.js";
|
|
9
8
|
import type { Params } from "./parser.js";
|
|
9
|
+
import { type BlockMsg, type PublicKeyMsg } from "./proto.js";
|
|
10
10
|
export declare class BuilderError extends Error {
|
|
11
11
|
}
|
|
12
12
|
export interface Keypair {
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAIL,eAAe,EAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAM,SAAS,EAAE,IAAI,EAAE,KAAK,EAAQ,MAAM,cAAc,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAIL,eAAe,EAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAM,SAAS,EAAE,IAAI,EAAE,KAAK,EAAQ,MAAM,cAAc,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,KAAK,QAAQ,EAQb,KAAK,YAAY,EAIlB,MAAM,YAAY,CAAC;AAMpB,qBAAa,YAAa,SAAQ,KAAK;CAAG;AAE1C,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;CACvB;AACD,OAAO,EAAE,eAAe,EAAE,CAAC;AA0H3B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;IAClC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,MAAM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E,YAAY,EACrB,WAAW,EAAE,UAAU,GAAG,SAAS,EACnC,iBAAiB,EAAE,UAAU,EAC7B,OAAO,EAAE,MAAM,GACd,UAAU,CAcZ;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,iBAAiB,EAAE,UAAU,EAC7B,OAAO,EAAE,MAAM,GACd,UAAU,CASZ;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAE5D;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAK3F;AAED,8CAA8C;AAC9C,wBAAgB,eAAe,CAAC,SAAS,GAAE,CAAC,GAAG,CAAK,GAAG;IACrD,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;CACvB,CAIA;AAED,OAAO,EAAE,UAAU,EAAE,CAAC;AA2FtB,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,SAAI,GAAG,IAAI,CAOjG;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,UAAU,EACjB,aAAa,EAAE,UAAU,EACzB,aAAa,SAAI,GAChB,OAAO,CAAC,IAAI,CAAC,CAWf;AA6FD,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAE7D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export * from "./base64.js";
|
|
|
13
13
|
export * from "./builder.js";
|
|
14
14
|
export { SignatureError } from "./crypto.js";
|
|
15
15
|
export { ExecutionError, type ExternFn, type Predicate, type RunLimits, type Term, } from "./datalog.js";
|
|
16
|
-
export { type
|
|
16
|
+
export { type Params, type ParamValue, ParseError } from "./parser.js";
|
|
17
17
|
export { ProtoError } from "./proto.js";
|
|
18
18
|
export * from "./version.js";
|
|
19
19
|
/** An unverified token: it can be attenuated and re-serialized. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAErB,KAAK,UAAU,EAEf,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,KAAK,YAAY,EAEjB,eAAe,EAEf,KAAK,kBAAkB,EACvB,eAAe,EAEhB,MAAM,cAAc,CAAC;AAEtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,IAAI,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAErB,KAAK,UAAU,EAEf,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,KAAK,YAAY,EAEjB,eAAe,EAEf,KAAK,kBAAkB,EACvB,eAAe,EAEhB,MAAM,cAAc,CAAC;AAEtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,IAAI,GACV,MAAM,cAAc,CAAC;AACtB,OA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AM,GAAG,SAAS,CAElC;IACD,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,mBAAmB,CAEjF;IACD,mEAAmE;IACnE,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAEvE;CACF;AAED,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/webrun-biscuit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Biscuit authorization tokens in pure TypeScript: proto2 codec, Ed25519 and secp256r1 signature chain, Datalog engine, parser, authorizer and builder. No WASM, no Node built-ins — runs in Node, browsers, Workers and Durable Objects.",
|
|
7
|
-
"
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/statewalker/httpeers/issues"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/statewalker/httpeers/tree/main/packages/webrun-biscuit#readme",
|
|
8
11
|
"author": {
|
|
9
12
|
"name": "Mikhail Kotelnikov",
|
|
10
13
|
"email": "mikhail.kotelnikov@gmail.com"
|
|
@@ -12,11 +15,12 @@
|
|
|
12
15
|
"license": "MIT",
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|
|
15
|
-
"url": "git
|
|
18
|
+
"url": "git+https://github.com/statewalker/httpeers.git",
|
|
16
19
|
"directory": "packages/webrun-biscuit"
|
|
17
20
|
},
|
|
18
21
|
"exports": {
|
|
19
22
|
".": {
|
|
23
|
+
"source": "./src/index.ts",
|
|
20
24
|
"types": "./dist/index.d.ts",
|
|
21
25
|
"import": "./dist/index.js"
|
|
22
26
|
}
|
|
@@ -32,9 +36,9 @@
|
|
|
32
36
|
"devDependencies": {
|
|
33
37
|
"@biscuit-auth/biscuit-wasm": "^0.6.0",
|
|
34
38
|
"rimraf": "^6.1.3",
|
|
35
|
-
"rolldown": "^1.2.
|
|
39
|
+
"rolldown": "^1.2.12",
|
|
36
40
|
"typescript": "^7.0.2",
|
|
37
|
-
"vitest": "^
|
|
41
|
+
"vitest": "^5.0.3"
|
|
38
42
|
},
|
|
39
43
|
"sideEffects": false,
|
|
40
44
|
"publishConfig": {
|
package/src/authorizer.ts
CHANGED
|
@@ -396,7 +396,9 @@ export function parseAuthorizer(src: string, params?: Params): AuthorizerCode {
|
|
|
396
396
|
const statements: Statement[] = parser.parse();
|
|
397
397
|
const unused = parser.unusedParameters();
|
|
398
398
|
if (unused.length > 0)
|
|
399
|
-
throw new ParseError(
|
|
399
|
+
throw new ParseError(
|
|
400
|
+
`unused parameter${unused.length > 1 ? "s" : ""} {${unused.join("}, {")}}`,
|
|
401
|
+
);
|
|
400
402
|
out.varNames = parser.variableNames();
|
|
401
403
|
for (const st of statements) {
|
|
402
404
|
if (st.k === "fact") out.facts.push(st.fact);
|
|
@@ -640,7 +642,12 @@ export function evaluate(
|
|
|
640
642
|
for (let id = 1; id < token.blocks.length; id++) {
|
|
641
643
|
token.blocks[id].checks.forEach((check, j) => {
|
|
642
644
|
if (!runCheck(check, id, blockTrusted[id]))
|
|
643
|
-
errors.push({
|
|
645
|
+
errors.push({
|
|
646
|
+
source: "block",
|
|
647
|
+
blockId: id,
|
|
648
|
+
checkId: j,
|
|
649
|
+
rule: printCheck(check, name(id)),
|
|
650
|
+
});
|
|
644
651
|
});
|
|
645
652
|
}
|
|
646
653
|
|
package/src/builder.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
sign,
|
|
16
16
|
} from "./crypto.js";
|
|
17
17
|
import type { Check, Op, Predicate, Rule, Scope, Term } from "./datalog.js";
|
|
18
|
+
import type { Params } from "./parser.js";
|
|
18
19
|
import {
|
|
19
20
|
type BiscuitMsg,
|
|
20
21
|
type BlockMsg,
|
|
@@ -30,7 +31,6 @@ import {
|
|
|
30
31
|
type ScopeMsg,
|
|
31
32
|
type TermMsg,
|
|
32
33
|
} from "./proto.js";
|
|
33
|
-
import type { Params } from "./parser.js";
|
|
34
34
|
import { DATALOG_3_2, requiredVersion } from "./version.js";
|
|
35
35
|
|
|
36
36
|
const SIGNATURE_VERSION = 1;
|
package/src/crypto.ts
CHANGED
|
@@ -275,7 +275,12 @@ type Subtle = {
|
|
|
275
275
|
extractable: boolean,
|
|
276
276
|
usages: string[],
|
|
277
277
|
): Promise<unknown>;
|
|
278
|
-
verify(
|
|
278
|
+
verify(
|
|
279
|
+
algorithm: string,
|
|
280
|
+
key: unknown,
|
|
281
|
+
signature: Uint8Array,
|
|
282
|
+
data: Uint8Array,
|
|
283
|
+
): Promise<boolean>;
|
|
279
284
|
exportKey(format: "jwk", key: unknown): Promise<{ x?: string }>;
|
|
280
285
|
};
|
|
281
286
|
|
|
@@ -332,7 +337,10 @@ async function verifySignatureAsync(
|
|
|
332
337
|
}
|
|
333
338
|
}
|
|
334
339
|
|
|
335
|
-
async function publicKeyFromSecretAsync(
|
|
340
|
+
async function publicKeyFromSecretAsync(
|
|
341
|
+
secret: Uint8Array,
|
|
342
|
+
algorithm: number,
|
|
343
|
+
): Promise<Uint8Array> {
|
|
336
344
|
if (algorithm !== ALG_ED25519 || secret.length !== 32 || !subtle || !(await nativeEd25519()))
|
|
337
345
|
return publicKeyFromSecret(secret, algorithm);
|
|
338
346
|
try {
|
package/src/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export {
|
|
|
41
41
|
type RunLimits,
|
|
42
42
|
type Term,
|
|
43
43
|
} from "./datalog.js";
|
|
44
|
-
export { type
|
|
44
|
+
export { type Params, type ParamValue, ParseError } from "./parser.js";
|
|
45
45
|
export { ProtoError } from "./proto.js";
|
|
46
46
|
export * from "./version.js";
|
|
47
47
|
|