@wireapp/core-crypto 0.6.0-rc.7 → 0.6.0-rc.8
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/package.json
CHANGED
Binary file
|
@@ -408,7 +408,7 @@ export interface CoreCryptoCallbacks {
|
|
408
408
|
* @param clientId - id of the client performing an operation requiring authorization
|
409
409
|
* @returns whether the user is authorized by the logic layer to perform the operation
|
410
410
|
*/
|
411
|
-
authorize: (conversationId: Uint8Array, clientId: Uint8Array) => boolean
|
411
|
+
authorize: (conversationId: Uint8Array, clientId: Uint8Array) => Promise<boolean>;
|
412
412
|
/**
|
413
413
|
* A mix between {@link authorize} and {@link clientIsExistingGroupUser}. We currently use this callback to verify
|
414
414
|
* external commits to join a group ; in such case, the client has to:
|
@@ -420,7 +420,7 @@ export interface CoreCryptoCallbacks {
|
|
420
420
|
* @param existingClients - all the clients currently within the MLS group
|
421
421
|
* @returns true if the external client is authorized to write to the conversation
|
422
422
|
*/
|
423
|
-
userAuthorize: (conversationId: Uint8Array, externalClientId: Uint8Array, existingClients: Uint8Array[]) => boolean
|
423
|
+
userAuthorize: (conversationId: Uint8Array, externalClientId: Uint8Array, existingClients: Uint8Array[]) => Promise<boolean>;
|
424
424
|
/**
|
425
425
|
* Callback to ensure that the given `clientId` belongs to one of the provided `existingClients`
|
426
426
|
* This basically allows to defer the client ID parsing logic to the caller - because CoreCrypto is oblivious to such things
|
@@ -429,7 +429,7 @@ export interface CoreCryptoCallbacks {
|
|
429
429
|
* @param clientId - id of a client
|
430
430
|
* @param existingClients - all the clients currently within the MLS group
|
431
431
|
*/
|
432
|
-
clientIsExistingGroupUser: (conversationId: Uint8Array, clientId: Uint8Array, existingClients: Uint8Array[]) => boolean
|
432
|
+
clientIsExistingGroupUser: (conversationId: Uint8Array, clientId: Uint8Array, existingClients: Uint8Array[]) => Promise<boolean>;
|
433
433
|
}
|
434
434
|
/**
|
435
435
|
* Wrapper for the WASM-compiled version of CoreCrypto
|
@@ -484,6 +484,22 @@ export declare class CoreCrypto {
|
|
484
484
|
* @param clientId - {@link CoreCryptoParams#clientId} but required
|
485
485
|
*/
|
486
486
|
mlsInit(clientId: ClientId): Promise<void>;
|
487
|
+
/**
|
488
|
+
* Generates a MLS KeyPair/CredentialBundle with a temporary, random client ID.
|
489
|
+
* This method is designed to be used in conjunction with {@link CoreCrypto.mlsInitWithClientID} and represents the first step in this process
|
490
|
+
*
|
491
|
+
* @returns This returns the TLS-serialized identity key (i.e. the signature keypair's public key)
|
492
|
+
*/
|
493
|
+
mlsGenerateKeypair(): Promise<Uint8Array>;
|
494
|
+
/**
|
495
|
+
* Updates the current temporary Client ID with the newly provided one. This is the second step in the externally-generated clients process
|
496
|
+
*
|
497
|
+
* Important: This is designed to be called after {@link CoreCrypto.mlsGenerateKeyPair}
|
498
|
+
*
|
499
|
+
* @param clientId - The newly-allocated client ID by the MLS Authentication Service
|
500
|
+
* @param signaturePublicKey - The public key you were given at the first step; This is for authentication purposes
|
501
|
+
*/
|
502
|
+
mlsInitWithClientId(clientId: ClientId, signaturePublicKey: Uint8Array): Promise<void>;
|
487
503
|
/** @hidden */
|
488
504
|
private constructor();
|
489
505
|
/**
|
@@ -503,7 +519,7 @@ export declare class CoreCrypto {
|
|
503
519
|
*
|
504
520
|
* @param callbacks - Any interface following the {@link CoreCryptoCallbacks} interface
|
505
521
|
*/
|
506
|
-
registerCallbacks(callbacks: CoreCryptoCallbacks): void
|
522
|
+
registerCallbacks(callbacks: CoreCryptoCallbacks, ctx?: any): Promise<void>;
|
507
523
|
/**
|
508
524
|
* Checks if the Client is member of a given conversation and if the MLS Group is loaded up
|
509
525
|
*
|
@@ -831,9 +847,19 @@ export declare class CoreCrypto {
|
|
831
847
|
/**
|
832
848
|
* Creates a new prekey with an automatically generated ID..
|
833
849
|
*
|
834
|
-
* @returns
|
850
|
+
* @returns A CBOR-serialized version of the PreKeyBundle corresponding to the newly generated and stored PreKey
|
835
851
|
*/
|
836
852
|
proteusNewPrekeyAuto(): Promise<Uint8Array>;
|
853
|
+
/**
|
854
|
+
* Proteus last resort prekey stuff
|
855
|
+
*
|
856
|
+
* @returns A CBOR-serialize version of the PreKeyBundle associated with the last resort PreKey (holding the last resort prekey id)
|
857
|
+
*/
|
858
|
+
proteusLastResortPrekey(): Promise<Uint8Array>;
|
859
|
+
/**
|
860
|
+
* @returns The last resort PreKey id
|
861
|
+
*/
|
862
|
+
static proteusLastResortPrekeyId(): number;
|
837
863
|
/**
|
838
864
|
* Proteus public key fingerprint
|
839
865
|
* It's basically the public key encoded as an hex string
|
@@ -876,12 +902,12 @@ export declare class CoreCrypto {
|
|
876
902
|
/**
|
877
903
|
* Creates an enrollment instance with private key material you can use in order to fetch
|
878
904
|
* a new x509 certificate from the acme server.
|
879
|
-
* Make sure to call
|
905
|
+
* Make sure to call {@link WireE2eIdentity.free} to dispose this instance and its associated
|
880
906
|
* keying material.
|
881
907
|
*
|
882
908
|
* @param ciphersuite - For generating signing key material. Only {@link Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519} is supported currently
|
883
909
|
*/
|
884
|
-
newAcmeEnrollment(): Promise<WireE2eIdentity>;
|
910
|
+
newAcmeEnrollment(ciphersuite?: Ciphersuite): Promise<WireE2eIdentity>;
|
885
911
|
/**
|
886
912
|
* Returns the current version of {@link CoreCrypto}
|
887
913
|
*
|
@@ -896,6 +922,7 @@ export declare class WireE2eIdentity {
|
|
896
922
|
#private;
|
897
923
|
/** @hidden */
|
898
924
|
constructor(e2ei: unknown);
|
925
|
+
free(): void;
|
899
926
|
/**
|
900
927
|
* Parses the response from `GET /acme/{provisioner-name}/directory`.
|
901
928
|
* Use this {@link AcmeDirectory} in the next step to fetch the first nonce from the acme server. Use
|
@@ -34,14 +34,6 @@ const heap = new Array(128).fill(undefined);
|
|
34
34
|
heap.push(undefined, null, true, false);
|
35
35
|
function getObject(idx) { return heap[idx]; }
|
36
36
|
let heap_next = heap.length;
|
37
|
-
function addHeapObject(obj) {
|
38
|
-
if (heap_next === heap.length)
|
39
|
-
heap.push(heap.length + 1);
|
40
|
-
const idx = heap_next;
|
41
|
-
heap_next = heap[idx];
|
42
|
-
heap[idx] = obj;
|
43
|
-
return idx;
|
44
|
-
}
|
45
37
|
function dropObject(idx) {
|
46
38
|
if (idx < 132)
|
47
39
|
return;
|
@@ -53,6 +45,14 @@ function takeObject(idx) {
|
|
53
45
|
dropObject(idx);
|
54
46
|
return ret;
|
55
47
|
}
|
48
|
+
function addHeapObject(obj) {
|
49
|
+
if (heap_next === heap.length)
|
50
|
+
heap.push(heap.length + 1);
|
51
|
+
const idx = heap_next;
|
52
|
+
heap_next = heap[idx];
|
53
|
+
heap[idx] = obj;
|
54
|
+
return idx;
|
55
|
+
}
|
56
56
|
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
57
57
|
cachedTextDecoder.decode();
|
58
58
|
let cachedUint8Memory0 = null;
|
@@ -279,23 +279,6 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
279
279
|
}
|
280
280
|
return result;
|
281
281
|
}
|
282
|
-
/**
|
283
|
-
* Returns the current version of CoreCrypto
|
284
|
-
* @returns {string}
|
285
|
-
*/
|
286
|
-
function version() {
|
287
|
-
try {
|
288
|
-
const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
|
289
|
-
wasm$1.version(retptr);
|
290
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
291
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
292
|
-
return getStringFromWasm0(r0, r1);
|
293
|
-
}
|
294
|
-
finally {
|
295
|
-
wasm$1.__wbindgen_add_to_stack_pointer(16);
|
296
|
-
wasm$1.__wbindgen_free(r0, r1);
|
297
|
-
}
|
298
|
-
}
|
299
282
|
function handleError(f, args) {
|
300
283
|
try {
|
301
284
|
return f.apply(this, args);
|
@@ -307,7 +290,7 @@ function handleError(f, args) {
|
|
307
290
|
function getArrayU8FromWasm0(ptr, len) {
|
308
291
|
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
309
292
|
}
|
310
|
-
function
|
293
|
+
function __wbg_adapter_271(arg0, arg1, arg2, arg3) {
|
311
294
|
wasm$1.wasm_bindgen__convert__closures__invoke2_mut__h191981cd1d6b08cc(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
312
295
|
}
|
313
296
|
/**
|
@@ -659,6 +642,23 @@ let CoreCrypto$1 = class CoreCrypto {
|
|
659
642
|
wasm$1.__wbg_corecrypto_free(ptr);
|
660
643
|
}
|
661
644
|
/**
|
645
|
+
* Returns the current version of CoreCrypto
|
646
|
+
* @returns {string}
|
647
|
+
*/
|
648
|
+
static version() {
|
649
|
+
try {
|
650
|
+
const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
|
651
|
+
wasm$1.corecrypto_version(retptr);
|
652
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
653
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
654
|
+
return getStringFromWasm0(r0, r1);
|
655
|
+
}
|
656
|
+
finally {
|
657
|
+
wasm$1.__wbindgen_add_to_stack_pointer(16);
|
658
|
+
wasm$1.__wbindgen_free(r0, r1);
|
659
|
+
}
|
660
|
+
}
|
661
|
+
/**
|
662
662
|
* see [core_crypto::MlsCentral::try_new]
|
663
663
|
* @param {string} path
|
664
664
|
* @param {string} key
|
@@ -707,6 +707,32 @@ let CoreCrypto$1 = class CoreCrypto {
|
|
707
707
|
return takeObject(ret);
|
708
708
|
}
|
709
709
|
/**
|
710
|
+
* Returns [`WasmCryptoResult<Vec<u8>>`]
|
711
|
+
*
|
712
|
+
* See [core_crypto::MlsCentral::mls_generate_keypair]
|
713
|
+
* @returns {Promise<any>}
|
714
|
+
*/
|
715
|
+
mls_generate_keypair() {
|
716
|
+
const ret = wasm$1.corecrypto_mls_generate_keypair(this.ptr);
|
717
|
+
return takeObject(ret);
|
718
|
+
}
|
719
|
+
/**
|
720
|
+
* Returns [`WasmCryptoResult<()>`]
|
721
|
+
*
|
722
|
+
* See [core_crypto::MlsCentral::mls_init_with_client_id]
|
723
|
+
* @param {Uint8Array} client_id
|
724
|
+
* @param {Uint8Array} signature_public_key
|
725
|
+
* @returns {Promise<any>}
|
726
|
+
*/
|
727
|
+
mls_init_with_client_id(client_id, signature_public_key) {
|
728
|
+
const ptr0 = passArray8ToWasm0(client_id, wasm$1.__wbindgen_malloc);
|
729
|
+
const len0 = WASM_VECTOR_LEN;
|
730
|
+
const ptr1 = passArray8ToWasm0(signature_public_key, wasm$1.__wbindgen_malloc);
|
731
|
+
const len1 = WASM_VECTOR_LEN;
|
732
|
+
const ret = wasm$1.corecrypto_mls_init_with_client_id(this.ptr, ptr0, len0, ptr1, len1);
|
733
|
+
return takeObject(ret);
|
734
|
+
}
|
735
|
+
/**
|
710
736
|
* Returns: [`WasmCryptoResult<()>`]
|
711
737
|
*
|
712
738
|
* see [core_crypto::MlsCentral::close]
|
@@ -1227,7 +1253,7 @@ let CoreCrypto$1 = class CoreCrypto {
|
|
1227
1253
|
* see [core_crypto::proteus::ProteusCentral::encrypt]
|
1228
1254
|
* @param {string} session_id
|
1229
1255
|
* @param {Uint8Array} plaintext
|
1230
|
-
* @returns {Promise<
|
1256
|
+
* @returns {Promise<Promise<any>>}
|
1231
1257
|
*/
|
1232
1258
|
proteus_encrypt(session_id, plaintext) {
|
1233
1259
|
const ptr0 = passStringToWasm0(session_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
|
@@ -1243,7 +1269,7 @@ let CoreCrypto$1 = class CoreCrypto {
|
|
1243
1269
|
* see [core_crypto::proteus::ProteusCentral::encrypt_batched]
|
1244
1270
|
* @param {(string)[]} sessions
|
1245
1271
|
* @param {Uint8Array} plaintext
|
1246
|
-
* @returns {Promise<
|
1272
|
+
* @returns {Promise<any>}
|
1247
1273
|
*/
|
1248
1274
|
proteus_encrypt_batched(sessions, plaintext) {
|
1249
1275
|
const ptr0 = passArrayJsValueToWasm0(sessions, wasm$1.__wbindgen_malloc);
|
@@ -1258,7 +1284,7 @@ let CoreCrypto$1 = class CoreCrypto {
|
|
1258
1284
|
*
|
1259
1285
|
* see [core_crypto::proteus::ProteusCentral::new_prekey]
|
1260
1286
|
* @param {number} prekey_id
|
1261
|
-
* @returns {Promise<
|
1287
|
+
* @returns {Promise<Promise<any>>}
|
1262
1288
|
*/
|
1263
1289
|
proteus_new_prekey(prekey_id) {
|
1264
1290
|
const ret = wasm$1.corecrypto_proteus_new_prekey(this.ptr, prekey_id);
|
@@ -1268,13 +1294,45 @@ let CoreCrypto$1 = class CoreCrypto {
|
|
1268
1294
|
* Returns: [`WasmCryptoResult<Uint8Array>`]
|
1269
1295
|
*
|
1270
1296
|
* see [core_crypto::proteus::ProteusCentral::new_prekey]
|
1271
|
-
* @returns {Promise<
|
1297
|
+
* @returns {Promise<Promise<any>>}
|
1272
1298
|
*/
|
1273
1299
|
proteus_new_prekey_auto() {
|
1274
1300
|
const ret = wasm$1.corecrypto_proteus_new_prekey_auto(this.ptr);
|
1275
1301
|
return takeObject(ret);
|
1276
1302
|
}
|
1277
1303
|
/**
|
1304
|
+
* Returns [`WasmCryptoResult<Uint8Array>`]
|
1305
|
+
*
|
1306
|
+
* see [core_crypto::proteus::ProteusCentral::last_resort_prekey]
|
1307
|
+
* @returns {Promise<any>}
|
1308
|
+
*/
|
1309
|
+
proteus_last_resort_prekey() {
|
1310
|
+
const ret = wasm$1.corecrypto_proteus_last_resort_prekey(this.ptr);
|
1311
|
+
return takeObject(ret);
|
1312
|
+
}
|
1313
|
+
/**
|
1314
|
+
* Returns: [`WasmCryptoResult<u16>`]
|
1315
|
+
*
|
1316
|
+
* see [core_crypto::proteus::ProteusCentral::last_resort_prekey_id]
|
1317
|
+
* @returns {number}
|
1318
|
+
*/
|
1319
|
+
static proteus_last_resort_prekey_id() {
|
1320
|
+
try {
|
1321
|
+
const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
|
1322
|
+
wasm$1.corecrypto_proteus_last_resort_prekey_id(retptr);
|
1323
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
1324
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
1325
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
1326
|
+
if (r2) {
|
1327
|
+
throw takeObject(r1);
|
1328
|
+
}
|
1329
|
+
return r0;
|
1330
|
+
}
|
1331
|
+
finally {
|
1332
|
+
wasm$1.__wbindgen_add_to_stack_pointer(16);
|
1333
|
+
}
|
1334
|
+
}
|
1335
|
+
/**
|
1278
1336
|
* Returns: [`WasmCryptoResult<String>`]
|
1279
1337
|
*
|
1280
1338
|
* see [core_crypto::proteus::ProteusCentral::fingerprint]
|
@@ -1421,9 +1479,10 @@ class CoreCryptoWasmCallbacks {
|
|
1421
1479
|
* @param {Function} authorize
|
1422
1480
|
* @param {Function} user_authorize
|
1423
1481
|
* @param {Function} client_is_existing_group_user
|
1482
|
+
* @param {any} ctx
|
1424
1483
|
*/
|
1425
|
-
constructor(authorize, user_authorize, client_is_existing_group_user) {
|
1426
|
-
const ret = wasm$1.corecryptowasmcallbacks_new(addHeapObject(authorize), addHeapObject(user_authorize), addHeapObject(client_is_existing_group_user));
|
1484
|
+
constructor(authorize, user_authorize, client_is_existing_group_user, ctx) {
|
1485
|
+
const ret = wasm$1.corecryptowasmcallbacks_new(addHeapObject(authorize), addHeapObject(user_authorize), addHeapObject(client_is_existing_group_user), addHeapObject(ctx));
|
1427
1486
|
return CoreCryptoWasmCallbacks.__wrap(ret);
|
1428
1487
|
}
|
1429
1488
|
}
|
@@ -2244,6 +2303,27 @@ async function load(module, imports) {
|
|
2244
2303
|
function getImports() {
|
2245
2304
|
const imports = {};
|
2246
2305
|
imports.wbg = {};
|
2306
|
+
imports.wbg.__wbg_new_f9876326328f45ed = function () {
|
2307
|
+
const ret = new Object();
|
2308
|
+
return addHeapObject(ret);
|
2309
|
+
};
|
2310
|
+
imports.wbg.__wbg_new_b525de17f44a8943 = function () {
|
2311
|
+
const ret = new Array();
|
2312
|
+
return addHeapObject(ret);
|
2313
|
+
};
|
2314
|
+
imports.wbg.__wbg_set_17224bc548dd1d7b = function (arg0, arg1, arg2) {
|
2315
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
2316
|
+
};
|
2317
|
+
imports.wbg.__wbg_set_20cbc34131e76824 = function (arg0, arg1, arg2) {
|
2318
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
2319
|
+
};
|
2320
|
+
imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
|
2321
|
+
takeObject(arg0);
|
2322
|
+
};
|
2323
|
+
imports.wbg.__wbindgen_number_new = function (arg0) {
|
2324
|
+
const ret = arg0;
|
2325
|
+
return addHeapObject(ret);
|
2326
|
+
};
|
2247
2327
|
imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
|
2248
2328
|
const ret = getObject(arg0);
|
2249
2329
|
return addHeapObject(ret);
|
@@ -2253,9 +2333,6 @@ function getImports() {
|
|
2253
2333
|
const ret = typeof (val) === 'object' && val !== null;
|
2254
2334
|
return ret;
|
2255
2335
|
};
|
2256
|
-
imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
|
2257
|
-
takeObject(arg0);
|
2258
|
-
};
|
2259
2336
|
imports.wbg.__wbg_getwithrefkey_15c62c2b8546208d = function (arg0, arg1) {
|
2260
2337
|
const ret = getObject(arg0)[getObject(arg1)];
|
2261
2338
|
return addHeapObject(ret);
|
@@ -2306,30 +2383,20 @@ function getImports() {
|
|
2306
2383
|
const ret = new Uint8Array(getObject(arg0));
|
2307
2384
|
return addHeapObject(ret);
|
2308
2385
|
};
|
2309
|
-
imports.wbg.
|
2310
|
-
const ret =
|
2311
|
-
return
|
2312
|
-
};
|
2313
|
-
imports.wbg.__wbg_new_f9876326328f45ed = function () {
|
2314
|
-
const ret = new Object();
|
2315
|
-
return addHeapObject(ret);
|
2386
|
+
imports.wbg.__wbg_push_49c286f04dd3bf59 = function (arg0, arg1) {
|
2387
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
2388
|
+
return ret;
|
2316
2389
|
};
|
2317
|
-
imports.wbg.
|
2318
|
-
const ret = new
|
2390
|
+
imports.wbg.__wbg_new_f841cc6f2098f4b5 = function () {
|
2391
|
+
const ret = new Map();
|
2319
2392
|
return addHeapObject(ret);
|
2320
2393
|
};
|
2321
|
-
imports.wbg.
|
2322
|
-
getObject(arg0)
|
2323
|
-
};
|
2324
|
-
imports.wbg.__wbg_set_20cbc34131e76824 = function (arg0, arg1, arg2) {
|
2325
|
-
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
2326
|
-
};
|
2327
|
-
imports.wbg.__wbindgen_number_new = function (arg0) {
|
2328
|
-
const ret = arg0;
|
2394
|
+
imports.wbg.__wbg_set_388c4c6422704173 = function (arg0, arg1, arg2) {
|
2395
|
+
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
2329
2396
|
return addHeapObject(ret);
|
2330
2397
|
};
|
2331
|
-
imports.wbg.
|
2332
|
-
const ret =
|
2398
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function (arg0) {
|
2399
|
+
const ret = BigInt.asUintN(64, arg0);
|
2333
2400
|
return addHeapObject(ret);
|
2334
2401
|
};
|
2335
2402
|
imports.wbg.__wbg_new_9d3a9ce4282a18a8 = function (arg0, arg1) {
|
@@ -2339,7 +2406,7 @@ function getImports() {
|
|
2339
2406
|
const a = state0.a;
|
2340
2407
|
state0.a = 0;
|
2341
2408
|
try {
|
2342
|
-
return
|
2409
|
+
return __wbg_adapter_271(a, state0.b, arg0, arg1);
|
2343
2410
|
}
|
2344
2411
|
finally {
|
2345
2412
|
state0.a = a;
|
@@ -2352,16 +2419,8 @@ function getImports() {
|
|
2352
2419
|
state0.a = state0.b = 0;
|
2353
2420
|
}
|
2354
2421
|
};
|
2355
|
-
imports.wbg.
|
2356
|
-
const ret =
|
2357
|
-
return ret;
|
2358
|
-
};
|
2359
|
-
imports.wbg.__wbg_new_f841cc6f2098f4b5 = function () {
|
2360
|
-
const ret = new Map();
|
2361
|
-
return addHeapObject(ret);
|
2362
|
-
};
|
2363
|
-
imports.wbg.__wbg_set_388c4c6422704173 = function (arg0, arg1, arg2) {
|
2364
|
-
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
2422
|
+
imports.wbg.__wbg_ffiwiree2eidentity_new = function (arg0) {
|
2423
|
+
const ret = FfiWireE2EIdentity.__wrap(arg0);
|
2365
2424
|
return addHeapObject(ret);
|
2366
2425
|
};
|
2367
2426
|
imports.wbg.__wbg_setonsuccess_925a7718d3f62bc1 = function (arg0, arg1) {
|
@@ -2888,6 +2947,10 @@ function getImports() {
|
|
2888
2947
|
const ret = getObject(arg0).then(getObject(arg1));
|
2889
2948
|
return addHeapObject(ret);
|
2890
2949
|
};
|
2950
|
+
imports.wbg.__wbg_then_f753623316e2873a = function (arg0, arg1, arg2) {
|
2951
|
+
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
2952
|
+
return addHeapObject(ret);
|
2953
|
+
};
|
2891
2954
|
imports.wbg.__wbg_resolve_fd40f858d9db1a04 = function (arg0) {
|
2892
2955
|
const ret = Promise.resolve(getObject(arg0));
|
2893
2956
|
return addHeapObject(ret);
|
@@ -2952,11 +3015,11 @@ function getImports() {
|
|
2952
3015
|
return addHeapObject(ret);
|
2953
3016
|
}, arguments);
|
2954
3017
|
};
|
2955
|
-
imports.wbg.
|
3018
|
+
imports.wbg.__wbindgen_closure_wrapper4402 = function (arg0, arg1, arg2) {
|
2956
3019
|
const ret = makeMutClosure(arg0, arg1, 145, __wbg_adapter_52);
|
2957
3020
|
return addHeapObject(ret);
|
2958
3021
|
};
|
2959
|
-
imports.wbg.
|
3022
|
+
imports.wbg.__wbindgen_closure_wrapper4858 = function (arg0, arg1, arg2) {
|
2960
3023
|
const ret = makeMutClosure(arg0, arg1, 145, __wbg_adapter_55);
|
2961
3024
|
return addHeapObject(ret);
|
2962
3025
|
};
|
@@ -3011,14 +3074,13 @@ var exports = /*#__PURE__*/Object.freeze({
|
|
3011
3074
|
PublicGroupStateBundle: PublicGroupStateBundle,
|
3012
3075
|
WirePolicy: WirePolicy$1,
|
3013
3076
|
default: init,
|
3014
|
-
initSync: initSync
|
3015
|
-
version: version
|
3077
|
+
initSync: initSync
|
3016
3078
|
});
|
3017
3079
|
|
3018
3080
|
var wasm = async (opt = {}) => {
|
3019
3081
|
let {importHook, serverPath} = opt;
|
3020
3082
|
|
3021
|
-
let path = "assets/core_crypto_ffi-
|
3083
|
+
let path = "assets/core_crypto_ffi-d7dac5b2.wasm";
|
3022
3084
|
|
3023
3085
|
if (serverPath != null) {
|
3024
3086
|
path = serverPath + /[^\/\\]*$/.exec(path)[0];
|
@@ -3034,7 +3096,7 @@ var wasm = async (opt = {}) => {
|
|
3034
3096
|
|
3035
3097
|
// Wire
|
3036
3098
|
// Copyright (C) 2022 Wire Swiss GmbH
|
3037
|
-
var _a, _CoreCrypto_module, _CoreCrypto_cc, _WireE2eIdentity_e2ei;
|
3099
|
+
var _a, _CoreCrypto_module, _CoreCrypto_cc, _CoreCrypto_assertModuleLoaded, _WireE2eIdentity_e2ei;
|
3038
3100
|
/**
|
3039
3101
|
* Error wrapper that takes care of extracting rich error details across the FFI (through JSON parsing)
|
3040
3102
|
*
|
@@ -3054,7 +3116,7 @@ class CoreCryptoError extends Error {
|
|
3054
3116
|
this.proteusErrorCode = richError.proteusErrorCode;
|
3055
3117
|
}
|
3056
3118
|
static fallback(msg, ...params) {
|
3057
|
-
console.warn(
|
3119
|
+
console.warn(`Cannot build CoreCryptoError, falling back to standard Error! ctx: ${msg}`);
|
3058
3120
|
// @ts-ignore
|
3059
3121
|
return new Error(msg, ...params);
|
3060
3122
|
}
|
@@ -3277,6 +3339,26 @@ class CoreCrypto {
|
|
3277
3339
|
async mlsInit(clientId) {
|
3278
3340
|
return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").mls_init(clientId));
|
3279
3341
|
}
|
3342
|
+
/**
|
3343
|
+
* Generates a MLS KeyPair/CredentialBundle with a temporary, random client ID.
|
3344
|
+
* This method is designed to be used in conjunction with {@link CoreCrypto.mlsInitWithClientID} and represents the first step in this process
|
3345
|
+
*
|
3346
|
+
* @returns This returns the TLS-serialized identity key (i.e. the signature keypair's public key)
|
3347
|
+
*/
|
3348
|
+
async mlsGenerateKeypair() {
|
3349
|
+
return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").mls_generate_keypair());
|
3350
|
+
}
|
3351
|
+
/**
|
3352
|
+
* Updates the current temporary Client ID with the newly provided one. This is the second step in the externally-generated clients process
|
3353
|
+
*
|
3354
|
+
* Important: This is designed to be called after {@link CoreCrypto.mlsGenerateKeyPair}
|
3355
|
+
*
|
3356
|
+
* @param clientId - The newly-allocated client ID by the MLS Authentication Service
|
3357
|
+
* @param signaturePublicKey - The public key you were given at the first step; This is for authentication purposes
|
3358
|
+
*/
|
3359
|
+
async mlsInitWithClientId(clientId, signaturePublicKey) {
|
3360
|
+
return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").mls_init_with_client_id(clientId, signaturePublicKey));
|
3361
|
+
}
|
3280
3362
|
/** @hidden */
|
3281
3363
|
constructor(cc) {
|
3282
3364
|
/** @hidden */
|
@@ -3304,10 +3386,10 @@ class CoreCrypto {
|
|
3304
3386
|
*
|
3305
3387
|
* @param callbacks - Any interface following the {@link CoreCryptoCallbacks} interface
|
3306
3388
|
*/
|
3307
|
-
registerCallbacks(callbacks) {
|
3389
|
+
async registerCallbacks(callbacks, ctx = null) {
|
3308
3390
|
try {
|
3309
|
-
const wasmCallbacks = new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).CoreCryptoWasmCallbacks)(callbacks.authorize, callbacks.userAuthorize, callbacks.clientIsExistingGroupUser);
|
3310
|
-
__classPrivateFieldGet(this, _CoreCrypto_cc, "f").set_callbacks(wasmCallbacks);
|
3391
|
+
const wasmCallbacks = new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).CoreCryptoWasmCallbacks)(callbacks.authorize, callbacks.userAuthorize, callbacks.clientIsExistingGroupUser, ctx);
|
3392
|
+
await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").set_callbacks(wasmCallbacks);
|
3311
3393
|
}
|
3312
3394
|
catch (e) {
|
3313
3395
|
throw CoreCryptoError.fromStdError(e);
|
@@ -3385,6 +3467,9 @@ class CoreCrypto {
|
|
3385
3467
|
* @returns a {@link DecryptedMessage}. Note that {@link DecryptedMessage#message} is `undefined` when the encrypted payload contains a system message such a proposal or commit
|
3386
3468
|
*/
|
3387
3469
|
async decryptMessage(conversationId, payload) {
|
3470
|
+
if (!payload?.length) {
|
3471
|
+
throw new Error("decryptMessage payload is empty or null");
|
3472
|
+
}
|
3388
3473
|
try {
|
3389
3474
|
const ffiDecryptedMessage = await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").decrypt_message(conversationId, payload));
|
3390
3475
|
const commitDelay = ffiDecryptedMessage.commit_delay ?
|
@@ -3865,11 +3950,26 @@ class CoreCrypto {
|
|
3865
3950
|
/**
|
3866
3951
|
* Creates a new prekey with an automatically generated ID..
|
3867
3952
|
*
|
3868
|
-
* @returns
|
3953
|
+
* @returns A CBOR-serialized version of the PreKeyBundle corresponding to the newly generated and stored PreKey
|
3869
3954
|
*/
|
3870
3955
|
async proteusNewPrekeyAuto() {
|
3871
3956
|
return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_new_prekey_auto());
|
3872
3957
|
}
|
3958
|
+
/**
|
3959
|
+
* Proteus last resort prekey stuff
|
3960
|
+
*
|
3961
|
+
* @returns A CBOR-serialize version of the PreKeyBundle associated with the last resort PreKey (holding the last resort prekey id)
|
3962
|
+
*/
|
3963
|
+
async proteusLastResortPrekey() {
|
3964
|
+
return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_last_resort_prekey());
|
3965
|
+
}
|
3966
|
+
/**
|
3967
|
+
* @returns The last resort PreKey id
|
3968
|
+
*/
|
3969
|
+
static proteusLastResortPrekeyId() {
|
3970
|
+
__classPrivateFieldGet(this, _a, "m", _CoreCrypto_assertModuleLoaded).call(this);
|
3971
|
+
return __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).CoreCrypto.proteus_last_resort_prekey_id();
|
3972
|
+
}
|
3873
3973
|
/**
|
3874
3974
|
* Proteus public key fingerprint
|
3875
3975
|
* It's basically the public key encoded as an hex string
|
@@ -3929,13 +4029,16 @@ class CoreCrypto {
|
|
3929
4029
|
/**
|
3930
4030
|
* Creates an enrollment instance with private key material you can use in order to fetch
|
3931
4031
|
* a new x509 certificate from the acme server.
|
3932
|
-
* Make sure to call
|
4032
|
+
* Make sure to call {@link WireE2eIdentity.free} to dispose this instance and its associated
|
3933
4033
|
* keying material.
|
3934
4034
|
*
|
3935
4035
|
* @param ciphersuite - For generating signing key material. Only {@link Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519} is supported currently
|
3936
4036
|
*/
|
3937
|
-
async newAcmeEnrollment() {
|
3938
|
-
|
4037
|
+
async newAcmeEnrollment(ciphersuite = Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519) {
|
4038
|
+
if (ciphersuite !== Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519) {
|
4039
|
+
throw new Error("This ACME ciphersuite isn't supported. Only `Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519` is as of now");
|
4040
|
+
}
|
4041
|
+
const e2ei = await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_acme_enrollment(ciphersuite));
|
3939
4042
|
return new WireE2eIdentity(e2ei);
|
3940
4043
|
}
|
3941
4044
|
/**
|
@@ -3944,13 +4047,15 @@ class CoreCrypto {
|
|
3944
4047
|
* @returns The `core-crypto-ffi` version as defined in its `Cargo.toml` file
|
3945
4048
|
*/
|
3946
4049
|
static version() {
|
3947
|
-
|
3948
|
-
|
3949
|
-
}
|
3950
|
-
return __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).version();
|
4050
|
+
__classPrivateFieldGet(this, _a, "m", _CoreCrypto_assertModuleLoaded).call(this);
|
4051
|
+
return __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).CoreCrypto.version();
|
3951
4052
|
}
|
3952
4053
|
}
|
3953
|
-
_a = CoreCrypto, _CoreCrypto_cc = new WeakMap()
|
4054
|
+
_a = CoreCrypto, _CoreCrypto_cc = new WeakMap(), _CoreCrypto_assertModuleLoaded = function _CoreCrypto_assertModuleLoaded() {
|
4055
|
+
if (!__classPrivateFieldGet(this, _a, "f", _CoreCrypto_module)) {
|
4056
|
+
throw new Error("Internal module hasn't been initialized. Please use `await CoreCrypto.init(params)` or `await CoreCrypto.deferredInit(params)` !");
|
4057
|
+
}
|
4058
|
+
};
|
3954
4059
|
/** @hidden */
|
3955
4060
|
_CoreCrypto_module = { value: void 0 };
|
3956
4061
|
class WireE2eIdentity {
|
@@ -3960,6 +4065,9 @@ class WireE2eIdentity {
|
|
3960
4065
|
_WireE2eIdentity_e2ei.set(this, void 0);
|
3961
4066
|
__classPrivateFieldSet(this, _WireE2eIdentity_e2ei, e2ei, "f");
|
3962
4067
|
}
|
4068
|
+
free() {
|
4069
|
+
__classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").free();
|
4070
|
+
}
|
3963
4071
|
/**
|
3964
4072
|
* Parses the response from `GET /acme/{provisioner-name}/directory`.
|
3965
4073
|
* Use this {@link AcmeDirectory} in the next step to fetch the first nonce from the acme server. Use
|
Binary file
|