ae456cb342
* fix: remove redundant migration * fix: remove deduplicatelidpnjids * fix: assertsessions complexity * fix: assertsessions call * fix: remove getencryptionjid * fix: add wirejid to injecte2esession, remove libsignal lid migration * fix: logger lid-mapping * fix: injecte2esession decoded approach * fix: changes made by @AstroX11 * fix: lint * fix: lint * fix: lint * Revert "fix: injecte2esession decoded approach" This reverts commit 4e368296ed084398b8a173ec117dc2478e481748. * fix: centralize getlidforpn calls in messages-send * fix: add resolvechunklids to signal * fix: remove useless arrays * fix: assertsessions logic * fix: lint * Revert "fix: assertsessions logic" This reverts commit 65b0730891c91573edcab1c96af010db54382fba. * fix: remove onwhatsapp fallback to prevent rate limit, migrate sessions when lid-map is created, new migration logic and user devices key * fix: migrate session devices, socket creation * fix: add back decryptionjid validation * fix: add resolveSignalAddress to get lid * fix: type error migration * fix: lint * fix: device level cache, proposed changes
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import { proto } from '../../WAProto/index.js'
|
|
import type { LIDMappingStore } from '../Signal/lid-mapping'
|
|
|
|
type DecryptGroupSignalOpts = {
|
|
group: string
|
|
authorJid: string
|
|
msg: Uint8Array
|
|
}
|
|
|
|
type ProcessSenderKeyDistributionMessageOpts = {
|
|
item: proto.Message.ISenderKeyDistributionMessage
|
|
authorJid: string
|
|
}
|
|
|
|
type DecryptSignalProtoOpts = {
|
|
jid: string
|
|
type: 'pkmsg' | 'msg'
|
|
ciphertext: Uint8Array
|
|
}
|
|
|
|
type EncryptMessageOpts = {
|
|
jid: string
|
|
data: Uint8Array
|
|
}
|
|
|
|
type EncryptGroupMessageOpts = {
|
|
group: string
|
|
data: Uint8Array
|
|
meId: string
|
|
}
|
|
|
|
type PreKey = {
|
|
keyId: number
|
|
publicKey: Uint8Array
|
|
}
|
|
|
|
type SignedPreKey = PreKey & {
|
|
signature: Uint8Array
|
|
}
|
|
|
|
type E2ESession = {
|
|
registrationId: number
|
|
identityKey: Uint8Array
|
|
signedPreKey: SignedPreKey
|
|
preKey: PreKey
|
|
}
|
|
|
|
type E2ESessionOpts = {
|
|
jid: string
|
|
session: E2ESession
|
|
}
|
|
|
|
export type SignalRepository = {
|
|
decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>
|
|
processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>
|
|
decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>
|
|
encryptMessage(opts: EncryptMessageOpts): Promise<{
|
|
type: 'pkmsg' | 'msg'
|
|
ciphertext: Uint8Array
|
|
}>
|
|
encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
|
|
senderKeyDistributionMessage: Uint8Array
|
|
ciphertext: Uint8Array
|
|
}>
|
|
injectE2ESession(opts: E2ESessionOpts): Promise<void>
|
|
validateSession(jid: string): Promise<{ exists: boolean; reason?: string }>
|
|
jidToSignalProtocolAddress(jid: string): string
|
|
migrateSession(fromJid: string, toJid: string): Promise<{ migrated: number; skipped: number; total: number }>
|
|
validateSession(jid: string): Promise<{ exists: boolean; reason?: string }>
|
|
deleteSession(jids: string[]): Promise<void>
|
|
}
|
|
|
|
// Optimized repository with pre-loaded LID mapping store
|
|
export interface SignalRepositoryWithLIDStore extends SignalRepository {
|
|
lidMapping: LIDMappingStore
|
|
}
|