@wireapp/core-crypto 1.0.0-rc.9 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,74 @@
1
+ /**
2
+ * For creating a challenge.
3
+ * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
4
+ */
5
+ export class AcmeChallenge {
6
+ free(): void;
7
+ /**
8
+ * Contains raw JSON data of this challenge. This is parsed by the underlying Rust library hence should not be accessed
9
+ */
10
+ readonly delegate: Uint8Array;
11
+ /**
12
+ * Non-standard, Wire specific claim. Indicates the consumer from where it should get the challenge proof.
13
+ * Either from wire-server "/access-token" endpoint in case of a DPoP challenge, or from an OAuth token endpoint for an OIDC challenge
14
+ */
15
+ readonly target: string;
16
+ /**
17
+ * URL of this challenge
18
+ */
19
+ readonly url: string;
20
+ }
21
+ /**
22
+ * Dump of the PKI environemnt as PEM
23
+ */
24
+ export class E2eiDumpedPkiEnv {
25
+ free(): void;
26
+ /**
27
+ * CRLs registered in the PKI env
28
+ */
29
+ readonly crls: (string)[];
30
+ /**
31
+ * Intermediate CAs that are loaded
32
+ */
33
+ readonly intermediates: (string)[];
34
+ /**
35
+ * Root CA in use (i.e. Trust Anchor)
36
+ */
37
+ readonly root_ca: string;
38
+ }
39
+ /**
40
+ * Result of an authorization creation.
41
+ * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5
42
+ */
43
+ export class NewAcmeAuthz {
44
+ free(): void;
45
+ /**
46
+ * Associated ACME Challenge
47
+ */
48
+ readonly challenge: AcmeChallenge;
49
+ /**
50
+ * DNS entry associated with those challenge
51
+ */
52
+ readonly identifier: string;
53
+ /**
54
+ * ACME challenge + ACME key thumbprint
55
+ */
56
+ readonly keyauth: string | undefined;
57
+ }
58
+ /**
59
+ * Result of an order creation.
60
+ * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
61
+ */
62
+ export class NewAcmeOrder {
63
+ free(): void;
64
+ /**
65
+ */
66
+ readonly authorizations: (Uint8Array)[];
67
+ /**
68
+ * Contains raw JSON data of this order. This is parsed by the underlying Rust library hence should not be accessed
69
+ */
70
+ readonly delegate: Uint8Array;
71
+ }
1
72
  /**
2
73
  * Error wrapper that takes care of extracting rich error details across the FFI (through JSON parsing)
3
74
  *
@@ -47,11 +118,7 @@ export declare enum Ciphersuite {
47
118
  /**
48
119
  * DH KEM P384 | AES-GCM 256 | SHA2-384 | EcDSA P384
49
120
  */
50
- MLS_256_DHKEMP384_AES256GCM_SHA384_P384 = 7,
51
- /**
52
- * x25519Kyber768Draft00 Hybrid KEM | AES-GCM 128 | SHA2-256 | Ed25519
53
- */
54
- MLS_128_X25519KYBER768DRAFT00_AES128GCM_SHA256_Ed25519 = 61489
121
+ MLS_256_DHKEMP384_AES256GCM_SHA384_P384 = 7
55
122
  }
56
123
  export declare enum CredentialType {
57
124
  /**
@@ -79,24 +146,6 @@ export interface ConversationConfiguration {
79
146
  * Implementation specific configuration
80
147
  */
81
148
  custom?: CustomConfiguration;
82
- /**
83
- * Trust anchors to be added in the group's context extensions
84
- */
85
- perDomainTrustAnchors?: PerDomainTrustAnchor[];
86
- }
87
- /**
88
- * A wrapper containing the configuration for trust anchors to be added in the group's context
89
- * extensions
90
- */
91
- export interface PerDomainTrustAnchor {
92
- /**
93
- * Domain name of the owning backend this anchor refers to. One of the certificate in the chain has to have this domain in its SANs
94
- */
95
- domain_name: string;
96
- /**
97
- * PEM encoded (partial) certificate chain. This contains the certificate chain for the CA certificate issuing the E2E Identity certificates
98
- */
99
- intermediate_certificate_chain: string;
100
149
  }
101
150
  /**
102
151
  * see [core_crypto::prelude::MlsWirePolicy]
@@ -179,6 +228,10 @@ export interface MemberAddedMessages {
179
228
  * @readonly
180
229
  */
181
230
  groupInfo: GroupInfoBundle;
231
+ /**
232
+ * New CRL distribution points that appeared by the introduction of a new credential
233
+ */
234
+ crlNewDistributionPoints?: string[];
182
235
  }
183
236
  /**
184
237
  * Data shape for a MLS generic commit + optional bundle (aka stapled commit & welcome)
@@ -275,6 +328,10 @@ export interface RotateBundle {
275
328
  * @readonly
276
329
  */
277
330
  keyPackageRefsToRemove: Uint8Array[];
331
+ /**
332
+ * New CRL distribution points that appeared by the introduction of a new credential
333
+ */
334
+ crlNewDistributionPoints?: string[];
278
335
  }
279
336
  /**
280
337
  * Params for CoreCrypto deferred initialization
@@ -290,10 +347,6 @@ export interface CoreCryptoDeferredParams {
290
347
  * This should be appropriately stored in a secure location (i.e. WebCrypto private key storage)
291
348
  */
292
349
  key: string;
293
- /**
294
- * All the ciphersuites this MLS client can support
295
- */
296
- ciphersuites: Ciphersuite[];
297
350
  /**
298
351
  * External PRNG entropy pool seed.
299
352
  * This **must** be exactly 32 bytes
@@ -314,19 +367,14 @@ export interface CoreCryptoParams extends CoreCryptoDeferredParams {
314
367
  * This should stay consistent as it will be verified against the stored signature & identity to validate the persisted credential
315
368
  */
316
369
  clientId: ClientId;
317
- }
318
- /**
319
- * Data shape for adding clients to a conversation
320
- */
321
- export interface Invitee {
322
370
  /**
323
- * Client ID as a byte array
371
+ * All the ciphersuites this MLS client can support
324
372
  */
325
- id: ClientId;
373
+ ciphersuites: Ciphersuite[];
326
374
  /**
327
- * MLS KeyPackage belonging to the aforementioned client
375
+ * Number of initial KeyPackage to create when initializing the client
328
376
  */
329
- kp: Uint8Array;
377
+ nbKeyPackage?: number;
330
378
  }
331
379
  export interface ConversationInitBundle {
332
380
  /**
@@ -348,6 +396,27 @@ export interface ConversationInitBundle {
348
396
  * @readonly
349
397
  */
350
398
  groupInfo: GroupInfoBundle;
399
+ /**
400
+ * New CRL distribution points that appeared by the introduction of a new credential
401
+ */
402
+ crlNewDistributionPoints?: string[];
403
+ }
404
+ /**
405
+ * Supporting struct for CRL registration result
406
+ */
407
+ export interface CRLRegistration {
408
+ /**
409
+ * Whether this CRL modifies the old CRL (i.e. has a different revocated cert list)
410
+ *
411
+ * @readonly
412
+ */
413
+ dirty: boolean;
414
+ /**
415
+ * Optional expiration timestamp
416
+ *
417
+ * @readonly
418
+ */
419
+ expiration?: number;
351
420
  }
352
421
  /**
353
422
  * This is a wrapper for all the possible outcomes you can get after decrypting a message
@@ -392,6 +461,10 @@ export interface DecryptedMessage {
392
461
  * because the DS did not fan them out in order.
393
462
  */
394
463
  bufferedMessages?: BufferedDecryptedMessage[];
464
+ /**
465
+ * New CRL distribution points that appeared by the introduction of a new credential
466
+ */
467
+ crlNewDistributionPoints?: string[];
395
468
  }
396
469
  /**
397
470
  * Almost same as {@link DecryptedMessage} but avoids recursion
@@ -425,17 +498,43 @@ export interface BufferedDecryptedMessage {
425
498
  * see {@link DecryptedMessage.identity}
426
499
  */
427
500
  identity?: WireIdentity;
501
+ /**
502
+ * see {@link DecryptedMessage.crlNewDistributionPoints}
503
+ */
504
+ crlNewDistributionPoints?: string[];
428
505
  }
429
506
  /**
430
- * Represents the identity claims identifying a client. Those claims are verifiable by any member in the group
507
+ * Represents the identity claims identifying a client
508
+ * Those claims are verifiable by any member in the group
431
509
  */
432
510
  export interface WireIdentity {
433
511
  /**
434
- * Represents the identity claims identifying a client. Those claims are verifiable by any member in the group
512
+ * Unique client identifier
435
513
  */
436
514
  clientId: string;
437
515
  /**
438
- * user handle e.g. `john_wire`
516
+ * Status of the Credential at the moment T when this object is created
517
+ */
518
+ status: DeviceStatus;
519
+ /**
520
+ * MLS thumbprint
521
+ */
522
+ thumbprint: string;
523
+ /**
524
+ * Indicates whether the credential is Basic or X509
525
+ */
526
+ credentialType: CredentialType;
527
+ /**
528
+ * In case {@link credentialType} is {@link CredentialType.X509} this is populated
529
+ */
530
+ x509Identity?: X509Identity;
531
+ }
532
+ /**
533
+ * Represents the parts of {@link WireIdentity} that are specific to a X509 certificate (and not a Basic one).
534
+ */
535
+ export interface X509Identity {
536
+ /**
537
+ * User handle e.g. `john_wire`
439
538
  */
440
539
  handle: string;
441
540
  /**
@@ -450,6 +549,54 @@ export interface WireIdentity {
450
549
  * X509 certificate identifying this client in the MLS group ; PEM encoded
451
550
  */
452
551
  certificate: string;
552
+ /**
553
+ * X509 certificate serial number
554
+ */
555
+ serialNumber: string;
556
+ /**
557
+ * X509 certificate not before as Unix timestamp
558
+ */
559
+ notBefore: bigint;
560
+ /**
561
+ * X509 certificate not after as Unix timestamp
562
+ */
563
+ notAfter: bigint;
564
+ }
565
+ export interface AcmeDirectory {
566
+ /**
567
+ * URL for fetching a new nonce. Use this only for creating a new account.
568
+ */
569
+ newNonce: string;
570
+ /**
571
+ * URL for creating a new account.
572
+ */
573
+ newAccount: string;
574
+ /**
575
+ * URL for creating a new order.
576
+ */
577
+ newOrder: string;
578
+ /**
579
+ * Revocation URL
580
+ */
581
+ revokeCert: string;
582
+ }
583
+ /**
584
+ * Indicates the standalone status of a device Credential in a MLS group at a moment T.
585
+ * This does not represent the states where a device is not using MLS or is not using end-to-end identity
586
+ */
587
+ export declare enum DeviceStatus {
588
+ /**
589
+ * All is fine
590
+ */
591
+ Valid = 1,
592
+ /**
593
+ * The Credential's certificate is expired
594
+ */
595
+ Expired = 2,
596
+ /**
597
+ * The Credential's certificate is revoked
598
+ */
599
+ Revoked = 3
453
600
  }
454
601
  /**
455
602
  * Returned by all methods creating proposals. Contains a proposal message and an identifier to roll back the proposal
@@ -467,6 +614,26 @@ export interface ProposalBundle {
467
614
  * @readonly
468
615
  */
469
616
  proposalRef: ProposalRef;
617
+ /**
618
+ * New CRL Distribution of members of this group
619
+ *
620
+ * @readonly
621
+ */
622
+ crlNewDistributionPoints?: string[];
623
+ }
624
+ export interface WelcomeBundle {
625
+ /**
626
+ * Conversation ID
627
+ *
628
+ * @readonly
629
+ */
630
+ id: Uint8Array;
631
+ /**
632
+ * New CRL Distribution of members of this group
633
+ *
634
+ * @readonly
635
+ */
636
+ crlNewDistributionPoints?: string[];
470
637
  }
471
638
  /**
472
639
  * MLS Proposal type
@@ -578,11 +745,43 @@ export interface CoreCryptoCallbacks {
578
745
  */
579
746
  clientIsExistingGroupUser: (conversationId: Uint8Array, clientId: Uint8Array, existingClients: Uint8Array[], parent_conversation_clients?: Uint8Array[]) => Promise<boolean>;
580
747
  }
748
+ /**
749
+ * An interface to register a logger in CoreCrypto
750
+ **/
751
+ export interface CoreCryptoLogger {
752
+ /**
753
+ * This method will be called by Core Crypto to log messages. It is up to the implementer to decide how to handle the message and where to actually log it.
754
+ * @param level - the level of the logged message. it will also be present in the json message
755
+ * @param json_msg - message to log in json format
756
+ **/
757
+ log: (level: CoreCryptoLogLevel, json_msg: string) => void;
758
+ }
759
+ /**
760
+ * Defines the maximum log level for the logs from Core Crypto
761
+ **/
762
+ export declare enum CoreCryptoLogLevel {
763
+ Off = 1,
764
+ Trace = 2,
765
+ Debug = 3,
766
+ Info = 4,
767
+ Warn = 5,
768
+ Error = 6
769
+ }
770
+ /**
771
+ * Initializes the global logger for Core Crypto and registers the callback. Can be called only once
772
+ * @param logger - the interface to be called when something is going to be logged
773
+ * @param level - the max level that should be logged
774
+ **/
775
+ export declare function initLogger(logger: CoreCryptoLogger, level: CoreCryptoLogLevel, ctx?: any): void;
581
776
  /**
582
777
  * Wrapper for the WASM-compiled version of CoreCrypto
583
778
  */
584
779
  export declare class CoreCrypto {
585
780
  #private;
781
+ /**
782
+ * Should only be used internally
783
+ */
784
+ inner(): unknown;
586
785
  /**
587
786
  * This is your entrypoint to initialize {@link CoreCrypto}!
588
787
  *
@@ -616,7 +815,7 @@ export declare class CoreCrypto {
616
815
  * });
617
816
  * ````
618
817
  */
619
- static init({ databaseName, key, clientId, wasmFilePath, ciphersuites, entropySeed }: CoreCryptoParams): Promise<CoreCrypto>;
818
+ static init({ databaseName, key, clientId, wasmFilePath, ciphersuites, entropySeed, nbKeyPackage, }: CoreCryptoParams): Promise<CoreCrypto>;
620
819
  /**
621
820
  * Almost identical to {@link CoreCrypto.init} but allows a 2 phase initialization of MLS.
622
821
  * First, calling this will set up the keystore and will allow generating proteus prekeys.
@@ -624,14 +823,15 @@ export declare class CoreCrypto {
624
823
  * Use this clientId to initialize MLS with {@link CoreCrypto.mlsInit}.
625
824
  * @param params - {@link CoreCryptoDeferredParams}
626
825
  */
627
- static deferredInit({ databaseName, key, ciphersuites, entropySeed, wasmFilePath }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
826
+ static deferredInit({ databaseName, key, entropySeed, wasmFilePath, }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
628
827
  /**
629
828
  * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
630
829
  *
631
830
  * @param clientId - {@link CoreCryptoParams#clientId} but required
632
831
  * @param ciphersuites - All the ciphersuites supported by this MLS client
832
+ * @param nbKeyPackage - number of initial KeyPackage to create when initializing the client
633
833
  */
634
- mlsInit(clientId: ClientId, ciphersuites: Ciphersuite[]): Promise<void>;
834
+ mlsInit(clientId: ClientId, ciphersuites: Ciphersuite[], nbKeyPackage?: number): Promise<void>;
635
835
  /**
636
836
  * Generates a MLS KeyPair/CredentialBundle with a temporary, random client ID.
637
837
  * This method is designed to be used in conjunction with {@link CoreCrypto.mlsInitWithClientId} and represents the first step in this process
@@ -715,6 +915,12 @@ export declare class CoreCrypto {
715
915
  * ```
716
916
  */
717
917
  conversationEpoch(conversationId: ConversationId): Promise<number>;
918
+ /**
919
+ * Returns the ciphersuite of a conversation
920
+ *
921
+ * @returns the ciphersuite of the conversation
922
+ */
923
+ conversationCiphersuite(conversationId: ConversationId): Promise<Ciphersuite>;
718
924
  /**
719
925
  * Wipes and destroys the local storage of a given conversation / MLS group
720
926
  *
@@ -756,22 +962,6 @@ export declare class CoreCrypto {
756
962
  * @returns The encrypted payload for the given group. This needs to be fanned out to the other members of the group.
757
963
  */
758
964
  encryptMessage(conversationId: ConversationId, message: Uint8Array): Promise<Uint8Array>;
759
- /**
760
- * Updates the trust anchors for a conversation. This should be called when a federated event happens (new team added/removed).
761
- * Clients should add and/or remove trust anchors from the new backend to the conversation. The method will check
762
- * for duplicated domains and the validity of the certificate chain.
763
- *
764
- * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
765
- * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
766
- * epoch, use new encryption secrets etc...
767
- *
768
- * @param conversationId - The ID of the conversation
769
- * @param removeDomainNames - Domains to remove from the trust anchors
770
- * @param addTrustAnchors - New trust anchors to add to the conversation
771
- *
772
- * @returns A {@link CommitBundle}
773
- */
774
- updateTrustAnchorsFromConversation(conversationId: ConversationId, removeDomainNames: string[], addTrustAnchors: PerDomainTrustAnchor[]): Promise<CommitBundle>;
775
965
  /**
776
966
  * Ingest a TLS-serialized MLS welcome message to join an existing MLS group
777
967
  *
@@ -783,14 +973,15 @@ export declare class CoreCrypto {
783
973
  * @param configuration - configuration of the MLS group
784
974
  * @returns The conversation ID of the newly joined group. You can use the same ID to decrypt/encrypt messages
785
975
  */
786
- processWelcomeMessage(welcomeMessage: Uint8Array, configuration?: CustomConfiguration): Promise<ConversationId>;
976
+ processWelcomeMessage(welcomeMessage: Uint8Array, configuration?: CustomConfiguration): Promise<WelcomeBundle>;
787
977
  /**
788
978
  * Get the client's public signature key. To upload to the DS for further backend side validation
789
979
  *
790
980
  * @param ciphersuite - of the signature key to get
981
+ * @param credentialType - of the public key to look for
791
982
  * @returns the client's public signature key
792
983
  */
793
- clientPublicKey(ciphersuite: Ciphersuite): Promise<Uint8Array>;
984
+ clientPublicKey(ciphersuite: Ciphersuite, credentialType: CredentialType): Promise<Uint8Array>;
794
985
  /**
795
986
  *
796
987
  * @param ciphersuite - of the KeyPackages to count
@@ -822,11 +1013,11 @@ export declare class CoreCrypto {
822
1013
  * epoch, use new encryption secrets etc...
823
1014
  *
824
1015
  * @param conversationId - The ID of the conversation
825
- * @param clients - Array of {@link Invitee} (which are Client ID / KeyPackage pairs)
1016
+ * @param keyPackages - KeyPackages of the new clients to add
826
1017
  *
827
1018
  * @returns A {@link CommitBundle}
828
1019
  */
829
- addClientsToConversation(conversationId: ConversationId, clients: Invitee[]): Promise<MemberAddedMessages>;
1020
+ addClientsToConversation(conversationId: ConversationId, keyPackages: Uint8Array[]): Promise<MemberAddedMessages>;
830
1021
  /**
831
1022
  * Removes the provided clients from a conversation; Assuming those clients exist and the current client is allowed
832
1023
  * to do so, otherwise this operation does nothing.
@@ -950,6 +1141,15 @@ export declare class CoreCrypto {
950
1141
  * @returns A `Uint8Array` representing the derived key
951
1142
  */
952
1143
  exportSecretKey(conversationId: ConversationId, keyLength: number): Promise<Uint8Array>;
1144
+ /**
1145
+ * Returns the raw public key of the single external sender present in this group.
1146
+ * This should be used to initialize a subconversation
1147
+ *
1148
+ * @param conversationId - The group's ID
1149
+ *
1150
+ * @returns A `Uint8Array` representing the external sender raw public key
1151
+ */
1152
+ getExternalSender(conversationId: ConversationId): Promise<Uint8Array>;
953
1153
  /**
954
1154
  * Returns all clients from group's members
955
1155
  *
@@ -1107,49 +1307,91 @@ export declare class CoreCrypto {
1107
1307
  * Creates an enrollment instance with private key material you can use in order to fetch
1108
1308
  * a new x509 certificate from the acme server.
1109
1309
  *
1110
- * @param clientId - client identifier with user b64Url encoded & clientId hex encoded e.g. `NDUyMGUyMmY2YjA3NGU3NjkyZjE1NjJjZTAwMmQ2NTQ:6add501bacd1d90e@example.com`
1310
+ * @param clientId - client identifier e.g. `b7ac11a4-8f01-4527-af88-1c30885a7931:6add501bacd1d90e@example.com`
1111
1311
  * @param displayName - human-readable name displayed in the application e.g. `Smith, Alice M (QA)`
1112
1312
  * @param handle - user handle e.g. `alice.smith.qa@example.com`
1113
- * @param expiryDays - generated x509 certificate expiry
1313
+ * @param expirySec - generated x509 certificate expiry
1114
1314
  * @param ciphersuite - for generating signing key material
1315
+ * @param team - name of the Wire team a user belongs to
1115
1316
  * @returns The new {@link E2eiEnrollment} enrollment instance to use with {@link CoreCrypto.e2eiMlsInitOnly}
1116
1317
  */
1117
- e2eiNewEnrollment(clientId: string, displayName: string, handle: string, expiryDays: number, ciphersuite: Ciphersuite): Promise<E2eiEnrollment>;
1318
+ e2eiNewEnrollment(clientId: string, displayName: string, handle: string, expirySec: number, ciphersuite: Ciphersuite, team?: string): Promise<E2eiEnrollment>;
1118
1319
  /**
1119
1320
  * Generates an E2EI enrollment instance for a "regular" client (with a Basic credential) willing to migrate to E2EI.
1120
1321
  * Once the enrollment is finished, use the instance in {@link CoreCrypto.e2eiRotateAll} to do the rotation.
1121
1322
  *
1122
- * @param clientId - client identifier with user b64Url encoded & clientId hex encoded e.g. `NDUyMGUyMmY2YjA3NGU3NjkyZjE1NjJjZTAwMmQ2NTQ:6add501bacd1d90e@example.com`
1123
1323
  * @param displayName - human-readable name displayed in the application e.g. `Smith, Alice M (QA)`
1124
1324
  * @param handle - user handle e.g. `alice.smith.qa@example.com`
1125
- * @param expiryDays - generated x509 certificate expiry
1325
+ * @param expirySec - generated x509 certificate expiry
1126
1326
  * @param ciphersuite - for generating signing key material
1327
+ * @param team - name of the Wire team a user belongs to
1127
1328
  * @returns The new {@link E2eiEnrollment} enrollment instance to use with {@link CoreCrypto.e2eiRotateAll}
1128
1329
  */
1129
- e2eiNewActivationEnrollment(clientId: string, displayName: string, handle: string, expiryDays: number, ciphersuite: Ciphersuite): Promise<E2eiEnrollment>;
1330
+ e2eiNewActivationEnrollment(displayName: string, handle: string, expirySec: number, ciphersuite: Ciphersuite, team?: string): Promise<E2eiEnrollment>;
1130
1331
  /**
1131
1332
  * Generates an E2EI enrollment instance for a E2EI client (with a X509 certificate credential)
1132
1333
  * having to change/rotate their credential, either because the former one is expired or it
1133
1334
  * has been revoked. It lets you change the DisplayName or the handle
1134
1335
  * if you need to. Once the enrollment is finished, use the instance in {@link CoreCrypto.e2eiRotateAll} to do the rotation.
1135
1336
  *
1136
- * @param clientId - client identifier with user b64Url encoded & clientId hex encoded e.g. `NDUyMGUyMmY2YjA3NGU3NjkyZjE1NjJjZTAwMmQ2NTQ:6add501bacd1d90e@example.com`
1137
- * @param expiryDays - generated x509 certificate expiry
1337
+ * @param expirySec - generated x509 certificate expiry
1138
1338
  * @param ciphersuite - for generating signing key material
1139
1339
  * @param displayName - human-readable name displayed in the application e.g. `Smith, Alice M (QA)`
1140
1340
  * @param handle - user handle e.g. `alice.smith.qa@example.com`
1341
+ * @param team - name of the Wire team a user belongs to
1141
1342
  * @returns The new {@link E2eiEnrollment} enrollment instance to use with {@link CoreCrypto.e2eiRotateAll}
1142
1343
  */
1143
- e2eiNewRotateEnrollment(clientId: string, expiryDays: number, ciphersuite: Ciphersuite, displayName?: string, handle?: string): Promise<E2eiEnrollment>;
1344
+ e2eiNewRotateEnrollment(expirySec: number, ciphersuite: Ciphersuite, displayName?: string, handle?: string, team?: string): Promise<E2eiEnrollment>;
1144
1345
  /**
1145
1346
  * Use this method to initialize end-to-end identity when a client signs up and the grace period is already expired ;
1146
1347
  * that means he cannot initialize with a Basic credential
1147
1348
  *
1148
1349
  * @param enrollment - the enrollment instance used to fetch the certificates
1149
1350
  * @param certificateChain - the raw response from ACME server
1351
+ * @param nbKeyPackage - number of initial KeyPackage to create when initializing the client
1150
1352
  * @returns a MlsClient initialized with only a x509 credential
1151
1353
  */
1152
- e2eiMlsInitOnly(enrollment: E2eiEnrollment, certificateChain: string): Promise<void>;
1354
+ e2eiMlsInitOnly(enrollment: E2eiEnrollment, certificateChain: string, nbKeyPackage?: number): Promise<string[] | undefined>;
1355
+ /**
1356
+ * Dumps the PKI environment as PEM
1357
+ *
1358
+ * @returns a struct with different fields representing the PKI environment as PEM strings
1359
+ */
1360
+ e2eiDumpPKIEnv(): Promise<E2eiDumpedPkiEnv | undefined>;
1361
+ /**
1362
+ * @returns whether the E2EI PKI environment is setup (i.e. Root CA, Intermediates, CRLs)
1363
+ */
1364
+ e2eiIsPKIEnvSetup(): Promise<boolean>;
1365
+ /**
1366
+ * Registers a Root Trust Anchor CA for the use in E2EI processing.
1367
+ *
1368
+ * Please note that without a Root Trust Anchor, all validations *will* fail;
1369
+ * So this is the first step to perform after initializing your E2EI client
1370
+ *
1371
+ * @param trustAnchorPEM - PEM certificate to anchor as a Trust Root
1372
+ */
1373
+ e2eiRegisterAcmeCA(trustAnchorPEM: string): Promise<void>;
1374
+ /**
1375
+ * Registers an Intermediate CA for the use in E2EI processing.
1376
+ *
1377
+ * Please note that a Root Trust Anchor CA is needed to validate Intermediate CAs;
1378
+ * You **need** to have a Root CA registered before calling this
1379
+ *
1380
+ * @param certPEM - PEM certificate to register as an Intermediate CA
1381
+ */
1382
+ e2eiRegisterIntermediateCA(certPEM: string): Promise<string[] | undefined>;
1383
+ /**
1384
+ * Registers a CRL for the use in E2EI processing.
1385
+ *
1386
+ * Please note that a Root Trust Anchor CA is needed to validate CRLs;
1387
+ * You **need** to have a Root CA registered before calling this
1388
+ *
1389
+ * @param crlDP - CRL Distribution Point; Basically the URL you fetched it from
1390
+ * @param crlDER - DER representation of the CRL
1391
+ *
1392
+ * @returns a {@link CRLRegistration} with the dirty state of the new CRL (see struct) and its expiration timestamp
1393
+ */
1394
+ e2eiRegisterCRL(crlDP: string, crlDER: Uint8Array): Promise<CRLRegistration>;
1153
1395
  /**
1154
1396
  * Creates a commit in all local conversations for changing the credential. Requires first
1155
1397
  * having enrolled a new X509 certificate with either {@link CoreCrypto.e2eiNewActivationEnrollment}
@@ -1177,7 +1419,7 @@ export declare class CoreCrypto {
1177
1419
  */
1178
1420
  e2eiEnrollmentStashPop(handle: Uint8Array): Promise<E2eiEnrollment>;
1179
1421
  /**
1180
- * Indicates when to mark a conversation as degraded i.e. when not all its members have a X509.
1422
+ * Indicates when to mark a conversation as not verified i.e. when not all its members have a X509.
1181
1423
  * Credential generated by Wire's end-to-end identity enrollment
1182
1424
  *
1183
1425
  * @param conversationId The group's ID
@@ -1196,10 +1438,29 @@ export declare class CoreCrypto {
1196
1438
  * Certificate Credential (after turning on end-to-end identity).
1197
1439
  *
1198
1440
  * @param conversationId - identifier of the conversation
1199
- * @param clientIds - identifiers of the user
1441
+ * @param deviceIds - identifiers of the devices
1200
1442
  * @returns identities or if no member has a x509 certificate, it will return an empty List
1201
1443
  */
1202
- getUserIdentities(conversationId: ConversationId, clientIds: ClientId[]): Promise<WireIdentity[]>;
1444
+ getDeviceIdentities(conversationId: ConversationId, deviceIds: ClientId[]): Promise<WireIdentity[]>;
1445
+ /**
1446
+ * From a given conversation, get the identity of the users (device holders) supplied.
1447
+ * Identity is only present for devices with a Certificate Credential (after turning on end-to-end identity).
1448
+ * If no member has a x509 certificate, it will return an empty Vec.
1449
+ *
1450
+ * @param conversationId - identifier of the conversation
1451
+ * @param userIds - user identifiers hyphenated UUIDv4 e.g. 'bd4c7053-1c5a-4020-9559-cd7bf7961954'
1452
+ * @returns a Map with all the identities for a given users. Consumers are then recommended to reduce those identities to determine the actual status of a user.
1453
+ */
1454
+ getUserIdentities(conversationId: ConversationId, userIds: string[]): Promise<Map<string, WireIdentity[]>>;
1455
+ /**
1456
+ * Gets the e2ei conversation state from a `GroupInfo`. Useful to check if the group has e2ei
1457
+ * turned on or not before joining it.
1458
+ *
1459
+ * @param groupInfo - a TLS encoded GroupInfo fetched from the Delivery Service
1460
+ * @param credentialType - kind of Credential to check usage of. Defaults to X509 for now as no other value will give any result.
1461
+ * @returns see {@link E2eiConversationState}
1462
+ */
1463
+ getCredentialInUse(groupInfo: Uint8Array, credentialType?: CredentialType): Promise<E2eiConversationState>;
1203
1464
  /**
1204
1465
  * Returns the current version of {@link CoreCrypto}
1205
1466
  *
@@ -1225,7 +1486,7 @@ export declare class E2eiEnrollment {
1225
1486
  * @param directory HTTP response body
1226
1487
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.1
1227
1488
  */
1228
- directoryResponse(directory: JsonRawData): AcmeDirectory;
1489
+ directoryResponse(directory: JsonRawData): Promise<AcmeDirectory>;
1229
1490
  /**
1230
1491
  * For creating a new acme account. This returns a signed JWS-alike request body to send to
1231
1492
  * `POST /acme/{provisioner-name}/new-account`.
@@ -1233,27 +1494,27 @@ export declare class E2eiEnrollment {
1233
1494
  * @param previousNonce you got from calling `HEAD {@link AcmeDirectory.newNonce}`
1234
1495
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.3
1235
1496
  */
1236
- newAccountRequest(previousNonce: string): JsonRawData;
1497
+ newAccountRequest(previousNonce: string): Promise<JsonRawData>;
1237
1498
  /**
1238
1499
  * Parses the response from `POST /acme/{provisioner-name}/new-account`.
1239
1500
  * @param account HTTP response body
1240
1501
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.3
1241
1502
  */
1242
- newAccountResponse(account: JsonRawData): void;
1503
+ newAccountResponse(account: JsonRawData): Promise<void>;
1243
1504
  /**
1244
1505
  * Creates a new acme order for the handle (userId + display name) and the clientId.
1245
1506
  *
1246
1507
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/new-account`
1247
1508
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1248
1509
  */
1249
- newOrderRequest(previousNonce: string): JsonRawData;
1510
+ newOrderRequest(previousNonce: string): Promise<JsonRawData>;
1250
1511
  /**
1251
1512
  * Parses the response from `POST /acme/{provisioner-name}/new-order`.
1252
1513
  *
1253
1514
  * @param order HTTP response body
1254
1515
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1255
1516
  */
1256
- newOrderResponse(order: JsonRawData): NewAcmeOrder;
1517
+ newOrderResponse(order: JsonRawData): Promise<NewAcmeOrder>;
1257
1518
  /**
1258
1519
  * Creates a new authorization request.
1259
1520
  *
@@ -1262,14 +1523,14 @@ export declare class E2eiEnrollment {
1262
1523
  * previous to this method if you are creating the second authorization)
1263
1524
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5
1264
1525
  */
1265
- newAuthzRequest(url: string, previousNonce: string): JsonRawData;
1526
+ newAuthzRequest(url: string, previousNonce: string): Promise<JsonRawData>;
1266
1527
  /**
1267
1528
  * Parses the response from `POST /acme/{provisioner-name}/authz/{authz-id}`
1268
1529
  *
1269
1530
  * @param authz HTTP response body
1270
1531
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5
1271
1532
  */
1272
- newAuthzResponse(authz: JsonRawData): NewAcmeAuthz;
1533
+ newAuthzResponse(authz: JsonRawData): Promise<NewAcmeAuthz>;
1273
1534
  /**
1274
1535
  * Generates a new client Dpop JWT token. It demonstrates proof of possession of the nonces
1275
1536
  * (from wire-server & acme server) and will be verified by the acme server when verifying the
@@ -1281,7 +1542,7 @@ export declare class E2eiEnrollment {
1281
1542
  * @param expirySecs of the client Dpop JWT. This should be equal to the grace period set in Team Management
1282
1543
  * @param backendNonce you get by calling `GET /clients/token/nonce` on wire-server as defined here {@link https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/get_clients__client__nonce}
1283
1544
  */
1284
- createDpopToken(expirySecs: number, backendNonce: string): Uint8Array;
1545
+ createDpopToken(expirySecs: number, backendNonce: string): Promise<Uint8Array>;
1285
1546
  /**
1286
1547
  * Creates a new challenge request for Wire Dpop challenge.
1287
1548
  *
@@ -1289,7 +1550,14 @@ export declare class E2eiEnrollment {
1289
1550
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
1290
1551
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1291
1552
  */
1292
- newDpopChallengeRequest(accessToken: string, previousNonce: string): JsonRawData;
1553
+ newDpopChallengeRequest(accessToken: string, previousNonce: string): Promise<JsonRawData>;
1554
+ /**
1555
+ * Parses the response from `POST /acme/{provisioner-name}/challenge/{challenge-id}` for the DPoP challenge.
1556
+ *
1557
+ * @param challenge HTTP response body
1558
+ * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1559
+ */
1560
+ newDpopChallengeResponse(challenge: JsonRawData): Promise<void>;
1293
1561
  /**
1294
1562
  * Creates a new challenge request for Wire Oidc challenge.
1295
1563
  *
@@ -1297,14 +1565,15 @@ export declare class E2eiEnrollment {
1297
1565
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
1298
1566
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1299
1567
  */
1300
- newOidcChallengeRequest(idToken: string, previousNonce: string): JsonRawData;
1568
+ newOidcChallengeRequest(idToken: string, previousNonce: string): Promise<JsonRawData>;
1301
1569
  /**
1302
- * Parses the response from `POST /acme/{provisioner-name}/challenge/{challenge-id}`.
1570
+ * Parses the response from `POST /acme/{provisioner-name}/challenge/{challenge-id}` for the OIDC challenge.
1303
1571
  *
1572
+ * @param cc the CoreCrypto instance
1304
1573
  * @param challenge HTTP response body
1305
1574
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1306
1575
  */
1307
- newChallengeResponse(challenge: JsonRawData): void;
1576
+ newOidcChallengeResponse(challenge: JsonRawData): Promise<void>;
1308
1577
  /**
1309
1578
  * Verifies that the previous challenge has been completed.
1310
1579
  *
@@ -1312,7 +1581,7 @@ export declare class E2eiEnrollment {
1312
1581
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/challenge/{challenge-id}`
1313
1582
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1314
1583
  */
1315
- checkOrderRequest(orderUrl: string, previousNonce: string): JsonRawData;
1584
+ checkOrderRequest(orderUrl: string, previousNonce: string): Promise<JsonRawData>;
1316
1585
  /**
1317
1586
  * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}`.
1318
1587
  *
@@ -1320,14 +1589,14 @@ export declare class E2eiEnrollment {
1320
1589
  * @return finalize url to use with {@link finalizeRequest}
1321
1590
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1322
1591
  */
1323
- checkOrderResponse(order: JsonRawData): string;
1592
+ checkOrderResponse(order: JsonRawData): Promise<string>;
1324
1593
  /**
1325
1594
  * Final step before fetching the certificate.
1326
1595
  *
1327
1596
  * @param previousNonce - `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}`
1328
1597
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1329
1598
  */
1330
- finalizeRequest(previousNonce: string): JsonRawData;
1599
+ finalizeRequest(previousNonce: string): Promise<JsonRawData>;
1331
1600
  /**
1332
1601
  * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}/finalize`.
1333
1602
  *
@@ -1335,111 +1604,14 @@ export declare class E2eiEnrollment {
1335
1604
  * @return the certificate url to use with {@link certificateRequest}
1336
1605
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1337
1606
  */
1338
- finalizeResponse(finalize: JsonRawData): string;
1607
+ finalizeResponse(finalize: JsonRawData): Promise<string>;
1339
1608
  /**
1340
1609
  * Creates a request for finally fetching the x509 certificate.
1341
1610
  *
1342
1611
  * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}/finalize`
1343
1612
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4.2
1344
1613
  */
1345
- certificateRequest(previousNonce: string): JsonRawData;
1346
- }
1347
- /**
1348
- * Holds URLs of all the standard ACME endpoint supported on an ACME server.
1349
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.1
1350
- */
1351
- export interface AcmeDirectory {
1352
- /**
1353
- * URL for fetching a new nonce. Use this only for creating a new account.
1354
- *
1355
- * @readonly
1356
- */
1357
- newNonce: string;
1358
- /**
1359
- * URL for creating a new account.
1360
- *
1361
- * @readonly
1362
- */
1363
- newAccount: string;
1364
- /**
1365
- * URL for creating a new order.
1366
- *
1367
- * @readonly
1368
- */
1369
- newOrder: string;
1370
- /**
1371
- * Revocation URL
1372
- *
1373
- * @readonly
1374
- */
1375
- revokeCert: string;
1376
- }
1377
- /**
1378
- * Result of an order creation
1379
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1380
- */
1381
- export interface NewAcmeOrder {
1382
- /**
1383
- * Contains raw JSON data of this order. This is parsed by the underlying Rust library hence should not be accessed
1384
- *
1385
- * @readonly
1386
- */
1387
- delegate: Uint8Array;
1388
- /**
1389
- * An authorization for each domain to create
1390
- *
1391
- * @readonly
1392
- */
1393
- authorizations: Uint8Array[];
1394
- }
1395
- /**
1396
- * Result of an authorization creation.
1397
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5
1398
- */
1399
- export interface NewAcmeAuthz {
1400
- /**
1401
- * DNS entry associated with those challenge
1402
- *
1403
- * @readonly
1404
- */
1405
- identifier: string;
1406
- /**
1407
- * Challenge for the clientId
1408
- *
1409
- * @readonly
1410
- */
1411
- wireDpopChallenge?: AcmeChallenge;
1412
- /**
1413
- * Challenge for the userId and displayName
1414
- *
1415
- * @readonly
1416
- */
1417
- wireOidcChallenge?: AcmeChallenge;
1418
- }
1419
- /**
1420
- * For creating a challenge
1421
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1422
- */
1423
- export interface AcmeChallenge {
1424
- /**
1425
- * Contains raw JSON data of this challenge. This is parsed by the underlying Rust library hence should not be accessed
1426
- *
1427
- * @readonly
1428
- */
1429
- delegate: Uint8Array;
1430
- /**
1431
- * URL of this challenge
1432
- *
1433
- * @readonly
1434
- */
1435
- url: string;
1436
- /**
1437
- * Non-standard, Wire specific claim. Indicates the consumer from where it should get the challenge proof.
1438
- * Either from wire-server "/access-token" endpoint in case of a DPoP challenge, or from an OAuth token endpoint for an OIDC challenge
1439
- *
1440
- * @readonly
1441
- */
1442
- target: string;
1614
+ certificateRequest(previousNonce: string): Promise<JsonRawData>;
1443
1615
  }
1444
1616
  /**
1445
1617
  * Indicates the state of a Conversation regarding end-to-end identity.
@@ -1454,9 +1626,9 @@ export declare enum E2eiConversationState {
1454
1626
  /**
1455
1627
  * Some clients are either still Basic or their certificate is expired
1456
1628
  */
1457
- Degraded = 2,
1629
+ NotVerified = 2,
1458
1630
  /**
1459
- * All clients are still Basic. If all client have expired certificates, Degraded is returned.
1631
+ * All clients are still Basic. If all client have expired certificates, NotVerified is returned.
1460
1632
  */
1461
1633
  NotEnabled = 3
1462
1634
  }