iosignal 9.14.0 → 9.21.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 +17 -3
- package/README.md +26 -3
- package/dist/browser/esm/io.d.ts +23 -0
- package/dist/browser/esm/io.js +3 -3
- package/dist/browser/esm/io.js.map +1 -1
- package/dist/browser/iife/io.js +3 -3
- package/dist/browser/iife/io.js.map +1 -1
- package/dist/node/iosignal.cjs +360 -53
- package/dist/node/iosignal.d.cts +69 -5
- package/dist/node/iosignal.d.ts +69 -5
- package/dist/node/iosignal.js +360 -54
- package/dist/types/client/IOCore.d.ts +23 -0
- package/dist/types/common/constants.d.ts +10 -0
- package/package.json +1 -1
package/dist/node/iosignal.d.cts
CHANGED
|
@@ -57,6 +57,11 @@ type SIZE_LIMIT = {
|
|
|
57
57
|
TAG_LEN2: number;
|
|
58
58
|
CONNECTION_CHECKER_PERIOD: number;
|
|
59
59
|
CLIENT_PING_PERIOD: number;
|
|
60
|
+
PONG_TIMEOUT: number;
|
|
61
|
+
RECONNECT_JITTER: number;
|
|
62
|
+
RECONNECT_BASE: number;
|
|
63
|
+
RECONNECT_MAX: number;
|
|
64
|
+
SERVER_HELLO_TIMEOUT: number;
|
|
60
65
|
PROMISE_TIMEOUT: number;
|
|
61
66
|
DID: number;
|
|
62
67
|
CID: number;
|
|
@@ -66,6 +71,11 @@ declare namespace SIZE_LIMIT {
|
|
|
66
71
|
let TAG_LEN2: number;
|
|
67
72
|
let CONNECTION_CHECKER_PERIOD: number;
|
|
68
73
|
let CLIENT_PING_PERIOD: number;
|
|
74
|
+
let PONG_TIMEOUT: number;
|
|
75
|
+
let RECONNECT_JITTER: number;
|
|
76
|
+
let RECONNECT_BASE: number;
|
|
77
|
+
let RECONNECT_MAX: number;
|
|
78
|
+
let SERVER_HELLO_TIMEOUT: number;
|
|
69
79
|
let PROMISE_TIMEOUT: number;
|
|
70
80
|
let DID: number;
|
|
71
81
|
let CID: number;
|
|
@@ -228,6 +238,16 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
228
238
|
* @type {number}
|
|
229
239
|
*/
|
|
230
240
|
lastTxRxTime: number;
|
|
241
|
+
/**
|
|
242
|
+
* Last time anything was received from the server (see keepAlive()).
|
|
243
|
+
* @type {number}
|
|
244
|
+
*/
|
|
245
|
+
lastRxTime: number;
|
|
246
|
+
/** @private Time of a PING that has had no answer yet; 0 when none is pending. */
|
|
247
|
+
private _pingSentAt;
|
|
248
|
+
/** @private Connections closed since the last ready, and the earliest time of the next automatic attempt. */
|
|
249
|
+
private _reconnectAttempts;
|
|
250
|
+
_nextConnectAt: number;
|
|
231
251
|
/**
|
|
232
252
|
* Period for connection checker.
|
|
233
253
|
* @type {number}
|
|
@@ -347,11 +367,24 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
347
367
|
* is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
|
|
348
368
|
*/
|
|
349
369
|
keepAlive(): void;
|
|
370
|
+
/** @private When keepAlive() may connect again after this close: see SIZE_LIMIT.RECONNECT_*. */
|
|
371
|
+
private scheduleReconnect;
|
|
372
|
+
/** @private True from the socket opening until it closes (any state a server message can arrive in). */
|
|
373
|
+
private isLinkUp;
|
|
350
374
|
/**
|
|
351
375
|
* Redirects the connection to a new URL.
|
|
352
376
|
* @param {string} url2 - The new URL to redirect to.
|
|
353
377
|
*/
|
|
354
378
|
redirect(url2: string): void;
|
|
379
|
+
/**
|
|
380
|
+
* Closes a connection that has not got the server's hello in SIZE_LIMIT.SERVER_HELLO_TIMEOUT
|
|
381
|
+
* (a server that cannot be reached, or a connection that opens but never answers). With
|
|
382
|
+
* autoReconnect the client then reconnects to this.url, so a failed redirect falls back to the
|
|
383
|
+
* original server, as the Arduino library does.
|
|
384
|
+
*/
|
|
385
|
+
armHelloTimer(): void;
|
|
386
|
+
helloTimerID: any;
|
|
387
|
+
clearHelloTimer(): void;
|
|
355
388
|
/**
|
|
356
389
|
* Opens the WebSocket connection.
|
|
357
390
|
* @param {string} [url] - Optional URL to connect to. If not provided, uses the instance's URL.
|
|
@@ -907,6 +940,7 @@ declare class Manager {
|
|
|
907
940
|
oversizeRejected: number;
|
|
908
941
|
rateLimited: number;
|
|
909
942
|
peerRxLimitSkipped: number;
|
|
943
|
+
subscriptionsRejected: number;
|
|
910
944
|
policyDenied: number;
|
|
911
945
|
hostInbound: number;
|
|
912
946
|
hostRejected: number;
|
|
@@ -1130,13 +1164,13 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
1130
1164
|
* loopback/private peer, true always, false never, or N trusted proxy hops.
|
|
1131
1165
|
* options.maxPayload: largest WebSocket message and CongSocket frame in bytes (default 32 MiB).
|
|
1132
1166
|
* options.maxBufferedBytes: close a peer whose unsent data exceeds this (default 64 MiB).
|
|
1133
|
-
* options.membersOnly:
|
|
1167
|
+
* options.membersOnly: only authenticated connections may send signals or subscribe.
|
|
1134
1168
|
* options.logMessages: log each received message after decryption: type and tag, never the payload.
|
|
1135
1169
|
* options.logStats: print a one-line summary every N ms (>= 1000; 0 = off); see stats().
|
|
1136
|
-
* options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries }.
|
|
1170
|
+
* options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries, requireEncryption }.
|
|
1137
1171
|
* options.retain: retained message limits, see serverOption.retain; adjustable later on server.retain.
|
|
1138
1172
|
* options.quotas: named quota profiles { name: { maxMessageBytes, fanout, msgPerSec, bytesPerSec,
|
|
1139
|
-
* maxConnections } }, merged over serverOption.quotas; always enforced, null is unlimited.
|
|
1173
|
+
* maxConnections, maxSubscriptions } }, merged over serverOption.quotas; always enforced, null is unlimited.
|
|
1140
1174
|
* Adjustable later on server.quotas. The client is told its maxMessageBytes.
|
|
1141
1175
|
* options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
|
|
1142
1176
|
* options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
|
|
@@ -1263,6 +1297,7 @@ declare namespace serverOption {
|
|
|
1263
1297
|
let maxClockSkewMs: number;
|
|
1264
1298
|
let authChallengeMaxAgeMs: number;
|
|
1265
1299
|
let maxReplayEntries: number;
|
|
1300
|
+
let requireEncryption: boolean;
|
|
1266
1301
|
}
|
|
1267
1302
|
export namespace quotas {
|
|
1268
1303
|
namespace anonymous {
|
|
@@ -1271,6 +1306,7 @@ declare namespace serverOption {
|
|
|
1271
1306
|
let msgPerSec: number;
|
|
1272
1307
|
let bytesPerSec: number;
|
|
1273
1308
|
let maxConnections: null;
|
|
1309
|
+
let maxSubscriptions: number;
|
|
1274
1310
|
}
|
|
1275
1311
|
namespace basic {
|
|
1276
1312
|
let maxMessageBytes_1: number;
|
|
@@ -1283,6 +1319,8 @@ declare namespace serverOption {
|
|
|
1283
1319
|
export { bytesPerSec_1 as bytesPerSec };
|
|
1284
1320
|
let maxConnections_1: number;
|
|
1285
1321
|
export { maxConnections_1 as maxConnections };
|
|
1322
|
+
let maxSubscriptions_1: number;
|
|
1323
|
+
export { maxSubscriptions_1 as maxSubscriptions };
|
|
1286
1324
|
}
|
|
1287
1325
|
namespace pro {
|
|
1288
1326
|
let maxMessageBytes_2: number;
|
|
@@ -1295,6 +1333,8 @@ declare namespace serverOption {
|
|
|
1295
1333
|
export { bytesPerSec_2 as bytesPerSec };
|
|
1296
1334
|
let maxConnections_2: number;
|
|
1297
1335
|
export { maxConnections_2 as maxConnections };
|
|
1336
|
+
let maxSubscriptions_2: number;
|
|
1337
|
+
export { maxSubscriptions_2 as maxSubscriptions };
|
|
1298
1338
|
}
|
|
1299
1339
|
namespace unlimited {
|
|
1300
1340
|
let maxMessageBytes_3: null;
|
|
@@ -1307,6 +1347,8 @@ declare namespace serverOption {
|
|
|
1307
1347
|
export { bytesPerSec_3 as bytesPerSec };
|
|
1308
1348
|
let maxConnections_3: null;
|
|
1309
1349
|
export { maxConnections_3 as maxConnections };
|
|
1350
|
+
let maxSubscriptions_3: null;
|
|
1351
|
+
export { maxSubscriptions_3 as maxSubscriptions };
|
|
1310
1352
|
}
|
|
1311
1353
|
}
|
|
1312
1354
|
export let anonymousQuota: string;
|
|
@@ -1340,6 +1382,9 @@ declare namespace serverOption {
|
|
|
1340
1382
|
}
|
|
1341
1383
|
export namespace auth_1 {
|
|
1342
1384
|
let failDelay: number;
|
|
1385
|
+
let maxFailuresPerConnection: number;
|
|
1386
|
+
let maxFailuresPerAddress: number;
|
|
1387
|
+
let failureWindowMs: number;
|
|
1343
1388
|
let duplicateLogin: string;
|
|
1344
1389
|
}
|
|
1345
1390
|
export { auth_1 as auth };
|
|
@@ -1355,6 +1400,7 @@ declare function getIPv6PrefixHexString(ip: any): string | null;
|
|
|
1355
1400
|
declare function numberWithCommas(x: any): any;
|
|
1356
1401
|
declare function getIPv4HexString(ipStr: any): string;
|
|
1357
1402
|
declare function getLocalAddress(): string;
|
|
1403
|
+
declare function checkLoginId(id: any): string;
|
|
1358
1404
|
declare function delay(ms: any): Promise<any>;
|
|
1359
1405
|
|
|
1360
1406
|
declare class FileKeyProvider {
|
|
@@ -1373,6 +1419,7 @@ declare class RedisKeyProvider {
|
|
|
1373
1419
|
redis: any;
|
|
1374
1420
|
getAuth(id: any): Promise<any>;
|
|
1375
1421
|
getAuthIdList(): Promise<any>;
|
|
1422
|
+
scanKeys(pattern: any): Promise<any>;
|
|
1376
1423
|
addAuth(id: any, keyStr: any, cid: string | undefined, role: any, quota: any): Promise<any>;
|
|
1377
1424
|
delAuth(id: any): Promise<any>;
|
|
1378
1425
|
save(id: any): Promise<any>;
|
|
@@ -1506,21 +1553,38 @@ declare class BohoAuth {
|
|
|
1506
1553
|
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
1507
1554
|
onAuthEvent: ((event: object) => any) | null;
|
|
1508
1555
|
resolveQuota: typeof defaultQuota | ((authInfo: object, role: string) => string | Promise<string>);
|
|
1556
|
+
addressFailures: Map<any, any>;
|
|
1509
1557
|
authLogger: FileLogger | undefined;
|
|
1510
1558
|
/** Policy for a connection: its Server's duplicateLogin option, else this instance's policy. */
|
|
1511
1559
|
duplicateLoginFor(peer: any): any;
|
|
1512
1560
|
set keepOldConnection(keepOld: boolean);
|
|
1513
1561
|
get keepOldConnection(): boolean;
|
|
1514
1562
|
emitAuthEvent(event: any): void;
|
|
1515
|
-
|
|
1563
|
+
/** True while this address has too many wrong logins: its logins are closed without a check. */
|
|
1564
|
+
addressBlocked(ip: any): boolean;
|
|
1565
|
+
send_auth_fail(peer: any, reason: any, countFailure?: boolean): void;
|
|
1566
|
+
close_unavailable(peer: any, reason: any): void;
|
|
1567
|
+
/**
|
|
1568
|
+
* Hook for a subclass: decide where a verified login belongs before it is accepted.
|
|
1569
|
+
* Called after the key and role checks, before quotas and the duplicate login check.
|
|
1570
|
+
* Return null to accept the login here, or a message (e.g. SERVER_REDIRECT) that is sent to the
|
|
1571
|
+
* client instead of AUTH_RES before the connection is closed. The default accepts every login.
|
|
1572
|
+
* @param {object} peer the connection
|
|
1573
|
+
* @param {object} authInfo the key provider's entry for the login ID (cid, uid, role, quota, ...)
|
|
1574
|
+
* @param {string} role resolved role
|
|
1575
|
+
* @param {string} id login ID
|
|
1576
|
+
* @returns {Promise<Uint8Array | null> | Uint8Array | null}
|
|
1577
|
+
*/
|
|
1578
|
+
beforeAccept(peer: object, authInfo: object, role: string, id: string): Promise<Uint8Array | null> | Uint8Array | null;
|
|
1516
1579
|
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
1517
1580
|
getAuth(id: any): Promise<any>;
|
|
1518
1581
|
getAuthIdList(): Promise<any>;
|
|
1519
1582
|
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): Promise<any>;
|
|
1520
1583
|
delAuth(id: any): Promise<any>;
|
|
1521
1584
|
save(): Promise<any>;
|
|
1585
|
+
#private;
|
|
1522
1586
|
}
|
|
1523
1587
|
|
|
1524
1588
|
declare const version: string;
|
|
1525
1589
|
|
|
1526
|
-
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 };
|
|
1590
|
+
export { BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, LocalKeyProvider, PAYLOAD_TYPE, ROLES, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS, Server, StringKeyProvider, checkLoginId, defaultQuota, delay, getIPv4HexString, getIPv6PrefixHexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, hasRole, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };
|
package/dist/node/iosignal.d.ts
CHANGED
|
@@ -57,6 +57,11 @@ type SIZE_LIMIT = {
|
|
|
57
57
|
TAG_LEN2: number;
|
|
58
58
|
CONNECTION_CHECKER_PERIOD: number;
|
|
59
59
|
CLIENT_PING_PERIOD: number;
|
|
60
|
+
PONG_TIMEOUT: number;
|
|
61
|
+
RECONNECT_JITTER: number;
|
|
62
|
+
RECONNECT_BASE: number;
|
|
63
|
+
RECONNECT_MAX: number;
|
|
64
|
+
SERVER_HELLO_TIMEOUT: number;
|
|
60
65
|
PROMISE_TIMEOUT: number;
|
|
61
66
|
DID: number;
|
|
62
67
|
CID: number;
|
|
@@ -66,6 +71,11 @@ declare namespace SIZE_LIMIT {
|
|
|
66
71
|
let TAG_LEN2: number;
|
|
67
72
|
let CONNECTION_CHECKER_PERIOD: number;
|
|
68
73
|
let CLIENT_PING_PERIOD: number;
|
|
74
|
+
let PONG_TIMEOUT: number;
|
|
75
|
+
let RECONNECT_JITTER: number;
|
|
76
|
+
let RECONNECT_BASE: number;
|
|
77
|
+
let RECONNECT_MAX: number;
|
|
78
|
+
let SERVER_HELLO_TIMEOUT: number;
|
|
69
79
|
let PROMISE_TIMEOUT: number;
|
|
70
80
|
let DID: number;
|
|
71
81
|
let CID: number;
|
|
@@ -228,6 +238,16 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
228
238
|
* @type {number}
|
|
229
239
|
*/
|
|
230
240
|
lastTxRxTime: number;
|
|
241
|
+
/**
|
|
242
|
+
* Last time anything was received from the server (see keepAlive()).
|
|
243
|
+
* @type {number}
|
|
244
|
+
*/
|
|
245
|
+
lastRxTime: number;
|
|
246
|
+
/** @private Time of a PING that has had no answer yet; 0 when none is pending. */
|
|
247
|
+
private _pingSentAt;
|
|
248
|
+
/** @private Connections closed since the last ready, and the earliest time of the next automatic attempt. */
|
|
249
|
+
private _reconnectAttempts;
|
|
250
|
+
_nextConnectAt: number;
|
|
231
251
|
/**
|
|
232
252
|
* Period for connection checker.
|
|
233
253
|
* @type {number}
|
|
@@ -347,11 +367,24 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
|
|
|
347
367
|
* is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
|
|
348
368
|
*/
|
|
349
369
|
keepAlive(): void;
|
|
370
|
+
/** @private When keepAlive() may connect again after this close: see SIZE_LIMIT.RECONNECT_*. */
|
|
371
|
+
private scheduleReconnect;
|
|
372
|
+
/** @private True from the socket opening until it closes (any state a server message can arrive in). */
|
|
373
|
+
private isLinkUp;
|
|
350
374
|
/**
|
|
351
375
|
* Redirects the connection to a new URL.
|
|
352
376
|
* @param {string} url2 - The new URL to redirect to.
|
|
353
377
|
*/
|
|
354
378
|
redirect(url2: string): void;
|
|
379
|
+
/**
|
|
380
|
+
* Closes a connection that has not got the server's hello in SIZE_LIMIT.SERVER_HELLO_TIMEOUT
|
|
381
|
+
* (a server that cannot be reached, or a connection that opens but never answers). With
|
|
382
|
+
* autoReconnect the client then reconnects to this.url, so a failed redirect falls back to the
|
|
383
|
+
* original server, as the Arduino library does.
|
|
384
|
+
*/
|
|
385
|
+
armHelloTimer(): void;
|
|
386
|
+
helloTimerID: any;
|
|
387
|
+
clearHelloTimer(): void;
|
|
355
388
|
/**
|
|
356
389
|
* Opens the WebSocket connection.
|
|
357
390
|
* @param {string} [url] - Optional URL to connect to. If not provided, uses the instance's URL.
|
|
@@ -907,6 +940,7 @@ declare class Manager {
|
|
|
907
940
|
oversizeRejected: number;
|
|
908
941
|
rateLimited: number;
|
|
909
942
|
peerRxLimitSkipped: number;
|
|
943
|
+
subscriptionsRejected: number;
|
|
910
944
|
policyDenied: number;
|
|
911
945
|
hostInbound: number;
|
|
912
946
|
hostRejected: number;
|
|
@@ -1130,13 +1164,13 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
1130
1164
|
* loopback/private peer, true always, false never, or N trusted proxy hops.
|
|
1131
1165
|
* options.maxPayload: largest WebSocket message and CongSocket frame in bytes (default 32 MiB).
|
|
1132
1166
|
* options.maxBufferedBytes: close a peer whose unsent data exceeds this (default 64 MiB).
|
|
1133
|
-
* options.membersOnly:
|
|
1167
|
+
* options.membersOnly: only authenticated connections may send signals or subscribe.
|
|
1134
1168
|
* options.logMessages: log each received message after decryption: type and tag, never the payload.
|
|
1135
1169
|
* options.logStats: print a one-line summary every N ms (>= 1000; 0 = off); see stats().
|
|
1136
|
-
* options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries }.
|
|
1170
|
+
* options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries, requireEncryption }.
|
|
1137
1171
|
* options.retain: retained message limits, see serverOption.retain; adjustable later on server.retain.
|
|
1138
1172
|
* options.quotas: named quota profiles { name: { maxMessageBytes, fanout, msgPerSec, bytesPerSec,
|
|
1139
|
-
* maxConnections } }, merged over serverOption.quotas; always enforced, null is unlimited.
|
|
1173
|
+
* maxConnections, maxSubscriptions } }, merged over serverOption.quotas; always enforced, null is unlimited.
|
|
1140
1174
|
* Adjustable later on server.quotas. The client is told its maxMessageBytes.
|
|
1141
1175
|
* options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
|
|
1142
1176
|
* options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
|
|
@@ -1263,6 +1297,7 @@ declare namespace serverOption {
|
|
|
1263
1297
|
let maxClockSkewMs: number;
|
|
1264
1298
|
let authChallengeMaxAgeMs: number;
|
|
1265
1299
|
let maxReplayEntries: number;
|
|
1300
|
+
let requireEncryption: boolean;
|
|
1266
1301
|
}
|
|
1267
1302
|
export namespace quotas {
|
|
1268
1303
|
namespace anonymous {
|
|
@@ -1271,6 +1306,7 @@ declare namespace serverOption {
|
|
|
1271
1306
|
let msgPerSec: number;
|
|
1272
1307
|
let bytesPerSec: number;
|
|
1273
1308
|
let maxConnections: null;
|
|
1309
|
+
let maxSubscriptions: number;
|
|
1274
1310
|
}
|
|
1275
1311
|
namespace basic {
|
|
1276
1312
|
let maxMessageBytes_1: number;
|
|
@@ -1283,6 +1319,8 @@ declare namespace serverOption {
|
|
|
1283
1319
|
export { bytesPerSec_1 as bytesPerSec };
|
|
1284
1320
|
let maxConnections_1: number;
|
|
1285
1321
|
export { maxConnections_1 as maxConnections };
|
|
1322
|
+
let maxSubscriptions_1: number;
|
|
1323
|
+
export { maxSubscriptions_1 as maxSubscriptions };
|
|
1286
1324
|
}
|
|
1287
1325
|
namespace pro {
|
|
1288
1326
|
let maxMessageBytes_2: number;
|
|
@@ -1295,6 +1333,8 @@ declare namespace serverOption {
|
|
|
1295
1333
|
export { bytesPerSec_2 as bytesPerSec };
|
|
1296
1334
|
let maxConnections_2: number;
|
|
1297
1335
|
export { maxConnections_2 as maxConnections };
|
|
1336
|
+
let maxSubscriptions_2: number;
|
|
1337
|
+
export { maxSubscriptions_2 as maxSubscriptions };
|
|
1298
1338
|
}
|
|
1299
1339
|
namespace unlimited {
|
|
1300
1340
|
let maxMessageBytes_3: null;
|
|
@@ -1307,6 +1347,8 @@ declare namespace serverOption {
|
|
|
1307
1347
|
export { bytesPerSec_3 as bytesPerSec };
|
|
1308
1348
|
let maxConnections_3: null;
|
|
1309
1349
|
export { maxConnections_3 as maxConnections };
|
|
1350
|
+
let maxSubscriptions_3: null;
|
|
1351
|
+
export { maxSubscriptions_3 as maxSubscriptions };
|
|
1310
1352
|
}
|
|
1311
1353
|
}
|
|
1312
1354
|
export let anonymousQuota: string;
|
|
@@ -1340,6 +1382,9 @@ declare namespace serverOption {
|
|
|
1340
1382
|
}
|
|
1341
1383
|
export namespace auth_1 {
|
|
1342
1384
|
let failDelay: number;
|
|
1385
|
+
let maxFailuresPerConnection: number;
|
|
1386
|
+
let maxFailuresPerAddress: number;
|
|
1387
|
+
let failureWindowMs: number;
|
|
1343
1388
|
let duplicateLogin: string;
|
|
1344
1389
|
}
|
|
1345
1390
|
export { auth_1 as auth };
|
|
@@ -1355,6 +1400,7 @@ declare function getIPv6PrefixHexString(ip: any): string | null;
|
|
|
1355
1400
|
declare function numberWithCommas(x: any): any;
|
|
1356
1401
|
declare function getIPv4HexString(ipStr: any): string;
|
|
1357
1402
|
declare function getLocalAddress(): string;
|
|
1403
|
+
declare function checkLoginId(id: any): string;
|
|
1358
1404
|
declare function delay(ms: any): Promise<any>;
|
|
1359
1405
|
|
|
1360
1406
|
declare class FileKeyProvider {
|
|
@@ -1373,6 +1419,7 @@ declare class RedisKeyProvider {
|
|
|
1373
1419
|
redis: any;
|
|
1374
1420
|
getAuth(id: any): Promise<any>;
|
|
1375
1421
|
getAuthIdList(): Promise<any>;
|
|
1422
|
+
scanKeys(pattern: any): Promise<any>;
|
|
1376
1423
|
addAuth(id: any, keyStr: any, cid: string | undefined, role: any, quota: any): Promise<any>;
|
|
1377
1424
|
delAuth(id: any): Promise<any>;
|
|
1378
1425
|
save(id: any): Promise<any>;
|
|
@@ -1506,21 +1553,38 @@ declare class BohoAuth {
|
|
|
1506
1553
|
get duplicateLogin(): "keepOld" | "keepNew" | null;
|
|
1507
1554
|
onAuthEvent: ((event: object) => any) | null;
|
|
1508
1555
|
resolveQuota: typeof defaultQuota | ((authInfo: object, role: string) => string | Promise<string>);
|
|
1556
|
+
addressFailures: Map<any, any>;
|
|
1509
1557
|
authLogger: FileLogger | undefined;
|
|
1510
1558
|
/** Policy for a connection: its Server's duplicateLogin option, else this instance's policy. */
|
|
1511
1559
|
duplicateLoginFor(peer: any): any;
|
|
1512
1560
|
set keepOldConnection(keepOld: boolean);
|
|
1513
1561
|
get keepOldConnection(): boolean;
|
|
1514
1562
|
emitAuthEvent(event: any): void;
|
|
1515
|
-
|
|
1563
|
+
/** True while this address has too many wrong logins: its logins are closed without a check. */
|
|
1564
|
+
addressBlocked(ip: any): boolean;
|
|
1565
|
+
send_auth_fail(peer: any, reason: any, countFailure?: boolean): void;
|
|
1566
|
+
close_unavailable(peer: any, reason: any): void;
|
|
1567
|
+
/**
|
|
1568
|
+
* Hook for a subclass: decide where a verified login belongs before it is accepted.
|
|
1569
|
+
* Called after the key and role checks, before quotas and the duplicate login check.
|
|
1570
|
+
* Return null to accept the login here, or a message (e.g. SERVER_REDIRECT) that is sent to the
|
|
1571
|
+
* client instead of AUTH_RES before the connection is closed. The default accepts every login.
|
|
1572
|
+
* @param {object} peer the connection
|
|
1573
|
+
* @param {object} authInfo the key provider's entry for the login ID (cid, uid, role, quota, ...)
|
|
1574
|
+
* @param {string} role resolved role
|
|
1575
|
+
* @param {string} id login ID
|
|
1576
|
+
* @returns {Promise<Uint8Array | null> | Uint8Array | null}
|
|
1577
|
+
*/
|
|
1578
|
+
beforeAccept(peer: object, authInfo: object, role: string, id: string): Promise<Uint8Array | null> | Uint8Array | null;
|
|
1516
1579
|
verify_auth_req(auth_req: any, peer: any): Promise<any>;
|
|
1517
1580
|
getAuth(id: any): Promise<any>;
|
|
1518
1581
|
getAuthIdList(): Promise<any>;
|
|
1519
1582
|
addAuth(id: any, keyStr: any, cid: any, role: any, quota: any): Promise<any>;
|
|
1520
1583
|
delAuth(id: any): Promise<any>;
|
|
1521
1584
|
save(): Promise<any>;
|
|
1585
|
+
#private;
|
|
1522
1586
|
}
|
|
1523
1587
|
|
|
1524
1588
|
declare const version: string;
|
|
1525
1589
|
|
|
1526
|
-
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 };
|
|
1590
|
+
export { BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, LocalKeyProvider, PAYLOAD_TYPE, ROLES, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS, Server, StringKeyProvider, checkLoginId, defaultQuota, delay, getIPv4HexString, getIPv6PrefixHexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, hasRole, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };
|