@towns-protocol/sdk
Version:
For more details, visit the following resources:
56 lines • 2.34 kB
TypeScript
import { CryptoStore, GroupEncryptionAlgorithmId, GroupEncryptionCrypto, type EncryptionDeviceInitOpts } from '@towns-protocol/encryption';
import { type StreamRpcClient } from './makeStreamRpcClient';
import { type SignerContext } from './signerContext';
import { makeRiverConfig } from './riverConfig';
import { type ParsedEvent, type ParsedStreamResponse } from './types';
import { type Envelope } from '@towns-protocol/proto';
type Client_Base = {
/** The userId of the Client. */
userId: string;
/** The signer of the Client. */
signer: SignerContext;
/** RPC client that connects to the Towns network. */
rpc: StreamRpcClient;
/** The environment of the Client. */
env: string;
/** Crypto Store */
keychain: CryptoStore;
/** Crypto Backend */
crypto: GroupEncryptionCrypto;
/** Algorithm used for group encryption. */
defaultGroupEncryptionAlgorithm: GroupEncryptionAlgorithmId;
/** Disable hash validation for streams. */
disableHashValidation: boolean;
/** Disable signature validation for streams. */
disableSignatureValidation: boolean;
/** Get a stream by streamId and unpack it */
getStream: (streamId: string) => Promise<ParsedStreamResponse>;
/** Unpack envelope using client config */
unpackEnvelope: (envelope: Envelope) => Promise<ParsedEvent>;
/** Unpack envelopes using client config */
unpackEnvelopes: (envelopes: Envelope[]) => Promise<ParsedEvent[]>;
};
export type ClientV2<extended extends Extended | undefined = Extended | undefined> = Client_Base & (extended extends Extended ? extended : unknown) & {
extend: <const client extends Extended>(fn: (client: ClientV2<extended>) => client) => ClientV2<Prettify<client> & (extended extends Extended ? extended : unknown)>;
};
type Extended = Prettify<{
[_ in keyof Client_Base]?: undefined;
} & {
[key: string]: unknown;
}>;
export type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
type CreateTownsClientParams = {
env: Parameters<typeof makeRiverConfig>[0];
encryptionDevice?: EncryptionDeviceInitOpts;
};
export declare const createTownsClient: (params: ({
privateKey: string;
} | {
mnemonic: string;
} | {
bearerToken: string;
}) & CreateTownsClientParams) => Promise<ClientV2>;
export {};
//# sourceMappingURL=client-v2.d.ts.map