@signalapp/libsignal-client 0.67.4 → 0.67.6

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
@@ -522,6 +522,7 @@ export function TESTING_CdsiLookupErrorConvert(errorDescription: string): void;
522
522
  export function TESTING_CdsiLookupResponseConvert(asyncRuntime: Wrapper<TokioAsyncContext>): CancellablePromise<LookupResponse>;
523
523
  export function TESTING_ChatConnectErrorConvert(errorDescription: string): void;
524
524
  export function TESTING_ChatRequestGetBody(request: Wrapper<HttpRequest>): Buffer;
525
+ export function TESTING_ChatRequestGetHeaderNames(request: Wrapper<HttpRequest>): string[];
525
526
  export function TESTING_ChatRequestGetHeaderValue(request: Wrapper<HttpRequest>, headerName: string): string;
526
527
  export function TESTING_ChatRequestGetMethod(request: Wrapper<HttpRequest>): string;
527
528
  export function TESTING_ChatRequestGetPath(request: Wrapper<HttpRequest>): string;
@@ -538,6 +539,7 @@ export function TESTING_ErrorOnReturnSync(_needsCleanup: null): null;
538
539
  export function TESTING_FakeChatConnection_Create(tokio: Wrapper<TokioAsyncContext>, listener: ChatListener, alertsJoinedByNewlines: string): FakeChatConnection;
539
540
  export function TESTING_FakeChatConnection_TakeAuthenticatedChat(chat: Wrapper<FakeChatConnection>): AuthenticatedChatConnection;
540
541
  export function TESTING_FakeChatConnection_TakeRemote(chat: Wrapper<FakeChatConnection>): FakeChatRemoteEnd;
542
+ export function TESTING_FakeChatConnection_TakeUnauthenticatedChat(chat: Wrapper<FakeChatConnection>): UnauthenticatedChatConnection;
541
543
  export function TESTING_FakeChatRemoteEnd_InjectConnectionInterrupted(chat: Wrapper<FakeChatRemoteEnd>): void;
542
544
  export function TESTING_FakeChatRemoteEnd_ReceiveIncomingRequest(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<FakeChatRemoteEnd>): CancellablePromise<FakeChatSentRequest | null>;
543
545
  export function TESTING_FakeChatRemoteEnd_SendRawServerRequest(chat: Wrapper<FakeChatRemoteEnd>, bytes: Buffer): void;
@@ -86,6 +86,15 @@ export declare class UnauthenticatedChatConnection implements ChatConnection {
86
86
  static connect(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager, listener: ConnectionEventsListener, options?: {
87
87
  abortSignal?: AbortSignal;
88
88
  }): Promise<UnauthenticatedChatConnection>;
89
+ /**
90
+ * Creates a chat connection backed by a fake remote end.
91
+ *
92
+ * @param asyncContext the async runtime to use
93
+ * @param listener the listener to send events to
94
+ * @returns an {@link UnauthenticatedChatConnection} and handle for the remote
95
+ * end of the fake connection.
96
+ */
97
+ static fakeConnect(asyncContext: TokioAsyncContext, listener: ChatServiceListener): [UnauthenticatedChatConnection, Wrapper<Native.FakeChatRemoteEnd>];
89
98
  private constructor();
90
99
  fetch(chatRequest: ChatRequest, options?: {
91
100
  abortSignal?: AbortSignal;
package/dist/net/Chat.js CHANGED
@@ -49,6 +49,23 @@ class UnauthenticatedChatConnection {
49
49
  Native.UnauthenticatedChatConnection_init_listener(connection, new WeakListenerWrapper(nativeChatListener));
50
50
  return new UnauthenticatedChatConnection(asyncContext, connection, nativeChatListener);
51
51
  }
52
+ /**
53
+ * Creates a chat connection backed by a fake remote end.
54
+ *
55
+ * @param asyncContext the async runtime to use
56
+ * @param listener the listener to send events to
57
+ * @returns an {@link UnauthenticatedChatConnection} and handle for the remote
58
+ * end of the fake connection.
59
+ */
60
+ static fakeConnect(asyncContext, listener) {
61
+ const nativeChatListener = makeNativeChatListener(asyncContext, listener);
62
+ const fakeChat = (0, net_1.newNativeHandle)(Native.TESTING_FakeChatConnection_Create(asyncContext, new WeakListenerWrapper(nativeChatListener), ''));
63
+ const chat = (0, net_1.newNativeHandle)(Native.TESTING_FakeChatConnection_TakeUnauthenticatedChat(fakeChat));
64
+ return [
65
+ new UnauthenticatedChatConnection(asyncContext, chat, nativeChatListener),
66
+ (0, net_1.newNativeHandle)(Native.TESTING_FakeChatConnection_TakeRemote(fakeChat)),
67
+ ];
68
+ }
52
69
  constructor(asyncContext, chatService,
53
70
  // Unused except to keep the listener alive since the Rust code only holds a
54
71
  // weak reference to the same object.
@@ -172,8 +189,10 @@ function makeNativeChatListener(asyncContext, listener) {
172
189
  _queue_empty() {
173
190
  throw new Error('Event not supported on unauthenticated connection');
174
191
  },
175
- _received_alerts(_alerts) {
176
- throw new Error('Event not supported on unauthenticated connection');
192
+ _received_alerts(alerts) {
193
+ if (alerts.length != 0) {
194
+ throw new Error(`Got ${alerts.length} unexpected alerts on an unauthenticated connection`);
195
+ }
177
196
  },
178
197
  _connection_interrupted(cause) {
179
198
  listener.onConnectionInterrupted(cause);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.67.4",
3
+ "version": "0.67.6",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",