@hesohq/verify-wasm 0.1.0-dev.2
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/heso_wasm.d.ts +353 -0
- package/heso_wasm.js +1125 -0
- package/heso_wasm_bg.wasm +0 -0
- package/heso_wasm_bg.wasm.d.ts +62 -0
- package/package.json +24 -0
package/heso_wasm.d.ts
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The verdict returned by all single-receipt verify functions.
|
|
6
|
+
*/
|
|
7
|
+
export class ActionVerdict {
|
|
8
|
+
private constructor();
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* The re-derived trust level: `"L0"` or `"L1"`.
|
|
13
|
+
* Only meaningful when `verdict == "Valid"`.
|
|
14
|
+
*/
|
|
15
|
+
trust_level: string;
|
|
16
|
+
/**
|
|
17
|
+
* One of the `ActionOutcome` variant names as a string. "Valid" on success;
|
|
18
|
+
* "WrongAlgorithm:…", "HashMismatch", "InvalidSignature:…", etc. on failure.
|
|
19
|
+
*/
|
|
20
|
+
verdict: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Decoded claims from a verified approval token.
|
|
25
|
+
*/
|
|
26
|
+
export class ApprovalTokenClaims {
|
|
27
|
+
private constructor();
|
|
28
|
+
free(): void;
|
|
29
|
+
[Symbol.dispose](): void;
|
|
30
|
+
/**
|
|
31
|
+
* Base64-encoded Ed25519 public key of the approver.
|
|
32
|
+
*/
|
|
33
|
+
approver_public_key: string;
|
|
34
|
+
/**
|
|
35
|
+
* Expiry as Unix seconds (`BigInt`).
|
|
36
|
+
*/
|
|
37
|
+
expiry_unix_secs: bigint;
|
|
38
|
+
/**
|
|
39
|
+
* The 32-byte random nonce as a `Uint8Array`.
|
|
40
|
+
*/
|
|
41
|
+
nonce: Uint8Array;
|
|
42
|
+
/**
|
|
43
|
+
* The scope string encoded in the token.
|
|
44
|
+
*/
|
|
45
|
+
scope: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The result of verifying a chain of `ActionReceipt`s.
|
|
50
|
+
*/
|
|
51
|
+
export class ChainResult {
|
|
52
|
+
private constructor();
|
|
53
|
+
free(): void;
|
|
54
|
+
[Symbol.dispose](): void;
|
|
55
|
+
/**
|
|
56
|
+
* Human-readable detail. Only set when `ok == false`.
|
|
57
|
+
*/
|
|
58
|
+
get detail(): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Human-readable detail. Only set when `ok == false`.
|
|
61
|
+
*/
|
|
62
|
+
set detail(value: string | null | undefined);
|
|
63
|
+
/**
|
|
64
|
+
* Error kind string. Only set when `ok == false`.
|
|
65
|
+
*/
|
|
66
|
+
get error(): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Error kind string. Only set when `ok == false`.
|
|
69
|
+
*/
|
|
70
|
+
set error(value: string | null | undefined);
|
|
71
|
+
/**
|
|
72
|
+
* Number of receipts verified. Only set when `ok == true`.
|
|
73
|
+
*/
|
|
74
|
+
get length(): number | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Number of receipts verified. Only set when `ok == true`.
|
|
77
|
+
*/
|
|
78
|
+
set length(value: number | null | undefined);
|
|
79
|
+
/**
|
|
80
|
+
* `true` when every link verified.
|
|
81
|
+
*/
|
|
82
|
+
ok: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The `seq` at which the error occurred. Only set when `ok == false`.
|
|
85
|
+
*/
|
|
86
|
+
get seq(): number | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The `seq` at which the error occurred. Only set when `ok == false`.
|
|
89
|
+
*/
|
|
90
|
+
set seq(value: number | null | undefined);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The verified, decoded result of a delegation envelope.
|
|
95
|
+
*/
|
|
96
|
+
export class VerifiedDelegation {
|
|
97
|
+
private constructor();
|
|
98
|
+
free(): void;
|
|
99
|
+
[Symbol.dispose](): void;
|
|
100
|
+
/**
|
|
101
|
+
* The authorized key `K` (raw 32-byte Ed25519 public key) as a `Uint8Array`.
|
|
102
|
+
*/
|
|
103
|
+
authorized_key: Uint8Array;
|
|
104
|
+
/**
|
|
105
|
+
* The envelope's expiry as Unix seconds (`BigInt`).
|
|
106
|
+
*/
|
|
107
|
+
expiry_unix_secs: bigint;
|
|
108
|
+
/**
|
|
109
|
+
* The envelope's not_before as Unix seconds (`BigInt`).
|
|
110
|
+
*/
|
|
111
|
+
not_before_unix_secs: bigint;
|
|
112
|
+
/**
|
|
113
|
+
* The scope the delegated authority was bound to.
|
|
114
|
+
*/
|
|
115
|
+
scope: string;
|
|
116
|
+
/**
|
|
117
|
+
* The subject string the operator stamped onto the delegation.
|
|
118
|
+
*/
|
|
119
|
+
sub: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Return the RFC-8785 (JCS) canonical bytes of an `ActionContent` JSON string,
|
|
124
|
+
* with `action_hash` stripped. The shared canonicalizer — the browser MUST
|
|
125
|
+
* call this rather than any hand-rolled JCS implementation to avoid drift.
|
|
126
|
+
*/
|
|
127
|
+
export function actionCanonicalBytes(content_json: string): Uint8Array;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Pre-anchor BLAKE3 hash (excludes `time_anchor` from the canonical bytes).
|
|
131
|
+
* Replaces `@noble/hashes` blake3 usage in `crypto.ts`.
|
|
132
|
+
*/
|
|
133
|
+
export function anchoredContentHash(content_json: string): string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Compute a domain-separated BLAKE3 chain-link digest from two 64-hex hashes.
|
|
137
|
+
* Replaces the `@noble`-backed chain helper in `crypto.ts`.
|
|
138
|
+
*/
|
|
139
|
+
export function chainHashHex(prev_hex: string, action_hex: string): string;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* BLAKE3 (64-hex) of the canonical bytes — the value that goes into
|
|
143
|
+
* `action_hash`. Replaces `@noble/hashes` blake3 usage in `crypto.ts`.
|
|
144
|
+
*/
|
|
145
|
+
export function contentHash(content_json: string): string;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Parse + validate policy TOML, running the load-time dangerous-lane floor check.
|
|
149
|
+
* Throws a `[PARSE]` or `[FLOOR_BYPASS]` `JsError` on failure; returns nothing on
|
|
150
|
+
* success. The web calls this before deploy so a floor-bypassing policy is caught
|
|
151
|
+
* in the browser with the exact engine reason, not bounced by the backend.
|
|
152
|
+
*/
|
|
153
|
+
export function parsePolicy(toml_src: string): void;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Parse + validate policy TOML and return the rules as a JSON array of
|
|
157
|
+
* [`PolicyRule`] (the Rust wire shape) so the web renders a pulled policy via the
|
|
158
|
+
* REAL parser — no JS TOML library, no JS re-implementation of the parse (which
|
|
159
|
+
* today splits on the wrong marker and drops all conditions). Throws the same
|
|
160
|
+
* `[PARSE]` / `[FLOOR_BYPASS]` errors as `parsePolicy`. Empty TOML yields `[]`.
|
|
161
|
+
*/
|
|
162
|
+
export function policyRulesFromToml(toml_src: string): string;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Render a single rule (JSON [`PolicyRule`]) into the canonical English sentence
|
|
166
|
+
* — the SAME `rule_display` stamped on signed receipts. Replaces the drifting JS
|
|
167
|
+
* renderer so the in-UI preview is byte-identical to the audit string.
|
|
168
|
+
*/
|
|
169
|
+
export function ruleToSentence(rule_json: string): string;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Return a short display form of a 64-hex BLAKE3 hash: `{prefix}:{first8}`.
|
|
173
|
+
* Replaces the `@noble`-backed display helper in `crypto.ts`.
|
|
174
|
+
*/
|
|
175
|
+
export function shortHash(hex: string, prefix?: string | null): string;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Floor pre-check over a candidate ruleset (JSON array of [`PolicyRule`]) WITHOUT
|
|
179
|
+
* serializing to TOML — the live check the builder runs as the user edits.
|
|
180
|
+
* Throws a `[FLOOR_BYPASS]` `JsError` (carrying the offending rule id + verb) when
|
|
181
|
+
* a rule would allow-without-approval a dangerous lane; returns nothing when the
|
|
182
|
+
* policy only tightens.
|
|
183
|
+
*/
|
|
184
|
+
export function validateNoFloorBypass(rules_json: string): void;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Verify a single `ActionReceipt` from its raw JSON bytes (`Uint8Array`) or a
|
|
188
|
+
* JSON string.
|
|
189
|
+
*
|
|
190
|
+
* Never panics — structural failures return an `ActionVerdict` with
|
|
191
|
+
* `verdict = "Malformed:…"`. This is the browser replacement for the
|
|
192
|
+
* `verifyReceipt` function in `crypto.ts`, backed by the identical Rust
|
|
193
|
+
* JCS + BLAKE3 + Ed25519 path so Node and browser get byte-identical results.
|
|
194
|
+
*/
|
|
195
|
+
export function verifyActionReceipt(receipt_bytes: Uint8Array): ActionVerdict;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Verify a serialized approval token and return its decoded claims.
|
|
199
|
+
*
|
|
200
|
+
* Pure verify (Ed25519 `verify_strict` via heso-verify), no OsRng — wasm-safe.
|
|
201
|
+
* Throws a `JsError` with a stable `[CODE]` prefix per `ApprovalTokenError`
|
|
202
|
+
* variant, matching the napi surface.
|
|
203
|
+
*
|
|
204
|
+
* `token` — raw token bytes (Uint8Array)
|
|
205
|
+
* `action_canonical` — the action's canonical bytes (from `actionCanonicalBytes`)
|
|
206
|
+
* `now_unix_secs` — current time as BigInt Unix seconds
|
|
207
|
+
* `seen_nonces` — array of already-seen 32-byte nonces (Uint8Array each)
|
|
208
|
+
* `required_scope` — the required scope string
|
|
209
|
+
* `registered_keys_b64` — array of base64 Ed25519 public keys on the allowlist
|
|
210
|
+
*/
|
|
211
|
+
export function verifyApprovalToken(token: Uint8Array, action_canonical: Uint8Array, now_unix_secs: bigint, seen_nonces: Array<any>, required_scope: string, registered_keys_b64: Array<any>): ApprovalTokenClaims;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Verify an ordered array of `ActionReceipt`s as a tamper-evident chain.
|
|
215
|
+
*
|
|
216
|
+
* Input: raw bytes of a JSON array of receipts (`Uint8Array` or similar).
|
|
217
|
+
*/
|
|
218
|
+
export function verifyChain(receipts_bytes: Uint8Array): ChainResult;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* RFC-6962 consistency proof verification.
|
|
222
|
+
*
|
|
223
|
+
* Returns `true` iff the proof proves the new tree is an append-only extension.
|
|
224
|
+
*/
|
|
225
|
+
export function verifyConsistency(old_size: number, old_root_hex: string, new_size: number, new_root_hex: string, proof_hashes_json: string): boolean;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Verify a serialized delegation envelope and its human co-sign.
|
|
229
|
+
*
|
|
230
|
+
* Pure verify (Ed25519 `verify_strict` via heso-verify), no OsRng — wasm-safe.
|
|
231
|
+
* Throws a `JsError` with a stable `[CODE]` prefix per `DelegationError` variant,
|
|
232
|
+
* matching the napi surface.
|
|
233
|
+
*
|
|
234
|
+
* `wire` — raw delegation envelope bytes (Uint8Array)
|
|
235
|
+
* `registered_operator_key` — the org-registered operator public key (raw 32 bytes)
|
|
236
|
+
* `action_hash` — the raw 32-byte BLAKE3 action digest being authorized
|
|
237
|
+
* `approval_token` — the human co-sign bearer token presented by K
|
|
238
|
+
* `required_scope` — the required scope string
|
|
239
|
+
* `now_unix_secs` — current time as BigInt Unix seconds
|
|
240
|
+
*/
|
|
241
|
+
export function verifyDelegation(wire: Uint8Array, registered_operator_key: Uint8Array, action_hash: Uint8Array, approval_token: Uint8Array, required_scope: string, now_unix_secs: bigint): VerifiedDelegation;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* RFC-6962 inclusion proof verification (SHA-256 Merkle tree).
|
|
245
|
+
*
|
|
246
|
+
* `leaf_value_hex` — the 64-hex `action_hash`; raw bytes are the leaf value.
|
|
247
|
+
* `proof_hashes` — array of 64-hex SHA-256 sibling hashes (space-separated
|
|
248
|
+
* OR JSON array string).
|
|
249
|
+
* `root_hex` — 64-hex SHA-256 tree root.
|
|
250
|
+
*
|
|
251
|
+
* Returns `true` iff the proof verifies.
|
|
252
|
+
*/
|
|
253
|
+
export function verifyInclusion(leaf_value_hex: string, index: number, size: number, root_hex: string, proof_hashes_json: string): boolean;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Verify a session chain (lifecycle role + transition checks).
|
|
257
|
+
*/
|
|
258
|
+
export function verifySessionChain(receipts_bytes: Uint8Array): ChainResult;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Verify a session chain with key-rotation as-of-position enforcement.
|
|
262
|
+
*
|
|
263
|
+
* `producer_key` — base64 genesis producer key (TOFU pin).
|
|
264
|
+
* `decision_key` — optional base64 genesis decision key.
|
|
265
|
+
*/
|
|
266
|
+
export function verifySessionChainWithRotation(receipts_bytes: Uint8Array, producer_key: string, decision_key?: string | null): ChainResult;
|
|
267
|
+
|
|
268
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
269
|
+
|
|
270
|
+
export interface InitOutput {
|
|
271
|
+
readonly memory: WebAssembly.Memory;
|
|
272
|
+
readonly __wbg_actionverdict_free: (a: number, b: number) => void;
|
|
273
|
+
readonly __wbg_get_actionverdict_verdict: (a: number) => [number, number];
|
|
274
|
+
readonly __wbg_set_actionverdict_verdict: (a: number, b: number, c: number) => void;
|
|
275
|
+
readonly __wbg_get_actionverdict_trust_level: (a: number) => [number, number];
|
|
276
|
+
readonly __wbg_set_actionverdict_trust_level: (a: number, b: number, c: number) => void;
|
|
277
|
+
readonly __wbg_chainresult_free: (a: number, b: number) => void;
|
|
278
|
+
readonly __wbg_get_chainresult_ok: (a: number) => number;
|
|
279
|
+
readonly __wbg_set_chainresult_ok: (a: number, b: number) => void;
|
|
280
|
+
readonly __wbg_get_chainresult_length: (a: number) => number;
|
|
281
|
+
readonly __wbg_set_chainresult_length: (a: number, b: number) => void;
|
|
282
|
+
readonly __wbg_get_chainresult_error: (a: number) => [number, number];
|
|
283
|
+
readonly __wbg_set_chainresult_error: (a: number, b: number, c: number) => void;
|
|
284
|
+
readonly __wbg_get_chainresult_seq: (a: number) => number;
|
|
285
|
+
readonly __wbg_set_chainresult_seq: (a: number, b: number) => void;
|
|
286
|
+
readonly __wbg_get_chainresult_detail: (a: number) => [number, number];
|
|
287
|
+
readonly __wbg_set_chainresult_detail: (a: number, b: number, c: number) => void;
|
|
288
|
+
readonly __wbg_approvaltokenclaims_free: (a: number, b: number) => void;
|
|
289
|
+
readonly __wbg_get_approvaltokenclaims_nonce: (a: number) => any;
|
|
290
|
+
readonly __wbg_set_approvaltokenclaims_nonce: (a: number, b: any) => void;
|
|
291
|
+
readonly __wbg_get_approvaltokenclaims_expiry_unix_secs: (a: number) => any;
|
|
292
|
+
readonly __wbg_set_approvaltokenclaims_expiry_unix_secs: (a: number, b: any) => void;
|
|
293
|
+
readonly __wbg_get_approvaltokenclaims_scope: (a: number) => [number, number];
|
|
294
|
+
readonly __wbg_get_approvaltokenclaims_approver_public_key: (a: number) => [number, number];
|
|
295
|
+
readonly __wbg_verifieddelegation_free: (a: number, b: number) => void;
|
|
296
|
+
readonly __wbg_get_verifieddelegation_sub: (a: number) => [number, number];
|
|
297
|
+
readonly __wbg_get_verifieddelegation_scope: (a: number) => [number, number];
|
|
298
|
+
readonly __wbg_get_verifieddelegation_not_before_unix_secs: (a: number) => any;
|
|
299
|
+
readonly __wbg_set_verifieddelegation_not_before_unix_secs: (a: number, b: any) => void;
|
|
300
|
+
readonly verifyActionReceipt: (a: number, b: number) => number;
|
|
301
|
+
readonly actionCanonicalBytes: (a: number, b: number) => [number, number, number];
|
|
302
|
+
readonly contentHash: (a: number, b: number) => [number, number, number, number];
|
|
303
|
+
readonly anchoredContentHash: (a: number, b: number) => [number, number, number, number];
|
|
304
|
+
readonly shortHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
305
|
+
readonly chainHashHex: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
306
|
+
readonly verifyApprovalToken: (a: number, b: number, c: number, d: number, e: any, f: any, g: number, h: number, i: any) => [number, number, number];
|
|
307
|
+
readonly verifyDelegation: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: any) => [number, number, number];
|
|
308
|
+
readonly verifyChain: (a: number, b: number) => [number, number, number];
|
|
309
|
+
readonly verifySessionChain: (a: number, b: number) => [number, number, number];
|
|
310
|
+
readonly verifySessionChainWithRotation: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
311
|
+
readonly verifyInclusion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
312
|
+
readonly verifyConsistency: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
313
|
+
readonly parsePolicy: (a: number, b: number) => [number, number];
|
|
314
|
+
readonly ruleToSentence: (a: number, b: number) => [number, number, number, number];
|
|
315
|
+
readonly policyRulesFromToml: (a: number, b: number) => [number, number, number, number];
|
|
316
|
+
readonly validateNoFloorBypass: (a: number, b: number) => [number, number];
|
|
317
|
+
readonly __wbg_set_verifieddelegation_authorized_key: (a: number, b: any) => void;
|
|
318
|
+
readonly __wbg_set_verifieddelegation_expiry_unix_secs: (a: number, b: any) => void;
|
|
319
|
+
readonly __wbg_get_verifieddelegation_authorized_key: (a: number) => any;
|
|
320
|
+
readonly __wbg_get_verifieddelegation_expiry_unix_secs: (a: number) => any;
|
|
321
|
+
readonly __wbg_set_approvaltokenclaims_scope: (a: number, b: number, c: number) => void;
|
|
322
|
+
readonly __wbg_set_approvaltokenclaims_approver_public_key: (a: number, b: number, c: number) => void;
|
|
323
|
+
readonly __wbg_set_verifieddelegation_sub: (a: number, b: number, c: number) => void;
|
|
324
|
+
readonly __wbg_set_verifieddelegation_scope: (a: number, b: number, c: number) => void;
|
|
325
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
326
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
327
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
328
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
329
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
330
|
+
readonly __wbindgen_start: () => void;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
337
|
+
* a precompiled `WebAssembly.Module`.
|
|
338
|
+
*
|
|
339
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
340
|
+
*
|
|
341
|
+
* @returns {InitOutput}
|
|
342
|
+
*/
|
|
343
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
347
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
348
|
+
*
|
|
349
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
350
|
+
*
|
|
351
|
+
* @returns {Promise<InitOutput>}
|
|
352
|
+
*/
|
|
353
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|