iosignal 9.19.0 → 9.22.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.
@@ -57,6 +57,10 @@ 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;
60
64
  SERVER_HELLO_TIMEOUT: number;
61
65
  PROMISE_TIMEOUT: number;
62
66
  DID: number;
@@ -67,6 +71,10 @@ declare namespace SIZE_LIMIT {
67
71
  let TAG_LEN2: number;
68
72
  let CONNECTION_CHECKER_PERIOD: number;
69
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;
70
78
  let SERVER_HELLO_TIMEOUT: number;
71
79
  let PROMISE_TIMEOUT: number;
72
80
  let DID: number;
@@ -230,6 +238,16 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
230
238
  * @type {number}
231
239
  */
232
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;
233
251
  /**
234
252
  * Period for connection checker.
235
253
  * @type {number}
@@ -349,6 +367,10 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
349
367
  * is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
350
368
  */
351
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;
352
374
  /**
353
375
  * Redirects the connection to a new URL.
354
376
  * @param {string} url2 - The new URL to redirect to.
@@ -613,6 +635,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
613
635
  type Buffer$1 = Boho.Buffer;
614
636
 
615
637
  declare function pack(payload: any): Buffer<ArrayBufferLike>;
638
+
616
639
  declare class CongRx extends Transform {
617
640
  /**
618
641
  * @param {import('stream').TransformOptions & { maxFrameSize?: number }} [options] Stream options.
@@ -630,7 +653,6 @@ declare class CongRx extends Transform {
630
653
  skipBytes: number;
631
654
  _transform(chunk: any, encoding: any, callback: any): void;
632
655
  addData(chunk: any): void;
633
- parse(): void;
634
656
  }
635
657
 
636
658
  declare class IOCongSocket extends IOCore {
@@ -918,6 +940,7 @@ declare class Manager {
918
940
  oversizeRejected: number;
919
941
  rateLimited: number;
920
942
  peerRxLimitSkipped: number;
943
+ subscriptionsRejected: number;
921
944
  policyDenied: number;
922
945
  hostInbound: number;
923
946
  hostRejected: number;
@@ -1141,13 +1164,13 @@ declare class Server extends EventEmitter$1<[never]> {
1141
1164
  * loopback/private peer, true always, false never, or N trusted proxy hops.
1142
1165
  * options.maxPayload: largest WebSocket message and CongSocket frame in bytes (default 32 MiB).
1143
1166
  * options.maxBufferedBytes: close a peer whose unsent data exceeds this (default 64 MiB).
1144
- * options.membersOnly: drop signals from connections that are not authenticated.
1167
+ * options.membersOnly: only authenticated connections may send signals or subscribe.
1145
1168
  * options.logMessages: log each received message after decryption: type and tag, never the payload.
1146
1169
  * options.logStats: print a one-line summary every N ms (>= 1000; 0 = off); see stats().
1147
- * options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries }.
1170
+ * options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries, requireEncryption }.
1148
1171
  * options.retain: retained message limits, see serverOption.retain; adjustable later on server.retain.
1149
1172
  * options.quotas: named quota profiles { name: { maxMessageBytes, fanout, msgPerSec, bytesPerSec,
1150
- * maxConnections } }, merged over serverOption.quotas; always enforced, null is unlimited.
1173
+ * maxConnections, maxSubscriptions } }, merged over serverOption.quotas; always enforced, null is unlimited.
1151
1174
  * Adjustable later on server.quotas. The client is told its maxMessageBytes.
1152
1175
  * options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
1153
1176
  * options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
@@ -1274,6 +1297,7 @@ declare namespace serverOption {
1274
1297
  let maxClockSkewMs: number;
1275
1298
  let authChallengeMaxAgeMs: number;
1276
1299
  let maxReplayEntries: number;
1300
+ let requireEncryption: boolean;
1277
1301
  }
1278
1302
  export namespace quotas {
1279
1303
  namespace anonymous {
@@ -1282,6 +1306,7 @@ declare namespace serverOption {
1282
1306
  let msgPerSec: number;
1283
1307
  let bytesPerSec: number;
1284
1308
  let maxConnections: null;
1309
+ let maxSubscriptions: number;
1285
1310
  }
1286
1311
  namespace basic {
1287
1312
  let maxMessageBytes_1: number;
@@ -1294,6 +1319,8 @@ declare namespace serverOption {
1294
1319
  export { bytesPerSec_1 as bytesPerSec };
1295
1320
  let maxConnections_1: number;
1296
1321
  export { maxConnections_1 as maxConnections };
1322
+ let maxSubscriptions_1: number;
1323
+ export { maxSubscriptions_1 as maxSubscriptions };
1297
1324
  }
1298
1325
  namespace pro {
1299
1326
  let maxMessageBytes_2: number;
@@ -1306,6 +1333,8 @@ declare namespace serverOption {
1306
1333
  export { bytesPerSec_2 as bytesPerSec };
1307
1334
  let maxConnections_2: number;
1308
1335
  export { maxConnections_2 as maxConnections };
1336
+ let maxSubscriptions_2: number;
1337
+ export { maxSubscriptions_2 as maxSubscriptions };
1309
1338
  }
1310
1339
  namespace unlimited {
1311
1340
  let maxMessageBytes_3: null;
@@ -1318,6 +1347,8 @@ declare namespace serverOption {
1318
1347
  export { bytesPerSec_3 as bytesPerSec };
1319
1348
  let maxConnections_3: null;
1320
1349
  export { maxConnections_3 as maxConnections };
1350
+ let maxSubscriptions_3: null;
1351
+ export { maxSubscriptions_3 as maxSubscriptions };
1321
1352
  }
1322
1353
  }
1323
1354
  export let anonymousQuota: string;
@@ -1351,6 +1382,9 @@ declare namespace serverOption {
1351
1382
  }
1352
1383
  export namespace auth_1 {
1353
1384
  let failDelay: number;
1385
+ let maxFailuresPerConnection: number;
1386
+ let maxFailuresPerAddress: number;
1387
+ let failureWindowMs: number;
1354
1388
  let duplicateLogin: string;
1355
1389
  }
1356
1390
  export { auth_1 as auth };
@@ -1366,6 +1400,7 @@ declare function getIPv6PrefixHexString(ip: any): string | null;
1366
1400
  declare function numberWithCommas(x: any): any;
1367
1401
  declare function getIPv4HexString(ipStr: any): string;
1368
1402
  declare function getLocalAddress(): string;
1403
+ declare function checkLoginId(id: any): string;
1369
1404
  declare function delay(ms: any): Promise<any>;
1370
1405
 
1371
1406
  declare class FileKeyProvider {
@@ -1518,13 +1553,17 @@ declare class BohoAuth {
1518
1553
  get duplicateLogin(): "keepOld" | "keepNew" | null;
1519
1554
  onAuthEvent: ((event: object) => any) | null;
1520
1555
  resolveQuota: typeof defaultQuota | ((authInfo: object, role: string) => string | Promise<string>);
1556
+ addressFailures: Map<any, any>;
1521
1557
  authLogger: FileLogger | undefined;
1522
1558
  /** Policy for a connection: its Server's duplicateLogin option, else this instance's policy. */
1523
1559
  duplicateLoginFor(peer: any): any;
1524
1560
  set keepOldConnection(keepOld: boolean);
1525
1561
  get keepOldConnection(): boolean;
1526
1562
  emitAuthEvent(event: any): void;
1527
- send_auth_fail(peer: any, reason: any): void;
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;
1528
1567
  /**
1529
1568
  * Hook for a subclass: decide where a verified login belongs before it is accepted.
1530
1569
  * Called after the key and role checks, before quotas and the duplicate login check.
@@ -1548,4 +1587,4 @@ declare class BohoAuth {
1548
1587
 
1549
1588
  declare const version: string;
1550
1589
 
1551
- 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 };
@@ -57,6 +57,10 @@ 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;
60
64
  SERVER_HELLO_TIMEOUT: number;
61
65
  PROMISE_TIMEOUT: number;
62
66
  DID: number;
@@ -67,6 +71,10 @@ declare namespace SIZE_LIMIT {
67
71
  let TAG_LEN2: number;
68
72
  let CONNECTION_CHECKER_PERIOD: number;
69
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;
70
78
  let SERVER_HELLO_TIMEOUT: number;
71
79
  let PROMISE_TIMEOUT: number;
72
80
  let DID: number;
@@ -230,6 +238,16 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
230
238
  * @type {number}
231
239
  */
232
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;
233
251
  /**
234
252
  * Period for connection checker.
235
253
  * @type {number}
@@ -349,6 +367,10 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
349
367
  * is implemented keepConnection() in the child classes (IOWS, IOCongSocket, etc.).
350
368
  */
351
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;
352
374
  /**
353
375
  * Redirects the connection to a new URL.
354
376
  * @param {string} url2 - The new URL to redirect to.
@@ -613,6 +635,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
613
635
  type Buffer$1 = Boho.Buffer;
614
636
 
615
637
  declare function pack(payload: any): Buffer<ArrayBufferLike>;
638
+
616
639
  declare class CongRx extends Transform {
617
640
  /**
618
641
  * @param {import('stream').TransformOptions & { maxFrameSize?: number }} [options] Stream options.
@@ -630,7 +653,6 @@ declare class CongRx extends Transform {
630
653
  skipBytes: number;
631
654
  _transform(chunk: any, encoding: any, callback: any): void;
632
655
  addData(chunk: any): void;
633
- parse(): void;
634
656
  }
635
657
 
636
658
  declare class IOCongSocket extends IOCore {
@@ -918,6 +940,7 @@ declare class Manager {
918
940
  oversizeRejected: number;
919
941
  rateLimited: number;
920
942
  peerRxLimitSkipped: number;
943
+ subscriptionsRejected: number;
921
944
  policyDenied: number;
922
945
  hostInbound: number;
923
946
  hostRejected: number;
@@ -1141,13 +1164,13 @@ declare class Server extends EventEmitter$1<[never]> {
1141
1164
  * loopback/private peer, true always, false never, or N trusted proxy hops.
1142
1165
  * options.maxPayload: largest WebSocket message and CongSocket frame in bytes (default 32 MiB).
1143
1166
  * options.maxBufferedBytes: close a peer whose unsent data exceeds this (default 64 MiB).
1144
- * options.membersOnly: drop signals from connections that are not authenticated.
1167
+ * options.membersOnly: only authenticated connections may send signals or subscribe.
1145
1168
  * options.logMessages: log each received message after decryption: type and tag, never the payload.
1146
1169
  * options.logStats: print a one-line summary every N ms (>= 1000; 0 = off); see stats().
1147
- * options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries }.
1170
+ * options.security: { maxClockSkewMs, authChallengeMaxAgeMs, maxReplayEntries, requireEncryption }.
1148
1171
  * options.retain: retained message limits, see serverOption.retain; adjustable later on server.retain.
1149
1172
  * options.quotas: named quota profiles { name: { maxMessageBytes, fanout, msgPerSec, bytesPerSec,
1150
- * maxConnections } }, merged over serverOption.quotas; always enforced, null is unlimited.
1173
+ * maxConnections, maxSubscriptions } }, merged over serverOption.quotas; always enforced, null is unlimited.
1151
1174
  * Adjustable later on server.quotas. The client is told its maxMessageBytes.
1152
1175
  * options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
1153
1176
  * options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
@@ -1274,6 +1297,7 @@ declare namespace serverOption {
1274
1297
  let maxClockSkewMs: number;
1275
1298
  let authChallengeMaxAgeMs: number;
1276
1299
  let maxReplayEntries: number;
1300
+ let requireEncryption: boolean;
1277
1301
  }
1278
1302
  export namespace quotas {
1279
1303
  namespace anonymous {
@@ -1282,6 +1306,7 @@ declare namespace serverOption {
1282
1306
  let msgPerSec: number;
1283
1307
  let bytesPerSec: number;
1284
1308
  let maxConnections: null;
1309
+ let maxSubscriptions: number;
1285
1310
  }
1286
1311
  namespace basic {
1287
1312
  let maxMessageBytes_1: number;
@@ -1294,6 +1319,8 @@ declare namespace serverOption {
1294
1319
  export { bytesPerSec_1 as bytesPerSec };
1295
1320
  let maxConnections_1: number;
1296
1321
  export { maxConnections_1 as maxConnections };
1322
+ let maxSubscriptions_1: number;
1323
+ export { maxSubscriptions_1 as maxSubscriptions };
1297
1324
  }
1298
1325
  namespace pro {
1299
1326
  let maxMessageBytes_2: number;
@@ -1306,6 +1333,8 @@ declare namespace serverOption {
1306
1333
  export { bytesPerSec_2 as bytesPerSec };
1307
1334
  let maxConnections_2: number;
1308
1335
  export { maxConnections_2 as maxConnections };
1336
+ let maxSubscriptions_2: number;
1337
+ export { maxSubscriptions_2 as maxSubscriptions };
1309
1338
  }
1310
1339
  namespace unlimited {
1311
1340
  let maxMessageBytes_3: null;
@@ -1318,6 +1347,8 @@ declare namespace serverOption {
1318
1347
  export { bytesPerSec_3 as bytesPerSec };
1319
1348
  let maxConnections_3: null;
1320
1349
  export { maxConnections_3 as maxConnections };
1350
+ let maxSubscriptions_3: null;
1351
+ export { maxSubscriptions_3 as maxSubscriptions };
1321
1352
  }
1322
1353
  }
1323
1354
  export let anonymousQuota: string;
@@ -1351,6 +1382,9 @@ declare namespace serverOption {
1351
1382
  }
1352
1383
  export namespace auth_1 {
1353
1384
  let failDelay: number;
1385
+ let maxFailuresPerConnection: number;
1386
+ let maxFailuresPerAddress: number;
1387
+ let failureWindowMs: number;
1354
1388
  let duplicateLogin: string;
1355
1389
  }
1356
1390
  export { auth_1 as auth };
@@ -1366,6 +1400,7 @@ declare function getIPv6PrefixHexString(ip: any): string | null;
1366
1400
  declare function numberWithCommas(x: any): any;
1367
1401
  declare function getIPv4HexString(ipStr: any): string;
1368
1402
  declare function getLocalAddress(): string;
1403
+ declare function checkLoginId(id: any): string;
1369
1404
  declare function delay(ms: any): Promise<any>;
1370
1405
 
1371
1406
  declare class FileKeyProvider {
@@ -1518,13 +1553,17 @@ declare class BohoAuth {
1518
1553
  get duplicateLogin(): "keepOld" | "keepNew" | null;
1519
1554
  onAuthEvent: ((event: object) => any) | null;
1520
1555
  resolveQuota: typeof defaultQuota | ((authInfo: object, role: string) => string | Promise<string>);
1556
+ addressFailures: Map<any, any>;
1521
1557
  authLogger: FileLogger | undefined;
1522
1558
  /** Policy for a connection: its Server's duplicateLogin option, else this instance's policy. */
1523
1559
  duplicateLoginFor(peer: any): any;
1524
1560
  set keepOldConnection(keepOld: boolean);
1525
1561
  get keepOldConnection(): boolean;
1526
1562
  emitAuthEvent(event: any): void;
1527
- send_auth_fail(peer: any, reason: any): void;
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;
1528
1567
  /**
1529
1568
  * Hook for a subclass: decide where a verified login belongs before it is accepted.
1530
1569
  * Called after the key and role checks, before quotas and the duplicate login check.
@@ -1548,4 +1587,4 @@ declare class BohoAuth {
1548
1587
 
1549
1588
  declare const version: string;
1550
1589
 
1551
- 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 };