Update libsignal-client to 0.76.0

This commit is contained in:
Fedor Indutny
2025-06-30 11:43:41 -07:00
committed by GitHub
parent e55efbd6ee
commit e4e8fadb0f
43 changed files with 245 additions and 883 deletions
+10 -8
View File
@@ -9,7 +9,7 @@ import { CDSSocketBase, CDSSocketState } from './CDSSocketBase';
import type { CDSSocketBaseOptionsType } from './CDSSocketBase';
export type CDSISocketOptionsType = Readonly<{
mrenclave: Buffer;
mrenclave: Uint8Array;
}> &
CDSSocketBaseOptionsType;
@@ -41,7 +41,7 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
);
}
this.socket.sendBytes(this.#cdsClient.initialRequest());
this.socket.sendBytes(Buffer.from(this.#cdsClient.initialRequest()));
{
const { done, value: message } = await this.socketIterator.next();
@@ -55,9 +55,11 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
protected override async sendRequest(
_version: number,
request: Buffer
request: Uint8Array
): Promise<void> {
this.socket.sendBytes(this.#cdsClient.establishedSend(request));
this.socket.sendBytes(
Buffer.from(this.#cdsClient.establishedSend(request))
);
const { done, value: ciphertext } = await this.socketIterator.next();
strictAssert(!done, 'CDSISocket.sendRequest(): expected token message');
@@ -70,8 +72,8 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
strictAssert(token, 'CDSISocket.sendRequest(): expected token');
this.socket.sendBytes(
this.#cdsClient.establishedSend(
Buffer.from(
Buffer.from(
this.#cdsClient.establishedSend(
Proto.CDSClientRequest.encode({
tokenAck: true,
}).finish()
@@ -81,8 +83,8 @@ export class CDSISocket extends CDSSocketBase<CDSISocketOptionsType> {
}
protected override async decryptResponse(
ciphertext: Buffer
): Promise<Buffer> {
ciphertext: Uint8Array
): Promise<Uint8Array> {
return this.#cdsClient.establishedRecv(ciphertext);
}
+12 -7
View File
@@ -47,7 +47,7 @@ export abstract class CDSSocketBase<
protected readonly logger: LoggerType;
protected readonly socketIterator: AsyncIterator<Buffer>;
protected readonly socketIterator: AsyncIterator<Uint8Array>;
constructor(protected readonly options: Options) {
super();
@@ -87,18 +87,18 @@ export abstract class CDSSocketBase<
);
const request = Proto.CDSClientRequest.encode({
newE164s: Buffer.concat(
newE164s: Bytes.concatenate(
e164s.map(e164 => {
// Long.fromString handles numbers with or without a leading '+'
return new Uint8Array(Long.fromString(e164).toBytesBE());
})
),
aciUakPairs: Buffer.concat(aciUakPairs),
aciUakPairs: Bytes.concatenate(aciUakPairs),
returnAcisWithoutUaks,
}).finish();
log.info(`CDSSocket.request(): sending version=${version} request`);
await this.sendRequest(version, Buffer.from(request));
await this.sendRequest(version, request);
const resultMap: Map<string, CDSResponseEntryType> = new Map();
@@ -129,9 +129,14 @@ export abstract class CDSSocketBase<
public abstract handshake(): Promise<void>;
protected abstract sendRequest(version: number, data: Buffer): Promise<void>;
protected abstract sendRequest(
version: number,
data: Uint8Array
): Promise<void>;
protected abstract decryptResponse(ciphertext: Buffer): Promise<Buffer>;
protected abstract decryptResponse(
ciphertext: Uint8Array
): Promise<Uint8Array>;
// EventEmitter types
@@ -161,7 +166,7 @@ export abstract class CDSSocketBase<
// Private
//
#iterateSocket(): AsyncIterator<Buffer> {
#iterateSocket(): AsyncIterator<Uint8Array> {
const stream = new Readable({ read: noop, objectMode: true });
this.socket.on('message', ({ type, binaryData }) => {