@signalapp/libsignal-client 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Native.d.ts CHANGED
@@ -306,6 +306,11 @@ export function ServerSecretParams_SignDeterministic(params: Serialized<ServerSe
306
306
  export function ServerSecretParams_VerifyAuthCredentialPresentation(serverSecretParams: Serialized<ServerSecretParams>, groupPublicParams: Serialized<GroupPublicParams>, presentationBytes: Buffer, currentTimeInSeconds: Timestamp): void;
307
307
  export function ServerSecretParams_VerifyProfileKeyCredentialPresentation(serverSecretParams: Serialized<ServerSecretParams>, groupPublicParams: Serialized<GroupPublicParams>, presentationBytes: Buffer, currentTimeInSeconds: Timestamp): void;
308
308
  export function ServerSecretParams_VerifyReceiptCredentialPresentation(serverSecretParams: Serialized<ServerSecretParams>, presentation: Serialized<ReceiptCredentialPresentation>): void;
309
+ export function ServiceId_ParseFromServiceIdBinary(input: Buffer): Buffer;
310
+ export function ServiceId_ParseFromServiceIdString(input: string): Buffer;
311
+ export function ServiceId_ServiceIdBinary(value: Buffer): Buffer;
312
+ export function ServiceId_ServiceIdLog(value: Buffer): string;
313
+ export function ServiceId_ServiceIdString(value: Buffer): string;
309
314
  export function SessionBuilder_ProcessPreKeyBundle(bundle: Wrapper<PreKeyBundle>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, ctx: null): Promise<void>;
310
315
  export function SessionCipher_DecryptPreKeySignalMessage(message: Wrapper<PreKeySignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore, ctx: null): Promise<Buffer>;
311
316
  export function SessionCipher_DecryptSignalMessage(message: Wrapper<SignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, ctx: null): Promise<Buffer>;
@@ -345,6 +350,8 @@ export function UnidentifiedSenderMessageContent_GetMsgType(m: Wrapper<Unidentif
345
350
  export function UnidentifiedSenderMessageContent_GetSenderCert(m: Wrapper<UnidentifiedSenderMessageContent>): SenderCertificate;
346
351
  export function UnidentifiedSenderMessageContent_New(message: Wrapper<CiphertextMessage>, sender: Wrapper<SenderCertificate>, contentHint: number, groupId: Buffer | null): UnidentifiedSenderMessageContent;
347
352
  export function UnidentifiedSenderMessageContent_Serialize(obj: Wrapper<UnidentifiedSenderMessageContent>): Buffer;
353
+ export function UsernameLink_Create(username: string): Buffer;
354
+ export function UsernameLink_DecryptUsername(entropy: Buffer, encryptedUsername: Buffer): string;
348
355
  export function Username_CandidatesFrom(nickname: string, minLen: number, maxLen: number): string;
349
356
  export function Username_Hash(username: string): Buffer;
350
357
  export function Username_Proof(username: string, randomness: Buffer): Buffer;
package/dist/Address.d.ts CHANGED
@@ -1,4 +1,36 @@
1
+ /// <reference types="node" />
1
2
  import * as Native from '../Native';
3
+ declare enum ServiceIdKind {
4
+ Aci = 0,
5
+ Pni = 1
6
+ }
7
+ type ThisType<T extends {
8
+ prototype: unknown;
9
+ }> = T['prototype'];
10
+ export declare class ServiceId extends Object {
11
+ private readonly serviceIdFixedWidthBinary;
12
+ protected constructor(serviceIdFixedWidthBinary: Buffer);
13
+ protected static fromUuidBytesAndKind<T extends typeof ServiceId>(this: T, uuidBytes: ArrayLike<number>, kind: ServiceIdKind): ThisType<T>;
14
+ getServiceIdBinary(): Buffer;
15
+ getServiceIdString(): string;
16
+ toString(): string;
17
+ private static parseFromServiceIdFixedWidthBinary;
18
+ static parseFromServiceIdBinary(serviceIdBinary: Buffer): ServiceId;
19
+ static parseFromServiceIdString(serviceIdString: string): ServiceId;
20
+ getRawUuid(): string;
21
+ getRawUuidBytes(): Buffer;
22
+ isEqual(other: ServiceId): boolean;
23
+ }
24
+ export declare class Aci extends ServiceId {
25
+ private readonly __type?;
26
+ static fromUuid(uuidString: string): Aci;
27
+ static fromUuidBytes(uuidBytes: ArrayLike<number>): Aci;
28
+ }
29
+ export declare class Pni extends ServiceId {
30
+ private readonly __type?;
31
+ static fromUuid(uuidString: string): Pni;
32
+ static fromUuidBytes(uuidBytes: ArrayLike<number>): Pni;
33
+ }
2
34
  export declare class ProtocolAddress {
3
35
  readonly _nativeHandle: Native.ProtocolAddress;
4
36
  private constructor();
@@ -7,3 +39,4 @@ export declare class ProtocolAddress {
7
39
  name(): string;
8
40
  deviceId(): number;
9
41
  }
42
+ export {};
package/dist/Address.js CHANGED
@@ -4,8 +4,83 @@
4
4
  // SPDX-License-Identifier: AGPL-3.0-only
5
5
  //
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ProtocolAddress = void 0;
7
+ exports.ProtocolAddress = exports.Pni = exports.Aci = exports.ServiceId = void 0;
8
8
  const Native = require("../Native");
9
+ const uuid = require("uuid");
10
+ var ServiceIdKind;
11
+ (function (ServiceIdKind) {
12
+ ServiceIdKind[ServiceIdKind["Aci"] = 0] = "Aci";
13
+ ServiceIdKind[ServiceIdKind["Pni"] = 1] = "Pni";
14
+ })(ServiceIdKind || (ServiceIdKind = {}));
15
+ const SERVICE_ID_FIXED_WIDTH_BINARY_LEN = 17;
16
+ class ServiceId extends Object {
17
+ constructor(serviceIdFixedWidthBinary) {
18
+ super();
19
+ if (serviceIdFixedWidthBinary.length != SERVICE_ID_FIXED_WIDTH_BINARY_LEN) {
20
+ throw new TypeError('invalid Service-Id-FixedWidthBinary');
21
+ }
22
+ this.serviceIdFixedWidthBinary = serviceIdFixedWidthBinary;
23
+ }
24
+ static fromUuidBytesAndKind(uuidBytes, kind) {
25
+ const buffer = Buffer.alloc(SERVICE_ID_FIXED_WIDTH_BINARY_LEN);
26
+ buffer[0] = kind;
27
+ buffer.set(uuidBytes, 1);
28
+ return new this(buffer);
29
+ }
30
+ getServiceIdBinary() {
31
+ return Native.ServiceId_ServiceIdBinary(this.serviceIdFixedWidthBinary);
32
+ }
33
+ getServiceIdString() {
34
+ return Native.ServiceId_ServiceIdString(this.serviceIdFixedWidthBinary);
35
+ }
36
+ toString() {
37
+ return Native.ServiceId_ServiceIdLog(this.serviceIdFixedWidthBinary);
38
+ }
39
+ static parseFromServiceIdFixedWidthBinary(serviceIdFixedWidthBinary) {
40
+ switch (serviceIdFixedWidthBinary[0]) {
41
+ case ServiceIdKind.Aci:
42
+ return new Aci(serviceIdFixedWidthBinary);
43
+ case ServiceIdKind.Pni:
44
+ return new Pni(serviceIdFixedWidthBinary);
45
+ default:
46
+ throw new TypeError('unknown type in Service-Id-FixedWidthBinary');
47
+ }
48
+ }
49
+ static parseFromServiceIdBinary(serviceIdBinary) {
50
+ return ServiceId.parseFromServiceIdFixedWidthBinary(Native.ServiceId_ParseFromServiceIdBinary(serviceIdBinary));
51
+ }
52
+ static parseFromServiceIdString(serviceIdString) {
53
+ return ServiceId.parseFromServiceIdFixedWidthBinary(Native.ServiceId_ParseFromServiceIdString(serviceIdString));
54
+ }
55
+ getRawUuid() {
56
+ return uuid.stringify(this.serviceIdFixedWidthBinary, 1);
57
+ }
58
+ getRawUuidBytes() {
59
+ return Buffer.from(this.serviceIdFixedWidthBinary.buffer, 1);
60
+ }
61
+ isEqual(other) {
62
+ return this.serviceIdFixedWidthBinary.equals(other.serviceIdFixedWidthBinary);
63
+ }
64
+ }
65
+ exports.ServiceId = ServiceId;
66
+ class Aci extends ServiceId {
67
+ static fromUuid(uuidString) {
68
+ return this.fromUuidBytes(uuid.parse(uuidString));
69
+ }
70
+ static fromUuidBytes(uuidBytes) {
71
+ return super.fromUuidBytesAndKind(uuidBytes, ServiceIdKind.Aci);
72
+ }
73
+ }
74
+ exports.Aci = Aci;
75
+ class Pni extends ServiceId {
76
+ static fromUuid(uuidString) {
77
+ return this.fromUuidBytes(uuid.parse(uuidString));
78
+ }
79
+ static fromUuidBytes(uuidBytes) {
80
+ return super.fromUuidBytesAndKind(uuidBytes, ServiceIdKind.Pni);
81
+ }
82
+ }
83
+ exports.Pni = Pni;
9
84
  class ProtocolAddress {
10
85
  constructor(handle) {
11
86
  this._nativeHandle = handle;
package/dist/Errors.d.ts CHANGED
@@ -17,7 +17,10 @@ export declare enum ErrorCode {
17
17
  NicknameTooLong = 13,
18
18
  IoError = 14,
19
19
  InvalidMediaInput = 15,
20
- UnsupportedMediaInput = 16
20
+ UnsupportedMediaInput = 16,
21
+ InputDataTooLong = 17,
22
+ InvalidEntropyDataLength = 18,
23
+ InvalidUsernameLinkEncryptedData = 19
21
24
  }
22
25
  export declare class LibSignalErrorBase extends Error {
23
26
  readonly code: ErrorCode;
@@ -72,6 +75,15 @@ export type NicknameTooShortError = LibSignalErrorCommon & {
72
75
  export type NicknameTooLongError = LibSignalErrorCommon & {
73
76
  code: ErrorCode.NicknameTooLong;
74
77
  };
78
+ export type InputDataTooLong = LibSignalErrorCommon & {
79
+ code: ErrorCode.InputDataTooLong;
80
+ };
81
+ export type InvalidEntropyDataLength = LibSignalErrorCommon & {
82
+ code: ErrorCode.InvalidEntropyDataLength;
83
+ };
84
+ export type InvalidUsernameLinkEncryptedData = LibSignalErrorCommon & {
85
+ code: ErrorCode.InvalidUsernameLinkEncryptedData;
86
+ };
75
87
  export type IoError = LibSignalErrorCommon & {
76
88
  code: ErrorCode.IoError;
77
89
  };
@@ -81,4 +93,4 @@ export type InvalidMediaInputError = LibSignalErrorCommon & {
81
93
  export type UnsupportedMediaInputError = LibSignalErrorCommon & {
82
94
  code: ErrorCode.UnsupportedMediaInput;
83
95
  };
84
- export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | CannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | IoError | InvalidMediaInputError | UnsupportedMediaInputError;
96
+ export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | CannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | InputDataTooLong | InvalidEntropyDataLength | InvalidUsernameLinkEncryptedData | IoError | InvalidMediaInputError | UnsupportedMediaInputError;
package/dist/Errors.js CHANGED
@@ -25,6 +25,9 @@ var ErrorCode;
25
25
  ErrorCode[ErrorCode["IoError"] = 14] = "IoError";
26
26
  ErrorCode[ErrorCode["InvalidMediaInput"] = 15] = "InvalidMediaInput";
27
27
  ErrorCode[ErrorCode["UnsupportedMediaInput"] = 16] = "UnsupportedMediaInput";
28
+ ErrorCode[ErrorCode["InputDataTooLong"] = 17] = "InputDataTooLong";
29
+ ErrorCode[ErrorCode["InvalidEntropyDataLength"] = 18] = "InvalidEntropyDataLength";
30
+ ErrorCode[ErrorCode["InvalidUsernameLinkEncryptedData"] = 19] = "InvalidUsernameLinkEncryptedData";
28
31
  })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
29
32
  class LibSignalErrorBase extends Error {
30
33
  constructor(message, name, operation, extraProps) {
@@ -3,4 +3,11 @@ export declare function generateCandidates(nickname: string, minNicknameLength:
3
3
  export declare function hash(username: string): Buffer;
4
4
  export declare function generateProof(username: string): Buffer;
5
5
  export declare function generateProofWithRandom(username: string, random: Buffer): Buffer;
6
+ export declare class UsernameLink {
7
+ readonly entropy: Buffer;
8
+ readonly encryptedUsername: Buffer;
9
+ constructor(entropy: Buffer, encryptedUsername: Buffer);
10
+ decryptUsername(): string;
11
+ }
12
+ export declare function createUsernameLink(username: string): UsernameLink;
6
13
  export declare function verifyProof(proof: Buffer, hash: Buffer): void;
package/dist/usernames.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // SPDX-License-Identifier: AGPL-3.0-only
5
5
  //
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.verifyProof = exports.generateProofWithRandom = exports.generateProof = exports.hash = exports.generateCandidates = void 0;
7
+ exports.verifyProof = exports.createUsernameLink = exports.UsernameLink = exports.generateProofWithRandom = exports.generateProof = exports.hash = exports.generateCandidates = void 0;
8
8
  /* eslint @typescript-eslint/no-shadow: ["error", { "allow": ["hash"] }] */
9
9
  const crypto_1 = require("crypto");
10
10
  const Constants_1 = require("./zkgroup/internal/Constants");
@@ -26,6 +26,23 @@ function generateProofWithRandom(username, random) {
26
26
  return Native.Username_Proof(username, random);
27
27
  }
28
28
  exports.generateProofWithRandom = generateProofWithRandom;
29
+ class UsernameLink {
30
+ constructor(entropy, encryptedUsername) {
31
+ this.entropy = entropy;
32
+ this.encryptedUsername = encryptedUsername;
33
+ }
34
+ decryptUsername() {
35
+ return Native.UsernameLink_DecryptUsername(this.entropy, this.encryptedUsername);
36
+ }
37
+ }
38
+ exports.UsernameLink = UsernameLink;
39
+ function createUsernameLink(username) {
40
+ const usernameLinkData = Native.UsernameLink_Create(username);
41
+ const entropy = usernameLinkData.slice(0, 32);
42
+ const encryptedUsername = usernameLinkData.slice(32);
43
+ return new UsernameLink(entropy, encryptedUsername);
44
+ }
45
+ exports.createUsernameLink = createUsernameLink;
29
46
  // Only for testing. Will throw on failure.
30
47
  function verifyProof(proof, hash) {
31
48
  Native.Username_Verify(proof, hash);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
Binary file
Binary file
Binary file