-
Notifications
You must be signed in to change notification settings - Fork 3
/
IMessage.ts
77 lines (65 loc) · 1.45 KB
/
IMessage.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
69
70
71
72
73
74
75
76
77
import type { Uint256 } from './Uint256';
/**
* @category Content
* @description Interface representing base message metadata and content
*/
export interface IMessage<M = any> {
isBroadcast: boolean;
feedId: Uint256;
msgId: string;
createdAt: number;
senderAddress: string;
recipientAddress: Uint256;
blockchain: string;
key: Uint8Array;
readonly $$meta: M;
}
/**
* @category Content
* @description Enum for all types of errors for message content reading/decrypting/unpacking
*/
export enum MessageContentFailure {
/**
* Not all parts of the message content were retrieved
*/
NOT_ALL_PARTS,
/**
* Some parts were not found
*/
NON_INTEGRITY_PARTS,
/**
* Some parts occured more than once
*/
DOUBLED_PARTS,
/**
* Decryption of the message content was unsuccessful
*/
NON_DECRYPTABLE,
/**
* Some parts of the message content were uploaded with a huge lag which may violate message's integrity
*/
TIMING_FAILURE,
}
/**
* @category Content
* @description Interface representing failed content-reading result
*/
export interface IMessageCorruptedContent {
msgId: string;
corrupted: true;
chunks: { createdAt: number }[];
reason: MessageContentFailure;
}
/**
* @category Content
* @description Interface representing successful content-reading result
*/
export interface IMessageContent {
msgId: string;
corrupted: false;
createdAt: number;
storage: string;
senderAddress: string;
parts: number;
content: Uint8Array;
}