@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.
Files changed (54) hide show
  1. package/README.md +330 -0
  2. package/dist/encryption/index.browser.cjs +13045 -0
  3. package/dist/encryption/index.browser.cjs.map +1 -0
  4. package/dist/encryption/index.browser.mjs +12959 -0
  5. package/dist/encryption/index.browser.mjs.map +1 -0
  6. package/dist/encryption/index.cjs +13045 -0
  7. package/dist/encryption/index.cjs.map +1 -0
  8. package/dist/encryption/index.d.mts +3 -0
  9. package/dist/encryption/index.d.ts +3 -0
  10. package/dist/encryption/index.mjs +12959 -0
  11. package/dist/encryption/index.mjs.map +1 -0
  12. package/dist/index-CcvHIY5q.d.mts +4988 -0
  13. package/dist/index-CcvHIY5q.d.ts +4988 -0
  14. package/dist/index.browser.cjs +20192 -5766
  15. package/dist/index.browser.cjs.map +1 -1
  16. package/dist/index.browser.full-bundle.min.js +20 -16
  17. package/dist/index.browser.full-bundle.min.js.map +1 -1
  18. package/dist/index.browser.mjs +20106 -5731
  19. package/dist/index.browser.mjs.map +1 -1
  20. package/dist/index.cjs +20191 -5765
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.mts +15 -1337
  23. package/dist/index.d.ts +15 -1337
  24. package/dist/index.mjs +20106 -5731
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/wasm_worker.worker.mjs +8 -4
  27. package/dist/wasm_worker.worker.mjs.map +1 -1
  28. package/package.json +21 -6
  29. package/public/e2ee-media-stream-worker.js +627 -0
  30. package/public/openmls_wasm_bg.wasm +0 -0
  31. package/src/attachment_utils.ts +0 -148
  32. package/src/auth.ts +0 -352
  33. package/src/channel.ts +0 -1879
  34. package/src/channel_state.ts +0 -612
  35. package/src/client.ts +0 -1759
  36. package/src/client_state.ts +0 -55
  37. package/src/connection.ts +0 -587
  38. package/src/ermis_call_node.ts +0 -1046
  39. package/src/errors.ts +0 -60
  40. package/src/events.ts +0 -46
  41. package/src/hevc_decoder_config.ts +0 -305
  42. package/src/index.ts +0 -17
  43. package/src/media_stream_receiver.ts +0 -593
  44. package/src/media_stream_sender.ts +0 -465
  45. package/src/shims/empty.ts +0 -1
  46. package/src/signal_message.ts +0 -171
  47. package/src/system_message.ts +0 -259
  48. package/src/token_manager.ts +0 -48
  49. package/src/types.ts +0 -594
  50. package/src/utils.ts +0 -553
  51. package/src/wasm/ermis_call_node_wasm.d.ts +0 -156
  52. package/src/wasm/ermis_call_node_wasm.js +0 -1568
  53. package/src/wasm_worker.ts +0 -219
  54. package/src/wasm_worker_proxy.ts +0 -244
package/dist/index.d.mts CHANGED
@@ -1,1339 +1,7 @@
1
- import { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
2
- import WebSocket from 'isomorphic-ws';
3
-
4
- /**
5
- * StableWSConnection - A WS connection that reconnects upon failure.
6
- * - the browser will sometimes report that you're online or offline
7
- * - the WS connection can break and fail (there is a 30s health check)
8
- * - sometimes your WS connection will seem to work while the user is in fact offline
9
- * - to speed up online/offline detection you can use the window.addEventListener('offline');
10
- *
11
- * There are 4 ways in which a connection can become unhealthy:
12
- * - websocket.onerror is called
13
- * - websocket.onclose is called
14
- * - the health check fails and no event is received for ~40 seconds
15
- * - the browser indicates the connection is now offline
16
- *
17
- * There are 2 assumptions we make about the server:
18
- * - state can be recovered by querying the channel again
19
- * - if the servers fails to publish a message to the client, the WS connection is destroyed
20
- */
21
- declare class StableWSConnection<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
22
- client: ErmisChat<ErmisChatGenerics>;
23
- connectionOpen?: ConnectAPIResponse<ErmisChatGenerics>;
24
- consecutiveFailures: number;
25
- pingInterval: number;
26
- healthCheckTimeoutRef?: NodeJS.Timeout;
27
- isConnecting: boolean;
28
- isDisconnected: boolean;
29
- isHealthy: boolean;
30
- isResolved?: boolean;
31
- lastEvent: Date | null;
32
- connectionCheckTimeout: number;
33
- connectionCheckTimeoutRef?: NodeJS.Timeout;
34
- rejectPromise?: (reason?: Error & {
35
- code?: string | number;
36
- isWSFailure?: boolean;
37
- StatusCode?: string | number;
38
- }) => void;
39
- requestID: string | undefined;
40
- resolvePromise?: (value: ConnectionOpen<ErmisChatGenerics>) => void;
41
- totalFailures: number;
42
- ws?: WebSocket;
43
- wsID: number;
44
- constructor({ client }: {
45
- client: ErmisChat<ErmisChatGenerics>;
46
- });
47
- _log(msg: string, extra?: UR, level?: LogLevel): void;
48
- setClient(client: ErmisChat<ErmisChatGenerics>): void;
49
- connect(timeout?: number): Promise<void | ConnectionOpen<ErmisChatGenerics>>;
50
- /**
51
- * _waitForHealthy polls the promise connection to see if its resolved until it times out
52
- * the default 15s timeout allows between 2~3 tries
53
- * @param timeout duration(ms)
54
- */
55
- _waitForHealthy(timeout?: number): Promise<void | ConnectionOpen<ErmisChatGenerics>>;
56
- /**
57
- * Builds and returns the url for websocket.
58
- * @private
59
- * @returns url string
60
- */
61
- _buildUrl: () => string;
62
- /**
63
- * disconnect - Disconnect the connection and doesn't recover...
64
- *
65
- */
66
- disconnect(timeout?: number): Promise<void>;
67
- _connect(): Promise<ConnectionOpen<ErmisChatGenerics> | undefined>;
68
- /**
69
- * _reconnect - Retry the connection to WS endpoint
70
- *
71
- * @param {{ interval?: number; refreshToken?: boolean }} options Following options are available
72
- *
73
- * - `interval` {int} number of ms that function should wait before reconnecting
74
- * - `refreshToken` {boolean} reload/refresh user token be refreshed before attempting reconnection.
75
- */
76
- _reconnect(options?: {
77
- interval?: number;
78
- refreshToken?: boolean;
79
- }): Promise<void>;
80
- /**
81
- * onlineStatusChanged - this function is called when the browser connects or disconnects from the internet.
82
- *
83
- * @param {Event} event Event with type online or offline
84
- *
85
- */
86
- onlineStatusChanged: (event: Event) => void;
87
- onopen: (wsID: number) => void;
88
- onmessage: (wsID: number, event: WebSocket.MessageEvent) => void;
89
- onclose: (wsID: number, event: WebSocket.CloseEvent) => void;
90
- onerror: (wsID: number, event: WebSocket.ErrorEvent) => void;
91
- /**
92
- * _setHealth - Sets the connection to healthy or unhealthy.
93
- * Broadcasts an event in case the connection status changed.
94
- *
95
- * @param {boolean} healthy boolean indicating if the connection is healthy or not
96
- *
97
- */
98
- _setHealth: (healthy: boolean) => void;
99
- /**
100
- * _errorFromWSEvent - Creates an error object for the WS event
101
- *
102
- */
103
- _errorFromWSEvent: (event: WebSocket.CloseEvent | WebSocket.Data | WebSocket.ErrorEvent, isWSFailure?: boolean) => Error & {
104
- code?: string | number;
105
- isWSFailure?: boolean;
106
- StatusCode?: string | number;
107
- };
108
- /**
109
- * _destroyCurrentWSConnection - Removes the current WS connection
110
- *
111
- */
112
- _destroyCurrentWSConnection(): void;
113
- /**
114
- * _setupPromise - sets up the this.connectOpen promise
115
- */
116
- _setupConnectionPromise: () => void;
117
- /**
118
- * Schedules a next health check ping for websocket.
119
- */
120
- scheduleNextPing: () => void;
121
- /**
122
- * scheduleConnectionCheck - schedules a check for time difference between last received event and now.
123
- * If the difference is more than 35 seconds, it means our health check logic has failed and websocket needs
124
- * to be reconnected.
125
- */
126
- scheduleConnectionCheck: () => void;
127
- }
128
-
129
- declare const EVENT_MAP: {
130
- 'channel.created': boolean;
131
- 'channel.deleted': boolean;
132
- 'channel.truncate': boolean;
133
- 'channel.updated': boolean;
134
- 'channel.pinned': boolean;
135
- 'channel.unpinned': boolean;
136
- 'health.check': boolean;
137
- 'member.added': boolean;
138
- 'member.removed': boolean;
139
- 'member.updated': boolean;
140
- 'member.joined': boolean;
141
- 'member.promoted': boolean;
142
- 'member.demoted': boolean;
143
- 'member.banned': boolean;
144
- 'member.unbanned': boolean;
145
- 'member.blocked': boolean;
146
- 'member.unblocked': boolean;
147
- 'message.deleted': boolean;
148
- 'message.deleted_for_me': boolean;
149
- 'message.new': boolean;
150
- 'message.read': boolean;
151
- 'message.updated': boolean;
152
- 'message.pinned': boolean;
153
- 'message.unpinned': boolean;
154
- 'notification.channel_deleted': boolean;
155
- 'notification.invite_accepted': boolean;
156
- 'notification.invite_rejected': boolean;
157
- 'notification.invite_messaging_skipped': boolean;
158
- 'pollchoice.new': boolean;
159
- 'reaction.deleted': boolean;
160
- 'reaction.new': boolean;
161
- 'typing.start': boolean;
162
- 'typing.stop': boolean;
163
- 'user.watching.start': boolean;
164
- 'user.watching.stop': boolean;
165
- 'connection.changed': boolean;
166
- 'connection.recovered': boolean;
167
- 'capabilities.changed': boolean;
168
- 'channel.topic.disabled': boolean;
169
- 'channel.topic.enabled': boolean;
170
- 'channel.topic.created': boolean;
171
- 'channel.topic.closed': boolean;
172
- 'channel.topic.reopen': boolean;
173
- 'channel.topic.updated': boolean;
174
- };
175
-
176
- type Role = 'owner' | 'moder' | 'member' | 'pending' | 'skipped' | string;
177
- type UR = Record<string, unknown>;
178
- type DefaultGenerics = {
179
- attachmentType: UR;
180
- channelType: UR;
181
- commandType: LiteralStringForUnion;
182
- eventType: UR;
183
- messageType: UR;
184
- pollOptionType: UR;
185
- pollType: UR;
186
- reactionType: UR;
187
- userType: UR;
188
- };
189
- type ExtendableGenerics = {
190
- attachmentType: UR;
191
- channelType: UR;
192
- commandType: string;
193
- eventType: UR;
194
- messageType: UR;
195
- pollOptionType: UR;
196
- pollType: UR;
197
- reactionType: UR;
198
- userType: UR;
199
- };
200
- /**
201
- * Response Types
202
- */
203
- type APIResponse = {
204
- duration?: string;
205
- };
206
- type ChannelResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['channelType'] & {
207
- cid: string;
208
- id: string;
209
- type: string;
210
- created_at?: string;
211
- created_by?: UserResponse<ErmisChatGenerics> | null;
212
- deleted_at?: string;
213
- last_message_at?: string;
214
- member_count?: number;
215
- members: ChannelMemberResponse<ErmisChatGenerics>[];
216
- name?: string;
217
- own_capabilities?: string[];
218
- updated_at?: string;
219
- image?: string;
220
- description?: string;
221
- member_message_cooldown?: number;
222
- member_capabilities?: string[];
223
- is_pinned?: boolean;
224
- topics_enabled?: boolean;
225
- parent_cid?: string;
226
- is_closed_topic?: boolean;
227
- };
228
- type QueryChannelsAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
229
- channels: Omit<ChannelAPIResponse<ErmisChatGenerics>, keyof APIResponse>[];
230
- };
231
- type QueryChannelAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & ChannelAPIResponse<ErmisChatGenerics>;
232
- type ChannelAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
233
- channel: ChannelResponse<ErmisChatGenerics>;
234
- members: ChannelMemberResponse<ErmisChatGenerics>[];
235
- messages: MessageResponse<ErmisChatGenerics>[];
236
- pinned_messages: MessageResponse<ErmisChatGenerics>[];
237
- membership?: ChannelMembership<ErmisChatGenerics> | null;
238
- read?: ReadResponse<ErmisChatGenerics>[];
239
- topics?: QueryChannelAPIResponse<ErmisChatGenerics>[];
240
- watcher_count?: number;
241
- watchers?: UserResponse<ErmisChatGenerics>[];
242
- is_pinned?: boolean;
243
- };
244
- type ChannelMemberResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
245
- banned?: boolean;
246
- blocked?: boolean;
247
- channel_role?: Role;
248
- created_at?: string;
249
- updated_at?: string;
250
- user?: UserResponse<ErmisChatGenerics>;
251
- user_id?: string;
252
- };
253
- type ConnectAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = Promise<void | ConnectionOpen<ErmisChatGenerics>>;
254
- type FormatMessageResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = Omit<MessageResponse<{
255
- attachmentType: ErmisChatGenerics['attachmentType'];
256
- channelType: ErmisChatGenerics['channelType'];
257
- commandType: ErmisChatGenerics['commandType'];
258
- eventType: ErmisChatGenerics['eventType'];
259
- messageType: {};
260
- pollOptionType: ErmisChatGenerics['pollOptionType'];
261
- pollType: ErmisChatGenerics['pollType'];
262
- reactionType: ErmisChatGenerics['reactionType'];
263
- userType: ErmisChatGenerics['userType'];
264
- }>, 'created_at' | 'pinned_at' | 'updated_at' | 'status'> & ErmisChatGenerics['messageType'] & {
265
- created_at: Date;
266
- pinned_at: Date | null;
267
- status: string;
268
- updated_at: Date;
269
- };
270
- type MessageDisplayType = 'normal' | 'deleted';
271
- type MessageResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = MessageResponseBase<ErmisChatGenerics> & {
272
- quoted_message?: MessageResponseBase<ErmisChatGenerics>;
273
- };
274
- type MessageResponseBase<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = MessageBase<ErmisChatGenerics> & {
275
- type: MessageLabel;
276
- display_type?: MessageDisplayType;
277
- channel?: ChannelResponse<ErmisChatGenerics>;
278
- cid?: string;
279
- created_at?: string;
280
- deleted_at?: string;
281
- latest_reactions?: ReactionResponse<ErmisChatGenerics>[];
282
- mentioned_users?: string[];
283
- own_reactions?: ReactionResponse<ErmisChatGenerics>[] | null;
284
- pinned_at?: string | null;
285
- pinned_by?: UserResponse<ErmisChatGenerics> | null;
286
- reaction_counts?: {
287
- [key: string]: number;
288
- } | null;
289
- reaction_scores?: {
290
- [key: string]: number;
291
- } | null;
292
- reply_count?: number;
293
- status?: string;
294
- updated_at?: string;
295
- };
296
- type ReactionAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
297
- message: MessageResponse<ErmisChatGenerics>;
298
- reaction: ReactionResponse<ErmisChatGenerics>;
299
- };
300
- type ReactionResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = Reaction<ErmisChatGenerics> & {
301
- created_at: string;
302
- message_id: string;
303
- updated_at: string;
304
- };
305
- type ReadResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
306
- last_read: string;
307
- user: UserResponse<ErmisChatGenerics>;
308
- last_read_message_id?: string;
309
- unread_messages?: number;
310
- last_send?: string;
311
- };
312
- type SendFileAPIResponse = APIResponse & {
313
- file: string;
314
- thumb_url?: string;
315
- };
316
- type SendMessageAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
317
- message: MessageResponse<ErmisChatGenerics>;
318
- };
319
- type UpdateChannelAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
320
- channel: ChannelResponse<ErmisChatGenerics>;
321
- members: ChannelMemberResponse<ErmisChatGenerics>[];
322
- message?: MessageResponse<ErmisChatGenerics>;
323
- };
324
- type UserResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['userType'] & {
325
- id: string;
326
- name?: string;
327
- avatar?: string;
328
- about_me?: string;
329
- project_id?: string;
330
- email?: string;
331
- phone?: string;
332
- };
333
- type Contact = {
334
- project_id: string;
335
- user_id: string;
336
- other_id: string;
337
- relation_status: string;
338
- created_at: string;
339
- updated_at: string;
340
- };
341
- type ContactResponse = APIResponse & {
342
- project_id_user_ids: {
343
- [key: string]: Contact[];
344
- };
345
- };
346
- type ContactResult<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
347
- contact_users: UserResponse<ErmisChatGenerics>[];
348
- block_users: UserResponse<ErmisChatGenerics>[];
349
- };
350
- type ChannelQueryOptions = {
351
- messages?: {
352
- limit?: number;
353
- id_lt?: string;
354
- id_gt?: string;
355
- id_around?: string;
356
- include_hidden_messages?: boolean;
357
- };
358
- };
359
- type ChannelStateOptions = {
360
- offlineMode?: boolean;
361
- skipInitialization?: string[];
362
- };
363
- type ErmisChatOptions = AxiosRequestConfig & {
364
- /**
365
- * Used to disable warnings that are triggered by using connectUser or connectAnonymousUser server-side.
366
- */
367
- allowServerSideConnect?: boolean;
368
- axiosRequestConfig?: AxiosRequestConfig;
369
- /**
370
- * Base url for User BE API (uss/v1). Defaults to baseURL + '/uss/v1' if not provided.
371
- */
372
- userBaseURL?: string;
373
- browser?: boolean;
374
- enableInsights?: boolean;
375
- /** experimental feature, please contact support if you want this feature enabled for you */
376
- logger?: Logger;
377
- /**
378
- * When network is recovered, we re-query the active channels on client. But in single query, you can recover
379
- * only 30 channels. So its not guaranteed that all the channels in activeChannels object have updated state.
380
- * Thus in UI sdks, state recovery is managed by components themselves, they don't rely on js client for this.
381
- *
382
- * `recoverStateOnReconnect` parameter can be used in such cases, to disable state recovery within js client.
383
- * When false, user/consumer of this client will need to make sure all the channels present on UI by
384
- * manually calling queryChannels endpoint.
385
- */
386
- recoverStateOnReconnect?: boolean;
387
- warmUp?: boolean;
388
- wsConnection?: StableWSConnection;
389
- recoveryConfig?: {
390
- filter?: ChannelFilters;
391
- sort?: ChannelSort;
392
- options?: {
393
- message_limit?: number;
394
- };
395
- };
396
- };
397
- /**
398
- * Event Types
399
- */
400
- type Event$1<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['eventType'] & {
401
- type: EventTypes;
402
- channel?: ChannelResponse<ErmisChatGenerics>;
403
- channel_id?: string;
404
- channel_type?: string;
405
- cid?: string;
406
- created_at?: string;
407
- hard_delete?: boolean;
408
- last_read_at?: string;
409
- last_read_message_id?: string;
410
- me?: UserResponse<ErmisChatGenerics>;
411
- member?: ChannelMemberResponse<ErmisChatGenerics>;
412
- message?: MessageResponse<ErmisChatGenerics>;
413
- online?: boolean;
414
- parent_id?: string;
415
- parent_cid?: string;
416
- reaction?: ReactionResponse<ErmisChatGenerics>;
417
- received_at?: string | Date;
418
- unread_messages?: number;
419
- user?: UserResponse<ErmisChatGenerics>;
420
- user_id?: string;
421
- watcher_count?: number;
422
- };
423
- type EventHandler<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = (event: Event$1<ErmisChatGenerics>) => void;
424
- type EventTypes = 'all' | keyof typeof EVENT_MAP;
425
- /**
426
- * Filter Types
427
- */
428
- type AscDesc = 1 | -1;
429
- type ChannelFilters = {
430
- project_id?: string;
431
- type: ('messaging' | 'team' | 'topic')[];
432
- limit?: number;
433
- offset?: number;
434
- roles?: string[];
435
- other_roles?: string[];
436
- banned?: boolean;
437
- blocked?: boolean;
438
- include_pinned_messages?: boolean;
439
- parent_cid?: string;
440
- parent_id?: string;
441
- include_parent?: boolean;
442
- include_hidden_messages?: boolean;
443
- include_quoted_messages?: boolean;
444
- };
445
- type CreateTopicData = {
446
- name: string;
447
- image?: string;
448
- [key: string]: any;
449
- };
450
- type EditTopicData = {
451
- name?: string;
452
- image?: string;
453
- description?: string;
454
- };
455
- type ChannelSort = {
456
- field: string;
457
- direction: -1 | 1;
458
- }[];
459
- type Attachment<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['attachmentType'] & {
460
- id?: string;
461
- thumb_url?: string;
462
- content_disposition?: string;
463
- content_length?: number;
464
- content_type?: string;
465
- updated_at?: string;
466
- created_at?: string;
467
- message_id?: string;
468
- file_name?: string;
469
- url?: string;
470
- cid?: string;
471
- user_id?: string;
472
- asset_url?: string;
473
- author_icon?: string;
474
- author_link?: string;
475
- author_name?: string;
476
- color?: string;
477
- duration?: number;
478
- fallback?: string;
479
- file_size?: number | string;
480
- footer?: string;
481
- footer_icon?: string;
482
- image_url?: string;
483
- mime_type?: string;
484
- og_scrape_url?: string;
485
- original_height?: number;
486
- original_width?: number;
487
- pretext?: string;
488
- text?: string;
489
- title?: string;
490
- title_link?: string;
491
- type?: string;
492
- waveform_data?: Array<number>;
493
- link_url?: string;
494
- };
495
- type ChannelData<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['channelType'] & {
496
- members?: string[];
497
- name?: string;
498
- is_pinned?: boolean;
499
- };
500
- type ChannelMembership<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
501
- banned?: boolean;
502
- blocked?: boolean;
503
- channel_role?: Role;
504
- created_at?: string;
505
- updated_at?: string;
506
- user?: UserResponse<ErmisChatGenerics>;
507
- };
508
- type ConnectionOpen<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
509
- cid?: string;
510
- created_at?: string;
511
- me?: UserResponse<ErmisChatGenerics>;
512
- type?: string;
513
- };
514
- type LiteralStringForUnion = string & {};
515
- type LogLevel = 'info' | 'error' | 'warn';
516
- type Logger = (logLevel: LogLevel, message: string, extraData?: Record<string, unknown>) => void;
517
- type Message<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = Partial<MessageBase<ErmisChatGenerics>> & {
518
- id?: string;
519
- mentioned_all?: boolean;
520
- mentioned_users?: string[];
521
- cid?: string;
522
- forward_cid?: string;
523
- forward_message_id?: string;
524
- poll_type?: string;
525
- poll_choices?: string[];
526
- sticker_url?: string;
527
- };
528
- type EditMessage = {
529
- text: string;
530
- mentioned_all?: boolean;
531
- mentioned_users?: string[];
532
- };
533
- type ForwardMessage<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
534
- cid: string;
535
- forward_cid: string;
536
- forward_message_id: string;
537
- id?: string;
538
- text?: string;
539
- attachments?: Attachment<ErmisChatGenerics>[];
540
- sticker_url?: string;
541
- };
542
- type PollMessage = {
543
- id?: string;
544
- text: string;
545
- poll_type: string;
546
- poll_choices: string[];
547
- };
548
- type MessageBase<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['messageType'] & {
549
- id: string;
550
- attachments?: Attachment[];
551
- html?: string;
552
- mml?: string;
553
- parent_id?: string;
554
- pinned?: boolean;
555
- pinned_at?: string | null;
556
- quoted_message_id?: string;
557
- text?: string;
558
- user?: UserResponse | null;
559
- user_id?: string;
560
- };
561
- type MessageLabel = 'regular' | 'system' | 'signal' | 'poll' | 'sticker' | 'error';
562
- type Reaction<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = ErmisChatGenerics['reactionType'] & {
563
- type: string;
564
- message_id?: string;
565
- score?: number;
566
- user?: UserResponse | null;
567
- user_id?: string;
568
- };
569
- type MessageSetType = 'latest' | 'current' | 'new';
570
- type APIErrorResponse = {
571
- code: number;
572
- duration: string;
573
- message: string;
574
- more_info: string;
575
- StatusCode: number;
576
- };
577
- declare class ErrorFromResponse<T> extends Error {
578
- code?: number;
579
- response?: AxiosResponse<T>;
580
- status?: number;
581
- }
582
- type UsersResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
583
- data: Array<UserResponse<ErmisChatGenerics>>;
584
- count: number;
585
- total: number;
586
- page: number;
587
- page_count: number;
588
- };
589
- type AttachmentResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
590
- attachments: Attachment<ErmisChatGenerics>[];
591
- };
592
- type SignalData = {
593
- cid?: string;
594
- is_video?: boolean;
595
- action?: string;
596
- signal?: Object;
597
- metadata?: Object;
598
- };
599
- declare enum CallAction {
600
- CREATE_CALL = "create-call",
601
- ACCEPT_CALL = "accept-call",
602
- SIGNAL_CALL = "signal-call",
603
- CONNECT_CALL = "connect-call",
604
- HEALTH_CALL = "health-call",
605
- END_CALL = "end-call",
606
- REJECT_CALL = "reject-call",
607
- MISS_CALL = "miss-call",
608
- UPGRADE_CALL = "upgrade-call"
609
- }
610
- declare enum CallStatus {
611
- PREPARING = "preparing",
612
- RINGING = "ringing",
613
- ENDED = "ended",
614
- CONNECTED = "connected",
615
- ERROR = "error"
616
- }
617
- type CallEventType = 'incoming' | 'outgoing';
618
- type CallEventData = {
619
- type: CallEventType;
620
- callType: string;
621
- cid: string;
622
- callerInfo: UserCallInfo | undefined;
623
- receiverInfo: UserCallInfo | undefined;
624
- metadata?: Object;
625
- };
626
- type UserCallInfo = {
627
- id: string;
628
- name?: string;
629
- avatar?: string;
630
- };
631
- type Metadata = {
632
- address?: string;
633
- };
634
- type INodeCall = {
635
- connect: (address: string) => Promise<void>;
636
- acceptConnection: () => Promise<void>;
637
- sendControlFrame: (packet: Uint8Array) => Promise<void>;
638
- sendAudioFrame: (packet: Uint8Array) => Promise<void>;
639
- sendFrame: (packet: Uint8Array) => Promise<void>;
640
- beginWithGop: (packet: Uint8Array) => Promise<void>;
641
- asyncRecv: () => Promise<Uint8Array>;
642
- };
643
- type VideoConfig = {
644
- codec: string;
645
- codedWidth: number;
646
- codedHeight: number;
647
- frameRate?: number;
648
- orientation?: number;
649
- rotation?: number;
650
- description?: any;
651
- };
652
- type AudioConfig = {
653
- codec: string;
654
- sampleRate: number;
655
- numberOfChannels: number;
656
- description?: string;
657
- };
658
- type TransceiverState = {
659
- audio_enable: boolean;
660
- video_enable: boolean;
661
- };
662
- interface IMediaReceiverEvents {
663
- onConnected?: () => void;
664
- onTransceiverState?: (state: any) => void;
665
- onRequestConfig?: () => void;
666
- onRequestKeyFrame?: () => void;
667
- onEndCall?: () => void;
668
- }
669
- declare enum FRAME_TYPE {
670
- VIDEO_CONFIG = 0,
671
- AUDIO_CONFIG = 1,
672
- VIDEO_KEY = 2,
673
- VIDEO_DELTA = 3,
674
- AUDIO = 4,
675
- ORIENTATION = 5,
676
- CONNECTED = 6,
677
- TRANSCEIVER_STATE = 7,
678
- REQUEST_CONFIG = 8,
679
- REQUEST_KEY_FRAME = 9,
680
- END_CALL = 10,
681
- HEALTH_CALL = 11
682
- }
683
-
684
- type ChannelReadStatus<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = Record<string, {
685
- last_read: Date;
686
- unread_messages: number;
687
- user: UserResponse<ErmisChatGenerics>;
688
- last_read_message_id?: string;
689
- last_send?: string;
690
- }>;
691
- /**
692
- * ChannelState - A container class for the channel state.
693
- * This class synchronously binds to a `Channel` and holds the single source of truth for
694
- * messages, read status, watchers, and typing indicators locally on the client.
695
- */
696
- declare class ChannelState<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
697
- _channel: Channel<ErmisChatGenerics>;
698
- /** The current count of users actively watching (having an open WebSocket) this channel. */
699
- watcher_count: number;
700
- /** A dictionary of active typing events gracefully keyed by the user's ID. */
701
- typing: Record<string, Event$1<ErmisChatGenerics>>;
702
- /** A dictionary of read states mapped per user's ID detailing the last viewed message. */
703
- read: ChannelReadStatus<ErmisChatGenerics>;
704
- /** The locally cached array of pinned messages across the channel. */
705
- pinnedMessages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>;
706
- /** A directory of users actively watching the channel, keyed by User ID. */
707
- watchers: Record<string, UserResponse<ErmisChatGenerics>>;
708
- /** A comprehensive directory mapping user IDs to their member status in the channel. */
709
- members: Record<string, ChannelMemberResponse<ErmisChatGenerics>>;
710
- /** The count of messages not yet read by the currently authenticated user. */
711
- unreadCount: number;
712
- /** Information detailing the authenticated user's own membership relation to this channel. */
713
- membership: ChannelMembership<ErmisChatGenerics>;
714
- /** Timestamp indicating when the very last message was created in this chat. */
715
- last_message_at: Date | null;
716
- /** Designates if the local channel state is entirely synchronized with the backend history. */
717
- isUpToDate: boolean;
718
- messageSets: {
719
- isCurrent: boolean;
720
- isLatest: boolean;
721
- messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>;
722
- }[];
723
- topics?: Channel<ErmisChatGenerics>[];
724
- constructor(channel: Channel<ErmisChatGenerics>);
725
- get messages(): Array<ReturnType<ChannelState<ErmisChatGenerics>["formatMessage"]>>;
726
- set messages(messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>);
727
- get latestMessages(): Array<ReturnType<ChannelState<ErmisChatGenerics>["formatMessage"]>>;
728
- set latestMessages(messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>);
729
- /**
730
- * Pushes a new message directly into the sorted array of the local tracking state.
731
- * Useful to achieve optimistic UI updates locally.
732
- *
733
- * @param newMessage - The message context payload to insert.
734
- * @param timestampChanged - Specifies if the underlying `created_at` timestamp mutated.
735
- * @param addIfDoesNotExist - Append it strictly if its ID doesn't already exist.
736
- * @param messageSetToAddToIfDoesNotExist - Specifies which message set scope to manipulate.
737
- */
738
- addMessageSorted(newMessage: MessageResponse<ErmisChatGenerics>, timestampChanged?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): {
739
- messageSet: {
740
- isCurrent: boolean;
741
- isLatest: boolean;
742
- messages: Array<ReturnType<ChannelState<ErmisChatGenerics>["formatMessage"]>>;
743
- };
744
- };
745
- formatMessage(message: MessageResponse<ErmisChatGenerics>): FormatMessageResponse<ErmisChatGenerics>;
746
- addMessagesSorted(newMessages: MessageResponse<ErmisChatGenerics>[], timestampChanged?: boolean, initializing?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): {
747
- messageSet: {
748
- isCurrent: boolean;
749
- isLatest: boolean;
750
- messages: Array<ReturnType<ChannelState<ErmisChatGenerics>["formatMessage"]>>;
751
- };
752
- };
753
- addPinnedMessages(pinnedMessages: MessageResponse<ErmisChatGenerics>[]): void;
754
- addPinnedMessage(pinnedMessage: MessageResponse<ErmisChatGenerics>): void;
755
- removePinnedMessage(message: MessageResponse<ErmisChatGenerics>): void;
756
- addReaction(reaction: ReactionResponse<ErmisChatGenerics>, message?: MessageResponse<ErmisChatGenerics>, enforce_unique?: boolean): MessageResponse<ErmisChatGenerics> | undefined;
757
- _addOwnReactionToMessage(ownReactions: ReactionResponse<ErmisChatGenerics>[] | null | undefined, reaction: ReactionResponse<ErmisChatGenerics>, enforce_unique?: boolean): ReactionResponse<ErmisChatGenerics>[];
758
- _removeOwnReactionFromMessage(ownReactions: ReactionResponse<ErmisChatGenerics>[] | null | undefined, reaction: ReactionResponse<ErmisChatGenerics>): ReactionResponse<ErmisChatGenerics>[] | null | undefined;
759
- removeReaction(reaction: ReactionResponse<ErmisChatGenerics>, message?: MessageResponse<ErmisChatGenerics>): MessageResponse<ErmisChatGenerics> | undefined;
760
- removeQuotedMessageReferences(message: MessageResponse<ErmisChatGenerics>): void;
761
- _updateMessage(message: {
762
- id?: string;
763
- parent_id?: string;
764
- pinned?: boolean;
765
- }, updateFunc: (msg: ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>) => ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>): void;
766
- setIsUpToDate: (isUpToDate: boolean) => void;
767
- /**
768
- * Update the status of a message by ID (used for optimistic UI).
769
- */
770
- updateMessageStatus(messageId: string, status: string): void;
771
- _addToMessageList(messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>, message: ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>, timestampChanged?: boolean, sortBy?: 'pinned_at' | 'created_at', addIfDoesNotExist?: boolean): FormatMessageResponse<ErmisChatGenerics>[];
772
- removeMessage(messageToRemove: {
773
- id: string;
774
- messageSetIndex?: number;
775
- parent_id?: string;
776
- }): boolean;
777
- removeMessageFromArray: (msgArray: Array<ReturnType<ChannelState<ErmisChatGenerics>["formatMessage"]>>, msg: {
778
- id: string;
779
- parent_id?: string;
780
- }) => {
781
- removed: boolean;
782
- result: FormatMessageResponse<ErmisChatGenerics>[];
783
- };
784
- /**
785
- * Refreshes internal user references cascading across all presently active messages.
786
- * Invoked instantly whenever an underlying user's profile metadata updates (e.g. name or avatar changes).
787
- *
788
- * @param user - The newly formatted and populated User details object.
789
- */
790
- updateUserMessages: (user: UserResponse<ErmisChatGenerics>) => void;
791
- deleteUserMessages: (user: UserResponse<ErmisChatGenerics>, hardDelete?: boolean) => void;
792
- filterErrorMessages(): void;
793
- clean(): void;
794
- clearMessages(): void;
795
- initMessages(): void;
796
- loadMessageIntoState(messageId: string | 'latest', parentMessageId?: string, limit?: number): Promise<void>;
797
- findMessage(messageId: string, parentMessageId?: string): FormatMessageResponse<ErmisChatGenerics> | undefined;
798
- private switchToMessageSet;
799
- private areMessageSetsOverlap;
800
- private findMessageSetIndex;
801
- private findTargetMessageSet;
802
- }
803
-
804
- /**
805
- * Normalize a file name for upload:
806
- * - Remove Vietnamese diacritics
807
- * - Replace đ/Đ with d/D
808
- * - Replace spaces with underscores
809
- * - Preserve extension
810
- */
811
- declare function normalizeFileName(name: string): string;
812
- /**
813
- * Check if a MIME type or file extension is HEIC/HEIF.
814
- */
815
- declare function isHeicFile(file: File): boolean;
816
- /**
817
- * Categorize a file by MIME type.
818
- * HEIC/HEIF files are treated as 'file' (not 'image') since browsers can't render them.
819
- */
820
- declare function getAttachmentCategory(mimeType: string, fileName?: string): 'image' | 'video' | 'audio' | 'file';
821
- /**
822
- * Check if a file is a video type that supports thumbnail extraction.
823
- */
824
- declare function isVideoFile(file: File): boolean;
825
- /**
826
- * Metadata for voice recording attachments.
827
- */
828
- type VoiceRecordingMeta = {
829
- waveform_data: number[];
830
- duration: number;
831
- };
832
- /**
833
- * Build a normalized attachment payload from an uploaded file.
834
- *
835
- * @param file - Original file object
836
- * @param uploadedUrl - URL returned by the upload API
837
- * @param thumbUrl - Optional thumbnail URL (for video)
838
- * @param voiceMeta - Optional voice recording metadata
839
- */
840
- declare function buildAttachmentPayload(file: File, uploadedUrl: string, thumbUrl?: string, voiceMeta?: VoiceRecordingMeta): Attachment;
841
-
842
- /**
843
- * Represents a Channel in the Ermis Network.
844
- * Channels handle chat sessions, livestream messages, teams, or video calls.
845
- * This class abstracts and exposes all API operations you can perform on a specific channel instance.
846
- */
847
- declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
848
- _client: ErmisChat<ErmisChatGenerics>;
849
- type: string;
850
- id: string | undefined;
851
- data: ChannelData<ErmisChatGenerics> | ChannelResponse<ErmisChatGenerics> | undefined;
852
- _data: ChannelData<ErmisChatGenerics> | ChannelResponse<ErmisChatGenerics>;
853
- cid: string;
854
- listeners: {
855
- [key: string]: (string | EventHandler<ErmisChatGenerics>)[];
856
- };
857
- state: ChannelState<ErmisChatGenerics>;
858
- initialized: boolean;
859
- offlineMode: boolean;
860
- lastKeyStroke?: Date;
861
- lastTypingEvent: Date | null;
862
- isTyping: boolean;
863
- disconnected: boolean;
864
- /**
865
- * Initializes a new Channel class instance.
866
- * Normally you should not call this directly; use `client.channel(type, id)` instead.
867
- *
868
- * @param client - The shared ErmisChat client instance initializing this channel.
869
- * @param type - The type of channel (`messaging`, `team`, `livestream`, etc.).
870
- * @param id - The unique ID of the channel.
871
- * @param data - Initial arbitrary metadata stored within this channel.
872
- */
873
- constructor(client: ErmisChat<ErmisChatGenerics>, type: string, id: string | undefined, data: ChannelData<ErmisChatGenerics>);
874
- getClient(): ErmisChat<ErmisChatGenerics>;
875
- /**
876
- * Sends a message to this channel.
877
- * By default, it pushes the message eagerly (optimistically) to the local UI state before the server replies.
878
- *
879
- * @param message - The constructed text/attachment object payload representing the message.
880
- * @returns A Promise resolving to the exact API response encompassing message details.
881
- */
882
- sendMessage(message: Message<ErmisChatGenerics>): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
883
- retryMessage(messageId: string): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
884
- createPoll(pollMessage: PollMessage): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
885
- votePoll(messageID: string, pollChoice: string): Promise<APIResponse>;
886
- forwardMessage(message: ForwardMessage<ErmisChatGenerics>, channel: {
887
- type: string;
888
- channelID: string;
889
- }): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
890
- pinMessage(messageID: string): Promise<unknown>;
891
- unpinMessage(messageID: string): Promise<unknown>;
892
- pin(): Promise<APIResponse>;
893
- unpin(): Promise<APIResponse>;
894
- editMessage(oldMessageID: string, message: EditMessage): Promise<unknown>;
895
- sendFile(uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse<ErmisChatGenerics>): Promise<SendFileAPIResponse>;
896
- /**
897
- * Pre-process files (normalize names), upload them in parallel,
898
- * generate video thumbnails, and build attachment payloads.
899
- *
900
- * @param files - Array of File objects to upload
901
- * @param options - Optional voice recording metadata
902
- * @returns `attachments` ready for sendMessage, and `failedFiles` for error display
903
- */
904
- uploadAndPrepareAttachments(files: File[], options?: {
905
- /** Map from file index → voice recording metadata */
906
- voiceMetadata?: Map<number, VoiceRecordingMeta>;
907
- }): Promise<{
908
- attachments: Attachment[];
909
- failedFiles: Array<{
910
- file: File;
911
- error: Error;
912
- }>;
913
- }>;
914
- sendEvent(event: Event$1<ErmisChatGenerics>): Promise<unknown>;
915
- sendReaction(messageID: string, reactionType: string): Promise<ReactionAPIResponse<ErmisChatGenerics>>;
916
- deleteReaction(messageID: string, reactionType: string): Promise<ReactionAPIResponse<ErmisChatGenerics>>;
917
- update(channelData?: Partial<ChannelData<ErmisChatGenerics>> | Partial<ChannelResponse<ErmisChatGenerics>>, updateMessage?: Message<ErmisChatGenerics>): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
918
- delete(): Promise<unknown>;
919
- truncate(): Promise<unknown>;
920
- blockUser(): Promise<unknown>;
921
- unblockUser(): Promise<unknown>;
922
- acceptInvite(action: string): Promise<APIResponse>;
923
- rejectInvite(): Promise<APIResponse>;
924
- skipInvite(): Promise<APIResponse>;
925
- /**
926
- * Directly invites or adds registered users into this channel.
927
- *
928
- * @param members - Array of user IDs explicitly selected to be added.
929
- */
930
- addMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
931
- addModerators(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
932
- banMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
933
- unbanMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
934
- updateCapabilities(capabilities: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
935
- /**
936
- * Set slow mode (message cooldown) for the channel.
937
- * Only applicable to team channels. Prevents members from sending
938
- * messages faster than the specified cooldown interval.
939
- *
940
- * @param cooldown - Cooldown duration in milliseconds.
941
- * Allowed values: 0 (off), 10000 (10s), 30000 (30s),
942
- * 60000 (1min), 300000 (5min), 900000 (15min), 3600000 (1h).
943
- */
944
- setSlowMode(cooldown: 0 | 10000 | 30000 | 60000 | 300000 | 900000 | 3600000): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
945
- queryAttachmentMessages(): Promise<AttachmentResponse<ErmisChatGenerics>>;
946
- searchMessage(search_term: string, offset: number): Promise<any>;
947
- /**
948
- * Expels specified currently participating users out of the channel.
949
- *
950
- * @param members - Array of user IDs to strictly remove from this chat.
951
- */
952
- removeMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
953
- demoteModerators(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
954
- _update(payload: Object): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
955
- _processTopics(topicsFromApi: any, users: any[]): void;
956
- muteNotification(duration: number | null): Promise<AttachmentResponse<ErmisChatGenerics>>;
957
- unMuteNotification(): Promise<AttachmentResponse<ErmisChatGenerics>>;
958
- keystroke(parent_id?: string, options?: {
959
- user_id: string;
960
- }): Promise<void>;
961
- stopTyping(parent_id?: string, options?: {
962
- user_id: string;
963
- }): Promise<void>;
964
- _isTypingIndicatorsEnabled(): boolean;
965
- lastMessage(): FormatMessageResponse<ErmisChatGenerics>;
966
- /**
967
- * Emits a mark-read event, updating the backend that the authenticated user has viewed up to the latest known message.
968
- * @returns Successful acknowledgement from the server.
969
- */
970
- markRead(): Promise<unknown>;
971
- clean(): void;
972
- /**
973
- * Subscribes to realtime events (WebSocket) for this channel, grabs the latest available metadata,
974
- * loads the most recent messages, and initializes the local state.
975
- *
976
- * @param options - Pagination limits like `{ watch: true, presence: true, state: true }`.
977
- * @returns The synchronized comprehensive channel state.
978
- */
979
- watch(options?: ChannelQueryOptions): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
980
- lastRead(): Date | null | undefined;
981
- _countMessageAsUnread(message: FormatMessageResponse<ErmisChatGenerics> | MessageResponse<ErmisChatGenerics>): boolean;
982
- countUnread(lastRead?: Date | null): number;
983
- getUnreadMemberCount(): {
984
- last_read: Date;
985
- unread_messages: number;
986
- user: UserResponse<ErmisChatGenerics>;
987
- last_read_message_id?: string;
988
- last_send?: string;
989
- }[];
990
- getCapabilitiesMember(): unknown;
991
- create: () => Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
992
- createTopic(data: CreateTopicData): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
993
- query(options: ChannelQueryOptions, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
994
- createDirectChannel(messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
995
- queryMessagesLessThanId(message_id: string, limit?: number): Promise<MessageResponse<ErmisChatGenerics>[]>;
996
- queryMessagesGreaterThanId(message_id: string, limit?: number): Promise<MessageResponse<ErmisChatGenerics>[]>;
997
- queryMessagesAroundId(message_id: string, limit?: number): Promise<MessageResponse<ErmisChatGenerics>[]>;
998
- deleteMessage(messageId: string): Promise<APIResponse & {
999
- message: MessageResponse<ErmisChatGenerics>;
1000
- }>;
1001
- deleteMessageForMe(messageId: string): Promise<APIResponse & {
1002
- message: MessageResponse<ErmisChatGenerics>;
1003
- }>;
1004
- getThumbBlobVideo(file: File): Promise<Blob | null>;
1005
- enableTopics(): Promise<unknown>;
1006
- disableTopics(): Promise<unknown>;
1007
- closeTopic(topicCID: string): Promise<unknown>;
1008
- reopenTopic(topicCID: string): Promise<unknown>;
1009
- editTopic(topicCID: string, data: EditTopicData): Promise<any>;
1010
- on(eventType: EventTypes, callback: EventHandler<ErmisChatGenerics>): {
1011
- unsubscribe: () => void;
1012
- };
1013
- on(callback: EventHandler<ErmisChatGenerics>): {
1014
- unsubscribe: () => void;
1015
- };
1016
- off(eventType: EventTypes, callback: EventHandler<ErmisChatGenerics>): void;
1017
- off(callback: EventHandler<ErmisChatGenerics>): void;
1018
- _handleChannelEvent(event: Event$1<ErmisChatGenerics>): Promise<void>;
1019
- _callChannelListeners: (event: Event$1<ErmisChatGenerics>) => void;
1020
- _channelURL: () => string;
1021
- _checkInitialized(): void;
1022
- _initializeState(state: ChannelAPIResponse<ErmisChatGenerics>, messageSetToAddToIfDoesNotExist?: MessageSetType, updateUserIds?: (id: string) => void): {
1023
- messageSet: {
1024
- isCurrent: boolean;
1025
- isLatest: boolean;
1026
- messages: FormatMessageResponse<ErmisChatGenerics>[];
1027
- };
1028
- };
1029
- _extendEventWithOwnReactions(event: Event$1<ErmisChatGenerics>): void;
1030
- _disconnect(): void;
1031
- }
1032
-
1033
- /**
1034
- * ClientState - A container class for the client state.
1035
- */
1036
- declare class ClientState<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
1037
- users: {
1038
- [key: string]: UserResponse<ErmisChatGenerics>;
1039
- };
1040
- userChannelReferences: {
1041
- [key: string]: {
1042
- [key: string]: boolean;
1043
- };
1044
- };
1045
- constructor();
1046
- updateUsers(users: UserResponse<ErmisChatGenerics>[]): void;
1047
- updateUser(user?: UserResponse<ErmisChatGenerics>): void;
1048
- updateUserReference(user: UserResponse<ErmisChatGenerics>, channelID: string): void;
1049
- deleteAllChannelReference(channelID: string): void;
1050
- }
1051
-
1052
- /**
1053
- * TokenManager
1054
- *
1055
- * Manages token storage and retrieval for the chat client.
1056
- */
1057
- declare class TokenManager<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
1058
- loadTokenPromise: Promise<string> | null;
1059
- token?: string;
1060
- user?: UserResponse<ErmisChatGenerics>;
1061
- constructor();
1062
- /**
1063
- * Set the static string token.
1064
- */
1065
- setTokenOrProvider: (tokenOrProvider: string | null, user: UserResponse<ErmisChatGenerics>) => Promise<void>;
1066
- /**
1067
- * Resets the token manager.
1068
- */
1069
- reset: () => void;
1070
- /**
1071
- * Resolves when token is ready.
1072
- */
1073
- tokenReady: () => Promise<string> | null;
1074
- /** Returns the current token */
1075
- getToken: () => string | undefined;
1076
- }
1077
-
1078
- /**
1079
- * The ErmisChat Client represents the connection securely established between your application
1080
- * and the Ermis core servers. It acts as the primary access point for real-time messaging,
1081
- * presence updates, call management, and channel querying.
1082
- *
1083
- * It is highly recommended to instantiate this class as a Singleton via `ErmisChat.getInstance()`.
1084
- */
1085
- declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
1086
- private static _instance?;
1087
- /** A map of active channels currently tracked by the client, keyed by Channel ID. */
1088
- activeChannels: {
1089
- [key: string]: Channel<ErmisChatGenerics>;
1090
- };
1091
- /** The internal configured Axios instance used for REST API requests. */
1092
- axiosInstance: AxiosInstance;
1093
- /** The primary base URL for REST API communication. */
1094
- baseURL?: string;
1095
- /** The specific base URL for standard user-focused REST calls. */
1096
- userBaseURL?: string;
1097
- /** True when the SDK is executed inside a browser environment. */
1098
- browser: boolean;
1099
- cleaningIntervalRef?: NodeJS.Timeout;
1100
- clientID?: string;
1101
- apiKey: string;
1102
- projectId: string;
1103
- /** Internal mapped registry of event listeners. */
1104
- listeners: Record<string, Array<(event: Event$1<ErmisChatGenerics>) => void>>;
1105
- logger: Logger;
1106
- /** Whether the client should automatically fetch missing messages upon unexpected disconnects. */
1107
- recoverStateOnReconnect?: boolean;
1108
- /** True when the SDK is executed in a NodeJS environment constraint. */
1109
- node: boolean;
1110
- /** Custom options passed during client initialization. */
1111
- options: ErmisChatOptions;
1112
- setUserPromise: ConnectAPIResponse<ErmisChatGenerics> | null;
1113
- /** Centralized global state orchestrating user and client metadata. */
1114
- state: ClientState<ErmisChatGenerics>;
1115
- tokenManager: TokenManager<ErmisChatGenerics>;
1116
- /** The globally authenticated current user object. */
1117
- user?: UserResponse<ErmisChatGenerics>;
1118
- userAgent?: string;
1119
- /** The unique ID of the current authenticated user. */
1120
- userID?: string;
1121
- /** The configured WebSocket endpoint base URL for realtime subscriptions. */
1122
- wsBaseURL?: string;
1123
- /** The active WebSocket connection controller. */
1124
- wsConnection: StableWSConnection<ErmisChatGenerics> | null;
1125
- wsPromise: ConnectAPIResponse<ErmisChatGenerics> | null;
1126
- /** Tracks consecutive REST API failures for exponential backoff purposes. */
1127
- consecutiveFailures: number;
1128
- defaultWSTimeout: number;
1129
- private eventSource;
1130
- /**
1131
- * Initializes a new Ermis Chat Client instance.
1132
- *
1133
- * @param apiKey - Your public Ermis Network API Key.
1134
- * @param projectId - Your specific Project UUID pointing to the app config.
1135
- * @param baseURL - The API base endpoint assigned to your project.
1136
- * @param options - Additional connection rules and configuration options.
1137
- */
1138
- constructor(apiKey: string, projectId: string, baseURL: string, options?: ErmisChatOptions);
1139
- /**
1140
- * Retrieves the globally registered Singleton instance of the ErmisChat client.
1141
- * If the instance lacks existence, it initializes a new one.
1142
- *
1143
- * @param key - Your public Ermis Network API Key.
1144
- * @param projectId - Your specific Project UUID.
1145
- * @param baseURL - The API base endpoint.
1146
- * @param options - Connection options.
1147
- * @returns The shared ErmisChat client instance.
1148
- */
1149
- static getInstance<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics>(key: string, projectId: string, baseURL: string, options?: ErmisChatOptions): ErmisChat<ErmisChatGenerics>;
1150
- refreshNewToken(refresh_token: string): Promise<APIResponse>;
1151
- getAuthType(): string;
1152
- setBaseURL(baseURL: string): void;
1153
- getExternalAuthToken(user: UserResponse<ErmisChatGenerics>, token: string | null): Promise<any>;
1154
- /**
1155
- * Connects a user to the Ermis network and establishes the WebSocket connection.
1156
- * This is the primary method to authenticate your client application.
1157
- *
1158
- * @param user - The User object containing `id`, `name`, and optional `avatar`.
1159
- * @param userTokenOrProvider - The JWT token or an async token provider function.
1160
- * @param extenal_auth - Set to `true` to use your custom backend external authentication flow.
1161
- * @returns A promise resolving to the API connection response once authenticated.
1162
- */
1163
- connectUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, external_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1164
- setUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, external_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1165
- _setToken: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null) => Promise<void>;
1166
- _setUser(user: UserResponse<ErmisChatGenerics>): void;
1167
- closeConnection: (timeout?: number) => Promise<void>;
1168
- openConnection: () => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1169
- _setupConnection: () => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1170
- /**
1171
- * Gracefully disconnects the current user, terminates the WebSocket connection,
1172
- * cleans up listeners, and resets the client's internal references.
1173
- *
1174
- * @param timeout - Optional timeout in milliseconds before forcing the disconnect.
1175
- */
1176
- disconnectUser: (timeout?: number) => Promise<void>;
1177
- disconnect: (timeout?: number) => Promise<void>;
1178
- /**
1179
- * Attaches an event listener to the client connection.
1180
- * Listeners can be scoped to specific event types (e.g. `message.new`) or listen to `all` events.
1181
- *
1182
- * @param callback - The handler invoked when the event is emitted.
1183
- * @returns An object containing an `unsubscribe` method to detach the listener.
1184
- */
1185
- on(callback: EventHandler<ErmisChatGenerics>): {
1186
- unsubscribe: () => void;
1187
- };
1188
- /**
1189
- * Attaches an event listener filtered by a specific event type.
1190
- *
1191
- * @param eventType - The specific event name to listen for (e.g., `'notification.message_new'`).
1192
- * @param callback - The handler invoked when the event is emitted.
1193
- * @returns An object containing an `unsubscribe` method to detach the listener.
1194
- */
1195
- on(eventType: string, callback: EventHandler<ErmisChatGenerics>): {
1196
- unsubscribe: () => void;
1197
- };
1198
- /**
1199
- * Detaches a previously registered general event listener.
1200
- * @param callback - The original handler reference to remove.
1201
- */
1202
- off(callback: EventHandler<ErmisChatGenerics>): void;
1203
- /**
1204
- * Detaches a previously registered event listener scoped to a specific event type.
1205
- * @param eventType - The specific event name.
1206
- * @param callback - The original handler reference to remove.
1207
- */
1208
- off(eventType: string, callback: EventHandler<ErmisChatGenerics>): void;
1209
- _logApiRequest(type: string, url: string, data: unknown, config: AxiosRequestConfig & {
1210
- config?: AxiosRequestConfig & {
1211
- maxBodyLength?: number;
1212
- };
1213
- }): void;
1214
- _logApiResponse<T>(type: string, url: string, response: AxiosResponse<T>): void;
1215
- _logApiError(type: string, url: string, error: unknown, options: unknown): void;
1216
- doAxiosRequest: <T>(type: string, url: string, data?: unknown, options?: AxiosRequestConfig & {
1217
- config?: AxiosRequestConfig & {
1218
- maxBodyLength?: number;
1219
- };
1220
- }) => Promise<T>;
1221
- get<T>(url: string, params?: AxiosRequestConfig['params']): Promise<T>;
1222
- put<T>(url: string, data?: unknown): Promise<T>;
1223
- post<T>(url: string, data?: unknown, params?: AxiosRequestConfig['params']): Promise<T>;
1224
- patch<T>(url: string, data?: unknown): Promise<T>;
1225
- delete<T>(url: string, params?: AxiosRequestConfig['params']): Promise<T>;
1226
- sendFile(url: string, uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse<ErmisChatGenerics>): Promise<SendFileAPIResponse>;
1227
- /**
1228
- * Downloads a media file as a Blob via the SDK's configured axiosInstance.
1229
- * This avoids CORS issues that arise when using `fetch()` directly from the browser,
1230
- * because axios is routed through the SDK's authenticated transport layer.
1231
- *
1232
- * @param url - The full URL of the media file to download.
1233
- * @returns A Blob of the file content.
1234
- */
1235
- downloadMedia(url: string): Promise<Blob>;
1236
- errorFromResponse(response: AxiosResponse<APIErrorResponse>): ErrorFromResponse<APIErrorResponse>;
1237
- handleResponse<T>(response: AxiosResponse<T>): T;
1238
- dispatchEvent: (event: Event$1<ErmisChatGenerics>) => void;
1239
- _afterDispatchEvent(event: Event$1<ErmisChatGenerics>): void;
1240
- private _handleChannelCreatedEvent;
1241
- handleEvent: (messageEvent: WebSocket.MessageEvent) => void;
1242
- _updateMemberWatcherReferences: (user: UserResponse<ErmisChatGenerics>) => void;
1243
- _updateUserReferences: (user: UserResponse<ErmisChatGenerics>) => void;
1244
- _updateUserMessageReferences: (user: UserResponse<ErmisChatGenerics>) => void;
1245
- _deleteUserMessageReference: (user: UserResponse<ErmisChatGenerics>, hardDelete?: boolean) => void;
1246
- _handleClientEvent(event: Event$1<ErmisChatGenerics>): (() => void)[];
1247
- _callClientListeners: (event: Event$1<ErmisChatGenerics>) => void;
1248
- recoverState: () => Promise<void>;
1249
- connect(): Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1250
- connectToSSE(onCallBack?: (data: any) => void): Promise<void>;
1251
- disconnectFromSSE(): Promise<void>;
1252
- queryUsers(page_size?: string, page?: number): Promise<UsersResponse>;
1253
- queryUser(user_id: string): Promise<UserResponse<ErmisChatGenerics>>;
1254
- getBatchUsers(users: string[], page?: number, page_size?: number): Promise<UserResponse<DefaultGenerics>[]>;
1255
- searchUsers(page: number, page_size: number, name?: string): Promise<UsersResponse>;
1256
- queryContacts(): Promise<ContactResult>;
1257
- _updateProjectID(project_id: string): void;
1258
- /**
1259
- * Uploads a new avatar image for the current user.
1260
- * The user's avatar URL is automatically updated in both the client and the local state.
1261
- *
1262
- * @param file - The image file to upload.
1263
- * @returns The response containing the new avatar URL.
1264
- */
1265
- uploadAvatar(file: File): Promise<{
1266
- avatar: string;
1267
- }>;
1268
- updateProfile(updates: Partial<UserResponse<ErmisChatGenerics>>): Promise<UserResponse<ErmisChatGenerics>>;
1269
- /**
1270
- * Queries the API for a list of channels based on provided search filters and sort conditions.
1271
- * Also hydrates these channels into the local SDK state memory.
1272
- *
1273
- * @param filterConditions - Specific criteria to filter channels (e.g. `{ type: 'messaging', members: { $in: ['user1'] } }`).
1274
- * @param sort - The sorting hierarchy applied to the channel results.
1275
- * @param options - Pagination and message limit parameters.
1276
- * @param stateOptions - Defines whether to skip state initialization or offline usage.
1277
- * @returns An array of hydrated and locally manageable `Channel` objects.
1278
- */
1279
- queryChannels(filterConditions: ChannelFilters, sort?: ChannelSort, options?: {
1280
- message_limit?: number;
1281
- }, stateOptions?: ChannelStateOptions): Promise<Channel<ErmisChatGenerics>[]>;
1282
- hydrateChannels(channelsFromApi?: ChannelAPIResponse<ErmisChatGenerics>[], stateOptions?: ChannelStateOptions): {
1283
- channels: Channel<ErmisChatGenerics>[];
1284
- userIds: string[];
1285
- };
1286
- searchPublicChannel(search_term: string, offset?: number, limit?: number): Promise<APIResponse>;
1287
- pinChannel(channelType: string, channelId: string): Promise<APIResponse>;
1288
- unpinChannel(channelType: string, channelId: string): Promise<APIResponse>;
1289
- /**
1290
- * Creates or instantiates an interactive `Channel` object locally based on type and custom data.
1291
- * This does NOT immediately ping the API unless `channel.watch()` or `channel.create()` is subsequently called.
1292
- *
1293
- * @param type - The strict channel type descriptor (e.g., `'messaging'`, `'team'`, `'livestream'`).
1294
- * @param custom - Initial metadata or specific members to include in the channel.
1295
- * @returns A newly instantiated `Channel` object.
1296
- */
1297
- channel(type: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
1298
- /**
1299
- * Creates or instantiates an interactive `Channel` object locally using a specific ID.
1300
- *
1301
- * @param type - The strict channel type descriptor.
1302
- * @param id - The unique identifer (UUID / slug) for the channel.
1303
- * @param custom - Initial metadata or specific members to include in the channel.
1304
- * @returns A newly instantiated `Channel` object.
1305
- */
1306
- channel(type: string, id: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
1307
- getChannelById: (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1308
- getChannel: (channelType: string, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1309
- /**
1310
- * Creates a quick channel and immediately registers it on the server.
1311
- * Quick channels are public group channels that anyone can join without an invitation.
1312
- * The creator is added as the first member automatically.
1313
- *
1314
- * @param name - An optional display name for the channel.
1315
- * @returns A promise that resolves to the created `Channel` object.
1316
- */
1317
- createQuickChannel(name?: string): Promise<Channel<ErmisChatGenerics>>;
1318
- /**
1319
- * Joins a quick channel by its ID.
1320
- * Automatically checks whether the caller is already a member.
1321
- * If not, it joins the channel and synchronizes state.
1322
- *
1323
- * @param channelId - The ID of the quick channel to join.
1324
- * @returns A promise that resolves to the joined `Channel` object.
1325
- */
1326
- joinQuickChannel(channelId: string): Promise<Channel<ErmisChatGenerics>>;
1327
- _normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
1328
- getUserAgent(): string;
1329
- setUserAgent(userAgent: string): void;
1330
- _enrichAxiosOptions(options?: AxiosRequestConfig & {
1331
- config?: AxiosRequestConfig;
1332
- }): AxiosRequestConfig;
1333
- _getToken(): string | null | undefined;
1334
- _startCleaning(): void;
1335
- _buildWSPayload: (client_request_id?: string) => string;
1336
- }
1
+ import { I as INodeCall, a as IMediaReceiverEvents, E as ExtendableGenerics, D as DefaultGenerics, b as ErmisChat, M as Metadata, U as UserCallInfo, C as CallEventData, c as ErmisChatOptions, L as Logger, A as APIErrorResponse, d as ErrorFromResponse, e as UserResponse, F as FormatMessageResponse, f as ForwardMessage, g as MessageResponse } from './index-CcvHIY5q.mjs';
2
+ export { h as APIResponse, i as ArchiveAckRecord, j as ArchiveAckStatus, k as ArchiveBlobRecord, l as ArchiveKeyWrapRecord, m as ArchiveMaterializationStatus, n as ArchiveScope, o as AscDesc, p as Attachment, q as AttachmentResponse, r as AudioConfig, B as BatchAddMembersToTopicsRequest, s as BatchAddMembersTopicBundle, t as BatchExternalJoinTopicBundle, u as BatchExternalJoinTopicsRequest, v as BatchTopicResponse, w as BatchTopicResult, x as BootstrapKnownE2eeChannelsOptions, y as BootstrapKnownE2eeChannelsResult, z as BrowserEncryptionStorage, G as CallAction, H as CallEventType, J as CallStatus, K as Channel, N as ChannelAPIResponse, O as ChannelData, P as ChannelFilters, Q as ChannelMemberResponse, R as ChannelMembership, S as ChannelQueryOptions, T as ChannelRepairState, V as ChannelRepairStatus, W as ChannelResponse, X as ChannelSort, Y as ChannelState, Z as ChannelStateOptions, _ as ChannelSyncResult, $ as CiphertextCursor, a0 as CiphertextQueryResponse, a1 as ClientState, a2 as CommitEvictionRequest, a3 as CommitEvictionResponse, a4 as CompleteE2eeAttachmentRequest, a5 as CompleteE2eeAttachmentResponse, a6 as ConnectAPIResponse, a7 as ConnectionOpen, a8 as Contact, a9 as ContactResponse, aa as ContactResult, ab as CreateTopicData, ac as DecryptResult, ad as DeleteE2eeAttachmentResponse, ae as DeviceKeyPackage, af as DownloadE2eeAttachmentGrantResponse, ag as E2EEAddMembersOptions, ah as E2EERemoveMembersOptions, ai as E2EE_ATTACHMENT_FRAME_SIZE, aj as E2EE_ATTACHMENT_MULTIPART_UPLOAD_DEFAULT_CONCURRENCY, ak as E2EE_ATTACHMENT_MULTIPART_UPLOAD_MAX_CONCURRENCY, al as E2EE_ATTACHMENT_MULTIPART_UPLOAD_URL_EXPIRY_SAFETY_MARGIN_MS, am as E2EE_ATTACHMENT_PREVIEW_JPEG_QUALITY, an as E2EE_ATTACHMENT_PREVIEW_MAX_SIDE, ao as E2EE_ATTACHMENT_VIDEO_PREVIEW_TIMEOUT_MS, ap as E2EE_MEDIA_STREAM_BASE_SESSION_CACHE_LIMIT, aq as E2EE_MEDIA_STREAM_FULL_REPLAY_CACHE_LIMIT, ar as E2EE_MEDIA_STREAM_GLOBAL_CACHE_LIMIT, as as E2EE_MEDIA_STREAM_PREFETCH_FRAMES, at as E2EE_MEDIA_STREAM_PREFETCH_THRESHOLD_FRAMES, au as E2EE_MEDIA_STREAM_SEQUENTIAL_PREFETCH_HITS, av as E2eeAttachmentAssetKind, aw as E2eeAttachmentCryptoProvider, ax as E2eeAttachmentHash, ay as E2eeAttachmentManifest, az as E2eeAttachmentManifestAsset, aA as E2eeAttachmentPreviewResult, aB as E2eeAttachmentTransferPhase, aC as E2eeAttachmentTransferProgress, aD as E2eeAttachmentUploadMode, aE as E2eeBootstrapProgress, aF as E2eeBootstrapStatus, aG as E2eeClient, aH as E2eeMediaFrameBatchPlan, aI as E2eeMediaFrameBatchPlanInput, aJ as E2eeMediaMp4ProbeResult, aK as E2eeMediaPlaybackStrategy, aL as E2eeMediaStreamHandle, aM as E2eeMediaStreamSessionOptions, aN as E2eeMediaStreamWorkerOptions, aO as E2eeMessageAadParams, aP as E2eePayload, aQ as E2eeRecoveryPolicy, aR as E2eeStoredMessage, aS as E2eeSyncEvent, aT as E2eeSyncState, aU as E2eeSyncStatus, aV as EVENT_MAP, aW as EditMessage, aX as EditTopicData, aY as EnableE2eeRequest, aZ as EncryptAssetOptions, a_ as EncryptMultipartAssetOptions, a$ as EncryptedAsset, b0 as EncryptedAssetMetadata, b1 as EncryptedChannelRepairMode, b2 as EncryptedChannelRepairResult, aG as EncryptionApiClient, b3 as EncryptionManager, b4 as EncryptionManagerOptions, b5 as EncryptionOperationResponse, b6 as EncryptionStorageAdapter, b7 as EncryptionSyncCheckpoint, b8 as EnsureE2eeChannelResult, b9 as EpochArchiveCheckpoint, ba as EpochIndexEntry, bb as Event, bc as EventCursor, bd as EventHandler, be as EventTypes, bf as ExternalJoinRequest, bg as FRAME_TYPE, bh as GetGroupInfoResponse, bi as GetKeyPackagesByCidResponse, bj as GetKeyPackagesResponse, bk as HistoricalCiphertext, z as IndexedDBEncryptionStorage, bl as InitE2eeAttachmentAssetResponse, bm as InitE2eeAttachmentMultipartPartResponse, bn as InitE2eeAttachmentMultipartResponse, bo as InitE2eeAttachmentRequest, bp as InitE2eeAttachmentResponse, bq as KeyPackageCountResponse, br as KeyRotationRequest, bs as ListArchiveAvailabilityResponse, bt as LiteralStringForUnion, bu as LogLevel, bv as LoggerOption, bw as MemberKeyPackages, bx as MemberSnapshotRecord, by as Message, bz as MessageBase, bA as MessageDisplayType, bB as MessageLabel, bC as MessageResponseBase, bD as MessageSetType, bE as MultipartEncryptedAssetPart, bF as MultipartEncryptedAssetUploadResult, bG as OpenMlsWasmModule, bH as PendingArchiveUpload, bI as PendingDeferredArchive, bJ as PendingE2eeSendRecord, bK as PendingE2eeSendStatus, bL as PendingE2eeSnapshot, bM as PollMessage, bN as ProtocolMessage, bO as ProtocolType, bP as PutPresignedObjectResult, bQ as QueryArchiveMaterialRequest, bR as QueryChannelAPIResponse, bS as QueryChannelsAPIResponse, bT as QueryE2eeAttachmentAssetProjection, bU as QueryE2eeAttachmentProjection, bV as QueryE2eeAttachmentsCursor, bW as QueryE2eeAttachmentsRequest, bX as QueryE2eeAttachmentsResponse, bY as QueryEpochArchivesRequest, bZ as QueryEpochArchivesResponse, b_ as QuerySponsoredArchiveRecipientsResponse, b$ as Reaction, c0 as ReactionAPIResponse, c1 as ReactionResponse, c2 as ReadResponse, c3 as RecoveryPublicKeyResponse, c4 as RecoveryStatus, c5 as RecoveryVaultResponse, c6 as RemovedChannelSyncData, c7 as RemovedChannelsSyncResult, c8 as RemovedSyncCursor, c9 as RepairIssue, ca as RepairIssueReason, cb as RepairIssueStatus, cc as RepairMessageResult, cd as RepairMode, ce as RepairResult, cf as RestorePermanentGapReason, cg as RestoreProgressRecord, ch as RestoreStatus, ci as RestoreTransientFailureReason, cj as RestoredMessage, ck as Role, cl as ScopeSyncEvent, cm as ScopeSyncResponse, cn as ScopeSyncResult, co as SendE2eeMessageRequest, cp as SendFileAPIResponse, cq as SendMessageAPIResponse, cr as Sha256, cs as SignalData, ct as SponsoredArchiveRecipient, cu as StableWSConnection, cv as TokenManager, cw as TransceiverState, cx as UR, cy as UnifiedSyncResponse, cz as UpdateChannelAPIResponse, cA as UpdateE2eeMessageRequest, cB as UploadEpochArchiveReason, cC as UploadEpochArchiveRequest, cD as UploadEpochArchiveResponse, cE as UploadGroupInfoRequest, cF as UploadKeyPackagesRequest, cG as UploadKeyPackagesResponse, cH as UploadRecoveryVaultRequest, cI as UploadRecoveryVaultResponse, cJ as UploadedE2eeAttachment, cK as UsersResponse, cL as VideoConfig, cM as VoiceRecordingMeta, cN as WaterfallResult, cO as base64ToBytes, cP as buildAttachmentManifest, cQ as buildAttachmentPayload, cR as buildE2eeMessageAadV1, cS as buildManifestAsset, cT as bytesEqual, cU as bytesToBase64, cV as canonicalAttachmentIds, cW as ciphertextSha256, cX as compareUuidRaw, cY as createE2eeAttachmentStreamUrl, cZ as decryptE2eeAsset, c_ as defaultE2eeAttachmentCryptoProvider, c$ as disposeAllE2eeAttachmentStreamSessions, d0 as disposeE2eeAttachmentStreamUrl, d1 as downloadEncryptedAsset, d2 as e2eeAttachmentMultipartUploadUrlExpiresAtMs, d3 as e2eeMediaFramePlainLength, d4 as e2eeMediaSessionCacheLimit, d5 as encryptAndUploadE2eeAssetMultipart, d6 as encryptE2eeAsset, d7 as ensureE2eeMediaStreamWorker, d8 as estimateE2eeEncryptedAssetSize, d9 as generateE2eeAttachmentPreview, da as getAttachmentCategory, db as hasE2eeAadMetadata, dc as isE2eeMediaMsePlaybackAllowed, dd as isE2eeMediaMsePlaybackEnabled, de as isHeicFile, df as isVideoFile, dg as loadOpenMlsWasm, dh as newUuid, di as normalizeFileName, dj as planE2eeMediaFrameBatch, dk as probeE2eeMediaMp4ForMse, dl as putPresignedObject, dm as putPresignedObjectWithResult, dn as resolveE2eeAttachmentMultipartUploadConcurrency, dp as sha256Hex, dq as uuidToRawBytes, dr as verifyEncryptedAssetHash, ds as webE2eeAttachmentCryptoProvider } from './index-CcvHIY5q.mjs';
3
+ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
4
+ import 'isomorphic-ws';
1337
5
 
1338
6
  /**
1339
7
  * WasmWorkerProxy — Proxy class chạy trên Main Thread.
@@ -1700,6 +368,16 @@ declare class ErmisAuthProvider {
1700
368
  }>;
1701
369
  }
1702
370
 
371
+ declare class IndexedDBUserCache<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
372
+ private dbPromise;
373
+ private readonly dbName;
374
+ constructor(projectId: string, ownerUserId: string);
375
+ private openDB;
376
+ saveUsers(users: Array<UserResponse<ErmisChatGenerics>>): Promise<void>;
377
+ saveUser(user: UserResponse<ErmisChatGenerics>): Promise<void>;
378
+ loadUsers(): Promise<Array<UserResponse<ErmisChatGenerics>>>;
379
+ }
380
+
1703
381
  /**
1704
382
  * logChatPromiseExecution - utility function for logging the execution of a promise..
1705
383
  * use this when you want to run the promise and handle errors by logging a warning
@@ -1840,4 +518,4 @@ interface SignalMessageTranslations {
1840
518
  */
1841
519
  declare function parseSignalMessage(value: string, myUserId: string, translations?: SignalMessageTranslations): SignalMessageResult | null;
1842
520
 
1843
- export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, CallType, type CallTypeValue, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type CreateTopicData, type DefaultGenerics, EVENT_MAP, type EditMessage, type EditTopicData, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageDisplayType, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, type SignalMessageResult, type SignalMessageTranslations, StableWSConnection, type SystemMessageTranslations, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
521
+ export { APIErrorResponse, CallEventData, CallType, type CallTypeValue, DefaultGenerics, ErmisAuthProvider, ErmisCallNode, ErmisChat, ErmisChatOptions, ErrorFromResponse, ExtendableGenerics, FormatMessageResponse, ForwardMessage, IMediaReceiverEvents, INodeCall, IndexedDBUserCache, Logger, MessageResponse, Metadata, type SignalMessageResult, type SignalMessageTranslations, type SystemMessageTranslations, UserCallInfo, UserResponse, chatCodes, createForwardMessagePayload, formatMessage, logChatPromiseExecution, parseSignalMessage, parseSystemMessage };