@wireapp/core-crypto 0.8.2 → 0.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireapp/core-crypto",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "CoreCrypto bindings for the Web",
5
5
  "type": "module",
6
6
  "module": "platforms/web/corecrypto.js",
@@ -49,6 +49,16 @@ export declare enum Ciphersuite {
49
49
  */
50
50
  MLS_256_DHKEMP384_AES256GCM_SHA384_P384 = 7
51
51
  }
52
+ export declare enum CredentialType {
53
+ /**
54
+ * Just a KeyPair
55
+ */
56
+ Basic = 1,
57
+ /**
58
+ * A certificate obtained through e2e identity enrollment process
59
+ */
60
+ X509 = 2
61
+ }
52
62
  /**
53
63
  * Configuration object for new conversations
54
64
  */
@@ -235,6 +245,10 @@ export interface CoreCryptoDeferredParams {
235
245
  * This should be appropriately stored in a secure location (i.e. WebCrypto private key storage)
236
246
  */
237
247
  key: string;
248
+ /**
249
+ * All the ciphersuites this MLS client can support
250
+ */
251
+ ciphersuites: Ciphersuite[];
238
252
  /**
239
253
  * External PRNG entropy pool seed.
240
254
  * This **must** be exactly 32 bytes
@@ -440,6 +454,17 @@ export interface ExternalRemoveProposalArgs extends ExternalProposalArgs {
440
454
  */
441
455
  keyPackageRef: Uint8Array;
442
456
  }
457
+ export interface ExternalAddProposalArgs extends ExternalProposalArgs {
458
+ /**
459
+ * {@link Ciphersuite} to propose to join the MLS group with.
460
+ */
461
+ ciphersuite: Ciphersuite;
462
+ /**
463
+ * Fails when it is {@link CredentialType.X509} and no Credential has been created
464
+ * for it beforehand with {@link CoreCrypto.e2eiMlsInit} or variants.
465
+ */
466
+ credentialType: CredentialType;
467
+ }
443
468
  export interface CoreCryptoCallbacks {
444
469
  /**
445
470
  * This callback is called by CoreCrypto to know whether a given clientId is authorized to "write"
@@ -513,7 +538,7 @@ export declare class CoreCrypto {
513
538
  * });
514
539
  * ````
515
540
  */
516
- static init({ databaseName, key, clientId, wasmFilePath, entropySeed }: CoreCryptoParams): Promise<CoreCrypto>;
541
+ static init({ databaseName, key, clientId, wasmFilePath, ciphersuites, entropySeed }: CoreCryptoParams): Promise<CoreCrypto>;
517
542
  /**
518
543
  * Almost identical to {@link CoreCrypto.init} but allows a 2 phase initialization of MLS.
519
544
  * First, calling this will set up the keystore and will allow generating proteus prekeys.
@@ -521,29 +546,32 @@ export declare class CoreCrypto {
521
546
  * Use this clientId to initialize MLS with {@link CoreCrypto.mlsInit}.
522
547
  * @param params - {@link CoreCryptoDeferredParams}
523
548
  */
524
- static deferredInit({ databaseName, key, entropySeed, wasmFilePath }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
549
+ static deferredInit({ databaseName, key, ciphersuites, entropySeed, wasmFilePath }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
525
550
  /**
526
551
  * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
527
552
  *
528
553
  * @param clientId - {@link CoreCryptoParams#clientId} but required
554
+ * @param ciphersuites - All the ciphersuites supported by this MLS client
529
555
  */
530
- mlsInit(clientId: ClientId): Promise<void>;
556
+ mlsInit(clientId: ClientId, ciphersuites: Ciphersuite[]): Promise<void>;
531
557
  /**
532
558
  * Generates a MLS KeyPair/CredentialBundle with a temporary, random client ID.
533
- * This method is designed to be used in conjunction with {@link CoreCrypto.mlsInitWithClientID} and represents the first step in this process
559
+ * This method is designed to be used in conjunction with {@link CoreCrypto.mlsInitWithClientId} and represents the first step in this process
534
560
  *
561
+ * @param ciphersuites - All the ciphersuites supported by this MLS client
535
562
  * @returns This returns the TLS-serialized identity key (i.e. the signature keypair's public key)
536
563
  */
537
- mlsGenerateKeypair(): Promise<Uint8Array>;
564
+ mlsGenerateKeypair(ciphersuites: Ciphersuite[]): Promise<Uint8Array[]>;
538
565
  /**
539
566
  * Updates the current temporary Client ID with the newly provided one. This is the second step in the externally-generated clients process
540
567
  *
541
- * Important: This is designed to be called after {@link CoreCrypto.mlsGenerateKeyPair}
568
+ * Important: This is designed to be called after {@link CoreCrypto.mlsGenerateKeypair}
542
569
  *
543
570
  * @param clientId - The newly-allocated client ID by the MLS Authentication Service
544
- * @param signaturePublicKey - The public key you were given at the first step; This is for authentication purposes
571
+ * @param signaturePublicKeys - The public key you were given at the first step; This is for authentication purposes
572
+ * @param ciphersuites - All the ciphersuites supported by this MLS client
545
573
  */
546
- mlsInitWithClientId(clientId: ClientId, signaturePublicKey: Uint8Array): Promise<void>;
574
+ mlsInitWithClientId(clientId: ClientId, signaturePublicKeys: Uint8Array[], ciphersuites: Ciphersuite[]): Promise<void>;
547
575
  /** @hidden */
548
576
  private constructor();
549
577
  /**
@@ -655,18 +683,21 @@ export declare class CoreCrypto {
655
683
  /**
656
684
  * @returns The client's public key
657
685
  */
658
- clientPublicKey(): Promise<Uint8Array>;
686
+ clientPublicKey(ciphersuite: Ciphersuite): Promise<Uint8Array>;
659
687
  /**
688
+ *
689
+ * @param ciphersuite - of the KeyPackages to count
660
690
  * @returns The amount of valid, non-expired KeyPackages that are persisted in the backing storage
661
691
  */
662
- clientValidKeypackagesCount(): Promise<number>;
692
+ clientValidKeypackagesCount(ciphersuite: Ciphersuite): Promise<number>;
663
693
  /**
664
694
  * Fetches a requested amount of keypackages
665
695
  *
696
+ * @param ciphersuite - of the KeyPackages to generate
666
697
  * @param amountRequested - The amount of keypackages requested
667
698
  * @returns An array of length `amountRequested` containing TLS-serialized KeyPackages
668
699
  */
669
- clientKeypackages(amountRequested: number): Promise<Array<Uint8Array>>;
700
+ clientKeypackages(ciphersuite: Ciphersuite, amountRequested: number): Promise<Array<Uint8Array>>;
670
701
  /**
671
702
  * Adds new clients to a conversation, assuming the current client has the right to add new clients to the conversation.
672
703
  *
@@ -727,7 +758,7 @@ export declare class CoreCrypto {
727
758
  * @returns A {@link ProposalBundle} containing the Proposal and its reference in order to roll it back if necessary
728
759
  */
729
760
  newProposal(proposalType: ProposalType, args: ProposalArgs | AddProposalArgs | RemoveProposalArgs): Promise<ProposalBundle>;
730
- newExternalProposal(externalProposalType: ExternalProposalType, args: ExternalProposalArgs | ExternalRemoveProposalArgs): Promise<Uint8Array>;
761
+ newExternalProposal(externalProposalType: ExternalProposalType, args: ExternalAddProposalArgs | ExternalRemoveProposalArgs): Promise<Uint8Array>;
731
762
  /**
732
763
  * Exports public group state for use in external commits
733
764
  *
@@ -746,10 +777,13 @@ export declare class CoreCrypto {
746
777
  * bad can happen if you forget to except some storage space wasted.
747
778
  *
748
779
  * @param publicGroupState - a TLS encoded PublicGroupState fetched from the Delivery Service
780
+ * @param credentialType - kind of Credential to use for joining this group. If {@link CredentialType.Basic} is
781
+ * chosen and no Credential has been created yet for it, a new one will be generated.
749
782
  * @param configuration - configuration of the MLS group
783
+ * When {@link CredentialType.X509} is chosen, it fails when no Credential has been created for the given {@link Ciphersuite}.
750
784
  * @returns see {@link ConversationInitBundle}
751
785
  */
752
- joinByExternalCommit(publicGroupState: Uint8Array, configuration?: CustomConfiguration): Promise<ConversationInitBundle>;
786
+ joinByExternalCommit(publicGroupState: Uint8Array, credentialType: CredentialType, configuration?: CustomConfiguration): Promise<ConversationInitBundle>;
753
787
  /**
754
788
  * This merges the commit generated by {@link CoreCrypto.joinByExternalCommit}, persists the group permanently
755
789
  * and deletes the temporary one. This step makes the group operational and ready to encrypt/decrypt message
@@ -966,17 +1000,32 @@ export declare class CoreCrypto {
966
1000
  * @param displayName human readable name displayed in the application e.g. `Smith, Alice M (QA)`
967
1001
  * @param handle user handle e.g. `alice.smith.qa@example.com`
968
1002
  * @param expiryDays generated x509 certificate expiry
969
- * @param ciphersuite - For generating signing key material. Only {@link Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519} is supported currently
1003
+ * @param ciphersuite - for generating signing key material
970
1004
  * @returns The new {@link WireE2eIdentity} object
971
1005
  */
972
- newAcmeEnrollment(clientId: string, displayName: string, handle: string, expiryDays: number, ciphersuite?: Ciphersuite): Promise<WireE2eIdentity>;
1006
+ e2eiNewEnrollment(clientId: string, displayName: string, handle: string, expiryDays: number, ciphersuite: Ciphersuite): Promise<WireE2eIdentity>;
973
1007
  /**
974
1008
  * Parses the ACME server response from the endpoint fetching x509 certificates and uses it to initialize the MLS client with a certificate
975
1009
  *
976
- * @param e2ei - the enrollment instance used to fetch the certificates
1010
+ * @param enrollment - the enrollment instance used to fetch the certificates
977
1011
  * @param certificateChain - the raw response from ACME server
978
1012
  */
979
- e2eiMlsInit(e2ei: WireE2eIdentity, certificateChain: string): Promise<void>;
1013
+ e2eiMlsInit(enrollment: WireE2eIdentity, certificateChain: string): Promise<void>;
1014
+ /**
1015
+ * Allows persisting an active enrollment (for example while redirecting the user during OAuth) in order to resume
1016
+ * it later with {@link e2eiEnrollmentStashPop}
1017
+ *
1018
+ * @param enrollment the enrollment instance to persist
1019
+ * @returns a handle to fetch the enrollment later with {@link e2eiEnrollmentStashPop}
1020
+ */
1021
+ e2eiEnrollmentStash(enrollment: WireE2eIdentity): Promise<Uint8Array>;
1022
+ /**
1023
+ * Fetches the persisted enrollment and deletes it from the keystore
1024
+ *
1025
+ * @param handle returned by {@link e2eiEnrollmentStash}
1026
+ * @returns the persisted enrollment instance
1027
+ */
1028
+ e2eiEnrollmentStashPop(handle: Uint8Array): Promise<WireE2eIdentity>;
980
1029
  /**
981
1030
  * Returns the current version of {@link CoreCrypto}
982
1031
  *
@@ -1055,11 +1104,10 @@ export declare class WireE2eIdentity {
1055
1104
  * Then send it to `POST /clients/{id}/access-token`
1056
1105
  * {@link https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_clients__cid__access_token} on wire-server.
1057
1106
  *
1058
- * @param accessTokenUrl backend endpoint where this token will be sent. Should be this one {@link https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_clients__cid__access_token}
1059
1107
  * @param expirySecs of the client Dpop JWT. This should be equal to the grace period set in Team Management
1060
1108
  * @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}
1061
1109
  */
1062
- createDpopToken(accessTokenUrl: string, expirySecs: number, backendNonce: string): Uint8Array;
1110
+ createDpopToken(expirySecs: number, backendNonce: string): Uint8Array;
1063
1111
  /**
1064
1112
  * Creates a new challenge request for Wire Dpop challenge.
1065
1113
  *
@@ -1096,9 +1144,10 @@ export declare class WireE2eIdentity {
1096
1144
  * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}`.
1097
1145
  *
1098
1146
  * @param order HTTP response body
1147
+ * @return the finalize url to use with {@link finalizeRequest}
1099
1148
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1100
1149
  */
1101
- checkOrderResponse(order: JsonRawData): void;
1150
+ checkOrderResponse(order: JsonRawData): string;
1102
1151
  /**
1103
1152
  * Final step before fetching the certificate.
1104
1153
  *
@@ -1111,9 +1160,10 @@ export declare class WireE2eIdentity {
1111
1160
  * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}/finalize`.
1112
1161
  *
1113
1162
  * @param finalize HTTP response body
1163
+ * @return the certificate url to use with {@link certificateRequest}
1114
1164
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1115
1165
  */
1116
- finalizeResponse(finalize: JsonRawData): void;
1166
+ finalizeResponse(finalize: JsonRawData): string;
1117
1167
  /**
1118
1168
  * Creates a request for finally fetching the x509 certificate.
1119
1169
  *
@@ -1205,6 +1255,13 @@ export interface AcmeChallenge {
1205
1255
  * @readonly
1206
1256
  */
1207
1257
  url: string;
1258
+ /**
1259
+ * Non-standard, Wire specific claim. Indicates the consumer from where it should get the challenge proof.
1260
+ * Either from wire-server "/access-token" endpoint in case of a DPoP challenge, or from an OAuth token endpoint for an OIDC challenge
1261
+ *
1262
+ * @readonly
1263
+ */
1264
+ target: string;
1208
1265
  }
1209
1266
 
1210
1267
  export {};