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