@wireapp/core-crypto 8.0.3 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,13 @@
2
2
 
3
3
  /* tslint:disable */
4
4
  /* eslint-disable */
5
+ /**
6
+ * Construct a ciphersuite enum instance from its discriminant.
7
+ */
5
8
  export function ciphersuiteFromU16(discriminant: number): Ciphersuite;
9
+ /**
10
+ * Get an instance of the default ciphersuite.
11
+ */
6
12
  export function ciphersuiteDefault(): Ciphersuite;
7
13
  /**
8
14
  * Updates the key of the CoreCrypto database.
@@ -46,6 +52,9 @@ export enum Ciphersuite {
46
52
  */
47
53
  MLS_256_DHKEMP384_AES256GCM_SHA384_P384 = 7
48
54
  }
55
+ /**
56
+ * Type of Credential
57
+ */
49
58
  export enum CredentialType {
50
59
  /**
51
60
  * Basic credential i.e. a KeyPair
@@ -56,6 +65,11 @@ export enum CredentialType {
56
65
  */
57
66
  X509 = 2
58
67
  }
68
+ /**
69
+ * Indicates the standalone status of a device Credential in a MLS group at a moment T.
70
+ *
71
+ * This does not represent the states where a device is not using MLS or is not using end-to-end identity
72
+ */
59
73
  export enum DeviceStatus {
60
74
  /**
61
75
  * All is fine
@@ -165,15 +179,24 @@ declare class AcmeDirectory {
165
179
  declare class BufferedDecryptedMessage {
166
180
  private constructor();
167
181
  free(): void;
182
+ /**
183
+ * Decrypted plaintext
184
+ */
168
185
  readonly message: Uint8Array | undefined;
169
186
  /**
170
- * It is set to false if ingesting this MLS message has resulted in the client being removed from the group (i.e. a Remove commit)
187
+ * False if processing this message caused the client to be removed from the group, i.e. due to a Remove commit
171
188
  */
172
189
  readonly isActive: boolean;
173
190
  /**
174
- * Commit delay hint (in milliseconds) to prevent clients from hammering the server with epoch changes
191
+ * Commit delay in seconds.
192
+ *
193
+ * When set, clients must delay this long before processing a commit.
194
+ * This reduces load on the backend, which otherwise would receive epoch change notifications from all clients simultaneously.
175
195
  */
176
196
  readonly commitDelay: bigint | undefined;
197
+ /**
198
+ * [ClientId] of the sender of the message being decrypted. Only present for application messages.
199
+ */
177
200
  readonly senderClientId: ClientId | undefined;
178
201
  /**
179
202
  * true when the decrypted message resulted in an epoch change i.e. it was a commit
@@ -181,9 +204,12 @@ declare class BufferedDecryptedMessage {
181
204
  * Deprecated: this member will be removed in the future. Prefer using the `EpochObserver` interface.
182
205
  */
183
206
  readonly hasEpochChanged: boolean;
207
+ /**
208
+ * Identity claims present in the sender credential
209
+ */
184
210
  readonly identity: WireIdentity;
185
211
  /**
186
- * New CRL Distribution of members of this group
212
+ * New CRL distribution points that appeared by the introduction of a new credential
187
213
  */
188
214
  readonly crlNewDistributionPoints: string[] | undefined;
189
215
  }
@@ -238,16 +264,41 @@ export class BuildMetadata {
238
264
  */
239
265
  readonly gitDirty: string;
240
266
  }
267
+ /**
268
+ * A Client identifier
269
+ *
270
+ * A unique identifier for clients. A client is an identifier for each App a user is using, such as desktop,
271
+ * mobile, etc. Users can have multiple clients.
272
+ * More information [here](https://messaginglayersecurity.rocks/mls-architecture/draft-ietf-mls-architecture.html#name-group-members-and-clients)
273
+ */
241
274
  export class ClientId {
242
275
  free(): void;
276
+ /**
277
+ * Instantiate a client id from a byte array.
278
+ */
243
279
  constructor(bytes: Uint8Array);
280
+ /**
281
+ * Copy the id into a new byte array.
282
+ */
244
283
  copyBytes(): Uint8Array;
245
284
  }
246
285
  declare class ConversationConfiguration {
247
286
  free(): void;
287
+ /**
288
+ * Construct a `ConversationConfiguration` from its parts.
289
+ */
248
290
  constructor(ciphersuite?: Ciphersuite | null, external_senders?: ExternalSenderKey[] | null, key_rotation_span?: number | null, wire_policy?: WirePolicy | null);
291
+ /**
292
+ * The ciphersuite used in the group
293
+ */
249
294
  readonly ciphersuite: Ciphersuite | undefined;
295
+ /**
296
+ * Delivery service public signature key and credential
297
+ */
250
298
  readonly externalSenders: ExternalSenderKey[];
299
+ /**
300
+ * Implementation specific configuration
301
+ */
251
302
  readonly custom: CustomConfiguration;
252
303
  }
253
304
  /**
@@ -465,6 +516,15 @@ declare class CoreCryptoContext {
465
516
  * See [core_crypto::transaction_context::TransactionContext::proteus_decrypt]
466
517
  */
467
518
  proteus_decrypt(session_id: string, ciphertext: Uint8Array): Promise<Uint8Array>;
519
+ /**
520
+ * Decrypt a message whether or not the proteus session already exists, and saves the session.
521
+ *
522
+ * This is intended to replace simple usages of `proteusDecrypt`.
523
+ *
524
+ * However, when decrypting large numbers of messages in a single session, the existing methods
525
+ * may be more efficient.
526
+ */
527
+ proteus_decrypt_safe(session_id: string, ciphertext: Uint8Array): Promise<Uint8Array>;
468
528
  /**
469
529
  * See [core_crypto::transaction_context::TransactionContext::proteus_encrypt]
470
530
  */
@@ -474,10 +534,18 @@ declare class CoreCryptoContext {
474
534
  */
475
535
  proteus_encrypt_batched(sessions: string[], plaintext: Uint8Array): Promise<Map<string, Uint8Array>>;
476
536
  /**
537
+ * Creates a new Proteus prekey with the given id and returns the CBOR-serialized version of the prekey bundle
538
+ *
539
+ * Warning: The Proteus client **MUST** be initialized with `proteus_init` first or an error will be returned
540
+ *
477
541
  * See [core_crypto::transaction_context::TransactionContext::proteus_new_prekey]
478
542
  */
479
543
  proteus_new_prekey(prekey_id: number): Promise<Uint8Array>;
480
544
  /**
545
+ * Creates a new Proteus prekey with an automatically incremented ID and returns the CBOR-serialized version of the prekey bundle
546
+ *
547
+ * Warning: The Proteus client **MUST** be initialized with `proteus_init` first or an error will be returned
548
+ *
481
549
  * See [core_crypto::transaction_context::TransactionContext::proteus_new_prekey_auto]
482
550
  */
483
551
  proteus_new_prekey_auto(): Promise<ProteusAutoPrekeyBundle>;
@@ -497,10 +565,6 @@ declare class CoreCryptoContext {
497
565
  * See [core_crypto::transaction_context::TransactionContext::proteus_fingerprint_remote]
498
566
  */
499
567
  proteus_fingerprint_remote(session_id: string): Promise<string>;
500
- /**
501
- * See [core_crypto::transaction_context::TransactionContext::proteus_cryptobox_migrate]
502
- */
503
- proteus_cryptobox_migrate(path: string): Promise<void>;
504
568
  /**
505
569
  * See [core_crypto::transaction_context::TransactionContext::proteus_reload_sessions]
506
570
  */
@@ -528,6 +592,9 @@ declare class CoreCryptoContext {
528
592
  }
529
593
  declare class CrlRegistration {
530
594
  free(): void;
595
+ /**
596
+ * Contstruct a CRL registration from its fields
597
+ */
531
598
  constructor(dirty: boolean, expiration?: bigint | null);
532
599
  /**
533
600
  * Whether this CRL modifies the old CRL (i.e. has a different revocated cert list)
@@ -547,6 +614,9 @@ declare class CrlRegistration {
547
614
  */
548
615
  export class CustomConfiguration {
549
616
  free(): void;
617
+ /**
618
+ * Construct a `CustomConfiguration` from its parts.
619
+ */
550
620
  constructor(key_rotation_span?: number | null, wire_policy?: WirePolicy | null);
551
621
  /**
552
622
  * Duration in seconds after which we will automatically force a self-update commit
@@ -569,22 +639,37 @@ export class CustomConfiguration {
569
639
  */
570
640
  set wirePolicy(value: WirePolicy | null | undefined);
571
641
  }
642
+ /**
643
+ * The key used to encrypt the database.
644
+ */
572
645
  export class DatabaseKey {
573
646
  free(): void;
647
+ /**
648
+ * Construct a new instance from a byte vector.
649
+ */
574
650
  constructor(buf: Uint8Array);
575
651
  }
576
652
  declare class DecryptedMessage {
577
653
  private constructor();
578
654
  free(): void;
655
+ /**
656
+ * Decrypted plaintext
657
+ */
579
658
  readonly message: Uint8Array | undefined;
580
659
  /**
581
- * It is set to false if ingesting this MLS message has resulted in the client being removed from the group (i.e. a Remove commit)
660
+ * False if processing this message caused the client to be removed from the group, i.e. due to a Remove commit
582
661
  */
583
662
  readonly isActive: boolean;
584
663
  /**
585
- * Commit delay hint (in milliseconds) to prevent clients from hammering the server with epoch changes
664
+ * Commit delay in seconds.
665
+ *
666
+ * When set, clients must delay this long before processing a commit.
667
+ * This reduces load on the backend, which otherwise would receive epoch change notifications from all clients simultaneously.
586
668
  */
587
669
  readonly commitDelay: bigint | undefined;
670
+ /**
671
+ * [ClientId] of the sender of the message being decrypted. Only present for application messages.
672
+ */
588
673
  readonly senderClientId: ClientId | undefined;
589
674
  /**
590
675
  * true when the decrypted message resulted in an epoch change i.e. it was a commit
@@ -592,10 +677,19 @@ declare class DecryptedMessage {
592
677
  * Deprecated: this member will be removed in the future. Prefer using the `EpochObserver` interface.
593
678
  */
594
679
  readonly hasEpochChanged: boolean;
680
+ /**
681
+ * Identity claims present in the sender credential
682
+ */
595
683
  readonly identity: WireIdentity;
684
+ /**
685
+ * Only set when the decrypted message is a commit.
686
+ *
687
+ * Contains buffered messages for next epoch which were received before the commit creating the epoch
688
+ * because the DS did not fan them out in order.
689
+ */
596
690
  readonly bufferedMessages: BufferedDecryptedMessage[] | undefined;
597
691
  /**
598
- * New CRL Distribution of members of this group
692
+ * New CRL distribution points that appeared by the introduction of a new credential
599
693
  */
600
694
  readonly crlNewDistributionPoints: string[] | undefined;
601
695
  }
@@ -721,9 +815,19 @@ declare class KeyPackage {
721
815
  */
722
816
  copyBytes(): Uint8Array;
723
817
  }
818
+ /**
819
+ * An entity / data which has been packaged by the application to be encrypted
820
+ * and transmitted in an application message.
821
+ */
724
822
  export class MlsTransportData {
725
823
  free(): void;
824
+ /**
825
+ * Construct `MlsTransportData` by providing data
826
+ */
726
827
  constructor(buf: Uint8Array);
828
+ /**
829
+ * The specific data which has been packaged to be encrypted/transmitted.
830
+ */
727
831
  readonly data: Uint8Array;
728
832
  }
729
833
  /**
@@ -757,13 +861,25 @@ export class NewAcmeAuthz {
757
861
  export class NewAcmeOrder {
758
862
  private constructor();
759
863
  free(): void;
864
+ /**
865
+ * Opaque raw json value
866
+ */
760
867
  readonly delegate: Uint8Array;
868
+ /**
869
+ * Authorizations to create with `new_authz_request`
870
+ */
761
871
  readonly authorizations: string[];
762
872
  }
763
873
  declare class ProteusAutoPrekeyBundle {
764
874
  private constructor();
765
875
  free(): void;
876
+ /**
877
+ * Prekey id (automatically incremented)
878
+ */
766
879
  readonly id: number;
880
+ /**
881
+ * CBOR serialization of prekey
882
+ */
767
883
  readonly pkb: Uint8Array;
768
884
  }
769
885
  /**
@@ -819,7 +935,8 @@ export class WelcomeBundle {
819
935
  readonly crlNewDistributionPoints: string[] | undefined;
820
936
  }
821
937
  /**
822
- * See [core_crypto::prelude::WireIdentity]
938
+ * Represents the identity claims identifying a client
939
+ * Those claims are verifiable by any member in the group
823
940
  */
824
941
  export class WireIdentity {
825
942
  private constructor();
@@ -836,21 +953,51 @@ export class WireIdentity {
836
953
  * MLS thumbprint
837
954
  */
838
955
  readonly thumbprint: string;
956
+ /**
957
+ * Indicates whether the credential is Basic or X509
958
+ */
839
959
  credentialType: CredentialType;
960
+ /**
961
+ * In case 'credential_type' is [CredentialType::X509] this is populated
962
+ */
840
963
  readonly x509Identity: X509Identity | undefined;
841
964
  }
842
965
  /**
843
- * See [core_crypto::prelude::X509Identity]
966
+ * Represents the parts of [WireIdentity][crate::WireIdentity] that are specific to a X509 certificate (and not a Basic one).
967
+ *
968
+ * We don't use an enum here since the sole purpose of this is to be exposed through the FFI (and
969
+ * union types are impossible to carry over the FFI boundary)
844
970
  */
845
971
  export class X509Identity {
846
972
  private constructor();
847
973
  free(): void;
974
+ /**
975
+ * user handle e.g. `john_wire`
976
+ */
848
977
  readonly handle: string;
978
+ /**
979
+ * Name as displayed in the messaging application e.g. `John Fitzgerald Kennedy`
980
+ */
849
981
  readonly displayName: string;
982
+ /**
983
+ * DNS domain for which this identity proof was generated e.g. `whitehouse.gov`
984
+ */
850
985
  readonly domain: string;
986
+ /**
987
+ * X509 certificate identifying this client in the MLS group ; PEM encoded
988
+ */
851
989
  readonly certificate: string;
990
+ /**
991
+ * X509 certificate serial number
992
+ */
852
993
  readonly serialNumber: string;
994
+ /**
995
+ * X509 certificate not before as Unix timestamp
996
+ */
853
997
  readonly notBefore: bigint;
998
+ /**
999
+ * X509 certificate not after as Unix timestamp
1000
+ */
854
1001
  readonly notAfter: bigint;
855
1002
  }
856
1003
  interface ConversationConfiguration$1 {
@@ -1642,12 +1789,6 @@ declare class CoreCryptoContext$1 {
1642
1789
  * @returns Hex-encoded public key string
1643
1790
  **/
1644
1791
  static proteusFingerprintPrekeybundle(prekey: Uint8Array): string;
1645
- /**
1646
- * Imports all the data stored by Cryptobox into the CoreCrypto keystore
1647
- *
1648
- * @param storeName - The name of the IndexedDB store where the data is stored
1649
- */
1650
- proteusCryptoboxMigrate(storeName: string): Promise<void>;
1651
1792
  /**
1652
1793
  * Creates an enrollment instance with private key material you can use in order to fetch
1653
1794
  * a new x509 certificate from the acme server.