Mostly strictly types Signal Data
parent
c7b76dfebb
commit
7a85d69970
@ -1,3 +1,389 @@
|
||||
import { ConversationType } from '../../ts/state/ducks/conversations';
|
||||
import { Mesasge } from '../../ts/types/Message';
|
||||
|
||||
type IdentityKey = {
|
||||
id: string;
|
||||
publicKey: ArrayBuffer;
|
||||
firstUse: boolean;
|
||||
verified: number;
|
||||
nonblockingApproval: boolean;
|
||||
} | null;
|
||||
|
||||
type PreKey = {
|
||||
id: string;
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
recipient: string;
|
||||
} | null;
|
||||
|
||||
type PairingAuthorisation = {
|
||||
primaryDevicePubKey: string;
|
||||
secondaryDevicePubKey: string;
|
||||
requestSignature: string;
|
||||
grantSignature: string | null;
|
||||
} | null;
|
||||
|
||||
type PairingAuthorisationInit = {
|
||||
requestSignature: string;
|
||||
grantSignature: string;
|
||||
};
|
||||
|
||||
type GuardNode = {
|
||||
ed25519PubKey: string;
|
||||
};
|
||||
|
||||
type SwarmNode = {
|
||||
address: string;
|
||||
ip: string;
|
||||
port: string;
|
||||
pubkey_ed25519: string;
|
||||
pubkey_x25519: string;
|
||||
};
|
||||
|
||||
type StorageItem = {
|
||||
id: string;
|
||||
value: any;
|
||||
};
|
||||
|
||||
type SessionDataInfo = {
|
||||
id: string;
|
||||
number: string;
|
||||
deviceId: number;
|
||||
record: string;
|
||||
};
|
||||
|
||||
type ServerToken = {
|
||||
serverUrl: string;
|
||||
token: string;
|
||||
};
|
||||
|
||||
// Basic
|
||||
export function searchMessages(query: string): Promise<Array<any>>;
|
||||
export function searchConversations(query: string): Promise<Array<any>>;
|
||||
export function getPrimaryDeviceFor(pubKey: string): Promise<string | null>;
|
||||
export function shutdown(): Promise<void>;
|
||||
export function close(): Promise<void>;
|
||||
export function removeDB(): Promise<void>;
|
||||
export function removeIndexedDBFiles(): Promise<void>;
|
||||
export function getPasswordHash(): Promise<string | null>;
|
||||
|
||||
// Identity Keys
|
||||
export function createOrUpdateIdentityKey(data: any): Promise<void>;
|
||||
export function getIdentityKeyById(id: string): Promise<IdentityKey>;
|
||||
export function bulkAddIdentityKeys(array: Array<IdentityKey>): Promise<void>;
|
||||
export function removeIdentityKeyById(id: string): Promise<void>;
|
||||
export function removeAllIdentityKeys(): Promise<void>;
|
||||
|
||||
// Pre Keys
|
||||
export function createOrUpdatePreKey(data: PreKey): Promise<void>;
|
||||
export function getPreKeyById(id: string): Promise<PreKey>;
|
||||
export function getPreKeyByRecipient(recipient: string): Promise<PreKey>;
|
||||
export function bulkAddPreKeys(data: Array<PreKey>): Promise<void>;
|
||||
export function removePreKeyById(id: string): Promise<void>;
|
||||
export function getAllPreKeys(): Promise<Array<PreKey>>;
|
||||
|
||||
// Signed Pre Keys
|
||||
export function createOrUpdateSignedPreKey(data: PreKey): Promise<void>;
|
||||
export function getSignedPreKeyById(id: string): Promise<PreKey>;
|
||||
export function getAllSignedPreKeys(recipient: string): Promise<PreKey>;
|
||||
export function bulkAddSignedPreKeys(array: Array<PreKey>): Promise<void>;
|
||||
export function removeSignedPreKeyById(id: string): Promise<void>;
|
||||
export function removeAllSignedPreKeys(): Promise<void>;
|
||||
|
||||
// Contact Pre Key
|
||||
export function createOrUpdateContactPreKey(data: PreKey): Promise<void>;
|
||||
export function getContactPreKeyById(id: string): Promise<PreKey>;
|
||||
export function getContactPreKeyByIdentityKey(key: string): Promise<PreKey>;
|
||||
export function getContactPreKeys(
|
||||
keyId: string,
|
||||
identityKeyString: string
|
||||
): Promise<Array<PreKey>>;
|
||||
export function getAllContactPreKeys(): Promise<Array<PreKey>>;
|
||||
export function bulkAddContactPreKeys(array: Array<PreKey>): Promise<void>;
|
||||
export function removeContactPreKeyByIdentityKey(id: string): Promise<void>;
|
||||
export function removeAllContactPreKeys(): Promise<void>;
|
||||
|
||||
// Contact Signed Pre Key
|
||||
export function createOrUpdateContactSignedPreKey(data: PreKey): Promise<void>;
|
||||
export function getContactSignedPreKeyByIdid(string): Promise<PreKey>;
|
||||
export function getContactSignedPreKeyByIdentityKey(
|
||||
key: string
|
||||
): Promise<PreKey>;
|
||||
export function getContactSignedPreKeys(
|
||||
keyId: string,
|
||||
identityKeyString: string
|
||||
): Promise<Array<PreKey>>;
|
||||
export function bulkAddContactSignedPreKeys(
|
||||
array: Array<PreKey>
|
||||
): Promise<void>;
|
||||
export function removeContactSignedPreKeyByIdentityKey(
|
||||
id: string
|
||||
): Promise<void>;
|
||||
export function removeAllContactSignedPreKeys(): Promise<void>;
|
||||
|
||||
// Authorisations & Linking
|
||||
export function createOrUpdatePairingAuthorisation(
|
||||
data: PairingAuthorisationInit
|
||||
): Promise<PairingAuthorisation>;
|
||||
export function removePairingAuthorisationForSecondaryPubKey(
|
||||
pubKey: string
|
||||
): Promise<void>;
|
||||
export function getGrantAuthorisationsForPrimaryPubKey(
|
||||
pubKey: string
|
||||
): Promise<Array<PairingAuthorisation>>;
|
||||
export function getGrantAuthorisationForSecondaryPubKey(
|
||||
pubKey: string
|
||||
): Promise<PairingAuthorisation>;
|
||||
export function getAuthorisationForSecondaryPubKey(
|
||||
pubKey: string
|
||||
): PairingAuthorisation;
|
||||
export function getSecondaryDevicesFor(
|
||||
primaryDevicePubKey: string
|
||||
): Array<string>;
|
||||
export function getPrimaryDeviceFor(
|
||||
secondaryDevicePubKey: string
|
||||
): string | null;
|
||||
export function getPairedDevicesFor(pubKey: string): Array<string>;
|
||||
|
||||
// Guard Nodes
|
||||
export function getGuardNodes(): Promise<GuardNode>;
|
||||
export function updateGuardNodes(nodes: Array<string>): Promise<void>;
|
||||
|
||||
// Storage Items
|
||||
export function createOrUpdateItem(data: StorageItem): Promise<void>;
|
||||
export function getItemById(id: string): Promise<StorageItem>;
|
||||
export function getAlItems(): Promise<Array<StorageItem>>;
|
||||
export function bulkAddItems(array: Array<StorageItem>): Promise<void>;
|
||||
export function removeItemById(id: string): Promise<void>;
|
||||
export function removeAllItems(): Promise<void>;
|
||||
|
||||
// Sessions
|
||||
export function createOrUpdateSession(data: SessionDataInfo): Promise<void>;
|
||||
export function getAllSessions(): Promise<Array<SessionDataInfo>>;
|
||||
export function getSessionById(id: string): Promise<SessionDataInfo>;
|
||||
export function getSessionsByNumber(number: string): Promise<SessionDataInfo>;
|
||||
export function bulkAddSessions(array: Array<SessionDataInfo>): Promise<void>;
|
||||
export function removeSessionById(id: string): Promise<void>;
|
||||
export function removeSessionsByNumber(number: string): Promise<void>;
|
||||
export function removeAllSessions(): Promise<void>;
|
||||
|
||||
// Conversations
|
||||
export function getConversationCount(): Promise<number>;
|
||||
export function saveConversation(data: ConversationType): Promise<void>;
|
||||
export function saveConversations(data: Array<ConversationType>): Promise<void>;
|
||||
export function updateConversation(data: ConversationType): Promise<void>;
|
||||
export function removeConversation(id: string): Promise<void>;
|
||||
|
||||
export function getAllConversations({
|
||||
ConversationCollection,
|
||||
}: {
|
||||
ConversationCollection: any;
|
||||
}): Promise<Array<ConversationCollection>>;
|
||||
|
||||
export function getAllConversationIds(): Promise<Array<string>>;
|
||||
export function getAllPrivateConversations(): Promise<Array<string>>;
|
||||
export function getAllPublicConversations(): Promise<Array<string>>;
|
||||
export function getPublicConversationsByServer(
|
||||
server: string,
|
||||
{ ConversationCollection }: { ConversationCollection: any }
|
||||
): Promise<ConversationCollection>;
|
||||
export function getPubkeysInPublicConversation(
|
||||
id: string
|
||||
): Promise<Array<string>>;
|
||||
export function savePublicServerToken(data: ServerToken): Promise<void>;
|
||||
export function getPublicServerTokenByServerUrl(
|
||||
serverUrl: string
|
||||
): Promise<string>;
|
||||
export function getAllGroupsInvolvingId(
|
||||
id: string,
|
||||
{ ConversationCollection }: { ConversationCollection: any }
|
||||
): Promise<Array<ConversationCollection>>;
|
||||
|
||||
// Returns conversation row
|
||||
// TODO: Make strict return types for search
|
||||
export function searchConversations(query: string): Promise<any>;
|
||||
export function searchMessages(query: string): Promise<any>;
|
||||
export function searchMessagesInConversation(
|
||||
query: string,
|
||||
conversationId: string,
|
||||
{ limit }?: { limit: any }
|
||||
): Promise<any>;
|
||||
export function getMessageCount(): Promise<number>;
|
||||
export function saveMessage(
|
||||
data: Mesasge,
|
||||
{ forceSave, Message }?: { forceSave: any; Message: any }
|
||||
): Promise<string>;
|
||||
export function cleanSeenMessages(): Promise<void>;
|
||||
export function cleanLastHashes(): Promise<void>;
|
||||
export function saveSeenMessageHash(data: {
|
||||
expiresAt: number;
|
||||
hash: string;
|
||||
}): Promise<void>;
|
||||
|
||||
// TODO: Strictly type the following
|
||||
export function updateLastHash(data: any): Promise<any>;
|
||||
export function saveSeenMessageHashes(data: any): Promise<any>;
|
||||
export function saveLegacyMessage(data: any): Promise<any>;
|
||||
export function saveMessages(
|
||||
arrayOfMessages: any,
|
||||
{ forceSave }?: any
|
||||
): Promise<any>;
|
||||
export function removeMessage(id: string, { Message }?: any): Promise<any>;
|
||||
export function getUnreadByConversation(
|
||||
conversationId: string,
|
||||
{ MessageCollection }?: any
|
||||
): Promise<any>;
|
||||
export function removeAllMessagesInConversation(
|
||||
conversationId: string,
|
||||
{ MessageCollection }?: any
|
||||
): Promise<void>;
|
||||
|
||||
export function getMessageBySender(
|
||||
{
|
||||
source,
|
||||
sourceDevice,
|
||||
sent_at,
|
||||
}: { source: any; sourceDevice: any; sent_at: any },
|
||||
{ Message }: { Message: any }
|
||||
): Promise<any>;
|
||||
export function getMessageIdsFromServerIds(
|
||||
serverIds: any,
|
||||
conversationId: any
|
||||
): Promise<any>;
|
||||
export function getMessageById(
|
||||
id: string,
|
||||
{ Message }: { Message: any }
|
||||
): Promise<any>;
|
||||
export function getAllMessages({
|
||||
MessageCollection,
|
||||
}: {
|
||||
MessageCollection: any;
|
||||
}): Promise<any>;
|
||||
export function getAllUnsentMessages({
|
||||
MessageCollection,
|
||||
}: {
|
||||
MessageCollection: any;
|
||||
}): Promise<any>;
|
||||
export function getAllMessageIds(): Promise<any>;
|
||||
export function getMessagesBySentAt(
|
||||
sentAt: any,
|
||||
{ MessageCollection }: { MessageCollection: any }
|
||||
): Promise<any>;
|
||||
export function getExpiredMessages({
|
||||
MessageCollection,
|
||||
}: {
|
||||
MessageCollection: any;
|
||||
}): Promise<any>;
|
||||
export function getOutgoingWithoutExpiresAt({
|
||||
MessageCollection,
|
||||
}: any): Promise<any>;
|
||||
export function getNextExpiringMessage({
|
||||
MessageCollection,
|
||||
}: {
|
||||
MessageCollection: any;
|
||||
}): Promise<any>;
|
||||
export function getNextExpiringMessage({
|
||||
MessageCollection,
|
||||
}: {
|
||||
MessageCollection: any;
|
||||
}): Promise<any>;
|
||||
export function getMessagesByConversation(
|
||||
conversationId: any,
|
||||
{
|
||||
limit,
|
||||
receivedAt,
|
||||
MessageCollection,
|
||||
type,
|
||||
}: {
|
||||
limit?: number;
|
||||
receivedAt?: number;
|
||||
MessageCollection: any;
|
||||
type?: string;
|
||||
}
|
||||
): Promise<any>;
|
||||
export function getSeenMessagesByHashList(hashes: any): Promise<any>;
|
||||
export function getLastHashBySnode(convoId: any, snode: any): Promise<any>;
|
||||
|
||||
// Unprocessed
|
||||
export function getUnprocessedCount(): Promise<any>;
|
||||
export function getAllUnprocessed(): Promise<any>;
|
||||
export function getUnprocessedById(id: any): Promise<any>;
|
||||
export function saveUnprocessed(
|
||||
data: any,
|
||||
{
|
||||
forceSave,
|
||||
}?: {
|
||||
forceSave: any;
|
||||
}
|
||||
): Promise<any>;
|
||||
export function saveUnprocesseds(
|
||||
arrayOfUnprocessed: any,
|
||||
{
|
||||
forceSave,
|
||||
}?: {
|
||||
forceSave: any;
|
||||
}
|
||||
): Promise<void>;
|
||||
export function updateUnprocessedAttempts(
|
||||
id: any,
|
||||
attempts: any
|
||||
): Promise<void>;
|
||||
export function updateUnprocessedWithData(id: any, data: any): Promise<void>;
|
||||
export function removeUnprocessed(id: any): Promise<void>;
|
||||
export function removeAllUnprocessed(): Promise<void>;
|
||||
|
||||
// Attachment Downloads
|
||||
export function getNextAttachmentDownloadJobs(limit: any): Promise<any>;
|
||||
export function saveAttachmentDownloadJob(job: any): Promise<void>;
|
||||
export function setAttachmentDownloadJobPending(
|
||||
id: any,
|
||||
pending: any
|
||||
): Promise<void>;
|
||||
export function resetAttachmentDownloadPending(): Promise<void>;
|
||||
export function removeAttachmentDownloadJob(id: any): Promise<void>;
|
||||
export function removeAllAttachmentDownloadJobs(): Promise<void>;
|
||||
|
||||
// Other
|
||||
export function removeAll(): Promise<void>;
|
||||
export function removeAllConfiguration(): Promise<void>;
|
||||
export function removeAllConversations(): Promise<void>;
|
||||
export function removeAllPrivateConversations(): Promise<void>;
|
||||
export function removeOtherData(): Promise<void>;
|
||||
export function cleanupOrphanedAttachments(): Promise<void>;
|
||||
|
||||
// Getters
|
||||
export function getMessagesNeedingUpgrade(
|
||||
limit: any,
|
||||
{
|
||||
maxVersion,
|
||||
}: {
|
||||
maxVersion?: number;
|
||||
}
|
||||
): Promise<any>;
|
||||
export function getLegacyMessagesNeedingUpgrade(
|
||||
limit: any,
|
||||
{
|
||||
maxVersion,
|
||||
}: {
|
||||
maxVersion?: number;
|
||||
}
|
||||
): Promise<any>;
|
||||
export function getMessagesWithVisualMediaAttachments(
|
||||
conversationId: any,
|
||||
{
|
||||
limit,
|
||||
}: {
|
||||
limit: any;
|
||||
}
|
||||
): Promise<any>;
|
||||
export function getMessagesWithFileAttachments(
|
||||
conversationId: any,
|
||||
{
|
||||
limit,
|
||||
}: {
|
||||
limit: any;
|
||||
}
|
||||
): Promise<any>;
|
||||
|
||||
// Sender Keys
|
||||
export function getSenderKeys(groupId: any, senderIdentity: any): Promise<any>;
|
||||
export function createOrUpdateSenderKeys(data: any): Promise<void>;
|
||||
|
@ -0,0 +1,77 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
seedNodeList: any;
|
||||
|
||||
WebAPI: any;
|
||||
LokiSnodeAPI: any;
|
||||
SenderKeyAPI: any;
|
||||
LokiMessageAPI: any;
|
||||
StubMessageAPI: any;
|
||||
StubAppDotNetApi: any;
|
||||
LokiPublicChatAPI: any;
|
||||
LokiAppDotNetServerAPI: any;
|
||||
LokiFileServerAPI: any;
|
||||
LokiRssAPI: any;
|
||||
}
|
||||
}
|
||||
|
||||
// window.WebAPI = initializeWebAPI();
|
||||
// const LokiSnodeAPI = require('./js/modules/loki_snode_api');
|
||||
// window.SenderKeyAPI = require('./js/modules/loki_sender_key_api');
|
||||
// window.lokiSnodeAPI
|
||||
// window.LokiMessageAPI = require('./js/modules/loki_message_api');
|
||||
// window.StubMessageAPI = require('./integration_test/stubs/stub_message_api');
|
||||
// window.StubAppDotNetApi = require('./integration_test/stubs/stub_app_dot_net_api');
|
||||
// window.LokiPublicChatAPI = require('./js/modules/loki_public_chat_api');
|
||||
// window.LokiAppDotNetServerAPI = require('./js/modules/loki_app_dot_net_api');
|
||||
// window.LokiFileServerAPI = require('./js/modules/loki_file_server_api');
|
||||
// window.LokiRssAPI = require('./js/modules/loki_rss_api');
|
||||
|
||||
export const exporttts = {
|
||||
// APIs
|
||||
WebAPI: window.WebAPI,
|
||||
|
||||
// Utilities
|
||||
Events: () => window.Events,
|
||||
Signal: () => window.Signal,
|
||||
Whisper: () => window.Whisper,
|
||||
ConversationController: () => window.ConversationController,
|
||||
passwordUtil: () => window.passwordUtil,
|
||||
|
||||
// Values
|
||||
CONSTANTS: () => window.CONSTANTS,
|
||||
versionInfo: () => window.versionInfo,
|
||||
mnemonic: () => window.mnemonic,
|
||||
lokiFeatureFlags: () => window.lokiFeatureFlags,
|
||||
|
||||
// Getters
|
||||
getAccountManager: () => window.getAccountManager,
|
||||
getConversations: () => window.getConversations,
|
||||
getFriendsFromContacts: () => window.getFriendsFromContacts,
|
||||
getSettingValue: () => window.getSettingValue,
|
||||
|
||||
// Setters
|
||||
setPassword: () => window.setPassword,
|
||||
setSettingValue: () => window.setSettingValue,
|
||||
|
||||
// UI Events
|
||||
pushToast: () => window.pushToast,
|
||||
confirmationDialog: () => window.confirmationDialog,
|
||||
|
||||
showQRDialog: () => window.showQRDialog,
|
||||
showSeedDialog: () => window.showSeedDialog,
|
||||
showPasswordDialog: () => window.showPasswordDialog,
|
||||
showEditProfileDialog: () => window.showEditProfileDialog,
|
||||
|
||||
toggleTheme: () => window.toggleTheme,
|
||||
toggleMenuBar: () => window.toggleMenuBar,
|
||||
toggleSpellCheck: () => window.toggleSpellCheck,
|
||||
toggleLinkPreview: () => window.toggleLinkPreview,
|
||||
toggleMediaPermissions: () => window.toggleMediaPermissions,
|
||||
|
||||
// Actions
|
||||
clearLocalData: () => window.clearLocalData,
|
||||
deleteAccount: () => window.deleteAccount,
|
||||
resetDatabase: () => window.resetDatabase,
|
||||
attemptConnection: () => window.attemptConnection,
|
||||
};
|
Loading…
Reference in New Issue