@statewalker/webrun-biscuit 0.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/LICENSE +21 -0
- package/README.md +262 -0
- package/dist/authorizer.d.ts +112 -0
- package/dist/authorizer.d.ts.map +1 -0
- package/dist/base64.d.ts +3 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/builder.d.ts +52 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/crypto.d.ts +22 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/datalog.d.ts +203 -0
- package/dist/datalog.d.ts.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3130 -0
- package/dist/parser.d.ts +80 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/print.d.ts +12 -0
- package/dist/print.d.ts.map +1 -0
- package/dist/proto.d.ts +132 -0
- package/dist/proto.d.ts.map +1 -0
- package/dist/version.d.ts +42 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +58 -0
- package/src/authorizer.ts +581 -0
- package/src/base64.ts +42 -0
- package/src/builder.ts +360 -0
- package/src/crypto.ts +208 -0
- package/src/datalog.ts +722 -0
- package/src/index.ts +93 -0
- package/src/parser.ts +606 -0
- package/src/print.ts +147 -0
- package/src/proto.ts +770 -0
- package/src/version.ts +158 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Biscuit Datalog: term model, fact/rule evaluation with origin tracking, and
|
|
3
|
+
* the stack-based expression virtual machine.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AUTHORIZER = 4294967295;
|
|
6
|
+
export type MapKey = {
|
|
7
|
+
t: "int";
|
|
8
|
+
v: bigint;
|
|
9
|
+
} | {
|
|
10
|
+
t: "str";
|
|
11
|
+
v: string;
|
|
12
|
+
};
|
|
13
|
+
export type Term = {
|
|
14
|
+
t: "var";
|
|
15
|
+
v: number;
|
|
16
|
+
} | {
|
|
17
|
+
t: "int";
|
|
18
|
+
v: bigint;
|
|
19
|
+
} | {
|
|
20
|
+
t: "str";
|
|
21
|
+
v: string;
|
|
22
|
+
} | {
|
|
23
|
+
t: "date";
|
|
24
|
+
v: bigint;
|
|
25
|
+
} | {
|
|
26
|
+
t: "bytes";
|
|
27
|
+
v: Uint8Array;
|
|
28
|
+
} | {
|
|
29
|
+
t: "bool";
|
|
30
|
+
v: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
t: "set";
|
|
33
|
+
v: Term[];
|
|
34
|
+
} | {
|
|
35
|
+
t: "null";
|
|
36
|
+
} | {
|
|
37
|
+
t: "array";
|
|
38
|
+
v: Term[];
|
|
39
|
+
} | {
|
|
40
|
+
t: "map";
|
|
41
|
+
v: [MapKey, Term][];
|
|
42
|
+
};
|
|
43
|
+
/** Canonical string key: JS Map/Set are reference-keyed, so every structural
|
|
44
|
+
* comparison and every de-duplication in the engine goes through this. */
|
|
45
|
+
export declare function termKey(t: Term): string;
|
|
46
|
+
export declare const mapKeyKey: (k: MapKey) => string;
|
|
47
|
+
export declare const termEq: (a: Term, b: Term) => boolean;
|
|
48
|
+
/** de-duplicated, deterministically ordered set contents */
|
|
49
|
+
export declare function normalizeSet(items: Term[]): Term[];
|
|
50
|
+
export interface Predicate {
|
|
51
|
+
name: string;
|
|
52
|
+
terms: Term[];
|
|
53
|
+
}
|
|
54
|
+
export interface Fact {
|
|
55
|
+
predicate: Predicate;
|
|
56
|
+
}
|
|
57
|
+
export type Op = {
|
|
58
|
+
kind: "value";
|
|
59
|
+
value: Term;
|
|
60
|
+
} | {
|
|
61
|
+
kind: "unary";
|
|
62
|
+
op: number;
|
|
63
|
+
ffi?: string;
|
|
64
|
+
} | {
|
|
65
|
+
kind: "binary";
|
|
66
|
+
op: number;
|
|
67
|
+
ffi?: string;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "closure";
|
|
70
|
+
params: number[];
|
|
71
|
+
ops: Op[];
|
|
72
|
+
};
|
|
73
|
+
export type Scope = {
|
|
74
|
+
kind: "authority";
|
|
75
|
+
} | {
|
|
76
|
+
kind: "previous";
|
|
77
|
+
} | {
|
|
78
|
+
kind: "publicKey";
|
|
79
|
+
key: string;
|
|
80
|
+
};
|
|
81
|
+
export interface Rule {
|
|
82
|
+
head: Predicate;
|
|
83
|
+
body: Predicate[];
|
|
84
|
+
expressions: Op[][];
|
|
85
|
+
scopes: Scope[];
|
|
86
|
+
}
|
|
87
|
+
export type CheckKind = "one" | "all" | "reject";
|
|
88
|
+
export interface Check {
|
|
89
|
+
queries: Rule[];
|
|
90
|
+
kind: CheckKind;
|
|
91
|
+
}
|
|
92
|
+
export declare const factKey: (f: Fact) => string;
|
|
93
|
+
export declare class Origin {
|
|
94
|
+
readonly ids: number[];
|
|
95
|
+
constructor(ids?: number[]);
|
|
96
|
+
static of(...ids: number[]): Origin;
|
|
97
|
+
union(other: Origin): Origin;
|
|
98
|
+
with(id: number): Origin;
|
|
99
|
+
get key(): string;
|
|
100
|
+
}
|
|
101
|
+
export declare class TrustedOrigins {
|
|
102
|
+
private readonly set;
|
|
103
|
+
constructor(ids: Iterable<number>);
|
|
104
|
+
static default(): TrustedOrigins;
|
|
105
|
+
/** the trusted set is a superset of the fact's origin */
|
|
106
|
+
contains(origin: Origin): boolean;
|
|
107
|
+
get key(): string;
|
|
108
|
+
/** the trusted block ids, for deriving a new set from this one */
|
|
109
|
+
ids(): Iterable<number>;
|
|
110
|
+
}
|
|
111
|
+
export declare function trustedOriginsFromScopes(ruleScopes: Scope[], defaults: TrustedOrigins, currentBlock: number, publicKeyToBlockIds: Map<string, number[]>): TrustedOrigins;
|
|
112
|
+
export type ExecutionErrorKind = "Overflow" | "DivideByZero" | "InvalidType" | "UnknownVariable" | "ShadowedVariable" | "InvalidStack" | "UndefinedExtern" | "TooManyFacts" | "TooManyIterations" | "Timeout";
|
|
113
|
+
export declare class ExecutionError extends Error {
|
|
114
|
+
readonly kind: ExecutionErrorKind;
|
|
115
|
+
constructor(kind: ExecutionErrorKind, message?: string);
|
|
116
|
+
}
|
|
117
|
+
export declare const BinaryOp: {
|
|
118
|
+
LessThan: number;
|
|
119
|
+
GreaterThan: number;
|
|
120
|
+
LessOrEqual: number;
|
|
121
|
+
GreaterOrEqual: number;
|
|
122
|
+
Equal: number;
|
|
123
|
+
Contains: number;
|
|
124
|
+
Prefix: number;
|
|
125
|
+
Suffix: number;
|
|
126
|
+
Regex: number;
|
|
127
|
+
Add: number;
|
|
128
|
+
Sub: number;
|
|
129
|
+
Mul: number;
|
|
130
|
+
Div: number;
|
|
131
|
+
And: number;
|
|
132
|
+
Or: number;
|
|
133
|
+
Intersection: number;
|
|
134
|
+
Union: number;
|
|
135
|
+
BitwiseAnd: number;
|
|
136
|
+
BitwiseOr: number;
|
|
137
|
+
BitwiseXor: number;
|
|
138
|
+
NotEqual: number;
|
|
139
|
+
HeterogeneousEqual: number;
|
|
140
|
+
HeterogeneousNotEqual: number;
|
|
141
|
+
LazyAnd: number;
|
|
142
|
+
LazyOr: number;
|
|
143
|
+
All: number;
|
|
144
|
+
Any: number;
|
|
145
|
+
Get: number;
|
|
146
|
+
Ffi: number;
|
|
147
|
+
TryOr: number;
|
|
148
|
+
};
|
|
149
|
+
export declare const UnaryOp: {
|
|
150
|
+
Negate: number;
|
|
151
|
+
Parens: number;
|
|
152
|
+
Length: number;
|
|
153
|
+
TypeOf: number;
|
|
154
|
+
Ffi: number;
|
|
155
|
+
};
|
|
156
|
+
export type ExternFn = (left: Term, right?: Term) => Term;
|
|
157
|
+
type Bindings = Map<number, Term>;
|
|
158
|
+
export declare function evaluateExpression(ops: Op[], values: Bindings, externs?: Map<string, ExternFn>): Term;
|
|
159
|
+
export interface RunLimits {
|
|
160
|
+
maxFacts: number;
|
|
161
|
+
maxIterations: number;
|
|
162
|
+
maxTimeMs: number;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Note the divergence: the reference defaults `max_time` to **1 millisecond**,
|
|
166
|
+
* which is unreachably tight for a cold JS engine and would make ordinary
|
|
167
|
+
* tokens fail non-deterministically. 1 second is generous by comparison, so a
|
|
168
|
+
* caller exposed to untrusted tokens should lower it deliberately rather than
|
|
169
|
+
* rely on this default as a denial-of-service bound.
|
|
170
|
+
*/
|
|
171
|
+
export declare const DEFAULT_LIMITS: RunLimits;
|
|
172
|
+
type OriginFact = [Origin, Fact];
|
|
173
|
+
/** facts grouped by `name/arity`, so a join never scans unrelated predicates */
|
|
174
|
+
type FactIndex = Map<string, OriginFact[]>;
|
|
175
|
+
export declare class World {
|
|
176
|
+
/** facts indexed by origin key */
|
|
177
|
+
readonly facts: Map<string, {
|
|
178
|
+
origin: Origin;
|
|
179
|
+
items: Map<string, Fact>;
|
|
180
|
+
}>;
|
|
181
|
+
readonly rules: {
|
|
182
|
+
origin: number;
|
|
183
|
+
trusted: TrustedOrigins;
|
|
184
|
+
rule: Rule;
|
|
185
|
+
}[];
|
|
186
|
+
externs: Map<string, ExternFn>;
|
|
187
|
+
iterations: number;
|
|
188
|
+
private generation;
|
|
189
|
+
private indexCache;
|
|
190
|
+
addFact(origin: Origin, fact: Fact): void;
|
|
191
|
+
addRule(origin: number, trusted: TrustedOrigins, rule: Rule): void;
|
|
192
|
+
factCount(): number;
|
|
193
|
+
private visible;
|
|
194
|
+
/** naive fixpoint: apply every rule until no new fact appears */
|
|
195
|
+
run(limits?: RunLimits): void;
|
|
196
|
+
apply(rule: Rule, facts: FactIndex, ruleOrigin: number): Generator<[Origin, Fact]>;
|
|
197
|
+
/** `check if` / policies: does at least one combination match? */
|
|
198
|
+
queryMatch(rule: Rule, origin: number, trusted: TrustedOrigins): boolean;
|
|
199
|
+
/** `check all`: every matching combination must satisfy the expressions */
|
|
200
|
+
queryMatchAll(rule: Rule, trusted: TrustedOrigins): boolean;
|
|
201
|
+
}
|
|
202
|
+
export {};
|
|
203
|
+
//# sourceMappingURL=datalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datalog.d.ts","source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AAI,EAAE,IAAI,GAAG,IAAI,CAEjE;IAED,SAAS,IAAI,MAAM,CAIlB;IAED,OAAO,CAAC,OAAO;IAkBf,iEAAiE;IACjE,GAAG,CAAC,MAAM,GAAE,SAA0B,GAAG,IAAI,CAmB5C;IAEA,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CA4BlF;IAED,kEAAkE;IAClE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAGvE;IAED,2EAA2E;IAC3E,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAY1D;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* biscuit-ts — pure TypeScript Biscuit tokens.
|
|
3
|
+
*
|
|
4
|
+
* const root = generateKeypair();
|
|
5
|
+
* const token = Biscuit.build(root.secretKey, 'user("alice");');
|
|
6
|
+
* const text = token.toBase64();
|
|
7
|
+
* const ok = Biscuit.fromBase64(text).verify(root.publicKey).authorize('allow if user("alice");');
|
|
8
|
+
*/
|
|
9
|
+
import { type AuthorizationResult, type AuthorizeOptions, type LoadedToken } from "./authorizer.js";
|
|
10
|
+
import { type BuildOptions, generateKeypair, type ThirdPartyResponse, thirdPartyBlock } from "./builder.js";
|
|
11
|
+
export * from "./authorizer.js";
|
|
12
|
+
export * from "./base64.js";
|
|
13
|
+
export * from "./builder.js";
|
|
14
|
+
export { SignatureError } from "./crypto.js";
|
|
15
|
+
export { ExecutionError, type ExternFn, type Term } from "./datalog.js";
|
|
16
|
+
export { ParseError } from "./parser.js";
|
|
17
|
+
export { ProtoError } from "./proto.js";
|
|
18
|
+
export * from "./version.js";
|
|
19
|
+
/** An unverified token: it can be attenuated and re-serialized. */
|
|
20
|
+
export declare class Biscuit {
|
|
21
|
+
readonly bytes: Uint8Array;
|
|
22
|
+
private constructor();
|
|
23
|
+
static build(rootSecret: Uint8Array, code: string, options?: BuildOptions): Biscuit;
|
|
24
|
+
static fromBytes(bytes: Uint8Array): Biscuit;
|
|
25
|
+
static fromBase64(text: string): Biscuit;
|
|
26
|
+
attenuate(code: string, options?: BuildOptions): Biscuit;
|
|
27
|
+
appendThirdParty(response: ThirdPartyResponse, options?: BuildOptions): Biscuit;
|
|
28
|
+
thirdPartyRequest(): import("./builder.js").ThirdPartyRequest;
|
|
29
|
+
seal(): Biscuit;
|
|
30
|
+
toBase64(): string;
|
|
31
|
+
/** Verify the signature chain. Throws if the token is not authentic. */
|
|
32
|
+
verify(rootPublicKey: Uint8Array, rootAlgorithm?: 0 | 1): VerifiedBiscuit;
|
|
33
|
+
}
|
|
34
|
+
/** A token whose signature chain has been checked against a root key. */
|
|
35
|
+
export declare class VerifiedBiscuit {
|
|
36
|
+
readonly token: LoadedToken;
|
|
37
|
+
readonly bytes: Uint8Array;
|
|
38
|
+
constructor(token: LoadedToken, bytes: Uint8Array);
|
|
39
|
+
get revocationIds(): string[];
|
|
40
|
+
/** the issuer's key identifier, when the token carries one */
|
|
41
|
+
get rootKeyId(): number | undefined;
|
|
42
|
+
authorize(authorizerCode: string, options?: AuthorizeOptions): AuthorizationResult;
|
|
43
|
+
}
|
|
44
|
+
export { generateKeypair, thirdPartyBlock };
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EAEjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,KAAK,YAAY,EAEjB,eAAe,EAEf,KAAK,kBAAkB,EACvB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