@signalapp/libsignal-client 0.59.0 → 0.60.1

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.
Files changed (30) hide show
  1. package/Native.d.ts +15 -2
  2. package/dist/AccountKeys.d.ts +49 -1
  3. package/dist/AccountKeys.js +68 -2
  4. package/dist/EcKeys.d.ts +33 -0
  5. package/dist/EcKeys.js +85 -0
  6. package/dist/MessageBackup.d.ts +26 -1
  7. package/dist/MessageBackup.js +27 -7
  8. package/dist/acknowledgments.md +4 -36
  9. package/dist/index.d.ts +2 -31
  10. package/dist/index.js +16 -90
  11. package/dist/zkgroup/backups/BackupAuthCredential.d.ts +2 -0
  12. package/dist/zkgroup/backups/BackupAuthCredential.js +8 -0
  13. package/dist/zkgroup/backups/BackupAuthCredentialPresentation.d.ts +2 -0
  14. package/dist/zkgroup/backups/BackupAuthCredentialPresentation.js +8 -0
  15. package/dist/zkgroup/backups/BackupAuthCredentialRequest.d.ts +3 -2
  16. package/dist/zkgroup/backups/BackupAuthCredentialRequest.js +4 -4
  17. package/dist/zkgroup/backups/BackupAuthCredentialRequestContext.d.ts +1 -1
  18. package/dist/zkgroup/backups/BackupCredentialType.d.ts +5 -0
  19. package/dist/zkgroup/backups/BackupCredentialType.js +14 -0
  20. package/dist/zkgroup/backups/BackupLevel.d.ts +2 -2
  21. package/dist/zkgroup/backups/BackupLevel.js +2 -2
  22. package/dist/zkgroup/index.d.ts +1 -0
  23. package/dist/zkgroup/index.js +3 -1
  24. package/package.json +1 -1
  25. package/prebuilds/darwin-arm64/@signalapp+libsignal-client.node +0 -0
  26. package/prebuilds/darwin-x64/@signalapp+libsignal-client.node +0 -0
  27. package/prebuilds/linux-arm64/@signalapp+libsignal-client.node +0 -0
  28. package/prebuilds/linux-x64/@signalapp+libsignal-client.node +0 -0
  29. package/prebuilds/win32-arm64/@signalapp+libsignal-client.node +0 -0
  30. package/prebuilds/win32-x64/@signalapp+libsignal-client.node +0 -0
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;
@@ -156,18 +158,25 @@ export function AuthCredentialWithPni_CheckValidContents(bytes: Buffer): void;
156
158
  export function BackupAuthCredentialPresentation_CheckValidContents(presentationBytes: Buffer): void;
157
159
  export function BackupAuthCredentialPresentation_GetBackupId(presentationBytes: Buffer): Buffer;
158
160
  export function BackupAuthCredentialPresentation_GetBackupLevel(presentationBytes: Buffer): number;
161
+ export function BackupAuthCredentialPresentation_GetType(presentationBytes: Buffer): number;
159
162
  export function BackupAuthCredentialPresentation_Verify(presentationBytes: Buffer, now: Timestamp, serverParamsBytes: Buffer): void;
160
163
  export function BackupAuthCredentialRequestContext_CheckValidContents(contextBytes: Buffer): void;
161
164
  export function BackupAuthCredentialRequestContext_GetRequest(contextBytes: Buffer): Buffer;
162
165
  export function BackupAuthCredentialRequestContext_New(backupKey: Buffer, uuid: Uuid): Buffer;
163
166
  export function BackupAuthCredentialRequestContext_ReceiveResponse(contextBytes: Buffer, responseBytes: Buffer, expectedRedemptionTime: Timestamp, paramsBytes: Buffer): Buffer;
164
167
  export function BackupAuthCredentialRequest_CheckValidContents(requestBytes: Buffer): void;
165
- export function BackupAuthCredentialRequest_IssueDeterministic(requestBytes: Buffer, redemptionTime: Timestamp, backupLevel: number, paramsBytes: Buffer, randomness: Buffer): Buffer;
168
+ export function BackupAuthCredentialRequest_IssueDeterministic(requestBytes: Buffer, redemptionTime: Timestamp, backupLevel: number, credentialType: number, paramsBytes: Buffer, randomness: Buffer): Buffer;
166
169
  export function BackupAuthCredentialResponse_CheckValidContents(responseBytes: Buffer): void;
167
170
  export function BackupAuthCredential_CheckValidContents(paramsBytes: Buffer): void;
168
171
  export function BackupAuthCredential_GetBackupId(credentialBytes: Buffer): Buffer;
169
172
  export function BackupAuthCredential_GetBackupLevel(credentialBytes: Buffer): number;
173
+ export function BackupAuthCredential_GetType(credentialBytes: Buffer): number;
170
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;
171
180
  export function CallLinkAuthCredentialPresentation_CheckValidContents(presentationBytes: Buffer): void;
172
181
  export function CallLinkAuthCredentialPresentation_GetUserId(presentationBytes: Buffer): Serialized<UuidCiphertext>;
173
182
  export function CallLinkAuthCredentialPresentation_Verify(presentationBytes: Buffer, now: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer): void;
@@ -309,7 +318,11 @@ export function LookupRequest_addPreviousE164(request: Wrapper<LookupRequest>, e
309
318
  export function LookupRequest_new(): LookupRequest;
310
319
  export function LookupRequest_setReturnAcisWithoutUaks(request: Wrapper<LookupRequest>, returnAcisWithoutUaks: boolean): void;
311
320
  export function LookupRequest_setToken(request: Wrapper<LookupRequest>, token: Buffer): void;
312
- export function MessageBackupKey_New(masterKey: Buffer, aci: Buffer): MessageBackupKey;
321
+ export function MessageBackupKey_FromAccountEntropyPool(accountEntropy: string, aci: Buffer): MessageBackupKey;
322
+ export function MessageBackupKey_FromBackupKeyAndBackupId(backupKey: Buffer, backupId: Buffer): MessageBackupKey;
323
+ export function MessageBackupKey_FromMasterKey(masterKey: Buffer, aci: Buffer): MessageBackupKey;
324
+ export function MessageBackupKey_GetAesKey(key: Wrapper<MessageBackupKey>): Buffer;
325
+ export function MessageBackupKey_GetHmacKey(key: Wrapper<MessageBackupKey>): Buffer;
313
326
  export function MessageBackupValidator_Validate(key: Wrapper<MessageBackupKey>, firstStream: InputStream, secondStream: InputStream, len: bigint, purpose: number): Promise<MessageBackupValidationOutcome>;
314
327
  export function MinidumpToJSONString(buffer: Buffer): string;
315
328
  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,54 @@
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
+ /** A key used for many aspects of backups. */
37
+ export declare class BackupKey extends ByteArray {
38
+ private readonly __type?;
39
+ static SIZE: number;
40
+ constructor(contents: Buffer);
41
+ /**
42
+ * Generates a random backup key.
43
+ *
44
+ * Useful for tests and for the media root backup key, which is not derived from anything else.
45
+ *
46
+ * @see {@link AccountEntropyPool.deriveBackupKey}
47
+ */
48
+ static generateRandom(): BackupKey;
49
+ /** Derives the backup ID to use given the current device's ACI. */
50
+ deriveBackupId(aci: Aci): Buffer;
51
+ /** Derives the backup EC key to use given the current device's ACI. */
52
+ deriveEcKey(aci: Aci): PrivateKey;
53
+ /** Derives the AES key used for encrypted fields in local backup metadata. */
54
+ deriveLocalBackupMetadataKey(): Buffer;
55
+ /** Derives the ID for uploading media with the name `mediaName`. */
56
+ deriveMediaId(mediaName: string): Buffer;
57
+ /**
58
+ * Derives the composite encryption key for uploading media with the given ID.
59
+ *
60
+ * This is a concatenation of an HMAC key (32 bytes) and an AES-CBC key (also 32 bytes).
61
+ */
62
+ deriveMediaEncryptionKey(mediaId: Buffer): Buffer;
15
63
  }
@@ -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,69 @@ 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
+ /** A key used for many aspects of backups. */
58
+ class BackupKey extends ByteArray_1.default {
59
+ constructor(contents) {
60
+ super(contents, BackupKey.checkLength(BackupKey.SIZE));
61
+ }
62
+ /**
63
+ * Generates a random backup key.
64
+ *
65
+ * Useful for tests and for the media root backup key, which is not derived from anything else.
66
+ *
67
+ * @see {@link AccountEntropyPool.deriveBackupKey}
68
+ */
69
+ static generateRandom() {
70
+ const bytes = crypto.randomBytes(BackupKey.SIZE);
71
+ return new BackupKey(bytes);
72
+ }
73
+ /** Derives the backup ID to use given the current device's ACI. */
74
+ deriveBackupId(aci) {
75
+ return Native.BackupKey_DeriveBackupId(this.contents, aci.getServiceIdFixedWidthBinary());
76
+ }
77
+ /** Derives the backup EC key to use given the current device's ACI. */
78
+ deriveEcKey(aci) {
79
+ return EcKeys_1.PrivateKey._fromNativeHandle(Native.BackupKey_DeriveEcKey(this.contents, aci.getServiceIdFixedWidthBinary()));
80
+ }
81
+ /** Derives the AES key used for encrypted fields in local backup metadata. */
82
+ deriveLocalBackupMetadataKey() {
83
+ return Native.BackupKey_DeriveLocalBackupMetadataKey(this.contents);
84
+ }
85
+ /** Derives the ID for uploading media with the name `mediaName`. */
86
+ deriveMediaId(mediaName) {
87
+ return Native.BackupKey_DeriveMediaId(this.contents, mediaName);
88
+ }
89
+ /**
90
+ * Derives the composite encryption key for uploading media with the given ID.
91
+ *
92
+ * This is a concatenation of an HMAC key (32 bytes) and an AES-CBC key (also 32 bytes).
93
+ */
94
+ deriveMediaEncryptionKey(mediaId) {
95
+ return Native.BackupKey_DeriveMediaEncryptionKey(this.contents, mediaId);
96
+ }
97
+ }
98
+ exports.BackupKey = BackupKey;
99
+ BackupKey.SIZE = 32;
34
100
  //# 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;
@@ -29,17 +30,41 @@ export declare class ValidationOutcome {
29
30
  get ok(): boolean;
30
31
  constructor(outcome: Native.MessageBackupValidationOutcome);
31
32
  }
33
+ export type MessageBackupKeyInput = Readonly<{
34
+ accountEntropy: string;
35
+ aci: Aci;
36
+ } | {
37
+ backupKey: BackupKey | Buffer;
38
+ backupId: Buffer;
39
+ }>;
32
40
  /**
33
41
  * Key used to encrypt and decrypt a message backup bundle.
34
42
  */
35
43
  export declare class MessageBackupKey {
36
44
  readonly _nativeHandle: Native.MessageBackupKey;
37
45
  /**
38
- * Create a public key from the given master key and ACI.
46
+ * Create a backup bundle key from the given master key and ACI.
39
47
  *
40
48
  * `masterKeyBytes` should contain exactly 32 bytes.
49
+ *
50
+ * @deprecated Use AccountEntropyPool instead.
41
51
  */
42
52
  constructor(masterKeyBytes: Buffer, aci: Aci);
53
+ /**
54
+ * Create a backup bundle key from an account entropy pool and ACI.
55
+ *
56
+ * ...or from a backup key and ID, used when reading from a local backup, which may have been
57
+ * created with a different ACI. This still uses AccountEntropyPool-based key derivation rules; it
58
+ * cannot be used to read a backup created from a master key.
59
+ *
60
+ * The account entropy pool must be **validated**; passing an arbitrary string here is considered
61
+ * a programmer error. Similarly, passing a backup key or ID of the wrong length is also an error.
62
+ */
63
+ constructor(input: MessageBackupKeyInput);
64
+ /** An HMAC key used to sign a backup file. */
65
+ get hmacKey(): Buffer;
66
+ /** An AES-256-CBC key used to encrypt a backup file. */
67
+ get aesKey(): Buffer;
43
68
  }
44
69
  export declare enum Purpose {
45
70
  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
  */
@@ -34,13 +35,32 @@ exports.ValidationOutcome = ValidationOutcome;
34
35
  * Key used to encrypt and decrypt a message backup bundle.
35
36
  */
36
37
  class MessageBackupKey {
37
- /**
38
- * Create a public key from the given master key and ACI.
39
- *
40
- * `masterKeyBytes` should contain exactly 32 bytes.
41
- */
42
- constructor(masterKeyBytes, aci) {
43
- this._nativeHandle = Native.MessageBackupKey_New(masterKeyBytes, aci.getServiceIdFixedWidthBinary());
38
+ constructor(inputOrMasterKeyBytes, maybeAci) {
39
+ if (inputOrMasterKeyBytes instanceof Buffer) {
40
+ if (maybeAci === undefined)
41
+ throw new Error('missing ACI parameter');
42
+ this._nativeHandle = Native.MessageBackupKey_FromMasterKey(inputOrMasterKeyBytes, maybeAci.getServiceIdFixedWidthBinary());
43
+ }
44
+ else if ('accountEntropy' in inputOrMasterKeyBytes) {
45
+ const { accountEntropy, aci } = inputOrMasterKeyBytes;
46
+ this._nativeHandle = Native.MessageBackupKey_FromAccountEntropyPool(accountEntropy, aci.getServiceIdFixedWidthBinary());
47
+ }
48
+ else {
49
+ const { backupId } = inputOrMasterKeyBytes;
50
+ let { backupKey } = inputOrMasterKeyBytes;
51
+ if (backupKey instanceof AccountKeys_1.BackupKey) {
52
+ backupKey = backupKey.contents;
53
+ }
54
+ this._nativeHandle = Native.MessageBackupKey_FromBackupKeyAndBackupId(backupKey, backupId);
55
+ }
56
+ }
57
+ /** An HMAC key used to sign a backup file. */
58
+ get hmacKey() {
59
+ return Native.MessageBackupKey_GetHmacKey(this);
60
+ }
61
+ /** An AES-256-CBC key used to encrypt a backup file. */
62
+ get aesKey() {
63
+ return Native.MessageBackupKey_GetAesKey(this);
44
64
  }
45
65
  }
46
66
  exports.MessageBackupKey = MessageBackupKey;
@@ -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.59.0, libsignal-jni 0.59.0, libsignal-jni-testing 0.59.0, libsignal-node 0.59.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.1, libsignal-jni 0.60.1, libsignal-jni-testing 0.60.1, libsignal-node 0.60.1, 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
@@ -2171,7 +2171,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2171
2171
 
2172
2172
  ```
2173
2173
 
2174
- ## bindgen 0.68.1
2174
+ ## bindgen 0.70.1
2175
2175
 
2176
2176
  ```
2177
2177
  BSD 3-Clause License
@@ -3300,7 +3300,7 @@ THE SOFTWARE.
3300
3300
 
3301
3301
  ```
3302
3302
 
3303
- ## either 1.13.0, itertools 0.13.0, petgraph 0.6.5
3303
+ ## either 1.13.0, itertools 0.10.5, itertools 0.13.0, petgraph 0.6.5
3304
3304
 
3305
3305
  ```
3306
3306
  Copyright (c) 2015
@@ -3443,7 +3443,7 @@ DEALINGS IN THE SOFTWARE.
3443
3443
 
3444
3444
  ```
3445
3445
 
3446
- ## gimli 0.31.0, heck 0.5.0, peeking_take_while 0.1.2, unicode-bidi 0.3.15, unicode-normalization 0.1.23
3446
+ ## gimli 0.31.0, heck 0.5.0, unicode-bidi 0.3.15, unicode-normalization 0.1.23
3447
3447
 
3448
3448
  ```
3449
3449
  Copyright (c) 2015 The Rust Project Developers
@@ -6845,38 +6845,6 @@ SOFTWARE.
6845
6845
 
6846
6846
  ```
6847
6847
 
6848
- ## lazycell 1.3.0
6849
-
6850
- ```
6851
- Original work Copyright (c) 2014 The Rust Project Developers
6852
- Modified work Copyright (c) 2016-2018 Nikita Pekin and lazycell contributors
6853
-
6854
- Permission is hereby granted, free of charge, to any
6855
- person obtaining a copy of this software and associated
6856
- documentation files (the "Software"), to deal in the
6857
- Software without restriction, including without
6858
- limitation the rights to use, copy, modify, merge,
6859
- publish, distribute, sublicense, and/or sell copies of
6860
- the Software, and to permit persons to whom the Software
6861
- is furnished to do so, subject to the following
6862
- conditions:
6863
-
6864
- The above copyright notice and this permission notice
6865
- shall be included in all copies or substantial portions
6866
- of the Software.
6867
-
6868
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
6869
- ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
6870
- TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
6871
- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
6872
- SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
6873
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
6874
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
6875
- IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
6876
- DEALINGS IN THE SOFTWARE.
6877
-
6878
- ```
6879
-
6880
6848
  ## curve25519-dalek-derive 0.1.1, adler2 2.0.0, anyhow 1.0.88, async-trait 0.1.82, atomic-waker 1.1.2, displaydoc 0.2.5, dyn-clone 1.0.17, fastrand 2.1.1, home 0.5.9, itoa 1.0.11, linkme-impl 0.3.28, linkme 0.3.28, linux-raw-sys 0.4.14, minimal-lexical 0.2.1, num_enum 0.7.3, num_enum_derive 0.7.3, once_cell 1.19.0, paste 1.0.15, pin-project-internal 1.1.5, pin-project-lite 0.2.14, pin-project 1.1.5, prettyplease 0.2.22, proc-macro-crate 3.2.0, proc-macro2 1.0.86, quote 1.0.37, rustc-hash 1.1.0, rustix 0.38.37, rustversion 1.0.17, semver 1.0.23, send_wrapper 0.6.0, serde 1.0.210, serde_derive 1.0.210, serde_json 1.0.128, syn-mid 0.6.0, syn 1.0.109, syn 2.0.77, thiserror-impl 1.0.63, thiserror 1.0.63, unicode-ident 1.0.13, utf-8 0.7.6
6881
6849
 
6882
6850
  ```
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;
@@ -3,6 +3,7 @@ import ByteArray from '../internal/ByteArray';
3
3
  import GenericServerPublicParams from '../GenericServerPublicParams';
4
4
  import BackupAuthCredentialPresentation from './BackupAuthCredentialPresentation';
5
5
  import BackupLevel from './BackupLevel';
6
+ import BackupCredentialType from './BackupCredentialType';
6
7
  export default class BackupAuthCredential extends ByteArray {
7
8
  private readonly __type?;
8
9
  constructor(contents: Buffer);
@@ -10,4 +11,5 @@ export default class BackupAuthCredential extends ByteArray {
10
11
  presentWithRandom(serverParams: GenericServerPublicParams, random: Buffer): BackupAuthCredentialPresentation;
11
12
  getBackupId(): Buffer;
12
13
  getBackupLevel(): BackupLevel;
14
+ getType(): BackupCredentialType;
13
15
  }
@@ -10,6 +10,7 @@ const ByteArray_1 = require("../internal/ByteArray");
10
10
  const Constants_1 = require("../internal/Constants");
11
11
  const BackupAuthCredentialPresentation_1 = require("./BackupAuthCredentialPresentation");
12
12
  const BackupLevel_1 = require("./BackupLevel");
13
+ const BackupCredentialType_1 = require("./BackupCredentialType");
13
14
  class BackupAuthCredential extends ByteArray_1.default {
14
15
  constructor(contents) {
15
16
  super(contents, Native.BackupAuthCredential_CheckValidContents);
@@ -31,6 +32,13 @@ class BackupAuthCredential extends ByteArray_1.default {
31
32
  }
32
33
  return n;
33
34
  }
35
+ getType() {
36
+ const n = Native.BackupAuthCredential_GetType(this.contents);
37
+ if (!(n in BackupCredentialType_1.default)) {
38
+ throw new TypeError(`Invalid BackupCredentialType ${n}`);
39
+ }
40
+ return n;
41
+ }
34
42
  }
35
43
  exports.default = BackupAuthCredential;
36
44
  //# sourceMappingURL=BackupAuthCredential.js.map
@@ -2,10 +2,12 @@
2
2
  import ByteArray from '../internal/ByteArray';
3
3
  import GenericServerSecretParams from '../GenericServerSecretParams';
4
4
  import BackupLevel from './BackupLevel';
5
+ import BackupCredentialType from './BackupCredentialType';
5
6
  export default class BackupAuthCredentialPresentation extends ByteArray {
6
7
  private readonly __type?;
7
8
  constructor(contents: Buffer);
8
9
  verify(serverParams: GenericServerSecretParams, now?: Date): void;
9
10
  getBackupId(): Buffer;
10
11
  getBackupLevel(): BackupLevel;
12
+ getType(): BackupCredentialType;
11
13
  }
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const ByteArray_1 = require("../internal/ByteArray");
8
8
  const Native = require("../../../Native");
9
9
  const BackupLevel_1 = require("./BackupLevel");
10
+ const BackupCredentialType_1 = require("./BackupCredentialType");
10
11
  class BackupAuthCredentialPresentation extends ByteArray_1.default {
11
12
  constructor(contents) {
12
13
  super(contents, Native.BackupAuthCredentialPresentation_CheckValidContents);
@@ -24,6 +25,13 @@ class BackupAuthCredentialPresentation extends ByteArray_1.default {
24
25
  }
25
26
  return n;
26
27
  }
28
+ getType() {
29
+ const n = Native.BackupAuthCredentialPresentation_GetType(this.contents);
30
+ if (!(n in BackupCredentialType_1.default)) {
31
+ throw new TypeError(`Invalid BackupCredentialType ${n}`);
32
+ }
33
+ return n;
34
+ }
27
35
  }
28
36
  exports.default = BackupAuthCredentialPresentation;
29
37
  //# sourceMappingURL=BackupAuthCredentialPresentation.js.map
@@ -3,9 +3,10 @@ import ByteArray from '../internal/ByteArray';
3
3
  import GenericServerSecretParams from '../GenericServerSecretParams';
4
4
  import BackupAuthCredentialResponse from './BackupAuthCredentialResponse';
5
5
  import BackupLevel from './BackupLevel';
6
+ import BackupCredentialType from './BackupCredentialType';
6
7
  export default class BackupAuthCredentialRequest extends ByteArray {
7
8
  private readonly __type?;
8
9
  constructor(contents: Buffer);
9
- issueCredential(timestamp: number, backupLevel: BackupLevel, params: GenericServerSecretParams): BackupAuthCredentialResponse;
10
- issueCredentialWithRandom(timestamp: number, backupLevel: BackupLevel, params: GenericServerSecretParams, random: Buffer): BackupAuthCredentialResponse;
10
+ issueCredential(timestamp: number, backupLevel: BackupLevel, type: BackupCredentialType, params: GenericServerSecretParams): BackupAuthCredentialResponse;
11
+ issueCredentialWithRandom(timestamp: number, backupLevel: BackupLevel, type: BackupCredentialType, params: GenericServerSecretParams, random: Buffer): BackupAuthCredentialResponse;
11
12
  }
@@ -13,12 +13,12 @@ class BackupAuthCredentialRequest extends ByteArray_1.default {
13
13
  constructor(contents) {
14
14
  super(contents, Native.BackupAuthCredentialRequest_CheckValidContents);
15
15
  }
16
- issueCredential(timestamp, backupLevel, params) {
16
+ issueCredential(timestamp, backupLevel, type, params) {
17
17
  const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
18
- return this.issueCredentialWithRandom(timestamp, backupLevel, params, random);
18
+ return this.issueCredentialWithRandom(timestamp, backupLevel, type, params, random);
19
19
  }
20
- issueCredentialWithRandom(timestamp, backupLevel, params, random) {
21
- return new BackupAuthCredentialResponse_1.default(Native.BackupAuthCredentialRequest_IssueDeterministic(this.contents, timestamp, backupLevel, params.contents, random));
20
+ issueCredentialWithRandom(timestamp, backupLevel, type, params, random) {
21
+ return new BackupAuthCredentialResponse_1.default(Native.BackupAuthCredentialRequest_IssueDeterministic(this.contents, timestamp, backupLevel, type, params.contents, random));
22
22
  }
23
23
  }
24
24
  exports.default = BackupAuthCredentialRequest;
@@ -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);
@@ -0,0 +1,5 @@
1
+ declare enum BackupCredentialType {
2
+ Messages = 1,
3
+ Media = 2
4
+ }
5
+ export default BackupCredentialType;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2024 Signal Messenger, LLC.
4
+ // SPDX-License-Identifier: AGPL-3.0-only
5
+ //
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ // This must match the Rust version of the enum.
8
+ var BackupCredentialType;
9
+ (function (BackupCredentialType) {
10
+ BackupCredentialType[BackupCredentialType["Messages"] = 1] = "Messages";
11
+ BackupCredentialType[BackupCredentialType["Media"] = 2] = "Media";
12
+ })(BackupCredentialType || (BackupCredentialType = {}));
13
+ exports.default = BackupCredentialType;
14
+ //# sourceMappingURL=BackupCredentialType.js.map
@@ -1,5 +1,5 @@
1
1
  declare enum BackupLevel {
2
- Messages = 200,
3
- Media = 201
2
+ Free = 200,
3
+ Paid = 201
4
4
  }
5
5
  export default BackupLevel;
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  // This must match the Rust version of the enum.
8
8
  var BackupLevel;
9
9
  (function (BackupLevel) {
10
- BackupLevel[BackupLevel["Messages"] = 200] = "Messages";
11
- BackupLevel[BackupLevel["Media"] = 201] = "Media";
10
+ BackupLevel[BackupLevel["Free"] = 200] = "Free";
11
+ BackupLevel[BackupLevel["Paid"] = 201] = "Paid";
12
12
  })(BackupLevel || (BackupLevel = {}));
13
13
  exports.default = BackupLevel;
14
14
  //# sourceMappingURL=BackupLevel.js.map
@@ -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.59.0",
3
+ "version": "0.60.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",