@bymax-one/nest-realtime 1.0.4 → 1.0.5

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/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.5] - 2026-08-04
11
+
12
+ ### Security
13
+
14
+ - The Redis credentials are no longer disclosed when the adapters that hold a client are
15
+ serialized. `RedisOfflineQueue` and `RedisRealtimePubSub` kept their ioredis instances
16
+ in TypeScript `private` properties, which are erased at runtime and leave enumerable
17
+ own properties, and an ioredis instance carries `options.password` as a plain field.
18
+ `JSON.stringify`, object spread and `util.inspect` therefore reached the password —
19
+ and, because both adapters are referenced from the module options, so did anything that
20
+ serialized those. Both clients and the lazily created subscriber connection move to
21
+ ECMAScript private fields.
22
+
23
+ Reading on purpose is unchanged and no public type or export moved.
24
+
10
25
  ## [1.0.4] - 2026-08-02
11
26
 
12
27
  ### Fixed
@@ -197,7 +212,8 @@ First published release.
197
212
  rather than by the manual sweep that raised the NestJS floors — that sweep
198
213
  asked about NestJS and never put the same question to the other ten peers.
199
214
 
200
- [Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.0.4...HEAD
215
+ [Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.0.5...HEAD
216
+ [1.0.5]: https://github.com/bymaxone/nest-realtime/compare/v1.0.4...v1.0.5
201
217
  [1.0.4]: https://github.com/bymaxone/nest-realtime/compare/v1.0.3...v1.0.4
202
218
  [1.0.3]: https://github.com/bymaxone/nest-realtime/compare/v1.0.2...v1.0.3
203
219
  [1.0.2]: https://github.com/bymaxone/nest-realtime/compare/v1.0.1...v1.0.2
package/README.md CHANGED
@@ -644,7 +644,7 @@ pnpm typecheck && pnpm lint && pnpm test && pnpm build && pnpm size
644
644
 
645
645
  ## 🔒 Security Policy
646
646
 
647
- If you discover a security vulnerability, please **do not** open a public issue. Instead, email us at **security@bymax.one** with details. We take security seriously and will respond promptly. Full policy and scope: [SECURITY.md](./SECURITY.md).
647
+ If you discover a security vulnerability, please **do not** open a public issue. Instead, email us at **support@bymax.one** with details. We take security seriously and will respond promptly. Full policy and scope: [SECURITY.md](./SECURITY.md).
648
648
 
649
649
  ---
650
650
 
@@ -1453,17 +1453,26 @@ exports.BymaxRealtimeModule = __decorateClass([
1453
1453
 
1454
1454
  // src/server/pubsub/redis-realtime-pubsub.ts
1455
1455
  var RedisRealtimePubSub = class {
1456
- pub;
1456
+ /**
1457
+ * The publishing Redis client.
1458
+ *
1459
+ * An ECMAScript private field for the same reason as the subscriber below: an
1460
+ * ioredis instance carries `options.password` as a plain field, and a
1461
+ * TypeScript `private` one is erased at runtime, leaving it enumerable to
1462
+ * anything that serializes this pubsub adapter.
1463
+ */
1464
+ #pub;
1457
1465
  channel;
1458
- subInit = null;
1466
+ /** The lazily created subscriber connection, which carries the same credentials. */
1467
+ #subInit = null;
1459
1468
  handlers = /* @__PURE__ */ new Set();
1460
1469
  constructor(options) {
1461
- this.pub = options.client;
1470
+ this.#pub = options.client;
1462
1471
  this.channel = options.channel ?? "bymax:realtime";
1463
1472
  }
1464
1473
  /** JSON-encodes the message and PUBLISHes it to the configured channel. */
1465
1474
  async publish(message) {
1466
- await this.pub.publish(this.channel, JSON.stringify(message));
1475
+ await this.#pub.publish(this.channel, JSON.stringify(message));
1467
1476
  }
1468
1477
  /**
1469
1478
  * Lazily creates the single shared subscribe client on first call; returns an async
@@ -1482,13 +1491,13 @@ var RedisRealtimePubSub = class {
1482
1491
  sub = await this.ensureSubscriber();
1483
1492
  } catch (err) {
1484
1493
  this.handlers.delete(handler);
1485
- this.subInit = null;
1494
+ this.#subInit = null;
1486
1495
  throw err;
1487
1496
  }
1488
1497
  return async () => {
1489
1498
  this.handlers.delete(handler);
1490
1499
  if (this.handlers.size === 0) {
1491
- this.subInit = null;
1500
+ this.#subInit = null;
1492
1501
  try {
1493
1502
  await sub.quit();
1494
1503
  } catch {
@@ -1498,11 +1507,11 @@ var RedisRealtimePubSub = class {
1498
1507
  }
1499
1508
  /** Lazily create the single shared subscribe client (idempotent under concurrent calls). */
1500
1509
  ensureSubscriber() {
1501
- if (!this.subInit) this.subInit = this.createSubscriber();
1502
- return this.subInit;
1510
+ if (!this.#subInit) this.#subInit = this.createSubscriber();
1511
+ return this.#subInit;
1503
1512
  }
1504
1513
  async createSubscriber() {
1505
- const sub = this.pub.duplicate();
1514
+ const sub = this.#pub.duplicate();
1506
1515
  await sub.subscribe(this.channel);
1507
1516
  sub.on("message", (_ch, payload) => this.dispatch(payload));
1508
1517
  return sub;
@@ -1525,7 +1534,16 @@ var RedisRealtimePubSub = class {
1525
1534
 
1526
1535
  // src/server/offline-queue/redis-offline-queue.ts
1527
1536
  var RedisOfflineQueue = class _RedisOfflineQueue {
1528
- client;
1537
+ /**
1538
+ * The Redis client.
1539
+ *
1540
+ * An ECMAScript private field rather than a TypeScript `private` one, which
1541
+ * is erased at runtime: an ioredis instance carries `options.password` as a
1542
+ * plain field, so leaving this enumerable would let anything that serializes
1543
+ * this queue — or the module options that reference it — reach the Redis
1544
+ * credentials.
1545
+ */
1546
+ #client;
1529
1547
  maxPerUser;
1530
1548
  ttlSeconds;
1531
1549
  /** Zero-pad width for the epoch-millisecond component of the sort key. */
@@ -1533,7 +1551,7 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1533
1551
  /** Zero-pad width for the intra-millisecond counter component of the sort key. */
1534
1552
  static COUNTER_PAD = 6;
1535
1553
  constructor(options) {
1536
- this.client = options.client;
1554
+ this.#client = options.client;
1537
1555
  this.maxPerUser = options.maxPerUser ?? 500;
1538
1556
  this.ttlSeconds = options.ttlSeconds ?? 3600;
1539
1557
  }
@@ -1572,7 +1590,7 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1572
1590
  }
1573
1591
  async append(userId, event) {
1574
1592
  const key = this.key(userId);
1575
- const pipeline = this.client.pipeline();
1593
+ const pipeline = this.#client.pipeline();
1576
1594
  pipeline.zadd(key, 0, this.encodeMember(event));
1577
1595
  pipeline.zremrangebyrank(key, 0, -(this.maxPerUser + 1));
1578
1596
  pipeline.expire(key, this.ttlSeconds);
@@ -1583,7 +1601,7 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1583
1601
  }
1584
1602
  async retrieveSince(userId, sinceId, limit) {
1585
1603
  const lowerBound = `[${this.lexKeyNext(sinceId)}`;
1586
- const raw = await this.client.zrangebylex(this.key(userId), lowerBound, "+", "LIMIT", 0, limit);
1604
+ const raw = await this.#client.zrangebylex(this.key(userId), lowerBound, "+", "LIMIT", 0, limit);
1587
1605
  return raw.map(
1588
1606
  (entry) => JSON.parse(
1589
1607
  entry.slice(entry.indexOf("|") + 1),
@@ -1593,9 +1611,9 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1593
1611
  }
1594
1612
  async acknowledge(userId, upToId) {
1595
1613
  const upperBound = `(${this.lexKeyNext(upToId)}`;
1596
- const toRemove = await this.client.zrangebylex(this.key(userId), "-", upperBound);
1614
+ const toRemove = await this.#client.zrangebylex(this.key(userId), "-", upperBound);
1597
1615
  if (toRemove.length > 0) {
1598
- await this.client.zrem(this.key(userId), ...toRemove);
1616
+ await this.#client.zrem(this.key(userId), ...toRemove);
1599
1617
  }
1600
1618
  }
1601
1619
  };
@@ -1203,9 +1203,8 @@ interface RedisRealtimePubSubOptions {
1203
1203
  * ```
1204
1204
  */
1205
1205
  declare class RedisRealtimePubSub implements IRealtimePubSub {
1206
- private readonly pub;
1206
+ #private;
1207
1207
  private readonly channel;
1208
- private subInit;
1209
1208
  private readonly handlers;
1210
1209
  constructor(options: RedisRealtimePubSubOptions);
1211
1210
  /** JSON-encodes the message and PUBLISHes it to the configured channel. */
@@ -1262,7 +1261,7 @@ interface RedisOfflineQueueOptions {
1262
1261
  * ```
1263
1262
  */
1264
1263
  declare class RedisOfflineQueue implements IOfflineQueueStorage {
1265
- private readonly client;
1264
+ #private;
1266
1265
  private readonly maxPerUser;
1267
1266
  private readonly ttlSeconds;
1268
1267
  /** Zero-pad width for the epoch-millisecond component of the sort key. */
@@ -1203,9 +1203,8 @@ interface RedisRealtimePubSubOptions {
1203
1203
  * ```
1204
1204
  */
1205
1205
  declare class RedisRealtimePubSub implements IRealtimePubSub {
1206
- private readonly pub;
1206
+ #private;
1207
1207
  private readonly channel;
1208
- private subInit;
1209
1208
  private readonly handlers;
1210
1209
  constructor(options: RedisRealtimePubSubOptions);
1211
1210
  /** JSON-encodes the message and PUBLISHes it to the configured channel. */
@@ -1262,7 +1261,7 @@ interface RedisOfflineQueueOptions {
1262
1261
  * ```
1263
1262
  */
1264
1263
  declare class RedisOfflineQueue implements IOfflineQueueStorage {
1265
- private readonly client;
1264
+ #private;
1266
1265
  private readonly maxPerUser;
1267
1266
  private readonly ttlSeconds;
1268
1267
  /** Zero-pad width for the epoch-millisecond component of the sort key. */
@@ -1451,17 +1451,26 @@ BymaxRealtimeModule = __decorateClass([
1451
1451
 
1452
1452
  // src/server/pubsub/redis-realtime-pubsub.ts
1453
1453
  var RedisRealtimePubSub = class {
1454
- pub;
1454
+ /**
1455
+ * The publishing Redis client.
1456
+ *
1457
+ * An ECMAScript private field for the same reason as the subscriber below: an
1458
+ * ioredis instance carries `options.password` as a plain field, and a
1459
+ * TypeScript `private` one is erased at runtime, leaving it enumerable to
1460
+ * anything that serializes this pubsub adapter.
1461
+ */
1462
+ #pub;
1455
1463
  channel;
1456
- subInit = null;
1464
+ /** The lazily created subscriber connection, which carries the same credentials. */
1465
+ #subInit = null;
1457
1466
  handlers = /* @__PURE__ */ new Set();
1458
1467
  constructor(options) {
1459
- this.pub = options.client;
1468
+ this.#pub = options.client;
1460
1469
  this.channel = options.channel ?? "bymax:realtime";
1461
1470
  }
1462
1471
  /** JSON-encodes the message and PUBLISHes it to the configured channel. */
1463
1472
  async publish(message) {
1464
- await this.pub.publish(this.channel, JSON.stringify(message));
1473
+ await this.#pub.publish(this.channel, JSON.stringify(message));
1465
1474
  }
1466
1475
  /**
1467
1476
  * Lazily creates the single shared subscribe client on first call; returns an async
@@ -1480,13 +1489,13 @@ var RedisRealtimePubSub = class {
1480
1489
  sub = await this.ensureSubscriber();
1481
1490
  } catch (err) {
1482
1491
  this.handlers.delete(handler);
1483
- this.subInit = null;
1492
+ this.#subInit = null;
1484
1493
  throw err;
1485
1494
  }
1486
1495
  return async () => {
1487
1496
  this.handlers.delete(handler);
1488
1497
  if (this.handlers.size === 0) {
1489
- this.subInit = null;
1498
+ this.#subInit = null;
1490
1499
  try {
1491
1500
  await sub.quit();
1492
1501
  } catch {
@@ -1496,11 +1505,11 @@ var RedisRealtimePubSub = class {
1496
1505
  }
1497
1506
  /** Lazily create the single shared subscribe client (idempotent under concurrent calls). */
1498
1507
  ensureSubscriber() {
1499
- if (!this.subInit) this.subInit = this.createSubscriber();
1500
- return this.subInit;
1508
+ if (!this.#subInit) this.#subInit = this.createSubscriber();
1509
+ return this.#subInit;
1501
1510
  }
1502
1511
  async createSubscriber() {
1503
- const sub = this.pub.duplicate();
1512
+ const sub = this.#pub.duplicate();
1504
1513
  await sub.subscribe(this.channel);
1505
1514
  sub.on("message", (_ch, payload) => this.dispatch(payload));
1506
1515
  return sub;
@@ -1523,7 +1532,16 @@ var RedisRealtimePubSub = class {
1523
1532
 
1524
1533
  // src/server/offline-queue/redis-offline-queue.ts
1525
1534
  var RedisOfflineQueue = class _RedisOfflineQueue {
1526
- client;
1535
+ /**
1536
+ * The Redis client.
1537
+ *
1538
+ * An ECMAScript private field rather than a TypeScript `private` one, which
1539
+ * is erased at runtime: an ioredis instance carries `options.password` as a
1540
+ * plain field, so leaving this enumerable would let anything that serializes
1541
+ * this queue — or the module options that reference it — reach the Redis
1542
+ * credentials.
1543
+ */
1544
+ #client;
1527
1545
  maxPerUser;
1528
1546
  ttlSeconds;
1529
1547
  /** Zero-pad width for the epoch-millisecond component of the sort key. */
@@ -1531,7 +1549,7 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1531
1549
  /** Zero-pad width for the intra-millisecond counter component of the sort key. */
1532
1550
  static COUNTER_PAD = 6;
1533
1551
  constructor(options) {
1534
- this.client = options.client;
1552
+ this.#client = options.client;
1535
1553
  this.maxPerUser = options.maxPerUser ?? 500;
1536
1554
  this.ttlSeconds = options.ttlSeconds ?? 3600;
1537
1555
  }
@@ -1570,7 +1588,7 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1570
1588
  }
1571
1589
  async append(userId, event) {
1572
1590
  const key = this.key(userId);
1573
- const pipeline = this.client.pipeline();
1591
+ const pipeline = this.#client.pipeline();
1574
1592
  pipeline.zadd(key, 0, this.encodeMember(event));
1575
1593
  pipeline.zremrangebyrank(key, 0, -(this.maxPerUser + 1));
1576
1594
  pipeline.expire(key, this.ttlSeconds);
@@ -1581,7 +1599,7 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1581
1599
  }
1582
1600
  async retrieveSince(userId, sinceId, limit) {
1583
1601
  const lowerBound = `[${this.lexKeyNext(sinceId)}`;
1584
- const raw = await this.client.zrangebylex(this.key(userId), lowerBound, "+", "LIMIT", 0, limit);
1602
+ const raw = await this.#client.zrangebylex(this.key(userId), lowerBound, "+", "LIMIT", 0, limit);
1585
1603
  return raw.map(
1586
1604
  (entry) => JSON.parse(
1587
1605
  entry.slice(entry.indexOf("|") + 1),
@@ -1591,9 +1609,9 @@ var RedisOfflineQueue = class _RedisOfflineQueue {
1591
1609
  }
1592
1610
  async acknowledge(userId, upToId) {
1593
1611
  const upperBound = `(${this.lexKeyNext(upToId)}`;
1594
- const toRemove = await this.client.zrangebylex(this.key(userId), "-", upperBound);
1612
+ const toRemove = await this.#client.zrangebylex(this.key(userId), "-", upperBound);
1595
1613
  if (toRemove.length > 0) {
1596
- await this.client.zrem(this.key(userId), ...toRemove);
1614
+ await this.#client.zrem(this.key(userId), ...toRemove);
1597
1615
  }
1598
1616
  }
1599
1617
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bymax-one/nest-realtime",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Realtime backend → frontend communication for NestJS — dual-transport SSE (default) and WebSocket (opt-in) with a unified server-side API.",
5
5
  "author": "Bymax One <support@bymax.one>",
6
6
  "license": "MIT",