From 85d3c35c0cc39271fb043c08f4c60ba6303d1c06 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 28 May 2020 12:46:42 +1000 Subject: [PATCH] Fix types --- js/modules/data.d.ts | 109 +++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/js/modules/data.d.ts b/js/modules/data.d.ts index e154cbf3c..92441555f 100644 --- a/js/modules/data.d.ts +++ b/js/modules/data.d.ts @@ -7,25 +7,46 @@ type IdentityKey = { firstUse: boolean; verified: number; nonblockingApproval: boolean; -} | null; +}; type PreKey = { - id: string; - publicKey: string; - privateKey: string; + id: number; + publicKey: ArrayBuffer; + privateKey: ArrayBuffer; recipient: string; -} | null; +}; + +type SignedPreKey = { + id: number; + publicKey: ArrayBuffer; + privateKey: ArrayBuffer; + created_at: number; + confirmed: boolean; + signature: ArrayBuffer; +}; + +type ContactPreKey = { + id: number; + identityKeyString: string; + publicKey: ArrayBuffer; + keyId: number; +}; + +type ContactSignedPreKey = { + id: number; + identityKeyString: string; + publicKey: ArrayBuffer; + keyId: number; + signature: ArrayBuffer; + created_at: number; + confirmed: boolean; +}; type PairingAuthorisation = { primaryDevicePubKey: string; secondaryDevicePubKey: string; - requestSignature: string; - grantSignature: string | null; -} | null; - -type PairingAuthorisationInit = { - requestSignature: string; - grantSignature: string; + requestSignature: ArrayBuffer; + grantSignature: ArrayBuffer | null; }; type GuardNode = { @@ -67,53 +88,61 @@ export function removeIndexedDBFiles(): Promise; export function getPasswordHash(): Promise; // Identity Keys -export function createOrUpdateIdentityKey(data: any): Promise; -export function getIdentityKeyById(id: string): Promise; +export function createOrUpdateIdentityKey(data: IdentityKey): 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: string): Promise; -export function getPreKeyByRecipient(recipient: string): Promise; +export function getPreKeyById(id: number): Promise; +export function getPreKeyByRecipient(recipient: string): Promise; export function bulkAddPreKeys(data: Array): Promise; -export function removePreKeyById(id: string): Promise; +export function removePreKeyById(id: number): Promise; export function getAllPreKeys(): Promise>; // Signed Pre Keys -export function createOrUpdateSignedPreKey(data: PreKey): Promise; -export function getSignedPreKeyById(id: string): Promise; -export function getAllSignedPreKeys(recipient: string): Promise; -export function bulkAddSignedPreKeys(array: Array): Promise; -export function removeSignedPreKeyById(id: string): Promise; +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: PreKey): Promise; -export function getContactPreKeyById(id: string): Promise; -export function getContactPreKeyByIdentityKey(key: string): Promise; +export function createOrUpdateContactPreKey(data: ContactPreKey): Promise; +export function getContactPreKeyById(id: number): Promise; +export function getContactPreKeyByIdentityKey( + key: string +): Promise; export function getContactPreKeys( - keyId: string, + keyId: number, identityKeyString: string -): Promise>; -export function getAllContactPreKeys(): Promise>; -export function bulkAddContactPreKeys(array: Array): Promise; -export function removeContactPreKeyByIdentityKey(id: string): Promise; +): 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: PreKey): Promise; -export function getContactSignedPreKeyByIdid(string): Promise; +export function createOrUpdateContactSignedPreKey( + data: ContactSignedPreKey +): Promise; +export function getContactSignedPreKeyById( + id: number +): Promise; export function getContactSignedPreKeyByIdentityKey( key: string -): Promise; +): Promise; export function getContactSignedPreKeys( - keyId: string, + keyId: number, identityKeyString: string -): Promise>; +): Promise>; export function bulkAddContactSignedPreKeys( - array: Array + array: Array ): Promise; export function removeContactSignedPreKeyByIdentityKey( id: string @@ -122,8 +151,8 @@ export function removeAllContactSignedPreKeys(): Promise; // Authorisations & Linking export function createOrUpdatePairingAuthorisation( - data: PairingAuthorisationInit -): Promise; + data: PairingAuthorisation +): Promise; export function removePairingAuthorisationForSecondaryPubKey( pubKey: string ): Promise; @@ -132,10 +161,10 @@ export function getGrantAuthorisationsForPrimaryPubKey( ): Promise>; export function getGrantAuthorisationForSecondaryPubKey( pubKey: string -): Promise; +): Promise; export function getAuthorisationForSecondaryPubKey( pubKey: string -): Promise; +): Promise; export function getSecondaryDevicesFor( primaryDevicePubKey: string ): Promise>;