mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-26 01:35:22 +02:00
Bridge look_up_username_hash to app languages
Co-authored-by: Jordan Rose <jrose@signal.org>
This commit is contained in:
45
node/ts/test/chat/ServiceTestUtils.ts
Normal file
45
node/ts/test/chat/ServiceTestUtils.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright 2025 Signal Messenger, LLC.
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
import * as Native from '../../../Native';
|
||||
import { TokioAsyncContext, UnauthenticatedChatConnection } from '../../net';
|
||||
|
||||
/**
|
||||
* A requirement that `Sub` not contain any properties that aren't in `Super`, or properties with
|
||||
* different types.
|
||||
*
|
||||
* Use {@link PickSubset} to generate a type that a `Super` instance can be assigned to. This will
|
||||
* be equivalent to `Sub` in practice, but TypeScript can only figure that out in concrete contexts.
|
||||
*/
|
||||
type Subset<Super, Sub> = Partial<Super> & {
|
||||
[K in Exclude<keyof Sub, keyof Super>]: never;
|
||||
};
|
||||
|
||||
/** See {@link Subset}. */
|
||||
type PickSubset<Super, Sub extends Subset<Super, Sub>> = Pick<
|
||||
Super,
|
||||
keyof Super & keyof Sub
|
||||
>;
|
||||
|
||||
/**
|
||||
* Makes an unauth connection with a fake remote, but forces the caller to specify which APIs they
|
||||
* need from the connection.
|
||||
*/
|
||||
export function connectUnauth<
|
||||
// The default of `object` forces the caller to provide a type explicitly to access any members of
|
||||
// the result.
|
||||
Api extends Subset<UnauthenticatedChatConnection, Api> = object
|
||||
>(
|
||||
tokio: TokioAsyncContext
|
||||
): [
|
||||
PickSubset<UnauthenticatedChatConnection, Api>,
|
||||
Native.Wrapper<Native.FakeChatRemoteEnd>
|
||||
] {
|
||||
return UnauthenticatedChatConnection.fakeConnect(tokio, {
|
||||
onConnectionInterrupted: () => {},
|
||||
onIncomingMessage: () => {},
|
||||
onQueueEmpty: () => {},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user