iosignal 8.1.0 → 9.6.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 +48 -0
- package/README.md +55 -0
- package/dist/browser/esm/io.d.ts +22 -17
- 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 +1179 -538
- package/dist/node/iosignal.d.cts +324 -127
- package/dist/node/iosignal.d.ts +324 -127
- package/dist/node/iosignal.js +1177 -540
- package/dist/types/client/IOCore.d.ts +22 -18
- 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}
|
|
@@ -306,6 +305,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
306
305
|
private _linkHandlers;
|
|
307
306
|
/** @private @type {Set<string>} */
|
|
308
307
|
private _listenTags;
|
|
308
|
+
_readyDispatch: boolean;
|
|
309
309
|
/** @private @type {Set<string>} */
|
|
310
310
|
private _manualSubscriptions;
|
|
311
311
|
/**
|
|
@@ -486,9 +486,13 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
486
486
|
*/
|
|
487
487
|
call(target: string, topic: string, ...args: any[]): Promise<any>;
|
|
488
488
|
/**
|
|
489
|
-
* Subscribes to a channel or channels.
|
|
489
|
+
* Subscribes to a channel or channels on the current, ready connection, at once.
|
|
490
|
+
* Call it from a ready handler (it runs on every connect) or later while ready; it is not
|
|
491
|
+
* repeated after a reconnect. To subscribe before connecting, or for every connection
|
|
492
|
+
* without a ready handler, use listen() or link().
|
|
490
493
|
* @param {string} tag - The tag(s) of the channel(s) to subscribe to (comma-separated).
|
|
491
494
|
* @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
|
|
495
|
+
* @throws {Error} If the connection is not ready (after destroy() it is a no-op instead).
|
|
492
496
|
*/
|
|
493
497
|
subscribe(tag: string): void;
|
|
494
498
|
/**
|
|
@@ -506,24 +510,26 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
506
510
|
* Convenience API for simple clients (for example, CLI tools): register a
|
|
507
511
|
* tag handler once and remember its subscription in channels. For subscription
|
|
508
512
|
* tags, register before connection readiness; the CID-ready flow subscribes on initial connection
|
|
509
|
-
* and again after reconnect,
|
|
513
|
+
* and again after reconnect, before 'ready' is emitted, so a ready handler may signal at once.
|
|
510
514
|
* This does not send a subscription immediately, even if already ready.
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
515
|
+
* Do not call listen() inside a ready handler; it throws there, for any tag: a subscription tag
|
|
516
|
+
* would be subscribed only after the next reconnect, and a handler registered on every
|
|
517
|
+
* connect runs once more after each reconnect. In a ready handler use on() and subscribe();
|
|
518
|
+
* for dynamic subscriptions use link().
|
|
519
|
+
* Direct signals need no subscription: use listen('@') during setup, or on('@'), for all
|
|
520
|
+
* direct signals, or '@topic' for an exact topic.
|
|
516
521
|
* Dispatch is synchronous: '@' first, then '@topic' when tag is not '@'.
|
|
517
522
|
* Returning false does not cancel dispatch; a thrown error interrupts it.
|
|
518
523
|
* @param {string} tag - The tag to listen on.
|
|
519
524
|
* @param {Function} handler - The callback function to handle the signal.
|
|
520
525
|
* @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
|
|
526
|
+
* @throws {Error} If called inside a ready handler.
|
|
521
527
|
*/
|
|
522
528
|
listen(tag: string, handler: Function): void;
|
|
523
529
|
/**
|
|
524
530
|
* Associates handlers with a local component for scoped teardown.
|
|
525
|
-
* Direct tags (@ or @topic) only register local handlers. Other tags
|
|
526
|
-
*
|
|
531
|
+
* Direct tags (@ or @topic) only register local handlers. Other tags are remembered for
|
|
532
|
+
* reconnection and subscribed at once on a ready connection; before that, when it becomes ready.
|
|
527
533
|
* @param {string} to - The local component identifier, not a server target.
|
|
528
534
|
* @param {string} tag - The exact event tag.
|
|
529
535
|
* @param {Function} handler - The callback receiving (tag, ...args).
|
|
@@ -595,10 +601,20 @@ type Buffer$1 = Boho.Buffer;
|
|
|
595
601
|
|
|
596
602
|
declare function pack(payload: any): Buffer<ArrayBufferLike>;
|
|
597
603
|
declare class CongRx extends Transform {
|
|
604
|
+
/**
|
|
605
|
+
* @param {import('stream').TransformOptions & { maxFrameSize?: number }} [options] Stream options.
|
|
606
|
+
* maxFrameSize: largest payload to buffer (default unlimited). A larger frame is
|
|
607
|
+
* skipped without buffering and reported by an 'oversize' event (payloadSize).
|
|
608
|
+
*/
|
|
609
|
+
constructor(options?: stream.TransformOptions & {
|
|
610
|
+
maxFrameSize?: number;
|
|
611
|
+
});
|
|
598
612
|
buffer: Buffer<ArrayBuffer>;
|
|
599
613
|
frames: any[];
|
|
600
614
|
rxi: number;
|
|
601
615
|
rxi_zero: number;
|
|
616
|
+
maxFrameSize: number;
|
|
617
|
+
skipBytes: number;
|
|
602
618
|
_transform(chunk: any, encoding: any, callback: any): void;
|
|
603
619
|
addData(chunk: any): void;
|
|
604
620
|
parse(): void;
|
|
@@ -630,26 +646,42 @@ declare class FileLogger {
|
|
|
630
646
|
declare class Metrics {
|
|
631
647
|
constructor(manager: any);
|
|
632
648
|
manager: any;
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
rxBytes: number[];
|
|
638
|
-
unixTime: number[];
|
|
639
|
-
period: number;
|
|
640
|
-
};
|
|
641
|
-
tickId: number;
|
|
649
|
+
previous: {
|
|
650
|
+
time: number;
|
|
651
|
+
counters: any;
|
|
652
|
+
} | null;
|
|
642
653
|
close(): void;
|
|
643
|
-
|
|
654
|
+
snapshot(): {
|
|
655
|
+
at: number;
|
|
656
|
+
connections: {
|
|
657
|
+
total: any;
|
|
658
|
+
authenticated: number;
|
|
659
|
+
anonymous: number;
|
|
660
|
+
websocket: number;
|
|
661
|
+
tcp: number;
|
|
662
|
+
};
|
|
663
|
+
channels: any;
|
|
664
|
+
retained: {
|
|
665
|
+
channel: any;
|
|
666
|
+
bytes: any;
|
|
667
|
+
};
|
|
668
|
+
counters: any;
|
|
669
|
+
memory: {
|
|
670
|
+
rss: number;
|
|
671
|
+
heapUsed: number;
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
summaryLine(now?: number): string;
|
|
675
|
+
oneline(): {
|
|
644
676
|
lastSSID: any;
|
|
645
677
|
remotes: any;
|
|
646
678
|
channels: any;
|
|
647
679
|
txBytes: any;
|
|
648
680
|
rxBytes: any;
|
|
649
681
|
};
|
|
650
|
-
getRemotes(
|
|
651
|
-
getCIdList(
|
|
652
|
-
getChannelList(
|
|
682
|
+
getRemotes(): string[];
|
|
683
|
+
getCIdList(): any[];
|
|
684
|
+
getChannelList(): any[];
|
|
653
685
|
getSubscribers(ch: any): any[];
|
|
654
686
|
getRemoteByCId(cid: any, mode?: number): {
|
|
655
687
|
ip: any;
|
|
@@ -667,7 +699,6 @@ declare class Metrics {
|
|
|
667
699
|
isAuth?: undefined;
|
|
668
700
|
encMode?: undefined;
|
|
669
701
|
channels?: undefined;
|
|
670
|
-
set?: undefined;
|
|
671
702
|
retain?: undefined;
|
|
672
703
|
result?: undefined;
|
|
673
704
|
} | {
|
|
@@ -686,7 +717,6 @@ declare class Metrics {
|
|
|
686
717
|
isAuth?: undefined;
|
|
687
718
|
encMode?: undefined;
|
|
688
719
|
channels?: undefined;
|
|
689
|
-
set?: undefined;
|
|
690
720
|
retain?: undefined;
|
|
691
721
|
result?: undefined;
|
|
692
722
|
} | {
|
|
@@ -705,14 +735,12 @@ declare class Metrics {
|
|
|
705
735
|
txBytes?: undefined;
|
|
706
736
|
rxBytes?: undefined;
|
|
707
737
|
channels?: undefined;
|
|
708
|
-
set?: undefined;
|
|
709
738
|
retain?: undefined;
|
|
710
739
|
result?: undefined;
|
|
711
740
|
} | {
|
|
712
741
|
ip: any;
|
|
713
742
|
uptime: number;
|
|
714
743
|
channels: any[];
|
|
715
|
-
set: any[];
|
|
716
744
|
retain: any[];
|
|
717
745
|
id?: undefined;
|
|
718
746
|
ssid?: undefined;
|
|
@@ -744,7 +772,6 @@ declare class Metrics {
|
|
|
744
772
|
isAuth?: undefined;
|
|
745
773
|
encMode?: undefined;
|
|
746
774
|
channels?: undefined;
|
|
747
|
-
set?: undefined;
|
|
748
775
|
retain?: undefined;
|
|
749
776
|
} | undefined;
|
|
750
777
|
}
|
|
@@ -752,16 +779,32 @@ declare class Metrics {
|
|
|
752
779
|
declare class Manager {
|
|
753
780
|
constructor(server: any, authManager: any);
|
|
754
781
|
server: any;
|
|
755
|
-
pingPeriod:
|
|
756
|
-
pingGrace:
|
|
757
|
-
|
|
758
|
-
|
|
782
|
+
pingPeriod: any;
|
|
783
|
+
pingGrace: any;
|
|
784
|
+
counters: {
|
|
785
|
+
rxMessages: number;
|
|
786
|
+
rxBytes: number;
|
|
787
|
+
txMessages: number;
|
|
788
|
+
txBytes: number;
|
|
789
|
+
publishes: number;
|
|
790
|
+
deliveryAttempts: number;
|
|
791
|
+
quotaExcluded: number;
|
|
792
|
+
oversizeRejected: number;
|
|
793
|
+
rateLimited: number;
|
|
794
|
+
peerRxLimitSkipped: number;
|
|
795
|
+
policyDenied: number;
|
|
796
|
+
};
|
|
759
797
|
authManager: any;
|
|
760
798
|
connectionLogger: FileLogger | undefined;
|
|
761
799
|
attackLogger: FileLogger | undefined;
|
|
762
800
|
remotes: Set<any>;
|
|
763
801
|
cid2remote: Map<any, any>;
|
|
802
|
+
accountConnectionCounts: Map<any, any>;
|
|
764
803
|
retain_messages: Map<any, any>;
|
|
804
|
+
retain_owner: Map<any, any>;
|
|
805
|
+
retainOwners: Map<any, any>;
|
|
806
|
+
retainExpiry: Map<any, any>;
|
|
807
|
+
retainBytes: number;
|
|
765
808
|
channel_map: Map<any, any>;
|
|
766
809
|
CHANNEL_PREFIX: string;
|
|
767
810
|
CID_PREFIX: string;
|
|
@@ -774,7 +817,27 @@ declare class Manager {
|
|
|
774
817
|
pingTickMs: number;
|
|
775
818
|
heartbeatStopped: boolean;
|
|
776
819
|
pingIntervalID: NodeJS.Timeout;
|
|
777
|
-
|
|
820
|
+
statsIntervalID: NodeJS.Timeout | undefined;
|
|
821
|
+
get retainOptions(): any;
|
|
822
|
+
get quotas(): any;
|
|
823
|
+
get anonymousQuota(): any;
|
|
824
|
+
accountConnections(uid: any): any;
|
|
825
|
+
addAccountConnection(remote: any, uid: any): void;
|
|
826
|
+
/**
|
|
827
|
+
* Replace the delivery policy of the connected, owned device with this CID (see deliveryPolicy.js);
|
|
828
|
+
* the next unicast to it already uses the new one. A new login reads the stored policy again.
|
|
829
|
+
* Returns false when no such connection is here or it has no owner (never filtered).
|
|
830
|
+
* Throws on an invalid policy, so a caller cannot install one by mistake.
|
|
831
|
+
*/
|
|
832
|
+
setDeliveryPolicy(cid: any, policy: any): boolean;
|
|
833
|
+
/**
|
|
834
|
+
* Count a message a delivery policy kept from `other` (unicast from it, or a publication to it) and,
|
|
835
|
+
* when someone listens, emit 'delivery:denied' on the server with what the server knows of both:
|
|
836
|
+
* { kind: 'unicast' | 'publish', cid, did, owner, other: { cid, uid, ip, authenticated }, at }.
|
|
837
|
+
* An anonymous connection's CID is not reported (random per connection).
|
|
838
|
+
*/
|
|
839
|
+
deliveryDenied(device: any, other: any, kind: any): void;
|
|
840
|
+
removeAccountConnection(remote: any): void;
|
|
778
841
|
heartbeatTick(): void;
|
|
779
842
|
addRemote(socket: any, req: any): void;
|
|
780
843
|
removeRemote(remote: any): void;
|
|
@@ -785,9 +848,17 @@ declare class Manager {
|
|
|
785
848
|
adminSignal(cid: any, message: any): "no cid" | undefined;
|
|
786
849
|
serverSignalTo(tag: any, ...args: any[]): "no cid" | undefined;
|
|
787
850
|
sender(tag: any, remote: any, message: any): (string | number)[];
|
|
851
|
+
retainFits(message: any, freed: any, ownerBytes: any, budget: any): boolean;
|
|
852
|
+
retainCopy(message: any): Buffer<ArrayBuffer>;
|
|
853
|
+
storeCidRetain(key: any, message: any, remote: any): void;
|
|
854
|
+
retainOwner(key: any): any;
|
|
855
|
+
storeChannelRetain(tag: any, message: any, remote: any): void;
|
|
856
|
+
orphanChannelRetains(remote: any): void;
|
|
857
|
+
expireChannelRetains(now?: number): void;
|
|
858
|
+
dropChannelRetain(tag: any): void;
|
|
859
|
+
releaseChannelRetain(tag: any, size: any): void;
|
|
788
860
|
subscribe(chArr: any, remote: any): any;
|
|
789
861
|
unsubscribe(chArr: any, remote: any): void;
|
|
790
|
-
monitor(): void;
|
|
791
862
|
anonymousCidRandom(size: any): Buffer<ArrayBuffer>;
|
|
792
863
|
issueAnonymousCid(): string | null;
|
|
793
864
|
closeRemoteByCId(cid: any): 0 | 1;
|
|
@@ -798,17 +869,50 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
798
869
|
/**
|
|
799
870
|
* @param {object} options Server configuration.
|
|
800
871
|
* options.localAuth: login without a key list, for local testing. 'idKey' (key = ID) or
|
|
801
|
-
* { mode: 'idKey' | 'sharedKey', key,
|
|
872
|
+
* { mode: 'idKey' | 'sharedKey', key, role, quota } (see LocalKeyProvider); the CID is the ID.
|
|
802
873
|
* Cannot be combined with authManager.
|
|
874
|
+
* Every other setting is this Server's own: given here, else the serverOption default, which is
|
|
875
|
+
* never modified. Nested groups (security, retain, quotas) are merged over their defaults;
|
|
876
|
+
* unknown or removed names are errors.
|
|
877
|
+
* options.heartbeatInterval: ms between liveness checks (default 50000).
|
|
878
|
+
* options.heartbeatGrace: extra ms a peer has to answer before it is closed (default 5000).
|
|
879
|
+
* options.trustProxy: when X-Forwarded-For/-Proto are used. 'private' (default) only from a
|
|
880
|
+
* loopback/private peer, true always, false never, or N trusted proxy hops.
|
|
881
|
+
* options.maxPayload: largest WebSocket message and CongSocket frame in bytes (default 32 MiB).
|
|
882
|
+
* options.maxBufferedBytes: close a peer whose unsent data exceeds this (default 64 MiB).
|
|
883
|
+
* options.membersOnly: drop signals from connections that are not authenticated.
|
|
884
|
+
* options.logMessages: log each received message after decryption: type and tag, never the payload.
|
|
885
|
+
* options.logStats: print a one-line summary every N ms (>= 1000; 0 = off); see stats().
|
|
886
|
+
* options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries }.
|
|
887
|
+
* options.retain: retained message limits, see serverOption.retain; adjustable later on server.retain.
|
|
888
|
+
* options.quotas: named quota profiles { name: { maxMessageBytes, fanout, msgPerSec, bytesPerSec,
|
|
889
|
+
* maxConnections } }, merged over serverOption.quotas; always enforced, null is unlimited.
|
|
890
|
+
* Adjustable later on server.quotas. The client is told its maxMessageBytes.
|
|
891
|
+
* options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
|
|
892
|
+
* options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
|
|
893
|
+
* manager's own policy without changing it, so an auth manager can be shared between servers.
|
|
894
|
+
* A failed listen (e.g. EADDRINUSE) is emitted as 'error'.
|
|
803
895
|
* @param {any} [authManager] Optional authentication manager.
|
|
804
896
|
*/
|
|
805
897
|
constructor(options: object, authManager?: any);
|
|
806
898
|
security: any;
|
|
899
|
+
retain: any;
|
|
900
|
+
quotas: {};
|
|
901
|
+
anonymousQuota: any;
|
|
902
|
+
heartbeatInterval: any;
|
|
903
|
+
heartbeatGrace: any;
|
|
904
|
+
maxPayload: any;
|
|
905
|
+
maxBufferedBytes: any;
|
|
906
|
+
logMessages: boolean;
|
|
907
|
+
logStats: any;
|
|
908
|
+
trustProxy: any;
|
|
909
|
+
membersOnly: boolean;
|
|
807
910
|
serviceNames: Set<any>;
|
|
808
911
|
services: Map<any, any>;
|
|
809
912
|
wss: any;
|
|
810
913
|
port: number | null;
|
|
811
914
|
congPort: number | null;
|
|
915
|
+
duplicateLogin: any;
|
|
812
916
|
httpServer: any;
|
|
813
917
|
wsPath: any;
|
|
814
918
|
manager: Manager;
|
|
@@ -817,6 +921,45 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
817
921
|
startWSServer(): void;
|
|
818
922
|
startCongServer(): void;
|
|
819
923
|
congServer: any;
|
|
924
|
+
onListenerError(name: any, err: any): void;
|
|
925
|
+
/**
|
|
926
|
+
* Current server state, for monitoring. counters are cumulative since the server started
|
|
927
|
+
* (rates are the reader's to compute from two snapshots). Enumerates connections once.
|
|
928
|
+
* @returns {{ at: number, connections: { total: number, authenticated: number, anonymous: number,
|
|
929
|
+
* websocket: number, tcp: number }, channels: number, retained: { channel: number, bytes: number },
|
|
930
|
+
* counters: { rxMessages: number, rxBytes: number, txMessages: number, txBytes: number,
|
|
931
|
+
* publishes: number, deliveryAttempts: number, quotaExcluded: number, peerRxLimitSkipped: number },
|
|
932
|
+
* memory: { rss: number, heapUsed: number } }}
|
|
933
|
+
*/
|
|
934
|
+
stats(): {
|
|
935
|
+
at: number;
|
|
936
|
+
connections: {
|
|
937
|
+
total: number;
|
|
938
|
+
authenticated: number;
|
|
939
|
+
anonymous: number;
|
|
940
|
+
websocket: number;
|
|
941
|
+
tcp: number;
|
|
942
|
+
};
|
|
943
|
+
channels: number;
|
|
944
|
+
retained: {
|
|
945
|
+
channel: number;
|
|
946
|
+
bytes: number;
|
|
947
|
+
};
|
|
948
|
+
counters: {
|
|
949
|
+
rxMessages: number;
|
|
950
|
+
rxBytes: number;
|
|
951
|
+
txMessages: number;
|
|
952
|
+
txBytes: number;
|
|
953
|
+
publishes: number;
|
|
954
|
+
deliveryAttempts: number;
|
|
955
|
+
quotaExcluded: number;
|
|
956
|
+
peerRxLimitSkipped: number;
|
|
957
|
+
};
|
|
958
|
+
memory: {
|
|
959
|
+
rss: number;
|
|
960
|
+
heapUsed: number;
|
|
961
|
+
};
|
|
962
|
+
};
|
|
820
963
|
/**
|
|
821
964
|
* RPC service register.
|
|
822
965
|
* service: service_name <string>
|
|
@@ -831,17 +974,75 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
831
974
|
}
|
|
832
975
|
|
|
833
976
|
declare namespace serverOption {
|
|
834
|
-
export let
|
|
835
|
-
export let
|
|
836
|
-
export let
|
|
837
|
-
export let
|
|
838
|
-
export let
|
|
839
|
-
export let
|
|
840
|
-
export let
|
|
841
|
-
export let
|
|
842
|
-
export
|
|
843
|
-
|
|
844
|
-
|
|
977
|
+
export let heartbeatInterval: number;
|
|
978
|
+
export let heartbeatGrace: number;
|
|
979
|
+
export let maxPayload: number;
|
|
980
|
+
export let trustProxy: string;
|
|
981
|
+
export let maxBufferedBytes: number;
|
|
982
|
+
export let membersOnly: boolean;
|
|
983
|
+
export let logMessages: boolean;
|
|
984
|
+
export let logStats: number;
|
|
985
|
+
export namespace security {
|
|
986
|
+
let maxClockSkewMs: number;
|
|
987
|
+
let authChallengeMaxAgeMs: number;
|
|
988
|
+
let maxReplayEntries: number;
|
|
989
|
+
}
|
|
990
|
+
export namespace quotas {
|
|
991
|
+
namespace anonymous {
|
|
992
|
+
let maxMessageBytes: number;
|
|
993
|
+
let fanout: number;
|
|
994
|
+
let msgPerSec: number;
|
|
995
|
+
let bytesPerSec: number;
|
|
996
|
+
let maxConnections: null;
|
|
997
|
+
}
|
|
998
|
+
namespace basic {
|
|
999
|
+
let maxMessageBytes_1: number;
|
|
1000
|
+
export { maxMessageBytes_1 as maxMessageBytes };
|
|
1001
|
+
let fanout_1: number;
|
|
1002
|
+
export { fanout_1 as fanout };
|
|
1003
|
+
let msgPerSec_1: number;
|
|
1004
|
+
export { msgPerSec_1 as msgPerSec };
|
|
1005
|
+
let bytesPerSec_1: number;
|
|
1006
|
+
export { bytesPerSec_1 as bytesPerSec };
|
|
1007
|
+
let maxConnections_1: number;
|
|
1008
|
+
export { maxConnections_1 as maxConnections };
|
|
1009
|
+
}
|
|
1010
|
+
namespace pro {
|
|
1011
|
+
let maxMessageBytes_2: number;
|
|
1012
|
+
export { maxMessageBytes_2 as maxMessageBytes };
|
|
1013
|
+
let fanout_2: number;
|
|
1014
|
+
export { fanout_2 as fanout };
|
|
1015
|
+
let msgPerSec_2: number;
|
|
1016
|
+
export { msgPerSec_2 as msgPerSec };
|
|
1017
|
+
let bytesPerSec_2: number;
|
|
1018
|
+
export { bytesPerSec_2 as bytesPerSec };
|
|
1019
|
+
let maxConnections_2: number;
|
|
1020
|
+
export { maxConnections_2 as maxConnections };
|
|
1021
|
+
}
|
|
1022
|
+
namespace unlimited {
|
|
1023
|
+
let maxMessageBytes_3: null;
|
|
1024
|
+
export { maxMessageBytes_3 as maxMessageBytes };
|
|
1025
|
+
let fanout_3: null;
|
|
1026
|
+
export { fanout_3 as fanout };
|
|
1027
|
+
let msgPerSec_3: null;
|
|
1028
|
+
export { msgPerSec_3 as msgPerSec };
|
|
1029
|
+
let bytesPerSec_3: null;
|
|
1030
|
+
export { bytesPerSec_3 as bytesPerSec };
|
|
1031
|
+
let maxConnections_3: null;
|
|
1032
|
+
export { maxConnections_3 as maxConnections };
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
export let anonymousQuota: string;
|
|
1036
|
+
export namespace retain {
|
|
1037
|
+
let enabled: boolean;
|
|
1038
|
+
let limitSize: number;
|
|
1039
|
+
let limitCounter: number;
|
|
1040
|
+
let tagsPerOwner: number;
|
|
1041
|
+
let bytesPerOwner: number;
|
|
1042
|
+
let anonymousGraceMs: number;
|
|
1043
|
+
let bytesPerConnection: number;
|
|
1044
|
+
let bytesTotal: number;
|
|
1045
|
+
}
|
|
845
1046
|
export namespace fileLogger {
|
|
846
1047
|
namespace connection {
|
|
847
1048
|
let use: boolean;
|
|
@@ -860,77 +1061,25 @@ declare namespace serverOption {
|
|
|
860
1061
|
export { path_2 as path };
|
|
861
1062
|
}
|
|
862
1063
|
}
|
|
863
|
-
export namespace
|
|
864
|
-
let
|
|
865
|
-
let
|
|
866
|
-
let trafficRate: boolean;
|
|
867
|
-
let disconnect: boolean;
|
|
1064
|
+
export namespace auth_1 {
|
|
1065
|
+
let failDelay: number;
|
|
1066
|
+
let duplicateLogin: string;
|
|
868
1067
|
}
|
|
869
|
-
export
|
|
870
|
-
export let adminLevel: number;
|
|
1068
|
+
export { auth_1 as auth };
|
|
871
1069
|
export namespace debug {
|
|
872
1070
|
let slow: boolean;
|
|
873
1071
|
let delay: number;
|
|
874
1072
|
let showAuthInfo: boolean;
|
|
875
1073
|
}
|
|
876
|
-
export namespace retain {
|
|
877
|
-
let isAvailable: boolean;
|
|
878
|
-
let limitSize: number;
|
|
879
|
-
let limitCounter: number;
|
|
880
|
-
}
|
|
881
|
-
export namespace security {
|
|
882
|
-
let maxClockSkewMs: number;
|
|
883
|
-
let authChallengeMaxAgeMs: number;
|
|
884
|
-
let maxReplayEntries: number;
|
|
885
|
-
}
|
|
886
|
-
export namespace auth_1 {
|
|
887
|
-
let delay_auth_fail: number;
|
|
888
|
-
let duplicateLogin: string;
|
|
889
|
-
}
|
|
890
|
-
export { auth_1 as auth };
|
|
891
|
-
export let membersOnly: boolean;
|
|
892
1074
|
}
|
|
893
1075
|
|
|
894
1076
|
declare function isPrivateIP(ip: any): boolean;
|
|
1077
|
+
declare function getIPv6PrefixHexString(ip: any): string | null;
|
|
895
1078
|
declare function numberWithCommas(x: any): any;
|
|
896
1079
|
declare function getIPv4HexString(ipStr: any): string;
|
|
897
1080
|
declare function getLocalAddress(): string;
|
|
898
1081
|
declare function delay(ms: any): Promise<any>;
|
|
899
1082
|
|
|
900
|
-
declare class BohoAuth {
|
|
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;
|
|
921
|
-
authLogger: FileLogger | undefined;
|
|
922
|
-
set keepOldConnection(keepOld: boolean);
|
|
923
|
-
get keepOldConnection(): boolean;
|
|
924
|
-
emitAuthEvent(event: any): void;
|
|
925
|
-
send_auth_fail(peer: any, reason: any): void;
|
|
926
|
-
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
927
|
-
getAuth(id: any): Promise<any>;
|
|
928
|
-
getAuthIdList(): Promise<any>;
|
|
929
|
-
addAuth(id: any, keyStr: any, cid: any, level?: number): Promise<any>;
|
|
930
|
-
delAuth(id: any): Promise<any>;
|
|
931
|
-
save(): Promise<any>;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
1083
|
declare class FileKeyProvider {
|
|
935
1084
|
constructor(_path: any);
|
|
936
1085
|
AUTH: Map<any, any>;
|
|
@@ -939,7 +1088,7 @@ declare class FileKeyProvider {
|
|
|
939
1088
|
loadAuthInfoFile_JSON(path: any): void;
|
|
940
1089
|
getAuth(id: any): Promise<any>;
|
|
941
1090
|
getAuthIdList(): Promise<any[]>;
|
|
942
|
-
addAuth(id: any, keyStr: any, cid: any,
|
|
1091
|
+
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): void;
|
|
943
1092
|
}
|
|
944
1093
|
|
|
945
1094
|
declare class RedisKeyProvider {
|
|
@@ -947,7 +1096,7 @@ declare class RedisKeyProvider {
|
|
|
947
1096
|
redis: any;
|
|
948
1097
|
getAuth(id: any): Promise<any>;
|
|
949
1098
|
getAuthIdList(): Promise<any>;
|
|
950
|
-
addAuth(id: any, keyStr: any, cid
|
|
1099
|
+
addAuth(id: any, keyStr: any, cid: string | undefined, role: any, quota: any): Promise<any>;
|
|
951
1100
|
delAuth(id: any): Promise<any>;
|
|
952
1101
|
save(id: any): Promise<any>;
|
|
953
1102
|
}
|
|
@@ -957,26 +1106,30 @@ declare class StringKeyProvider {
|
|
|
957
1106
|
AUTH: Map<any, any>;
|
|
958
1107
|
getAuth(id: any): Promise<any>;
|
|
959
1108
|
getAuthIdList(): Promise<any[]>;
|
|
960
|
-
addAuth(id: any, keyStr: any, cid: any,
|
|
1109
|
+
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): void;
|
|
961
1110
|
}
|
|
962
1111
|
|
|
963
1112
|
declare class LocalKeyProvider {
|
|
964
1113
|
/**
|
|
965
|
-
* @param {'idKey' | { mode: 'idKey' | 'sharedKey', key?: string,
|
|
1114
|
+
* @param {'idKey' | { mode: 'idKey' | 'sharedKey', key?: string,
|
|
1115
|
+
* role?: 'device' | 'service' | 'admin', quota?: string }} options
|
|
966
1116
|
* A string is the mode alone.
|
|
967
1117
|
*/
|
|
968
1118
|
constructor(options: "idKey" | {
|
|
969
1119
|
mode: "idKey" | "sharedKey";
|
|
970
1120
|
key?: string;
|
|
971
|
-
|
|
1121
|
+
role?: "device" | "service" | "admin";
|
|
1122
|
+
quota?: string;
|
|
972
1123
|
});
|
|
973
1124
|
mode: "idKey" | "sharedKey";
|
|
974
|
-
|
|
1125
|
+
role: "device" | "service" | "admin";
|
|
1126
|
+
quota: string | undefined;
|
|
975
1127
|
sharedKeyHash: string | null;
|
|
976
1128
|
getAuth(id: any): Promise<{
|
|
1129
|
+
quota?: string | undefined;
|
|
977
1130
|
key: string;
|
|
978
1131
|
cid: any;
|
|
979
|
-
|
|
1132
|
+
role: "device" | "service" | "admin";
|
|
980
1133
|
} | undefined>;
|
|
981
1134
|
}
|
|
982
1135
|
|
|
@@ -1026,15 +1179,12 @@ declare namespace sudoService {
|
|
|
1026
1179
|
declare class RedisService {
|
|
1027
1180
|
/**
|
|
1028
1181
|
* @param {object} redisClient
|
|
1029
|
-
* @param {
|
|
1030
|
-
*
|
|
1182
|
+
* @param {'anonymous' | 'device' | 'service' | 'admin'} [minRole='service'] lowest role allowed;
|
|
1183
|
+
* 'anonymous' allows every connection.
|
|
1031
1184
|
*/
|
|
1032
|
-
constructor(redisClient: object,
|
|
1033
|
-
requireAuth?: boolean;
|
|
1034
|
-
});
|
|
1185
|
+
constructor(redisClient: object, minRole?: "anonymous" | "device" | "service" | "admin");
|
|
1035
1186
|
redisClient: object;
|
|
1036
|
-
|
|
1037
|
-
requireAuth: boolean;
|
|
1187
|
+
minRole: "anonymous" | "device" | "service" | "admin";
|
|
1038
1188
|
commands: string[];
|
|
1039
1189
|
checkPermission(remote: any, req: any): boolean;
|
|
1040
1190
|
call(remote: any, req: any): Promise<void>;
|
|
@@ -1047,6 +1197,53 @@ declare function parsePayload(args: any): {
|
|
|
1047
1197
|
};
|
|
1048
1198
|
declare function getPayloadFromSignalPack(signalPack: any): any;
|
|
1049
1199
|
|
|
1200
|
+
/** True if the remote is authenticated with this role or a higher one ('anonymous': always). */
|
|
1201
|
+
declare function hasRole(remote: any, role: any): boolean;
|
|
1202
|
+
/** Default quota profile of a login: the account's quota, else 'basic' for a device, 'unlimited' otherwise. */
|
|
1203
|
+
declare function defaultQuota(authInfo: any, role: any): any;
|
|
1204
|
+
declare const ROLES: string[];
|
|
1205
|
+
declare class BohoAuth {
|
|
1206
|
+
/**
|
|
1207
|
+
* @param {object} keyProvider
|
|
1208
|
+
* @param {{ duplicateLogin?: 'keepOld' | 'keepNew', onAuthEvent?: (event: object) => any,
|
|
1209
|
+
* resolveQuota?: (authInfo: object, role: string) => string | Promise<string> }} [options]
|
|
1210
|
+
* duplicateLogin: unset follows serverOption.auth.duplicateLogin (default 'keepNew').
|
|
1211
|
+
* A Server's duplicateLogin option takes precedence for that Server's connections.
|
|
1212
|
+
* onAuthEvent: called with { type, did, cid, uid, ip, oldIp, socketType, oldSocketType, reason, at }
|
|
1213
|
+
* for 'replaced' (keepNew evicted the old connection) and 'duplicate_rejected' (keepOld).
|
|
1214
|
+
* socketType/oldSocketType are 'websocket' or 'congsocket'.
|
|
1215
|
+
* Errors and rejected promises are logged and never affect authentication.
|
|
1216
|
+
* resolveQuota: name of the Server quota profile for a login (default: defaultQuota), e.g. from
|
|
1217
|
+
* the account owner's plan. An unknown name fails the login.
|
|
1218
|
+
*/
|
|
1219
|
+
constructor(keyProvider: object, options?: {
|
|
1220
|
+
duplicateLogin?: "keepOld" | "keepNew";
|
|
1221
|
+
onAuthEvent?: (event: object) => any;
|
|
1222
|
+
resolveQuota?: (authInfo: object, role: string) => string | Promise<string>;
|
|
1223
|
+
});
|
|
1224
|
+
keyProvider: object;
|
|
1225
|
+
_duplicateLogin: any;
|
|
1226
|
+
/** @param {'keepOld' | 'keepNew' | null} policy null returns to the serverOption default. */
|
|
1227
|
+
set duplicateLogin(policy: "keepOld" | "keepNew" | null);
|
|
1228
|
+
/** Effective duplicate login policy: this instance's setting, else serverOption.auth.duplicateLogin. */
|
|
1229
|
+
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
1230
|
+
onAuthEvent: ((event: object) => any) | null;
|
|
1231
|
+
resolveQuota: typeof defaultQuota | ((authInfo: object, role: string) => string | Promise<string>);
|
|
1232
|
+
authLogger: FileLogger | undefined;
|
|
1233
|
+
/** Policy for a connection: its Server's duplicateLogin option, else this instance's policy. */
|
|
1234
|
+
duplicateLoginFor(peer: any): any;
|
|
1235
|
+
set keepOldConnection(keepOld: boolean);
|
|
1236
|
+
get keepOldConnection(): boolean;
|
|
1237
|
+
emitAuthEvent(event: any): void;
|
|
1238
|
+
send_auth_fail(peer: any, reason: any): void;
|
|
1239
|
+
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
1240
|
+
getAuth(id: any): Promise<any>;
|
|
1241
|
+
getAuthIdList(): Promise<any>;
|
|
1242
|
+
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): Promise<any>;
|
|
1243
|
+
delAuth(id: any): Promise<any>;
|
|
1244
|
+
save(): Promise<any>;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1050
1247
|
declare const version: string;
|
|
1051
1248
|
|
|
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 };
|
|
1249
|
+
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 };
|