@massalabs/gossip-sdk 0.0.2-dev.20260428143717 → 0.0.2-dev.20260428190031

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.
@@ -1,64 +1,53 @@
1
1
  let wasm;
2
2
 
3
3
  function addToExternrefTable0(obj) {
4
- const idx = wasm.__externref_table_alloc();
5
- wasm.__wbindgen_export_2.set(idx, obj);
6
- return idx;
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_export_2.set(idx, obj);
6
+ return idx;
7
7
  }
8
8
 
9
9
  function handleError(f, args) {
10
- try {
11
- return f.apply(this, args);
12
- } catch (e) {
13
- const idx = addToExternrefTable0(e);
14
- wasm.__wbindgen_exn_store(idx);
15
- }
10
+ try {
11
+ return f.apply(this, args);
12
+ } catch (e) {
13
+ const idx = addToExternrefTable0(e);
14
+ wasm.__wbindgen_exn_store(idx);
15
+ }
16
16
  }
17
17
 
18
18
  let cachedUint8ArrayMemory0 = null;
19
19
 
20
20
  function getUint8ArrayMemory0() {
21
- if (
22
- cachedUint8ArrayMemory0 === null ||
23
- cachedUint8ArrayMemory0.byteLength === 0
24
- ) {
25
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
26
- }
27
- return cachedUint8ArrayMemory0;
21
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
22
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
23
+ }
24
+ return cachedUint8ArrayMemory0;
28
25
  }
29
26
 
30
- let cachedTextDecoder = new TextDecoder('utf-8', {
31
- ignoreBOM: true,
32
- fatal: true,
33
- });
27
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
34
28
 
35
29
  cachedTextDecoder.decode();
36
30
 
37
31
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
38
32
  let numBytesDecoded = 0;
39
33
  function decodeText(ptr, len) {
40
- numBytesDecoded += len;
41
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
42
- cachedTextDecoder = new TextDecoder('utf-8', {
43
- ignoreBOM: true,
44
- fatal: true,
45
- });
46
- cachedTextDecoder.decode();
47
- numBytesDecoded = len;
48
- }
49
- return cachedTextDecoder.decode(
50
- getUint8ArrayMemory0().subarray(ptr, ptr + len)
51
- );
34
+ numBytesDecoded += len;
35
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
36
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
37
+ cachedTextDecoder.decode();
38
+ numBytesDecoded = len;
39
+ }
40
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
52
41
  }
53
42
 
54
43
  function getStringFromWasm0(ptr, len) {
55
- ptr = ptr >>> 0;
56
- return decodeText(ptr, len);
44
+ ptr = ptr >>> 0;
45
+ return decodeText(ptr, len);
57
46
  }
58
47
 
59
48
  function getArrayU8FromWasm0(ptr, len) {
60
- ptr = ptr >>> 0;
61
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
49
+ ptr = ptr >>> 0;
50
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
62
51
  }
63
52
 
64
53
  let WASM_VECTOR_LEN = 0;
@@ -66,95 +55,85 @@ let WASM_VECTOR_LEN = 0;
66
55
  const cachedTextEncoder = new TextEncoder();
67
56
 
68
57
  if (!('encodeInto' in cachedTextEncoder)) {
69
- cachedTextEncoder.encodeInto = function (arg, view) {
70
- const buf = cachedTextEncoder.encode(arg);
71
- view.set(buf);
72
- return {
73
- read: arg.length,
74
- written: buf.length,
75
- };
76
- };
58
+ cachedTextEncoder.encodeInto = function (arg, view) {
59
+ const buf = cachedTextEncoder.encode(arg);
60
+ view.set(buf);
61
+ return {
62
+ read: arg.length,
63
+ written: buf.length
64
+ };
65
+ }
77
66
  }
78
67
 
79
68
  function passStringToWasm0(arg, malloc, realloc) {
80
- if (realloc === undefined) {
81
- const buf = cachedTextEncoder.encode(arg);
82
- const ptr = malloc(buf.length, 1) >>> 0;
83
- getUint8ArrayMemory0()
84
- .subarray(ptr, ptr + buf.length)
85
- .set(buf);
86
- WASM_VECTOR_LEN = buf.length;
87
- return ptr;
88
- }
89
69
 
90
- let len = arg.length;
91
- let ptr = malloc(len, 1) >>> 0;
70
+ if (realloc === undefined) {
71
+ const buf = cachedTextEncoder.encode(arg);
72
+ const ptr = malloc(buf.length, 1) >>> 0;
73
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
74
+ WASM_VECTOR_LEN = buf.length;
75
+ return ptr;
76
+ }
92
77
 
93
- const mem = getUint8ArrayMemory0();
78
+ let len = arg.length;
79
+ let ptr = malloc(len, 1) >>> 0;
94
80
 
95
- let offset = 0;
81
+ const mem = getUint8ArrayMemory0();
96
82
 
97
- for (; offset < len; offset++) {
98
- const code = arg.charCodeAt(offset);
99
- if (code > 0x7f) break;
100
- mem[ptr + offset] = code;
101
- }
83
+ let offset = 0;
102
84
 
103
- if (offset !== len) {
104
- if (offset !== 0) {
105
- arg = arg.slice(offset);
85
+ for (; offset < len; offset++) {
86
+ const code = arg.charCodeAt(offset);
87
+ if (code > 0x7F) break;
88
+ mem[ptr + offset] = code;
106
89
  }
107
- ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
108
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
109
- const ret = cachedTextEncoder.encodeInto(arg, view);
110
90
 
111
- offset += ret.written;
112
- ptr = realloc(ptr, len, offset, 1) >>> 0;
113
- }
91
+ if (offset !== len) {
92
+ if (offset !== 0) {
93
+ arg = arg.slice(offset);
94
+ }
95
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
96
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
97
+ const ret = cachedTextEncoder.encodeInto(arg, view);
98
+
99
+ offset += ret.written;
100
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
101
+ }
114
102
 
115
- WASM_VECTOR_LEN = offset;
116
- return ptr;
103
+ WASM_VECTOR_LEN = offset;
104
+ return ptr;
117
105
  }
118
106
 
119
107
  let cachedDataViewMemory0 = null;
120
108
 
121
109
  function getDataViewMemory0() {
122
- if (
123
- cachedDataViewMemory0 === null ||
124
- cachedDataViewMemory0.buffer.detached === true ||
125
- (cachedDataViewMemory0.buffer.detached === undefined &&
126
- cachedDataViewMemory0.buffer !== wasm.memory.buffer)
127
- ) {
128
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
129
- }
130
- return cachedDataViewMemory0;
110
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
111
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
112
+ }
113
+ return cachedDataViewMemory0;
131
114
  }
132
115
 
133
116
  function isLikeNone(x) {
134
- return x === undefined || x === null;
117
+ return x === undefined || x === null;
135
118
  }
136
119
 
137
120
  function passArray8ToWasm0(arg, malloc) {
138
- const ptr = malloc(arg.length * 1, 1) >>> 0;
139
- getUint8ArrayMemory0().set(arg, ptr / 1);
140
- WASM_VECTOR_LEN = arg.length;
141
- return ptr;
121
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
122
+ getUint8ArrayMemory0().set(arg, ptr / 1);
123
+ WASM_VECTOR_LEN = arg.length;
124
+ return ptr;
142
125
  }
143
126
 
144
127
  function takeFromExternrefTable0(idx) {
145
- const value = wasm.__wbindgen_export_2.get(idx);
146
- wasm.__externref_table_dealloc(idx);
147
- return value;
148
- }
149
-
150
- export function start() {
151
- wasm.start();
128
+ const value = wasm.__wbindgen_export_2.get(idx);
129
+ wasm.__externref_table_dealloc(idx);
130
+ return value;
152
131
  }
153
132
 
154
133
  function _assertClass(instance, klass) {
155
- if (!(instance instanceof klass)) {
156
- throw new Error(`expected instance of ${klass.name}`);
157
- }
134
+ if (!(instance instanceof klass)) {
135
+ throw new Error(`expected instance of ${klass.name}`);
136
+ }
158
137
  }
159
138
  /**
160
139
  * Encrypts data using AES-256-SIV authenticated encryption.
@@ -194,23 +173,16 @@ function _assertClass(instance, klass) {
194
173
  * @returns {Uint8Array}
195
174
  */
196
175
  export function aead_encrypt(key, nonce, plaintext, aad) {
197
- _assertClass(key, EncryptionKey);
198
- _assertClass(nonce, Nonce);
199
- const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
200
- const len0 = WASM_VECTOR_LEN;
201
- const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
202
- const len1 = WASM_VECTOR_LEN;
203
- const ret = wasm.aead_encrypt(
204
- key.__wbg_ptr,
205
- nonce.__wbg_ptr,
206
- ptr0,
207
- len0,
208
- ptr1,
209
- len1
210
- );
211
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
212
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
213
- return v3;
176
+ _assertClass(key, EncryptionKey);
177
+ _assertClass(nonce, Nonce);
178
+ const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
179
+ const len0 = WASM_VECTOR_LEN;
180
+ const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
181
+ const len1 = WASM_VECTOR_LEN;
182
+ const ret = wasm.aead_encrypt(key.__wbg_ptr, nonce.__wbg_ptr, ptr0, len0, ptr1, len1);
183
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
184
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
185
+ return v3;
214
186
  }
215
187
 
216
188
  /**
@@ -222,17 +194,17 @@ export function aead_encrypt(key, nonce, plaintext, aad) {
222
194
  * @returns {UserKeys}
223
195
  */
224
196
  export function generate_user_keys(passphrase) {
225
- const ptr0 = passStringToWasm0(
226
- passphrase,
227
- wasm.__wbindgen_malloc,
228
- wasm.__wbindgen_realloc
229
- );
230
- const len0 = WASM_VECTOR_LEN;
231
- const ret = wasm.generate_user_keys(ptr0, len0);
232
- if (ret[2]) {
233
- throw takeFromExternrefTable0(ret[1]);
234
- }
235
- return UserKeys.__wrap(ret[0]);
197
+ const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
198
+ const len0 = WASM_VECTOR_LEN;
199
+ const ret = wasm.generate_user_keys(ptr0, len0);
200
+ if (ret[2]) {
201
+ throw takeFromExternrefTable0(ret[1]);
202
+ }
203
+ return UserKeys.__wrap(ret[0]);
204
+ }
205
+
206
+ export function start() {
207
+ wasm.start();
236
208
  }
237
209
 
238
210
  /**
@@ -274,26 +246,19 @@ export function generate_user_keys(passphrase) {
274
246
  * @returns {Uint8Array | undefined}
275
247
  */
276
248
  export function aead_decrypt(key, nonce, ciphertext, aad) {
277
- _assertClass(key, EncryptionKey);
278
- _assertClass(nonce, Nonce);
279
- const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
280
- const len0 = WASM_VECTOR_LEN;
281
- const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
282
- const len1 = WASM_VECTOR_LEN;
283
- const ret = wasm.aead_decrypt(
284
- key.__wbg_ptr,
285
- nonce.__wbg_ptr,
286
- ptr0,
287
- len0,
288
- ptr1,
289
- len1
290
- );
291
- let v3;
292
- if (ret[0] !== 0) {
293
- v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
294
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
295
- }
296
- return v3;
249
+ _assertClass(key, EncryptionKey);
250
+ _assertClass(nonce, Nonce);
251
+ const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
252
+ const len0 = WASM_VECTOR_LEN;
253
+ const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
254
+ const len1 = WASM_VECTOR_LEN;
255
+ const ret = wasm.aead_decrypt(key.__wbg_ptr, nonce.__wbg_ptr, ptr0, len0, ptr1, len1);
256
+ let v3;
257
+ if (ret[0] !== 0) {
258
+ v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
259
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
260
+ }
261
+ return v3;
297
262
  }
298
263
 
299
264
  /**
@@ -301,178 +266,159 @@ export function aead_decrypt(key, nonce, ciphertext, aad) {
301
266
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
302
267
  */
303
268
  export const SessionStatus = Object.freeze({
304
- Active: 0,
305
- 0: 'Active',
306
- UnknownPeer: 1,
307
- 1: 'UnknownPeer',
308
- NoSession: 2,
309
- 2: 'NoSession',
310
- PeerRequested: 3,
311
- 3: 'PeerRequested',
312
- SelfRequested: 4,
313
- 4: 'SelfRequested',
314
- Killed: 5,
315
- 5: 'Killed',
316
- Saturated: 6,
317
- 6: 'Saturated',
269
+ Active: 0, "0": "Active",
270
+ UnknownPeer: 1, "1": "UnknownPeer",
271
+ NoSession: 2, "2": "NoSession",
272
+ PeerRequested: 3, "3": "PeerRequested",
273
+ SelfRequested: 4, "4": "SelfRequested",
274
+ Killed: 5, "5": "Killed",
275
+ Saturated: 6, "6": "Saturated",
318
276
  });
319
277
 
320
- const AnnouncementResultFinalization =
321
- typeof FinalizationRegistry === 'undefined'
278
+ const AnnouncementResultFinalization = (typeof FinalizationRegistry === 'undefined')
322
279
  ? { register: () => {}, unregister: () => {} }
323
- : new FinalizationRegistry(ptr =>
324
- wasm.__wbg_announcementresult_free(ptr >>> 0, 1)
325
- );
280
+ : new FinalizationRegistry(ptr => wasm.__wbg_announcementresult_free(ptr >>> 0, 1));
326
281
  /**
327
282
  * Result from feeding an incoming announcement.
328
283
  */
329
284
  export class AnnouncementResult {
330
- static __wrap(ptr) {
331
- ptr = ptr >>> 0;
332
- const obj = Object.create(AnnouncementResult.prototype);
333
- obj.__wbg_ptr = ptr;
334
- AnnouncementResultFinalization.register(obj, obj.__wbg_ptr, obj);
335
- return obj;
336
- }
337
-
338
- __destroy_into_raw() {
339
- const ptr = this.__wbg_ptr;
340
- this.__wbg_ptr = 0;
341
- AnnouncementResultFinalization.unregister(this);
342
- return ptr;
343
- }
344
-
345
- free() {
346
- const ptr = this.__destroy_into_raw();
347
- wasm.__wbg_announcementresult_free(ptr, 0);
348
- }
349
- /**
350
- * Gets the announcer's public keys.
351
- * @returns {UserPublicKeys}
352
- */
353
- get announcer_public_keys() {
354
- const ret = wasm.announcementresult_announcer_public_keys(this.__wbg_ptr);
355
- return UserPublicKeys.__wrap(ret);
356
- }
357
- /**
358
- * Gets the announcement timestamp in milliseconds since Unix epoch.
359
- * @returns {number}
360
- */
361
- get timestamp() {
362
- const ret = wasm.announcementresult_timestamp(this.__wbg_ptr);
363
- return ret;
364
- }
365
- /**
366
- * Gets the user data embedded in the announcement.
367
- * @returns {Uint8Array}
368
- */
369
- get user_data() {
370
- const ret = wasm.announcementresult_user_data(this.__wbg_ptr);
371
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
372
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
373
- return v1;
374
- }
285
+
286
+ static __wrap(ptr) {
287
+ ptr = ptr >>> 0;
288
+ const obj = Object.create(AnnouncementResult.prototype);
289
+ obj.__wbg_ptr = ptr;
290
+ AnnouncementResultFinalization.register(obj, obj.__wbg_ptr, obj);
291
+ return obj;
292
+ }
293
+
294
+ __destroy_into_raw() {
295
+ const ptr = this.__wbg_ptr;
296
+ this.__wbg_ptr = 0;
297
+ AnnouncementResultFinalization.unregister(this);
298
+ return ptr;
299
+ }
300
+
301
+ free() {
302
+ const ptr = this.__destroy_into_raw();
303
+ wasm.__wbg_announcementresult_free(ptr, 0);
304
+ }
305
+ /**
306
+ * Gets the announcer's public keys.
307
+ * @returns {UserPublicKeys}
308
+ */
309
+ get announcer_public_keys() {
310
+ const ret = wasm.announcementresult_announcer_public_keys(this.__wbg_ptr);
311
+ return UserPublicKeys.__wrap(ret);
312
+ }
313
+ /**
314
+ * Gets the announcement timestamp in milliseconds since Unix epoch.
315
+ * @returns {number}
316
+ */
317
+ get timestamp() {
318
+ const ret = wasm.announcementresult_timestamp(this.__wbg_ptr);
319
+ return ret;
320
+ }
321
+ /**
322
+ * Gets the user data embedded in the announcement.
323
+ * @returns {Uint8Array}
324
+ */
325
+ get user_data() {
326
+ const ret = wasm.announcementresult_user_data(this.__wbg_ptr);
327
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
328
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
329
+ return v1;
330
+ }
375
331
  }
376
- if (Symbol.dispose)
377
- AnnouncementResult.prototype[Symbol.dispose] =
378
- AnnouncementResult.prototype.free;
332
+ if (Symbol.dispose) AnnouncementResult.prototype[Symbol.dispose] = AnnouncementResult.prototype.free;
379
333
 
380
- const EncryptionKeyFinalization =
381
- typeof FinalizationRegistry === 'undefined'
334
+ const EncryptionKeyFinalization = (typeof FinalizationRegistry === 'undefined')
382
335
  ? { register: () => {}, unregister: () => {} }
383
- : new FinalizationRegistry(ptr =>
384
- wasm.__wbg_encryptionkey_free(ptr >>> 0, 1)
385
- );
336
+ : new FinalizationRegistry(ptr => wasm.__wbg_encryptionkey_free(ptr >>> 0, 1));
386
337
  /**
387
338
  * Encryption key for AEAD operations (AES-256-SIV).
388
339
  *
389
340
  * AES-256-SIV uses a 64-byte (512-bit) key: two 256-bit keys for encryption and MAC.
390
341
  */
391
342
  export class EncryptionKey {
392
- static __wrap(ptr) {
393
- ptr = ptr >>> 0;
394
- const obj = Object.create(EncryptionKey.prototype);
395
- obj.__wbg_ptr = ptr;
396
- EncryptionKeyFinalization.register(obj, obj.__wbg_ptr, obj);
397
- return obj;
398
- }
399
-
400
- __destroy_into_raw() {
401
- const ptr = this.__wbg_ptr;
402
- this.__wbg_ptr = 0;
403
- EncryptionKeyFinalization.unregister(this);
404
- return ptr;
405
- }
406
-
407
- free() {
408
- const ptr = this.__destroy_into_raw();
409
- wasm.__wbg_encryptionkey_free(ptr, 0);
410
- }
411
- /**
412
- * Creates an encryption key from raw bytes (must be 64 bytes).
413
- * @param {Uint8Array} bytes
414
- * @returns {EncryptionKey}
415
- */
416
- static from_bytes(bytes) {
417
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
418
- const len0 = WASM_VECTOR_LEN;
419
- const ret = wasm.encryptionkey_from_bytes(ptr0, len0);
420
- if (ret[2]) {
421
- throw takeFromExternrefTable0(ret[1]);
422
- }
423
- return EncryptionKey.__wrap(ret[0]);
424
- }
425
- /**
426
- * Generates a new random encryption key (64 bytes).
427
- * @returns {EncryptionKey}
428
- */
429
- static generate() {
430
- const ret = wasm.encryptionkey_generate();
431
- return EncryptionKey.__wrap(ret);
432
- }
433
- /**
434
- * Gets the raw bytes of the encryption key.
435
- * @returns {Uint8Array}
436
- */
437
- to_bytes() {
438
- const ret = wasm.encryptionkey_to_bytes(this.__wbg_ptr);
439
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
440
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
441
- return v1;
442
- }
443
- /**
444
- * Generates a deterministic encryption key (64 bytes) from a seed and salt.
445
- *
446
- * Uses Argon2id via `crypto_password_kdf` to derive a 64-byte key suitable for
447
- * AES-256-SIV (which requires 64 bytes: 2×256-bit keys).
448
- *
449
- * - `seed`: application-provided seed string (treat like a password)
450
- * - `salt`: unique, random salt (minimum 8 bytes, recommended 16+ bytes)
451
- * @param {string} seed
452
- * @param {Uint8Array} salt
453
- * @returns {EncryptionKey}
454
- */
455
- static from_seed(seed, salt) {
456
- const ptr0 = passStringToWasm0(
457
- seed,
458
- wasm.__wbindgen_malloc,
459
- wasm.__wbindgen_realloc
460
- );
461
- const len0 = WASM_VECTOR_LEN;
462
- const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
463
- const len1 = WASM_VECTOR_LEN;
464
- const ret = wasm.encryptionkey_from_seed(ptr0, len0, ptr1, len1);
465
- if (ret[2]) {
466
- throw takeFromExternrefTable0(ret[1]);
343
+
344
+ static __wrap(ptr) {
345
+ ptr = ptr >>> 0;
346
+ const obj = Object.create(EncryptionKey.prototype);
347
+ obj.__wbg_ptr = ptr;
348
+ EncryptionKeyFinalization.register(obj, obj.__wbg_ptr, obj);
349
+ return obj;
350
+ }
351
+
352
+ __destroy_into_raw() {
353
+ const ptr = this.__wbg_ptr;
354
+ this.__wbg_ptr = 0;
355
+ EncryptionKeyFinalization.unregister(this);
356
+ return ptr;
357
+ }
358
+
359
+ free() {
360
+ const ptr = this.__destroy_into_raw();
361
+ wasm.__wbg_encryptionkey_free(ptr, 0);
362
+ }
363
+ /**
364
+ * Creates an encryption key from raw bytes (must be 64 bytes).
365
+ * @param {Uint8Array} bytes
366
+ * @returns {EncryptionKey}
367
+ */
368
+ static from_bytes(bytes) {
369
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
370
+ const len0 = WASM_VECTOR_LEN;
371
+ const ret = wasm.encryptionkey_from_bytes(ptr0, len0);
372
+ if (ret[2]) {
373
+ throw takeFromExternrefTable0(ret[1]);
374
+ }
375
+ return EncryptionKey.__wrap(ret[0]);
376
+ }
377
+ /**
378
+ * Generates a new random encryption key (64 bytes).
379
+ * @returns {EncryptionKey}
380
+ */
381
+ static generate() {
382
+ const ret = wasm.encryptionkey_generate();
383
+ return EncryptionKey.__wrap(ret);
384
+ }
385
+ /**
386
+ * Gets the raw bytes of the encryption key.
387
+ * @returns {Uint8Array}
388
+ */
389
+ to_bytes() {
390
+ const ret = wasm.encryptionkey_to_bytes(this.__wbg_ptr);
391
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
392
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
393
+ return v1;
394
+ }
395
+ /**
396
+ * Generates a deterministic encryption key (64 bytes) from a seed and salt.
397
+ *
398
+ * Uses Argon2id via `crypto_password_kdf` to derive a 64-byte key suitable for
399
+ * AES-256-SIV (which requires 64 bytes: 2×256-bit keys).
400
+ *
401
+ * - `seed`: application-provided seed string (treat like a password)
402
+ * - `salt`: unique, random salt (minimum 8 bytes, recommended 16+ bytes)
403
+ * @param {string} seed
404
+ * @param {Uint8Array} salt
405
+ * @returns {EncryptionKey}
406
+ */
407
+ static from_seed(seed, salt) {
408
+ const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
409
+ const len0 = WASM_VECTOR_LEN;
410
+ const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
411
+ const len1 = WASM_VECTOR_LEN;
412
+ const ret = wasm.encryptionkey_from_seed(ptr0, len0, ptr1, len1);
413
+ if (ret[2]) {
414
+ throw takeFromExternrefTable0(ret[1]);
415
+ }
416
+ return EncryptionKey.__wrap(ret[0]);
467
417
  }
468
- return EncryptionKey.__wrap(ret[0]);
469
- }
470
418
  }
471
- if (Symbol.dispose)
472
- EncryptionKey.prototype[Symbol.dispose] = EncryptionKey.prototype.free;
419
+ if (Symbol.dispose) EncryptionKey.prototype[Symbol.dispose] = EncryptionKey.prototype.free;
473
420
 
474
- const NonceFinalization =
475
- typeof FinalizationRegistry === 'undefined'
421
+ const NonceFinalization = (typeof FinalizationRegistry === 'undefined')
476
422
  ? { register: () => {}, unregister: () => {} }
477
423
  : new FinalizationRegistry(ptr => wasm.__wbg_nonce_free(ptr >>> 0, 1));
478
424
  /**
@@ -482,1134 +428,1029 @@ const NonceFinalization =
482
428
  * per encryption for maximum security, though SIV mode is nonce-misuse resistant.
483
429
  */
484
430
  export class Nonce {
485
- static __wrap(ptr) {
486
- ptr = ptr >>> 0;
487
- const obj = Object.create(Nonce.prototype);
488
- obj.__wbg_ptr = ptr;
489
- NonceFinalization.register(obj, obj.__wbg_ptr, obj);
490
- return obj;
491
- }
492
-
493
- __destroy_into_raw() {
494
- const ptr = this.__wbg_ptr;
495
- this.__wbg_ptr = 0;
496
- NonceFinalization.unregister(this);
497
- return ptr;
498
- }
499
-
500
- free() {
501
- const ptr = this.__destroy_into_raw();
502
- wasm.__wbg_nonce_free(ptr, 0);
503
- }
504
- /**
505
- * Creates a nonce from raw bytes (must be 16 bytes).
506
- * @param {Uint8Array} bytes
507
- * @returns {Nonce}
508
- */
509
- static from_bytes(bytes) {
510
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
511
- const len0 = WASM_VECTOR_LEN;
512
- const ret = wasm.nonce_from_bytes(ptr0, len0);
513
- if (ret[2]) {
514
- throw takeFromExternrefTable0(ret[1]);
515
- }
516
- return Nonce.__wrap(ret[0]);
517
- }
518
- /**
519
- * Generates a new random nonce (16 bytes).
520
- * @returns {Nonce}
521
- */
522
- static generate() {
523
- const ret = wasm.nonce_generate();
524
- return Nonce.__wrap(ret);
525
- }
526
- /**
527
- * Gets the raw bytes of the nonce.
528
- * @returns {Uint8Array}
529
- */
530
- to_bytes() {
531
- const ret = wasm.nonce_to_bytes(this.__wbg_ptr);
532
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
533
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
534
- return v1;
535
- }
431
+
432
+ static __wrap(ptr) {
433
+ ptr = ptr >>> 0;
434
+ const obj = Object.create(Nonce.prototype);
435
+ obj.__wbg_ptr = ptr;
436
+ NonceFinalization.register(obj, obj.__wbg_ptr, obj);
437
+ return obj;
438
+ }
439
+
440
+ __destroy_into_raw() {
441
+ const ptr = this.__wbg_ptr;
442
+ this.__wbg_ptr = 0;
443
+ NonceFinalization.unregister(this);
444
+ return ptr;
445
+ }
446
+
447
+ free() {
448
+ const ptr = this.__destroy_into_raw();
449
+ wasm.__wbg_nonce_free(ptr, 0);
450
+ }
451
+ /**
452
+ * Creates a nonce from raw bytes (must be 16 bytes).
453
+ * @param {Uint8Array} bytes
454
+ * @returns {Nonce}
455
+ */
456
+ static from_bytes(bytes) {
457
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
458
+ const len0 = WASM_VECTOR_LEN;
459
+ const ret = wasm.nonce_from_bytes(ptr0, len0);
460
+ if (ret[2]) {
461
+ throw takeFromExternrefTable0(ret[1]);
462
+ }
463
+ return Nonce.__wrap(ret[0]);
464
+ }
465
+ /**
466
+ * Generates a new random nonce (16 bytes).
467
+ * @returns {Nonce}
468
+ */
469
+ static generate() {
470
+ const ret = wasm.nonce_generate();
471
+ return Nonce.__wrap(ret);
472
+ }
473
+ /**
474
+ * Gets the raw bytes of the nonce.
475
+ * @returns {Uint8Array}
476
+ */
477
+ to_bytes() {
478
+ const ret = wasm.nonce_to_bytes(this.__wbg_ptr);
479
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
480
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
481
+ return v1;
482
+ }
536
483
  }
537
484
  if (Symbol.dispose) Nonce.prototype[Symbol.dispose] = Nonce.prototype.free;
538
485
 
539
- const ReceiveMessageOutputFinalization =
540
- typeof FinalizationRegistry === 'undefined'
486
+ const ReceiveMessageOutputFinalization = (typeof FinalizationRegistry === 'undefined')
541
487
  ? { register: () => {}, unregister: () => {} }
542
- : new FinalizationRegistry(ptr =>
543
- wasm.__wbg_receivemessageoutput_free(ptr >>> 0, 1)
544
- );
488
+ : new FinalizationRegistry(ptr => wasm.__wbg_receivemessageoutput_free(ptr >>> 0, 1));
545
489
  /**
546
490
  * Output from receiving a message.
547
491
  */
548
492
  export class ReceiveMessageOutput {
549
- static __wrap(ptr) {
550
- ptr = ptr >>> 0;
551
- const obj = Object.create(ReceiveMessageOutput.prototype);
552
- obj.__wbg_ptr = ptr;
553
- ReceiveMessageOutputFinalization.register(obj, obj.__wbg_ptr, obj);
554
- return obj;
555
- }
556
-
557
- __destroy_into_raw() {
558
- const ptr = this.__wbg_ptr;
559
- this.__wbg_ptr = 0;
560
- ReceiveMessageOutputFinalization.unregister(this);
561
- return ptr;
562
- }
563
-
564
- free() {
565
- const ptr = this.__destroy_into_raw();
566
- wasm.__wbg_receivemessageoutput_free(ptr, 0);
567
- }
568
- /**
569
- * Gets the list of newly acknowledged seekers.
570
- * @returns {Array<any>}
571
- */
572
- get acknowledged_seekers() {
573
- const ret = wasm.receivemessageoutput_acknowledged_seekers(this.__wbg_ptr);
574
- return ret;
575
- }
576
- /**
577
- * Gets the received message contents.
578
- * @returns {Uint8Array}
579
- */
580
- get message() {
581
- const ret = wasm.receivemessageoutput_message(this.__wbg_ptr);
582
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
583
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
584
- return v1;
585
- }
586
- /**
587
- * Gets the sender's user id (32 bytes).
588
- * @returns {Uint8Array}
589
- */
590
- get user_id() {
591
- const ret = wasm.receivemessageoutput_user_id(this.__wbg_ptr);
592
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
593
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
594
- return v1;
595
- }
596
- /**
597
- * Gets the message timestamp (milliseconds since Unix epoch).
598
- * @returns {number}
599
- */
600
- get timestamp() {
601
- const ret = wasm.receivemessageoutput_timestamp(this.__wbg_ptr);
602
- return ret;
603
- }
493
+
494
+ static __wrap(ptr) {
495
+ ptr = ptr >>> 0;
496
+ const obj = Object.create(ReceiveMessageOutput.prototype);
497
+ obj.__wbg_ptr = ptr;
498
+ ReceiveMessageOutputFinalization.register(obj, obj.__wbg_ptr, obj);
499
+ return obj;
500
+ }
501
+
502
+ __destroy_into_raw() {
503
+ const ptr = this.__wbg_ptr;
504
+ this.__wbg_ptr = 0;
505
+ ReceiveMessageOutputFinalization.unregister(this);
506
+ return ptr;
507
+ }
508
+
509
+ free() {
510
+ const ptr = this.__destroy_into_raw();
511
+ wasm.__wbg_receivemessageoutput_free(ptr, 0);
512
+ }
513
+ /**
514
+ * Gets the list of newly acknowledged seekers.
515
+ * @returns {Array<any>}
516
+ */
517
+ get acknowledged_seekers() {
518
+ const ret = wasm.receivemessageoutput_acknowledged_seekers(this.__wbg_ptr);
519
+ return ret;
520
+ }
521
+ /**
522
+ * Gets the received message contents.
523
+ * @returns {Uint8Array}
524
+ */
525
+ get message() {
526
+ const ret = wasm.receivemessageoutput_message(this.__wbg_ptr);
527
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
528
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
529
+ return v1;
530
+ }
531
+ /**
532
+ * Gets the sender's user id (32 bytes).
533
+ * @returns {Uint8Array}
534
+ */
535
+ get user_id() {
536
+ const ret = wasm.receivemessageoutput_user_id(this.__wbg_ptr);
537
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
538
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
539
+ return v1;
540
+ }
541
+ /**
542
+ * Gets the message timestamp (milliseconds since Unix epoch).
543
+ * @returns {number}
544
+ */
545
+ get timestamp() {
546
+ const ret = wasm.receivemessageoutput_timestamp(this.__wbg_ptr);
547
+ return ret;
548
+ }
604
549
  }
605
- if (Symbol.dispose)
606
- ReceiveMessageOutput.prototype[Symbol.dispose] =
607
- ReceiveMessageOutput.prototype.free;
550
+ if (Symbol.dispose) ReceiveMessageOutput.prototype[Symbol.dispose] = ReceiveMessageOutput.prototype.free;
608
551
 
609
- const SendMessageOutputFinalization =
610
- typeof FinalizationRegistry === 'undefined'
552
+ const SendMessageOutputFinalization = (typeof FinalizationRegistry === 'undefined')
611
553
  ? { register: () => {}, unregister: () => {} }
612
- : new FinalizationRegistry(ptr =>
613
- wasm.__wbg_sendmessageoutput_free(ptr >>> 0, 1)
614
- );
554
+ : new FinalizationRegistry(ptr => wasm.__wbg_sendmessageoutput_free(ptr >>> 0, 1));
615
555
  /**
616
556
  * Output from sending a message.
617
557
  */
618
558
  export class SendMessageOutput {
619
- static __wrap(ptr) {
620
- ptr = ptr >>> 0;
621
- const obj = Object.create(SendMessageOutput.prototype);
622
- obj.__wbg_ptr = ptr;
623
- SendMessageOutputFinalization.register(obj, obj.__wbg_ptr, obj);
624
- return obj;
625
- }
626
-
627
- __destroy_into_raw() {
628
- const ptr = this.__wbg_ptr;
629
- this.__wbg_ptr = 0;
630
- SendMessageOutputFinalization.unregister(this);
631
- return ptr;
632
- }
633
-
634
- free() {
635
- const ptr = this.__destroy_into_raw();
636
- wasm.__wbg_sendmessageoutput_free(ptr, 0);
637
- }
638
- /**
639
- * Gets the encrypted message data.
640
- * @returns {Uint8Array}
641
- */
642
- get data() {
643
- const ret = wasm.sendmessageoutput_data(this.__wbg_ptr);
644
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
645
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
646
- return v1;
647
- }
648
- /**
649
- * Gets the seeker (identifier for message board lookup).
650
- * @returns {Uint8Array}
651
- */
652
- get seeker() {
653
- const ret = wasm.sendmessageoutput_seeker(this.__wbg_ptr);
654
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
655
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
656
- return v1;
657
- }
559
+
560
+ static __wrap(ptr) {
561
+ ptr = ptr >>> 0;
562
+ const obj = Object.create(SendMessageOutput.prototype);
563
+ obj.__wbg_ptr = ptr;
564
+ SendMessageOutputFinalization.register(obj, obj.__wbg_ptr, obj);
565
+ return obj;
566
+ }
567
+
568
+ __destroy_into_raw() {
569
+ const ptr = this.__wbg_ptr;
570
+ this.__wbg_ptr = 0;
571
+ SendMessageOutputFinalization.unregister(this);
572
+ return ptr;
573
+ }
574
+
575
+ free() {
576
+ const ptr = this.__destroy_into_raw();
577
+ wasm.__wbg_sendmessageoutput_free(ptr, 0);
578
+ }
579
+ /**
580
+ * Gets the encrypted message data.
581
+ * @returns {Uint8Array}
582
+ */
583
+ get data() {
584
+ const ret = wasm.sendmessageoutput_data(this.__wbg_ptr);
585
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
586
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
587
+ return v1;
588
+ }
589
+ /**
590
+ * Gets the seeker (identifier for message board lookup).
591
+ * @returns {Uint8Array}
592
+ */
593
+ get seeker() {
594
+ const ret = wasm.sendmessageoutput_seeker(this.__wbg_ptr);
595
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
596
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
597
+ return v1;
598
+ }
658
599
  }
659
- if (Symbol.dispose)
660
- SendMessageOutput.prototype[Symbol.dispose] =
661
- SendMessageOutput.prototype.free;
600
+ if (Symbol.dispose) SendMessageOutput.prototype[Symbol.dispose] = SendMessageOutput.prototype.free;
662
601
 
663
- const SessionConfigFinalization =
664
- typeof FinalizationRegistry === 'undefined'
602
+ const SessionConfigFinalization = (typeof FinalizationRegistry === 'undefined')
665
603
  ? { register: () => {}, unregister: () => {} }
666
- : new FinalizationRegistry(ptr =>
667
- wasm.__wbg_sessionconfig_free(ptr >>> 0, 1)
668
- );
604
+ : new FinalizationRegistry(ptr => wasm.__wbg_sessionconfig_free(ptr >>> 0, 1));
669
605
  /**
670
606
  * Session manager configuration for controlling session behavior.
671
607
  */
672
608
  export class SessionConfig {
673
- static __wrap(ptr) {
674
- ptr = ptr >>> 0;
675
- const obj = Object.create(SessionConfig.prototype);
676
- obj.__wbg_ptr = ptr;
677
- SessionConfigFinalization.register(obj, obj.__wbg_ptr, obj);
678
- return obj;
679
- }
680
-
681
- __destroy_into_raw() {
682
- const ptr = this.__wbg_ptr;
683
- this.__wbg_ptr = 0;
684
- SessionConfigFinalization.unregister(this);
685
- return ptr;
686
- }
687
-
688
- free() {
689
- const ptr = this.__destroy_into_raw();
690
- wasm.__wbg_sessionconfig_free(ptr, 0);
691
- }
692
- /**
693
- * Creates a default configuration with sensible defaults:
694
- * - Announcement age: 1 week
695
- * - Announcement future: 1 minute
696
- * - Message age: 1 week
697
- * - Message future: 1 minute
698
- * - Session inactivity: 1 week
699
- * - Keep-alive interval: 1 day
700
- * - Max lag: 10000 messages
701
- * - Max peer lag before keep-alive: 8 messages
702
- * @returns {SessionConfig}
703
- */
704
- static new_default() {
705
- const ret = wasm.sessionconfig_new_default();
706
- return SessionConfig.__wrap(ret);
707
- }
708
- /**
709
- * Creates a new session configuration with the given parameters.
710
- * @param {number} max_incoming_announcement_age_millis
711
- * @param {number} max_incoming_announcement_future_millis
712
- * @param {number} max_incoming_message_age_millis
713
- * @param {number} max_incoming_message_future_millis
714
- * @param {number} max_session_inactivity_millis
715
- * @param {number} keep_alive_interval_millis
716
- * @param {bigint} max_session_lag_length
717
- * @param {bigint} max_keep_alive_peer_lag_length
718
- */
719
- constructor(
720
- max_incoming_announcement_age_millis,
721
- max_incoming_announcement_future_millis,
722
- max_incoming_message_age_millis,
723
- max_incoming_message_future_millis,
724
- max_session_inactivity_millis,
725
- keep_alive_interval_millis,
726
- max_session_lag_length,
727
- max_keep_alive_peer_lag_length
728
- ) {
729
- const ret = wasm.sessionconfig_new(
730
- max_incoming_announcement_age_millis,
731
- max_incoming_announcement_future_millis,
732
- max_incoming_message_age_millis,
733
- max_incoming_message_future_millis,
734
- max_session_inactivity_millis,
735
- keep_alive_interval_millis,
736
- max_session_lag_length,
737
- max_keep_alive_peer_lag_length
738
- );
739
- this.__wbg_ptr = ret >>> 0;
740
- SessionConfigFinalization.register(this, this.__wbg_ptr, this);
741
- return this;
742
- }
609
+
610
+ static __wrap(ptr) {
611
+ ptr = ptr >>> 0;
612
+ const obj = Object.create(SessionConfig.prototype);
613
+ obj.__wbg_ptr = ptr;
614
+ SessionConfigFinalization.register(obj, obj.__wbg_ptr, obj);
615
+ return obj;
616
+ }
617
+
618
+ __destroy_into_raw() {
619
+ const ptr = this.__wbg_ptr;
620
+ this.__wbg_ptr = 0;
621
+ SessionConfigFinalization.unregister(this);
622
+ return ptr;
623
+ }
624
+
625
+ free() {
626
+ const ptr = this.__destroy_into_raw();
627
+ wasm.__wbg_sessionconfig_free(ptr, 0);
628
+ }
629
+ /**
630
+ * Creates a default configuration with sensible defaults:
631
+ * - Announcement age: 1 week
632
+ * - Announcement future: 1 minute
633
+ * - Message age: 1 week
634
+ * - Message future: 1 minute
635
+ * - Session inactivity: 1 week
636
+ * - Keep-alive interval: 1 day
637
+ * - Max lag: 10000 messages
638
+ * - Max peer lag before keep-alive: 8 messages
639
+ * @returns {SessionConfig}
640
+ */
641
+ static new_default() {
642
+ const ret = wasm.sessionconfig_new_default();
643
+ return SessionConfig.__wrap(ret);
644
+ }
645
+ /**
646
+ * Creates a new session configuration with the given parameters.
647
+ * @param {number} max_incoming_announcement_age_millis
648
+ * @param {number} max_incoming_announcement_future_millis
649
+ * @param {number} max_incoming_message_age_millis
650
+ * @param {number} max_incoming_message_future_millis
651
+ * @param {number} max_session_inactivity_millis
652
+ * @param {number} keep_alive_interval_millis
653
+ * @param {bigint} max_session_lag_length
654
+ * @param {bigint} max_keep_alive_peer_lag_length
655
+ */
656
+ constructor(max_incoming_announcement_age_millis, max_incoming_announcement_future_millis, max_incoming_message_age_millis, max_incoming_message_future_millis, max_session_inactivity_millis, keep_alive_interval_millis, max_session_lag_length, max_keep_alive_peer_lag_length) {
657
+ const ret = wasm.sessionconfig_new(max_incoming_announcement_age_millis, max_incoming_announcement_future_millis, max_incoming_message_age_millis, max_incoming_message_future_millis, max_session_inactivity_millis, keep_alive_interval_millis, max_session_lag_length, max_keep_alive_peer_lag_length);
658
+ this.__wbg_ptr = ret >>> 0;
659
+ SessionConfigFinalization.register(this, this.__wbg_ptr, this);
660
+ return this;
661
+ }
743
662
  }
744
- if (Symbol.dispose)
745
- SessionConfig.prototype[Symbol.dispose] = SessionConfig.prototype.free;
663
+ if (Symbol.dispose) SessionConfig.prototype[Symbol.dispose] = SessionConfig.prototype.free;
746
664
 
747
- const SessionManagerWrapperFinalization =
748
- typeof FinalizationRegistry === 'undefined'
665
+ const SessionManagerWrapperFinalization = (typeof FinalizationRegistry === 'undefined')
749
666
  ? { register: () => {}, unregister: () => {} }
750
- : new FinalizationRegistry(ptr =>
751
- wasm.__wbg_sessionmanagerwrapper_free(ptr >>> 0, 1)
752
- );
667
+ : new FinalizationRegistry(ptr => wasm.__wbg_sessionmanagerwrapper_free(ptr >>> 0, 1));
753
668
  /**
754
669
  * Session manager wrapper for WebAssembly.
755
670
  */
756
671
  export class SessionManagerWrapper {
757
- static __wrap(ptr) {
758
- ptr = ptr >>> 0;
759
- const obj = Object.create(SessionManagerWrapper.prototype);
760
- obj.__wbg_ptr = ptr;
761
- SessionManagerWrapperFinalization.register(obj, obj.__wbg_ptr, obj);
762
- return obj;
763
- }
764
-
765
- __destroy_into_raw() {
766
- const ptr = this.__wbg_ptr;
767
- this.__wbg_ptr = 0;
768
- SessionManagerWrapperFinalization.unregister(this);
769
- return ptr;
770
- }
771
-
772
- free() {
773
- const ptr = this.__destroy_into_raw();
774
- wasm.__wbg_sessionmanagerwrapper_free(ptr, 0);
775
- }
776
- /**
777
- * Discards a peer and all associated session state.
778
- * @param {Uint8Array} peer_id
779
- */
780
- peer_discard(peer_id) {
781
- const ptr0 = passArray8ToWasm0(peer_id, wasm.__wbindgen_malloc);
782
- const len0 = WASM_VECTOR_LEN;
783
- const ret = wasm.sessionmanagerwrapper_peer_discard(
784
- this.__wbg_ptr,
785
- ptr0,
786
- len0
787
- );
788
- if (ret[1]) {
789
- throw takeFromExternrefTable0(ret[0]);
790
- }
791
- }
792
- /**
793
- * Sends a message to a peer.
794
- * @param {Uint8Array} peer_id
795
- * @param {Uint8Array} message_contents
796
- * @returns {SendMessageOutput | undefined}
797
- */
798
- send_message(peer_id, message_contents) {
799
- const ptr0 = passArray8ToWasm0(peer_id, wasm.__wbindgen_malloc);
800
- const len0 = WASM_VECTOR_LEN;
801
- const ptr1 = passArray8ToWasm0(message_contents, wasm.__wbindgen_malloc);
802
- const len1 = WASM_VECTOR_LEN;
803
- const ret = wasm.sessionmanagerwrapper_send_message(
804
- this.__wbg_ptr,
805
- ptr0,
806
- len0,
807
- ptr1,
808
- len1
809
- );
810
- if (ret[2]) {
811
- throw takeFromExternrefTable0(ret[1]);
812
- }
813
- return ret[0] === 0 ? undefined : SendMessageOutput.__wrap(ret[0]);
814
- }
815
- /**
816
- * Serializes and encrypts the session manager into a blob.
817
- * @param {EncryptionKey} key
818
- * @returns {Uint8Array}
819
- */
820
- to_encrypted_blob(key) {
821
- _assertClass(key, EncryptionKey);
822
- const ret = wasm.sessionmanagerwrapper_to_encrypted_blob(
823
- this.__wbg_ptr,
824
- key.__wbg_ptr
825
- );
826
- if (ret[3]) {
827
- throw takeFromExternrefTable0(ret[2]);
828
- }
829
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
830
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
831
- return v1;
832
- }
833
- /**
834
- * Deserializes a session manager from an encrypted blob.
835
- * @param {Uint8Array} encrypted_blob
836
- * @param {EncryptionKey} key
837
- * @returns {SessionManagerWrapper}
838
- */
839
- static from_encrypted_blob(encrypted_blob, key) {
840
- const ptr0 = passArray8ToWasm0(encrypted_blob, wasm.__wbindgen_malloc);
841
- const len0 = WASM_VECTOR_LEN;
842
- _assertClass(key, EncryptionKey);
843
- const ret = wasm.sessionmanagerwrapper_from_encrypted_blob(
844
- ptr0,
845
- len0,
846
- key.__wbg_ptr
847
- );
848
- if (ret[2]) {
849
- throw takeFromExternrefTable0(ret[1]);
850
- }
851
- return SessionManagerWrapper.__wrap(ret[0]);
852
- }
853
- /**
854
- * Gets the session status for a peer.
855
- * @param {Uint8Array} peer_id
856
- * @returns {SessionStatus}
857
- */
858
- peer_session_status(peer_id) {
859
- const ptr0 = passArray8ToWasm0(peer_id, wasm.__wbindgen_malloc);
860
- const len0 = WASM_VECTOR_LEN;
861
- const ret = wasm.sessionmanagerwrapper_peer_session_status(
862
- this.__wbg_ptr,
863
- ptr0,
864
- len0
865
- );
866
- if (ret[2]) {
867
- throw takeFromExternrefTable0(ret[1]);
868
- }
869
- return ret[0];
870
- }
871
- /**
872
- * Establishes an outgoing session with a peer.
873
- *
874
- * # Parameters
875
- *
876
- * - `peer_pk`: The peer's public keys
877
- * - `our_pk`: Our public keys
878
- * - `our_sk`: Our secret keys
879
- * - `user_data`: Arbitrary user data to include in the announcement (can be empty)
880
- *
881
- * # Security Warning
882
- *
883
- * **The user_data in announcements has reduced security compared to regular messages:**
884
- * - ✅ **Plausible deniability preserved**: The user_data is not cryptographically signed,
885
- * so you can deny having sent specific user_data content (though you cannot deny the
886
- * announcement itself).
887
- * - ❌ **No post-compromise secrecy**: If your long-term keys are compromised in the
888
- * future, past announcements (including their user_data) can be decrypted.
889
- *
890
- * **Recommendation**: Avoid including highly sensitive information in user_data. Use it for
891
- * metadata like protocol version, public display names, or capability flags. Send truly
892
- * sensitive data through regular messages after the session is established.
893
- *
894
- * # Returns
895
- *
896
- * The announcement bytes to publish to the blockchain.
897
- * @param {UserPublicKeys} peer_pk
898
- * @param {UserPublicKeys} our_pk
899
- * @param {UserSecretKeys} our_sk
900
- * @param {Uint8Array} user_data
901
- * @returns {Uint8Array}
902
- */
903
- establish_outgoing_session(peer_pk, our_pk, our_sk, user_data) {
904
- _assertClass(peer_pk, UserPublicKeys);
905
- _assertClass(our_pk, UserPublicKeys);
906
- _assertClass(our_sk, UserSecretKeys);
907
- const ptr0 = passArray8ToWasm0(user_data, wasm.__wbindgen_malloc);
908
- const len0 = WASM_VECTOR_LEN;
909
- const ret = wasm.sessionmanagerwrapper_establish_outgoing_session(
910
- this.__wbg_ptr,
911
- peer_pk.__wbg_ptr,
912
- our_pk.__wbg_ptr,
913
- our_sk.__wbg_ptr,
914
- ptr0,
915
- len0
916
- );
917
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
918
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
919
- return v2;
920
- }
921
- /**
922
- * Feeds an incoming announcement from the blockchain.
923
- *
924
- * # Parameters
925
- *
926
- * - `announcement_bytes`: The raw announcement bytes received from the blockchain
927
- * - `our_pk`: Our public keys
928
- * - `our_sk`: Our secret keys
929
- *
930
- * # Returns
931
- *
932
- * If the announcement is valid, returns an `AnnouncementResult` containing:
933
- * - The announcer's public keys
934
- * - The timestamp when the announcement was created (milliseconds since Unix epoch)
935
- * - The user data embedded in the announcement
936
- *
937
- * Returns `None` if the announcement is invalid or too old.
938
- *
939
- * # Security Warning
940
- *
941
- * **The user_data in announcements has reduced security compared to regular messages:**
942
- * - ✅ **Plausible deniability preserved**: The user_data is not cryptographically signed,
943
- * so the sender can deny having sent specific user_data content (though they cannot deny
944
- * the announcement itself).
945
- * - ❌ **No post-compromise secrecy**: If the sender's long-term keys are compromised
946
- * in the future, all past announcements (including their user_data) can be decrypted.
947
- *
948
- * **Recommendation**: Treat user_data as having limited confidentiality. Use it for
949
- * metadata that is not highly sensitive. Send truly sensitive information through regular
950
- * messages after the session is established.
951
- * @param {Uint8Array} announcement_bytes
952
- * @param {UserPublicKeys} our_pk
953
- * @param {UserSecretKeys} our_sk
954
- * @returns {AnnouncementResult | undefined}
955
- */
956
- feed_incoming_announcement(announcement_bytes, our_pk, our_sk) {
957
- const ptr0 = passArray8ToWasm0(announcement_bytes, wasm.__wbindgen_malloc);
958
- const len0 = WASM_VECTOR_LEN;
959
- _assertClass(our_pk, UserPublicKeys);
960
- _assertClass(our_sk, UserSecretKeys);
961
- const ret = wasm.sessionmanagerwrapper_feed_incoming_announcement(
962
- this.__wbg_ptr,
963
- ptr0,
964
- len0,
965
- our_pk.__wbg_ptr,
966
- our_sk.__wbg_ptr
967
- );
968
- return ret === 0 ? undefined : AnnouncementResult.__wrap(ret);
969
- }
970
- /**
971
- * Gets the list of message board seekers to monitor.
972
- * @returns {Array<any>}
973
- */
974
- get_message_board_read_keys() {
975
- const ret = wasm.sessionmanagerwrapper_get_message_board_read_keys(
976
- this.__wbg_ptr
977
- );
978
- return ret;
979
- }
980
- /**
981
- * Processes an incoming message from the message board.
982
- * @param {Uint8Array} seeker
983
- * @param {Uint8Array} ciphertext
984
- * @param {UserSecretKeys} our_sk
985
- * @returns {ReceiveMessageOutput | undefined}
986
- */
987
- feed_incoming_message_board_read(seeker, ciphertext, our_sk) {
988
- const ptr0 = passArray8ToWasm0(seeker, wasm.__wbindgen_malloc);
989
- const len0 = WASM_VECTOR_LEN;
990
- const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
991
- const len1 = WASM_VECTOR_LEN;
992
- _assertClass(our_sk, UserSecretKeys);
993
- const ret = wasm.sessionmanagerwrapper_feed_incoming_message_board_read(
994
- this.__wbg_ptr,
995
- ptr0,
996
- len0,
997
- ptr1,
998
- len1,
999
- our_sk.__wbg_ptr
1000
- );
1001
- return ret === 0 ? undefined : ReceiveMessageOutput.__wrap(ret);
1002
- }
1003
- /**
1004
- * Creates a new session manager with the given configuration.
1005
- * @param {SessionConfig} config
1006
- */
1007
- constructor(config) {
1008
- _assertClass(config, SessionConfig);
1009
- var ptr0 = config.__destroy_into_raw();
1010
- const ret = wasm.sessionmanagerwrapper_new(ptr0);
1011
- this.__wbg_ptr = ret >>> 0;
1012
- SessionManagerWrapperFinalization.register(this, this.__wbg_ptr, this);
1013
- return this;
1014
- }
1015
- /**
1016
- * Refreshes sessions and returns peer IDs that need keep-alive messages.
1017
- * @returns {Array<any>}
1018
- */
1019
- refresh() {
1020
- const ret = wasm.sessionmanagerwrapper_refresh(this.__wbg_ptr);
1021
- return ret;
1022
- }
1023
- /**
1024
- * Gets the list of all peer IDs.
1025
- * @returns {Array<any>}
1026
- */
1027
- peer_list() {
1028
- const ret = wasm.sessionmanagerwrapper_peer_list(this.__wbg_ptr);
1029
- return ret;
1030
- }
672
+
673
+ static __wrap(ptr) {
674
+ ptr = ptr >>> 0;
675
+ const obj = Object.create(SessionManagerWrapper.prototype);
676
+ obj.__wbg_ptr = ptr;
677
+ SessionManagerWrapperFinalization.register(obj, obj.__wbg_ptr, obj);
678
+ return obj;
679
+ }
680
+
681
+ __destroy_into_raw() {
682
+ const ptr = this.__wbg_ptr;
683
+ this.__wbg_ptr = 0;
684
+ SessionManagerWrapperFinalization.unregister(this);
685
+ return ptr;
686
+ }
687
+
688
+ free() {
689
+ const ptr = this.__destroy_into_raw();
690
+ wasm.__wbg_sessionmanagerwrapper_free(ptr, 0);
691
+ }
692
+ /**
693
+ * Discards a peer and all associated session state.
694
+ * @param {Uint8Array} peer_id
695
+ */
696
+ peer_discard(peer_id) {
697
+ const ptr0 = passArray8ToWasm0(peer_id, wasm.__wbindgen_malloc);
698
+ const len0 = WASM_VECTOR_LEN;
699
+ const ret = wasm.sessionmanagerwrapper_peer_discard(this.__wbg_ptr, ptr0, len0);
700
+ if (ret[1]) {
701
+ throw takeFromExternrefTable0(ret[0]);
702
+ }
703
+ }
704
+ /**
705
+ * Sends a message to a peer.
706
+ * @param {Uint8Array} peer_id
707
+ * @param {Uint8Array} message_contents
708
+ * @returns {SendMessageOutput | undefined}
709
+ */
710
+ send_message(peer_id, message_contents) {
711
+ const ptr0 = passArray8ToWasm0(peer_id, wasm.__wbindgen_malloc);
712
+ const len0 = WASM_VECTOR_LEN;
713
+ const ptr1 = passArray8ToWasm0(message_contents, wasm.__wbindgen_malloc);
714
+ const len1 = WASM_VECTOR_LEN;
715
+ const ret = wasm.sessionmanagerwrapper_send_message(this.__wbg_ptr, ptr0, len0, ptr1, len1);
716
+ if (ret[2]) {
717
+ throw takeFromExternrefTable0(ret[1]);
718
+ }
719
+ return ret[0] === 0 ? undefined : SendMessageOutput.__wrap(ret[0]);
720
+ }
721
+ /**
722
+ * Serializes and encrypts the session manager into a blob.
723
+ * @param {EncryptionKey} key
724
+ * @returns {Uint8Array}
725
+ */
726
+ to_encrypted_blob(key) {
727
+ _assertClass(key, EncryptionKey);
728
+ const ret = wasm.sessionmanagerwrapper_to_encrypted_blob(this.__wbg_ptr, key.__wbg_ptr);
729
+ if (ret[3]) {
730
+ throw takeFromExternrefTable0(ret[2]);
731
+ }
732
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
733
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
734
+ return v1;
735
+ }
736
+ /**
737
+ * Deserializes a session manager from an encrypted blob.
738
+ * @param {Uint8Array} encrypted_blob
739
+ * @param {EncryptionKey} key
740
+ * @returns {SessionManagerWrapper}
741
+ */
742
+ static from_encrypted_blob(encrypted_blob, key) {
743
+ const ptr0 = passArray8ToWasm0(encrypted_blob, wasm.__wbindgen_malloc);
744
+ const len0 = WASM_VECTOR_LEN;
745
+ _assertClass(key, EncryptionKey);
746
+ const ret = wasm.sessionmanagerwrapper_from_encrypted_blob(ptr0, len0, key.__wbg_ptr);
747
+ if (ret[2]) {
748
+ throw takeFromExternrefTable0(ret[1]);
749
+ }
750
+ return SessionManagerWrapper.__wrap(ret[0]);
751
+ }
752
+ /**
753
+ * Gets the session status for a peer.
754
+ * @param {Uint8Array} peer_id
755
+ * @returns {SessionStatus}
756
+ */
757
+ peer_session_status(peer_id) {
758
+ const ptr0 = passArray8ToWasm0(peer_id, wasm.__wbindgen_malloc);
759
+ const len0 = WASM_VECTOR_LEN;
760
+ const ret = wasm.sessionmanagerwrapper_peer_session_status(this.__wbg_ptr, ptr0, len0);
761
+ if (ret[2]) {
762
+ throw takeFromExternrefTable0(ret[1]);
763
+ }
764
+ return ret[0];
765
+ }
766
+ /**
767
+ * Establishes an outgoing session with a peer.
768
+ *
769
+ * # Parameters
770
+ *
771
+ * - `peer_pk`: The peer's public keys
772
+ * - `our_pk`: Our public keys
773
+ * - `our_sk`: Our secret keys
774
+ * - `user_data`: Arbitrary user data to include in the announcement (can be empty)
775
+ *
776
+ * # Security Warning
777
+ *
778
+ * **The user_data in announcements has reduced security compared to regular messages:**
779
+ * - ✅ **Plausible deniability preserved**: The user_data is not cryptographically signed,
780
+ * so you can deny having sent specific user_data content (though you cannot deny the
781
+ * announcement itself).
782
+ * - ❌ **No post-compromise secrecy**: If your long-term keys are compromised in the
783
+ * future, past announcements (including their user_data) can be decrypted.
784
+ *
785
+ * **Recommendation**: Avoid including highly sensitive information in user_data. Use it for
786
+ * metadata like protocol version, public display names, or capability flags. Send truly
787
+ * sensitive data through regular messages after the session is established.
788
+ *
789
+ * # Returns
790
+ *
791
+ * The announcement bytes to publish to the blockchain.
792
+ * @param {UserPublicKeys} peer_pk
793
+ * @param {UserPublicKeys} our_pk
794
+ * @param {UserSecretKeys} our_sk
795
+ * @param {Uint8Array} user_data
796
+ * @returns {Uint8Array}
797
+ */
798
+ establish_outgoing_session(peer_pk, our_pk, our_sk, user_data) {
799
+ _assertClass(peer_pk, UserPublicKeys);
800
+ _assertClass(our_pk, UserPublicKeys);
801
+ _assertClass(our_sk, UserSecretKeys);
802
+ const ptr0 = passArray8ToWasm0(user_data, wasm.__wbindgen_malloc);
803
+ const len0 = WASM_VECTOR_LEN;
804
+ const ret = wasm.sessionmanagerwrapper_establish_outgoing_session(this.__wbg_ptr, peer_pk.__wbg_ptr, our_pk.__wbg_ptr, our_sk.__wbg_ptr, ptr0, len0);
805
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
806
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
807
+ return v2;
808
+ }
809
+ /**
810
+ * Feeds an incoming announcement from the blockchain.
811
+ *
812
+ * # Parameters
813
+ *
814
+ * - `announcement_bytes`: The raw announcement bytes received from the blockchain
815
+ * - `our_pk`: Our public keys
816
+ * - `our_sk`: Our secret keys
817
+ *
818
+ * # Returns
819
+ *
820
+ * If the announcement is valid, returns an `AnnouncementResult` containing:
821
+ * - The announcer's public keys
822
+ * - The timestamp when the announcement was created (milliseconds since Unix epoch)
823
+ * - The user data embedded in the announcement
824
+ *
825
+ * Returns `None` if the announcement is invalid or too old.
826
+ *
827
+ * # Security Warning
828
+ *
829
+ * **The user_data in announcements has reduced security compared to regular messages:**
830
+ * - ✅ **Plausible deniability preserved**: The user_data is not cryptographically signed,
831
+ * so the sender can deny having sent specific user_data content (though they cannot deny
832
+ * the announcement itself).
833
+ * - ❌ **No post-compromise secrecy**: If the sender's long-term keys are compromised
834
+ * in the future, all past announcements (including their user_data) can be decrypted.
835
+ *
836
+ * **Recommendation**: Treat user_data as having limited confidentiality. Use it for
837
+ * metadata that is not highly sensitive. Send truly sensitive information through regular
838
+ * messages after the session is established.
839
+ * @param {Uint8Array} announcement_bytes
840
+ * @param {UserPublicKeys} our_pk
841
+ * @param {UserSecretKeys} our_sk
842
+ * @returns {AnnouncementResult | undefined}
843
+ */
844
+ feed_incoming_announcement(announcement_bytes, our_pk, our_sk) {
845
+ const ptr0 = passArray8ToWasm0(announcement_bytes, wasm.__wbindgen_malloc);
846
+ const len0 = WASM_VECTOR_LEN;
847
+ _assertClass(our_pk, UserPublicKeys);
848
+ _assertClass(our_sk, UserSecretKeys);
849
+ const ret = wasm.sessionmanagerwrapper_feed_incoming_announcement(this.__wbg_ptr, ptr0, len0, our_pk.__wbg_ptr, our_sk.__wbg_ptr);
850
+ return ret === 0 ? undefined : AnnouncementResult.__wrap(ret);
851
+ }
852
+ /**
853
+ * Gets the list of message board seekers to monitor.
854
+ * @returns {Array<any>}
855
+ */
856
+ get_message_board_read_keys() {
857
+ const ret = wasm.sessionmanagerwrapper_get_message_board_read_keys(this.__wbg_ptr);
858
+ return ret;
859
+ }
860
+ /**
861
+ * Processes an incoming message from the message board.
862
+ * @param {Uint8Array} seeker
863
+ * @param {Uint8Array} ciphertext
864
+ * @param {UserSecretKeys} our_sk
865
+ * @returns {ReceiveMessageOutput | undefined}
866
+ */
867
+ feed_incoming_message_board_read(seeker, ciphertext, our_sk) {
868
+ const ptr0 = passArray8ToWasm0(seeker, wasm.__wbindgen_malloc);
869
+ const len0 = WASM_VECTOR_LEN;
870
+ const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
871
+ const len1 = WASM_VECTOR_LEN;
872
+ _assertClass(our_sk, UserSecretKeys);
873
+ const ret = wasm.sessionmanagerwrapper_feed_incoming_message_board_read(this.__wbg_ptr, ptr0, len0, ptr1, len1, our_sk.__wbg_ptr);
874
+ return ret === 0 ? undefined : ReceiveMessageOutput.__wrap(ret);
875
+ }
876
+ /**
877
+ * Creates a new session manager with the given configuration.
878
+ * @param {SessionConfig} config
879
+ */
880
+ constructor(config) {
881
+ _assertClass(config, SessionConfig);
882
+ var ptr0 = config.__destroy_into_raw();
883
+ const ret = wasm.sessionmanagerwrapper_new(ptr0);
884
+ this.__wbg_ptr = ret >>> 0;
885
+ SessionManagerWrapperFinalization.register(this, this.__wbg_ptr, this);
886
+ return this;
887
+ }
888
+ /**
889
+ * Refreshes sessions and returns peer IDs that need keep-alive messages.
890
+ * @returns {Array<any>}
891
+ */
892
+ refresh() {
893
+ const ret = wasm.sessionmanagerwrapper_refresh(this.__wbg_ptr);
894
+ return ret;
895
+ }
896
+ /**
897
+ * Gets the list of all peer IDs.
898
+ * @returns {Array<any>}
899
+ */
900
+ peer_list() {
901
+ const ret = wasm.sessionmanagerwrapper_peer_list(this.__wbg_ptr);
902
+ return ret;
903
+ }
1031
904
  }
1032
- if (Symbol.dispose)
1033
- SessionManagerWrapper.prototype[Symbol.dispose] =
1034
- SessionManagerWrapper.prototype.free;
905
+ if (Symbol.dispose) SessionManagerWrapper.prototype[Symbol.dispose] = SessionManagerWrapper.prototype.free;
1035
906
 
1036
- const UserKeysFinalization =
1037
- typeof FinalizationRegistry === 'undefined'
907
+ const UserKeysFinalization = (typeof FinalizationRegistry === 'undefined')
1038
908
  ? { register: () => {}, unregister: () => {} }
1039
909
  : new FinalizationRegistry(ptr => wasm.__wbg_userkeys_free(ptr >>> 0, 1));
1040
910
  /**
1041
911
  * User keypair containing both public and secret keys.
1042
912
  */
1043
913
  export class UserKeys {
1044
- static __wrap(ptr) {
1045
- ptr = ptr >>> 0;
1046
- const obj = Object.create(UserKeys.prototype);
1047
- obj.__wbg_ptr = ptr;
1048
- UserKeysFinalization.register(obj, obj.__wbg_ptr, obj);
1049
- return obj;
1050
- }
1051
-
1052
- __destroy_into_raw() {
1053
- const ptr = this.__wbg_ptr;
1054
- this.__wbg_ptr = 0;
1055
- UserKeysFinalization.unregister(this);
1056
- return ptr;
1057
- }
1058
-
1059
- free() {
1060
- const ptr = this.__destroy_into_raw();
1061
- wasm.__wbg_userkeys_free(ptr, 0);
1062
- }
1063
- /**
1064
- * EIP-55 checksummed EVM address (0x…) derived from the EVM public key.
1065
- * @returns {string}
1066
- */
1067
- evm_address() {
1068
- let deferred1_0;
1069
- let deferred1_1;
1070
- try {
1071
- const ret = wasm.userkeys_evm_address(this.__wbg_ptr);
1072
- deferred1_0 = ret[0];
1073
- deferred1_1 = ret[1];
1074
- return getStringFromWasm0(ret[0], ret[1]);
1075
- } finally {
1076
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1077
- }
1078
- }
1079
- /**
1080
- * Gets the public keys.
1081
- * @returns {UserPublicKeys}
1082
- */
1083
- public_keys() {
1084
- const ret = wasm.userkeys_public_keys(this.__wbg_ptr);
1085
- if (ret[2]) {
1086
- throw takeFromExternrefTable0(ret[1]);
1087
- }
1088
- return UserPublicKeys.__wrap(ret[0]);
1089
- }
1090
- /**
1091
- * Gets the secret keys.
1092
- * @returns {UserSecretKeys}
1093
- */
1094
- secret_keys() {
1095
- const ret = wasm.userkeys_secret_keys(this.__wbg_ptr);
1096
- if (ret[2]) {
1097
- throw takeFromExternrefTable0(ret[1]);
1098
- }
1099
- return UserSecretKeys.__wrap(ret[0]);
1100
- }
1101
- /**
1102
- * Massa address (AU…) derived from the Massa public key.
1103
- * @returns {string}
1104
- */
1105
- massa_address() {
1106
- let deferred1_0;
1107
- let deferred1_1;
1108
- try {
1109
- const ret = wasm.userkeys_massa_address(this.__wbg_ptr);
1110
- deferred1_0 = ret[0];
1111
- deferred1_1 = ret[1];
1112
- return getStringFromWasm0(ret[0], ret[1]);
1113
- } finally {
1114
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1115
- }
1116
- }
914
+
915
+ static __wrap(ptr) {
916
+ ptr = ptr >>> 0;
917
+ const obj = Object.create(UserKeys.prototype);
918
+ obj.__wbg_ptr = ptr;
919
+ UserKeysFinalization.register(obj, obj.__wbg_ptr, obj);
920
+ return obj;
921
+ }
922
+
923
+ __destroy_into_raw() {
924
+ const ptr = this.__wbg_ptr;
925
+ this.__wbg_ptr = 0;
926
+ UserKeysFinalization.unregister(this);
927
+ return ptr;
928
+ }
929
+
930
+ free() {
931
+ const ptr = this.__destroy_into_raw();
932
+ wasm.__wbg_userkeys_free(ptr, 0);
933
+ }
934
+ /**
935
+ * EIP-55 checksummed EVM address (0x…) derived from the EVM public key.
936
+ * @returns {string}
937
+ */
938
+ evm_address() {
939
+ let deferred1_0;
940
+ let deferred1_1;
941
+ try {
942
+ const ret = wasm.userkeys_evm_address(this.__wbg_ptr);
943
+ deferred1_0 = ret[0];
944
+ deferred1_1 = ret[1];
945
+ return getStringFromWasm0(ret[0], ret[1]);
946
+ } finally {
947
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
948
+ }
949
+ }
950
+ /**
951
+ * Gets the public keys.
952
+ * @returns {UserPublicKeys}
953
+ */
954
+ public_keys() {
955
+ const ret = wasm.userkeys_public_keys(this.__wbg_ptr);
956
+ if (ret[2]) {
957
+ throw takeFromExternrefTable0(ret[1]);
958
+ }
959
+ return UserPublicKeys.__wrap(ret[0]);
960
+ }
961
+ /**
962
+ * Gets the secret keys.
963
+ * @returns {UserSecretKeys}
964
+ */
965
+ secret_keys() {
966
+ const ret = wasm.userkeys_secret_keys(this.__wbg_ptr);
967
+ if (ret[2]) {
968
+ throw takeFromExternrefTable0(ret[1]);
969
+ }
970
+ return UserSecretKeys.__wrap(ret[0]);
971
+ }
972
+ /**
973
+ * Massa address (AU…) derived from the Massa public key.
974
+ * @returns {string}
975
+ */
976
+ massa_address() {
977
+ let deferred1_0;
978
+ let deferred1_1;
979
+ try {
980
+ const ret = wasm.userkeys_massa_address(this.__wbg_ptr);
981
+ deferred1_0 = ret[0];
982
+ deferred1_1 = ret[1];
983
+ return getStringFromWasm0(ret[0], ret[1]);
984
+ } finally {
985
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
986
+ }
987
+ }
1117
988
  }
1118
- if (Symbol.dispose)
1119
- UserKeys.prototype[Symbol.dispose] = UserKeys.prototype.free;
989
+ if (Symbol.dispose) UserKeys.prototype[Symbol.dispose] = UserKeys.prototype.free;
1120
990
 
1121
- const UserPublicKeysFinalization =
1122
- typeof FinalizationRegistry === 'undefined'
991
+ const UserPublicKeysFinalization = (typeof FinalizationRegistry === 'undefined')
1123
992
  ? { register: () => {}, unregister: () => {} }
1124
- : new FinalizationRegistry(ptr =>
1125
- wasm.__wbg_userpublickeys_free(ptr >>> 0, 1)
1126
- );
993
+ : new FinalizationRegistry(ptr => wasm.__wbg_userpublickeys_free(ptr >>> 0, 1));
1127
994
  /**
1128
995
  * User public keys for authentication and encryption.
1129
996
  */
1130
997
  export class UserPublicKeys {
1131
- static __wrap(ptr) {
1132
- ptr = ptr >>> 0;
1133
- const obj = Object.create(UserPublicKeys.prototype);
1134
- obj.__wbg_ptr = ptr;
1135
- UserPublicKeysFinalization.register(obj, obj.__wbg_ptr, obj);
1136
- return obj;
1137
- }
1138
-
1139
- __destroy_into_raw() {
1140
- const ptr = this.__wbg_ptr;
1141
- this.__wbg_ptr = 0;
1142
- UserPublicKeysFinalization.unregister(this);
1143
- return ptr;
1144
- }
1145
-
1146
- free() {
1147
- const ptr = this.__destroy_into_raw();
1148
- wasm.__wbg_userpublickeys_free(ptr, 0);
1149
- }
1150
- /**
1151
- * Deserializes public keys from bytes.
1152
- * @param {Uint8Array} bytes
1153
- * @returns {UserPublicKeys}
1154
- */
1155
- static from_bytes(bytes) {
1156
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1157
- const len0 = WASM_VECTOR_LEN;
1158
- const ret = wasm.userpublickeys_from_bytes(ptr0, len0);
1159
- if (ret[2]) {
1160
- throw takeFromExternrefTable0(ret[1]);
1161
- }
1162
- return UserPublicKeys.__wrap(ret[0]);
1163
- }
1164
- /**
1165
- * Gets the EVM public key bytes (compressed, secp256k1).
1166
- * @returns {Uint8Array}
1167
- */
1168
- get evm_public_key() {
1169
- const ret = wasm.userpublickeys_evm_public_key(this.__wbg_ptr);
1170
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1171
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1172
- return v1;
1173
- }
1174
- /**
1175
- * Gets the KEM public key bytes.
1176
- * @returns {Uint8Array}
1177
- */
1178
- get kem_public_key() {
1179
- const ret = wasm.userpublickeys_kem_public_key(this.__wbg_ptr);
1180
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1181
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1182
- return v1;
1183
- }
1184
- /**
1185
- * Gets the Massa public key bytes.
1186
- * @returns {Uint8Array}
1187
- */
1188
- get massa_public_key() {
1189
- const ret = wasm.userpublickeys_massa_public_key(this.__wbg_ptr);
1190
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1191
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1192
- return v1;
1193
- }
1194
- /**
1195
- * Gets the DSA verification key bytes.
1196
- * @returns {Uint8Array}
1197
- */
1198
- get dsa_verification_key() {
1199
- const ret = wasm.userpublickeys_dsa_verification_key(this.__wbg_ptr);
1200
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1201
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1202
- return v1;
1203
- }
1204
- /**
1205
- * Serializes the public keys to bytes.
1206
- * @returns {Uint8Array}
1207
- */
1208
- to_bytes() {
1209
- const ret = wasm.userpublickeys_to_bytes(this.__wbg_ptr);
1210
- if (ret[3]) {
1211
- throw takeFromExternrefTable0(ret[2]);
1212
- }
1213
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1214
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1215
- return v1;
1216
- }
1217
- /**
1218
- * Derives a unique user ID from the public keys.
1219
- * @returns {Uint8Array}
1220
- */
1221
- derive_id() {
1222
- const ret = wasm.userpublickeys_derive_id(this.__wbg_ptr);
1223
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1224
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1225
- return v1;
1226
- }
998
+
999
+ static __wrap(ptr) {
1000
+ ptr = ptr >>> 0;
1001
+ const obj = Object.create(UserPublicKeys.prototype);
1002
+ obj.__wbg_ptr = ptr;
1003
+ UserPublicKeysFinalization.register(obj, obj.__wbg_ptr, obj);
1004
+ return obj;
1005
+ }
1006
+
1007
+ __destroy_into_raw() {
1008
+ const ptr = this.__wbg_ptr;
1009
+ this.__wbg_ptr = 0;
1010
+ UserPublicKeysFinalization.unregister(this);
1011
+ return ptr;
1012
+ }
1013
+
1014
+ free() {
1015
+ const ptr = this.__destroy_into_raw();
1016
+ wasm.__wbg_userpublickeys_free(ptr, 0);
1017
+ }
1018
+ /**
1019
+ * Deserializes public keys from bytes.
1020
+ * @param {Uint8Array} bytes
1021
+ * @returns {UserPublicKeys}
1022
+ */
1023
+ static from_bytes(bytes) {
1024
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1025
+ const len0 = WASM_VECTOR_LEN;
1026
+ const ret = wasm.userpublickeys_from_bytes(ptr0, len0);
1027
+ if (ret[2]) {
1028
+ throw takeFromExternrefTable0(ret[1]);
1029
+ }
1030
+ return UserPublicKeys.__wrap(ret[0]);
1031
+ }
1032
+ /**
1033
+ * Gets the EVM public key bytes (compressed, secp256k1).
1034
+ * @returns {Uint8Array}
1035
+ */
1036
+ get evm_public_key() {
1037
+ const ret = wasm.userpublickeys_evm_public_key(this.__wbg_ptr);
1038
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1039
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1040
+ return v1;
1041
+ }
1042
+ /**
1043
+ * Gets the KEM public key bytes.
1044
+ * @returns {Uint8Array}
1045
+ */
1046
+ get kem_public_key() {
1047
+ const ret = wasm.userpublickeys_kem_public_key(this.__wbg_ptr);
1048
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1049
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1050
+ return v1;
1051
+ }
1052
+ /**
1053
+ * Gets the Massa public key bytes.
1054
+ * @returns {Uint8Array}
1055
+ */
1056
+ get massa_public_key() {
1057
+ const ret = wasm.userpublickeys_massa_public_key(this.__wbg_ptr);
1058
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1059
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1060
+ return v1;
1061
+ }
1062
+ /**
1063
+ * Gets the DSA verification key bytes.
1064
+ * @returns {Uint8Array}
1065
+ */
1066
+ get dsa_verification_key() {
1067
+ const ret = wasm.userpublickeys_dsa_verification_key(this.__wbg_ptr);
1068
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1069
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1070
+ return v1;
1071
+ }
1072
+ /**
1073
+ * Serializes the public keys to bytes.
1074
+ * @returns {Uint8Array}
1075
+ */
1076
+ to_bytes() {
1077
+ const ret = wasm.userpublickeys_to_bytes(this.__wbg_ptr);
1078
+ if (ret[3]) {
1079
+ throw takeFromExternrefTable0(ret[2]);
1080
+ }
1081
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1082
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1083
+ return v1;
1084
+ }
1085
+ /**
1086
+ * Derives a unique user ID from the public keys.
1087
+ * @returns {Uint8Array}
1088
+ */
1089
+ derive_id() {
1090
+ const ret = wasm.userpublickeys_derive_id(this.__wbg_ptr);
1091
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1092
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1093
+ return v1;
1094
+ }
1227
1095
  }
1228
- if (Symbol.dispose)
1229
- UserPublicKeys.prototype[Symbol.dispose] = UserPublicKeys.prototype.free;
1096
+ if (Symbol.dispose) UserPublicKeys.prototype[Symbol.dispose] = UserPublicKeys.prototype.free;
1230
1097
 
1231
- const UserSecretKeysFinalization =
1232
- typeof FinalizationRegistry === 'undefined'
1098
+ const UserSecretKeysFinalization = (typeof FinalizationRegistry === 'undefined')
1233
1099
  ? { register: () => {}, unregister: () => {} }
1234
- : new FinalizationRegistry(ptr =>
1235
- wasm.__wbg_usersecretkeys_free(ptr >>> 0, 1)
1236
- );
1100
+ : new FinalizationRegistry(ptr => wasm.__wbg_usersecretkeys_free(ptr >>> 0, 1));
1237
1101
  /**
1238
1102
  * User secret keys for signing and decryption.
1239
1103
  */
1240
1104
  export class UserSecretKeys {
1241
- static __wrap(ptr) {
1242
- ptr = ptr >>> 0;
1243
- const obj = Object.create(UserSecretKeys.prototype);
1244
- obj.__wbg_ptr = ptr;
1245
- UserSecretKeysFinalization.register(obj, obj.__wbg_ptr, obj);
1246
- return obj;
1247
- }
1248
-
1249
- __destroy_into_raw() {
1250
- const ptr = this.__wbg_ptr;
1251
- this.__wbg_ptr = 0;
1252
- UserSecretKeysFinalization.unregister(this);
1253
- return ptr;
1254
- }
1255
-
1256
- free() {
1257
- const ptr = this.__destroy_into_raw();
1258
- wasm.__wbg_usersecretkeys_free(ptr, 0);
1259
- }
1260
- /**
1261
- * Deserializes secret keys from bytes.
1262
- * @param {Uint8Array} bytes
1263
- * @returns {UserSecretKeys}
1264
- */
1265
- static from_bytes(bytes) {
1266
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1267
- const len0 = WASM_VECTOR_LEN;
1268
- const ret = wasm.usersecretkeys_from_bytes(ptr0, len0);
1269
- if (ret[2]) {
1270
- throw takeFromExternrefTable0(ret[1]);
1271
- }
1272
- return UserSecretKeys.__wrap(ret[0]);
1273
- }
1274
- /**
1275
- * Gets the EVM secret key bytes (raw 32-byte scalar).
1276
- * @returns {Uint8Array}
1277
- */
1278
- get evm_secret_key() {
1279
- const ret = wasm.usersecretkeys_evm_secret_key(this.__wbg_ptr);
1280
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1281
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1282
- return v1;
1283
- }
1284
- /**
1285
- * Gets the KEM secret key bytes.
1286
- * @returns {Uint8Array}
1287
- */
1288
- get kem_secret_key() {
1289
- const ret = wasm.usersecretkeys_kem_secret_key(this.__wbg_ptr);
1290
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1291
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1292
- return v1;
1293
- }
1294
- /**
1295
- * Gets the DSA signing key bytes.
1296
- * @returns {Uint8Array}
1297
- */
1298
- get dsa_signing_key() {
1299
- const ret = wasm.usersecretkeys_dsa_signing_key(this.__wbg_ptr);
1300
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1301
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1302
- return v1;
1303
- }
1304
- /**
1305
- * Gets only the Massa secret key bytes
1306
- * @returns {Uint8Array}
1307
- */
1308
- get massa_secret_key() {
1309
- const ret = wasm.usersecretkeys_massa_secret_key(this.__wbg_ptr);
1310
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1311
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1312
- return v1;
1313
- }
1314
- /**
1315
- * Serializes the secret keys to bytes for secure storage.
1316
- * @returns {Uint8Array}
1317
- */
1318
- to_bytes() {
1319
- const ret = wasm.usersecretkeys_to_bytes(this.__wbg_ptr);
1320
- if (ret[3]) {
1321
- throw takeFromExternrefTable0(ret[2]);
1322
- }
1323
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1324
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1325
- return v1;
1326
- }
1105
+
1106
+ static __wrap(ptr) {
1107
+ ptr = ptr >>> 0;
1108
+ const obj = Object.create(UserSecretKeys.prototype);
1109
+ obj.__wbg_ptr = ptr;
1110
+ UserSecretKeysFinalization.register(obj, obj.__wbg_ptr, obj);
1111
+ return obj;
1112
+ }
1113
+
1114
+ __destroy_into_raw() {
1115
+ const ptr = this.__wbg_ptr;
1116
+ this.__wbg_ptr = 0;
1117
+ UserSecretKeysFinalization.unregister(this);
1118
+ return ptr;
1119
+ }
1120
+
1121
+ free() {
1122
+ const ptr = this.__destroy_into_raw();
1123
+ wasm.__wbg_usersecretkeys_free(ptr, 0);
1124
+ }
1125
+ /**
1126
+ * Deserializes secret keys from bytes.
1127
+ * @param {Uint8Array} bytes
1128
+ * @returns {UserSecretKeys}
1129
+ */
1130
+ static from_bytes(bytes) {
1131
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1132
+ const len0 = WASM_VECTOR_LEN;
1133
+ const ret = wasm.usersecretkeys_from_bytes(ptr0, len0);
1134
+ if (ret[2]) {
1135
+ throw takeFromExternrefTable0(ret[1]);
1136
+ }
1137
+ return UserSecretKeys.__wrap(ret[0]);
1138
+ }
1139
+ /**
1140
+ * Gets the EVM secret key bytes (raw 32-byte scalar).
1141
+ * @returns {Uint8Array}
1142
+ */
1143
+ get evm_secret_key() {
1144
+ const ret = wasm.usersecretkeys_evm_secret_key(this.__wbg_ptr);
1145
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1146
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1147
+ return v1;
1148
+ }
1149
+ /**
1150
+ * Gets the KEM secret key bytes.
1151
+ * @returns {Uint8Array}
1152
+ */
1153
+ get kem_secret_key() {
1154
+ const ret = wasm.usersecretkeys_kem_secret_key(this.__wbg_ptr);
1155
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1156
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1157
+ return v1;
1158
+ }
1159
+ /**
1160
+ * Gets the DSA signing key bytes.
1161
+ * @returns {Uint8Array}
1162
+ */
1163
+ get dsa_signing_key() {
1164
+ const ret = wasm.usersecretkeys_dsa_signing_key(this.__wbg_ptr);
1165
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1166
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1167
+ return v1;
1168
+ }
1169
+ /**
1170
+ * Gets only the Massa secret key bytes
1171
+ * @returns {Uint8Array}
1172
+ */
1173
+ get massa_secret_key() {
1174
+ const ret = wasm.usersecretkeys_massa_secret_key(this.__wbg_ptr);
1175
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1176
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1177
+ return v1;
1178
+ }
1179
+ /**
1180
+ * Serializes the secret keys to bytes for secure storage.
1181
+ * @returns {Uint8Array}
1182
+ */
1183
+ to_bytes() {
1184
+ const ret = wasm.usersecretkeys_to_bytes(this.__wbg_ptr);
1185
+ if (ret[3]) {
1186
+ throw takeFromExternrefTable0(ret[2]);
1187
+ }
1188
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1189
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1190
+ return v1;
1191
+ }
1327
1192
  }
1328
- if (Symbol.dispose)
1329
- UserSecretKeys.prototype[Symbol.dispose] = UserSecretKeys.prototype.free;
1193
+ if (Symbol.dispose) UserSecretKeys.prototype[Symbol.dispose] = UserSecretKeys.prototype.free;
1330
1194
 
1331
1195
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
1332
1196
 
1333
1197
  async function __wbg_load(module, imports) {
1334
- if (typeof Response === 'function' && module instanceof Response) {
1335
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1336
- try {
1337
- return await WebAssembly.instantiateStreaming(module, imports);
1338
- } catch (e) {
1339
- const validResponse =
1340
- module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
1341
-
1342
- if (
1343
- validResponse &&
1344
- module.headers.get('Content-Type') !== 'application/wasm'
1345
- ) {
1346
- console.warn(
1347
- '`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',
1348
- e
1349
- );
1350
- } else {
1351
- throw e;
1198
+ if (typeof Response === 'function' && module instanceof Response) {
1199
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1200
+ try {
1201
+ return await WebAssembly.instantiateStreaming(module, imports);
1202
+
1203
+ } catch (e) {
1204
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
1205
+
1206
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1207
+ 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);
1208
+
1209
+ } else {
1210
+ throw e;
1211
+ }
1212
+ }
1352
1213
  }
1353
- }
1354
- }
1355
1214
 
1356
- const bytes = await module.arrayBuffer();
1357
- return await WebAssembly.instantiate(bytes, imports);
1358
- } else {
1359
- const instance = await WebAssembly.instantiate(module, imports);
1215
+ const bytes = await module.arrayBuffer();
1216
+ return await WebAssembly.instantiate(bytes, imports);
1360
1217
 
1361
- if (instance instanceof WebAssembly.Instance) {
1362
- return { instance, module };
1363
1218
  } else {
1364
- return instance;
1219
+ const instance = await WebAssembly.instantiate(module, imports);
1220
+
1221
+ if (instance instanceof WebAssembly.Instance) {
1222
+ return { instance, module };
1223
+
1224
+ } else {
1225
+ return instance;
1226
+ }
1365
1227
  }
1366
- }
1367
1228
  }
1368
1229
 
1369
1230
  function __wbg_get_imports() {
1370
- const imports = {};
1371
- imports.wbg = {};
1372
- imports.wbg.__wbg_call_13410aac570ffff7 = function () {
1373
- return handleError(function (arg0, arg1) {
1374
- const ret = arg0.call(arg1);
1375
- return ret;
1376
- }, arguments);
1377
- };
1378
- imports.wbg.__wbg_call_a5400b25a865cfd8 = function () {
1379
- return handleError(function (arg0, arg1, arg2) {
1380
- const ret = arg0.call(arg1, arg2);
1381
- return ret;
1382
- }, arguments);
1383
- };
1384
- imports.wbg.__wbg_crypto_574e78ad8b13b65f = function (arg0) {
1385
- const ret = arg0.crypto;
1386
- return ret;
1387
- };
1388
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function (arg0, arg1) {
1389
- let deferred0_0;
1390
- let deferred0_1;
1391
- try {
1392
- deferred0_0 = arg0;
1393
- deferred0_1 = arg1;
1394
- console.error(getStringFromWasm0(arg0, arg1));
1395
- } finally {
1396
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1397
- }
1398
- };
1399
- imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function () {
1400
- return handleError(function (arg0, arg1) {
1401
- arg0.getRandomValues(arg1);
1402
- }, arguments);
1403
- };
1404
- imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function (arg0) {
1405
- const ret = arg0.length;
1406
- return ret;
1407
- };
1408
- imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function (arg0) {
1409
- const ret = arg0.msCrypto;
1410
- return ret;
1411
- };
1412
- imports.wbg.__wbg_new_1f3a344cf3123716 = function () {
1413
- const ret = new Array();
1414
- return ret;
1415
- };
1416
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function () {
1417
- const ret = new Error();
1418
- return ret;
1419
- };
1420
- imports.wbg.__wbg_newfromslice_074c56947bd43469 = function (arg0, arg1) {
1421
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1422
- return ret;
1423
- };
1424
- imports.wbg.__wbg_newnoargs_254190557c45b4ec = function (arg0, arg1) {
1425
- const ret = new Function(getStringFromWasm0(arg0, arg1));
1426
- return ret;
1427
- };
1428
- imports.wbg.__wbg_newwithlength_a167dcc7aaa3ba77 = function (arg0) {
1429
- const ret = new Uint8Array(arg0 >>> 0);
1430
- return ret;
1431
- };
1432
- imports.wbg.__wbg_node_905d3e251edff8a2 = function (arg0) {
1433
- const ret = arg0.node;
1434
- return ret;
1435
- };
1436
- imports.wbg.__wbg_now_1e80617bcee43265 = function () {
1437
- const ret = Date.now();
1438
- return ret;
1439
- };
1440
- imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function (arg0) {
1441
- const ret = arg0.process;
1442
- return ret;
1443
- };
1444
- imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function (
1445
- arg0,
1446
- arg1,
1447
- arg2
1448
- ) {
1449
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1450
- };
1451
- imports.wbg.__wbg_push_330b2eb93e4e1212 = function (arg0, arg1) {
1452
- const ret = arg0.push(arg1);
1453
- return ret;
1454
- };
1455
- imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function () {
1456
- return handleError(function (arg0, arg1) {
1457
- arg0.randomFillSync(arg1);
1458
- }, arguments);
1459
- };
1460
- imports.wbg.__wbg_require_60cc747a6bc5215a = function () {
1461
- return handleError(function () {
1462
- const ret = module.require;
1463
- return ret;
1464
- }, arguments);
1465
- };
1466
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function (arg0, arg1) {
1467
- const ret = arg1.stack;
1468
- const ptr1 = passStringToWasm0(
1469
- ret,
1470
- wasm.__wbindgen_malloc,
1471
- wasm.__wbindgen_realloc
1472
- );
1473
- const len1 = WASM_VECTOR_LEN;
1474
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1475
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1476
- };
1477
- imports.wbg.__wbg_static_accessor_GLOBAL_8921f820c2ce3f12 = function () {
1478
- const ret = typeof global === 'undefined' ? null : global;
1479
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1480
- };
1481
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_f0a4409105898184 = function () {
1482
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
1483
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1484
- };
1485
- imports.wbg.__wbg_static_accessor_SELF_995b214ae681ff99 = function () {
1486
- const ret = typeof self === 'undefined' ? null : self;
1487
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1488
- };
1489
- imports.wbg.__wbg_static_accessor_WINDOW_cde3890479c675ea = function () {
1490
- const ret = typeof window === 'undefined' ? null : window;
1491
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1492
- };
1493
- imports.wbg.__wbg_subarray_70fd07feefe14294 = function (arg0, arg1, arg2) {
1494
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1495
- return ret;
1496
- };
1497
- imports.wbg.__wbg_versions_c01dfd4722a88165 = function (arg0) {
1498
- const ret = arg0.versions;
1499
- return ret;
1500
- };
1501
- imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function (arg0) {
1502
- const ret = typeof arg0 === 'function';
1503
- return ret;
1504
- };
1505
- imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function (arg0) {
1506
- const val = arg0;
1507
- const ret = typeof val === 'object' && val !== null;
1508
- return ret;
1509
- };
1510
- imports.wbg.__wbg_wbindgenisstring_d4fa939789f003b0 = function (arg0) {
1511
- const ret = typeof arg0 === 'string';
1512
- return ret;
1513
- };
1514
- imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function (arg0) {
1515
- const ret = arg0 === undefined;
1516
- return ret;
1517
- };
1518
- imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function (arg0, arg1) {
1519
- throw new Error(getStringFromWasm0(arg0, arg1));
1520
- };
1521
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function (arg0, arg1) {
1522
- // Cast intrinsic for `Ref(String) -> Externref`.
1523
- const ret = getStringFromWasm0(arg0, arg1);
1524
- return ret;
1525
- };
1526
- imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function (arg0, arg1) {
1527
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1528
- const ret = getArrayU8FromWasm0(arg0, arg1);
1529
- return ret;
1530
- };
1531
- imports.wbg.__wbindgen_init_externref_table = function () {
1532
- const table = wasm.__wbindgen_export_2;
1533
- const offset = table.grow(4);
1534
- table.set(0, undefined);
1535
- table.set(offset + 0, undefined);
1536
- table.set(offset + 1, null);
1537
- table.set(offset + 2, true);
1538
- table.set(offset + 3, false);
1539
- };
1540
-
1541
- return imports;
1231
+ const imports = {};
1232
+ imports.wbg = {};
1233
+ imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
1234
+ const ret = arg0.call(arg1);
1235
+ return ret;
1236
+ }, arguments) };
1237
+ imports.wbg.__wbg_call_a5400b25a865cfd8 = function() { return handleError(function (arg0, arg1, arg2) {
1238
+ const ret = arg0.call(arg1, arg2);
1239
+ return ret;
1240
+ }, arguments) };
1241
+ imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
1242
+ const ret = arg0.crypto;
1243
+ return ret;
1244
+ };
1245
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
1246
+ let deferred0_0;
1247
+ let deferred0_1;
1248
+ try {
1249
+ deferred0_0 = arg0;
1250
+ deferred0_1 = arg1;
1251
+ console.error(getStringFromWasm0(arg0, arg1));
1252
+ } finally {
1253
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1254
+ }
1255
+ };
1256
+ imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
1257
+ arg0.getRandomValues(arg1);
1258
+ }, arguments) };
1259
+ imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
1260
+ const ret = arg0.length;
1261
+ return ret;
1262
+ };
1263
+ imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
1264
+ const ret = arg0.msCrypto;
1265
+ return ret;
1266
+ };
1267
+ imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
1268
+ const ret = new Array();
1269
+ return ret;
1270
+ };
1271
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
1272
+ const ret = new Error();
1273
+ return ret;
1274
+ };
1275
+ imports.wbg.__wbg_newfromslice_074c56947bd43469 = function(arg0, arg1) {
1276
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1277
+ return ret;
1278
+ };
1279
+ imports.wbg.__wbg_newnoargs_254190557c45b4ec = function(arg0, arg1) {
1280
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
1281
+ return ret;
1282
+ };
1283
+ imports.wbg.__wbg_newwithlength_a167dcc7aaa3ba77 = function(arg0) {
1284
+ const ret = new Uint8Array(arg0 >>> 0);
1285
+ return ret;
1286
+ };
1287
+ imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
1288
+ const ret = arg0.node;
1289
+ return ret;
1290
+ };
1291
+ imports.wbg.__wbg_now_1e80617bcee43265 = function() {
1292
+ const ret = Date.now();
1293
+ return ret;
1294
+ };
1295
+ imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
1296
+ const ret = arg0.process;
1297
+ return ret;
1298
+ };
1299
+ imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
1300
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1301
+ };
1302
+ imports.wbg.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
1303
+ const ret = arg0.push(arg1);
1304
+ return ret;
1305
+ };
1306
+ imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
1307
+ arg0.randomFillSync(arg1);
1308
+ }, arguments) };
1309
+ imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
1310
+ const ret = module.require;
1311
+ return ret;
1312
+ }, arguments) };
1313
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
1314
+ const ret = arg1.stack;
1315
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1316
+ const len1 = WASM_VECTOR_LEN;
1317
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1318
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1319
+ };
1320
+ imports.wbg.__wbg_static_accessor_GLOBAL_8921f820c2ce3f12 = function() {
1321
+ const ret = typeof global === 'undefined' ? null : global;
1322
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1323
+ };
1324
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_f0a4409105898184 = function() {
1325
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1326
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1327
+ };
1328
+ imports.wbg.__wbg_static_accessor_SELF_995b214ae681ff99 = function() {
1329
+ const ret = typeof self === 'undefined' ? null : self;
1330
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1331
+ };
1332
+ imports.wbg.__wbg_static_accessor_WINDOW_cde3890479c675ea = function() {
1333
+ const ret = typeof window === 'undefined' ? null : window;
1334
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1335
+ };
1336
+ imports.wbg.__wbg_subarray_70fd07feefe14294 = function(arg0, arg1, arg2) {
1337
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1338
+ return ret;
1339
+ };
1340
+ imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
1341
+ const ret = arg0.versions;
1342
+ return ret;
1343
+ };
1344
+ imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
1345
+ const ret = typeof(arg0) === 'function';
1346
+ return ret;
1347
+ };
1348
+ imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
1349
+ const val = arg0;
1350
+ const ret = typeof(val) === 'object' && val !== null;
1351
+ return ret;
1352
+ };
1353
+ imports.wbg.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
1354
+ const ret = typeof(arg0) === 'string';
1355
+ return ret;
1356
+ };
1357
+ imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
1358
+ const ret = arg0 === undefined;
1359
+ return ret;
1360
+ };
1361
+ imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
1362
+ throw new Error(getStringFromWasm0(arg0, arg1));
1363
+ };
1364
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1365
+ // Cast intrinsic for `Ref(String) -> Externref`.
1366
+ const ret = getStringFromWasm0(arg0, arg1);
1367
+ return ret;
1368
+ };
1369
+ imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
1370
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1371
+ const ret = getArrayU8FromWasm0(arg0, arg1);
1372
+ return ret;
1373
+ };
1374
+ imports.wbg.__wbindgen_init_externref_table = function() {
1375
+ const table = wasm.__wbindgen_export_2;
1376
+ const offset = table.grow(4);
1377
+ table.set(0, undefined);
1378
+ table.set(offset + 0, undefined);
1379
+ table.set(offset + 1, null);
1380
+ table.set(offset + 2, true);
1381
+ table.set(offset + 3, false);
1382
+ ;
1383
+ };
1384
+
1385
+ return imports;
1542
1386
  }
1543
1387
 
1544
- function __wbg_init_memory(imports, memory) {}
1388
+ function __wbg_init_memory(imports, memory) {
1389
+
1390
+ }
1545
1391
 
1546
1392
  function __wbg_finalize_init(instance, module) {
1547
- wasm = instance.exports;
1548
- __wbg_init.__wbindgen_wasm_module = module;
1549
- cachedDataViewMemory0 = null;
1550
- cachedUint8ArrayMemory0 = null;
1393
+ wasm = instance.exports;
1394
+ __wbg_init.__wbindgen_wasm_module = module;
1395
+ cachedDataViewMemory0 = null;
1396
+ cachedUint8ArrayMemory0 = null;
1551
1397
 
1552
- wasm.__wbindgen_start();
1553
- return wasm;
1398
+
1399
+ wasm.__wbindgen_start();
1400
+ return wasm;
1554
1401
  }
1555
1402
 
1556
1403
  function initSync(module) {
1557
- if (wasm !== undefined) return wasm;
1404
+ if (wasm !== undefined) return wasm;
1558
1405
 
1559
- if (typeof module !== 'undefined') {
1560
- if (Object.getPrototypeOf(module) === Object.prototype) {
1561
- ({ module } = module);
1562
- } else {
1563
- console.warn(
1564
- 'using deprecated parameters for `initSync()`; pass a single object instead'
1565
- );
1406
+
1407
+ if (typeof module !== 'undefined') {
1408
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1409
+ ({module} = module)
1410
+ } else {
1411
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1412
+ }
1566
1413
  }
1567
- }
1568
1414
 
1569
- const imports = __wbg_get_imports();
1415
+ const imports = __wbg_get_imports();
1570
1416
 
1571
- __wbg_init_memory(imports);
1417
+ __wbg_init_memory(imports);
1572
1418
 
1573
- if (!(module instanceof WebAssembly.Module)) {
1574
- module = new WebAssembly.Module(module);
1575
- }
1419
+ if (!(module instanceof WebAssembly.Module)) {
1420
+ module = new WebAssembly.Module(module);
1421
+ }
1576
1422
 
1577
- const instance = new WebAssembly.Instance(module, imports);
1423
+ const instance = new WebAssembly.Instance(module, imports);
1578
1424
 
1579
- return __wbg_finalize_init(instance, module);
1425
+ return __wbg_finalize_init(instance, module);
1580
1426
  }
1581
1427
 
1582
1428
  async function __wbg_init(module_or_path) {
1583
- if (wasm !== undefined) return wasm;
1429
+ if (wasm !== undefined) return wasm;
1584
1430
 
1585
- if (typeof module_or_path !== 'undefined') {
1586
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1587
- ({ module_or_path } = module_or_path);
1588
- } else {
1589
- console.warn(
1590
- 'using deprecated parameters for the initialization function; pass a single object instead'
1591
- );
1431
+
1432
+ if (typeof module_or_path !== 'undefined') {
1433
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1434
+ ({module_or_path} = module_or_path)
1435
+ } else {
1436
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1437
+ }
1592
1438
  }
1593
- }
1594
1439
 
1595
- if (typeof module_or_path === 'undefined') {
1596
- module_or_path = new URL('gossip_wasm_bg.wasm', import.meta.url);
1597
- }
1598
- const imports = __wbg_get_imports();
1440
+ if (typeof module_or_path === 'undefined') {
1441
+ module_or_path = new URL('gossip_wasm_bg.wasm', import.meta.url);
1442
+ }
1443
+ const imports = __wbg_get_imports();
1599
1444
 
1600
- if (
1601
- typeof module_or_path === 'string' ||
1602
- (typeof Request === 'function' && module_or_path instanceof Request) ||
1603
- (typeof URL === 'function' && module_or_path instanceof URL)
1604
- ) {
1605
- module_or_path = fetch(module_or_path);
1606
- }
1445
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1446
+ module_or_path = fetch(module_or_path);
1447
+ }
1607
1448
 
1608
- __wbg_init_memory(imports);
1449
+ __wbg_init_memory(imports);
1609
1450
 
1610
- const { instance, module } = await __wbg_load(await module_or_path, imports);
1451
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1611
1452
 
1612
- return __wbg_finalize_init(instance, module);
1453
+ return __wbg_finalize_init(instance, module);
1613
1454
  }
1614
1455
 
1615
1456
  export { initSync };