@wireapp/core-crypto 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2284 +0,0 @@
1
- let wasm$1;
2
-
3
- const heap = new Array(32).fill(undefined);
4
-
5
- heap.push(undefined, null, true, false);
6
-
7
- function getObject(idx) { return heap[idx]; }
8
-
9
- let heap_next = heap.length;
10
-
11
- function addHeapObject(obj) {
12
- if (heap_next === heap.length) heap.push(heap.length + 1);
13
- const idx = heap_next;
14
- heap_next = heap[idx];
15
-
16
- heap[idx] = obj;
17
- return idx;
18
- }
19
-
20
- function dropObject(idx) {
21
- if (idx < 36) return;
22
- heap[idx] = heap_next;
23
- heap_next = idx;
24
- }
25
-
26
- function takeObject(idx) {
27
- const ret = getObject(idx);
28
- dropObject(idx);
29
- return ret;
30
- }
31
-
32
- const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
33
-
34
- cachedTextDecoder.decode();
35
-
36
- let cachedUint8Memory0 = new Uint8Array();
37
-
38
- function getUint8Memory0() {
39
- if (cachedUint8Memory0.byteLength === 0) {
40
- cachedUint8Memory0 = new Uint8Array(wasm$1.memory.buffer);
41
- }
42
- return cachedUint8Memory0;
43
- }
44
-
45
- function getStringFromWasm0(ptr, len) {
46
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
47
- }
48
-
49
- function isLikeNone(x) {
50
- return x === undefined || x === null;
51
- }
52
-
53
- let cachedFloat64Memory0 = new Float64Array();
54
-
55
- function getFloat64Memory0() {
56
- if (cachedFloat64Memory0.byteLength === 0) {
57
- cachedFloat64Memory0 = new Float64Array(wasm$1.memory.buffer);
58
- }
59
- return cachedFloat64Memory0;
60
- }
61
-
62
- let cachedInt32Memory0 = new Int32Array();
63
-
64
- function getInt32Memory0() {
65
- if (cachedInt32Memory0.byteLength === 0) {
66
- cachedInt32Memory0 = new Int32Array(wasm$1.memory.buffer);
67
- }
68
- return cachedInt32Memory0;
69
- }
70
-
71
- let WASM_VECTOR_LEN = 0;
72
-
73
- const cachedTextEncoder = new TextEncoder('utf-8');
74
-
75
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
76
- ? function (arg, view) {
77
- return cachedTextEncoder.encodeInto(arg, view);
78
- }
79
- : function (arg, view) {
80
- const buf = cachedTextEncoder.encode(arg);
81
- view.set(buf);
82
- return {
83
- read: arg.length,
84
- written: buf.length
85
- };
86
- });
87
-
88
- function passStringToWasm0(arg, malloc, realloc) {
89
-
90
- if (realloc === undefined) {
91
- const buf = cachedTextEncoder.encode(arg);
92
- const ptr = malloc(buf.length);
93
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
94
- WASM_VECTOR_LEN = buf.length;
95
- return ptr;
96
- }
97
-
98
- let len = arg.length;
99
- let ptr = malloc(len);
100
-
101
- const mem = getUint8Memory0();
102
-
103
- let offset = 0;
104
-
105
- for (; offset < len; offset++) {
106
- const code = arg.charCodeAt(offset);
107
- if (code > 0x7F) break;
108
- mem[ptr + offset] = code;
109
- }
110
-
111
- if (offset !== len) {
112
- if (offset !== 0) {
113
- arg = arg.slice(offset);
114
- }
115
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
116
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
117
- const ret = encodeString(arg, view);
118
-
119
- offset += ret.written;
120
- }
121
-
122
- WASM_VECTOR_LEN = offset;
123
- return ptr;
124
- }
125
-
126
- function debugString(val) {
127
- // primitive types
128
- const type = typeof val;
129
- if (type == 'number' || type == 'boolean' || val == null) {
130
- return `${val}`;
131
- }
132
- if (type == 'string') {
133
- return `"${val}"`;
134
- }
135
- if (type == 'symbol') {
136
- const description = val.description;
137
- if (description == null) {
138
- return 'Symbol';
139
- } else {
140
- return `Symbol(${description})`;
141
- }
142
- }
143
- if (type == 'function') {
144
- const name = val.name;
145
- if (typeof name == 'string' && name.length > 0) {
146
- return `Function(${name})`;
147
- } else {
148
- return 'Function';
149
- }
150
- }
151
- // objects
152
- if (Array.isArray(val)) {
153
- const length = val.length;
154
- let debug = '[';
155
- if (length > 0) {
156
- debug += debugString(val[0]);
157
- }
158
- for(let i = 1; i < length; i++) {
159
- debug += ', ' + debugString(val[i]);
160
- }
161
- debug += ']';
162
- return debug;
163
- }
164
- // Test for built-in
165
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
166
- let className;
167
- if (builtInMatches.length > 1) {
168
- className = builtInMatches[1];
169
- } else {
170
- // Failed to match the standard '[object ClassName]'
171
- return toString.call(val);
172
- }
173
- if (className == 'Object') {
174
- // we're a user defined class or Object
175
- // JSON.stringify avoids problems with cycles, and is generally much
176
- // easier than looping through ownProperties of `val`.
177
- try {
178
- return 'Object(' + JSON.stringify(val) + ')';
179
- } catch (_) {
180
- return 'Object';
181
- }
182
- }
183
- // errors
184
- if (val instanceof Error) {
185
- return `${val.name}: ${val.message}\n${val.stack}`;
186
- }
187
- // TODO we could test for more things here, like `Set`s and `Map`s.
188
- return className;
189
- }
190
-
191
- function makeMutClosure(arg0, arg1, dtor, f) {
192
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
193
- const real = (...args) => {
194
- // First up with a closure we increment the internal reference
195
- // count. This ensures that the Rust closure environment won't
196
- // be deallocated while we're invoking it.
197
- state.cnt++;
198
- const a = state.a;
199
- state.a = 0;
200
- try {
201
- return f(a, state.b, ...args);
202
- } finally {
203
- if (--state.cnt === 0) {
204
- wasm$1.__wbindgen_export_2.get(state.dtor)(a, state.b);
205
-
206
- } else {
207
- state.a = a;
208
- }
209
- }
210
- };
211
- real.original = state;
212
-
213
- return real;
214
- }
215
- function __wbg_adapter_40(arg0, arg1, arg2) {
216
- try {
217
- const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
218
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfa283dadb011e75c(retptr, arg0, arg1, addHeapObject(arg2));
219
- var r0 = getInt32Memory0()[retptr / 4 + 0];
220
- var r1 = getInt32Memory0()[retptr / 4 + 1];
221
- if (r1) {
222
- throw takeObject(r0);
223
- }
224
- } finally {
225
- wasm$1.__wbindgen_add_to_stack_pointer(16);
226
- }
227
- }
228
-
229
- function __wbg_adapter_43(arg0, arg1, arg2) {
230
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h04f9c855c75e5606(arg0, arg1, addHeapObject(arg2));
231
- }
232
-
233
- /**
234
- * @returns {string}
235
- */
236
- function version() {
237
- try {
238
- const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
239
- wasm$1.version(retptr);
240
- var r0 = getInt32Memory0()[retptr / 4 + 0];
241
- var r1 = getInt32Memory0()[retptr / 4 + 1];
242
- return getStringFromWasm0(r0, r1);
243
- } finally {
244
- wasm$1.__wbindgen_add_to_stack_pointer(16);
245
- wasm$1.__wbindgen_free(r0, r1);
246
- }
247
- }
248
-
249
- function passArray8ToWasm0(arg, malloc) {
250
- const ptr = malloc(arg.length * 1);
251
- getUint8Memory0().set(arg, ptr / 1);
252
- WASM_VECTOR_LEN = arg.length;
253
- return ptr;
254
- }
255
-
256
- function _assertClass(instance, klass) {
257
- if (!(instance instanceof klass)) {
258
- throw new Error(`expected instance of ${klass.name}`);
259
- }
260
- return instance.ptr;
261
- }
262
-
263
- let cachedUint32Memory0 = new Uint32Array();
264
-
265
- function getUint32Memory0() {
266
- if (cachedUint32Memory0.byteLength === 0) {
267
- cachedUint32Memory0 = new Uint32Array(wasm$1.memory.buffer);
268
- }
269
- return cachedUint32Memory0;
270
- }
271
-
272
- function passArrayJsValueToWasm0(array, malloc) {
273
- const ptr = malloc(array.length * 4);
274
- const mem = getUint32Memory0();
275
- for (let i = 0; i < array.length; i++) {
276
- mem[ptr / 4 + i] = addHeapObject(array[i]);
277
- }
278
- WASM_VECTOR_LEN = array.length;
279
- return ptr;
280
- }
281
-
282
- function handleError(f, args) {
283
- try {
284
- return f.apply(this, args);
285
- } catch (e) {
286
- wasm$1.__wbindgen_exn_store(addHeapObject(e));
287
- }
288
- }
289
-
290
- function getArrayU8FromWasm0(ptr, len) {
291
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
292
- }
293
- function __wbg_adapter_176(arg0, arg1, arg2, arg3) {
294
- wasm$1.wasm_bindgen__convert__closures__invoke2_mut__h4791cbe418449d5d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
295
- }
296
-
297
- /**
298
- * see [core_crypto::prelude::CiphersuiteName]
299
- */
300
- const Ciphersuite = Object.freeze({
301
- /**
302
- * DH KEM x25519 | AES-GCM 128 | SHA2-256 | Ed25519
303
- */
304
- MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519:1,"1":"MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519",
305
- /**
306
- * DH KEM P256 | AES-GCM 128 | SHA2-256 | EcDSA P256
307
- */
308
- MLS_128_DHKEMP256_AES128GCM_SHA256_P256:2,"2":"MLS_128_DHKEMP256_AES128GCM_SHA256_P256",
309
- /**
310
- * DH KEM x25519 | Chacha20Poly1305 | SHA2-256 | Ed25519
311
- */
312
- MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519:3,"3":"MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519",
313
- /**
314
- * DH KEM x448 | AES-GCM 256 | SHA2-512 | Ed448
315
- */
316
- MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448:4,"4":"MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448",
317
- /**
318
- * DH KEM P521 | AES-GCM 256 | SHA2-512 | EcDSA P521
319
- */
320
- MLS_256_DHKEMP521_AES256GCM_SHA512_P521:5,"5":"MLS_256_DHKEMP521_AES256GCM_SHA512_P521",
321
- /**
322
- * DH KEM x448 | Chacha20Poly1305 | SHA2-512 | Ed448
323
- */
324
- MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448:6,"6":"MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448",
325
- /**
326
- * DH KEM P384 | AES-GCM 256 | SHA2-384 | EcDSA P384
327
- */
328
- MLS_256_DHKEMP384_AES256GCM_SHA384_P384:7,"7":"MLS_256_DHKEMP384_AES256GCM_SHA384_P384", });
329
- /**
330
- */
331
- class CommitBundle {
332
-
333
- __destroy_into_raw() {
334
- const ptr = this.ptr;
335
- this.ptr = 0;
336
-
337
- return ptr;
338
- }
339
-
340
- free() {
341
- const ptr = this.__destroy_into_raw();
342
- wasm$1.__wbg_commitbundle_free(ptr);
343
- }
344
- /**
345
- * @returns {Uint8Array}
346
- */
347
- get commit() {
348
- const ret = wasm$1.commitbundle_commit(this.ptr);
349
- return takeObject(ret);
350
- }
351
- /**
352
- * @returns {Uint8Array | undefined}
353
- */
354
- get welcome() {
355
- const ret = wasm$1.commitbundle_welcome(this.ptr);
356
- return takeObject(ret);
357
- }
358
- /**
359
- * @returns {Uint8Array}
360
- */
361
- get public_group_state() {
362
- const ret = wasm$1.commitbundle_public_group_state(this.ptr);
363
- return takeObject(ret);
364
- }
365
- }
366
- /**
367
- * see [core_crypto::prelude::MlsConversationConfiguration]
368
- */
369
- class ConversationConfiguration {
370
-
371
- static __wrap(ptr) {
372
- const obj = Object.create(ConversationConfiguration.prototype);
373
- obj.ptr = ptr;
374
-
375
- return obj;
376
- }
377
-
378
- __destroy_into_raw() {
379
- const ptr = this.ptr;
380
- this.ptr = 0;
381
-
382
- return ptr;
383
- }
384
-
385
- free() {
386
- const ptr = this.__destroy_into_raw();
387
- wasm$1.__wbg_conversationconfiguration_free(ptr);
388
- }
389
- /**
390
- * @param {(Uint8Array)[] | undefined} admins
391
- * @param {number | undefined} ciphersuite
392
- * @param {number | undefined} key_rotation_span
393
- * @param {(Uint8Array)[] | undefined} external_senders
394
- */
395
- constructor(admins, ciphersuite, key_rotation_span, external_senders) {
396
- var ptr0 = isLikeNone(admins) ? 0 : passArrayJsValueToWasm0(admins, wasm$1.__wbindgen_malloc);
397
- var len0 = WASM_VECTOR_LEN;
398
- var ptr1 = isLikeNone(external_senders) ? 0 : passArrayJsValueToWasm0(external_senders, wasm$1.__wbindgen_malloc);
399
- var len1 = WASM_VECTOR_LEN;
400
- const ret = wasm$1.conversationconfiguration_new(ptr0, len0, isLikeNone(ciphersuite) ? 8 : ciphersuite, !isLikeNone(key_rotation_span), isLikeNone(key_rotation_span) ? 0 : key_rotation_span, ptr1, len1);
401
- return ConversationConfiguration.__wrap(ret);
402
- }
403
- }
404
- /**
405
- */
406
- class CoreCrypto$1 {
407
-
408
- static __wrap(ptr) {
409
- const obj = Object.create(CoreCrypto$1.prototype);
410
- obj.ptr = ptr;
411
-
412
- return obj;
413
- }
414
-
415
- __destroy_into_raw() {
416
- const ptr = this.ptr;
417
- this.ptr = 0;
418
-
419
- return ptr;
420
- }
421
-
422
- free() {
423
- const ptr = this.__destroy_into_raw();
424
- wasm$1.__wbg_corecrypto_free(ptr);
425
- }
426
- /**
427
- * see [core_crypto::MlsCentral::try_new]
428
- * @param {string} path
429
- * @param {string} key
430
- * @param {string} client_id
431
- * @param {Uint8Array | undefined} entropy_seed
432
- * @returns {Promise<CoreCrypto>}
433
- */
434
- static _internal_new(path, key, client_id, entropy_seed) {
435
- const ptr0 = passStringToWasm0(path, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
436
- const len0 = WASM_VECTOR_LEN;
437
- const ptr1 = passStringToWasm0(key, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
438
- const len1 = WASM_VECTOR_LEN;
439
- const ptr2 = passStringToWasm0(client_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
440
- const len2 = WASM_VECTOR_LEN;
441
- var ptr3 = isLikeNone(entropy_seed) ? 0 : passArray8ToWasm0(entropy_seed, wasm$1.__wbindgen_malloc);
442
- var len3 = WASM_VECTOR_LEN;
443
- const ret = wasm$1.corecrypto__internal_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
444
- return takeObject(ret);
445
- }
446
- /**
447
- * Returns: [`WasmCryptoResult<()>`]
448
- *
449
- * see [core_crypto::MlsCentral::close]
450
- * @returns {Promise<any>}
451
- */
452
- close() {
453
- const ptr = this.__destroy_into_raw();
454
- const ret = wasm$1.corecrypto_close(ptr);
455
- return takeObject(ret);
456
- }
457
- /**
458
- * Returns: [`WasmCryptoResult<()>`]
459
- *
460
- * see [core_crypto::MlsCentral::wipe]
461
- * @returns {Promise<any>}
462
- */
463
- wipe() {
464
- const ptr = this.__destroy_into_raw();
465
- const ret = wasm$1.corecrypto_wipe(ptr);
466
- return takeObject(ret);
467
- }
468
- /**
469
- * Returns: [`WasmCryptoResult<()>`]
470
- *
471
- * see [core_crypto::MlsCentral::callbacks]
472
- * @param {CoreCryptoWasmCallbacks} callbacks
473
- * @returns {Promise<any>}
474
- */
475
- set_callbacks(callbacks) {
476
- _assertClass(callbacks, CoreCryptoWasmCallbacks);
477
- var ptr0 = callbacks.ptr;
478
- callbacks.ptr = 0;
479
- const ret = wasm$1.corecrypto_set_callbacks(this.ptr, ptr0);
480
- return takeObject(ret);
481
- }
482
- /**
483
- * Returns:: [`WasmCryptoResult<js_sys::Uint8Array>`]
484
- *
485
- * see [core_crypto::MlsCentral::client_public_key]
486
- * @returns {Promise<any>}
487
- */
488
- client_public_key() {
489
- const ret = wasm$1.corecrypto_client_public_key(this.ptr);
490
- return takeObject(ret);
491
- }
492
- /**
493
- * Returns: [`WasmCryptoResult<js_sys::Array<js_sys::Uint8Array>>`]
494
- *
495
- * see [core_crypto::MlsCentral::client_keypackages]
496
- * @param {number} amount_requested
497
- * @returns {Promise<any>}
498
- */
499
- client_keypackages(amount_requested) {
500
- const ret = wasm$1.corecrypto_client_keypackages(this.ptr, amount_requested);
501
- return takeObject(ret);
502
- }
503
- /**
504
- * Returns: [`WasmCryptoResult<usize>`]
505
- *
506
- * see [core_crypto::MlsCentral::client_valid_keypackages_count]
507
- * @returns {Promise<any>}
508
- */
509
- client_valid_keypackages_count() {
510
- const ret = wasm$1.corecrypto_client_valid_keypackages_count(this.ptr);
511
- return takeObject(ret);
512
- }
513
- /**
514
- * Returns: [`WasmCryptoResult<()>`]
515
- *
516
- * see [core_crypto::MlsCentral::new_conversation]
517
- * @param {Uint8Array} conversation_id
518
- * @param {ConversationConfiguration} config
519
- * @returns {Promise<any>}
520
- */
521
- create_conversation(conversation_id, config) {
522
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
523
- const len0 = WASM_VECTOR_LEN;
524
- _assertClass(config, ConversationConfiguration);
525
- var ptr1 = config.ptr;
526
- config.ptr = 0;
527
- const ret = wasm$1.corecrypto_create_conversation(this.ptr, ptr0, len0, ptr1);
528
- return takeObject(ret);
529
- }
530
- /**
531
- * Returns [`WasmCryptoResult<u64>`]
532
- *
533
- * see [core_crypto::MlsCentral::conversation_epoch]
534
- * @param {Uint8Array} conversation_id
535
- * @returns {Promise<any>}
536
- */
537
- conversation_epoch(conversation_id) {
538
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
539
- const len0 = WASM_VECTOR_LEN;
540
- const ret = wasm$1.corecrypto_conversation_epoch(this.ptr, ptr0, len0);
541
- return takeObject(ret);
542
- }
543
- /**
544
- * Returns: [`bool`]
545
- *
546
- * see [core_crypto::MlsCentral::conversation_exists]
547
- * @param {Uint8Array} conversation_id
548
- * @returns {Promise<any>}
549
- */
550
- conversation_exists(conversation_id) {
551
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
552
- const len0 = WASM_VECTOR_LEN;
553
- const ret = wasm$1.corecrypto_conversation_exists(this.ptr, ptr0, len0);
554
- return takeObject(ret);
555
- }
556
- /**
557
- * Returns: [`WasmCryptoResult<Uint8Array>`]
558
- *
559
- * see [core_crypto::MlsCentral::process_raw_welcome_message]
560
- * @param {Uint8Array} welcome_message
561
- * @returns {Promise<any>}
562
- */
563
- process_welcome_message(welcome_message) {
564
- const ptr0 = passArray8ToWasm0(welcome_message, wasm$1.__wbindgen_malloc);
565
- const len0 = WASM_VECTOR_LEN;
566
- const ret = wasm$1.corecrypto_process_welcome_message(this.ptr, ptr0, len0);
567
- return takeObject(ret);
568
- }
569
- /**
570
- * Returns: [`WasmCryptoResult<Option<MemberAddedMessages>>`]
571
- *
572
- * see [core_crypto::MlsCentral::add_members_to_conversation]
573
- * @param {Uint8Array} conversation_id
574
- * @param {any[]} clients
575
- * @returns {Promise<any>}
576
- */
577
- add_clients_to_conversation(conversation_id, clients) {
578
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
579
- const len0 = WASM_VECTOR_LEN;
580
- const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
581
- const len1 = WASM_VECTOR_LEN;
582
- const ret = wasm$1.corecrypto_add_clients_to_conversation(this.ptr, ptr0, len0, ptr1, len1);
583
- return takeObject(ret);
584
- }
585
- /**
586
- * Returns: [`WasmCryptoResult<Option<js_sys::Uint8Array>>`]
587
- *
588
- * see [core_crypto::MlsCentral::remove_members_from_conversation]
589
- * @param {Uint8Array} conversation_id
590
- * @param {(Uint8Array)[]} clients
591
- * @returns {Promise<any>}
592
- */
593
- remove_clients_from_conversation(conversation_id, clients) {
594
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
595
- const len0 = WASM_VECTOR_LEN;
596
- const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
597
- const len1 = WASM_VECTOR_LEN;
598
- const ret = wasm$1.corecrypto_remove_clients_from_conversation(this.ptr, ptr0, len0, ptr1, len1);
599
- return takeObject(ret);
600
- }
601
- /**
602
- * Returns: [`WasmCryptoResult<CommitBundle>`]
603
- *
604
- * see [core_crypto::MlsCentral::update_keying_material]
605
- * @param {Uint8Array} conversation_id
606
- * @returns {Promise<any>}
607
- */
608
- update_keying_material(conversation_id) {
609
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
610
- const len0 = WASM_VECTOR_LEN;
611
- const ret = wasm$1.corecrypto_update_keying_material(this.ptr, ptr0, len0);
612
- return takeObject(ret);
613
- }
614
- /**
615
- * see [core_crypto::MlsCentral::commit_pending_proposals]
616
- * @param {Uint8Array} conversation_id
617
- * @returns {Promise<any>}
618
- */
619
- commit_pending_proposals(conversation_id) {
620
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
621
- const len0 = WASM_VECTOR_LEN;
622
- const ret = wasm$1.corecrypto_commit_pending_proposals(this.ptr, ptr0, len0);
623
- return takeObject(ret);
624
- }
625
- /**
626
- * Returns: [`WasmCryptoResult<Option<MemberAddedMessages>>`]
627
- *
628
- * see [core_crypto::MlsCentral::add_members_to_conversation]
629
- * @param {Uint8Array} conversation_id
630
- * @param {any[]} clients
631
- * @returns {Promise<any>}
632
- */
633
- final_add_clients_to_conversation(conversation_id, clients) {
634
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
635
- const len0 = WASM_VECTOR_LEN;
636
- const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
637
- const len1 = WASM_VECTOR_LEN;
638
- const ret = wasm$1.corecrypto_final_add_clients_to_conversation(this.ptr, ptr0, len0, ptr1, len1);
639
- return takeObject(ret);
640
- }
641
- /**
642
- * Returns: [`WasmCryptoResult<Option<js_sys::Uint8Array>>`]
643
- *
644
- * see [core_crypto::MlsCentral::remove_members_from_conversation]
645
- * @param {Uint8Array} conversation_id
646
- * @param {(Uint8Array)[]} clients
647
- * @returns {Promise<any>}
648
- */
649
- final_remove_clients_from_conversation(conversation_id, clients) {
650
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
651
- const len0 = WASM_VECTOR_LEN;
652
- const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
653
- const len1 = WASM_VECTOR_LEN;
654
- const ret = wasm$1.corecrypto_final_remove_clients_from_conversation(this.ptr, ptr0, len0, ptr1, len1);
655
- return takeObject(ret);
656
- }
657
- /**
658
- * Returns: [`WasmCryptoResult<CommitBundle>`]
659
- *
660
- * see [core_crypto::MlsCentral::update_keying_material]
661
- * @param {Uint8Array} conversation_id
662
- * @returns {Promise<any>}
663
- */
664
- final_update_keying_material(conversation_id) {
665
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
666
- const len0 = WASM_VECTOR_LEN;
667
- const ret = wasm$1.corecrypto_final_update_keying_material(this.ptr, ptr0, len0);
668
- return takeObject(ret);
669
- }
670
- /**
671
- * see [core_crypto::MlsCentral::commit_pending_proposals]
672
- * @param {Uint8Array} conversation_id
673
- * @returns {Promise<any>}
674
- */
675
- final_commit_pending_proposals(conversation_id) {
676
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
677
- const len0 = WASM_VECTOR_LEN;
678
- const ret = wasm$1.corecrypto_final_commit_pending_proposals(this.ptr, ptr0, len0);
679
- return takeObject(ret);
680
- }
681
- /**
682
- * Returns: [`WasmCryptoResult<()>`]
683
- *
684
- * see [core_crypto::MlsCentral::wipe_conversation]
685
- * @param {Uint8Array} conversation_id
686
- * @returns {Promise<any>}
687
- */
688
- wipe_conversation(conversation_id) {
689
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
690
- const len0 = WASM_VECTOR_LEN;
691
- const ret = wasm$1.corecrypto_wipe_conversation(this.ptr, ptr0, len0);
692
- return takeObject(ret);
693
- }
694
- /**
695
- * Returns: [`WasmCryptoResult<DecryptedMessage>`]
696
- *
697
- * see [core_crypto::MlsCentral::decrypt_message]
698
- * @param {Uint8Array} conversation_id
699
- * @param {Uint8Array} payload
700
- * @returns {Promise<any>}
701
- */
702
- decrypt_message(conversation_id, payload) {
703
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
704
- const len0 = WASM_VECTOR_LEN;
705
- const ptr1 = passArray8ToWasm0(payload, wasm$1.__wbindgen_malloc);
706
- const len1 = WASM_VECTOR_LEN;
707
- const ret = wasm$1.corecrypto_decrypt_message(this.ptr, ptr0, len0, ptr1, len1);
708
- return takeObject(ret);
709
- }
710
- /**
711
- * Returns: [`WasmCryptoResult<Uint8Array>`]
712
- *
713
- * see [core_crypto::MlsCentral::encrypt_message]
714
- * @param {Uint8Array} conversation_id
715
- * @param {Uint8Array} message
716
- * @returns {Promise<any>}
717
- */
718
- encrypt_message(conversation_id, message) {
719
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
720
- const len0 = WASM_VECTOR_LEN;
721
- const ptr1 = passArray8ToWasm0(message, wasm$1.__wbindgen_malloc);
722
- const len1 = WASM_VECTOR_LEN;
723
- const ret = wasm$1.corecrypto_encrypt_message(this.ptr, ptr0, len0, ptr1, len1);
724
- return takeObject(ret);
725
- }
726
- /**
727
- * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
728
- *
729
- * see [core_crypto::MlsCentral::new_proposal]
730
- * @param {Uint8Array} conversation_id
731
- * @param {Uint8Array} keypackage
732
- * @returns {Promise<any>}
733
- */
734
- new_add_proposal(conversation_id, keypackage) {
735
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
736
- const len0 = WASM_VECTOR_LEN;
737
- const ptr1 = passArray8ToWasm0(keypackage, wasm$1.__wbindgen_malloc);
738
- const len1 = WASM_VECTOR_LEN;
739
- const ret = wasm$1.corecrypto_new_add_proposal(this.ptr, ptr0, len0, ptr1, len1);
740
- return takeObject(ret);
741
- }
742
- /**
743
- * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
744
- *
745
- * see [core_crypto::MlsCentral::new_proposal]
746
- * @param {Uint8Array} conversation_id
747
- * @returns {Promise<any>}
748
- */
749
- new_update_proposal(conversation_id) {
750
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
751
- const len0 = WASM_VECTOR_LEN;
752
- const ret = wasm$1.corecrypto_new_update_proposal(this.ptr, ptr0, len0);
753
- return takeObject(ret);
754
- }
755
- /**
756
- * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
757
- *
758
- * see [core_crypto::MlsCentral::new_proposal]
759
- * @param {Uint8Array} conversation_id
760
- * @param {Uint8Array} client_id
761
- * @returns {Promise<any>}
762
- */
763
- new_remove_proposal(conversation_id, client_id) {
764
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
765
- const len0 = WASM_VECTOR_LEN;
766
- const ptr1 = passArray8ToWasm0(client_id, wasm$1.__wbindgen_malloc);
767
- const len1 = WASM_VECTOR_LEN;
768
- const ret = wasm$1.corecrypto_new_remove_proposal(this.ptr, ptr0, len0, ptr1, len1);
769
- return takeObject(ret);
770
- }
771
- /**
772
- * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
773
- *
774
- * see [core_crypto::MlsCentral::new_external_add_proposal]
775
- * @param {Uint8Array} conversation_id
776
- * @param {number} epoch
777
- * @returns {Promise<any>}
778
- */
779
- new_external_add_proposal(conversation_id, epoch) {
780
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
781
- const len0 = WASM_VECTOR_LEN;
782
- const ret = wasm$1.corecrypto_new_external_add_proposal(this.ptr, ptr0, len0, epoch);
783
- return takeObject(ret);
784
- }
785
- /**
786
- * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
787
- *
788
- * see [core_crypto::MlsCentral::new_external_remove_proposal]
789
- * @param {Uint8Array} conversation_id
790
- * @param {number} epoch
791
- * @param {Uint8Array} keypackage_ref
792
- * @returns {Promise<any>}
793
- */
794
- new_external_remove_proposal(conversation_id, epoch, keypackage_ref) {
795
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
796
- const len0 = WASM_VECTOR_LEN;
797
- const ptr1 = passArray8ToWasm0(keypackage_ref, wasm$1.__wbindgen_malloc);
798
- const len1 = WASM_VECTOR_LEN;
799
- const ret = wasm$1.corecrypto_new_external_remove_proposal(this.ptr, ptr0, len0, epoch, ptr1, len1);
800
- return takeObject(ret);
801
- }
802
- /**
803
- * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
804
- *
805
- * see [core_crypto::MlsCentral::export_public_group_state]
806
- * @param {Uint8Array} conversation_id
807
- * @returns {Promise<any>}
808
- */
809
- export_group_state(conversation_id) {
810
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
811
- const len0 = WASM_VECTOR_LEN;
812
- const ret = wasm$1.corecrypto_export_group_state(this.ptr, ptr0, len0);
813
- return takeObject(ret);
814
- }
815
- /**
816
- * Returns: [`WasmCryptoResult<MlsConversationInitMessage>`]
817
- *
818
- * see [core_crypto::MlsCentral::join_by_external_commit]
819
- * @param {Uint8Array} group_state
820
- * @returns {Promise<any>}
821
- */
822
- join_by_external_commit(group_state) {
823
- const ptr0 = passArray8ToWasm0(group_state, wasm$1.__wbindgen_malloc);
824
- const len0 = WASM_VECTOR_LEN;
825
- const ret = wasm$1.corecrypto_join_by_external_commit(this.ptr, ptr0, len0);
826
- return takeObject(ret);
827
- }
828
- /**
829
- * Returns: [`WasmCryptoResult<()>`]
830
- *
831
- * see [core_crypto::MlsCentral::merge_pending_group_from_external_commit]
832
- * @param {Uint8Array} conversation_id
833
- * @param {ConversationConfiguration} configuration
834
- * @returns {Promise<any>}
835
- */
836
- merge_pending_group_from_external_commit(conversation_id, configuration) {
837
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
838
- const len0 = WASM_VECTOR_LEN;
839
- _assertClass(configuration, ConversationConfiguration);
840
- var ptr1 = configuration.ptr;
841
- configuration.ptr = 0;
842
- const ret = wasm$1.corecrypto_merge_pending_group_from_external_commit(this.ptr, ptr0, len0, ptr1);
843
- return takeObject(ret);
844
- }
845
- /**
846
- * see [core_crypto::MlsCentral::commit_accepted]
847
- * @param {Uint8Array} conversation_id
848
- * @returns {Promise<any>}
849
- */
850
- commit_accepted(conversation_id) {
851
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
852
- const len0 = WASM_VECTOR_LEN;
853
- const ret = wasm$1.corecrypto_commit_accepted(this.ptr, ptr0, len0);
854
- return takeObject(ret);
855
- }
856
- /**
857
- * see [core_crypto::MlsCentral::clear_pending_proposal]
858
- * @param {Uint8Array} conversation_id
859
- * @param {Uint8Array} proposal_ref
860
- * @returns {Promise<any>}
861
- */
862
- clear_pending_proposal(conversation_id, proposal_ref) {
863
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
864
- const len0 = WASM_VECTOR_LEN;
865
- const ptr1 = passArray8ToWasm0(proposal_ref, wasm$1.__wbindgen_malloc);
866
- const len1 = WASM_VECTOR_LEN;
867
- const ret = wasm$1.corecrypto_clear_pending_proposal(this.ptr, ptr0, len0, ptr1, len1);
868
- return takeObject(ret);
869
- }
870
- /**
871
- * see [core_crypto::MlsCentral::clear_pending_commit]
872
- * @param {Uint8Array} conversation_id
873
- * @returns {Promise<any>}
874
- */
875
- clear_pending_commit(conversation_id) {
876
- const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
877
- const len0 = WASM_VECTOR_LEN;
878
- const ret = wasm$1.corecrypto_clear_pending_commit(this.ptr, ptr0, len0);
879
- return takeObject(ret);
880
- }
881
- /**
882
- * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
883
- *
884
- * see [core_crypto::MlsCentral::random_bytes]
885
- * @param {number} len
886
- * @returns {Promise<any>}
887
- */
888
- random_bytes(len) {
889
- const ret = wasm$1.corecrypto_random_bytes(this.ptr, len);
890
- return takeObject(ret);
891
- }
892
- /**
893
- * Returns: [`WasmCryptoResult<()>`]
894
- *
895
- * see [mls_crypto_provider::MlsCryptoProvider::reseed]
896
- * @param {Uint8Array} seed
897
- * @returns {Promise<any>}
898
- */
899
- reseed_rng(seed) {
900
- const ptr0 = passArray8ToWasm0(seed, wasm$1.__wbindgen_malloc);
901
- const len0 = WASM_VECTOR_LEN;
902
- const ret = wasm$1.corecrypto_reseed_rng(this.ptr, ptr0, len0);
903
- return takeObject(ret);
904
- }
905
- }
906
- /**
907
- * see [core_crypto::prelude::CoreCryptoCallbacks]
908
- */
909
- class CoreCryptoWasmCallbacks {
910
-
911
- static __wrap(ptr) {
912
- const obj = Object.create(CoreCryptoWasmCallbacks.prototype);
913
- obj.ptr = ptr;
914
-
915
- return obj;
916
- }
917
-
918
- __destroy_into_raw() {
919
- const ptr = this.ptr;
920
- this.ptr = 0;
921
-
922
- return ptr;
923
- }
924
-
925
- free() {
926
- const ptr = this.__destroy_into_raw();
927
- wasm$1.__wbg_corecryptowasmcallbacks_free(ptr);
928
- }
929
- /**
930
- * @param {Function} authorize
931
- * @param {Function} is_user_in_group
932
- */
933
- constructor(authorize, is_user_in_group) {
934
- const ret = wasm$1.corecryptowasmcallbacks_new(addHeapObject(authorize), addHeapObject(is_user_in_group));
935
- return CoreCryptoWasmCallbacks.__wrap(ret);
936
- }
937
- }
938
- /**
939
- * see [core_crypto::prelude::decrypt::MlsConversationDecryptMessage]
940
- */
941
- class DecryptedMessage {
942
-
943
- static __wrap(ptr) {
944
- const obj = Object.create(DecryptedMessage.prototype);
945
- obj.ptr = ptr;
946
-
947
- return obj;
948
- }
949
-
950
- __destroy_into_raw() {
951
- const ptr = this.ptr;
952
- this.ptr = 0;
953
-
954
- return ptr;
955
- }
956
-
957
- free() {
958
- const ptr = this.__destroy_into_raw();
959
- wasm$1.__wbg_decryptedmessage_free(ptr);
960
- }
961
- /**
962
- * @returns {Uint8Array | undefined}
963
- */
964
- get message() {
965
- const ret = wasm$1.decryptedmessage_message(this.ptr);
966
- return takeObject(ret);
967
- }
968
- /**
969
- * @returns {Array<any>}
970
- */
971
- get proposals() {
972
- const ret = wasm$1.decryptedmessage_proposals(this.ptr);
973
- return takeObject(ret);
974
- }
975
- /**
976
- * @returns {boolean}
977
- */
978
- get is_active() {
979
- const ret = wasm$1.decryptedmessage_is_active(this.ptr);
980
- return ret !== 0;
981
- }
982
- /**
983
- * @returns {number | undefined}
984
- */
985
- get commit_delay() {
986
- try {
987
- const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
988
- wasm$1.decryptedmessage_commit_delay(retptr, this.ptr);
989
- var r0 = getInt32Memory0()[retptr / 4 + 0];
990
- var r1 = getInt32Memory0()[retptr / 4 + 1];
991
- return r0 === 0 ? undefined : r1 >>> 0;
992
- } finally {
993
- wasm$1.__wbindgen_add_to_stack_pointer(16);
994
- }
995
- }
996
- }
997
- /**
998
- * see [core_crypto::prelude::ConversationMember]
999
- */
1000
- class Invitee {
1001
-
1002
- static __wrap(ptr) {
1003
- const obj = Object.create(Invitee.prototype);
1004
- obj.ptr = ptr;
1005
-
1006
- return obj;
1007
- }
1008
-
1009
- __destroy_into_raw() {
1010
- const ptr = this.ptr;
1011
- this.ptr = 0;
1012
-
1013
- return ptr;
1014
- }
1015
-
1016
- free() {
1017
- const ptr = this.__destroy_into_raw();
1018
- wasm$1.__wbg_invitee_free(ptr);
1019
- }
1020
- /**
1021
- * @param {Uint8Array} id
1022
- * @param {Uint8Array} kp
1023
- */
1024
- constructor(id, kp) {
1025
- const ret = wasm$1.invitee_new(addHeapObject(id), addHeapObject(kp));
1026
- return Invitee.__wrap(ret);
1027
- }
1028
- /**
1029
- * @returns {Uint8Array}
1030
- */
1031
- get id() {
1032
- const ret = wasm$1.invitee_id(this.ptr);
1033
- return takeObject(ret);
1034
- }
1035
- /**
1036
- * @returns {Uint8Array}
1037
- */
1038
- get kp() {
1039
- const ret = wasm$1.invitee_kp(this.ptr);
1040
- return takeObject(ret);
1041
- }
1042
- }
1043
- /**
1044
- * see [core_crypto::prelude::MlsConversationCreationMessage]
1045
- */
1046
- class MemberAddedMessages {
1047
-
1048
- static __wrap(ptr) {
1049
- const obj = Object.create(MemberAddedMessages.prototype);
1050
- obj.ptr = ptr;
1051
-
1052
- return obj;
1053
- }
1054
-
1055
- __destroy_into_raw() {
1056
- const ptr = this.ptr;
1057
- this.ptr = 0;
1058
-
1059
- return ptr;
1060
- }
1061
-
1062
- free() {
1063
- const ptr = this.__destroy_into_raw();
1064
- wasm$1.__wbg_memberaddedmessages_free(ptr);
1065
- }
1066
- /**
1067
- * @param {Uint8Array} welcome
1068
- * @param {Uint8Array} commit
1069
- * @param {Uint8Array} public_group_state
1070
- */
1071
- constructor(welcome, commit, public_group_state) {
1072
- const ret = wasm$1.memberaddedmessages_new(addHeapObject(welcome), addHeapObject(commit), addHeapObject(public_group_state));
1073
- return MemberAddedMessages.__wrap(ret);
1074
- }
1075
- /**
1076
- * @returns {Uint8Array}
1077
- */
1078
- get welcome() {
1079
- const ret = wasm$1.memberaddedmessages_welcome(this.ptr);
1080
- return takeObject(ret);
1081
- }
1082
- /**
1083
- * @returns {Uint8Array}
1084
- */
1085
- get commit() {
1086
- const ret = wasm$1.memberaddedmessages_commit(this.ptr);
1087
- return takeObject(ret);
1088
- }
1089
- /**
1090
- * @returns {Uint8Array}
1091
- */
1092
- get public_group_state() {
1093
- const ret = wasm$1.memberaddedmessages_public_group_state(this.ptr);
1094
- return takeObject(ret);
1095
- }
1096
- }
1097
- /**
1098
- */
1099
- class MlsConversationInitMessage {
1100
-
1101
- __destroy_into_raw() {
1102
- const ptr = this.ptr;
1103
- this.ptr = 0;
1104
-
1105
- return ptr;
1106
- }
1107
-
1108
- free() {
1109
- const ptr = this.__destroy_into_raw();
1110
- wasm$1.__wbg_mlsconversationinitmessage_free(ptr);
1111
- }
1112
- /**
1113
- * @returns {Uint8Array}
1114
- */
1115
- get commit() {
1116
- const ret = wasm$1.mlsconversationinitmessage_commit(this.ptr);
1117
- return takeObject(ret);
1118
- }
1119
- /**
1120
- * @returns {Uint8Array}
1121
- */
1122
- get group() {
1123
- const ret = wasm$1.mlsconversationinitmessage_group(this.ptr);
1124
- return takeObject(ret);
1125
- }
1126
- }
1127
- /**
1128
- */
1129
- class ProposalBundle {
1130
-
1131
- static __wrap(ptr) {
1132
- const obj = Object.create(ProposalBundle.prototype);
1133
- obj.ptr = ptr;
1134
-
1135
- return obj;
1136
- }
1137
-
1138
- __destroy_into_raw() {
1139
- const ptr = this.ptr;
1140
- this.ptr = 0;
1141
-
1142
- return ptr;
1143
- }
1144
-
1145
- free() {
1146
- const ptr = this.__destroy_into_raw();
1147
- wasm$1.__wbg_proposalbundle_free(ptr);
1148
- }
1149
- /**
1150
- * @returns {Uint8Array}
1151
- */
1152
- get proposal() {
1153
- const ret = wasm$1.proposalbundle_proposal(this.ptr);
1154
- return takeObject(ret);
1155
- }
1156
- /**
1157
- * @returns {Uint8Array}
1158
- */
1159
- get proposal_ref() {
1160
- const ret = wasm$1.proposalbundle_proposal_ref(this.ptr);
1161
- return takeObject(ret);
1162
- }
1163
- }
1164
-
1165
- async function load(module, imports) {
1166
- if (typeof Response === 'function' && module instanceof Response) {
1167
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1168
- try {
1169
- return await WebAssembly.instantiateStreaming(module, imports);
1170
-
1171
- } catch (e) {
1172
- if (module.headers.get('Content-Type') != 'application/wasm') {
1173
- 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);
1174
-
1175
- } else {
1176
- throw e;
1177
- }
1178
- }
1179
- }
1180
-
1181
- const bytes = await module.arrayBuffer();
1182
- return await WebAssembly.instantiate(bytes, imports);
1183
-
1184
- } else {
1185
- const instance = await WebAssembly.instantiate(module, imports);
1186
-
1187
- if (instance instanceof WebAssembly.Instance) {
1188
- return { instance, module };
1189
-
1190
- } else {
1191
- return instance;
1192
- }
1193
- }
1194
- }
1195
-
1196
- function getImports() {
1197
- const imports = {};
1198
- imports.wbg = {};
1199
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1200
- const ret = getObject(arg0);
1201
- return addHeapObject(ret);
1202
- };
1203
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1204
- takeObject(arg0);
1205
- };
1206
- imports.wbg.__wbindgen_is_object = function(arg0) {
1207
- const val = getObject(arg0);
1208
- const ret = typeof(val) === 'object' && val !== null;
1209
- return ret;
1210
- };
1211
- imports.wbg.__wbg_new_e6a9fecc2bf26696 = function() {
1212
- const ret = new Object();
1213
- return addHeapObject(ret);
1214
- };
1215
- imports.wbg.__wbg_set_e93b31d47b90bff6 = function(arg0, arg1, arg2) {
1216
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1217
- };
1218
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
1219
- const ret = new Error(getStringFromWasm0(arg0, arg1));
1220
- return addHeapObject(ret);
1221
- };
1222
- imports.wbg.__wbg_new0_adda2d4bcb124f0a = function() {
1223
- const ret = new Date();
1224
- return addHeapObject(ret);
1225
- };
1226
- imports.wbg.__wbg_getTime_58b0bdbebd4ef11d = function(arg0) {
1227
- const ret = getObject(arg0).getTime();
1228
- return ret;
1229
- };
1230
- imports.wbg.__wbg_new_cda198d9dbc6d7ea = function(arg0) {
1231
- const ret = new Uint8Array(getObject(arg0));
1232
- return addHeapObject(ret);
1233
- };
1234
- imports.wbg.__wbindgen_bigint_new = function(arg0, arg1) {
1235
- const ret = BigInt(getStringFromWasm0(arg0, arg1));
1236
- return addHeapObject(ret);
1237
- };
1238
- imports.wbg.__wbg_new_ee1a3da85465d621 = function() {
1239
- const ret = new Array();
1240
- return addHeapObject(ret);
1241
- };
1242
- imports.wbg.__wbg_push_0bc7fce4a139a883 = function(arg0, arg1) {
1243
- const ret = getObject(arg0).push(getObject(arg1));
1244
- return ret;
1245
- };
1246
- imports.wbg.__wbg_decryptedmessage_new = function(arg0) {
1247
- const ret = DecryptedMessage.__wrap(arg0);
1248
- return addHeapObject(ret);
1249
- };
1250
- imports.wbg.__wbindgen_number_new = function(arg0) {
1251
- const ret = arg0;
1252
- return addHeapObject(ret);
1253
- };
1254
- imports.wbg.__wbg_corecrypto_new = function(arg0) {
1255
- const ret = CoreCrypto$1.__wrap(arg0);
1256
- return addHeapObject(ret);
1257
- };
1258
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1259
- const ret = getStringFromWasm0(arg0, arg1);
1260
- return addHeapObject(ret);
1261
- };
1262
- imports.wbg.__wbindgen_boolean_get = function(arg0) {
1263
- const v = getObject(arg0);
1264
- const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
1265
- return ret;
1266
- };
1267
- imports.wbg.__wbg_new_52205195aa880fc2 = function(arg0, arg1) {
1268
- try {
1269
- var state0 = {a: arg0, b: arg1};
1270
- var cb0 = (arg0, arg1) => {
1271
- const a = state0.a;
1272
- state0.a = 0;
1273
- try {
1274
- return __wbg_adapter_176(a, state0.b, arg0, arg1);
1275
- } finally {
1276
- state0.a = a;
1277
- }
1278
- };
1279
- const ret = new Promise(cb0);
1280
- return addHeapObject(ret);
1281
- } finally {
1282
- state0.a = state0.b = 0;
1283
- }
1284
- };
1285
- imports.wbg.__wbg_proposalbundle_new = function(arg0) {
1286
- const ret = ProposalBundle.__wrap(arg0);
1287
- return addHeapObject(ret);
1288
- };
1289
- imports.wbg.__wbg_get_093fe3cdafaf8976 = function(arg0, arg1) {
1290
- const ret = getObject(arg0)[takeObject(arg1)];
1291
- return addHeapObject(ret);
1292
- };
1293
- imports.wbg.__wbg_isArray_a1a8c3a8ac24bdf1 = function(arg0) {
1294
- const ret = Array.isArray(getObject(arg0));
1295
- return ret;
1296
- };
1297
- imports.wbg.__wbg_length_a73bfd4c96dd97ef = function(arg0) {
1298
- const ret = getObject(arg0).length;
1299
- return ret;
1300
- };
1301
- imports.wbg.__wbg_iterator_22ed2b976832ff0c = function() {
1302
- const ret = Symbol.iterator;
1303
- return addHeapObject(ret);
1304
- };
1305
- imports.wbg.__wbg_get_72332cd2bc57924c = function() { return handleError(function (arg0, arg1) {
1306
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
1307
- return addHeapObject(ret);
1308
- }, arguments) };
1309
- imports.wbg.__wbindgen_is_function = function(arg0) {
1310
- const ret = typeof(getObject(arg0)) === 'function';
1311
- return ret;
1312
- };
1313
- imports.wbg.__wbg_call_33d7bcddbbfa394a = function() { return handleError(function (arg0, arg1) {
1314
- const ret = getObject(arg0).call(getObject(arg1));
1315
- return addHeapObject(ret);
1316
- }, arguments) };
1317
- imports.wbg.__wbg_next_726d1c2255989269 = function(arg0) {
1318
- const ret = getObject(arg0).next;
1319
- return addHeapObject(ret);
1320
- };
1321
- imports.wbg.__wbg_next_3d0c4cc33e7418c9 = function() { return handleError(function (arg0) {
1322
- const ret = getObject(arg0).next();
1323
- return addHeapObject(ret);
1324
- }, arguments) };
1325
- imports.wbg.__wbg_done_e5655b169bb04f60 = function(arg0) {
1326
- const ret = getObject(arg0).done;
1327
- return ret;
1328
- };
1329
- imports.wbg.__wbg_value_8f901bca1014f843 = function(arg0) {
1330
- const ret = getObject(arg0).value;
1331
- return addHeapObject(ret);
1332
- };
1333
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
1334
- const obj = getObject(arg1);
1335
- const ret = typeof(obj) === 'number' ? obj : undefined;
1336
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
1337
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
1338
- };
1339
- imports.wbg.__wbg_isSafeInteger_f6dd91807e9c4d35 = function(arg0) {
1340
- const ret = Number.isSafeInteger(getObject(arg0));
1341
- return ret;
1342
- };
1343
- imports.wbg.__wbg_get_ad41fee29b7e0f53 = function(arg0, arg1) {
1344
- const ret = getObject(arg0)[arg1 >>> 0];
1345
- return addHeapObject(ret);
1346
- };
1347
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
1348
- const obj = getObject(arg1);
1349
- const ret = typeof(obj) === 'string' ? obj : undefined;
1350
- var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1351
- var len0 = WASM_VECTOR_LEN;
1352
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1353
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1354
- };
1355
- imports.wbg.__wbindgen_is_null = function(arg0) {
1356
- const ret = getObject(arg0) === null;
1357
- return ret;
1358
- };
1359
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
1360
- const ret = getObject(arg0) === undefined;
1361
- return ret;
1362
- };
1363
- imports.wbg.__wbg_name_f232931b09239ddb = function(arg0, arg1) {
1364
- const ret = getObject(arg1).name;
1365
- const ptr0 = passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1366
- const len0 = WASM_VECTOR_LEN;
1367
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1368
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1369
- };
1370
- imports.wbg.__wbg_transaction_0dcffc72158c7b6f = function() { return handleError(function (arg0, arg1, arg2) {
1371
- const ret = getObject(arg0).transaction(getObject(arg1), takeObject(arg2));
1372
- return addHeapObject(ret);
1373
- }, arguments) };
1374
- imports.wbg.__wbg_set_64cc39858b2ec3f1 = function(arg0, arg1, arg2) {
1375
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1376
- };
1377
- imports.wbg.__wbindgen_cb_drop = function(arg0) {
1378
- const obj = takeObject(arg0).original;
1379
- if (obj.cnt-- == 1) {
1380
- obj.a = 0;
1381
- return true;
1382
- }
1383
- const ret = false;
1384
- return ret;
1385
- };
1386
- imports.wbg.__wbg_commit_6211fe2744b83edc = function() { return handleError(function (arg0) {
1387
- getObject(arg0).commit();
1388
- }, arguments) };
1389
- imports.wbg.__wbg_setoncomplete_8bfbade4ed628fd0 = function(arg0, arg1) {
1390
- getObject(arg0).oncomplete = getObject(arg1);
1391
- };
1392
- imports.wbg.__wbg_setonerror_9d842115702fd223 = function(arg0, arg1) {
1393
- getObject(arg0).onerror = getObject(arg1);
1394
- };
1395
- imports.wbg.__wbg_put_e193e5c9c96e937f = function() { return handleError(function (arg0, arg1, arg2) {
1396
- const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
1397
- return addHeapObject(ret);
1398
- }, arguments) };
1399
- imports.wbg.__wbg_put_a727d1fdb5788ec1 = function() { return handleError(function (arg0, arg1) {
1400
- const ret = getObject(arg0).put(getObject(arg1));
1401
- return addHeapObject(ret);
1402
- }, arguments) };
1403
- imports.wbg.__wbg_setonsuccess_bb91afe1f8110021 = function(arg0, arg1) {
1404
- getObject(arg0).onsuccess = getObject(arg1);
1405
- };
1406
- imports.wbg.__wbg_setonerror_db491b84dd45e918 = function(arg0, arg1) {
1407
- getObject(arg0).onerror = getObject(arg1);
1408
- };
1409
- imports.wbg.__wbg_openCursor_4292a52d0e6d4246 = function() { return handleError(function (arg0, arg1) {
1410
- const ret = getObject(arg0).openCursor(getObject(arg1));
1411
- return addHeapObject(ret);
1412
- }, arguments) };
1413
- imports.wbg.__wbg_openCursor_10a7a7a41fce054c = function() { return handleError(function (arg0) {
1414
- const ret = getObject(arg0).openCursor();
1415
- return addHeapObject(ret);
1416
- }, arguments) };
1417
- imports.wbg.__wbg_delete_1ca98818fdc40291 = function() { return handleError(function (arg0, arg1) {
1418
- const ret = getObject(arg0).delete(getObject(arg1));
1419
- return addHeapObject(ret);
1420
- }, arguments) };
1421
- imports.wbg.__wbg_get_28f9ffc7eb5802f3 = function() { return handleError(function (arg0, arg1) {
1422
- const ret = getObject(arg0).get(getObject(arg1));
1423
- return addHeapObject(ret);
1424
- }, arguments) };
1425
- imports.wbg.__wbg_open_2a1e9120d3d8897d = function() { return handleError(function (arg0, arg1, arg2) {
1426
- const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
1427
- return addHeapObject(ret);
1428
- }, arguments) };
1429
- imports.wbg.__wbg_open_3384efa97bde264f = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1430
- const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
1431
- return addHeapObject(ret);
1432
- }, arguments) };
1433
- imports.wbg.__wbg_setonupgradeneeded_8956d6214819f478 = function(arg0, arg1) {
1434
- getObject(arg0).onupgradeneeded = getObject(arg1);
1435
- };
1436
- imports.wbg.__wbg_count_6f4c35312ff0234d = function() { return handleError(function (arg0) {
1437
- const ret = getObject(arg0).count();
1438
- return addHeapObject(ret);
1439
- }, arguments) };
1440
- imports.wbg.__wbg_count_ea5300005a5f227d = function() { return handleError(function (arg0, arg1) {
1441
- const ret = getObject(arg0).count(getObject(arg1));
1442
- return addHeapObject(ret);
1443
- }, arguments) };
1444
- imports.wbg.__wbg_deleteDatabase_7b98d08298856363 = function() { return handleError(function (arg0, arg1, arg2) {
1445
- const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
1446
- return addHeapObject(ret);
1447
- }, arguments) };
1448
- imports.wbg.__wbg_close_87495affacd7f79d = function(arg0) {
1449
- getObject(arg0).close();
1450
- };
1451
- imports.wbg.__wbg_get_a06b4198f86b037d = function() { return handleError(function (arg0, arg1) {
1452
- const ret = getObject(arg0).get(getObject(arg1));
1453
- return addHeapObject(ret);
1454
- }, arguments) };
1455
- imports.wbg.__wbg_openCursor_a9656bd0901e39c0 = function() { return handleError(function (arg0) {
1456
- const ret = getObject(arg0).openCursor();
1457
- return addHeapObject(ret);
1458
- }, arguments) };
1459
- imports.wbg.__wbg_openCursor_2cfe2e04de0b6b91 = function() { return handleError(function (arg0, arg1) {
1460
- const ret = getObject(arg0).openCursor(getObject(arg1));
1461
- return addHeapObject(ret);
1462
- }, arguments) };
1463
- imports.wbg.__wbg_randomFillSync_91e2b39becca6147 = function() { return handleError(function (arg0, arg1, arg2) {
1464
- getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
1465
- }, arguments) };
1466
- imports.wbg.__wbg_subarray_270ff8dd5582c1ac = function(arg0, arg1, arg2) {
1467
- const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1468
- return addHeapObject(ret);
1469
- };
1470
- imports.wbg.__wbg_getRandomValues_b14734aa289bc356 = function() { return handleError(function (arg0, arg1) {
1471
- getObject(arg0).getRandomValues(getObject(arg1));
1472
- }, arguments) };
1473
- imports.wbg.__wbg_length_51f19f73d6d9eff3 = function(arg0) {
1474
- const ret = getObject(arg0).length;
1475
- return ret;
1476
- };
1477
- imports.wbg.__wbg_process_e56fd54cf6319b6c = function(arg0) {
1478
- const ret = getObject(arg0).process;
1479
- return addHeapObject(ret);
1480
- };
1481
- imports.wbg.__wbg_versions_77e21455908dad33 = function(arg0) {
1482
- const ret = getObject(arg0).versions;
1483
- return addHeapObject(ret);
1484
- };
1485
- imports.wbg.__wbg_node_0dd25d832e4785d5 = function(arg0) {
1486
- const ret = getObject(arg0).node;
1487
- return addHeapObject(ret);
1488
- };
1489
- imports.wbg.__wbindgen_is_string = function(arg0) {
1490
- const ret = typeof(getObject(arg0)) === 'string';
1491
- return ret;
1492
- };
1493
- imports.wbg.__wbg_static_accessor_NODE_MODULE_26b231378c1be7dd = function() {
1494
- const ret = module;
1495
- return addHeapObject(ret);
1496
- };
1497
- imports.wbg.__wbg_require_0db1598d9ccecb30 = function() { return handleError(function (arg0, arg1, arg2) {
1498
- const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
1499
- return addHeapObject(ret);
1500
- }, arguments) };
1501
- imports.wbg.__wbg_crypto_b95d7173266618a9 = function(arg0) {
1502
- const ret = getObject(arg0).crypto;
1503
- return addHeapObject(ret);
1504
- };
1505
- imports.wbg.__wbg_msCrypto_5a86d77a66230f81 = function(arg0) {
1506
- const ret = getObject(arg0).msCrypto;
1507
- return addHeapObject(ret);
1508
- };
1509
- imports.wbg.__wbg_newwithlength_66e5530e7079ea1b = function(arg0) {
1510
- const ret = new Uint8Array(arg0 >>> 0);
1511
- return addHeapObject(ret);
1512
- };
1513
- imports.wbg.__wbg_self_fd00a1ef86d1b2ed = function() { return handleError(function () {
1514
- const ret = self.self;
1515
- return addHeapObject(ret);
1516
- }, arguments) };
1517
- imports.wbg.__wbg_window_6f6e346d8bbd61d7 = function() { return handleError(function () {
1518
- const ret = window.window;
1519
- return addHeapObject(ret);
1520
- }, arguments) };
1521
- imports.wbg.__wbg_globalThis_3348936ac49df00a = function() { return handleError(function () {
1522
- const ret = globalThis.globalThis;
1523
- return addHeapObject(ret);
1524
- }, arguments) };
1525
- imports.wbg.__wbg_global_67175caf56f55ca9 = function() { return handleError(function () {
1526
- const ret = global.global;
1527
- return addHeapObject(ret);
1528
- }, arguments) };
1529
- imports.wbg.__wbg_newnoargs_971e9a5abe185139 = function(arg0, arg1) {
1530
- const ret = new Function(getStringFromWasm0(arg0, arg1));
1531
- return addHeapObject(ret);
1532
- };
1533
- imports.wbg.__wbg_call_65af9f665ab6ade5 = function() { return handleError(function (arg0, arg1, arg2) {
1534
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1535
- return addHeapObject(ret);
1536
- }, arguments) };
1537
- imports.wbg.__wbg_call_187e4e7f6f4285fb = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1538
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
1539
- return addHeapObject(ret);
1540
- }, arguments) };
1541
- imports.wbg.__wbg_set_2762e698c2f5b7e0 = function() { return handleError(function (arg0, arg1, arg2) {
1542
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1543
- return ret;
1544
- }, arguments) };
1545
- imports.wbg.__wbindgen_memory = function() {
1546
- const ret = wasm$1.memory;
1547
- return addHeapObject(ret);
1548
- };
1549
- imports.wbg.__wbg_buffer_34f5ec9f8a838ba0 = function(arg0) {
1550
- const ret = getObject(arg0).buffer;
1551
- return addHeapObject(ret);
1552
- };
1553
- imports.wbg.__wbg_newwithbyteoffsetandlength_88fdad741db1b182 = function(arg0, arg1, arg2) {
1554
- const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
1555
- return addHeapObject(ret);
1556
- };
1557
- imports.wbg.__wbg_set_1a930cfcda1a8067 = function(arg0, arg1, arg2) {
1558
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
1559
- };
1560
- imports.wbg.__wbg_now_1b6e18d94ce2c037 = function() {
1561
- const ret = Date.now();
1562
- return ret;
1563
- };
1564
- imports.wbg.__wbg_target_68a5c10e2732a79e = function(arg0) {
1565
- const ret = getObject(arg0).target;
1566
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1567
- };
1568
- imports.wbg.__wbg_error_c872d3f7251736f1 = function() { return handleError(function (arg0) {
1569
- const ret = getObject(arg0).error;
1570
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1571
- }, arguments) };
1572
- imports.wbg.__wbg_objectStoreNames_d11a3d06e3226638 = function(arg0) {
1573
- const ret = getObject(arg0).objectStoreNames;
1574
- return addHeapObject(ret);
1575
- };
1576
- imports.wbg.__wbg_contains_bcaf1388e1ca982c = function(arg0, arg1, arg2) {
1577
- const ret = getObject(arg0).contains(getStringFromWasm0(arg1, arg2));
1578
- return ret;
1579
- };
1580
- imports.wbg.__wbg_createObjectStore_454d7cf701faa545 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1581
- const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2), getObject(arg3));
1582
- return addHeapObject(ret);
1583
- }, arguments) };
1584
- imports.wbg.__wbg_transaction_0ba302b35542323f = function(arg0) {
1585
- const ret = getObject(arg0).transaction;
1586
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1587
- };
1588
- imports.wbg.__wbg_indexNames_8f97f1f79bc278bf = function(arg0) {
1589
- const ret = getObject(arg0).indexNames;
1590
- return addHeapObject(ret);
1591
- };
1592
- imports.wbg.__wbg_createIndex_20c39366f6b22548 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1593
- const ret = getObject(arg0).createIndex(getStringFromWasm0(arg1, arg2), getObject(arg3), getObject(arg4));
1594
- return addHeapObject(ret);
1595
- }, arguments) };
1596
- imports.wbg.__wbg_length_580a8f6d9757b9da = function(arg0) {
1597
- const ret = getObject(arg0).length;
1598
- return ret;
1599
- };
1600
- imports.wbg.__wbg_deleteIndex_9d33d4fd04e9038c = function() { return handleError(function (arg0, arg1, arg2) {
1601
- getObject(arg0).deleteIndex(getStringFromWasm0(arg1, arg2));
1602
- }, arguments) };
1603
- imports.wbg.__wbg_deleteObjectStore_ec34033b22e0c4e1 = function() { return handleError(function (arg0, arg1, arg2) {
1604
- getObject(arg0).deleteObjectStore(getStringFromWasm0(arg1, arg2));
1605
- }, arguments) };
1606
- imports.wbg.__wbindgen_is_falsy = function(arg0) {
1607
- const ret = !getObject(arg0);
1608
- return ret;
1609
- };
1610
- imports.wbg.__wbg_key_3ce14c27a234543a = function() { return handleError(function (arg0) {
1611
- const ret = getObject(arg0).key;
1612
- return addHeapObject(ret);
1613
- }, arguments) };
1614
- imports.wbg.__wbg_advance_5da26ebf2f15b82e = function() { return handleError(function (arg0, arg1) {
1615
- getObject(arg0).advance(arg1 >>> 0);
1616
- }, arguments) };
1617
- imports.wbg.__wbg_instanceof_IdbFactory_acaddaa9df3f73bc = function(arg0) {
1618
- const ret = getObject(arg0) instanceof IDBFactory;
1619
- return ret;
1620
- };
1621
- imports.wbg.__wbg_index_49e22b15910e16d4 = function() { return handleError(function (arg0, arg1, arg2) {
1622
- const ret = getObject(arg0).index(getStringFromWasm0(arg1, arg2));
1623
- return addHeapObject(ret);
1624
- }, arguments) };
1625
- imports.wbg.__wbg_toString_dc4768002eeae1b0 = function(arg0) {
1626
- const ret = getObject(arg0).toString();
1627
- return addHeapObject(ret);
1628
- };
1629
- imports.wbg.__wbg_new_3ee7ebe9952c1fbd = function(arg0, arg1) {
1630
- const ret = new Error(getStringFromWasm0(arg0, arg1));
1631
- return addHeapObject(ret);
1632
- };
1633
- imports.wbg.__wbg_instanceof_Uint8Array_36c37b9ca15e3e0a = function(arg0) {
1634
- const ret = getObject(arg0) instanceof Uint8Array;
1635
- return ret;
1636
- };
1637
- imports.wbg.__wbg_instanceof_ArrayBuffer_02bbeeb60438c785 = function(arg0) {
1638
- const ret = getObject(arg0) instanceof ArrayBuffer;
1639
- return ret;
1640
- };
1641
- imports.wbg.__wbg_String_7462bcc0fcdbaf7d = function(arg0, arg1) {
1642
- const ret = String(getObject(arg1));
1643
- const ptr0 = passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1644
- const len0 = WASM_VECTOR_LEN;
1645
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1646
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1647
- };
1648
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
1649
- const ret = debugString(getObject(arg1));
1650
- const ptr0 = passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1651
- const len0 = WASM_VECTOR_LEN;
1652
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1653
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1654
- };
1655
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1656
- throw new Error(getStringFromWasm0(arg0, arg1));
1657
- };
1658
- imports.wbg.__wbg_then_18da6e5453572fc8 = function(arg0, arg1) {
1659
- const ret = getObject(arg0).then(getObject(arg1));
1660
- return addHeapObject(ret);
1661
- };
1662
- imports.wbg.__wbg_resolve_0107b3a501450ba0 = function(arg0) {
1663
- const ret = Promise.resolve(getObject(arg0));
1664
- return addHeapObject(ret);
1665
- };
1666
- imports.wbg.__wbg_get_50220f3428ca7e51 = function(arg0, arg1, arg2) {
1667
- const ret = getObject(arg1)[arg2 >>> 0];
1668
- var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1669
- var len0 = WASM_VECTOR_LEN;
1670
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1671
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1672
- };
1673
- imports.wbg.__wbg_continue_43562ff8da972056 = function() { return handleError(function (arg0) {
1674
- getObject(arg0).continue();
1675
- }, arguments) };
1676
- imports.wbg.__wbg_value_a3a782e66c6935d3 = function() { return handleError(function (arg0) {
1677
- const ret = getObject(arg0).value;
1678
- return addHeapObject(ret);
1679
- }, arguments) };
1680
- imports.wbg.__wbg_openCursor_48949b0ae4868b31 = function() { return handleError(function (arg0, arg1, arg2) {
1681
- const ret = getObject(arg0).openCursor(getObject(arg1), takeObject(arg2));
1682
- return addHeapObject(ret);
1683
- }, arguments) };
1684
- imports.wbg.__wbg_openCursor_abefd2bc54b71e0f = function() { return handleError(function (arg0, arg1, arg2) {
1685
- const ret = getObject(arg0).openCursor(getObject(arg1), takeObject(arg2));
1686
- return addHeapObject(ret);
1687
- }, arguments) };
1688
- imports.wbg.__wbg_result_4b44b0d900b4ab6f = function() { return handleError(function (arg0) {
1689
- const ret = getObject(arg0).result;
1690
- return addHeapObject(ret);
1691
- }, arguments) };
1692
- imports.wbg.__wbg_objectStore_76c268be095ec9a5 = function() { return handleError(function (arg0, arg1, arg2) {
1693
- const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
1694
- return addHeapObject(ret);
1695
- }, arguments) };
1696
- imports.wbg.__wbindgen_closure_wrapper2486 = function(arg0, arg1, arg2) {
1697
- const ret = makeMutClosure(arg0, arg1, 105, __wbg_adapter_40);
1698
- return addHeapObject(ret);
1699
- };
1700
- imports.wbg.__wbindgen_closure_wrapper4443 = function(arg0, arg1, arg2) {
1701
- const ret = makeMutClosure(arg0, arg1, 113, __wbg_adapter_43);
1702
- return addHeapObject(ret);
1703
- };
1704
-
1705
- return imports;
1706
- }
1707
-
1708
- function finalizeInit(instance, module) {
1709
- wasm$1 = instance.exports;
1710
- init.__wbindgen_wasm_module = module;
1711
- cachedFloat64Memory0 = new Float64Array();
1712
- cachedInt32Memory0 = new Int32Array();
1713
- cachedUint32Memory0 = new Uint32Array();
1714
- cachedUint8Memory0 = new Uint8Array();
1715
-
1716
-
1717
- return wasm$1;
1718
- }
1719
-
1720
- function initSync(bytes) {
1721
- const imports = getImports();
1722
-
1723
- const module = new WebAssembly.Module(bytes);
1724
- const instance = new WebAssembly.Instance(module, imports);
1725
-
1726
- return finalizeInit(instance, module);
1727
- }
1728
-
1729
- async function init(input) {
1730
- if (typeof input === 'undefined') {
1731
- input = new URL('index_bg.wasm', import.meta.url);
1732
- }
1733
- const imports = getImports();
1734
-
1735
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
1736
- input = fetch(input);
1737
- }
1738
-
1739
- const { instance, module } = await load(await input, imports);
1740
-
1741
- return finalizeInit(instance, module);
1742
- }
1743
-
1744
- var exports = /*#__PURE__*/Object.freeze({
1745
- __proto__: null,
1746
- version: version,
1747
- Ciphersuite: Ciphersuite,
1748
- CommitBundle: CommitBundle,
1749
- ConversationConfiguration: ConversationConfiguration,
1750
- CoreCrypto: CoreCrypto$1,
1751
- CoreCryptoWasmCallbacks: CoreCryptoWasmCallbacks,
1752
- DecryptedMessage: DecryptedMessage,
1753
- Invitee: Invitee,
1754
- MemberAddedMessages: MemberAddedMessages,
1755
- MlsConversationInitMessage: MlsConversationInitMessage,
1756
- ProposalBundle: ProposalBundle,
1757
- initSync: initSync,
1758
- 'default': init
1759
- });
1760
-
1761
- var wasm = async (opt = {}) => {
1762
- let {importHook, serverPath} = opt;
1763
-
1764
- let path = "assets/core_crypto_ffi-e63ef1c1.wasm";
1765
-
1766
- if (serverPath != null) {
1767
- path = serverPath + /[^\/\\]*$/.exec(path)[0];
1768
- }
1769
-
1770
- if (importHook != null) {
1771
- path = importHook(path);
1772
- }
1773
-
1774
- await init(path);
1775
- return exports;
1776
- };
1777
-
1778
- // Wire
1779
- /**
1780
- * Wrapper for the WASM-compiled version of CoreCrypto
1781
- */
1782
- class CoreCrypto {
1783
- /** @hidden */
1784
- constructor(cc) {
1785
- this.#cc = cc;
1786
- }
1787
- /** @hidden */
1788
- static #module;
1789
- /** @hidden */
1790
- #cc;
1791
- /**
1792
- * This is your entrypoint to initialize {@link CoreCrypto}!
1793
- *
1794
- * @param params - {@link CoreCryptoParams}
1795
- *
1796
- * @example
1797
- * ## Simple init
1798
- * ```ts
1799
- * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1800
- * // Do the rest with `cc`
1801
- * ```
1802
- *
1803
- * ## Custom Entropy seed init & wasm file location
1804
- * ```ts
1805
- * // FYI, this is the IETF test vector #1
1806
- * const entropySeed = Uint32Array.from([
1807
- * 0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
1808
- * 0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b,
1809
- * 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8,
1810
- * 0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2,
1811
- * ]);
1812
- *
1813
- * const wasmFilePath = "/long/complicated/path/on/webserver/whatever.wasm";
1814
- *
1815
- * const cc = await CoreCrypto.init({
1816
- * databaseName: "test",
1817
- * key: "test",
1818
- * clientId: "test",
1819
- * entropySeed,
1820
- * wasmFilePath,
1821
- * });
1822
- * ````
1823
- */
1824
- static async init({ databaseName, key, clientId, wasmFilePath, entropySeed }) {
1825
- if (!this.#module) {
1826
- const wasmImportArgs = wasmFilePath ? { importHook: () => wasmFilePath } : undefined;
1827
- const exports = (await wasm(wasmImportArgs));
1828
- this.#module = exports;
1829
- }
1830
- const cc = await this.#module.CoreCrypto._internal_new(databaseName, key, clientId, entropySeed);
1831
- return new this(cc);
1832
- }
1833
- /**
1834
- * Wipes the {@link CoreCrypto} backing storage (i.e. {@link https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API | IndexedDB} database)
1835
- *
1836
- * **CAUTION**: This {@link CoreCrypto} instance won't be useable after a call to this method, but there's no way to express this requirement in TypeScript so you'll get errors instead!
1837
- */
1838
- async wipe() {
1839
- await this.#cc.wipe();
1840
- }
1841
- /**
1842
- * Closes this {@link CoreCrypto} instance and deallocates all loaded resources
1843
- *
1844
- * **CAUTION**: This {@link CoreCrypto} instance won't be useable after a call to this method, but there's no way to express this requirement in TypeScript so you'll get errors instead!
1845
- */
1846
- async close() {
1847
- await this.#cc.close();
1848
- }
1849
- /**
1850
- * Checks if the Client is member of a given conversation and if the MLS Group is loaded up
1851
- *
1852
- * @returns Whether the given conversation ID exists
1853
- *
1854
- * @example
1855
- * ```ts
1856
- * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1857
- * const encoder = new TextEncoder();
1858
- * if (await cc.conversationExists(encoder.encode("my super chat"))) {
1859
- * // Do something
1860
- * } else {
1861
- * // Do something else
1862
- * }
1863
- * ```
1864
- */
1865
- async conversationExists(conversationId) {
1866
- return await this.#cc.conversation_exists(conversationId);
1867
- }
1868
- /**
1869
- * Returns the current epoch of a conversation
1870
- *
1871
- * @returns the epoch of the conversation
1872
- *
1873
- * @example
1874
- * ```ts
1875
- * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1876
- * const encoder = new TextEncoder();
1877
- * console.log(await cc.conversationEpoch(encoder.encode("my super chat")))
1878
- * ```
1879
- */
1880
- async conversationEpoch(conversationId) {
1881
- return await this.#cc.conversation_epoch(conversationId);
1882
- }
1883
- /**
1884
- * Wipes and destroys the local storage of a given conversation / MLS group
1885
- *
1886
- * @param conversationId - The ID of the conversation to remove
1887
- */
1888
- async wipeConversation(conversationId) {
1889
- return await this.#cc.wipe_conversation(conversationId);
1890
- }
1891
- /**
1892
- * Creates a new conversation with the current client being the sole member
1893
- * You will want to use {@link CoreCrypto.addClientsToConversation} afterwards to add clients to this conversation
1894
- *
1895
- * @param conversationId - The conversation ID; You can either make them random or let the backend attribute MLS group IDs
1896
- * @param configuration.admins - An array of client IDs that will have administrative permissions over the group
1897
- * @param configuration.ciphersuite - The {@link Ciphersuite} that is chosen to be the group's
1898
- * @param configuration.keyRotationSpan - The amount of time in milliseconds after which the MLS Keypackages will be rotated
1899
- * @param configuration.externalSenders - Array of Client IDs that are qualified as external senders within the group
1900
- */
1901
- async createConversation(conversationId, configuration = {}) {
1902
- const { admins, ciphersuite, keyRotationSpan, externalSenders } = configuration ?? {};
1903
- const config = new CoreCrypto.#module.ConversationConfiguration(admins, ciphersuite, keyRotationSpan, externalSenders);
1904
- const ret = await this.#cc.create_conversation(conversationId, config);
1905
- return ret;
1906
- }
1907
- /**
1908
- * Decrypts a message for a given conversation
1909
- *
1910
- * @param conversationId - The ID of the conversation
1911
- * @param payload - The encrypted message buffer
1912
- *
1913
- * @returns Either a {@link DecryptedMessage} payload or `undefined` - This happens when the encrypted payload contains a system message such a proposal or commit
1914
- */
1915
- async decryptMessage(conversationId, payload) {
1916
- const ffiDecryptedMessage = await this.#cc.decrypt_message(conversationId, payload);
1917
- const commitDelay = ffiDecryptedMessage.commit_delay ?
1918
- ffiDecryptedMessage.commit_delay * 1000 :
1919
- undefined;
1920
- const ret = {
1921
- message: ffiDecryptedMessage.message,
1922
- proposals: ffiDecryptedMessage.proposals,
1923
- isActive: ffiDecryptedMessage.is_active,
1924
- commitDelay
1925
- };
1926
- return ret;
1927
- }
1928
- /**
1929
- * Encrypts a message for a given conversation
1930
- *
1931
- * @param conversationId - The ID of the conversation
1932
- * @param message - The plaintext message to encrypt
1933
- *
1934
- * @returns The encrypted payload for the given group. This needs to be fanned out to the other members of the group.
1935
- */
1936
- async encryptMessage(conversationId, message) {
1937
- return await this.#cc.encrypt_message(conversationId, message);
1938
- }
1939
- /**
1940
- * Ingest a TLS-serialized MLS welcome message to join a an existing MLS group
1941
- *
1942
- * @param welcomeMessage - TLS-serialized MLS Welcome message
1943
- * @returns The conversation ID of the newly joined group. You can use the same ID to decrypt/encrypt messages
1944
- */
1945
- async processWelcomeMessage(welcomeMessage) {
1946
- return await this.#cc.process_welcome_message(welcomeMessage);
1947
- }
1948
- /**
1949
- * @returns The client's public key
1950
- */
1951
- async clientPublicKey() {
1952
- return await this.#cc.client_public_key();
1953
- }
1954
- /**
1955
- * @returns The amount of valid, non-expired KeyPackages that are persisted in the backing storage
1956
- */
1957
- async clientValidKeypackagesCount() {
1958
- return await this.#cc.client_valid_keypackages_count();
1959
- }
1960
- /**
1961
- * Fetches a requested amount of keypackages
1962
- *
1963
- * @param amountRequested - The amount of keypackages requested
1964
- * @returns An array of length `amountRequested` containing TLS-serialized KeyPackages
1965
- */
1966
- async clientKeypackages(amountRequested) {
1967
- return await this.#cc.client_keypackages(amountRequested);
1968
- }
1969
- /**
1970
- * Adds new clients to a conversation, assuming the current client has the right to add new clients to the conversation.
1971
- *
1972
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
1973
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
1974
- * epoch, use new encryption secrets etc...
1975
- *
1976
- * @param conversationId - The ID of the conversation
1977
- * @param clients - Array of {@link Invitee} (which are Client ID / KeyPackage pairs)
1978
- *
1979
- * @returns A {@link CommitBundle}
1980
- */
1981
- async addClientsToConversation(conversationId, clients) {
1982
- const ffiClients = clients.map((invitee) => new CoreCrypto.#module.Invitee(invitee.id, invitee.kp));
1983
- const ffiRet = await this.#cc.add_clients_to_conversation(conversationId, ffiClients);
1984
- ffiClients.forEach(c => c.free());
1985
- const ret = {
1986
- welcome: ffiRet.welcome,
1987
- commit: ffiRet.commit,
1988
- publicGroupState: ffiRet.public_group_state
1989
- };
1990
- return ret;
1991
- }
1992
- /**
1993
- * Removes the provided clients from a conversation; Assuming those clients exist and the current client is allowed
1994
- * to do so, otherwise this operation does nothing.
1995
- *
1996
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
1997
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
1998
- * epoch, use new encryption secrets etc...
1999
- *
2000
- * @param conversationId - The ID of the conversation
2001
- * @param clientIds - Array of Client IDs to remove.
2002
- *
2003
- * @returns A {@link CommitBundle}, or `undefined` if for any reason, the operation would result in an empty commit
2004
- */
2005
- async removeClientsFromConversation(conversationId, clientIds) {
2006
- const ffiRet = await this.#cc.remove_clients_from_conversation(conversationId, clientIds);
2007
- const ret = {
2008
- welcome: ffiRet.welcome,
2009
- commit: ffiRet.commit,
2010
- publicGroupState: ffiRet.public_group_state
2011
- };
2012
- return ret;
2013
- }
2014
- /**
2015
- * Creates an update commit which forces every client to update their keypackages in the conversation
2016
- *
2017
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2018
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2019
- * epoch, use new encryption secrets etc...
2020
- *
2021
- * @param conversationId - The ID of the conversation
2022
- *
2023
- * @returns A {@link CommitBundle}
2024
- */
2025
- async updateKeyingMaterial(conversationId) {
2026
- const ffiRet = await this.#cc.update_keying_material(conversationId);
2027
- const ret = {
2028
- welcome: ffiRet.welcome,
2029
- commit: ffiRet.commit,
2030
- publicGroupState: ffiRet.public_group_state
2031
- };
2032
- return ret;
2033
- }
2034
- /**
2035
- * Commits the local pending proposals and returns the {@link CommitBundle} object containing what can result from this operation.
2036
- *
2037
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2038
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2039
- * epoch, use new encryption secrets etc...
2040
- *
2041
- * @param conversationId - The ID of the conversation
2042
- *
2043
- * @returns A {@link CommitBundle}
2044
- */
2045
- async commitPendingProposals(conversationId) {
2046
- const ffiCommitBundle = await this.#cc.commit_pending_proposals(conversationId);
2047
- const ret = {
2048
- welcome: ffiCommitBundle.welcome,
2049
- commit: ffiCommitBundle.commit,
2050
- publicGroupState: ffiCommitBundle.public_group_state
2051
- };
2052
- return ret;
2053
- }
2054
- /**
2055
- * Adds new clients to a conversation, assuming the current client has the right to add new clients to the conversation.
2056
- * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2057
- * It also contains a Welcome message the Delivery Service will forward to invited clients and
2058
- * an updated PublicGroupState required by clients willing to join the group by an external commit.
2059
- *
2060
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2061
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2062
- * epoch, use new encryption secrets etc...
2063
- *
2064
- * @param conversationId - The ID of the conversation
2065
- * @param clients - Array of {@link Invitee} (which are Client ID / KeyPackage pairs)
2066
- *
2067
- * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service
2068
- */
2069
- async finalAddClientsToConversation(conversationId, clients) {
2070
- const ffiClients = clients.map((invitee) => new CoreCrypto.#module.Invitee(invitee.id, invitee.kp));
2071
- const ret = await this.#cc.add_clients_to_conversation(conversationId, ffiClients);
2072
- ffiClients.forEach(c => c.free());
2073
- return ret;
2074
- }
2075
- /**
2076
- * Removes the provided clients from a conversation; Assuming those clients exist and the current client is allowed
2077
- * to do so, otherwise this operation does nothing.
2078
- *
2079
- * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2080
- * It also contains a Welcome message the Delivery Service will forward to invited clients and
2081
- * an updated PublicGroupState required by clients willing to join the group by an external commit.
2082
- *
2083
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2084
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2085
- * epoch, use new encryption secrets etc...
2086
- *
2087
- * @param conversationId - The ID of the conversation
2088
- * @param clientIds - Array of Client IDs to remove.
2089
- *
2090
- * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service, or `undefined` if for any reason, the operation would result in an empty commit
2091
- */
2092
- async finalRemoveClientsFromConversation(conversationId, clientIds) {
2093
- return await this.#cc.remove_clients_from_conversation(conversationId, clientIds);
2094
- }
2095
- /**
2096
- * Creates an update commit which forces every client to update their keypackages in the conversation
2097
- *
2098
- * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2099
- * It also contains a Welcome message the Delivery Service will forward to invited clients and
2100
- * an updated PublicGroupState required by clients willing to join the group by an external commit.
2101
- *
2102
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2103
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2104
- * epoch, use new encryption secrets etc...
2105
- *
2106
- * @param conversationId - The ID of the conversation
2107
- *
2108
- * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service
2109
- */
2110
- async finalUpdateKeyingMaterial(conversationId) {
2111
- return await this.#cc.update_keying_material(conversationId);
2112
- }
2113
- /**
2114
- * Commits the local pending proposals and returns the {@link CommitBundle} object containing what can result from this operation.
2115
- *
2116
- * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2117
- * It also contains a Welcome message the Delivery Service will forward to invited clients and
2118
- * an updated PublicGroupState required by clients willing to join the group by an external commit.
2119
- *
2120
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2121
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2122
- * epoch, use new encryption secrets etc...
2123
- *
2124
- * @param conversationId - The ID of the conversation
2125
- *
2126
- * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service
2127
- */
2128
- async finalCommitPendingProposals(conversationId) {
2129
- return await this.#cc.commit_pending_proposals(conversationId);
2130
- }
2131
- /**
2132
- * Creates a new proposal for the provided Conversation ID
2133
- *
2134
- * @param proposalType - The type of proposal, see {@link ProposalType}
2135
- * @param args - The arguments of the proposal, see {@link ProposalArgs}, {@link AddProposalArgs} or {@link RemoveProposalArgs}
2136
- *
2137
- * @returns A {@link ProposalBundle} containing the Proposal and its reference in order to roll it back if necessary
2138
- */
2139
- async newProposal(proposalType, args) {
2140
- switch (proposalType) {
2141
- case 0 /* ProposalType.Add */: {
2142
- if (!args.kp) {
2143
- throw new Error("kp is not contained in the proposal arguments");
2144
- }
2145
- return await this.#cc.new_add_proposal(args.conversationId, args.kp);
2146
- }
2147
- case 1 /* ProposalType.Remove */: {
2148
- if (!args.clientId) {
2149
- throw new Error("clientId is not contained in the proposal arguments");
2150
- }
2151
- return await this.#cc.new_remove_proposal(args.conversationId, args.clientId);
2152
- }
2153
- case 2 /* ProposalType.Update */: {
2154
- return await this.#cc.new_update_proposal(args.conversationId);
2155
- }
2156
- default:
2157
- throw new Error("Invalid proposal type!");
2158
- }
2159
- }
2160
- async newExternalProposal(externalProposalType, args) {
2161
- switch (externalProposalType) {
2162
- case 0 /* ExternalProposalType.Add */: {
2163
- return await this.#cc.new_external_add_proposal(args.conversationId, args.epoch);
2164
- }
2165
- case 1 /* ExternalProposalType.Remove */: {
2166
- if (!args.keyPackageRef) {
2167
- throw new Error("keyPackageRef is not contained in the external proposal arguments");
2168
- }
2169
- return await this.#cc.new_external_remove_proposal(args.conversationId, args.epoch, args.keyPackageRef);
2170
- }
2171
- default:
2172
- throw new Error("Invalid external proposal type!");
2173
- }
2174
- }
2175
- /**
2176
- * Exports public group state for use in external commits
2177
- *
2178
- * @param conversationId - MLS Conversation ID
2179
- * @returns TLS-serialized MLS public group state
2180
- */
2181
- async exportGroupState(conversationId) {
2182
- return await this.#cc.export_group_state(conversationId);
2183
- }
2184
- /**
2185
- * Allows to create an external commit to "apply" to join a group through its public group state
2186
- *
2187
- * Also see the second step of this process: {@link CoreCrypto.mergePendingGroupFromExternalCommit}
2188
- *
2189
- * @param publicGroupState - The public group state that can be fetched from the backend for a given conversation
2190
- * @returns see {@link MlsConversationInitMessage}
2191
- */
2192
- async joinByExternalCommit(publicGroupState) {
2193
- const ffiInitMessage = await this.#cc.join_by_external_commit(publicGroupState);
2194
- const ret = {
2195
- group: ffiInitMessage.group,
2196
- commit: ffiInitMessage.commit
2197
- };
2198
- return ret;
2199
- }
2200
- /**
2201
- * This is the second step of the process of joining a group through an external commit
2202
- *
2203
- * This step makes the group operational and ready to encrypt/decrypt message
2204
- *
2205
- * @param conversationId - The ID of the conversation
2206
- * @param configuration - Configuration of the group, see {@link ConversationConfiguration}
2207
- */
2208
- async mergePendingGroupFromExternalCommit(conversationId, configuration) {
2209
- const { admins, ciphersuite, keyRotationSpan, externalSenders } = configuration ?? {};
2210
- const config = new CoreCrypto.#module.ConversationConfiguration(admins, ciphersuite, keyRotationSpan, externalSenders);
2211
- return await this.#cc.merge_pending_group_from_external_commit(conversationId, config);
2212
- }
2213
- /**
2214
- * Allows to mark the latest commit produced as "accepted" and be able to safely merge it
2215
- * into the local group state
2216
- *
2217
- * @param conversationId - The group's ID
2218
- */
2219
- async commitAccepted(conversationId) {
2220
- return await this.#cc.commit_accepted(conversationId);
2221
- }
2222
- /**
2223
- * Allows {@link CoreCrypto} to act as a CSPRNG provider
2224
- * @note The underlying CSPRNG algorithm is ChaCha20 and takes in account the external seed provider either at init time or provided with {@link CoreCrypto.reseedRng}
2225
- *
2226
- * @param length - The number of bytes to be returned in the `Uint8Array`
2227
- *
2228
- * @returns A `Uint8Array` buffer that contains `length` cryptographically-secure random bytes
2229
- */
2230
- async randomBytes(length) {
2231
- return await this.#cc.random_bytes(length);
2232
- }
2233
- /**
2234
- * Allows to reseed {@link CoreCrypto}'s internal CSPRNG with a new seed.
2235
- *
2236
- * @param seed - **exactly 32** bytes buffer seed
2237
- */
2238
- async reseedRng(seed) {
2239
- if (seed.length !== 32) {
2240
- throw new Error(`The seed length needs to be exactly 32 bytes. ${seed.length} bytes provided.`);
2241
- }
2242
- return await this.#cc.reseed_rng(seed);
2243
- }
2244
- /**
2245
- * Allows to remove a pending proposal (rollback). Use this when backend rejects the proposal you just sent e.g. if permissions
2246
- * have changed meanwhile.
2247
- *
2248
- * **CAUTION**: only use this when you had an explicit response from the Delivery Service
2249
- * e.g. 403 or 409. Do not use otherwise e.g. 5xx responses, timeout etc..
2250
- *
2251
- * @param conversationId - The group's ID
2252
- * @param proposalRef - A reference to the proposal to delete. You get one when using {@link CoreCrypto.newProposal}
2253
- */
2254
- async clear_pending_proposal(conversationId, proposalRef) {
2255
- return await this.#cc.clear_pending_proposal(conversationId, proposalRef);
2256
- }
2257
- /**
2258
- * Allows to remove a pending commit (rollback). Use this when backend rejects the commit you just sent e.g. if permissions
2259
- * have changed meanwhile.
2260
- *
2261
- * **CAUTION**: only use this when you had an explicit response from the Delivery Service
2262
- * e.g. 403. Do not use otherwise e.g. 5xx responses, timeout etc..
2263
- * **DO NOT** use when Delivery Service responds 409, pending state will be renewed
2264
- * in {@link CoreCrypto.decrypt_message}
2265
- *
2266
- * @param conversationId - The group's ID
2267
- */
2268
- async clear_pending_commit(conversationId) {
2269
- return await this.#cc.clear_pending_commit(conversationId);
2270
- }
2271
- /**
2272
- * Returns the current version of {@link CoreCrypto}
2273
- *
2274
- * @returns The `core-crypto-ffi` version as defined in its `Cargo.toml` file
2275
- */
2276
- static version() {
2277
- if (!this.#module) {
2278
- throw new Error("Internal module hasn't been initialized. Please use `await CoreCrypto.init(params)`!");
2279
- }
2280
- return this.#module.version();
2281
- }
2282
- }
2283
-
2284
- export { CoreCrypto };