@signalapp/libsignal-client 0.43.0 → 0.44.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
@@ -115,9 +115,9 @@ export abstract class InputStream {
115
115
 
116
116
  export abstract class SyncInputStream extends Buffer {}
117
117
 
118
- interface Wrapper<T> {
119
- readonly _nativeHandle: T;
120
- }
118
+ type Wrapper<T> = Readonly<{
119
+ _nativeHandle: T;
120
+ }>;
121
121
 
122
122
  interface MessageBackupValidationOutcome {
123
123
  errorMessage: string | null;
@@ -177,7 +177,9 @@ export function ChatService_unauth_send_and_debug(asyncRuntime: Wrapper<TokioAsy
177
177
  export function CiphertextMessage_FromPlaintextContent(m: Wrapper<PlaintextContent>): CiphertextMessage;
178
178
  export function CiphertextMessage_Serialize(obj: Wrapper<CiphertextMessage>): Buffer;
179
179
  export function CiphertextMessage_Type(msg: Wrapper<CiphertextMessage>): number;
180
+ export function ConnectionManager_clear_proxy(connectionManager: Wrapper<ConnectionManager>): void;
180
181
  export function ConnectionManager_new(environment: number): ConnectionManager;
182
+ export function ConnectionManager_set_proxy(connectionManager: Wrapper<ConnectionManager>, host: string, port: number): void;
181
183
  export function CreateCallLinkCredentialPresentation_CheckValidContents(presentationBytes: Buffer): void;
182
184
  export function CreateCallLinkCredentialPresentation_Verify(presentationBytes: Buffer, roomId: Buffer, now: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer): void;
183
185
  export function CreateCallLinkCredentialRequestContext_CheckValidContents(contextBytes: Buffer): void;
@@ -669,7 +669,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
669
669
 
670
670
  ```
671
671
 
672
- ## attest 0.1.0, device-transfer 0.1.0, libsignal-bridge 0.1.0, libsignal-bridge-macros 0.1.0, libsignal-core 0.1.0, libsignal-ffi 0.43.0, libsignal-jni 0.43.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, libsignal-node 0.43.0, libsignal-protocol 0.1.0, libsignal-svr3 0.1.0, poksho 0.7.0, signal-crypto 0.1.0, signal-media 0.1.0, signal-neon-futures 0.1.0, signal-neon-futures-tests 0.1.0, signal-pin 0.1.0, usernames 0.1.0, zkcredential 0.1.0, zkgroup 0.9.0
672
+ ## attest 0.1.0, device-transfer 0.1.0, libsignal-bridge 0.1.0, libsignal-bridge-macros 0.1.0, libsignal-core 0.1.0, libsignal-ffi 0.44.0, libsignal-jni 0.44.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, libsignal-node 0.44.0, libsignal-protocol 0.1.0, libsignal-svr3 0.1.0, poksho 0.7.0, signal-crypto 0.1.0, signal-media 0.1.0, signal-neon-futures 0.1.0, signal-neon-futures-tests 0.1.0, signal-pin 0.1.0, usernames 0.1.0, zkcredential 0.1.0, zkgroup 0.9.0
673
673
 
674
674
  ```
675
675
  GNU AFFERO GENERAL PUBLIC LICENSE
package/dist/net.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { ReadonlyDeep } from 'type-fest';
3
3
  import * as Native from '../Native';
4
+ import { Wrapper } from '../Native';
4
5
  export declare enum Environment {
5
6
  Staging = 0,
6
7
  Production = 1
@@ -33,31 +34,34 @@ export type ChatRequest = Readonly<{
33
34
  body?: Uint8Array;
34
35
  timeoutMillis?: number;
35
36
  }>;
36
- export declare class Net {
37
- private readonly _asyncContext;
38
- private readonly _chatService;
39
- private readonly _connectionManager;
40
- /**
41
- * Instance of the {@link Svr3Client} to access SVR3.
42
- */
43
- svr3: Svr3Client;
44
- constructor(env: Environment);
37
+ type TokioAsyncContext = Wrapper<Native.TokioAsyncContext>;
38
+ type ConnectionManager = Wrapper<Native.ConnectionManager>;
39
+ /**
40
+ * Provides API methods to connect and communicate with the Chat Service.
41
+ * Before using either authenticated or unauthenticated channels,
42
+ * a corresponding `connect*` method must be called.
43
+ * It's also important to call {@link #disconnect()} method when the instance is no longer needed.
44
+ */
45
+ export declare class ChatService {
46
+ private readonly asyncContext;
47
+ private readonly chatService;
48
+ constructor(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager);
45
49
  /**
46
50
  * Initiates termination of the underlying connection to the Chat Service. After the service is
47
51
  * disconnected, it will not attempt to automatically reconnect until you call
48
- * {@link Net#connectAuthenticatedChatService} and/or {@link Net#connectUnauthenticatedChatService}.
52
+ * {@link #connectAuthenticated()} and/or {@link #connectUnauthenticated()}.
49
53
  *
50
- * Note: the same instance of {@code ChatService} can be reused after {@code disconnect()} was
54
+ * Note: the same instance of `ChatService` can be reused after `disconnect()` was
51
55
  * called.
52
56
  */
53
- disconnectChatService(): Promise<void>;
57
+ disconnect(): Promise<void>;
54
58
  /**
55
59
  * Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
56
60
  * the service is connected, all the requests will be using the established connection. Also, if
57
61
  * the connection is lost for any reason other than the call to {@link #disconnect()}, an
58
62
  * automatic reconnect attempt will be made.
59
63
  */
60
- connectUnauthenticatedChatService(): Promise<Native.ChatServiceDebugInfo>;
64
+ connectUnauthenticated(): Promise<Native.ChatServiceDebugInfo>;
61
65
  /**
62
66
  * Initiates establishing of the underlying authenticated connection to the Chat Service. Once the
63
67
  * service is connected, all the requests will be using the established connection. Also, if the
@@ -66,25 +70,53 @@ export declare class Net {
66
70
  *
67
71
  * Calling this method will result in starting to accept incoming requests from the Chat Service.
68
72
  */
69
- connectAuthenticatedChatService(): Promise<Native.ChatServiceDebugInfo>;
73
+ connectAuthenticated(): Promise<Native.ChatServiceDebugInfo>;
70
74
  /**
71
75
  * Sends request to the Chat Service over an unauthenticated channel.
72
76
  *
73
77
  * In addition to the response, an object containing debug information about the request flow is
74
78
  * returned.
75
79
  *
76
- * @throws {ChatServiceInactive} if you haven't called {@link Net#connectUnauthenticatedChatService()}.
80
+ * @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
77
81
  */
78
82
  unauthenticatedFetchAndDebug(chatRequest: ChatRequest): Promise<Native.ResponseAndDebugInfo>;
79
83
  /**
80
84
  * Sends request to the Chat Service over an unauthenticated channel.
81
85
  *
82
- * @throws {ChatServiceInactive} if you haven't called {@link Net#connectUnauthenticatedChatService()}.
86
+ * @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
83
87
  */
84
88
  unauthenticatedFetch(chatRequest: ChatRequest): Promise<Native.ChatResponse>;
85
89
  static buildHttpRequest(chatRequest: ChatRequest): {
86
90
  _nativeHandle: Native.HttpRequest;
87
91
  };
92
+ }
93
+ export declare class Net {
94
+ private readonly asyncContext;
95
+ private readonly connectionManager;
96
+ /**
97
+ * Instance of the {@link Svr3Client} to access SVR3.
98
+ */
99
+ svr3: Svr3Client;
100
+ constructor(env: Environment);
101
+ /**
102
+ * Creates a new instance of {@link ChatService}.
103
+ */
104
+ newChatService(): ChatService;
105
+ /**
106
+ * Sets the proxy host to be used for all new connections (until overridden).
107
+ *
108
+ * Sets a domain name and port to be used to proxy all new outgoing
109
+ * connections. The proxy can be overridden by calling this method again or
110
+ * unset by calling {@link #clearProxy}.
111
+ */
112
+ setProxy(host: string, port: number): void;
113
+ /**
114
+ * Ensures that future connections will be made directly, not through a proxy.
115
+ *
116
+ * Clears any proxy configuration set via {@link #setProxy}. If none was set, calling this
117
+ * method is a no-op.
118
+ */
119
+ clearProxy(): void;
88
120
  cdsiLookup({ username, password }: Readonly<ServiceAuth>, { e164s, acisAndAccessKeys, returnAcisWithoutUaks, }: ReadonlyDeep<CDSRequestOptionsType>): Promise<CDSResponseType<string, string>>;
89
121
  }
90
122
  /**
@@ -180,3 +212,4 @@ export interface Svr3Client {
180
212
  */
181
213
  restore(password: string, shareSet: Buffer, auth: Readonly<ServiceAuth>): Promise<Buffer>;
182
214
  }
215
+ export {};
package/dist/net.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.Net = exports.Environment = void 0;
7
+ exports.Net = exports.ChatService = exports.Environment = void 0;
8
8
  const Native = require("../Native");
9
9
  const Address_1 = require("./Address");
10
10
  const DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS = 5000;
@@ -14,27 +14,32 @@ var Environment;
14
14
  Environment[Environment["Staging"] = 0] = "Staging";
15
15
  Environment[Environment["Production"] = 1] = "Production";
16
16
  })(Environment = exports.Environment || (exports.Environment = {}));
17
- class Net {
18
- constructor(env) {
19
- this._asyncContext = { _nativeHandle: Native.TokioAsyncContext_new() };
20
- this._connectionManager = {
21
- _nativeHandle: Native.ConnectionManager_new(env),
22
- };
23
- this._chatService = {
24
- _nativeHandle: Native.ChatService_new(this._connectionManager, '', ''),
25
- };
26
- this.svr3 = new Svr3ClientImpl(this._asyncContext, this._connectionManager);
17
+ function newNativeHandle(handle) {
18
+ return {
19
+ _nativeHandle: handle,
20
+ };
21
+ }
22
+ /**
23
+ * Provides API methods to connect and communicate with the Chat Service.
24
+ * Before using either authenticated or unauthenticated channels,
25
+ * a corresponding `connect*` method must be called.
26
+ * It's also important to call {@link #disconnect()} method when the instance is no longer needed.
27
+ */
28
+ class ChatService {
29
+ constructor(asyncContext, connectionManager) {
30
+ this.asyncContext = asyncContext;
31
+ this.chatService = newNativeHandle(Native.ChatService_new(connectionManager, '', ''));
27
32
  }
28
33
  /**
29
34
  * Initiates termination of the underlying connection to the Chat Service. After the service is
30
35
  * disconnected, it will not attempt to automatically reconnect until you call
31
- * {@link Net#connectAuthenticatedChatService} and/or {@link Net#connectUnauthenticatedChatService}.
36
+ * {@link #connectAuthenticated()} and/or {@link #connectUnauthenticated()}.
32
37
  *
33
- * Note: the same instance of {@code ChatService} can be reused after {@code disconnect()} was
38
+ * Note: the same instance of `ChatService` can be reused after `disconnect()` was
34
39
  * called.
35
40
  */
36
- async disconnectChatService() {
37
- await Native.ChatService_disconnect(this._asyncContext, this._chatService);
41
+ async disconnect() {
42
+ await Native.ChatService_disconnect(this.asyncContext, this.chatService);
38
43
  }
39
44
  /**
40
45
  * Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
@@ -42,8 +47,8 @@ class Net {
42
47
  * the connection is lost for any reason other than the call to {@link #disconnect()}, an
43
48
  * automatic reconnect attempt will be made.
44
49
  */
45
- async connectUnauthenticatedChatService() {
46
- return await Native.ChatService_connect_unauth(this._asyncContext, this._chatService);
50
+ async connectUnauthenticated() {
51
+ return await Native.ChatService_connect_unauth(this.asyncContext, this.chatService);
47
52
  }
48
53
  /**
49
54
  * Initiates establishing of the underlying authenticated connection to the Chat Service. Once the
@@ -53,8 +58,8 @@ class Net {
53
58
  *
54
59
  * Calling this method will result in starting to accept incoming requests from the Chat Service.
55
60
  */
56
- async connectAuthenticatedChatService() {
57
- return await Native.ChatService_connect_auth(this._asyncContext, this._chatService);
61
+ async connectAuthenticated() {
62
+ return await Native.ChatService_connect_auth(this.asyncContext, this.chatService);
58
63
  }
59
64
  /**
60
65
  * Sends request to the Chat Service over an unauthenticated channel.
@@ -62,18 +67,18 @@ class Net {
62
67
  * In addition to the response, an object containing debug information about the request flow is
63
68
  * returned.
64
69
  *
65
- * @throws {ChatServiceInactive} if you haven't called {@link Net#connectUnauthenticatedChatService()}.
70
+ * @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
66
71
  */
67
72
  async unauthenticatedFetchAndDebug(chatRequest) {
68
- return await Native.ChatService_unauth_send_and_debug(this._asyncContext, this._chatService, Net.buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS);
73
+ return await Native.ChatService_unauth_send_and_debug(this.asyncContext, this.chatService, ChatService.buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS);
69
74
  }
70
75
  /**
71
76
  * Sends request to the Chat Service over an unauthenticated channel.
72
77
  *
73
- * @throws {ChatServiceInactive} if you haven't called {@link Net#connectUnauthenticatedChatService()}.
78
+ * @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
74
79
  */
75
80
  async unauthenticatedFetch(chatRequest) {
76
- return await Native.ChatService_unauth_send(this._asyncContext, this._chatService, Net.buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS);
81
+ return await Native.ChatService_unauth_send(this.asyncContext, this.chatService, ChatService.buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS);
77
82
  }
78
83
  static buildHttpRequest(chatRequest) {
79
84
  const { verb, path, body, headers } = chatRequest;
@@ -87,8 +92,41 @@ class Net {
87
92
  });
88
93
  return httpRequest;
89
94
  }
95
+ }
96
+ exports.ChatService = ChatService;
97
+ class Net {
98
+ constructor(env) {
99
+ this.asyncContext = newNativeHandle(Native.TokioAsyncContext_new());
100
+ this.connectionManager = newNativeHandle(Native.ConnectionManager_new(env));
101
+ this.svr3 = new Svr3ClientImpl(this.asyncContext, this.connectionManager);
102
+ }
103
+ /**
104
+ * Creates a new instance of {@link ChatService}.
105
+ */
106
+ newChatService() {
107
+ return new ChatService(this.asyncContext, this.connectionManager);
108
+ }
109
+ /**
110
+ * Sets the proxy host to be used for all new connections (until overridden).
111
+ *
112
+ * Sets a domain name and port to be used to proxy all new outgoing
113
+ * connections. The proxy can be overridden by calling this method again or
114
+ * unset by calling {@link #clearProxy}.
115
+ */
116
+ setProxy(host, port) {
117
+ Native.ConnectionManager_set_proxy(this.connectionManager, host, port);
118
+ }
119
+ /**
120
+ * Ensures that future connections will be made directly, not through a proxy.
121
+ *
122
+ * Clears any proxy configuration set via {@link #setProxy}. If none was set, calling this
123
+ * method is a no-op.
124
+ */
125
+ clearProxy() {
126
+ Native.ConnectionManager_clear_proxy(this.connectionManager);
127
+ }
90
128
  async cdsiLookup({ username, password }, { e164s, acisAndAccessKeys, returnAcisWithoutUaks, }) {
91
- const request = { _nativeHandle: Native.LookupRequest_new() };
129
+ const request = newNativeHandle(Native.LookupRequest_new());
92
130
  e164s.forEach((e164) => {
93
131
  Native.LookupRequest_addE164(request, e164);
94
132
  });
@@ -96,23 +134,21 @@ class Net {
96
134
  Native.LookupRequest_addAciAndAccessKey(request, Address_1.Aci.parseFromServiceIdString(aciStr).getServiceIdFixedWidthBinary(), Buffer.from(accessKeyStr, 'base64'));
97
135
  });
98
136
  Native.LookupRequest_setReturnAcisWithoutUaks(request, returnAcisWithoutUaks);
99
- const lookup = await Native.CdsiLookup_new(this._asyncContext, this._connectionManager, username, password, request);
100
- return await Native.CdsiLookup_complete(this._asyncContext, {
101
- _nativeHandle: lookup,
102
- });
137
+ const lookup = await Native.CdsiLookup_new(this.asyncContext, this.connectionManager, username, password, request);
138
+ return await Native.CdsiLookup_complete(this.asyncContext, newNativeHandle(lookup));
103
139
  }
104
140
  }
105
141
  exports.Net = Net;
106
142
  class Svr3ClientImpl {
107
- constructor(_asyncContext, _connectionManager) {
108
- this._asyncContext = _asyncContext;
109
- this._connectionManager = _connectionManager;
143
+ constructor(asyncContext, connectionManager) {
144
+ this.asyncContext = asyncContext;
145
+ this.connectionManager = connectionManager;
110
146
  }
111
147
  async backup(what, password, maxTries, auth) {
112
- return Native.Svr3Backup(this._asyncContext, this._connectionManager, what, password, maxTries, auth.username, auth.password);
148
+ return Native.Svr3Backup(this.asyncContext, this.connectionManager, what, password, maxTries, auth.username, auth.password);
113
149
  }
114
150
  async restore(password, shareSet, auth) {
115
- return Native.Svr3Restore(this._asyncContext, this._connectionManager, password, shareSet, auth.username, auth.password);
151
+ return Native.Svr3Restore(this.asyncContext, this.connectionManager, password, shareSet, auth.username, auth.password);
116
152
  }
117
153
  }
118
154
  //# sourceMappingURL=net.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.43.0",
3
+ "version": "0.44.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