implement encrypting app patches

This commit is contained in:
Adhiraj Singh
2021-09-28 19:22:39 +05:30
parent 1890b6a021
commit fdfe310fdf
12 changed files with 420 additions and 216 deletions

View File

@@ -1,5 +1,6 @@
import type { Contact } from "./Contact"
import type { proto } from "../../WAProto"
import type { WAPatchName, ChatMutation } from "./Chat"
export type KeyPair = { public: Uint8Array, private: Uint8Array }
export type SignedKeyPair = { keyPair: KeyPair, signature: Uint8Array, keyId: number }
@@ -13,7 +14,7 @@ export type SignalIdentity = {
identifierKey: Uint8Array
}
export type CollectionType = 'regular_high' | 'regular_low' | 'critical_unblock_low' | 'critical_block'
export type LTHashState = { version: number, hash: Buffer, mutations: ChatMutation[] }
export type AuthenticationCreds = {
noiseKey: KeyPair
@@ -24,9 +25,6 @@ export type AuthenticationCreds = {
me?: Contact
account?: proto.ADVSignedDeviceIdentity
signalIdentities?: SignalIdentity[]
appStateVersion?: {
[T in CollectionType]: number
}
myAppStateKeyId?: string
firstUnuploadedPreKeyId: number
serverHasPreKeys: boolean
@@ -45,6 +43,9 @@ export type SignalKeyStore = {
getAppStateSyncKey: (id: string) => Awaitable<proto.IAppStateSyncKeyData>
setAppStateSyncKey: (id: string, item: proto.IAppStateSyncKeyData | null) => Awaitable<void>
getAppStateSyncVersion: (name: WAPatchName) => Awaitable<LTHashState>
setAppStateSyncVersion: (id: WAPatchName, item: LTHashState) => Awaitable<void>
}
export type AuthenticationState = {

View File

@@ -3,12 +3,14 @@ import type { proto } from "../../WAProto"
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
export type WAPatchName = 'critical_block' | 'critical_unblock_low' | 'regular_low' | 'regular_high' | 'regular'
export interface PresenceData {
lastKnownPresence: WAPresence
lastSeen?: number
}
export type ChatMutation = { action: proto.ISyncActionValue, index: [string, string] }
export type ChatMutation = { action: proto.ISyncActionValue, index: [string, string], indexMac: Uint8Array, valueMac: Uint8Array, operation: number }
export type Chat = Omit<proto.IConversation, 'messages'> & {
/** unix timestamp of date when mute ends, if applicable */

View File

@@ -1,6 +1,7 @@
import type { ReadStream } from "fs"
import type { Logger } from "pino"
import type { URL } from "url"
import type { GroupMetadata } from "./GroupMetadata"
import { proto } from '../../WAProto'
// export the WAMessage Prototypes
@@ -103,6 +104,13 @@ export type AnyMessageContent = AnyRegularMessageContent | {
} | {
disappearingMessagesInChat: boolean | number
}
export type MessageRelayOptions = {
messageId?: string
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
//cachedDevices?: (jid: string) => Promise<string[] | undefined>
}
export type MiscMessageGenerationOptions = {
/** Force message id */
messageId?: string