finalize multi-device

This commit is contained in:
Adhiraj Singh
2021-09-15 13:40:02 +05:30
parent 9cba28e891
commit f267f27ada
82 changed files with 35228 additions and 10644 deletions

View File

@@ -1,22 +1,51 @@
import type { Contact } from "./Contact"
import type { proto } from "../../WAProto"
export interface AuthenticationCredentials {
clientID: string
serverToken: string
clientToken: string
encKey: Buffer
macKey: Buffer
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 interface AuthenticationCredentialsBase64 {
clientID: string
serverToken: string
clientToken: string
encKey: string
macKey: string
export type SignalIdentity = {
identifier: ProtocolAddress
identifierKey: Uint8Array
}
export interface AuthenticationCredentialsBrowser {
WABrowserId: string
WASecretBundle: {encKey: string, macKey: string} | string
WAToken1: string
WAToken2: string
export type CollectionType = 'regular_high' | 'regular_low' | 'critical_unblock_low' | 'critical_block'
export type AuthenticationCreds = {
noiseKey: KeyPair
signedIdentityKey: KeyPair
signedPreKey: SignedKeyPair
registrationId: number
advSecretKey: string
me?: Contact
account?: proto.ADVSignedDeviceIdentity
signalIdentities?: SignalIdentity[]
appStateSyncKeys?: proto.IAppStateSyncKey[]
appStateVersion?: {
[T in CollectionType]: number
}
firstUnuploadedPreKeyId: number
serverHasPreKeys: boolean
nextPreKeyId: number
}
export type AnyAuthenticationCredentials = AuthenticationCredentialsBrowser | AuthenticationCredentialsBase64 | AuthenticationCredentials
type Awaitable<T> = T | Promise<T>
export type SignalKeyStore = {
getPreKey: (keyId: number) => Awaitable<KeyPair>
setPreKey: (keyId: number, pair: KeyPair | null) => Awaitable<void>
getSession: (sessionId: string) => Awaitable<any>
setSession: (sessionId: string, item: any | null) => Awaitable<void>
getSenderKey: (id: string) => Awaitable<any>
setSenderKey: (id: string, item: any | null) => Awaitable<void>
}
export type AuthenticationState = {
creds: AuthenticationCreds
keys: SignalKeyStore
}