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