iosignal 8.0.0 → 9.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 +61 -0
- package/README.md +68 -0
- package/dist/browser/esm/io.d.ts +6 -8
- package/dist/browser/esm/io.js +5 -5
- package/dist/browser/esm/io.js.map +1 -1
- package/dist/browser/iife/io.js +5 -5
- package/dist/browser/iife/io.js.map +1 -1
- package/dist/node/iosignal.cjs +992 -509
- package/dist/node/iosignal.d.cts +312 -114
- package/dist/node/iosignal.d.ts +312 -114
- package/dist/node/iosignal.js +989 -511
- package/dist/types/client/IOCore.d.ts +6 -9
- package/dist/types/common/constants.d.ts +2 -2
- package/package.json +2 -3
- package/dist/types/common/quotaTable.d.ts +0 -47
package/dist/node/iosignal.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ import Boho__default from 'boho';
|
|
|
3
3
|
export { default as Boho } from 'boho';
|
|
4
4
|
import * as buffer from 'buffer';
|
|
5
5
|
import { EventEmitter } from 'eventemitter3';
|
|
6
|
+
import * as stream from 'stream';
|
|
6
7
|
import { Transform } from 'stream';
|
|
7
8
|
import EventEmitter$1 from 'events';
|
|
8
9
|
export { default as MBP } from 'meta-buffer-pack';
|
|
@@ -87,7 +88,7 @@ type IOMsg = {
|
|
|
87
88
|
SERVER_READY: number;
|
|
88
89
|
CID_REQ: number;
|
|
89
90
|
CID_RES: number;
|
|
90
|
-
|
|
91
|
+
QUOTA: number;
|
|
91
92
|
AUTH_CLEAR: number;
|
|
92
93
|
SERVER_REDIRECT: number;
|
|
93
94
|
LOOP: number;
|
|
@@ -123,10 +124,10 @@ declare namespace IOMsg {
|
|
|
123
124
|
export { CID_REQ_1 as CID_REQ };
|
|
124
125
|
let CID_RES_1: number;
|
|
125
126
|
export { CID_RES_1 as CID_RES };
|
|
126
|
-
export let QUOTA_LEVEL: number;
|
|
127
127
|
let AUTH_CLEAR_1: number;
|
|
128
128
|
export { AUTH_CLEAR_1 as AUTH_CLEAR };
|
|
129
129
|
export let SERVER_REDIRECT: number;
|
|
130
|
+
export let QUOTA: number;
|
|
130
131
|
export let LOOP: number;
|
|
131
132
|
export let ECHO: number;
|
|
132
133
|
export let PING: number;
|
|
@@ -283,15 +284,13 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
283
284
|
*/
|
|
284
285
|
mid: number;
|
|
285
286
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
|
|
289
|
-
level: number;
|
|
290
|
-
/**
|
|
291
|
-
* Quota table for current level.
|
|
292
|
-
* @type {object}
|
|
287
|
+
* This connection's quota as told by the server (QUOTA). maxMessageBytes: largest message
|
|
288
|
+
* send() passes on; null: no limit (also until the server tells).
|
|
289
|
+
* @type {{ maxMessageBytes: number | null }}
|
|
293
290
|
*/
|
|
294
|
-
quota:
|
|
291
|
+
quota: {
|
|
292
|
+
maxMessageBytes: number | null;
|
|
293
|
+
};
|
|
295
294
|
/**
|
|
296
295
|
* Server settings.
|
|
297
296
|
* @type {object}
|
|
@@ -595,10 +594,20 @@ type Buffer$1 = Boho.Buffer;
|
|
|
595
594
|
|
|
596
595
|
declare function pack(payload: any): Buffer<ArrayBufferLike>;
|
|
597
596
|
declare class CongRx extends Transform {
|
|
597
|
+
/**
|
|
598
|
+
* @param {import('stream').TransformOptions & { maxFrameSize?: number }} [options] Stream options.
|
|
599
|
+
* maxFrameSize: largest payload to buffer (default unlimited). A larger frame is
|
|
600
|
+
* skipped without buffering and reported by an 'oversize' event (payloadSize).
|
|
601
|
+
*/
|
|
602
|
+
constructor(options?: stream.TransformOptions & {
|
|
603
|
+
maxFrameSize?: number;
|
|
604
|
+
});
|
|
598
605
|
buffer: Buffer<ArrayBuffer>;
|
|
599
606
|
frames: any[];
|
|
600
607
|
rxi: number;
|
|
601
608
|
rxi_zero: number;
|
|
609
|
+
maxFrameSize: number;
|
|
610
|
+
skipBytes: number;
|
|
602
611
|
_transform(chunk: any, encoding: any, callback: any): void;
|
|
603
612
|
addData(chunk: any): void;
|
|
604
613
|
parse(): void;
|
|
@@ -630,26 +639,42 @@ declare class FileLogger {
|
|
|
630
639
|
declare class Metrics {
|
|
631
640
|
constructor(manager: any);
|
|
632
641
|
manager: any;
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
rxBytes: number[];
|
|
638
|
-
unixTime: number[];
|
|
639
|
-
period: number;
|
|
640
|
-
};
|
|
641
|
-
tickId: number;
|
|
642
|
+
previous: {
|
|
643
|
+
time: number;
|
|
644
|
+
counters: any;
|
|
645
|
+
} | null;
|
|
642
646
|
close(): void;
|
|
643
|
-
|
|
647
|
+
snapshot(): {
|
|
648
|
+
at: number;
|
|
649
|
+
connections: {
|
|
650
|
+
total: any;
|
|
651
|
+
authenticated: number;
|
|
652
|
+
anonymous: number;
|
|
653
|
+
websocket: number;
|
|
654
|
+
tcp: number;
|
|
655
|
+
};
|
|
656
|
+
channels: any;
|
|
657
|
+
retained: {
|
|
658
|
+
channel: any;
|
|
659
|
+
bytes: any;
|
|
660
|
+
};
|
|
661
|
+
counters: any;
|
|
662
|
+
memory: {
|
|
663
|
+
rss: number;
|
|
664
|
+
heapUsed: number;
|
|
665
|
+
};
|
|
666
|
+
};
|
|
667
|
+
summaryLine(now?: number): string;
|
|
668
|
+
oneline(): {
|
|
644
669
|
lastSSID: any;
|
|
645
670
|
remotes: any;
|
|
646
671
|
channels: any;
|
|
647
672
|
txBytes: any;
|
|
648
673
|
rxBytes: any;
|
|
649
674
|
};
|
|
650
|
-
getRemotes(
|
|
651
|
-
getCIdList(
|
|
652
|
-
getChannelList(
|
|
675
|
+
getRemotes(): string[];
|
|
676
|
+
getCIdList(): any[];
|
|
677
|
+
getChannelList(): any[];
|
|
653
678
|
getSubscribers(ch: any): any[];
|
|
654
679
|
getRemoteByCId(cid: any, mode?: number): {
|
|
655
680
|
ip: any;
|
|
@@ -667,7 +692,6 @@ declare class Metrics {
|
|
|
667
692
|
isAuth?: undefined;
|
|
668
693
|
encMode?: undefined;
|
|
669
694
|
channels?: undefined;
|
|
670
|
-
set?: undefined;
|
|
671
695
|
retain?: undefined;
|
|
672
696
|
result?: undefined;
|
|
673
697
|
} | {
|
|
@@ -686,7 +710,6 @@ declare class Metrics {
|
|
|
686
710
|
isAuth?: undefined;
|
|
687
711
|
encMode?: undefined;
|
|
688
712
|
channels?: undefined;
|
|
689
|
-
set?: undefined;
|
|
690
713
|
retain?: undefined;
|
|
691
714
|
result?: undefined;
|
|
692
715
|
} | {
|
|
@@ -705,14 +728,12 @@ declare class Metrics {
|
|
|
705
728
|
txBytes?: undefined;
|
|
706
729
|
rxBytes?: undefined;
|
|
707
730
|
channels?: undefined;
|
|
708
|
-
set?: undefined;
|
|
709
731
|
retain?: undefined;
|
|
710
732
|
result?: undefined;
|
|
711
733
|
} | {
|
|
712
734
|
ip: any;
|
|
713
735
|
uptime: number;
|
|
714
736
|
channels: any[];
|
|
715
|
-
set: any[];
|
|
716
737
|
retain: any[];
|
|
717
738
|
id?: undefined;
|
|
718
739
|
ssid?: undefined;
|
|
@@ -744,7 +765,6 @@ declare class Metrics {
|
|
|
744
765
|
isAuth?: undefined;
|
|
745
766
|
encMode?: undefined;
|
|
746
767
|
channels?: undefined;
|
|
747
|
-
set?: undefined;
|
|
748
768
|
retain?: undefined;
|
|
749
769
|
} | undefined;
|
|
750
770
|
}
|
|
@@ -752,16 +772,31 @@ declare class Metrics {
|
|
|
752
772
|
declare class Manager {
|
|
753
773
|
constructor(server: any, authManager: any);
|
|
754
774
|
server: any;
|
|
755
|
-
pingPeriod:
|
|
756
|
-
pingGrace:
|
|
757
|
-
|
|
758
|
-
|
|
775
|
+
pingPeriod: any;
|
|
776
|
+
pingGrace: any;
|
|
777
|
+
counters: {
|
|
778
|
+
rxMessages: number;
|
|
779
|
+
rxBytes: number;
|
|
780
|
+
txMessages: number;
|
|
781
|
+
txBytes: number;
|
|
782
|
+
publishes: number;
|
|
783
|
+
deliveryAttempts: number;
|
|
784
|
+
quotaExcluded: number;
|
|
785
|
+
oversizeRejected: number;
|
|
786
|
+
rateLimited: number;
|
|
787
|
+
peerRxLimitSkipped: number;
|
|
788
|
+
};
|
|
759
789
|
authManager: any;
|
|
760
790
|
connectionLogger: FileLogger | undefined;
|
|
761
791
|
attackLogger: FileLogger | undefined;
|
|
762
792
|
remotes: Set<any>;
|
|
763
793
|
cid2remote: Map<any, any>;
|
|
794
|
+
accountConnectionCounts: Map<any, any>;
|
|
764
795
|
retain_messages: Map<any, any>;
|
|
796
|
+
retain_owner: Map<any, any>;
|
|
797
|
+
retainOwners: Map<any, any>;
|
|
798
|
+
retainExpiry: Map<any, any>;
|
|
799
|
+
retainBytes: number;
|
|
765
800
|
channel_map: Map<any, any>;
|
|
766
801
|
CHANNEL_PREFIX: string;
|
|
767
802
|
CID_PREFIX: string;
|
|
@@ -774,7 +809,13 @@ declare class Manager {
|
|
|
774
809
|
pingTickMs: number;
|
|
775
810
|
heartbeatStopped: boolean;
|
|
776
811
|
pingIntervalID: NodeJS.Timeout;
|
|
777
|
-
|
|
812
|
+
statsIntervalID: NodeJS.Timeout | undefined;
|
|
813
|
+
get retainOptions(): any;
|
|
814
|
+
get quotas(): any;
|
|
815
|
+
get anonymousQuota(): any;
|
|
816
|
+
accountConnections(uid: any): any;
|
|
817
|
+
addAccountConnection(remote: any, uid: any): void;
|
|
818
|
+
removeAccountConnection(remote: any): void;
|
|
778
819
|
heartbeatTick(): void;
|
|
779
820
|
addRemote(socket: any, req: any): void;
|
|
780
821
|
removeRemote(remote: any): void;
|
|
@@ -785,9 +826,17 @@ declare class Manager {
|
|
|
785
826
|
adminSignal(cid: any, message: any): "no cid" | undefined;
|
|
786
827
|
serverSignalTo(tag: any, ...args: any[]): "no cid" | undefined;
|
|
787
828
|
sender(tag: any, remote: any, message: any): (string | number)[];
|
|
829
|
+
retainFits(message: any, freed: any, ownerBytes: any, budget: any): boolean;
|
|
830
|
+
retainCopy(message: any): Buffer<ArrayBuffer>;
|
|
831
|
+
storeCidRetain(key: any, message: any, remote: any): void;
|
|
832
|
+
retainOwner(key: any): any;
|
|
833
|
+
storeChannelRetain(tag: any, message: any, remote: any): void;
|
|
834
|
+
orphanChannelRetains(remote: any): void;
|
|
835
|
+
expireChannelRetains(now?: number): void;
|
|
836
|
+
dropChannelRetain(tag: any): void;
|
|
837
|
+
releaseChannelRetain(tag: any, size: any): void;
|
|
788
838
|
subscribe(chArr: any, remote: any): any;
|
|
789
839
|
unsubscribe(chArr: any, remote: any): void;
|
|
790
|
-
monitor(): void;
|
|
791
840
|
anonymousCidRandom(size: any): Buffer<ArrayBuffer>;
|
|
792
841
|
issueAnonymousCid(): string | null;
|
|
793
842
|
closeRemoteByCId(cid: any): 0 | 1;
|
|
@@ -797,15 +846,51 @@ declare class Manager {
|
|
|
797
846
|
declare class Server extends EventEmitter$1<[never]> {
|
|
798
847
|
/**
|
|
799
848
|
* @param {object} options Server configuration.
|
|
849
|
+
* options.localAuth: login without a key list, for local testing. 'idKey' (key = ID) or
|
|
850
|
+
* { mode: 'idKey' | 'sharedKey', key, role, quota } (see LocalKeyProvider); the CID is the ID.
|
|
851
|
+
* Cannot be combined with authManager.
|
|
852
|
+
* Every other setting is this Server's own: given here, else the serverOption default, which is
|
|
853
|
+
* never modified. Nested groups (security, retain, quotas) are merged over their defaults;
|
|
854
|
+
* unknown or removed names are errors.
|
|
855
|
+
* options.heartbeatInterval: ms between liveness checks (default 50000).
|
|
856
|
+
* options.heartbeatGrace: extra ms a peer has to answer before it is closed (default 5000).
|
|
857
|
+
* options.trustProxy: when X-Forwarded-For/-Proto are used. 'private' (default) only from a
|
|
858
|
+
* loopback/private peer, true always, false never, or N trusted proxy hops.
|
|
859
|
+
* options.maxPayload: largest WebSocket message and CongSocket frame in bytes (default 32 MiB).
|
|
860
|
+
* options.maxBufferedBytes: close a peer whose unsent data exceeds this (default 64 MiB).
|
|
861
|
+
* options.membersOnly: drop signals from connections that are not authenticated.
|
|
862
|
+
* options.logMessages: log each received message after decryption: type and tag, never the payload.
|
|
863
|
+
* options.logStats: print a one-line summary every N ms (>= 1000; 0 = off); see stats().
|
|
864
|
+
* options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries }.
|
|
865
|
+
* options.retain: retained message limits, see serverOption.retain; adjustable later on server.retain.
|
|
866
|
+
* options.quotas: named quota profiles { name: { maxMessageBytes, fanout, msgPerSec, bytesPerSec,
|
|
867
|
+
* maxConnections } }, merged over serverOption.quotas; always enforced, null is unlimited.
|
|
868
|
+
* Adjustable later on server.quotas. The client is told its maxMessageBytes.
|
|
869
|
+
* options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
|
|
870
|
+
* options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
|
|
871
|
+
* manager's own policy without changing it, so an auth manager can be shared between servers.
|
|
872
|
+
* A failed listen (e.g. EADDRINUSE) is emitted as 'error'.
|
|
800
873
|
* @param {any} [authManager] Optional authentication manager.
|
|
801
874
|
*/
|
|
802
875
|
constructor(options: object, authManager?: any);
|
|
803
876
|
security: any;
|
|
877
|
+
retain: any;
|
|
878
|
+
quotas: {};
|
|
879
|
+
anonymousQuota: any;
|
|
880
|
+
heartbeatInterval: any;
|
|
881
|
+
heartbeatGrace: any;
|
|
882
|
+
maxPayload: any;
|
|
883
|
+
maxBufferedBytes: any;
|
|
884
|
+
logMessages: boolean;
|
|
885
|
+
logStats: any;
|
|
886
|
+
trustProxy: any;
|
|
887
|
+
membersOnly: boolean;
|
|
804
888
|
serviceNames: Set<any>;
|
|
805
889
|
services: Map<any, any>;
|
|
806
|
-
wss:
|
|
890
|
+
wss: any;
|
|
807
891
|
port: number | null;
|
|
808
892
|
congPort: number | null;
|
|
893
|
+
duplicateLogin: any;
|
|
809
894
|
httpServer: any;
|
|
810
895
|
wsPath: any;
|
|
811
896
|
manager: Manager;
|
|
@@ -814,6 +899,45 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
814
899
|
startWSServer(): void;
|
|
815
900
|
startCongServer(): void;
|
|
816
901
|
congServer: any;
|
|
902
|
+
onListenerError(name: any, err: any): void;
|
|
903
|
+
/**
|
|
904
|
+
* Current server state, for monitoring. counters are cumulative since the server started
|
|
905
|
+
* (rates are the reader's to compute from two snapshots). Enumerates connections once.
|
|
906
|
+
* @returns {{ at: number, connections: { total: number, authenticated: number, anonymous: number,
|
|
907
|
+
* websocket: number, tcp: number }, channels: number, retained: { channel: number, bytes: number },
|
|
908
|
+
* counters: { rxMessages: number, rxBytes: number, txMessages: number, txBytes: number,
|
|
909
|
+
* publishes: number, deliveryAttempts: number, quotaExcluded: number, peerRxLimitSkipped: number },
|
|
910
|
+
* memory: { rss: number, heapUsed: number } }}
|
|
911
|
+
*/
|
|
912
|
+
stats(): {
|
|
913
|
+
at: number;
|
|
914
|
+
connections: {
|
|
915
|
+
total: number;
|
|
916
|
+
authenticated: number;
|
|
917
|
+
anonymous: number;
|
|
918
|
+
websocket: number;
|
|
919
|
+
tcp: number;
|
|
920
|
+
};
|
|
921
|
+
channels: number;
|
|
922
|
+
retained: {
|
|
923
|
+
channel: number;
|
|
924
|
+
bytes: number;
|
|
925
|
+
};
|
|
926
|
+
counters: {
|
|
927
|
+
rxMessages: number;
|
|
928
|
+
rxBytes: number;
|
|
929
|
+
txMessages: number;
|
|
930
|
+
txBytes: number;
|
|
931
|
+
publishes: number;
|
|
932
|
+
deliveryAttempts: number;
|
|
933
|
+
quotaExcluded: number;
|
|
934
|
+
peerRxLimitSkipped: number;
|
|
935
|
+
};
|
|
936
|
+
memory: {
|
|
937
|
+
rss: number;
|
|
938
|
+
heapUsed: number;
|
|
939
|
+
};
|
|
940
|
+
};
|
|
817
941
|
/**
|
|
818
942
|
* RPC service register.
|
|
819
943
|
* service: service_name <string>
|
|
@@ -828,17 +952,75 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
828
952
|
}
|
|
829
953
|
|
|
830
954
|
declare namespace serverOption {
|
|
831
|
-
export let
|
|
832
|
-
export let
|
|
833
|
-
export let
|
|
834
|
-
export let
|
|
835
|
-
export let
|
|
836
|
-
export let
|
|
837
|
-
export let
|
|
838
|
-
export let
|
|
839
|
-
export
|
|
840
|
-
|
|
841
|
-
|
|
955
|
+
export let heartbeatInterval: number;
|
|
956
|
+
export let heartbeatGrace: number;
|
|
957
|
+
export let maxPayload: number;
|
|
958
|
+
export let trustProxy: string;
|
|
959
|
+
export let maxBufferedBytes: number;
|
|
960
|
+
export let membersOnly: boolean;
|
|
961
|
+
export let logMessages: boolean;
|
|
962
|
+
export let logStats: number;
|
|
963
|
+
export namespace security {
|
|
964
|
+
let maxClockSkewMs: number;
|
|
965
|
+
let authChallengeMaxAgeMs: number;
|
|
966
|
+
let maxReplayEntries: number;
|
|
967
|
+
}
|
|
968
|
+
export namespace quotas {
|
|
969
|
+
namespace anonymous {
|
|
970
|
+
let maxMessageBytes: number;
|
|
971
|
+
let fanout: number;
|
|
972
|
+
let msgPerSec: number;
|
|
973
|
+
let bytesPerSec: number;
|
|
974
|
+
let maxConnections: null;
|
|
975
|
+
}
|
|
976
|
+
namespace basic {
|
|
977
|
+
let maxMessageBytes_1: number;
|
|
978
|
+
export { maxMessageBytes_1 as maxMessageBytes };
|
|
979
|
+
let fanout_1: number;
|
|
980
|
+
export { fanout_1 as fanout };
|
|
981
|
+
let msgPerSec_1: number;
|
|
982
|
+
export { msgPerSec_1 as msgPerSec };
|
|
983
|
+
let bytesPerSec_1: number;
|
|
984
|
+
export { bytesPerSec_1 as bytesPerSec };
|
|
985
|
+
let maxConnections_1: number;
|
|
986
|
+
export { maxConnections_1 as maxConnections };
|
|
987
|
+
}
|
|
988
|
+
namespace pro {
|
|
989
|
+
let maxMessageBytes_2: number;
|
|
990
|
+
export { maxMessageBytes_2 as maxMessageBytes };
|
|
991
|
+
let fanout_2: number;
|
|
992
|
+
export { fanout_2 as fanout };
|
|
993
|
+
let msgPerSec_2: number;
|
|
994
|
+
export { msgPerSec_2 as msgPerSec };
|
|
995
|
+
let bytesPerSec_2: number;
|
|
996
|
+
export { bytesPerSec_2 as bytesPerSec };
|
|
997
|
+
let maxConnections_2: number;
|
|
998
|
+
export { maxConnections_2 as maxConnections };
|
|
999
|
+
}
|
|
1000
|
+
namespace unlimited {
|
|
1001
|
+
let maxMessageBytes_3: null;
|
|
1002
|
+
export { maxMessageBytes_3 as maxMessageBytes };
|
|
1003
|
+
let fanout_3: null;
|
|
1004
|
+
export { fanout_3 as fanout };
|
|
1005
|
+
let msgPerSec_3: null;
|
|
1006
|
+
export { msgPerSec_3 as msgPerSec };
|
|
1007
|
+
let bytesPerSec_3: null;
|
|
1008
|
+
export { bytesPerSec_3 as bytesPerSec };
|
|
1009
|
+
let maxConnections_3: null;
|
|
1010
|
+
export { maxConnections_3 as maxConnections };
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
export let anonymousQuota: string;
|
|
1014
|
+
export namespace retain {
|
|
1015
|
+
let enabled: boolean;
|
|
1016
|
+
let limitSize: number;
|
|
1017
|
+
let limitCounter: number;
|
|
1018
|
+
let tagsPerOwner: number;
|
|
1019
|
+
let bytesPerOwner: number;
|
|
1020
|
+
let anonymousGraceMs: number;
|
|
1021
|
+
let bytesPerConnection: number;
|
|
1022
|
+
let bytesTotal: number;
|
|
1023
|
+
}
|
|
842
1024
|
export namespace fileLogger {
|
|
843
1025
|
namespace connection {
|
|
844
1026
|
let use: boolean;
|
|
@@ -857,77 +1039,25 @@ declare namespace serverOption {
|
|
|
857
1039
|
export { path_2 as path };
|
|
858
1040
|
}
|
|
859
1041
|
}
|
|
860
|
-
export namespace
|
|
861
|
-
let
|
|
862
|
-
let
|
|
863
|
-
let trafficRate: boolean;
|
|
864
|
-
let disconnect: boolean;
|
|
1042
|
+
export namespace auth_1 {
|
|
1043
|
+
let failDelay: number;
|
|
1044
|
+
let duplicateLogin: string;
|
|
865
1045
|
}
|
|
866
|
-
export
|
|
867
|
-
export let adminLevel: number;
|
|
1046
|
+
export { auth_1 as auth };
|
|
868
1047
|
export namespace debug {
|
|
869
1048
|
let slow: boolean;
|
|
870
1049
|
let delay: number;
|
|
871
1050
|
let showAuthInfo: boolean;
|
|
872
1051
|
}
|
|
873
|
-
export namespace retain {
|
|
874
|
-
let isAvailable: boolean;
|
|
875
|
-
let limitSize: number;
|
|
876
|
-
let limitCounter: number;
|
|
877
|
-
}
|
|
878
|
-
export namespace security {
|
|
879
|
-
let maxClockSkewMs: number;
|
|
880
|
-
let authChallengeMaxAgeMs: number;
|
|
881
|
-
let maxReplayEntries: number;
|
|
882
|
-
}
|
|
883
|
-
export namespace auth_1 {
|
|
884
|
-
let delay_auth_fail: number;
|
|
885
|
-
let duplicateLogin: string;
|
|
886
|
-
}
|
|
887
|
-
export { auth_1 as auth };
|
|
888
|
-
export let membersOnly: boolean;
|
|
889
1052
|
}
|
|
890
1053
|
|
|
891
1054
|
declare function isPrivateIP(ip: any): boolean;
|
|
1055
|
+
declare function getIPv6PrefixHexString(ip: any): string | null;
|
|
892
1056
|
declare function numberWithCommas(x: any): any;
|
|
893
1057
|
declare function getIPv4HexString(ipStr: any): string;
|
|
894
1058
|
declare function getLocalAddress(): string;
|
|
895
1059
|
declare function delay(ms: any): Promise<any>;
|
|
896
1060
|
|
|
897
|
-
declare class BohoAuth {
|
|
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;
|
|
918
|
-
authLogger: FileLogger | undefined;
|
|
919
|
-
set keepOldConnection(keepOld: boolean);
|
|
920
|
-
get keepOldConnection(): boolean;
|
|
921
|
-
emitAuthEvent(event: any): void;
|
|
922
|
-
send_auth_fail(peer: any, reason: any): void;
|
|
923
|
-
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
924
|
-
getAuth(id: any): Promise<any>;
|
|
925
|
-
getAuthIdList(): Promise<any>;
|
|
926
|
-
addAuth(id: any, keyStr: any, cid: any, level?: number): Promise<any>;
|
|
927
|
-
delAuth(id: any): Promise<any>;
|
|
928
|
-
save(): Promise<any>;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
1061
|
declare class FileKeyProvider {
|
|
932
1062
|
constructor(_path: any);
|
|
933
1063
|
AUTH: Map<any, any>;
|
|
@@ -936,7 +1066,7 @@ declare class FileKeyProvider {
|
|
|
936
1066
|
loadAuthInfoFile_JSON(path: any): void;
|
|
937
1067
|
getAuth(id: any): Promise<any>;
|
|
938
1068
|
getAuthIdList(): Promise<any[]>;
|
|
939
|
-
addAuth(id: any, keyStr: any, cid: any,
|
|
1069
|
+
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): void;
|
|
940
1070
|
}
|
|
941
1071
|
|
|
942
1072
|
declare class RedisKeyProvider {
|
|
@@ -944,7 +1074,7 @@ declare class RedisKeyProvider {
|
|
|
944
1074
|
redis: any;
|
|
945
1075
|
getAuth(id: any): Promise<any>;
|
|
946
1076
|
getAuthIdList(): Promise<any>;
|
|
947
|
-
addAuth(id: any, keyStr: any, cid
|
|
1077
|
+
addAuth(id: any, keyStr: any, cid: string | undefined, role: any, quota: any): Promise<any>;
|
|
948
1078
|
delAuth(id: any): Promise<any>;
|
|
949
1079
|
save(id: any): Promise<any>;
|
|
950
1080
|
}
|
|
@@ -954,7 +1084,31 @@ declare class StringKeyProvider {
|
|
|
954
1084
|
AUTH: Map<any, any>;
|
|
955
1085
|
getAuth(id: any): Promise<any>;
|
|
956
1086
|
getAuthIdList(): Promise<any[]>;
|
|
957
|
-
addAuth(id: any, keyStr: any, cid: any,
|
|
1087
|
+
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): void;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
declare class LocalKeyProvider {
|
|
1091
|
+
/**
|
|
1092
|
+
* @param {'idKey' | { mode: 'idKey' | 'sharedKey', key?: string,
|
|
1093
|
+
* role?: 'device' | 'service' | 'admin', quota?: string }} options
|
|
1094
|
+
* A string is the mode alone.
|
|
1095
|
+
*/
|
|
1096
|
+
constructor(options: "idKey" | {
|
|
1097
|
+
mode: "idKey" | "sharedKey";
|
|
1098
|
+
key?: string;
|
|
1099
|
+
role?: "device" | "service" | "admin";
|
|
1100
|
+
quota?: string;
|
|
1101
|
+
});
|
|
1102
|
+
mode: "idKey" | "sharedKey";
|
|
1103
|
+
role: "device" | "service" | "admin";
|
|
1104
|
+
quota: string | undefined;
|
|
1105
|
+
sharedKeyHash: string | null;
|
|
1106
|
+
getAuth(id: any): Promise<{
|
|
1107
|
+
quota?: string | undefined;
|
|
1108
|
+
key: string;
|
|
1109
|
+
cid: any;
|
|
1110
|
+
role: "device" | "service" | "admin";
|
|
1111
|
+
} | undefined>;
|
|
958
1112
|
}
|
|
959
1113
|
|
|
960
1114
|
declare function checkPermission$1(remote: any): boolean;
|
|
@@ -1003,15 +1157,12 @@ declare namespace sudoService {
|
|
|
1003
1157
|
declare class RedisService {
|
|
1004
1158
|
/**
|
|
1005
1159
|
* @param {object} redisClient
|
|
1006
|
-
* @param {
|
|
1007
|
-
*
|
|
1160
|
+
* @param {'anonymous' | 'device' | 'service' | 'admin'} [minRole='service'] lowest role allowed;
|
|
1161
|
+
* 'anonymous' allows every connection.
|
|
1008
1162
|
*/
|
|
1009
|
-
constructor(redisClient: object,
|
|
1010
|
-
requireAuth?: boolean;
|
|
1011
|
-
});
|
|
1163
|
+
constructor(redisClient: object, minRole?: "anonymous" | "device" | "service" | "admin");
|
|
1012
1164
|
redisClient: object;
|
|
1013
|
-
|
|
1014
|
-
requireAuth: boolean;
|
|
1165
|
+
minRole: "anonymous" | "device" | "service" | "admin";
|
|
1015
1166
|
commands: string[];
|
|
1016
1167
|
checkPermission(remote: any, req: any): boolean;
|
|
1017
1168
|
call(remote: any, req: any): Promise<void>;
|
|
@@ -1024,6 +1175,53 @@ declare function parsePayload(args: any): {
|
|
|
1024
1175
|
};
|
|
1025
1176
|
declare function getPayloadFromSignalPack(signalPack: any): any;
|
|
1026
1177
|
|
|
1178
|
+
/** True if the remote is authenticated with this role or a higher one ('anonymous': always). */
|
|
1179
|
+
declare function hasRole(remote: any, role: any): boolean;
|
|
1180
|
+
/** Default quota profile of a login: the account's quota, else 'basic' for a device, 'unlimited' otherwise. */
|
|
1181
|
+
declare function defaultQuota(authInfo: any, role: any): any;
|
|
1182
|
+
declare const ROLES: string[];
|
|
1183
|
+
declare class BohoAuth {
|
|
1184
|
+
/**
|
|
1185
|
+
* @param {object} keyProvider
|
|
1186
|
+
* @param {{ duplicateLogin?: 'keepOld' | 'keepNew', onAuthEvent?: (event: object) => any,
|
|
1187
|
+
* resolveQuota?: (authInfo: object, role: string) => string | Promise<string> }} [options]
|
|
1188
|
+
* duplicateLogin: unset follows serverOption.auth.duplicateLogin (default 'keepNew').
|
|
1189
|
+
* A Server's duplicateLogin option takes precedence for that Server's connections.
|
|
1190
|
+
* onAuthEvent: called with { type, did, cid, uid, ip, oldIp, socketType, oldSocketType, reason, at }
|
|
1191
|
+
* for 'replaced' (keepNew evicted the old connection) and 'duplicate_rejected' (keepOld).
|
|
1192
|
+
* socketType/oldSocketType are 'websocket' or 'congsocket'.
|
|
1193
|
+
* Errors and rejected promises are logged and never affect authentication.
|
|
1194
|
+
* resolveQuota: name of the Server quota profile for a login (default: defaultQuota), e.g. from
|
|
1195
|
+
* the account owner's plan. An unknown name fails the login.
|
|
1196
|
+
*/
|
|
1197
|
+
constructor(keyProvider: object, options?: {
|
|
1198
|
+
duplicateLogin?: "keepOld" | "keepNew";
|
|
1199
|
+
onAuthEvent?: (event: object) => any;
|
|
1200
|
+
resolveQuota?: (authInfo: object, role: string) => string | Promise<string>;
|
|
1201
|
+
});
|
|
1202
|
+
keyProvider: object;
|
|
1203
|
+
_duplicateLogin: any;
|
|
1204
|
+
/** @param {'keepOld' | 'keepNew' | null} policy null returns to the serverOption default. */
|
|
1205
|
+
set duplicateLogin(policy: "keepOld" | "keepNew" | null);
|
|
1206
|
+
/** Effective duplicate login policy: this instance's setting, else serverOption.auth.duplicateLogin. */
|
|
1207
|
+
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
1208
|
+
onAuthEvent: ((event: object) => any) | null;
|
|
1209
|
+
resolveQuota: typeof defaultQuota | ((authInfo: object, role: string) => string | Promise<string>);
|
|
1210
|
+
authLogger: FileLogger | undefined;
|
|
1211
|
+
/** Policy for a connection: its Server's duplicateLogin option, else this instance's policy. */
|
|
1212
|
+
duplicateLoginFor(peer: any): any;
|
|
1213
|
+
set keepOldConnection(keepOld: boolean);
|
|
1214
|
+
get keepOldConnection(): boolean;
|
|
1215
|
+
emitAuthEvent(event: any): void;
|
|
1216
|
+
send_auth_fail(peer: any, reason: any): void;
|
|
1217
|
+
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
1218
|
+
getAuth(id: any): Promise<any>;
|
|
1219
|
+
getAuthIdList(): Promise<any>;
|
|
1220
|
+
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): Promise<any>;
|
|
1221
|
+
delAuth(id: any): Promise<any>;
|
|
1222
|
+
save(): Promise<any>;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1027
1225
|
declare const version: string;
|
|
1028
1226
|
|
|
1029
|
-
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 };
|
|
1227
|
+
export { BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, LocalKeyProvider, PAYLOAD_TYPE, ROLES, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS, Server, StringKeyProvider, defaultQuota, delay, getIPv4HexString, getIPv6PrefixHexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, hasRole, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };
|