cojson-core-wasm 0.17.10

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.
@@ -0,0 +1,1280 @@
1
+ let wasm;
2
+
3
+ let WASM_VECTOR_LEN = 0;
4
+
5
+ let cachedUint8ArrayMemory0 = null;
6
+
7
+ function getUint8ArrayMemory0() {
8
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
9
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
10
+ }
11
+ return cachedUint8ArrayMemory0;
12
+ }
13
+
14
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
15
+
16
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
17
+ ? function (arg, view) {
18
+ return cachedTextEncoder.encodeInto(arg, view);
19
+ }
20
+ : function (arg, view) {
21
+ const buf = cachedTextEncoder.encode(arg);
22
+ view.set(buf);
23
+ return {
24
+ read: arg.length,
25
+ written: buf.length
26
+ };
27
+ });
28
+
29
+ function passStringToWasm0(arg, malloc, realloc) {
30
+
31
+ if (realloc === undefined) {
32
+ const buf = cachedTextEncoder.encode(arg);
33
+ const ptr = malloc(buf.length, 1) >>> 0;
34
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
35
+ WASM_VECTOR_LEN = buf.length;
36
+ return ptr;
37
+ }
38
+
39
+ let len = arg.length;
40
+ let ptr = malloc(len, 1) >>> 0;
41
+
42
+ const mem = getUint8ArrayMemory0();
43
+
44
+ let offset = 0;
45
+
46
+ for (; offset < len; offset++) {
47
+ const code = arg.charCodeAt(offset);
48
+ if (code > 0x7F) break;
49
+ mem[ptr + offset] = code;
50
+ }
51
+
52
+ if (offset !== len) {
53
+ if (offset !== 0) {
54
+ arg = arg.slice(offset);
55
+ }
56
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
57
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
58
+ const ret = encodeString(arg, view);
59
+
60
+ offset += ret.written;
61
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
62
+ }
63
+
64
+ WASM_VECTOR_LEN = offset;
65
+ return ptr;
66
+ }
67
+
68
+ let cachedDataViewMemory0 = null;
69
+
70
+ function getDataViewMemory0() {
71
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
72
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
73
+ }
74
+ return cachedDataViewMemory0;
75
+ }
76
+
77
+ function addToExternrefTable0(obj) {
78
+ const idx = wasm.__externref_table_alloc();
79
+ wasm.__wbindgen_export_4.set(idx, obj);
80
+ return idx;
81
+ }
82
+
83
+ function handleError(f, args) {
84
+ try {
85
+ return f.apply(this, args);
86
+ } catch (e) {
87
+ const idx = addToExternrefTable0(e);
88
+ wasm.__wbindgen_exn_store(idx);
89
+ }
90
+ }
91
+
92
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
93
+
94
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
95
+
96
+ function getStringFromWasm0(ptr, len) {
97
+ ptr = ptr >>> 0;
98
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
99
+ }
100
+
101
+ function isLikeNone(x) {
102
+ return x === undefined || x === null;
103
+ }
104
+
105
+ function debugString(val) {
106
+ // primitive types
107
+ const type = typeof val;
108
+ if (type == 'number' || type == 'boolean' || val == null) {
109
+ return `${val}`;
110
+ }
111
+ if (type == 'string') {
112
+ return `"${val}"`;
113
+ }
114
+ if (type == 'symbol') {
115
+ const description = val.description;
116
+ if (description == null) {
117
+ return 'Symbol';
118
+ } else {
119
+ return `Symbol(${description})`;
120
+ }
121
+ }
122
+ if (type == 'function') {
123
+ const name = val.name;
124
+ if (typeof name == 'string' && name.length > 0) {
125
+ return `Function(${name})`;
126
+ } else {
127
+ return 'Function';
128
+ }
129
+ }
130
+ // objects
131
+ if (Array.isArray(val)) {
132
+ const length = val.length;
133
+ let debug = '[';
134
+ if (length > 0) {
135
+ debug += debugString(val[0]);
136
+ }
137
+ for(let i = 1; i < length; i++) {
138
+ debug += ', ' + debugString(val[i]);
139
+ }
140
+ debug += ']';
141
+ return debug;
142
+ }
143
+ // Test for built-in
144
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
145
+ let className;
146
+ if (builtInMatches && builtInMatches.length > 1) {
147
+ className = builtInMatches[1];
148
+ } else {
149
+ // Failed to match the standard '[object ClassName]'
150
+ return toString.call(val);
151
+ }
152
+ if (className == 'Object') {
153
+ // we're a user defined class or Object
154
+ // JSON.stringify avoids problems with cycles, and is generally much
155
+ // easier than looping through ownProperties of `val`.
156
+ try {
157
+ return 'Object(' + JSON.stringify(val) + ')';
158
+ } catch (_) {
159
+ return 'Object';
160
+ }
161
+ }
162
+ // errors
163
+ if (val instanceof Error) {
164
+ return `${val.name}: ${val.message}\n${val.stack}`;
165
+ }
166
+ // TODO we could test for more things here, like `Set`s and `Map`s.
167
+ return className;
168
+ }
169
+
170
+ function passArray8ToWasm0(arg, malloc) {
171
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
172
+ getUint8ArrayMemory0().set(arg, ptr / 1);
173
+ WASM_VECTOR_LEN = arg.length;
174
+ return ptr;
175
+ }
176
+
177
+ function takeFromExternrefTable0(idx) {
178
+ const value = wasm.__wbindgen_export_4.get(idx);
179
+ wasm.__externref_table_dealloc(idx);
180
+ return value;
181
+ }
182
+
183
+ function getArrayU8FromWasm0(ptr, len) {
184
+ ptr = ptr >>> 0;
185
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
186
+ }
187
+ /**
188
+ * WASM-exposed function for XSalsa20 encryption without authentication.
189
+ * - `key`: 32-byte key for encryption
190
+ * - `nonce_material`: Raw bytes used to generate a 24-byte nonce via BLAKE3
191
+ * - `plaintext`: Raw bytes to encrypt
192
+ * Returns the encrypted bytes or throws a JsError if encryption fails.
193
+ * Note: This function does not provide authentication. Use encrypt_xsalsa20_poly1305 for authenticated encryption.
194
+ * @param {Uint8Array} key
195
+ * @param {Uint8Array} nonce_material
196
+ * @param {Uint8Array} plaintext
197
+ * @returns {Uint8Array}
198
+ */
199
+ export function encrypt_xsalsa20(key, nonce_material, plaintext) {
200
+ const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
201
+ const len0 = WASM_VECTOR_LEN;
202
+ const ptr1 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
203
+ const len1 = WASM_VECTOR_LEN;
204
+ const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
205
+ const len2 = WASM_VECTOR_LEN;
206
+ const ret = wasm.encrypt_xsalsa20(ptr0, len0, ptr1, len1, ptr2, len2);
207
+ if (ret[3]) {
208
+ throw takeFromExternrefTable0(ret[2]);
209
+ }
210
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
211
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
212
+ return v4;
213
+ }
214
+
215
+ /**
216
+ * WASM-exposed function for XSalsa20 decryption without authentication.
217
+ * - `key`: 32-byte key for decryption (must match encryption key)
218
+ * - `nonce_material`: Raw bytes used to generate a 24-byte nonce (must match encryption)
219
+ * - `ciphertext`: Encrypted bytes to decrypt
220
+ * Returns the decrypted bytes or throws a JsError if decryption fails.
221
+ * Note: This function does not provide authentication. Use decrypt_xsalsa20_poly1305 for authenticated decryption.
222
+ * @param {Uint8Array} key
223
+ * @param {Uint8Array} nonce_material
224
+ * @param {Uint8Array} ciphertext
225
+ * @returns {Uint8Array}
226
+ */
227
+ export function decrypt_xsalsa20(key, nonce_material, ciphertext) {
228
+ const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
229
+ const len0 = WASM_VECTOR_LEN;
230
+ const ptr1 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
231
+ const len1 = WASM_VECTOR_LEN;
232
+ const ptr2 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
233
+ const len2 = WASM_VECTOR_LEN;
234
+ const ret = wasm.decrypt_xsalsa20(ptr0, len0, ptr1, len1, ptr2, len2);
235
+ if (ret[3]) {
236
+ throw takeFromExternrefTable0(ret[2]);
237
+ }
238
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
239
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
240
+ return v4;
241
+ }
242
+
243
+ function passArrayJsValueToWasm0(array, malloc) {
244
+ const ptr = malloc(array.length * 4, 4) >>> 0;
245
+ for (let i = 0; i < array.length; i++) {
246
+ const add = addToExternrefTable0(array[i]);
247
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
248
+ }
249
+ WASM_VECTOR_LEN = array.length;
250
+ return ptr;
251
+ }
252
+ /**
253
+ * Generate a new Ed25519 signing key using secure random number generation.
254
+ * Returns 32 bytes of raw key material suitable for use with other Ed25519 functions.
255
+ * @returns {Uint8Array}
256
+ */
257
+ export function new_ed25519_signing_key() {
258
+ const ret = wasm.new_ed25519_signing_key();
259
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
260
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
261
+ return v1;
262
+ }
263
+
264
+ /**
265
+ * WASM-exposed function to derive an Ed25519 verifying key from a signing key.
266
+ * - `signing_key`: 32 bytes of signing key material
267
+ * Returns 32 bytes of verifying key material or throws JsError if key is invalid.
268
+ * @param {Uint8Array} signing_key
269
+ * @returns {Uint8Array}
270
+ */
271
+ export function ed25519_verifying_key(signing_key) {
272
+ const ptr0 = passArray8ToWasm0(signing_key, wasm.__wbindgen_malloc);
273
+ const len0 = WASM_VECTOR_LEN;
274
+ const ret = wasm.ed25519_verifying_key(ptr0, len0);
275
+ if (ret[3]) {
276
+ throw takeFromExternrefTable0(ret[2]);
277
+ }
278
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
279
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
280
+ return v2;
281
+ }
282
+
283
+ /**
284
+ * WASM-exposed function to sign a message using Ed25519.
285
+ * - `signing_key`: 32 bytes of signing key material
286
+ * - `message`: Raw bytes to sign
287
+ * Returns 64 bytes of signature material or throws JsError if signing fails.
288
+ * @param {Uint8Array} signing_key
289
+ * @param {Uint8Array} message
290
+ * @returns {Uint8Array}
291
+ */
292
+ export function ed25519_sign(signing_key, message) {
293
+ const ptr0 = passArray8ToWasm0(signing_key, wasm.__wbindgen_malloc);
294
+ const len0 = WASM_VECTOR_LEN;
295
+ const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
296
+ const len1 = WASM_VECTOR_LEN;
297
+ const ret = wasm.ed25519_sign(ptr0, len0, ptr1, len1);
298
+ if (ret[3]) {
299
+ throw takeFromExternrefTable0(ret[2]);
300
+ }
301
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
302
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
303
+ return v3;
304
+ }
305
+
306
+ /**
307
+ * WASM-exposed function to verify an Ed25519 signature.
308
+ * - `verifying_key`: 32 bytes of verifying key material
309
+ * - `message`: Raw bytes that were signed
310
+ * - `signature`: 64 bytes of signature material
311
+ * Returns true if signature is valid, false otherwise, or throws JsError if verification fails.
312
+ * @param {Uint8Array} verifying_key
313
+ * @param {Uint8Array} message
314
+ * @param {Uint8Array} signature
315
+ * @returns {boolean}
316
+ */
317
+ export function ed25519_verify(verifying_key, message, signature) {
318
+ const ptr0 = passArray8ToWasm0(verifying_key, wasm.__wbindgen_malloc);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
321
+ const len1 = WASM_VECTOR_LEN;
322
+ const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
323
+ const len2 = WASM_VECTOR_LEN;
324
+ const ret = wasm.ed25519_verify(ptr0, len0, ptr1, len1, ptr2, len2);
325
+ if (ret[2]) {
326
+ throw takeFromExternrefTable0(ret[1]);
327
+ }
328
+ return ret[0] !== 0;
329
+ }
330
+
331
+ /**
332
+ * WASM-exposed function to validate and copy Ed25519 signing key bytes.
333
+ * - `bytes`: 32 bytes of signing key material to validate
334
+ * Returns the same 32 bytes if valid or throws JsError if invalid.
335
+ * @param {Uint8Array} bytes
336
+ * @returns {Uint8Array}
337
+ */
338
+ export function ed25519_signing_key_from_bytes(bytes) {
339
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
340
+ const len0 = WASM_VECTOR_LEN;
341
+ const ret = wasm.ed25519_signing_key_from_bytes(ptr0, len0);
342
+ if (ret[3]) {
343
+ throw takeFromExternrefTable0(ret[2]);
344
+ }
345
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
346
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
347
+ return v2;
348
+ }
349
+
350
+ /**
351
+ * WASM-exposed function to derive the public key from an Ed25519 signing key.
352
+ * - `signing_key`: 32 bytes of signing key material
353
+ * Returns 32 bytes of public key material or throws JsError if key is invalid.
354
+ * @param {Uint8Array} signing_key
355
+ * @returns {Uint8Array}
356
+ */
357
+ export function ed25519_signing_key_to_public(signing_key) {
358
+ const ptr0 = passArray8ToWasm0(signing_key, wasm.__wbindgen_malloc);
359
+ const len0 = WASM_VECTOR_LEN;
360
+ const ret = wasm.ed25519_signing_key_to_public(ptr0, len0);
361
+ if (ret[3]) {
362
+ throw takeFromExternrefTable0(ret[2]);
363
+ }
364
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
365
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
366
+ return v2;
367
+ }
368
+
369
+ /**
370
+ * WASM-exposed function to sign a message with an Ed25519 signing key.
371
+ * - `signing_key`: 32 bytes of signing key material
372
+ * - `message`: Raw bytes to sign
373
+ * Returns 64 bytes of signature material or throws JsError if signing fails.
374
+ * @param {Uint8Array} signing_key
375
+ * @param {Uint8Array} message
376
+ * @returns {Uint8Array}
377
+ */
378
+ export function ed25519_signing_key_sign(signing_key, message) {
379
+ const ptr0 = passArray8ToWasm0(signing_key, wasm.__wbindgen_malloc);
380
+ const len0 = WASM_VECTOR_LEN;
381
+ const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
382
+ const len1 = WASM_VECTOR_LEN;
383
+ const ret = wasm.ed25519_signing_key_sign(ptr0, len0, ptr1, len1);
384
+ if (ret[3]) {
385
+ throw takeFromExternrefTable0(ret[2]);
386
+ }
387
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
388
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
389
+ return v3;
390
+ }
391
+
392
+ /**
393
+ * WASM-exposed function to validate and copy Ed25519 verifying key bytes.
394
+ * - `bytes`: 32 bytes of verifying key material to validate
395
+ * Returns the same 32 bytes if valid or throws JsError if invalid.
396
+ * @param {Uint8Array} bytes
397
+ * @returns {Uint8Array}
398
+ */
399
+ export function ed25519_verifying_key_from_bytes(bytes) {
400
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
401
+ const len0 = WASM_VECTOR_LEN;
402
+ const ret = wasm.ed25519_verifying_key_from_bytes(ptr0, len0);
403
+ if (ret[3]) {
404
+ throw takeFromExternrefTable0(ret[2]);
405
+ }
406
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
407
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
408
+ return v2;
409
+ }
410
+
411
+ /**
412
+ * WASM-exposed function to validate and copy Ed25519 signature bytes.
413
+ * - `bytes`: 64 bytes of signature material to validate
414
+ * Returns the same 64 bytes if valid or throws JsError if invalid.
415
+ * @param {Uint8Array} bytes
416
+ * @returns {Uint8Array}
417
+ */
418
+ export function ed25519_signature_from_bytes(bytes) {
419
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
420
+ const len0 = WASM_VECTOR_LEN;
421
+ const ret = wasm.ed25519_signature_from_bytes(ptr0, len0);
422
+ if (ret[3]) {
423
+ throw takeFromExternrefTable0(ret[2]);
424
+ }
425
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
426
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
427
+ return v2;
428
+ }
429
+
430
+ /**
431
+ * WASM-exposed function to sign a message using Ed25519.
432
+ * - `message`: Raw bytes to sign
433
+ * - `secret`: Raw Ed25519 signing key bytes
434
+ * Returns base58-encoded signature with "signature_z" prefix or throws JsError if signing fails.
435
+ * @param {Uint8Array} message
436
+ * @param {Uint8Array} secret
437
+ * @returns {string}
438
+ */
439
+ export function sign(message, secret) {
440
+ let deferred4_0;
441
+ let deferred4_1;
442
+ try {
443
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
444
+ const len0 = WASM_VECTOR_LEN;
445
+ const ptr1 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
446
+ const len1 = WASM_VECTOR_LEN;
447
+ const ret = wasm.sign(ptr0, len0, ptr1, len1);
448
+ var ptr3 = ret[0];
449
+ var len3 = ret[1];
450
+ if (ret[3]) {
451
+ ptr3 = 0; len3 = 0;
452
+ throw takeFromExternrefTable0(ret[2]);
453
+ }
454
+ deferred4_0 = ptr3;
455
+ deferred4_1 = len3;
456
+ return getStringFromWasm0(ptr3, len3);
457
+ } finally {
458
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
459
+ }
460
+ }
461
+
462
+ /**
463
+ * WASM-exposed function to verify an Ed25519 signature.
464
+ * - `signature`: Raw signature bytes
465
+ * - `message`: Raw bytes that were signed
466
+ * - `id`: Raw Ed25519 verifying key bytes
467
+ * Returns true if signature is valid, false otherwise, or throws JsError if verification fails.
468
+ * @param {Uint8Array} signature
469
+ * @param {Uint8Array} message
470
+ * @param {Uint8Array} id
471
+ * @returns {boolean}
472
+ */
473
+ export function verify(signature, message, id) {
474
+ const ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
475
+ const len0 = WASM_VECTOR_LEN;
476
+ const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
477
+ const len1 = WASM_VECTOR_LEN;
478
+ const ptr2 = passArray8ToWasm0(id, wasm.__wbindgen_malloc);
479
+ const len2 = WASM_VECTOR_LEN;
480
+ const ret = wasm.verify(ptr0, len0, ptr1, len1, ptr2, len2);
481
+ if (ret[2]) {
482
+ throw takeFromExternrefTable0(ret[1]);
483
+ }
484
+ return ret[0] !== 0;
485
+ }
486
+
487
+ /**
488
+ * WASM-exposed function to derive a signer ID from a signing key.
489
+ * - `secret`: Raw Ed25519 signing key bytes
490
+ * Returns base58-encoded verifying key with "signer_z" prefix or throws JsError if derivation fails.
491
+ * @param {Uint8Array} secret
492
+ * @returns {string}
493
+ */
494
+ export function get_signer_id(secret) {
495
+ let deferred3_0;
496
+ let deferred3_1;
497
+ try {
498
+ const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
499
+ const len0 = WASM_VECTOR_LEN;
500
+ const ret = wasm.get_signer_id(ptr0, len0);
501
+ var ptr2 = ret[0];
502
+ var len2 = ret[1];
503
+ if (ret[3]) {
504
+ ptr2 = 0; len2 = 0;
505
+ throw takeFromExternrefTable0(ret[2]);
506
+ }
507
+ deferred3_0 = ptr2;
508
+ deferred3_1 = len2;
509
+ return getStringFromWasm0(ptr2, len2);
510
+ } finally {
511
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
512
+ }
513
+ }
514
+
515
+ /**
516
+ * Generate a 24-byte nonce from input material using BLAKE3.
517
+ * - `nonce_material`: Raw bytes to derive the nonce from
518
+ * Returns 24 bytes suitable for use as a nonce in cryptographic operations.
519
+ * This function is deterministic - the same input will produce the same nonce.
520
+ * @param {Uint8Array} nonce_material
521
+ * @returns {Uint8Array}
522
+ */
523
+ export function generate_nonce(nonce_material) {
524
+ const ptr0 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
525
+ const len0 = WASM_VECTOR_LEN;
526
+ const ret = wasm.generate_nonce(ptr0, len0);
527
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
528
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
529
+ return v2;
530
+ }
531
+
532
+ /**
533
+ * Hash data once using BLAKE3.
534
+ * - `data`: Raw bytes to hash
535
+ * Returns 32 bytes of hash output.
536
+ * This is the simplest way to compute a BLAKE3 hash of a single piece of data.
537
+ * @param {Uint8Array} data
538
+ * @returns {Uint8Array}
539
+ */
540
+ export function blake3_hash_once(data) {
541
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
542
+ const len0 = WASM_VECTOR_LEN;
543
+ const ret = wasm.blake3_hash_once(ptr0, len0);
544
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
545
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
546
+ return v2;
547
+ }
548
+
549
+ /**
550
+ * Hash data once using BLAKE3 with a context prefix.
551
+ * - `data`: Raw bytes to hash
552
+ * - `context`: Context bytes to prefix to the data
553
+ * Returns 32 bytes of hash output.
554
+ * This is useful for domain separation - the same data hashed with different contexts will produce different outputs.
555
+ * @param {Uint8Array} data
556
+ * @param {Uint8Array} context
557
+ * @returns {Uint8Array}
558
+ */
559
+ export function blake3_hash_once_with_context(data, context) {
560
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
561
+ const len0 = WASM_VECTOR_LEN;
562
+ const ptr1 = passArray8ToWasm0(context, wasm.__wbindgen_malloc);
563
+ const len1 = WASM_VECTOR_LEN;
564
+ const ret = wasm.blake3_hash_once_with_context(ptr0, len0, ptr1, len1);
565
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
566
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
567
+ return v3;
568
+ }
569
+
570
+ /**
571
+ * Get an empty BLAKE3 state for incremental hashing.
572
+ * Returns a new Blake3Hasher instance for incremental hashing.
573
+ * @returns {Blake3Hasher}
574
+ */
575
+ export function blake3_empty_state() {
576
+ const ret = wasm.blake3_empty_state();
577
+ return Blake3Hasher.__wrap(ret);
578
+ }
579
+
580
+ function _assertClass(instance, klass) {
581
+ if (!(instance instanceof klass)) {
582
+ throw new Error(`expected instance of ${klass.name}`);
583
+ }
584
+ }
585
+ /**
586
+ * Update a BLAKE3 state with new data for incremental hashing.
587
+ * - `state`: Current Blake3Hasher instance
588
+ * - `data`: New data to incorporate into the hash
589
+ * Returns the updated Blake3Hasher.
590
+ * @param {Blake3Hasher} state
591
+ * @param {Uint8Array} data
592
+ */
593
+ export function blake3_update_state(state, data) {
594
+ _assertClass(state, Blake3Hasher);
595
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
596
+ const len0 = WASM_VECTOR_LEN;
597
+ wasm.blake3_update_state(state.__wbg_ptr, ptr0, len0);
598
+ }
599
+
600
+ /**
601
+ * Get the final hash from a BLAKE3 state.
602
+ * - `state`: The Blake3Hasher to finalize
603
+ * Returns 32 bytes of hash output.
604
+ * This finalizes an incremental hashing operation.
605
+ * @param {Blake3Hasher} state
606
+ * @returns {Uint8Array}
607
+ */
608
+ export function blake3_digest_for_state(state) {
609
+ _assertClass(state, Blake3Hasher);
610
+ var ptr0 = state.__destroy_into_raw();
611
+ const ret = wasm.blake3_digest_for_state(ptr0);
612
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
613
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
614
+ return v2;
615
+ }
616
+
617
+ /**
618
+ * Generate a new X25519 private key using secure random number generation.
619
+ * Returns 32 bytes of raw key material suitable for use with other X25519 functions.
620
+ * This key can be reused for multiple Diffie-Hellman exchanges.
621
+ * @returns {Uint8Array}
622
+ */
623
+ export function new_x25519_private_key() {
624
+ const ret = wasm.new_x25519_private_key();
625
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
626
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
627
+ return v1;
628
+ }
629
+
630
+ /**
631
+ * WASM-exposed function to derive an X25519 public key from a private key.
632
+ * - `private_key`: 32 bytes of private key material
633
+ * Returns 32 bytes of public key material or throws JsError if key is invalid.
634
+ * @param {Uint8Array} private_key
635
+ * @returns {Uint8Array}
636
+ */
637
+ export function x25519_public_key(private_key) {
638
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
639
+ const len0 = WASM_VECTOR_LEN;
640
+ const ret = wasm.x25519_public_key(ptr0, len0);
641
+ if (ret[3]) {
642
+ throw takeFromExternrefTable0(ret[2]);
643
+ }
644
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
645
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
646
+ return v2;
647
+ }
648
+
649
+ /**
650
+ * WASM-exposed function to perform X25519 Diffie-Hellman key exchange.
651
+ * - `private_key`: 32 bytes of private key material
652
+ * - `public_key`: 32 bytes of public key material
653
+ * Returns 32 bytes of shared secret material or throws JsError if key exchange fails.
654
+ * @param {Uint8Array} private_key
655
+ * @param {Uint8Array} public_key
656
+ * @returns {Uint8Array}
657
+ */
658
+ export function x25519_diffie_hellman(private_key, public_key) {
659
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
660
+ const len0 = WASM_VECTOR_LEN;
661
+ const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
662
+ const len1 = WASM_VECTOR_LEN;
663
+ const ret = wasm.x25519_diffie_hellman(ptr0, len0, ptr1, len1);
664
+ if (ret[3]) {
665
+ throw takeFromExternrefTable0(ret[2]);
666
+ }
667
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
668
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
669
+ return v3;
670
+ }
671
+
672
+ /**
673
+ * WASM-exposed function to derive a sealer ID from a sealer secret.
674
+ * - `secret`: Raw bytes of the sealer secret
675
+ * Returns a base58-encoded sealer ID with "sealer_z" prefix or throws JsError if derivation fails.
676
+ * @param {Uint8Array} secret
677
+ * @returns {string}
678
+ */
679
+ export function get_sealer_id(secret) {
680
+ let deferred3_0;
681
+ let deferred3_1;
682
+ try {
683
+ const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
684
+ const len0 = WASM_VECTOR_LEN;
685
+ const ret = wasm.get_sealer_id(ptr0, len0);
686
+ var ptr2 = ret[0];
687
+ var len2 = ret[1];
688
+ if (ret[3]) {
689
+ ptr2 = 0; len2 = 0;
690
+ throw takeFromExternrefTable0(ret[2]);
691
+ }
692
+ deferred3_0 = ptr2;
693
+ deferred3_1 = len2;
694
+ return getStringFromWasm0(ptr2, len2);
695
+ } finally {
696
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
697
+ }
698
+ }
699
+
700
+ /**
701
+ * WASM-exposed function for sealing a message using X25519 + XSalsa20-Poly1305.
702
+ * Provides authenticated encryption with perfect forward secrecy.
703
+ * - `message`: Raw bytes to seal
704
+ * - `sender_secret`: Base58-encoded sender's private key with "sealerSecret_z" prefix
705
+ * - `recipient_id`: Base58-encoded recipient's public key with "sealer_z" prefix
706
+ * - `nonce_material`: Raw bytes used to generate the nonce
707
+ * Returns sealed bytes or throws JsError if sealing fails.
708
+ * @param {Uint8Array} message
709
+ * @param {string} sender_secret
710
+ * @param {string} recipient_id
711
+ * @param {Uint8Array} nonce_material
712
+ * @returns {Uint8Array}
713
+ */
714
+ export function seal(message, sender_secret, recipient_id, nonce_material) {
715
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
716
+ const len0 = WASM_VECTOR_LEN;
717
+ const ptr1 = passStringToWasm0(sender_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
718
+ const len1 = WASM_VECTOR_LEN;
719
+ const ptr2 = passStringToWasm0(recipient_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
720
+ const len2 = WASM_VECTOR_LEN;
721
+ const ptr3 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
722
+ const len3 = WASM_VECTOR_LEN;
723
+ const ret = wasm.seal(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
724
+ if (ret[3]) {
725
+ throw takeFromExternrefTable0(ret[2]);
726
+ }
727
+ var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
728
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
729
+ return v5;
730
+ }
731
+
732
+ /**
733
+ * WASM-exposed function for unsealing a message using X25519 + XSalsa20-Poly1305.
734
+ * Provides authenticated decryption with perfect forward secrecy.
735
+ * - `sealed_message`: The sealed bytes to decrypt
736
+ * - `recipient_secret`: Base58-encoded recipient's private key with "sealerSecret_z" prefix
737
+ * - `sender_id`: Base58-encoded sender's public key with "sealer_z" prefix
738
+ * - `nonce_material`: Raw bytes used to generate the nonce (must match sealing)
739
+ * Returns unsealed bytes or throws JsError if unsealing fails.
740
+ * @param {Uint8Array} sealed_message
741
+ * @param {string} recipient_secret
742
+ * @param {string} sender_id
743
+ * @param {Uint8Array} nonce_material
744
+ * @returns {Uint8Array}
745
+ */
746
+ export function unseal(sealed_message, recipient_secret, sender_id, nonce_material) {
747
+ const ptr0 = passArray8ToWasm0(sealed_message, wasm.__wbindgen_malloc);
748
+ const len0 = WASM_VECTOR_LEN;
749
+ const ptr1 = passStringToWasm0(recipient_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
750
+ const len1 = WASM_VECTOR_LEN;
751
+ const ptr2 = passStringToWasm0(sender_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
752
+ const len2 = WASM_VECTOR_LEN;
753
+ const ptr3 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
754
+ const len3 = WASM_VECTOR_LEN;
755
+ const ret = wasm.unseal(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
756
+ if (ret[3]) {
757
+ throw takeFromExternrefTable0(ret[2]);
758
+ }
759
+ var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
760
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
761
+ return v5;
762
+ }
763
+
764
+ /**
765
+ * WASM-exposed function to encrypt bytes with a key secret and nonce material.
766
+ * - `value`: The raw bytes to encrypt
767
+ * - `key_secret`: A base58-encoded key secret with "keySecret_z" prefix
768
+ * - `nonce_material`: Raw bytes used to generate the nonce
769
+ * Returns the encrypted bytes or throws a JsError if encryption fails.
770
+ * @param {Uint8Array} value
771
+ * @param {string} key_secret
772
+ * @param {Uint8Array} nonce_material
773
+ * @returns {Uint8Array}
774
+ */
775
+ export function encrypt(value, key_secret, nonce_material) {
776
+ const ptr0 = passArray8ToWasm0(value, wasm.__wbindgen_malloc);
777
+ const len0 = WASM_VECTOR_LEN;
778
+ const ptr1 = passStringToWasm0(key_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
779
+ const len1 = WASM_VECTOR_LEN;
780
+ const ptr2 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
781
+ const len2 = WASM_VECTOR_LEN;
782
+ const ret = wasm.encrypt(ptr0, len0, ptr1, len1, ptr2, len2);
783
+ if (ret[3]) {
784
+ throw takeFromExternrefTable0(ret[2]);
785
+ }
786
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
787
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
788
+ return v4;
789
+ }
790
+
791
+ /**
792
+ * WASM-exposed function to decrypt bytes with a key secret and nonce material.
793
+ * - `ciphertext`: The encrypted bytes to decrypt
794
+ * - `key_secret`: A base58-encoded key secret with "keySecret_z" prefix
795
+ * - `nonce_material`: Raw bytes used to generate the nonce (must match encryption)
796
+ * Returns the decrypted bytes or throws a JsError if decryption fails.
797
+ * @param {Uint8Array} ciphertext
798
+ * @param {string} key_secret
799
+ * @param {Uint8Array} nonce_material
800
+ * @returns {Uint8Array}
801
+ */
802
+ export function decrypt(ciphertext, key_secret, nonce_material) {
803
+ const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
804
+ const len0 = WASM_VECTOR_LEN;
805
+ const ptr1 = passStringToWasm0(key_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
806
+ const len1 = WASM_VECTOR_LEN;
807
+ const ptr2 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
808
+ const len2 = WASM_VECTOR_LEN;
809
+ const ret = wasm.decrypt(ptr0, len0, ptr1, len1, ptr2, len2);
810
+ if (ret[3]) {
811
+ throw takeFromExternrefTable0(ret[2]);
812
+ }
813
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
814
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
815
+ return v4;
816
+ }
817
+
818
+ const Blake3HasherFinalization = (typeof FinalizationRegistry === 'undefined')
819
+ ? { register: () => {}, unregister: () => {} }
820
+ : new FinalizationRegistry(ptr => wasm.__wbg_blake3hasher_free(ptr >>> 0, 1));
821
+
822
+ export class Blake3Hasher {
823
+
824
+ static __wrap(ptr) {
825
+ ptr = ptr >>> 0;
826
+ const obj = Object.create(Blake3Hasher.prototype);
827
+ obj.__wbg_ptr = ptr;
828
+ Blake3HasherFinalization.register(obj, obj.__wbg_ptr, obj);
829
+ return obj;
830
+ }
831
+
832
+ __destroy_into_raw() {
833
+ const ptr = this.__wbg_ptr;
834
+ this.__wbg_ptr = 0;
835
+ Blake3HasherFinalization.unregister(this);
836
+ return ptr;
837
+ }
838
+
839
+ free() {
840
+ const ptr = this.__destroy_into_raw();
841
+ wasm.__wbg_blake3hasher_free(ptr, 0);
842
+ }
843
+ constructor() {
844
+ const ret = wasm.blake3_empty_state();
845
+ this.__wbg_ptr = ret >>> 0;
846
+ Blake3HasherFinalization.register(this, this.__wbg_ptr, this);
847
+ return this;
848
+ }
849
+ /**
850
+ * @param {Uint8Array} data
851
+ */
852
+ update(data) {
853
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
854
+ const len0 = WASM_VECTOR_LEN;
855
+ wasm.blake3_update_state(this.__wbg_ptr, ptr0, len0);
856
+ }
857
+ /**
858
+ * @returns {Uint8Array}
859
+ */
860
+ finalize() {
861
+ const ret = wasm.blake3hasher_finalize(this.__wbg_ptr);
862
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
863
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
864
+ return v1;
865
+ }
866
+ /**
867
+ * @returns {Blake3Hasher}
868
+ */
869
+ clone() {
870
+ const ret = wasm.blake3hasher_clone(this.__wbg_ptr);
871
+ return Blake3Hasher.__wrap(ret);
872
+ }
873
+ }
874
+
875
+ const SessionLogFinalization = (typeof FinalizationRegistry === 'undefined')
876
+ ? { register: () => {}, unregister: () => {} }
877
+ : new FinalizationRegistry(ptr => wasm.__wbg_sessionlog_free(ptr >>> 0, 1));
878
+
879
+ export class SessionLog {
880
+
881
+ static __wrap(ptr) {
882
+ ptr = ptr >>> 0;
883
+ const obj = Object.create(SessionLog.prototype);
884
+ obj.__wbg_ptr = ptr;
885
+ SessionLogFinalization.register(obj, obj.__wbg_ptr, obj);
886
+ return obj;
887
+ }
888
+
889
+ __destroy_into_raw() {
890
+ const ptr = this.__wbg_ptr;
891
+ this.__wbg_ptr = 0;
892
+ SessionLogFinalization.unregister(this);
893
+ return ptr;
894
+ }
895
+
896
+ free() {
897
+ const ptr = this.__destroy_into_raw();
898
+ wasm.__wbg_sessionlog_free(ptr, 0);
899
+ }
900
+ /**
901
+ * @param {string} co_id
902
+ * @param {string} session_id
903
+ * @param {string} signer_id
904
+ */
905
+ constructor(co_id, session_id, signer_id) {
906
+ const ptr0 = passStringToWasm0(co_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
907
+ const len0 = WASM_VECTOR_LEN;
908
+ const ptr1 = passStringToWasm0(session_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
909
+ const len1 = WASM_VECTOR_LEN;
910
+ const ptr2 = passStringToWasm0(signer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
911
+ const len2 = WASM_VECTOR_LEN;
912
+ const ret = wasm.sessionlog_new(ptr0, len0, ptr1, len1, ptr2, len2);
913
+ this.__wbg_ptr = ret >>> 0;
914
+ SessionLogFinalization.register(this, this.__wbg_ptr, this);
915
+ return this;
916
+ }
917
+ /**
918
+ * @returns {SessionLog}
919
+ */
920
+ clone() {
921
+ const ret = wasm.sessionlog_clone(this.__wbg_ptr);
922
+ return SessionLog.__wrap(ret);
923
+ }
924
+ /**
925
+ * @param {string[]} transactions_json
926
+ * @param {string} new_signature_str
927
+ * @param {boolean} skip_verify
928
+ */
929
+ tryAdd(transactions_json, new_signature_str, skip_verify) {
930
+ const ptr0 = passArrayJsValueToWasm0(transactions_json, wasm.__wbindgen_malloc);
931
+ const len0 = WASM_VECTOR_LEN;
932
+ const ptr1 = passStringToWasm0(new_signature_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
933
+ const len1 = WASM_VECTOR_LEN;
934
+ const ret = wasm.sessionlog_tryAdd(this.__wbg_ptr, ptr0, len0, ptr1, len1, skip_verify);
935
+ if (ret[1]) {
936
+ throw takeFromExternrefTable0(ret[0]);
937
+ }
938
+ }
939
+ /**
940
+ * @param {string} changes_json
941
+ * @param {string} signer_secret
942
+ * @param {string} encryption_key
943
+ * @param {string} key_id
944
+ * @param {number} made_at
945
+ * @returns {string}
946
+ */
947
+ addNewPrivateTransaction(changes_json, signer_secret, encryption_key, key_id, made_at) {
948
+ let deferred6_0;
949
+ let deferred6_1;
950
+ try {
951
+ const ptr0 = passStringToWasm0(changes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
952
+ const len0 = WASM_VECTOR_LEN;
953
+ const ptr1 = passStringToWasm0(signer_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
954
+ const len1 = WASM_VECTOR_LEN;
955
+ const ptr2 = passStringToWasm0(encryption_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
956
+ const len2 = WASM_VECTOR_LEN;
957
+ const ptr3 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
958
+ const len3 = WASM_VECTOR_LEN;
959
+ const ret = wasm.sessionlog_addNewPrivateTransaction(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, made_at);
960
+ var ptr5 = ret[0];
961
+ var len5 = ret[1];
962
+ if (ret[3]) {
963
+ ptr5 = 0; len5 = 0;
964
+ throw takeFromExternrefTable0(ret[2]);
965
+ }
966
+ deferred6_0 = ptr5;
967
+ deferred6_1 = len5;
968
+ return getStringFromWasm0(ptr5, len5);
969
+ } finally {
970
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
971
+ }
972
+ }
973
+ /**
974
+ * @param {string} changes_json
975
+ * @param {string} signer_secret
976
+ * @param {number} made_at
977
+ * @returns {string}
978
+ */
979
+ addNewTrustingTransaction(changes_json, signer_secret, made_at) {
980
+ let deferred4_0;
981
+ let deferred4_1;
982
+ try {
983
+ const ptr0 = passStringToWasm0(changes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
984
+ const len0 = WASM_VECTOR_LEN;
985
+ const ptr1 = passStringToWasm0(signer_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
986
+ const len1 = WASM_VECTOR_LEN;
987
+ const ret = wasm.sessionlog_addNewTrustingTransaction(this.__wbg_ptr, ptr0, len0, ptr1, len1, made_at);
988
+ var ptr3 = ret[0];
989
+ var len3 = ret[1];
990
+ if (ret[3]) {
991
+ ptr3 = 0; len3 = 0;
992
+ throw takeFromExternrefTable0(ret[2]);
993
+ }
994
+ deferred4_0 = ptr3;
995
+ deferred4_1 = len3;
996
+ return getStringFromWasm0(ptr3, len3);
997
+ } finally {
998
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
999
+ }
1000
+ }
1001
+ /**
1002
+ * @param {number} tx_index
1003
+ * @param {string} encryption_key
1004
+ * @returns {string}
1005
+ */
1006
+ decryptNextTransactionChangesJson(tx_index, encryption_key) {
1007
+ let deferred3_0;
1008
+ let deferred3_1;
1009
+ try {
1010
+ const ptr0 = passStringToWasm0(encryption_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1011
+ const len0 = WASM_VECTOR_LEN;
1012
+ const ret = wasm.sessionlog_decryptNextTransactionChangesJson(this.__wbg_ptr, tx_index, ptr0, len0);
1013
+ var ptr2 = ret[0];
1014
+ var len2 = ret[1];
1015
+ if (ret[3]) {
1016
+ ptr2 = 0; len2 = 0;
1017
+ throw takeFromExternrefTable0(ret[2]);
1018
+ }
1019
+ deferred3_0 = ptr2;
1020
+ deferred3_1 = len2;
1021
+ return getStringFromWasm0(ptr2, len2);
1022
+ } finally {
1023
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1024
+ }
1025
+ }
1026
+ }
1027
+
1028
+ async function __wbg_load(module, imports) {
1029
+ if (typeof Response === 'function' && module instanceof Response) {
1030
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1031
+ try {
1032
+ return await WebAssembly.instantiateStreaming(module, imports);
1033
+
1034
+ } catch (e) {
1035
+ if (module.headers.get('Content-Type') != 'application/wasm') {
1036
+ 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);
1037
+
1038
+ } else {
1039
+ throw e;
1040
+ }
1041
+ }
1042
+ }
1043
+
1044
+ const bytes = await module.arrayBuffer();
1045
+ return await WebAssembly.instantiate(bytes, imports);
1046
+
1047
+ } else {
1048
+ const instance = await WebAssembly.instantiate(module, imports);
1049
+
1050
+ if (instance instanceof WebAssembly.Instance) {
1051
+ return { instance, module };
1052
+
1053
+ } else {
1054
+ return instance;
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+ function __wbg_get_imports() {
1060
+ const imports = {};
1061
+ imports.wbg = {};
1062
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
1063
+ const ret = String(arg1);
1064
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1065
+ const len1 = WASM_VECTOR_LEN;
1066
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1067
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1068
+ };
1069
+ imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
1070
+ const ret = arg0.buffer;
1071
+ return ret;
1072
+ };
1073
+ imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
1074
+ const ret = arg0.call(arg1);
1075
+ return ret;
1076
+ }, arguments) };
1077
+ imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
1078
+ const ret = arg0.call(arg1, arg2);
1079
+ return ret;
1080
+ }, arguments) };
1081
+ imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
1082
+ const ret = arg0.crypto;
1083
+ return ret;
1084
+ };
1085
+ imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
1086
+ arg0.getRandomValues(arg1);
1087
+ }, arguments) };
1088
+ imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
1089
+ const ret = arg0.msCrypto;
1090
+ return ret;
1091
+ };
1092
+ imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
1093
+ const ret = new Uint8Array(arg0);
1094
+ return ret;
1095
+ };
1096
+ imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
1097
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
1098
+ return ret;
1099
+ };
1100
+ imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
1101
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
1102
+ return ret;
1103
+ };
1104
+ imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
1105
+ const ret = new Uint8Array(arg0 >>> 0);
1106
+ return ret;
1107
+ };
1108
+ imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
1109
+ const ret = arg0.node;
1110
+ return ret;
1111
+ };
1112
+ imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
1113
+ const ret = arg0.process;
1114
+ return ret;
1115
+ };
1116
+ imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
1117
+ arg0.randomFillSync(arg1);
1118
+ }, arguments) };
1119
+ imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
1120
+ const ret = module.require;
1121
+ return ret;
1122
+ }, arguments) };
1123
+ imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
1124
+ arg0.set(arg1, arg2 >>> 0);
1125
+ };
1126
+ imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
1127
+ const ret = typeof global === 'undefined' ? null : global;
1128
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1129
+ };
1130
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
1131
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1132
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1133
+ };
1134
+ imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
1135
+ const ret = typeof self === 'undefined' ? null : self;
1136
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1137
+ };
1138
+ imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
1139
+ const ret = typeof window === 'undefined' ? null : window;
1140
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1141
+ };
1142
+ imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
1143
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1144
+ return ret;
1145
+ };
1146
+ imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
1147
+ const ret = arg0.versions;
1148
+ return ret;
1149
+ };
1150
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
1151
+ const ret = debugString(arg1);
1152
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1153
+ const len1 = WASM_VECTOR_LEN;
1154
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1155
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1156
+ };
1157
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
1158
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1159
+ return ret;
1160
+ };
1161
+ imports.wbg.__wbindgen_init_externref_table = function() {
1162
+ const table = wasm.__wbindgen_export_4;
1163
+ const offset = table.grow(4);
1164
+ table.set(0, undefined);
1165
+ table.set(offset + 0, undefined);
1166
+ table.set(offset + 1, null);
1167
+ table.set(offset + 2, true);
1168
+ table.set(offset + 3, false);
1169
+ ;
1170
+ };
1171
+ imports.wbg.__wbindgen_is_function = function(arg0) {
1172
+ const ret = typeof(arg0) === 'function';
1173
+ return ret;
1174
+ };
1175
+ imports.wbg.__wbindgen_is_object = function(arg0) {
1176
+ const val = arg0;
1177
+ const ret = typeof(val) === 'object' && val !== null;
1178
+ return ret;
1179
+ };
1180
+ imports.wbg.__wbindgen_is_string = function(arg0) {
1181
+ const ret = typeof(arg0) === 'string';
1182
+ return ret;
1183
+ };
1184
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
1185
+ const ret = arg0 === undefined;
1186
+ return ret;
1187
+ };
1188
+ imports.wbg.__wbindgen_memory = function() {
1189
+ const ret = wasm.memory;
1190
+ return ret;
1191
+ };
1192
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
1193
+ const obj = arg1;
1194
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1195
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1196
+ var len1 = WASM_VECTOR_LEN;
1197
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1198
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1199
+ };
1200
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1201
+ const ret = getStringFromWasm0(arg0, arg1);
1202
+ return ret;
1203
+ };
1204
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1205
+ throw new Error(getStringFromWasm0(arg0, arg1));
1206
+ };
1207
+
1208
+ return imports;
1209
+ }
1210
+
1211
+ function __wbg_init_memory(imports, memory) {
1212
+
1213
+ }
1214
+
1215
+ function __wbg_finalize_init(instance, module) {
1216
+ wasm = instance.exports;
1217
+ __wbg_init.__wbindgen_wasm_module = module;
1218
+ cachedDataViewMemory0 = null;
1219
+ cachedUint8ArrayMemory0 = null;
1220
+
1221
+
1222
+ wasm.__wbindgen_start();
1223
+ return wasm;
1224
+ }
1225
+
1226
+ function initSync(module) {
1227
+ if (wasm !== undefined) return wasm;
1228
+
1229
+
1230
+ if (typeof module !== 'undefined') {
1231
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1232
+ ({module} = module)
1233
+ } else {
1234
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1235
+ }
1236
+ }
1237
+
1238
+ const imports = __wbg_get_imports();
1239
+
1240
+ __wbg_init_memory(imports);
1241
+
1242
+ if (!(module instanceof WebAssembly.Module)) {
1243
+ module = new WebAssembly.Module(module);
1244
+ }
1245
+
1246
+ const instance = new WebAssembly.Instance(module, imports);
1247
+
1248
+ return __wbg_finalize_init(instance, module);
1249
+ }
1250
+
1251
+ async function __wbg_init(module_or_path) {
1252
+ if (wasm !== undefined) return wasm;
1253
+
1254
+
1255
+ if (typeof module_or_path !== 'undefined') {
1256
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1257
+ ({module_or_path} = module_or_path)
1258
+ } else {
1259
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1260
+ }
1261
+ }
1262
+
1263
+ if (typeof module_or_path === 'undefined') {
1264
+ throw new Error();
1265
+ }
1266
+ const imports = __wbg_get_imports();
1267
+
1268
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1269
+ module_or_path = fetch(module_or_path);
1270
+ }
1271
+
1272
+ __wbg_init_memory(imports);
1273
+
1274
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1275
+
1276
+ return __wbg_finalize_init(instance, module);
1277
+ }
1278
+
1279
+ export { initSync };
1280
+ export default __wbg_init;