@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.js
ADDED
|
@@ -0,0 +1,1125 @@
|
|
|
1
|
+
/* @ts-self-types="./heso_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The verdict returned by all single-receipt verify functions.
|
|
5
|
+
*/
|
|
6
|
+
export class ActionVerdict {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(ActionVerdict.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
ActionVerdictFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
ActionVerdictFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_actionverdict_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The re-derived trust level: `"L0"` or `"L1"`.
|
|
25
|
+
* Only meaningful when `verdict == "Valid"`.
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
get trust_level() {
|
|
29
|
+
let deferred1_0;
|
|
30
|
+
let deferred1_1;
|
|
31
|
+
try {
|
|
32
|
+
const ret = wasm.__wbg_get_actionverdict_trust_level(this.__wbg_ptr);
|
|
33
|
+
deferred1_0 = ret[0];
|
|
34
|
+
deferred1_1 = ret[1];
|
|
35
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
36
|
+
} finally {
|
|
37
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* One of the `ActionOutcome` variant names as a string. "Valid" on success;
|
|
42
|
+
* "WrongAlgorithm:…", "HashMismatch", "InvalidSignature:…", etc. on failure.
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
get verdict() {
|
|
46
|
+
let deferred1_0;
|
|
47
|
+
let deferred1_1;
|
|
48
|
+
try {
|
|
49
|
+
const ret = wasm.__wbg_get_actionverdict_verdict(this.__wbg_ptr);
|
|
50
|
+
deferred1_0 = ret[0];
|
|
51
|
+
deferred1_1 = ret[1];
|
|
52
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
53
|
+
} finally {
|
|
54
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The re-derived trust level: `"L0"` or `"L1"`.
|
|
59
|
+
* Only meaningful when `verdict == "Valid"`.
|
|
60
|
+
* @param {string} arg0
|
|
61
|
+
*/
|
|
62
|
+
set trust_level(arg0) {
|
|
63
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
64
|
+
const len0 = WASM_VECTOR_LEN;
|
|
65
|
+
wasm.__wbg_set_actionverdict_trust_level(this.__wbg_ptr, ptr0, len0);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* One of the `ActionOutcome` variant names as a string. "Valid" on success;
|
|
69
|
+
* "WrongAlgorithm:…", "HashMismatch", "InvalidSignature:…", etc. on failure.
|
|
70
|
+
* @param {string} arg0
|
|
71
|
+
*/
|
|
72
|
+
set verdict(arg0) {
|
|
73
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
74
|
+
const len0 = WASM_VECTOR_LEN;
|
|
75
|
+
wasm.__wbg_set_actionverdict_verdict(this.__wbg_ptr, ptr0, len0);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (Symbol.dispose) ActionVerdict.prototype[Symbol.dispose] = ActionVerdict.prototype.free;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Decoded claims from a verified approval token.
|
|
82
|
+
*/
|
|
83
|
+
export class ApprovalTokenClaims {
|
|
84
|
+
static __wrap(ptr) {
|
|
85
|
+
const obj = Object.create(ApprovalTokenClaims.prototype);
|
|
86
|
+
obj.__wbg_ptr = ptr;
|
|
87
|
+
ApprovalTokenClaimsFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
88
|
+
return obj;
|
|
89
|
+
}
|
|
90
|
+
__destroy_into_raw() {
|
|
91
|
+
const ptr = this.__wbg_ptr;
|
|
92
|
+
this.__wbg_ptr = 0;
|
|
93
|
+
ApprovalTokenClaimsFinalization.unregister(this);
|
|
94
|
+
return ptr;
|
|
95
|
+
}
|
|
96
|
+
free() {
|
|
97
|
+
const ptr = this.__destroy_into_raw();
|
|
98
|
+
wasm.__wbg_approvaltokenclaims_free(ptr, 0);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Base64-encoded Ed25519 public key of the approver.
|
|
102
|
+
* @returns {string}
|
|
103
|
+
*/
|
|
104
|
+
get approver_public_key() {
|
|
105
|
+
let deferred1_0;
|
|
106
|
+
let deferred1_1;
|
|
107
|
+
try {
|
|
108
|
+
const ret = wasm.__wbg_get_approvaltokenclaims_approver_public_key(this.__wbg_ptr);
|
|
109
|
+
deferred1_0 = ret[0];
|
|
110
|
+
deferred1_1 = ret[1];
|
|
111
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
112
|
+
} finally {
|
|
113
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Expiry as Unix seconds (`BigInt`).
|
|
118
|
+
* @returns {bigint}
|
|
119
|
+
*/
|
|
120
|
+
get expiry_unix_secs() {
|
|
121
|
+
const ret = wasm.__wbg_get_approvaltokenclaims_expiry_unix_secs(this.__wbg_ptr);
|
|
122
|
+
return ret;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The 32-byte random nonce as a `Uint8Array`.
|
|
126
|
+
* @returns {Uint8Array}
|
|
127
|
+
*/
|
|
128
|
+
get nonce() {
|
|
129
|
+
const ret = wasm.__wbg_get_approvaltokenclaims_nonce(this.__wbg_ptr);
|
|
130
|
+
return ret;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The scope string encoded in the token.
|
|
134
|
+
* @returns {string}
|
|
135
|
+
*/
|
|
136
|
+
get scope() {
|
|
137
|
+
let deferred1_0;
|
|
138
|
+
let deferred1_1;
|
|
139
|
+
try {
|
|
140
|
+
const ret = wasm.__wbg_get_approvaltokenclaims_scope(this.__wbg_ptr);
|
|
141
|
+
deferred1_0 = ret[0];
|
|
142
|
+
deferred1_1 = ret[1];
|
|
143
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
144
|
+
} finally {
|
|
145
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Base64-encoded Ed25519 public key of the approver.
|
|
150
|
+
* @param {string} arg0
|
|
151
|
+
*/
|
|
152
|
+
set approver_public_key(arg0) {
|
|
153
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
wasm.__wbg_set_approvaltokenclaims_approver_public_key(this.__wbg_ptr, ptr0, len0);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Expiry as Unix seconds (`BigInt`).
|
|
159
|
+
* @param {bigint} arg0
|
|
160
|
+
*/
|
|
161
|
+
set expiry_unix_secs(arg0) {
|
|
162
|
+
wasm.__wbg_set_approvaltokenclaims_expiry_unix_secs(this.__wbg_ptr, arg0);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The 32-byte random nonce as a `Uint8Array`.
|
|
166
|
+
* @param {Uint8Array} arg0
|
|
167
|
+
*/
|
|
168
|
+
set nonce(arg0) {
|
|
169
|
+
wasm.__wbg_set_approvaltokenclaims_nonce(this.__wbg_ptr, arg0);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The scope string encoded in the token.
|
|
173
|
+
* @param {string} arg0
|
|
174
|
+
*/
|
|
175
|
+
set scope(arg0) {
|
|
176
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
177
|
+
const len0 = WASM_VECTOR_LEN;
|
|
178
|
+
wasm.__wbg_set_approvaltokenclaims_scope(this.__wbg_ptr, ptr0, len0);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (Symbol.dispose) ApprovalTokenClaims.prototype[Symbol.dispose] = ApprovalTokenClaims.prototype.free;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The result of verifying a chain of `ActionReceipt`s.
|
|
185
|
+
*/
|
|
186
|
+
export class ChainResult {
|
|
187
|
+
static __wrap(ptr) {
|
|
188
|
+
const obj = Object.create(ChainResult.prototype);
|
|
189
|
+
obj.__wbg_ptr = ptr;
|
|
190
|
+
ChainResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
191
|
+
return obj;
|
|
192
|
+
}
|
|
193
|
+
__destroy_into_raw() {
|
|
194
|
+
const ptr = this.__wbg_ptr;
|
|
195
|
+
this.__wbg_ptr = 0;
|
|
196
|
+
ChainResultFinalization.unregister(this);
|
|
197
|
+
return ptr;
|
|
198
|
+
}
|
|
199
|
+
free() {
|
|
200
|
+
const ptr = this.__destroy_into_raw();
|
|
201
|
+
wasm.__wbg_chainresult_free(ptr, 0);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Human-readable detail. Only set when `ok == false`.
|
|
205
|
+
* @returns {string | undefined}
|
|
206
|
+
*/
|
|
207
|
+
get detail() {
|
|
208
|
+
const ret = wasm.__wbg_get_chainresult_detail(this.__wbg_ptr);
|
|
209
|
+
let v1;
|
|
210
|
+
if (ret[0] !== 0) {
|
|
211
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
212
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
213
|
+
}
|
|
214
|
+
return v1;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Error kind string. Only set when `ok == false`.
|
|
218
|
+
* @returns {string | undefined}
|
|
219
|
+
*/
|
|
220
|
+
get error() {
|
|
221
|
+
const ret = wasm.__wbg_get_chainresult_error(this.__wbg_ptr);
|
|
222
|
+
let v1;
|
|
223
|
+
if (ret[0] !== 0) {
|
|
224
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
225
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
226
|
+
}
|
|
227
|
+
return v1;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Number of receipts verified. Only set when `ok == true`.
|
|
231
|
+
* @returns {number | undefined}
|
|
232
|
+
*/
|
|
233
|
+
get length() {
|
|
234
|
+
const ret = wasm.__wbg_get_chainresult_length(this.__wbg_ptr);
|
|
235
|
+
return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* `true` when every link verified.
|
|
239
|
+
* @returns {boolean}
|
|
240
|
+
*/
|
|
241
|
+
get ok() {
|
|
242
|
+
const ret = wasm.__wbg_get_chainresult_ok(this.__wbg_ptr);
|
|
243
|
+
return ret !== 0;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The `seq` at which the error occurred. Only set when `ok == false`.
|
|
247
|
+
* @returns {number | undefined}
|
|
248
|
+
*/
|
|
249
|
+
get seq() {
|
|
250
|
+
const ret = wasm.__wbg_get_chainresult_seq(this.__wbg_ptr);
|
|
251
|
+
return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Human-readable detail. Only set when `ok == false`.
|
|
255
|
+
* @param {string | null} [arg0]
|
|
256
|
+
*/
|
|
257
|
+
set detail(arg0) {
|
|
258
|
+
var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
259
|
+
var len0 = WASM_VECTOR_LEN;
|
|
260
|
+
wasm.__wbg_set_chainresult_detail(this.__wbg_ptr, ptr0, len0);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Error kind string. Only set when `ok == false`.
|
|
264
|
+
* @param {string | null} [arg0]
|
|
265
|
+
*/
|
|
266
|
+
set error(arg0) {
|
|
267
|
+
var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
268
|
+
var len0 = WASM_VECTOR_LEN;
|
|
269
|
+
wasm.__wbg_set_chainresult_error(this.__wbg_ptr, ptr0, len0);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Number of receipts verified. Only set when `ok == true`.
|
|
273
|
+
* @param {number | null} [arg0]
|
|
274
|
+
*/
|
|
275
|
+
set length(arg0) {
|
|
276
|
+
wasm.__wbg_set_chainresult_length(this.__wbg_ptr, isLikeNone(arg0) ? Number.MAX_SAFE_INTEGER : (arg0) >>> 0);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* `true` when every link verified.
|
|
280
|
+
* @param {boolean} arg0
|
|
281
|
+
*/
|
|
282
|
+
set ok(arg0) {
|
|
283
|
+
wasm.__wbg_set_chainresult_ok(this.__wbg_ptr, arg0);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The `seq` at which the error occurred. Only set when `ok == false`.
|
|
287
|
+
* @param {number | null} [arg0]
|
|
288
|
+
*/
|
|
289
|
+
set seq(arg0) {
|
|
290
|
+
wasm.__wbg_set_chainresult_seq(this.__wbg_ptr, isLikeNone(arg0) ? Number.MAX_SAFE_INTEGER : (arg0) >>> 0);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (Symbol.dispose) ChainResult.prototype[Symbol.dispose] = ChainResult.prototype.free;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The verified, decoded result of a delegation envelope.
|
|
297
|
+
*/
|
|
298
|
+
export class VerifiedDelegation {
|
|
299
|
+
static __wrap(ptr) {
|
|
300
|
+
const obj = Object.create(VerifiedDelegation.prototype);
|
|
301
|
+
obj.__wbg_ptr = ptr;
|
|
302
|
+
VerifiedDelegationFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
303
|
+
return obj;
|
|
304
|
+
}
|
|
305
|
+
__destroy_into_raw() {
|
|
306
|
+
const ptr = this.__wbg_ptr;
|
|
307
|
+
this.__wbg_ptr = 0;
|
|
308
|
+
VerifiedDelegationFinalization.unregister(this);
|
|
309
|
+
return ptr;
|
|
310
|
+
}
|
|
311
|
+
free() {
|
|
312
|
+
const ptr = this.__destroy_into_raw();
|
|
313
|
+
wasm.__wbg_verifieddelegation_free(ptr, 0);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The authorized key `K` (raw 32-byte Ed25519 public key) as a `Uint8Array`.
|
|
317
|
+
* @returns {Uint8Array}
|
|
318
|
+
*/
|
|
319
|
+
get authorized_key() {
|
|
320
|
+
const ret = wasm.__wbg_get_verifieddelegation_authorized_key(this.__wbg_ptr);
|
|
321
|
+
return ret;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The envelope's expiry as Unix seconds (`BigInt`).
|
|
325
|
+
* @returns {bigint}
|
|
326
|
+
*/
|
|
327
|
+
get expiry_unix_secs() {
|
|
328
|
+
const ret = wasm.__wbg_get_verifieddelegation_expiry_unix_secs(this.__wbg_ptr);
|
|
329
|
+
return ret;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* The envelope's not_before as Unix seconds (`BigInt`).
|
|
333
|
+
* @returns {bigint}
|
|
334
|
+
*/
|
|
335
|
+
get not_before_unix_secs() {
|
|
336
|
+
const ret = wasm.__wbg_get_verifieddelegation_not_before_unix_secs(this.__wbg_ptr);
|
|
337
|
+
return ret;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* The scope the delegated authority was bound to.
|
|
341
|
+
* @returns {string}
|
|
342
|
+
*/
|
|
343
|
+
get scope() {
|
|
344
|
+
let deferred1_0;
|
|
345
|
+
let deferred1_1;
|
|
346
|
+
try {
|
|
347
|
+
const ret = wasm.__wbg_get_verifieddelegation_scope(this.__wbg_ptr);
|
|
348
|
+
deferred1_0 = ret[0];
|
|
349
|
+
deferred1_1 = ret[1];
|
|
350
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
351
|
+
} finally {
|
|
352
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* The subject string the operator stamped onto the delegation.
|
|
357
|
+
* @returns {string}
|
|
358
|
+
*/
|
|
359
|
+
get sub() {
|
|
360
|
+
let deferred1_0;
|
|
361
|
+
let deferred1_1;
|
|
362
|
+
try {
|
|
363
|
+
const ret = wasm.__wbg_get_verifieddelegation_sub(this.__wbg_ptr);
|
|
364
|
+
deferred1_0 = ret[0];
|
|
365
|
+
deferred1_1 = ret[1];
|
|
366
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
367
|
+
} finally {
|
|
368
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The authorized key `K` (raw 32-byte Ed25519 public key) as a `Uint8Array`.
|
|
373
|
+
* @param {Uint8Array} arg0
|
|
374
|
+
*/
|
|
375
|
+
set authorized_key(arg0) {
|
|
376
|
+
wasm.__wbg_set_verifieddelegation_authorized_key(this.__wbg_ptr, arg0);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* The envelope's expiry as Unix seconds (`BigInt`).
|
|
380
|
+
* @param {bigint} arg0
|
|
381
|
+
*/
|
|
382
|
+
set expiry_unix_secs(arg0) {
|
|
383
|
+
wasm.__wbg_set_verifieddelegation_expiry_unix_secs(this.__wbg_ptr, arg0);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* The envelope's not_before as Unix seconds (`BigInt`).
|
|
387
|
+
* @param {bigint} arg0
|
|
388
|
+
*/
|
|
389
|
+
set not_before_unix_secs(arg0) {
|
|
390
|
+
wasm.__wbg_set_verifieddelegation_not_before_unix_secs(this.__wbg_ptr, arg0);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* The scope the delegated authority was bound to.
|
|
394
|
+
* @param {string} arg0
|
|
395
|
+
*/
|
|
396
|
+
set scope(arg0) {
|
|
397
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
398
|
+
const len0 = WASM_VECTOR_LEN;
|
|
399
|
+
wasm.__wbg_set_verifieddelegation_scope(this.__wbg_ptr, ptr0, len0);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* The subject string the operator stamped onto the delegation.
|
|
403
|
+
* @param {string} arg0
|
|
404
|
+
*/
|
|
405
|
+
set sub(arg0) {
|
|
406
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
407
|
+
const len0 = WASM_VECTOR_LEN;
|
|
408
|
+
wasm.__wbg_set_verifieddelegation_sub(this.__wbg_ptr, ptr0, len0);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (Symbol.dispose) VerifiedDelegation.prototype[Symbol.dispose] = VerifiedDelegation.prototype.free;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Return the RFC-8785 (JCS) canonical bytes of an `ActionContent` JSON string,
|
|
415
|
+
* with `action_hash` stripped. The shared canonicalizer — the browser MUST
|
|
416
|
+
* call this rather than any hand-rolled JCS implementation to avoid drift.
|
|
417
|
+
* @param {string} content_json
|
|
418
|
+
* @returns {Uint8Array}
|
|
419
|
+
*/
|
|
420
|
+
export function actionCanonicalBytes(content_json) {
|
|
421
|
+
const ptr0 = passStringToWasm0(content_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
422
|
+
const len0 = WASM_VECTOR_LEN;
|
|
423
|
+
const ret = wasm.actionCanonicalBytes(ptr0, len0);
|
|
424
|
+
if (ret[2]) {
|
|
425
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
426
|
+
}
|
|
427
|
+
return takeFromExternrefTable0(ret[0]);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Pre-anchor BLAKE3 hash (excludes `time_anchor` from the canonical bytes).
|
|
432
|
+
* Replaces `@noble/hashes` blake3 usage in `crypto.ts`.
|
|
433
|
+
* @param {string} content_json
|
|
434
|
+
* @returns {string}
|
|
435
|
+
*/
|
|
436
|
+
export function anchoredContentHash(content_json) {
|
|
437
|
+
let deferred3_0;
|
|
438
|
+
let deferred3_1;
|
|
439
|
+
try {
|
|
440
|
+
const ptr0 = passStringToWasm0(content_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
441
|
+
const len0 = WASM_VECTOR_LEN;
|
|
442
|
+
const ret = wasm.anchoredContentHash(ptr0, len0);
|
|
443
|
+
var ptr2 = ret[0];
|
|
444
|
+
var len2 = ret[1];
|
|
445
|
+
if (ret[3]) {
|
|
446
|
+
ptr2 = 0; len2 = 0;
|
|
447
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
448
|
+
}
|
|
449
|
+
deferred3_0 = ptr2;
|
|
450
|
+
deferred3_1 = len2;
|
|
451
|
+
return getStringFromWasm0(ptr2, len2);
|
|
452
|
+
} finally {
|
|
453
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Compute a domain-separated BLAKE3 chain-link digest from two 64-hex hashes.
|
|
459
|
+
* Replaces the `@noble`-backed chain helper in `crypto.ts`.
|
|
460
|
+
* @param {string} prev_hex
|
|
461
|
+
* @param {string} action_hex
|
|
462
|
+
* @returns {string}
|
|
463
|
+
*/
|
|
464
|
+
export function chainHashHex(prev_hex, action_hex) {
|
|
465
|
+
let deferred4_0;
|
|
466
|
+
let deferred4_1;
|
|
467
|
+
try {
|
|
468
|
+
const ptr0 = passStringToWasm0(prev_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
469
|
+
const len0 = WASM_VECTOR_LEN;
|
|
470
|
+
const ptr1 = passStringToWasm0(action_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
471
|
+
const len1 = WASM_VECTOR_LEN;
|
|
472
|
+
const ret = wasm.chainHashHex(ptr0, len0, ptr1, len1);
|
|
473
|
+
var ptr3 = ret[0];
|
|
474
|
+
var len3 = ret[1];
|
|
475
|
+
if (ret[3]) {
|
|
476
|
+
ptr3 = 0; len3 = 0;
|
|
477
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
478
|
+
}
|
|
479
|
+
deferred4_0 = ptr3;
|
|
480
|
+
deferred4_1 = len3;
|
|
481
|
+
return getStringFromWasm0(ptr3, len3);
|
|
482
|
+
} finally {
|
|
483
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* BLAKE3 (64-hex) of the canonical bytes — the value that goes into
|
|
489
|
+
* `action_hash`. Replaces `@noble/hashes` blake3 usage in `crypto.ts`.
|
|
490
|
+
* @param {string} content_json
|
|
491
|
+
* @returns {string}
|
|
492
|
+
*/
|
|
493
|
+
export function contentHash(content_json) {
|
|
494
|
+
let deferred3_0;
|
|
495
|
+
let deferred3_1;
|
|
496
|
+
try {
|
|
497
|
+
const ptr0 = passStringToWasm0(content_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
498
|
+
const len0 = WASM_VECTOR_LEN;
|
|
499
|
+
const ret = wasm.contentHash(ptr0, len0);
|
|
500
|
+
var ptr2 = ret[0];
|
|
501
|
+
var len2 = ret[1];
|
|
502
|
+
if (ret[3]) {
|
|
503
|
+
ptr2 = 0; len2 = 0;
|
|
504
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
505
|
+
}
|
|
506
|
+
deferred3_0 = ptr2;
|
|
507
|
+
deferred3_1 = len2;
|
|
508
|
+
return getStringFromWasm0(ptr2, len2);
|
|
509
|
+
} finally {
|
|
510
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Parse + validate policy TOML, running the load-time dangerous-lane floor check.
|
|
516
|
+
* Throws a `[PARSE]` or `[FLOOR_BYPASS]` `JsError` on failure; returns nothing on
|
|
517
|
+
* success. The web calls this before deploy so a floor-bypassing policy is caught
|
|
518
|
+
* in the browser with the exact engine reason, not bounced by the backend.
|
|
519
|
+
* @param {string} toml_src
|
|
520
|
+
*/
|
|
521
|
+
export function parsePolicy(toml_src) {
|
|
522
|
+
const ptr0 = passStringToWasm0(toml_src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
523
|
+
const len0 = WASM_VECTOR_LEN;
|
|
524
|
+
const ret = wasm.parsePolicy(ptr0, len0);
|
|
525
|
+
if (ret[1]) {
|
|
526
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Parse + validate policy TOML and return the rules as a JSON array of
|
|
532
|
+
* [`PolicyRule`] (the Rust wire shape) so the web renders a pulled policy via the
|
|
533
|
+
* REAL parser — no JS TOML library, no JS re-implementation of the parse (which
|
|
534
|
+
* today splits on the wrong marker and drops all conditions). Throws the same
|
|
535
|
+
* `[PARSE]` / `[FLOOR_BYPASS]` errors as `parsePolicy`. Empty TOML yields `[]`.
|
|
536
|
+
* @param {string} toml_src
|
|
537
|
+
* @returns {string}
|
|
538
|
+
*/
|
|
539
|
+
export function policyRulesFromToml(toml_src) {
|
|
540
|
+
let deferred3_0;
|
|
541
|
+
let deferred3_1;
|
|
542
|
+
try {
|
|
543
|
+
const ptr0 = passStringToWasm0(toml_src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
544
|
+
const len0 = WASM_VECTOR_LEN;
|
|
545
|
+
const ret = wasm.policyRulesFromToml(ptr0, len0);
|
|
546
|
+
var ptr2 = ret[0];
|
|
547
|
+
var len2 = ret[1];
|
|
548
|
+
if (ret[3]) {
|
|
549
|
+
ptr2 = 0; len2 = 0;
|
|
550
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
551
|
+
}
|
|
552
|
+
deferred3_0 = ptr2;
|
|
553
|
+
deferred3_1 = len2;
|
|
554
|
+
return getStringFromWasm0(ptr2, len2);
|
|
555
|
+
} finally {
|
|
556
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Render a single rule (JSON [`PolicyRule`]) into the canonical English sentence
|
|
562
|
+
* — the SAME `rule_display` stamped on signed receipts. Replaces the drifting JS
|
|
563
|
+
* renderer so the in-UI preview is byte-identical to the audit string.
|
|
564
|
+
* @param {string} rule_json
|
|
565
|
+
* @returns {string}
|
|
566
|
+
*/
|
|
567
|
+
export function ruleToSentence(rule_json) {
|
|
568
|
+
let deferred3_0;
|
|
569
|
+
let deferred3_1;
|
|
570
|
+
try {
|
|
571
|
+
const ptr0 = passStringToWasm0(rule_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
572
|
+
const len0 = WASM_VECTOR_LEN;
|
|
573
|
+
const ret = wasm.ruleToSentence(ptr0, len0);
|
|
574
|
+
var ptr2 = ret[0];
|
|
575
|
+
var len2 = ret[1];
|
|
576
|
+
if (ret[3]) {
|
|
577
|
+
ptr2 = 0; len2 = 0;
|
|
578
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
579
|
+
}
|
|
580
|
+
deferred3_0 = ptr2;
|
|
581
|
+
deferred3_1 = len2;
|
|
582
|
+
return getStringFromWasm0(ptr2, len2);
|
|
583
|
+
} finally {
|
|
584
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Return a short display form of a 64-hex BLAKE3 hash: `{prefix}:{first8}`.
|
|
590
|
+
* Replaces the `@noble`-backed display helper in `crypto.ts`.
|
|
591
|
+
* @param {string} hex
|
|
592
|
+
* @param {string | null} [prefix]
|
|
593
|
+
* @returns {string}
|
|
594
|
+
*/
|
|
595
|
+
export function shortHash(hex, prefix) {
|
|
596
|
+
let deferred4_0;
|
|
597
|
+
let deferred4_1;
|
|
598
|
+
try {
|
|
599
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
600
|
+
const len0 = WASM_VECTOR_LEN;
|
|
601
|
+
var ptr1 = isLikeNone(prefix) ? 0 : passStringToWasm0(prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
602
|
+
var len1 = WASM_VECTOR_LEN;
|
|
603
|
+
const ret = wasm.shortHash(ptr0, len0, ptr1, len1);
|
|
604
|
+
var ptr3 = ret[0];
|
|
605
|
+
var len3 = ret[1];
|
|
606
|
+
if (ret[3]) {
|
|
607
|
+
ptr3 = 0; len3 = 0;
|
|
608
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
609
|
+
}
|
|
610
|
+
deferred4_0 = ptr3;
|
|
611
|
+
deferred4_1 = len3;
|
|
612
|
+
return getStringFromWasm0(ptr3, len3);
|
|
613
|
+
} finally {
|
|
614
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Floor pre-check over a candidate ruleset (JSON array of [`PolicyRule`]) WITHOUT
|
|
620
|
+
* serializing to TOML — the live check the builder runs as the user edits.
|
|
621
|
+
* Throws a `[FLOOR_BYPASS]` `JsError` (carrying the offending rule id + verb) when
|
|
622
|
+
* a rule would allow-without-approval a dangerous lane; returns nothing when the
|
|
623
|
+
* policy only tightens.
|
|
624
|
+
* @param {string} rules_json
|
|
625
|
+
*/
|
|
626
|
+
export function validateNoFloorBypass(rules_json) {
|
|
627
|
+
const ptr0 = passStringToWasm0(rules_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
628
|
+
const len0 = WASM_VECTOR_LEN;
|
|
629
|
+
const ret = wasm.validateNoFloorBypass(ptr0, len0);
|
|
630
|
+
if (ret[1]) {
|
|
631
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Verify a single `ActionReceipt` from its raw JSON bytes (`Uint8Array`) or a
|
|
637
|
+
* JSON string.
|
|
638
|
+
*
|
|
639
|
+
* Never panics — structural failures return an `ActionVerdict` with
|
|
640
|
+
* `verdict = "Malformed:…"`. This is the browser replacement for the
|
|
641
|
+
* `verifyReceipt` function in `crypto.ts`, backed by the identical Rust
|
|
642
|
+
* JCS + BLAKE3 + Ed25519 path so Node and browser get byte-identical results.
|
|
643
|
+
* @param {Uint8Array} receipt_bytes
|
|
644
|
+
* @returns {ActionVerdict}
|
|
645
|
+
*/
|
|
646
|
+
export function verifyActionReceipt(receipt_bytes) {
|
|
647
|
+
const ptr0 = passArray8ToWasm0(receipt_bytes, wasm.__wbindgen_malloc);
|
|
648
|
+
const len0 = WASM_VECTOR_LEN;
|
|
649
|
+
const ret = wasm.verifyActionReceipt(ptr0, len0);
|
|
650
|
+
return ActionVerdict.__wrap(ret);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Verify a serialized approval token and return its decoded claims.
|
|
655
|
+
*
|
|
656
|
+
* Pure verify (Ed25519 `verify_strict` via heso-verify), no OsRng — wasm-safe.
|
|
657
|
+
* Throws a `JsError` with a stable `[CODE]` prefix per `ApprovalTokenError`
|
|
658
|
+
* variant, matching the napi surface.
|
|
659
|
+
*
|
|
660
|
+
* `token` — raw token bytes (Uint8Array)
|
|
661
|
+
* `action_canonical` — the action's canonical bytes (from `actionCanonicalBytes`)
|
|
662
|
+
* `now_unix_secs` — current time as BigInt Unix seconds
|
|
663
|
+
* `seen_nonces` — array of already-seen 32-byte nonces (Uint8Array each)
|
|
664
|
+
* `required_scope` — the required scope string
|
|
665
|
+
* `registered_keys_b64` — array of base64 Ed25519 public keys on the allowlist
|
|
666
|
+
* @param {Uint8Array} token
|
|
667
|
+
* @param {Uint8Array} action_canonical
|
|
668
|
+
* @param {bigint} now_unix_secs
|
|
669
|
+
* @param {Array<any>} seen_nonces
|
|
670
|
+
* @param {string} required_scope
|
|
671
|
+
* @param {Array<any>} registered_keys_b64
|
|
672
|
+
* @returns {ApprovalTokenClaims}
|
|
673
|
+
*/
|
|
674
|
+
export function verifyApprovalToken(token, action_canonical, now_unix_secs, seen_nonces, required_scope, registered_keys_b64) {
|
|
675
|
+
const ptr0 = passArray8ToWasm0(token, wasm.__wbindgen_malloc);
|
|
676
|
+
const len0 = WASM_VECTOR_LEN;
|
|
677
|
+
const ptr1 = passArray8ToWasm0(action_canonical, wasm.__wbindgen_malloc);
|
|
678
|
+
const len1 = WASM_VECTOR_LEN;
|
|
679
|
+
const ptr2 = passStringToWasm0(required_scope, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
680
|
+
const len2 = WASM_VECTOR_LEN;
|
|
681
|
+
const ret = wasm.verifyApprovalToken(ptr0, len0, ptr1, len1, now_unix_secs, seen_nonces, ptr2, len2, registered_keys_b64);
|
|
682
|
+
if (ret[2]) {
|
|
683
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
684
|
+
}
|
|
685
|
+
return ApprovalTokenClaims.__wrap(ret[0]);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Verify an ordered array of `ActionReceipt`s as a tamper-evident chain.
|
|
690
|
+
*
|
|
691
|
+
* Input: raw bytes of a JSON array of receipts (`Uint8Array` or similar).
|
|
692
|
+
* @param {Uint8Array} receipts_bytes
|
|
693
|
+
* @returns {ChainResult}
|
|
694
|
+
*/
|
|
695
|
+
export function verifyChain(receipts_bytes) {
|
|
696
|
+
const ptr0 = passArray8ToWasm0(receipts_bytes, wasm.__wbindgen_malloc);
|
|
697
|
+
const len0 = WASM_VECTOR_LEN;
|
|
698
|
+
const ret = wasm.verifyChain(ptr0, len0);
|
|
699
|
+
if (ret[2]) {
|
|
700
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
701
|
+
}
|
|
702
|
+
return ChainResult.__wrap(ret[0]);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* RFC-6962 consistency proof verification.
|
|
707
|
+
*
|
|
708
|
+
* Returns `true` iff the proof proves the new tree is an append-only extension.
|
|
709
|
+
* @param {number} old_size
|
|
710
|
+
* @param {string} old_root_hex
|
|
711
|
+
* @param {number} new_size
|
|
712
|
+
* @param {string} new_root_hex
|
|
713
|
+
* @param {string} proof_hashes_json
|
|
714
|
+
* @returns {boolean}
|
|
715
|
+
*/
|
|
716
|
+
export function verifyConsistency(old_size, old_root_hex, new_size, new_root_hex, proof_hashes_json) {
|
|
717
|
+
const ptr0 = passStringToWasm0(old_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
718
|
+
const len0 = WASM_VECTOR_LEN;
|
|
719
|
+
const ptr1 = passStringToWasm0(new_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
720
|
+
const len1 = WASM_VECTOR_LEN;
|
|
721
|
+
const ptr2 = passStringToWasm0(proof_hashes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
722
|
+
const len2 = WASM_VECTOR_LEN;
|
|
723
|
+
const ret = wasm.verifyConsistency(old_size, ptr0, len0, new_size, ptr1, len1, ptr2, len2);
|
|
724
|
+
if (ret[2]) {
|
|
725
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
726
|
+
}
|
|
727
|
+
return ret[0] !== 0;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Verify a serialized delegation envelope and its human co-sign.
|
|
732
|
+
*
|
|
733
|
+
* Pure verify (Ed25519 `verify_strict` via heso-verify), no OsRng — wasm-safe.
|
|
734
|
+
* Throws a `JsError` with a stable `[CODE]` prefix per `DelegationError` variant,
|
|
735
|
+
* matching the napi surface.
|
|
736
|
+
*
|
|
737
|
+
* `wire` — raw delegation envelope bytes (Uint8Array)
|
|
738
|
+
* `registered_operator_key` — the org-registered operator public key (raw 32 bytes)
|
|
739
|
+
* `action_hash` — the raw 32-byte BLAKE3 action digest being authorized
|
|
740
|
+
* `approval_token` — the human co-sign bearer token presented by K
|
|
741
|
+
* `required_scope` — the required scope string
|
|
742
|
+
* `now_unix_secs` — current time as BigInt Unix seconds
|
|
743
|
+
* @param {Uint8Array} wire
|
|
744
|
+
* @param {Uint8Array} registered_operator_key
|
|
745
|
+
* @param {Uint8Array} action_hash
|
|
746
|
+
* @param {Uint8Array} approval_token
|
|
747
|
+
* @param {string} required_scope
|
|
748
|
+
* @param {bigint} now_unix_secs
|
|
749
|
+
* @returns {VerifiedDelegation}
|
|
750
|
+
*/
|
|
751
|
+
export function verifyDelegation(wire, registered_operator_key, action_hash, approval_token, required_scope, now_unix_secs) {
|
|
752
|
+
const ptr0 = passArray8ToWasm0(wire, wasm.__wbindgen_malloc);
|
|
753
|
+
const len0 = WASM_VECTOR_LEN;
|
|
754
|
+
const ptr1 = passArray8ToWasm0(registered_operator_key, wasm.__wbindgen_malloc);
|
|
755
|
+
const len1 = WASM_VECTOR_LEN;
|
|
756
|
+
const ptr2 = passArray8ToWasm0(action_hash, wasm.__wbindgen_malloc);
|
|
757
|
+
const len2 = WASM_VECTOR_LEN;
|
|
758
|
+
const ptr3 = passArray8ToWasm0(approval_token, wasm.__wbindgen_malloc);
|
|
759
|
+
const len3 = WASM_VECTOR_LEN;
|
|
760
|
+
const ptr4 = passStringToWasm0(required_scope, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
761
|
+
const len4 = WASM_VECTOR_LEN;
|
|
762
|
+
const ret = wasm.verifyDelegation(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, now_unix_secs);
|
|
763
|
+
if (ret[2]) {
|
|
764
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
765
|
+
}
|
|
766
|
+
return VerifiedDelegation.__wrap(ret[0]);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* RFC-6962 inclusion proof verification (SHA-256 Merkle tree).
|
|
771
|
+
*
|
|
772
|
+
* `leaf_value_hex` — the 64-hex `action_hash`; raw bytes are the leaf value.
|
|
773
|
+
* `proof_hashes` — array of 64-hex SHA-256 sibling hashes (space-separated
|
|
774
|
+
* OR JSON array string).
|
|
775
|
+
* `root_hex` — 64-hex SHA-256 tree root.
|
|
776
|
+
*
|
|
777
|
+
* Returns `true` iff the proof verifies.
|
|
778
|
+
* @param {string} leaf_value_hex
|
|
779
|
+
* @param {number} index
|
|
780
|
+
* @param {number} size
|
|
781
|
+
* @param {string} root_hex
|
|
782
|
+
* @param {string} proof_hashes_json
|
|
783
|
+
* @returns {boolean}
|
|
784
|
+
*/
|
|
785
|
+
export function verifyInclusion(leaf_value_hex, index, size, root_hex, proof_hashes_json) {
|
|
786
|
+
const ptr0 = passStringToWasm0(leaf_value_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
787
|
+
const len0 = WASM_VECTOR_LEN;
|
|
788
|
+
const ptr1 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
789
|
+
const len1 = WASM_VECTOR_LEN;
|
|
790
|
+
const ptr2 = passStringToWasm0(proof_hashes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
791
|
+
const len2 = WASM_VECTOR_LEN;
|
|
792
|
+
const ret = wasm.verifyInclusion(ptr0, len0, index, size, ptr1, len1, ptr2, len2);
|
|
793
|
+
if (ret[2]) {
|
|
794
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
795
|
+
}
|
|
796
|
+
return ret[0] !== 0;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Verify a session chain (lifecycle role + transition checks).
|
|
801
|
+
* @param {Uint8Array} receipts_bytes
|
|
802
|
+
* @returns {ChainResult}
|
|
803
|
+
*/
|
|
804
|
+
export function verifySessionChain(receipts_bytes) {
|
|
805
|
+
const ptr0 = passArray8ToWasm0(receipts_bytes, wasm.__wbindgen_malloc);
|
|
806
|
+
const len0 = WASM_VECTOR_LEN;
|
|
807
|
+
const ret = wasm.verifySessionChain(ptr0, len0);
|
|
808
|
+
if (ret[2]) {
|
|
809
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
810
|
+
}
|
|
811
|
+
return ChainResult.__wrap(ret[0]);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Verify a session chain with key-rotation as-of-position enforcement.
|
|
816
|
+
*
|
|
817
|
+
* `producer_key` — base64 genesis producer key (TOFU pin).
|
|
818
|
+
* `decision_key` — optional base64 genesis decision key.
|
|
819
|
+
* @param {Uint8Array} receipts_bytes
|
|
820
|
+
* @param {string} producer_key
|
|
821
|
+
* @param {string | null} [decision_key]
|
|
822
|
+
* @returns {ChainResult}
|
|
823
|
+
*/
|
|
824
|
+
export function verifySessionChainWithRotation(receipts_bytes, producer_key, decision_key) {
|
|
825
|
+
const ptr0 = passArray8ToWasm0(receipts_bytes, wasm.__wbindgen_malloc);
|
|
826
|
+
const len0 = WASM_VECTOR_LEN;
|
|
827
|
+
const ptr1 = passStringToWasm0(producer_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
828
|
+
const len1 = WASM_VECTOR_LEN;
|
|
829
|
+
var ptr2 = isLikeNone(decision_key) ? 0 : passStringToWasm0(decision_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
830
|
+
var len2 = WASM_VECTOR_LEN;
|
|
831
|
+
const ret = wasm.verifySessionChainWithRotation(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
832
|
+
if (ret[2]) {
|
|
833
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
834
|
+
}
|
|
835
|
+
return ChainResult.__wrap(ret[0]);
|
|
836
|
+
}
|
|
837
|
+
function __wbg_get_imports() {
|
|
838
|
+
const import0 = {
|
|
839
|
+
__proto__: null,
|
|
840
|
+
__wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
|
|
841
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
842
|
+
return ret;
|
|
843
|
+
},
|
|
844
|
+
__wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d: function(arg0, arg1) {
|
|
845
|
+
const v = arg1;
|
|
846
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
847
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
848
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
849
|
+
},
|
|
850
|
+
__wbg___wbindgen_jsval_eq_1068e624fa87f6ab: function(arg0, arg1) {
|
|
851
|
+
const ret = arg0 === arg1;
|
|
852
|
+
return ret;
|
|
853
|
+
},
|
|
854
|
+
__wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
|
|
855
|
+
const obj = arg1;
|
|
856
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
857
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
858
|
+
var len1 = WASM_VECTOR_LEN;
|
|
859
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
860
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
861
|
+
},
|
|
862
|
+
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
863
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
864
|
+
},
|
|
865
|
+
__wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
|
|
866
|
+
const ret = arg0[arg1 >>> 0];
|
|
867
|
+
return ret;
|
|
868
|
+
},
|
|
869
|
+
__wbg_length_4a591ecaa01354d9: function(arg0) {
|
|
870
|
+
const ret = arg0.length;
|
|
871
|
+
return ret;
|
|
872
|
+
},
|
|
873
|
+
__wbg_length_66f1a4b2e9026940: function(arg0) {
|
|
874
|
+
const ret = arg0.length;
|
|
875
|
+
return ret;
|
|
876
|
+
},
|
|
877
|
+
__wbg_new_from_slice_18fa1f71286d66b8: function(arg0, arg1) {
|
|
878
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
879
|
+
return ret;
|
|
880
|
+
},
|
|
881
|
+
__wbg_new_with_length_36a4998e27b014c5: function(arg0) {
|
|
882
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
883
|
+
return ret;
|
|
884
|
+
},
|
|
885
|
+
__wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
|
|
886
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
887
|
+
},
|
|
888
|
+
__wbg_set_29c99a8aac1c01e5: function(arg0, arg1, arg2) {
|
|
889
|
+
arg0.set(getArrayU8FromWasm0(arg1, arg2));
|
|
890
|
+
},
|
|
891
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
892
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
893
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
894
|
+
return ret;
|
|
895
|
+
},
|
|
896
|
+
__wbindgen_init_externref_table: function() {
|
|
897
|
+
const table = wasm.__wbindgen_externrefs;
|
|
898
|
+
const offset = table.grow(4);
|
|
899
|
+
table.set(0, undefined);
|
|
900
|
+
table.set(offset + 0, undefined);
|
|
901
|
+
table.set(offset + 1, null);
|
|
902
|
+
table.set(offset + 2, true);
|
|
903
|
+
table.set(offset + 3, false);
|
|
904
|
+
},
|
|
905
|
+
};
|
|
906
|
+
return {
|
|
907
|
+
__proto__: null,
|
|
908
|
+
"./heso_wasm_bg.js": import0,
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
const ActionVerdictFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
913
|
+
? { register: () => {}, unregister: () => {} }
|
|
914
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_actionverdict_free(ptr, 1));
|
|
915
|
+
const ApprovalTokenClaimsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
916
|
+
? { register: () => {}, unregister: () => {} }
|
|
917
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_approvaltokenclaims_free(ptr, 1));
|
|
918
|
+
const ChainResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
919
|
+
? { register: () => {}, unregister: () => {} }
|
|
920
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_chainresult_free(ptr, 1));
|
|
921
|
+
const VerifiedDelegationFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
922
|
+
? { register: () => {}, unregister: () => {} }
|
|
923
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_verifieddelegation_free(ptr, 1));
|
|
924
|
+
|
|
925
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
926
|
+
ptr = ptr >>> 0;
|
|
927
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
let cachedDataViewMemory0 = null;
|
|
931
|
+
function getDataViewMemory0() {
|
|
932
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
933
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
934
|
+
}
|
|
935
|
+
return cachedDataViewMemory0;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function getStringFromWasm0(ptr, len) {
|
|
939
|
+
return decodeText(ptr >>> 0, len);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
let cachedUint8ArrayMemory0 = null;
|
|
943
|
+
function getUint8ArrayMemory0() {
|
|
944
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
945
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
946
|
+
}
|
|
947
|
+
return cachedUint8ArrayMemory0;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
function isLikeNone(x) {
|
|
951
|
+
return x === undefined || x === null;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
955
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
956
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
957
|
+
WASM_VECTOR_LEN = arg.length;
|
|
958
|
+
return ptr;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
962
|
+
if (realloc === undefined) {
|
|
963
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
964
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
965
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
966
|
+
WASM_VECTOR_LEN = buf.length;
|
|
967
|
+
return ptr;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
let len = arg.length;
|
|
971
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
972
|
+
|
|
973
|
+
const mem = getUint8ArrayMemory0();
|
|
974
|
+
|
|
975
|
+
let offset = 0;
|
|
976
|
+
|
|
977
|
+
for (; offset < len; offset++) {
|
|
978
|
+
const code = arg.charCodeAt(offset);
|
|
979
|
+
if (code > 0x7F) break;
|
|
980
|
+
mem[ptr + offset] = code;
|
|
981
|
+
}
|
|
982
|
+
if (offset !== len) {
|
|
983
|
+
if (offset !== 0) {
|
|
984
|
+
arg = arg.slice(offset);
|
|
985
|
+
}
|
|
986
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
987
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
988
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
989
|
+
|
|
990
|
+
offset += ret.written;
|
|
991
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
WASM_VECTOR_LEN = offset;
|
|
995
|
+
return ptr;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function takeFromExternrefTable0(idx) {
|
|
999
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1000
|
+
wasm.__externref_table_dealloc(idx);
|
|
1001
|
+
return value;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1005
|
+
cachedTextDecoder.decode();
|
|
1006
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1007
|
+
let numBytesDecoded = 0;
|
|
1008
|
+
function decodeText(ptr, len) {
|
|
1009
|
+
numBytesDecoded += len;
|
|
1010
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1011
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1012
|
+
cachedTextDecoder.decode();
|
|
1013
|
+
numBytesDecoded = len;
|
|
1014
|
+
}
|
|
1015
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1019
|
+
|
|
1020
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1021
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1022
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1023
|
+
view.set(buf);
|
|
1024
|
+
return {
|
|
1025
|
+
read: arg.length,
|
|
1026
|
+
written: buf.length
|
|
1027
|
+
};
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
let WASM_VECTOR_LEN = 0;
|
|
1032
|
+
|
|
1033
|
+
let wasmModule, wasmInstance, wasm;
|
|
1034
|
+
function __wbg_finalize_init(instance, module) {
|
|
1035
|
+
wasmInstance = instance;
|
|
1036
|
+
wasm = instance.exports;
|
|
1037
|
+
wasmModule = module;
|
|
1038
|
+
cachedDataViewMemory0 = null;
|
|
1039
|
+
cachedUint8ArrayMemory0 = null;
|
|
1040
|
+
wasm.__wbindgen_start();
|
|
1041
|
+
return wasm;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
async function __wbg_load(module, imports) {
|
|
1045
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1046
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1047
|
+
try {
|
|
1048
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1051
|
+
|
|
1052
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1053
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1054
|
+
|
|
1055
|
+
} else { throw e; }
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
const bytes = await module.arrayBuffer();
|
|
1060
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1061
|
+
} else {
|
|
1062
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1063
|
+
|
|
1064
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1065
|
+
return { instance, module };
|
|
1066
|
+
} else {
|
|
1067
|
+
return instance;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
function expectedResponseType(type) {
|
|
1072
|
+
switch (type) {
|
|
1073
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1074
|
+
}
|
|
1075
|
+
return false;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
function initSync(module) {
|
|
1080
|
+
if (wasm !== undefined) return wasm;
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
if (module !== undefined) {
|
|
1084
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1085
|
+
({module} = module)
|
|
1086
|
+
} else {
|
|
1087
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
const imports = __wbg_get_imports();
|
|
1092
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1093
|
+
module = new WebAssembly.Module(module);
|
|
1094
|
+
}
|
|
1095
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1096
|
+
return __wbg_finalize_init(instance, module);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
async function __wbg_init(module_or_path) {
|
|
1100
|
+
if (wasm !== undefined) return wasm;
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
if (module_or_path !== undefined) {
|
|
1104
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1105
|
+
({module_or_path} = module_or_path)
|
|
1106
|
+
} else {
|
|
1107
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
if (module_or_path === undefined) {
|
|
1112
|
+
module_or_path = new URL('heso_wasm_bg.wasm', import.meta.url);
|
|
1113
|
+
}
|
|
1114
|
+
const imports = __wbg_get_imports();
|
|
1115
|
+
|
|
1116
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1117
|
+
module_or_path = fetch(module_or_path);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1121
|
+
|
|
1122
|
+
return __wbg_finalize_init(instance, module);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
export { initSync, __wbg_init as default };
|