@statewalker/webrun-biscuit 0.1.0 → 0.2.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 +69 -10
- package/dist/authorizer.d.ts +41 -4
- package/dist/authorizer.d.ts.map +1 -1
- package/dist/builder.d.ts +6 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/crypto.d.ts +7 -0
- package/dist/crypto.d.ts.map +1 -1
- package/dist/datalog.d.ts +2 -0
- package/dist/datalog.d.ts.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +377 -118
- package/dist/parser.d.ts +13 -2
- package/dist/parser.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/authorizer.ts +123 -27
- package/src/builder.ts +31 -9
- package/src/crypto.ts +164 -18
- package/src/datalog.ts +10 -0
- package/src/index.ts +26 -2
- package/src/parser.ts +69 -2
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -49,6 +49,59 @@ const result = verified.authorize('operation("read"); allow if user("alice");');
|
|
|
49
49
|
type system then prevents authorizing a token whose signature chain was never checked, which is the
|
|
50
50
|
mistake worth designing against.
|
|
51
51
|
|
|
52
|
+
### Parameters: never splice a value into Datalog
|
|
53
|
+
|
|
54
|
+
Anything that did not come from you — a user id, a request path, a role name —
|
|
55
|
+
goes in as a `{name}` parameter. It is bound as a **term**, so no string can
|
|
56
|
+
change the shape of the program:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const token = Biscuit.build(root.secretKey, "user({id});", { params: { id: userId } });
|
|
60
|
+
verified.authorize("resource({path});\nallow if user($u), owner($u, {path});", {
|
|
61
|
+
params: { path: url.pathname },
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Strings, safe-integer numbers, `bigint`, booleans, `null`, `Date`, `Uint8Array`,
|
|
66
|
+
arrays and `Set`s are accepted. An unbound parameter and an unused one are both a
|
|
67
|
+
`ParseError`, as in the reference; `{true}`, `{false}` and `{null}` remain one-element
|
|
68
|
+
sets.
|
|
69
|
+
|
|
70
|
+
### Querying the evaluated world
|
|
71
|
+
|
|
72
|
+
`evaluate` is `authorize` that keeps the world, so facts can be read back — the
|
|
73
|
+
reference's `Authorizer::query`. A query sees what the authorizer sees (authority
|
|
74
|
+
block and authorizer facts) unless it says `trusting`, so an attenuation block cannot
|
|
75
|
+
inject what it reads:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
const ev = verified.evaluate("allow if true;");
|
|
79
|
+
ev.result; // { kind: "ok", policy: 0 }
|
|
80
|
+
ev.query("claim($s) <- subject($s)"); // [{ name: "claim", terms: [{ t: "str", v: "alice" }] }]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Pass `null` instead of a token to decide from the authorizer's own facts and rules:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { evaluate } from "@statewalker/webrun-biscuit";
|
|
87
|
+
evaluate(null, 'role("admin");\ncapability("x") <- role("admin");').query("c($c) <- capability($c)");
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
A failed check carries its rule text, printed exactly as the reference prints it:
|
|
91
|
+
`{ source: "block", blockId: 0, checkId: 0, rule: "check if bound($k), connection_peer($k)" }`.
|
|
92
|
+
|
|
93
|
+
### Faster verification: `verifyAsync`
|
|
94
|
+
|
|
95
|
+
`verify` is synchronous and pure JS. `verifyAsync` checks Ed25519 signatures with the
|
|
96
|
+
platform's WebCrypto where it has it — Node, current browsers, Workers — which is about
|
|
97
|
+
eight times faster (0.25 ms against 1.9 ms per token in Node 24). secp256r1, and any
|
|
98
|
+
runtime without WebCrypto Ed25519, fall back to the same pure-JS code, and both paths
|
|
99
|
+
consume one list of signature checks, so neither can skip a check the other makes.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const verified = await Biscuit.fromBase64(token).verifyAsync(root.publicKey);
|
|
103
|
+
```
|
|
104
|
+
|
|
52
105
|
### Examples
|
|
53
106
|
|
|
54
107
|
secp256r1 works the same way, with the algorithm passed at both ends:
|
|
@@ -144,10 +197,10 @@ not to change the verdict.
|
|
|
144
197
|
### A green suite is not the claim; a suite that can fail is
|
|
145
198
|
|
|
146
199
|
```sh
|
|
147
|
-
pnpm test # the main suite,
|
|
148
|
-
pnpm test:cross # against the reference implementation,
|
|
200
|
+
pnpm test # the main suite, 180 tests
|
|
201
|
+
pnpm test:cross # against the reference implementation, 56 tests
|
|
149
202
|
pnpm test:all # both
|
|
150
|
-
pnpm mutate # inject
|
|
203
|
+
pnpm mutate # inject 13 known defects, require the suite to catch each
|
|
151
204
|
pnpm build # dist/ plus declarations
|
|
152
205
|
```
|
|
153
206
|
|
|
@@ -163,12 +216,15 @@ pnpm build # dist/ plus declarations
|
|
|
163
216
|
| `08-hardening` | property round-trips, mutation/truncation fuzzing, join scaling |
|
|
164
217
|
| `09-world-snapshot` | the post-run world per origin, against the official snapshots |
|
|
165
218
|
| `10-versions` | version bounds, feature gates, rejection of the deprecated v1/v2 corpora |
|
|
219
|
+
| `11-parameters` | `{name}` binding, hostile strings, unbound and unused parameters |
|
|
220
|
+
| `12-evaluate` | queries, their scope, token-less evaluation, failed-check rule text |
|
|
166
221
|
|
|
167
|
-
`scripts/mutate.mjs` is the check on all of it. It injects
|
|
222
|
+
`scripts/mutate.mjs` is the check on all of it. It injects thirteen defects — a lenient protobuf decoder,
|
|
168
223
|
wrapping i64 arithmetic, `check all` degraded to `check if`, a universally trusting authorizer, `deny`
|
|
169
|
-
treated as `allow`, unchecked seal signatures,
|
|
170
|
-
|
|
171
|
-
|
|
224
|
+
treated as `allow`, unchecked seal signatures, an async verifier that ignores WebCrypto's verdict, a
|
|
225
|
+
query that can read an attenuation block's facts, silently ignored parameters, missing version bounds,
|
|
226
|
+
and more — and requires each to break at least one test. A surviving mutation is a hole in the tests,
|
|
227
|
+
not a success. All thirteen are caught. Two of them were **not** caught when the harness was first written: nothing verified a forged
|
|
172
228
|
seal signature, and nothing exercised a matching `deny` policy.
|
|
173
229
|
|
|
174
230
|
Each mutation's `find` string is a literal excerpt of the source, and must match exactly once. That is
|
|
@@ -240,9 +296,12 @@ only `null` and sets containing `null`, so a block using arrays may legally decl
|
|
|
240
296
|
like an upstream oversight and is mirrored deliberately, because matching the reference matters more
|
|
241
297
|
than being right here. `03-interop-chains` confirms it empirically.
|
|
242
298
|
|
|
243
|
-
**
|
|
244
|
-
|
|
245
|
-
|
|
299
|
+
**WebCrypto Ed25519 is not ZIP-215.** `verifyAsync` inherits the platform's verification rules, and
|
|
300
|
+
`verify` those of `@noble/curves`. They agree on every honestly produced signature and on the whole
|
|
301
|
+
corpus; they may differ only on deliberately malformed encodings, which neither accepts as a forgery.
|
|
302
|
+
|
|
303
|
+
**Not implemented:** authorizer snapshots (`AuthorizerSnapshot` / `SnapshotBlock`); run limits on
|
|
304
|
+
`query` (the evaluation it reads from is bounded, the query itself is not); a revocation-checking helper, since revocation ids are exposed but comparing them against a
|
|
246
305
|
list is left to the caller; and wire-compatible third-party blocks — `thirdPartyRequest()` returns a
|
|
247
306
|
plain object rather than the `ThirdPartyBlockRequest` protobuf message, so our own end-to-end
|
|
248
307
|
third-party flow works and is tested, but the cross-implementation one does not.
|
package/dist/authorizer.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Turns a serialized token plus authorizer code into an authorization result,
|
|
3
3
|
* mirroring the evaluation order of the reference implementation.
|
|
4
4
|
*/
|
|
5
|
-
import { type Check, type ExternFn, type Fact, type Rule, type RunLimits, type Scope } from "./datalog.js";
|
|
5
|
+
import { type Check, type ExternFn, type Fact, type Predicate, type Rule, type RunLimits, type Scope } from "./datalog.js";
|
|
6
|
+
import { type Params } from "./parser.js";
|
|
6
7
|
export declare const DEFAULT_SYMBOLS: string[];
|
|
7
8
|
export declare class TokenError extends Error {
|
|
8
9
|
readonly kind: "Format" | "Symbol";
|
|
@@ -28,6 +29,11 @@ export interface LoadedToken {
|
|
|
28
29
|
export declare function loadToken(bytes: Uint8Array, rootPublicKey: Uint8Array,
|
|
29
30
|
/** the root key's algorithm: 0 = Ed25519, 1 = secp256r1 */
|
|
30
31
|
rootAlgorithm?: 0 | 1): LoadedToken;
|
|
32
|
+
/**
|
|
33
|
+
* `loadToken`, verifying signatures with the platform's WebCrypto Ed25519 where
|
|
34
|
+
* available — see `verifyTokenAsync`. Same result, same errors.
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadTokenAsync(bytes: Uint8Array, rootPublicKey: Uint8Array, rootAlgorithm?: 0 | 1): Promise<LoadedToken>;
|
|
31
37
|
/**
|
|
32
38
|
* Reads the key identifier from a token **without verifying it**, so a caller
|
|
33
39
|
* can choose which root key to verify against. The token is untrusted at this
|
|
@@ -37,10 +43,12 @@ export declare function peekRootKeyId(bytes: Uint8Array): number | undefined;
|
|
|
37
43
|
export type FailedCheck = {
|
|
38
44
|
source: "authorizer";
|
|
39
45
|
checkId: number;
|
|
46
|
+
rule: string;
|
|
40
47
|
} | {
|
|
41
48
|
source: "block";
|
|
42
49
|
blockId: number;
|
|
43
50
|
checkId: number;
|
|
51
|
+
rule: string;
|
|
44
52
|
};
|
|
45
53
|
export type AuthorizationResult = {
|
|
46
54
|
kind: "ok";
|
|
@@ -98,15 +106,44 @@ interface AuthorizerCode {
|
|
|
98
106
|
scopes: Scope[];
|
|
99
107
|
varNames: Map<number, string>;
|
|
100
108
|
}
|
|
101
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Parse authorizer (or block) source. `{name}` parameters are bound from
|
|
111
|
+
* `params` as terms; an unbound or an unused parameter is a `ParseError`, as it
|
|
112
|
+
* is in the reference.
|
|
113
|
+
*/
|
|
114
|
+
export declare function parseAuthorizer(src: string, params?: Params): AuthorizerCode;
|
|
102
115
|
export interface AuthorizeOptions {
|
|
103
116
|
limits?: RunLimits;
|
|
104
117
|
/** extern functions callable as `.extern::name(...)` */
|
|
105
118
|
externs?: Map<string, ExternFn>;
|
|
119
|
+
/** values for `{name}` parameters in the authorizer code */
|
|
120
|
+
params?: Params;
|
|
121
|
+
}
|
|
122
|
+
export interface QueryOptions {
|
|
123
|
+
/** values for `{name}` parameters in the query rule */
|
|
124
|
+
params?: Params;
|
|
125
|
+
}
|
|
126
|
+
/** One authorizer run: its result, plus read access to the world it produced. */
|
|
127
|
+
export interface Evaluation {
|
|
128
|
+
readonly result: AuthorizationResult;
|
|
129
|
+
/**
|
|
130
|
+
* Every distinct fact `rule` derives from the evaluated world — the
|
|
131
|
+
* reference's `Authorizer::query`. The rule sees what the authorizer sees
|
|
132
|
+
* (authority block and authorizer facts) unless it says `trusting ...`.
|
|
133
|
+
* Throws when the evaluation itself did not complete.
|
|
134
|
+
*/
|
|
135
|
+
query(rule: string, options?: QueryOptions): Predicate[];
|
|
136
|
+
/** The post-run world, in the shape the official sample corpus records it. */
|
|
137
|
+
snapshot(): WorldSnapshot;
|
|
106
138
|
}
|
|
107
|
-
export declare function authorize(token: LoadedToken, authorizerSrc: string, options?: AuthorizeOptions): AuthorizationResult;
|
|
139
|
+
export declare function authorize(token: LoadedToken | null, authorizerSrc: string, options?: AuthorizeOptions): AuthorizationResult;
|
|
108
140
|
/** Same as `authorize`, and also returns the post-run world, in the shape the
|
|
109
141
|
* official sample corpus records it. */
|
|
110
|
-
export declare function authorizeDetailed(token: LoadedToken, authorizerSrc: string, options?: AuthorizeOptions): AuthorizeDetails;
|
|
142
|
+
export declare function authorizeDetailed(token: LoadedToken | null, authorizerSrc: string, options?: AuthorizeOptions): AuthorizeDetails;
|
|
143
|
+
/**
|
|
144
|
+
* Run the authorizer against a verified token — or against no token at all,
|
|
145
|
+
* for a decision made from the authorizer's own facts and rules.
|
|
146
|
+
*/
|
|
147
|
+
export declare function evaluate(loadedToken: LoadedToken | null, authorizerSrc: string, options?: AuthorizeOptions): Evaluation;
|
|
111
148
|
export {};
|
|
112
149
|
//# sourceMappingURL=authorizer.d.ts.map
|
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,QAAQ,EACb,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"authorizer.d.ts","sourceRoot":"","sources":["../src/authorizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEL,KAAK,KAAK,EAGV,KAAK,QAAQ,EACb,KAAK,IAAI,EAKT,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,KAAK,EAKX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,MAAM,EAAsC,MAAM,aAAa,CAAC;AAiB9E,eAAO,MAAM,eAAe,UA6B3B,CAAC;AAGF,qBAAa,UAAW,SAAQ,KAAK;IAEjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ;IADpC,YACW,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAClC,OAAO,EAAE,MAAM,EAGhB;CACF;AA+GD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AA2CD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;qDACiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,UAAU,EACjB,aAAa,EAAE,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iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC;;;;;OAKG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,EAAE,CAAC;IACzD,8EAA8E;IAC9E,QAAQ,IAAI,aAAa,CAAC;CAC3B;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,gBAAqB,GAC7B,mBAAmB,CAErB;AAID;yCACyC;AACzC,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,gBAAqB,GAC7B,gBAAgB,CAGlB;AAID;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,WAAW,EAAE,WAAW,GAAG,IAAI,EAC/B,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,gBAAqB,GAC7B,UAAU,CA4LZ"}
|
package/dist/builder.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { generateKeypair } from "./crypto.js";
|
|
7
7
|
import type { Check, Predicate, Rule, Scope } from "./datalog.js";
|
|
8
8
|
import { type BlockMsg, type PublicKeyMsg } from "./proto.js";
|
|
9
|
+
import type { Params } from "./parser.js";
|
|
9
10
|
export declare class BuilderError extends Error {
|
|
10
11
|
}
|
|
11
12
|
export interface Keypair {
|
|
@@ -20,6 +21,8 @@ export interface BlockContent {
|
|
|
20
21
|
rules: Rule[];
|
|
21
22
|
checks: Check[];
|
|
22
23
|
scopes: Scope[];
|
|
24
|
+
/** variable id -> name; ids without a name are written as their decimal id */
|
|
25
|
+
varNames?: ReadonlyMap<number, string>;
|
|
23
26
|
}
|
|
24
27
|
export declare function buildBlockMsg(content: BlockContent, knownSymbols?: string[], knownKeys?: string[], minVersion?: number): BlockMsg;
|
|
25
28
|
export interface BuildOptions {
|
|
@@ -27,6 +30,8 @@ export interface BuildOptions {
|
|
|
27
30
|
/** supply a next keypair instead of generating one (tests, determinism) */
|
|
28
31
|
nextKeypair?: Keypair;
|
|
29
32
|
algorithm?: 0 | 1;
|
|
33
|
+
/** values for `{name}` parameters in the block code */
|
|
34
|
+
params?: Params;
|
|
30
35
|
}
|
|
31
36
|
/** Mint a new token whose authority block holds `code`. */
|
|
32
37
|
export declare function buildToken(rootSecret: Uint8Array, code: string | BlockContent, options?: BuildOptions): Uint8Array;
|
|
@@ -46,7 +51,7 @@ export interface ThirdPartyResponse {
|
|
|
46
51
|
publicKey: PublicKeyMsg;
|
|
47
52
|
}
|
|
48
53
|
/** The third party builds and signs a block without holding the token. */
|
|
49
|
-
export declare function thirdPartyBlock(request: ThirdPartyRequest, externalSecret: Uint8Array, code: string | BlockContent, algorithm?: 0 | 1): ThirdPartyResponse;
|
|
54
|
+
export declare function thirdPartyBlock(request: ThirdPartyRequest, externalSecret: Uint8Array, code: string | BlockContent, algorithm?: 0 | 1, params?: Params): ThirdPartyResponse;
|
|
50
55
|
/** The token holder appends a block signed by a third party. */
|
|
51
56
|
export declare function appendThirdParty(tokenBytes: Uint8Array, response: ThirdPartyResponse, options?: BuildOptions): Uint8Array;
|
|
52
57
|
//# sourceMappingURL=builder.d.ts.map
|
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,EAEL,KAAK,QAAQ,EAQb,KAAK,YAAY,EAIlB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],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YAAiB,GACzB,UAAU,CAgBZ;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CACvB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,GAAG,YAAY,EAC3B,OAAO,GAAE,YAAiB,GACzB,UAAU,CA4BZ;AAED,wDAAwD;AACxD,wBAAgB,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAO5D;AAID,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB,CAI3E;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,YAAY,CAAC;CACzB;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAC7B,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EAAE,UAAU,EAC1B,IAAI,EAAE,MAAM,GAAG,YAAY,EAC3B,SAAS,GAAE,CAAC,GAAG,CAAK,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,kBAAkB,CAWpB;AAED,gEAAgE;AAChE,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,YAAiB,GACzB,UAAU,CA2BZ"}
|
package/dist/crypto.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ export declare function generateKeypair(algorithm?: 0 | 1): {
|
|
|
17
17
|
export { bytesEqual };
|
|
18
18
|
/** Verifies the full signature chain and the proof. Throws on failure. */
|
|
19
19
|
export declare function verifyToken(token: BiscuitMsg, rootPublicKey: Uint8Array, rootAlgorithm?: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* `verifyToken`, using the platform's WebCrypto for Ed25519 where it offers it
|
|
22
|
+
* — about ten times faster than the pure-JS path in Node and current browsers.
|
|
23
|
+
* secp256r1, and any runtime without WebCrypto Ed25519, fall back to
|
|
24
|
+
* `@noble/curves`, so the result never depends on where it runs.
|
|
25
|
+
*/
|
|
26
|
+
export declare function verifyTokenAsync(token: BiscuitMsg, rootPublicKey: Uint8Array, rootAlgorithm?: number): Promise<void>;
|
|
20
27
|
/** Revocation identifier of each block: its signature bytes. */
|
|
21
28
|
export declare function revocationIds(token: BiscuitMsg): Uint8Array[];
|
|
22
29
|
//# sourceMappingURL=crypto.d.ts.map
|
package/dist/crypto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExE,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAkB5C,QAAA,MAAM,UAAU,MAAO,UAAU,KAAK,UAAU,KAAG,OACK,CAAC;AAwBzD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAIrF;AAID,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,YAAY,EACrB,WAAW,CAAC,EAAE,UAAU,GACvB,UAAU,CAEZ;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GACd,UAAU,CAWZ;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,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;AAqFD,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAE7D"}
|
package/dist/datalog.d.ts
CHANGED
|
@@ -194,6 +194,8 @@ export declare class World {
|
|
|
194
194
|
/** naive fixpoint: apply every rule until no new fact appears */
|
|
195
195
|
run(limits?: RunLimits): void;
|
|
196
196
|
apply(rule: Rule, facts: FactIndex, ruleOrigin: number): Generator<[Origin, Fact]>;
|
|
197
|
+
/** every distinct fact `rule` derives from the facts `trusted` can see */
|
|
198
|
+
query(rule: Rule, trusted: TrustedOrigins): Predicate[];
|
|
197
199
|
/** `check if` / policies: does at least one combination match? */
|
|
198
200
|
queryMatch(rule: Rule, origin: number, trusted: TrustedOrigins): boolean;
|
|
199
201
|
/** `check all`: every matching combination must satisfy the expressions */
|
package/dist/datalog.d.ts.map
CHANGED
|
@@ -1 +1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ACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
* const text = token.toBase64();
|
|
7
7
|
* const ok = Biscuit.fromBase64(text).verify(root.publicKey).authorize('allow if user("alice");');
|
|
8
8
|
*/
|
|
9
|
-
import { type AuthorizationResult, type AuthorizeOptions, type LoadedToken } from "./authorizer.js";
|
|
9
|
+
import { type AuthorizationResult, type AuthorizeOptions, type Evaluation, type LoadedToken } from "./authorizer.js";
|
|
10
10
|
import { type BuildOptions, generateKeypair, type ThirdPartyResponse, thirdPartyBlock } from "./builder.js";
|
|
11
11
|
export * from "./authorizer.js";
|
|
12
12
|
export * from "./base64.js";
|
|
13
13
|
export * from "./builder.js";
|
|
14
14
|
export { SignatureError } from "./crypto.js";
|
|
15
|
-
export { ExecutionError, type ExternFn, type Term } from "./datalog.js";
|
|
16
|
-
export { ParseError } from "./parser.js";
|
|
15
|
+
export { ExecutionError, type ExternFn, type Predicate, type RunLimits, type Term, } from "./datalog.js";
|
|
16
|
+
export { type ParamValue, type Params, 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. */
|
|
@@ -30,6 +30,11 @@ export declare class Biscuit {
|
|
|
30
30
|
toBase64(): string;
|
|
31
31
|
/** Verify the signature chain. Throws if the token is not authentic. */
|
|
32
32
|
verify(rootPublicKey: Uint8Array, rootAlgorithm?: 0 | 1): VerifiedBiscuit;
|
|
33
|
+
/**
|
|
34
|
+
* `verify`, using WebCrypto Ed25519 where the platform has it — roughly ten
|
|
35
|
+
* times faster than the pure-JS path. Rejects exactly where `verify` throws.
|
|
36
|
+
*/
|
|
37
|
+
verifyAsync(rootPublicKey: Uint8Array, rootAlgorithm?: 0 | 1): Promise<VerifiedBiscuit>;
|
|
33
38
|
}
|
|
34
39
|
/** A token whose signature chain has been checked against a root key. */
|
|
35
40
|
export declare class VerifiedBiscuit {
|
|
@@ -40,6 +45,8 @@ export declare class VerifiedBiscuit {
|
|
|
40
45
|
/** the issuer's key identifier, when the token carries one */
|
|
41
46
|
get rootKeyId(): number | undefined;
|
|
42
47
|
authorize(authorizerCode: string, options?: AuthorizeOptions): AuthorizationResult;
|
|
48
|
+
/** Authorize, keeping the evaluated world available to `query`. */
|
|
49
|
+
evaluate(authorizerCode: string, options?: AuthorizeOptions): Evaluation;
|
|
43
50
|
}
|
|
44
51
|
export { generateKeypair, thirdPartyBlock };
|
|
45
52
|
//# sourceMappingURL=index.d.ts.map
|
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,WAAW,
|
|
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,UAAU,EAAE,KAAK,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAA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