iosignal 7.0.2 → 7.0.4

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.
@@ -0,0 +1,980 @@
1
+ import * as Boho from 'boho';
2
+ import Boho__default from 'boho';
3
+ export { default as Boho } from 'boho';
4
+ import * as buffer from 'buffer';
5
+ import { EventEmitter } from 'eventemitter3';
6
+ import { Transform } from 'stream';
7
+ import EventEmitter$1 from 'events';
8
+ export { default as MBP } from 'meta-buffer-pack';
9
+
10
+ type STATE = {
11
+ CONNECTING: number;
12
+ OPEN: number;
13
+ SERVER_READY: number;
14
+ AUTH_REQ: number;
15
+ AUTH_RES: number;
16
+ AUTH_FAIL: number;
17
+ AUTH_CLEAR: number;
18
+ CID_REQ: number;
19
+ CID_RES: number;
20
+ READY: number;
21
+ CLOSING: number;
22
+ CLOSED: number;
23
+ STOP: number;
24
+ REDIRECTING: number;
25
+ };
26
+ declare namespace STATE {
27
+ let CONNECTING: number;
28
+ let OPEN: number;
29
+ let SERVER_READY: number;
30
+ let AUTH_REQ: number;
31
+ let AUTH_RES: number;
32
+ let AUTH_FAIL: number;
33
+ let AUTH_CLEAR: number;
34
+ let CID_REQ: number;
35
+ let CID_RES: number;
36
+ let READY: number;
37
+ let CLOSING: number;
38
+ let CLOSED: number;
39
+ let STOP: number;
40
+ let REDIRECTING: number;
41
+ }
42
+ type ENC_MODE = {
43
+ NO: number;
44
+ YES: number;
45
+ AUTO: number;
46
+ };
47
+ declare namespace ENC_MODE {
48
+ let NO: number;
49
+ let YES: number;
50
+ let AUTO: number;
51
+ }
52
+ type SIZE_LIMIT = {
53
+ TAG_LEN1: number;
54
+ TAG_LEN2: number;
55
+ CONNECTION_CHECKER_PERIOD: number;
56
+ CLIENT_PING_PERIOD: number;
57
+ PROMISE_TIMEOUT: number;
58
+ DID: number;
59
+ CID: number;
60
+ };
61
+ declare namespace SIZE_LIMIT {
62
+ let TAG_LEN1: number;
63
+ let TAG_LEN2: number;
64
+ let CONNECTION_CHECKER_PERIOD: number;
65
+ let CLIENT_PING_PERIOD: number;
66
+ let PROMISE_TIMEOUT: number;
67
+ let DID: number;
68
+ let CID: number;
69
+ }
70
+ type PAYLOAD_TYPE = {
71
+ EMPTY: number;
72
+ TEXT: number;
73
+ BINARY: number;
74
+ OBJECT: number;
75
+ MJSON: number;
76
+ MBA: number;
77
+ };
78
+ declare namespace PAYLOAD_TYPE {
79
+ let EMPTY: number;
80
+ let TEXT: number;
81
+ let BINARY: number;
82
+ let OBJECT: number;
83
+ let MJSON: number;
84
+ let MBA: number;
85
+ }
86
+ type IOMsg = {
87
+ SERVER_READY: number;
88
+ CID_REQ: number;
89
+ CID_RES: number;
90
+ QUOTA_LEVEL: number;
91
+ AUTH_CLEAR: number;
92
+ SERVER_REDIRECT: number;
93
+ LOOP: number;
94
+ ECHO: number;
95
+ PING: number;
96
+ PONG: number;
97
+ CLOSE: number;
98
+ SIGNAL: number;
99
+ SIGNAL_REQ: number;
100
+ SIGNAL_E2E: number;
101
+ SUBSCRIBE: number;
102
+ SUBSCRIBE_REQ: number;
103
+ UNSUBSCRIBE: number;
104
+ SERVER_SIGNAL: number;
105
+ IAM: number;
106
+ IAM_RES: number;
107
+ SET: number;
108
+ RESPONSE_CODE: number;
109
+ RESPONSE_MBP: number;
110
+ CALL: number;
111
+ RESPONSE: number;
112
+ FLOW_MODE: number;
113
+ WAIT: number;
114
+ RESUME: number;
115
+ TIME_OUT: number;
116
+ OVER_SIZE: number;
117
+ OVER_FLOW: number;
118
+ };
119
+ declare namespace IOMsg {
120
+ let SERVER_READY_1: number;
121
+ export { SERVER_READY_1 as SERVER_READY };
122
+ let CID_REQ_1: number;
123
+ export { CID_REQ_1 as CID_REQ };
124
+ let CID_RES_1: number;
125
+ export { CID_RES_1 as CID_RES };
126
+ export let QUOTA_LEVEL: number;
127
+ let AUTH_CLEAR_1: number;
128
+ export { AUTH_CLEAR_1 as AUTH_CLEAR };
129
+ export let SERVER_REDIRECT: number;
130
+ export let LOOP: number;
131
+ export let ECHO: number;
132
+ export let PING: number;
133
+ export let PONG: number;
134
+ export let CLOSE: number;
135
+ export let SIGNAL: number;
136
+ export let SIGNAL_REQ: number;
137
+ export let SIGNAL_E2E: number;
138
+ export let SUBSCRIBE: number;
139
+ export let SUBSCRIBE_REQ: number;
140
+ export let UNSUBSCRIBE: number;
141
+ export let SERVER_SIGNAL: number;
142
+ export let IAM: number;
143
+ export let IAM_RES: number;
144
+ export let SET: number;
145
+ export let RESPONSE_MBP: number;
146
+ export let CALL: number;
147
+ export let FLOW_MODE: number;
148
+ export let WAIT: number;
149
+ export let RESUME: number;
150
+ export let TIME_OUT: number;
151
+ export let OVER_SIZE: number;
152
+ export let OVER_FLOW: number;
153
+ }
154
+ type STATUS = {
155
+ OK: number;
156
+ ERROR: number;
157
+ };
158
+ declare namespace STATUS {
159
+ let OK: number;
160
+ let ERROR: number;
161
+ }
162
+
163
+ /**
164
+ * Core class for handling WebSocket communication.
165
+ * @augments {EventEmitter}
166
+ */
167
+ declare class IOCore extends EventEmitter<string | symbol, any> {
168
+ /**
169
+ * @param {string} url - The WebSocket URL to connect to.
170
+ */
171
+ constructor(url: string);
172
+ /**
173
+ * Client ID received from the server.
174
+ * @type {string}
175
+ */
176
+ cid: string;
177
+ /**
178
+ * IP address received from the server.
179
+ * @type {string}
180
+ */
181
+ ip: string;
182
+ /**
183
+ * The WebSocket instance.
184
+ * @type {WebSocket | null}
185
+ */
186
+ socket: WebSocket | null;
187
+ /**
188
+ * The default server URL.
189
+ * @type {string}
190
+ */
191
+ url: string;
192
+ /**
193
+ * Current connection state (number).
194
+ * @type {number}
195
+ */
196
+ state: number;
197
+ /**
198
+ * Current connection state (string).
199
+ * @type {string}
200
+ */
201
+ stateName: string;
202
+ _stateRevision: number;
203
+ /**
204
+ * Transmitted message counter.
205
+ * @type {number}
206
+ */
207
+ txCounter: number;
208
+ /**
209
+ * Received message counter.
210
+ * @type {number}
211
+ */
212
+ rxCounter: number;
213
+ /**
214
+ * Transmitted bytes counter.
215
+ * @type {number}
216
+ */
217
+ txBytes: number;
218
+ /**
219
+ * Received bytes counter.
220
+ * @type {number}
221
+ */
222
+ rxBytes: number;
223
+ /**
224
+ * Last transmit/receive time.
225
+ * @type {number}
226
+ */
227
+ lastTxRxTime: number;
228
+ /**
229
+ * Period for connection checker.
230
+ * @type {number}
231
+ */
232
+ connectionCheckerPeriod: number;
233
+ /**
234
+ * Interval ID for connection checker.
235
+ * @type {ReturnType<typeof setInterval> | null}
236
+ */
237
+ connectionCheckerIntervalID: ReturnType<typeof setInterval> | null;
238
+ /**
239
+ * Boho instance for encryption/decryption.
240
+ * @type {Boho}
241
+ */
242
+ boho: Boho__default;
243
+ /** @type {import('buffer').Buffer} */
244
+ serverTimeNonce: buffer.Buffer;
245
+ /**
246
+ * Indicates if the connection is TLS (wss).
247
+ * @type {boolean}
248
+ */
249
+ TLS: boolean;
250
+ /**
251
+ * Encryption mode.
252
+ * @type {number}
253
+ */
254
+ encMode: number;
255
+ /**
256
+ * Indicates if authentication is used.
257
+ * @type {boolean}
258
+ */
259
+ useAuth: boolean;
260
+ /**
261
+ * Nickname.
262
+ * @type {string}
263
+ */
264
+ nick: string;
265
+ /**
266
+ * Set of subscribed channels.
267
+ * @type {Set<string>}
268
+ */
269
+ channels: Set<string>;
270
+ /**
271
+ * Map of promises for message responses.
272
+ * @type {Map<number, Array<Function>>}
273
+ */
274
+ promiseMap: Map<number, Array<Function>>;
275
+ /**
276
+ * Timeout for message promises.
277
+ * @type {number}
278
+ */
279
+ promiseTimeOut: number;
280
+ /**
281
+ * Message ID for promises.
282
+ * @type {number}
283
+ */
284
+ mid: number;
285
+ /**
286
+ * Quota level.
287
+ * @type {number}
288
+ */
289
+ level: number;
290
+ /**
291
+ * Quota table for current level.
292
+ * @type {object}
293
+ */
294
+ quota: object;
295
+ /**
296
+ * Server settings.
297
+ * @type {object}
298
+ */
299
+ serverSet: object;
300
+ /**
301
+ * Map of linked channels.
302
+ * @type {Map<string, Set<string>>}
303
+ */
304
+ linkMap: Map<string, Set<string>>;
305
+ /**
306
+ * Indicates if auto-reconnect is enabled.
307
+ * @type {boolean}
308
+ * @default true
309
+ * */
310
+ autoReconnect: boolean;
311
+ /**
312
+ * A flag to prevent duplicate close operations.
313
+ * @type {boolean}
314
+ * @private
315
+ */
316
+ private _closed;
317
+ /**
318
+ * Performs common cleanup for the connection. It rejects pending RPCs,
319
+ * resets the socket reference, and sets the state to closed.
320
+ * This method is guarded to only run once.
321
+ * If autoReconnect is false, it also clears the keep-alive timer.
322
+ */
323
+ close(): void;
324
+ /**
325
+ * Disables auto-reconnect and closes the current connection.
326
+ * The instance can be re-opened manually later. For complete cleanup, use destroy().
327
+ */
328
+ stop(): void;
329
+ /**
330
+ * Permanently destroys the instance, cleaning up all resources.
331
+ * The instance will not be usable after this.
332
+ */
333
+ destroy(): void;
334
+ /**
335
+ * The core keep-alive logic.
336
+ * The specific logic for checking the socket's state and reconnecting
337
+ * is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
338
+ */
339
+ keepAlive(): void;
340
+ /**
341
+ * Redirects the connection to a new URL.
342
+ * @param {string} url2 - The new URL to redirect to.
343
+ */
344
+ redirect(url2: string): void;
345
+ /**
346
+ * Opens the WebSocket connection.
347
+ * @param {string} [url] - Optional URL to connect to. If not provided, uses the instance's URL.
348
+ */
349
+ open(url?: string): void;
350
+ /**
351
+ * Handles the 'open' event of the WebSocket. Resets the closed flag and sets the state to open.
352
+ */
353
+ onOpen(): void;
354
+ /**
355
+ * Handles the 'close' event of the WebSocket.
356
+ */
357
+ onClose(): void;
358
+ /**
359
+ * Manually logs in with provided ID and key.
360
+ * @param {string} id - The user ID. or 'id.key'
361
+ * @param {string} key - The user key.
362
+ * @returns {this}
363
+ */
364
+ login(id: string, key: string): this;
365
+ /**
366
+ * Sets up authentication for auto-login.
367
+ * @param {string} id - The user ID. or 'id.Key'
368
+ * @param {string} key - The user key.
369
+ * @returns {this}
370
+ */
371
+ auth(id: string, key: string): this;
372
+ /**
373
+ * Handles incoming data from the WebSocket.
374
+ * @param {Buffer} buffer - The incoming data buffer.
375
+ */
376
+ onData(buffer: Buffer$1): void;
377
+ did: any;
378
+ uid: any;
379
+ /**
380
+ * Sends an IAM (I Am) message to the server.
381
+ * @param {string} [title] - Optional title for the IAM message.
382
+ */
383
+ iam(title?: string): void;
384
+ /**
385
+ * Sends a PING message to the server.
386
+ */
387
+ ping(): void;
388
+ /**
389
+ * Sends a PONG message to the server.
390
+ */
391
+ pong(): void;
392
+ /**
393
+ * Sends an ECHO message to the server.
394
+ * @param {*} [args] - Optional arguments to echo.
395
+ */
396
+ echo(args?: any): void;
397
+ /**
398
+ * Sends binary data.
399
+ * @param {...any} data - Data to send.
400
+ */
401
+ bin(...data: any[]): void;
402
+ /**
403
+ * Sends data over the WebSocket.
404
+ * @param {Buffer} data - The data buffer to send.
405
+ */
406
+ send(data: Buffer$1): void;
407
+ /**
408
+ * Determines if encryption should be used based on current mode and TLS status.
409
+ * @returns {boolean}
410
+ */
411
+ getEncryptionMode(): boolean;
412
+ /**
413
+ * Sends data with encryption based on the encryption mode.
414
+ * @param {Buffer} data - The data buffer to send.
415
+ * @param {boolean} [useEncryption] - Optional. Force encryption or not. If undefined, uses default policy.
416
+ */
417
+ send_enc_mode(data: Buffer$1, useEncryption?: boolean): void;
418
+ /**
419
+ * Sets a message promise for a given message ID.
420
+ * @param {number} mid - The message ID.
421
+ * @returns {Promise<any>}
422
+ */
423
+ setMsgPromise(mid: number): Promise<any>;
424
+ /**
425
+ * Tests and resolves/rejects a promise based on the incoming buffer.
426
+ * @param {Buffer} buffer - The incoming data buffer.
427
+ */
428
+ testPromise(buffer: Buffer$1): void;
429
+ /**
430
+ * alias of signal()
431
+ * Sends a signal with a tag and arguments.
432
+ * @param {string} tag - The signal tag.
433
+ * @param {...any} args - Arguments for the signal.
434
+ */
435
+ publish(tag: string, ...args: any[]): void;
436
+ /**
437
+ * Sends a signal with a tag and arguments.
438
+ * @param {string} tag - The signal tag.
439
+ * @param {...any} args - Arguments for the signal.
440
+ * @throws {TypeError} If tag is not a string.
441
+ */
442
+ signal(tag: string, ...args: any[]): void;
443
+ /**
444
+ * Decrypts E2E data.
445
+ * @param {Buffer} data - The encrypted data.
446
+ * @param {string} key - The decryption key.
447
+ * @returns {Buffer}
448
+ */
449
+ decrypt_e2e(data: Buffer$1, key: string): Buffer$1;
450
+ /**
451
+ * Sends an E2E (End-to-End) encrypted signal.
452
+ * @param {string} tag - The signal tag.
453
+ * @param {Buffer} data - The data to encrypt and send.
454
+ * @param {string} key - The encryption key.
455
+ * @throws {TypeError} If tag is not a string.
456
+ */
457
+ signal_e2e(tag: string, data: Buffer$1, key: string): void;
458
+ /**
459
+ * Sets a value in the store.
460
+ * @param {string} storeName - The name of the store.
461
+ * @param {...any} args - Arguments to set.
462
+ * @returns {Promise<any>}
463
+ */
464
+ set(storeName: string, ...args: any[]): Promise<any>;
465
+ /**
466
+ * Gets a value from the store.
467
+ * @param {string} storeName - The name of the store.
468
+ * @returns {Promise<any>}
469
+ */
470
+ get(storeName: string): Promise<any>;
471
+ /**
472
+ * Sends a request to a target and topic.(remote service call)
473
+ * @param {string} target - The target(service name) of the request.
474
+ * @param {string} topic - The topic(service function name) of the request.
475
+ * @param {...any} args - Optional arguments for the request.
476
+ * @returns {Promise<any>}
477
+ */
478
+ call(target: string, topic: string, ...args: any[]): Promise<any>;
479
+ /**
480
+ * Subscribes to a channel or channels.
481
+ * @param {string} tag - The tag(s) of the channel(s) to subscribe to (comma-separated).
482
+ * @throws {TypeError} If tag is not a string or exceeds length limit.
483
+ */
484
+ subscribe(tag: string): void;
485
+ /**
486
+ * Sends subscriptions stored by listen()/link() on each CID-ready transition,
487
+ * including reconnection. This automates subscription setup for simple clients.
488
+ */
489
+ subscribe_channels(): void;
490
+ /**
491
+ * Unsubscribes from a channel or channels.
492
+ * @param {string} [tag=""] - The tag(s) of the channel(s) to unsubscribe from (comma-separated). If empty, unsubscribes from all.
493
+ * @throws {TypeError} If tag is not a string or exceeds length limit.
494
+ */
495
+ unsubscribe(tag?: string): void;
496
+ /**
497
+ * Convenience API for simple clients (for example, CLI tools): register a
498
+ * tag handler once and remember its subscription in channels. Register before
499
+ * connection readiness; the CID-ready flow subscribes on initial connection
500
+ * and again after reconnect, without application-level ready/subscribe code.
501
+ * This does not send a subscription immediately, even if already ready.
502
+ * For precise subscription/send ordering or dynamic subscriptions, use
503
+ * on() with subscribe() in a ready handler instead. Direct signals use on('@').
504
+ * @param {string} tag - The tag to listen on.
505
+ * @param {Function} handler - The callback function to handle the signal.
506
+ * @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
507
+ */
508
+ listen(tag: string, handler: Function): void;
509
+ /**
510
+ * Links a local target to a remote tag and sets up a handler.
511
+ * @param {string} to - The local link target.
512
+ * @param {string} tag - The remote tag.
513
+ * @param {Function} handler - The callback function to handle the signal.
514
+ * @throws {TypeError} If 'to' or 'tag' are not strings, handler is not a function, or tag length is invalid.
515
+ */
516
+ link(to: string, tag: string, handler: Function): void;
517
+ /**
518
+ * Unlinks a specific tag from a local target.
519
+ * @param {string} to - The local link target.
520
+ * @param {string} tag - The tag to unlink.
521
+ * @throws {TypeError} If 'to' or 'tag' are not strings or tag length is invalid.
522
+ */
523
+ unlink(to: string, tag: string): void;
524
+ /**
525
+ * Unlinks all tags from a local target.
526
+ * @param {string} to - The local link target.
527
+ * @throws {TypeError} If 'to' is not a string.
528
+ */
529
+ unlinkAll(to: string): void;
530
+ /**
531
+ * Gets connection metrics.
532
+ * @returns {{tx: number, rx: number, txb: number, rxb: number, last: number}}
533
+ */
534
+ getMetric(): {
535
+ tx: number;
536
+ rx: number;
537
+ txb: number;
538
+ rxb: number;
539
+ last: number;
540
+ };
541
+ /**
542
+ * Gets the current connection state.
543
+ * @returns {number}
544
+ */
545
+ getState(): number;
546
+ /**
547
+ * Gets the current connection state name.
548
+ * @returns {string}
549
+ */
550
+ getStateName(): string;
551
+ /**
552
+ * Gets security-related information.
553
+ * @returns {{useAuth: boolean, isTLS: boolean, isAuthorized: boolean, encMode: number, usingEncryption: boolean}}
554
+ */
555
+ getSecurity(): {
556
+ useAuth: boolean;
557
+ isTLS: boolean;
558
+ isAuthorized: boolean;
559
+ encMode: number;
560
+ usingEncryption: boolean;
561
+ };
562
+ /**
563
+ * Changes the connection state and emits events.
564
+ * @param {string} state - The new state name (e.g., 'ready', 'closed').
565
+ * @param {string} [emitEventAndMessage] - Optional message to emit with the state change event.
566
+ *
567
+ * 주의.
568
+ * 1. 상태가 변경 될 때만 'change' 이벤트 호출된다.
569
+ * 2. emitEventAndMessage 옵션 값이 지정되야 해당 이벤트 이름이 호출된다.
570
+ * 보통 이벤트 이름과 동일하게 적거나 이벤트 상황 안내문을 넣는다.
571
+ * 3. 두 상태값 갱신 후 change, 개별 이벤트 순서로 호출한다.
572
+ * 콜백에서 다른 상태로 전이하면 이전 상태의 개별 이벤트는 생략한다.
573
+ * @returns {boolean} Whether this transition is still current after callbacks.
574
+ */
575
+ stateChange(state: string, emitEventAndMessage?: string): boolean;
576
+ }
577
+ type Buffer$1 = Boho.Buffer;
578
+
579
+ declare function pack(payload: any): Buffer<ArrayBufferLike>;
580
+ declare class CongRx extends Transform {
581
+ buffer: Buffer<ArrayBuffer>;
582
+ frames: any[];
583
+ rxi: number;
584
+ rxi_zero: number;
585
+ _transform(chunk: any, encoding: any, callback: any): void;
586
+ addData(chunk: any): void;
587
+ parse(): void;
588
+ }
589
+
590
+ declare class IOCongSocket extends IOCore {
591
+ constructor(url: any);
592
+ congRx: CongRx | null | undefined;
593
+ keepConnection(): void;
594
+ createConnection(url: any): void;
595
+ onTCPSocketMessage(data: any): void;
596
+ socket_send(data: any): void;
597
+ }
598
+
599
+ declare class IOWS extends IOCore {
600
+ constructor(url: any);
601
+ keepConnection(): void;
602
+ createConnection(url: any): void;
603
+ onWebSocketMessage(data: any): void;
604
+ socket_send(data: any): void;
605
+ }
606
+
607
+ declare class FileLogger {
608
+ constructor(path: any);
609
+ file: number;
610
+ log(msg: any): void;
611
+ }
612
+
613
+ declare class Metrics {
614
+ constructor(manager: any);
615
+ manager: any;
616
+ metricsPack: {
617
+ remotes: number[];
618
+ channels: number[];
619
+ txBytes: number[];
620
+ rxBytes: number[];
621
+ unixTime: number[];
622
+ period: number;
623
+ };
624
+ tickId: number;
625
+ close(): void;
626
+ oneline(prn: any): {
627
+ lastSSID: any;
628
+ remotes: any;
629
+ channels: any;
630
+ txBytes: any;
631
+ rxBytes: any;
632
+ };
633
+ getRemotes(prn: any): string[];
634
+ getCIdList(prn: any): any[];
635
+ getChannelList(prn: any): any[];
636
+ getSubscribers(ch: any): any[];
637
+ getRemoteByCId(cid: any, mode?: number): {
638
+ ip: any;
639
+ id: any;
640
+ ssid: any;
641
+ cid: any;
642
+ uid: any;
643
+ uptime: number;
644
+ tx: any;
645
+ rx: any;
646
+ txBytes: any;
647
+ rxBytes: any;
648
+ nick?: undefined;
649
+ isSecure?: undefined;
650
+ isAuth?: undefined;
651
+ encMode?: undefined;
652
+ channels?: undefined;
653
+ set?: undefined;
654
+ retain?: undefined;
655
+ result?: undefined;
656
+ } | {
657
+ ip: any;
658
+ uptime: number;
659
+ nick: any;
660
+ ssid: any;
661
+ id?: undefined;
662
+ cid?: undefined;
663
+ uid?: undefined;
664
+ tx?: undefined;
665
+ rx?: undefined;
666
+ txBytes?: undefined;
667
+ rxBytes?: undefined;
668
+ isSecure?: undefined;
669
+ isAuth?: undefined;
670
+ encMode?: undefined;
671
+ channels?: undefined;
672
+ set?: undefined;
673
+ retain?: undefined;
674
+ result?: undefined;
675
+ } | {
676
+ ip: any;
677
+ uptime: number;
678
+ nick: any;
679
+ ssid: any;
680
+ isSecure: any;
681
+ isAuth: any;
682
+ encMode: any;
683
+ id?: undefined;
684
+ cid?: undefined;
685
+ uid?: undefined;
686
+ tx?: undefined;
687
+ rx?: undefined;
688
+ txBytes?: undefined;
689
+ rxBytes?: undefined;
690
+ channels?: undefined;
691
+ set?: undefined;
692
+ retain?: undefined;
693
+ result?: undefined;
694
+ } | {
695
+ ip: any;
696
+ uptime: number;
697
+ channels: any[];
698
+ set: any[];
699
+ retain: any[];
700
+ id?: undefined;
701
+ ssid?: undefined;
702
+ cid?: undefined;
703
+ uid?: undefined;
704
+ tx?: undefined;
705
+ rx?: undefined;
706
+ txBytes?: undefined;
707
+ rxBytes?: undefined;
708
+ nick?: undefined;
709
+ isSecure?: undefined;
710
+ isAuth?: undefined;
711
+ encMode?: undefined;
712
+ result?: undefined;
713
+ } | {
714
+ result: string;
715
+ ip?: undefined;
716
+ id?: undefined;
717
+ ssid?: undefined;
718
+ cid?: undefined;
719
+ uid?: undefined;
720
+ uptime?: undefined;
721
+ tx?: undefined;
722
+ rx?: undefined;
723
+ txBytes?: undefined;
724
+ rxBytes?: undefined;
725
+ nick?: undefined;
726
+ isSecure?: undefined;
727
+ isAuth?: undefined;
728
+ encMode?: undefined;
729
+ channels?: undefined;
730
+ set?: undefined;
731
+ retain?: undefined;
732
+ } | undefined;
733
+ }
734
+
735
+ declare class Manager {
736
+ constructor(server: any, authManager: any);
737
+ server: any;
738
+ pingPeriod: number;
739
+ pingGrace: number;
740
+ txBytes: number;
741
+ rxBytes: number;
742
+ authManager: any;
743
+ connectionLogger: FileLogger | undefined;
744
+ attackLogger: FileLogger | undefined;
745
+ remotes: Set<any>;
746
+ cid2remote: Map<any, any>;
747
+ retain_messages: Map<any, any>;
748
+ channel_map: Map<any, any>;
749
+ CHANNEL_PREFIX: string;
750
+ CID_PREFIX: string;
751
+ metrics: Metrics;
752
+ lastSSID: number;
753
+ pingGroups: Set<any>[];
754
+ nextPingGroup: number;
755
+ pingGroupCursor: number;
756
+ heartbeatPending: Map<any, any>;
757
+ pingTickMs: number;
758
+ heartbeatStopped: boolean;
759
+ pingIntervalID: NodeJS.Timeout;
760
+ monitIntervalID: number | undefined;
761
+ heartbeatTick(): void;
762
+ addRemote(socket: any, req: any): void;
763
+ removeRemote(remote: any): void;
764
+ serverSignal(obj: any): void;
765
+ getSignalTag(buffer: any): string;
766
+ getNewSignalTagMessage(buffer: any, newTag: any): Buffer<ArrayBuffer> | null;
767
+ deligateSignal(remote: any, tag: any, ...args: any[]): void;
768
+ adminSignal(cid: any, message: any): "no cid" | undefined;
769
+ serverSignalTo(tag: any, ...args: any[]): "no cid" | undefined;
770
+ sender(tag: any, remote: any, message: any): (string | number)[];
771
+ subscribe(chArr: any, remote: any): any;
772
+ unsubscribe(chArr: any, remote: any): void;
773
+ monitor(): void;
774
+ closeRemoteByCId(cid: any): 0 | 1;
775
+ close(): void;
776
+ }
777
+
778
+ declare class Server extends EventEmitter$1<[never]> {
779
+ /**
780
+ * @param {object} options Server configuration.
781
+ * @param {any} [authManager] Optional authentication manager.
782
+ */
783
+ constructor(options: object, authManager?: any);
784
+ security: any;
785
+ serviceNames: Set<any>;
786
+ wss: {};
787
+ port: number | null;
788
+ congPort: number | null;
789
+ httpServer: any;
790
+ wsPath: any;
791
+ manager: Manager;
792
+ serverCountToListen: number;
793
+ listeningServerCount: number;
794
+ startWSServer(): void;
795
+ startCongServer(): void;
796
+ congServer: any;
797
+ /**
798
+ * RPC service register.
799
+ * service: service_name <string>
800
+ * service_module <function module|class instance>
801
+ * return this
802
+ */
803
+ attach(service: any, service_module: any): this;
804
+ /**
805
+ * @param {() => void} [callback] Called when the server has closed.
806
+ */
807
+ close(callback?: () => void): void;
808
+ }
809
+
810
+ declare namespace serverOption {
811
+ export let clientTracking: boolean;
812
+ export let port: null;
813
+ export let congPort: null;
814
+ export let httpServer: null;
815
+ export let wsPath: null;
816
+ export let timeout: number;
817
+ export let pingTimeoutGrace: number;
818
+ export let showMessage: string;
819
+ export let showMetric: number;
820
+ export let showChannel: number;
821
+ export let monitorPeriod: number;
822
+ export namespace fileLogger {
823
+ namespace connection {
824
+ let use: boolean;
825
+ let path: string;
826
+ }
827
+ namespace auth {
828
+ let use_1: boolean;
829
+ export { use_1 as use };
830
+ let path_1: string;
831
+ export { path_1 as path };
832
+ }
833
+ namespace attack {
834
+ let use_2: boolean;
835
+ export { use_2 as use };
836
+ let path_2: string;
837
+ export { path_2 as path };
838
+ }
839
+ }
840
+ export namespace useQuota {
841
+ let signalSize: boolean;
842
+ let publishCounter: boolean;
843
+ let trafficRate: boolean;
844
+ let disconnect: boolean;
845
+ }
846
+ export let defaultQuotaIndex: number;
847
+ export let adminLevel: number;
848
+ export namespace debug {
849
+ let slow: boolean;
850
+ let delay: number;
851
+ let showAuthInfo: boolean;
852
+ }
853
+ export namespace retain {
854
+ let isAvailable: boolean;
855
+ let limitSize: number;
856
+ let limitCounter: number;
857
+ }
858
+ export namespace security {
859
+ let maxClockSkewMs: number;
860
+ let authChallengeMaxAgeMs: number;
861
+ let maxReplayEntries: number;
862
+ }
863
+ export namespace auth_1 {
864
+ let delay_auth_fail: number;
865
+ }
866
+ export { auth_1 as auth };
867
+ export let membersOnly: boolean;
868
+ }
869
+
870
+ declare function isPrivateIP(ip: any): boolean;
871
+ declare function numberWithCommas(x: any): any;
872
+ declare function getIPv4HexString(ipStr: any): string;
873
+ declare function getLocalAddress(): string;
874
+ declare function delay(ms: any): Promise<any>;
875
+
876
+ declare class BohoAuth {
877
+ constructor(keyProvider: any);
878
+ keyProvider: any;
879
+ keepOldConnection: boolean;
880
+ authLogger: FileLogger | undefined;
881
+ send_auth_fail(peer: any, reason: any): void;
882
+ verify_auth_req(auth_req: any, peer: any): Promise<any>;
883
+ getAuth(id: any): Promise<any>;
884
+ getAuthIdList(): Promise<any>;
885
+ addAuth(id: any, keyStr: any, cid: any, level?: number): Promise<any>;
886
+ delAuth(id: any): Promise<any>;
887
+ save(): Promise<any>;
888
+ }
889
+
890
+ declare class FileKeyProvider {
891
+ constructor(_path: any);
892
+ AUTH: Map<any, any>;
893
+ path: string;
894
+ loadAuthInfoFile_JS(path: any): void;
895
+ loadAuthInfoFile_JSON(path: any): void;
896
+ getAuth(id: any): Promise<any>;
897
+ getAuthIdList(): Promise<any[]>;
898
+ addAuth(id: any, keyStr: any, cid: any, level?: number): void;
899
+ }
900
+
901
+ declare class RedisKeyProvider {
902
+ constructor(redisClient: any);
903
+ redis: any;
904
+ getAuth(id: any): Promise<any>;
905
+ getAuthIdList(): Promise<any>;
906
+ addAuth(id: any, keyStr: any, cid?: string, level?: number): Promise<any>;
907
+ delAuth(id: any): Promise<any>;
908
+ save(id: any): Promise<any>;
909
+ }
910
+
911
+ declare class StringKeyProvider {
912
+ constructor(authInfo: any);
913
+ AUTH: Map<any, any>;
914
+ getAuth(id: any): Promise<any>;
915
+ getAuthIdList(): Promise<any[]>;
916
+ addAuth(id: any, keyStr: any, cid: any, level?: number): void;
917
+ }
918
+
919
+ declare function checkPermission$1(remote: any): boolean;
920
+ /**
921
+ * client api call example: await io.call('reply','echo','hello')
922
+ */
923
+ declare function echo(remote: any, req: any): Promise<void>;
924
+ /**
925
+ * client api call example: await io.call('reply','date')
926
+ */
927
+ declare function date(remote: any, req: any): Promise<void>;
928
+ /**
929
+ * client api call example: await io.call('reply','unixtime')
930
+ */
931
+ declare function unixtime(remote: any, req: any): Promise<void>;
932
+ declare const commands$1: string[];
933
+
934
+ declare const replyService_date: typeof date;
935
+ declare const replyService_echo: typeof echo;
936
+ declare const replyService_unixtime: typeof unixtime;
937
+ declare namespace replyService {
938
+ export {
939
+ checkPermission$1 as checkPermission,
940
+ commands$1 as commands,
941
+ replyService_date as date,
942
+ replyService_echo as echo,
943
+ replyService_unixtime as unixtime,
944
+ };
945
+ }
946
+
947
+ declare function checkPermission(remote: any): boolean;
948
+ declare function call(remote: any, req: any): Promise<void>;
949
+ declare const commands: string[];
950
+
951
+ declare const sudoService_call: typeof call;
952
+ declare const sudoService_checkPermission: typeof checkPermission;
953
+ declare const sudoService_commands: typeof commands;
954
+ declare namespace sudoService {
955
+ export {
956
+ sudoService_call as call,
957
+ sudoService_checkPermission as checkPermission,
958
+ sudoService_commands as commands,
959
+ };
960
+ }
961
+
962
+ declare class RedisService {
963
+ constructor(redisClient: any, _minLevel: any);
964
+ redisClient: any;
965
+ minLevel: any;
966
+ commands: string[];
967
+ checkPermission(remote: any, req: any): boolean;
968
+ call(remote: any, req: any): Promise<void>;
969
+ }
970
+
971
+ declare function getSignalPack(tag: any, ...args: any[]): Buffer<ArrayBufferLike>;
972
+ declare function parsePayload(args: any): {
973
+ type: number;
974
+ buffer: Uint8Array<ArrayBuffer> | Buffer<ArrayBufferLike> | null | undefined;
975
+ };
976
+ declare function getPayloadFromSignalPack(signalPack: any): any;
977
+
978
+ declare const version: string;
979
+
980
+ export { BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, PAYLOAD_TYPE, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS, Server, StringKeyProvider, delay, getIPv4HexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };