@massalabs/gossip-sdk 0.0.2-dev.20260128094509 → 0.0.2-dev.20260128160824

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.
Files changed (148) hide show
  1. package/dist/api/messageProtocol/index.d.ts +19 -0
  2. package/dist/api/messageProtocol/index.js +26 -0
  3. package/dist/api/messageProtocol/mock.d.ts +12 -0
  4. package/{src/api/messageProtocol/mock.ts → dist/api/messageProtocol/mock.js} +2 -3
  5. package/dist/api/messageProtocol/rest.d.ts +22 -0
  6. package/dist/api/messageProtocol/rest.js +161 -0
  7. package/dist/api/messageProtocol/types.d.ts +61 -0
  8. package/dist/api/messageProtocol/types.js +6 -0
  9. package/dist/assets/generated/wasm/README.md +281 -0
  10. package/dist/assets/generated/wasm/gossip_wasm.d.ts +638 -0
  11. package/dist/assets/generated/wasm/gossip_wasm.js +1557 -0
  12. package/dist/assets/generated/wasm/gossip_wasm_bg.wasm +0 -0
  13. package/dist/assets/generated/wasm/gossip_wasm_bg.wasm.d.ts +164 -0
  14. package/dist/assets/generated/wasm/package.json +15 -0
  15. package/dist/assets/generated/wasm-node/README.md +281 -0
  16. package/dist/assets/generated/wasm-node/gossip_wasm.d.ts +443 -0
  17. package/dist/assets/generated/wasm-node/gossip_wasm.js +1488 -0
  18. package/dist/assets/generated/wasm-node/gossip_wasm_bg.wasm +0 -0
  19. package/dist/assets/generated/wasm-node/gossip_wasm_bg.wasm.d.ts +164 -0
  20. package/dist/assets/generated/wasm-node/package.json +11 -0
  21. package/dist/config/protocol.d.ts +36 -0
  22. package/dist/config/protocol.js +77 -0
  23. package/dist/config/sdk.d.ts +82 -0
  24. package/dist/config/sdk.js +55 -0
  25. package/{src/contacts.ts → dist/contacts.d.ts} +11 -95
  26. package/dist/contacts.js +166 -0
  27. package/dist/core/SdkEventEmitter.d.ts +36 -0
  28. package/dist/core/SdkEventEmitter.js +59 -0
  29. package/dist/core/SdkPolling.d.ts +35 -0
  30. package/dist/core/SdkPolling.js +100 -0
  31. package/{src/core/index.ts → dist/core/index.d.ts} +0 -2
  32. package/dist/core/index.js +5 -0
  33. package/dist/crypto/bip39.d.ts +34 -0
  34. package/dist/crypto/bip39.js +62 -0
  35. package/dist/crypto/encryption.d.ts +37 -0
  36. package/dist/crypto/encryption.js +46 -0
  37. package/dist/db.d.ts +190 -0
  38. package/dist/db.js +311 -0
  39. package/dist/gossipSdk.d.ts +274 -0
  40. package/dist/gossipSdk.js +690 -0
  41. package/dist/index.d.ts +59 -0
  42. package/dist/index.js +61 -0
  43. package/dist/services/announcement.d.ts +43 -0
  44. package/dist/services/announcement.js +491 -0
  45. package/dist/services/auth.d.ts +37 -0
  46. package/dist/services/auth.js +76 -0
  47. package/dist/services/discussion.d.ts +63 -0
  48. package/dist/services/discussion.js +297 -0
  49. package/dist/services/message.d.ts +74 -0
  50. package/dist/services/message.js +826 -0
  51. package/dist/services/refresh.d.ts +41 -0
  52. package/dist/services/refresh.js +205 -0
  53. package/{src/sw.ts → dist/sw.d.ts} +1 -8
  54. package/dist/sw.js +10 -0
  55. package/dist/types/events.d.ts +80 -0
  56. package/dist/types/events.js +7 -0
  57. package/dist/types.d.ts +32 -0
  58. package/dist/types.js +7 -0
  59. package/dist/utils/base64.d.ts +10 -0
  60. package/dist/utils/base64.js +30 -0
  61. package/dist/utils/contacts.d.ts +42 -0
  62. package/dist/utils/contacts.js +113 -0
  63. package/dist/utils/discussions.d.ts +24 -0
  64. package/dist/utils/discussions.js +38 -0
  65. package/dist/utils/logs.d.ts +19 -0
  66. package/dist/utils/logs.js +89 -0
  67. package/dist/utils/messageSerialization.d.ts +64 -0
  68. package/dist/utils/messageSerialization.js +184 -0
  69. package/dist/utils/queue.d.ts +50 -0
  70. package/dist/utils/queue.js +110 -0
  71. package/dist/utils/type.d.ts +10 -0
  72. package/dist/utils/type.js +4 -0
  73. package/dist/utils/userId.d.ts +40 -0
  74. package/dist/utils/userId.js +90 -0
  75. package/dist/utils/validation.d.ts +50 -0
  76. package/dist/utils/validation.js +112 -0
  77. package/dist/utils.d.ts +30 -0
  78. package/{src/utils.ts → dist/utils.js} +9 -19
  79. package/dist/wasm/encryption.d.ts +56 -0
  80. package/{src/wasm/encryption.ts → dist/wasm/encryption.js} +22 -51
  81. package/dist/wasm/index.d.ts +10 -0
  82. package/{src/wasm/index.ts → dist/wasm/index.js} +1 -8
  83. package/dist/wasm/loader.d.ts +22 -0
  84. package/dist/wasm/loader.js +78 -0
  85. package/dist/wasm/session.d.ts +85 -0
  86. package/dist/wasm/session.js +226 -0
  87. package/dist/wasm/userKeys.d.ts +17 -0
  88. package/{src/wasm/userKeys.ts → dist/wasm/userKeys.js} +6 -13
  89. package/package.json +15 -2
  90. package/src/api/messageProtocol/index.ts +0 -53
  91. package/src/api/messageProtocol/rest.ts +0 -209
  92. package/src/api/messageProtocol/types.ts +0 -70
  93. package/src/config/protocol.ts +0 -97
  94. package/src/config/sdk.ts +0 -131
  95. package/src/core/SdkEventEmitter.ts +0 -91
  96. package/src/core/SdkPolling.ts +0 -134
  97. package/src/crypto/bip39.ts +0 -84
  98. package/src/crypto/encryption.ts +0 -77
  99. package/src/db.ts +0 -465
  100. package/src/gossipSdk.ts +0 -994
  101. package/src/index.ts +0 -211
  102. package/src/services/announcement.ts +0 -653
  103. package/src/services/auth.ts +0 -95
  104. package/src/services/discussion.ts +0 -380
  105. package/src/services/message.ts +0 -1055
  106. package/src/services/refresh.ts +0 -234
  107. package/src/types/events.ts +0 -108
  108. package/src/types.ts +0 -70
  109. package/src/utils/base64.ts +0 -39
  110. package/src/utils/contacts.ts +0 -161
  111. package/src/utils/discussions.ts +0 -55
  112. package/src/utils/logs.ts +0 -86
  113. package/src/utils/messageSerialization.ts +0 -257
  114. package/src/utils/queue.ts +0 -106
  115. package/src/utils/type.ts +0 -7
  116. package/src/utils/userId.ts +0 -114
  117. package/src/utils/validation.ts +0 -144
  118. package/src/wasm/loader.ts +0 -123
  119. package/src/wasm/session.ts +0 -276
  120. package/test/config/protocol.spec.ts +0 -31
  121. package/test/config/sdk.spec.ts +0 -163
  122. package/test/db/helpers.spec.ts +0 -142
  123. package/test/db/operations.spec.ts +0 -128
  124. package/test/db/states.spec.ts +0 -535
  125. package/test/integration/discussion-flow.spec.ts +0 -422
  126. package/test/integration/messaging-flow.spec.ts +0 -708
  127. package/test/integration/sdk-lifecycle.spec.ts +0 -325
  128. package/test/mocks/index.ts +0 -9
  129. package/test/mocks/mockMessageProtocol.ts +0 -100
  130. package/test/services/auth.spec.ts +0 -311
  131. package/test/services/discussion.spec.ts +0 -279
  132. package/test/services/message-deduplication.spec.ts +0 -299
  133. package/test/services/message-startup.spec.ts +0 -331
  134. package/test/services/message.spec.ts +0 -817
  135. package/test/services/refresh.spec.ts +0 -199
  136. package/test/services/session-status.spec.ts +0 -349
  137. package/test/session/wasm.spec.ts +0 -227
  138. package/test/setup.ts +0 -52
  139. package/test/utils/contacts.spec.ts +0 -156
  140. package/test/utils/discussions.spec.ts +0 -66
  141. package/test/utils/queue.spec.ts +0 -52
  142. package/test/utils/serialization.spec.ts +0 -120
  143. package/test/utils/userId.spec.ts +0 -120
  144. package/test/utils/validation.spec.ts +0 -223
  145. package/test/utils.ts +0 -212
  146. package/tsconfig.json +0 -26
  147. package/tsconfig.tsbuildinfo +0 -1
  148. package/vitest.config.ts +0 -28
@@ -0,0 +1,1557 @@
1
+ let wasm;
2
+
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_export_2.set(idx, obj);
6
+ return idx;
7
+ }
8
+
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
+ }
16
+ }
17
+
18
+ let cachedUint8ArrayMemory0 = null;
19
+
20
+ function getUint8ArrayMemory0() {
21
+ if (
22
+ cachedUint8ArrayMemory0 === null ||
23
+ cachedUint8ArrayMemory0.byteLength === 0
24
+ ) {
25
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
26
+ }
27
+ return cachedUint8ArrayMemory0;
28
+ }
29
+
30
+ let cachedTextDecoder = new TextDecoder('utf-8', {
31
+ ignoreBOM: true,
32
+ fatal: true,
33
+ });
34
+
35
+ cachedTextDecoder.decode();
36
+
37
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
38
+ let numBytesDecoded = 0;
39
+ function decodeText(ptr, len) {
40
+ numBytesDecoded += len;
41
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
42
+ cachedTextDecoder = new TextDecoder('utf-8', {
43
+ ignoreBOM: true,
44
+ fatal: true,
45
+ });
46
+ cachedTextDecoder.decode();
47
+ numBytesDecoded = len;
48
+ }
49
+ return cachedTextDecoder.decode(
50
+ getUint8ArrayMemory0().subarray(ptr, ptr + len)
51
+ );
52
+ }
53
+
54
+ function getStringFromWasm0(ptr, len) {
55
+ ptr = ptr >>> 0;
56
+ return decodeText(ptr, len);
57
+ }
58
+
59
+ function getArrayU8FromWasm0(ptr, len) {
60
+ ptr = ptr >>> 0;
61
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
62
+ }
63
+
64
+ let WASM_VECTOR_LEN = 0;
65
+
66
+ const cachedTextEncoder = new TextEncoder();
67
+
68
+ if (!('encodeInto' in cachedTextEncoder)) {
69
+ cachedTextEncoder.encodeInto = function (arg, view) {
70
+ const buf = cachedTextEncoder.encode(arg);
71
+ view.set(buf);
72
+ return {
73
+ read: arg.length,
74
+ written: buf.length,
75
+ };
76
+ };
77
+ }
78
+
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
+ }
89
+
90
+ let len = arg.length;
91
+ let ptr = malloc(len, 1) >>> 0;
92
+
93
+ const mem = getUint8ArrayMemory0();
94
+
95
+ let offset = 0;
96
+
97
+ for (; offset < len; offset++) {
98
+ const code = arg.charCodeAt(offset);
99
+ if (code > 0x7f) break;
100
+ mem[ptr + offset] = code;
101
+ }
102
+
103
+ if (offset !== len) {
104
+ if (offset !== 0) {
105
+ arg = arg.slice(offset);
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);
110
+
111
+ offset += ret.written;
112
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
113
+ }
114
+
115
+ WASM_VECTOR_LEN = offset;
116
+ return ptr;
117
+ }
118
+
119
+ let cachedDataViewMemory0 = null;
120
+
121
+ function getDataViewMemory0() {
122
+ if (
123
+ cachedDataViewMemory0 === null ||
124
+ cachedDataViewMemory0.buffer.detached === true ||
125
+ (cachedDataViewMemory0.buffer.detached === undefined &&
126
+ cachedDataViewMemory0.buffer !== wasm.memory.buffer)
127
+ ) {
128
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
129
+ }
130
+ return cachedDataViewMemory0;
131
+ }
132
+
133
+ function isLikeNone(x) {
134
+ return x === undefined || x === null;
135
+ }
136
+
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;
142
+ }
143
+
144
+ function takeFromExternrefTable0(idx) {
145
+ const value = wasm.__wbindgen_export_2.get(idx);
146
+ wasm.__externref_table_dealloc(idx);
147
+ return value;
148
+ }
149
+
150
+ export function start() {
151
+ wasm.start();
152
+ }
153
+
154
+ function _assertClass(instance, klass) {
155
+ if (!(instance instanceof klass)) {
156
+ throw new Error(`expected instance of ${klass.name}`);
157
+ }
158
+ }
159
+ /**
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}
196
+ */
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;
218
+ }
219
+
220
+ /**
221
+ * Encrypts data using AES-256-SIV authenticated encryption.
222
+ *
223
+ * # Parameters
224
+ *
225
+ * - `key`: The encryption key (64 bytes)
226
+ * - `nonce`: The nonce (16 bytes, should be unique per encryption)
227
+ * - `plaintext`: The data to encrypt
228
+ * - `aad`: Additional authenticated data (not encrypted, but authenticated)
229
+ *
230
+ * # Returns
231
+ *
232
+ * The ciphertext with authentication tag appended.
233
+ *
234
+ * # Security Notes
235
+ *
236
+ * - The nonce should be unique for each encryption operation
237
+ * - AES-SIV is nonce-misuse resistant: reusing nonces only leaks if plaintexts are identical
238
+ * - AAD is authenticated but not encrypted; it must be transmitted separately
239
+ * - The same AAD must be provided during decryption
240
+ *
241
+ * # Example
242
+ *
243
+ * ```javascript
244
+ * const key = EncryptionKey.generate();
245
+ * const nonce = Nonce.generate();
246
+ * const plaintext = new TextEncoder().encode("Secret message");
247
+ * const aad = new TextEncoder().encode("context info");
248
+ *
249
+ * const ciphertext = aead_encrypt(key, nonce, plaintext, aad);
250
+ * ```
251
+ * @param {EncryptionKey} key
252
+ * @param {Nonce} nonce
253
+ * @param {Uint8Array} plaintext
254
+ * @param {Uint8Array} aad
255
+ * @returns {Uint8Array}
256
+ */
257
+ export function aead_encrypt(key, nonce, plaintext, aad) {
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;
275
+ }
276
+
277
+ /**
278
+ * Generates user keys from a passphrase using password-based key derivation.
279
+ * @param {string} passphrase
280
+ * @returns {UserKeys}
281
+ */
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]);
294
+ }
295
+
296
+ /**
297
+ * Session status indicating the state of a peer session.
298
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
299
+ */
300
+ export const SessionStatus = Object.freeze({
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',
315
+ });
316
+
317
+ const AnnouncementResultFinalization =
318
+ typeof FinalizationRegistry === 'undefined'
319
+ ? { register: () => {}, unregister: () => {} }
320
+ : new FinalizationRegistry(ptr =>
321
+ wasm.__wbg_announcementresult_free(ptr >>> 0, 1)
322
+ );
323
+ /**
324
+ * Result from feeding an incoming announcement.
325
+ */
326
+ export class AnnouncementResult {
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
+ }
372
+ }
373
+ if (Symbol.dispose)
374
+ AnnouncementResult.prototype[Symbol.dispose] =
375
+ AnnouncementResult.prototype.free;
376
+
377
+ const EncryptionKeyFinalization =
378
+ typeof FinalizationRegistry === 'undefined'
379
+ ? { register: () => {}, unregister: () => {} }
380
+ : new FinalizationRegistry(ptr =>
381
+ wasm.__wbg_encryptionkey_free(ptr >>> 0, 1)
382
+ );
383
+ /**
384
+ * Encryption key for AEAD operations (AES-256-SIV).
385
+ *
386
+ * AES-256-SIV uses a 64-byte (512-bit) key: two 256-bit keys for encryption and MAC.
387
+ */
388
+ export class EncryptionKey {
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]);
464
+ }
465
+ return EncryptionKey.__wrap(ret[0]);
466
+ }
467
+ }
468
+ if (Symbol.dispose)
469
+ EncryptionKey.prototype[Symbol.dispose] = EncryptionKey.prototype.free;
470
+
471
+ const NonceFinalization =
472
+ typeof FinalizationRegistry === 'undefined'
473
+ ? { register: () => {}, unregister: () => {} }
474
+ : new FinalizationRegistry(ptr => wasm.__wbg_nonce_free(ptr >>> 0, 1));
475
+ /**
476
+ * Nonce for AEAD operations (AES-256-SIV).
477
+ *
478
+ * AES-256-SIV uses a 16-byte (128-bit) nonce. The nonce should be unique
479
+ * per encryption for maximum security, though SIV mode is nonce-misuse resistant.
480
+ */
481
+ export class Nonce {
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
+ }
533
+ }
534
+ if (Symbol.dispose) Nonce.prototype[Symbol.dispose] = Nonce.prototype.free;
535
+
536
+ const ReceiveMessageOutputFinalization =
537
+ typeof FinalizationRegistry === 'undefined'
538
+ ? { register: () => {}, unregister: () => {} }
539
+ : new FinalizationRegistry(ptr =>
540
+ wasm.__wbg_receivemessageoutput_free(ptr >>> 0, 1)
541
+ );
542
+ /**
543
+ * Output from receiving a message.
544
+ */
545
+ export class ReceiveMessageOutput {
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
+ }
601
+ }
602
+ if (Symbol.dispose)
603
+ ReceiveMessageOutput.prototype[Symbol.dispose] =
604
+ ReceiveMessageOutput.prototype.free;
605
+
606
+ const SendMessageOutputFinalization =
607
+ typeof FinalizationRegistry === 'undefined'
608
+ ? { register: () => {}, unregister: () => {} }
609
+ : new FinalizationRegistry(ptr =>
610
+ wasm.__wbg_sendmessageoutput_free(ptr >>> 0, 1)
611
+ );
612
+ /**
613
+ * Output from sending a message.
614
+ */
615
+ export class SendMessageOutput {
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
+ }
655
+ }
656
+ if (Symbol.dispose)
657
+ SendMessageOutput.prototype[Symbol.dispose] =
658
+ SendMessageOutput.prototype.free;
659
+
660
+ const SessionConfigFinalization =
661
+ typeof FinalizationRegistry === 'undefined'
662
+ ? { register: () => {}, unregister: () => {} }
663
+ : new FinalizationRegistry(ptr =>
664
+ wasm.__wbg_sessionconfig_free(ptr >>> 0, 1)
665
+ );
666
+ /**
667
+ * Session manager configuration for controlling session behavior.
668
+ */
669
+ export class SessionConfig {
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
+ }
736
+ }
737
+ if (Symbol.dispose)
738
+ SessionConfig.prototype[Symbol.dispose] = SessionConfig.prototype.free;
739
+
740
+ const SessionManagerWrapperFinalization =
741
+ typeof FinalizationRegistry === 'undefined'
742
+ ? { register: () => {}, unregister: () => {} }
743
+ : new FinalizationRegistry(ptr =>
744
+ wasm.__wbg_sessionmanagerwrapper_free(ptr >>> 0, 1)
745
+ );
746
+ /**
747
+ * Session manager wrapper for WebAssembly.
748
+ */
749
+ export class SessionManagerWrapper {
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
+ }
1024
+ }
1025
+ if (Symbol.dispose)
1026
+ SessionManagerWrapper.prototype[Symbol.dispose] =
1027
+ SessionManagerWrapper.prototype.free;
1028
+
1029
+ const UserKeysFinalization =
1030
+ typeof FinalizationRegistry === 'undefined'
1031
+ ? { register: () => {}, unregister: () => {} }
1032
+ : new FinalizationRegistry(ptr => wasm.__wbg_userkeys_free(ptr >>> 0, 1));
1033
+ /**
1034
+ * User keypair containing both public and secret keys.
1035
+ */
1036
+ export class UserKeys {
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]);
1075
+ }
1076
+ return UserSecretKeys.__wrap(ret[0]);
1077
+ }
1078
+ }
1079
+ if (Symbol.dispose)
1080
+ UserKeys.prototype[Symbol.dispose] = UserKeys.prototype.free;
1081
+
1082
+ const UserPublicKeysFinalization =
1083
+ typeof FinalizationRegistry === 'undefined'
1084
+ ? { register: () => {}, unregister: () => {} }
1085
+ : new FinalizationRegistry(ptr =>
1086
+ wasm.__wbg_userpublickeys_free(ptr >>> 0, 1)
1087
+ );
1088
+ /**
1089
+ * User public keys for authentication and encryption.
1090
+ */
1091
+ export class UserPublicKeys {
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
+ }
1178
+ }
1179
+ if (Symbol.dispose)
1180
+ UserPublicKeys.prototype[Symbol.dispose] = UserPublicKeys.prototype.free;
1181
+
1182
+ const UserSecretKeysFinalization =
1183
+ typeof FinalizationRegistry === 'undefined'
1184
+ ? { register: () => {}, unregister: () => {} }
1185
+ : new FinalizationRegistry(ptr =>
1186
+ wasm.__wbg_usersecretkeys_free(ptr >>> 0, 1)
1187
+ );
1188
+ /**
1189
+ * User secret keys for signing and decryption.
1190
+ */
1191
+ export class UserSecretKeys {
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
+ }
1268
+ }
1269
+ if (Symbol.dispose)
1270
+ UserSecretKeys.prototype[Symbol.dispose] = UserSecretKeys.prototype.free;
1271
+
1272
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
1273
+
1274
+ async function __wbg_load(module, imports) {
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;
1293
+ }
1294
+ }
1295
+ }
1296
+
1297
+ const bytes = await module.arrayBuffer();
1298
+ return await WebAssembly.instantiate(bytes, imports);
1299
+ } else {
1300
+ const instance = await WebAssembly.instantiate(module, imports);
1301
+
1302
+ if (instance instanceof WebAssembly.Instance) {
1303
+ return { instance, module };
1304
+ } else {
1305
+ return instance;
1306
+ }
1307
+ }
1308
+ }
1309
+
1310
+ function __wbg_get_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;
1483
+ }
1484
+
1485
+ function __wbg_init_memory(imports, memory) {}
1486
+
1487
+ function __wbg_finalize_init(instance, module) {
1488
+ wasm = instance.exports;
1489
+ __wbg_init.__wbindgen_wasm_module = module;
1490
+ cachedDataViewMemory0 = null;
1491
+ cachedUint8ArrayMemory0 = null;
1492
+
1493
+ wasm.__wbindgen_start();
1494
+ return wasm;
1495
+ }
1496
+
1497
+ function initSync(module) {
1498
+ if (wasm !== undefined) return wasm;
1499
+
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
+ );
1507
+ }
1508
+ }
1509
+
1510
+ const imports = __wbg_get_imports();
1511
+
1512
+ __wbg_init_memory(imports);
1513
+
1514
+ if (!(module instanceof WebAssembly.Module)) {
1515
+ module = new WebAssembly.Module(module);
1516
+ }
1517
+
1518
+ const instance = new WebAssembly.Instance(module, imports);
1519
+
1520
+ return __wbg_finalize_init(instance, module);
1521
+ }
1522
+
1523
+ async function __wbg_init(module_or_path) {
1524
+ if (wasm !== undefined) return wasm;
1525
+
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
+ );
1533
+ }
1534
+ }
1535
+
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();
1540
+
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
+ }
1548
+
1549
+ __wbg_init_memory(imports);
1550
+
1551
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1552
+
1553
+ return __wbg_finalize_init(instance, module);
1554
+ }
1555
+
1556
+ export { initSync };
1557
+ export default __wbg_init;