iosignal 9.13.0 → 9.19.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.
@@ -6,6 +6,8 @@ import { EventEmitter } from 'eventemitter3';
6
6
  import * as stream from 'stream';
7
7
  import { Transform } from 'stream';
8
8
  import EventEmitter$1 from 'events';
9
+ import * as perf_hooks from 'perf_hooks';
10
+ import http from 'http';
9
11
  export { default as MBP } from 'meta-buffer-pack';
10
12
 
11
13
  type STATE = {
@@ -55,6 +57,7 @@ type SIZE_LIMIT = {
55
57
  TAG_LEN2: number;
56
58
  CONNECTION_CHECKER_PERIOD: number;
57
59
  CLIENT_PING_PERIOD: number;
60
+ SERVER_HELLO_TIMEOUT: number;
58
61
  PROMISE_TIMEOUT: number;
59
62
  DID: number;
60
63
  CID: number;
@@ -64,6 +67,7 @@ declare namespace SIZE_LIMIT {
64
67
  let TAG_LEN2: number;
65
68
  let CONNECTION_CHECKER_PERIOD: number;
66
69
  let CLIENT_PING_PERIOD: number;
70
+ let SERVER_HELLO_TIMEOUT: number;
67
71
  let PROMISE_TIMEOUT: number;
68
72
  let DID: number;
69
73
  let CID: number;
@@ -350,6 +354,15 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
350
354
  * @param {string} url2 - The new URL to redirect to.
351
355
  */
352
356
  redirect(url2: string): void;
357
+ /**
358
+ * Closes a connection that has not got the server's hello in SIZE_LIMIT.SERVER_HELLO_TIMEOUT
359
+ * (a server that cannot be reached, or a connection that opens but never answers). With
360
+ * autoReconnect the client then reconnects to this.url, so a failed redirect falls back to the
361
+ * original server, as the Arduino library does.
362
+ */
363
+ armHelloTimer(): void;
364
+ helloTimerID: any;
365
+ clearHelloTimer(): void;
353
366
  /**
354
367
  * Opens the WebSocket connection.
355
368
  * @param {string} [url] - Optional URL to connect to. If not provided, uses the instance's URL.
@@ -686,6 +699,25 @@ declare class Host extends EventEmitter$1<[never]> {
686
699
  closed: boolean;
687
700
  /** @type {Map<string, Readonly<object>>} cid -> from, connections that sent to this host */
688
701
  _participants: Map<string, Readonly<object>>;
702
+ /** cid -> { inputs, firstAt, lastAt }: activity of each participant, for the dashboard */
703
+ _activity: Map<any, any>;
704
+ counters: {
705
+ inbound: number;
706
+ rejected: number;
707
+ denied: number;
708
+ published: number;
709
+ delivered: number;
710
+ sent: number;
711
+ joins: number;
712
+ leaves: number;
713
+ errors: number;
714
+ handlerMs: number;
715
+ };
716
+ handlerMaxMs: number;
717
+ reported: {};
718
+ _journal: any[];
719
+ _journalSeq: number;
720
+ _loops: Set<any>;
689
721
  /** Connections that have sent to this host and are still online: cid -> from. */
690
722
  get participants(): Map<string, object>;
691
723
  /** Stop tracking a participant; no 'leave' is emitted for it (until it sends again). */
@@ -700,6 +732,35 @@ declare class Host extends EventEmitter$1<[never]> {
700
732
  * or its receive buffer is too small for the message.
701
733
  */
702
734
  to(cid: any, topic: any, ...args: any[]): boolean;
735
+ /**
736
+ * Values to show on the server dashboard ("game" panel), e.g. { round: 3, players: 8 }.
737
+ * Merged into the last report; a key set to null is removed. Numbers, short strings and booleans,
738
+ * at most 20 keys.
739
+ */
740
+ report(values: any): this;
741
+ /**
742
+ * Run fn(now) every intervalMs, like setInterval, and measure it for the dashboard: the gap between
743
+ * ticks and how long each tick took. A throwing tick is reported as an 'error' and the loop goes on.
744
+ * Returns a stop function; close() stops every loop.
745
+ */
746
+ loop(intervalMs: any, fn: any): () => void;
747
+ /** Timing of the loops started with loop(): target, ticks, gap p50/p99 and step average/max (ms). */
748
+ loopStats(): {
749
+ intervalMs: any;
750
+ ticks: any;
751
+ gapP50: any;
752
+ gapP99: any;
753
+ gapMax: number;
754
+ stepAvg: number;
755
+ stepMax: number;
756
+ }[];
757
+ /** Participants with their activity: [{ from, inputs, firstAt, lastAt }]. */
758
+ activity(): any[];
759
+ /** Notable events after sequence `after`: [{ seq, at, kind: 'join'|'leave'|'denied'|'error', ... }]. */
760
+ journal(after?: number): any[];
761
+ _note(kind: any, data: any): void;
762
+ _denied(remote: any, tag: any): void;
763
+ _failed(error: any): void;
703
764
  /** Release the tags (they become ordinary channels again) and the host's retained values. */
704
765
  close(): void;
705
766
  _open(): void;
@@ -936,6 +997,135 @@ declare class Manager {
936
997
  close(): void;
937
998
  }
938
999
 
1000
+ declare class ServerStats {
1001
+ constructor(server: any, { onSample }?: {
1002
+ onSample?: null | undefined;
1003
+ });
1004
+ server: any;
1005
+ onSample: any;
1006
+ base: any;
1007
+ counters: {
1008
+ opened: number;
1009
+ closed: number;
1010
+ authFailed: number;
1011
+ };
1012
+ onState: (_peer: any, _previous: any) => void;
1013
+ delay: perf_hooks.IntervalHistogram;
1014
+ cpu: NodeJS.CpuUsage;
1015
+ elu: perf_hooks.EventLoopUtilization;
1016
+ previousAt: number;
1017
+ previous: {
1018
+ opened: number;
1019
+ closed: number;
1020
+ authFailed: number;
1021
+ };
1022
+ timer: NodeJS.Timeout;
1023
+ sample(): void;
1024
+ value: {
1025
+ at: number;
1026
+ total: any;
1027
+ authenticated: number;
1028
+ anonymous: number;
1029
+ websocket: number;
1030
+ transports: {
1031
+ websocket: {
1032
+ total: number;
1033
+ authenticated: number;
1034
+ };
1035
+ tcp: {
1036
+ total: number;
1037
+ authenticated: number;
1038
+ };
1039
+ };
1040
+ hostAvailableBytes: number | null;
1041
+ hostTotalBytes: number;
1042
+ channels: any;
1043
+ states: {};
1044
+ queuedBytes: number;
1045
+ maxQueuedBytes: number;
1046
+ txQueuePeakBytes: number;
1047
+ txWriteFalseCount: number;
1048
+ txDrainMaxMs: number;
1049
+ txBlockedConnections: number;
1050
+ txBlockedMaxMs: number;
1051
+ counters: {
1052
+ opened: number;
1053
+ closed: number;
1054
+ authFailed: number;
1055
+ };
1056
+ rates: {
1057
+ [k: string]: number;
1058
+ };
1059
+ rss: number;
1060
+ heapUsed: number;
1061
+ cpuPercent: number;
1062
+ eventLoopUtilization: number;
1063
+ eventLoopP99Ms: number;
1064
+ quota: {
1065
+ anonymous: any;
1066
+ profiles: any;
1067
+ };
1068
+ } | undefined;
1069
+ dispose(): void;
1070
+ }
1071
+
1072
+ /**
1073
+ * The server dashboard: a web page (options.path) that shows the server and its hosts live.
1074
+ * It talks to the page through IOSignal itself: viewers send 'hello' to DASHBOARD.IN, a host checks
1075
+ * access, and every second it sends the latest sample to each viewer with host.to().
1076
+ *
1077
+ * options (all optional):
1078
+ * path: '/dashboard'
1079
+ * access: 'open' | { token: '...' } | { login: { roles: ['admin'], cids: [] } }
1080
+ * panels: panels shown first (DASHBOARD_PANELS); viewers can switch them
1081
+ * history: seconds kept for the charts (default 300, 10-3600)
1082
+ * maxViewers: default 20
1083
+ * showIdentities: show participant CIDs and names (default: true unless access is 'open')
1084
+ */
1085
+ declare class Dashboard {
1086
+ constructor(server: any, options?: {});
1087
+ path: string;
1088
+ access: {
1089
+ mode: string;
1090
+ hash?: undefined;
1091
+ roles?: undefined;
1092
+ cids?: undefined;
1093
+ } | {
1094
+ mode: string;
1095
+ hash: NonSharedBuffer;
1096
+ roles?: undefined;
1097
+ cids?: undefined;
1098
+ } | {
1099
+ mode: string;
1100
+ roles: any[];
1101
+ cids: Set<any>;
1102
+ hash?: undefined;
1103
+ };
1104
+ panels: any[];
1105
+ history: any;
1106
+ maxViewers: any;
1107
+ showIdentities: any;
1108
+ server: any;
1109
+ startedAt: number;
1110
+ viewers: Map<any, any>;
1111
+ series: any[];
1112
+ lastHostCounters: Map<any, any>;
1113
+ lastJournal: Map<any, any>;
1114
+ events: any[];
1115
+ host: any;
1116
+ stats: ServerStats;
1117
+ /** Whether this viewer (the server's view of it) may watch. */
1118
+ allowed(from: any, msg: any): boolean;
1119
+ /**
1120
+ * Serves the page (GET path) and the browser client (path + '/io.js'). Returns true when it
1121
+ * answered. A Server with `port` calls it itself; with your own httpServer call it first in
1122
+ * your request handler: if (server.dashboard.handle(req, res)) return
1123
+ */
1124
+ handle(req: any, res: any): boolean;
1125
+ close(): void;
1126
+ #private;
1127
+ }
1128
+
939
1129
  declare class Server extends EventEmitter$1<[never]> {
940
1130
  /**
941
1131
  * @param {object} options Server configuration.
@@ -962,6 +1152,9 @@ declare class Server extends EventEmitter$1<[never]> {
962
1152
  * options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
963
1153
  * options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
964
1154
  * manager's own policy without changing it, so an auth manager can be shared between servers.
1155
+ * options.dashboard: true or { path, access, panels, history, maxViewers, showIdentities } shows a live
1156
+ * status page of the server and its hosts (see Dashboard.js); off by default. With `port` the Server
1157
+ * serves it itself; with your own httpServer call server.dashboard.handle(req, res) in its handler.
965
1158
  * A failed listen (e.g. EADDRINUSE) is emitted as 'error'.
966
1159
  * @param {any} [authManager] Optional authentication manager.
967
1160
  */
@@ -988,9 +1181,11 @@ declare class Server extends EventEmitter$1<[never]> {
988
1181
  httpServer: any;
989
1182
  wsPath: any;
990
1183
  manager: Manager;
1184
+ dashboard: Dashboard | null;
991
1185
  serverCountToListen: number;
992
1186
  listeningServerCount: number;
993
1187
  startWSServer(): void;
1188
+ ownHttp: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | undefined;
994
1189
  startCongServer(): void;
995
1190
  congServer: any;
996
1191
  onListenerError(name: any, err: any): void;
@@ -1189,6 +1384,7 @@ declare class RedisKeyProvider {
1189
1384
  redis: any;
1190
1385
  getAuth(id: any): Promise<any>;
1191
1386
  getAuthIdList(): Promise<any>;
1387
+ scanKeys(pattern: any): Promise<any>;
1192
1388
  addAuth(id: any, keyStr: any, cid: string | undefined, role: any, quota: any): Promise<any>;
1193
1389
  delAuth(id: any): Promise<any>;
1194
1390
  save(id: any): Promise<any>;
@@ -1329,12 +1525,25 @@ declare class BohoAuth {
1329
1525
  get keepOldConnection(): boolean;
1330
1526
  emitAuthEvent(event: any): void;
1331
1527
  send_auth_fail(peer: any, reason: any): void;
1528
+ /**
1529
+ * Hook for a subclass: decide where a verified login belongs before it is accepted.
1530
+ * Called after the key and role checks, before quotas and the duplicate login check.
1531
+ * Return null to accept the login here, or a message (e.g. SERVER_REDIRECT) that is sent to the
1532
+ * client instead of AUTH_RES before the connection is closed. The default accepts every login.
1533
+ * @param {object} peer the connection
1534
+ * @param {object} authInfo the key provider's entry for the login ID (cid, uid, role, quota, ...)
1535
+ * @param {string} role resolved role
1536
+ * @param {string} id login ID
1537
+ * @returns {Promise<Uint8Array | null> | Uint8Array | null}
1538
+ */
1539
+ beforeAccept(peer: object, authInfo: object, role: string, id: string): Promise<Uint8Array | null> | Uint8Array | null;
1332
1540
  verify_auth_req(auth_req: any, peer: any): Promise<any>;
1333
1541
  getAuth(id: any): Promise<any>;
1334
1542
  getAuthIdList(): Promise<any>;
1335
1543
  addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): Promise<any>;
1336
1544
  delAuth(id: any): Promise<any>;
1337
1545
  save(): Promise<any>;
1546
+ #private;
1338
1547
  }
1339
1548
 
1340
1549
  declare const version: string;
@@ -6,6 +6,8 @@ import { EventEmitter } from 'eventemitter3';
6
6
  import * as stream from 'stream';
7
7
  import { Transform } from 'stream';
8
8
  import EventEmitter$1 from 'events';
9
+ import * as perf_hooks from 'perf_hooks';
10
+ import http from 'http';
9
11
  export { default as MBP } from 'meta-buffer-pack';
10
12
 
11
13
  type STATE = {
@@ -55,6 +57,7 @@ type SIZE_LIMIT = {
55
57
  TAG_LEN2: number;
56
58
  CONNECTION_CHECKER_PERIOD: number;
57
59
  CLIENT_PING_PERIOD: number;
60
+ SERVER_HELLO_TIMEOUT: number;
58
61
  PROMISE_TIMEOUT: number;
59
62
  DID: number;
60
63
  CID: number;
@@ -64,6 +67,7 @@ declare namespace SIZE_LIMIT {
64
67
  let TAG_LEN2: number;
65
68
  let CONNECTION_CHECKER_PERIOD: number;
66
69
  let CLIENT_PING_PERIOD: number;
70
+ let SERVER_HELLO_TIMEOUT: number;
67
71
  let PROMISE_TIMEOUT: number;
68
72
  let DID: number;
69
73
  let CID: number;
@@ -350,6 +354,15 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
350
354
  * @param {string} url2 - The new URL to redirect to.
351
355
  */
352
356
  redirect(url2: string): void;
357
+ /**
358
+ * Closes a connection that has not got the server's hello in SIZE_LIMIT.SERVER_HELLO_TIMEOUT
359
+ * (a server that cannot be reached, or a connection that opens but never answers). With
360
+ * autoReconnect the client then reconnects to this.url, so a failed redirect falls back to the
361
+ * original server, as the Arduino library does.
362
+ */
363
+ armHelloTimer(): void;
364
+ helloTimerID: any;
365
+ clearHelloTimer(): void;
353
366
  /**
354
367
  * Opens the WebSocket connection.
355
368
  * @param {string} [url] - Optional URL to connect to. If not provided, uses the instance's URL.
@@ -686,6 +699,25 @@ declare class Host extends EventEmitter$1<[never]> {
686
699
  closed: boolean;
687
700
  /** @type {Map<string, Readonly<object>>} cid -> from, connections that sent to this host */
688
701
  _participants: Map<string, Readonly<object>>;
702
+ /** cid -> { inputs, firstAt, lastAt }: activity of each participant, for the dashboard */
703
+ _activity: Map<any, any>;
704
+ counters: {
705
+ inbound: number;
706
+ rejected: number;
707
+ denied: number;
708
+ published: number;
709
+ delivered: number;
710
+ sent: number;
711
+ joins: number;
712
+ leaves: number;
713
+ errors: number;
714
+ handlerMs: number;
715
+ };
716
+ handlerMaxMs: number;
717
+ reported: {};
718
+ _journal: any[];
719
+ _journalSeq: number;
720
+ _loops: Set<any>;
689
721
  /** Connections that have sent to this host and are still online: cid -> from. */
690
722
  get participants(): Map<string, object>;
691
723
  /** Stop tracking a participant; no 'leave' is emitted for it (until it sends again). */
@@ -700,6 +732,35 @@ declare class Host extends EventEmitter$1<[never]> {
700
732
  * or its receive buffer is too small for the message.
701
733
  */
702
734
  to(cid: any, topic: any, ...args: any[]): boolean;
735
+ /**
736
+ * Values to show on the server dashboard ("game" panel), e.g. { round: 3, players: 8 }.
737
+ * Merged into the last report; a key set to null is removed. Numbers, short strings and booleans,
738
+ * at most 20 keys.
739
+ */
740
+ report(values: any): this;
741
+ /**
742
+ * Run fn(now) every intervalMs, like setInterval, and measure it for the dashboard: the gap between
743
+ * ticks and how long each tick took. A throwing tick is reported as an 'error' and the loop goes on.
744
+ * Returns a stop function; close() stops every loop.
745
+ */
746
+ loop(intervalMs: any, fn: any): () => void;
747
+ /** Timing of the loops started with loop(): target, ticks, gap p50/p99 and step average/max (ms). */
748
+ loopStats(): {
749
+ intervalMs: any;
750
+ ticks: any;
751
+ gapP50: any;
752
+ gapP99: any;
753
+ gapMax: number;
754
+ stepAvg: number;
755
+ stepMax: number;
756
+ }[];
757
+ /** Participants with their activity: [{ from, inputs, firstAt, lastAt }]. */
758
+ activity(): any[];
759
+ /** Notable events after sequence `after`: [{ seq, at, kind: 'join'|'leave'|'denied'|'error', ... }]. */
760
+ journal(after?: number): any[];
761
+ _note(kind: any, data: any): void;
762
+ _denied(remote: any, tag: any): void;
763
+ _failed(error: any): void;
703
764
  /** Release the tags (they become ordinary channels again) and the host's retained values. */
704
765
  close(): void;
705
766
  _open(): void;
@@ -936,6 +997,135 @@ declare class Manager {
936
997
  close(): void;
937
998
  }
938
999
 
1000
+ declare class ServerStats {
1001
+ constructor(server: any, { onSample }?: {
1002
+ onSample?: null | undefined;
1003
+ });
1004
+ server: any;
1005
+ onSample: any;
1006
+ base: any;
1007
+ counters: {
1008
+ opened: number;
1009
+ closed: number;
1010
+ authFailed: number;
1011
+ };
1012
+ onState: (_peer: any, _previous: any) => void;
1013
+ delay: perf_hooks.IntervalHistogram;
1014
+ cpu: NodeJS.CpuUsage;
1015
+ elu: perf_hooks.EventLoopUtilization;
1016
+ previousAt: number;
1017
+ previous: {
1018
+ opened: number;
1019
+ closed: number;
1020
+ authFailed: number;
1021
+ };
1022
+ timer: NodeJS.Timeout;
1023
+ sample(): void;
1024
+ value: {
1025
+ at: number;
1026
+ total: any;
1027
+ authenticated: number;
1028
+ anonymous: number;
1029
+ websocket: number;
1030
+ transports: {
1031
+ websocket: {
1032
+ total: number;
1033
+ authenticated: number;
1034
+ };
1035
+ tcp: {
1036
+ total: number;
1037
+ authenticated: number;
1038
+ };
1039
+ };
1040
+ hostAvailableBytes: number | null;
1041
+ hostTotalBytes: number;
1042
+ channels: any;
1043
+ states: {};
1044
+ queuedBytes: number;
1045
+ maxQueuedBytes: number;
1046
+ txQueuePeakBytes: number;
1047
+ txWriteFalseCount: number;
1048
+ txDrainMaxMs: number;
1049
+ txBlockedConnections: number;
1050
+ txBlockedMaxMs: number;
1051
+ counters: {
1052
+ opened: number;
1053
+ closed: number;
1054
+ authFailed: number;
1055
+ };
1056
+ rates: {
1057
+ [k: string]: number;
1058
+ };
1059
+ rss: number;
1060
+ heapUsed: number;
1061
+ cpuPercent: number;
1062
+ eventLoopUtilization: number;
1063
+ eventLoopP99Ms: number;
1064
+ quota: {
1065
+ anonymous: any;
1066
+ profiles: any;
1067
+ };
1068
+ } | undefined;
1069
+ dispose(): void;
1070
+ }
1071
+
1072
+ /**
1073
+ * The server dashboard: a web page (options.path) that shows the server and its hosts live.
1074
+ * It talks to the page through IOSignal itself: viewers send 'hello' to DASHBOARD.IN, a host checks
1075
+ * access, and every second it sends the latest sample to each viewer with host.to().
1076
+ *
1077
+ * options (all optional):
1078
+ * path: '/dashboard'
1079
+ * access: 'open' | { token: '...' } | { login: { roles: ['admin'], cids: [] } }
1080
+ * panels: panels shown first (DASHBOARD_PANELS); viewers can switch them
1081
+ * history: seconds kept for the charts (default 300, 10-3600)
1082
+ * maxViewers: default 20
1083
+ * showIdentities: show participant CIDs and names (default: true unless access is 'open')
1084
+ */
1085
+ declare class Dashboard {
1086
+ constructor(server: any, options?: {});
1087
+ path: string;
1088
+ access: {
1089
+ mode: string;
1090
+ hash?: undefined;
1091
+ roles?: undefined;
1092
+ cids?: undefined;
1093
+ } | {
1094
+ mode: string;
1095
+ hash: NonSharedBuffer;
1096
+ roles?: undefined;
1097
+ cids?: undefined;
1098
+ } | {
1099
+ mode: string;
1100
+ roles: any[];
1101
+ cids: Set<any>;
1102
+ hash?: undefined;
1103
+ };
1104
+ panels: any[];
1105
+ history: any;
1106
+ maxViewers: any;
1107
+ showIdentities: any;
1108
+ server: any;
1109
+ startedAt: number;
1110
+ viewers: Map<any, any>;
1111
+ series: any[];
1112
+ lastHostCounters: Map<any, any>;
1113
+ lastJournal: Map<any, any>;
1114
+ events: any[];
1115
+ host: any;
1116
+ stats: ServerStats;
1117
+ /** Whether this viewer (the server's view of it) may watch. */
1118
+ allowed(from: any, msg: any): boolean;
1119
+ /**
1120
+ * Serves the page (GET path) and the browser client (path + '/io.js'). Returns true when it
1121
+ * answered. A Server with `port` calls it itself; with your own httpServer call it first in
1122
+ * your request handler: if (server.dashboard.handle(req, res)) return
1123
+ */
1124
+ handle(req: any, res: any): boolean;
1125
+ close(): void;
1126
+ #private;
1127
+ }
1128
+
939
1129
  declare class Server extends EventEmitter$1<[never]> {
940
1130
  /**
941
1131
  * @param {object} options Server configuration.
@@ -962,6 +1152,9 @@ declare class Server extends EventEmitter$1<[never]> {
962
1152
  * options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
963
1153
  * options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
964
1154
  * manager's own policy without changing it, so an auth manager can be shared between servers.
1155
+ * options.dashboard: true or { path, access, panels, history, maxViewers, showIdentities } shows a live
1156
+ * status page of the server and its hosts (see Dashboard.js); off by default. With `port` the Server
1157
+ * serves it itself; with your own httpServer call server.dashboard.handle(req, res) in its handler.
965
1158
  * A failed listen (e.g. EADDRINUSE) is emitted as 'error'.
966
1159
  * @param {any} [authManager] Optional authentication manager.
967
1160
  */
@@ -988,9 +1181,11 @@ declare class Server extends EventEmitter$1<[never]> {
988
1181
  httpServer: any;
989
1182
  wsPath: any;
990
1183
  manager: Manager;
1184
+ dashboard: Dashboard | null;
991
1185
  serverCountToListen: number;
992
1186
  listeningServerCount: number;
993
1187
  startWSServer(): void;
1188
+ ownHttp: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | undefined;
994
1189
  startCongServer(): void;
995
1190
  congServer: any;
996
1191
  onListenerError(name: any, err: any): void;
@@ -1189,6 +1384,7 @@ declare class RedisKeyProvider {
1189
1384
  redis: any;
1190
1385
  getAuth(id: any): Promise<any>;
1191
1386
  getAuthIdList(): Promise<any>;
1387
+ scanKeys(pattern: any): Promise<any>;
1192
1388
  addAuth(id: any, keyStr: any, cid: string | undefined, role: any, quota: any): Promise<any>;
1193
1389
  delAuth(id: any): Promise<any>;
1194
1390
  save(id: any): Promise<any>;
@@ -1329,12 +1525,25 @@ declare class BohoAuth {
1329
1525
  get keepOldConnection(): boolean;
1330
1526
  emitAuthEvent(event: any): void;
1331
1527
  send_auth_fail(peer: any, reason: any): void;
1528
+ /**
1529
+ * Hook for a subclass: decide where a verified login belongs before it is accepted.
1530
+ * Called after the key and role checks, before quotas and the duplicate login check.
1531
+ * Return null to accept the login here, or a message (e.g. SERVER_REDIRECT) that is sent to the
1532
+ * client instead of AUTH_RES before the connection is closed. The default accepts every login.
1533
+ * @param {object} peer the connection
1534
+ * @param {object} authInfo the key provider's entry for the login ID (cid, uid, role, quota, ...)
1535
+ * @param {string} role resolved role
1536
+ * @param {string} id login ID
1537
+ * @returns {Promise<Uint8Array | null> | Uint8Array | null}
1538
+ */
1539
+ beforeAccept(peer: object, authInfo: object, role: string, id: string): Promise<Uint8Array | null> | Uint8Array | null;
1332
1540
  verify_auth_req(auth_req: any, peer: any): Promise<any>;
1333
1541
  getAuth(id: any): Promise<any>;
1334
1542
  getAuthIdList(): Promise<any>;
1335
1543
  addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): Promise<any>;
1336
1544
  delAuth(id: any): Promise<any>;
1337
1545
  save(): Promise<any>;
1546
+ #private;
1338
1547
  }
1339
1548
 
1340
1549
  declare const version: string;