import { ConversationType } from '../../ts/state/ducks/conversations'; import { Message } from '../../ts/types/Message'; export type IdentityKey = { id: string; publicKey: ArrayBuffer; firstUse: boolean; verified: number; nonblockingApproval: boolean; secretKey?: string; // found in medium groups }; export type PreKey = { id: number; publicKey: ArrayBuffer; privateKey: ArrayBuffer; recipient: string; }; export type SignedPreKey = { id: number; publicKey: ArrayBuffer; privateKey: ArrayBuffer; created_at: number; confirmed: boolean; signature: ArrayBuffer; }; export type ContactPreKey = { id: number; identityKeyString: string; publicKey: ArrayBuffer; keyId: number; }; export type ContactSignedPreKey = { id: number; identityKeyString: string; publicKey: ArrayBuffer; keyId: number; signature: ArrayBuffer; created_at: number; confirmed: boolean; }; export type PairingAuthorisation = { primaryDevicePubKey: string; secondaryDevicePubKey: string; requestSignature: ArrayBuffer; grantSignature?: ArrayBuffer; }; export type GuardNode = { ed25519PubKey: string; }; export type SwarmNode = { address: string; ip: string; port: string; pubkey_ed25519: string; pubkey_x25519: string; }; export type StorageItem = { id: string; value: any; }; export type SessionDataInfo = { id: string; number: string; deviceId: number; record: string; }; export type ServerToken = { serverUrl: string; token: string; }; // Basic export function searchMessages(query: string): Promise>; export function searchConversations(query: string): Promise>; export function shutdown(): Promise; export function close(): Promise; export function removeDB(): Promise; export function removeIndexedDBFiles(): Promise; export function getPasswordHash(): Promise; // Identity Keys // TODO: identity key has different shape depending on how it is called, // so we need to come up with a way to make TS work with all of them export function createOrUpdateIdentityKey(data: any): Promise; export function getIdentityKeyById(id: string): Promise; export function bulkAddIdentityKeys(array: Array): Promise; export function removeIdentityKeyById(id: string): Promise; export function removeAllIdentityKeys(): Promise; // Pre Keys export function createOrUpdatePreKey(data: PreKey): Promise; export function getPreKeyById(id: number): Promise; export function getPreKeyByRecipient(recipient: string): Promise; export function bulkAddPreKeys(data: Array): Promise; export function removePreKeyById(id: number): Promise; export function getAllPreKeys(): Promise>; // Signed Pre Keys export function createOrUpdateSignedPreKey(data: SignedPreKey): Promise; export function getSignedPreKeyById(id: number): Promise; export function getAllSignedPreKeys(): Promise; export function bulkAddSignedPreKeys(array: Array): Promise; export function removeSignedPreKeyById(id: number): Promise; export function removeAllSignedPreKeys(): Promise; // Contact Pre Key export function createOrUpdateContactPreKey(data: ContactPreKey): Promise; export function getContactPreKeyById(id: number): Promise; export function getContactPreKeyByIdentityKey( key: string ): Promise; export function getContactPreKeys( keyId: number, identityKeyString: string ): Promise>; export function getAllContactPreKeys(): Promise>; export function bulkAddContactPreKeys( array: Array ): Promise; export function removeContactPreKeyByIdentityKey(id: number): Promise; export function removeAllContactPreKeys(): Promise; // Contact Signed Pre Key export function createOrUpdateContactSignedPreKey( data: ContactSignedPreKey ): Promise; export function getContactSignedPreKeyById( id: number ): Promise; export function getContactSignedPreKeyByIdentityKey( key: string ): Promise; export function getContactSignedPreKeys( keyId: number, identityKeyString: string ): Promise>; export function bulkAddContactSignedPreKeys( array: Array ): Promise; export function removeContactSignedPreKeyByIdentityKey( id: string ): Promise; export function removeAllContactSignedPreKeys(): Promise; // Authorisations & Linking export function createOrUpdatePairingAuthorisation( data: PairingAuthorisation ): Promise; export function getPairingAuthorisationsFor( pubKey: string ): Promise>; export function removePairingAuthorisationsFor(pubKey: string): Promise; // Guard Nodes export function getGuardNodes(): Promise>; export function updateGuardNodes(nodes: Array): Promise; // Storage Items export function createOrUpdateItem(data: StorageItem): Promise; export function getItemById(id: string): Promise; export function getAlItems(): Promise>; export function bulkAddItems(array: Array): Promise; export function removeItemById(id: string): Promise; export function removeAllItems(): Promise; // Sessions export function createOrUpdateSession(data: SessionDataInfo): Promise; export function getAllSessions(): Promise>; export function getSessionById(id: string): Promise; export function getSessionsByNumber(number: string): Promise; export function bulkAddSessions(array: Array): Promise; export function removeSessionById(id: string): Promise; export function removeSessionsByNumber(number: string): Promise; export function removeAllSessions(): Promise; // Conversations export function getConversationCount(): Promise; export function saveConversation(data: ConversationType): Promise; export function saveConversations(data: Array): Promise; export function updateConversation(data: ConversationType): Promise; export function removeConversation(id: string): Promise; export function getAllConversations({ ConversationCollection, }: { ConversationCollection: any; }): Promise>; export function getAllConversationIds(): Promise>; export function getAllPublicConversations(): Promise>; export function getPublicConversationsByServer( server: string, { ConversationCollection }: { ConversationCollection: any } ): Promise; export function getPubkeysInPublicConversation( id: string ): Promise>; export function savePublicServerToken(data: ServerToken): Promise; export function getPublicServerTokenByServerUrl( serverUrl: string ): Promise; export function getAllGroupsInvolvingId( id: string, { ConversationCollection }: { ConversationCollection: any } ): Promise>; // Returns conversation row // TODO: Make strict return types for search export function searchConversations(query: string): Promise; export function searchMessages(query: string): Promise; export function searchMessagesInConversation( query: string, conversationId: string, { limit }?: { limit: any } ): Promise; export function saveMessage( data: Mesasge, { forceSave, Message }?: { forceSave?: any; Message?: any } ): Promise; export function cleanSeenMessages(): Promise; export function cleanLastHashes(): Promise; export function saveSeenMessageHash(data: { expiresAt: number; hash: string; }): Promise; export function getSwarmNodesForPubkey(pubkey: string): Promise>; export function updateSwarmNodesForPubkey( pubkey: string, snodeEdKeys: Array ): Promise; // TODO: Strictly type the following export function updateLastHash(data: any): Promise; export function saveSeenMessageHashes(data: any): Promise; export function saveLegacyMessage(data: any): Promise; export function saveMessages( arrayOfMessages: any, { forceSave }?: any ): Promise; export function removeMessage(id: string, { Message }?: any): Promise; export function getUnreadByConversation( conversationId: string, { MessageCollection }?: any ): Promise; export function removeAllMessagesInConversation( conversationId: string, { MessageCollection }?: any ): Promise; export function getMessageBySender( { source, sourceDevice, sent_at, }: { source: any; sourceDevice: any; sent_at: any }, { Message }: { Message: any } ): Promise; export function getMessagesBySender( { source, sourceDevice }: { source: any; sourceDevice: any }, { Message }: { Message: any } ): Promise; export function getMessageIdsFromServerIds( serverIds: any, conversationId: any ): Promise; export function getMessageById( id: string, { Message }: { Message: any } ): Promise; export function getAllMessages({ MessageCollection, }: { MessageCollection: any; }): Promise; export function getAllUnsentMessages({ MessageCollection, }: { MessageCollection: any; }): Promise; export function getAllMessageIds(): Promise; export function getMessagesBySentAt( sentAt: any, { MessageCollection }: { MessageCollection: any } ): Promise; export function getExpiredMessages({ MessageCollection, }: { MessageCollection: any; }): Promise; export function getOutgoingWithoutExpiresAt({ MessageCollection, }: any): Promise; export function getNextExpiringMessage({ MessageCollection, }: { MessageCollection: any; }): Promise; export function getNextExpiringMessage({ MessageCollection, }: { MessageCollection: any; }): Promise; export function getMessagesByConversation( conversationId: any, { limit, receivedAt, MessageCollection, type, }: { limit?: number; receivedAt?: number; MessageCollection: any; type?: string; } ): Promise; export function getSeenMessagesByHashList(hashes: any): Promise; export function getLastHashBySnode(convoId: any, snode: any): Promise; // Unprocessed export function getUnprocessedCount(): Promise; export function getAllUnprocessed(): Promise; export function getUnprocessedById(id: any): Promise; export function saveUnprocessed( data: any, { forceSave, }?: { forceSave: any; } ): Promise; export function saveUnprocesseds( arrayOfUnprocessed: any, { forceSave, }?: { forceSave: any; } ): Promise; export function updateUnprocessedAttempts( id: any, attempts: any ): Promise; export function updateUnprocessedWithData(id: any, data: any): Promise; export function removeUnprocessed(id: any): Promise; export function removeAllUnprocessed(): Promise; // Attachment Downloads export function getNextAttachmentDownloadJobs(limit: any): Promise; export function saveAttachmentDownloadJob(job: any): Promise; export function setAttachmentDownloadJobPending( id: any, pending: any ): Promise; export function resetAttachmentDownloadPending(): Promise; export function removeAttachmentDownloadJob(id: any): Promise; export function removeAllAttachmentDownloadJobs(): Promise; // Other export function removeAll(): Promise; export function removeAllConfiguration(): Promise; export function removeAllConversations(): Promise; export function removeAllPrivateConversations(): Promise; export function removeOtherData(): Promise; export function cleanupOrphanedAttachments(): Promise; // Getters export function getMessagesNeedingUpgrade( limit: any, { maxVersion, }: { maxVersion?: number; } ): Promise; export function getLegacyMessagesNeedingUpgrade( limit: any, { maxVersion, }: { maxVersion?: number; } ): Promise; export function getMessagesWithVisualMediaAttachments( conversationId: any, { limit, }: { limit: any; } ): Promise; export function getMessagesWithFileAttachments( conversationId: any, { limit, }: { limit: any; } ): Promise; // Sender Keys export function getSenderKeys(groupId: any, senderIdentity: any): Promise; export function createOrUpdateSenderKeys(data: any): Promise; export function removeAllClosedGroupRatchets(groupId: string): Promise;