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