-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathpayload.ts
More file actions
32 lines (27 loc) · 1.01 KB
/
payload.ts
File metadata and controls
32 lines (27 loc) · 1.01 KB
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
/* eslint-disable import/export */
/* eslint-disable @typescript-eslint/no-namespace */
import { encodeMessage, decodeMessage, message, bytes } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
export namespace pb {
export interface NoiseHandshakePayload {
identityKey: Uint8Array
identitySig: Uint8Array
data: Uint8Array
}
export namespace NoiseHandshakePayload {
export const codec = (): Codec<NoiseHandshakePayload> => {
return message<NoiseHandshakePayload>({
1: { name: 'identityKey', codec: bytes },
2: { name: 'identitySig', codec: bytes },
3: { name: 'data', codec: bytes }
})
}
export const encode = (obj: NoiseHandshakePayload): Uint8ArrayList => {
return encodeMessage(obj, NoiseHandshakePayload.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): NoiseHandshakePayload => {
return decodeMessage(buf, NoiseHandshakePayload.codec())
}
}
}