@tenuo/core 0.2.4-beta.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 +187 -0
- package/README.md +62 -0
- package/dist/api.d.ts +270 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +8 -0
- package/dist/api.js.map +1 -0
- package/dist/client.d.ts +18 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +417 -0
- package/dist/client.js.map +1 -0
- package/dist/constraints.d.ts +11 -0
- package/dist/constraints.d.ts.map +1 -0
- package/dist/constraints.js +32 -0
- package/dist/constraints.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +37 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/package.json +1 -0
- package/dist/generated/tenuo_wasm.d.ts +290 -0
- package/dist/generated/tenuo_wasm.js +1415 -0
- package/dist/generated/tenuo_wasm_bg.wasm +0 -0
- package/dist/generated/tenuo_wasm_bg.wasm.d.ts +58 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +4 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +258 -0
- package/dist/mcp.js.map +1 -0
- package/dist/nonce.d.ts +11 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/nonce.js +28 -0
- package/dist/nonce.js.map +1 -0
- package/dist/session.d.ts +19 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +50 -0
- package/dist/session.js.map +1 -0
- package/dist/wasm.d.ts +107 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +64 -0
- package/dist/wasm.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1415 @@
|
|
|
1
|
+
/* @ts-self-types="./tenuo_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Issuer + authorizer for `createTenuo({ root: devRoot() })`.
|
|
5
|
+
* Verifier-only contexts have `issuer: None` and cannot mint.
|
|
6
|
+
*/
|
|
7
|
+
class SdkContext {
|
|
8
|
+
static __wrap(ptr) {
|
|
9
|
+
const obj = Object.create(SdkContext.prototype);
|
|
10
|
+
obj.__wbg_ptr = ptr;
|
|
11
|
+
SdkContextFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
__destroy_into_raw() {
|
|
15
|
+
const ptr = this.__wbg_ptr;
|
|
16
|
+
this.__wbg_ptr = 0;
|
|
17
|
+
SdkContextFinalization.unregister(this);
|
|
18
|
+
return ptr;
|
|
19
|
+
}
|
|
20
|
+
free() {
|
|
21
|
+
const ptr = this.__destroy_into_raw();
|
|
22
|
+
wasm.__wbg_sdkcontext_free(ptr, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sign PoP and authorize in one call. Never returns allow without a core allow.
|
|
26
|
+
*
|
|
27
|
+
* `tool_allow` is the wrapper ceiling (`tenuo.tool(..., { allow })`). Null/undefined
|
|
28
|
+
* means no extra ceiling. Session and ceiling are AND'd; Rust decides both.
|
|
29
|
+
* @param {SdkSession} session
|
|
30
|
+
* @param {string} tool
|
|
31
|
+
* @param {any} args_json
|
|
32
|
+
* @param {any} approvals
|
|
33
|
+
* @param {any} tool_allow
|
|
34
|
+
* @param {string | null} [request_id]
|
|
35
|
+
* @returns {any}
|
|
36
|
+
*/
|
|
37
|
+
authorize(session, tool, args_json, approvals, tool_allow, request_id) {
|
|
38
|
+
_assertClass(session, SdkSession);
|
|
39
|
+
const ptr0 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
40
|
+
const len0 = WASM_VECTOR_LEN;
|
|
41
|
+
var ptr1 = isLikeNone(request_id) ? 0 : passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
42
|
+
var len1 = WASM_VECTOR_LEN;
|
|
43
|
+
const ret = wasm.sdkcontext_authorize(this.__wbg_ptr, session.__wbg_ptr, ptr0, len0, args_json, approvals, tool_allow, ptr1, len1);
|
|
44
|
+
return ret;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Test / replay seam. Not exposed on `createTenuo` or `execute`.
|
|
48
|
+
* @param {SdkSession} session
|
|
49
|
+
* @param {string} tool
|
|
50
|
+
* @param {any} args_json
|
|
51
|
+
* @param {number} as_of
|
|
52
|
+
* @param {any} approvals
|
|
53
|
+
* @param {any} tool_allow
|
|
54
|
+
* @returns {any}
|
|
55
|
+
*/
|
|
56
|
+
authorizeAsOf(session, tool, args_json, as_of, approvals, tool_allow) {
|
|
57
|
+
_assertClass(session, SdkSession);
|
|
58
|
+
const ptr0 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
const ret = wasm.sdkcontext_authorizeAsOf(this.__wbg_ptr, session.__wbg_ptr, ptr0, len0, args_json, as_of, approvals, tool_allow);
|
|
61
|
+
return ret;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Authorize a warrant + PoP presented on the wire. No holder secret.
|
|
65
|
+
*
|
|
66
|
+
* `tool_allow` is the server host ceiling (`mcp.handler(..., { allow })`).
|
|
67
|
+
* Null/undefined: no extra ceiling. Empty object: open.
|
|
68
|
+
* @param {any} warrants
|
|
69
|
+
* @param {string} tool
|
|
70
|
+
* @param {any} args_json
|
|
71
|
+
* @param {string} pop
|
|
72
|
+
* @param {any} approvals
|
|
73
|
+
* @param {any} tool_allow
|
|
74
|
+
* @param {string | null} [request_id]
|
|
75
|
+
* @returns {any}
|
|
76
|
+
*/
|
|
77
|
+
authorizePresented(warrants, tool, args_json, pop, approvals, tool_allow, request_id) {
|
|
78
|
+
const ptr0 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
79
|
+
const len0 = WASM_VECTOR_LEN;
|
|
80
|
+
const ptr1 = passStringToWasm0(pop, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
81
|
+
const len1 = WASM_VECTOR_LEN;
|
|
82
|
+
var ptr2 = isLikeNone(request_id) ? 0 : passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
83
|
+
var len2 = WASM_VECTOR_LEN;
|
|
84
|
+
const ret = wasm.sdkcontext_authorizePresented(this.__wbg_ptr, warrants, ptr0, len0, args_json, ptr1, len1, approvals, tool_allow, ptr2, len2);
|
|
85
|
+
return ret;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Authorizer-only context. `mint()` fails; import a session from the wire.
|
|
89
|
+
* @param {any} roots
|
|
90
|
+
* @returns {SdkContext}
|
|
91
|
+
*/
|
|
92
|
+
static fromTrustedRoots(roots) {
|
|
93
|
+
const ret = wasm.sdkcontext_fromTrustedRoots(roots);
|
|
94
|
+
if (ret[2]) {
|
|
95
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
96
|
+
}
|
|
97
|
+
return SdkContext.__wrap(ret[0]);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Load a published SignedRevocationList. The SRL must be signed by a trusted root.
|
|
101
|
+
* @param {string} wire
|
|
102
|
+
*/
|
|
103
|
+
loadRevocationList(wire) {
|
|
104
|
+
const ptr0 = passStringToWasm0(wire, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
+
const len0 = WASM_VECTOR_LEN;
|
|
106
|
+
const ret = wasm.sdkcontext_loadRevocationList(this.__wbg_ptr, ptr0, len0);
|
|
107
|
+
if (ret[1]) {
|
|
108
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Mint a short-lived session from an allow map:
|
|
113
|
+
* `{ "read_file": { "path": { "kind": "under", "root": "/data" } } }`
|
|
114
|
+
*
|
|
115
|
+
* `require_approval` is optional:
|
|
116
|
+
* `{ "approvers": ["hex..."], "min": 2, "tools": ["transfer"] }`
|
|
117
|
+
* @param {any} allow_json
|
|
118
|
+
* @param {number} ttl_seconds
|
|
119
|
+
* @param {any} require_approval
|
|
120
|
+
* @returns {SdkSession}
|
|
121
|
+
*/
|
|
122
|
+
mint(allow_json, ttl_seconds, require_approval) {
|
|
123
|
+
const ret = wasm.sdkcontext_mint(this.__wbg_ptr, allow_json, ttl_seconds, require_approval);
|
|
124
|
+
if (ret[2]) {
|
|
125
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
126
|
+
}
|
|
127
|
+
return SdkSession.__wrap(ret[0]);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Attenuate the leaf. The current holder signs; the same holder keeps the child.
|
|
131
|
+
* @param {SdkSession} session
|
|
132
|
+
* @param {any} allow_json
|
|
133
|
+
* @returns {SdkSession}
|
|
134
|
+
*/
|
|
135
|
+
narrow(session, allow_json) {
|
|
136
|
+
_assertClass(session, SdkSession);
|
|
137
|
+
const ret = wasm.sdkcontext_narrow(this.__wbg_ptr, session.__wbg_ptr, allow_json);
|
|
138
|
+
if (ret[2]) {
|
|
139
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
140
|
+
}
|
|
141
|
+
return SdkSession.__wrap(ret[0]);
|
|
142
|
+
}
|
|
143
|
+
constructor() {
|
|
144
|
+
const ret = wasm.sdkcontext_new();
|
|
145
|
+
this.__wbg_ptr = ret;
|
|
146
|
+
SdkContextFinalization.register(this, this.__wbg_ptr, this);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Holder PoP only. Does not authorize. Used to fill `_meta.tenuo.signature`.
|
|
151
|
+
* @param {SdkSession} session
|
|
152
|
+
* @param {string} tool
|
|
153
|
+
* @param {any} args_json
|
|
154
|
+
* @returns {string}
|
|
155
|
+
*/
|
|
156
|
+
signPop(session, tool, args_json) {
|
|
157
|
+
let deferred3_0;
|
|
158
|
+
let deferred3_1;
|
|
159
|
+
try {
|
|
160
|
+
_assertClass(session, SdkSession);
|
|
161
|
+
const ptr0 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
162
|
+
const len0 = WASM_VECTOR_LEN;
|
|
163
|
+
const ret = wasm.sdkcontext_signPop(this.__wbg_ptr, session.__wbg_ptr, ptr0, len0, args_json);
|
|
164
|
+
var ptr2 = ret[0];
|
|
165
|
+
var len2 = ret[1];
|
|
166
|
+
if (ret[3]) {
|
|
167
|
+
ptr2 = 0; len2 = 0;
|
|
168
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
169
|
+
}
|
|
170
|
+
deferred3_0 = ptr2;
|
|
171
|
+
deferred3_1 = len2;
|
|
172
|
+
return getStringFromWasm0(ptr2, len2);
|
|
173
|
+
} finally {
|
|
174
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Test / host seam. Signs an SRL with the local issuer. Does not load it.
|
|
179
|
+
* @param {any} ids
|
|
180
|
+
* @returns {string}
|
|
181
|
+
*/
|
|
182
|
+
signRevocationList(ids) {
|
|
183
|
+
let deferred2_0;
|
|
184
|
+
let deferred2_1;
|
|
185
|
+
try {
|
|
186
|
+
const ret = wasm.sdkcontext_signRevocationList(this.__wbg_ptr, ids);
|
|
187
|
+
var ptr1 = ret[0];
|
|
188
|
+
var len1 = ret[1];
|
|
189
|
+
if (ret[3]) {
|
|
190
|
+
ptr1 = 0; len1 = 0;
|
|
191
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
192
|
+
}
|
|
193
|
+
deferred2_0 = ptr1;
|
|
194
|
+
deferred2_1 = len1;
|
|
195
|
+
return getStringFromWasm0(ptr1, len1);
|
|
196
|
+
} finally {
|
|
197
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (Symbol.dispose) SdkContext.prototype[Symbol.dispose] = SdkContext.prototype.free;
|
|
202
|
+
exports.SdkContext = SdkContext;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Opaque warrant chain (root first) + leaf holder key. Not JSON-serializable from JS.
|
|
206
|
+
*/
|
|
207
|
+
class SdkSession {
|
|
208
|
+
static __wrap(ptr) {
|
|
209
|
+
const obj = Object.create(SdkSession.prototype);
|
|
210
|
+
obj.__wbg_ptr = ptr;
|
|
211
|
+
SdkSessionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
212
|
+
return obj;
|
|
213
|
+
}
|
|
214
|
+
__destroy_into_raw() {
|
|
215
|
+
const ptr = this.__wbg_ptr;
|
|
216
|
+
this.__wbg_ptr = 0;
|
|
217
|
+
SdkSessionFinalization.unregister(this);
|
|
218
|
+
return ptr;
|
|
219
|
+
}
|
|
220
|
+
free() {
|
|
221
|
+
const ptr = this.__destroy_into_raw();
|
|
222
|
+
wasm.__wbg_sdksession_free(ptr, 0);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Application idempotency key: SHA-256 of `(warrant_id, tool, canonical args)`.
|
|
226
|
+
* Not a PoP. MCP replay uses the PoP signature, not this key.
|
|
227
|
+
* @param {string} tool
|
|
228
|
+
* @param {any} args_json
|
|
229
|
+
* @returns {string}
|
|
230
|
+
*/
|
|
231
|
+
dedupKey(tool, args_json) {
|
|
232
|
+
let deferred3_0;
|
|
233
|
+
let deferred3_1;
|
|
234
|
+
try {
|
|
235
|
+
const ptr0 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
236
|
+
const len0 = WASM_VECTOR_LEN;
|
|
237
|
+
const ret = wasm.sdksession_dedupKey(this.__wbg_ptr, ptr0, len0, args_json);
|
|
238
|
+
var ptr2 = ret[0];
|
|
239
|
+
var len2 = ret[1];
|
|
240
|
+
if (ret[3]) {
|
|
241
|
+
ptr2 = 0; len2 = 0;
|
|
242
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
243
|
+
}
|
|
244
|
+
deferred3_0 = ptr2;
|
|
245
|
+
deferred3_1 = len2;
|
|
246
|
+
return getStringFromWasm0(ptr2, len2);
|
|
247
|
+
} finally {
|
|
248
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Test / interop seam. Not on the public TypeScript Session type.
|
|
253
|
+
* @returns {any}
|
|
254
|
+
*/
|
|
255
|
+
exportWire() {
|
|
256
|
+
const ret = wasm.sdksession_exportWire(this.__wbg_ptr);
|
|
257
|
+
if (ret[2]) {
|
|
258
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
259
|
+
}
|
|
260
|
+
return takeFromExternrefTable0(ret[0]);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Import a chain: string[] of wire tokens, or `{ payload_hex, signature_hex }[]`.
|
|
264
|
+
* @param {any} parts
|
|
265
|
+
* @param {Uint8Array} holder_secret
|
|
266
|
+
* @returns {SdkSession}
|
|
267
|
+
*/
|
|
268
|
+
static fromChain(parts, holder_secret) {
|
|
269
|
+
const ptr0 = passArray8ToWasm0(holder_secret, wasm.__wbindgen_malloc);
|
|
270
|
+
const len0 = WASM_VECTOR_LEN;
|
|
271
|
+
const ret = wasm.sdksession_fromChain(parts, ptr0, len0);
|
|
272
|
+
if (ret[2]) {
|
|
273
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
274
|
+
}
|
|
275
|
+
return SdkSession.__wrap(ret[0]);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Reconstruct a warrant from published payload + signature hex (A.14).
|
|
279
|
+
* @param {string} payload_hex
|
|
280
|
+
* @param {string} signature_hex
|
|
281
|
+
* @param {Uint8Array} holder_secret
|
|
282
|
+
* @returns {SdkSession}
|
|
283
|
+
*/
|
|
284
|
+
static fromParts(payload_hex, signature_hex, holder_secret) {
|
|
285
|
+
const ptr0 = passStringToWasm0(payload_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
286
|
+
const len0 = WASM_VECTOR_LEN;
|
|
287
|
+
const ptr1 = passStringToWasm0(signature_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
288
|
+
const len1 = WASM_VECTOR_LEN;
|
|
289
|
+
const ptr2 = passArray8ToWasm0(holder_secret, wasm.__wbindgen_malloc);
|
|
290
|
+
const len2 = WASM_VECTOR_LEN;
|
|
291
|
+
const ret = wasm.sdksession_fromParts(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
292
|
+
if (ret[2]) {
|
|
293
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
294
|
+
}
|
|
295
|
+
return SdkSession.__wrap(ret[0]);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Import a published warrant (base64 or envelope hex) plus the holder secret.
|
|
299
|
+
* @param {string} warrant
|
|
300
|
+
* @param {Uint8Array} holder_secret
|
|
301
|
+
* @returns {SdkSession}
|
|
302
|
+
*/
|
|
303
|
+
static fromWire(warrant, holder_secret) {
|
|
304
|
+
const ptr0 = passStringToWasm0(warrant, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
305
|
+
const len0 = WASM_VECTOR_LEN;
|
|
306
|
+
const ptr1 = passArray8ToWasm0(holder_secret, wasm.__wbindgen_malloc);
|
|
307
|
+
const len1 = WASM_VECTOR_LEN;
|
|
308
|
+
const ret = wasm.sdksession_fromWire(ptr0, len0, ptr1, len1);
|
|
309
|
+
if (ret[2]) {
|
|
310
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
311
|
+
}
|
|
312
|
+
return SdkSession.__wrap(ret[0]);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* CBOR warrant stack as standard base64. Matches Python `encode_warrant_stack`.
|
|
316
|
+
* @returns {string}
|
|
317
|
+
*/
|
|
318
|
+
toStackWire() {
|
|
319
|
+
let deferred2_0;
|
|
320
|
+
let deferred2_1;
|
|
321
|
+
try {
|
|
322
|
+
const ret = wasm.sdksession_toStackWire(this.__wbg_ptr);
|
|
323
|
+
var ptr1 = ret[0];
|
|
324
|
+
var len1 = ret[1];
|
|
325
|
+
if (ret[3]) {
|
|
326
|
+
ptr1 = 0; len1 = 0;
|
|
327
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
328
|
+
}
|
|
329
|
+
deferred2_0 = ptr1;
|
|
330
|
+
deferred2_1 = len1;
|
|
331
|
+
return getStringFromWasm0(ptr1, len1);
|
|
332
|
+
} finally {
|
|
333
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Warrant tokens, root first. Does not include the holder secret.
|
|
338
|
+
* @returns {any}
|
|
339
|
+
*/
|
|
340
|
+
toWire() {
|
|
341
|
+
const ret = wasm.sdksession_toWire(this.__wbg_ptr);
|
|
342
|
+
if (ret[2]) {
|
|
343
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
344
|
+
}
|
|
345
|
+
return takeFromExternrefTable0(ret[0]);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Warrant IDs, root first. Test / revoke seam.
|
|
349
|
+
* @returns {any}
|
|
350
|
+
*/
|
|
351
|
+
warrantIds() {
|
|
352
|
+
const ret = wasm.sdksession_warrantIds(this.__wbg_ptr);
|
|
353
|
+
if (ret[2]) {
|
|
354
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
355
|
+
}
|
|
356
|
+
return takeFromExternrefTable0(ret[0]);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (Symbol.dispose) SdkSession.prototype[Symbol.dispose] = SdkSession.prototype.free;
|
|
360
|
+
exports.SdkSession = SdkSession;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @param {string} warrant_b64
|
|
364
|
+
* @param {string} tool
|
|
365
|
+
* @param {any} args_json
|
|
366
|
+
* @param {string} trusted_root_hex
|
|
367
|
+
* @param {boolean} dry_run
|
|
368
|
+
* @returns {any}
|
|
369
|
+
*/
|
|
370
|
+
function check_access(warrant_b64, tool, args_json, trusted_root_hex, dry_run) {
|
|
371
|
+
const ptr0 = passStringToWasm0(warrant_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
372
|
+
const len0 = WASM_VECTOR_LEN;
|
|
373
|
+
const ptr1 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
374
|
+
const len1 = WASM_VECTOR_LEN;
|
|
375
|
+
const ptr2 = passStringToWasm0(trusted_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
376
|
+
const len2 = WASM_VECTOR_LEN;
|
|
377
|
+
const ret = wasm.check_access(ptr0, len0, ptr1, len1, args_json, ptr2, len2, dry_run);
|
|
378
|
+
return ret;
|
|
379
|
+
}
|
|
380
|
+
exports.check_access = check_access;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Check authorization with a real PoP signature
|
|
384
|
+
* @param {string} warrant_b64
|
|
385
|
+
* @param {string} tool
|
|
386
|
+
* @param {any} args_json
|
|
387
|
+
* @param {string} trusted_root_hex
|
|
388
|
+
* @param {string} pop_signature_hex
|
|
389
|
+
* @returns {any}
|
|
390
|
+
*/
|
|
391
|
+
function check_access_with_pop(warrant_b64, tool, args_json, trusted_root_hex, pop_signature_hex) {
|
|
392
|
+
const ptr0 = passStringToWasm0(warrant_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
393
|
+
const len0 = WASM_VECTOR_LEN;
|
|
394
|
+
const ptr1 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
395
|
+
const len1 = WASM_VECTOR_LEN;
|
|
396
|
+
const ptr2 = passStringToWasm0(trusted_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
397
|
+
const len2 = WASM_VECTOR_LEN;
|
|
398
|
+
const ptr3 = passStringToWasm0(pop_signature_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
399
|
+
const len3 = WASM_VECTOR_LEN;
|
|
400
|
+
const ret = wasm.check_access_with_pop(ptr0, len0, ptr1, len1, args_json, ptr2, len2, ptr3, len3);
|
|
401
|
+
return ret;
|
|
402
|
+
}
|
|
403
|
+
exports.check_access_with_pop = check_access_with_pop;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* @param {string[]} warrant_b64_list
|
|
407
|
+
* @param {string} tool
|
|
408
|
+
* @param {any} args_json
|
|
409
|
+
* @param {string} trusted_root_hex
|
|
410
|
+
* @param {boolean} dry_run
|
|
411
|
+
* @returns {any}
|
|
412
|
+
*/
|
|
413
|
+
function check_chain_access(warrant_b64_list, tool, args_json, trusted_root_hex, dry_run) {
|
|
414
|
+
const ptr0 = passArrayJsValueToWasm0(warrant_b64_list, wasm.__wbindgen_malloc);
|
|
415
|
+
const len0 = WASM_VECTOR_LEN;
|
|
416
|
+
const ptr1 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
417
|
+
const len1 = WASM_VECTOR_LEN;
|
|
418
|
+
const ptr2 = passStringToWasm0(trusted_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
419
|
+
const len2 = WASM_VECTOR_LEN;
|
|
420
|
+
const ret = wasm.check_chain_access(ptr0, len0, ptr1, len1, args_json, ptr2, len2, dry_run);
|
|
421
|
+
return ret;
|
|
422
|
+
}
|
|
423
|
+
exports.check_chain_access = check_chain_access;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Check a warrant chain with signed approvals and optional revocation list.
|
|
427
|
+
*
|
|
428
|
+
* Extends `check_chain_access` with:
|
|
429
|
+
* - `approvals_b64`: JS array of base64-encoded CBOR `SignedApproval` blobs for M-of-N
|
|
430
|
+
* approval verification (pass `[]` if not needed).
|
|
431
|
+
* - `srl_b64`: optional base64-encoded CBOR `SignedRevocationList`. When provided, the
|
|
432
|
+
* SRL is verified (using the trusted root as its issuer) and applied before chain checks.
|
|
433
|
+
* Pass `null`/`undefined` to skip revocation checking.
|
|
434
|
+
* @param {string[]} warrant_b64_list
|
|
435
|
+
* @param {string} tool
|
|
436
|
+
* @param {any} args_json
|
|
437
|
+
* @param {string} trusted_root_hex
|
|
438
|
+
* @param {any} approvals_b64
|
|
439
|
+
* @param {string | null} [srl_b64]
|
|
440
|
+
* @returns {any}
|
|
441
|
+
*/
|
|
442
|
+
function check_chain_access_with_approvals(warrant_b64_list, tool, args_json, trusted_root_hex, approvals_b64, srl_b64) {
|
|
443
|
+
const ptr0 = passArrayJsValueToWasm0(warrant_b64_list, wasm.__wbindgen_malloc);
|
|
444
|
+
const len0 = WASM_VECTOR_LEN;
|
|
445
|
+
const ptr1 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
446
|
+
const len1 = WASM_VECTOR_LEN;
|
|
447
|
+
const ptr2 = passStringToWasm0(trusted_root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
448
|
+
const len2 = WASM_VECTOR_LEN;
|
|
449
|
+
var ptr3 = isLikeNone(srl_b64) ? 0 : passStringToWasm0(srl_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
450
|
+
var len3 = WASM_VECTOR_LEN;
|
|
451
|
+
const ret = wasm.check_chain_access_with_approvals(ptr0, len0, ptr1, len1, args_json, ptr2, len2, approvals_b64, ptr3, len3);
|
|
452
|
+
return ret;
|
|
453
|
+
}
|
|
454
|
+
exports.check_chain_access_with_approvals = check_chain_access_with_approvals;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Check if a warrant ID appears in a signed revocation list.
|
|
458
|
+
*
|
|
459
|
+
* Does not verify the SRL signature — call `verify_srl` first if you need
|
|
460
|
+
* signature assurance. Returns `{ revoked, error? }`.
|
|
461
|
+
* @param {string} warrant_id
|
|
462
|
+
* @param {string} srl_cbor_b64
|
|
463
|
+
* @returns {any}
|
|
464
|
+
*/
|
|
465
|
+
function check_revocation(warrant_id, srl_cbor_b64) {
|
|
466
|
+
const ptr0 = passStringToWasm0(warrant_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
467
|
+
const len0 = WASM_VECTOR_LEN;
|
|
468
|
+
const ptr1 = passStringToWasm0(srl_cbor_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
469
|
+
const len1 = WASM_VECTOR_LEN;
|
|
470
|
+
const ret = wasm.check_revocation(ptr0, len0, ptr1, len1);
|
|
471
|
+
return ret;
|
|
472
|
+
}
|
|
473
|
+
exports.check_revocation = check_revocation;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Compute the canonical request hash for a (warrant, tool, args) tuple.
|
|
477
|
+
*
|
|
478
|
+
* The hash is SHA-256(warrant_id | tool | CBOR(sorted_args) | holder_key) and is
|
|
479
|
+
* what every SignedApproval must cover. Use this to build the payload for
|
|
480
|
+
* POST /v1/approvals/requests so the backend can verify it matches.
|
|
481
|
+
*
|
|
482
|
+
* Returns `{ "hash": "<hex>" }` on success, or `{ "hash": null, "error": "..." }` on failure.
|
|
483
|
+
* @param {string} warrant_b64
|
|
484
|
+
* @param {string} tool
|
|
485
|
+
* @param {any} args_json
|
|
486
|
+
* @returns {any}
|
|
487
|
+
*/
|
|
488
|
+
function compute_request_hash_wasm(warrant_b64, tool, args_json) {
|
|
489
|
+
const ptr0 = passStringToWasm0(warrant_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
490
|
+
const len0 = WASM_VECTOR_LEN;
|
|
491
|
+
const ptr1 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
492
|
+
const len1 = WASM_VECTOR_LEN;
|
|
493
|
+
const ret = wasm.compute_request_hash_wasm(ptr0, len0, ptr1, len1, args_json);
|
|
494
|
+
return ret;
|
|
495
|
+
}
|
|
496
|
+
exports.compute_request_hash_wasm = compute_request_hash_wasm;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Create a self-signed root Issuer warrant for use as a persistent trust anchor.
|
|
500
|
+
* This is called once during plugin setup and stored on disk.
|
|
501
|
+
* The Issuer warrant's keypair replaces per-session signing keys — all Execution
|
|
502
|
+
* warrants (depth ≥ 1) are derived from it, enabling proper WASM chain verification
|
|
503
|
+
* across plugin restarts.
|
|
504
|
+
*
|
|
505
|
+
* Config: { signing_key_hex?: string, issuable_tools: string[], max_issue_depth?: number, ttl_seconds?: number }
|
|
506
|
+
* @param {any} config_json
|
|
507
|
+
* @returns {any}
|
|
508
|
+
*/
|
|
509
|
+
function create_issuer_warrant(config_json) {
|
|
510
|
+
const ret = wasm.create_issuer_warrant(config_json);
|
|
511
|
+
return ret;
|
|
512
|
+
}
|
|
513
|
+
exports.create_issuer_warrant = create_issuer_warrant;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Create a fresh sample warrant with the given tool and TTL
|
|
517
|
+
* This generates new keys each time, ensuring the warrant is never expired
|
|
518
|
+
* @param {string} tool
|
|
519
|
+
* @param {string} constraint_field
|
|
520
|
+
* @param {string} constraint_pattern
|
|
521
|
+
* @param {bigint} ttl_seconds
|
|
522
|
+
* @returns {any}
|
|
523
|
+
*/
|
|
524
|
+
function create_sample_warrant(tool, constraint_field, constraint_pattern, ttl_seconds) {
|
|
525
|
+
const ptr0 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
526
|
+
const len0 = WASM_VECTOR_LEN;
|
|
527
|
+
const ptr1 = passStringToWasm0(constraint_field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
528
|
+
const len1 = WASM_VECTOR_LEN;
|
|
529
|
+
const ptr2 = passStringToWasm0(constraint_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
530
|
+
const len2 = WASM_VECTOR_LEN;
|
|
531
|
+
const ret = wasm.create_sample_warrant(ptr0, len0, ptr1, len1, ptr2, len2, ttl_seconds);
|
|
532
|
+
return ret;
|
|
533
|
+
}
|
|
534
|
+
exports.create_sample_warrant = create_sample_warrant;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Create a warrant from the full builder config (multiple tools, multiple constraints)
|
|
538
|
+
* This is more flexible than create_sample_warrant
|
|
539
|
+
* @param {any} config_json
|
|
540
|
+
* @returns {any}
|
|
541
|
+
*/
|
|
542
|
+
function create_warrant_from_config(config_json) {
|
|
543
|
+
const ret = wasm.create_warrant_from_config(config_json);
|
|
544
|
+
return ret;
|
|
545
|
+
}
|
|
546
|
+
exports.create_warrant_from_config = create_warrant_from_config;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Decode a PEM chain (or single warrant) and return detailed chain analysis
|
|
550
|
+
* @param {string} input
|
|
551
|
+
* @returns {any}
|
|
552
|
+
*/
|
|
553
|
+
function decode_pem_chain_wasm(input) {
|
|
554
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
555
|
+
const len0 = WASM_VECTOR_LEN;
|
|
556
|
+
const ret = wasm.decode_pem_chain_wasm(ptr0, len0);
|
|
557
|
+
return ret;
|
|
558
|
+
}
|
|
559
|
+
exports.decode_pem_chain_wasm = decode_pem_chain_wasm;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @param {string} base64_warrant
|
|
563
|
+
* @returns {any}
|
|
564
|
+
*/
|
|
565
|
+
function decode_warrant(base64_warrant) {
|
|
566
|
+
const ptr0 = passStringToWasm0(base64_warrant, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
567
|
+
const len0 = WASM_VECTOR_LEN;
|
|
568
|
+
const ret = wasm.decode_warrant(ptr0, len0);
|
|
569
|
+
return ret;
|
|
570
|
+
}
|
|
571
|
+
exports.decode_warrant = decode_warrant;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Evaluate whether a tool call requires approval based on the warrant's embedded approval gates.
|
|
575
|
+
*
|
|
576
|
+
* Returns `{ approval_required: true/false, tool, error }`.
|
|
577
|
+
* This reads `extensions["tenuo.approval_gates"]` from the warrant, parses it,
|
|
578
|
+
* and runs the gate evaluation logic from tenuo-core.
|
|
579
|
+
* @param {string} warrant_b64
|
|
580
|
+
* @param {string} tool
|
|
581
|
+
* @param {any} args_json
|
|
582
|
+
* @returns {any}
|
|
583
|
+
*/
|
|
584
|
+
function evaluate_approval_gates(warrant_b64, tool, args_json) {
|
|
585
|
+
const ptr0 = passStringToWasm0(warrant_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
587
|
+
const ptr1 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
588
|
+
const len1 = WASM_VECTOR_LEN;
|
|
589
|
+
const ret = wasm.evaluate_approval_gates(ptr0, len0, ptr1, len1, args_json);
|
|
590
|
+
return ret;
|
|
591
|
+
}
|
|
592
|
+
exports.evaluate_approval_gates = evaluate_approval_gates;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Generate a new Ed25519 keypair for testing PoP
|
|
596
|
+
* @returns {any}
|
|
597
|
+
*/
|
|
598
|
+
function generate_keypair() {
|
|
599
|
+
const ret = wasm.generate_keypair();
|
|
600
|
+
return ret;
|
|
601
|
+
}
|
|
602
|
+
exports.generate_keypair = generate_keypair;
|
|
603
|
+
|
|
604
|
+
function init_panic_hook() {
|
|
605
|
+
wasm.init_panic_hook();
|
|
606
|
+
}
|
|
607
|
+
exports.init_panic_hook = init_panic_hook;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Parse a `TENUO_CONNECT_TOKEN` string into its component fields.
|
|
611
|
+
*
|
|
612
|
+
* The token is a base64url-encoded JSON blob: `{ v, e, k, a?, t? }`.
|
|
613
|
+
* This WASM binding keeps the parsing canonical so TypeScript doesn't need
|
|
614
|
+
* to duplicate the decode logic.
|
|
615
|
+
*
|
|
616
|
+
* Returns `{ endpoint, apiKey, agentId?, registrationToken?, error? }`.
|
|
617
|
+
* @param {string} token
|
|
618
|
+
* @returns {any}
|
|
619
|
+
*/
|
|
620
|
+
function parse_connect_token(token) {
|
|
621
|
+
const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
622
|
+
const len0 = WASM_VECTOR_LEN;
|
|
623
|
+
const ret = wasm.parse_connect_token(ptr0, len0);
|
|
624
|
+
return ret;
|
|
625
|
+
}
|
|
626
|
+
exports.parse_connect_token = parse_connect_token;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* @param {string} payload_hex
|
|
630
|
+
* @param {string} signature_hex
|
|
631
|
+
* @returns {any}
|
|
632
|
+
*/
|
|
633
|
+
function sdkInspectParts(payload_hex, signature_hex) {
|
|
634
|
+
const ptr0 = passStringToWasm0(payload_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
635
|
+
const len0 = WASM_VECTOR_LEN;
|
|
636
|
+
const ptr1 = passStringToWasm0(signature_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
637
|
+
const len1 = WASM_VECTOR_LEN;
|
|
638
|
+
const ret = wasm.sdkInspectParts(ptr0, len0, ptr1, len1);
|
|
639
|
+
if (ret[2]) {
|
|
640
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
641
|
+
}
|
|
642
|
+
return takeFromExternrefTable0(ret[0]);
|
|
643
|
+
}
|
|
644
|
+
exports.sdkInspectParts = sdkInspectParts;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* @param {string} wire
|
|
648
|
+
* @returns {any}
|
|
649
|
+
*/
|
|
650
|
+
function sdkInspectWarrant(wire) {
|
|
651
|
+
const ptr0 = passStringToWasm0(wire, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
652
|
+
const len0 = WASM_VECTOR_LEN;
|
|
653
|
+
const ret = wasm.sdkInspectWarrant(ptr0, len0);
|
|
654
|
+
if (ret[2]) {
|
|
655
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
656
|
+
}
|
|
657
|
+
return takeFromExternrefTable0(ret[0]);
|
|
658
|
+
}
|
|
659
|
+
exports.sdkInspectWarrant = sdkInspectWarrant;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Test / host seam. Signs a SignedApproval envelope; does not authorize.
|
|
663
|
+
* @param {SdkSession} session
|
|
664
|
+
* @param {string} tool
|
|
665
|
+
* @param {any} args_json
|
|
666
|
+
* @param {Uint8Array} approver_secret
|
|
667
|
+
* @param {string} external_id
|
|
668
|
+
* @param {number | null} [as_of]
|
|
669
|
+
* @returns {string}
|
|
670
|
+
*/
|
|
671
|
+
function sdkSignApproval(session, tool, args_json, approver_secret, external_id, as_of) {
|
|
672
|
+
let deferred5_0;
|
|
673
|
+
let deferred5_1;
|
|
674
|
+
try {
|
|
675
|
+
_assertClass(session, SdkSession);
|
|
676
|
+
const ptr0 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
677
|
+
const len0 = WASM_VECTOR_LEN;
|
|
678
|
+
const ptr1 = passArray8ToWasm0(approver_secret, wasm.__wbindgen_malloc);
|
|
679
|
+
const len1 = WASM_VECTOR_LEN;
|
|
680
|
+
const ptr2 = passStringToWasm0(external_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
681
|
+
const len2 = WASM_VECTOR_LEN;
|
|
682
|
+
const ret = wasm.sdkSignApproval(session.__wbg_ptr, ptr0, len0, args_json, ptr1, len1, ptr2, len2, !isLikeNone(as_of), isLikeNone(as_of) ? 0 : as_of);
|
|
683
|
+
var ptr4 = ret[0];
|
|
684
|
+
var len4 = ret[1];
|
|
685
|
+
if (ret[3]) {
|
|
686
|
+
ptr4 = 0; len4 = 0;
|
|
687
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
688
|
+
}
|
|
689
|
+
deferred5_0 = ptr4;
|
|
690
|
+
deferred5_1 = len4;
|
|
691
|
+
return getStringFromWasm0(ptr4, len4);
|
|
692
|
+
} finally {
|
|
693
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
exports.sdkSignApproval = sdkSignApproval;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Test seam. Signs the published generator envelope (not the in-memory SRL codec).
|
|
700
|
+
* @param {any} ids
|
|
701
|
+
* @param {number} version
|
|
702
|
+
* @param {Uint8Array} issuer_secret
|
|
703
|
+
* @returns {string}
|
|
704
|
+
*/
|
|
705
|
+
function sdkSignPublishedRevocationList(ids, version, issuer_secret) {
|
|
706
|
+
let deferred3_0;
|
|
707
|
+
let deferred3_1;
|
|
708
|
+
try {
|
|
709
|
+
const ptr0 = passArray8ToWasm0(issuer_secret, wasm.__wbindgen_malloc);
|
|
710
|
+
const len0 = WASM_VECTOR_LEN;
|
|
711
|
+
const ret = wasm.sdkSignPublishedRevocationList(ids, version, ptr0, len0);
|
|
712
|
+
var ptr2 = ret[0];
|
|
713
|
+
var len2 = ret[1];
|
|
714
|
+
if (ret[3]) {
|
|
715
|
+
ptr2 = 0; len2 = 0;
|
|
716
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
717
|
+
}
|
|
718
|
+
deferred3_0 = ptr2;
|
|
719
|
+
deferred3_1 = len2;
|
|
720
|
+
return getStringFromWasm0(ptr2, len2);
|
|
721
|
+
} finally {
|
|
722
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
exports.sdkSignPublishedRevocationList = sdkSignPublishedRevocationList;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Test / host seam. Signs an SRL with a provided issuer secret. Does not load it.
|
|
729
|
+
* @param {any} ids
|
|
730
|
+
* @param {Uint8Array} issuer_secret
|
|
731
|
+
* @returns {string}
|
|
732
|
+
*/
|
|
733
|
+
function sdkSignRevocationList(ids, issuer_secret) {
|
|
734
|
+
let deferred3_0;
|
|
735
|
+
let deferred3_1;
|
|
736
|
+
try {
|
|
737
|
+
const ptr0 = passArray8ToWasm0(issuer_secret, wasm.__wbindgen_malloc);
|
|
738
|
+
const len0 = WASM_VECTOR_LEN;
|
|
739
|
+
const ret = wasm.sdkSignRevocationList(ids, ptr0, len0);
|
|
740
|
+
var ptr2 = ret[0];
|
|
741
|
+
var len2 = ret[1];
|
|
742
|
+
if (ret[3]) {
|
|
743
|
+
ptr2 = 0; len2 = 0;
|
|
744
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
745
|
+
}
|
|
746
|
+
deferred3_0 = ptr2;
|
|
747
|
+
deferred3_1 = len2;
|
|
748
|
+
return getStringFromWasm0(ptr2, len2);
|
|
749
|
+
} finally {
|
|
750
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
exports.sdkSignRevocationList = sdkSignRevocationList;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Signature authenticity only. Not authorization.
|
|
757
|
+
* @param {string} wire
|
|
758
|
+
* @returns {any}
|
|
759
|
+
*/
|
|
760
|
+
function sdkVerifyReceipt(wire) {
|
|
761
|
+
const ptr0 = passStringToWasm0(wire, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
762
|
+
const len0 = WASM_VECTOR_LEN;
|
|
763
|
+
const ret = wasm.sdkVerifyReceipt(ptr0, len0);
|
|
764
|
+
if (ret[2]) {
|
|
765
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
766
|
+
}
|
|
767
|
+
return takeFromExternrefTable0(ret[0]);
|
|
768
|
+
}
|
|
769
|
+
exports.sdkVerifyReceipt = sdkVerifyReceipt;
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Verify a receipt's embedded warrant chain against trusted roots, at the
|
|
773
|
+
* receipt's own decision instant.
|
|
774
|
+
*
|
|
775
|
+
* This is the root-anchored half of receipt verification: it needs no trust
|
|
776
|
+
* in `signer_key` at all, because the chain is signed by the root and the
|
|
777
|
+
* holder, not by the enforcement point. The signature over the receipt is
|
|
778
|
+
* still checked first — an unauthenticated payload is never parsed into a
|
|
779
|
+
* chain to verify.
|
|
780
|
+
*
|
|
781
|
+
* A deny receipt whose chain fails with the same error it states is
|
|
782
|
+
* *corroborated*: the embedded authority independently supports the refusal.
|
|
783
|
+
* A deny whose chain verifies is not inconsistent — constraint and
|
|
784
|
+
* possession failures deny over a valid chain, and chain-level verification
|
|
785
|
+
* does not evaluate those.
|
|
786
|
+
* @param {string} wire
|
|
787
|
+
* @param {any} roots
|
|
788
|
+
* @returns {any}
|
|
789
|
+
*/
|
|
790
|
+
function sdkVerifyReceiptChain(wire, roots) {
|
|
791
|
+
const ptr0 = passStringToWasm0(wire, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
792
|
+
const len0 = WASM_VECTOR_LEN;
|
|
793
|
+
const ret = wasm.sdkVerifyReceiptChain(ptr0, len0, roots);
|
|
794
|
+
if (ret[2]) {
|
|
795
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
796
|
+
}
|
|
797
|
+
return takeFromExternrefTable0(ret[0]);
|
|
798
|
+
}
|
|
799
|
+
exports.sdkVerifyReceiptChain = sdkVerifyReceiptChain;
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Create a Proof-of-Possession signature for a warrant
|
|
803
|
+
* @param {string} private_key_hex
|
|
804
|
+
* @param {string} warrant_b64
|
|
805
|
+
* @param {string} tool
|
|
806
|
+
* @param {any} args_json
|
|
807
|
+
* @returns {any}
|
|
808
|
+
*/
|
|
809
|
+
function sign(private_key_hex, warrant_b64, tool, args_json) {
|
|
810
|
+
const ptr0 = passStringToWasm0(private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
811
|
+
const len0 = WASM_VECTOR_LEN;
|
|
812
|
+
const ptr1 = passStringToWasm0(warrant_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
813
|
+
const len1 = WASM_VECTOR_LEN;
|
|
814
|
+
const ptr2 = passStringToWasm0(tool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
815
|
+
const len2 = WASM_VECTOR_LEN;
|
|
816
|
+
const ret = wasm.sign(ptr0, len0, ptr1, len1, ptr2, len2, args_json);
|
|
817
|
+
return ret;
|
|
818
|
+
}
|
|
819
|
+
exports.sign = sign;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Sign an authorization receipt for audit ingestion.
|
|
823
|
+
*
|
|
824
|
+
* Produces the same CBOR+Ed25519 format used by the authorizer binary, allowing
|
|
825
|
+
* browser/Node plugins to generate verifiable forensic receipts.
|
|
826
|
+
*
|
|
827
|
+
* `payload_json` — `{ authorizer_id, warrant_chain_b64, action, outcome, timestamp, root_principal? }`
|
|
828
|
+
* `authorizer_key_hex` — hex-encoded Ed25519 private key (32 bytes).
|
|
829
|
+
*
|
|
830
|
+
* Returns `{ signature_hex, signing_payload_cbor_hex, error? }`.
|
|
831
|
+
* @param {any} payload_json
|
|
832
|
+
* @param {string} authorizer_key_hex
|
|
833
|
+
* @returns {any}
|
|
834
|
+
*/
|
|
835
|
+
function sign_receipt(payload_json, authorizer_key_hex) {
|
|
836
|
+
const ptr0 = passStringToWasm0(authorizer_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
837
|
+
const len0 = WASM_VECTOR_LEN;
|
|
838
|
+
const ret = wasm.sign_receipt(payload_json, ptr0, len0);
|
|
839
|
+
return ret;
|
|
840
|
+
}
|
|
841
|
+
exports.sign_receipt = sign_receipt;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Verify that enough valid signed approvals cover a known request hash.
|
|
845
|
+
*
|
|
846
|
+
* Use this when you already have a pre-computed `request_hash_hex` and want
|
|
847
|
+
* to check the approval set independently of tool/args re-parsing.
|
|
848
|
+
*
|
|
849
|
+
* `warrant_b64` — the leaf warrant (provides `required_approvers` and threshold).
|
|
850
|
+
* `request_hash_hex` — hex-encoded 32-byte hash from `compute_request_hash_wasm`.
|
|
851
|
+
* `approvals_b64` — JS array of base64-encoded CBOR `SignedApproval` blobs.
|
|
852
|
+
*
|
|
853
|
+
* Returns `{ satisfied, valid_count, required, error? }`.
|
|
854
|
+
* @param {string} warrant_b64
|
|
855
|
+
* @param {string} request_hash_hex
|
|
856
|
+
* @param {any} approvals_b64
|
|
857
|
+
* @returns {any}
|
|
858
|
+
*/
|
|
859
|
+
function verify_approval_set(warrant_b64, request_hash_hex, approvals_b64) {
|
|
860
|
+
const ptr0 = passStringToWasm0(warrant_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
861
|
+
const len0 = WASM_VECTOR_LEN;
|
|
862
|
+
const ptr1 = passStringToWasm0(request_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
863
|
+
const len1 = WASM_VECTOR_LEN;
|
|
864
|
+
const ret = wasm.verify_approval_set(ptr0, len0, ptr1, len1, approvals_b64);
|
|
865
|
+
return ret;
|
|
866
|
+
}
|
|
867
|
+
exports.verify_approval_set = verify_approval_set;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Verify a single signed approval blob and return its payload.
|
|
871
|
+
*
|
|
872
|
+
* `approval_cbor_b64` — base64-encoded CBOR `SignedApproval`.
|
|
873
|
+
*
|
|
874
|
+
* Returns `{ valid, approver_hex, request_hash_hex, approved_at, expires_at, error? }`.
|
|
875
|
+
* @param {string} approval_cbor_b64
|
|
876
|
+
* @returns {any}
|
|
877
|
+
*/
|
|
878
|
+
function verify_signed_approval(approval_cbor_b64) {
|
|
879
|
+
const ptr0 = passStringToWasm0(approval_cbor_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
880
|
+
const len0 = WASM_VECTOR_LEN;
|
|
881
|
+
const ret = wasm.verify_signed_approval(ptr0, len0);
|
|
882
|
+
return ret;
|
|
883
|
+
}
|
|
884
|
+
exports.verify_signed_approval = verify_signed_approval;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Verify a signed revocation list and return its metadata.
|
|
888
|
+
*
|
|
889
|
+
* `srl_cbor_b64` — base64-encoded CBOR `SignedRevocationList`.
|
|
890
|
+
* `expected_issuer_hex` — hex-encoded Ed25519 public key of the expected SRL issuer.
|
|
891
|
+
*
|
|
892
|
+
* Returns `{ valid, version, revoked_count, issued_at, error? }`.
|
|
893
|
+
* @param {string} srl_cbor_b64
|
|
894
|
+
* @param {string} expected_issuer_hex
|
|
895
|
+
* @returns {any}
|
|
896
|
+
*/
|
|
897
|
+
function verify_srl(srl_cbor_b64, expected_issuer_hex) {
|
|
898
|
+
const ptr0 = passStringToWasm0(srl_cbor_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
899
|
+
const len0 = WASM_VECTOR_LEN;
|
|
900
|
+
const ptr1 = passStringToWasm0(expected_issuer_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
901
|
+
const len1 = WASM_VECTOR_LEN;
|
|
902
|
+
const ret = wasm.verify_srl(ptr0, len0, ptr1, len1);
|
|
903
|
+
return ret;
|
|
904
|
+
}
|
|
905
|
+
exports.verify_srl = verify_srl;
|
|
906
|
+
function __wbg_get_imports() {
|
|
907
|
+
const import0 = {
|
|
908
|
+
__proto__: null,
|
|
909
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
910
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
911
|
+
return ret;
|
|
912
|
+
},
|
|
913
|
+
__wbg_Number_c4bdf66bb78f7977: function(arg0) {
|
|
914
|
+
const ret = Number(arg0);
|
|
915
|
+
return ret;
|
|
916
|
+
},
|
|
917
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
918
|
+
const ret = String(arg1);
|
|
919
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
920
|
+
const len1 = WASM_VECTOR_LEN;
|
|
921
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
922
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
923
|
+
},
|
|
924
|
+
__wbg___wbindgen_bigint_get_as_i64_d9e915702856f831: function(arg0, arg1) {
|
|
925
|
+
const v = arg1;
|
|
926
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
927
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
928
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
929
|
+
},
|
|
930
|
+
__wbg___wbindgen_boolean_get_edaed31a367ce1bd: function(arg0) {
|
|
931
|
+
const v = arg0;
|
|
932
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
933
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
934
|
+
},
|
|
935
|
+
__wbg___wbindgen_debug_string_8a447059637473e2: function(arg0, arg1) {
|
|
936
|
+
const ret = debugString(arg1);
|
|
937
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
938
|
+
const len1 = WASM_VECTOR_LEN;
|
|
939
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
940
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
941
|
+
},
|
|
942
|
+
__wbg___wbindgen_in_4990f46af709e33c: function(arg0, arg1) {
|
|
943
|
+
const ret = arg0 in arg1;
|
|
944
|
+
return ret;
|
|
945
|
+
},
|
|
946
|
+
__wbg___wbindgen_is_bigint_90b5ccfe67c78460: function(arg0) {
|
|
947
|
+
const ret = typeof(arg0) === 'bigint';
|
|
948
|
+
return ret;
|
|
949
|
+
},
|
|
950
|
+
__wbg___wbindgen_is_function_acc5528be2b923f2: function(arg0) {
|
|
951
|
+
const ret = typeof(arg0) === 'function';
|
|
952
|
+
return ret;
|
|
953
|
+
},
|
|
954
|
+
__wbg___wbindgen_is_null_6d937fbfb6478470: function(arg0) {
|
|
955
|
+
const ret = arg0 === null;
|
|
956
|
+
return ret;
|
|
957
|
+
},
|
|
958
|
+
__wbg___wbindgen_is_object_0beba4a1980d3eea: function(arg0) {
|
|
959
|
+
const val = arg0;
|
|
960
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
961
|
+
return ret;
|
|
962
|
+
},
|
|
963
|
+
__wbg___wbindgen_is_string_1fca8072260dd261: function(arg0) {
|
|
964
|
+
const ret = typeof(arg0) === 'string';
|
|
965
|
+
return ret;
|
|
966
|
+
},
|
|
967
|
+
__wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
|
|
968
|
+
const ret = arg0 === undefined;
|
|
969
|
+
return ret;
|
|
970
|
+
},
|
|
971
|
+
__wbg___wbindgen_jsval_eq_4e8c38722cb8ff51: function(arg0, arg1) {
|
|
972
|
+
const ret = arg0 === arg1;
|
|
973
|
+
return ret;
|
|
974
|
+
},
|
|
975
|
+
__wbg___wbindgen_jsval_loose_eq_4b9aba9e5b3c4582: function(arg0, arg1) {
|
|
976
|
+
const ret = arg0 == arg1;
|
|
977
|
+
return ret;
|
|
978
|
+
},
|
|
979
|
+
__wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
|
|
980
|
+
const obj = arg1;
|
|
981
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
982
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
983
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
984
|
+
},
|
|
985
|
+
__wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
|
|
986
|
+
const obj = arg1;
|
|
987
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
988
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
989
|
+
var len1 = WASM_VECTOR_LEN;
|
|
990
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
991
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
992
|
+
},
|
|
993
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
994
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
995
|
+
},
|
|
996
|
+
__wbg___wbindgen_typeof_fee77315c05833ec: function(arg0) {
|
|
997
|
+
const ret = typeof arg0;
|
|
998
|
+
return ret;
|
|
999
|
+
},
|
|
1000
|
+
__wbg_call_8e98ed2f3c86c4b5: function() { return handleError(function (arg0, arg1) {
|
|
1001
|
+
const ret = arg0.call(arg1);
|
|
1002
|
+
return ret;
|
|
1003
|
+
}, arguments); },
|
|
1004
|
+
__wbg_done_b62d4a7d2286852a: function(arg0) {
|
|
1005
|
+
const ret = arg0.done;
|
|
1006
|
+
return ret;
|
|
1007
|
+
},
|
|
1008
|
+
__wbg_entries_c261c3fa1f281256: function(arg0) {
|
|
1009
|
+
const ret = Object.entries(arg0);
|
|
1010
|
+
return ret;
|
|
1011
|
+
},
|
|
1012
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
1013
|
+
let deferred0_0;
|
|
1014
|
+
let deferred0_1;
|
|
1015
|
+
try {
|
|
1016
|
+
deferred0_0 = arg0;
|
|
1017
|
+
deferred0_1 = arg1;
|
|
1018
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1019
|
+
} finally {
|
|
1020
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1021
|
+
}
|
|
1022
|
+
},
|
|
1023
|
+
__wbg_from_50138b2ca136f50c: function(arg0) {
|
|
1024
|
+
const ret = Array.from(arg0);
|
|
1025
|
+
return ret;
|
|
1026
|
+
},
|
|
1027
|
+
__wbg_getRandomValues_a697888e9ba1eee3: function() { return handleError(function (arg0, arg1) {
|
|
1028
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1029
|
+
}, arguments); },
|
|
1030
|
+
__wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
|
|
1031
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1032
|
+
}, arguments); },
|
|
1033
|
+
__wbg_getTime_7a770f8a2ec8d634: function(arg0) {
|
|
1034
|
+
const ret = arg0.getTime();
|
|
1035
|
+
return ret;
|
|
1036
|
+
},
|
|
1037
|
+
__wbg_get_197a3fe98f169e38: function(arg0, arg1) {
|
|
1038
|
+
const ret = arg0[arg1 >>> 0];
|
|
1039
|
+
return ret;
|
|
1040
|
+
},
|
|
1041
|
+
__wbg_get_9a29be2cb383ed9a: function() { return handleError(function (arg0, arg1) {
|
|
1042
|
+
const ret = Reflect.get(arg0, arg1);
|
|
1043
|
+
return ret;
|
|
1044
|
+
}, arguments); },
|
|
1045
|
+
__wbg_get_dddb90ff5d27a080: function() { return handleError(function (arg0, arg1) {
|
|
1046
|
+
const ret = Reflect.get(arg0, arg1);
|
|
1047
|
+
return ret;
|
|
1048
|
+
}, arguments); },
|
|
1049
|
+
__wbg_get_unchecked_54a4374c38e08460: function(arg0, arg1) {
|
|
1050
|
+
const ret = arg0[arg1 >>> 0];
|
|
1051
|
+
return ret;
|
|
1052
|
+
},
|
|
1053
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
1054
|
+
const ret = arg0[arg1];
|
|
1055
|
+
return ret;
|
|
1056
|
+
},
|
|
1057
|
+
__wbg_instanceof_ArrayBuffer_2a7bb09fee70c2da: function(arg0) {
|
|
1058
|
+
let result;
|
|
1059
|
+
try {
|
|
1060
|
+
result = arg0 instanceof ArrayBuffer;
|
|
1061
|
+
} catch (_) {
|
|
1062
|
+
result = false;
|
|
1063
|
+
}
|
|
1064
|
+
const ret = result;
|
|
1065
|
+
return ret;
|
|
1066
|
+
},
|
|
1067
|
+
__wbg_instanceof_Map_afa18d5840c04c15: function(arg0) {
|
|
1068
|
+
let result;
|
|
1069
|
+
try {
|
|
1070
|
+
result = arg0 instanceof Map;
|
|
1071
|
+
} catch (_) {
|
|
1072
|
+
result = false;
|
|
1073
|
+
}
|
|
1074
|
+
const ret = result;
|
|
1075
|
+
return ret;
|
|
1076
|
+
},
|
|
1077
|
+
__wbg_instanceof_Uint8Array_f080092dc70f5d58: function(arg0) {
|
|
1078
|
+
let result;
|
|
1079
|
+
try {
|
|
1080
|
+
result = arg0 instanceof Uint8Array;
|
|
1081
|
+
} catch (_) {
|
|
1082
|
+
result = false;
|
|
1083
|
+
}
|
|
1084
|
+
const ret = result;
|
|
1085
|
+
return ret;
|
|
1086
|
+
},
|
|
1087
|
+
__wbg_isArray_145a34fd0a38d37b: function(arg0) {
|
|
1088
|
+
const ret = Array.isArray(arg0);
|
|
1089
|
+
return ret;
|
|
1090
|
+
},
|
|
1091
|
+
__wbg_isSafeInteger_a3389a198582f5f6: function(arg0) {
|
|
1092
|
+
const ret = Number.isSafeInteger(arg0);
|
|
1093
|
+
return ret;
|
|
1094
|
+
},
|
|
1095
|
+
__wbg_iterator_cc47ba25a2be735a: function() {
|
|
1096
|
+
const ret = Symbol.iterator;
|
|
1097
|
+
return ret;
|
|
1098
|
+
},
|
|
1099
|
+
__wbg_keys_e2132f5645c137bf: function(arg0) {
|
|
1100
|
+
const ret = Object.keys(arg0);
|
|
1101
|
+
return ret;
|
|
1102
|
+
},
|
|
1103
|
+
__wbg_length_589238bdcf171f0e: function(arg0) {
|
|
1104
|
+
const ret = arg0.length;
|
|
1105
|
+
return ret;
|
|
1106
|
+
},
|
|
1107
|
+
__wbg_length_c6054974c0a6cdb9: function(arg0) {
|
|
1108
|
+
const ret = arg0.length;
|
|
1109
|
+
return ret;
|
|
1110
|
+
},
|
|
1111
|
+
__wbg_new_0_1b32bedde98fef4b: function() {
|
|
1112
|
+
const ret = new Date();
|
|
1113
|
+
return ret;
|
|
1114
|
+
},
|
|
1115
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
1116
|
+
const ret = new Error();
|
|
1117
|
+
return ret;
|
|
1118
|
+
},
|
|
1119
|
+
__wbg_new_2e117a478906f062: function() {
|
|
1120
|
+
const ret = new Object();
|
|
1121
|
+
return ret;
|
|
1122
|
+
},
|
|
1123
|
+
__wbg_new_3444eb7412549f0b: function() {
|
|
1124
|
+
const ret = new Map();
|
|
1125
|
+
return ret;
|
|
1126
|
+
},
|
|
1127
|
+
__wbg_new_36e147a8ced3c6e0: function() {
|
|
1128
|
+
const ret = new Array();
|
|
1129
|
+
return ret;
|
|
1130
|
+
},
|
|
1131
|
+
__wbg_new_81880fb5002cb255: function(arg0) {
|
|
1132
|
+
const ret = new Uint8Array(arg0);
|
|
1133
|
+
return ret;
|
|
1134
|
+
},
|
|
1135
|
+
__wbg_next_0c4066e251d2eff9: function() { return handleError(function (arg0) {
|
|
1136
|
+
const ret = arg0.next();
|
|
1137
|
+
return ret;
|
|
1138
|
+
}, arguments); },
|
|
1139
|
+
__wbg_next_402fa10b59ab20c3: function(arg0) {
|
|
1140
|
+
const ret = arg0.next;
|
|
1141
|
+
return ret;
|
|
1142
|
+
},
|
|
1143
|
+
__wbg_now_ad5c9ea5a44932af: function() { return handleError(function () {
|
|
1144
|
+
const ret = Date.now();
|
|
1145
|
+
return ret;
|
|
1146
|
+
}, arguments); },
|
|
1147
|
+
__wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
|
|
1148
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1149
|
+
},
|
|
1150
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
1151
|
+
arg0[arg1] = arg2;
|
|
1152
|
+
},
|
|
1153
|
+
__wbg_set_9a1d61e17de7054c: function(arg0, arg1, arg2) {
|
|
1154
|
+
const ret = arg0.set(arg1, arg2);
|
|
1155
|
+
return ret;
|
|
1156
|
+
},
|
|
1157
|
+
__wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
|
|
1158
|
+
arg0[arg1 >>> 0] = arg2;
|
|
1159
|
+
},
|
|
1160
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
1161
|
+
const ret = arg1.stack;
|
|
1162
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1163
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1164
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1165
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1166
|
+
},
|
|
1167
|
+
__wbg_value_49f783bb59765962: function(arg0) {
|
|
1168
|
+
const ret = arg0.value;
|
|
1169
|
+
return ret;
|
|
1170
|
+
},
|
|
1171
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
1172
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1173
|
+
const ret = arg0;
|
|
1174
|
+
return ret;
|
|
1175
|
+
},
|
|
1176
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
1177
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
1178
|
+
const ret = arg0;
|
|
1179
|
+
return ret;
|
|
1180
|
+
},
|
|
1181
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1182
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1183
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1184
|
+
return ret;
|
|
1185
|
+
},
|
|
1186
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
1187
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
1188
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1189
|
+
return ret;
|
|
1190
|
+
},
|
|
1191
|
+
__wbindgen_init_externref_table: function() {
|
|
1192
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1193
|
+
const offset = table.grow(4);
|
|
1194
|
+
table.set(0, undefined);
|
|
1195
|
+
table.set(offset + 0, undefined);
|
|
1196
|
+
table.set(offset + 1, null);
|
|
1197
|
+
table.set(offset + 2, true);
|
|
1198
|
+
table.set(offset + 3, false);
|
|
1199
|
+
},
|
|
1200
|
+
};
|
|
1201
|
+
return {
|
|
1202
|
+
__proto__: null,
|
|
1203
|
+
"./tenuo_wasm_bg.js": import0,
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
const SdkContextFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1208
|
+
? { register: () => {}, unregister: () => {} }
|
|
1209
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sdkcontext_free(ptr, 1));
|
|
1210
|
+
const SdkSessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1211
|
+
? { register: () => {}, unregister: () => {} }
|
|
1212
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sdksession_free(ptr, 1));
|
|
1213
|
+
|
|
1214
|
+
function addToExternrefTable0(obj) {
|
|
1215
|
+
const idx = wasm.__externref_table_alloc();
|
|
1216
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1217
|
+
return idx;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
function _assertClass(instance, klass) {
|
|
1221
|
+
if (!(instance instanceof klass)) {
|
|
1222
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
function debugString(val) {
|
|
1227
|
+
// primitive types
|
|
1228
|
+
const type = typeof val;
|
|
1229
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
1230
|
+
return `${val}`;
|
|
1231
|
+
}
|
|
1232
|
+
if (type == 'string') {
|
|
1233
|
+
return `"${val}"`;
|
|
1234
|
+
}
|
|
1235
|
+
if (type == 'symbol') {
|
|
1236
|
+
const description = val.description;
|
|
1237
|
+
if (description == null) {
|
|
1238
|
+
return 'Symbol';
|
|
1239
|
+
} else {
|
|
1240
|
+
return `Symbol(${description})`;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (type == 'function') {
|
|
1244
|
+
const name = val.name;
|
|
1245
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
1246
|
+
return `Function(${name})`;
|
|
1247
|
+
} else {
|
|
1248
|
+
return 'Function';
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
// objects
|
|
1252
|
+
if (Array.isArray(val)) {
|
|
1253
|
+
const length = val.length;
|
|
1254
|
+
let debug = '[';
|
|
1255
|
+
if (length > 0) {
|
|
1256
|
+
debug += debugString(val[0]);
|
|
1257
|
+
}
|
|
1258
|
+
for(let i = 1; i < length; i++) {
|
|
1259
|
+
debug += ', ' + debugString(val[i]);
|
|
1260
|
+
}
|
|
1261
|
+
debug += ']';
|
|
1262
|
+
return debug;
|
|
1263
|
+
}
|
|
1264
|
+
// Test for built-in
|
|
1265
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
1266
|
+
let className;
|
|
1267
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
1268
|
+
className = builtInMatches[1];
|
|
1269
|
+
} else {
|
|
1270
|
+
// Failed to match the standard '[object ClassName]'
|
|
1271
|
+
return toString.call(val);
|
|
1272
|
+
}
|
|
1273
|
+
if (className == 'Object') {
|
|
1274
|
+
// we're a user defined class or Object
|
|
1275
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
1276
|
+
// easier than looping through ownProperties of `val`.
|
|
1277
|
+
try {
|
|
1278
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
1279
|
+
} catch (_) {
|
|
1280
|
+
return 'Object';
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
// errors
|
|
1284
|
+
if (val instanceof Error) {
|
|
1285
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
1286
|
+
}
|
|
1287
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
1288
|
+
return className;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1292
|
+
ptr = ptr >>> 0;
|
|
1293
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
let cachedDataViewMemory0 = null;
|
|
1297
|
+
function getDataViewMemory0() {
|
|
1298
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1299
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1300
|
+
}
|
|
1301
|
+
return cachedDataViewMemory0;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
function getStringFromWasm0(ptr, len) {
|
|
1305
|
+
return decodeText(ptr >>> 0, len);
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1309
|
+
function getUint8ArrayMemory0() {
|
|
1310
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1311
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1312
|
+
}
|
|
1313
|
+
return cachedUint8ArrayMemory0;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function handleError(f, args) {
|
|
1317
|
+
try {
|
|
1318
|
+
return f.apply(this, args);
|
|
1319
|
+
} catch (e) {
|
|
1320
|
+
const idx = addToExternrefTable0(e);
|
|
1321
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
function isLikeNone(x) {
|
|
1326
|
+
return x === undefined || x === null;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1330
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1331
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1332
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1333
|
+
return ptr;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1337
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1338
|
+
for (let i = 0; i < array.length; i++) {
|
|
1339
|
+
const add = addToExternrefTable0(array[i]);
|
|
1340
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1341
|
+
}
|
|
1342
|
+
WASM_VECTOR_LEN = array.length;
|
|
1343
|
+
return ptr;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1347
|
+
if (realloc === undefined) {
|
|
1348
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1349
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1350
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1351
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1352
|
+
return ptr;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
let len = arg.length;
|
|
1356
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1357
|
+
|
|
1358
|
+
const mem = getUint8ArrayMemory0();
|
|
1359
|
+
|
|
1360
|
+
let offset = 0;
|
|
1361
|
+
|
|
1362
|
+
for (; offset < len; offset++) {
|
|
1363
|
+
const code = arg.charCodeAt(offset);
|
|
1364
|
+
if (code > 0x7F) break;
|
|
1365
|
+
mem[ptr + offset] = code;
|
|
1366
|
+
}
|
|
1367
|
+
if (offset !== len) {
|
|
1368
|
+
if (offset !== 0) {
|
|
1369
|
+
arg = arg.slice(offset);
|
|
1370
|
+
}
|
|
1371
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1372
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1373
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1374
|
+
|
|
1375
|
+
offset += ret.written;
|
|
1376
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
WASM_VECTOR_LEN = offset;
|
|
1380
|
+
return ptr;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
function takeFromExternrefTable0(idx) {
|
|
1384
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1385
|
+
wasm.__externref_table_dealloc(idx);
|
|
1386
|
+
return value;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1390
|
+
cachedTextDecoder.decode();
|
|
1391
|
+
function decodeText(ptr, len) {
|
|
1392
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1396
|
+
|
|
1397
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1398
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1399
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1400
|
+
view.set(buf);
|
|
1401
|
+
return {
|
|
1402
|
+
read: arg.length,
|
|
1403
|
+
written: buf.length
|
|
1404
|
+
};
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
let WASM_VECTOR_LEN = 0;
|
|
1409
|
+
|
|
1410
|
+
const wasmPath = `${__dirname}/tenuo_wasm_bg.wasm`;
|
|
1411
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
1412
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
1413
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
1414
|
+
let wasm = wasmInstance.exports;
|
|
1415
|
+
wasm.__wbindgen_start();
|