-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Signal.ts
68 lines (58 loc) · 1.37 KB
/
Signal.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { proto } from '../../WAProto'
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>
jidToSignalProtocolAddress(jid: string): string
}