@wireapp/core-crypto 0.6.0-rc.7 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireapp/core-crypto",
3
- "version": "0.6.0-rc.7",
3
+ "version": "0.6.0",
4
4
  "description": "CoreCrypto bindings for the Web",
5
5
  "type": "module",
6
6
  "module": "platforms/web/corecrypto.js",
@@ -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: A CBOR-serialized version of the PreKeyBundle corresponding to the newly generated and stored PreKey
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 [WireE2eIdentity::free] (not yet available) to dispose this instance and its associated
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
@@ -923,15 +950,17 @@ export declare class WireE2eIdentity {
923
950
  /**
924
951
  * Creates a new acme order for the handle (userId + display name) and the clientId.
925
952
  *
926
- * @param handle domain of the authorization server e.g. `idp.example.org`
927
- * @param clientId domain of the wire-server e.g. `wire.example.org`
953
+ * @param displayName human readable name displayed in the application e.g. `Smith, Alice M (QA)`
954
+ * @param domain DNS name of owning backend e.g. `example.com`
955
+ * @param clientId client identifier with user b64Url encoded & clientId hex encoded e.g. `impp:wireapp=NDUyMGUyMmY2YjA3NGU3NjkyZjE1NjJjZTAwMmQ2NTQ/6add501bacd1d90e@example.com`
956
+ * @param handle user handle e.g. `impp:wireapp=alice.smith.qa@example.com`
928
957
  * @param expiryDays generated x509 certificate expiry
929
958
  * @param directory you got from {@link directoryResponse}
930
959
  * @param account you got from {@link newAccountResponse}
931
960
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/new-account`
932
961
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
933
962
  */
934
- newOrderRequest(handle: string, clientId: string, expiryDays: number, directory: AcmeDirectory, account: AcmeAccount, previousNonce: string): JsonRawData;
963
+ newOrderRequest(displayName: string, domain: string, clientId: string, handle: string, expiryDays: number, directory: AcmeDirectory, account: AcmeAccount, previousNonce: string): JsonRawData;
935
964
  /**
936
965
  * Parses the response from `POST /acme/{provisioner-name}/new-order`.
937
966
  *
@@ -978,14 +1007,25 @@ export declare class WireE2eIdentity {
978
1007
  */
979
1008
  createDpopToken(accessTokenUrl: string, userId: string, clientId: bigint, domain: string, clientIdChallenge: AcmeChallenge, backendNonce: string, expiryDays: number): string;
980
1009
  /**
981
- * Creates a new challenge request.
1010
+ * Creates a new challenge request for Wire Dpop challenge.
1011
+ *
1012
+ * @param accessToken returned by wire-server from https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_clients__cid__access_token
1013
+ * @param dpopChallenge you found after {@link newAuthzResponse}
1014
+ * @param account you found after {@link newAccountResponse}
1015
+ * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
1016
+ * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1017
+ */
1018
+ newDpopChallengeRequest(accessToken: string, dpopChallenge: AcmeChallenge, account: AcmeAccount, previousNonce: string): JsonRawData;
1019
+ /**
1020
+ * Creates a new challenge request for Wire Oidc challenge.
982
1021
  *
983
- * @param handleChallenge you found after {@link newAuthzResponse}
1022
+ * @param idToken you get back from Identity Provider
1023
+ * @param oidcChallenge you found after {@link newAuthzResponse}
984
1024
  * @param account you found after {@link newAccountResponse}
985
1025
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
986
1026
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
987
1027
  */
988
- newChallengeRequest(handleChallenge: AcmeChallenge, account: AcmeAccount, previousNonce: string): JsonRawData;
1028
+ newOidcChallengeRequest(idToken: string, oidcChallenge: AcmeChallenge, account: AcmeAccount, previousNonce: string): JsonRawData;
989
1029
  /**
990
1030
  * Parses the response from `POST /acme/{provisioner-name}/challenge/{challenge-id}`.
991
1031
  *
@@ -1012,13 +1052,12 @@ export declare class WireE2eIdentity {
1012
1052
  /**
1013
1053
  * Final step before fetching the certificate.
1014
1054
  *
1015
- * @param domains - domains you want to generate a certificate for e.g. `["wire.com"]`
1016
1055
  * @param order - order you got from {@link checkOrderResponse}
1017
1056
  * @param account - account you found after {@link newAccountResponse}
1018
1057
  * @param previousNonce - `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}`
1019
1058
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1020
1059
  */
1021
- finalizeRequest(domains: string[], order: AcmeOrder, account: AcmeAccount, previousNonce: string): JsonRawData;
1060
+ finalizeRequest(order: AcmeOrder, account: AcmeAccount, previousNonce: string): JsonRawData;
1022
1061
  /**
1023
1062
  * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}/finalize`.
1024
1063
  *
@@ -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;
@@ -228,7 +228,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
228
228
  function __wbg_adapter_52(arg0, arg1, arg2) {
229
229
  try {
230
230
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
231
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0b669391a1ca469a(retptr, arg0, arg1, addHeapObject(arg2));
231
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h07d37b19e83c7ae3(retptr, arg0, arg1, addHeapObject(arg2));
232
232
  var r0 = getInt32Memory0()[retptr / 4 + 0];
233
233
  var r1 = getInt32Memory0()[retptr / 4 + 1];
234
234
  if (r1) {
@@ -240,7 +240,7 @@ function __wbg_adapter_52(arg0, arg1, arg2) {
240
240
  }
241
241
  }
242
242
  function __wbg_adapter_55(arg0, arg1, arg2) {
243
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha3d8e2730fb8635e(arg0, arg1, addHeapObject(arg2));
243
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hde4447b48c9e13f3(arg0, arg1, addHeapObject(arg2));
244
244
  }
245
245
  function _assertClass(instance, klass) {
246
246
  if (!(instance instanceof klass)) {
@@ -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,8 +290,8 @@ function handleError(f, args) {
307
290
  function getArrayU8FromWasm0(ptr, len) {
308
291
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
309
292
  }
310
- function __wbg_adapter_267(arg0, arg1, arg2, arg3) {
311
- wasm$1.wasm_bindgen__convert__closures__invoke2_mut__h191981cd1d6b08cc(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
293
+ function __wbg_adapter_268(arg0, arg1, arg2, arg3) {
294
+ wasm$1.wasm_bindgen__convert__closures__invoke2_mut__h1934ea7100a9edf0(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
312
295
  }
313
296
  /**
314
297
  * see [core_crypto::prelude::MlsWirePolicy]
@@ -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<Uint8Array>}
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<Map<any, any>>}
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<Uint8Array>}
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<Uint8Array>}
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
  }
@@ -1605,24 +1664,30 @@ class FfiWireE2EIdentity {
1605
1664
  }
1606
1665
  /**
1607
1666
  * See [core_crypto::e2e_identity::WireE2eIdentity::new_order_request]
1608
- * @param {string} handle
1667
+ * @param {string} display_name
1668
+ * @param {string} domain
1609
1669
  * @param {string} client_id
1670
+ * @param {string} handle
1610
1671
  * @param {number} expiry_days
1611
1672
  * @param {any} directory
1612
1673
  * @param {Uint8Array} account
1613
1674
  * @param {string} previous_nonce
1614
1675
  * @returns {Uint8Array}
1615
1676
  */
1616
- new_order_request(handle, client_id, expiry_days, directory, account, previous_nonce) {
1677
+ new_order_request(display_name, domain, client_id, handle, expiry_days, directory, account, previous_nonce) {
1617
1678
  try {
1618
1679
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
1619
- const ptr0 = passStringToWasm0(handle, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1680
+ const ptr0 = passStringToWasm0(display_name, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1620
1681
  const len0 = WASM_VECTOR_LEN;
1621
- const ptr1 = passStringToWasm0(client_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1682
+ const ptr1 = passStringToWasm0(domain, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1622
1683
  const len1 = WASM_VECTOR_LEN;
1623
- const ptr2 = passStringToWasm0(previous_nonce, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1684
+ const ptr2 = passStringToWasm0(client_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1624
1685
  const len2 = WASM_VECTOR_LEN;
1625
- wasm$1.ffiwiree2eidentity_new_order_request(retptr, this.ptr, ptr0, len0, ptr1, len1, expiry_days, addHeapObject(directory), addHeapObject(account), ptr2, len2);
1686
+ const ptr3 = passStringToWasm0(handle, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1687
+ const len3 = WASM_VECTOR_LEN;
1688
+ const ptr4 = passStringToWasm0(previous_nonce, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1689
+ const len4 = WASM_VECTOR_LEN;
1690
+ wasm$1.ffiwiree2eidentity_new_order_request(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, expiry_days, addHeapObject(directory), addHeapObject(account), ptr4, len4);
1626
1691
  var r0 = getInt32Memory0()[retptr / 4 + 0];
1627
1692
  var r1 = getInt32Memory0()[retptr / 4 + 1];
1628
1693
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -1746,18 +1811,49 @@ class FfiWireE2EIdentity {
1746
1811
  }
1747
1812
  }
1748
1813
  /**
1749
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_challenge_request]
1750
- * @param {any} handle_challenge
1814
+ * See [core_crypto::e2e_identity::WireE2eIdentity::new_dpop_challenge_request]
1815
+ * @param {string} access_token
1816
+ * @param {any} dpop_challenge
1751
1817
  * @param {Uint8Array} account
1752
1818
  * @param {string} previous_nonce
1753
1819
  * @returns {Uint8Array}
1754
1820
  */
1755
- new_challenge_request(handle_challenge, account, previous_nonce) {
1821
+ new_dpop_challenge_request(access_token, dpop_challenge, account, previous_nonce) {
1756
1822
  try {
1757
1823
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
1758
- const ptr0 = passStringToWasm0(previous_nonce, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1824
+ const ptr0 = passStringToWasm0(access_token, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1759
1825
  const len0 = WASM_VECTOR_LEN;
1760
- wasm$1.ffiwiree2eidentity_new_challenge_request(retptr, this.ptr, addHeapObject(handle_challenge), addHeapObject(account), ptr0, len0);
1826
+ const ptr1 = passStringToWasm0(previous_nonce, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1827
+ const len1 = WASM_VECTOR_LEN;
1828
+ wasm$1.ffiwiree2eidentity_new_dpop_challenge_request(retptr, this.ptr, ptr0, len0, addHeapObject(dpop_challenge), addHeapObject(account), ptr1, len1);
1829
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1830
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1831
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1832
+ if (r2) {
1833
+ throw takeObject(r1);
1834
+ }
1835
+ return takeObject(r0);
1836
+ }
1837
+ finally {
1838
+ wasm$1.__wbindgen_add_to_stack_pointer(16);
1839
+ }
1840
+ }
1841
+ /**
1842
+ * See [core_crypto::e2e_identity::WireE2eIdentity::new_oidc_challenge_request]
1843
+ * @param {string} id_token
1844
+ * @param {any} oidc_challenge
1845
+ * @param {Uint8Array} account
1846
+ * @param {string} previous_nonce
1847
+ * @returns {Uint8Array}
1848
+ */
1849
+ new_oidc_challenge_request(id_token, oidc_challenge, account, previous_nonce) {
1850
+ try {
1851
+ const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
1852
+ const ptr0 = passStringToWasm0(id_token, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1853
+ const len0 = WASM_VECTOR_LEN;
1854
+ const ptr1 = passStringToWasm0(previous_nonce, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1855
+ const len1 = WASM_VECTOR_LEN;
1856
+ wasm$1.ffiwiree2eidentity_new_oidc_challenge_request(retptr, this.ptr, ptr0, len0, addHeapObject(oidc_challenge), addHeapObject(account), ptr1, len1);
1761
1857
  var r0 = getInt32Memory0()[retptr / 4 + 0];
1762
1858
  var r1 = getInt32Memory0()[retptr / 4 + 1];
1763
1859
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -1838,20 +1934,17 @@ class FfiWireE2EIdentity {
1838
1934
  }
1839
1935
  /**
1840
1936
  * See [core_crypto::e2e_identity::WireE2eIdentity::finalize_request]
1841
- * @param {(string)[]} domains
1842
1937
  * @param {Uint8Array} order
1843
1938
  * @param {Uint8Array} account
1844
1939
  * @param {string} previous_nonce
1845
1940
  * @returns {Uint8Array}
1846
1941
  */
1847
- finalize_request(domains, order, account, previous_nonce) {
1942
+ finalize_request(order, account, previous_nonce) {
1848
1943
  try {
1849
1944
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
1850
- const ptr0 = passArrayJsValueToWasm0(domains, wasm$1.__wbindgen_malloc);
1945
+ const ptr0 = passStringToWasm0(previous_nonce, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1851
1946
  const len0 = WASM_VECTOR_LEN;
1852
- const ptr1 = passStringToWasm0(previous_nonce, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1853
- const len1 = WASM_VECTOR_LEN;
1854
- wasm$1.ffiwiree2eidentity_finalize_request(retptr, this.ptr, ptr0, len0, addHeapObject(order), addHeapObject(account), ptr1, len1);
1947
+ wasm$1.ffiwiree2eidentity_finalize_request(retptr, this.ptr, addHeapObject(order), addHeapObject(account), ptr0, len0);
1855
1948
  var r0 = getInt32Memory0()[retptr / 4 + 0];
1856
1949
  var r1 = getInt32Memory0()[retptr / 4 + 1];
1857
1950
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -2049,16 +2142,16 @@ class NewAcmeAuthz {
2049
2142
  }
2050
2143
  /**
2051
2144
  * @param {string} identifier
2052
- * @param {AcmeChallenge | undefined} wire_http_challenge
2145
+ * @param {AcmeChallenge | undefined} wire_dpop_challenge
2053
2146
  * @param {AcmeChallenge | undefined} wire_oidc_challenge
2054
2147
  */
2055
- constructor(identifier, wire_http_challenge, wire_oidc_challenge) {
2148
+ constructor(identifier, wire_dpop_challenge, wire_oidc_challenge) {
2056
2149
  const ptr0 = passStringToWasm0(identifier, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
2057
2150
  const len0 = WASM_VECTOR_LEN;
2058
2151
  let ptr1 = 0;
2059
- if (!isLikeNone(wire_http_challenge)) {
2060
- _assertClass(wire_http_challenge, AcmeChallenge);
2061
- ptr1 = wire_http_challenge.__destroy_into_raw();
2152
+ if (!isLikeNone(wire_dpop_challenge)) {
2153
+ _assertClass(wire_dpop_challenge, AcmeChallenge);
2154
+ ptr1 = wire_dpop_challenge.__destroy_into_raw();
2062
2155
  }
2063
2156
  let ptr2 = 0;
2064
2157
  if (!isLikeNone(wire_oidc_challenge)) {
@@ -2087,8 +2180,8 @@ class NewAcmeAuthz {
2087
2180
  /**
2088
2181
  * @returns {AcmeChallenge | undefined}
2089
2182
  */
2090
- get wire_http_challenge() {
2091
- const ret = wasm$1.newacmeauthz_wire_http_challenge(this.ptr);
2183
+ get wire_dpop_challenge() {
2184
+ const ret = wasm$1.newacmeauthz_wire_dpop_challenge(this.ptr);
2092
2185
  return ret === 0 ? undefined : AcmeChallenge.__wrap(ret);
2093
2186
  }
2094
2187
  /**
@@ -2244,6 +2337,27 @@ async function load(module, imports) {
2244
2337
  function getImports() {
2245
2338
  const imports = {};
2246
2339
  imports.wbg = {};
2340
+ imports.wbg.__wbg_new_f9876326328f45ed = function () {
2341
+ const ret = new Object();
2342
+ return addHeapObject(ret);
2343
+ };
2344
+ imports.wbg.__wbg_new_b525de17f44a8943 = function () {
2345
+ const ret = new Array();
2346
+ return addHeapObject(ret);
2347
+ };
2348
+ imports.wbg.__wbg_set_17224bc548dd1d7b = function (arg0, arg1, arg2) {
2349
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2350
+ };
2351
+ imports.wbg.__wbg_set_20cbc34131e76824 = function (arg0, arg1, arg2) {
2352
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2353
+ };
2354
+ imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
2355
+ takeObject(arg0);
2356
+ };
2357
+ imports.wbg.__wbindgen_number_new = function (arg0) {
2358
+ const ret = arg0;
2359
+ return addHeapObject(ret);
2360
+ };
2247
2361
  imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
2248
2362
  const ret = getObject(arg0);
2249
2363
  return addHeapObject(ret);
@@ -2253,9 +2367,6 @@ function getImports() {
2253
2367
  const ret = typeof (val) === 'object' && val !== null;
2254
2368
  return ret;
2255
2369
  };
2256
- imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
2257
- takeObject(arg0);
2258
- };
2259
2370
  imports.wbg.__wbg_getwithrefkey_15c62c2b8546208d = function (arg0, arg1) {
2260
2371
  const ret = getObject(arg0)[getObject(arg1)];
2261
2372
  return addHeapObject(ret);
@@ -2296,42 +2407,16 @@ function getImports() {
2296
2407
  const ret = getObject(arg0).length;
2297
2408
  return ret;
2298
2409
  };
2410
+ imports.wbg.__wbg_new_537b7341ce90bb31 = function (arg0) {
2411
+ const ret = new Uint8Array(getObject(arg0));
2412
+ return addHeapObject(ret);
2413
+ };
2299
2414
  imports.wbg.__wbg_call_9495de66fdbe016b = function () {
2300
2415
  return handleError(function (arg0, arg1, arg2) {
2301
2416
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2302
2417
  return addHeapObject(ret);
2303
2418
  }, arguments);
2304
2419
  };
2305
- imports.wbg.__wbg_new_537b7341ce90bb31 = function (arg0) {
2306
- const ret = new Uint8Array(getObject(arg0));
2307
- return addHeapObject(ret);
2308
- };
2309
- imports.wbg.__wbindgen_bigint_from_u64 = function (arg0) {
2310
- const ret = BigInt.asUintN(64, arg0);
2311
- return addHeapObject(ret);
2312
- };
2313
- imports.wbg.__wbg_new_f9876326328f45ed = function () {
2314
- const ret = new Object();
2315
- return addHeapObject(ret);
2316
- };
2317
- imports.wbg.__wbg_new_b525de17f44a8943 = function () {
2318
- const ret = new Array();
2319
- return addHeapObject(ret);
2320
- };
2321
- imports.wbg.__wbg_set_17224bc548dd1d7b = function (arg0, arg1, arg2) {
2322
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
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;
2329
- return addHeapObject(ret);
2330
- };
2331
- imports.wbg.__wbg_ffiwiree2eidentity_new = function (arg0) {
2332
- const ret = FfiWireE2EIdentity.__wrap(arg0);
2333
- return addHeapObject(ret);
2334
- };
2335
2420
  imports.wbg.__wbg_new_9d3a9ce4282a18a8 = function (arg0, arg1) {
2336
2421
  try {
2337
2422
  var state0 = { a: arg0, b: arg1 };
@@ -2339,7 +2424,7 @@ function getImports() {
2339
2424
  const a = state0.a;
2340
2425
  state0.a = 0;
2341
2426
  try {
2342
- return __wbg_adapter_267(a, state0.b, arg0, arg1);
2427
+ return __wbg_adapter_268(a, state0.b, arg0, arg1);
2343
2428
  }
2344
2429
  finally {
2345
2430
  state0.a = a;
@@ -2352,6 +2437,10 @@ function getImports() {
2352
2437
  state0.a = state0.b = 0;
2353
2438
  }
2354
2439
  };
2440
+ imports.wbg.__wbg_ffiwiree2eidentity_new = function (arg0) {
2441
+ const ret = FfiWireE2EIdentity.__wrap(arg0);
2442
+ return addHeapObject(ret);
2443
+ };
2355
2444
  imports.wbg.__wbg_push_49c286f04dd3bf59 = function (arg0, arg1) {
2356
2445
  const ret = getObject(arg0).push(getObject(arg1));
2357
2446
  return ret;
@@ -2364,6 +2453,10 @@ function getImports() {
2364
2453
  const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2365
2454
  return addHeapObject(ret);
2366
2455
  };
2456
+ imports.wbg.__wbindgen_bigint_from_u64 = function (arg0) {
2457
+ const ret = BigInt.asUintN(64, arg0);
2458
+ return addHeapObject(ret);
2459
+ };
2367
2460
  imports.wbg.__wbg_setonsuccess_925a7718d3f62bc1 = function (arg0, arg1) {
2368
2461
  getObject(arg0).onsuccess = getObject(arg1);
2369
2462
  };
@@ -2448,8 +2541,8 @@ function getImports() {
2448
2541
  return addHeapObject(ret);
2449
2542
  }, arguments);
2450
2543
  };
2451
- imports.wbg.__wbg_length_ea0846e494e3b16e = function (arg0) {
2452
- const ret = getObject(arg0).length;
2544
+ imports.wbg.__wbg_now_78244d2ced74c026 = function () {
2545
+ const ret = performance.now();
2453
2546
  return ret;
2454
2547
  };
2455
2548
  imports.wbg.__wbg_reject_57029f54148d79c3 = function (arg0) {
@@ -2464,10 +2557,6 @@ function getImports() {
2464
2557
  const ret = Date.now();
2465
2558
  return ret;
2466
2559
  };
2467
- imports.wbg.__wbg_now_78244d2ced74c026 = function () {
2468
- const ret = performance.now();
2469
- return ret;
2470
- };
2471
2560
  imports.wbg.__wbg_new_abda76e883ba8a5f = function () {
2472
2561
  const ret = new Error();
2473
2562
  return addHeapObject(ret);
@@ -2642,10 +2731,6 @@ function getImports() {
2642
2731
  const ret = new Uint8Array(arg0 >>> 0);
2643
2732
  return addHeapObject(ret);
2644
2733
  };
2645
- imports.wbg.__wbg_charCodeAt_d78a90aced59e02f = function (arg0, arg1) {
2646
- const ret = getObject(arg0).charCodeAt(arg1 >>> 0);
2647
- return ret;
2648
- };
2649
2734
  imports.wbg.__wbg_next_88560ec06a094dea = function () {
2650
2735
  return handleError(function (arg0) {
2651
2736
  const ret = getObject(arg0).next();
@@ -2727,12 +2812,6 @@ function getImports() {
2727
2812
  const ret = getObject(arg0).target;
2728
2813
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
2729
2814
  };
2730
- imports.wbg.__wbg_error_f64b8d41ed4d2fdc = function () {
2731
- return handleError(function (arg0) {
2732
- const ret = getObject(arg0).error;
2733
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
2734
- }, arguments);
2735
- };
2736
2815
  imports.wbg.__wbg_result_3a1fef332bc47038 = function () {
2737
2816
  return handleError(function (arg0) {
2738
2817
  const ret = getObject(arg0).result;
@@ -2773,6 +2852,12 @@ function getImports() {
2773
2852
  getObject(arg0).deleteObjectStore(getStringFromWasm0(arg1, arg2));
2774
2853
  }, arguments);
2775
2854
  };
2855
+ imports.wbg.__wbg_error_f64b8d41ed4d2fdc = function () {
2856
+ return handleError(function (arg0) {
2857
+ const ret = getObject(arg0).error;
2858
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2859
+ }, arguments);
2860
+ };
2776
2861
  imports.wbg.__wbindgen_is_falsy = function (arg0) {
2777
2862
  const ret = !getObject(arg0);
2778
2863
  return ret;
@@ -2818,29 +2903,6 @@ function getImports() {
2818
2903
  const ret = getObject(arg0).toString();
2819
2904
  return addHeapObject(ret);
2820
2905
  };
2821
- imports.wbg.__wbg_instanceof_Window_e266f02eee43b570 = function (arg0) {
2822
- let result;
2823
- try {
2824
- result = getObject(arg0) instanceof Window;
2825
- }
2826
- catch {
2827
- result = false;
2828
- }
2829
- const ret = result;
2830
- return ret;
2831
- };
2832
- imports.wbg.__wbg_crypto_71b946c90b06fb5b = function () {
2833
- return handleError(function (arg0) {
2834
- const ret = getObject(arg0).crypto;
2835
- return addHeapObject(ret);
2836
- }, arguments);
2837
- };
2838
- imports.wbg.__wbg_getRandomValues_2a91ccd2d6c499b0 = function () {
2839
- return handleError(function (arg0, arg1, arg2) {
2840
- const ret = getObject(arg0).getRandomValues(getArrayU8FromWasm0(arg1, arg2));
2841
- return addHeapObject(ret);
2842
- }, arguments);
2843
- };
2844
2906
  imports.wbg.__wbg_instanceof_Uint8Array_01cebe79ca606cca = function (arg0) {
2845
2907
  let result;
2846
2908
  try {
@@ -2888,6 +2950,10 @@ function getImports() {
2888
2950
  const ret = getObject(arg0).then(getObject(arg1));
2889
2951
  return addHeapObject(ret);
2890
2952
  };
2953
+ imports.wbg.__wbg_then_f753623316e2873a = function (arg0, arg1, arg2) {
2954
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
2955
+ return addHeapObject(ret);
2956
+ };
2891
2957
  imports.wbg.__wbg_resolve_fd40f858d9db1a04 = function (arg0) {
2892
2958
  const ret = Promise.resolve(getObject(arg0));
2893
2959
  return addHeapObject(ret);
@@ -2952,12 +3018,12 @@ function getImports() {
2952
3018
  return addHeapObject(ret);
2953
3019
  }, arguments);
2954
3020
  };
2955
- imports.wbg.__wbindgen_closure_wrapper4324 = function (arg0, arg1, arg2) {
2956
- const ret = makeMutClosure(arg0, arg1, 145, __wbg_adapter_52);
3021
+ imports.wbg.__wbindgen_closure_wrapper4410 = function (arg0, arg1, arg2) {
3022
+ const ret = makeMutClosure(arg0, arg1, 143, __wbg_adapter_52);
2957
3023
  return addHeapObject(ret);
2958
3024
  };
2959
- imports.wbg.__wbindgen_closure_wrapper4778 = function (arg0, arg1, arg2) {
2960
- const ret = makeMutClosure(arg0, arg1, 145, __wbg_adapter_55);
3025
+ imports.wbg.__wbindgen_closure_wrapper4895 = function (arg0, arg1, arg2) {
3026
+ const ret = makeMutClosure(arg0, arg1, 143, __wbg_adapter_55);
2961
3027
  return addHeapObject(ret);
2962
3028
  };
2963
3029
  return imports;
@@ -3011,14 +3077,13 @@ var exports = /*#__PURE__*/Object.freeze({
3011
3077
  PublicGroupStateBundle: PublicGroupStateBundle,
3012
3078
  WirePolicy: WirePolicy$1,
3013
3079
  default: init,
3014
- initSync: initSync,
3015
- version: version
3080
+ initSync: initSync
3016
3081
  });
3017
3082
 
3018
3083
  var wasm = async (opt = {}) => {
3019
3084
  let {importHook, serverPath} = opt;
3020
3085
 
3021
- let path = "assets/core_crypto_ffi-734d7b2f.wasm";
3086
+ let path = "assets/core_crypto_ffi-49b28313.wasm";
3022
3087
 
3023
3088
  if (serverPath != null) {
3024
3089
  path = serverPath + /[^\/\\]*$/.exec(path)[0];
@@ -3034,7 +3099,7 @@ var wasm = async (opt = {}) => {
3034
3099
 
3035
3100
  // Wire
3036
3101
  // Copyright (C) 2022 Wire Swiss GmbH
3037
- var _a, _CoreCrypto_module, _CoreCrypto_cc, _WireE2eIdentity_e2ei;
3102
+ var _a, _CoreCrypto_module, _CoreCrypto_cc, _CoreCrypto_assertModuleLoaded, _WireE2eIdentity_e2ei;
3038
3103
  /**
3039
3104
  * Error wrapper that takes care of extracting rich error details across the FFI (through JSON parsing)
3040
3105
  *
@@ -3054,7 +3119,7 @@ class CoreCryptoError extends Error {
3054
3119
  this.proteusErrorCode = richError.proteusErrorCode;
3055
3120
  }
3056
3121
  static fallback(msg, ...params) {
3057
- console.warn("Cannot build CoreCryptoError, falling back to standard Error");
3122
+ console.warn(`Cannot build CoreCryptoError, falling back to standard Error! ctx: ${msg}`);
3058
3123
  // @ts-ignore
3059
3124
  return new Error(msg, ...params);
3060
3125
  }
@@ -3277,6 +3342,26 @@ class CoreCrypto {
3277
3342
  async mlsInit(clientId) {
3278
3343
  return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").mls_init(clientId));
3279
3344
  }
3345
+ /**
3346
+ * Generates a MLS KeyPair/CredentialBundle with a temporary, random client ID.
3347
+ * This method is designed to be used in conjunction with {@link CoreCrypto.mlsInitWithClientID} and represents the first step in this process
3348
+ *
3349
+ * @returns This returns the TLS-serialized identity key (i.e. the signature keypair's public key)
3350
+ */
3351
+ async mlsGenerateKeypair() {
3352
+ return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").mls_generate_keypair());
3353
+ }
3354
+ /**
3355
+ * Updates the current temporary Client ID with the newly provided one. This is the second step in the externally-generated clients process
3356
+ *
3357
+ * Important: This is designed to be called after {@link CoreCrypto.mlsGenerateKeyPair}
3358
+ *
3359
+ * @param clientId - The newly-allocated client ID by the MLS Authentication Service
3360
+ * @param signaturePublicKey - The public key you were given at the first step; This is for authentication purposes
3361
+ */
3362
+ async mlsInitWithClientId(clientId, signaturePublicKey) {
3363
+ return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").mls_init_with_client_id(clientId, signaturePublicKey));
3364
+ }
3280
3365
  /** @hidden */
3281
3366
  constructor(cc) {
3282
3367
  /** @hidden */
@@ -3304,10 +3389,10 @@ class CoreCrypto {
3304
3389
  *
3305
3390
  * @param callbacks - Any interface following the {@link CoreCryptoCallbacks} interface
3306
3391
  */
3307
- registerCallbacks(callbacks) {
3392
+ async registerCallbacks(callbacks, ctx = null) {
3308
3393
  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);
3394
+ const wasmCallbacks = new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).CoreCryptoWasmCallbacks)(callbacks.authorize, callbacks.userAuthorize, callbacks.clientIsExistingGroupUser, ctx);
3395
+ await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").set_callbacks(wasmCallbacks);
3311
3396
  }
3312
3397
  catch (e) {
3313
3398
  throw CoreCryptoError.fromStdError(e);
@@ -3385,6 +3470,9 @@ class CoreCrypto {
3385
3470
  * @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
3471
  */
3387
3472
  async decryptMessage(conversationId, payload) {
3473
+ if (!payload?.length) {
3474
+ throw new Error("decryptMessage payload is empty or null");
3475
+ }
3388
3476
  try {
3389
3477
  const ffiDecryptedMessage = await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").decrypt_message(conversationId, payload));
3390
3478
  const commitDelay = ffiDecryptedMessage.commit_delay ?
@@ -3865,11 +3953,26 @@ class CoreCrypto {
3865
3953
  /**
3866
3954
  * Creates a new prekey with an automatically generated ID..
3867
3955
  *
3868
- * @returns: A CBOR-serialized version of the PreKeyBundle corresponding to the newly generated and stored PreKey
3956
+ * @returns A CBOR-serialized version of the PreKeyBundle corresponding to the newly generated and stored PreKey
3869
3957
  */
3870
3958
  async proteusNewPrekeyAuto() {
3871
3959
  return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_new_prekey_auto());
3872
3960
  }
3961
+ /**
3962
+ * Proteus last resort prekey stuff
3963
+ *
3964
+ * @returns A CBOR-serialize version of the PreKeyBundle associated with the last resort PreKey (holding the last resort prekey id)
3965
+ */
3966
+ async proteusLastResortPrekey() {
3967
+ return await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_last_resort_prekey());
3968
+ }
3969
+ /**
3970
+ * @returns The last resort PreKey id
3971
+ */
3972
+ static proteusLastResortPrekeyId() {
3973
+ __classPrivateFieldGet(this, _a, "m", _CoreCrypto_assertModuleLoaded).call(this);
3974
+ return __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).CoreCrypto.proteus_last_resort_prekey_id();
3975
+ }
3873
3976
  /**
3874
3977
  * Proteus public key fingerprint
3875
3978
  * It's basically the public key encoded as an hex string
@@ -3929,13 +4032,16 @@ class CoreCrypto {
3929
4032
  /**
3930
4033
  * Creates an enrollment instance with private key material you can use in order to fetch
3931
4034
  * a new x509 certificate from the acme server.
3932
- * Make sure to call [WireE2eIdentity::free] (not yet available) to dispose this instance and its associated
4035
+ * Make sure to call {@link WireE2eIdentity.free} to dispose this instance and its associated
3933
4036
  * keying material.
3934
4037
  *
3935
4038
  * @param ciphersuite - For generating signing key material. Only {@link Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519} is supported currently
3936
4039
  */
3937
- async newAcmeEnrollment() {
3938
- const e2ei = await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_acme_enrollment(Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519));
4040
+ async newAcmeEnrollment(ciphersuite = Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519) {
4041
+ if (ciphersuite !== Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519) {
4042
+ throw new Error("This ACME ciphersuite isn't supported. Only `Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519` is as of now");
4043
+ }
4044
+ const e2ei = await CoreCryptoError.asyncMapErr(__classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_acme_enrollment(ciphersuite));
3939
4045
  return new WireE2eIdentity(e2ei);
3940
4046
  }
3941
4047
  /**
@@ -3944,13 +4050,15 @@ class CoreCrypto {
3944
4050
  * @returns The `core-crypto-ffi` version as defined in its `Cargo.toml` file
3945
4051
  */
3946
4052
  static version() {
3947
- if (!__classPrivateFieldGet(this, _a, "f", _CoreCrypto_module)) {
3948
- throw new Error("Internal module hasn't been initialized. Please use `await CoreCrypto.init(params)`!");
3949
- }
3950
- return __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).version();
4053
+ __classPrivateFieldGet(this, _a, "m", _CoreCrypto_assertModuleLoaded).call(this);
4054
+ return __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).CoreCrypto.version();
3951
4055
  }
3952
4056
  }
3953
- _a = CoreCrypto, _CoreCrypto_cc = new WeakMap();
4057
+ _a = CoreCrypto, _CoreCrypto_cc = new WeakMap(), _CoreCrypto_assertModuleLoaded = function _CoreCrypto_assertModuleLoaded() {
4058
+ if (!__classPrivateFieldGet(this, _a, "f", _CoreCrypto_module)) {
4059
+ throw new Error("Internal module hasn't been initialized. Please use `await CoreCrypto.init(params)` or `await CoreCrypto.deferredInit(params)` !");
4060
+ }
4061
+ };
3954
4062
  /** @hidden */
3955
4063
  _CoreCrypto_module = { value: void 0 };
3956
4064
  class WireE2eIdentity {
@@ -3960,6 +4068,9 @@ class WireE2eIdentity {
3960
4068
  _WireE2eIdentity_e2ei.set(this, void 0);
3961
4069
  __classPrivateFieldSet(this, _WireE2eIdentity_e2ei, e2ei, "f");
3962
4070
  }
4071
+ free() {
4072
+ __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").free();
4073
+ }
3963
4074
  /**
3964
4075
  * Parses the response from `GET /acme/{provisioner-name}/directory`.
3965
4076
  * Use this {@link AcmeDirectory} in the next step to fetch the first nonce from the acme server. Use
@@ -4008,17 +4119,19 @@ class WireE2eIdentity {
4008
4119
  /**
4009
4120
  * Creates a new acme order for the handle (userId + display name) and the clientId.
4010
4121
  *
4011
- * @param handle domain of the authorization server e.g. `idp.example.org`
4012
- * @param clientId domain of the wire-server e.g. `wire.example.org`
4122
+ * @param displayName human readable name displayed in the application e.g. `Smith, Alice M (QA)`
4123
+ * @param domain DNS name of owning backend e.g. `example.com`
4124
+ * @param clientId client identifier with user b64Url encoded & clientId hex encoded e.g. `impp:wireapp=NDUyMGUyMmY2YjA3NGU3NjkyZjE1NjJjZTAwMmQ2NTQ/6add501bacd1d90e@example.com`
4125
+ * @param handle user handle e.g. `impp:wireapp=alice.smith.qa@example.com`
4013
4126
  * @param expiryDays generated x509 certificate expiry
4014
4127
  * @param directory you got from {@link directoryResponse}
4015
4128
  * @param account you got from {@link newAccountResponse}
4016
4129
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/new-account`
4017
4130
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
4018
4131
  */
4019
- newOrderRequest(handle, clientId, expiryDays, directory, account, previousNonce) {
4132
+ newOrderRequest(displayName, domain, clientId, handle, expiryDays, directory, account, previousNonce) {
4020
4133
  try {
4021
- return __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").new_order_request(handle, clientId, expiryDays, directory, account, previousNonce);
4134
+ return __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").new_order_request(displayName, domain, clientId, handle, expiryDays, directory, account, previousNonce);
4022
4135
  }
4023
4136
  catch (e) {
4024
4137
  throw CoreCryptoError.fromStdError(e);
@@ -4098,16 +4211,34 @@ class WireE2eIdentity {
4098
4211
  }
4099
4212
  }
4100
4213
  /**
4101
- * Creates a new challenge request.
4214
+ * Creates a new challenge request for Wire Dpop challenge.
4215
+ *
4216
+ * @param accessToken returned by wire-server from https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_clients__cid__access_token
4217
+ * @param dpopChallenge you found after {@link newAuthzResponse}
4218
+ * @param account you found after {@link newAccountResponse}
4219
+ * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
4220
+ * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
4221
+ */
4222
+ newDpopChallengeRequest(accessToken, dpopChallenge, account, previousNonce) {
4223
+ try {
4224
+ return __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").new_dpop_challenge_request(accessToken, dpopChallenge, account, previousNonce);
4225
+ }
4226
+ catch (e) {
4227
+ throw CoreCryptoError.fromStdError(e);
4228
+ }
4229
+ }
4230
+ /**
4231
+ * Creates a new challenge request for Wire Oidc challenge.
4102
4232
  *
4103
- * @param handleChallenge you found after {@link newAuthzResponse}
4233
+ * @param idToken you get back from Identity Provider
4234
+ * @param oidcChallenge you found after {@link newAuthzResponse}
4104
4235
  * @param account you found after {@link newAccountResponse}
4105
4236
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
4106
4237
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
4107
4238
  */
4108
- newChallengeRequest(handleChallenge, account, previousNonce) {
4239
+ newOidcChallengeRequest(idToken, oidcChallenge, account, previousNonce) {
4109
4240
  try {
4110
- return __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").new_challenge_request(handleChallenge, account, previousNonce);
4241
+ return __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").new_oidc_challenge_request(idToken, oidcChallenge, account, previousNonce);
4111
4242
  }
4112
4243
  catch (e) {
4113
4244
  throw CoreCryptoError.fromStdError(e);
@@ -4160,15 +4291,14 @@ class WireE2eIdentity {
4160
4291
  /**
4161
4292
  * Final step before fetching the certificate.
4162
4293
  *
4163
- * @param domains - domains you want to generate a certificate for e.g. `["wire.com"]`
4164
4294
  * @param order - order you got from {@link checkOrderResponse}
4165
4295
  * @param account - account you found after {@link newAccountResponse}
4166
4296
  * @param previousNonce - `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}`
4167
4297
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
4168
4298
  */
4169
- finalizeRequest(domains, order, account, previousNonce) {
4299
+ finalizeRequest(order, account, previousNonce) {
4170
4300
  try {
4171
- return __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").finalize_request(domains, order, account, previousNonce);
4301
+ return __classPrivateFieldGet(this, _WireE2eIdentity_e2ei, "f").finalize_request(order, account, previousNonce);
4172
4302
  }
4173
4303
  catch (e) {
4174
4304
  throw CoreCryptoError.fromStdError(e);