iosignal 7.2.0 → 8.1.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 +72 -186
- package/README.md +76 -221
- package/dist/browser/esm/io.d.ts +5 -2
- package/dist/browser/esm/io.js +1 -1
- package/dist/browser/esm/io.js.map +1 -1
- package/dist/browser/iife/io.js +1 -1
- package/dist/browser/iife/io.js.map +1 -1
- package/dist/node/iosignal.cjs +408 -223
- package/dist/node/iosignal.d.cts +67 -9
- package/dist/node/iosignal.d.ts +67 -9
- package/dist/node/iosignal.js +408 -224
- package/dist/types/client/IOCore.d.ts +4 -1
- package/dist/types/client/browser/IOWebSocket.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/iosignal.d.cts
CHANGED
|
@@ -334,7 +334,9 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
334
334
|
stop(): void;
|
|
335
335
|
/**
|
|
336
336
|
* Permanently destroys the instance, cleaning up all resources.
|
|
337
|
-
* 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'.
|
|
338
340
|
*/
|
|
339
341
|
destroy(): void;
|
|
340
342
|
/**
|
|
@@ -417,6 +419,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
417
419
|
getEncryptionMode(): boolean;
|
|
418
420
|
/**
|
|
419
421
|
* Sends data with encryption based on the encryption mode.
|
|
422
|
+
* Like an unconnected socket, a destroyed instance silently drops the data.
|
|
420
423
|
* @param {Buffer} data - The data buffer to send.
|
|
421
424
|
* @param {boolean} [useEncryption] - Optional. Force encryption or not. If undefined, uses default policy.
|
|
422
425
|
*/
|
|
@@ -785,6 +788,8 @@ declare class Manager {
|
|
|
785
788
|
subscribe(chArr: any, remote: any): any;
|
|
786
789
|
unsubscribe(chArr: any, remote: any): void;
|
|
787
790
|
monitor(): void;
|
|
791
|
+
anonymousCidRandom(size: any): Buffer<ArrayBuffer>;
|
|
792
|
+
issueAnonymousCid(): string | null;
|
|
788
793
|
closeRemoteByCId(cid: any): 0 | 1;
|
|
789
794
|
close(): void;
|
|
790
795
|
}
|
|
@@ -792,12 +797,16 @@ declare class Manager {
|
|
|
792
797
|
declare class Server extends EventEmitter$1<[never]> {
|
|
793
798
|
/**
|
|
794
799
|
* @param {object} options Server configuration.
|
|
800
|
+
* options.localAuth: login without a key list, for local testing. 'idKey' (key = ID) or
|
|
801
|
+
* { mode: 'idKey' | 'sharedKey', key, level } (see LocalKeyProvider); the CID is the ID.
|
|
802
|
+
* Cannot be combined with authManager.
|
|
795
803
|
* @param {any} [authManager] Optional authentication manager.
|
|
796
804
|
*/
|
|
797
805
|
constructor(options: object, authManager?: any);
|
|
798
806
|
security: any;
|
|
799
807
|
serviceNames: Set<any>;
|
|
800
|
-
|
|
808
|
+
services: Map<any, any>;
|
|
809
|
+
wss: any;
|
|
801
810
|
port: number | null;
|
|
802
811
|
congPort: number | null;
|
|
803
812
|
httpServer: any;
|
|
@@ -876,6 +885,7 @@ declare namespace serverOption {
|
|
|
876
885
|
}
|
|
877
886
|
export namespace auth_1 {
|
|
878
887
|
let delay_auth_fail: number;
|
|
888
|
+
let duplicateLogin: string;
|
|
879
889
|
}
|
|
880
890
|
export { auth_1 as auth };
|
|
881
891
|
export let membersOnly: boolean;
|
|
@@ -888,10 +898,30 @@ declare function getLocalAddress(): string;
|
|
|
888
898
|
declare function delay(ms: any): Promise<any>;
|
|
889
899
|
|
|
890
900
|
declare class BohoAuth {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
901
|
+
/**
|
|
902
|
+
* @param {object} keyProvider
|
|
903
|
+
* @param {{ duplicateLogin?: 'keepOld' | 'keepNew', onAuthEvent?: (event: object) => any }} [options]
|
|
904
|
+
* duplicateLogin: unset follows serverOption.auth.duplicateLogin (default 'keepNew').
|
|
905
|
+
* onAuthEvent: called with { type, did, cid, uid, ip, oldIp, socketType, oldSocketType, reason, at }
|
|
906
|
+
* for 'replaced' (keepNew evicted the old connection) and 'duplicate_rejected' (keepOld).
|
|
907
|
+
* socketType/oldSocketType are 'websocket' or 'congsocket'.
|
|
908
|
+
* Errors and rejected promises are logged and never affect authentication.
|
|
909
|
+
*/
|
|
910
|
+
constructor(keyProvider: object, options?: {
|
|
911
|
+
duplicateLogin?: "keepOld" | "keepNew";
|
|
912
|
+
onAuthEvent?: (event: object) => any;
|
|
913
|
+
});
|
|
914
|
+
keyProvider: object;
|
|
915
|
+
_duplicateLogin: any;
|
|
916
|
+
/** @param {'keepOld' | 'keepNew' | null} policy null returns to the serverOption default. */
|
|
917
|
+
set duplicateLogin(policy: "keepOld" | "keepNew" | null);
|
|
918
|
+
/** Effective duplicate login policy: this instance's setting, else serverOption.auth.duplicateLogin. */
|
|
919
|
+
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
920
|
+
onAuthEvent: ((event: object) => any) | null;
|
|
894
921
|
authLogger: FileLogger | undefined;
|
|
922
|
+
set keepOldConnection(keepOld: boolean);
|
|
923
|
+
get keepOldConnection(): boolean;
|
|
924
|
+
emitAuthEvent(event: any): void;
|
|
895
925
|
send_auth_fail(peer: any, reason: any): void;
|
|
896
926
|
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
897
927
|
getAuth(id: any): Promise<any>;
|
|
@@ -930,6 +960,26 @@ declare class StringKeyProvider {
|
|
|
930
960
|
addAuth(id: any, keyStr: any, cid: any, level?: number): void;
|
|
931
961
|
}
|
|
932
962
|
|
|
963
|
+
declare class LocalKeyProvider {
|
|
964
|
+
/**
|
|
965
|
+
* @param {'idKey' | { mode: 'idKey' | 'sharedKey', key?: string, level?: number }} options
|
|
966
|
+
* A string is the mode alone.
|
|
967
|
+
*/
|
|
968
|
+
constructor(options: "idKey" | {
|
|
969
|
+
mode: "idKey" | "sharedKey";
|
|
970
|
+
key?: string;
|
|
971
|
+
level?: number;
|
|
972
|
+
});
|
|
973
|
+
mode: "idKey" | "sharedKey";
|
|
974
|
+
level: number | undefined;
|
|
975
|
+
sharedKeyHash: string | null;
|
|
976
|
+
getAuth(id: any): Promise<{
|
|
977
|
+
key: string;
|
|
978
|
+
cid: any;
|
|
979
|
+
level: number;
|
|
980
|
+
} | undefined>;
|
|
981
|
+
}
|
|
982
|
+
|
|
933
983
|
declare function checkPermission$1(remote: any): boolean;
|
|
934
984
|
/**
|
|
935
985
|
* client api call example: await io.call('reply','echo','hello')
|
|
@@ -974,9 +1024,17 @@ declare namespace sudoService {
|
|
|
974
1024
|
}
|
|
975
1025
|
|
|
976
1026
|
declare class RedisService {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1027
|
+
/**
|
|
1028
|
+
* @param {object} redisClient
|
|
1029
|
+
* @param {number} [_minLevel=200]
|
|
1030
|
+
* @param {{ requireAuth?: boolean }} [options] requireAuth (default true): allow Boho-authenticated remotes only.
|
|
1031
|
+
*/
|
|
1032
|
+
constructor(redisClient: object, _minLevel?: number, options?: {
|
|
1033
|
+
requireAuth?: boolean;
|
|
1034
|
+
});
|
|
1035
|
+
redisClient: object;
|
|
1036
|
+
minLevel: number;
|
|
1037
|
+
requireAuth: boolean;
|
|
980
1038
|
commands: string[];
|
|
981
1039
|
checkPermission(remote: any, req: any): boolean;
|
|
982
1040
|
call(remote: any, req: any): Promise<void>;
|
|
@@ -991,4 +1049,4 @@ declare function getPayloadFromSignalPack(signalPack: any): any;
|
|
|
991
1049
|
|
|
992
1050
|
declare const version: string;
|
|
993
1051
|
|
|
994
|
-
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 };
|
|
1052
|
+
export { BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, LocalKeyProvider, PAYLOAD_TYPE, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS, Server, StringKeyProvider, delay, getIPv4HexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };
|
package/dist/node/iosignal.d.ts
CHANGED
|
@@ -334,7 +334,9 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
334
334
|
stop(): void;
|
|
335
335
|
/**
|
|
336
336
|
* Permanently destroys the instance, cleaning up all resources.
|
|
337
|
-
* 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'.
|
|
338
340
|
*/
|
|
339
341
|
destroy(): void;
|
|
340
342
|
/**
|
|
@@ -417,6 +419,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
417
419
|
getEncryptionMode(): boolean;
|
|
418
420
|
/**
|
|
419
421
|
* Sends data with encryption based on the encryption mode.
|
|
422
|
+
* Like an unconnected socket, a destroyed instance silently drops the data.
|
|
420
423
|
* @param {Buffer} data - The data buffer to send.
|
|
421
424
|
* @param {boolean} [useEncryption] - Optional. Force encryption or not. If undefined, uses default policy.
|
|
422
425
|
*/
|
|
@@ -785,6 +788,8 @@ declare class Manager {
|
|
|
785
788
|
subscribe(chArr: any, remote: any): any;
|
|
786
789
|
unsubscribe(chArr: any, remote: any): void;
|
|
787
790
|
monitor(): void;
|
|
791
|
+
anonymousCidRandom(size: any): Buffer<ArrayBuffer>;
|
|
792
|
+
issueAnonymousCid(): string | null;
|
|
788
793
|
closeRemoteByCId(cid: any): 0 | 1;
|
|
789
794
|
close(): void;
|
|
790
795
|
}
|
|
@@ -792,12 +797,16 @@ declare class Manager {
|
|
|
792
797
|
declare class Server extends EventEmitter$1<[never]> {
|
|
793
798
|
/**
|
|
794
799
|
* @param {object} options Server configuration.
|
|
800
|
+
* options.localAuth: login without a key list, for local testing. 'idKey' (key = ID) or
|
|
801
|
+
* { mode: 'idKey' | 'sharedKey', key, level } (see LocalKeyProvider); the CID is the ID.
|
|
802
|
+
* Cannot be combined with authManager.
|
|
795
803
|
* @param {any} [authManager] Optional authentication manager.
|
|
796
804
|
*/
|
|
797
805
|
constructor(options: object, authManager?: any);
|
|
798
806
|
security: any;
|
|
799
807
|
serviceNames: Set<any>;
|
|
800
|
-
|
|
808
|
+
services: Map<any, any>;
|
|
809
|
+
wss: any;
|
|
801
810
|
port: number | null;
|
|
802
811
|
congPort: number | null;
|
|
803
812
|
httpServer: any;
|
|
@@ -876,6 +885,7 @@ declare namespace serverOption {
|
|
|
876
885
|
}
|
|
877
886
|
export namespace auth_1 {
|
|
878
887
|
let delay_auth_fail: number;
|
|
888
|
+
let duplicateLogin: string;
|
|
879
889
|
}
|
|
880
890
|
export { auth_1 as auth };
|
|
881
891
|
export let membersOnly: boolean;
|
|
@@ -888,10 +898,30 @@ declare function getLocalAddress(): string;
|
|
|
888
898
|
declare function delay(ms: any): Promise<any>;
|
|
889
899
|
|
|
890
900
|
declare class BohoAuth {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
901
|
+
/**
|
|
902
|
+
* @param {object} keyProvider
|
|
903
|
+
* @param {{ duplicateLogin?: 'keepOld' | 'keepNew', onAuthEvent?: (event: object) => any }} [options]
|
|
904
|
+
* duplicateLogin: unset follows serverOption.auth.duplicateLogin (default 'keepNew').
|
|
905
|
+
* onAuthEvent: called with { type, did, cid, uid, ip, oldIp, socketType, oldSocketType, reason, at }
|
|
906
|
+
* for 'replaced' (keepNew evicted the old connection) and 'duplicate_rejected' (keepOld).
|
|
907
|
+
* socketType/oldSocketType are 'websocket' or 'congsocket'.
|
|
908
|
+
* Errors and rejected promises are logged and never affect authentication.
|
|
909
|
+
*/
|
|
910
|
+
constructor(keyProvider: object, options?: {
|
|
911
|
+
duplicateLogin?: "keepOld" | "keepNew";
|
|
912
|
+
onAuthEvent?: (event: object) => any;
|
|
913
|
+
});
|
|
914
|
+
keyProvider: object;
|
|
915
|
+
_duplicateLogin: any;
|
|
916
|
+
/** @param {'keepOld' | 'keepNew' | null} policy null returns to the serverOption default. */
|
|
917
|
+
set duplicateLogin(policy: "keepOld" | "keepNew" | null);
|
|
918
|
+
/** Effective duplicate login policy: this instance's setting, else serverOption.auth.duplicateLogin. */
|
|
919
|
+
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
920
|
+
onAuthEvent: ((event: object) => any) | null;
|
|
894
921
|
authLogger: FileLogger | undefined;
|
|
922
|
+
set keepOldConnection(keepOld: boolean);
|
|
923
|
+
get keepOldConnection(): boolean;
|
|
924
|
+
emitAuthEvent(event: any): void;
|
|
895
925
|
send_auth_fail(peer: any, reason: any): void;
|
|
896
926
|
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
897
927
|
getAuth(id: any): Promise<any>;
|
|
@@ -930,6 +960,26 @@ declare class StringKeyProvider {
|
|
|
930
960
|
addAuth(id: any, keyStr: any, cid: any, level?: number): void;
|
|
931
961
|
}
|
|
932
962
|
|
|
963
|
+
declare class LocalKeyProvider {
|
|
964
|
+
/**
|
|
965
|
+
* @param {'idKey' | { mode: 'idKey' | 'sharedKey', key?: string, level?: number }} options
|
|
966
|
+
* A string is the mode alone.
|
|
967
|
+
*/
|
|
968
|
+
constructor(options: "idKey" | {
|
|
969
|
+
mode: "idKey" | "sharedKey";
|
|
970
|
+
key?: string;
|
|
971
|
+
level?: number;
|
|
972
|
+
});
|
|
973
|
+
mode: "idKey" | "sharedKey";
|
|
974
|
+
level: number | undefined;
|
|
975
|
+
sharedKeyHash: string | null;
|
|
976
|
+
getAuth(id: any): Promise<{
|
|
977
|
+
key: string;
|
|
978
|
+
cid: any;
|
|
979
|
+
level: number;
|
|
980
|
+
} | undefined>;
|
|
981
|
+
}
|
|
982
|
+
|
|
933
983
|
declare function checkPermission$1(remote: any): boolean;
|
|
934
984
|
/**
|
|
935
985
|
* client api call example: await io.call('reply','echo','hello')
|
|
@@ -974,9 +1024,17 @@ declare namespace sudoService {
|
|
|
974
1024
|
}
|
|
975
1025
|
|
|
976
1026
|
declare class RedisService {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1027
|
+
/**
|
|
1028
|
+
* @param {object} redisClient
|
|
1029
|
+
* @param {number} [_minLevel=200]
|
|
1030
|
+
* @param {{ requireAuth?: boolean }} [options] requireAuth (default true): allow Boho-authenticated remotes only.
|
|
1031
|
+
*/
|
|
1032
|
+
constructor(redisClient: object, _minLevel?: number, options?: {
|
|
1033
|
+
requireAuth?: boolean;
|
|
1034
|
+
});
|
|
1035
|
+
redisClient: object;
|
|
1036
|
+
minLevel: number;
|
|
1037
|
+
requireAuth: boolean;
|
|
980
1038
|
commands: string[];
|
|
981
1039
|
checkPermission(remote: any, req: any): boolean;
|
|
982
1040
|
call(remote: any, req: any): Promise<void>;
|
|
@@ -991,4 +1049,4 @@ declare function getPayloadFromSignalPack(signalPack: any): any;
|
|
|
991
1049
|
|
|
992
1050
|
declare const version: string;
|
|
993
1051
|
|
|
994
|
-
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 };
|
|
1052
|
+
export { BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, LocalKeyProvider, PAYLOAD_TYPE, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS, Server, StringKeyProvider, delay, getIPv4HexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };
|