@signalapp/libsignal-client 0.52.3 → 0.52.4

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
@@ -192,6 +192,9 @@ export function ChatService_unauth_send_and_debug(asyncRuntime: Wrapper<TokioAsy
192
192
  export function CiphertextMessage_FromPlaintextContent(m: Wrapper<PlaintextContent>): CiphertextMessage;
193
193
  export function CiphertextMessage_Serialize(obj: Wrapper<CiphertextMessage>): Buffer;
194
194
  export function CiphertextMessage_Type(msg: Wrapper<CiphertextMessage>): number;
195
+ export function ComparableBackup_GetComparableString(backup: Wrapper<ComparableBackup>): string;
196
+ export function ComparableBackup_GetUnknownFields(backup: Wrapper<ComparableBackup>): string[];
197
+ export function ComparableBackup_ReadUnencrypted(stream: InputStream, len: bigint, purpose: number): Promise<ComparableBackup>;
195
198
  export function ConnectionManager_clear_proxy(connectionManager: Wrapper<ConnectionManager>): void;
196
199
  export function ConnectionManager_new(environment: number, userAgent: string): ConnectionManager;
197
200
  export function ConnectionManager_set_ipv6_enabled(connectionManager: Wrapper<ConnectionManager>, ipv6Enabled: boolean): void;
@@ -553,6 +556,8 @@ interface Aes256GcmSiv { readonly __type: unique symbol; }
553
556
  interface CdsiLookup { readonly __type: unique symbol; }
554
557
  interface Chat { readonly __type: unique symbol; }
555
558
  interface CiphertextMessage { readonly __type: unique symbol; }
559
+ interface ComparableBackup { readonly __type: unique symbol; }
560
+ interface ComparableBackup { readonly __type: unique symbol; }
556
561
  interface ConnectionManager { readonly __type: unique symbol; }
557
562
  interface DecryptionErrorMessage { readonly __type: unique symbol; }
558
563
  interface ExpiringProfileKeyCredential { readonly __type: unique symbol; }
package/dist/Errors.d.ts CHANGED
@@ -36,7 +36,8 @@ export declare enum ErrorCode {
36
36
  ChatServiceInactive = 32,
37
37
  AppExpired = 33,
38
38
  DeviceDelinked = 34,
39
- Cancelled = 35
39
+ BackupValidation = 35,
40
+ Cancelled = 36
40
41
  }
41
42
  export declare class LibSignalErrorBase extends Error {
42
43
  readonly code: ErrorCode;
@@ -156,6 +157,10 @@ export type SvrRestoreFailedError = LibSignalErrorCommon & {
156
157
  code: ErrorCode.SvrRestoreFailed;
157
158
  readonly triesRemaining: number;
158
159
  };
160
+ export type BackupValidationError = LibSignalErrorCommon & {
161
+ code: ErrorCode.BackupValidation;
162
+ readonly unknownFields: ReadonlyArray<string>;
163
+ };
159
164
  export type CancellationError = LibSignalErrorCommon & {
160
165
  code: ErrorCode.Cancelled;
161
166
  };
package/dist/Errors.js CHANGED
@@ -43,7 +43,8 @@ var ErrorCode;
43
43
  ErrorCode[ErrorCode["ChatServiceInactive"] = 32] = "ChatServiceInactive";
44
44
  ErrorCode[ErrorCode["AppExpired"] = 33] = "AppExpired";
45
45
  ErrorCode[ErrorCode["DeviceDelinked"] = 34] = "DeviceDelinked";
46
- ErrorCode[ErrorCode["Cancelled"] = 35] = "Cancelled";
46
+ ErrorCode[ErrorCode["BackupValidation"] = 35] = "BackupValidation";
47
+ ErrorCode[ErrorCode["Cancelled"] = 36] = "Cancelled";
47
48
  })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
48
49
  class LibSignalErrorBase extends Error {
49
50
  constructor(message, name, operation, extraProps) {
@@ -56,3 +56,47 @@ export declare enum Purpose {
56
56
  * @throws IoError If an IO error on the input occurs.
57
57
  */
58
58
  export declare function validate(backupKey: MessageBackupKey, purpose: Purpose, inputFactory: InputStreamFactory, length: bigint): Promise<ValidationOutcome>;
59
+ /**
60
+ * An in-memory representation of a backup file used to compare contents.
61
+ *
62
+ * When comparing the contents of two backups:
63
+ * 1. Create a `ComparableBackup` instance for each of the inputs.
64
+ * 2. Check the `unknownFields()` value; if it's not empty, some parts of the
65
+ * backup weren't parsed and won't be compared.
66
+ * 3. Produce a canonical string for each backup with `comparableString()`.
67
+ * 4. Compare the canonical string representations.
68
+ *
69
+ * The diff of the canonical strings (which may be rather large) will show the
70
+ * differences between the logical content of the input backup files.
71
+ */
72
+ export declare class ComparableBackup {
73
+ readonly _nativeHandle: Native.ComparableBackup;
74
+ constructor(handle: Native.ComparableBackup);
75
+ /**
76
+ * Read an unencrypted backup file into memory for comparison.
77
+ *
78
+ * @param purpose Whether the backup is intended for device-to-device transfer or remote storage.
79
+ * @param input An input stream that reads the backup contents.
80
+ * @param length The exact length of the input stream.
81
+ * @returns The in-memory representation.
82
+ * @throws BackupValidationError If an IO error occurs or the input is invalid.
83
+ */
84
+ static fromUnencrypted(purpose: Purpose, input: InputStream, length: bigint): Promise<ComparableBackup>;
85
+ /**
86
+ * Produces a string representation of the contents.
87
+ *
88
+ * The returned strings for two backups will be equal if the backups contain
89
+ * the same logical content. If two backups' strings are not equal, the diff
90
+ * will show what is different between them.
91
+ *
92
+ * @returns a canonical string representation of the backup
93
+ */
94
+ comparableString(): string;
95
+ /**
96
+ * Unrecognized protobuf fields present in the backup.
97
+ *
98
+ * If this is not empty, some parts of the backup were not recognized and
99
+ * won't be present in the string representation.
100
+ */
101
+ get unknownFields(): Array<string>;
102
+ }
@@ -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.validate = exports.Purpose = exports.MessageBackupKey = exports.ValidationOutcome = void 0;
7
+ exports.ComparableBackup = exports.validate = exports.Purpose = exports.MessageBackupKey = exports.ValidationOutcome = void 0;
8
8
  /**
9
9
  * Message backup validation routines.
10
10
  *
@@ -66,4 +66,57 @@ async function validate(backupKey, purpose, inputFactory, length) {
66
66
  return new ValidationOutcome(await Native.MessageBackupValidator_Validate(backupKey, firstStream, secondStream, length, purpose));
67
67
  }
68
68
  exports.validate = validate;
69
+ /**
70
+ * An in-memory representation of a backup file used to compare contents.
71
+ *
72
+ * When comparing the contents of two backups:
73
+ * 1. Create a `ComparableBackup` instance for each of the inputs.
74
+ * 2. Check the `unknownFields()` value; if it's not empty, some parts of the
75
+ * backup weren't parsed and won't be compared.
76
+ * 3. Produce a canonical string for each backup with `comparableString()`.
77
+ * 4. Compare the canonical string representations.
78
+ *
79
+ * The diff of the canonical strings (which may be rather large) will show the
80
+ * differences between the logical content of the input backup files.
81
+ */
82
+ class ComparableBackup {
83
+ constructor(handle) {
84
+ this._nativeHandle = handle;
85
+ }
86
+ /**
87
+ * Read an unencrypted backup file into memory for comparison.
88
+ *
89
+ * @param purpose Whether the backup is intended for device-to-device transfer or remote storage.
90
+ * @param input An input stream that reads the backup contents.
91
+ * @param length The exact length of the input stream.
92
+ * @returns The in-memory representation.
93
+ * @throws BackupValidationError If an IO error occurs or the input is invalid.
94
+ */
95
+ static async fromUnencrypted(purpose, input, length) {
96
+ const handle = await Native.ComparableBackup_ReadUnencrypted(input, length, purpose);
97
+ return new ComparableBackup(handle);
98
+ }
99
+ /**
100
+ * Produces a string representation of the contents.
101
+ *
102
+ * The returned strings for two backups will be equal if the backups contain
103
+ * the same logical content. If two backups' strings are not equal, the diff
104
+ * will show what is different between them.
105
+ *
106
+ * @returns a canonical string representation of the backup
107
+ */
108
+ comparableString() {
109
+ return Native.ComparableBackup_GetComparableString(this);
110
+ }
111
+ /**
112
+ * Unrecognized protobuf fields present in the backup.
113
+ *
114
+ * If this is not empty, some parts of the backup were not recognized and
115
+ * won't be present in the string representation.
116
+ */
117
+ get unknownFields() {
118
+ return Native.ComparableBackup_GetUnknownFields(this);
119
+ }
120
+ }
121
+ exports.ComparableBackup = ComparableBackup;
69
122
  //# sourceMappingURL=MessageBackup.js.map
@@ -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
- ## attest 0.1.0, libsignal-ffi 0.52.3, libsignal-jni 0.52.3, libsignal-jni-testing 0.52.3, libsignal-node 0.52.3, 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, signal-media 0.1.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, signal-pin 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
+ ## attest 0.1.0, libsignal-ffi 0.52.4, libsignal-jni 0.52.4, libsignal-jni-testing 0.52.4, libsignal-node 0.52.4, 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, signal-media 0.1.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, signal-pin 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.52.3",
3
+ "version": "0.52.4",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",