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 } export type ProtocolAddress = { name: string // jid deviceId: number } export type SignalIdentity = { identifier: ProtocolAddress identifierKey: Uint8Array } export type LTHashState = { version: number, hash: Buffer, mutations: ChatMutation[] } export type AuthenticationCreds = { noiseKey: KeyPair signedIdentityKey: KeyPair signedPreKey: SignedKeyPair registrationId: number advSecretKey: string me?: Contact account?: proto.ADVSignedDeviceIdentity signalIdentities?: SignalIdentity[] myAppStateKeyId?: string firstUnuploadedPreKeyId: number serverHasPreKeys: boolean nextPreKeyId: number } type Awaitable = T | Promise export type SignalKeyStore = { getPreKey: (keyId: number) => Awaitable setPreKey: (keyId: number, pair: KeyPair | null) => Awaitable getSession: (sessionId: string) => Awaitable setSession: (sessionId: string, item: any | null) => Awaitable getSenderKey: (id: string) => Awaitable setSenderKey: (id: string, item: any | null) => Awaitable getAppStateSyncKey: (id: string) => Awaitable setAppStateSyncKey: (id: string, item: proto.IAppStateSyncKeyData | null) => Awaitable getAppStateSyncVersion: (name: WAPatchName) => Awaitable setAppStateSyncVersion: (id: WAPatchName, item: LTHashState) => Awaitable } export type AuthenticationState = { creds: AuthenticationCreds keys: SignalKeyStore }