-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
95 lines (78 loc) · 1.6 KB
/
types.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import fs, { WriteStream } from "fs";
export type Message =
| TextMessage
| TransferMessage
| TransferPacketMessage
| TransferResponse
| TransferConnectionMessage
| BurnMessage
| CloseMessage
| ReceiveConfirmationMessage;
export interface GenericError {
error: { message: string; code: string };
}
export interface TextMessage {
type: "text";
text: string;
}
export interface TransferMessage {
type: "transfer";
info: TransferInfo;
}
export interface TransferConnectionMessage {
type: "transferconnection";
address: Address;
transfer_id: number;
}
export interface TransferPacketMessage {
type: "transferpacket";
}
export interface TransferResponse {
type: "transferresponse";
accepted: boolean;
transfer_id: number;
}
export interface BurnMessage {
type: "burn";
}
export interface CloseMessage {
type: "close";
}
export interface ReceiveConfirmationMessage {
type: "receiveconfirmation";
transfer_id: number;
}
export interface TransferInfo {
id: number;
total_packets: number;
total_bytes: number;
packet_size: number;
encryption_token: string;
}
export interface TransferPacket {
size: number;
id: number;
transfer_id: number;
}
export type ServerInfo = {
hostname: string;
api_port: number;
socket_port: number;
};
export type Credentials = {
authtoken?: string;
userid?: number;
};
export type Address = {
hostname: string;
port: number;
};
export class GenericError {
error: { message: string; code: string };
constructor(message: string, code: string) {
this.error = {
message: message,
code: code,
};
}
}