@signalapp/libsignal-client 0.28.0 → 0.29.1

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/dist/Address.d.ts CHANGED
@@ -35,8 +35,15 @@ export declare class ProtocolAddress {
35
35
  readonly _nativeHandle: Native.ProtocolAddress;
36
36
  private constructor();
37
37
  static _fromNativeHandle(handle: Native.ProtocolAddress): ProtocolAddress;
38
- static new(name: string, deviceId: number): ProtocolAddress;
38
+ static new(name: string | ServiceId, deviceId: number): ProtocolAddress;
39
39
  name(): string;
40
+ /**
41
+ * Returns a ServiceId if this address contains a valid ServiceId, `null` otherwise.
42
+ *
43
+ * In a future release ProtocolAddresses will *only* support ServiceIds.
44
+ */
45
+ serviceId(): ServiceId | null;
40
46
  deviceId(): number;
47
+ toString(): string;
41
48
  }
42
49
  export {};
package/dist/Address.js CHANGED
@@ -89,14 +89,33 @@ class ProtocolAddress {
89
89
  return new ProtocolAddress(handle);
90
90
  }
91
91
  static new(name, deviceId) {
92
+ if (typeof name !== 'string') {
93
+ name = name.getServiceIdString();
94
+ }
92
95
  return new ProtocolAddress(Native.ProtocolAddress_New(name, deviceId));
93
96
  }
94
97
  name() {
95
98
  return Native.ProtocolAddress_Name(this);
96
99
  }
100
+ /**
101
+ * Returns a ServiceId if this address contains a valid ServiceId, `null` otherwise.
102
+ *
103
+ * In a future release ProtocolAddresses will *only* support ServiceIds.
104
+ */
105
+ serviceId() {
106
+ try {
107
+ return ServiceId.parseFromServiceIdString(this.name());
108
+ }
109
+ catch (_a) {
110
+ return null;
111
+ }
112
+ }
97
113
  deviceId() {
98
114
  return Native.ProtocolAddress_DeviceId(this);
99
115
  }
116
+ toString() {
117
+ return `${this.name()}.${this.deviceId()}`;
118
+ }
100
119
  }
101
120
  exports.ProtocolAddress = ProtocolAddress;
102
121
  //# sourceMappingURL=Address.js.map
@@ -1,13 +1,12 @@
1
1
  /// <reference types="node" />
2
+ export type UsernameLink = {
3
+ entropy: Buffer;
4
+ encryptedUsername: Buffer;
5
+ };
2
6
  export declare function generateCandidates(nickname: string, minNicknameLength: number, maxNicknameLength: number): string[];
3
7
  export declare function hash(username: string): Buffer;
4
8
  export declare function generateProof(username: string): Buffer;
5
9
  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
- }
10
+ export declare function decryptUsernameLink(usernameLink: UsernameLink): string;
12
11
  export declare function createUsernameLink(username: string): UsernameLink;
13
12
  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.createUsernameLink = exports.UsernameLink = exports.generateProofWithRandom = exports.generateProof = exports.hash = exports.generateCandidates = void 0;
7
+ exports.verifyProof = exports.createUsernameLink = exports.decryptUsernameLink = 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,21 +26,15 @@ 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
- }
29
+ function decryptUsernameLink(usernameLink) {
30
+ return Native.UsernameLink_DecryptUsername(usernameLink.entropy, usernameLink.encryptedUsername);
37
31
  }
38
- exports.UsernameLink = UsernameLink;
32
+ exports.decryptUsernameLink = decryptUsernameLink;
39
33
  function createUsernameLink(username) {
40
34
  const usernameLinkData = Native.UsernameLink_Create(username);
41
35
  const entropy = usernameLinkData.slice(0, 32);
42
36
  const encryptedUsername = usernameLinkData.slice(32);
43
- return new UsernameLink(entropy, encryptedUsername);
37
+ return { entropy, encryptedUsername };
44
38
  }
45
39
  exports.createUsernameLink = createUsernameLink;
46
40
  // Only for testing. Will throw on failure.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.28.0",
3
+ "version": "0.29.1",
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