diff --git a/Cargo.lock b/Cargo.lock index 1a2c88577..32eae87b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2542,7 +2542,7 @@ dependencies = [ [[package]] name = "libsignal-ffi" -version = "0.88.4" +version = "0.89.0" dependencies = [ "cpufeatures", "hex", @@ -2563,14 +2563,14 @@ dependencies = [ [[package]] name = "libsignal-jni" -version = "0.88.4" +version = "0.89.0" dependencies = [ "libsignal-jni-impl", ] [[package]] name = "libsignal-jni-impl" -version = "0.88.4" +version = "0.89.0" dependencies = [ "cfg-if", "cpufeatures", @@ -2587,7 +2587,7 @@ dependencies = [ [[package]] name = "libsignal-jni-testing" -version = "0.88.4" +version = "0.89.0" dependencies = [ "jni", "libsignal-bridge-testing", @@ -2902,7 +2902,7 @@ dependencies = [ [[package]] name = "libsignal-node" -version = "0.88.4" +version = "0.89.0" dependencies = [ "futures", "libsignal-bridge", diff --git a/Cargo.toml b/Cargo.toml index 07ed3618e..bb967a13b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ default-members = [ resolver = "2" # so that our dev-dependency features don't leak into products [workspace.package] -version = "0.88.4" +version = "0.89.0" authors = ["Signal Messenger LLC"] license = "AGPL-3.0-only" rust-version = "1.88" diff --git a/LibSignalClient.podspec b/LibSignalClient.podspec index bdd9e7077..54f6a0a1b 100644 --- a/LibSignalClient.podspec +++ b/LibSignalClient.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |s| s.name = 'LibSignalClient' - s.version = '0.88.4' + s.version = '0.89.0' s.summary = 'A Swift wrapper library for communicating with the Signal messaging service.' s.homepage = 'https://github.com/signalapp/libsignal' diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index be2ace846..eb7e5ce22 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,4 @@ -v0.88.4 +v0.89.0 - Node: Implementing `IdentityKeyStore.getIdentityKeyPair()` can avoid rederivation of the public key from the existing `IdentityKeyStore.getIdentityKey()` requirement. In the future, the PrivateKey-only `getIdentityKey()` will be removed. +- Node: Update all uses of `Uint8Array` and `Buffer` to use `ArrayBuffer` diff --git a/java/build.gradle b/java/build.gradle index 2f2334531..d134fbd06 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -23,7 +23,7 @@ repositories { } allprojects { - version = "0.88.4" + version = "0.89.0" group = "org.signal" tasks.withType(JavaCompile) { diff --git a/node/package-lock.json b/node/package-lock.json index 79e759871..c04c0eb4c 100644 --- a/node/package-lock.json +++ b/node/package-lock.json @@ -1,12 +1,12 @@ { "name": "@signalapp/libsignal-client", - "version": "0.88.4", + "version": "0.89.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@signalapp/libsignal-client", - "version": "0.88.4", + "version": "0.89.0", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { @@ -23,7 +23,7 @@ "@types/chai-as-promised": "^8.0.2", "@types/chance": "^1.1.3", "@types/mocha": "^10.0.10", - "@types/node": "~20.11.0", + "@types/node": "^24.12.0", "@types/sinon": "^17.0.3", "@types/sinon-chai": "^4.0.0", "@typescript-eslint/parser": "^8.44.0", @@ -48,7 +48,7 @@ "sinon": "^21.0.0", "sinon-chai": "^4.0.1", "source-map-support": "^0.5.19", - "typescript": "5.3.3", + "typescript": "5.9.3", "typescript-eslint": "^8.44.0" } }, @@ -797,12 +797,13 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.30", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz", - "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==", + "version": "24.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.0.tgz", + "integrity": "sha512-GYDxsZi3ChgmckRT9HPU0WEhKLP08ev/Yfcq2AstjrDASOYCSXeyjDsHg4v5t4jOj7cyDX3vmprafKlWIG9MXQ==", "dev": true, + "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~7.16.0" } }, "node_modules/@types/sinon": { @@ -873,7 +874,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.44.0.tgz", "integrity": "sha512-VGMpFQGUQWYT9LfnPcX8ouFojyrZ/2w3K5BucvxL/spdNehccKhB4jUyB1yBCXpr2XFm0jkECxgrpXBW2ipoAw==", "dev": true, - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.44.0", "@typescript-eslint/types": "8.44.0", @@ -1071,7 +1071,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1474,7 +1473,6 @@ "resolved": "https://registry.npmjs.org/chai/-/chai-6.0.1.tgz", "integrity": "sha512-/JOoU2//6p5vCXh00FpNgtlw0LjvhGttaWc+y7wpW9yjBm3ys0dI8tSKZxIOgNruz5J0RleccatSIC3uxEZP0g==", "dev": true, - "peer": true, "engines": { "node": ">=18" } @@ -2070,7 +2068,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.35.0.tgz", "integrity": "sha512-QePbBFMJFjgmlE+cXAlbHZbHpdFVS2E/6vzCy7aKlebddvl1vadiC4JFV5u/wqTkNUwEV8WrQi257jf5f06hrg==", "dev": true, - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -2230,7 +2227,6 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz", "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "dev": true, - "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -4401,7 +4397,6 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true, - "peer": true, "bin": { "prettier": "bin-prettier.js" }, @@ -5125,7 +5120,6 @@ "resolved": "https://registry.npmjs.org/sinon/-/sinon-21.0.0.tgz", "integrity": "sha512-TOgRcwFPbfGtpqvZw+hyqJDvqfapr1qUlOizROIk4bBLjlsjlB00Pg6wMFXNtJRpu+eCZuVOaLatG7M8105kAw==", "dev": true, - "peer": true, "dependencies": { "@sinonjs/commons": "^3.0.1", "@sinonjs/fake-timers": "^13.0.5", @@ -5549,7 +5543,6 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, - "peer": true, "engines": { "node": ">=12" }, @@ -5728,11 +5721,11 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, - "peer": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -5792,10 +5785,11 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "dev": true + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" }, "node_modules/unique-stream": { "version": "2.3.1", diff --git a/node/package.json b/node/package.json index bbcb17870..fb3e5d672 100644 --- a/node/package.json +++ b/node/package.json @@ -1,6 +1,6 @@ { "name": "@signalapp/libsignal-client", - "version": "0.88.4", + "version": "0.89.0", "repository": "github:signalapp/libsignal", "license": "AGPL-3.0-only", "type": "module", @@ -46,7 +46,7 @@ "@types/chai-as-promised": "^8.0.2", "@types/chance": "^1.1.3", "@types/mocha": "^10.0.10", - "@types/node": "~20.11.0", + "@types/node": "^24.12.0", "@types/sinon": "^17.0.3", "@types/sinon-chai": "^4.0.0", "@typescript-eslint/parser": "^8.44.0", @@ -71,7 +71,7 @@ "sinon": "^21.0.0", "sinon-chai": "^4.0.1", "source-map-support": "^0.5.19", - "typescript": "5.3.3", + "typescript": "5.9.3", "typescript-eslint": "^8.44.0" } } diff --git a/node/ts/AccountKeys.ts b/node/ts/AccountKeys.ts index f5ed1ed77..60d40d958 100644 --- a/node/ts/AccountKeys.ts +++ b/node/ts/AccountKeys.ts @@ -49,7 +49,9 @@ export class AccountEntropyPool { * `accountEntropyPool` must be a **validated** account entropy pool; * passing an arbitrary string here is considered a programmer error. */ - public static deriveSvrKey(accountEntropyPool: string): Uint8Array { + public static deriveSvrKey( + accountEntropyPool: string + ): Uint8Array { return Native.AccountEntropyPool_DeriveSvrKey(accountEntropyPool); } @@ -79,7 +81,7 @@ export class BackupKey extends ByteArray { private readonly __type?: never; static SIZE = 32; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, BackupKey.checkLength(BackupKey.SIZE)); } @@ -100,7 +102,7 @@ export class BackupKey extends ByteArray { * * Used for both message and media backups. */ - public deriveBackupId(aci: Aci): Uint8Array { + public deriveBackupId(aci: Aci): Uint8Array { return Native.BackupKey_DeriveBackupId( this.contents, aci.getServiceIdFixedWidthBinary() @@ -126,7 +128,7 @@ export class BackupKey extends ByteArray { * * Only relevant for message backup keys. */ - public deriveLocalBackupMetadataKey(): Uint8Array { + public deriveLocalBackupMetadataKey(): Uint8Array { return Native.BackupKey_DeriveLocalBackupMetadataKey(this.contents); } @@ -135,7 +137,7 @@ export class BackupKey extends ByteArray { * * Only relevant for media backup keys. */ - public deriveMediaId(mediaName: string): Uint8Array { + public deriveMediaId(mediaName: string): Uint8Array { return Native.BackupKey_DeriveMediaId(this.contents, mediaName); } @@ -146,7 +148,9 @@ export class BackupKey extends ByteArray { * * Only relevant for media backup keys. */ - public deriveMediaEncryptionKey(mediaId: Uint8Array): Uint8Array { + public deriveMediaEncryptionKey( + mediaId: Uint8Array + ): Uint8Array { return Native.BackupKey_DeriveMediaEncryptionKey(this.contents, mediaId); } @@ -158,7 +162,9 @@ export class BackupKey extends ByteArray { * * Only relevant for media backup keys. */ - public deriveThumbnailTransitEncryptionKey(mediaId: Uint8Array): Uint8Array { + public deriveThumbnailTransitEncryptionKey( + mediaId: Uint8Array + ): Uint8Array { return Native.BackupKey_DeriveThumbnailTransitEncryptionKey( this.contents, mediaId @@ -176,7 +182,7 @@ export class BackupForwardSecrecyToken extends ByteArray { private readonly __type?: never; static SIZE = 32; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super( contents, BackupForwardSecrecyToken.checkLength(BackupForwardSecrecyToken.SIZE) diff --git a/node/ts/Address.ts b/node/ts/Address.ts index 085b4e883..5c8743bef 100644 --- a/node/ts/Address.ts +++ b/node/ts/Address.ts @@ -7,6 +7,7 @@ import * as Native from './Native.js'; import * as uuid from 'uuid'; import { Buffer } from 'node:buffer'; +import { parseUuid } from './uuid.js'; export enum ServiceIdKind { Aci = 0, @@ -22,10 +23,10 @@ const SERVICE_ID_FIXED_WIDTH_BINARY_LEN = 17; * user on the Signal service. */ export abstract class ServiceId extends Object { - private readonly serviceIdFixedWidthBinary: Uint8Array; + private readonly serviceIdFixedWidthBinary: Uint8Array; // This has to be public for `InstanceType`, which we use below. - constructor(serviceIdFixedWidthBinary: Uint8Array) { + constructor(serviceIdFixedWidthBinary: Uint8Array) { super(); if (serviceIdFixedWidthBinary.length != SERVICE_ID_FIXED_WIDTH_BINARY_LEN) { throw new TypeError('invalid Service-Id-FixedWidthBinary'); @@ -38,7 +39,9 @@ export abstract class ServiceId extends Object { // Because ServiceId is abstract, and TypeScript won't let us construct an abstract class. // Strictly speaking we don't need the 'typeof' and 'InstanceType', // but it's more consistent with the factory methods below. - this: new (serviceIdFixedWidthBinary: Uint8Array) => InstanceType, + this: new ( + serviceIdFixedWidthBinary: Uint8Array + ) => InstanceType, uuidBytes: ArrayLike, kind: ServiceIdKind ): InstanceType { @@ -48,11 +51,11 @@ export abstract class ServiceId extends Object { return new this(buffer); } - getServiceIdBinary(): Uint8Array { + getServiceIdBinary(): Uint8Array { return Native.ServiceId_ServiceIdBinary(this.serviceIdFixedWidthBinary); } - getServiceIdFixedWidthBinary(): Uint8Array { + getServiceIdFixedWidthBinary(): Uint8Array { return Uint8Array.from(this.serviceIdFixedWidthBinary); } @@ -76,7 +79,7 @@ export abstract class ServiceId extends Object { static parseFromServiceIdFixedWidthBinary( this: T, - serviceIdFixedWidthBinary: Uint8Array + serviceIdFixedWidthBinary: Uint8Array ): InstanceType { let result: ServiceId; switch (serviceIdFixedWidthBinary[0]) { @@ -94,7 +97,7 @@ export abstract class ServiceId extends Object { static parseFromServiceIdBinary( this: T, - serviceIdBinary: Uint8Array + serviceIdBinary: Uint8Array ): InstanceType { const result = ServiceId.parseFromServiceIdFixedWidthBinary( Native.ServiceId_ParseFromServiceIdBinary(serviceIdBinary) @@ -116,7 +119,7 @@ export abstract class ServiceId extends Object { return uuid.stringify(this.serviceIdFixedWidthBinary, 1); } - getRawUuidBytes(): Uint8Array { + getRawUuidBytes(): Uint8Array { return this.serviceIdFixedWidthBinary.subarray(1); } @@ -136,7 +139,9 @@ export abstract class ServiceId extends Object { ); } - static toConcatenatedFixedWidthBinary(serviceIds: ServiceId[]): Uint8Array { + static toConcatenatedFixedWidthBinary( + serviceIds: ServiceId[] + ): Uint8Array { const result = new Uint8Array( serviceIds.length * SERVICE_ID_FIXED_WIDTH_BINARY_LEN ); @@ -153,7 +158,7 @@ export class Aci extends ServiceId { private readonly __type?: never; static fromUuid(uuidString: string): Aci { - return this.fromUuidBytes(uuid.parse(uuidString)); + return this.fromUuidBytes(parseUuid(uuidString)); } static fromUuidBytes(uuidBytes: ArrayLike): Aci { @@ -165,7 +170,7 @@ export class Pni extends ServiceId { private readonly __type?: never; static fromUuid(uuidString: string): Pni { - return this.fromUuidBytes(uuid.parse(uuidString)); + return this.fromUuidBytes(parseUuid(uuidString)); } static fromUuidBytes(uuidBytes: ArrayLike): Pni { diff --git a/node/ts/EcKeys.ts b/node/ts/EcKeys.ts index 597345202..aee9d78ce 100644 --- a/node/ts/EcKeys.ts +++ b/node/ts/EcKeys.ts @@ -16,7 +16,7 @@ export class PublicKey { return new PublicKey(handle); } - static deserialize(buf: Uint8Array): PublicKey { + static deserialize(buf: Uint8Array): PublicKey { return new PublicKey(Native.PublicKey_Deserialize(buf)); } @@ -24,19 +24,22 @@ export class PublicKey { return Native.PublicKey_Equals(this, other); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.PublicKey_Serialize(this); } - getPublicKeyBytes(): Uint8Array { + getPublicKeyBytes(): Uint8Array { return Native.PublicKey_GetPublicKeyBytes(this); } - verify(msg: Uint8Array, sig: Uint8Array): boolean { + verify(msg: Uint8Array, sig: Uint8Array): boolean { return Native.PublicKey_Verify(this, msg, sig); } - verifyAlternateIdentity(other: PublicKey, signature: Uint8Array): boolean { + verifyAlternateIdentity( + other: PublicKey, + signature: Uint8Array + ): boolean { return Native.IdentityKey_VerifyAlternateIdentity(this, other, signature); } @@ -53,10 +56,10 @@ export class PublicKey { * @see PrivateKey#open */ seal( - msg: Uint8Array, - info: string | Uint8Array, - associatedData?: Uint8Array - ): Uint8Array { + msg: Uint8Array, + info: string | Uint8Array, + associatedData?: Uint8Array + ): Uint8Array { const infoBuffer = typeof info === 'string' ? new TextEncoder().encode(info) : info; return Native.PublicKey_HpkeSeal( @@ -83,19 +86,19 @@ export class PrivateKey { return new PrivateKey(Native.PrivateKey_Generate()); } - static deserialize(buf: Uint8Array): PrivateKey { + static deserialize(buf: Uint8Array): PrivateKey { return new PrivateKey(Native.PrivateKey_Deserialize(buf)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.PrivateKey_Serialize(this); } - sign(msg: Uint8Array): Uint8Array { + sign(msg: Uint8Array): Uint8Array { return Native.PrivateKey_Sign(this, msg); } - agree(other_key: PublicKey): Uint8Array { + agree(other_key: PublicKey): Uint8Array { return Native.PrivateKey_Agree(this, other_key); } @@ -111,10 +114,10 @@ export class PrivateKey { * `info` and `associatedData` must match those used during sealing. */ open( - ciphertext: Uint8Array, - info: string | Uint8Array, - associatedData?: Uint8Array - ): Uint8Array { + ciphertext: Uint8Array, + info: string | Uint8Array, + associatedData?: Uint8Array + ): Uint8Array { const infoBuffer = typeof info === 'string' ? new TextEncoder().encode(info) : info; return Native.PrivateKey_HpkeOpen( @@ -140,7 +143,7 @@ export class IdentityKeyPair { return new IdentityKeyPair(privateKey.getPublicKey(), privateKey); } - static deserialize(buffer: Uint8Array): IdentityKeyPair { + static deserialize(buffer: Uint8Array): IdentityKeyPair { const [publicKey, privateKey] = Native.IdentityKeyPair_Deserialize(buffer); return new IdentityKeyPair( PublicKey._fromNativeHandle(publicKey), @@ -148,11 +151,11 @@ export class IdentityKeyPair { ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.IdentityKeyPair_Serialize(this.publicKey, this.privateKey); } - signAlternateIdentity(other: PublicKey): Uint8Array { + signAlternateIdentity(other: PublicKey): Uint8Array { return Native.IdentityKeyPair_SignAlternateIdentity( this.publicKey, this.privateKey, diff --git a/node/ts/Errors.ts b/node/ts/Errors.ts index 1ea057dd9..312fd9759 100644 --- a/node/ts/Errors.ts +++ b/node/ts/Errors.ts @@ -72,7 +72,7 @@ export enum ErrorCode { } /** Called out as a separate type so it's not confused with a normal ServiceIdBinary. */ -type ServiceIdFixedWidthBinary = Uint8Array; +type ServiceIdFixedWidthBinary = Uint8Array; /** * A failure sending to a recipient on account of not being up to date on their devices. diff --git a/node/ts/MessageBackup.ts b/node/ts/MessageBackup.ts index 892e6c314..45a344e28 100644 --- a/node/ts/MessageBackup.ts +++ b/node/ts/MessageBackup.ts @@ -55,8 +55,8 @@ export type MessageBackupKeyInput = Readonly< forwardSecrecyToken?: BackupForwardSecrecyToken; } | { - backupKey: BackupKey | Uint8Array; - backupId: Uint8Array; + backupKey: BackupKey | Uint8Array; + backupId: Uint8Array; forwardSecrecyToken?: BackupForwardSecrecyToken; } >; @@ -101,12 +101,12 @@ export class MessageBackupKey { } /** An HMAC key used to sign a backup file. */ - public get hmacKey(): Uint8Array { + public get hmacKey(): Uint8Array { return Native.MessageBackupKey_GetHmacKey(this); } /** An AES-256-CBC key used to encrypt a backup file. */ - public get aesKey(): Uint8Array { + public get aesKey(): Uint8Array { return Native.MessageBackupKey_GetAesKey(this); } } @@ -188,7 +188,7 @@ export class OnlineBackupValidator { * * @throws BackupValidationError on error */ - constructor(backupInfo: Uint8Array, purpose: Purpose) { + constructor(backupInfo: Uint8Array, purpose: Purpose) { this._nativeHandle = Native.OnlineBackupValidator_New(backupInfo, purpose); } @@ -199,7 +199,7 @@ export class OnlineBackupValidator { * * @throws BackupValidationError on error */ - addFrame(frame: Uint8Array): void { + addFrame(frame: Uint8Array): void { Native.OnlineBackupValidator_AddFrame(this, frame); } @@ -318,7 +318,7 @@ export class BackupJsonExporter { * @throws Error if the input is invalid. */ public static start( - backupInfo: Uint8Array, + backupInfo: Uint8Array, options?: { validate?: boolean } ): { exporter: BackupJsonExporter; chunk: string } { const shouldValidate = options?.validate ?? true; @@ -337,7 +337,9 @@ export class BackupJsonExporter { * aborting. * @throws Error if the input data cannot be parsed. */ - public exportFrames(frames: Uint8Array): BackupJsonFrameResult[] { + public exportFrames( + frames: Uint8Array + ): BackupJsonFrameResult[] { return Native.BackupJsonExporter_ExportFrames(this, frames).map( ([line, errorMessage]) => ({ ...(line !== null && { line }), diff --git a/node/ts/Minidump.ts b/node/ts/Minidump.ts index 89c693557..05474cff2 100644 --- a/node/ts/Minidump.ts +++ b/node/ts/Minidump.ts @@ -5,6 +5,6 @@ import * as Native from './Native.js'; -export function toJSONString(buffer: Uint8Array): string { +export function toJSONString(buffer: Uint8Array): string { return Native.MinidumpToJSONString(buffer); } diff --git a/node/ts/Mp4Sanitizer.ts b/node/ts/Mp4Sanitizer.ts index 29e3d01ed..a7c155857 100644 --- a/node/ts/Mp4Sanitizer.ts +++ b/node/ts/Mp4Sanitizer.ts @@ -56,7 +56,7 @@ export class SanitizedMetadata { * Get the sanitized metadata, if any. * @returns The sanitized metadata, or `null` if it didn't need to be sanitized. */ - getMetadata(): Uint8Array | null { + getMetadata(): Uint8Array | null { const metadata = Native.SanitizedMetadata_GetMetadata(this); if (metadata.length == 0) { return null; diff --git a/node/ts/Native.ts b/node/ts/Native.ts index 21f6b3087..95f0452f7 100644 --- a/node/ts/Native.ts +++ b/node/ts/Native.ts @@ -5,7 +5,7 @@ // WARNING: this file was automatically generated -export type Uuid = Uint8Array; +export type Uuid = Uint8Array; /// A Native.Timestamp may be measured in seconds or in milliseconds; /// what's important is that it's an integer less than Number.MAX_SAFE_INTEGER. @@ -28,7 +28,7 @@ export type ChatResponse = { status: number; message: string | undefined; headers: ReadonlyArray<[string, string]>; - body: Uint8Array | undefined; + body: Uint8Array | undefined; }; export type ChatServiceDebugInfo = { @@ -72,11 +72,11 @@ export type SessionStore = BridgeSessionStore; export type SenderKeyStore = BridgeSenderKeyStore; export type InputStream = { - _read: (amount: number) => Promise; + _read: (amount: number) => Promise>; _skip: (amount: number) => Promise; }; -export type SyncInputStream = Uint8Array; +export type SyncInputStream = Uint8Array; export type ChallengeOption = 'pushChallenge' | 'captcha'; @@ -103,8 +103,8 @@ export type CheckSvr2CredentialsResponse = Map< export type SignedPublicPreKey = { keyId: number; - publicKey: Uint8Array; - signature: Uint8Array; + publicKey: Uint8Array; + signature: Uint8Array; }; export type Wrapper = Readonly<{ @@ -128,7 +128,7 @@ export type CancellablePromise = Promise & { }; // eslint-disable-next-line @typescript-eslint/no-unused-vars -export type Serialized = Uint8Array; +export type Serialized = Uint8Array; type ConnectChatBridge = Wrapper; type TestingFutureCancellationGuard = Wrapper; @@ -138,94 +138,94 @@ import load from 'node-gyp-build'; type NativeFunctions = { registerErrors: (errorsModule: Record) => void; initLogger: (maxLevel: LogLevel, callback: (level: LogLevel, target: string, file: string | null, line: number | null, message: string) => void) => void - SealedSenderMultiRecipientMessage_Parse: (buffer: Uint8Array) => SealedSenderMultiRecipientMessage; - MinidumpToJSONString: (buffer: Uint8Array) => string; - Aes256GcmSiv_New: (key: Uint8Array) => Aes256GcmSiv; - Aes256GcmSiv_Encrypt: (aesGcmSivObj: Wrapper, ptext: Uint8Array, nonce: Uint8Array, associatedData: Uint8Array) => Uint8Array; - Aes256GcmSiv_Decrypt: (aesGcmSiv: Wrapper, ctext: Uint8Array, nonce: Uint8Array, associatedData: Uint8Array) => Uint8Array; - PublicKey_HpkeSeal: (pk: Wrapper, plaintext: Uint8Array, info: Uint8Array, associatedData: Uint8Array) => Uint8Array; - PrivateKey_HpkeOpen: (sk: Wrapper, ciphertext: Uint8Array, info: Uint8Array, associatedData: Uint8Array) => Uint8Array; - HKDF_DeriveSecrets: (outputLength: number, ikm: Uint8Array, label: Uint8Array | null, salt: Uint8Array | null) => Uint8Array; - ServiceId_ServiceIdBinary: (value: Uint8Array) => Uint8Array; - ServiceId_ServiceIdString: (value: Uint8Array) => string; - ServiceId_ServiceIdLog: (value: Uint8Array) => string; - ServiceId_ParseFromServiceIdBinary: (input: Uint8Array) => Uint8Array; - ServiceId_ParseFromServiceIdString: (input: string) => Uint8Array; + SealedSenderMultiRecipientMessage_Parse: (buffer: Uint8Array) => SealedSenderMultiRecipientMessage; + MinidumpToJSONString: (buffer: Uint8Array) => string; + Aes256GcmSiv_New: (key: Uint8Array) => Aes256GcmSiv; + Aes256GcmSiv_Encrypt: (aesGcmSivObj: Wrapper, ptext: Uint8Array, nonce: Uint8Array, associatedData: Uint8Array) => Uint8Array; + Aes256GcmSiv_Decrypt: (aesGcmSiv: Wrapper, ctext: Uint8Array, nonce: Uint8Array, associatedData: Uint8Array) => Uint8Array; + PublicKey_HpkeSeal: (pk: Wrapper, plaintext: Uint8Array, info: Uint8Array, associatedData: Uint8Array) => Uint8Array; + PrivateKey_HpkeOpen: (sk: Wrapper, ciphertext: Uint8Array, info: Uint8Array, associatedData: Uint8Array) => Uint8Array; + HKDF_DeriveSecrets: (outputLength: number, ikm: Uint8Array, label: Uint8Array | null, salt: Uint8Array | null) => Uint8Array; + ServiceId_ServiceIdBinary: (value: Uint8Array) => Uint8Array; + ServiceId_ServiceIdString: (value: Uint8Array) => string; + ServiceId_ServiceIdLog: (value: Uint8Array) => string; + ServiceId_ParseFromServiceIdBinary: (input: Uint8Array) => Uint8Array; + ServiceId_ParseFromServiceIdString: (input: string) => Uint8Array; ProtocolAddress_New: (name: string, deviceId: number) => ProtocolAddress; - PublicKey_Deserialize: (data: Uint8Array) => PublicKey; - PublicKey_Serialize: (obj: Wrapper) => Uint8Array; - PublicKey_GetPublicKeyBytes: (obj: Wrapper) => Uint8Array; + PublicKey_Deserialize: (data: Uint8Array) => PublicKey; + PublicKey_Serialize: (obj: Wrapper) => Uint8Array; + PublicKey_GetPublicKeyBytes: (obj: Wrapper) => Uint8Array; ProtocolAddress_DeviceId: (obj: Wrapper) => number; ProtocolAddress_Name: (obj: Wrapper) => string; PublicKey_Equals: (lhs: Wrapper, rhs: Wrapper) => boolean; - PublicKey_Verify: (key: Wrapper, message: Uint8Array, signature: Uint8Array) => boolean; - PrivateKey_Deserialize: (data: Uint8Array) => PrivateKey; - PrivateKey_Serialize: (obj: Wrapper) => Uint8Array; + PublicKey_Verify: (key: Wrapper, message: Uint8Array, signature: Uint8Array) => boolean; + PrivateKey_Deserialize: (data: Uint8Array) => PrivateKey; + PrivateKey_Serialize: (obj: Wrapper) => Uint8Array; PrivateKey_Generate: () => PrivateKey; PrivateKey_GetPublicKey: (k: Wrapper) => PublicKey; - PrivateKey_Sign: (key: Wrapper, message: Uint8Array) => Uint8Array; - PrivateKey_Agree: (privateKey: Wrapper, publicKey: Wrapper) => Uint8Array; - KyberPublicKey_Serialize: (obj: Wrapper) => Uint8Array; - KyberPublicKey_Deserialize: (data: Uint8Array) => KyberPublicKey; - KyberSecretKey_Serialize: (obj: Wrapper) => Uint8Array; - KyberSecretKey_Deserialize: (data: Uint8Array) => KyberSecretKey; + PrivateKey_Sign: (key: Wrapper, message: Uint8Array) => Uint8Array; + PrivateKey_Agree: (privateKey: Wrapper, publicKey: Wrapper) => Uint8Array; + KyberPublicKey_Serialize: (obj: Wrapper) => Uint8Array; + KyberPublicKey_Deserialize: (data: Uint8Array) => KyberPublicKey; + KyberSecretKey_Serialize: (obj: Wrapper) => Uint8Array; + KyberSecretKey_Deserialize: (data: Uint8Array) => KyberSecretKey; KyberPublicKey_Equals: (lhs: Wrapper, rhs: Wrapper) => boolean; KyberKeyPair_Generate: () => KyberKeyPair; KyberKeyPair_GetPublicKey: (keyPair: Wrapper) => KyberPublicKey; KyberKeyPair_GetSecretKey: (keyPair: Wrapper) => KyberSecretKey; - IdentityKeyPair_Serialize: (publicKey: Wrapper, privateKey: Wrapper) => Uint8Array; - IdentityKeyPair_Deserialize: (input: Uint8Array) => [PublicKey, PrivateKey]; - IdentityKeyPair_SignAlternateIdentity: (publicKey: Wrapper, privateKey: Wrapper, otherIdentity: Wrapper) => Uint8Array; - IdentityKey_VerifyAlternateIdentity: (publicKey: Wrapper, otherIdentity: Wrapper, signature: Uint8Array) => boolean; - Fingerprint_New: (iterations: number, version: number, localIdentifier: Uint8Array, localKey: Wrapper, remoteIdentifier: Uint8Array, remoteKey: Wrapper) => Fingerprint; - Fingerprint_ScannableEncoding: (obj: Wrapper) => Uint8Array; + IdentityKeyPair_Serialize: (publicKey: Wrapper, privateKey: Wrapper) => Uint8Array; + IdentityKeyPair_Deserialize: (input: Uint8Array) => [PublicKey, PrivateKey]; + IdentityKeyPair_SignAlternateIdentity: (publicKey: Wrapper, privateKey: Wrapper, otherIdentity: Wrapper) => Uint8Array; + IdentityKey_VerifyAlternateIdentity: (publicKey: Wrapper, otherIdentity: Wrapper, signature: Uint8Array) => boolean; + Fingerprint_New: (iterations: number, version: number, localIdentifier: Uint8Array, localKey: Wrapper, remoteIdentifier: Uint8Array, remoteKey: Wrapper) => Fingerprint; + Fingerprint_ScannableEncoding: (obj: Wrapper) => Uint8Array; Fingerprint_DisplayString: (obj: Wrapper) => string; - ScannableFingerprint_Compare: (fprint1: Uint8Array, fprint2: Uint8Array) => boolean; - SignalMessage_Deserialize: (data: Uint8Array) => SignalMessage; - SignalMessage_GetBody: (obj: Wrapper) => Uint8Array; - SignalMessage_GetSerialized: (obj: Wrapper) => Uint8Array; + ScannableFingerprint_Compare: (fprint1: Uint8Array, fprint2: Uint8Array) => boolean; + SignalMessage_Deserialize: (data: Uint8Array) => SignalMessage; + SignalMessage_GetBody: (obj: Wrapper) => Uint8Array; + SignalMessage_GetSerialized: (obj: Wrapper) => Uint8Array; SignalMessage_GetCounter: (obj: Wrapper) => number; SignalMessage_GetMessageVersion: (obj: Wrapper) => number; - SignalMessage_GetPqRatchet: (msg: Wrapper) => Uint8Array; - SignalMessage_New: (messageVersion: number, macKey: Uint8Array, senderRatchetKey: Wrapper, counter: number, previousCounter: number, ciphertext: Uint8Array, senderIdentityKey: Wrapper, receiverIdentityKey: Wrapper, pqRatchet: Uint8Array) => SignalMessage; - SignalMessage_VerifyMac: (msg: Wrapper, senderIdentityKey: Wrapper, receiverIdentityKey: Wrapper, macKey: Uint8Array) => boolean; + SignalMessage_GetPqRatchet: (msg: Wrapper) => Uint8Array; + SignalMessage_New: (messageVersion: number, macKey: Uint8Array, senderRatchetKey: Wrapper, counter: number, previousCounter: number, ciphertext: Uint8Array, senderIdentityKey: Wrapper, receiverIdentityKey: Wrapper, pqRatchet: Uint8Array) => SignalMessage; + SignalMessage_VerifyMac: (msg: Wrapper, senderIdentityKey: Wrapper, receiverIdentityKey: Wrapper, macKey: Uint8Array) => boolean; PreKeySignalMessage_New: (messageVersion: number, registrationId: number, preKeyId: number | null, signedPreKeyId: number, baseKey: Wrapper, identityKey: Wrapper, signalMessage: Wrapper) => PreKeySignalMessage; - PreKeySignalMessage_Deserialize: (data: Uint8Array) => PreKeySignalMessage; - PreKeySignalMessage_Serialize: (obj: Wrapper) => Uint8Array; + PreKeySignalMessage_Deserialize: (data: Uint8Array) => PreKeySignalMessage; + PreKeySignalMessage_Serialize: (obj: Wrapper) => Uint8Array; PreKeySignalMessage_GetRegistrationId: (obj: Wrapper) => number; PreKeySignalMessage_GetSignedPreKeyId: (obj: Wrapper) => number; PreKeySignalMessage_GetPreKeyId: (obj: Wrapper) => number | null; PreKeySignalMessage_GetVersion: (obj: Wrapper) => number; - SenderKeyMessage_Deserialize: (data: Uint8Array) => SenderKeyMessage; - SenderKeyMessage_GetCipherText: (obj: Wrapper) => Uint8Array; - SenderKeyMessage_Serialize: (obj: Wrapper) => Uint8Array; + SenderKeyMessage_Deserialize: (data: Uint8Array) => SenderKeyMessage; + SenderKeyMessage_GetCipherText: (obj: Wrapper) => Uint8Array; + SenderKeyMessage_Serialize: (obj: Wrapper) => Uint8Array; SenderKeyMessage_GetDistributionId: (obj: Wrapper) => Uuid; SenderKeyMessage_GetChainId: (obj: Wrapper) => number; SenderKeyMessage_GetIteration: (obj: Wrapper) => number; - SenderKeyMessage_New: (messageVersion: number, distributionId: Uuid, chainId: number, iteration: number, ciphertext: Uint8Array, pk: Wrapper) => SenderKeyMessage; + SenderKeyMessage_New: (messageVersion: number, distributionId: Uuid, chainId: number, iteration: number, ciphertext: Uint8Array, pk: Wrapper) => SenderKeyMessage; SenderKeyMessage_VerifySignature: (skm: Wrapper, pubkey: Wrapper) => boolean; - SenderKeyDistributionMessage_Deserialize: (data: Uint8Array) => SenderKeyDistributionMessage; - SenderKeyDistributionMessage_GetChainKey: (obj: Wrapper) => Uint8Array; - SenderKeyDistributionMessage_Serialize: (obj: Wrapper) => Uint8Array; + SenderKeyDistributionMessage_Deserialize: (data: Uint8Array) => SenderKeyDistributionMessage; + SenderKeyDistributionMessage_GetChainKey: (obj: Wrapper) => Uint8Array; + SenderKeyDistributionMessage_Serialize: (obj: Wrapper) => Uint8Array; SenderKeyDistributionMessage_GetDistributionId: (obj: Wrapper) => Uuid; SenderKeyDistributionMessage_GetChainId: (obj: Wrapper) => number; SenderKeyDistributionMessage_GetIteration: (obj: Wrapper) => number; - SenderKeyDistributionMessage_New: (messageVersion: number, distributionId: Uuid, chainId: number, iteration: number, chainkey: Uint8Array, pk: Wrapper) => SenderKeyDistributionMessage; - DecryptionErrorMessage_Deserialize: (data: Uint8Array) => DecryptionErrorMessage; + SenderKeyDistributionMessage_New: (messageVersion: number, distributionId: Uuid, chainId: number, iteration: number, chainkey: Uint8Array, pk: Wrapper) => SenderKeyDistributionMessage; + DecryptionErrorMessage_Deserialize: (data: Uint8Array) => DecryptionErrorMessage; DecryptionErrorMessage_GetTimestamp: (obj: Wrapper) => Timestamp; DecryptionErrorMessage_GetDeviceId: (obj: Wrapper) => number; - DecryptionErrorMessage_Serialize: (obj: Wrapper) => Uint8Array; + DecryptionErrorMessage_Serialize: (obj: Wrapper) => Uint8Array; DecryptionErrorMessage_GetRatchetKey: (m: Wrapper) => PublicKey | null; - DecryptionErrorMessage_ForOriginalMessage: (originalBytes: Uint8Array, originalType: number, originalTimestamp: Timestamp, originalSenderDeviceId: number) => DecryptionErrorMessage; - DecryptionErrorMessage_ExtractFromSerializedContent: (bytes: Uint8Array) => DecryptionErrorMessage; - PlaintextContent_Deserialize: (data: Uint8Array) => PlaintextContent; - PlaintextContent_Serialize: (obj: Wrapper) => Uint8Array; - PlaintextContent_GetBody: (obj: Wrapper) => Uint8Array; + DecryptionErrorMessage_ForOriginalMessage: (originalBytes: Uint8Array, originalType: number, originalTimestamp: Timestamp, originalSenderDeviceId: number) => DecryptionErrorMessage; + DecryptionErrorMessage_ExtractFromSerializedContent: (bytes: Uint8Array) => DecryptionErrorMessage; + PlaintextContent_Deserialize: (data: Uint8Array) => PlaintextContent; + PlaintextContent_Serialize: (obj: Wrapper) => Uint8Array; + PlaintextContent_GetBody: (obj: Wrapper) => Uint8Array; PlaintextContent_FromDecryptionErrorMessage: (m: Wrapper) => PlaintextContent; - PreKeyBundle_New: (registrationId: number, deviceId: number, prekeyId: number | null, prekey: Wrapper | null, signedPrekeyId: number, signedPrekey: Wrapper, signedPrekeySignature: Uint8Array, identityKey: Wrapper, kyberPrekeyId: number, kyberPrekey: Wrapper, kyberPrekeySignature: Uint8Array) => PreKeyBundle; + PreKeyBundle_New: (registrationId: number, deviceId: number, prekeyId: number | null, prekey: Wrapper | null, signedPrekeyId: number, signedPrekey: Wrapper, signedPrekeySignature: Uint8Array, identityKey: Wrapper, kyberPrekeyId: number, kyberPrekey: Wrapper, kyberPrekeySignature: Uint8Array) => PreKeyBundle; PreKeyBundle_GetIdentityKey: (p: Wrapper) => PublicKey; - PreKeyBundle_GetSignedPreKeySignature: (obj: Wrapper) => Uint8Array; - PreKeyBundle_GetKyberPreKeySignature: (obj: Wrapper) => Uint8Array; + PreKeyBundle_GetSignedPreKeySignature: (obj: Wrapper) => Uint8Array; + PreKeyBundle_GetKyberPreKeySignature: (obj: Wrapper) => Uint8Array; PreKeyBundle_GetRegistrationId: (obj: Wrapper) => number; PreKeyBundle_GetDeviceId: (obj: Wrapper) => number; PreKeyBundle_GetSignedPreKeyId: (obj: Wrapper) => number; @@ -234,42 +234,42 @@ type NativeFunctions = { PreKeyBundle_GetPreKeyPublic: (obj: Wrapper) => PublicKey | null; PreKeyBundle_GetSignedPreKeyPublic: (obj: Wrapper) => PublicKey; PreKeyBundle_GetKyberPreKeyPublic: (bundle: Wrapper) => KyberPublicKey; - SignedPreKeyRecord_Deserialize: (data: Uint8Array) => SignedPreKeyRecord; - SignedPreKeyRecord_GetSignature: (obj: Wrapper) => Uint8Array; - SignedPreKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; + SignedPreKeyRecord_Deserialize: (data: Uint8Array) => SignedPreKeyRecord; + SignedPreKeyRecord_GetSignature: (obj: Wrapper) => Uint8Array; + SignedPreKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; SignedPreKeyRecord_GetId: (obj: Wrapper) => number; SignedPreKeyRecord_GetTimestamp: (obj: Wrapper) => Timestamp; SignedPreKeyRecord_GetPublicKey: (obj: Wrapper) => PublicKey; SignedPreKeyRecord_GetPrivateKey: (obj: Wrapper) => PrivateKey; - KyberPreKeyRecord_Deserialize: (data: Uint8Array) => KyberPreKeyRecord; - KyberPreKeyRecord_GetSignature: (obj: Wrapper) => Uint8Array; - KyberPreKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; + KyberPreKeyRecord_Deserialize: (data: Uint8Array) => KyberPreKeyRecord; + KyberPreKeyRecord_GetSignature: (obj: Wrapper) => Uint8Array; + KyberPreKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; KyberPreKeyRecord_GetId: (obj: Wrapper) => number; KyberPreKeyRecord_GetTimestamp: (obj: Wrapper) => Timestamp; KyberPreKeyRecord_GetPublicKey: (obj: Wrapper) => KyberPublicKey; KyberPreKeyRecord_GetSecretKey: (obj: Wrapper) => KyberSecretKey; KyberPreKeyRecord_GetKeyPair: (obj: Wrapper) => KyberKeyPair; - SignedPreKeyRecord_New: (id: number, timestamp: Timestamp, pubKey: Wrapper, privKey: Wrapper, signature: Uint8Array) => SignedPreKeyRecord; - KyberPreKeyRecord_New: (id: number, timestamp: Timestamp, keyPair: Wrapper, signature: Uint8Array) => KyberPreKeyRecord; - PreKeyRecord_Deserialize: (data: Uint8Array) => PreKeyRecord; - PreKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; + SignedPreKeyRecord_New: (id: number, timestamp: Timestamp, pubKey: Wrapper, privKey: Wrapper, signature: Uint8Array) => SignedPreKeyRecord; + KyberPreKeyRecord_New: (id: number, timestamp: Timestamp, keyPair: Wrapper, signature: Uint8Array) => KyberPreKeyRecord; + PreKeyRecord_Deserialize: (data: Uint8Array) => PreKeyRecord; + PreKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; PreKeyRecord_GetId: (obj: Wrapper) => number; PreKeyRecord_GetPublicKey: (obj: Wrapper) => PublicKey; PreKeyRecord_GetPrivateKey: (obj: Wrapper) => PrivateKey; PreKeyRecord_New: (id: number, pubKey: Wrapper, privKey: Wrapper) => PreKeyRecord; - SenderKeyRecord_Deserialize: (data: Uint8Array) => SenderKeyRecord; - SenderKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; - ServerCertificate_Deserialize: (data: Uint8Array) => ServerCertificate; - ServerCertificate_GetSerialized: (obj: Wrapper) => Uint8Array; - ServerCertificate_GetCertificate: (obj: Wrapper) => Uint8Array; - ServerCertificate_GetSignature: (obj: Wrapper) => Uint8Array; + SenderKeyRecord_Deserialize: (data: Uint8Array) => SenderKeyRecord; + SenderKeyRecord_Serialize: (obj: Wrapper) => Uint8Array; + ServerCertificate_Deserialize: (data: Uint8Array) => ServerCertificate; + ServerCertificate_GetSerialized: (obj: Wrapper) => Uint8Array; + ServerCertificate_GetCertificate: (obj: Wrapper) => Uint8Array; + ServerCertificate_GetSignature: (obj: Wrapper) => Uint8Array; ServerCertificate_GetKeyId: (obj: Wrapper) => number; ServerCertificate_GetKey: (obj: Wrapper) => PublicKey; ServerCertificate_New: (keyId: number, serverKey: Wrapper, trustRoot: Wrapper) => ServerCertificate; - SenderCertificate_Deserialize: (data: Uint8Array) => SenderCertificate; - SenderCertificate_GetSerialized: (obj: Wrapper) => Uint8Array; - SenderCertificate_GetCertificate: (obj: Wrapper) => Uint8Array; - SenderCertificate_GetSignature: (obj: Wrapper) => Uint8Array; + SenderCertificate_Deserialize: (data: Uint8Array) => SenderCertificate; + SenderCertificate_GetSerialized: (obj: Wrapper) => Uint8Array; + SenderCertificate_GetCertificate: (obj: Wrapper) => Uint8Array; + SenderCertificate_GetSignature: (obj: Wrapper) => Uint8Array; SenderCertificate_GetSenderUuid: (obj: Wrapper) => string; SenderCertificate_GetSenderE164: (obj: Wrapper) => string | null; SenderCertificate_GetExpiration: (obj: Wrapper) => Timestamp; @@ -278,193 +278,193 @@ type NativeFunctions = { SenderCertificate_Validate: (cert: Wrapper, trustRoots: Wrapper[], time: Timestamp) => boolean; SenderCertificate_GetServerCertificate: (cert: Wrapper) => ServerCertificate; SenderCertificate_New: (senderUuid: string, senderE164: string | null, senderDeviceId: number, senderKey: Wrapper, expiration: Timestamp, signerCert: Wrapper, signerKey: Wrapper) => SenderCertificate; - UnidentifiedSenderMessageContent_Deserialize: (data: Uint8Array) => UnidentifiedSenderMessageContent; - UnidentifiedSenderMessageContent_Serialize: (obj: Wrapper) => Uint8Array; - UnidentifiedSenderMessageContent_GetContents: (obj: Wrapper) => Uint8Array; - UnidentifiedSenderMessageContent_GetGroupId: (obj: Wrapper) => Uint8Array | null; + UnidentifiedSenderMessageContent_Deserialize: (data: Uint8Array) => UnidentifiedSenderMessageContent; + UnidentifiedSenderMessageContent_Serialize: (obj: Wrapper) => Uint8Array; + UnidentifiedSenderMessageContent_GetContents: (obj: Wrapper) => Uint8Array; + UnidentifiedSenderMessageContent_GetGroupId: (obj: Wrapper) => Uint8Array | null; UnidentifiedSenderMessageContent_GetSenderCert: (m: Wrapper) => SenderCertificate; UnidentifiedSenderMessageContent_GetMsgType: (m: Wrapper) => number; UnidentifiedSenderMessageContent_GetContentHint: (m: Wrapper) => number; - UnidentifiedSenderMessageContent_New: (message: Wrapper, sender: Wrapper, contentHint: number, groupId: Uint8Array | null) => UnidentifiedSenderMessageContent; + UnidentifiedSenderMessageContent_New: (message: Wrapper, sender: Wrapper, contentHint: number, groupId: Uint8Array | null) => UnidentifiedSenderMessageContent; CiphertextMessage_Type: (msg: Wrapper) => number; - CiphertextMessage_Serialize: (obj: Wrapper) => Uint8Array; + CiphertextMessage_Serialize: (obj: Wrapper) => Uint8Array; CiphertextMessage_FromPlaintextContent: (m: Wrapper) => CiphertextMessage; SessionRecord_ArchiveCurrentState: (sessionRecord: Wrapper) => void; SessionRecord_HasUsableSenderChain: (s: Wrapper, now: Timestamp) => boolean; SessionRecord_CurrentRatchetKeyMatches: (s: Wrapper, key: Wrapper) => boolean; - SessionRecord_Deserialize: (data: Uint8Array) => SessionRecord; - SessionRecord_Serialize: (obj: Wrapper) => Uint8Array; + SessionRecord_Deserialize: (data: Uint8Array) => SessionRecord; + SessionRecord_Serialize: (obj: Wrapper) => Uint8Array; SessionRecord_GetLocalRegistrationId: (obj: Wrapper) => number; SessionRecord_GetRemoteRegistrationId: (obj: Wrapper) => number; SealedSenderDecryptionResult_GetSenderUuid: (obj: Wrapper) => string; SealedSenderDecryptionResult_GetSenderE164: (obj: Wrapper) => string | null; SealedSenderDecryptionResult_GetDeviceId: (obj: Wrapper) => number; - SealedSenderDecryptionResult_Message: (obj: Wrapper) => Uint8Array; + SealedSenderDecryptionResult_Message: (obj: Wrapper) => Uint8Array; SessionBuilder_ProcessPreKeyBundle: (bundle: Wrapper, protocolAddress: Wrapper, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, now: Timestamp) => Promise; - SessionCipher_EncryptMessage: (ptext: Uint8Array, protocolAddress: Wrapper, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, now: Timestamp) => Promise; - SessionCipher_DecryptSignalMessage: (message: Wrapper, protocolAddress: Wrapper, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore) => Promise; - SessionCipher_DecryptPreKeySignalMessage: (message: Wrapper, protocolAddress: Wrapper, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore) => Promise; - SealedSender_Encrypt: (destination: Wrapper, content: Wrapper, identityKeyStore: IdentityKeyStore) => Promise; - SealedSender_MultiRecipientEncrypt: (recipients: Wrapper[], recipientSessions: Wrapper[], excludedRecipients: Uint8Array, content: Wrapper, identityKeyStore: IdentityKeyStore) => Promise; - SealedSender_MultiRecipientMessageForSingleRecipient: (encodedMultiRecipientMessage: Uint8Array) => Uint8Array; - SealedSender_DecryptToUsmc: (ctext: Uint8Array, identityStore: IdentityKeyStore) => Promise; - SealedSender_DecryptMessage: (message: Uint8Array, trustRoot: Wrapper, timestamp: Timestamp, localE164: string | null, localUuid: string, localDeviceId: number, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore) => Promise; + SessionCipher_EncryptMessage: (ptext: Uint8Array, protocolAddress: Wrapper, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, now: Timestamp) => Promise; + SessionCipher_DecryptSignalMessage: (message: Wrapper, protocolAddress: Wrapper, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore) => Promise>; + SessionCipher_DecryptPreKeySignalMessage: (message: Wrapper, protocolAddress: Wrapper, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore) => Promise>; + SealedSender_Encrypt: (destination: Wrapper, content: Wrapper, identityKeyStore: IdentityKeyStore) => Promise>; + SealedSender_MultiRecipientEncrypt: (recipients: Wrapper[], recipientSessions: Wrapper[], excludedRecipients: Uint8Array, content: Wrapper, identityKeyStore: IdentityKeyStore) => Promise>; + SealedSender_MultiRecipientMessageForSingleRecipient: (encodedMultiRecipientMessage: Uint8Array) => Uint8Array; + SealedSender_DecryptToUsmc: (ctext: Uint8Array, identityStore: IdentityKeyStore) => Promise; + SealedSender_DecryptMessage: (message: Uint8Array, trustRoot: Wrapper, timestamp: Timestamp, localE164: string | null, localUuid: string, localDeviceId: number, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore) => Promise; SenderKeyDistributionMessage_Create: (sender: Wrapper, distributionId: Uuid, store: SenderKeyStore) => Promise; SenderKeyDistributionMessage_Process: (sender: Wrapper, senderKeyDistributionMessage: Wrapper, store: SenderKeyStore) => Promise; - GroupCipher_EncryptMessage: (sender: Wrapper, distributionId: Uuid, message: Uint8Array, store: SenderKeyStore) => Promise; - GroupCipher_DecryptMessage: (sender: Wrapper, message: Uint8Array, store: SenderKeyStore) => Promise; - Cds2ClientState_New: (mrenclave: Uint8Array, attestationMsg: Uint8Array, currentTimestamp: Timestamp) => SgxClientState; - HsmEnclaveClient_New: (trustedPublicKey: Uint8Array, trustedCodeHashes: Uint8Array) => HsmEnclaveClient; - HsmEnclaveClient_CompleteHandshake: (cli: Wrapper, handshakeReceived: Uint8Array) => void; - HsmEnclaveClient_EstablishedSend: (cli: Wrapper, plaintextToSend: Uint8Array) => Uint8Array; - HsmEnclaveClient_EstablishedRecv: (cli: Wrapper, receivedCiphertext: Uint8Array) => Uint8Array; - HsmEnclaveClient_InitialRequest: (obj: Wrapper) => Uint8Array; - SgxClientState_InitialRequest: (obj: Wrapper) => Uint8Array; - SgxClientState_CompleteHandshake: (cli: Wrapper, handshakeReceived: Uint8Array) => void; - SgxClientState_EstablishedSend: (cli: Wrapper, plaintextToSend: Uint8Array) => Uint8Array; - SgxClientState_EstablishedRecv: (cli: Wrapper, receivedCiphertext: Uint8Array) => Uint8Array; - ExpiringProfileKeyCredential_CheckValidContents: (buffer: Uint8Array) => void; - ExpiringProfileKeyCredentialResponse_CheckValidContents: (buffer: Uint8Array) => void; - GroupMasterKey_CheckValidContents: (buffer: Uint8Array) => void; - GroupPublicParams_CheckValidContents: (buffer: Uint8Array) => void; - GroupSecretParams_CheckValidContents: (buffer: Uint8Array) => void; - ProfileKey_CheckValidContents: (buffer: Uint8Array) => void; - ProfileKeyCiphertext_CheckValidContents: (buffer: Uint8Array) => void; - ProfileKeyCommitment_CheckValidContents: (buffer: Uint8Array) => void; - ProfileKeyCredentialRequest_CheckValidContents: (buffer: Uint8Array) => void; - ProfileKeyCredentialRequestContext_CheckValidContents: (buffer: Uint8Array) => void; - ReceiptCredential_CheckValidContents: (buffer: Uint8Array) => void; - ReceiptCredentialPresentation_CheckValidContents: (buffer: Uint8Array) => void; - ReceiptCredentialRequest_CheckValidContents: (buffer: Uint8Array) => void; - ReceiptCredentialRequestContext_CheckValidContents: (buffer: Uint8Array) => void; - ReceiptCredentialResponse_CheckValidContents: (buffer: Uint8Array) => void; - UuidCiphertext_CheckValidContents: (buffer: Uint8Array) => void; - ServerPublicParams_Deserialize: (buffer: Uint8Array) => ServerPublicParams; - ServerPublicParams_Serialize: (handle: Wrapper) => Uint8Array; - ServerSecretParams_Deserialize: (buffer: Uint8Array) => ServerSecretParams; - ServerSecretParams_Serialize: (handle: Wrapper) => Uint8Array; - ProfileKey_GetCommitment: (profileKey: Serialized, userId: Uint8Array) => Serialized; - ProfileKey_GetProfileKeyVersion: (profileKey: Serialized, userId: Uint8Array) => Uint8Array; - ProfileKey_DeriveAccessKey: (profileKey: Serialized) => Uint8Array; - GroupSecretParams_GenerateDeterministic: (randomness: Uint8Array) => Serialized; + GroupCipher_EncryptMessage: (sender: Wrapper, distributionId: Uuid, message: Uint8Array, store: SenderKeyStore) => Promise; + GroupCipher_DecryptMessage: (sender: Wrapper, message: Uint8Array, store: SenderKeyStore) => Promise>; + Cds2ClientState_New: (mrenclave: Uint8Array, attestationMsg: Uint8Array, currentTimestamp: Timestamp) => SgxClientState; + HsmEnclaveClient_New: (trustedPublicKey: Uint8Array, trustedCodeHashes: Uint8Array) => HsmEnclaveClient; + HsmEnclaveClient_CompleteHandshake: (cli: Wrapper, handshakeReceived: Uint8Array) => void; + HsmEnclaveClient_EstablishedSend: (cli: Wrapper, plaintextToSend: Uint8Array) => Uint8Array; + HsmEnclaveClient_EstablishedRecv: (cli: Wrapper, receivedCiphertext: Uint8Array) => Uint8Array; + HsmEnclaveClient_InitialRequest: (obj: Wrapper) => Uint8Array; + SgxClientState_InitialRequest: (obj: Wrapper) => Uint8Array; + SgxClientState_CompleteHandshake: (cli: Wrapper, handshakeReceived: Uint8Array) => void; + SgxClientState_EstablishedSend: (cli: Wrapper, plaintextToSend: Uint8Array) => Uint8Array; + SgxClientState_EstablishedRecv: (cli: Wrapper, receivedCiphertext: Uint8Array) => Uint8Array; + ExpiringProfileKeyCredential_CheckValidContents: (buffer: Uint8Array) => void; + ExpiringProfileKeyCredentialResponse_CheckValidContents: (buffer: Uint8Array) => void; + GroupMasterKey_CheckValidContents: (buffer: Uint8Array) => void; + GroupPublicParams_CheckValidContents: (buffer: Uint8Array) => void; + GroupSecretParams_CheckValidContents: (buffer: Uint8Array) => void; + ProfileKey_CheckValidContents: (buffer: Uint8Array) => void; + ProfileKeyCiphertext_CheckValidContents: (buffer: Uint8Array) => void; + ProfileKeyCommitment_CheckValidContents: (buffer: Uint8Array) => void; + ProfileKeyCredentialRequest_CheckValidContents: (buffer: Uint8Array) => void; + ProfileKeyCredentialRequestContext_CheckValidContents: (buffer: Uint8Array) => void; + ReceiptCredential_CheckValidContents: (buffer: Uint8Array) => void; + ReceiptCredentialPresentation_CheckValidContents: (buffer: Uint8Array) => void; + ReceiptCredentialRequest_CheckValidContents: (buffer: Uint8Array) => void; + ReceiptCredentialRequestContext_CheckValidContents: (buffer: Uint8Array) => void; + ReceiptCredentialResponse_CheckValidContents: (buffer: Uint8Array) => void; + UuidCiphertext_CheckValidContents: (buffer: Uint8Array) => void; + ServerPublicParams_Deserialize: (buffer: Uint8Array) => ServerPublicParams; + ServerPublicParams_Serialize: (handle: Wrapper) => Uint8Array; + ServerSecretParams_Deserialize: (buffer: Uint8Array) => ServerSecretParams; + ServerSecretParams_Serialize: (handle: Wrapper) => Uint8Array; + ProfileKey_GetCommitment: (profileKey: Serialized, userId: Uint8Array) => Serialized; + ProfileKey_GetProfileKeyVersion: (profileKey: Serialized, userId: Uint8Array) => Uint8Array; + ProfileKey_DeriveAccessKey: (profileKey: Serialized) => Uint8Array; + GroupSecretParams_GenerateDeterministic: (randomness: Uint8Array) => Serialized; GroupSecretParams_DeriveFromMasterKey: (masterKey: Serialized) => Serialized; GroupSecretParams_GetMasterKey: (params: Serialized) => Serialized; GroupSecretParams_GetPublicParams: (params: Serialized) => Serialized; - GroupSecretParams_EncryptServiceId: (params: Serialized, serviceId: Uint8Array) => Serialized; - GroupSecretParams_DecryptServiceId: (params: Serialized, ciphertext: Serialized) => Uint8Array; - GroupSecretParams_EncryptProfileKey: (params: Serialized, profileKey: Serialized, userId: Uint8Array) => Serialized; - GroupSecretParams_DecryptProfileKey: (params: Serialized, profileKey: Serialized, userId: Uint8Array) => Serialized; - GroupSecretParams_EncryptBlobWithPaddingDeterministic: (params: Serialized, randomness: Uint8Array, plaintext: Uint8Array, paddingLen: number) => Uint8Array; - GroupSecretParams_DecryptBlobWithPadding: (params: Serialized, ciphertext: Uint8Array) => Uint8Array; - ServerSecretParams_GenerateDeterministic: (randomness: Uint8Array) => ServerSecretParams; + GroupSecretParams_EncryptServiceId: (params: Serialized, serviceId: Uint8Array) => Serialized; + GroupSecretParams_DecryptServiceId: (params: Serialized, ciphertext: Serialized) => Uint8Array; + GroupSecretParams_EncryptProfileKey: (params: Serialized, profileKey: Serialized, userId: Uint8Array) => Serialized; + GroupSecretParams_DecryptProfileKey: (params: Serialized, profileKey: Serialized, userId: Uint8Array) => Serialized; + GroupSecretParams_EncryptBlobWithPaddingDeterministic: (params: Serialized, randomness: Uint8Array, plaintext: Uint8Array, paddingLen: number) => Uint8Array; + GroupSecretParams_DecryptBlobWithPadding: (params: Serialized, ciphertext: Uint8Array) => Uint8Array; + ServerSecretParams_GenerateDeterministic: (randomness: Uint8Array) => ServerSecretParams; ServerSecretParams_GetPublicParams: (params: Wrapper) => ServerPublicParams; - ServerSecretParams_SignDeterministic: (params: Wrapper, randomness: Uint8Array, message: Uint8Array) => Uint8Array; - ServerPublicParams_GetEndorsementPublicKey: (params: Wrapper) => Uint8Array; - ServerPublicParams_ReceiveAuthCredentialWithPniAsServiceId: (params: Wrapper, aci: Uint8Array, pni: Uint8Array, redemptionTime: Timestamp, authCredentialWithPniResponseBytes: Uint8Array) => Uint8Array; - ServerPublicParams_CreateAuthCredentialWithPniPresentationDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, groupSecretParams: Serialized, authCredentialWithPniBytes: Uint8Array) => Uint8Array; - ServerPublicParams_CreateProfileKeyCredentialRequestContextDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, userId: Uint8Array, profileKey: Serialized) => Serialized; + ServerSecretParams_SignDeterministic: (params: Wrapper, randomness: Uint8Array, message: Uint8Array) => Uint8Array; + ServerPublicParams_GetEndorsementPublicKey: (params: Wrapper) => Uint8Array; + ServerPublicParams_ReceiveAuthCredentialWithPniAsServiceId: (params: Wrapper, aci: Uint8Array, pni: Uint8Array, redemptionTime: Timestamp, authCredentialWithPniResponseBytes: Uint8Array) => Uint8Array; + ServerPublicParams_CreateAuthCredentialWithPniPresentationDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, groupSecretParams: Serialized, authCredentialWithPniBytes: Uint8Array) => Uint8Array; + ServerPublicParams_CreateProfileKeyCredentialRequestContextDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, userId: Uint8Array, profileKey: Serialized) => Serialized; ServerPublicParams_ReceiveExpiringProfileKeyCredential: (serverPublicParams: Wrapper, requestContext: Serialized, response: Serialized, currentTimeInSeconds: Timestamp) => Serialized; - ServerPublicParams_CreateExpiringProfileKeyCredentialPresentationDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, groupSecretParams: Serialized, profileKeyCredential: Serialized) => Uint8Array; - ServerPublicParams_CreateReceiptCredentialRequestContextDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, receiptSerial: Uint8Array) => Serialized; + ServerPublicParams_CreateExpiringProfileKeyCredentialPresentationDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, groupSecretParams: Serialized, profileKeyCredential: Serialized) => Uint8Array; + ServerPublicParams_CreateReceiptCredentialRequestContextDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, receiptSerial: Uint8Array) => Serialized; ServerPublicParams_ReceiveReceiptCredential: (serverPublicParams: Wrapper, requestContext: Serialized, response: Serialized) => Serialized; - ServerPublicParams_CreateReceiptCredentialPresentationDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, receiptCredential: Serialized) => Serialized; - ServerSecretParams_IssueAuthCredentialWithPniZkcDeterministic: (serverSecretParams: Wrapper, randomness: Uint8Array, aci: Uint8Array, pni: Uint8Array, redemptionTime: Timestamp) => Uint8Array; - AuthCredentialWithPni_CheckValidContents: (bytes: Uint8Array) => void; - AuthCredentialWithPniResponse_CheckValidContents: (bytes: Uint8Array) => void; - ServerSecretParams_VerifyAuthCredentialPresentation: (serverSecretParams: Wrapper, groupPublicParams: Serialized, presentationBytes: Uint8Array, currentTimeInSeconds: Timestamp) => void; - ServerSecretParams_IssueExpiringProfileKeyCredentialDeterministic: (serverSecretParams: Wrapper, randomness: Uint8Array, request: Serialized, userId: Uint8Array, commitment: Serialized, expirationInSeconds: Timestamp) => Serialized; - ServerSecretParams_VerifyProfileKeyCredentialPresentation: (serverSecretParams: Wrapper, groupPublicParams: Serialized, presentationBytes: Uint8Array, currentTimeInSeconds: Timestamp) => void; - ServerSecretParams_IssueReceiptCredentialDeterministic: (serverSecretParams: Wrapper, randomness: Uint8Array, request: Serialized, receiptExpirationTime: Timestamp, receiptLevel: bigint) => Serialized; + ServerPublicParams_CreateReceiptCredentialPresentationDeterministic: (serverPublicParams: Wrapper, randomness: Uint8Array, receiptCredential: Serialized) => Serialized; + ServerSecretParams_IssueAuthCredentialWithPniZkcDeterministic: (serverSecretParams: Wrapper, randomness: Uint8Array, aci: Uint8Array, pni: Uint8Array, redemptionTime: Timestamp) => Uint8Array; + AuthCredentialWithPni_CheckValidContents: (bytes: Uint8Array) => void; + AuthCredentialWithPniResponse_CheckValidContents: (bytes: Uint8Array) => void; + ServerSecretParams_VerifyAuthCredentialPresentation: (serverSecretParams: Wrapper, groupPublicParams: Serialized, presentationBytes: Uint8Array, currentTimeInSeconds: Timestamp) => void; + ServerSecretParams_IssueExpiringProfileKeyCredentialDeterministic: (serverSecretParams: Wrapper, randomness: Uint8Array, request: Serialized, userId: Uint8Array, commitment: Serialized, expirationInSeconds: Timestamp) => Serialized; + ServerSecretParams_VerifyProfileKeyCredentialPresentation: (serverSecretParams: Wrapper, groupPublicParams: Serialized, presentationBytes: Uint8Array, currentTimeInSeconds: Timestamp) => void; + ServerSecretParams_IssueReceiptCredentialDeterministic: (serverSecretParams: Wrapper, randomness: Uint8Array, request: Serialized, receiptExpirationTime: Timestamp, receiptLevel: bigint) => Serialized; ServerSecretParams_VerifyReceiptCredentialPresentation: (serverSecretParams: Wrapper, presentation: Serialized) => void; - GroupPublicParams_GetGroupIdentifier: (groupPublicParams: Serialized) => Uint8Array; - ServerPublicParams_VerifySignature: (serverPublicParams: Wrapper, message: Uint8Array, notarySignature: Uint8Array) => void; - AuthCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; - AuthCredentialPresentation_GetUuidCiphertext: (presentationBytes: Uint8Array) => Serialized; - AuthCredentialPresentation_GetPniCiphertext: (presentationBytes: Uint8Array) => Serialized; - AuthCredentialPresentation_GetRedemptionTime: (presentationBytes: Uint8Array) => Timestamp; + GroupPublicParams_GetGroupIdentifier: (groupPublicParams: Serialized) => Uint8Array; + ServerPublicParams_VerifySignature: (serverPublicParams: Wrapper, message: Uint8Array, notarySignature: Uint8Array) => void; + AuthCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; + AuthCredentialPresentation_GetUuidCiphertext: (presentationBytes: Uint8Array) => Serialized; + AuthCredentialPresentation_GetPniCiphertext: (presentationBytes: Uint8Array) => Serialized; + AuthCredentialPresentation_GetRedemptionTime: (presentationBytes: Uint8Array) => Timestamp; ProfileKeyCredentialRequestContext_GetRequest: (context: Serialized) => Serialized; ExpiringProfileKeyCredential_GetExpirationTime: (credential: Serialized) => Timestamp; - ProfileKeyCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; - ProfileKeyCredentialPresentation_GetUuidCiphertext: (presentationBytes: Uint8Array) => Serialized; - ProfileKeyCredentialPresentation_GetProfileKeyCiphertext: (presentationBytes: Uint8Array) => Serialized; + ProfileKeyCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; + ProfileKeyCredentialPresentation_GetUuidCiphertext: (presentationBytes: Uint8Array) => Serialized; + ProfileKeyCredentialPresentation_GetProfileKeyCiphertext: (presentationBytes: Uint8Array) => Serialized; ReceiptCredentialRequestContext_GetRequest: (requestContext: Serialized) => Serialized; ReceiptCredential_GetReceiptExpirationTime: (receiptCredential: Serialized) => Timestamp; ReceiptCredential_GetReceiptLevel: (receiptCredential: Serialized) => bigint; ReceiptCredentialPresentation_GetReceiptExpirationTime: (presentation: Serialized) => Timestamp; ReceiptCredentialPresentation_GetReceiptLevel: (presentation: Serialized) => bigint; - ReceiptCredentialPresentation_GetReceiptSerial: (presentation: Serialized) => Uint8Array; - GenericServerSecretParams_CheckValidContents: (paramsBytes: Uint8Array) => void; - GenericServerSecretParams_GenerateDeterministic: (randomness: Uint8Array) => Uint8Array; - GenericServerSecretParams_GetPublicParams: (paramsBytes: Uint8Array) => Uint8Array; - GenericServerPublicParams_CheckValidContents: (paramsBytes: Uint8Array) => void; - CallLinkSecretParams_CheckValidContents: (paramsBytes: Uint8Array) => void; - CallLinkSecretParams_DeriveFromRootKey: (rootKey: Uint8Array) => Uint8Array; - CallLinkSecretParams_GetPublicParams: (paramsBytes: Uint8Array) => Uint8Array; - CallLinkSecretParams_DecryptUserId: (paramsBytes: Uint8Array, userId: Serialized) => Uint8Array; - CallLinkSecretParams_EncryptUserId: (paramsBytes: Uint8Array, userId: Uint8Array) => Serialized; - CallLinkPublicParams_CheckValidContents: (paramsBytes: Uint8Array) => void; - CreateCallLinkCredentialRequestContext_CheckValidContents: (contextBytes: Uint8Array) => void; - CreateCallLinkCredentialRequestContext_NewDeterministic: (roomId: Uint8Array, randomness: Uint8Array) => Uint8Array; - CreateCallLinkCredentialRequestContext_GetRequest: (contextBytes: Uint8Array) => Uint8Array; - CreateCallLinkCredentialRequest_CheckValidContents: (requestBytes: Uint8Array) => void; - CreateCallLinkCredentialRequest_IssueDeterministic: (requestBytes: Uint8Array, userId: Uint8Array, timestamp: Timestamp, paramsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; - CreateCallLinkCredentialResponse_CheckValidContents: (responseBytes: Uint8Array) => void; - CreateCallLinkCredentialRequestContext_ReceiveResponse: (contextBytes: Uint8Array, responseBytes: Uint8Array, userId: Uint8Array, paramsBytes: Uint8Array) => Uint8Array; - CreateCallLinkCredential_CheckValidContents: (paramsBytes: Uint8Array) => void; - CreateCallLinkCredential_PresentDeterministic: (credentialBytes: Uint8Array, roomId: Uint8Array, userId: Uint8Array, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; - CreateCallLinkCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; - CreateCallLinkCredentialPresentation_Verify: (presentationBytes: Uint8Array, roomId: Uint8Array, now: Timestamp, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array) => void; - CallLinkAuthCredentialResponse_CheckValidContents: (responseBytes: Uint8Array) => void; - CallLinkAuthCredentialResponse_IssueDeterministic: (userId: Uint8Array, redemptionTime: Timestamp, paramsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; - CallLinkAuthCredentialResponse_Receive: (responseBytes: Uint8Array, userId: Uint8Array, redemptionTime: Timestamp, paramsBytes: Uint8Array) => Uint8Array; - CallLinkAuthCredential_CheckValidContents: (credentialBytes: Uint8Array) => void; - CallLinkAuthCredential_PresentDeterministic: (credentialBytes: Uint8Array, userId: Uint8Array, redemptionTime: Timestamp, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; - CallLinkAuthCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; - CallLinkAuthCredentialPresentation_Verify: (presentationBytes: Uint8Array, now: Timestamp, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array) => void; - CallLinkAuthCredentialPresentation_GetUserId: (presentationBytes: Uint8Array) => Serialized; - BackupAuthCredentialRequestContext_New: (backupKey: Uint8Array, uuid: Uuid) => Uint8Array; - BackupAuthCredentialRequestContext_CheckValidContents: (contextBytes: Uint8Array) => void; - BackupAuthCredentialRequestContext_GetRequest: (contextBytes: Uint8Array) => Uint8Array; - BackupAuthCredentialRequest_CheckValidContents: (requestBytes: Uint8Array) => void; - BackupAuthCredentialRequest_IssueDeterministic: (requestBytes: Uint8Array, redemptionTime: Timestamp, backupLevel: number, credentialType: number, paramsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; - BackupAuthCredentialResponse_CheckValidContents: (responseBytes: Uint8Array) => void; - BackupAuthCredentialRequestContext_ReceiveResponse: (contextBytes: Uint8Array, responseBytes: Uint8Array, expectedRedemptionTime: Timestamp, paramsBytes: Uint8Array) => Uint8Array; - BackupAuthCredential_CheckValidContents: (paramsBytes: Uint8Array) => void; - BackupAuthCredential_GetBackupId: (credentialBytes: Uint8Array) => Uint8Array; - BackupAuthCredential_GetBackupLevel: (credentialBytes: Uint8Array) => number; - BackupAuthCredential_GetType: (credentialBytes: Uint8Array) => number; - BackupAuthCredential_PresentDeterministic: (credentialBytes: Uint8Array, serverParamsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; - BackupAuthCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; - BackupAuthCredentialPresentation_Verify: (presentationBytes: Uint8Array, now: Timestamp, serverParamsBytes: Uint8Array) => void; - BackupAuthCredentialPresentation_GetBackupId: (presentationBytes: Uint8Array) => Uint8Array; - BackupAuthCredentialPresentation_GetBackupLevel: (presentationBytes: Uint8Array) => number; - BackupAuthCredentialPresentation_GetType: (presentationBytes: Uint8Array) => number; - GroupSendDerivedKeyPair_CheckValidContents: (bytes: Uint8Array) => void; - GroupSendDerivedKeyPair_ForExpiration: (expiration: Timestamp, serverParams: Wrapper) => Uint8Array; - GroupSendEndorsementsResponse_CheckValidContents: (bytes: Uint8Array) => void; - GroupSendEndorsementsResponse_IssueDeterministic: (concatenatedGroupMemberCiphertexts: Uint8Array, keyPair: Uint8Array, randomness: Uint8Array) => Uint8Array; - GroupSendEndorsementsResponse_GetExpiration: (responseBytes: Uint8Array) => Timestamp; - GroupSendEndorsementsResponse_ReceiveAndCombineWithServiceIds: (responseBytes: Uint8Array, groupMembers: Uint8Array, localUser: Uint8Array, now: Timestamp, groupParams: Serialized, serverParams: Wrapper) => Uint8Array[]; - GroupSendEndorsementsResponse_ReceiveAndCombineWithCiphertexts: (responseBytes: Uint8Array, concatenatedGroupMemberCiphertexts: Uint8Array, localUserCiphertext: Uint8Array, now: Timestamp, serverParams: Wrapper) => Uint8Array[]; - GroupSendEndorsement_CheckValidContents: (bytes: Uint8Array) => void; - GroupSendEndorsement_Combine: (endorsements: Uint8Array[]) => Uint8Array; - GroupSendEndorsement_Remove: (endorsement: Uint8Array, toRemove: Uint8Array) => Uint8Array; - GroupSendEndorsement_ToToken: (endorsement: Uint8Array, groupParams: Serialized) => Uint8Array; - GroupSendEndorsement_CallLinkParams_ToToken: (endorsement: Uint8Array, callLinkSecretParamsSerialized: Uint8Array) => Uint8Array; - GroupSendToken_CheckValidContents: (bytes: Uint8Array) => void; - GroupSendToken_ToFullToken: (token: Uint8Array, expiration: Timestamp) => Uint8Array; - GroupSendFullToken_CheckValidContents: (bytes: Uint8Array) => void; - GroupSendFullToken_GetExpiration: (token: Uint8Array) => Timestamp; - GroupSendFullToken_Verify: (token: Uint8Array, userIds: Uint8Array, now: Timestamp, keyPair: Uint8Array) => void; + ReceiptCredentialPresentation_GetReceiptSerial: (presentation: Serialized) => Uint8Array; + GenericServerSecretParams_CheckValidContents: (paramsBytes: Uint8Array) => void; + GenericServerSecretParams_GenerateDeterministic: (randomness: Uint8Array) => Uint8Array; + GenericServerSecretParams_GetPublicParams: (paramsBytes: Uint8Array) => Uint8Array; + GenericServerPublicParams_CheckValidContents: (paramsBytes: Uint8Array) => void; + CallLinkSecretParams_CheckValidContents: (paramsBytes: Uint8Array) => void; + CallLinkSecretParams_DeriveFromRootKey: (rootKey: Uint8Array) => Uint8Array; + CallLinkSecretParams_GetPublicParams: (paramsBytes: Uint8Array) => Uint8Array; + CallLinkSecretParams_DecryptUserId: (paramsBytes: Uint8Array, userId: Serialized) => Uint8Array; + CallLinkSecretParams_EncryptUserId: (paramsBytes: Uint8Array, userId: Uint8Array) => Serialized; + CallLinkPublicParams_CheckValidContents: (paramsBytes: Uint8Array) => void; + CreateCallLinkCredentialRequestContext_CheckValidContents: (contextBytes: Uint8Array) => void; + CreateCallLinkCredentialRequestContext_NewDeterministic: (roomId: Uint8Array, randomness: Uint8Array) => Uint8Array; + CreateCallLinkCredentialRequestContext_GetRequest: (contextBytes: Uint8Array) => Uint8Array; + CreateCallLinkCredentialRequest_CheckValidContents: (requestBytes: Uint8Array) => void; + CreateCallLinkCredentialRequest_IssueDeterministic: (requestBytes: Uint8Array, userId: Uint8Array, timestamp: Timestamp, paramsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; + CreateCallLinkCredentialResponse_CheckValidContents: (responseBytes: Uint8Array) => void; + CreateCallLinkCredentialRequestContext_ReceiveResponse: (contextBytes: Uint8Array, responseBytes: Uint8Array, userId: Uint8Array, paramsBytes: Uint8Array) => Uint8Array; + CreateCallLinkCredential_CheckValidContents: (paramsBytes: Uint8Array) => void; + CreateCallLinkCredential_PresentDeterministic: (credentialBytes: Uint8Array, roomId: Uint8Array, userId: Uint8Array, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; + CreateCallLinkCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; + CreateCallLinkCredentialPresentation_Verify: (presentationBytes: Uint8Array, roomId: Uint8Array, now: Timestamp, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array) => void; + CallLinkAuthCredentialResponse_CheckValidContents: (responseBytes: Uint8Array) => void; + CallLinkAuthCredentialResponse_IssueDeterministic: (userId: Uint8Array, redemptionTime: Timestamp, paramsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; + CallLinkAuthCredentialResponse_Receive: (responseBytes: Uint8Array, userId: Uint8Array, redemptionTime: Timestamp, paramsBytes: Uint8Array) => Uint8Array; + CallLinkAuthCredential_CheckValidContents: (credentialBytes: Uint8Array) => void; + CallLinkAuthCredential_PresentDeterministic: (credentialBytes: Uint8Array, userId: Uint8Array, redemptionTime: Timestamp, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; + CallLinkAuthCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; + CallLinkAuthCredentialPresentation_Verify: (presentationBytes: Uint8Array, now: Timestamp, serverParamsBytes: Uint8Array, callLinkParamsBytes: Uint8Array) => void; + CallLinkAuthCredentialPresentation_GetUserId: (presentationBytes: Uint8Array) => Serialized; + BackupAuthCredentialRequestContext_New: (backupKey: Uint8Array, uuid: Uuid) => Uint8Array; + BackupAuthCredentialRequestContext_CheckValidContents: (contextBytes: Uint8Array) => void; + BackupAuthCredentialRequestContext_GetRequest: (contextBytes: Uint8Array) => Uint8Array; + BackupAuthCredentialRequest_CheckValidContents: (requestBytes: Uint8Array) => void; + BackupAuthCredentialRequest_IssueDeterministic: (requestBytes: Uint8Array, redemptionTime: Timestamp, backupLevel: number, credentialType: number, paramsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; + BackupAuthCredentialResponse_CheckValidContents: (responseBytes: Uint8Array) => void; + BackupAuthCredentialRequestContext_ReceiveResponse: (contextBytes: Uint8Array, responseBytes: Uint8Array, expectedRedemptionTime: Timestamp, paramsBytes: Uint8Array) => Uint8Array; + BackupAuthCredential_CheckValidContents: (paramsBytes: Uint8Array) => void; + BackupAuthCredential_GetBackupId: (credentialBytes: Uint8Array) => Uint8Array; + BackupAuthCredential_GetBackupLevel: (credentialBytes: Uint8Array) => number; + BackupAuthCredential_GetType: (credentialBytes: Uint8Array) => number; + BackupAuthCredential_PresentDeterministic: (credentialBytes: Uint8Array, serverParamsBytes: Uint8Array, randomness: Uint8Array) => Uint8Array; + BackupAuthCredentialPresentation_CheckValidContents: (presentationBytes: Uint8Array) => void; + BackupAuthCredentialPresentation_Verify: (presentationBytes: Uint8Array, now: Timestamp, serverParamsBytes: Uint8Array) => void; + BackupAuthCredentialPresentation_GetBackupId: (presentationBytes: Uint8Array) => Uint8Array; + BackupAuthCredentialPresentation_GetBackupLevel: (presentationBytes: Uint8Array) => number; + BackupAuthCredentialPresentation_GetType: (presentationBytes: Uint8Array) => number; + GroupSendDerivedKeyPair_CheckValidContents: (bytes: Uint8Array) => void; + GroupSendDerivedKeyPair_ForExpiration: (expiration: Timestamp, serverParams: Wrapper) => Uint8Array; + GroupSendEndorsementsResponse_CheckValidContents: (bytes: Uint8Array) => void; + GroupSendEndorsementsResponse_IssueDeterministic: (concatenatedGroupMemberCiphertexts: Uint8Array, keyPair: Uint8Array, randomness: Uint8Array) => Uint8Array; + GroupSendEndorsementsResponse_GetExpiration: (responseBytes: Uint8Array) => Timestamp; + GroupSendEndorsementsResponse_ReceiveAndCombineWithServiceIds: (responseBytes: Uint8Array, groupMembers: Uint8Array, localUser: Uint8Array, now: Timestamp, groupParams: Serialized, serverParams: Wrapper) => Uint8Array[]; + GroupSendEndorsementsResponse_ReceiveAndCombineWithCiphertexts: (responseBytes: Uint8Array, concatenatedGroupMemberCiphertexts: Uint8Array, localUserCiphertext: Uint8Array, now: Timestamp, serverParams: Wrapper) => Uint8Array[]; + GroupSendEndorsement_CheckValidContents: (bytes: Uint8Array) => void; + GroupSendEndorsement_Combine: (endorsements: Uint8Array[]) => Uint8Array; + GroupSendEndorsement_Remove: (endorsement: Uint8Array, toRemove: Uint8Array) => Uint8Array; + GroupSendEndorsement_ToToken: (endorsement: Uint8Array, groupParams: Serialized) => Uint8Array; + GroupSendEndorsement_CallLinkParams_ToToken: (endorsement: Uint8Array, callLinkSecretParamsSerialized: Uint8Array) => Uint8Array; + GroupSendToken_CheckValidContents: (bytes: Uint8Array) => void; + GroupSendToken_ToFullToken: (token: Uint8Array, expiration: Timestamp) => Uint8Array; + GroupSendFullToken_CheckValidContents: (bytes: Uint8Array) => void; + GroupSendFullToken_GetExpiration: (token: Uint8Array) => Timestamp; + GroupSendFullToken_Verify: (token: Uint8Array, userIds: Uint8Array, now: Timestamp, keyPair: Uint8Array) => void; LookupRequest_new: () => LookupRequest; LookupRequest_addE164: (request: Wrapper, e164: string) => void; LookupRequest_addPreviousE164: (request: Wrapper, e164: string) => void; - LookupRequest_setToken: (request: Wrapper, token: Uint8Array) => void; - LookupRequest_addAciAndAccessKey: (request: Wrapper, aci: Uint8Array, accessKey: Uint8Array) => void; + LookupRequest_setToken: (request: Wrapper, token: Uint8Array) => void; + LookupRequest_addAciAndAccessKey: (request: Wrapper, aci: Uint8Array, accessKey: Uint8Array) => void; CdsiLookup_new: (asyncRuntime: Wrapper, connectionManager: Wrapper, username: string, password: string, request: Wrapper) => CancellablePromise; - CdsiLookup_token: (lookup: Wrapper) => Uint8Array; + CdsiLookup_token: (lookup: Wrapper) => Uint8Array; CdsiLookup_complete: (asyncRuntime: Wrapper, lookup: Wrapper) => CancellablePromise; - HttpRequest_new: (method: string, path: string, bodyAsSlice: Uint8Array | null) => HttpRequest; + HttpRequest_new: (method: string, path: string, bodyAsSlice: Uint8Array | null) => HttpRequest; HttpRequest_add_header: (request: Wrapper, name: string, value: string) => void; ChatConnectionInfo_local_port: (connectionInfo: Wrapper) => number; ChatConnectionInfo_ip_version: (connectionInfo: Wrapper) => number; @@ -474,9 +474,9 @@ type NativeFunctions = { UnauthenticatedChatConnection_send: (asyncRuntime: Wrapper, chat: Wrapper, httpRequest: Wrapper, timeoutMillis: number) => CancellablePromise; UnauthenticatedChatConnection_disconnect: (asyncRuntime: Wrapper, chat: Wrapper) => CancellablePromise; UnauthenticatedChatConnection_info: (chat: Wrapper) => ChatConnectionInfo; - UnauthenticatedChatConnection_look_up_username_hash: (asyncRuntime: Wrapper, chat: Wrapper, hash: Uint8Array) => CancellablePromise; - UnauthenticatedChatConnection_look_up_username_link: (asyncRuntime: Wrapper, chat: Wrapper, uuid: Uuid, entropy: Uint8Array) => CancellablePromise<[string, Uint8Array] | null>; - UnauthenticatedChatConnection_send_multi_recipient_message: (asyncRuntime: Wrapper, chat: Wrapper, payload: Uint8Array, timestamp: Timestamp, auth: Uint8Array|null, onlineOnly: boolean, isUrgent: boolean) => CancellablePromise; + UnauthenticatedChatConnection_look_up_username_hash: (asyncRuntime: Wrapper, chat: Wrapper, hash: Uint8Array) => CancellablePromise; + UnauthenticatedChatConnection_look_up_username_link: (asyncRuntime: Wrapper, chat: Wrapper, uuid: Uuid, entropy: Uint8Array) => CancellablePromise<[string, Uint8Array] | null>; + UnauthenticatedChatConnection_send_multi_recipient_message: (asyncRuntime: Wrapper, chat: Wrapper, payload: Uint8Array, timestamp: Timestamp, auth: Uint8Array | null, onlineOnly: boolean, isUrgent: boolean) => CancellablePromise[]>; AuthenticatedChatConnection_preconnect: (asyncRuntime: Wrapper, connectionManager: Wrapper) => CancellablePromise; AuthenticatedChatConnection_connect: (asyncRuntime: Wrapper, connectionManager: Wrapper, username: string, password: string, receiveStories: boolean, languages: string[]) => CancellablePromise; AuthenticatedChatConnection_init_listener: (chat: Wrapper, listener: ChatListener) => void; @@ -488,13 +488,13 @@ type NativeFunctions = { ProvisioningChatConnection_init_listener: (chat: Wrapper, listener: ProvisioningListener) => void; ProvisioningChatConnection_info: (chat: Wrapper) => ChatConnectionInfo; ProvisioningChatConnection_disconnect: (asyncRuntime: Wrapper, chat: Wrapper) => CancellablePromise; - KeyTransparency_AciSearchKey: (aci: Uint8Array) => Uint8Array; - KeyTransparency_E164SearchKey: (e164: string) => Uint8Array; - KeyTransparency_UsernameHashSearchKey: (hash: Uint8Array) => Uint8Array; - KeyTransparency_Search: (asyncRuntime: Wrapper, environment: number, chatConnection: Wrapper, aci: Uint8Array, aciIdentityKey: Wrapper, e164: string | null, unidentifiedAccessKey: Uint8Array | null, usernameHash: Uint8Array | null, accountData: Uint8Array | null, lastDistinguishedTreeHead: Uint8Array) => CancellablePromise; - KeyTransparency_Monitor: (asyncRuntime: Wrapper, environment: number, chatConnection: Wrapper, aci: Uint8Array, aciIdentityKey: Wrapper, e164: string | null, unidentifiedAccessKey: Uint8Array | null, usernameHash: Uint8Array | null, accountData: Uint8Array | null, lastDistinguishedTreeHead: Uint8Array, isSelfMonitor: boolean) => CancellablePromise; - KeyTransparency_Distinguished: (asyncRuntime: Wrapper, environment: number, chatConnection: Wrapper, lastDistinguishedTreeHead: Uint8Array | null) => CancellablePromise; - UnauthenticatedChatConnection_account_exists: (asyncRuntime: Wrapper, chat: Wrapper, account: Uint8Array) => CancellablePromise; + KeyTransparency_AciSearchKey: (aci: Uint8Array) => Uint8Array; + KeyTransparency_E164SearchKey: (e164: string) => Uint8Array; + KeyTransparency_UsernameHashSearchKey: (hash: Uint8Array) => Uint8Array; + KeyTransparency_Search: (asyncRuntime: Wrapper, environment: number, chatConnection: Wrapper, aci: Uint8Array, aciIdentityKey: Wrapper, e164: string | null, unidentifiedAccessKey: Uint8Array | null, usernameHash: Uint8Array | null, accountData: Uint8Array | null, lastDistinguishedTreeHead: Uint8Array) => CancellablePromise>; + KeyTransparency_Monitor: (asyncRuntime: Wrapper, environment: number, chatConnection: Wrapper, aci: Uint8Array, aciIdentityKey: Wrapper, e164: string | null, unidentifiedAccessKey: Uint8Array | null, usernameHash: Uint8Array | null, accountData: Uint8Array | null, lastDistinguishedTreeHead: Uint8Array, isSelfMonitor: boolean) => CancellablePromise>; + KeyTransparency_Distinguished: (asyncRuntime: Wrapper, environment: number, chatConnection: Wrapper, lastDistinguishedTreeHead: Uint8Array | null) => CancellablePromise>; + UnauthenticatedChatConnection_account_exists: (asyncRuntime: Wrapper, chat: Wrapper, account: Uint8Array) => CancellablePromise; RegistrationService_CreateSession: (asyncRuntime: Wrapper, createSession: RegistrationCreateSessionRequest, connectChat: ConnectChatBridge) => CancellablePromise; RegistrationService_ResumeSession: (asyncRuntime: Wrapper, sessionId: string, number: string, connectChat: ConnectChatBridge) => CancellablePromise; RegistrationService_RequestVerificationCode: (asyncRuntime: Wrapper, service: Wrapper, transport: string, client: string, languages: string[]) => CancellablePromise; @@ -517,25 +517,25 @@ type NativeFunctions = { RegisterAccountRequest_SetIdentityPublicKey: (registerAccount: Wrapper, identityType: number, identityKey: Wrapper) => void; RegisterAccountRequest_SetIdentitySignedPreKey: (registerAccount: Wrapper, identityType: number, signedPreKey: SignedPublicPreKey) => void; RegisterAccountRequest_SetIdentityPqLastResortPreKey: (registerAccount: Wrapper, identityType: number, pqLastResortPreKey: SignedPublicPreKey) => void; - RegistrationAccountAttributes_Create: (recoveryPassword: Uint8Array, aciRegistrationId: number, pniRegistrationId: number, registrationLock: string | null, unidentifiedAccessKey: Uint8Array, unrestrictedUnidentifiedAccess: boolean, capabilities: string[], discoverableByPhoneNumber: boolean) => RegistrationAccountAttributes; - RegisterAccountResponse_GetIdentity: (response: Wrapper, identityType: number) => Uint8Array; + RegistrationAccountAttributes_Create: (recoveryPassword: Uint8Array, aciRegistrationId: number, pniRegistrationId: number, registrationLock: string | null, unidentifiedAccessKey: Uint8Array, unrestrictedUnidentifiedAccess: boolean, capabilities: string[], discoverableByPhoneNumber: boolean) => RegistrationAccountAttributes; + RegisterAccountResponse_GetIdentity: (response: Wrapper, identityType: number) => Uint8Array; RegisterAccountResponse_GetNumber: (response: Wrapper) => string; - RegisterAccountResponse_GetUsernameHash: (response: Wrapper) => Uint8Array | null; + RegisterAccountResponse_GetUsernameHash: (response: Wrapper) => Uint8Array | null; RegisterAccountResponse_GetUsernameLinkHandle: (response: Wrapper) => Uuid | null; RegisterAccountResponse_GetStorageCapable: (response: Wrapper) => boolean; RegisterAccountResponse_GetReregistration: (response: Wrapper) => boolean; RegisterAccountResponse_GetEntitlementBadges: (response: Wrapper) => RegisterResponseBadge[]; RegisterAccountResponse_GetEntitlementBackupLevel: (response: Wrapper) => bigint | null; RegisterAccountResponse_GetEntitlementBackupExpirationSeconds: (response: Wrapper) => bigint | null; - SecureValueRecoveryForBackups_CreateNewBackupChain: (environment: number, backupKey: Uint8Array) => Uint8Array; - SecureValueRecoveryForBackups_StoreBackup: (asyncRuntime: Wrapper, backupKey: Uint8Array, previousSecretData: Uint8Array, connectionManager: Wrapper, username: string, password: string) => CancellablePromise; - SecureValueRecoveryForBackups_RestoreBackupFromServer: (asyncRuntime: Wrapper, backupKey: Uint8Array, metadata: Uint8Array, connectionManager: Wrapper, username: string, password: string) => CancellablePromise; + SecureValueRecoveryForBackups_CreateNewBackupChain: (environment: number, backupKey: Uint8Array) => Uint8Array; + SecureValueRecoveryForBackups_StoreBackup: (asyncRuntime: Wrapper, backupKey: Uint8Array, previousSecretData: Uint8Array, connectionManager: Wrapper, username: string, password: string) => CancellablePromise; + SecureValueRecoveryForBackups_RestoreBackupFromServer: (asyncRuntime: Wrapper, backupKey: Uint8Array, metadata: Uint8Array, connectionManager: Wrapper, username: string, password: string) => CancellablePromise; SecureValueRecoveryForBackups_RemoveBackup: (asyncRuntime: Wrapper, connectionManager: Wrapper, username: string, password: string) => CancellablePromise; - BackupStoreResponse_GetForwardSecrecyToken: (response: Wrapper) => Uint8Array; - BackupStoreResponse_GetOpaqueMetadata: (response: Wrapper) => Uint8Array; - BackupStoreResponse_GetNextBackupSecretData: (response: Wrapper) => Uint8Array; - BackupRestoreResponse_GetForwardSecrecyToken: (response: Wrapper) => Uint8Array; - BackupRestoreResponse_GetNextBackupSecretData: (response: Wrapper) => Uint8Array; + BackupStoreResponse_GetForwardSecrecyToken: (response: Wrapper) => Uint8Array; + BackupStoreResponse_GetOpaqueMetadata: (response: Wrapper) => Uint8Array; + BackupStoreResponse_GetNextBackupSecretData: (response: Wrapper) => Uint8Array; + BackupRestoreResponse_GetForwardSecrecyToken: (response: Wrapper) => Uint8Array; + BackupRestoreResponse_GetNextBackupSecretData: (response: Wrapper) => Uint8Array; TokioAsyncContext_new: () => TokioAsyncContext; TokioAsyncContext_cancel: (context: Wrapper, rawCancellationId: bigint) => void; ConnectionProxyConfig_new: (scheme: string, host: string, port: number, username: string | null, password: string | null) => ConnectionProxyConfig; @@ -549,51 +549,51 @@ type NativeFunctions = { ConnectionManager_on_network_change: (connectionManager: Wrapper) => void; AccountEntropyPool_Generate: () => string; AccountEntropyPool_IsValid: (accountEntropy: string) => boolean; - AccountEntropyPool_DeriveSvrKey: (accountEntropy: AccountEntropyPool) => Uint8Array; - AccountEntropyPool_DeriveBackupKey: (accountEntropy: AccountEntropyPool) => Uint8Array; - BackupKey_DeriveBackupId: (backupKey: Uint8Array, aci: Uint8Array) => Uint8Array; - BackupKey_DeriveEcKey: (backupKey: Uint8Array, aci: Uint8Array) => PrivateKey; - BackupKey_DeriveLocalBackupMetadataKey: (backupKey: Uint8Array) => Uint8Array; - BackupKey_DeriveMediaId: (backupKey: Uint8Array, mediaName: string) => Uint8Array; - BackupKey_DeriveMediaEncryptionKey: (backupKey: Uint8Array, mediaId: Uint8Array) => Uint8Array; - BackupKey_DeriveThumbnailTransitEncryptionKey: (backupKey: Uint8Array, mediaId: Uint8Array) => Uint8Array; + AccountEntropyPool_DeriveSvrKey: (accountEntropy: AccountEntropyPool) => Uint8Array; + AccountEntropyPool_DeriveBackupKey: (accountEntropy: AccountEntropyPool) => Uint8Array; + BackupKey_DeriveBackupId: (backupKey: Uint8Array, aci: Uint8Array) => Uint8Array; + BackupKey_DeriveEcKey: (backupKey: Uint8Array, aci: Uint8Array) => PrivateKey; + BackupKey_DeriveLocalBackupMetadataKey: (backupKey: Uint8Array) => Uint8Array; + BackupKey_DeriveMediaId: (backupKey: Uint8Array, mediaName: string) => Uint8Array; + BackupKey_DeriveMediaEncryptionKey: (backupKey: Uint8Array, mediaId: Uint8Array) => Uint8Array; + BackupKey_DeriveThumbnailTransitEncryptionKey: (backupKey: Uint8Array, mediaId: Uint8Array) => Uint8Array; IncrementalMac_CalculateChunkSize: (dataSize: number) => number; - IncrementalMac_Initialize: (key: Uint8Array, chunkSize: number) => IncrementalMac; - IncrementalMac_Update: (mac: Wrapper, bytes: Uint8Array, offset: number, length: number) => Uint8Array; - IncrementalMac_Finalize: (mac: Wrapper) => Uint8Array; - ValidatingMac_Initialize: (key: Uint8Array, chunkSize: number, digests: Uint8Array) => ValidatingMac | null; - ValidatingMac_Update: (mac: Wrapper, bytes: Uint8Array, offset: number, length: number) => number; + IncrementalMac_Initialize: (key: Uint8Array, chunkSize: number) => IncrementalMac; + IncrementalMac_Update: (mac: Wrapper, bytes: Uint8Array, offset: number, length: number) => Uint8Array; + IncrementalMac_Finalize: (mac: Wrapper) => Uint8Array; + ValidatingMac_Initialize: (key: Uint8Array, chunkSize: number, digests: Uint8Array) => ValidatingMac | null; + ValidatingMac_Update: (mac: Wrapper, bytes: Uint8Array, offset: number, length: number) => number; ValidatingMac_Finalize: (mac: Wrapper) => number; - MessageBackupKey_FromAccountEntropyPool: (accountEntropy: AccountEntropyPool, aci: Uint8Array, forwardSecrecyToken: Uint8Array | null) => MessageBackupKey; - MessageBackupKey_FromBackupKeyAndBackupId: (backupKey: Uint8Array, backupId: Uint8Array, forwardSecrecyToken: Uint8Array | null) => MessageBackupKey; - MessageBackupKey_GetHmacKey: (key: Wrapper) => Uint8Array; - MessageBackupKey_GetAesKey: (key: Wrapper) => Uint8Array; + MessageBackupKey_FromAccountEntropyPool: (accountEntropy: AccountEntropyPool, aci: Uint8Array, forwardSecrecyToken: Uint8Array | null) => MessageBackupKey; + MessageBackupKey_FromBackupKeyAndBackupId: (backupKey: Uint8Array, backupId: Uint8Array, forwardSecrecyToken: Uint8Array | null) => MessageBackupKey; + MessageBackupKey_GetHmacKey: (key: Wrapper) => Uint8Array; + MessageBackupKey_GetAesKey: (key: Wrapper) => Uint8Array; MessageBackupValidator_Validate: (key: Wrapper, firstStream: InputStream, secondStream: InputStream, len: bigint, purpose: number) => Promise; - OnlineBackupValidator_New: (backupInfoFrame: Uint8Array, purpose: number) => OnlineBackupValidator; - OnlineBackupValidator_AddFrame: (backup: Wrapper, frame: Uint8Array) => void; + OnlineBackupValidator_New: (backupInfoFrame: Uint8Array, purpose: number) => OnlineBackupValidator; + OnlineBackupValidator_AddFrame: (backup: Wrapper, frame: Uint8Array) => void; OnlineBackupValidator_Finalize: (backup: Wrapper) => void; - BackupJsonExporter_New: (backupInfo: Uint8Array, shouldValidate: boolean) => BackupJsonExporter; + BackupJsonExporter_New: (backupInfo: Uint8Array, shouldValidate: boolean) => BackupJsonExporter; BackupJsonExporter_GetInitialChunk: (exporter: Wrapper) => string; - BackupJsonExporter_ExportFrames: (exporter: Wrapper, frames: Uint8Array) => JsonFrameExportResult[]; + BackupJsonExporter_ExportFrames: (exporter: Wrapper, frames: Uint8Array) => JsonFrameExportResult[]; BackupJsonExporter_Finish: (exporter: Wrapper) => void; - Username_Hash: (username: string) => Uint8Array; - Username_Proof: (username: string, randomness: Uint8Array) => Uint8Array; - Username_Verify: (proof: Uint8Array, hash: Uint8Array) => void; + Username_Hash: (username: string) => Uint8Array; + Username_Proof: (username: string, randomness: Uint8Array) => Uint8Array; + Username_Verify: (proof: Uint8Array, hash: Uint8Array) => void; Username_CandidatesFrom: (nickname: string, minLen: number, maxLen: number) => string[]; - Username_HashFromParts: (nickname: string, discriminator: string, minLen: number, maxLen: number) => Uint8Array; - UsernameLink_Create: (username: string, entropy: Uint8Array | null) => Uint8Array; - UsernameLink_DecryptUsername: (entropy: Uint8Array, encryptedUsername: Uint8Array) => string; + Username_HashFromParts: (nickname: string, discriminator: string, minLen: number, maxLen: number) => Uint8Array; + UsernameLink_Create: (username: string, entropy: Uint8Array | null) => Uint8Array; + UsernameLink_DecryptUsername: (entropy: Uint8Array, encryptedUsername: Uint8Array) => string; SignalMedia_CheckAvailable: () => void; Mp4Sanitizer_Sanitize: (input: InputStream, len: bigint) => Promise; WebpSanitizer_Sanitize: (input: SyncInputStream) => void; - SanitizedMetadata_GetMetadata: (sanitized: Wrapper) => Uint8Array; + SanitizedMetadata_GetMetadata: (sanitized: Wrapper) => Uint8Array; SanitizedMetadata_GetDataOffset: (sanitized: Wrapper) => bigint; SanitizedMetadata_GetDataLen: (sanitized: Wrapper) => bigint; BridgedStringMap_new: (initialCapacity: number) => BridgedStringMap; BridgedStringMap_insert: (map: Wrapper, key: string, value: string) => void; TESTING_NonSuspendingBackgroundThreadRuntime_New: () => NonSuspendingBackgroundThreadRuntime; TESTING_FutureSuccess: (asyncRuntime: Wrapper, input: number) => CancellablePromise; - TESTING_TokioAsyncContext_FutureSuccessBytes: (asyncRuntime: Wrapper, count: number) => CancellablePromise; + TESTING_TokioAsyncContext_FutureSuccessBytes: (asyncRuntime: Wrapper, count: number) => CancellablePromise>; TESTING_FutureFailure: (asyncRuntime: Wrapper, _input: number) => CancellablePromise; TESTING_FutureCancellationCounter_Create: (initialValue: number) => TestingFutureCancellationCounter; TESTING_FutureCancellationCounter_WaitForCount: (asyncRuntime: Wrapper, count: Wrapper, target: number) => CancellablePromise; @@ -623,14 +623,14 @@ type NativeFunctions = { TESTING_ErrorOnReturnIo: (asyncRuntime: Wrapper, _needsCleanup: null) => CancellablePromise; TESTING_ReturnStringArray: () => string[]; TESTING_JoinStringArray: (array: string[], joinWith: string) => string; - TESTING_ProcessBytestringArray: (input: Uint8Array[]) => Uint8Array[]; + TESTING_ProcessBytestringArray: (input: Uint8Array[]) => Uint8Array[]; TESTING_RoundTripU8: (input: number) => number; TESTING_RoundTripU16: (input: number) => number; TESTING_RoundTripU32: (input: number) => number; TESTING_RoundTripI32: (input: number) => number; TESTING_RoundTripU64: (input: bigint) => bigint; TESTING_ConvertOptionalUuid: (present: boolean) => Uuid | null; - TESTING_InputStreamReadIntoZeroLengthSlice: (capsAlphabetInput: InputStream) => Promise; + TESTING_InputStreamReadIntoZeroLengthSlice: (capsAlphabetInput: InputStream) => Promise>; ComparableBackup_ReadUnencrypted: (stream: InputStream, len: bigint, purpose: number) => Promise; ComparableBackup_GetComparableString: (backup: Wrapper) => string; ComparableBackup_GetUnknownFields: (backup: Wrapper) => string[]; @@ -642,8 +642,8 @@ type NativeFunctions = { TESTING_FakeChatConnection_TakeUnauthenticatedChat: (chat: Wrapper) => UnauthenticatedChatConnection; TESTING_FakeChatConnection_TakeProvisioningChat: (chat: Wrapper) => ProvisioningChatConnection; TESTING_FakeChatConnection_TakeRemote: (chat: Wrapper) => FakeChatRemoteEnd; - TESTING_FakeChatRemoteEnd_SendRawServerRequest: (chat: Wrapper, bytes: Uint8Array) => void; - TESTING_FakeChatRemoteEnd_SendRawServerResponse: (chat: Wrapper, bytes: Uint8Array) => void; + TESTING_FakeChatRemoteEnd_SendRawServerRequest: (chat: Wrapper, bytes: Uint8Array) => void; + TESTING_FakeChatRemoteEnd_SendRawServerResponse: (chat: Wrapper, bytes: Uint8Array) => void; TESTING_FakeChatRemoteEnd_SendServerResponse: (chat: Wrapper, response: Wrapper) => void; TESTING_FakeChatRemoteEnd_InjectConnectionInterrupted: (chat: Wrapper) => void; TESTING_FakeChatRemoteEnd_ReceiveIncomingRequest: (asyncRuntime: Wrapper, chat: Wrapper) => CancellablePromise<[HttpRequest, bigint] | null>; @@ -652,8 +652,8 @@ type NativeFunctions = { TESTING_ChatRequestGetPath: (request: Wrapper) => string; TESTING_ChatRequestGetHeaderNames: (request: Wrapper) => string[]; TESTING_ChatRequestGetHeaderValue: (request: Wrapper, headerName: string) => string; - TESTING_ChatRequestGetBody: (request: Wrapper) => Uint8Array; - TESTING_FakeChatResponse_Create: (id: bigint, status: number, message: string, headers: string[], body: Uint8Array | null) => FakeChatResponse; + TESTING_ChatRequestGetBody: (request: Wrapper) => Uint8Array; + TESTING_FakeChatResponse_Create: (id: bigint, status: number, message: string, headers: string[], body: Uint8Array | null) => FakeChatResponse; TESTING_ChatConnectErrorConvert: (errorDescription: string) => void; TESTING_ChatSendErrorConvert: (errorDescription: string) => void; TESTING_KeyTransFatalVerificationFailure: () => void; @@ -673,9 +673,9 @@ type NativeFunctions = { TESTING_CdsiLookupResponseConvert: (asyncRuntime: Wrapper) => CancellablePromise; TESTING_CdsiLookupErrorConvert: (errorDescription: string) => void; TESTING_ServerMessageAck_Create: () => ServerMessageAck; - TESTING_ConnectionManager_newLocalOverride: (userAgent: string, chatPort: number, cdsiPort: number, svr2Port: number, svrBPort: number, rootCertificateDer: Uint8Array) => ConnectionManager; + TESTING_ConnectionManager_newLocalOverride: (userAgent: string, chatPort: number, cdsiPort: number, svr2Port: number, svrBPort: number, rootCertificateDer: Uint8Array) => ConnectionManager; TESTING_ConnectionManager_isUsingProxy: (manager: Wrapper) => number; - TESTING_CreateOTP: (username: string, secret: Uint8Array) => string; + TESTING_CreateOTP: (username: string, secret: Uint8Array) => string; TESTING_CreateOTPFromBase64: (username: string, secret: string) => string; TESTING_SignedPublicPreKey_CheckBridgesCorrectly: (sourcePublicKey: Wrapper, signedPreKey: SignedPublicPreKey) => void; TestingSemaphore_New: (initial: number) => TestingSemaphore; @@ -1807,16 +1807,16 @@ export interface AuthenticatedChatConnection { readonly __type: unique symbol; } export interface ProvisioningChatConnection { readonly __type: unique symbol; } export interface HttpRequest { readonly __type: unique symbol; } export /*trait*/ type ChatListener = { - receivedIncomingMessage: (envelope: Uint8Array, timestamp: Timestamp, ack: ServerMessageAck) => void; + receivedIncomingMessage: (envelope: Uint8Array, timestamp: Timestamp, ack: ServerMessageAck) => void; receivedQueueEmpty: () => void; receivedAlerts: (alerts: string[]) => void; - connectionInterrupted: (disconnectCause: Error|null) => void; + connectionInterrupted: (disconnectCause: Error | null) => void; }; export interface ServerMessageAck { readonly __type: unique symbol; } export /*trait*/ type ProvisioningListener = { receivedAddress: (address: string, sendAck: ServerMessageAck) => void; - receivedEnvelope: (envelope: Uint8Array, sendAck: ServerMessageAck) => void; - connectionInterrupted: (disconnectCause: Error|null) => void; + receivedEnvelope: (envelope: Uint8Array, sendAck: ServerMessageAck) => void; + connectionInterrupted: (disconnectCause: Error | null) => void; }; export interface RegistrationService { readonly __type: unique symbol; } export interface RegistrationSession { readonly __type: unique symbol; } diff --git a/node/ts/SealedSenderMultiRecipientMessage.ts b/node/ts/SealedSenderMultiRecipientMessage.ts index 22e6c1220..2b6553302 100644 --- a/node/ts/SealedSenderMultiRecipientMessage.ts +++ b/node/ts/SealedSenderMultiRecipientMessage.ts @@ -25,14 +25,14 @@ export interface Recipient { * material. */ export default class SealedSenderMultiRecipientMessage { - readonly _buffer: Uint8Array; + readonly _buffer: Uint8Array; readonly _recipientMap: { [serviceId: string]: Native.SealedSenderMultiRecipientMessageRecipient; }; readonly _excludedRecipients: string[]; readonly _offsetOfSharedData: number; - constructor(buffer: Uint8Array) { + constructor(buffer: Uint8Array) { const { recipientMap, excludedRecipients, offsetOfSharedData } = Native.SealedSenderMultiRecipientMessage_Parse(buffer); this._buffer = buffer; @@ -68,7 +68,7 @@ export default class SealedSenderMultiRecipientMessage { * {@link #recipientsByServiceIdString}. The same payload should be sent to all of the recipient's * devices. */ - messageForRecipient(recipient: Recipient): Uint8Array { + messageForRecipient(recipient: Recipient): Uint8Array { const nativeRecipient = recipient as Native.SealedSenderMultiRecipientMessageRecipient; // Use Buffer.concat for convenience, but return a proper Uint8Array, both for the correct type diff --git a/node/ts/WebpSanitizer.ts b/node/ts/WebpSanitizer.ts index 828b5bfea..302c7a5a3 100644 --- a/node/ts/WebpSanitizer.ts +++ b/node/ts/WebpSanitizer.ts @@ -27,6 +27,6 @@ import type { * @throws {InvalidMediaInputError} If the input could not be parsed because it was invalid. * @throws {UnsupportedMediaInputError} If the input could not be parsed because it's unsupported in some way. */ -export function sanitize(input: Uint8Array): void { +export function sanitize(input: Uint8Array): void { Native.WebpSanitizer_Sanitize(input); } diff --git a/node/ts/incremental_mac.ts b/node/ts/incremental_mac.ts index 7f43cb963..9b46ff27c 100644 --- a/node/ts/incremental_mac.ts +++ b/node/ts/incremental_mac.ts @@ -29,9 +29,9 @@ export function inferChunkSize(dataSize: number): ChunkSizeChoice { class DigestingWritable extends stream.Writable { _nativeHandle: Native.IncrementalMac; - _digests: Uint8Array[] = []; + _digests: Uint8Array[] = []; - constructor(key: Uint8Array, sizeChoice: ChunkSizeChoice) { + constructor(key: Uint8Array, sizeChoice: ChunkSizeChoice) { super(); this._nativeHandle = Native.IncrementalMac_Initialize( key, @@ -39,7 +39,7 @@ class DigestingWritable extends stream.Writable { ); } - getFinalDigest(): Uint8Array { + getFinalDigest(): Uint8Array { // Use Buffer.concat for convenience, but return a proper Uint8Array, both for the correct type // and to make an independent copy of a possibly-reused buffer. return new Uint8Array(Buffer.concat(this._digests)); @@ -74,7 +74,7 @@ class DigestingWritable extends stream.Writable { export class DigestingPassThrough extends stream.Transform { private digester: DigestingWritable; - constructor(key: Uint8Array, sizeChoice: ChunkSizeChoice) { + constructor(key: Uint8Array, sizeChoice: ChunkSizeChoice) { super(); this.digester = new DigestingWritable(key, sizeChoice); @@ -84,12 +84,12 @@ export class DigestingPassThrough extends stream.Transform { }); } - getFinalDigest(): Uint8Array { + getFinalDigest(): Uint8Array { return this.digester.getFinalDigest(); } public override _transform( - data: Uint8Array, + data: Uint8Array, enc: BufferEncoding, callback: CallbackType ): void { @@ -119,9 +119,9 @@ class ValidatingWritable extends stream.Writable { _validatedBytes = 0; constructor( - key: Uint8Array, + key: Uint8Array, sizeChoice: ChunkSizeChoice, - digest: Uint8Array + digest: Uint8Array ) { super(); const handle = Native.ValidatingMac_Initialize( @@ -177,12 +177,12 @@ class ValidatingWritable extends stream.Writable { export class ValidatingPassThrough extends stream.Transform { private validator: ValidatingWritable; - private buffer = new Array(); + private buffer = new Array>(); constructor( - key: Uint8Array, + key: Uint8Array, sizeChoice: ChunkSizeChoice, - digest: Uint8Array + digest: Uint8Array ) { super(); this.validator = new ValidatingWritable(key, sizeChoice, digest); @@ -194,7 +194,7 @@ export class ValidatingPassThrough extends stream.Transform { } public override _transform( - data: Uint8Array, + data: Uint8Array, enc: BufferEncoding, callback: CallbackType ): void { @@ -263,10 +263,8 @@ export function chunkSizeInBytes(sizeChoice: ChunkSizeChoice): number { switch (sizeChoice.kind) { case 'everyN': return sizeChoice.n; - break; case 'chunksOf': return Native.IncrementalMac_CalculateChunkSize(sizeChoice.dataSize); - break; } } diff --git a/node/ts/index.ts b/node/ts/index.ts index a2cfba15b..170fda044 100644 --- a/node/ts/index.ts +++ b/node/ts/index.ts @@ -14,7 +14,7 @@ import { Aci, ProtocolAddress, ServiceId } from './Address.js'; export * from './Address.js'; import { IdentityKeyPair, PrivateKey, PublicKey } from './EcKeys.js'; export * from './EcKeys.js'; -import { Uuid } from './uuid.js'; +import { parseUuid, Uuid } from './uuid.js'; export * from './uuid.js'; export * as usernames from './usernames.js'; @@ -53,21 +53,21 @@ export enum ContentHint { export function hkdf( outputLength: number, - keyMaterial: Uint8Array, - label: Uint8Array, - salt: Uint8Array | null -): Uint8Array { + keyMaterial: Uint8Array, + label: Uint8Array, + salt: Uint8Array | null +): Uint8Array { return Native.HKDF_DeriveSecrets(outputLength, keyMaterial, label, salt); } export class ScannableFingerprint { - private readonly scannable: Uint8Array; + private readonly scannable: Uint8Array; - private constructor(scannable: Uint8Array) { + private constructor(scannable: Uint8Array) { this.scannable = scannable; } - static _fromBuffer(scannable: Uint8Array): ScannableFingerprint { + static _fromBuffer(scannable: Uint8Array): ScannableFingerprint { return new ScannableFingerprint(scannable); } @@ -75,7 +75,7 @@ export class ScannableFingerprint { return Native.ScannableFingerprint_Compare(this.scannable, other.scannable); } - toBuffer(): Uint8Array { + toBuffer(): Uint8Array { return this.scannable; } } @@ -106,9 +106,9 @@ export class Fingerprint { static new( iterations: number, version: number, - localIdentifier: Uint8Array, + localIdentifier: Uint8Array, localKey: PublicKey, - remoteIdentifier: Uint8Array, + remoteIdentifier: Uint8Array, remoteKey: PublicKey ): Fingerprint { return new Fingerprint( @@ -146,11 +146,11 @@ export class Fingerprint { export class Aes256GcmSiv { readonly _nativeHandle: Native.Aes256GcmSiv; - private constructor(key: Uint8Array) { + private constructor(key: Uint8Array) { this._nativeHandle = Native.Aes256GcmSiv_New(key); } - static new(key: Uint8Array): Aes256GcmSiv { + static new(key: Uint8Array): Aes256GcmSiv { return new Aes256GcmSiv(key); } @@ -164,10 +164,10 @@ export class Aes256GcmSiv { * @returns The encrypted data, including an appended 16-byte authentication tag. */ encrypt( - message: Uint8Array, - nonce: Uint8Array, - associatedData: Uint8Array - ): Uint8Array { + message: Uint8Array, + nonce: Uint8Array, + associatedData: Uint8Array + ): Uint8Array { return Native.Aes256GcmSiv_Encrypt(this, message, nonce, associatedData); } @@ -181,10 +181,10 @@ export class Aes256GcmSiv { * @returns The decrypted data */ decrypt( - message: Uint8Array, - nonce: Uint8Array, - associatedData: Uint8Array - ): Uint8Array { + message: Uint8Array, + nonce: Uint8Array, + associatedData: Uint8Array + ): Uint8Array { return Native.Aes256GcmSiv_Decrypt(this, message, nonce, associatedData); } } @@ -200,11 +200,11 @@ export class KEMPublicKey { return new KEMPublicKey(handle); } - static deserialize(buf: Uint8Array): KEMPublicKey { + static deserialize(buf: Uint8Array): KEMPublicKey { return new KEMPublicKey(Native.KyberPublicKey_Deserialize(buf)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.KyberPublicKey_Serialize(this); } } @@ -220,11 +220,11 @@ export class KEMSecretKey { return new KEMSecretKey(handle); } - static deserialize(buf: Uint8Array): KEMSecretKey { + static deserialize(buf: Uint8Array): KEMSecretKey { return new KEMSecretKey(Native.KyberSecretKey_Deserialize(buf)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.KyberSecretKey_Serialize(this); } } @@ -261,14 +261,14 @@ export class KEMKeyPair { export type SignedPublicPreKey = { id: () => number; publicKey: () => PublicKey; - signature: () => Uint8Array; + signature: () => Uint8Array; }; /** The public information contained in a {@link KyberPreKeyRecord} */ export type SignedKyberPublicPreKey = { id: () => number; publicKey: () => KEMPublicKey; - signature: () => Uint8Array; + signature: () => Uint8Array; }; export class PreKeyBundle { @@ -285,11 +285,11 @@ export class PreKeyBundle { prekey: PublicKey | null, signed_prekey_id: number, signed_prekey: PublicKey, - signed_prekey_signature: Uint8Array, + signed_prekey_signature: Uint8Array, identity_key: PublicKey, kyber_prekey_id: number, kyber_prekey: KEMPublicKey, - kyber_prekey_signature: Uint8Array + kyber_prekey_signature: Uint8Array ): PreKeyBundle { return new PreKeyBundle( Native.PreKeyBundle_New( @@ -339,7 +339,7 @@ export class PreKeyBundle { Native.PreKeyBundle_GetSignedPreKeyPublic(this) ); } - signedPreKeySignature(): Uint8Array { + signedPreKeySignature(): Uint8Array { return Native.PreKeyBundle_GetSignedPreKeySignature(this); } @@ -353,7 +353,7 @@ export class PreKeyBundle { ); } - kyberPreKeySignature(): Uint8Array { + kyberPreKeySignature(): Uint8Array { return Native.PreKeyBundle_GetKyberPreKeySignature(this); } } @@ -373,7 +373,7 @@ export class PreKeyRecord { return new PreKeyRecord(Native.PreKeyRecord_New(id, pubKey, privKey)); } - static deserialize(buffer: Uint8Array): PreKeyRecord { + static deserialize(buffer: Uint8Array): PreKeyRecord { return new PreKeyRecord(Native.PreKeyRecord_Deserialize(buffer)); } @@ -391,7 +391,7 @@ export class PreKeyRecord { return PublicKey._fromNativeHandle(Native.PreKeyRecord_GetPublicKey(this)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.PreKeyRecord_Serialize(this); } } @@ -414,14 +414,14 @@ export class SignedPreKeyRecord implements SignedPublicPreKey { timestamp: number, pubKey: PublicKey, privKey: PrivateKey, - signature: Uint8Array + signature: Uint8Array ): SignedPreKeyRecord { return new SignedPreKeyRecord( Native.SignedPreKeyRecord_New(id, timestamp, pubKey, privKey, signature) ); } - static deserialize(buffer: Uint8Array): SignedPreKeyRecord { + static deserialize(buffer: Uint8Array): SignedPreKeyRecord { return new SignedPreKeyRecord( Native.SignedPreKeyRecord_Deserialize(buffer) ); @@ -443,11 +443,11 @@ export class SignedPreKeyRecord implements SignedPublicPreKey { ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.SignedPreKeyRecord_Serialize(this); } - signature(): Uint8Array { + signature(): Uint8Array { return Native.SignedPreKeyRecord_GetSignature(this); } @@ -473,18 +473,18 @@ export class KyberPreKeyRecord implements SignedKyberPublicPreKey { id: number, timestamp: number, keyPair: KEMKeyPair, - signature: Uint8Array + signature: Uint8Array ): KyberPreKeyRecord { return new KyberPreKeyRecord( Native.KyberPreKeyRecord_New(id, timestamp, keyPair, signature) ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.KyberPreKeyRecord_Serialize(this); } - static deserialize(buffer: Uint8Array): KyberPreKeyRecord { + static deserialize(buffer: Uint8Array): KyberPreKeyRecord { return new KyberPreKeyRecord(Native.KyberPreKeyRecord_Deserialize(buffer)); } @@ -510,7 +510,7 @@ export class KyberPreKeyRecord implements SignedKyberPublicPreKey { ); } - signature(): Uint8Array { + signature(): Uint8Array { return Native.KyberPreKeyRecord_GetSignature(this); } @@ -528,14 +528,14 @@ export class SignalMessage { static _new( messageVersion: number, - macKey: Uint8Array, + macKey: Uint8Array, senderRatchetKey: PublicKey, counter: number, previousCounter: number, - ciphertext: Uint8Array, + ciphertext: Uint8Array, senderIdentityKey: PublicKey, receiverIdentityKey: PublicKey, - pqRatchet: Uint8Array + pqRatchet: Uint8Array ): SignalMessage { return new SignalMessage( Native.SignalMessage_New( @@ -552,15 +552,15 @@ export class SignalMessage { ); } - static deserialize(buffer: Uint8Array): SignalMessage { + static deserialize(buffer: Uint8Array): SignalMessage { return new SignalMessage(Native.SignalMessage_Deserialize(buffer)); } - body(): Uint8Array { + body(): Uint8Array { return Native.SignalMessage_GetBody(this); } - pqRatchet(): Uint8Array { + pqRatchet(): Uint8Array { return Native.SignalMessage_GetPqRatchet(this); } @@ -572,14 +572,14 @@ export class SignalMessage { return Native.SignalMessage_GetMessageVersion(this); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.SignalMessage_GetSerialized(this); } verifyMac( senderIdentityKey: PublicKey, recevierIdentityKey: PublicKey, - macKey: Uint8Array + macKey: Uint8Array ): boolean { return Native.SignalMessage_VerifyMac( this, @@ -619,7 +619,7 @@ export class PreKeySignalMessage { ); } - static deserialize(buffer: Uint8Array): PreKeySignalMessage { + static deserialize(buffer: Uint8Array): PreKeySignalMessage { return new PreKeySignalMessage( Native.PreKeySignalMessage_Deserialize(buffer) ); @@ -641,7 +641,7 @@ export class PreKeySignalMessage { return Native.PreKeySignalMessage_GetVersion(this); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.PreKeySignalMessage_Serialize(this); } } @@ -657,11 +657,11 @@ export class SessionRecord { return new SessionRecord(nativeHandle); } - static deserialize(buffer: Uint8Array): SessionRecord { + static deserialize(buffer: Uint8Array): SessionRecord { return new SessionRecord(Native.SessionRecord_Deserialize(buffer)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.SessionRecord_Serialize(this); } @@ -714,11 +714,11 @@ export class ServerCertificate { ); } - static deserialize(buffer: Uint8Array): ServerCertificate { + static deserialize(buffer: Uint8Array): ServerCertificate { return new ServerCertificate(Native.ServerCertificate_Deserialize(buffer)); } - certificateData(): Uint8Array { + certificateData(): Uint8Array { return Native.ServerCertificate_GetCertificate(this); } @@ -730,11 +730,11 @@ export class ServerCertificate { return Native.ServerCertificate_GetKeyId(this); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.ServerCertificate_GetSerialized(this); } - signature(): Uint8Array { + signature(): Uint8Array { return Native.ServerCertificate_GetSignature(this); } } @@ -752,11 +752,11 @@ export class SenderKeyRecord { this._nativeHandle = nativeHandle; } - static deserialize(buffer: Uint8Array): SenderKeyRecord { + static deserialize(buffer: Uint8Array): SenderKeyRecord { return new SenderKeyRecord(Native.SenderKeyRecord_Deserialize(buffer)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.SenderKeyRecord_Serialize(this); } } @@ -799,15 +799,15 @@ export class SenderCertificate { ); } - static deserialize(buffer: Uint8Array): SenderCertificate { + static deserialize(buffer: Uint8Array): SenderCertificate { return new SenderCertificate(Native.SenderCertificate_Deserialize(buffer)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.SenderCertificate_GetSerialized(this); } - certificate(): Uint8Array { + certificate(): Uint8Array { return Native.SenderCertificate_GetCertificate(this); } expiration(): number { @@ -842,7 +842,7 @@ export class SenderCertificate { Native.SenderCertificate_GetServerCertificate(this) ); } - signature(): Uint8Array { + signature(): Uint8Array { return Native.SenderCertificate_GetSignature(this); } @@ -910,7 +910,7 @@ export class SenderKeyDistributionMessage { ): Promise { const handle = await Native.SenderKeyDistributionMessage_Create( sender, - uuid.parse(distributionId), + parseUuid(distributionId), bridgeSenderKeyStore(store) ); return new SenderKeyDistributionMessage(handle); @@ -921,13 +921,13 @@ export class SenderKeyDistributionMessage { distributionId: Uuid, chainId: number, iteration: number, - chainKey: Uint8Array, + chainKey: Uint8Array, pk: PublicKey ): SenderKeyDistributionMessage { return new SenderKeyDistributionMessage( Native.SenderKeyDistributionMessage_New( messageVersion, - uuid.parse(distributionId), + parseUuid(distributionId), chainId, iteration, chainKey, @@ -936,17 +936,19 @@ export class SenderKeyDistributionMessage { ); } - static deserialize(buffer: Uint8Array): SenderKeyDistributionMessage { + static deserialize( + buffer: Uint8Array + ): SenderKeyDistributionMessage { return new SenderKeyDistributionMessage( Native.SenderKeyDistributionMessage_Deserialize(buffer) ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.SenderKeyDistributionMessage_Serialize(this); } - chainKey(): Uint8Array { + chainKey(): Uint8Array { return Native.SenderKeyDistributionMessage_GetChainKey(this); } @@ -989,13 +991,13 @@ export class SenderKeyMessage { distributionId: Uuid, chainId: number, iteration: number, - ciphertext: Uint8Array, + ciphertext: Uint8Array, pk: PrivateKey ): SenderKeyMessage { return new SenderKeyMessage( Native.SenderKeyMessage_New( messageVersion, - uuid.parse(distributionId), + parseUuid(distributionId), chainId, iteration, ciphertext, @@ -1004,15 +1006,15 @@ export class SenderKeyMessage { ); } - static deserialize(buffer: Uint8Array): SenderKeyMessage { + static deserialize(buffer: Uint8Array): SenderKeyMessage { return new SenderKeyMessage(Native.SenderKeyMessage_Deserialize(buffer)); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.SenderKeyMessage_Serialize(this); } - ciphertext(): Uint8Array { + ciphertext(): Uint8Array { return Native.SenderKeyMessage_GetCipherText(this); } @@ -1050,7 +1052,7 @@ export class UnidentifiedSenderMessageContent { message: CiphertextMessage, sender: SenderCertificate, contentHint: number, - groupId: Uint8Array | null + groupId: Uint8Array | null ): UnidentifiedSenderMessageContent { return new UnidentifiedSenderMessageContent( Native.UnidentifiedSenderMessageContent_New( @@ -1062,17 +1064,19 @@ export class UnidentifiedSenderMessageContent { ); } - static deserialize(buffer: Uint8Array): UnidentifiedSenderMessageContent { + static deserialize( + buffer: Uint8Array + ): UnidentifiedSenderMessageContent { return new UnidentifiedSenderMessageContent( Native.UnidentifiedSenderMessageContent_Deserialize(buffer) ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.UnidentifiedSenderMessageContent_Serialize(this); } - contents(): Uint8Array { + contents(): Uint8Array { return Native.UnidentifiedSenderMessageContent_GetContents(this); } @@ -1090,7 +1094,7 @@ export class UnidentifiedSenderMessageContent { return Native.UnidentifiedSenderMessageContent_GetContentHint(this); } - groupId(): Uint8Array | null { + groupId(): Uint8Array | null { return Native.UnidentifiedSenderMessageContent_GetGroupId(this); } } @@ -1174,12 +1178,12 @@ export async function groupEncrypt( sender: ProtocolAddress, distributionId: Uuid, store: SenderKeyStore, - message: Uint8Array + message: Uint8Array ): Promise { return CiphertextMessage._fromNativeHandle( await Native.GroupCipher_EncryptMessage( sender, - uuid.parse(distributionId), + parseUuid(distributionId), message, bridgeSenderKeyStore(store) ) @@ -1189,8 +1193,8 @@ export async function groupEncrypt( export async function groupDecrypt( sender: ProtocolAddress, store: SenderKeyStore, - message: Uint8Array -): Promise { + message: Uint8Array +): Promise> { return Native.GroupCipher_DecryptMessage( sender, message, @@ -1211,7 +1215,7 @@ export class SealedSenderDecryptionResult { return new SealedSenderDecryptionResult(nativeHandle); } - message(): Uint8Array { + message(): Uint8Array { return Native.SealedSenderDecryptionResult_Message(this); } @@ -1262,7 +1266,7 @@ export class CiphertextMessage { return message.asCiphertextMessage(); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.CiphertextMessage_Serialize(this); } @@ -1278,7 +1282,7 @@ export class PlaintextContent implements CiphertextMessageConvertible { this._nativeHandle = nativeHandle; } - static deserialize(buffer: Uint8Array): PlaintextContent { + static deserialize(buffer: Uint8Array): PlaintextContent { return new PlaintextContent(Native.PlaintextContent_Deserialize(buffer)); } @@ -1288,11 +1292,11 @@ export class PlaintextContent implements CiphertextMessageConvertible { ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.PlaintextContent_Serialize(this); } - body(): Uint8Array { + body(): Uint8Array { return Native.PlaintextContent_GetBody(this); } @@ -1317,7 +1321,7 @@ export class DecryptionErrorMessage { } static forOriginal( - bytes: Uint8Array, + bytes: Uint8Array, type: CiphertextMessageType, timestamp: number, originalSenderDeviceId: number @@ -1332,19 +1336,21 @@ export class DecryptionErrorMessage { ); } - static deserialize(buffer: Uint8Array): DecryptionErrorMessage { + static deserialize(buffer: Uint8Array): DecryptionErrorMessage { return new DecryptionErrorMessage( Native.DecryptionErrorMessage_Deserialize(buffer) ); } - static extractFromSerializedBody(buffer: Uint8Array): DecryptionErrorMessage { + static extractFromSerializedBody( + buffer: Uint8Array + ): DecryptionErrorMessage { return new DecryptionErrorMessage( Native.DecryptionErrorMessage_ExtractFromSerializedContent(buffer) ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.DecryptionErrorMessage_Serialize(this); } @@ -1452,7 +1458,7 @@ export function processPreKeyBundle( } export async function signalEncrypt( - message: Uint8Array, + message: Uint8Array, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore, @@ -1474,7 +1480,7 @@ export function signalDecrypt( address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore -): Promise { +): Promise> { return Native.SessionCipher_DecryptSignalMessage( message, address, @@ -1557,7 +1563,7 @@ export function signalDecryptPreKey( prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore -): Promise { +): Promise> { return Native.SessionCipher_DecryptPreKeySignalMessage( message, address, @@ -1570,12 +1576,12 @@ export function signalDecryptPreKey( } export async function sealedSenderEncryptMessage( - message: Uint8Array, + message: Uint8Array, address: ProtocolAddress, senderCert: SenderCertificate, sessionStore: SessionStore, identityStore: IdentityKeyStore -): Promise { +): Promise> { const ciphertext = await signalEncrypt( message, address, @@ -1595,7 +1601,7 @@ export function sealedSenderEncrypt( content: UnidentifiedSenderMessageContent, address: ProtocolAddress, identityStore: IdentityKeyStore -): Promise { +): Promise> { return Native.SealedSender_Encrypt( address, content, @@ -1613,13 +1619,13 @@ export type SealedSenderMultiRecipientEncryptOptions = { export async function sealedSenderMultiRecipientEncrypt( options: SealedSenderMultiRecipientEncryptOptions -): Promise; +): Promise>; export async function sealedSenderMultiRecipientEncrypt( content: UnidentifiedSenderMessageContent, recipients: ProtocolAddress[], identityStore: IdentityKeyStore, sessionStore: SessionStore -): Promise; +): Promise>; export async function sealedSenderMultiRecipientEncrypt( contentOrOptions: @@ -1628,7 +1634,7 @@ export async function sealedSenderMultiRecipientEncrypt( recipients?: ProtocolAddress[], identityStore?: IdentityKeyStore, sessionStore?: SessionStore -): Promise { +): Promise> { let excludedRecipients: ServiceId[] | undefined = undefined; if (contentOrOptions instanceof UnidentifiedSenderMessageContent) { if (!recipients || !identityStore || !sessionStore) { @@ -1656,13 +1662,13 @@ export async function sealedSenderMultiRecipientEncrypt( // For testing only export function sealedSenderMultiRecipientMessageForSingleRecipient( - message: Uint8Array -): Uint8Array { + message: Uint8Array +): Uint8Array { return Native.SealedSender_MultiRecipientMessageForSingleRecipient(message); } export async function sealedSenderDecryptMessage( - message: Uint8Array, + message: Uint8Array, trustRoot: PublicKey, timestamp: number, localE164: string | null, @@ -1691,7 +1697,7 @@ export async function sealedSenderDecryptMessage( } export async function sealedSenderDecryptToUsmc( - message: Uint8Array, + message: Uint8Array, identityStore: IdentityKeyStore ): Promise { const usmc = await Native.SealedSender_DecryptToUsmc( @@ -1709,8 +1715,8 @@ export class Cds2Client { } static new( - mrenclave: Uint8Array, - attestationMsg: Uint8Array, + mrenclave: Uint8Array, + attestationMsg: Uint8Array, currentTimestamp: Date ): Cds2Client { return new Cds2Client( @@ -1722,19 +1728,19 @@ export class Cds2Client { ); } - initialRequest(): Uint8Array { + initialRequest(): Uint8Array { return Native.SgxClientState_InitialRequest(this); } - completeHandshake(buffer: Uint8Array): void { + completeHandshake(buffer: Uint8Array): void { return Native.SgxClientState_CompleteHandshake(this, buffer); } - establishedSend(buffer: Uint8Array): Uint8Array { + establishedSend(buffer: Uint8Array): Uint8Array { return Native.SgxClientState_EstablishedSend(this, buffer); } - establishedRecv(buffer: Uint8Array): Uint8Array { + establishedRecv(buffer: Uint8Array): Uint8Array { return Native.SgxClientState_EstablishedRecv(this, buffer); } } @@ -1747,8 +1753,8 @@ export class HsmEnclaveClient { } static new( - public_key: Uint8Array, - code_hashes: Uint8Array[] + public_key: Uint8Array, + code_hashes: Uint8Array[] ): HsmEnclaveClient { code_hashes.forEach((hash) => { if (hash.length != 32) { @@ -1762,19 +1768,19 @@ export class HsmEnclaveClient { ); } - initialRequest(): Uint8Array { + initialRequest(): Uint8Array { return Native.HsmEnclaveClient_InitialRequest(this); } - completeHandshake(buffer: Uint8Array): void { + completeHandshake(buffer: Uint8Array): void { return Native.HsmEnclaveClient_CompleteHandshake(this, buffer); } - establishedSend(buffer: Uint8Array): Uint8Array { + establishedSend(buffer: Uint8Array): Uint8Array { return Native.HsmEnclaveClient_EstablishedSend(this, buffer); } - establishedRecv(buffer: Uint8Array): Uint8Array { + establishedRecv(buffer: Uint8Array): Uint8Array { return Native.HsmEnclaveClient_EstablishedRecv(this, buffer); } } diff --git a/node/ts/io.ts b/node/ts/io.ts index e99125544..89eb8e795 100644 --- a/node/ts/io.ts +++ b/node/ts/io.ts @@ -10,7 +10,7 @@ import type { IoError } from './Errors.js'; * An abstract class representing an input stream of bytes. */ export abstract class InputStream implements Native.InputStream { - _read(amount: number): Promise { + _read(amount: number): Promise> { return this.read(amount); } @@ -37,7 +37,7 @@ export abstract class InputStream implements Native.InputStream { * @returns A promise yielding a {@link Uint8Array} containing the read bytes. * @throws {IoError} If an I/O error occurred while reading from the input. */ - abstract read(amount: number): Promise; + abstract read(amount: number): Promise>; /** * Skip an amount of bytes in the input stream. diff --git a/node/ts/net.ts b/node/ts/net.ts index 7371d6fdc..1756e767c 100644 --- a/node/ts/net.ts +++ b/node/ts/net.ts @@ -59,7 +59,7 @@ export type ChatRequest = Readonly<{ verb: string; path: string; headers: ReadonlyArray<[string, string]>; - body?: Uint8Array; + body?: Uint8Array; timeoutMillis?: number; }>; @@ -108,7 +108,7 @@ export type NetConstructorOptions = Readonly< TESTING_localServer_cdsiPort: number; TESTING_localServer_svr2Port: number; TESTING_localServer_svrBPort: number; - TESTING_localServer_rootCertificateDer: Uint8Array; + TESTING_localServer_rootCertificateDer: Uint8Array; } >; diff --git a/node/ts/net/Chat.ts b/node/ts/net/Chat.ts index 328730345..a22eab689 100644 --- a/node/ts/net/Chat.ts +++ b/node/ts/net/Chat.ts @@ -16,7 +16,7 @@ export type ChatRequest = Readonly<{ verb: string; path: string; headers: ReadonlyArray<[string, string]>; - body?: Uint8Array; + body?: Uint8Array; timeoutMillis?: number; }>; @@ -55,7 +55,7 @@ export interface ChatServiceListener extends ConnectionEventsListener { * queue and attempt to deliver it again in the future. */ onIncomingMessage: ( - envelope: Uint8Array, + envelope: Uint8Array, timestamp: number, ack: ChatServerMessageAck ) => void; @@ -93,7 +93,10 @@ export interface ProvisioningConnectionListener * * Once the server receives the `ack` for this message, it will close this connection. */ - onReceivedEnvelope: (envelope: Uint8Array, ack: ChatServerMessageAck) => void; + onReceivedEnvelope: ( + envelope: Uint8Array, + ack: ChatServerMessageAck + ) => void; } /** @@ -452,7 +455,7 @@ export class ProvisioningConnection { listener.onReceivedAddress(address, new ChatServerMessageAck(ack)); }, receivedEnvelope( - envelope: Uint8Array, + envelope: Uint8Array, ack: Native.ServerMessageAck ): void { listener.onReceivedEnvelope(envelope, new ChatServerMessageAck(ack)); @@ -511,7 +514,7 @@ class WeakListenerWrapper implements Native.ChatListener { this.listener.deref()?.connectionInterrupted(reason); } receivedIncomingMessage( - envelope: Uint8Array, + envelope: Uint8Array, timestamp: number, ack: Native.ServerMessageAck ): void { @@ -534,7 +537,10 @@ class WeakProvisioningListenerWrapper implements Native.ProvisioningListener { receivedAddress(address: string, ack: Native.ServerMessageAck): void { this.listener.deref()?.receivedAddress(address, ack); } - receivedEnvelope(envelope: Uint8Array, ack: Native.ServerMessageAck): void { + receivedEnvelope( + envelope: Uint8Array, + ack: Native.ServerMessageAck + ): void { this.listener.deref()?.receivedEnvelope(envelope, ack); } connectionInterrupted(reason: Error | null): void { @@ -549,7 +555,7 @@ function makeNativeChatListener( if ('onQueueEmpty' in listener) { return { receivedIncomingMessage( - envelope: Uint8Array, + envelope: Uint8Array, timestamp: number, ack: Native.ServerMessageAck ): void { @@ -573,7 +579,7 @@ function makeNativeChatListener( return { receivedIncomingMessage( - _envelope: Uint8Array, + _envelope: Uint8Array, _timestamp: number, _ack: Native.ServerMessageAck ): void { diff --git a/node/ts/net/FakeChat.ts b/node/ts/net/FakeChat.ts index 5e596ff83..181b9fc12 100644 --- a/node/ts/net/FakeChat.ts +++ b/node/ts/net/FakeChat.ts @@ -36,7 +36,7 @@ export class InternalRequest implements Native.Wrapper { ); } - public get body(): Uint8Array { + public get body(): Uint8Array { return Native.TESTING_ChatRequestGetBody(this); } } @@ -46,7 +46,7 @@ export type ServerResponse = { status: number; message?: string; headers?: string[]; - body?: Uint8Array; + body?: Uint8Array; }; export class FakeChatRemote { @@ -98,11 +98,11 @@ export class FakeChatRemote { Native.TESTING_FakeChatRemoteEnd_SendServerResponse(this, nativeResponse); } - public sendRawServerResponse(bytes: Uint8Array): void { + public sendRawServerResponse(bytes: Uint8Array): void { Native.TESTING_FakeChatRemoteEnd_SendRawServerResponse(this, bytes); } - public sendRawServerRequest(bytes: Uint8Array): void { + public sendRawServerRequest(bytes: Uint8Array): void { Native.TESTING_FakeChatRemoteEnd_SendRawServerRequest(this, bytes); } diff --git a/node/ts/net/KeyTransparency.ts b/node/ts/net/KeyTransparency.ts index c03989f2e..db5434155 100644 --- a/node/ts/net/KeyTransparency.ts +++ b/node/ts/net/KeyTransparency.ts @@ -25,13 +25,16 @@ import { * used by the {@link Client}. */ export interface Store { - getLastDistinguishedTreeHead: () => Promise; + getLastDistinguishedTreeHead: () => Promise | null>; setLastDistinguishedTreeHead: ( - bytes: Readonly | null + bytes: Readonly> | null ) => Promise; - getAccountData: (aci: Aci) => Promise; - setAccountData: (aci: Aci, bytes: Readonly) => Promise; + getAccountData: (aci: Aci) => Promise | null>; + setAccountData: ( + aci: Aci, + bytes: Readonly> + ) => Promise; } /** @@ -51,7 +54,7 @@ export type AciInfo = { aci: Aci; identityKey: PublicKey }; */ export type E164Info = { e164: string; - unidentifiedAccessKey: Readonly; + unidentifiedAccessKey: Readonly>; }; /** @@ -64,7 +67,7 @@ export type Request = { /** Unidentified access key associated with the account. Optional. */ e164Info?: E164Info; /* Hash of the username associated with the account. Optional. */ - usernameHash?: Readonly; + usernameHash?: Readonly>; }; /** @@ -280,7 +283,7 @@ export class ClientImpl implements Client { private async updateDistinguished( store: Store, { abortSignal }: Readonly - ): Promise { + ): Promise> { const bytes = await this.asyncContext.makeCancellable( abortSignal, Native.KeyTransparency_Distinguished( @@ -297,7 +300,7 @@ export class ClientImpl implements Client { async _getLatestDistinguished( store: Store, options: Readonly - ): Promise { + ): Promise> { return ( (await store.getLastDistinguishedTreeHead()) ?? (await this.updateDistinguished(store, options)) diff --git a/node/ts/net/Registration.ts b/node/ts/net/Registration.ts index d3141f60d..bbdef1b8a 100644 --- a/node/ts/net/Registration.ts +++ b/node/ts/net/Registration.ts @@ -318,11 +318,11 @@ export class AccountAttributes { capabilities, discoverableByPhoneNumber, }: { - recoveryPassword: Uint8Array; + recoveryPassword: Uint8Array; aciRegistrationId: number; pniRegistrationId: number; registrationLock: string | null; - unidentifiedAccessKey: Uint8Array; + unidentifiedAccessKey: Uint8Array; unrestrictedUnidentifiedAccess: boolean; capabilities: Set; discoverableByPhoneNumber: boolean; @@ -361,10 +361,10 @@ export class RegisterAccountResponse { return Native.RegisterAccountResponse_GetNumber(this); } - public get usernameHash(): Uint8Array | null { + public get usernameHash(): Uint8Array | null { return Native.RegisterAccountResponse_GetUsernameHash(this); } - public get usernameLinkHandle(): Uint8Array | null { + public get usernameLinkHandle(): Uint8Array | null { return Native.RegisterAccountResponse_GetUsernameLinkHandle(this); } diff --git a/node/ts/net/SvrB.ts b/node/ts/net/SvrB.ts index 61a5eb403..c93a6b60b 100644 --- a/node/ts/net/SvrB.ts +++ b/node/ts/net/SvrB.ts @@ -45,7 +45,7 @@ export type StoreBackupResponse = { * to fetch the forward secrecy token from SVR-B. This is currently stored in the header of * the backup file. */ - metadata: Uint8Array; + metadata: Uint8Array; /** * Opaque value that must be persisted and provided to the next call to {@link SvrB#store}. @@ -53,7 +53,7 @@ export type StoreBackupResponse = { * See the {@link SvrB} documentation for lifecycle and persistence handling * for this value. */ - nextBackupSecretData: Uint8Array; + nextBackupSecretData: Uint8Array; }; class StoreBackupResponseImpl implements StoreBackupResponse { @@ -66,11 +66,11 @@ class StoreBackupResponseImpl implements StoreBackupResponse { return new BackupForwardSecrecyToken(tokenBytes); } - get metadata(): Uint8Array { + get metadata(): Uint8Array { return Native.BackupStoreResponse_GetOpaqueMetadata(this); } - get nextBackupSecretData(): Uint8Array { + get nextBackupSecretData(): Uint8Array { return Native.BackupStoreResponse_GetNextBackupSecretData(this); } } @@ -100,7 +100,7 @@ export type RestoreBackupResponse = { * See the {@link SvrB} documentation for lifecycle and persistence handling * for this value. */ - nextBackupSecretData: Uint8Array; + nextBackupSecretData: Uint8Array; }; class RestoreBackupResponseImpl implements RestoreBackupResponse { @@ -114,7 +114,7 @@ class RestoreBackupResponseImpl implements RestoreBackupResponse { return new BackupForwardSecrecyToken(tokenBytes); } - get nextBackupSecretData(): Uint8Array { + get nextBackupSecretData(): Uint8Array { return Native.BackupRestoreResponse_GetNextBackupSecretData(this); } } @@ -197,7 +197,7 @@ export class SvrB { * Should not be used if any previous backups exist for this `backupKey`, whether uploaded or * restored by the local device. See {@link SvrB} for more information. */ - createNewBackupChain(backupKey: BackupKey): Uint8Array { + createNewBackupChain(backupKey: BackupKey): Uint8Array { return Native.SecureValueRecoveryForBackups_CreateNewBackupChain( this.environment, backupKey.serialize() @@ -235,7 +235,7 @@ export class SvrB { */ async store( backupKey: BackupKey, - previousSecretData: Uint8Array, + previousSecretData: Uint8Array, options?: { abortSignal?: AbortSignal } ): Promise { const promise = Native.SecureValueRecoveryForBackups_StoreBackup( @@ -289,7 +289,7 @@ export class SvrB { */ async restore( backupKey: BackupKey, - metadata: Uint8Array, + metadata: Uint8Array, options?: { abortSignal?: AbortSignal } ): Promise { const promise = diff --git a/node/ts/net/chat/UnauthMessagesService.ts b/node/ts/net/chat/UnauthMessagesService.ts index 17fef1997..a53e50aa2 100644 --- a/node/ts/net/chat/UnauthMessagesService.ts +++ b/node/ts/net/chat/UnauthMessagesService.ts @@ -25,7 +25,7 @@ declare module '../Chat' { /** See {@link UnauthMessagesService#sendMultiRecipientMessage}. */ export type MultiRecipientMessageRequest = Readonly<{ - payload: Uint8Array; + payload: Uint8Array; timestamp: number; auth: 'story' | GroupSendFullToken; onlineOnly: boolean; diff --git a/node/ts/net/chat/UnauthUsernamesService.ts b/node/ts/net/chat/UnauthUsernamesService.ts index 68f14b4fd..974553474 100644 --- a/node/ts/net/chat/UnauthUsernamesService.ts +++ b/node/ts/net/chat/UnauthUsernamesService.ts @@ -8,7 +8,7 @@ import * as uuid from 'uuid'; import * as Native from '../../Native.js'; import { Aci } from '../../Address.js'; -import { Uuid } from '../../uuid.js'; +import { parseUuid, Uuid } from '../../uuid.js'; import { RequestOptions, UnauthenticatedChatConnection } from '../Chat.js'; // For documentation @@ -35,7 +35,7 @@ export interface UnauthUsernamesService { */ lookUpUsernameHash: ( request: { - hash: Uint8Array; + hash: Uint8Array; }, options?: RequestOptions ) => Promise; @@ -54,17 +54,17 @@ export interface UnauthUsernamesService { lookUpUsernameLink: ( request: { uuid: Uuid; - entropy: Uint8Array; + entropy: Uint8Array; }, options?: RequestOptions - ) => Promise<{ username: string; hash: Uint8Array } | null>; + ) => Promise<{ username: string; hash: Uint8Array } | null>; } UnauthenticatedChatConnection.prototype.lookUpUsernameHash = async function ( { hash, }: { - hash: Uint8Array; + hash: Uint8Array; }, options?: RequestOptions ): Promise { @@ -85,16 +85,16 @@ UnauthenticatedChatConnection.prototype.lookUpUsernameLink = async function ( entropy, }: { uuid: Uuid; - entropy: Uint8Array; + entropy: Uint8Array; }, options?: RequestOptions -): Promise<{ username: string; hash: Uint8Array } | null> { +): Promise<{ username: string; hash: Uint8Array } | null> { const response = await this._asyncContext.makeCancellable( options?.abortSignal, Native.UnauthenticatedChatConnection_look_up_username_link( this._asyncContext, this._chatService, - uuid.parse(linkUuid), + parseUuid(linkUuid), entropy ) ); diff --git a/node/ts/test/BridgingTest.ts b/node/ts/test/BridgingTest.ts index f76dd6523..31edc55ec 100644 --- a/node/ts/test/BridgingTest.ts +++ b/node/ts/test/BridgingTest.ts @@ -3,11 +3,11 @@ // SPDX-License-Identifier: AGPL-3.0-only // -import * as uuid from 'uuid'; import { assert, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import * as Native from '../Native.js'; import { BridgedStringMap } from '../internal.js'; +import { parseUuid } from '../uuid.js'; use(chaiAsPromised); @@ -195,7 +195,7 @@ describe('bridge_fn', () => { const present = Native.TESTING_ConvertOptionalUuid(true); assert.deepEqual( present, - uuid.parse('abababab-1212-8989-baba-565656565656') + parseUuid('abababab-1212-8989-baba-565656565656') ); const absent = Native.TESTING_ConvertOptionalUuid(false); diff --git a/node/ts/test/ChatTest.ts b/node/ts/test/ChatTest.ts index 541c99f5f..b94af79b0 100644 --- a/node/ts/test/ChatTest.ts +++ b/node/ts/test/ChatTest.ts @@ -72,7 +72,7 @@ class ChatServer { let chatServer: ChatServer; let network: Net; -function pemToDer(pem: string): Buffer { +function pemToDer(pem: string): Buffer { const pemContent = pem .replace(/-----BEGIN [^-]+-----/, '') .replace(/-----END [^-]+-----/, '') @@ -128,7 +128,7 @@ describe('chat connection to mock server', () => { async (listener: ConnectionEventsListener | ChatServiceListener) => { const serviceListener = { onIncomingMessage: ( - _envelope: Uint8Array, + _envelope: Uint8Array, _timestamp: number, _ack: ChatServerMessageAck ) => {}, @@ -188,7 +188,7 @@ describe('chat connection to mock server', () => { void promisedAlerts.resolve(alerts); }, onIncomingMessage: ( - _envelope: Uint8Array, + _envelope: Uint8Array, _timestamp: number, _ack: ChatServerMessageAck ) => {}, diff --git a/node/ts/test/HsmEnclaveTest.ts b/node/ts/test/HsmEnclaveTest.ts index 1610fe8eb..321748233 100644 --- a/node/ts/test/HsmEnclaveTest.ts +++ b/node/ts/test/HsmEnclaveTest.ts @@ -20,7 +20,7 @@ describe('HsmEnclaveClient', () => { ); it('create client', () => { - const hashes: Buffer[] = []; + const hashes: Buffer[] = []; hashes.push( Buffer.from( '0000000000000000000000000000000000000000000000000000000000000000', @@ -41,7 +41,7 @@ describe('HsmEnclaveClient', () => { assert.lengthOf(initialMessage, 112, 'initial message length'); }); it('invalid hashes', () => { - const hashes: Buffer[] = []; + const hashes: Buffer[] = []; hashes.push( Buffer.from( '00000000000000000000000000000000000000000000000000000000', @@ -62,7 +62,7 @@ describe('HsmEnclaveClient', () => { } }); it('create client fails with no hashes', () => { - const hashes: Buffer[] = []; + const hashes: Buffer[] = []; try { SignalClient.HsmEnclaveClient.new(validKey, hashes); assert.fail(); @@ -74,7 +74,7 @@ describe('HsmEnclaveClient', () => { } }); it('complete handshake without initial request', () => { - const hashes: Buffer[] = []; + const hashes: Buffer[] = []; hashes.push( Buffer.from( '0000000000000000000000000000000000000000000000000000000000000000', @@ -97,7 +97,7 @@ describe('HsmEnclaveClient', () => { } }); it('established send fails prior to establishment', () => { - const hashes: Buffer[] = []; + const hashes: Buffer[] = []; hashes.push( Buffer.from( '0000000000000000000000000000000000000000000000000000000000000000', @@ -120,7 +120,7 @@ describe('HsmEnclaveClient', () => { } }); it('established recv fails prior to establishment', () => { - const hashes: Buffer[] = []; + const hashes: Buffer[] = []; hashes.push( Buffer.from( '0000000000000000000000000000000000000000000000000000000000000000', diff --git a/node/ts/test/IncrementalMacTest.ts b/node/ts/test/IncrementalMacTest.ts index 066f5940a..5eb6e26b2 100644 --- a/node/ts/test/IncrementalMacTest.ts +++ b/node/ts/test/IncrementalMacTest.ts @@ -132,8 +132,10 @@ describe('Incremental MAC', () => { // Use uneven chunk size to trigger buffering const CHUNK_SIZE = 13579; - function toChunkedReadable(buffer: Uint8Array): stream.Readable { - const chunked = new Array(); + function toChunkedReadable( + buffer: Uint8Array + ): stream.Readable { + const chunked = new Array>(); for (let i = 0; i < buffer.byteLength; i += CHUNK_SIZE) { chunked.push(buffer.subarray(i, i + CHUNK_SIZE)); } diff --git a/node/ts/test/KeyTransparencyTest.ts b/node/ts/test/KeyTransparencyTest.ts index 1919b728a..4576fd4df 100644 --- a/node/ts/test/KeyTransparencyTest.ts +++ b/node/ts/test/KeyTransparencyTest.ts @@ -190,32 +190,34 @@ describe('KeyTransparency Integration', function (this: Mocha.Suite) { }); class InMemoryKtStore implements KT.Store { - storage: Map, Array>>; - distinguished: Readonly | null; + storage: Map, Array>>>; + distinguished: Readonly> | null; constructor() { - this.storage = new Map>>(); + this.storage = new Map>>>(); this.distinguished = null; } // eslint-disable-next-line @typescript-eslint/require-await - async getLastDistinguishedTreeHead(): Promise { + async getLastDistinguishedTreeHead(): Promise | null> { return this.distinguished; } // eslint-disable-next-line @typescript-eslint/require-await - async setLastDistinguishedTreeHead(bytes: Readonly | null) { + async setLastDistinguishedTreeHead( + bytes: Readonly> | null + ) { this.distinguished = bytes; } // eslint-disable-next-line @typescript-eslint/require-await - async getAccountData(aci: Aci): Promise { + async getAccountData(aci: Aci): Promise | null> { const allVersions = this.storage.get(aci) ?? []; return allVersions.at(-1) ?? null; } // eslint-disable-next-line @typescript-eslint/require-await - async setAccountData(aci: Aci, bytes: Readonly) { + async setAccountData(aci: Aci, bytes: Readonly>) { const allVersions = this.storage.get(aci) ?? []; allVersions.push(bytes); this.storage.set(aci, allVersions); diff --git a/node/ts/test/MediaSanitizerTest.ts b/node/ts/test/MediaSanitizerTest.ts index 8fe142538..abf741229 100644 --- a/node/ts/test/MediaSanitizerTest.ts +++ b/node/ts/test/MediaSanitizerTest.ts @@ -193,7 +193,7 @@ function assertSanitizedMetadataEqual( sanitized: SanitizedMetadata, dataOffset: number | bigint, dataLen: number | bigint, - metadata: Uint8Array | null + metadata: Uint8Array | null ) { assert.deepEqual(sanitized.getMetadata(), metadata); assert.equal(sanitized.getDataOffset(), BigInt(dataOffset)); diff --git a/node/ts/test/MessageBackupTest.ts b/node/ts/test/MessageBackupTest.ts index 37f852f25..7c796fa89 100644 --- a/node/ts/test/MessageBackupTest.ts +++ b/node/ts/test/MessageBackupTest.ts @@ -160,7 +160,7 @@ describe('MessageBackup', () => { async close(): Promise { closeCount += 1; } - async read(_amount: number): Promise { + async read(_amount: number): Promise> { return Uint8Array.of(); } async skip(amount: number): Promise { @@ -192,9 +192,11 @@ const exampleBackup = fs.readFileSync( path.join(import.meta.dirname, '../../ts/test/canonical-backup.binproto') ); -function chunkLengthDelimited(binproto: Uint8Array): Uint8Array[] { +function chunkLengthDelimited( + binproto: Uint8Array +): Uint8Array[] { const r = Reader.create(binproto); - const chunks: Uint8Array[] = []; + const chunks: Uint8Array[] = []; while (r.pos < r.len) { const headerStart = r.pos; // start of the varint length prefix @@ -214,7 +216,9 @@ function chunkLengthDelimited(binproto: Uint8Array): Uint8Array[] { return chunks; } -function stripLengthPrefix(chunk: Uint8Array): Uint8Array { +function stripLengthPrefix( + chunk: Uint8Array +): Uint8Array { const reader = Reader.create(chunk); const length = reader.uint32(); const bodyStart = reader.pos; @@ -228,7 +232,9 @@ function stripLengthPrefix(chunk: Uint8Array): Uint8Array { return chunk.subarray(bodyStart, bodyEnd); } -function insertLengthPrefix(chunk: Uint8Array): Uint8Array { +function insertLengthPrefix( + chunk: Uint8Array +): Uint8Array { if (chunk.byteLength > 0x7f) { throw new Error( 'not implemented: chunks with more than one varint byte of length' @@ -245,7 +251,9 @@ const [exampleBackupInfoChunk, ...exampleFrameChunks] = exampleBackupChunks; const exampleBackupInfo = stripLengthPrefix(exampleBackupInfoChunk); const exampleFrames = exampleFrameChunks; -function concatFrames(chunks: ReadonlyArray): Uint8Array { +function concatFrames( + chunks: ReadonlyArray> +): Uint8Array { if (chunks.length === 0) { return new Uint8Array(); } @@ -298,11 +306,11 @@ const VIEW_ONCE_CHAT_ITEM_FRAME = Uint8Array.from( Buffer.from('IhwIChALGAwyDQgKEAsYCZIBBAoCGAGSAQQKAhgB', 'base64') ); -function createDisappearingChatItemFrame(): Uint8Array { +function createDisappearingChatItemFrame(): Uint8Array { return insertLengthPrefix(DISAPPEARING_CHAT_ITEM_FRAME); } -function createViewOnceChatItemFrame(): Uint8Array { +function createViewOnceChatItemFrame(): Uint8Array { return insertLengthPrefix(VIEW_ONCE_CHAT_ITEM_FRAME); } @@ -606,7 +614,7 @@ describe('OnlineBackupValidator', () => { // Here we override that `read` member with one that always produces a Uint8Array, // for more convenient use in the test. Note that this is unchecked. type ReadableUsingUint8Array = Omit & { - read: (size: number) => Uint8Array; + read: (size: number) => Uint8Array; }; const input: ReadableUsingUint8Array = new Readable(); input.push(exampleBackup); @@ -656,7 +664,7 @@ describe('OnlineBackupValidator', () => { // 1: 1 // 2: 1731715200000 // 3: {`00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff`} - const VALID_BACKUP_INFO: Buffer = Buffer.from( + const VALID_BACKUP_INFO: Buffer = Buffer.from( 'CAEQgOiTkrMyGiAAESIzRFVmd4iZqrvM3e7/ABEiM0RVZneImaq7zN3u/w==', 'base64' ); diff --git a/node/ts/test/NetTest.ts b/node/ts/test/NetTest.ts index 858d09815..aeb4e8e18 100644 --- a/node/ts/test/NetTest.ts +++ b/node/ts/test/NetTest.ts @@ -511,7 +511,7 @@ describe('chat service api', () => { // a helper function to check that the message has been passed to the listener async function check( - serverRequest: Uint8Array, + serverRequest: Uint8Array, expectedMethod: sinon.SinonStub, expectedArguments: unknown[] ) { @@ -543,7 +543,7 @@ describe('chat service api', () => { it('messages arrive in order', async () => { const listener: ChatServiceListener = { onIncomingMessage( - _envelope: Uint8Array, + _envelope: Uint8Array, _timestamp: number, _ack: ChatServerMessageAck ): void { @@ -566,7 +566,7 @@ describe('chat service api', () => { ); const completable = new CompletablePromise(); - const callsToMake: Buffer[] = [ + const callsToMake: Buffer[] = [ INCOMING_MESSAGE_1, EMPTY_QUEUE, INVALID_MESSAGE, @@ -617,7 +617,7 @@ describe('chat service api', () => { const connectionInterruptedReasons: (object | null)[] = []; const listener: ChatServiceListener = { onIncomingMessage( - _envelope: Uint8Array, + _envelope: Uint8Array, _timestamp: number, _ack: ChatServerMessageAck ): void { @@ -761,7 +761,7 @@ describe('chat service api', () => { ack.send(200); }, onReceivedEnvelope( - envelope: Uint8Array, + envelope: Uint8Array, ack: ChatServerMessageAck ): void { recordCall('onReceivedEnvelope', envelope); @@ -778,7 +778,7 @@ describe('chat service api', () => { ); const completable = new CompletablePromise(); - const callsToMake: Buffer[] = [ + const callsToMake: Buffer[] = [ PUT_ADDRESS, INVALID_MESSAGE, PUT_ENVELOPE, diff --git a/node/ts/test/SealedSenderServerAPI.ts b/node/ts/test/SealedSenderServerAPI.ts index ae6e4a224..dd5bb251e 100644 --- a/node/ts/test/SealedSenderServerAPI.ts +++ b/node/ts/test/SealedSenderServerAPI.ts @@ -15,7 +15,7 @@ import { assertArrayEquals } from './util.js'; util.initLogger(); -function bufferFromHexStrings(...input: string[]): Buffer { +function bufferFromHexStrings(...input: string[]): Buffer { return Buffer.concat(input.map((s) => Buffer.from(s, 'hex'))); } diff --git a/node/ts/test/ZKGroup-test.ts b/node/ts/test/ZKGroup-test.ts index b7e7a65ed..431c645a3 100644 --- a/node/ts/test/ZKGroup-test.ts +++ b/node/ts/test/ZKGroup-test.ts @@ -101,7 +101,7 @@ describe('ZKGroup', () => { it('deserializationErrorType', () => { function assertDeserializeInvalidThrows( - constructor: new (serialized: Uint8Array) => T + constructor: new (serialized: Uint8Array) => T ) { assert.throws( () => { diff --git a/node/ts/test/ioutil.ts b/node/ts/test/ioutil.ts index 2dbc3d22a..0caabfb86 100644 --- a/node/ts/test/ioutil.ts +++ b/node/ts/test/ioutil.ts @@ -8,7 +8,7 @@ import { InputStream } from '../io.js'; export class ErrorInputStream extends InputStream { public static Error = class extends Error {}; - read(_amount: number): Promise { + read(_amount: number): Promise> { throw new ErrorInputStream.Error(); } skip(_amount: number): Promise { @@ -17,14 +17,14 @@ export class ErrorInputStream extends InputStream { } export class Uint8ArrayInputStream extends InputStream { - data: Uint8Array; + data: Uint8Array; - constructor(data: Uint8Array) { + constructor(data: Uint8Array) { super(); this.data = data; } - read(amount: number): Promise { + read(amount: number): Promise> { const read_amount = Math.min(amount, this.data.length); const read_data = this.data.subarray(0, read_amount); this.data = this.data.subarray(read_amount); diff --git a/node/ts/test/protocol/AddressTest.ts b/node/ts/test/protocol/AddressTest.ts index 344c24523..74c923b12 100644 --- a/node/ts/test/protocol/AddressTest.ts +++ b/node/ts/test/protocol/AddressTest.ts @@ -10,6 +10,7 @@ import { assert, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import * as uuid from 'uuid'; import { Buffer } from 'node:buffer'; +import { parseUuid } from '../../uuid.js'; use(chaiAsPromised); util.initLogger(); @@ -47,14 +48,14 @@ describe('ServiceId', () => { const aci = SignalClient.Aci.fromUuid(testingUuid); assert.instanceOf(aci, SignalClient.Aci); assert.isTrue( - aci.isEqual(SignalClient.Aci.fromUuidBytes(uuid.parse(testingUuid))) + aci.isEqual(SignalClient.Aci.fromUuidBytes(parseUuid(testingUuid))) ); assert.isFalse(aci.isEqual(SignalClient.Pni.fromUuid(testingUuid))); assert.deepEqual(testingUuid, aci.getRawUuid()); - assert.deepEqual(uuid.parse(testingUuid), aci.getRawUuidBytes()); + assert.deepEqual(parseUuid(testingUuid), aci.getRawUuidBytes()); assert.deepEqual(testingUuid, aci.getServiceIdString()); - assert.deepEqual(uuid.parse(testingUuid), aci.getServiceIdBinary()); + assert.deepEqual(parseUuid(testingUuid), aci.getServiceIdBinary()); assert.deepEqual(``, `${aci}`); { @@ -85,12 +86,12 @@ describe('ServiceId', () => { const pni = SignalClient.Pni.fromUuid(testingUuid); assert.instanceOf(pni, SignalClient.Pni); assert.isTrue( - pni.isEqual(SignalClient.Pni.fromUuidBytes(uuid.parse(testingUuid))) + pni.isEqual(SignalClient.Pni.fromUuidBytes(parseUuid(testingUuid))) ); assert.isFalse(pni.isEqual(SignalClient.Aci.fromUuid(testingUuid))); assert.deepEqual(testingUuid, pni.getRawUuid()); - assert.deepEqual(uuid.parse(testingUuid), pni.getRawUuidBytes()); + assert.deepEqual(parseUuid(testingUuid), pni.getRawUuidBytes()); assert.deepEqual(`PNI:${testingUuid}`, pni.getServiceIdString()); assert.deepEqual( Buffer.concat([Buffer.of(0x01), pni.getRawUuidBytes()]), diff --git a/node/ts/test/protocol/TestStores.ts b/node/ts/test/protocol/TestStores.ts index d6c74efca..3d40089c4 100644 --- a/node/ts/test/protocol/TestStores.ts +++ b/node/ts/test/protocol/TestStores.ts @@ -11,7 +11,7 @@ import * as util from '../util.js'; util.initLogger(); export class InMemorySessionStore extends SignalClient.SessionStore { - private state = new Map(); + private state = new Map>(); async saveSession( name: SignalClient.ProtocolAddress, record: SignalClient.SessionRecord @@ -98,7 +98,7 @@ export class InMemoryIdentityKeyStore extends SignalClient.IdentityKeyStore { } export class InMemoryPreKeyStore extends SignalClient.PreKeyStore { - private state = new Map(); + private state = new Map>(); async savePreKey( id: number, record: SignalClient.PreKeyRecord @@ -118,7 +118,7 @@ export class InMemoryPreKeyStore extends SignalClient.PreKeyStore { } export class InMemorySignedPreKeyStore extends SignalClient.SignedPreKeyStore { - private state = new Map(); + private state = new Map>(); async saveSignedPreKey( id: number, record: SignalClient.SignedPreKeyRecord @@ -135,7 +135,7 @@ export class InMemorySignedPreKeyStore extends SignalClient.SignedPreKeyStore { } export class InMemoryKyberPreKeyStore extends SignalClient.KyberPreKeyStore { - private state = new Map(); + private state = new Map>(); private used = new Set(); private baseKeysSeen = new Map(); async saveKyberPreKey( diff --git a/node/ts/test/util.ts b/node/ts/test/util.ts index 6a82665f7..62b8c2469 100644 --- a/node/ts/test/util.ts +++ b/node/ts/test/util.ts @@ -62,14 +62,17 @@ export class CompletablePromise { } } -export function assertByteArray(hex: string, actual: Uint8Array): void { +export function assertByteArray( + hex: string, + actual: Uint8Array +): void { const actualHex = Buffer.from(actual).toString('hex'); assert.strictEqual(hex, actualHex); } export function assertArrayEquals( - expected: Uint8Array, - actual: Uint8Array + expected: Uint8Array, + actual: Uint8Array ): void { const expectedHex = Buffer.from(expected).toString('hex'); const actualHex = Buffer.from(actual).toString('hex'); @@ -77,8 +80,8 @@ export function assertArrayEquals( assert.strictEqual(expectedHex, actualHex); } export function assertArrayNotEquals( - expected: Uint8Array, - actual: Uint8Array + expected: Uint8Array, + actual: Uint8Array ): void { const expectedHex = Buffer.from(expected).toString('hex'); const actualHex = Buffer.from(actual).toString('hex'); diff --git a/node/ts/usernames.ts b/node/ts/usernames.ts index a3d4ffe6c..0b9fa2a67 100644 --- a/node/ts/usernames.ts +++ b/node/ts/usernames.ts @@ -10,8 +10,8 @@ import { RANDOM_LENGTH } from './zkgroup/internal/Constants.js'; import * as Native from './Native.js'; export type UsernameLink = { - entropy: Uint8Array; - encryptedUsername: Uint8Array; + entropy: Uint8Array; + encryptedUsername: Uint8Array; }; export function generateCandidates( @@ -31,7 +31,7 @@ export function fromParts( discriminator: string, minNicknameLength: number, maxNicknameLength: number -): { username: string; hash: Uint8Array } { +): { username: string; hash: Uint8Array } { const hash = Native.Username_HashFromParts( nickname, discriminator, @@ -43,19 +43,19 @@ export function fromParts( return { username, hash }; } -export function hash(username: string): Uint8Array { +export function hash(username: string): Uint8Array { return Native.Username_Hash(username); } -export function generateProof(username: string): Uint8Array { +export function generateProof(username: string): Uint8Array { const random = randomBytes(RANDOM_LENGTH); return generateProofWithRandom(username, random); } export function generateProofWithRandom( username: string, - random: Uint8Array -): Uint8Array { + random: Uint8Array +): Uint8Array { return Native.Username_Proof(username, random); } @@ -68,7 +68,7 @@ export function decryptUsernameLink(usernameLink: UsernameLink): string { export function createUsernameLink( username: string, - previousEntropy?: Uint8Array + previousEntropy?: Uint8Array ): UsernameLink { const usernameLinkData = Native.UsernameLink_Create( username, @@ -80,6 +80,9 @@ export function createUsernameLink( } // Only for testing. Will throw on failure. -export function verifyProof(proof: Uint8Array, hash: Uint8Array): void { +export function verifyProof( + proof: Uint8Array, + hash: Uint8Array +): void { Native.Username_Verify(proof, hash); } diff --git a/node/ts/uuid.ts b/node/ts/uuid.ts index 2099caf13..fb0f1aebe 100644 --- a/node/ts/uuid.ts +++ b/node/ts/uuid.ts @@ -3,4 +3,11 @@ // SPDX-License-Identifier: AGPL-3.0-only // +import * as uuid from 'uuid'; + export type Uuid = string; + +export function parseUuid(input: string): Uint8Array { + // @ts-expect-error See https://github.com/uuidjs/uuid/pull/927 + return uuid.parse(input); +} diff --git a/node/ts/zkgroup/GenericServerPublicParams.ts b/node/ts/zkgroup/GenericServerPublicParams.ts index 546cce810..591f132bb 100644 --- a/node/ts/zkgroup/GenericServerPublicParams.ts +++ b/node/ts/zkgroup/GenericServerPublicParams.ts @@ -9,7 +9,7 @@ import * as Native from '../Native.js'; export default class GenericServerPublicParams extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GenericServerPublicParams_CheckValidContents); } } diff --git a/node/ts/zkgroup/GenericServerSecretParams.ts b/node/ts/zkgroup/GenericServerSecretParams.ts index b47d78dca..8f482a9e1 100644 --- a/node/ts/zkgroup/GenericServerSecretParams.ts +++ b/node/ts/zkgroup/GenericServerSecretParams.ts @@ -19,13 +19,15 @@ export default class GenericServerSecretParams extends ByteArray { return GenericServerSecretParams.generateWithRandom(random); } - static generateWithRandom(random: Uint8Array): GenericServerSecretParams { + static generateWithRandom( + random: Uint8Array + ): GenericServerSecretParams { return new GenericServerSecretParams( Native.GenericServerSecretParams_GenerateDeterministic(random) ); } - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GenericServerSecretParams_CheckValidContents); } diff --git a/node/ts/zkgroup/NotarySignature.ts b/node/ts/zkgroup/NotarySignature.ts index d82665b9b..9118df67a 100644 --- a/node/ts/zkgroup/NotarySignature.ts +++ b/node/ts/zkgroup/NotarySignature.ts @@ -9,7 +9,7 @@ export default class NotarySignature extends ByteArray { private readonly __type?: never; static SIZE = 64; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, NotarySignature.checkLength(NotarySignature.SIZE)); } } diff --git a/node/ts/zkgroup/ServerPublicParams.ts b/node/ts/zkgroup/ServerPublicParams.ts index a65474cf0..591bad247 100644 --- a/node/ts/zkgroup/ServerPublicParams.ts +++ b/node/ts/zkgroup/ServerPublicParams.ts @@ -9,7 +9,7 @@ import NotarySignature from './NotarySignature.js'; export default class ServerPublicParams { readonly _nativeHandle: Native.ServerPublicParams; - constructor(contents: Uint8Array | Native.ServerPublicParams) { + constructor(contents: Uint8Array | Native.ServerPublicParams) { if (contents instanceof Uint8Array) { this._nativeHandle = Native.ServerPublicParams_Deserialize(contents); } else { @@ -22,11 +22,14 @@ export default class ServerPublicParams { * * Allows decoupling RingRTC's use of endorsements from libsignal's. */ - getEndorsementPublicKey(): Uint8Array { + getEndorsementPublicKey(): Uint8Array { return Native.ServerPublicParams_GetEndorsementPublicKey(this); } - verifySignature(message: Uint8Array, notarySignature: NotarySignature): void { + verifySignature( + message: Uint8Array, + notarySignature: NotarySignature + ): void { Native.ServerPublicParams_VerifySignature( this, message, @@ -34,7 +37,7 @@ export default class ServerPublicParams { ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.ServerPublicParams_Serialize(this); } } diff --git a/node/ts/zkgroup/ServerSecretParams.ts b/node/ts/zkgroup/ServerSecretParams.ts index a92207d29..32baf75ec 100644 --- a/node/ts/zkgroup/ServerSecretParams.ts +++ b/node/ts/zkgroup/ServerSecretParams.ts @@ -17,7 +17,9 @@ export default class ServerSecretParams { return ServerSecretParams.generateWithRandom(random); } - static generateWithRandom(random: Uint8Array): ServerSecretParams { + static generateWithRandom( + random: Uint8Array + ): ServerSecretParams { return new ServerSecretParams( Native.ServerSecretParams_GenerateDeterministic(random) ); @@ -25,7 +27,7 @@ export default class ServerSecretParams { readonly _nativeHandle: Native.ServerSecretParams; - constructor(contents: Uint8Array | Native.ServerSecretParams) { + constructor(contents: Uint8Array | Native.ServerSecretParams) { if (contents instanceof Uint8Array) { this._nativeHandle = Native.ServerSecretParams_Deserialize(contents); } else { @@ -39,19 +41,22 @@ export default class ServerSecretParams { ); } - sign(message: Uint8Array): NotarySignature { + sign(message: Uint8Array): NotarySignature { const random = randomBytes(RANDOM_LENGTH); return this.signWithRandom(random, message); } - signWithRandom(random: Uint8Array, message: Uint8Array): NotarySignature { + signWithRandom( + random: Uint8Array, + message: Uint8Array + ): NotarySignature { return new NotarySignature( Native.ServerSecretParams_SignDeterministic(this, random, message) ); } - serialize(): Uint8Array { + serialize(): Uint8Array { return Native.ServerSecretParams_Serialize(this); } } diff --git a/node/ts/zkgroup/auth/AuthCredentialPresentation.ts b/node/ts/zkgroup/auth/AuthCredentialPresentation.ts index 0a2efb704..d4588e7b2 100644 --- a/node/ts/zkgroup/auth/AuthCredentialPresentation.ts +++ b/node/ts/zkgroup/auth/AuthCredentialPresentation.ts @@ -10,7 +10,7 @@ import UuidCiphertext from '../groups/UuidCiphertext.js'; export default class AuthCredentialPresentation extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.AuthCredentialPresentation_CheckValidContents); } diff --git a/node/ts/zkgroup/auth/AuthCredentialWithPni.ts b/node/ts/zkgroup/auth/AuthCredentialWithPni.ts index a38429a61..c0695e36d 100644 --- a/node/ts/zkgroup/auth/AuthCredentialWithPni.ts +++ b/node/ts/zkgroup/auth/AuthCredentialWithPni.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class AuthCredentialWithPni extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.AuthCredentialWithPni_CheckValidContents); } } diff --git a/node/ts/zkgroup/auth/AuthCredentialWithPniResponse.ts b/node/ts/zkgroup/auth/AuthCredentialWithPniResponse.ts index 358cab5e2..4f36b5613 100644 --- a/node/ts/zkgroup/auth/AuthCredentialWithPniResponse.ts +++ b/node/ts/zkgroup/auth/AuthCredentialWithPniResponse.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class AuthCredentialWithPniResponse extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.AuthCredentialWithPniResponse_CheckValidContents); } } diff --git a/node/ts/zkgroup/auth/ClientZkAuthOperations.ts b/node/ts/zkgroup/auth/ClientZkAuthOperations.ts index 760aeb289..1b007c337 100644 --- a/node/ts/zkgroup/auth/ClientZkAuthOperations.ts +++ b/node/ts/zkgroup/auth/ClientZkAuthOperations.ts @@ -58,7 +58,7 @@ export default class ClientZkAuthOperations { } createAuthCredentialWithPniPresentationWithRandom( - random: Uint8Array, + random: Uint8Array, groupSecretParams: GroupSecretParams, authCredential: AuthCredentialWithPni ): AuthCredentialPresentation { diff --git a/node/ts/zkgroup/auth/ServerZkAuthOperations.ts b/node/ts/zkgroup/auth/ServerZkAuthOperations.ts index b45b72692..bd1e25254 100644 --- a/node/ts/zkgroup/auth/ServerZkAuthOperations.ts +++ b/node/ts/zkgroup/auth/ServerZkAuthOperations.ts @@ -36,7 +36,7 @@ export default class ServerZkAuthOperations { } issueAuthCredentialWithPniZkcWithRandom( - random: Uint8Array, + random: Uint8Array, aci: Aci, pni: Pni, redemptionTime: number diff --git a/node/ts/zkgroup/backups/BackupAuthCredential.ts b/node/ts/zkgroup/backups/BackupAuthCredential.ts index 9560ed0ff..c1b57df3d 100644 --- a/node/ts/zkgroup/backups/BackupAuthCredential.ts +++ b/node/ts/zkgroup/backups/BackupAuthCredential.ts @@ -17,7 +17,7 @@ import BackupCredentialType from './BackupCredentialType.js'; export default class BackupAuthCredential extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.BackupAuthCredential_CheckValidContents); } @@ -30,7 +30,7 @@ export default class BackupAuthCredential extends ByteArray { presentWithRandom( serverParams: GenericServerPublicParams, - random: Uint8Array + random: Uint8Array ): BackupAuthCredentialPresentation { return new BackupAuthCredentialPresentation( Native.BackupAuthCredential_PresentDeterministic( @@ -41,7 +41,7 @@ export default class BackupAuthCredential extends ByteArray { ); } - getBackupId(): Uint8Array { + getBackupId(): Uint8Array { return Native.BackupAuthCredential_GetBackupId(this.contents); } diff --git a/node/ts/zkgroup/backups/BackupAuthCredentialPresentation.ts b/node/ts/zkgroup/backups/BackupAuthCredentialPresentation.ts index 0966b2d6a..7654f6adf 100644 --- a/node/ts/zkgroup/backups/BackupAuthCredentialPresentation.ts +++ b/node/ts/zkgroup/backups/BackupAuthCredentialPresentation.ts @@ -13,7 +13,7 @@ import BackupCredentialType from './BackupCredentialType.js'; export default class BackupAuthCredentialPresentation extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.BackupAuthCredentialPresentation_CheckValidContents); } @@ -28,7 +28,7 @@ export default class BackupAuthCredentialPresentation extends ByteArray { ); } - getBackupId(): Uint8Array { + getBackupId(): Uint8Array { return Native.BackupAuthCredentialPresentation_GetBackupId(this.contents); } diff --git a/node/ts/zkgroup/backups/BackupAuthCredentialRequest.ts b/node/ts/zkgroup/backups/BackupAuthCredentialRequest.ts index c1ffb3fce..2266288a6 100644 --- a/node/ts/zkgroup/backups/BackupAuthCredentialRequest.ts +++ b/node/ts/zkgroup/backups/BackupAuthCredentialRequest.ts @@ -17,7 +17,7 @@ import BackupCredentialType from './BackupCredentialType.js'; export default class BackupAuthCredentialRequest extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.BackupAuthCredentialRequest_CheckValidContents); } @@ -42,7 +42,7 @@ export default class BackupAuthCredentialRequest extends ByteArray { backupLevel: BackupLevel, type: BackupCredentialType, params: GenericServerSecretParams, - random: Uint8Array + random: Uint8Array ): BackupAuthCredentialResponse { return new BackupAuthCredentialResponse( Native.BackupAuthCredentialRequest_IssueDeterministic( diff --git a/node/ts/zkgroup/backups/BackupAuthCredentialRequestContext.ts b/node/ts/zkgroup/backups/BackupAuthCredentialRequestContext.ts index 76783f88b..1290be57f 100644 --- a/node/ts/zkgroup/backups/BackupAuthCredentialRequestContext.ts +++ b/node/ts/zkgroup/backups/BackupAuthCredentialRequestContext.ts @@ -3,8 +3,6 @@ // SPDX-License-Identifier: AGPL-3.0-only // -import * as uuid from 'uuid'; - import ByteArray from '../internal/ByteArray.js'; import * as Native from '../../Native.js'; @@ -12,12 +10,12 @@ import BackupAuthCredentialRequest from './BackupAuthCredentialRequest.js'; import BackupAuthCredentialResponse from './BackupAuthCredentialResponse.js'; import BackupAuthCredential from './BackupAuthCredential.js'; import GenericServerPublicParams from '../GenericServerPublicParams.js'; -import type { Uuid } from '../../index.js'; +import { parseUuid, type Uuid } from '../../index.js'; export default class BackupAuthCredentialRequestContext extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super( contents, Native.BackupAuthCredentialRequestContext_CheckValidContents @@ -25,11 +23,11 @@ export default class BackupAuthCredentialRequestContext extends ByteArray { } static create( - backupKey: Uint8Array, + backupKey: Uint8Array, aci: Uuid ): BackupAuthCredentialRequestContext { return new BackupAuthCredentialRequestContext( - Native.BackupAuthCredentialRequestContext_New(backupKey, uuid.parse(aci)) + Native.BackupAuthCredentialRequestContext_New(backupKey, parseUuid(aci)) ); } diff --git a/node/ts/zkgroup/backups/BackupAuthCredentialResponse.ts b/node/ts/zkgroup/backups/BackupAuthCredentialResponse.ts index 988c05c22..c06f8906f 100644 --- a/node/ts/zkgroup/backups/BackupAuthCredentialResponse.ts +++ b/node/ts/zkgroup/backups/BackupAuthCredentialResponse.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class BackupAuthCredentialResponse extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.BackupAuthCredentialResponse_CheckValidContents); } } diff --git a/node/ts/zkgroup/calllinks/CallLinkAuthCredential.ts b/node/ts/zkgroup/calllinks/CallLinkAuthCredential.ts index 9b68f079d..933d3ace1 100644 --- a/node/ts/zkgroup/calllinks/CallLinkAuthCredential.ts +++ b/node/ts/zkgroup/calllinks/CallLinkAuthCredential.ts @@ -17,7 +17,7 @@ import { Aci } from '../../Address.js'; export default class CallLinkAuthCredential extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.CallLinkAuthCredential_CheckValidContents); } @@ -42,7 +42,7 @@ export default class CallLinkAuthCredential extends ByteArray { redemptionTime: number, serverParams: GenericServerPublicParams, callLinkParams: CallLinkSecretParams, - random: Uint8Array + random: Uint8Array ): CallLinkAuthCredentialPresentation { return new CallLinkAuthCredentialPresentation( Native.CallLinkAuthCredential_PresentDeterministic( diff --git a/node/ts/zkgroup/calllinks/CallLinkAuthCredentialPresentation.ts b/node/ts/zkgroup/calllinks/CallLinkAuthCredentialPresentation.ts index 05456596e..17a3a0807 100644 --- a/node/ts/zkgroup/calllinks/CallLinkAuthCredentialPresentation.ts +++ b/node/ts/zkgroup/calllinks/CallLinkAuthCredentialPresentation.ts @@ -13,7 +13,7 @@ import UuidCiphertext from '../groups/UuidCiphertext.js'; export default class CallLinkAuthCredentialPresentation extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super( contents, Native.CallLinkAuthCredentialPresentation_CheckValidContents diff --git a/node/ts/zkgroup/calllinks/CallLinkAuthCredentialResponse.ts b/node/ts/zkgroup/calllinks/CallLinkAuthCredentialResponse.ts index bd2cc6d1f..5e32b34d8 100644 --- a/node/ts/zkgroup/calllinks/CallLinkAuthCredentialResponse.ts +++ b/node/ts/zkgroup/calllinks/CallLinkAuthCredentialResponse.ts @@ -17,7 +17,7 @@ import { Aci } from '../../Address.js'; export default class CallLinkAuthCredentialResponse extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.CallLinkAuthCredentialResponse_CheckValidContents); } @@ -39,7 +39,7 @@ export default class CallLinkAuthCredentialResponse extends ByteArray { userId: Aci, redemptionTime: number, params: GenericServerSecretParams, - random: Uint8Array + random: Uint8Array ): CallLinkAuthCredentialResponse { return new CallLinkAuthCredentialResponse( Native.CallLinkAuthCredentialResponse_IssueDeterministic( diff --git a/node/ts/zkgroup/calllinks/CallLinkPublicParams.ts b/node/ts/zkgroup/calllinks/CallLinkPublicParams.ts index fdfe8b9da..5b924577e 100644 --- a/node/ts/zkgroup/calllinks/CallLinkPublicParams.ts +++ b/node/ts/zkgroup/calllinks/CallLinkPublicParams.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class CallLinkPublicParams extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.CallLinkPublicParams_CheckValidContents); } } diff --git a/node/ts/zkgroup/calllinks/CallLinkSecretParams.ts b/node/ts/zkgroup/calllinks/CallLinkSecretParams.ts index c82032a7b..8ae0b03c5 100644 --- a/node/ts/zkgroup/calllinks/CallLinkSecretParams.ts +++ b/node/ts/zkgroup/calllinks/CallLinkSecretParams.ts @@ -13,13 +13,15 @@ import { Aci } from '../../Address.js'; export default class CallLinkSecretParams extends ByteArray { private readonly __type?: never; - static deriveFromRootKey(callLinkRootKey: Uint8Array): CallLinkSecretParams { + static deriveFromRootKey( + callLinkRootKey: Uint8Array + ): CallLinkSecretParams { return new CallLinkSecretParams( Native.CallLinkSecretParams_DeriveFromRootKey(callLinkRootKey) ); } - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.CallLinkSecretParams_CheckValidContents); } diff --git a/node/ts/zkgroup/calllinks/CreateCallLinkCredential.ts b/node/ts/zkgroup/calllinks/CreateCallLinkCredential.ts index 528db4ff4..a97dc1cc7 100644 --- a/node/ts/zkgroup/calllinks/CreateCallLinkCredential.ts +++ b/node/ts/zkgroup/calllinks/CreateCallLinkCredential.ts @@ -17,12 +17,12 @@ import { Aci } from '../../Address.js'; export default class CreateCallLinkCredential extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.CreateCallLinkCredential_CheckValidContents); } present( - roomId: Uint8Array, + roomId: Uint8Array, userId: Aci, serverParams: GenericServerPublicParams, callLinkParams: CallLinkSecretParams @@ -38,11 +38,11 @@ export default class CreateCallLinkCredential extends ByteArray { } presentWithRandom( - roomId: Uint8Array, + roomId: Uint8Array, userId: Aci, serverParams: GenericServerPublicParams, callLinkParams: CallLinkSecretParams, - random: Uint8Array + random: Uint8Array ): CreateCallLinkCredentialPresentation { return new CreateCallLinkCredentialPresentation( Native.CreateCallLinkCredential_PresentDeterministic( diff --git a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialPresentation.ts b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialPresentation.ts index 2cff5afce..71022264c 100644 --- a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialPresentation.ts +++ b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialPresentation.ts @@ -12,7 +12,7 @@ import GenericServerSecretParams from '../GenericServerSecretParams.js'; export default class CreateCallLinkCredentialPresentation extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super( contents, Native.CreateCallLinkCredentialPresentation_CheckValidContents @@ -20,7 +20,7 @@ export default class CreateCallLinkCredentialPresentation extends ByteArray { } verify( - roomId: Uint8Array, + roomId: Uint8Array, serverParams: GenericServerSecretParams, callLinkParams: CallLinkPublicParams, now: Date = new Date() diff --git a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequest.ts b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequest.ts index 44a44afe1..ef520b747 100644 --- a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequest.ts +++ b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequest.ts @@ -16,7 +16,7 @@ import { Aci } from '../../Address.js'; export default class CreateCallLinkCredentialRequest extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.CreateCallLinkCredentialRequest_CheckValidContents); } @@ -33,7 +33,7 @@ export default class CreateCallLinkCredentialRequest extends ByteArray { userId: Aci, timestamp: number, params: GenericServerSecretParams, - random: Uint8Array + random: Uint8Array ): CreateCallLinkCredentialResponse { return new CreateCallLinkCredentialResponse( Native.CreateCallLinkCredentialRequest_IssueDeterministic( diff --git a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.ts b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.ts index 673ee30c3..b7a3b4a07 100644 --- a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.ts +++ b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.ts @@ -18,21 +18,23 @@ import { Aci } from '../../Address.js'; export default class CreateCallLinkCredentialRequestContext extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super( contents, Native.CreateCallLinkCredentialRequestContext_CheckValidContents ); } - static forRoomId(roomId: Uint8Array): CreateCallLinkCredentialRequestContext { + static forRoomId( + roomId: Uint8Array + ): CreateCallLinkCredentialRequestContext { const random = randomBytes(RANDOM_LENGTH); return this.forRoomIdWithRandom(roomId, random); } static forRoomIdWithRandom( - roomId: Uint8Array, - random: Uint8Array + roomId: Uint8Array, + random: Uint8Array ): CreateCallLinkCredentialRequestContext { return new CreateCallLinkCredentialRequestContext( Native.CreateCallLinkCredentialRequestContext_NewDeterministic( diff --git a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialResponse.ts b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialResponse.ts index edfe87a28..48ac31bae 100644 --- a/node/ts/zkgroup/calllinks/CreateCallLinkCredentialResponse.ts +++ b/node/ts/zkgroup/calllinks/CreateCallLinkCredentialResponse.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class CreateCallLinkCredentialResponse extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.CreateCallLinkCredentialResponse_CheckValidContents); } } diff --git a/node/ts/zkgroup/groups/ClientZkGroupCipher.ts b/node/ts/zkgroup/groups/ClientZkGroupCipher.ts index d95a6142e..be83c939b 100644 --- a/node/ts/zkgroup/groups/ClientZkGroupCipher.ts +++ b/node/ts/zkgroup/groups/ClientZkGroupCipher.ts @@ -62,13 +62,16 @@ export default class ClientZkGroupCipher { ); } - encryptBlob(plaintext: Uint8Array): Uint8Array { + encryptBlob(plaintext: Uint8Array): Uint8Array { const random = randomBytes(RANDOM_LENGTH); return this.encryptBlobWithRandom(random, plaintext); } - encryptBlobWithRandom(random: Uint8Array, plaintext: Uint8Array): Uint8Array { + encryptBlobWithRandom( + random: Uint8Array, + plaintext: Uint8Array + ): Uint8Array { return Native.GroupSecretParams_EncryptBlobWithPaddingDeterministic( this.groupSecretParams.getContents(), random, @@ -77,7 +80,9 @@ export default class ClientZkGroupCipher { ); } - decryptBlob(blobCiphertext: Uint8Array): Uint8Array { + decryptBlob( + blobCiphertext: Uint8Array + ): Uint8Array { return Native.GroupSecretParams_DecryptBlobWithPadding( this.groupSecretParams.getContents(), blobCiphertext diff --git a/node/ts/zkgroup/groups/GroupIdentifier.ts b/node/ts/zkgroup/groups/GroupIdentifier.ts index 63fd2e629..7d5d5d647 100644 --- a/node/ts/zkgroup/groups/GroupIdentifier.ts +++ b/node/ts/zkgroup/groups/GroupIdentifier.ts @@ -10,7 +10,7 @@ export default class GroupIdentifier extends ByteArray { private readonly __type?: never; static SIZE = 32; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, GroupIdentifier.checkLength(GroupIdentifier.SIZE)); } diff --git a/node/ts/zkgroup/groups/GroupMasterKey.ts b/node/ts/zkgroup/groups/GroupMasterKey.ts index 529058f86..ebd34a0df 100644 --- a/node/ts/zkgroup/groups/GroupMasterKey.ts +++ b/node/ts/zkgroup/groups/GroupMasterKey.ts @@ -9,7 +9,7 @@ export default class GroupMasterKey extends ByteArray { private readonly __type?: never; static SIZE = 32; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, GroupMasterKey.checkLength(GroupMasterKey.SIZE)); } } diff --git a/node/ts/zkgroup/groups/GroupPublicParams.ts b/node/ts/zkgroup/groups/GroupPublicParams.ts index 0793be829..a79a1e3c0 100644 --- a/node/ts/zkgroup/groups/GroupPublicParams.ts +++ b/node/ts/zkgroup/groups/GroupPublicParams.ts @@ -10,7 +10,7 @@ import GroupIdentifier from './GroupIdentifier.js'; export default class GroupPublicParams extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GroupPublicParams_CheckValidContents); } diff --git a/node/ts/zkgroup/groups/GroupSecretParams.ts b/node/ts/zkgroup/groups/GroupSecretParams.ts index f08a8aaf7..d6ba7bad5 100644 --- a/node/ts/zkgroup/groups/GroupSecretParams.ts +++ b/node/ts/zkgroup/groups/GroupSecretParams.ts @@ -20,7 +20,9 @@ export default class GroupSecretParams extends ByteArray { return GroupSecretParams.generateWithRandom(random); } - static generateWithRandom(random: Uint8Array): GroupSecretParams { + static generateWithRandom( + random: Uint8Array + ): GroupSecretParams { return new GroupSecretParams( Native.GroupSecretParams_GenerateDeterministic(random) ); @@ -34,7 +36,7 @@ export default class GroupSecretParams extends ByteArray { ); } - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GroupSecretParams_CheckValidContents); } diff --git a/node/ts/zkgroup/groups/ProfileKeyCiphertext.ts b/node/ts/zkgroup/groups/ProfileKeyCiphertext.ts index 6b34360a0..b5261ca65 100644 --- a/node/ts/zkgroup/groups/ProfileKeyCiphertext.ts +++ b/node/ts/zkgroup/groups/ProfileKeyCiphertext.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ProfileKeyCiphertext extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ProfileKeyCiphertext_CheckValidContents); } } diff --git a/node/ts/zkgroup/groups/UuidCiphertext.ts b/node/ts/zkgroup/groups/UuidCiphertext.ts index 0c619674e..89955406a 100644 --- a/node/ts/zkgroup/groups/UuidCiphertext.ts +++ b/node/ts/zkgroup/groups/UuidCiphertext.ts @@ -9,11 +9,13 @@ import * as Native from '../../Native.js'; export default class UuidCiphertext extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.UuidCiphertext_CheckValidContents); } - static serializeAndConcatenate(ciphertexts: UuidCiphertext[]): Uint8Array { + static serializeAndConcatenate( + ciphertexts: UuidCiphertext[] + ): Uint8Array { if (ciphertexts.length == 0) { return Uint8Array.of(); } diff --git a/node/ts/zkgroup/groupsend/GroupSendDerivedKeyPair.ts b/node/ts/zkgroup/groupsend/GroupSendDerivedKeyPair.ts index 452891515..32919e81e 100644 --- a/node/ts/zkgroup/groupsend/GroupSendDerivedKeyPair.ts +++ b/node/ts/zkgroup/groupsend/GroupSendDerivedKeyPair.ts @@ -22,7 +22,7 @@ import type GroupSendEndorsementsResponse from './GroupSendEndorsementsResponse. * @see {@link GroupSendFullToken#verify} */ export default class GroupSendDerivedKeyPair extends ByteArray { - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GroupSendDerivedKeyPair_CheckValidContents); } diff --git a/node/ts/zkgroup/groupsend/GroupSendEndorsement.ts b/node/ts/zkgroup/groupsend/GroupSendEndorsement.ts index 71ae740bb..5d0bc6ff6 100644 --- a/node/ts/zkgroup/groupsend/GroupSendEndorsement.ts +++ b/node/ts/zkgroup/groupsend/GroupSendEndorsement.ts @@ -45,7 +45,10 @@ import CallLinkSecretParams from '../calllinks/CallLinkSecretParams.js'; * it's still cheaper than a usual zkgroup presentation.) */ export default class GroupSendEndorsement extends ByteArray { - constructor(contents: Uint8Array, marker?: typeof UNCHECKED_AND_UNCLONED) { + constructor( + contents: Uint8Array, + marker?: typeof UNCHECKED_AND_UNCLONED + ) { super(contents, marker ?? Native.GroupSendEndorsement_CheckValidContents); } diff --git a/node/ts/zkgroup/groupsend/GroupSendEndorsementsResponse.ts b/node/ts/zkgroup/groupsend/GroupSendEndorsementsResponse.ts index 975e0c415..94b4afe15 100644 --- a/node/ts/zkgroup/groupsend/GroupSendEndorsementsResponse.ts +++ b/node/ts/zkgroup/groupsend/GroupSendEndorsementsResponse.ts @@ -41,7 +41,7 @@ export type ReceivedEndorsements = { * perspective. */ export default class GroupSendEndorsementsResponse extends ByteArray { - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GroupSendEndorsementsResponse_CheckValidContents); } @@ -69,7 +69,7 @@ export default class GroupSendEndorsementsResponse extends ByteArray { public static issueWithRandom( groupMembers: UuidCiphertext[], keyPair: GroupSendDerivedKeyPair, - random: Uint8Array + random: Uint8Array ): GroupSendEndorsementsResponse { return new GroupSendEndorsementsResponse( Native.GroupSendEndorsementsResponse_IssueDeterministic( diff --git a/node/ts/zkgroup/groupsend/GroupSendFullToken.ts b/node/ts/zkgroup/groupsend/GroupSendFullToken.ts index a1c3c32b3..d78b00619 100644 --- a/node/ts/zkgroup/groupsend/GroupSendFullToken.ts +++ b/node/ts/zkgroup/groupsend/GroupSendFullToken.ts @@ -19,7 +19,7 @@ import type { VerificationFailedError } from '../../Errors.js'; * Generated by {@link GroupSendToken#toFullToken}, and verified by the chat server. */ export default class GroupSendFullToken extends ByteArray { - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GroupSendFullToken_CheckValidContents); } diff --git a/node/ts/zkgroup/groupsend/GroupSendToken.ts b/node/ts/zkgroup/groupsend/GroupSendToken.ts index cbb59bb5e..e44c9fcac 100644 --- a/node/ts/zkgroup/groupsend/GroupSendToken.ts +++ b/node/ts/zkgroup/groupsend/GroupSendToken.ts @@ -20,7 +20,7 @@ import type GroupSendEndorsementsResponse from './GroupSendEndorsementsResponse. * Generated by {@link GroupSendEndorsement#toToken}. */ export default class GroupSendToken extends ByteArray { - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.GroupSendToken_CheckValidContents); } diff --git a/node/ts/zkgroup/internal/ByteArray.ts b/node/ts/zkgroup/internal/ByteArray.ts index e0dddbc0a..06907b9dc 100644 --- a/node/ts/zkgroup/internal/ByteArray.ts +++ b/node/ts/zkgroup/internal/ByteArray.ts @@ -9,11 +9,13 @@ import * as Native from '../../Native.js'; export const UNCHECKED_AND_UNCLONED: unique symbol = Symbol(); export default class ByteArray { - contents: Uint8Array; + contents: Uint8Array; protected constructor( - contents: Uint8Array, - checkValid: ((contents: Uint8Array) => void) | typeof UNCHECKED_AND_UNCLONED + contents: Uint8Array, + checkValid: + | ((contents: Uint8Array) => void) + | typeof UNCHECKED_AND_UNCLONED ) { if (checkValid === UNCHECKED_AND_UNCLONED) { this.contents = contents; @@ -25,7 +27,7 @@ export default class ByteArray { protected static checkLength( expectedLength: number - ): (contents: Uint8Array) => void { + ): (contents: Uint8Array) => void { return (contents) => { if (contents.length !== expectedLength) { throw new LibSignalErrorBase( @@ -37,11 +39,11 @@ export default class ByteArray { }; } - public getContents(): Uint8Array { + public getContents(): Uint8Array { return this.contents; } - public serialize(): Uint8Array { + public serialize(): Uint8Array { return Uint8Array.from(this.contents); } } diff --git a/node/ts/zkgroup/profiles/ClientZkProfileOperations.ts b/node/ts/zkgroup/profiles/ClientZkProfileOperations.ts index bfe795977..41491ddf1 100644 --- a/node/ts/zkgroup/profiles/ClientZkProfileOperations.ts +++ b/node/ts/zkgroup/profiles/ClientZkProfileOperations.ts @@ -40,7 +40,7 @@ export default class ClientZkProfileOperations { } createProfileKeyCredentialRequestContextWithRandom( - random: Uint8Array, + random: Uint8Array, userId: Aci, profileKey: ProfileKey ): ProfileKeyCredentialRequestContext { @@ -83,7 +83,7 @@ export default class ClientZkProfileOperations { } createExpiringProfileKeyCredentialPresentationWithRandom( - random: Uint8Array, + random: Uint8Array, groupSecretParams: GroupSecretParams, profileKeyCredential: ExpiringProfileKeyCredential ): ProfileKeyCredentialPresentation { diff --git a/node/ts/zkgroup/profiles/ExpiringProfileKeyCredential.ts b/node/ts/zkgroup/profiles/ExpiringProfileKeyCredential.ts index 0e0d26dba..c1afee59a 100644 --- a/node/ts/zkgroup/profiles/ExpiringProfileKeyCredential.ts +++ b/node/ts/zkgroup/profiles/ExpiringProfileKeyCredential.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ExpiringProfileKeyCredential extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ExpiringProfileKeyCredential_CheckValidContents); } diff --git a/node/ts/zkgroup/profiles/ExpiringProfileKeyCredentialResponse.ts b/node/ts/zkgroup/profiles/ExpiringProfileKeyCredentialResponse.ts index d546e3c76..08a7b9b59 100644 --- a/node/ts/zkgroup/profiles/ExpiringProfileKeyCredentialResponse.ts +++ b/node/ts/zkgroup/profiles/ExpiringProfileKeyCredentialResponse.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ExpiringProfileKeyCredentialResponse extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super( contents, Native.ExpiringProfileKeyCredentialResponse_CheckValidContents diff --git a/node/ts/zkgroup/profiles/ProfileKey.ts b/node/ts/zkgroup/profiles/ProfileKey.ts index 0f72f282a..52cab50fe 100644 --- a/node/ts/zkgroup/profiles/ProfileKey.ts +++ b/node/ts/zkgroup/profiles/ProfileKey.ts @@ -13,7 +13,7 @@ export default class ProfileKey extends ByteArray { private readonly __type?: never; static SIZE = 32; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, ProfileKey.checkLength(ProfileKey.SIZE)); } @@ -35,7 +35,7 @@ export default class ProfileKey extends ByteArray { ); } - deriveAccessKey(): Uint8Array { + deriveAccessKey(): Uint8Array { return Native.ProfileKey_DeriveAccessKey(this.contents); } } diff --git a/node/ts/zkgroup/profiles/ProfileKeyCommitment.ts b/node/ts/zkgroup/profiles/ProfileKeyCommitment.ts index 977edef18..645834e88 100644 --- a/node/ts/zkgroup/profiles/ProfileKeyCommitment.ts +++ b/node/ts/zkgroup/profiles/ProfileKeyCommitment.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ProfileKeyCommitment extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ProfileKeyCommitment_CheckValidContents); } } diff --git a/node/ts/zkgroup/profiles/ProfileKeyCredentialPresentation.ts b/node/ts/zkgroup/profiles/ProfileKeyCredentialPresentation.ts index a1547c096..2c339900b 100644 --- a/node/ts/zkgroup/profiles/ProfileKeyCredentialPresentation.ts +++ b/node/ts/zkgroup/profiles/ProfileKeyCredentialPresentation.ts @@ -11,7 +11,7 @@ import ProfileKeyCiphertext from '../groups/ProfileKeyCiphertext.js'; export default class ProfileKeyCredentialPresentation extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ProfileKeyCredentialPresentation_CheckValidContents); } diff --git a/node/ts/zkgroup/profiles/ProfileKeyCredentialRequest.ts b/node/ts/zkgroup/profiles/ProfileKeyCredentialRequest.ts index f6d8dff6a..e7efcc69a 100644 --- a/node/ts/zkgroup/profiles/ProfileKeyCredentialRequest.ts +++ b/node/ts/zkgroup/profiles/ProfileKeyCredentialRequest.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ProfileKeyCredentialRequest extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ProfileKeyCredentialRequest_CheckValidContents); } } diff --git a/node/ts/zkgroup/profiles/ProfileKeyCredentialRequestContext.ts b/node/ts/zkgroup/profiles/ProfileKeyCredentialRequestContext.ts index 8a855735a..a3392bc72 100644 --- a/node/ts/zkgroup/profiles/ProfileKeyCredentialRequestContext.ts +++ b/node/ts/zkgroup/profiles/ProfileKeyCredentialRequestContext.ts @@ -10,7 +10,7 @@ import ProfileKeyCredentialRequest from './ProfileKeyCredentialRequest.js'; export default class ProfileKeyCredentialRequestContext extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super( contents, Native.ProfileKeyCredentialRequestContext_CheckValidContents diff --git a/node/ts/zkgroup/profiles/ProfileKeyVersion.ts b/node/ts/zkgroup/profiles/ProfileKeyVersion.ts index 1208b2c4c..824040270 100644 --- a/node/ts/zkgroup/profiles/ProfileKeyVersion.ts +++ b/node/ts/zkgroup/profiles/ProfileKeyVersion.ts @@ -9,7 +9,7 @@ export default class ProfileKeyVersion extends ByteArray { private readonly __type?: never; static SIZE = 64; - constructor(contents: Uint8Array | string) { + constructor(contents: Uint8Array | string) { super( typeof contents === 'string' ? new TextEncoder().encode(contents) diff --git a/node/ts/zkgroup/profiles/ServerZkProfileOperations.ts b/node/ts/zkgroup/profiles/ServerZkProfileOperations.ts index 9665ef3d1..a445e4223 100644 --- a/node/ts/zkgroup/profiles/ServerZkProfileOperations.ts +++ b/node/ts/zkgroup/profiles/ServerZkProfileOperations.ts @@ -41,7 +41,7 @@ export default class ServerZkProfileOperations { } issueExpiringProfileKeyCredentialWithRandom( - random: Uint8Array, + random: Uint8Array, profileKeyCredentialRequest: ProfileKeyCredentialRequest, userId: Aci, profileKeyCommitment: ProfileKeyCommitment, diff --git a/node/ts/zkgroup/receipts/ClientZkReceiptOperations.ts b/node/ts/zkgroup/receipts/ClientZkReceiptOperations.ts index 543fea0e9..dec373f8d 100644 --- a/node/ts/zkgroup/receipts/ClientZkReceiptOperations.ts +++ b/node/ts/zkgroup/receipts/ClientZkReceiptOperations.ts @@ -31,7 +31,7 @@ export default class ClientZkReceiptOperations { } createReceiptCredentialRequestContextWithRandom( - random: Uint8Array, + random: Uint8Array, receiptSerial: ReceiptSerial ): ReceiptCredentialRequestContext { return new ReceiptCredentialRequestContext( @@ -67,7 +67,7 @@ export default class ClientZkReceiptOperations { } createReceiptCredentialPresentationWithRandom( - random: Uint8Array, + random: Uint8Array, receiptCredential: ReceiptCredential ): ReceiptCredentialPresentation { return new ReceiptCredentialPresentation( diff --git a/node/ts/zkgroup/receipts/ReceiptCredential.ts b/node/ts/zkgroup/receipts/ReceiptCredential.ts index 60da697a6..7fc5d2d3b 100644 --- a/node/ts/zkgroup/receipts/ReceiptCredential.ts +++ b/node/ts/zkgroup/receipts/ReceiptCredential.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ReceiptCredential extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ReceiptCredential_CheckValidContents); } diff --git a/node/ts/zkgroup/receipts/ReceiptCredentialPresentation.ts b/node/ts/zkgroup/receipts/ReceiptCredentialPresentation.ts index 498d9a091..6d210d634 100644 --- a/node/ts/zkgroup/receipts/ReceiptCredentialPresentation.ts +++ b/node/ts/zkgroup/receipts/ReceiptCredentialPresentation.ts @@ -11,7 +11,7 @@ export default class ReceiptCredentialPresentation extends ByteArray { private readonly __type?: never; static SIZE = 329; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ReceiptCredentialPresentation_CheckValidContents); } diff --git a/node/ts/zkgroup/receipts/ReceiptCredentialRequest.ts b/node/ts/zkgroup/receipts/ReceiptCredentialRequest.ts index ee16798b6..957fc7b8c 100644 --- a/node/ts/zkgroup/receipts/ReceiptCredentialRequest.ts +++ b/node/ts/zkgroup/receipts/ReceiptCredentialRequest.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ReceiptCredentialRequest extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ReceiptCredentialRequest_CheckValidContents); } } diff --git a/node/ts/zkgroup/receipts/ReceiptCredentialRequestContext.ts b/node/ts/zkgroup/receipts/ReceiptCredentialRequestContext.ts index 82f78e489..feb3d03ca 100644 --- a/node/ts/zkgroup/receipts/ReceiptCredentialRequestContext.ts +++ b/node/ts/zkgroup/receipts/ReceiptCredentialRequestContext.ts @@ -11,7 +11,7 @@ export default class ReceiptCredentialRequestContext extends ByteArray { private readonly __type?: never; static SIZE = 177; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ReceiptCredentialRequestContext_CheckValidContents); } diff --git a/node/ts/zkgroup/receipts/ReceiptCredentialResponse.ts b/node/ts/zkgroup/receipts/ReceiptCredentialResponse.ts index e2b76cebf..3177b1fa5 100644 --- a/node/ts/zkgroup/receipts/ReceiptCredentialResponse.ts +++ b/node/ts/zkgroup/receipts/ReceiptCredentialResponse.ts @@ -9,7 +9,7 @@ import * as Native from '../../Native.js'; export default class ReceiptCredentialResponse extends ByteArray { private readonly __type?: never; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, Native.ReceiptCredentialResponse_CheckValidContents); } } diff --git a/node/ts/zkgroup/receipts/ReceiptSerial.ts b/node/ts/zkgroup/receipts/ReceiptSerial.ts index 57179fee0..eb53f880f 100644 --- a/node/ts/zkgroup/receipts/ReceiptSerial.ts +++ b/node/ts/zkgroup/receipts/ReceiptSerial.ts @@ -9,7 +9,7 @@ export default class ReceiptSerial extends ByteArray { private readonly __type?: never; static SIZE = 16; - constructor(contents: Uint8Array) { + constructor(contents: Uint8Array) { super(contents, ReceiptSerial.checkLength(ReceiptSerial.SIZE)); } } diff --git a/node/ts/zkgroup/receipts/ServerZkReceiptOperations.ts b/node/ts/zkgroup/receipts/ServerZkReceiptOperations.ts index 230d82356..19054378e 100644 --- a/node/ts/zkgroup/receipts/ServerZkReceiptOperations.ts +++ b/node/ts/zkgroup/receipts/ServerZkReceiptOperations.ts @@ -33,7 +33,7 @@ export default class ServerZkReceiptOperations { } issueReceiptCredentialWithRandom( - random: Uint8Array, + random: Uint8Array, receiptCredentialRequest: ReceiptCredentialRequest, receiptExpirationTime: number, receiptLevel: bigint diff --git a/node/tsconfig.json b/node/tsconfig.json index 110827926..637b83533 100644 --- a/node/tsconfig.json +++ b/node/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2021", + "target": "es2024", "module": "es2022", "moduleResolution": "bundler", "declaration": true, diff --git a/rust/bridge/node/bin/Native.ts.in b/rust/bridge/node/bin/Native.ts.in index c10b7f994..9b09b04e8 100644 --- a/rust/bridge/node/bin/Native.ts.in +++ b/rust/bridge/node/bin/Native.ts.in @@ -5,7 +5,7 @@ // WARNING: this file was automatically generated -export type Uuid = Uint8Array; +export type Uuid = Uint8Array; /// A Native.Timestamp may be measured in seconds or in milliseconds; /// what's important is that it's an integer less than Number.MAX_SAFE_INTEGER. @@ -28,7 +28,7 @@ export type ChatResponse = { status: number; message: string | undefined; headers: ReadonlyArray<[string, string]>; - body: Uint8Array | undefined; + body: Uint8Array | undefined; }; export type ChatServiceDebugInfo = { @@ -72,11 +72,11 @@ export type SessionStore = BridgeSessionStore; export type SenderKeyStore = BridgeSenderKeyStore; export type InputStream = { - _read: (amount: number) => Promise; + _read: (amount: number) => Promise>; _skip: (amount: number) => Promise; }; -export type SyncInputStream = Uint8Array; +export type SyncInputStream = Uint8Array; export type ChallengeOption = 'pushChallenge' | 'captcha'; @@ -103,8 +103,8 @@ export type CheckSvr2CredentialsResponse = Map< export type SignedPublicPreKey = { keyId: number; - publicKey: Uint8Array; - signature: Uint8Array; + publicKey: Uint8Array; + signature: Uint8Array; }; export type Wrapper = Readonly<{ @@ -128,7 +128,7 @@ export type CancellablePromise = Promise & { }; // eslint-disable-next-line @typescript-eslint/no-unused-vars -export type Serialized = Uint8Array; +export type Serialized = Uint8Array; type ConnectChatBridge = Wrapper; type TestingFutureCancellationGuard = Wrapper; diff --git a/rust/bridge/node/bin/gen_ts_decl.py b/rust/bridge/node/bin/gen_ts_decl.py index 9ad83ab5e..19e4cf0e7 100755 --- a/rust/bridge/node/bin/gen_ts_decl.py +++ b/rust/bridge/node/bin/gen_ts_decl.py @@ -64,7 +64,7 @@ def translate_to_ts(typ: str) -> str: type_map = { '()': 'void', - '&[u8]': 'Uint8Array', + '&[u8]': 'Uint8Array', 'i32': 'number', 'u8': 'number', 'u16': 'number', @@ -73,26 +73,26 @@ def translate_to_ts(typ: str) -> str: 'bool': 'boolean', 'String': 'string', '&str': 'string', - 'Vec': 'Uint8Array', - 'Box<[u8]>': 'Uint8Array', - 'bytes::Bytes': 'Uint8Array', - 'ServiceId': 'Uint8Array', - 'Aci': 'Uint8Array', - 'Pni': 'Uint8Array', + 'Vec': 'Uint8Array', + 'Box<[u8]>': 'Uint8Array', + 'bytes::Bytes': 'Uint8Array', + 'ServiceId': 'Uint8Array', + 'Aci': 'Uint8Array', + 'Pni': 'Uint8Array', 'E164': 'string', - "ServiceIdSequence<'_>": 'Uint8Array', + "ServiceIdSequence<'_>": 'Uint8Array', 'PathAndQuery': 'string', 'LanguageList': 'string[]', - '&BackupKey': 'Uint8Array', - 'MultiRecipientSendAuthorization': 'Uint8Array|null', - 'DisconnectCause': 'Error|null', + '&BackupKey': 'Uint8Array', + 'MultiRecipientSendAuthorization': 'Uint8Array | null', + 'DisconnectCause': 'Error | null', } if typ in type_map: return type_map[typ] if typ.startswith('[u8;') or typ.startswith('&[u8;'): - return 'Uint8Array' + return 'Uint8Array' if typ.startswith('&mutdyn'): return typ[7:] @@ -253,9 +253,9 @@ def collect_decls(crate_dir: str, features: Iterable[str] = ()) -> Iterator[str] print('Exiting with error') sys.exit(1) - comment_decl = re.compile(r'\s*///\s*ts: (.+)') + comment_decl = re.compile(r'\s*///\s*ts: `(.+)`') # Note that the doc attribute is sometimes wrapped onto two lines. - attr_decl = re.compile(r'\s*(?:#\[doc\s*=\s*)?"ts: (.+)"\]') + attr_decl = re.compile(r'\s*(?:#\[doc\s*=\s*)?"ts: `(.+)`"\]') # Make sure /not/ to match arguments with nested parentheses, # which won't survive textual splitting below. diff --git a/rust/bridge/node/src/lib.rs b/rust/bridge/node/src/lib.rs index 00ebef3ba..c55af4607 100644 --- a/rust/bridge/node/src/lib.rs +++ b/rust/bridge/node/src/lib.rs @@ -62,7 +62,7 @@ impl<'a> From> for Handle<'a, JsArray> { } } -/// ts: export function SealedSenderMultiRecipientMessage_Parse(buffer: Uint8Array): SealedSenderMultiRecipientMessage +/// ts: `export function SealedSenderMultiRecipientMessage_Parse(buffer: Uint8Array): SealedSenderMultiRecipientMessage` fn sealed_sender_multi_recipient_message_parse(mut cx: FunctionContext) -> JsResult { let buffer_arg = cx.argument::(0)?; let buffer = AssumedImmutableBuffer::new(&cx, buffer_arg); @@ -143,7 +143,7 @@ fn sealed_sender_multi_recipient_message_parse(mut cx: FunctionContext) -> JsRes Ok(result) } -/// ts: export function MinidumpToJSONString(buffer: Uint8Array): string +/// ts: `export function MinidumpToJSONString(buffer: Uint8Array): string` fn minidump_to_json_string(mut cx: FunctionContext) -> JsResult { let buffer_arg = cx.argument::(0)?; let dump = Minidump::read(buffer_arg.as_slice(&cx)).expect("Failed to parse minidump"); diff --git a/rust/bridge/node/src/logging.rs b/rust/bridge/node/src/logging.rs index 9d6a115b5..63f9258bf 100644 --- a/rust/bridge/node/src/logging.rs +++ b/rust/bridge/node/src/logging.rs @@ -9,7 +9,7 @@ use std::sync::atomic::AtomicBool; use libsignal_bridge::node::SimpleArgTypeInfo; use neon::prelude::*; -/// ts: export const enum LogLevel { Error = 1, Warn, Info, Debug, Trace } +/// ts: `export const enum LogLevel { Error = 1, Warn, Info, Debug, Trace }` #[derive(Clone, Copy)] enum LogLevel { Error = 1, @@ -188,7 +188,7 @@ fn set_max_level_from_js_level(max_level: u32) { log::set_max_level(log::Level::from(level).to_level_filter()); } -/// ts: export function initLogger(maxLevel: LogLevel, callback: (level: LogLevel, target: string, file: string | null, line: number | null, message: string) => void): void +/// ts: `export function initLogger(maxLevel: LogLevel, callback: (level: LogLevel, target: string, file: string | null, line: number | null, message: string) => void): void` pub(crate) fn init_logger(mut cx: FunctionContext) -> JsResult { let max_level_arg = cx.argument::(0)?; let max_level = u32::convert_from(&mut cx, max_level_arg)?; diff --git a/rust/bridge/shared/macros/src/node.rs b/rust/bridge/shared/macros/src/node.rs index 9e490aa4e..59840ff34 100644 --- a/rust/bridge/shared/macros/src/node.rs +++ b/rust/bridge/shared/macros/src/node.rs @@ -240,7 +240,7 @@ fn generate_ts_signature_comment( let result_type_str = result_type_format(result_type(&sig.output)); format!( - "ts: export function {}({}): {}", + "ts: `export function {}({}): {}`", name_without_prefix, ts_args.join(", "), result_type_str @@ -269,7 +269,7 @@ pub(crate) fn bridge_trait(trait_to_bridge: &ItemTrait) -> Result let callback_ts_decls = callbacks.iter().map(|c| &c.ts_decl); let ts_declaration_comment = format!( - "ts: export /*trait*/ type {trait_name} = {{\n{}\n}};", + "ts: `export /*trait*/ type {trait_name} = {{\n{}\n}};`", callback_ts_decls.format("\n") ); diff --git a/rust/bridge/shared/types/src/net/remote_config.rs b/rust/bridge/shared/types/src/net/remote_config.rs index df6345698..748c4f56c 100644 --- a/rust/bridge/shared/types/src/net/remote_config.rs +++ b/rust/bridge/shared/types/src/net/remote_config.rs @@ -81,7 +81,7 @@ macro_rules! define_keys { } impl RemoteConfigKey { - #[doc = concat!("ts: export const NetRemoteConfigKeys = [", $("'", $key, "', "),* ,"] as const;")] + #[doc = concat!("ts: `export const NetRemoteConfigKeys = [", $("'", $key, "', "),* ,"] as const;`")] pub const KEYS: &[&str] = &[$($key),*]; #[cfg(test)] const IDENTITIER_KEY_PAIRS: &[(&str, &str)] = &[ diff --git a/rust/bridge/shared/types/src/node/convert.rs b/rust/bridge/shared/types/src/node/convert.rs index 5391cd1af..c9962c6b8 100644 --- a/rust/bridge/shared/types/src/node/convert.rs +++ b/rust/bridge/shared/types/src/node/convert.rs @@ -1997,7 +1997,7 @@ macro_rules! node_bridge_as_handle { ( $typ:ty as false $(, $($_:tt)*)? ) => {}; ( $typ:ty as $node_name:ident $(, mut = false)? ) => { ::paste::paste! { - #[doc = "ts: interface " $typ " { readonly __type: unique symbol; }"] + #[doc = "ts: `interface " $typ " { readonly __type: unique symbol; }`"] impl node::BridgeHandle for $typ { type Strategy = node::Immutable; } @@ -2038,7 +2038,7 @@ macro_rules! node_bridge_as_handle { }; ( $typ:ty as $node_name:ident, mut = true ) => { ::paste::paste! { - #[doc = "ts: interface " $typ " { readonly __type: unique symbol; }"] + #[doc = "ts: `interface " $typ " { readonly __type: unique symbol; }`"] impl node::BridgeHandle for $typ { type Strategy = node::Mutable; } diff --git a/rust/bridge/shared/types/src/zkgroup.rs b/rust/bridge/shared/types/src/zkgroup.rs index ef2c2e8ed..7c94ced18 100644 --- a/rust/bridge/shared/types/src/zkgroup.rs +++ b/rust/bridge/shared/types/src/zkgroup.rs @@ -34,7 +34,7 @@ macro_rules! bridge_as_fixed_length_serializable { ::paste::paste! { // Declare a marker type for TypeScript, the same as bridge_as_handle. // (This is harmless for the other bridges.) - #[doc = "ts: interface " $typ " { readonly __type: unique symbol; }"] + #[doc = "ts: `interface " $typ " { readonly __type: unique symbol; }`"] impl FixedLengthBincodeSerializable for $typ { type Array = [u8; [<$typ:snake:upper _LEN>]]; } diff --git a/rust/core/src/version.rs b/rust/core/src/version.rs index e6f34ffc7..7473eaf24 100644 --- a/rust/core/src/version.rs +++ b/rust/core/src/version.rs @@ -5,4 +5,4 @@ // The value of this constant is updated by the script // and should not be manually modified -pub const VERSION: &str = "0.88.4"; +pub const VERSION: &str = "0.89.0";