iosignal 7.1.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +64 -191
- package/README.md +68 -226
- package/dist/browser/esm/io.d.ts +36 -19
- package/dist/browser/esm/io.js +3 -3
- package/dist/browser/esm/io.js.map +1 -1
- package/dist/browser/iife/io.js +3 -3
- package/dist/browser/iife/io.js.map +1 -1
- package/dist/node/iosignal.cjs +467 -295
- package/dist/node/iosignal.d.cts +73 -24
- package/dist/node/iosignal.d.ts +73 -24
- package/dist/node/iosignal.js +467 -295
- package/dist/types/client/IOCore.d.ts +35 -18
- package/dist/types/client/browser/IOWebSocket.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/iosignal.d.cts
CHANGED
|
@@ -302,6 +302,12 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
302
302
|
* @type {Map<string, Set<string>>}
|
|
303
303
|
*/
|
|
304
304
|
linkMap: Map<string, Set<string>>;
|
|
305
|
+
/** @private @type {Map<string, Map<string, Set<Function>>>} */
|
|
306
|
+
private _linkHandlers;
|
|
307
|
+
/** @private @type {Set<string>} */
|
|
308
|
+
private _listenTags;
|
|
309
|
+
/** @private @type {Set<string>} */
|
|
310
|
+
private _manualSubscriptions;
|
|
305
311
|
/**
|
|
306
312
|
* Indicates if auto-reconnect is enabled.
|
|
307
313
|
* @type {boolean}
|
|
@@ -328,7 +334,9 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
328
334
|
stop(): void;
|
|
329
335
|
/**
|
|
330
336
|
* Permanently destroys the instance, cleaning up all resources.
|
|
331
|
-
* The instance will not be usable after this.
|
|
337
|
+
* The instance will not be usable after this. Later signal()/publish()/subscribe()
|
|
338
|
+
* calls are silently dropped, the same as sends while disconnected, and call()
|
|
339
|
+
* rejects with code 'CONNECTION_CLOSED'.
|
|
332
340
|
*/
|
|
333
341
|
destroy(): void;
|
|
334
342
|
/**
|
|
@@ -411,6 +419,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
411
419
|
getEncryptionMode(): boolean;
|
|
412
420
|
/**
|
|
413
421
|
* Sends data with encryption based on the encryption mode.
|
|
422
|
+
* Like an unconnected socket, a destroyed instance silently drops the data.
|
|
414
423
|
* @param {Buffer} data - The data buffer to send.
|
|
415
424
|
* @param {boolean} [useEncryption] - Optional. Force encryption or not. If undefined, uses default policy.
|
|
416
425
|
*/
|
|
@@ -479,7 +488,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
479
488
|
/**
|
|
480
489
|
* Subscribes to a channel or channels.
|
|
481
490
|
* @param {string} tag - The tag(s) of the channel(s) to subscribe to (comma-separated).
|
|
482
|
-
* @throws {TypeError} If tag is
|
|
491
|
+
* @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
|
|
483
492
|
*/
|
|
484
493
|
subscribe(tag: string): void;
|
|
485
494
|
/**
|
|
@@ -490,41 +499,49 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
490
499
|
/**
|
|
491
500
|
* Unsubscribes from a channel or channels.
|
|
492
501
|
* @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
|
|
502
|
+
* @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
|
|
494
503
|
*/
|
|
495
504
|
unsubscribe(tag?: string): void;
|
|
496
505
|
/**
|
|
497
506
|
* Convenience API for simple clients (for example, CLI tools): register a
|
|
498
|
-
* tag handler once and remember its subscription in channels.
|
|
499
|
-
* connection readiness; the CID-ready flow subscribes on initial connection
|
|
507
|
+
* tag handler once and remember its subscription in channels. For subscription
|
|
508
|
+
* tags, register before connection readiness; the CID-ready flow subscribes on initial connection
|
|
500
509
|
* and again after reconnect, without application-level ready/subscribe code.
|
|
501
510
|
* This does not send a subscription immediately, even if already ready.
|
|
502
511
|
* For precise subscription/send ordering or dynamic subscriptions, use
|
|
503
|
-
* on() with subscribe() in a ready handler instead.
|
|
512
|
+
* on() with subscribe() in a ready handler instead.
|
|
513
|
+
* Direct signals need no subscription: use on/listen('@') for all direct
|
|
514
|
+
* signals, or on/listen('@topic') for an exact topic. Direct handlers can be
|
|
515
|
+
* registered before or after readiness, before the message arrives.
|
|
516
|
+
* Dispatch is synchronous: '@' first, then '@topic' when tag is not '@'.
|
|
517
|
+
* Returning false does not cancel dispatch; a thrown error interrupts it.
|
|
504
518
|
* @param {string} tag - The tag to listen on.
|
|
505
519
|
* @param {Function} handler - The callback function to handle the signal.
|
|
506
520
|
* @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
|
|
507
521
|
*/
|
|
508
522
|
listen(tag: string, handler: Function): void;
|
|
509
523
|
/**
|
|
510
|
-
*
|
|
511
|
-
* @
|
|
512
|
-
*
|
|
513
|
-
* @param {
|
|
514
|
-
* @
|
|
524
|
+
* Associates handlers with a local component for scoped teardown.
|
|
525
|
+
* Direct tags (@ or @topic) only register local handlers. Other tags also
|
|
526
|
+
* subscribe now and are remembered for reconnection.
|
|
527
|
+
* @param {string} to - The local component identifier, not a server target.
|
|
528
|
+
* @param {string} tag - The exact event tag.
|
|
529
|
+
* @param {Function} handler - The callback receiving (tag, ...args).
|
|
530
|
+
* @throws {TypeError} If the arguments or subscription tags are invalid.
|
|
515
531
|
*/
|
|
516
532
|
link(to: string, tag: string, handler: Function): void;
|
|
517
533
|
/**
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
* @param {string}
|
|
521
|
-
* @
|
|
534
|
+
* Removes only one local component's handlers for a tag. Direct tags never
|
|
535
|
+
* send an unsubscribe. Shared subscriptions and explicit subscriptions remain.
|
|
536
|
+
* @param {string} to - The local component identifier.
|
|
537
|
+
* @param {string} tag - The exact linked tag.
|
|
538
|
+
* @throws {TypeError} If the arguments are invalid.
|
|
522
539
|
*/
|
|
523
540
|
unlink(to: string, tag: string): void;
|
|
524
541
|
/**
|
|
525
|
-
*
|
|
526
|
-
* @param {string} to - The local
|
|
527
|
-
* @throws {TypeError} If
|
|
542
|
+
* Removes this local component's links without removing other listeners.
|
|
543
|
+
* @param {string} to - The local component identifier.
|
|
544
|
+
* @throws {TypeError} If the component identifier is not a string.
|
|
528
545
|
*/
|
|
529
546
|
unlinkAll(to: string): void;
|
|
530
547
|
/**
|
|
@@ -771,6 +788,8 @@ declare class Manager {
|
|
|
771
788
|
subscribe(chArr: any, remote: any): any;
|
|
772
789
|
unsubscribe(chArr: any, remote: any): void;
|
|
773
790
|
monitor(): void;
|
|
791
|
+
anonymousCidRandom(size: any): Buffer<ArrayBuffer>;
|
|
792
|
+
issueAnonymousCid(): string | null;
|
|
774
793
|
closeRemoteByCId(cid: any): 0 | 1;
|
|
775
794
|
close(): void;
|
|
776
795
|
}
|
|
@@ -783,6 +802,7 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
783
802
|
constructor(options: object, authManager?: any);
|
|
784
803
|
security: any;
|
|
785
804
|
serviceNames: Set<any>;
|
|
805
|
+
services: Map<any, any>;
|
|
786
806
|
wss: {};
|
|
787
807
|
port: number | null;
|
|
788
808
|
congPort: number | null;
|
|
@@ -862,6 +882,7 @@ declare namespace serverOption {
|
|
|
862
882
|
}
|
|
863
883
|
export namespace auth_1 {
|
|
864
884
|
let delay_auth_fail: number;
|
|
885
|
+
let duplicateLogin: string;
|
|
865
886
|
}
|
|
866
887
|
export { auth_1 as auth };
|
|
867
888
|
export let membersOnly: boolean;
|
|
@@ -874,10 +895,30 @@ declare function getLocalAddress(): string;
|
|
|
874
895
|
declare function delay(ms: any): Promise<any>;
|
|
875
896
|
|
|
876
897
|
declare class BohoAuth {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
898
|
+
/**
|
|
899
|
+
* @param {object} keyProvider
|
|
900
|
+
* @param {{ duplicateLogin?: 'keepOld' | 'keepNew', onAuthEvent?: (event: object) => any }} [options]
|
|
901
|
+
* duplicateLogin: unset follows serverOption.auth.duplicateLogin (default 'keepNew').
|
|
902
|
+
* onAuthEvent: called with { type, did, cid, uid, ip, oldIp, socketType, oldSocketType, reason, at }
|
|
903
|
+
* for 'replaced' (keepNew evicted the old connection) and 'duplicate_rejected' (keepOld).
|
|
904
|
+
* socketType/oldSocketType are 'websocket' or 'congsocket'.
|
|
905
|
+
* Errors and rejected promises are logged and never affect authentication.
|
|
906
|
+
*/
|
|
907
|
+
constructor(keyProvider: object, options?: {
|
|
908
|
+
duplicateLogin?: "keepOld" | "keepNew";
|
|
909
|
+
onAuthEvent?: (event: object) => any;
|
|
910
|
+
});
|
|
911
|
+
keyProvider: object;
|
|
912
|
+
_duplicateLogin: any;
|
|
913
|
+
/** @param {'keepOld' | 'keepNew' | null} policy null returns to the serverOption default. */
|
|
914
|
+
set duplicateLogin(policy: "keepOld" | "keepNew" | null);
|
|
915
|
+
/** Effective duplicate login policy: this instance's setting, else serverOption.auth.duplicateLogin. */
|
|
916
|
+
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
917
|
+
onAuthEvent: ((event: object) => any) | null;
|
|
880
918
|
authLogger: FileLogger | undefined;
|
|
919
|
+
set keepOldConnection(keepOld: boolean);
|
|
920
|
+
get keepOldConnection(): boolean;
|
|
921
|
+
emitAuthEvent(event: any): void;
|
|
881
922
|
send_auth_fail(peer: any, reason: any): void;
|
|
882
923
|
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
883
924
|
getAuth(id: any): Promise<any>;
|
|
@@ -960,9 +1001,17 @@ declare namespace sudoService {
|
|
|
960
1001
|
}
|
|
961
1002
|
|
|
962
1003
|
declare class RedisService {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1004
|
+
/**
|
|
1005
|
+
* @param {object} redisClient
|
|
1006
|
+
* @param {number} [_minLevel=200]
|
|
1007
|
+
* @param {{ requireAuth?: boolean }} [options] requireAuth (default true): allow Boho-authenticated remotes only.
|
|
1008
|
+
*/
|
|
1009
|
+
constructor(redisClient: object, _minLevel?: number, options?: {
|
|
1010
|
+
requireAuth?: boolean;
|
|
1011
|
+
});
|
|
1012
|
+
redisClient: object;
|
|
1013
|
+
minLevel: number;
|
|
1014
|
+
requireAuth: boolean;
|
|
966
1015
|
commands: string[];
|
|
967
1016
|
checkPermission(remote: any, req: any): boolean;
|
|
968
1017
|
call(remote: any, req: any): Promise<void>;
|
package/dist/node/iosignal.d.ts
CHANGED
|
@@ -302,6 +302,12 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
302
302
|
* @type {Map<string, Set<string>>}
|
|
303
303
|
*/
|
|
304
304
|
linkMap: Map<string, Set<string>>;
|
|
305
|
+
/** @private @type {Map<string, Map<string, Set<Function>>>} */
|
|
306
|
+
private _linkHandlers;
|
|
307
|
+
/** @private @type {Set<string>} */
|
|
308
|
+
private _listenTags;
|
|
309
|
+
/** @private @type {Set<string>} */
|
|
310
|
+
private _manualSubscriptions;
|
|
305
311
|
/**
|
|
306
312
|
* Indicates if auto-reconnect is enabled.
|
|
307
313
|
* @type {boolean}
|
|
@@ -328,7 +334,9 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
328
334
|
stop(): void;
|
|
329
335
|
/**
|
|
330
336
|
* Permanently destroys the instance, cleaning up all resources.
|
|
331
|
-
* The instance will not be usable after this.
|
|
337
|
+
* The instance will not be usable after this. Later signal()/publish()/subscribe()
|
|
338
|
+
* calls are silently dropped, the same as sends while disconnected, and call()
|
|
339
|
+
* rejects with code 'CONNECTION_CLOSED'.
|
|
332
340
|
*/
|
|
333
341
|
destroy(): void;
|
|
334
342
|
/**
|
|
@@ -411,6 +419,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
411
419
|
getEncryptionMode(): boolean;
|
|
412
420
|
/**
|
|
413
421
|
* Sends data with encryption based on the encryption mode.
|
|
422
|
+
* Like an unconnected socket, a destroyed instance silently drops the data.
|
|
414
423
|
* @param {Buffer} data - The data buffer to send.
|
|
415
424
|
* @param {boolean} [useEncryption] - Optional. Force encryption or not. If undefined, uses default policy.
|
|
416
425
|
*/
|
|
@@ -479,7 +488,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
479
488
|
/**
|
|
480
489
|
* Subscribes to a channel or channels.
|
|
481
490
|
* @param {string} tag - The tag(s) of the channel(s) to subscribe to (comma-separated).
|
|
482
|
-
* @throws {TypeError} If tag is
|
|
491
|
+
* @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
|
|
483
492
|
*/
|
|
484
493
|
subscribe(tag: string): void;
|
|
485
494
|
/**
|
|
@@ -490,41 +499,49 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
490
499
|
/**
|
|
491
500
|
* Unsubscribes from a channel or channels.
|
|
492
501
|
* @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
|
|
502
|
+
* @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
|
|
494
503
|
*/
|
|
495
504
|
unsubscribe(tag?: string): void;
|
|
496
505
|
/**
|
|
497
506
|
* Convenience API for simple clients (for example, CLI tools): register a
|
|
498
|
-
* tag handler once and remember its subscription in channels.
|
|
499
|
-
* connection readiness; the CID-ready flow subscribes on initial connection
|
|
507
|
+
* tag handler once and remember its subscription in channels. For subscription
|
|
508
|
+
* tags, register before connection readiness; the CID-ready flow subscribes on initial connection
|
|
500
509
|
* and again after reconnect, without application-level ready/subscribe code.
|
|
501
510
|
* This does not send a subscription immediately, even if already ready.
|
|
502
511
|
* For precise subscription/send ordering or dynamic subscriptions, use
|
|
503
|
-
* on() with subscribe() in a ready handler instead.
|
|
512
|
+
* on() with subscribe() in a ready handler instead.
|
|
513
|
+
* Direct signals need no subscription: use on/listen('@') for all direct
|
|
514
|
+
* signals, or on/listen('@topic') for an exact topic. Direct handlers can be
|
|
515
|
+
* registered before or after readiness, before the message arrives.
|
|
516
|
+
* Dispatch is synchronous: '@' first, then '@topic' when tag is not '@'.
|
|
517
|
+
* Returning false does not cancel dispatch; a thrown error interrupts it.
|
|
504
518
|
* @param {string} tag - The tag to listen on.
|
|
505
519
|
* @param {Function} handler - The callback function to handle the signal.
|
|
506
520
|
* @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
|
|
507
521
|
*/
|
|
508
522
|
listen(tag: string, handler: Function): void;
|
|
509
523
|
/**
|
|
510
|
-
*
|
|
511
|
-
* @
|
|
512
|
-
*
|
|
513
|
-
* @param {
|
|
514
|
-
* @
|
|
524
|
+
* Associates handlers with a local component for scoped teardown.
|
|
525
|
+
* Direct tags (@ or @topic) only register local handlers. Other tags also
|
|
526
|
+
* subscribe now and are remembered for reconnection.
|
|
527
|
+
* @param {string} to - The local component identifier, not a server target.
|
|
528
|
+
* @param {string} tag - The exact event tag.
|
|
529
|
+
* @param {Function} handler - The callback receiving (tag, ...args).
|
|
530
|
+
* @throws {TypeError} If the arguments or subscription tags are invalid.
|
|
515
531
|
*/
|
|
516
532
|
link(to: string, tag: string, handler: Function): void;
|
|
517
533
|
/**
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
* @param {string}
|
|
521
|
-
* @
|
|
534
|
+
* Removes only one local component's handlers for a tag. Direct tags never
|
|
535
|
+
* send an unsubscribe. Shared subscriptions and explicit subscriptions remain.
|
|
536
|
+
* @param {string} to - The local component identifier.
|
|
537
|
+
* @param {string} tag - The exact linked tag.
|
|
538
|
+
* @throws {TypeError} If the arguments are invalid.
|
|
522
539
|
*/
|
|
523
540
|
unlink(to: string, tag: string): void;
|
|
524
541
|
/**
|
|
525
|
-
*
|
|
526
|
-
* @param {string} to - The local
|
|
527
|
-
* @throws {TypeError} If
|
|
542
|
+
* Removes this local component's links without removing other listeners.
|
|
543
|
+
* @param {string} to - The local component identifier.
|
|
544
|
+
* @throws {TypeError} If the component identifier is not a string.
|
|
528
545
|
*/
|
|
529
546
|
unlinkAll(to: string): void;
|
|
530
547
|
/**
|
|
@@ -771,6 +788,8 @@ declare class Manager {
|
|
|
771
788
|
subscribe(chArr: any, remote: any): any;
|
|
772
789
|
unsubscribe(chArr: any, remote: any): void;
|
|
773
790
|
monitor(): void;
|
|
791
|
+
anonymousCidRandom(size: any): Buffer<ArrayBuffer>;
|
|
792
|
+
issueAnonymousCid(): string | null;
|
|
774
793
|
closeRemoteByCId(cid: any): 0 | 1;
|
|
775
794
|
close(): void;
|
|
776
795
|
}
|
|
@@ -783,6 +802,7 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
783
802
|
constructor(options: object, authManager?: any);
|
|
784
803
|
security: any;
|
|
785
804
|
serviceNames: Set<any>;
|
|
805
|
+
services: Map<any, any>;
|
|
786
806
|
wss: {};
|
|
787
807
|
port: number | null;
|
|
788
808
|
congPort: number | null;
|
|
@@ -862,6 +882,7 @@ declare namespace serverOption {
|
|
|
862
882
|
}
|
|
863
883
|
export namespace auth_1 {
|
|
864
884
|
let delay_auth_fail: number;
|
|
885
|
+
let duplicateLogin: string;
|
|
865
886
|
}
|
|
866
887
|
export { auth_1 as auth };
|
|
867
888
|
export let membersOnly: boolean;
|
|
@@ -874,10 +895,30 @@ declare function getLocalAddress(): string;
|
|
|
874
895
|
declare function delay(ms: any): Promise<any>;
|
|
875
896
|
|
|
876
897
|
declare class BohoAuth {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
898
|
+
/**
|
|
899
|
+
* @param {object} keyProvider
|
|
900
|
+
* @param {{ duplicateLogin?: 'keepOld' | 'keepNew', onAuthEvent?: (event: object) => any }} [options]
|
|
901
|
+
* duplicateLogin: unset follows serverOption.auth.duplicateLogin (default 'keepNew').
|
|
902
|
+
* onAuthEvent: called with { type, did, cid, uid, ip, oldIp, socketType, oldSocketType, reason, at }
|
|
903
|
+
* for 'replaced' (keepNew evicted the old connection) and 'duplicate_rejected' (keepOld).
|
|
904
|
+
* socketType/oldSocketType are 'websocket' or 'congsocket'.
|
|
905
|
+
* Errors and rejected promises are logged and never affect authentication.
|
|
906
|
+
*/
|
|
907
|
+
constructor(keyProvider: object, options?: {
|
|
908
|
+
duplicateLogin?: "keepOld" | "keepNew";
|
|
909
|
+
onAuthEvent?: (event: object) => any;
|
|
910
|
+
});
|
|
911
|
+
keyProvider: object;
|
|
912
|
+
_duplicateLogin: any;
|
|
913
|
+
/** @param {'keepOld' | 'keepNew' | null} policy null returns to the serverOption default. */
|
|
914
|
+
set duplicateLogin(policy: "keepOld" | "keepNew" | null);
|
|
915
|
+
/** Effective duplicate login policy: this instance's setting, else serverOption.auth.duplicateLogin. */
|
|
916
|
+
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
917
|
+
onAuthEvent: ((event: object) => any) | null;
|
|
880
918
|
authLogger: FileLogger | undefined;
|
|
919
|
+
set keepOldConnection(keepOld: boolean);
|
|
920
|
+
get keepOldConnection(): boolean;
|
|
921
|
+
emitAuthEvent(event: any): void;
|
|
881
922
|
send_auth_fail(peer: any, reason: any): void;
|
|
882
923
|
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
883
924
|
getAuth(id: any): Promise<any>;
|
|
@@ -960,9 +1001,17 @@ declare namespace sudoService {
|
|
|
960
1001
|
}
|
|
961
1002
|
|
|
962
1003
|
declare class RedisService {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1004
|
+
/**
|
|
1005
|
+
* @param {object} redisClient
|
|
1006
|
+
* @param {number} [_minLevel=200]
|
|
1007
|
+
* @param {{ requireAuth?: boolean }} [options] requireAuth (default true): allow Boho-authenticated remotes only.
|
|
1008
|
+
*/
|
|
1009
|
+
constructor(redisClient: object, _minLevel?: number, options?: {
|
|
1010
|
+
requireAuth?: boolean;
|
|
1011
|
+
});
|
|
1012
|
+
redisClient: object;
|
|
1013
|
+
minLevel: number;
|
|
1014
|
+
requireAuth: boolean;
|
|
966
1015
|
commands: string[];
|
|
967
1016
|
checkPermission(remote: any, req: any): boolean;
|
|
968
1017
|
call(remote: any, req: any): Promise<void>;
|