@signalapp/libsignal-client 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Native.d.ts CHANGED
@@ -40,6 +40,11 @@ export abstract class SenderKeyStore {
40
40
  _getSenderKey(sender: ProtocolAddress, distributionId: Uuid): Promise<SenderKeyRecord | null>;
41
41
  }
42
42
 
43
+ export abstract class InputStream {
44
+ _read(amount: number): Promise<Buffer>;
45
+ _skip(amount: number): Promise<void>;
46
+ }
47
+
43
48
  interface Wrapper<T> {
44
49
  readonly _nativeHandle: T
45
50
  }
@@ -132,6 +137,11 @@ export function IdentityKeyPair_Deserialize(buffer: Buffer): {publicKey:PublicKe
132
137
  export function IdentityKeyPair_Serialize(publicKey: Wrapper<PublicKey>, privateKey: Wrapper<PrivateKey>): Buffer;
133
138
  export function IdentityKeyPair_SignAlternateIdentity(publicKey: Wrapper<PublicKey>, privateKey: Wrapper<PrivateKey>, otherIdentity: Wrapper<PublicKey>): Buffer;
134
139
  export function IdentityKey_VerifyAlternateIdentity(publicKey: Wrapper<PublicKey>, otherIdentity: Wrapper<PublicKey>, signature: Buffer): boolean;
140
+ export function IncrementalMac_CalculateChunkSize(dataSize: number): number;
141
+ export function IncrementalMac_Finalize(mac: Wrapper<IncrementalMac>): Buffer;
142
+ export function IncrementalMac_Initialize(key: Buffer, chunkSize: number): IncrementalMac;
143
+ export function IncrementalMac_Update(mac: Wrapper<IncrementalMac>, bytes: Buffer, offset: number, length: number): Buffer;
144
+ export function Mp4Sanitizer_Sanitize(input: InputStream, len: Buffer): Promise<SanitizedMetadata>;
135
145
  export function PlaintextContent_Deserialize(data: Buffer): PlaintextContent;
136
146
  export function PlaintextContent_FromDecryptionErrorMessage(m: Wrapper<DecryptionErrorMessage>): PlaintextContent;
137
147
  export function PlaintextContent_GetBody(obj: Wrapper<PlaintextContent>): Buffer;
@@ -181,6 +191,7 @@ export function ProtocolAddress_Name(obj: Wrapper<ProtocolAddress>): string;
181
191
  export function ProtocolAddress_New(name: string, deviceId: number): ProtocolAddress;
182
192
  export function PublicKey_Compare(key1: Wrapper<PublicKey>, key2: Wrapper<PublicKey>): number;
183
193
  export function PublicKey_Deserialize(data: Buffer): PublicKey;
194
+ export function PublicKey_Equals(lhs: Wrapper<PublicKey>, rhs: Wrapper<PublicKey>): boolean;
184
195
  export function PublicKey_GetPublicKeyBytes(obj: Wrapper<PublicKey>): Buffer;
185
196
  export function PublicKey_Serialize(obj: Wrapper<PublicKey>): Buffer;
186
197
  export function PublicKey_Verify(key: Wrapper<PublicKey>, message: Buffer, signature: Buffer): boolean;
@@ -195,6 +206,9 @@ export function ReceiptCredentialResponse_CheckValidContents(buffer: Buffer): vo
195
206
  export function ReceiptCredential_CheckValidContents(buffer: Buffer): void;
196
207
  export function ReceiptCredential_GetReceiptExpirationTime(receiptCredential: Serialized<ReceiptCredential>): Timestamp;
197
208
  export function ReceiptCredential_GetReceiptLevel(receiptCredential: Serialized<ReceiptCredential>): Buffer;
209
+ export function SanitizedMetadata_GetDataLen(sanitized: Wrapper<SanitizedMetadata>): Buffer;
210
+ export function SanitizedMetadata_GetDataOffset(sanitized: Wrapper<SanitizedMetadata>): Buffer;
211
+ export function SanitizedMetadata_GetMetadata(sanitized: Wrapper<SanitizedMetadata>): Buffer;
198
212
  export function ScannableFingerprint_Compare(fprint1: Buffer, fprint2: Buffer): boolean;
199
213
  export function SealedSenderDecryptionResult_GetDeviceId(obj: Wrapper<SealedSenderDecryptionResult>): number;
200
214
  export function SealedSenderDecryptionResult_GetSenderE164(obj: Wrapper<SealedSenderDecryptionResult>): string | null;
@@ -281,6 +295,7 @@ export function SgxClientState_CompleteHandshake(cli: Wrapper<SgxClientState>, h
281
295
  export function SgxClientState_EstablishedRecv(cli: Wrapper<SgxClientState>, receivedCiphertext: Buffer): Buffer;
282
296
  export function SgxClientState_EstablishedSend(cli: Wrapper<SgxClientState>, plaintextToSend: Buffer): Buffer;
283
297
  export function SgxClientState_InitialRequest(obj: Wrapper<SgxClientState>): Buffer;
298
+ export function SignalMedia_CheckAvailable(): void;
284
299
  export function SignalMessage_Deserialize(data: Buffer): SignalMessage;
285
300
  export function SignalMessage_GetBody(obj: Wrapper<SignalMessage>): Buffer;
286
301
  export function SignalMessage_GetCounter(obj: Wrapper<SignalMessage>): number;
@@ -309,6 +324,9 @@ export function Username_Hash(username: string): Buffer;
309
324
  export function Username_Proof(username: string, randomness: Buffer): Buffer;
310
325
  export function Username_Verify(proof: Buffer, hash: Buffer): void;
311
326
  export function UuidCiphertext_CheckValidContents(buffer: Buffer): void;
327
+ export function ValidatingMac_Finalize(mac: Wrapper<ValidatingMac>): boolean;
328
+ export function ValidatingMac_Initialize(key: Buffer, chunkSize: number, digests: Buffer): ValidatingMac;
329
+ export function ValidatingMac_Update(mac: Wrapper<ValidatingMac>, bytes: Buffer, offset: number, length: number): boolean;
312
330
  export function initLogger(maxLevel: LogLevel, callback: (level: LogLevel, target: string, file: string | null, line: number | null, message: string) => void): void
313
331
  interface Aes256GcmSiv { readonly __type: unique symbol; }
314
332
  interface AuthCredential { readonly __type: unique symbol; }
@@ -324,6 +342,7 @@ interface GroupMasterKey { readonly __type: unique symbol; }
324
342
  interface GroupPublicParams { readonly __type: unique symbol; }
325
343
  interface GroupSecretParams { readonly __type: unique symbol; }
326
344
  interface HsmEnclaveClient { readonly __type: unique symbol; }
345
+ interface IncrementalMac { readonly __type: unique symbol; }
327
346
  interface PlaintextContent { readonly __type: unique symbol; }
328
347
  interface PreKeyBundle { readonly __type: unique symbol; }
329
348
  interface PreKeyRecord { readonly __type: unique symbol; }
@@ -341,6 +360,7 @@ interface ReceiptCredentialPresentation { readonly __type: unique symbol; }
341
360
  interface ReceiptCredentialRequest { readonly __type: unique symbol; }
342
361
  interface ReceiptCredentialRequestContext { readonly __type: unique symbol; }
343
362
  interface ReceiptCredentialResponse { readonly __type: unique symbol; }
363
+ interface SanitizedMetadata { readonly __type: unique symbol; }
344
364
  interface SealedSenderDecryptionResult { readonly __type: unique symbol; }
345
365
  interface SenderCertificate { readonly __type: unique symbol; }
346
366
  interface SenderKeyDistributionMessage { readonly __type: unique symbol; }
@@ -355,3 +375,4 @@ interface SignalMessage { readonly __type: unique symbol; }
355
375
  interface SignedPreKeyRecord { readonly __type: unique symbol; }
356
376
  interface UnidentifiedSenderMessageContent { readonly __type: unique symbol; }
357
377
  interface UuidCiphertext { readonly __type: unique symbol; }
378
+ interface ValidatingMac { readonly __type: unique symbol; }
package/dist/Errors.d.ts CHANGED
@@ -14,7 +14,10 @@ export declare enum ErrorCode {
14
14
  MissingSeparator = 10,
15
15
  BadNicknameCharacter = 11,
16
16
  NicknameTooShort = 12,
17
- NicknameTooLong = 13
17
+ NicknameTooLong = 13,
18
+ IoError = 14,
19
+ InvalidMediaInput = 15,
20
+ UnsupportedMediaInput = 16
18
21
  }
19
22
  export declare class LibSignalErrorBase extends Error {
20
23
  readonly code: ErrorCode;
@@ -69,4 +72,13 @@ export type NicknameTooShortError = LibSignalErrorCommon & {
69
72
  export type NicknameTooLongError = LibSignalErrorCommon & {
70
73
  code: ErrorCode.NicknameTooLong;
71
74
  };
72
- export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | CannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError;
75
+ export type IoError = LibSignalErrorCommon & {
76
+ code: ErrorCode.IoError;
77
+ };
78
+ export type InvalidMediaInputError = LibSignalErrorCommon & {
79
+ code: ErrorCode.InvalidMediaInput;
80
+ };
81
+ export type UnsupportedMediaInputError = LibSignalErrorCommon & {
82
+ code: ErrorCode.UnsupportedMediaInput;
83
+ };
84
+ export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | CannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | IoError | InvalidMediaInputError | UnsupportedMediaInputError;
package/dist/Errors.js CHANGED
@@ -22,6 +22,9 @@ var ErrorCode;
22
22
  ErrorCode[ErrorCode["BadNicknameCharacter"] = 11] = "BadNicknameCharacter";
23
23
  ErrorCode[ErrorCode["NicknameTooShort"] = 12] = "NicknameTooShort";
24
24
  ErrorCode[ErrorCode["NicknameTooLong"] = 13] = "NicknameTooLong";
25
+ ErrorCode[ErrorCode["IoError"] = 14] = "IoError";
26
+ ErrorCode[ErrorCode["InvalidMediaInput"] = 15] = "InvalidMediaInput";
27
+ ErrorCode[ErrorCode["UnsupportedMediaInput"] = 16] = "UnsupportedMediaInput";
25
28
  })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
26
29
  class LibSignalErrorBase extends Error {
27
30
  constructor(message, name, operation, extraProps) {
@@ -0,0 +1,61 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * An MP4 format “sanitizer”.
4
+ *
5
+ * Currently the sanitizer always performs the following functions:
6
+ *
7
+ * - Return all presentation metadata present in the input as a self-contained contiguous byte array.
8
+ * - Find and return a pointer to the span in the input containing the (contiguous) media data.
9
+ *
10
+ * “Presentation” metadata means any metadata which is required by an MP4 player to play the file. “Self-contained and
11
+ * contiguous” means that the returned metadata can be concatenated with the media data to form a valid MP4 file.
12
+ *
13
+ * The original metadata may or may not need to be modified in order to perform these functions. In the case that the
14
+ * original metadata does not need to be modified, the returned sanitized metadata will be null to prevent needless data
15
+ * copying.
16
+ *
17
+ * ## Unsupported MP4 features
18
+ *
19
+ * The sanitizer does not currently support:
20
+ *
21
+ * - “Fragmented” MP4 files, which are mostly used for adaptive-bitrate streaming.
22
+ * - Discontiguous media data, i.e. media data (mdat) boxes interspersed with presentation metadata (moov).
23
+ * - Media data references (dref) pointing to separate files.
24
+ * - Any similar format, e.g. Quicktime File Format (mov) or the legacy MP4 version 1, which does not contain the "isom"
25
+ * compatible brand in its file type header (ftyp).
26
+ *
27
+ * @module Mp4Sanitizer
28
+ */
29
+ import * as Native from '../Native';
30
+ import { InputStream } from './io';
31
+ export declare class SanitizedMetadata {
32
+ readonly _nativeHandle: Native.SanitizedMetadata;
33
+ private constructor();
34
+ static _fromNativeHandle(handle: Native.SanitizedMetadata): SanitizedMetadata;
35
+ /**
36
+ * Get the sanitized metadata, if any.
37
+ * @return The sanitized metadata, or {@code null} if it didn't need to be sanitized.
38
+ */
39
+ getMetadata(): Buffer | null;
40
+ /**
41
+ * Get the offset of the media data in the processed input.
42
+ * @return The offset of the media data in the processed input.
43
+ */
44
+ getDataOffset(): bigint;
45
+ /**
46
+ * Get the length of the media data in the processed input.
47
+ * @return The length of the media data in the processed input.
48
+ */
49
+ getDataLen(): bigint;
50
+ }
51
+ /**
52
+ * Sanitize an MP4 input.
53
+ *
54
+ * @param input An MP4 format input stream.
55
+ * @param length The exact length of the input stream.
56
+ * @return The sanitized metadata.
57
+ * @throws IoError If an IO error on the input occurs.
58
+ * @throws InvalidMediaInputError If the input could not be parsed because it was invalid.
59
+ * @throws UnsupportedMediaInputError If the input could not be parsed because it's unsupported in some way.
60
+ */
61
+ export declare function sanitize(input: InputStream, len: bigint): Promise<SanitizedMetadata>;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2023 Signal Messenger, LLC.
4
+ // SPDX-License-Identifier: AGPL-3.0-only
5
+ //
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.sanitize = exports.SanitizedMetadata = void 0;
17
+ /**
18
+ * An MP4 format “sanitizer”.
19
+ *
20
+ * Currently the sanitizer always performs the following functions:
21
+ *
22
+ * - Return all presentation metadata present in the input as a self-contained contiguous byte array.
23
+ * - Find and return a pointer to the span in the input containing the (contiguous) media data.
24
+ *
25
+ * “Presentation” metadata means any metadata which is required by an MP4 player to play the file. “Self-contained and
26
+ * contiguous” means that the returned metadata can be concatenated with the media data to form a valid MP4 file.
27
+ *
28
+ * The original metadata may or may not need to be modified in order to perform these functions. In the case that the
29
+ * original metadata does not need to be modified, the returned sanitized metadata will be null to prevent needless data
30
+ * copying.
31
+ *
32
+ * ## Unsupported MP4 features
33
+ *
34
+ * The sanitizer does not currently support:
35
+ *
36
+ * - “Fragmented” MP4 files, which are mostly used for adaptive-bitrate streaming.
37
+ * - Discontiguous media data, i.e. media data (mdat) boxes interspersed with presentation metadata (moov).
38
+ * - Media data references (dref) pointing to separate files.
39
+ * - Any similar format, e.g. Quicktime File Format (mov) or the legacy MP4 version 1, which does not contain the "isom"
40
+ * compatible brand in its file type header (ftyp).
41
+ *
42
+ * @module Mp4Sanitizer
43
+ */
44
+ const Native = require("../Native");
45
+ const BigIntUtil_1 = require("./zkgroup/internal/BigIntUtil");
46
+ class SanitizedMetadata {
47
+ constructor(handle) {
48
+ this._nativeHandle = handle;
49
+ }
50
+ static _fromNativeHandle(handle) {
51
+ return new SanitizedMetadata(handle);
52
+ }
53
+ /**
54
+ * Get the sanitized metadata, if any.
55
+ * @return The sanitized metadata, or {@code null} if it didn't need to be sanitized.
56
+ */
57
+ getMetadata() {
58
+ const metadata = Native.SanitizedMetadata_GetMetadata(this);
59
+ if (metadata.length == 0) {
60
+ return null;
61
+ }
62
+ return metadata;
63
+ }
64
+ /**
65
+ * Get the offset of the media data in the processed input.
66
+ * @return The offset of the media data in the processed input.
67
+ */
68
+ getDataOffset() {
69
+ const buffer = Native.SanitizedMetadata_GetDataOffset(this);
70
+ return buffer.readBigUInt64BE();
71
+ }
72
+ /**
73
+ * Get the length of the media data in the processed input.
74
+ * @return The length of the media data in the processed input.
75
+ */
76
+ getDataLen() {
77
+ const buffer = Native.SanitizedMetadata_GetDataLen(this);
78
+ return buffer.readBigUInt64BE();
79
+ }
80
+ }
81
+ exports.SanitizedMetadata = SanitizedMetadata;
82
+ /**
83
+ * Sanitize an MP4 input.
84
+ *
85
+ * @param input An MP4 format input stream.
86
+ * @param length The exact length of the input stream.
87
+ * @return The sanitized metadata.
88
+ * @throws IoError If an IO error on the input occurs.
89
+ * @throws InvalidMediaInputError If the input could not be parsed because it was invalid.
90
+ * @throws UnsupportedMediaInputError If the input could not be parsed because it's unsupported in some way.
91
+ */
92
+ function sanitize(input, len) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const sanitizedMetadataNativeHandle = yield Native.Mp4Sanitizer_Sanitize(input, (0, BigIntUtil_1.bufferFromBigUInt64BE)(len));
95
+ return SanitizedMetadata._fromNativeHandle(sanitizedMetadataNativeHandle);
96
+ });
97
+ }
98
+ exports.sanitize = sanitize;
99
+ //# sourceMappingURL=Mp4Sanitizer.js.map
@@ -0,0 +1,28 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import * as Native from '../Native';
4
+ import * as stream from 'stream';
5
+ export type ChunkSizeChoice = {
6
+ kind: 'everyN';
7
+ n: number;
8
+ } | {
9
+ kind: 'chunksOf';
10
+ dataSize: number;
11
+ };
12
+ export declare function everyNthByte(n: number): ChunkSizeChoice;
13
+ export declare function inferChunkSize(dataSize: number): ChunkSizeChoice;
14
+ export declare class DigestingWritable extends stream.Writable {
15
+ _nativeHandle: Native.IncrementalMac;
16
+ _digests: Buffer[];
17
+ constructor(key: Buffer, sizeChoice: ChunkSizeChoice);
18
+ getFinalDigest(): Buffer;
19
+ _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
20
+ _final(callback: (error?: Error | null) => void): void;
21
+ }
22
+ export declare class ValidatingWritable extends stream.Writable {
23
+ _nativeHandle: Native.ValidatingMac;
24
+ constructor(key: Buffer, sizeChoice: ChunkSizeChoice, digest: Buffer);
25
+ _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
26
+ _final(callback: (error?: Error | null) => void): void;
27
+ }
28
+ export declare function chunkSizeInBytes(sizeChoice: ChunkSizeChoice): number;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2023 Signal Messenger, LLC.
4
+ // SPDX-License-Identifier: AGPL-3.0-only
5
+ //
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.chunkSizeInBytes = exports.ValidatingWritable = exports.DigestingWritable = exports.inferChunkSize = exports.everyNthByte = void 0;
8
+ const Native = require("../Native");
9
+ const stream = require("stream");
10
+ const Errors_1 = require("./Errors");
11
+ function everyNthByte(n) {
12
+ return { kind: 'everyN', n: n };
13
+ }
14
+ exports.everyNthByte = everyNthByte;
15
+ function inferChunkSize(dataSize) {
16
+ return { kind: 'chunksOf', dataSize: dataSize };
17
+ }
18
+ exports.inferChunkSize = inferChunkSize;
19
+ class DigestingWritable extends stream.Writable {
20
+ constructor(key, sizeChoice) {
21
+ super();
22
+ this._digests = [];
23
+ this._nativeHandle = Native.IncrementalMac_Initialize(key, chunkSizeInBytes(sizeChoice));
24
+ }
25
+ getFinalDigest() {
26
+ return Buffer.concat(this._digests);
27
+ }
28
+ _write(
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
30
+ chunk, _encoding, callback) {
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
32
+ const buffer = Buffer.from(chunk, 'binary');
33
+ const next_digest = Native.IncrementalMac_Update(this, buffer, 0, buffer.length);
34
+ if (next_digest.length != 0) {
35
+ this._digests.push(next_digest);
36
+ }
37
+ callback();
38
+ }
39
+ _final(callback) {
40
+ this._digests.push(Native.IncrementalMac_Finalize(this));
41
+ callback();
42
+ }
43
+ }
44
+ exports.DigestingWritable = DigestingWritable;
45
+ class ValidatingWritable extends stream.Writable {
46
+ constructor(key, sizeChoice, digest) {
47
+ super();
48
+ this._nativeHandle = Native.ValidatingMac_Initialize(key, chunkSizeInBytes(sizeChoice), digest);
49
+ }
50
+ _write(
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
52
+ chunk, _encoding, callback) {
53
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
54
+ const buffer = Buffer.from(chunk, 'binary');
55
+ if (Native.ValidatingMac_Update(this, buffer, 0, buffer.length)) {
56
+ callback();
57
+ }
58
+ else {
59
+ callback(makeVerificationError('Corrupted input data'));
60
+ }
61
+ }
62
+ _final(callback) {
63
+ if (Native.ValidatingMac_Finalize(this)) {
64
+ callback();
65
+ }
66
+ else {
67
+ callback(makeVerificationError('Corrupted input data (finalize)'));
68
+ }
69
+ }
70
+ }
71
+ exports.ValidatingWritable = ValidatingWritable;
72
+ function chunkSizeInBytes(sizeChoice) {
73
+ switch (sizeChoice.kind) {
74
+ case 'everyN':
75
+ return sizeChoice.n;
76
+ break;
77
+ case 'chunksOf':
78
+ return Native.IncrementalMac_CalculateChunkSize(sizeChoice.dataSize);
79
+ break;
80
+ }
81
+ }
82
+ exports.chunkSizeInBytes = chunkSizeInBytes;
83
+ function makeVerificationError(message) {
84
+ return new Errors_1.LibSignalErrorBase(message, 'VerificationFailed', 'incremental_mac');
85
+ }
86
+ //# sourceMappingURL=incremental_mac.js.map
package/dist/index.d.ts CHANGED
@@ -3,6 +3,8 @@ export * from './Errors';
3
3
  import { ProtocolAddress } from './Address';
4
4
  export * from './Address';
5
5
  export * as usernames from './usernames';
6
+ export * as io from './io';
7
+ export * as Mp4Sanitizer from './Mp4Sanitizer';
6
8
  import * as Native from '../Native';
7
9
  export declare enum CiphertextMessageType {
8
10
  Whisper = 2,
package/dist/index.js CHANGED
@@ -27,14 +27,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27
27
  });
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.LogLevel = exports.HsmEnclaveClient = exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = exports.sealedSenderMultiRecipientMessageForSingleRecipient = 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.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.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.IdentityKeyPair = exports.PrivateKey = exports.PublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.HKDF = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.usernames = void 0;
31
- exports.initLogger = void 0;
30
+ exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = exports.sealedSenderMultiRecipientMessageForSingleRecipient = 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.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.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.IdentityKeyPair = exports.PrivateKey = exports.PublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.HKDF = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.Mp4Sanitizer = exports.io = exports.usernames = void 0;
31
+ exports.initLogger = exports.LogLevel = exports.HsmEnclaveClient = void 0;
32
32
  const uuid = require("uuid");
33
33
  const Errors = require("./Errors");
34
34
  __exportStar(require("./Errors"), exports);
35
35
  const Address_1 = require("./Address");
36
36
  __exportStar(require("./Address"), exports);
37
37
  exports.usernames = require("./usernames");
38
+ exports.io = require("./io");
39
+ exports.Mp4Sanitizer = require("./Mp4Sanitizer");
38
40
  const Native = require("../Native");
39
41
  Native.registerErrors(Errors);
40
42
  // These enums must be kept in sync with their Rust counterparts.
package/dist/io.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+ import * as Native from '../Native';
3
+ /**
4
+ * An abstract class representing an input stream of bytes.
5
+ */
6
+ export declare abstract class InputStream implements Native.InputStream {
7
+ _read(amount: number): Promise<Buffer>;
8
+ _skip(amount: number): Promise<void>;
9
+ /**
10
+ * Read an amount of bytes from the input stream.
11
+ *
12
+ * The actual amount of bytes returned may be smaller than the amount requested by the caller, for any reason;
13
+ * however, returning zero bytes always indicates that the end of the stream has been reached.
14
+ *
15
+ * @param amount The amount of bytes to read.
16
+ * @return A promise yielding a {@link Buffer} containing the read bytes.
17
+ * @throws IoError If an I/O error occurred while reading from the input.
18
+ */
19
+ abstract read(amount: number): Promise<Buffer>;
20
+ /**
21
+ * Skip an amount of bytes in the input stream.
22
+ *
23
+ * If the requested number of bytes could not be skipped for any reason, an {@link IoError} must be raised instead.
24
+ *
25
+ * @param amount The amount of bytes to skip.
26
+ * @return A promise which is resolved once the bytes have been skipped.
27
+ * @throws IoError If an I/O error occurred while skipping the bytes in the input.
28
+ */
29
+ abstract skip(amount: number): Promise<void>;
30
+ }
package/dist/io.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2023 Signal Messenger, LLC.
4
+ // SPDX-License-Identifier: AGPL-3.0-only
5
+ //
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.InputStream = void 0;
8
+ /**
9
+ * An abstract class representing an input stream of bytes.
10
+ */
11
+ class InputStream {
12
+ _read(amount) {
13
+ return this.read(amount);
14
+ }
15
+ _skip(amount) {
16
+ return this.skip(amount);
17
+ }
18
+ }
19
+ exports.InputStream = InputStream;
20
+ //# sourceMappingURL=io.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
Binary file
Binary file
Binary file