@ermis-network/ermis-chat-sdk 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +330 -0
- package/dist/encryption/index.browser.cjs +13045 -0
- package/dist/encryption/index.browser.cjs.map +1 -0
- package/dist/encryption/index.browser.mjs +12959 -0
- package/dist/encryption/index.browser.mjs.map +1 -0
- package/dist/encryption/index.cjs +13045 -0
- package/dist/encryption/index.cjs.map +1 -0
- package/dist/encryption/index.d.mts +3 -0
- package/dist/encryption/index.d.ts +3 -0
- package/dist/encryption/index.mjs +12959 -0
- package/dist/encryption/index.mjs.map +1 -0
- package/dist/index-CcvHIY5q.d.mts +4988 -0
- package/dist/index-CcvHIY5q.d.ts +4988 -0
- package/dist/index.browser.cjs +20192 -5766
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.full-bundle.min.js +20 -16
- package/dist/index.browser.full-bundle.min.js.map +1 -1
- package/dist/index.browser.mjs +20106 -5731
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.cjs +20191 -5765
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +15 -1337
- package/dist/index.d.ts +15 -1337
- package/dist/index.mjs +20106 -5731
- package/dist/index.mjs.map +1 -1
- package/dist/wasm_worker.worker.mjs +8 -4
- package/dist/wasm_worker.worker.mjs.map +1 -1
- package/package.json +21 -6
- package/public/e2ee-media-stream-worker.js +627 -0
- package/public/openmls_wasm_bg.wasm +0 -0
- package/src/attachment_utils.ts +0 -148
- package/src/auth.ts +0 -352
- package/src/channel.ts +0 -1879
- package/src/channel_state.ts +0 -612
- package/src/client.ts +0 -1759
- package/src/client_state.ts +0 -55
- package/src/connection.ts +0 -587
- package/src/ermis_call_node.ts +0 -1046
- package/src/errors.ts +0 -60
- package/src/events.ts +0 -46
- package/src/hevc_decoder_config.ts +0 -305
- package/src/index.ts +0 -17
- package/src/media_stream_receiver.ts +0 -593
- package/src/media_stream_sender.ts +0 -465
- package/src/shims/empty.ts +0 -1
- package/src/signal_message.ts +0 -171
- package/src/system_message.ts +0 -259
- package/src/token_manager.ts +0 -48
- package/src/types.ts +0 -594
- package/src/utils.ts +0 -553
- package/src/wasm/ermis_call_node_wasm.d.ts +0 -156
- package/src/wasm/ermis_call_node_wasm.js +0 -1568
- package/src/wasm_worker.ts +0 -219
- package/src/wasm_worker_proxy.ts +0 -244
package/src/types.ts
DELETED
|
@@ -1,594 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { StableWSConnection } from './connection';
|
|
3
|
-
import { EVENT_MAP } from './events';
|
|
4
|
-
|
|
5
|
-
export type Role = 'owner' | 'moder' | 'member' | 'pending' | 'skipped' | string;
|
|
6
|
-
|
|
7
|
-
/* Unknown Record */
|
|
8
|
-
export type UR = Record<string, unknown>;
|
|
9
|
-
export type DefaultGenerics = {
|
|
10
|
-
attachmentType: UR;
|
|
11
|
-
channelType: UR;
|
|
12
|
-
commandType: LiteralStringForUnion;
|
|
13
|
-
eventType: UR;
|
|
14
|
-
messageType: UR;
|
|
15
|
-
pollOptionType: UR;
|
|
16
|
-
pollType: UR;
|
|
17
|
-
reactionType: UR;
|
|
18
|
-
userType: UR;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ExtendableGenerics = {
|
|
22
|
-
attachmentType: UR;
|
|
23
|
-
channelType: UR;
|
|
24
|
-
commandType: string;
|
|
25
|
-
eventType: UR;
|
|
26
|
-
messageType: UR;
|
|
27
|
-
pollOptionType: UR;
|
|
28
|
-
pollType: UR;
|
|
29
|
-
reactionType: UR;
|
|
30
|
-
userType: UR;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Response Types
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
export type APIResponse = {
|
|
38
|
-
duration?: string;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type ChannelResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
42
|
-
ErmisChatGenerics['channelType'] & {
|
|
43
|
-
cid: string;
|
|
44
|
-
id: string;
|
|
45
|
-
type: string;
|
|
46
|
-
created_at?: string;
|
|
47
|
-
created_by?: UserResponse<ErmisChatGenerics> | null;
|
|
48
|
-
deleted_at?: string;
|
|
49
|
-
last_message_at?: string;
|
|
50
|
-
member_count?: number;
|
|
51
|
-
members: ChannelMemberResponse<ErmisChatGenerics>[];
|
|
52
|
-
name?: string;
|
|
53
|
-
own_capabilities?: string[];
|
|
54
|
-
updated_at?: string;
|
|
55
|
-
image?: string;
|
|
56
|
-
description?: string;
|
|
57
|
-
member_message_cooldown?: number;
|
|
58
|
-
member_capabilities?: string[];
|
|
59
|
-
is_pinned?: boolean;
|
|
60
|
-
topics_enabled?: boolean;
|
|
61
|
-
parent_cid?: string;
|
|
62
|
-
is_closed_topic?: boolean;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type QueryChannelsAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
66
|
-
channels: Omit<ChannelAPIResponse<ErmisChatGenerics>, keyof APIResponse>[];
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export type QueryChannelAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse &
|
|
70
|
-
ChannelAPIResponse<ErmisChatGenerics>;
|
|
71
|
-
|
|
72
|
-
export type ChannelAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
73
|
-
channel: ChannelResponse<ErmisChatGenerics>;
|
|
74
|
-
members: ChannelMemberResponse<ErmisChatGenerics>[];
|
|
75
|
-
messages: MessageResponse<ErmisChatGenerics>[];
|
|
76
|
-
pinned_messages: MessageResponse<ErmisChatGenerics>[];
|
|
77
|
-
membership?: ChannelMembership<ErmisChatGenerics> | null;
|
|
78
|
-
read?: ReadResponse<ErmisChatGenerics>[];
|
|
79
|
-
topics?: QueryChannelAPIResponse<ErmisChatGenerics>[];
|
|
80
|
-
watcher_count?: number;
|
|
81
|
-
watchers?: UserResponse<ErmisChatGenerics>[];
|
|
82
|
-
is_pinned?: boolean;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export type ChannelMemberResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
86
|
-
banned?: boolean;
|
|
87
|
-
blocked?: boolean;
|
|
88
|
-
channel_role?: Role;
|
|
89
|
-
created_at?: string;
|
|
90
|
-
updated_at?: string;
|
|
91
|
-
user?: UserResponse<ErmisChatGenerics>;
|
|
92
|
-
user_id?: string;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export type ConnectAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
96
|
-
Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
97
|
-
|
|
98
|
-
export type FormatMessageResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = Omit<
|
|
99
|
-
MessageResponse<{
|
|
100
|
-
attachmentType: ErmisChatGenerics['attachmentType'];
|
|
101
|
-
channelType: ErmisChatGenerics['channelType'];
|
|
102
|
-
commandType: ErmisChatGenerics['commandType'];
|
|
103
|
-
eventType: ErmisChatGenerics['eventType'];
|
|
104
|
-
messageType: {};
|
|
105
|
-
pollOptionType: ErmisChatGenerics['pollOptionType'];
|
|
106
|
-
pollType: ErmisChatGenerics['pollType'];
|
|
107
|
-
reactionType: ErmisChatGenerics['reactionType'];
|
|
108
|
-
userType: ErmisChatGenerics['userType'];
|
|
109
|
-
}>,
|
|
110
|
-
'created_at' | 'pinned_at' | 'updated_at' | 'status'
|
|
111
|
-
> &
|
|
112
|
-
ErmisChatGenerics['messageType'] & {
|
|
113
|
-
created_at: Date;
|
|
114
|
-
pinned_at: Date | null;
|
|
115
|
-
status: string;
|
|
116
|
-
updated_at: Date;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export type MessageDisplayType = 'normal' | 'deleted';
|
|
120
|
-
|
|
121
|
-
export type MessageResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
122
|
-
MessageResponseBase<ErmisChatGenerics> & {
|
|
123
|
-
quoted_message?: MessageResponseBase<ErmisChatGenerics>;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export type MessageResponseBase<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
127
|
-
MessageBase<ErmisChatGenerics> & {
|
|
128
|
-
type: MessageLabel;
|
|
129
|
-
display_type?: MessageDisplayType;
|
|
130
|
-
channel?: ChannelResponse<ErmisChatGenerics>;
|
|
131
|
-
cid?: string;
|
|
132
|
-
created_at?: string;
|
|
133
|
-
deleted_at?: string;
|
|
134
|
-
latest_reactions?: ReactionResponse<ErmisChatGenerics>[];
|
|
135
|
-
mentioned_users?: string[];
|
|
136
|
-
own_reactions?: ReactionResponse<ErmisChatGenerics>[] | null;
|
|
137
|
-
pinned_at?: string | null;
|
|
138
|
-
pinned_by?: UserResponse<ErmisChatGenerics> | null;
|
|
139
|
-
reaction_counts?: { [key: string]: number } | null;
|
|
140
|
-
reaction_scores?: { [key: string]: number } | null;
|
|
141
|
-
reply_count?: number;
|
|
142
|
-
status?: string;
|
|
143
|
-
updated_at?: string;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export type ReactionAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
147
|
-
message: MessageResponse<ErmisChatGenerics>;
|
|
148
|
-
reaction: ReactionResponse<ErmisChatGenerics>;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export type ReactionResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
152
|
-
Reaction<ErmisChatGenerics> & {
|
|
153
|
-
created_at: string;
|
|
154
|
-
message_id: string;
|
|
155
|
-
updated_at: string;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export type ReadResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
159
|
-
last_read: string;
|
|
160
|
-
user: UserResponse<ErmisChatGenerics>;
|
|
161
|
-
last_read_message_id?: string;
|
|
162
|
-
unread_messages?: number;
|
|
163
|
-
last_send?: string;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
// Thumb URL(thumb_url) is added considering video attachments as the backend will return the thumbnail in the response.
|
|
167
|
-
export type SendFileAPIResponse = APIResponse & { file: string; thumb_url?: string };
|
|
168
|
-
|
|
169
|
-
export type SendMessageAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
170
|
-
message: MessageResponse<ErmisChatGenerics>;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export type UpdateChannelAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
174
|
-
channel: ChannelResponse<ErmisChatGenerics>;
|
|
175
|
-
members: ChannelMemberResponse<ErmisChatGenerics>[];
|
|
176
|
-
message?: MessageResponse<ErmisChatGenerics>;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export type UserResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
180
|
-
ErmisChatGenerics['userType'] & {
|
|
181
|
-
id: string;
|
|
182
|
-
name?: string;
|
|
183
|
-
avatar?: string;
|
|
184
|
-
about_me?: string;
|
|
185
|
-
project_id?: string;
|
|
186
|
-
email?: string;
|
|
187
|
-
phone?: string;
|
|
188
|
-
};
|
|
189
|
-
export type Contact = {
|
|
190
|
-
project_id: string;
|
|
191
|
-
user_id: string;
|
|
192
|
-
other_id: string;
|
|
193
|
-
relation_status: string;
|
|
194
|
-
created_at: string;
|
|
195
|
-
updated_at: string;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export type ContactResponse = APIResponse & {
|
|
199
|
-
project_id_user_ids: {
|
|
200
|
-
[key: string]: Contact[];
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export type ContactResult<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
205
|
-
contact_users: UserResponse<ErmisChatGenerics>[];
|
|
206
|
-
block_users: UserResponse<ErmisChatGenerics>[];
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
export type ChannelQueryOptions = {
|
|
210
|
-
messages?: {
|
|
211
|
-
limit?: number;
|
|
212
|
-
id_lt?: string;
|
|
213
|
-
id_gt?: string;
|
|
214
|
-
id_around?: string;
|
|
215
|
-
include_hidden_messages?: boolean;
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
export type ChannelStateOptions = {
|
|
220
|
-
offlineMode?: boolean;
|
|
221
|
-
skipInitialization?: string[];
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export type ErmisChatOptions = AxiosRequestConfig & {
|
|
225
|
-
/**
|
|
226
|
-
* Used to disable warnings that are triggered by using connectUser or connectAnonymousUser server-side.
|
|
227
|
-
*/
|
|
228
|
-
allowServerSideConnect?: boolean;
|
|
229
|
-
axiosRequestConfig?: AxiosRequestConfig;
|
|
230
|
-
/**
|
|
231
|
-
* Base url for User BE API (uss/v1). Defaults to baseURL + '/uss/v1' if not provided.
|
|
232
|
-
*/
|
|
233
|
-
userBaseURL?: string;
|
|
234
|
-
browser?: boolean;
|
|
235
|
-
enableInsights?: boolean;
|
|
236
|
-
/** experimental feature, please contact support if you want this feature enabled for you */
|
|
237
|
-
logger?: Logger;
|
|
238
|
-
/**
|
|
239
|
-
* When network is recovered, we re-query the active channels on client. But in single query, you can recover
|
|
240
|
-
* only 30 channels. So its not guaranteed that all the channels in activeChannels object have updated state.
|
|
241
|
-
* Thus in UI sdks, state recovery is managed by components themselves, they don't rely on js client for this.
|
|
242
|
-
*
|
|
243
|
-
* `recoverStateOnReconnect` parameter can be used in such cases, to disable state recovery within js client.
|
|
244
|
-
* When false, user/consumer of this client will need to make sure all the channels present on UI by
|
|
245
|
-
* manually calling queryChannels endpoint.
|
|
246
|
-
*/
|
|
247
|
-
recoverStateOnReconnect?: boolean;
|
|
248
|
-
warmUp?: boolean;
|
|
249
|
-
// Set the instance of StableWSConnection on chat client. Its purely for testing purpose and should
|
|
250
|
-
// not be used in production apps.
|
|
251
|
-
wsConnection?: StableWSConnection;
|
|
252
|
-
recoveryConfig?: {
|
|
253
|
-
filter?: ChannelFilters;
|
|
254
|
-
sort?: ChannelSort;
|
|
255
|
-
options?: { message_limit?: number };
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Event Types
|
|
261
|
-
*/
|
|
262
|
-
|
|
263
|
-
export type Event<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['eventType'] & {
|
|
264
|
-
type: EventTypes;
|
|
265
|
-
channel?: ChannelResponse<ErmisChatGenerics>;
|
|
266
|
-
channel_id?: string;
|
|
267
|
-
channel_type?: string;
|
|
268
|
-
cid?: string;
|
|
269
|
-
created_at?: string;
|
|
270
|
-
hard_delete?: boolean;
|
|
271
|
-
last_read_at?: string;
|
|
272
|
-
last_read_message_id?: string;
|
|
273
|
-
me?: UserResponse<ErmisChatGenerics>;
|
|
274
|
-
member?: ChannelMemberResponse<ErmisChatGenerics>;
|
|
275
|
-
message?: MessageResponse<ErmisChatGenerics>;
|
|
276
|
-
online?: boolean;
|
|
277
|
-
parent_id?: string;
|
|
278
|
-
parent_cid?: string;
|
|
279
|
-
reaction?: ReactionResponse<ErmisChatGenerics>;
|
|
280
|
-
received_at?: string | Date;
|
|
281
|
-
unread_messages?: number;
|
|
282
|
-
user?: UserResponse<ErmisChatGenerics>;
|
|
283
|
-
user_id?: string;
|
|
284
|
-
watcher_count?: number;
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
export type EventHandler<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = (
|
|
288
|
-
event: Event<ErmisChatGenerics>,
|
|
289
|
-
) => void;
|
|
290
|
-
|
|
291
|
-
export type EventTypes = 'all' | keyof typeof EVENT_MAP;
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Filter Types
|
|
295
|
-
*/
|
|
296
|
-
|
|
297
|
-
export type AscDesc = 1 | -1;
|
|
298
|
-
|
|
299
|
-
export type ChannelFilters = {
|
|
300
|
-
project_id?: string;
|
|
301
|
-
type: ('messaging' | 'team' | 'topic')[];
|
|
302
|
-
limit?: number;
|
|
303
|
-
offset?: number;
|
|
304
|
-
roles?: string[];
|
|
305
|
-
other_roles?: string[];
|
|
306
|
-
banned?: boolean;
|
|
307
|
-
blocked?: boolean;
|
|
308
|
-
include_pinned_messages?: boolean;
|
|
309
|
-
parent_cid?: string;
|
|
310
|
-
parent_id?: string;
|
|
311
|
-
include_parent?: boolean;
|
|
312
|
-
include_hidden_messages?: boolean;
|
|
313
|
-
include_quoted_messages?: boolean;
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
export type CreateTopicData = {
|
|
317
|
-
name: string;
|
|
318
|
-
image?: string;
|
|
319
|
-
[key: string]: any;
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
export type EditTopicData = {
|
|
323
|
-
name?: string;
|
|
324
|
-
image?: string;
|
|
325
|
-
description?: string;
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
export type ChannelSort = {
|
|
329
|
-
field: string;
|
|
330
|
-
direction: -1 | 1;
|
|
331
|
-
}[];
|
|
332
|
-
|
|
333
|
-
export type Attachment<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
334
|
-
ErmisChatGenerics['attachmentType'] & {
|
|
335
|
-
// main fields for ermis.
|
|
336
|
-
id?: string;
|
|
337
|
-
thumb_url?: string;
|
|
338
|
-
content_disposition?: string;
|
|
339
|
-
content_length?: number;
|
|
340
|
-
content_type?: string;
|
|
341
|
-
updated_at?: string;
|
|
342
|
-
created_at?: string;
|
|
343
|
-
message_id?: string;
|
|
344
|
-
file_name?: string;
|
|
345
|
-
url?: string;
|
|
346
|
-
cid?: string;
|
|
347
|
-
user_id?: string;
|
|
348
|
-
asset_url?: string;
|
|
349
|
-
author_icon?: string;
|
|
350
|
-
author_link?: string;
|
|
351
|
-
author_name?: string;
|
|
352
|
-
color?: string;
|
|
353
|
-
duration?: number;
|
|
354
|
-
fallback?: string;
|
|
355
|
-
file_size?: number | string;
|
|
356
|
-
footer?: string;
|
|
357
|
-
footer_icon?: string;
|
|
358
|
-
image_url?: string;
|
|
359
|
-
mime_type?: string;
|
|
360
|
-
og_scrape_url?: string;
|
|
361
|
-
original_height?: number;
|
|
362
|
-
original_width?: number;
|
|
363
|
-
pretext?: string;
|
|
364
|
-
text?: string;
|
|
365
|
-
title?: string;
|
|
366
|
-
title_link?: string;
|
|
367
|
-
type?: string;
|
|
368
|
-
waveform_data?: Array<number>;
|
|
369
|
-
link_url?: string;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
export type ChannelData<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
373
|
-
ErmisChatGenerics['channelType'] & {
|
|
374
|
-
members?: string[];
|
|
375
|
-
name?: string;
|
|
376
|
-
is_pinned?: boolean;
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
export type ChannelMembership<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
380
|
-
banned?: boolean;
|
|
381
|
-
blocked?: boolean;
|
|
382
|
-
channel_role?: Role;
|
|
383
|
-
created_at?: string;
|
|
384
|
-
updated_at?: string;
|
|
385
|
-
user?: UserResponse<ErmisChatGenerics>;
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
export type ConnectionOpen<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
389
|
-
cid?: string;
|
|
390
|
-
created_at?: string;
|
|
391
|
-
me?: UserResponse<ErmisChatGenerics>;
|
|
392
|
-
type?: string;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
export type LiteralStringForUnion = string & {};
|
|
396
|
-
|
|
397
|
-
export type LogLevel = 'info' | 'error' | 'warn';
|
|
398
|
-
|
|
399
|
-
export type Logger = (logLevel: LogLevel, message: string, extraData?: Record<string, unknown>) => void;
|
|
400
|
-
|
|
401
|
-
export type Message<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = Partial<
|
|
402
|
-
MessageBase<ErmisChatGenerics>
|
|
403
|
-
> & {
|
|
404
|
-
id?: string;
|
|
405
|
-
mentioned_all?: boolean;
|
|
406
|
-
mentioned_users?: string[];
|
|
407
|
-
cid?: string;
|
|
408
|
-
forward_cid?: string;
|
|
409
|
-
forward_message_id?: string;
|
|
410
|
-
poll_type?: string; // single | multiple
|
|
411
|
-
poll_choices?: string[];
|
|
412
|
-
sticker_url?: string;
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
export type EditMessage = {
|
|
416
|
-
text: string;
|
|
417
|
-
mentioned_all?: boolean;
|
|
418
|
-
mentioned_users?: string[];
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
export type ForwardMessage<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
422
|
-
cid: string;
|
|
423
|
-
forward_cid: string;
|
|
424
|
-
forward_message_id: string;
|
|
425
|
-
id?: string;
|
|
426
|
-
text?: string;
|
|
427
|
-
attachments?: Attachment<ErmisChatGenerics>[];
|
|
428
|
-
sticker_url?: string;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
export type PollMessage = {
|
|
432
|
-
id?: string;
|
|
433
|
-
text: string;
|
|
434
|
-
poll_type: string; // single | multiple
|
|
435
|
-
poll_choices: string[];
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
export type MessageBase<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
439
|
-
ErmisChatGenerics['messageType'] & {
|
|
440
|
-
id: string;
|
|
441
|
-
attachments?: Attachment[];
|
|
442
|
-
html?: string;
|
|
443
|
-
mml?: string;
|
|
444
|
-
parent_id?: string;
|
|
445
|
-
pinned?: boolean;
|
|
446
|
-
pinned_at?: string | null;
|
|
447
|
-
quoted_message_id?: string;
|
|
448
|
-
text?: string;
|
|
449
|
-
user?: UserResponse | null;
|
|
450
|
-
user_id?: string;
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
export type MessageLabel = 'regular' | 'system' | 'signal' | 'poll' | 'sticker' | 'error';
|
|
454
|
-
|
|
455
|
-
export type Reaction<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> =
|
|
456
|
-
ErmisChatGenerics['reactionType'] & {
|
|
457
|
-
type: string;
|
|
458
|
-
message_id?: string;
|
|
459
|
-
score?: number;
|
|
460
|
-
user?: UserResponse | null;
|
|
461
|
-
user_id?: string;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
export type MessageSetType = 'latest' | 'current' | 'new';
|
|
465
|
-
|
|
466
|
-
export type APIErrorResponse = {
|
|
467
|
-
code: number;
|
|
468
|
-
duration: string;
|
|
469
|
-
message: string;
|
|
470
|
-
more_info: string;
|
|
471
|
-
StatusCode: number;
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
export class ErrorFromResponse<T> extends Error {
|
|
475
|
-
code?: number;
|
|
476
|
-
response?: AxiosResponse<T>;
|
|
477
|
-
status?: number;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
export type UsersResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
481
|
-
data: Array<UserResponse<ErmisChatGenerics>>;
|
|
482
|
-
count: number;
|
|
483
|
-
total: number;
|
|
484
|
-
page: number;
|
|
485
|
-
page_count: number;
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
export type AttachmentResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
489
|
-
attachments: Attachment<ErmisChatGenerics>[];
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
export type SignalData = {
|
|
493
|
-
cid?: string;
|
|
494
|
-
is_video?: boolean;
|
|
495
|
-
action?: string;
|
|
496
|
-
signal?: Object;
|
|
497
|
-
metadata?: Object;
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
export enum CallAction {
|
|
501
|
-
CREATE_CALL = 'create-call',
|
|
502
|
-
ACCEPT_CALL = 'accept-call',
|
|
503
|
-
SIGNAL_CALL = 'signal-call',
|
|
504
|
-
CONNECT_CALL = 'connect-call',
|
|
505
|
-
HEALTH_CALL = 'health-call',
|
|
506
|
-
END_CALL = 'end-call',
|
|
507
|
-
REJECT_CALL = 'reject-call',
|
|
508
|
-
MISS_CALL = 'miss-call',
|
|
509
|
-
UPGRADE_CALL = 'upgrade-call',
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
export enum CallStatus {
|
|
513
|
-
PREPARING = 'preparing',
|
|
514
|
-
RINGING = 'ringing',
|
|
515
|
-
ENDED = 'ended',
|
|
516
|
-
CONNECTED = 'connected',
|
|
517
|
-
ERROR = 'error',
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
export type CallEventType = 'incoming' | 'outgoing';
|
|
521
|
-
|
|
522
|
-
export type CallEventData = {
|
|
523
|
-
type: CallEventType;
|
|
524
|
-
callType: string;
|
|
525
|
-
cid: string;
|
|
526
|
-
callerInfo: UserCallInfo | undefined;
|
|
527
|
-
receiverInfo: UserCallInfo | undefined;
|
|
528
|
-
metadata?: Object;
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
export type UserCallInfo = {
|
|
532
|
-
id: string;
|
|
533
|
-
name?: string;
|
|
534
|
-
avatar?: string;
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
export type Metadata = {
|
|
538
|
-
address?: string;
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
export type INodeCall = {
|
|
542
|
-
connect: (address: string) => Promise<void>;
|
|
543
|
-
acceptConnection: () => Promise<void>;
|
|
544
|
-
sendControlFrame: (packet: Uint8Array) => Promise<void>;
|
|
545
|
-
sendAudioFrame: (packet: Uint8Array) => Promise<void>; // audio
|
|
546
|
-
sendFrame: (packet: Uint8Array) => Promise<void>; // video delta
|
|
547
|
-
beginWithGop: (packet: Uint8Array) => Promise<void>; // video key
|
|
548
|
-
asyncRecv: () => Promise<Uint8Array>;
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
export type VideoConfig = {
|
|
552
|
-
codec: string;
|
|
553
|
-
codedWidth: number;
|
|
554
|
-
codedHeight: number;
|
|
555
|
-
frameRate?: number;
|
|
556
|
-
orientation?: number;
|
|
557
|
-
rotation?: number;
|
|
558
|
-
description?: any;
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
export type AudioConfig = {
|
|
562
|
-
codec: string;
|
|
563
|
-
sampleRate: number;
|
|
564
|
-
numberOfChannels: number;
|
|
565
|
-
description?: string;
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
export type TransceiverState = {
|
|
569
|
-
audio_enable: boolean;
|
|
570
|
-
video_enable: boolean;
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
export interface IMediaReceiverEvents {
|
|
574
|
-
onConnected?: () => void;
|
|
575
|
-
onTransceiverState?: (state: any) => void;
|
|
576
|
-
onRequestConfig?: () => void;
|
|
577
|
-
onRequestKeyFrame?: () => void;
|
|
578
|
-
onEndCall?: () => void;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
export enum FRAME_TYPE {
|
|
582
|
-
VIDEO_CONFIG = 0,
|
|
583
|
-
AUDIO_CONFIG = 1,
|
|
584
|
-
VIDEO_KEY = 2,
|
|
585
|
-
VIDEO_DELTA = 3,
|
|
586
|
-
AUDIO = 4,
|
|
587
|
-
ORIENTATION = 5,
|
|
588
|
-
CONNECTED = 6,
|
|
589
|
-
TRANSCEIVER_STATE = 7,
|
|
590
|
-
REQUEST_CONFIG = 8,
|
|
591
|
-
REQUEST_KEY_FRAME = 9,
|
|
592
|
-
END_CALL = 10,
|
|
593
|
-
HEALTH_CALL = 11,
|
|
594
|
-
}
|