// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { ConversationAttributesType, MessageAttributesType, SenderKeyInfoType, } from '../model-types.d'; import type { StoredJob } from '../jobs/types'; import type { ReactionType, ReactionReadStatus } from '../types/Reactions'; import type { ConversationColorType, CustomColorType } from '../types/Colors'; import type { StorageAccessType } from '../types/Storage.d'; import type { AttachmentType } from '../types/Attachment'; import type { BytesToStrings } from '../types/Util'; import type { QualifiedAddressStringType } from '../types/QualifiedAddress'; import type { StoryDistributionIdString } from '../types/StoryDistributionId'; import type { AciString, PniString, ServiceIdString } from '../types/ServiceId'; import type { BadgeType } from '../badges/types'; import type { LoggerType } from '../types/Logging'; import type { ReadStatus } from '../messages/MessageReadStatus'; import type { RawBodyRange } from '../types/BodyRange'; import type { GetMessagesBetweenOptions, MaybeStaleCallHistory, } from './Server'; import type { MessageTimestamps } from '../state/ducks/conversations'; import type { CallHistoryDetails, CallHistoryFilter, CallHistoryGroup, CallHistoryPagination, } from '../types/CallDisposition'; export type AdjacentMessagesByConversationOptionsType = Readonly<{ conversationId: string; messageId?: string; includeStoryReplies: boolean; limit?: number; receivedAt?: number; sentAt?: number; storyId: string | undefined; requireVisualMediaAttachments?: boolean; }>; export type GetNearbyMessageFromDeletedSetOptionsType = Readonly<{ conversationId: string; lastSelectedMessage: MessageTimestamps; deletedMessageIds: ReadonlyArray; storyId: string | undefined; includeStoryReplies: boolean; }>; export type AttachmentDownloadJobTypeType = | 'long-message' | 'attachment' | 'preview' | 'contact' | 'quote' | 'sticker'; export type AttachmentDownloadJobType = { attachment: AttachmentType; attempts: number; id: string; index: number; messageId: string; pending: number; timestamp: number; type: AttachmentDownloadJobTypeType; }; export type MessageMetricsType = { id: string; received_at: number; sent_at: number; }; export type ConversationMetricsType = { oldest?: MessageMetricsType; newest?: MessageMetricsType; oldestUnseen?: MessageMetricsType; totalUnseen: number; }; export type ConversationType = ConversationAttributesType; export type EmojiType = { shortName: string; lastUsage: number; }; export type IdentityKeyType = { firstUse: boolean; id: ServiceIdString | `conversation:${string}`; nonblockingApproval: boolean; publicKey: Uint8Array; timestamp: number; verified: number; }; export type StoredIdentityKeyType = { firstUse: boolean; id: ServiceIdString | `conversation:${string}`; nonblockingApproval: boolean; publicKey: string; timestamp: number; verified: number; }; export type IdentityKeyIdType = IdentityKeyType['id']; export type ItemKeyType = keyof StorageAccessType; export type AllItemsType = Partial; export type StoredAllItemsType = Partial>; export type ItemType = { id: K; value: StorageAccessType[K]; }; export type StoredItemType = { id: K; value: BytesToStrings; }; export type MessageType = MessageAttributesType; export type MessageTypeUnhydrated = { json: string; }; export type PreKeyIdType = `${ServiceIdString}:${number}`; export type KyberPreKeyType = { id: PreKeyIdType; createdAt: number; data: Uint8Array; isConfirmed: boolean; isLastResort: boolean; keyId: number; ourServiceId: ServiceIdString; }; export type StoredKyberPreKeyType = KyberPreKeyType & { data: string; }; export type PreKeyType = { id: PreKeyIdType; createdAt: number; keyId: number; ourServiceId: ServiceIdString; privateKey: Uint8Array; publicKey: Uint8Array; }; export type StoredPreKeyType = PreKeyType & { privateKey: string; publicKey: string; }; export type ServerSearchResultMessageType = { json: string; // If the FTS matches text in message.body, snippet will be populated ftsSnippet: string | null; // Otherwise, a matching mention will be returned mentionAci: string | null; mentionStart: number | null; mentionLength: number | null; }; export type ClientSearchResultMessageType = MessageType & { json: string; bodyRanges: ReadonlyArray; snippet: string; }; export type SentProtoType = { contentHint: number; proto: Uint8Array; timestamp: number; urgent: boolean; hasPniSignatureMessage: boolean; }; export type SentProtoWithMessageIdsType = SentProtoType & { messageIds: Array; }; export type SentRecipientsType = Record>; export type SentMessagesType = Array; // These two are for test only export type SentRecipientsDBType = { payloadId: number; recipientServiceId: ServiceIdString; deviceId: number; }; export type SentMessageDBType = { payloadId: number; messageId: string; }; export type SenderKeyType = { // Primary key id: `${QualifiedAddressStringType}--${string}`; // These two are combined into one string to give us the final id senderId: string; distributionId: string; // Raw data to serialize/deserialize into signal-client SenderKeyRecord data: Uint8Array; lastUpdatedDate: number; }; export type SenderKeyIdType = SenderKeyType['id']; export type SessionType = { id: QualifiedAddressStringType; ourServiceId: ServiceIdString; serviceId: ServiceIdString; conversationId: string; deviceId: number; record: string; version?: number; }; export type SessionIdType = SessionType['id']; export type SignedPreKeyType = { confirmed: boolean; created_at: number; ourServiceId: ServiceIdString; id: `${ServiceIdString}:${number}`; keyId: number; privateKey: Uint8Array; publicKey: Uint8Array; }; export type StoredSignedPreKeyType = { confirmed: boolean; created_at: number; ourServiceId: ServiceIdString; id: `${ServiceIdString}:${number}`; keyId: number; privateKey: string; publicKey: string; }; export type SignedPreKeyIdType = SignedPreKeyType['id']; export type StickerType = Readonly<{ id: number; packId: string; emoji?: string; isCoverOnly: boolean; lastUsed?: number; path: string; width: number; height: number; }>; export const StickerPackStatuses = [ 'known', 'ephemeral', 'downloaded', 'installed', 'pending', 'error', ] as const; export type StickerPackStatusType = typeof StickerPackStatuses[number]; export type StorageServiceFieldsType = Readonly<{ storageID?: string; storageVersion?: number; storageUnknownFields?: Uint8Array | null; storageNeedsSync: boolean; }>; export type InstalledStickerPackType = Readonly<{ id: string; key: string; uninstalledAt?: undefined; position?: number | null; }> & StorageServiceFieldsType; export type UninstalledStickerPackType = Readonly<{ id: string; key?: undefined; uninstalledAt: number; position?: undefined; }> & StorageServiceFieldsType; export type StickerPackInfoType = | InstalledStickerPackType | UninstalledStickerPackType; export type StickerPackType = InstalledStickerPackType & Readonly<{ attemptedStatus?: 'downloaded' | 'installed' | 'ephemeral'; author: string; coverStickerId: number; createdAt: number; downloadAttempts: number; installedAt?: number; lastUsed?: number; status: StickerPackStatusType; stickerCount: number; stickers: Record; title: string; }>; export type UnprocessedType = { id: string; timestamp: number; receivedAtCounter: number | null; version: number; attempts: number; envelope?: string; messageAgeSec?: number; source?: string; sourceServiceId?: ServiceIdString; sourceDevice?: number; destinationServiceId?: ServiceIdString; updatedPni?: PniString; serverGuid?: string; serverTimestamp?: number; decrypted?: string; urgent?: boolean; story?: boolean; reportingToken?: string; }; export type UnprocessedUpdateType = { source?: string; sourceServiceId?: ServiceIdString; sourceDevice?: number; serverGuid?: string; serverTimestamp?: number; decrypted?: string; }; export type ConversationMessageStatsType = { activity?: MessageType; preview?: MessageType; hasUserInitiatedMessages: boolean; }; export type DeleteSentProtoRecipientOptionsType = Readonly<{ timestamp: number; recipientServiceId: ServiceIdString; deviceId: number; }>; export type DeleteSentProtoRecipientResultType = Readonly<{ successfulPhoneNumberShares: ReadonlyArray; }>; export type StoryDistributionType = Readonly<{ id: StoryDistributionIdString; name: string; deletedAtTimestamp?: number; allowsReplies: boolean; isBlockList: boolean; senderKeyInfo: SenderKeyInfoType | undefined; }> & StorageServiceFieldsType; export type StoryDistributionMemberType = Readonly<{ listId: StoryDistributionIdString; serviceId: ServiceIdString; }>; export type StoryDistributionWithMembersType = Readonly< { members: Array; } & StoryDistributionType >; export type StoryReadType = Readonly<{ authorId: ServiceIdString; conversationId: string; storyId: string; storyReadDate: number; }>; export type ReactionResultType = Pick< ReactionType, 'targetAuthorAci' | 'targetTimestamp' | 'messageId' > & { rowid: number }; export type GetUnreadByConversationAndMarkReadResultType = Array< { originalReadStatus: ReadStatus | undefined } & Pick< MessageType, | 'id' | 'source' | 'sourceServiceId' | 'sent_at' | 'type' | 'readStatus' | 'seenStatus' > >; export type GetConversationRangeCenteredOnMessageResultType = Readonly<{ older: Array; newer: Array; metrics: ConversationMetricsType; }>; export type MessageCursorType = Readonly<{ done: boolean; runId: string; count: number; }>; export type MessageAttachmentsCursorType = MessageCursorType & Readonly<{ __message_attachments_cursor: never; }>; export type GetKnownMessageAttachmentsResultType = Readonly<{ cursor: MessageAttachmentsCursorType; attachments: ReadonlyArray; }>; export type PageMessagesCursorType = MessageCursorType & Readonly<{ __page_messages_cursor: never; }>; export type PageMessagesResultType = Readonly<{ cursor: PageMessagesCursorType; messages: ReadonlyArray; }>; export type GetAllStoriesResultType = ReadonlyArray< MessageType & { hasReplies: boolean; hasRepliesFromSelf: boolean; } >; export type FTSOptimizationStateType = Readonly<{ steps: number; done?: boolean; }>; export type EditedMessageType = Readonly<{ conversationId: string; messageId: string; sentAt: number; readStatus: MessageType['readStatus']; }>; export type DataInterface = { close: () => Promise; pauseWriteAccess(): Promise; resumeWriteAccess(): Promise; removeDB: () => Promise; removeIndexedDBFiles: () => Promise; removeIdentityKeyById: (id: IdentityKeyIdType) => Promise; removeAllIdentityKeys: () => Promise; removeKyberPreKeyById: ( id: PreKeyIdType | Array ) => Promise; removeKyberPreKeysByServiceId: (serviceId: ServiceIdString) => Promise; removeAllKyberPreKeys: () => Promise; removePreKeyById: (id: PreKeyIdType | Array) => Promise; removePreKeysByServiceId: (serviceId: ServiceIdString) => Promise; removeAllPreKeys: () => Promise; removeSignedPreKeyById: ( id: SignedPreKeyIdType | Array ) => Promise; removeSignedPreKeysByServiceId: (serviceId: ServiceIdString) => Promise; removeAllSignedPreKeys: () => Promise; removeAllItems: () => Promise; removeItemById: (id: ItemKeyType | Array) => Promise; createOrUpdateSenderKey: (key: SenderKeyType) => Promise; getSenderKeyById: (id: SenderKeyIdType) => Promise; removeAllSenderKeys: () => Promise; getAllSenderKeys: () => Promise>; removeSenderKeyById: (id: SenderKeyIdType) => Promise; insertSentProto: ( proto: SentProtoType, options: { recipients: SentRecipientsType; messageIds: SentMessagesType; } ) => Promise; deleteSentProtosOlderThan: (timestamp: number) => Promise; deleteSentProtoByMessageId: (messageId: string) => Promise; insertProtoRecipients: (options: { id: number; recipientServiceId: ServiceIdString; deviceIds: Array; }) => Promise; deleteSentProtoRecipient: ( options: | DeleteSentProtoRecipientOptionsType | ReadonlyArray ) => Promise; getSentProtoByRecipient: (options: { now: number; recipientServiceId: ServiceIdString; timestamp: number; }) => Promise; removeAllSentProtos: () => Promise; getAllSentProtos: () => Promise>; // Test-only _getAllSentProtoRecipients: () => Promise>; _getAllSentProtoMessageIds: () => Promise>; createOrUpdateSession: (data: SessionType) => Promise; createOrUpdateSessions: (array: Array) => Promise; commitDecryptResult(options: { senderKeys: Array; sessions: Array; unprocessed: Array; }): Promise; bulkAddSessions: (array: Array) => Promise; removeSessionById: (id: SessionIdType) => Promise; removeSessionsByConversation: (conversationId: string) => Promise; removeSessionsByServiceId: (serviceId: ServiceIdString) => Promise; removeAllSessions: () => Promise; getAllSessions: () => Promise>; getConversationCount: () => Promise; saveConversation: (data: ConversationType) => Promise; saveConversations: (array: Array) => Promise; getConversationById: (id: string) => Promise; // updateConversation is a normal data method on Server, a sync batch-add on Client updateConversations: (array: Array) => Promise; // removeConversation handles either one id or an array on Server, and one id on Client _removeAllConversations: () => Promise; updateAllConversationColors: ( conversationColor?: ConversationColorType, customColorData?: { id: string; value: CustomColorType; } ) => Promise; removeAllProfileKeyCredentials: () => Promise; getAllConversations: () => Promise>; getAllConversationIds: () => Promise>; getAllGroupsInvolvingServiceId: ( serviceId: ServiceIdString ) => Promise>; getMessageCount: (conversationId?: string) => Promise; getStoryCount: (conversationId: string) => Promise; saveMessage: ( data: MessageType, options: { jobToInsert?: StoredJob; forceSave?: boolean; ourAci: AciString; } ) => Promise; saveMessages: ( arrayOfMessages: ReadonlyArray, options: { forceSave?: boolean; ourAci: AciString } ) => Promise; removeMessage: (id: string) => Promise; removeMessages: (ids: ReadonlyArray) => Promise; pageMessages: ( cursor?: PageMessagesCursorType ) => Promise; finishPageMessages: (cursor: PageMessagesCursorType) => Promise; getTotalUnreadForConversation: ( conversationId: string, options: { storyId: string | undefined; includeStoryReplies: boolean; } ) => Promise; getTotalUnreadMentionsOfMeForConversation: ( conversationId: string, options: { storyId?: string; includeStoryReplies: boolean; } ) => Promise; getOldestUnreadMentionOfMeForConversation( conversationId: string, options: { storyId?: string; includeStoryReplies: boolean; } ): Promise; getUnreadByConversationAndMarkRead: (options: { conversationId: string; includeStoryReplies: boolean; newestUnreadAt: number; now?: number; readAt?: number; storyId?: string; }) => Promise; getUnreadEditedMessagesAndMarkRead: (options: { conversationId: string; newestUnreadAt: number; }) => Promise; getUnreadReactionsAndMarkRead: (options: { conversationId: string; newestUnreadAt: number; storyId?: string; }) => Promise>; markReactionAsRead: ( targetAuthorServiceId: ServiceIdString, targetTimestamp: number ) => Promise; removeReactionFromConversation: (reaction: { emoji: string; fromId: string; targetAuthorServiceId: ServiceIdString; targetTimestamp: number; }) => Promise; getReactionByTimestamp: ( fromId: string, timestamp: number ) => Promise; addReaction: ( reactionObj: ReactionType, options: { readStatus: ReactionReadStatus; } ) => Promise; _getAllReactions: () => Promise>; _removeAllReactions: () => Promise; getMessageBySender: (options: { source?: string; sourceServiceId?: ServiceIdString; sourceDevice?: number; sent_at: number; }) => Promise; getMessageById: (id: string) => Promise; getMessagesById: ( messageIds: ReadonlyArray ) => Promise>; _getAllMessages: () => Promise>; _getAllEditedMessages: () => Promise< Array<{ messageId: string; sentAt: number }> >; _removeAllMessages: () => Promise; getAllMessageIds: () => Promise>; getMessagesBySentAt: (sentAt: number) => Promise>; getExpiredMessages: () => Promise>; getMessagesUnexpectedlyMissingExpirationStartTimestamp: () => Promise< Array >; getSoonestMessageExpiry: () => Promise; getNextTapToViewMessageTimestampToAgeOut: () => Promise; getTapToViewMessagesNeedingErase: () => Promise>; // getOlderMessagesByConversation is JSON on server, full message on Client getAllStories: (options: { conversationId?: string; sourceServiceId?: ServiceIdString; }) => Promise; // getNewerMessagesByConversation is JSON on server, full message on Client getMessageMetricsForConversation: (options: { conversationId: string; storyId?: string; includeStoryReplies: boolean; }) => Promise; // getConversationRangeCenteredOnMessage is JSON on server, full message on client getConversationMessageStats: (options: { conversationId: string; includeStoryReplies: boolean; }) => Promise; getLastConversationMessage(options: { conversationId: string; }): Promise; getAllCallHistory: () => Promise>; clearCallHistory: (beforeTimestamp: number) => Promise>; cleanupCallHistoryMessages: () => Promise; getCallHistoryUnreadCount(): Promise; markCallHistoryRead(callId: string): Promise; markAllCallHistoryRead( beforeTimestamp: number ): Promise>; getCallHistoryMessageByCallId(options: { conversationId: string; callId: string; }): Promise; getCallHistory( callId: string, peerId: ServiceIdString | string ): Promise; getCallHistoryGroupsCount(filter: CallHistoryFilter): Promise; getCallHistoryGroups( filter: CallHistoryFilter, pagination: CallHistoryPagination ): Promise>; saveCallHistory(callHistory: CallHistoryDetails): Promise; hasGroupCallHistoryMessage: ( conversationId: string, eraId: string ) => Promise; markCallHistoryMissed(callIds: ReadonlyArray): Promise; getRecentStaleRingsAndMarkOlderMissed(): Promise< ReadonlyArray >; migrateConversationMessages: ( obsoleteId: string, currentId: string ) => Promise; getMessagesBetween: ( conversationId: string, options: GetMessagesBetweenOptions ) => Promise>; getNearbyMessageFromDeletedSet: ( options: GetNearbyMessageFromDeletedSetOptionsType ) => Promise; saveEditedMessage: ( mainMessage: MessageType, ourAci: AciString, opts: EditedMessageType ) => Promise; getUnprocessedCount: () => Promise; getUnprocessedByIdsAndIncrementAttempts: ( ids: ReadonlyArray ) => Promise>; getAllUnprocessedIds: () => Promise>; updateUnprocessedWithData: ( id: string, data: UnprocessedUpdateType ) => Promise; updateUnprocessedsWithData: ( array: Array<{ id: string; data: UnprocessedUpdateType }> ) => Promise; getUnprocessedById: (id: string) => Promise; removeUnprocessed: (id: string | Array) => Promise; /** only for testing */ removeAllUnprocessed: () => Promise; getAttachmentDownloadJobById: ( id: string ) => Promise; getNextAttachmentDownloadJobs: ( limit?: number, options?: { timestamp?: number } ) => Promise>; saveAttachmentDownloadJob: (job: AttachmentDownloadJobType) => Promise; resetAttachmentDownloadPending: () => Promise; setAttachmentDownloadJobPending: ( id: string, pending: boolean ) => Promise; removeAttachmentDownloadJob: (id: string) => Promise; removeAllAttachmentDownloadJobs: () => Promise; createOrUpdateStickerPack: (pack: StickerPackType) => Promise; updateStickerPackStatus: ( id: string, status: StickerPackStatusType, options?: { timestamp: number } ) => Promise; updateStickerPackInfo: (info: StickerPackInfoType) => Promise; createOrUpdateSticker: (sticker: StickerType) => Promise; updateStickerLastUsed: ( packId: string, stickerId: number, lastUsed: number ) => Promise; addStickerPackReference: (messageId: string, packId: string) => Promise; deleteStickerPackReference: ( messageId: string, packId: string ) => Promise | undefined>; getStickerCount: () => Promise; deleteStickerPack: (packId: string) => Promise>; getAllStickerPacks: () => Promise>; addUninstalledStickerPack: ( pack: UninstalledStickerPackType ) => Promise; removeUninstalledStickerPack: (packId: string) => Promise; getInstalledStickerPacks: () => Promise>; getUninstalledStickerPacks: () => Promise>; installStickerPack: (packId: string, timestamp: number) => Promise; uninstallStickerPack: (packId: string, timestamp: number) => Promise; getStickerPackInfo: ( packId: string ) => Promise; getAllStickers: () => Promise>; getRecentStickers: (options?: { limit?: number; }) => Promise>; clearAllErrorStickerPackAttempts: () => Promise; updateEmojiUsage: (shortName: string, timeUsed?: number) => Promise; getRecentEmojis: (limit?: number) => Promise>; getAllBadges(): Promise>; updateOrCreateBadges(badges: ReadonlyArray): Promise; badgeImageFileDownloaded(url: string, localPath: string): Promise; _getAllStoryDistributions(): Promise>; _getAllStoryDistributionMembers(): Promise< Array >; _deleteAllStoryDistributions(): Promise; createNewStoryDistribution( distribution: StoryDistributionWithMembersType ): Promise; getAllStoryDistributionsWithMembers(): Promise< Array >; getStoryDistributionWithMembers( id: string ): Promise; modifyStoryDistribution(distribution: StoryDistributionType): Promise; modifyStoryDistributionMembers( listId: string, options: { toAdd: Array; toRemove: Array; } ): Promise; modifyStoryDistributionWithMembers( distribution: StoryDistributionType, options: { toAdd: Array; toRemove: Array; } ): Promise; deleteStoryDistribution(id: StoryDistributionIdString): Promise; _getAllStoryReads(): Promise>; _deleteAllStoryReads(): Promise; addNewStoryRead(read: StoryReadType): Promise; getLastStoryReadsForAuthor(options: { authorId: ServiceIdString; conversationId?: string; limit?: number; }): Promise>; countStoryReadsByConversation(conversationId: string): Promise; removeAll: () => Promise; removeAllConfiguration: () => Promise; eraseStorageServiceState: () => Promise; getMessagesNeedingUpgrade: ( limit: number, options: { maxVersion: number } ) => Promise>; getMessagesWithVisualMediaAttachments: ( conversationId: string, options: { limit: number } ) => Promise>; getMessagesWithFileAttachments: ( conversationId: string, options: { limit: number } ) => Promise>; getMessageServerGuidsForSpam: ( conversationId: string ) => Promise>; getJobsInQueue(queueType: string): Promise>; insertJob(job: Readonly): Promise; deleteJob(id: string): Promise; wasGroupCallRingPreviouslyCanceled(ringId: bigint): Promise; processGroupCallRingCancellation(ringId: bigint): Promise; cleanExpiredGroupCallRingCancellations(): Promise; getMaxMessageCounter(): Promise; getStatisticsForLogging(): Promise>; optimizeFTS: ( state?: FTSOptimizationStateType ) => Promise; }; export type ServerInterface = DataInterface & { // Differing signature on client/server updateConversation: (data: ConversationType) => Promise; removeConversation: (id: Array | string) => Promise; searchMessages: ({ query, conversationId, options, contactServiceIdsMatchingQuery, }: { query: string; conversationId?: string; options?: { limit?: number }; contactServiceIdsMatchingQuery?: Array; }) => Promise>; getRecentStoryReplies( storyId: string, options?: GetRecentStoryRepliesOptionsType ): Promise>; getOlderMessagesByConversation: ( options: AdjacentMessagesByConversationOptionsType ) => Promise>; getNewerMessagesByConversation: ( options: AdjacentMessagesByConversationOptionsType ) => Promise>; getConversationRangeCenteredOnMessage: ( options: AdjacentMessagesByConversationOptionsType ) => Promise< GetConversationRangeCenteredOnMessageResultType >; createOrUpdateIdentityKey: (data: StoredIdentityKeyType) => Promise; getIdentityKeyById: ( id: IdentityKeyIdType ) => Promise; bulkAddIdentityKeys: (array: Array) => Promise; getAllIdentityKeys: () => Promise>; createOrUpdateKyberPreKey: (data: StoredKyberPreKeyType) => Promise; getKyberPreKeyById: ( id: PreKeyIdType ) => Promise; bulkAddKyberPreKeys: (array: Array) => Promise; getAllKyberPreKeys: () => Promise>; createOrUpdatePreKey: (data: StoredPreKeyType) => Promise; getPreKeyById: (id: PreKeyIdType) => Promise; bulkAddPreKeys: (array: Array) => Promise; getAllPreKeys: () => Promise>; createOrUpdateSignedPreKey: (data: StoredSignedPreKeyType) => Promise; getSignedPreKeyById: ( id: SignedPreKeyIdType ) => Promise; bulkAddSignedPreKeys: (array: Array) => Promise; getAllSignedPreKeys: () => Promise>; createOrUpdateItem( data: StoredItemType ): Promise; getItemById( id: K ): Promise | undefined>; getAllItems: () => Promise; // Server-only initialize: (options: { appVersion: string; configDir: string; key: string; logger: LoggerType; }) => Promise; getKnownMessageAttachments: ( cursor?: MessageAttachmentsCursorType ) => Promise; finishGetKnownMessageAttachments: ( cursor: MessageAttachmentsCursorType ) => Promise; getKnownConversationAttachments: () => Promise>; removeKnownStickers: ( allStickers: ReadonlyArray ) => Promise>; removeKnownDraftAttachments: ( allStickers: ReadonlyArray ) => Promise>; getAllBadgeImageFileLocalPaths: () => Promise>; runCorruptionChecks: () => void; }; export type GetRecentStoryRepliesOptionsType = { limit?: number; messageId?: string; receivedAt?: number; sentAt?: number; }; // Differing signature on client/server export type ClientExclusiveInterface = { // Differing signature on client/server updateConversation: (data: ConversationType) => void; removeConversation: (id: string) => Promise; flushUpdateConversationBatcher: () => Promise; searchMessages: ({ query, conversationId, options, contactServiceIdsMatchingQuery, }: { query: string; conversationId?: string; options?: { limit?: number }; contactServiceIdsMatchingQuery?: Array; }) => Promise>; getRecentStoryReplies( storyId: string, options?: GetRecentStoryRepliesOptionsType ): Promise>; getOlderMessagesByConversation: ( options: AdjacentMessagesByConversationOptionsType ) => Promise>; getNewerMessagesByConversation: ( options: AdjacentMessagesByConversationOptionsType ) => Promise>; getConversationRangeCenteredOnMessage: ( options: AdjacentMessagesByConversationOptionsType ) => Promise>; createOrUpdateIdentityKey: (data: IdentityKeyType) => Promise; getIdentityKeyById: ( id: IdentityKeyIdType ) => Promise; bulkAddIdentityKeys: (array: Array) => Promise; getAllIdentityKeys: () => Promise>; createOrUpdateKyberPreKey: (data: KyberPreKeyType) => Promise; getKyberPreKeyById: ( id: PreKeyIdType ) => Promise; bulkAddKyberPreKeys: (array: Array) => Promise; getAllKyberPreKeys: () => Promise>; createOrUpdatePreKey: (data: PreKeyType) => Promise; getPreKeyById: (id: PreKeyIdType) => Promise; bulkAddPreKeys: (array: Array) => Promise; getAllPreKeys: () => Promise>; createOrUpdateSignedPreKey: (data: SignedPreKeyType) => Promise; getSignedPreKeyById: ( id: SignedPreKeyIdType ) => Promise; bulkAddSignedPreKeys: (array: Array) => Promise; getAllSignedPreKeys: () => Promise>; createOrUpdateItem(data: ItemType): Promise; getItemById(id: K): Promise | undefined>; getAllItems: () => Promise; // Client-side only shutdown: () => Promise; removeAllMessagesInConversation: ( conversationId: string, options: { logId: string; } ) => Promise; removeOtherData: () => Promise; cleanupOrphanedAttachments: () => Promise; ensureFilePermissions: () => Promise; }; export type ClientInterface = DataInterface & ClientExclusiveInterface;