import { SpaceReviewEventObject, TipSentEventObject } from '@towns-protocol/web3'; import { PlainMessage, ChannelMessage_Post_Mention, ChannelMessage, ChannelMessage_Post, ChannelMessage_Post_Content_Text, ChannelMessage_Post_Content_Image, ChannelMessage_Post_Content_GM, ChannelMessage_Reaction, ChannelMessage_Redaction, StreamEvent, EncryptedData, StreamSettings, SpacePayload_ChannelSettings, FullyReadMarker, Envelope, ChannelMessage_Post_Attachment, ChunkedMedia, UserBio, Tags, BlockchainTransaction, CreationCookie, BlockchainTransaction_TokenTransfer, GetLastMiniblockHashResponse, InfoResponse, InteractionRequestPayload, InteractionResponsePayload, EventRef } from '@towns-protocol/proto'; import { CryptoStore, EnsureOutboundSessionOpts, GroupEncryptionAlgorithmId, GroupEncryptionCrypto, GroupEncryptionSession, IGroupEncryptionClient, UserDevice, UserDeviceCollection, type EncryptionDeviceInitOpts } from '@towns-protocol/encryption'; import { DecryptionEvents, DecryptionExtensionsOptions, EntitlementsDelegate } from './decryptionExtensions'; import { StreamRpcClient } from './makeStreamRpcClient'; import TypedEmitter from 'typed-emitter'; import { UnpackEnvelopeOpts } from './sign'; import { StreamEvents } from './streamEvents'; import { StreamStateView } from './streamStateView'; import { ParsedMiniblock, ClientInitStatus, ContractReceipt, SolanaTransactionReceipt, ParsedEvent, ExclusionFilter } from './types'; import { Stream } from './stream'; import { LoadedStream } from './persistenceStore'; import { SyncedStreams } from './syncedStreams'; import { SyncedStream } from './syncedStream'; import { SignerContext } from './signerContext'; import { StreamsView } from './views/streamsView'; import { NotificationsClient, INotificationStore } from './notificationsClient'; import { RpcOptions } from './rpcCommon'; export type ClientEvents = StreamEvents & DecryptionEvents; export declare enum SyncMode { Full = 0,// load all streams Lite = 1 } export type ClientOptions = { persistenceStoreName?: string; logNamespaceFilter?: string; highPriorityStreamIds?: string[]; unpackEnvelopeOpts?: UnpackEnvelopeOpts; defaultGroupEncryptionAlgorithm?: GroupEncryptionAlgorithmId; logId?: string; notifications?: { url: string; store?: INotificationStore; rpcOptions?: RpcOptions; }; decryptionExtensionsOpts?: DecryptionExtensionsOptions; excludeEventsInScrollback?: ExclusionFilter; syncMode?: SyncMode; }; type SendChannelMessageOptions = { beforeSendEventHook?: Promise; onLocalEventAppended?: (localId: string) => void; disableTags?: boolean; /** * If provided, the app client address will be added to the tags * and the message will be treated as a slash command. */ appClientAddress?: string; }; type SendBlockchainTransactionOptions = { disableTags?: boolean; }; declare const Client_base: new () => TypedEmitter; export declare class Client extends Client_base implements IGroupEncryptionClient { opts?: ClientOptions | undefined; readonly signerContext: SignerContext; readonly rpcClient: StreamRpcClient; readonly userId: string; readonly streams: SyncedStreams; readonly streamsView: StreamsView; readonly logId: string; readonly notifications?: NotificationsClient; readonly excludeEventsInScrollback?: ExclusionFilter; userStreamId?: string; userSettingsStreamId?: string; userMetadataStreamId?: string; userInboxStreamId?: string; private readonly logCall; private readonly logSync; private readonly logEmitFromStream; private readonly logEmitFromClient; private readonly logEvent; private readonly logError; private readonly logInfo; private readonly logDebug; cryptoBackend?: GroupEncryptionCrypto; cryptoStore: CryptoStore; private getStreamRequests; private getStreamExRequests; private initStreamRequests; private getScrollbackRequests; private creatingStreamIds; private entitlementsDelegate; private decryptionExtensions?; private syncedStreamsExtensions; private persistenceStore; private defaultGroupEncryptionAlgorithm; private pendingUsernames; private pendingUsernameTimeouts; constructor(signerContext: SignerContext, rpcClient: StreamRpcClient, cryptoStore: CryptoStore, entitlementsDelegate: EntitlementsDelegate, opts?: ClientOptions | undefined); get streamSyncActive(): boolean; get clientInitStatus(): ClientInitStatus; get cryptoInitialized(): boolean; stop(): Promise; stream(streamId: string | Uint8Array): SyncedStream | undefined; createSyncedStream(streamId: string | Uint8Array): SyncedStream; private initUserJoinedStreams; initializeUser(opts?: { spaceId?: Uint8Array | string; installedAppAddress?: Uint8Array | string; encryptionDeviceInit?: EncryptionDeviceInitOpts; appAddress?: Uint8Array | string; skipSync?: boolean; }): Promise<{ initCryptoTime: number; initUserStreamTime: number; initUserInboxStreamTime: number; initUserMetadataStreamTime: number; initUserSettingsStreamTime: number; }>; onNetworkStatusChanged(isOnline: boolean): void; private initUserStream; private initUserInboxStream; private initUserMetadataStream; private initUserSettingsStream; private getUserStream; private createUserStream; private createUserMetadataStream; private createUserInboxStream; private createUserSettingsStream; private createStreamAndSync; createSpace(spaceAddressOrId: string): Promise<{ streamId: string; }>; createChannel(spaceId: string | Uint8Array, _channelName: string, _channelTopic: string, inChannelId: string | Uint8Array, streamSettings?: PlainMessage, channelSettings?: PlainMessage): Promise<{ streamId: string; }>; createDMChannel(userId: string, appAddress?: string, streamSettings?: PlainMessage): Promise<{ streamId: string; }>; createGDMChannel(userIds: string[], channelProperties?: EncryptedData, streamSettings?: PlainMessage): Promise<{ streamId: string; }>; createMediaStream(channelId: string | Uint8Array | undefined, spaceId: string | Uint8Array | undefined, userId: string | undefined, chunkCount: number, firstChunk?: Uint8Array, firstChunkIv?: Uint8Array, streamSettings?: PlainMessage, perChunkEncryption?: boolean): Promise<{ creationCookie: CreationCookie; }>; updateChannel(spaceId: string | Uint8Array, channelId: string | Uint8Array, unused1: string, unused2: string): Promise<{ eventId: string; newEvents: EventRef[]; }>; updateChannelAutojoin(spaceId: string | Uint8Array, channelId: string | Uint8Array, autojoin: boolean): Promise<{ eventId: string; newEvents: EventRef[]; }>; updateChannelHideUserJoinLeaveEvents(spaceId: string | Uint8Array, channelId: string | Uint8Array, hideUserJoinLeaveEvents: boolean): Promise<{ eventId: string; newEvents: EventRef[]; }>; updateGDMChannelProperties(streamId: string, channelName: string, channelTopic: string): Promise<{ eventId: string; newEvents: EventRef[]; }>; setStreamEncryptionAlgorithm(streamId: string, encryptionAlgorithm?: string): Promise<{ eventId: string; newEvents: EventRef[]; }>; sendFullyReadMarkers(channelId: string | Uint8Array, fullyReadMarkers: Record): Promise<{ eventId: string; newEvents: EventRef[]; }>; updateUserBlock(userId: string, isBlocked: boolean): Promise<{ eventId: string; newEvents: EventRef[]; }>; setSpaceImage(spaceStreamId: string, chunkedMediaInfo: PlainMessage): Promise<{ eventId: string; newEvents: EventRef[]; }>; setUserProfileImage(chunkedMediaInfo: PlainMessage, userId?: string): Promise<{ eventId: string; newEvents: EventRef[]; }>; getUserProfileImage(userId: string | Uint8Array): Promise; setUserBio(bio: PlainMessage): Promise<{ eventId: string; newEvents: EventRef[]; }>; getUserBio(userId: string | Uint8Array): Promise; setDisplayName(streamId: string, displayName: string): Promise; setUsername(streamId: string, username: string, force?: boolean, options?: { largeGroupThreshold?: number; delayMs?: number; }): Promise; setPendingUsernames(): Promise; setEnsAddress(streamId: string, walletAddress: string | Uint8Array): Promise; setNft(streamId: string, tokenId: string, chainId: number, contractAddress: string): Promise; getPersistedEvent(streamId: string, eventId: string): Promise; pin(streamId: string, eventId: string): Promise<{ eventId: string; newEvents: EventRef[]; }>; unpin(streamId: string, eventId: string): Promise<{ eventId: string; newEvents: EventRef[]; }>; isUsernameAvailable(streamId: string, username: string): boolean; waitForStream(inStreamId: string | Uint8Array, opts?: { timeoutMs?: number; logId?: string; }): Promise; getStream(streamId: string): Promise; private _getStream; private streamViewFromUnpackedResponse; getStreamEx(streamId: string): Promise; private _getStreamEx; initStream(streamId: string | Uint8Array, allowGetStream?: boolean, persistedData?: LoadedStream): Promise; private _initStream; private onJoinedStream; private onInvitedToStream; private onLeftStream; private onStreamUpToDate; startSync(): void; stopSync(): Promise; emit(event: E, ...args: Parameters): boolean; sendMessage(streamId: string, body: string, mentions?: PlainMessage[], attachments?: PlainMessage[]): Promise<{ eventId: string; }>; sendChannelMessage(streamId: string, inPayload: PlainMessage, opts?: SendChannelMessageOptions): Promise<{ eventId: string; }>; private makeAndSendChannelMessageEvent; sendChannelMessage_Text(streamId: string, payload: Omit, 'content'> & { content: PlainMessage; }, opts?: SendChannelMessageOptions): Promise<{ eventId: string; }>; sendChannelMessage_Image(streamId: string, payload: Omit, 'content'> & { content: PlainMessage; }, opts?: SendChannelMessageOptions): Promise<{ eventId: string; }>; sendChannelMessage_GM(streamId: string, payload: Omit, 'content'> & { content: PlainMessage; }, opts?: SendChannelMessageOptions): Promise<{ eventId: string; }>; sendMediaPayload(creationCookie: CreationCookie, last: boolean, data: Uint8Array, chunkIndex: number, iv?: Uint8Array): Promise<{ creationCookie: CreationCookie; }>; getMediaPayload(streamId: string, secretKey: Uint8Array, iv: Uint8Array): Promise; sendChannelMessage_Reaction(streamId: string, payload: PlainMessage, opts?: SendChannelMessageOptions): Promise<{ eventId: string; }>; sendChannelMessage_Redaction(streamId: string, payload: PlainMessage): Promise<{ eventId: string; }>; sendChannelMessage_Edit(streamId: string, refEventId: string, newPost: PlainMessage): Promise<{ eventId: string; }>; sendChannelMessage_Edit_Text(streamId: string, refEventId: string, payload: Omit, 'content'> & { content: PlainMessage; }): Promise<{ eventId: string; }>; sendInteractionRequest(streamId: string, content: PlainMessage, recipient?: string | Uint8Array, opts?: { tags?: PlainMessage; ephemeral?: boolean; }): Promise<{ eventId: string; }>; sendInteractionResponse(streamId: string, recipient: Uint8Array, payload: PlainMessage, toUserDevice: UserDevice, opts?: { tags?: PlainMessage; ephemeral?: boolean; threadId: string | undefined; }): Promise<{ eventId: string; }>; redactMessage(streamId: string, eventId: string): Promise<{ eventId: string; }>; retrySendMessage(streamId: string, localId: string): Promise; inviteUser(streamId: string | Uint8Array, userId: string): Promise<{ eventId: string; }>; joinUser(streamId: string | Uint8Array, userId: string): Promise<{ eventId: string; }>; joinStream(streamId: string | Uint8Array, opts?: { skipWaitForMiniblockConfirmation?: boolean; skipWaitForUserStreamUpdate?: boolean; }): Promise; leaveStream(streamId: string | Uint8Array): Promise<{ eventId: string; }>; removeUser(streamId: string | Uint8Array, userId: string): Promise<{ eventId: string; }>; addTransaction(chainId: number, receipt: ContractReceipt | SolanaTransactionReceipt, content?: PlainMessage['content'], tags?: PlainMessage): Promise<{ eventId: string; }>; addTransaction_Tip(chainId: number, receipt: ContractReceipt, event: TipSentEventObject, toUserId: string, opts?: SendBlockchainTransactionOptions): Promise<{ eventId: string; }>; addTransaction_Transfer(chainId: number, receipt: ContractReceipt | SolanaTransactionReceipt, event: PlainMessage, opts?: SendBlockchainTransactionOptions): Promise<{ eventId: string; }>; addTransaction_SpaceReview(chainId: number, receipt: ContractReceipt, event: SpaceReviewEventObject, spaceId: string): Promise<{ eventId: string; }>; getMiniblocks(streamId: string | Uint8Array, fromInclusive: bigint, toExclusive: bigint, exclusionFilter?: ExclusionFilter, opts?: { skipPersistence?: boolean; }): Promise<{ miniblocks: ParsedMiniblock[]; terminus: boolean; }>; scrollback(streamId: string): Promise<{ terminus: boolean; fromInclusiveMiniblockNum: bigint; }>; /** * Get the list of active devices for all users in the room * * * @returns Promise which resolves to `null`, or an array whose * first element is a {@link DeviceInfoMap} indicating * the devices that messages should be encrypted to, and whose second * element is a map from userId to deviceId to data indicating the devices * that are in the room but that have been blocked. */ getDevicesInStream(stream_id: string): Promise; getUsersEntitledToKeyExchange(streamId: string): Promise; getMiniblockInfo(streamId: string): Promise<{ miniblockNum: bigint; miniblockHash: Uint8Array; }>; downloadNewInboxMessages(): Promise; downloadSingleUserDeviceInfo(userId: string, forceDownload: boolean): Promise<{ userId: string; devices: UserDevice[]; }>; downloadUserDeviceInfo(userIds: string[]): Promise; knownDevicesForUserId(userId: string): Promise; makeEventAndAddToStream(streamId: string | Uint8Array, payload: PlainMessage['payload'], options?: { method?: string; localId?: string; cleartext?: Uint8Array; tags?: PlainMessage; ephemeral?: boolean; }): Promise<{ eventId: string; newEvents: EventRef[]; }>; makeEventWithHashAndAddToStream(streamId: string | Uint8Array, payload: PlainMessage['payload'], prevMiniblockHash: Uint8Array, prevMiniblockNum: bigint, localId?: string, cleartext?: Uint8Array, tags?: PlainMessage, retryCount?: number, ephemeral?: boolean): Promise<{ prevMiniblockHash: Uint8Array; eventId: string; newEvents: EventRef[]; }>; makeMediaEventWithHashAndAddToMediaStream(creationCookie: CreationCookie, last: boolean, payload: PlainMessage['payload']): Promise<{ creationCookie: CreationCookie; }>; getStreamLastMiniblockHash(streamId: string | Uint8Array): Promise; private initCrypto; /** * Resets crypto backend and creates a new encryption account, uploading device keys to UserDeviceKey stream. */ resetCrypto(): Promise; uploadDeviceKeys(): Promise<{ eventId: string; newEvents: EventRef[]; }>; ackInboxStream(): Promise; setHighPriorityStreams(streamIds: string[]): void; ensureOutboundSession(streamId: string, opts?: EnsureOutboundSessionOpts): Promise; /** * decrypts and updates the decrypted event */ decryptGroupEvent(streamId: string, eventId: string, kind: string, // kind of data encryptedData: EncryptedData): Promise; private cleartextForGroupEvent; private _makeShareGroupSessionsContent; private _encryptAndShareGroupSessionsToDevice; encryptAndShareGroupSessionsToDevice(inStreamId: string | Uint8Array, sessions: GroupEncryptionSession[], algorithm: GroupEncryptionAlgorithmId, userId: string, deviceKeys: UserDevice[]): Promise; encryptAndShareGroupSessionsToStream(inStreamId: string | Uint8Array, sessions: GroupEncryptionSession[], algorithm: GroupEncryptionAlgorithmId, priorityUserIds: string[]): Promise; encryptAndShareLatestGroupSessionToUser(inStreamId: string | Uint8Array, toUserId: string): Promise; encryptGroupEvent(event: Uint8Array, streamId: string, algorithm: GroupEncryptionAlgorithmId): Promise; encryptWithDeviceKeys(payloadClearText: string, deviceKeys: UserDevice[]): Promise>; userDeviceKey(): UserDevice; debugForceMakeMiniblock(streamId: string, opts: { forceSnapshot?: boolean; lastKnownMiniblockNum?: bigint; }): Promise; debugForceAddEvent(streamId: string, event: Envelope): Promise; debugDropStream(syncId: string, streamId: string): Promise; } export {}; //# sourceMappingURL=client.d.ts.map