@signalapp/libsignal-client 0.60.0 → 0.60.2

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/Native.d.ts CHANGED
@@ -143,6 +143,8 @@ type Serialized<T> = Buffer;
143
143
  export function registerErrors(errorsModule: Record<string, unknown>): void;
144
144
 
145
145
  export const enum LogLevel { Error = 1, Warn, Info, Debug, Trace }
146
+ export function AccountEntropyPool_DeriveBackupKey(accountEntropy: string): Buffer;
147
+ export function AccountEntropyPool_DeriveSvrKey(accountEntropy: string): Buffer;
146
148
  export function AccountEntropyPool_Generate(): string;
147
149
  export function Aes256GcmSiv_Decrypt(aesGcmSiv: Wrapper<Aes256GcmSiv>, ctext: Buffer, nonce: Buffer, associatedData: Buffer): Buffer;
148
150
  export function Aes256GcmSiv_Encrypt(aesGcmSivObj: Wrapper<Aes256GcmSiv>, ptext: Buffer, nonce: Buffer, associatedData: Buffer): Buffer;
@@ -170,6 +172,12 @@ export function BackupAuthCredential_GetBackupId(credentialBytes: Buffer): Buffe
170
172
  export function BackupAuthCredential_GetBackupLevel(credentialBytes: Buffer): number;
171
173
  export function BackupAuthCredential_GetType(credentialBytes: Buffer): number;
172
174
  export function BackupAuthCredential_PresentDeterministic(credentialBytes: Buffer, serverParamsBytes: Buffer, randomness: Buffer): Buffer;
175
+ export function BackupKey_DeriveBackupId(backupKey: Buffer, aci: Buffer): Buffer;
176
+ export function BackupKey_DeriveEcKey(backupKey: Buffer, aci: Buffer): PrivateKey;
177
+ export function BackupKey_DeriveLocalBackupMetadataKey(backupKey: Buffer): Buffer;
178
+ export function BackupKey_DeriveMediaEncryptionKey(backupKey: Buffer, mediaId: Buffer): Buffer;
179
+ export function BackupKey_DeriveMediaId(backupKey: Buffer, mediaName: string): Buffer;
180
+ export function BackupKey_DeriveThumbnailTransitEncryptionKey(backupKey: Buffer, mediaId: Buffer): Buffer;
173
181
  export function CallLinkAuthCredentialPresentation_CheckValidContents(presentationBytes: Buffer): void;
174
182
  export function CallLinkAuthCredentialPresentation_GetUserId(presentationBytes: Buffer): Serialized<UuidCiphertext>;
175
183
  export function CallLinkAuthCredentialPresentation_Verify(presentationBytes: Buffer, now: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer): void;
@@ -314,6 +322,8 @@ export function LookupRequest_setToken(request: Wrapper<LookupRequest>, token: B
314
322
  export function MessageBackupKey_FromAccountEntropyPool(accountEntropy: string, aci: Buffer): MessageBackupKey;
315
323
  export function MessageBackupKey_FromBackupKeyAndBackupId(backupKey: Buffer, backupId: Buffer): MessageBackupKey;
316
324
  export function MessageBackupKey_FromMasterKey(masterKey: Buffer, aci: Buffer): MessageBackupKey;
325
+ export function MessageBackupKey_GetAesKey(key: Wrapper<MessageBackupKey>): Buffer;
326
+ export function MessageBackupKey_GetHmacKey(key: Wrapper<MessageBackupKey>): Buffer;
317
327
  export function MessageBackupValidator_Validate(key: Wrapper<MessageBackupKey>, firstStream: InputStream, secondStream: InputStream, len: bigint, purpose: number): Promise<MessageBackupValidationOutcome>;
318
328
  export function MinidumpToJSONString(buffer: Buffer): string;
319
329
  export function Mp4Sanitizer_Sanitize(input: InputStream, len: bigint): Promise<SanitizedMetadata>;
@@ -1,3 +1,7 @@
1
+ /// <reference types="node" />
2
+ import ByteArray from './zkgroup/internal/ByteArray';
3
+ import { Aci } from './Address';
4
+ import { PrivateKey } from './EcKeys';
1
5
  /**
2
6
  * The randomly-generated user-memorized entropy used to derive the backup key,
3
7
  * with other possible future uses.
@@ -6,10 +10,87 @@
6
10
  */
7
11
  export declare class AccountEntropyPool {
8
12
  /**
9
- * Randomly generates an Account Entropy Pool and returns the cannonical string
13
+ * Randomly generates an Account Entropy Pool and returns the canonical string
10
14
  * representation of that pool.
11
15
  *
12
16
  * @returns cryptographically random 64 character string of characters a-z, 0-9
13
17
  */
14
18
  static generate(): string;
19
+ /**
20
+ * Derives an SVR key from the given account entropy pool.
21
+ *
22
+ * `accountEntropyPool` must be a **validated** account entropy pool;
23
+ * passing an arbitrary string here is considered a programmer error.
24
+ */
25
+ static deriveSvrKey(accountEntropyPool: string): Buffer;
26
+ /**
27
+ * Derives a backup key from the given account entropy pool.
28
+ *
29
+ * `accountEntropyPool` must be a **validated** account entropy pool;
30
+ * passing an arbitrary string here is considered a programmer error.
31
+ *
32
+ * @see {@link BackupKey.generateRandom}
33
+ */
34
+ static deriveBackupKey(accountEntropyPool: string): BackupKey;
35
+ }
36
+ /**
37
+ * A key used for many aspects of backups.
38
+ *
39
+ * Clients are typically concerned with two long-lived keys: a "messages" key (sometimes called "the
40
+ * root backup key" or just "the backup key") that's derived from an {@link AccountEntropyPool}, and
41
+ * a "media" key (formally the "media root backup key") that's not derived from anything else.
42
+ */
43
+ export declare class BackupKey extends ByteArray {
44
+ private readonly __type?;
45
+ static SIZE: number;
46
+ constructor(contents: Buffer);
47
+ /**
48
+ * Generates a random backup key.
49
+ *
50
+ * Useful for tests and for the media root backup key, which is not derived from anything else.
51
+ *
52
+ * @see {@link AccountEntropyPool.deriveBackupKey}
53
+ */
54
+ static generateRandom(): BackupKey;
55
+ /**
56
+ * Derives the backup ID to use given the current device's ACI.
57
+ *
58
+ * Used for both message and media backups.
59
+ */
60
+ deriveBackupId(aci: Aci): Buffer;
61
+ /**
62
+ * Derives the backup EC key to use given the current device's ACI.
63
+ *
64
+ * Used for both message and media backups.
65
+ */
66
+ deriveEcKey(aci: Aci): PrivateKey;
67
+ /**
68
+ * Derives the AES key used for encrypted fields in local backup metadata.
69
+ *
70
+ * Only relevant for message backup keys.
71
+ */
72
+ deriveLocalBackupMetadataKey(): Buffer;
73
+ /**
74
+ * Derives the ID for uploading media with the name `mediaName`.
75
+ *
76
+ * Only relevant for media backup keys.
77
+ */
78
+ deriveMediaId(mediaName: string): Buffer;
79
+ /**
80
+ * Derives the composite encryption key for re-encrypting media with the given ID.
81
+ *
82
+ * This is a concatenation of an HMAC key (32 bytes) and an AES-CBC key (also 32 bytes).
83
+ *
84
+ * Only relevant for media backup keys.
85
+ */
86
+ deriveMediaEncryptionKey(mediaId: Buffer): Buffer;
87
+ /**
88
+ * Derives the composite encryption key for uploading thumbnails with the given ID to the "transit
89
+ * tier" CDN.
90
+ *
91
+ * This is a concatenation of an HMAC key (32 bytes) and an AES-CBC key (also 32 bytes).
92
+ *
93
+ * Only relevant for media backup keys.
94
+ */
95
+ deriveThumbnailTransitEncryptionKey(mediaId: Buffer): Buffer;
15
96
  }
@@ -4,7 +4,7 @@
4
4
  // SPDX-License-Identifier: AGPL-3.0-only
5
5
  //
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.AccountEntropyPool = void 0;
7
+ exports.BackupKey = exports.AccountEntropyPool = void 0;
8
8
  /**
9
9
  * Cryptographic hashing, randomness generation, etc. related to SVR/Backup Keys.
10
10
  *
@@ -12,7 +12,10 @@ exports.AccountEntropyPool = void 0;
12
12
  *
13
13
  * @module AccountKeys
14
14
  */
15
+ const crypto = require("node:crypto");
15
16
  const Native = require("../Native");
17
+ const ByteArray_1 = require("./zkgroup/internal/ByteArray");
18
+ const EcKeys_1 = require("./EcKeys");
16
19
  /**
17
20
  * The randomly-generated user-memorized entropy used to derive the backup key,
18
21
  * with other possible future uses.
@@ -21,7 +24,7 @@ const Native = require("../Native");
21
24
  */
22
25
  class AccountEntropyPool {
23
26
  /**
24
- * Randomly generates an Account Entropy Pool and returns the cannonical string
27
+ * Randomly generates an Account Entropy Pool and returns the canonical string
25
28
  * representation of that pool.
26
29
  *
27
30
  * @returns cryptographically random 64 character string of characters a-z, 0-9
@@ -29,6 +32,104 @@ class AccountEntropyPool {
29
32
  static generate() {
30
33
  return Native.AccountEntropyPool_Generate();
31
34
  }
35
+ /**
36
+ * Derives an SVR key from the given account entropy pool.
37
+ *
38
+ * `accountEntropyPool` must be a **validated** account entropy pool;
39
+ * passing an arbitrary string here is considered a programmer error.
40
+ */
41
+ static deriveSvrKey(accountEntropyPool) {
42
+ return Native.AccountEntropyPool_DeriveSvrKey(accountEntropyPool);
43
+ }
44
+ /**
45
+ * Derives a backup key from the given account entropy pool.
46
+ *
47
+ * `accountEntropyPool` must be a **validated** account entropy pool;
48
+ * passing an arbitrary string here is considered a programmer error.
49
+ *
50
+ * @see {@link BackupKey.generateRandom}
51
+ */
52
+ static deriveBackupKey(accountEntropyPool) {
53
+ return new BackupKey(Native.AccountEntropyPool_DeriveBackupKey(accountEntropyPool));
54
+ }
32
55
  }
33
56
  exports.AccountEntropyPool = AccountEntropyPool;
57
+ /**
58
+ * A key used for many aspects of backups.
59
+ *
60
+ * Clients are typically concerned with two long-lived keys: a "messages" key (sometimes called "the
61
+ * root backup key" or just "the backup key") that's derived from an {@link AccountEntropyPool}, and
62
+ * a "media" key (formally the "media root backup key") that's not derived from anything else.
63
+ */
64
+ class BackupKey extends ByteArray_1.default {
65
+ constructor(contents) {
66
+ super(contents, BackupKey.checkLength(BackupKey.SIZE));
67
+ }
68
+ /**
69
+ * Generates a random backup key.
70
+ *
71
+ * Useful for tests and for the media root backup key, which is not derived from anything else.
72
+ *
73
+ * @see {@link AccountEntropyPool.deriveBackupKey}
74
+ */
75
+ static generateRandom() {
76
+ const bytes = crypto.randomBytes(BackupKey.SIZE);
77
+ return new BackupKey(bytes);
78
+ }
79
+ /**
80
+ * Derives the backup ID to use given the current device's ACI.
81
+ *
82
+ * Used for both message and media backups.
83
+ */
84
+ deriveBackupId(aci) {
85
+ return Native.BackupKey_DeriveBackupId(this.contents, aci.getServiceIdFixedWidthBinary());
86
+ }
87
+ /**
88
+ * Derives the backup EC key to use given the current device's ACI.
89
+ *
90
+ * Used for both message and media backups.
91
+ */
92
+ deriveEcKey(aci) {
93
+ return EcKeys_1.PrivateKey._fromNativeHandle(Native.BackupKey_DeriveEcKey(this.contents, aci.getServiceIdFixedWidthBinary()));
94
+ }
95
+ /**
96
+ * Derives the AES key used for encrypted fields in local backup metadata.
97
+ *
98
+ * Only relevant for message backup keys.
99
+ */
100
+ deriveLocalBackupMetadataKey() {
101
+ return Native.BackupKey_DeriveLocalBackupMetadataKey(this.contents);
102
+ }
103
+ /**
104
+ * Derives the ID for uploading media with the name `mediaName`.
105
+ *
106
+ * Only relevant for media backup keys.
107
+ */
108
+ deriveMediaId(mediaName) {
109
+ return Native.BackupKey_DeriveMediaId(this.contents, mediaName);
110
+ }
111
+ /**
112
+ * Derives the composite encryption key for re-encrypting media with the given ID.
113
+ *
114
+ * This is a concatenation of an HMAC key (32 bytes) and an AES-CBC key (also 32 bytes).
115
+ *
116
+ * Only relevant for media backup keys.
117
+ */
118
+ deriveMediaEncryptionKey(mediaId) {
119
+ return Native.BackupKey_DeriveMediaEncryptionKey(this.contents, mediaId);
120
+ }
121
+ /**
122
+ * Derives the composite encryption key for uploading thumbnails with the given ID to the "transit
123
+ * tier" CDN.
124
+ *
125
+ * This is a concatenation of an HMAC key (32 bytes) and an AES-CBC key (also 32 bytes).
126
+ *
127
+ * Only relevant for media backup keys.
128
+ */
129
+ deriveThumbnailTransitEncryptionKey(mediaId) {
130
+ return Native.BackupKey_DeriveThumbnailTransitEncryptionKey(this.contents, mediaId);
131
+ }
132
+ }
133
+ exports.BackupKey = BackupKey;
134
+ BackupKey.SIZE = 32;
34
135
  //# sourceMappingURL=AccountKeys.js.map
@@ -0,0 +1,33 @@
1
+ /// <reference types="node" />
2
+ import * as Native from '../Native';
3
+ export declare class PublicKey {
4
+ readonly _nativeHandle: Native.PublicKey;
5
+ private constructor();
6
+ static _fromNativeHandle(handle: Native.PublicKey): PublicKey;
7
+ static deserialize(buf: Buffer): PublicKey;
8
+ compare(other: PublicKey): number;
9
+ serialize(): Buffer;
10
+ getPublicKeyBytes(): Buffer;
11
+ verify(msg: Buffer, sig: Buffer): boolean;
12
+ verifyAlternateIdentity(other: PublicKey, signature: Buffer): boolean;
13
+ }
14
+ export declare class PrivateKey {
15
+ readonly _nativeHandle: Native.PrivateKey;
16
+ private constructor();
17
+ static _fromNativeHandle(handle: Native.PrivateKey): PrivateKey;
18
+ static generate(): PrivateKey;
19
+ static deserialize(buf: Buffer): PrivateKey;
20
+ serialize(): Buffer;
21
+ sign(msg: Buffer): Buffer;
22
+ agree(other_key: PublicKey): Buffer;
23
+ getPublicKey(): PublicKey;
24
+ }
25
+ export declare class IdentityKeyPair {
26
+ readonly publicKey: PublicKey;
27
+ readonly privateKey: PrivateKey;
28
+ constructor(publicKey: PublicKey, privateKey: PrivateKey);
29
+ static generate(): IdentityKeyPair;
30
+ static deserialize(buffer: Buffer): IdentityKeyPair;
31
+ serialize(): Buffer;
32
+ signAlternateIdentity(other: PublicKey): Buffer;
33
+ }
package/dist/EcKeys.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2020-2022 Signal Messenger, LLC.
4
+ // SPDX-License-Identifier: AGPL-3.0-only
5
+ //
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.IdentityKeyPair = exports.PrivateKey = exports.PublicKey = void 0;
8
+ const Native = require("../Native");
9
+ class PublicKey {
10
+ constructor(handle) {
11
+ this._nativeHandle = handle;
12
+ }
13
+ static _fromNativeHandle(handle) {
14
+ return new PublicKey(handle);
15
+ }
16
+ static deserialize(buf) {
17
+ return new PublicKey(Native.PublicKey_Deserialize(buf));
18
+ }
19
+ /// Returns -1, 0, or 1
20
+ compare(other) {
21
+ return Native.PublicKey_Compare(this, other);
22
+ }
23
+ serialize() {
24
+ return Native.PublicKey_Serialize(this);
25
+ }
26
+ getPublicKeyBytes() {
27
+ return Native.PublicKey_GetPublicKeyBytes(this);
28
+ }
29
+ verify(msg, sig) {
30
+ return Native.PublicKey_Verify(this, msg, sig);
31
+ }
32
+ verifyAlternateIdentity(other, signature) {
33
+ return Native.IdentityKey_VerifyAlternateIdentity(this, other, signature);
34
+ }
35
+ }
36
+ exports.PublicKey = PublicKey;
37
+ class PrivateKey {
38
+ constructor(handle) {
39
+ this._nativeHandle = handle;
40
+ }
41
+ static _fromNativeHandle(handle) {
42
+ return new PrivateKey(handle);
43
+ }
44
+ static generate() {
45
+ return new PrivateKey(Native.PrivateKey_Generate());
46
+ }
47
+ static deserialize(buf) {
48
+ return new PrivateKey(Native.PrivateKey_Deserialize(buf));
49
+ }
50
+ serialize() {
51
+ return Native.PrivateKey_Serialize(this);
52
+ }
53
+ sign(msg) {
54
+ return Native.PrivateKey_Sign(this, msg);
55
+ }
56
+ agree(other_key) {
57
+ return Native.PrivateKey_Agree(this, other_key);
58
+ }
59
+ getPublicKey() {
60
+ return PublicKey._fromNativeHandle(Native.PrivateKey_GetPublicKey(this));
61
+ }
62
+ }
63
+ exports.PrivateKey = PrivateKey;
64
+ class IdentityKeyPair {
65
+ constructor(publicKey, privateKey) {
66
+ this.publicKey = publicKey;
67
+ this.privateKey = privateKey;
68
+ }
69
+ static generate() {
70
+ const privateKey = PrivateKey.generate();
71
+ return new IdentityKeyPair(privateKey.getPublicKey(), privateKey);
72
+ }
73
+ static deserialize(buffer) {
74
+ const { privateKey, publicKey } = Native.IdentityKeyPair_Deserialize(buffer);
75
+ return new IdentityKeyPair(PublicKey._fromNativeHandle(publicKey), PrivateKey._fromNativeHandle(privateKey));
76
+ }
77
+ serialize() {
78
+ return Native.IdentityKeyPair_Serialize(this.publicKey, this.privateKey);
79
+ }
80
+ signAlternateIdentity(other) {
81
+ return Native.IdentityKeyPair_SignAlternateIdentity(this.publicKey, this.privateKey, other);
82
+ }
83
+ }
84
+ exports.IdentityKeyPair = IdentityKeyPair;
85
+ //# sourceMappingURL=EcKeys.js.map
@@ -5,6 +5,7 @@
5
5
  * @module MessageBackup
6
6
  */
7
7
  import * as Native from '../Native';
8
+ import { BackupKey } from './AccountKeys';
8
9
  import { Aci } from './Address';
9
10
  import { InputStream } from './io';
10
11
  export type InputStreamFactory = () => InputStream;
@@ -33,11 +34,13 @@ export type MessageBackupKeyInput = Readonly<{
33
34
  accountEntropy: string;
34
35
  aci: Aci;
35
36
  } | {
36
- backupKey: Buffer;
37
+ backupKey: BackupKey | Buffer;
37
38
  backupId: Buffer;
38
39
  }>;
39
40
  /**
40
41
  * Key used to encrypt and decrypt a message backup bundle.
42
+ *
43
+ * @see {@link BackupKey}
41
44
  */
42
45
  export declare class MessageBackupKey {
43
46
  readonly _nativeHandle: Native.MessageBackupKey;
@@ -60,6 +63,10 @@ export declare class MessageBackupKey {
60
63
  * a programmer error. Similarly, passing a backup key or ID of the wrong length is also an error.
61
64
  */
62
65
  constructor(input: MessageBackupKeyInput);
66
+ /** An HMAC key used to sign a backup file. */
67
+ get hmacKey(): Buffer;
68
+ /** An AES-256-CBC key used to encrypt a backup file. */
69
+ get aesKey(): Buffer;
63
70
  }
64
71
  export declare enum Purpose {
65
72
  DeviceTransfer = 0,
@@ -11,6 +11,7 @@ exports.ComparableBackup = exports.validate = exports.Purpose = exports.MessageB
11
11
  * @module MessageBackup
12
12
  */
13
13
  const Native = require("../Native");
14
+ const AccountKeys_1 = require("./AccountKeys");
14
15
  /**
15
16
  * Result of validating a message backup bundle.
16
17
  */
@@ -32,6 +33,8 @@ class ValidationOutcome {
32
33
  exports.ValidationOutcome = ValidationOutcome;
33
34
  /**
34
35
  * Key used to encrypt and decrypt a message backup bundle.
36
+ *
37
+ * @see {@link BackupKey}
35
38
  */
36
39
  class MessageBackupKey {
37
40
  constructor(inputOrMasterKeyBytes, maybeAci) {
@@ -45,10 +48,22 @@ class MessageBackupKey {
45
48
  this._nativeHandle = Native.MessageBackupKey_FromAccountEntropyPool(accountEntropy, aci.getServiceIdFixedWidthBinary());
46
49
  }
47
50
  else {
48
- const { backupKey, backupId } = inputOrMasterKeyBytes;
51
+ const { backupId } = inputOrMasterKeyBytes;
52
+ let { backupKey } = inputOrMasterKeyBytes;
53
+ if (backupKey instanceof AccountKeys_1.BackupKey) {
54
+ backupKey = backupKey.contents;
55
+ }
49
56
  this._nativeHandle = Native.MessageBackupKey_FromBackupKeyAndBackupId(backupKey, backupId);
50
57
  }
51
58
  }
59
+ /** An HMAC key used to sign a backup file. */
60
+ get hmacKey() {
61
+ return Native.MessageBackupKey_GetHmacKey(this);
62
+ }
63
+ /** An AES-256-CBC key used to encrypt a backup file. */
64
+ get aesKey() {
65
+ return Native.MessageBackupKey_GetAesKey(this);
66
+ }
52
67
  }
53
68
  exports.MessageBackupKey = MessageBackupKey;
54
69
  // This must match the Rust version of the enum.
@@ -669,7 +669,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
669
669
 
670
670
  ```
671
671
 
672
- ## libsignal-account-keys 0.1.0, attest 0.1.0, libsignal-ffi 0.60.0, libsignal-jni 0.60.0, libsignal-jni-testing 0.60.0, libsignal-node 0.60.0, signal-neon-futures 0.1.0, signal-neon-futures-tests 0.1.0, libsignal-bridge 0.1.0, libsignal-bridge-macros 0.1.0, libsignal-bridge-testing 0.1.0, libsignal-bridge-types 0.1.0, libsignal-core 0.1.0, signal-crypto 0.1.0, device-transfer 0.1.0, libsignal-keytrans 0.0.1, signal-media 0.1.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, libsignal-net-infra 0.1.0, poksho 0.7.0, libsignal-protocol 0.1.0, libsignal-svr3 0.1.0, usernames 0.1.0, zkcredential 0.1.0, zkgroup 0.9.0
672
+ ## libsignal-account-keys 0.1.0, attest 0.1.0, libsignal-ffi 0.60.2, libsignal-jni 0.60.2, libsignal-jni-testing 0.60.2, libsignal-node 0.60.2, signal-neon-futures 0.1.0, signal-neon-futures-tests 0.1.0, libsignal-bridge 0.1.0, libsignal-bridge-macros 0.1.0, libsignal-bridge-testing 0.1.0, libsignal-bridge-types 0.1.0, libsignal-core 0.1.0, signal-crypto 0.1.0, device-transfer 0.1.0, libsignal-keytrans 0.0.1, signal-media 0.1.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, libsignal-net-infra 0.1.0, poksho 0.7.0, libsignal-protocol 0.1.0, libsignal-svr3 0.1.0, usernames 0.1.0, zkcredential 0.1.0, zkgroup 0.9.0
673
673
 
674
674
  ```
675
675
  GNU AFFERO GENERAL PUBLIC LICENSE
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  export * from './Errors';
3
3
  import { Aci, ProtocolAddress, ServiceId } from './Address';
4
4
  export * from './Address';
5
+ import { PrivateKey, PublicKey } from './EcKeys';
6
+ export * from './EcKeys';
5
7
  export * as usernames from './usernames';
6
8
  export * as io from './io';
7
9
  export * as Net from './net';
@@ -59,28 +61,6 @@ export declare class Aes256GcmSiv {
59
61
  encrypt(message: Buffer, nonce: Buffer, associated_data: Buffer): Buffer;
60
62
  decrypt(message: Buffer, nonce: Buffer, associated_data: Buffer): Buffer;
61
63
  }
62
- export declare class PublicKey {
63
- readonly _nativeHandle: Native.PublicKey;
64
- private constructor();
65
- static _fromNativeHandle(handle: Native.PublicKey): PublicKey;
66
- static deserialize(buf: Buffer): PublicKey;
67
- compare(other: PublicKey): number;
68
- serialize(): Buffer;
69
- getPublicKeyBytes(): Buffer;
70
- verify(msg: Buffer, sig: Buffer): boolean;
71
- verifyAlternateIdentity(other: PublicKey, signature: Buffer): boolean;
72
- }
73
- export declare class PrivateKey {
74
- readonly _nativeHandle: Native.PrivateKey;
75
- private constructor();
76
- static _fromNativeHandle(handle: Native.PrivateKey): PrivateKey;
77
- static generate(): PrivateKey;
78
- static deserialize(buf: Buffer): PrivateKey;
79
- serialize(): Buffer;
80
- sign(msg: Buffer): Buffer;
81
- agree(other_key: PublicKey): Buffer;
82
- getPublicKey(): PublicKey;
83
- }
84
64
  export declare class KEMPublicKey {
85
65
  readonly _nativeHandle: Native.KyberPublicKey;
86
66
  private constructor();
@@ -103,15 +83,6 @@ export declare class KEMKeyPair {
103
83
  getPublicKey(): KEMPublicKey;
104
84
  getSecretKey(): KEMSecretKey;
105
85
  }
106
- export declare class IdentityKeyPair {
107
- readonly publicKey: PublicKey;
108
- readonly privateKey: PrivateKey;
109
- constructor(publicKey: PublicKey, privateKey: PrivateKey);
110
- static generate(): IdentityKeyPair;
111
- static deserialize(buffer: Buffer): IdentityKeyPair;
112
- serialize(): Buffer;
113
- signAlternateIdentity(other: PublicKey): Buffer;
114
- }
115
86
  export declare class PreKeyBundle {
116
87
  readonly _nativeHandle: Native.PreKeyBundle;
117
88
  private constructor();
package/dist/index.js CHANGED
@@ -18,13 +18,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.signalDecryptPreKey = exports.signalDecrypt = exports.signalEncrypt = exports.processPreKeyBundle = exports.DecryptionErrorMessage = exports.PlaintextContent = exports.CiphertextMessage = exports.SealedSenderDecryptionResult = exports.groupDecrypt = exports.groupEncrypt = exports.SenderKeyStore = exports.KyberPreKeyStore = exports.SignedPreKeyStore = exports.PreKeyStore = exports.IdentityKeyStore = exports.SessionStore = exports.UnidentifiedSenderMessageContent = exports.SenderKeyMessage = exports.processSenderKeyDistributionMessage = exports.SenderKeyDistributionMessage = exports.SenderCertificate = exports.SenderKeyRecord = exports.ServerCertificate = exports.SessionRecord = exports.PreKeySignalMessage = exports.SignalMessage = exports.KyberPreKeyRecord = exports.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.IdentityKeyPair = exports.KEMKeyPair = exports.KEMSecretKey = exports.KEMPublicKey = exports.PrivateKey = exports.PublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.HKDF = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.WebpSanitizer = exports.Mp4Sanitizer = exports.Net = exports.io = exports.usernames = void 0;
22
- exports.initLogger = exports.LogLevel = exports.HsmEnclaveClient = exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = exports.sealedSenderMultiRecipientMessageForSingleRecipient = exports.sealedSenderMultiRecipientEncrypt = exports.sealedSenderEncrypt = exports.sealedSenderEncryptMessage = void 0;
21
+ exports.sealedSenderMultiRecipientEncrypt = exports.sealedSenderEncrypt = exports.sealedSenderEncryptMessage = exports.signalDecryptPreKey = exports.signalDecrypt = exports.signalEncrypt = exports.processPreKeyBundle = exports.DecryptionErrorMessage = exports.PlaintextContent = exports.CiphertextMessage = exports.SealedSenderDecryptionResult = exports.groupDecrypt = exports.groupEncrypt = exports.SenderKeyStore = exports.KyberPreKeyStore = exports.SignedPreKeyStore = exports.PreKeyStore = exports.IdentityKeyStore = exports.SessionStore = exports.UnidentifiedSenderMessageContent = exports.SenderKeyMessage = exports.processSenderKeyDistributionMessage = exports.SenderKeyDistributionMessage = exports.SenderCertificate = exports.SenderKeyRecord = exports.ServerCertificate = exports.SessionRecord = exports.PreKeySignalMessage = exports.SignalMessage = exports.KyberPreKeyRecord = exports.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.KEMKeyPair = exports.KEMSecretKey = exports.KEMPublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.HKDF = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.WebpSanitizer = exports.Mp4Sanitizer = exports.Net = exports.io = exports.usernames = void 0;
22
+ exports.initLogger = exports.LogLevel = exports.HsmEnclaveClient = exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = exports.sealedSenderMultiRecipientMessageForSingleRecipient = void 0;
23
23
  const uuid = require("uuid");
24
24
  const Errors = require("./Errors");
25
25
  __exportStar(require("./Errors"), exports);
26
26
  const Address_1 = require("./Address");
27
27
  __exportStar(require("./Address"), exports);
28
+ const EcKeys_1 = require("./EcKeys");
29
+ __exportStar(require("./EcKeys"), exports);
28
30
  exports.usernames = require("./usernames");
29
31
  exports.io = require("./io");
30
32
  exports.Net = require("./net");
@@ -128,61 +130,6 @@ class Aes256GcmSiv {
128
130
  }
129
131
  }
130
132
  exports.Aes256GcmSiv = Aes256GcmSiv;
131
- class PublicKey {
132
- constructor(handle) {
133
- this._nativeHandle = handle;
134
- }
135
- static _fromNativeHandle(handle) {
136
- return new PublicKey(handle);
137
- }
138
- static deserialize(buf) {
139
- return new PublicKey(Native.PublicKey_Deserialize(buf));
140
- }
141
- /// Returns -1, 0, or 1
142
- compare(other) {
143
- return Native.PublicKey_Compare(this, other);
144
- }
145
- serialize() {
146
- return Native.PublicKey_Serialize(this);
147
- }
148
- getPublicKeyBytes() {
149
- return Native.PublicKey_GetPublicKeyBytes(this);
150
- }
151
- verify(msg, sig) {
152
- return Native.PublicKey_Verify(this, msg, sig);
153
- }
154
- verifyAlternateIdentity(other, signature) {
155
- return Native.IdentityKey_VerifyAlternateIdentity(this, other, signature);
156
- }
157
- }
158
- exports.PublicKey = PublicKey;
159
- class PrivateKey {
160
- constructor(handle) {
161
- this._nativeHandle = handle;
162
- }
163
- static _fromNativeHandle(handle) {
164
- return new PrivateKey(handle);
165
- }
166
- static generate() {
167
- return new PrivateKey(Native.PrivateKey_Generate());
168
- }
169
- static deserialize(buf) {
170
- return new PrivateKey(Native.PrivateKey_Deserialize(buf));
171
- }
172
- serialize() {
173
- return Native.PrivateKey_Serialize(this);
174
- }
175
- sign(msg) {
176
- return Native.PrivateKey_Sign(this, msg);
177
- }
178
- agree(other_key) {
179
- return Native.PrivateKey_Agree(this, other_key);
180
- }
181
- getPublicKey() {
182
- return PublicKey._fromNativeHandle(Native.PrivateKey_GetPublicKey(this));
183
- }
184
- }
185
- exports.PrivateKey = PrivateKey;
186
133
  class KEMPublicKey {
187
134
  constructor(handle) {
188
135
  this._nativeHandle = handle;
@@ -231,27 +178,6 @@ class KEMKeyPair {
231
178
  }
232
179
  }
233
180
  exports.KEMKeyPair = KEMKeyPair;
234
- class IdentityKeyPair {
235
- constructor(publicKey, privateKey) {
236
- this.publicKey = publicKey;
237
- this.privateKey = privateKey;
238
- }
239
- static generate() {
240
- const privateKey = PrivateKey.generate();
241
- return new IdentityKeyPair(privateKey.getPublicKey(), privateKey);
242
- }
243
- static deserialize(buffer) {
244
- const { privateKey, publicKey } = Native.IdentityKeyPair_Deserialize(buffer);
245
- return new IdentityKeyPair(PublicKey._fromNativeHandle(publicKey), PrivateKey._fromNativeHandle(privateKey));
246
- }
247
- serialize() {
248
- return Native.IdentityKeyPair_Serialize(this.publicKey, this.privateKey);
249
- }
250
- signAlternateIdentity(other) {
251
- return Native.IdentityKeyPair_SignAlternateIdentity(this.publicKey, this.privateKey, other);
252
- }
253
- }
254
- exports.IdentityKeyPair = IdentityKeyPair;
255
181
  class PreKeyBundle {
256
182
  constructor(handle) {
257
183
  this._nativeHandle = handle;
@@ -265,7 +191,7 @@ class PreKeyBundle {
265
191
  return Native.PreKeyBundle_GetDeviceId(this);
266
192
  }
267
193
  identityKey() {
268
- return PublicKey._fromNativeHandle(Native.PreKeyBundle_GetIdentityKey(this));
194
+ return EcKeys_1.PublicKey._fromNativeHandle(Native.PreKeyBundle_GetIdentityKey(this));
269
195
  }
270
196
  preKeyId() {
271
197
  return Native.PreKeyBundle_GetPreKeyId(this);
@@ -276,7 +202,7 @@ class PreKeyBundle {
276
202
  return null;
277
203
  }
278
204
  else {
279
- return PublicKey._fromNativeHandle(handle);
205
+ return EcKeys_1.PublicKey._fromNativeHandle(handle);
280
206
  }
281
207
  }
282
208
  registrationId() {
@@ -286,7 +212,7 @@ class PreKeyBundle {
286
212
  return Native.PreKeyBundle_GetSignedPreKeyId(this);
287
213
  }
288
214
  signedPreKeyPublic() {
289
- return PublicKey._fromNativeHandle(Native.PreKeyBundle_GetSignedPreKeyPublic(this));
215
+ return EcKeys_1.PublicKey._fromNativeHandle(Native.PreKeyBundle_GetSignedPreKeyPublic(this));
290
216
  }
291
217
  signedPreKeySignature() {
292
218
  return Native.PreKeyBundle_GetSignedPreKeySignature(this);
@@ -321,10 +247,10 @@ class PreKeyRecord {
321
247
  return Native.PreKeyRecord_GetId(this);
322
248
  }
323
249
  privateKey() {
324
- return PrivateKey._fromNativeHandle(Native.PreKeyRecord_GetPrivateKey(this));
250
+ return EcKeys_1.PrivateKey._fromNativeHandle(Native.PreKeyRecord_GetPrivateKey(this));
325
251
  }
326
252
  publicKey() {
327
- return PublicKey._fromNativeHandle(Native.PreKeyRecord_GetPublicKey(this));
253
+ return EcKeys_1.PublicKey._fromNativeHandle(Native.PreKeyRecord_GetPublicKey(this));
328
254
  }
329
255
  serialize() {
330
256
  return Native.PreKeyRecord_Serialize(this);
@@ -348,10 +274,10 @@ class SignedPreKeyRecord {
348
274
  return Native.SignedPreKeyRecord_GetId(this);
349
275
  }
350
276
  privateKey() {
351
- return PrivateKey._fromNativeHandle(Native.SignedPreKeyRecord_GetPrivateKey(this));
277
+ return EcKeys_1.PrivateKey._fromNativeHandle(Native.SignedPreKeyRecord_GetPrivateKey(this));
352
278
  }
353
279
  publicKey() {
354
- return PublicKey._fromNativeHandle(Native.SignedPreKeyRecord_GetPublicKey(this));
280
+ return EcKeys_1.PublicKey._fromNativeHandle(Native.SignedPreKeyRecord_GetPublicKey(this));
355
281
  }
356
282
  serialize() {
357
283
  return Native.SignedPreKeyRecord_Serialize(this);
@@ -506,7 +432,7 @@ class ServerCertificate {
506
432
  return Native.ServerCertificate_GetCertificate(this);
507
433
  }
508
434
  key() {
509
- return PublicKey._fromNativeHandle(Native.ServerCertificate_GetKey(this));
435
+ return EcKeys_1.PublicKey._fromNativeHandle(Native.ServerCertificate_GetKey(this));
510
436
  }
511
437
  keyId() {
512
438
  return Native.ServerCertificate_GetKeyId(this);
@@ -560,7 +486,7 @@ class SenderCertificate {
560
486
  return Native.SenderCertificate_GetExpiration(this);
561
487
  }
562
488
  key() {
563
- return PublicKey._fromNativeHandle(Native.SenderCertificate_GetKey(this));
489
+ return EcKeys_1.PublicKey._fromNativeHandle(Native.SenderCertificate_GetKey(this));
564
490
  }
565
491
  senderE164() {
566
492
  return Native.SenderCertificate_GetSenderE164(this);
@@ -717,11 +643,11 @@ class IdentityKeyStore {
717
643
  return this.getLocalRegistrationId();
718
644
  }
719
645
  async _saveIdentity(name, key) {
720
- return this.saveIdentity(Address_1.ProtocolAddress._fromNativeHandle(name), PublicKey._fromNativeHandle(key));
646
+ return this.saveIdentity(Address_1.ProtocolAddress._fromNativeHandle(name), EcKeys_1.PublicKey._fromNativeHandle(key));
721
647
  }
722
648
  async _isTrustedIdentity(name, key, sending) {
723
649
  const direction = sending ? Direction.Sending : Direction.Receiving;
724
- return this.isTrustedIdentity(Address_1.ProtocolAddress._fromNativeHandle(name), PublicKey._fromNativeHandle(key), direction);
650
+ return this.isTrustedIdentity(Address_1.ProtocolAddress._fromNativeHandle(name), EcKeys_1.PublicKey._fromNativeHandle(key), direction);
725
651
  }
726
652
  async _getIdentity(name) {
727
653
  const key = await this.getIdentity(Address_1.ProtocolAddress._fromNativeHandle(name));
@@ -894,7 +820,7 @@ class DecryptionErrorMessage {
894
820
  ratchetKey() {
895
821
  const keyHandle = Native.DecryptionErrorMessage_GetRatchetKey(this);
896
822
  if (keyHandle) {
897
- return PublicKey._fromNativeHandle(keyHandle);
823
+ return EcKeys_1.PublicKey._fromNativeHandle(keyHandle);
898
824
  }
899
825
  else {
900
826
  return undefined;
@@ -4,7 +4,7 @@ import BackupAuthCredentialRequest from './BackupAuthCredentialRequest';
4
4
  import BackupAuthCredentialResponse from './BackupAuthCredentialResponse';
5
5
  import BackupAuthCredential from './BackupAuthCredential';
6
6
  import GenericServerPublicParams from '../GenericServerPublicParams';
7
- import { Uuid } from '../..';
7
+ import type { Uuid } from '../..';
8
8
  export default class BackupAuthCredentialRequestContext extends ByteArray {
9
9
  private readonly __type?;
10
10
  constructor(contents: Buffer);
@@ -48,6 +48,7 @@ export { default as BackupAuthCredentialPresentation } from './backups/BackupAut
48
48
  export { default as BackupAuthCredentialRequest } from './backups/BackupAuthCredentialRequest';
49
49
  export { default as BackupAuthCredentialRequestContext } from './backups/BackupAuthCredentialRequestContext';
50
50
  export { default as BackupAuthCredentialResponse } from './backups/BackupAuthCredentialResponse';
51
+ export { default as BackupCredentialType } from './backups/BackupCredentialType';
51
52
  export { default as BackupLevel } from './backups/BackupLevel';
52
53
  export { default as GroupSendDerivedKeyPair } from './groupsend/GroupSendDerivedKeyPair';
53
54
  export { default as GroupSendEndorsement } from './groupsend/GroupSendEndorsement';
@@ -5,7 +5,7 @@
5
5
  //
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.BackupAuthCredentialResponse = exports.BackupAuthCredentialRequestContext = exports.BackupAuthCredentialRequest = exports.BackupAuthCredentialPresentation = exports.BackupAuthCredential = exports.CreateCallLinkCredentialResponse = exports.CreateCallLinkCredentialRequestContext = exports.CreateCallLinkCredentialRequest = exports.CreateCallLinkCredentialPresentation = exports.CreateCallLinkCredential = exports.CallLinkAuthCredentialResponse = exports.CallLinkAuthCredentialPresentation = exports.CallLinkAuthCredential = exports.CallLinkSecretParams = exports.CallLinkPublicParams = exports.ReceiptSerial = exports.ReceiptCredentialResponse = exports.ReceiptCredentialRequestContext = exports.ReceiptCredentialRequest = exports.ReceiptCredentialPresentation = exports.ReceiptCredential = exports.ServerZkReceiptOperations = exports.ClientZkReceiptOperations = exports.ExpiringProfileKeyCredentialResponse = exports.ExpiringProfileKeyCredential = exports.ProfileKeyVersion = exports.ProfileKeyCredentialRequestContext = exports.ProfileKeyCredentialRequest = exports.ProfileKeyCredentialPresentation = exports.ProfileKeyCommitment = exports.ProfileKey = exports.ServerZkProfileOperations = exports.ClientZkProfileOperations = exports.UuidCiphertext = exports.ProfileKeyCiphertext = exports.GroupSecretParams = exports.GroupPublicParams = exports.GroupMasterKey = exports.GroupIdentifier = exports.ClientZkGroupCipher = exports.AuthCredentialWithPniResponse = exports.AuthCredentialWithPni = exports.AuthCredentialPresentation = exports.ServerZkAuthOperations = exports.ClientZkAuthOperations = exports.NotarySignature = exports.GenericServerSecretParams = exports.GenericServerPublicParams = exports.ServerSecretParams = exports.ServerPublicParams = void 0;
8
- exports.GroupSendToken = exports.GroupSendFullToken = exports.GroupSendEndorsementsResponse = exports.GroupSendEndorsement = exports.GroupSendDerivedKeyPair = exports.BackupLevel = void 0;
8
+ exports.GroupSendToken = exports.GroupSendFullToken = exports.GroupSendEndorsementsResponse = exports.GroupSendEndorsement = exports.GroupSendDerivedKeyPair = exports.BackupLevel = exports.BackupCredentialType = void 0;
9
9
  // Root
10
10
  var ServerPublicParams_1 = require("./ServerPublicParams");
11
11
  Object.defineProperty(exports, "ServerPublicParams", { enumerable: true, get: function () { return ServerPublicParams_1.default; } });
@@ -113,6 +113,8 @@ var BackupAuthCredentialRequestContext_1 = require("./backups/BackupAuthCredenti
113
113
  Object.defineProperty(exports, "BackupAuthCredentialRequestContext", { enumerable: true, get: function () { return BackupAuthCredentialRequestContext_1.default; } });
114
114
  var BackupAuthCredentialResponse_1 = require("./backups/BackupAuthCredentialResponse");
115
115
  Object.defineProperty(exports, "BackupAuthCredentialResponse", { enumerable: true, get: function () { return BackupAuthCredentialResponse_1.default; } });
116
+ var BackupCredentialType_1 = require("./backups/BackupCredentialType");
117
+ Object.defineProperty(exports, "BackupCredentialType", { enumerable: true, get: function () { return BackupCredentialType_1.default; } });
116
118
  var BackupLevel_1 = require("./backups/BackupLevel");
117
119
  Object.defineProperty(exports, "BackupLevel", { enumerable: true, get: function () { return BackupLevel_1.default; } });
118
120
  // Group Send
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.60.0",
3
+ "version": "0.60.2",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",