@signalapp/libsignal-client 0.52.4 → 0.53.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/dist/acknowledgments.md +1 -1
- package/dist/net.d.ts +57 -49
- package/dist/net.js +83 -70
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/darwin-x64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/linux-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/linux-x64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/win32-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/win32-x64/@signalapp+libsignal-client.node +0 -0
package/dist/acknowledgments.md
CHANGED
|
@@ -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, libsignal-ffi 0.
|
|
672
|
+
## attest 0.1.0, libsignal-ffi 0.53.0, libsignal-jni 0.53.0, libsignal-jni-testing 0.53.0, libsignal-node 0.53.0, signal-neon-futures 0.1.0, signal-neon-futures-tests 0.1.0, libsignal-bridge 0.1.0, libsignal-bridge-macros 0.1.0, libsignal-bridge-testing 0.1.0, libsignal-bridge-types 0.1.0, libsignal-core 0.1.0, signal-crypto 0.1.0, device-transfer 0.1.0, signal-media 0.1.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, signal-pin 0.1.0, poksho 0.7.0, libsignal-protocol 0.1.0, libsignal-svr3 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
|
@@ -80,47 +80,23 @@ export interface ChatServiceListener {
|
|
|
80
80
|
onConnectionInterrupted(): void;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Provides API methods to connect and communicate with the Chat Service.
|
|
84
|
-
* Before
|
|
85
|
-
* a corresponding `connect*` method must be called.
|
|
83
|
+
* Provides API methods to connect and communicate with the Chat Service over an authenticated channel.
|
|
84
|
+
* Before sending/receiving requests, a {@link #connect()} method must be called.
|
|
86
85
|
* It's also important to call {@link #disconnect()} method when the instance is no longer needed.
|
|
87
86
|
*/
|
|
88
|
-
export declare class
|
|
87
|
+
export declare class AuthenticatedChatService {
|
|
89
88
|
private readonly asyncContext;
|
|
90
89
|
readonly chatService: Wrapper<Native.Chat>;
|
|
91
|
-
constructor(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager);
|
|
92
|
-
/**
|
|
93
|
-
* Sets the listener for server push messages on the authenticated connection.
|
|
94
|
-
*
|
|
95
|
-
* Note that this creates a **non-garbage-collectable** reference to `listener`. If `listener`
|
|
96
|
-
* contains a reference to this ChatService (directly or indirectly), both objects will be kept
|
|
97
|
-
* alive even with no other references. This may be fine if `listener` is a long-lived object
|
|
98
|
-
* anyway, but if not, make sure to eventually break the cycle, possibly by calling
|
|
99
|
-
* {@link #clearListener}.
|
|
100
|
-
*/
|
|
101
|
-
setListener(listener: ChatServiceListener): void;
|
|
102
|
-
clearListener(): void;
|
|
90
|
+
constructor(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager, username: string, password: string, listener: ChatServiceListener);
|
|
103
91
|
/**
|
|
104
92
|
* Initiates termination of the underlying connection to the Chat Service. After the service is
|
|
105
93
|
* disconnected, it will not attempt to automatically reconnect until you call
|
|
106
|
-
* {@link #
|
|
94
|
+
* {@link #connect()}.
|
|
107
95
|
*
|
|
108
|
-
* Note: the same instance of `
|
|
96
|
+
* Note: the same instance of `AuthenticatedChatService` can be reused after {@link #disconnect()} was
|
|
109
97
|
* called.
|
|
110
98
|
*/
|
|
111
99
|
disconnect(): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
|
|
114
|
-
* the service is connected, all the requests will be using the established connection. Also, if
|
|
115
|
-
* the connection is lost for any reason other than the call to {@link #disconnect()}, an
|
|
116
|
-
* automatic reconnect attempt will be made.
|
|
117
|
-
*
|
|
118
|
-
* @throws {AppExpiredError} if the current app version is too old (as judged by the server).
|
|
119
|
-
* @throws {LibSignalError} with other codes for other failures.
|
|
120
|
-
*/
|
|
121
|
-
connectUnauthenticated(options?: {
|
|
122
|
-
abortSignal?: AbortSignal;
|
|
123
|
-
}): Promise<Native.ChatServiceDebugInfo>;
|
|
124
100
|
/**
|
|
125
101
|
* Initiates establishing of the underlying authenticated connection to the Chat Service. Once the
|
|
126
102
|
* service is connected, all the requests will be using the established connection. Also, if the
|
|
@@ -128,61 +104,89 @@ export declare class ChatService {
|
|
|
128
104
|
* reconnect attempt will be made.
|
|
129
105
|
*
|
|
130
106
|
* Calling this method will result in starting to accept incoming requests from the Chat Service.
|
|
131
|
-
* You should set a listener first using {@link #setListener()}.
|
|
132
107
|
*
|
|
133
108
|
* @throws {AppExpiredError} if the current app version is too old (as judged by the server).
|
|
134
109
|
* @throws {DeviceDelinkedError} if the current device has been delinked.
|
|
135
110
|
* @throws {LibSignalError} with other codes for other failures.
|
|
136
111
|
*/
|
|
137
|
-
|
|
112
|
+
connect(options?: {
|
|
138
113
|
abortSignal?: AbortSignal;
|
|
139
114
|
}): Promise<Native.ChatServiceDebugInfo>;
|
|
140
115
|
/**
|
|
141
|
-
* Sends request to the Chat Service over an
|
|
116
|
+
* Sends request to the Chat Service over an authenticated channel.
|
|
142
117
|
*
|
|
143
118
|
* In addition to the response, an object containing debug information about the request flow is
|
|
144
119
|
* returned.
|
|
145
120
|
*
|
|
146
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
121
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connect()} (as a
|
|
147
122
|
* rejection of the promise).
|
|
148
123
|
*/
|
|
149
|
-
|
|
124
|
+
fetchAndDebug(chatRequest: ChatRequest, options?: {
|
|
150
125
|
abortSignal?: AbortSignal;
|
|
151
126
|
}): Promise<Native.ResponseAndDebugInfo>;
|
|
152
127
|
/**
|
|
153
|
-
* Sends request to the Chat Service over an
|
|
128
|
+
* Sends request to the Chat Service over an authenticated channel.
|
|
154
129
|
*
|
|
155
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
130
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connect()} (as a
|
|
156
131
|
* rejection of the promise).
|
|
157
132
|
*/
|
|
158
|
-
|
|
133
|
+
fetch(chatRequest: ChatRequest, options?: {
|
|
159
134
|
abortSignal?: AbortSignal;
|
|
160
135
|
}): Promise<Native.ChatResponse>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Provides API methods to connect and communicate with the Chat Service over an unauthenticated channel.
|
|
139
|
+
* Before sending requests, a {@link #connect()} method must be called.
|
|
140
|
+
* It's also important to call {@link #disconnect()} method when the instance is no longer needed.
|
|
141
|
+
*/
|
|
142
|
+
export declare class UnauthenticatedChatService {
|
|
143
|
+
private readonly asyncContext;
|
|
144
|
+
readonly chatService: Wrapper<Native.Chat>;
|
|
145
|
+
constructor(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager);
|
|
161
146
|
/**
|
|
162
|
-
*
|
|
147
|
+
* Initiates termination of the underlying connection to the Chat Service. After the service is
|
|
148
|
+
* disconnected, it will not attempt to automatically reconnect until you call
|
|
149
|
+
* {@link #connect()}.
|
|
150
|
+
*
|
|
151
|
+
* Note: the same instance of `UnauthenticatedChatService` can be reused after {@link #disconnect()} was
|
|
152
|
+
* called.
|
|
153
|
+
*/
|
|
154
|
+
disconnect(): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
|
|
157
|
+
* the service is connected, all the requests will be using the established connection. Also, if
|
|
158
|
+
* the connection is lost for any reason other than the call to {@link #disconnect()}, an
|
|
159
|
+
* automatic reconnect attempt will be made.
|
|
160
|
+
*
|
|
161
|
+
* @throws {AppExpiredError} if the current app version is too old (as judged by the server).
|
|
162
|
+
* @throws {LibSignalError} with other codes for other failures.
|
|
163
|
+
*/
|
|
164
|
+
connect(options?: {
|
|
165
|
+
abortSignal?: AbortSignal;
|
|
166
|
+
}): Promise<Native.ChatServiceDebugInfo>;
|
|
167
|
+
/**
|
|
168
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
163
169
|
*
|
|
164
170
|
* In addition to the response, an object containing debug information about the request flow is
|
|
165
171
|
* returned.
|
|
166
172
|
*
|
|
167
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
173
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()} (as a
|
|
168
174
|
* rejection of the promise).
|
|
169
175
|
*/
|
|
170
|
-
|
|
176
|
+
fetchAndDebug(chatRequest: ChatRequest, options?: {
|
|
171
177
|
abortSignal?: AbortSignal;
|
|
172
178
|
}): Promise<Native.ResponseAndDebugInfo>;
|
|
173
179
|
/**
|
|
174
|
-
* Sends request to the Chat Service over an
|
|
180
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
175
181
|
*
|
|
176
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
182
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connect()} (as a
|
|
177
183
|
* rejection of the promise).
|
|
178
184
|
*/
|
|
179
|
-
|
|
185
|
+
fetch(chatRequest: ChatRequest, options?: {
|
|
180
186
|
abortSignal?: AbortSignal;
|
|
181
187
|
}): Promise<Native.ChatResponse>;
|
|
182
|
-
static buildHttpRequest(chatRequest: ChatRequest): {
|
|
183
|
-
_nativeHandle: Native.HttpRequest;
|
|
184
|
-
};
|
|
185
188
|
}
|
|
189
|
+
export declare function buildHttpRequest(chatRequest: ChatRequest): Wrapper<Native.HttpRequest>;
|
|
186
190
|
export declare class Net {
|
|
187
191
|
private readonly asyncContext;
|
|
188
192
|
private readonly connectionManager;
|
|
@@ -192,9 +196,13 @@ export declare class Net {
|
|
|
192
196
|
svr3: Svr3Client;
|
|
193
197
|
constructor(env: Environment, userAgent: string);
|
|
194
198
|
/**
|
|
195
|
-
* Creates a new instance of {@link
|
|
199
|
+
* Creates a new instance of {@link AuthenticatedChatService}.
|
|
200
|
+
*/
|
|
201
|
+
newAuthenticatedChatService(username: string, password: string, listener: ChatServiceListener): AuthenticatedChatService;
|
|
202
|
+
/**
|
|
203
|
+
* Creates a new instance of {@link UnauthenticatedChatService}.
|
|
196
204
|
*/
|
|
197
|
-
|
|
205
|
+
newUnauthenticatedChatService(): UnauthenticatedChatService;
|
|
198
206
|
/**
|
|
199
207
|
* Enables/disables IPv6 for all new connections (until changed).
|
|
200
208
|
*
|
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.RestoredSecret = exports.Net = exports.
|
|
7
|
+
exports.RestoredSecret = exports.Net = exports.buildHttpRequest = exports.UnauthenticatedChatService = exports.AuthenticatedChatService = exports.ChatServerMessageAck = exports.TokioAsyncContext = exports.newNativeHandle = exports.Environment = void 0;
|
|
8
8
|
const Native = require("../Native");
|
|
9
9
|
const Address_1 = require("./Address");
|
|
10
10
|
const node_buffer_1 = require("node:buffer");
|
|
@@ -60,27 +60,14 @@ class ChatServerMessageAck {
|
|
|
60
60
|
}
|
|
61
61
|
exports.ChatServerMessageAck = ChatServerMessageAck;
|
|
62
62
|
/**
|
|
63
|
-
* Provides API methods to connect and communicate with the Chat Service.
|
|
64
|
-
* Before
|
|
65
|
-
* a corresponding `connect*` method must be called.
|
|
63
|
+
* Provides API methods to connect and communicate with the Chat Service over an authenticated channel.
|
|
64
|
+
* Before sending/receiving requests, a {@link #connect()} method must be called.
|
|
66
65
|
* It's also important to call {@link #disconnect()} method when the instance is no longer needed.
|
|
67
66
|
*/
|
|
68
|
-
class
|
|
69
|
-
constructor(asyncContext, connectionManager) {
|
|
67
|
+
class AuthenticatedChatService {
|
|
68
|
+
constructor(asyncContext, connectionManager, username, password, listener) {
|
|
70
69
|
this.asyncContext = asyncContext;
|
|
71
|
-
this.chatService = newNativeHandle(Native.ChatService_new(connectionManager,
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Sets the listener for server push messages on the authenticated connection.
|
|
75
|
-
*
|
|
76
|
-
* Note that this creates a **non-garbage-collectable** reference to `listener`. If `listener`
|
|
77
|
-
* contains a reference to this ChatService (directly or indirectly), both objects will be kept
|
|
78
|
-
* alive even with no other references. This may be fine if `listener` is a long-lived object
|
|
79
|
-
* anyway, but if not, make sure to eventually break the cycle, possibly by calling
|
|
80
|
-
* {@link #clearListener}.
|
|
81
|
-
*/
|
|
82
|
-
setListener(listener) {
|
|
83
|
-
const asyncContext = this.asyncContext;
|
|
70
|
+
this.chatService = newNativeHandle(Native.ChatService_new(connectionManager, username, password));
|
|
84
71
|
const nativeChatListener = {
|
|
85
72
|
_incoming_message(envelope, timestamp, ack) {
|
|
86
73
|
listener.onIncomingMessage(envelope, timestamp, new ChatServerMessageAck(asyncContext, ack));
|
|
@@ -94,32 +81,17 @@ class ChatService {
|
|
|
94
81
|
};
|
|
95
82
|
Native.ChatServer_SetListener(asyncContext, this.chatService, nativeChatListener);
|
|
96
83
|
}
|
|
97
|
-
clearListener() {
|
|
98
|
-
Native.ChatServer_SetListener(this.asyncContext, this.chatService, null);
|
|
99
|
-
}
|
|
100
84
|
/**
|
|
101
85
|
* Initiates termination of the underlying connection to the Chat Service. After the service is
|
|
102
86
|
* disconnected, it will not attempt to automatically reconnect until you call
|
|
103
|
-
* {@link #
|
|
87
|
+
* {@link #connect()}.
|
|
104
88
|
*
|
|
105
|
-
* Note: the same instance of `
|
|
89
|
+
* Note: the same instance of `AuthenticatedChatService` can be reused after {@link #disconnect()} was
|
|
106
90
|
* called.
|
|
107
91
|
*/
|
|
108
92
|
disconnect() {
|
|
109
93
|
return Native.ChatService_disconnect(this.asyncContext, this.chatService);
|
|
110
94
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
|
|
113
|
-
* the service is connected, all the requests will be using the established connection. Also, if
|
|
114
|
-
* the connection is lost for any reason other than the call to {@link #disconnect()}, an
|
|
115
|
-
* automatic reconnect attempt will be made.
|
|
116
|
-
*
|
|
117
|
-
* @throws {AppExpiredError} if the current app version is too old (as judged by the server).
|
|
118
|
-
* @throws {LibSignalError} with other codes for other failures.
|
|
119
|
-
*/
|
|
120
|
-
connectUnauthenticated(options) {
|
|
121
|
-
return this.asyncContext.makeCancellable(options?.abortSignal, Native.ChatService_connect_unauth(this.asyncContext, this.chatService));
|
|
122
|
-
}
|
|
123
95
|
/**
|
|
124
96
|
* Initiates establishing of the underlying authenticated connection to the Chat Service. Once the
|
|
125
97
|
* service is connected, all the requests will be using the established connection. Also, if the
|
|
@@ -127,71 +99,106 @@ class ChatService {
|
|
|
127
99
|
* reconnect attempt will be made.
|
|
128
100
|
*
|
|
129
101
|
* Calling this method will result in starting to accept incoming requests from the Chat Service.
|
|
130
|
-
* You should set a listener first using {@link #setListener()}.
|
|
131
102
|
*
|
|
132
103
|
* @throws {AppExpiredError} if the current app version is too old (as judged by the server).
|
|
133
104
|
* @throws {DeviceDelinkedError} if the current device has been delinked.
|
|
134
105
|
* @throws {LibSignalError} with other codes for other failures.
|
|
135
106
|
*/
|
|
136
|
-
|
|
107
|
+
connect(options) {
|
|
137
108
|
return this.asyncContext.makeCancellable(options?.abortSignal, Native.ChatService_connect_auth(this.asyncContext, this.chatService));
|
|
138
109
|
}
|
|
139
110
|
/**
|
|
140
|
-
* Sends request to the Chat Service over an
|
|
111
|
+
* Sends request to the Chat Service over an authenticated channel.
|
|
141
112
|
*
|
|
142
113
|
* In addition to the response, an object containing debug information about the request flow is
|
|
143
114
|
* returned.
|
|
144
115
|
*
|
|
145
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
116
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connect()} (as a
|
|
146
117
|
* rejection of the promise).
|
|
147
118
|
*/
|
|
148
|
-
|
|
149
|
-
return this.asyncContext.makeCancellable(options?.abortSignal, Native.
|
|
119
|
+
fetchAndDebug(chatRequest, options) {
|
|
120
|
+
return this.asyncContext.makeCancellable(options?.abortSignal, Native.ChatService_auth_send_and_debug(this.asyncContext, this.chatService, buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS));
|
|
150
121
|
}
|
|
151
122
|
/**
|
|
152
|
-
* Sends request to the Chat Service over an
|
|
123
|
+
* Sends request to the Chat Service over an authenticated channel.
|
|
153
124
|
*
|
|
154
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
125
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connect()} (as a
|
|
155
126
|
* rejection of the promise).
|
|
156
127
|
*/
|
|
157
|
-
|
|
158
|
-
return this.asyncContext.makeCancellable(options?.abortSignal, Native.
|
|
128
|
+
fetch(chatRequest, options) {
|
|
129
|
+
return this.asyncContext.makeCancellable(options?.abortSignal, Native.ChatService_auth_send(this.asyncContext, this.chatService, buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.AuthenticatedChatService = AuthenticatedChatService;
|
|
133
|
+
/**
|
|
134
|
+
* Provides API methods to connect and communicate with the Chat Service over an unauthenticated channel.
|
|
135
|
+
* Before sending requests, a {@link #connect()} method must be called.
|
|
136
|
+
* It's also important to call {@link #disconnect()} method when the instance is no longer needed.
|
|
137
|
+
*/
|
|
138
|
+
class UnauthenticatedChatService {
|
|
139
|
+
constructor(asyncContext, connectionManager) {
|
|
140
|
+
this.asyncContext = asyncContext;
|
|
141
|
+
this.chatService = newNativeHandle(Native.ChatService_new(connectionManager, '', ''));
|
|
159
142
|
}
|
|
160
143
|
/**
|
|
161
|
-
*
|
|
144
|
+
* Initiates termination of the underlying connection to the Chat Service. After the service is
|
|
145
|
+
* disconnected, it will not attempt to automatically reconnect until you call
|
|
146
|
+
* {@link #connect()}.
|
|
147
|
+
*
|
|
148
|
+
* Note: the same instance of `UnauthenticatedChatService` can be reused after {@link #disconnect()} was
|
|
149
|
+
* called.
|
|
150
|
+
*/
|
|
151
|
+
disconnect() {
|
|
152
|
+
return Native.ChatService_disconnect(this.asyncContext, this.chatService);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
|
|
156
|
+
* the service is connected, all the requests will be using the established connection. Also, if
|
|
157
|
+
* the connection is lost for any reason other than the call to {@link #disconnect()}, an
|
|
158
|
+
* automatic reconnect attempt will be made.
|
|
159
|
+
*
|
|
160
|
+
* @throws {AppExpiredError} if the current app version is too old (as judged by the server).
|
|
161
|
+
* @throws {LibSignalError} with other codes for other failures.
|
|
162
|
+
*/
|
|
163
|
+
connect(options) {
|
|
164
|
+
return this.asyncContext.makeCancellable(options?.abortSignal, Native.ChatService_connect_unauth(this.asyncContext, this.chatService));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
162
168
|
*
|
|
163
169
|
* In addition to the response, an object containing debug information about the request flow is
|
|
164
170
|
* returned.
|
|
165
171
|
*
|
|
166
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
172
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()} (as a
|
|
167
173
|
* rejection of the promise).
|
|
168
174
|
*/
|
|
169
|
-
|
|
170
|
-
return this.asyncContext.makeCancellable(options?.abortSignal, Native.
|
|
175
|
+
fetchAndDebug(chatRequest, options) {
|
|
176
|
+
return this.asyncContext.makeCancellable(options?.abortSignal, Native.ChatService_unauth_send_and_debug(this.asyncContext, this.chatService, buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS));
|
|
171
177
|
}
|
|
172
178
|
/**
|
|
173
|
-
* Sends request to the Chat Service over an
|
|
179
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
174
180
|
*
|
|
175
|
-
* @throws {ChatServiceInactive} if you haven't called {@link #
|
|
181
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connect()} (as a
|
|
176
182
|
* rejection of the promise).
|
|
177
183
|
*/
|
|
178
|
-
|
|
179
|
-
return this.asyncContext.makeCancellable(options?.abortSignal, Native.
|
|
180
|
-
}
|
|
181
|
-
static buildHttpRequest(chatRequest) {
|
|
182
|
-
const { verb, path, body, headers } = chatRequest;
|
|
183
|
-
const bodyBuffer = body !== undefined ? node_buffer_1.Buffer.from(body) : null;
|
|
184
|
-
const httpRequest = {
|
|
185
|
-
_nativeHandle: Native.HttpRequest_new(verb, path, bodyBuffer),
|
|
186
|
-
};
|
|
187
|
-
headers.forEach((header) => {
|
|
188
|
-
const [name, value] = header;
|
|
189
|
-
Native.HttpRequest_add_header(httpRequest, name, value);
|
|
190
|
-
});
|
|
191
|
-
return httpRequest;
|
|
184
|
+
fetch(chatRequest, options) {
|
|
185
|
+
return this.asyncContext.makeCancellable(options?.abortSignal, Native.ChatService_unauth_send(this.asyncContext, this.chatService, buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS));
|
|
192
186
|
}
|
|
193
187
|
}
|
|
194
|
-
exports.
|
|
188
|
+
exports.UnauthenticatedChatService = UnauthenticatedChatService;
|
|
189
|
+
function buildHttpRequest(chatRequest) {
|
|
190
|
+
const { verb, path, body, headers } = chatRequest;
|
|
191
|
+
const bodyBuffer = body !== undefined ? node_buffer_1.Buffer.from(body) : null;
|
|
192
|
+
const httpRequest = {
|
|
193
|
+
_nativeHandle: Native.HttpRequest_new(verb, path, bodyBuffer),
|
|
194
|
+
};
|
|
195
|
+
headers.forEach((header) => {
|
|
196
|
+
const [name, value] = header;
|
|
197
|
+
Native.HttpRequest_add_header(httpRequest, name, value);
|
|
198
|
+
});
|
|
199
|
+
return httpRequest;
|
|
200
|
+
}
|
|
201
|
+
exports.buildHttpRequest = buildHttpRequest;
|
|
195
202
|
class Net {
|
|
196
203
|
constructor(env, userAgent) {
|
|
197
204
|
this.asyncContext = new TokioAsyncContext(Native.TokioAsyncContext_new());
|
|
@@ -199,10 +206,16 @@ class Net {
|
|
|
199
206
|
this.svr3 = new Svr3ClientImpl(this.asyncContext, this.connectionManager);
|
|
200
207
|
}
|
|
201
208
|
/**
|
|
202
|
-
* Creates a new instance of {@link
|
|
209
|
+
* Creates a new instance of {@link AuthenticatedChatService}.
|
|
210
|
+
*/
|
|
211
|
+
newAuthenticatedChatService(username, password, listener) {
|
|
212
|
+
return new AuthenticatedChatService(this.asyncContext, this.connectionManager, username, password, listener);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Creates a new instance of {@link UnauthenticatedChatService}.
|
|
203
216
|
*/
|
|
204
|
-
|
|
205
|
-
return new
|
|
217
|
+
newUnauthenticatedChatService() {
|
|
218
|
+
return new UnauthenticatedChatService(this.asyncContext, this.connectionManager);
|
|
206
219
|
}
|
|
207
220
|
/**
|
|
208
221
|
* Enables/disables IPv6 for all new connections (until changed).
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|