@bymax-one/nest-realtime 1.2.6 → 1.2.8
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 +145 -1
- package/README.md +84 -52
- package/dist/internal/index.cjs +296 -436
- package/dist/internal/index.d.cts +215 -45
- package/dist/internal/index.d.ts +215 -45
- package/dist/internal/index.mjs +295 -437
- package/dist/react/index.cjs +0 -2
- package/dist/react/index.d.cts +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.mjs +0 -2
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/shared/index.cjs +1 -0
- package/dist/shared/index.d.cts +3 -1
- package/dist/shared/index.d.ts +3 -1
- package/dist/shared/index.mjs +1 -0
- package/dist/websocket/index.cjs +60 -283
- package/dist/websocket/index.d.cts +30 -11
- package/dist/websocket/index.d.ts +30 -11
- package/dist/websocket/index.mjs +61 -284
- package/package.json +3 -3
|
@@ -154,10 +154,55 @@ interface IConnectionAuthenticator {
|
|
|
154
154
|
revalidate?(connectionId: string, originalAuth: AuthenticationResult): Promise<boolean>;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* @fileoverview Canonical error codes emitted by the library (the §14 catalog).
|
|
159
|
+
* @layer shared
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* Canonical error codes emitted by the library. Map 1-to-1 with
|
|
163
|
+
* `docs/technical_specification.md` §14.
|
|
164
|
+
*
|
|
165
|
+
* `TOO_MANY_CONNECTIONS` signals FIFO eviction: when a user exceeds
|
|
166
|
+
* `maxConnectionsPerUser`, the OLDEST connection is evicted (closed with this
|
|
167
|
+
* code) and the new one is admitted — it is never an HTTP 429 rejection.
|
|
168
|
+
*/
|
|
169
|
+
declare const REALTIME_ERROR_CODES: {
|
|
170
|
+
readonly INVALID_OPTIONS: "REALTIME_INVALID_OPTIONS";
|
|
171
|
+
readonly NO_AUTHENTICATOR: "REALTIME_NO_AUTHENTICATOR";
|
|
172
|
+
readonly AUTH_FAILED: "REALTIME_AUTH_FAILED";
|
|
173
|
+
readonly REAUTHENTICATION_FAILED: "REALTIME_REAUTHENTICATION_FAILED";
|
|
174
|
+
readonly TOO_MANY_CONNECTIONS: "REALTIME_TOO_MANY_CONNECTIONS";
|
|
175
|
+
readonly INVALID_TICKET: "REALTIME_INVALID_TICKET";
|
|
176
|
+
readonly PUBSUB_UNAVAILABLE: "REALTIME_PUBSUB_UNAVAILABLE";
|
|
177
|
+
readonly TRANSPORT_UNAVAILABLE: "REALTIME_TRANSPORT_UNAVAILABLE";
|
|
178
|
+
readonly REDIS_ADAPTER_FAILED: "REALTIME_REDIS_ADAPTER_FAILED";
|
|
179
|
+
readonly PAYLOAD_TOO_LARGE: "REALTIME_PAYLOAD_TOO_LARGE";
|
|
180
|
+
readonly REPLAY_BUFFER_MISS: "REALTIME_REPLAY_BUFFER_MISS";
|
|
181
|
+
};
|
|
182
|
+
/** Union of canonical error code values. */
|
|
183
|
+
type RealtimeErrorCode = (typeof REALTIME_ERROR_CODES)[keyof typeof REALTIME_ERROR_CODES];
|
|
184
|
+
|
|
157
185
|
/**
|
|
158
186
|
* @fileoverview Optional connection lifecycle hooks the consumer can provide.
|
|
159
187
|
* @layer contracts
|
|
160
188
|
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* A delivery path that failed without failing the call that depended on it, such as an emit
|
|
192
|
+
* whose publish to the other instances was refused. The call still resolved; this is how the
|
|
193
|
+
* failure becomes visible.
|
|
194
|
+
*/
|
|
195
|
+
interface DeliveryFailure {
|
|
196
|
+
/** The stable error code of the failure. */
|
|
197
|
+
readonly code: RealtimeErrorCode;
|
|
198
|
+
/**
|
|
199
|
+
* What was being delivered: an emit (`emitToUser`, `emitToTenant`, `emitToRoom`,
|
|
200
|
+
* `broadcast`) or `offlineAppend` / `offlineRetrieve` for the offline queue.
|
|
201
|
+
*/
|
|
202
|
+
readonly op: string;
|
|
203
|
+
/** The failure underneath. */
|
|
204
|
+
readonly error: Error;
|
|
205
|
+
}
|
|
161
206
|
/** Metadata describing a connection at a lifecycle transition. */
|
|
162
207
|
interface ConnectionEventMeta {
|
|
163
208
|
readonly connectionId: string;
|
|
@@ -227,6 +272,12 @@ interface IConnectionLifecycleHooks {
|
|
|
227
272
|
}): void | Promise<void>;
|
|
228
273
|
/** Called on re-authentication failure, before disconnect. */
|
|
229
274
|
onReauthenticationFailed?(meta: ConnectionEventMeta): void | Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Called when a delivery path fails but the call that used it still resolves: the publish of an
|
|
277
|
+
* emit to the other instances, or the offline queue. Count it to see cross-instance loss; it
|
|
278
|
+
* is also logged with the same code. A throwing hook is logged and ignored.
|
|
279
|
+
*/
|
|
280
|
+
onDeliveryFailure?(failure: DeliveryFailure): void | Promise<void>;
|
|
230
281
|
}
|
|
231
282
|
|
|
232
283
|
/**
|
|
@@ -253,8 +304,20 @@ interface RealtimePubSubMessage {
|
|
|
253
304
|
interface IRealtimePubSub {
|
|
254
305
|
/** Publish a message to all subscribers (the other instances). */
|
|
255
306
|
publish(message: RealtimePubSubMessage): Promise<void>;
|
|
256
|
-
/**
|
|
307
|
+
/**
|
|
308
|
+
* Subscribe to messages. Resolves to an async unsubscribe handle.
|
|
309
|
+
*
|
|
310
|
+
* Rejects when the bus refuses the subscription for a reason no retry fixes (a wrong password,
|
|
311
|
+
* a missing permission), which fails the application's boot. A bus that cannot be reached yet
|
|
312
|
+
* may resolve and report itself through `isSubscribed`.
|
|
313
|
+
*/
|
|
257
314
|
subscribe(handler: (message: RealtimePubSubMessage) => void): Promise<() => Promise<void>>;
|
|
315
|
+
/**
|
|
316
|
+
* Whether this instance is subscribed right now, so the messages other instances publish reach
|
|
317
|
+
* it. Optional: a bus that cannot be unsubscribed once subscribed (the in-memory one) omits it
|
|
318
|
+
* and counts as subscribed.
|
|
319
|
+
*/
|
|
320
|
+
isSubscribed?(): boolean;
|
|
258
321
|
}
|
|
259
322
|
|
|
260
323
|
/**
|
|
@@ -772,7 +835,21 @@ interface ITransport {
|
|
|
772
835
|
*/
|
|
773
836
|
declare class RealtimeService {
|
|
774
837
|
private readonly transport;
|
|
775
|
-
|
|
838
|
+
private readonly pubsub?;
|
|
839
|
+
constructor(transport: ITransport, pubsub?: IRealtimePubSub | undefined);
|
|
840
|
+
/**
|
|
841
|
+
* Whether this instance hears the events and revocations other instances publish. False while
|
|
842
|
+
* the bus is unreachable or its subscriber connection is down, so a readiness probe can take a
|
|
843
|
+
* deaf instance out of rotation. True for a bus that does not report a state, and with
|
|
844
|
+
* `transport: 'websocket'`, which does not subscribe to the bus.
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* ```ts
|
|
848
|
+
* // In a health indicator: `isHealthy` is false while the instance cannot hear the others.
|
|
849
|
+
* return indicator.check('realtime', realtime.isPubSubReady())
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
852
|
+
isPubSubReady(): boolean;
|
|
776
853
|
/**
|
|
777
854
|
* Send to all of a user's connections (across devices/tabs).
|
|
778
855
|
*
|
|
@@ -797,11 +874,28 @@ declare class RealtimeService {
|
|
|
797
874
|
* The room id is not checked. Never pass client-supplied input that could start
|
|
798
875
|
* with the reserved `user:` or `tenant:` prefixes: joining `tenant:<other>`
|
|
799
876
|
* receives that tenant's events.
|
|
877
|
+
*
|
|
878
|
+
* Acts on a connection this instance holds; for any other id it resolves and changes
|
|
879
|
+
* nothing. A failure of the transport that holds the connection rejects the call.
|
|
800
880
|
*/
|
|
801
881
|
joinRoom(connectionId: string, roomId: string): Promise<void>;
|
|
802
|
-
/**
|
|
882
|
+
/**
|
|
883
|
+
* Remove a specific connection from a room.
|
|
884
|
+
*
|
|
885
|
+
* Acts on a connection this instance holds; for any other id it resolves and changes
|
|
886
|
+
* nothing. A failure of the transport that holds the connection rejects the call.
|
|
887
|
+
*/
|
|
803
888
|
leaveRoom(connectionId: string, roomId: string): Promise<void>;
|
|
804
|
-
/**
|
|
889
|
+
/**
|
|
890
|
+
* Force-disconnect a specific connection (e.g. on auth revocation).
|
|
891
|
+
*
|
|
892
|
+
* Resolves once the connection is closed on this instance or the revocation has been handed
|
|
893
|
+
* to the bus for the instance that holds it.
|
|
894
|
+
*
|
|
895
|
+
* @throws {Error} `REALTIME_PUBSUB_UNAVAILABLE` when the bus refuses the revocation, or
|
|
896
|
+
* `REALTIME_TRANSPORT_UNAVAILABLE` when the transport that holds the connection fails.
|
|
897
|
+
* The connection may still be connected: retry.
|
|
898
|
+
*/
|
|
805
899
|
disconnect(connectionId: string, reason?: string): Promise<void>;
|
|
806
900
|
}
|
|
807
901
|
|
|
@@ -857,6 +951,12 @@ declare class ReauthenticationService implements OnModuleInit, OnApplicationShut
|
|
|
857
951
|
* Exposed as public for test access.
|
|
858
952
|
*/
|
|
859
953
|
runCycle(): Promise<void>;
|
|
954
|
+
/**
|
|
955
|
+
* Revoke a connection whose revalidation failed, and keep the cycle going when the
|
|
956
|
+
* revocation itself is rejected. The positive-cache entry is already gone, so the next
|
|
957
|
+
* cycle revalidates the connection and tries again.
|
|
958
|
+
*/
|
|
959
|
+
private revoke;
|
|
860
960
|
/** Evict the positive-cache entry, optionally emit the failure event, then disconnect. */
|
|
861
961
|
private handleFailure;
|
|
862
962
|
}
|
|
@@ -899,8 +999,9 @@ declare class RoomRegistry {
|
|
|
899
999
|
*/
|
|
900
1000
|
declare class OfflineQueueDeliveryService {
|
|
901
1001
|
private readonly storage?;
|
|
1002
|
+
private readonly hooks?;
|
|
902
1003
|
private readonly logger;
|
|
903
|
-
constructor(storage?: IOfflineQueueStorage | undefined);
|
|
1004
|
+
constructor(storage?: IOfflineQueueStorage | undefined, hooks?: IConnectionLifecycleHooks | undefined);
|
|
904
1005
|
/**
|
|
905
1006
|
* Return events for `userId` that arrived after `lastEventId` and are NOT
|
|
906
1007
|
* already covered by `ringBufferIds` (already replayed from in-memory buffer).
|
|
@@ -1137,13 +1238,36 @@ declare class SseTransport implements ITransport {
|
|
|
1137
1238
|
* @returns The `ConnectionRecord`, or `undefined` when not found.
|
|
1138
1239
|
*/
|
|
1139
1240
|
getConnection(connectionId: string): ConnectionRecord | undefined;
|
|
1241
|
+
/**
|
|
1242
|
+
* Emit to a user: live here, to the other instances over the bus, and into the offline queue
|
|
1243
|
+
* when the user has no live connection on this instance.
|
|
1244
|
+
*
|
|
1245
|
+
* A failed publish or a failed append is reported (log and `onDeliveryFailure`) and the call
|
|
1246
|
+
* still resolves, since delivery to the other instances is at-most-once. It rejects only when
|
|
1247
|
+
* the event has no delivery path left: the user is offline here, the queue could not keep it,
|
|
1248
|
+
* and the bus either failed or cannot reach another instance (the in-memory bus). A rejection
|
|
1249
|
+
* carries the queue failure as its cause and is not also reported to the hook.
|
|
1250
|
+
*/
|
|
1140
1251
|
emitToUser(userId: string, event: string, data: unknown): Promise<void>;
|
|
1252
|
+
/** Append to the offline queue; resolves with the failure, or `undefined` once it is kept. */
|
|
1253
|
+
private tryAppend;
|
|
1254
|
+
/** Whether the bus can carry an event to another instance (the in-memory bus cannot). */
|
|
1255
|
+
private busReachesOtherInstances;
|
|
1141
1256
|
emitToTenant(tenantId: string, event: string, data: unknown): Promise<void>;
|
|
1142
1257
|
emitToRoom(roomId: string, event: string, data: unknown): Promise<void>;
|
|
1143
1258
|
broadcast(event: string, data: unknown): Promise<void>;
|
|
1259
|
+
/** Join a connection this instance holds to a room; any other id is left alone. */
|
|
1144
1260
|
joinRoom(connectionId: string, roomId: string): Promise<void>;
|
|
1261
|
+
/** Remove a connection this instance holds from a room; any other id is left alone. */
|
|
1145
1262
|
leaveRoom(connectionId: string, roomId: string): Promise<void>;
|
|
1146
|
-
/**
|
|
1263
|
+
/**
|
|
1264
|
+
* Disconnect a connection locally if owned here, otherwise revoke cross-instance.
|
|
1265
|
+
*
|
|
1266
|
+
* Resolves once the connection is closed here or the revocation has been handed to the bus. A
|
|
1267
|
+
* connection held here as a WebSocket is left to the WebSocket transport and nothing is
|
|
1268
|
+
* published. It rejects with `REALTIME_PUBSUB_UNAVAILABLE` when the bus refuses it: nothing has reached
|
|
1269
|
+
* the connection, so the caller must not read the resolution as a revocation.
|
|
1270
|
+
*/
|
|
1147
1271
|
disconnect(connectionId: string, reason?: string): Promise<void>;
|
|
1148
1272
|
/**
|
|
1149
1273
|
* Deliver an event to a user's local SSE connections and update the replay buffer.
|
|
@@ -1189,8 +1313,11 @@ declare class SseTransport implements ITransport {
|
|
|
1189
1313
|
private buildMessage;
|
|
1190
1314
|
/** Deliver to one connection, isolating failures so others still receive the event. */
|
|
1191
1315
|
private deliver;
|
|
1192
|
-
/** Publish once to the bus;
|
|
1316
|
+
/** Publish once to the bus; resolves with the failure, or `undefined` once the bus accepted it. */
|
|
1317
|
+
private tryPublish;
|
|
1318
|
+
/** Publish once to the bus. A failure is reported and never fails the live emit path. */
|
|
1193
1319
|
private publish;
|
|
1320
|
+
private reportPublishFailure;
|
|
1194
1321
|
/** Evict a user's oldest connections (FIFO) when over `maxConnectionsPerUser`. */
|
|
1195
1322
|
private evictBeyondLimit;
|
|
1196
1323
|
}
|
|
@@ -1358,8 +1485,9 @@ declare class InMemoryPubSub implements IRealtimePubSub {
|
|
|
1358
1485
|
* the transport's `*Local` methods, which deliver without re-publishing.
|
|
1359
1486
|
*
|
|
1360
1487
|
* Messages from this instance (echo) are dropped via the `origin` guard.
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1488
|
+
* A subscribe that fails fails the boot: an instance that cannot hear the others would
|
|
1489
|
+
* miss every revocation. A bus that merely cannot be reached yet resolves its subscribe and
|
|
1490
|
+
* reports itself through `isSubscribed()` instead. An unsubscribe failure is logged.
|
|
1363
1491
|
*/
|
|
1364
1492
|
declare class RealtimePubSubSubscriber implements OnModuleInit, OnApplicationShutdown {
|
|
1365
1493
|
private readonly pubsub;
|
|
@@ -1373,11 +1501,6 @@ declare class RealtimePubSubSubscriber implements OnModuleInit, OnApplicationShu
|
|
|
1373
1501
|
private handle;
|
|
1374
1502
|
}
|
|
1375
1503
|
|
|
1376
|
-
/**
|
|
1377
|
-
* @fileoverview Redis-backed pub/sub for cross-instance SSE fan-out.
|
|
1378
|
-
* @layer infrastructure
|
|
1379
|
-
*/
|
|
1380
|
-
|
|
1381
1504
|
/** Options for RedisRealtimePubSub. */
|
|
1382
1505
|
interface RedisRealtimePubSubOptions {
|
|
1383
1506
|
/** The Redis client used for publishing. A separate subscriber clone is created internally. */
|
|
@@ -1392,7 +1515,14 @@ interface RedisRealtimePubSubOptions {
|
|
|
1392
1515
|
* `SUBSCRIBE` (a lazily-duplicated clone). The subscriber clone is created on
|
|
1393
1516
|
* the first `subscribe()` call and quit on the last `unsubscribe()`.
|
|
1394
1517
|
*
|
|
1395
|
-
* Messages are JSON-encoded.
|
|
1518
|
+
* Messages are JSON-encoded. A malformed payload is dropped and counted, and the count is
|
|
1519
|
+
* reported at most once a minute.
|
|
1520
|
+
*
|
|
1521
|
+
* Whether this instance hears the other instances is a state, `isSubscribed()`, that follows the
|
|
1522
|
+
* subscriber connection for the life of the process. `subscribe()` fails when the server answers
|
|
1523
|
+
* with an error reply (a wrong password, a missing permission), which no retry can fix; when the
|
|
1524
|
+
* server cannot be reached it resolves at once and the instance stays unsubscribed until a
|
|
1525
|
+
* connection succeeds. Each change of that state is logged once, not once per retry.
|
|
1396
1526
|
*
|
|
1397
1527
|
* @example
|
|
1398
1528
|
* ```ts
|
|
@@ -1408,14 +1538,28 @@ declare class RedisRealtimePubSub implements IRealtimePubSub {
|
|
|
1408
1538
|
#private;
|
|
1409
1539
|
private readonly channel;
|
|
1410
1540
|
private readonly handlers;
|
|
1541
|
+
private readonly logger;
|
|
1542
|
+
/** Payloads dropped as unparsable since the last report, and when that report was made. */
|
|
1543
|
+
private malformedDropped;
|
|
1544
|
+
private malformedReportedAt;
|
|
1411
1545
|
constructor(options: RedisRealtimePubSubOptions);
|
|
1412
|
-
/**
|
|
1546
|
+
/**
|
|
1547
|
+
* Whether this instance holds a confirmed subscription to the channel, so the events and
|
|
1548
|
+
* revocations other instances publish reach it. False before the first successful subscribe,
|
|
1549
|
+
* while the subscriber connection is down, and after the last handler has unsubscribed.
|
|
1550
|
+
*/
|
|
1551
|
+
isSubscribed(): boolean;
|
|
1552
|
+
/**
|
|
1553
|
+
* JSON-encodes the message and PUBLISHes it to the configured channel. While the client is
|
|
1554
|
+
* reconnecting or closed it rejects at once: ioredis would queue the command and send it, late,
|
|
1555
|
+
* when the connection returns, so a revocation would wait out the whole outage.
|
|
1556
|
+
*/
|
|
1413
1557
|
publish(message: RealtimePubSubMessage): Promise<void>;
|
|
1414
1558
|
/**
|
|
1415
1559
|
* Lazily creates the single shared subscribe client on first call; returns an async
|
|
1416
1560
|
* unsubscribe that quits the client when the last handler is removed. Concurrent
|
|
1417
1561
|
* subscribe calls are idempotent — only one client is ever created. Malformed
|
|
1418
|
-
* payloads are dropped
|
|
1562
|
+
* payloads are dropped, and reported at most once a minute with their count.
|
|
1419
1563
|
*
|
|
1420
1564
|
* If the subscriber client cannot be created (e.g. Redis temporarily unavailable),
|
|
1421
1565
|
* the handler registration is rolled back and the cached init promise is cleared so
|
|
@@ -1425,6 +1569,22 @@ declare class RedisRealtimePubSub implements IRealtimePubSub {
|
|
|
1425
1569
|
/** Lazily create the single shared subscribe client (idempotent under concurrent calls). */
|
|
1426
1570
|
private ensureSubscriber;
|
|
1427
1571
|
private createSubscriber;
|
|
1572
|
+
/**
|
|
1573
|
+
* Settles the boot against the first SUBSCRIBE. An error reply is the server refusing, which
|
|
1574
|
+
* fails the boot; any other failure, an error event or a close or a rejection that is not an
|
|
1575
|
+
* error reply, is the connection failing, which lets the boot go on unready.
|
|
1576
|
+
*/
|
|
1577
|
+
private negotiate;
|
|
1578
|
+
private confirm;
|
|
1579
|
+
/** A server that was reached and refused the SUBSCRIBE after boot: it stays unsubscribed. */
|
|
1580
|
+
private refused;
|
|
1581
|
+
private markUp;
|
|
1582
|
+
private markDown;
|
|
1583
|
+
/**
|
|
1584
|
+
* Count a payload dropped as unparsable and report the count at most once per minute, so a
|
|
1585
|
+
* producer on an incompatible version is visible without flooding the log.
|
|
1586
|
+
*/
|
|
1587
|
+
private reportMalformed;
|
|
1428
1588
|
private dispatch;
|
|
1429
1589
|
}
|
|
1430
1590
|
|
|
@@ -1587,6 +1747,42 @@ declare function composeRoomId(prefix: keyof typeof ROOM_PREFIXES, ...parts: str
|
|
|
1587
1747
|
/** Describe a thrown or rejected value without throwing: `.message` on `null`, or `String()` on a prototype-less object, would. */
|
|
1588
1748
|
declare function describeError(reason: unknown): string;
|
|
1589
1749
|
|
|
1750
|
+
/**
|
|
1751
|
+
* @fileoverview The error a call rejects with when it could not reach what it was asked to act on.
|
|
1752
|
+
* @layer utils
|
|
1753
|
+
*/
|
|
1754
|
+
|
|
1755
|
+
/**
|
|
1756
|
+
* Builds the rejection for a call whose effect did not happen, such as a revocation that never
|
|
1757
|
+
* reached its connection. The stable code leads the message, as it does in the other errors this
|
|
1758
|
+
* library raises, and the original failure travels as `cause`.
|
|
1759
|
+
*
|
|
1760
|
+
* @param code - The stable error code to carry.
|
|
1761
|
+
* @param who - The class that raises it, shown in brackets.
|
|
1762
|
+
* @param what - What could not be reached.
|
|
1763
|
+
* @param cause - The failure underneath, whatever was thrown.
|
|
1764
|
+
*/
|
|
1765
|
+
declare function unavailableError(code: RealtimeErrorCode, who: string, what: string, cause: unknown): Error;
|
|
1766
|
+
|
|
1767
|
+
/**
|
|
1768
|
+
* @fileoverview Makes a delivery path's failure visible without failing the call that used it.
|
|
1769
|
+
* @layer utils
|
|
1770
|
+
*/
|
|
1771
|
+
|
|
1772
|
+
/**
|
|
1773
|
+
* Logs a delivery failure with its stable code and the operation, and hands it to the
|
|
1774
|
+
* `onDeliveryFailure` hook. The hook runs on its own: whether it throws or rejects, the failure
|
|
1775
|
+
* is logged and the caller carries on.
|
|
1776
|
+
*
|
|
1777
|
+
* @param logger - The raising class's logger.
|
|
1778
|
+
* @param hooks - The consumer's lifecycle hooks, if any.
|
|
1779
|
+
* @param failure - What failed; `error` may be whatever was thrown.
|
|
1780
|
+
* @param what - A short description for the log line.
|
|
1781
|
+
*/
|
|
1782
|
+
declare function reportDeliveryFailure(logger: Logger, hooks: IConnectionLifecycleHooks | undefined, failure: Omit<DeliveryFailure, 'error'> & {
|
|
1783
|
+
readonly error: unknown;
|
|
1784
|
+
}, what: string): void;
|
|
1785
|
+
|
|
1590
1786
|
/**
|
|
1591
1787
|
* @fileoverview Parser turning a raw HTTP `Cookie` header into a plain object.
|
|
1592
1788
|
* @layer utils
|
|
@@ -1681,31 +1877,5 @@ declare const RESERVED_EVENT_NAMES: {
|
|
|
1681
1877
|
/** Union of reserved event name values. */
|
|
1682
1878
|
type ReservedEventName = (typeof RESERVED_EVENT_NAMES)[keyof typeof RESERVED_EVENT_NAMES];
|
|
1683
1879
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
* @layer shared
|
|
1687
|
-
*/
|
|
1688
|
-
/**
|
|
1689
|
-
* Canonical error codes emitted by the library. Map 1-to-1 with
|
|
1690
|
-
* `docs/technical_specification.md` §14.
|
|
1691
|
-
*
|
|
1692
|
-
* `TOO_MANY_CONNECTIONS` signals FIFO eviction: when a user exceeds
|
|
1693
|
-
* `maxConnectionsPerUser`, the OLDEST connection is evicted (closed with this
|
|
1694
|
-
* code) and the new one is admitted — it is never an HTTP 429 rejection.
|
|
1695
|
-
*/
|
|
1696
|
-
declare const REALTIME_ERROR_CODES: {
|
|
1697
|
-
readonly INVALID_OPTIONS: "REALTIME_INVALID_OPTIONS";
|
|
1698
|
-
readonly NO_AUTHENTICATOR: "REALTIME_NO_AUTHENTICATOR";
|
|
1699
|
-
readonly AUTH_FAILED: "REALTIME_AUTH_FAILED";
|
|
1700
|
-
readonly REAUTHENTICATION_FAILED: "REALTIME_REAUTHENTICATION_FAILED";
|
|
1701
|
-
readonly TOO_MANY_CONNECTIONS: "REALTIME_TOO_MANY_CONNECTIONS";
|
|
1702
|
-
readonly INVALID_TICKET: "REALTIME_INVALID_TICKET";
|
|
1703
|
-
readonly PUBSUB_UNAVAILABLE: "REALTIME_PUBSUB_UNAVAILABLE";
|
|
1704
|
-
readonly REDIS_ADAPTER_FAILED: "REALTIME_REDIS_ADAPTER_FAILED";
|
|
1705
|
-
readonly PAYLOAD_TOO_LARGE: "REALTIME_PAYLOAD_TOO_LARGE";
|
|
1706
|
-
readonly REPLAY_BUFFER_MISS: "REALTIME_REPLAY_BUFFER_MISS";
|
|
1707
|
-
};
|
|
1708
|
-
/** Union of canonical error code values. */
|
|
1709
|
-
type RealtimeErrorCode = (typeof REALTIME_ERROR_CODES)[keyof typeof REALTIME_ERROR_CODES];
|
|
1710
|
-
|
|
1711
|
-
export { type AuthenticationResult, BymaxRealtimeModule, type BymaxRealtimeModuleAsyncOptions, type BymaxRealtimeModuleOptions, type BymaxRealtimeModuleOptionsFactory, type ConnectionAuthContext, type ConnectionEventMeta, ConnectionRegistry, type CorsConfig, EventIdGenerator, EventReplayBuffer, HeartbeatService, type IConnectionAuthenticator, type IConnectionLifecycleHooks, type IOfflineQueueStorage, type IPresenceStorage, type IRealtimePubSub, type ITransport, InMemoryPubSub, OfflineQueueDeliveryService, type OfflineQueuedEvent, type PublicConnectionMeta, REALTIME_AUTHENTICATOR_TOKEN, REALTIME_ERROR_CODES, REALTIME_HOOKS_TOKEN, REALTIME_INSTANCE_ID_TOKEN, REALTIME_OFFLINE_QUEUE_TOKEN, REALTIME_OPTIONS_TOKEN, REALTIME_PRESENCE_TOKEN, REALTIME_PUBSUB_TOKEN, REALTIME_TRANSPORT_TOKEN, RESERVED_EVENT_NAMES, ROOM_PREFIXES, type RealtimeErrorCode, type RealtimeEvent, type RealtimePubSubMessage, RealtimePubSubSubscriber, RealtimeService, type ReauthenticationPolicy, ReauthenticationService, RedisOfflineQueue, type RedisOfflineQueueOptions, RedisRealtimePubSub, type RedisRealtimePubSubOptions, type ReservedEventName, type RoomPrefix, RoomRegistry, type SseOptions, type SseRealtimeModuleAsyncOptions, type SseRealtimeModuleOptions, SseSubscriptionHandler, SseTransport, type TransportMode, type TransportRegistration, type TransportWiring, type WebSocketOptions, type WebSocketRealtimeModuleAsyncOptions, type WebSocketRealtimeModuleOptions, assertIdentityIsNotBlank, composeForRoot, composeForRootAsync, composeRoomId, createSseController, describeError, parseCookieHeader, resolveAuthTenant, sseWiring };
|
|
1880
|
+
export { BymaxRealtimeModule, ConnectionRegistry, EventIdGenerator, EventReplayBuffer, HeartbeatService, InMemoryPubSub, OfflineQueueDeliveryService, REALTIME_AUTHENTICATOR_TOKEN, REALTIME_ERROR_CODES, REALTIME_HOOKS_TOKEN, REALTIME_INSTANCE_ID_TOKEN, REALTIME_OFFLINE_QUEUE_TOKEN, REALTIME_OPTIONS_TOKEN, REALTIME_PRESENCE_TOKEN, REALTIME_PUBSUB_TOKEN, REALTIME_TRANSPORT_TOKEN, RESERVED_EVENT_NAMES, ROOM_PREFIXES, RealtimePubSubSubscriber, RealtimeService, ReauthenticationService, RedisOfflineQueue, RedisRealtimePubSub, RoomRegistry, SseSubscriptionHandler, SseTransport, assertIdentityIsNotBlank, composeForRoot, composeForRootAsync, composeRoomId, createSseController, describeError, parseCookieHeader, reportDeliveryFailure, resolveAuthTenant, sseWiring, unavailableError };
|
|
1881
|
+
export type { AuthenticationResult, BymaxRealtimeModuleAsyncOptions, BymaxRealtimeModuleOptions, BymaxRealtimeModuleOptionsFactory, ConnectionAuthContext, ConnectionEventMeta, CorsConfig, DeliveryFailure, IConnectionAuthenticator, IConnectionLifecycleHooks, IOfflineQueueStorage, IPresenceStorage, IRealtimePubSub, ITransport, OfflineQueuedEvent, PublicConnectionMeta, RealtimeErrorCode, RealtimeEvent, RealtimePubSubMessage, ReauthenticationPolicy, RedisOfflineQueueOptions, RedisRealtimePubSubOptions, ReservedEventName, RoomPrefix, SseOptions, SseRealtimeModuleAsyncOptions, SseRealtimeModuleOptions, TransportMode, TransportRegistration, TransportWiring, WebSocketOptions, WebSocketRealtimeModuleAsyncOptions, WebSocketRealtimeModuleOptions };
|