@massalabs/gossip-sdk 0.0.2-dev.20260128111120 → 0.0.2-dev.20260128162527

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