@replit/river 0.23.16 → 0.200.0-rc.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.
Files changed (72) hide show
  1. package/dist/{chunk-YXDAOVP7.js → chunk-3FALN7ZG.js} +2 -2
  2. package/dist/{chunk-R47IZD67.js → chunk-6GK2IIDP.js} +2 -2
  3. package/dist/{chunk-MQCGG6KL.js → chunk-6RKO3DDG.js} +4 -4
  4. package/dist/chunk-E2ZXI663.js +1995 -0
  5. package/dist/chunk-E2ZXI663.js.map +1 -0
  6. package/dist/{chunk-TXSQRTZB.js → chunk-LK74ZG7M.js} +25 -10
  7. package/dist/chunk-LK74ZG7M.js.map +1 -0
  8. package/dist/{chunk-UDXM64QK.js → chunk-NDLWNT7B.js} +2 -2
  9. package/dist/{chunk-6LCL2ZZF.js → chunk-QMM35C3H.js} +1 -1
  10. package/dist/chunk-QMM35C3H.js.map +1 -0
  11. package/dist/{chunk-JA7XGTAL.js → chunk-TK7QHUFP.js} +4 -4
  12. package/dist/{chunk-WN77AT67.js → chunk-YUY37VAK.js} +22 -6
  13. package/dist/chunk-YUY37VAK.js.map +1 -0
  14. package/dist/{connection-d738cc08.d.ts → connection-0638316b.d.ts} +1 -1
  15. package/dist/{connection-99a67d3e.d.ts → connection-c6521735.d.ts} +1 -1
  16. package/dist/{index-ea74cdbb.d.ts → index-10ebd26a.d.ts} +33 -33
  17. package/dist/logging/index.cjs.map +1 -1
  18. package/dist/logging/index.d.cts +1 -1
  19. package/dist/logging/index.d.ts +1 -1
  20. package/dist/logging/index.js +1 -1
  21. package/dist/router/index.cjs +1053 -912
  22. package/dist/router/index.cjs.map +1 -1
  23. package/dist/router/index.d.cts +19 -23
  24. package/dist/router/index.d.ts +19 -23
  25. package/dist/router/index.js +12 -6
  26. package/dist/services-34d97070.d.ts +1366 -0
  27. package/dist/transport/impls/uds/client.cjs +20 -4
  28. package/dist/transport/impls/uds/client.cjs.map +1 -1
  29. package/dist/transport/impls/uds/client.d.cts +3 -4
  30. package/dist/transport/impls/uds/client.d.ts +3 -4
  31. package/dist/transport/impls/uds/client.js +6 -6
  32. package/dist/transport/impls/uds/server.cjs +20 -4
  33. package/dist/transport/impls/uds/server.cjs.map +1 -1
  34. package/dist/transport/impls/uds/server.d.cts +4 -4
  35. package/dist/transport/impls/uds/server.d.ts +4 -4
  36. package/dist/transport/impls/uds/server.js +6 -6
  37. package/dist/transport/impls/ws/client.cjs +20 -4
  38. package/dist/transport/impls/ws/client.cjs.map +1 -1
  39. package/dist/transport/impls/ws/client.d.cts +5 -6
  40. package/dist/transport/impls/ws/client.d.ts +5 -6
  41. package/dist/transport/impls/ws/client.js +6 -6
  42. package/dist/transport/impls/ws/server.cjs +20 -4
  43. package/dist/transport/impls/ws/server.cjs.map +1 -1
  44. package/dist/transport/impls/ws/server.d.cts +4 -4
  45. package/dist/transport/impls/ws/server.d.ts +4 -4
  46. package/dist/transport/impls/ws/server.js +6 -6
  47. package/dist/transport/index.cjs +20 -4
  48. package/dist/transport/index.cjs.map +1 -1
  49. package/dist/transport/index.d.cts +27 -5
  50. package/dist/transport/index.d.ts +27 -5
  51. package/dist/transport/index.js +6 -6
  52. package/dist/util/testHelpers.cjs +370 -326
  53. package/dist/util/testHelpers.cjs.map +1 -1
  54. package/dist/util/testHelpers.d.cts +32 -21
  55. package/dist/util/testHelpers.d.ts +32 -21
  56. package/dist/util/testHelpers.js +76 -42
  57. package/dist/util/testHelpers.js.map +1 -1
  58. package/package.json +2 -3
  59. package/dist/chunk-6LCL2ZZF.js.map +0 -1
  60. package/dist/chunk-LTSLICON.js +0 -1865
  61. package/dist/chunk-LTSLICON.js.map +0 -1
  62. package/dist/chunk-TXSQRTZB.js.map +0 -1
  63. package/dist/chunk-WN77AT67.js.map +0 -1
  64. package/dist/client-0926d3d6.d.ts +0 -52
  65. package/dist/handshake-75d0124f.d.ts +0 -516
  66. package/dist/server-3740c5d9.d.ts +0 -24
  67. package/dist/services-75e84a9f.d.ts +0 -709
  68. /package/dist/{chunk-YXDAOVP7.js.map → chunk-3FALN7ZG.js.map} +0 -0
  69. /package/dist/{chunk-R47IZD67.js.map → chunk-6GK2IIDP.js.map} +0 -0
  70. /package/dist/{chunk-MQCGG6KL.js.map → chunk-6RKO3DDG.js.map} +0 -0
  71. /package/dist/{chunk-UDXM64QK.js.map → chunk-NDLWNT7B.js.map} +0 -0
  72. /package/dist/{chunk-JA7XGTAL.js.map → chunk-TK7QHUFP.js.map} +0 -0
@@ -1,516 +0,0 @@
1
- import { C as Codec } from './types-3e5768ec.js';
2
- import { e as TelemetryInfo, M as MessageMetadata, c as TransportClientId, f as PropagationContext, L as Logger, P as PartialTransportMessage, a as TransportMessage, b as OpaqueTransportMessage, g as LogFn, h as LoggingLevel } from './index-ea74cdbb.js';
3
- import { TSchema, Static } from '@sinclair/typebox';
4
-
5
- /**
6
- * A connection is the actual raw underlying transport connection.
7
- * It’s responsible for dispatching to/from the actual connection itself
8
- * This should be instantiated as soon as the client/server has a connection
9
- * It’s tied to the lifecycle of the underlying transport connection (i.e. if the WS drops, this connection should be deleted)
10
- */
11
- declare abstract class Connection {
12
- id: string;
13
- telemetry?: TelemetryInfo;
14
- constructor();
15
- get loggingMetadata(): MessageMetadata;
16
- /**
17
- * Handle adding a callback for when a message is received.
18
- * @param msg The message that was received.
19
- */
20
- abstract addDataListener(cb: (msg: Uint8Array) => void): void;
21
- abstract removeDataListener(cb: (msg: Uint8Array) => void): void;
22
- /**
23
- * Handle adding a callback for when the connection is closed.
24
- * This should also be called if an error happens.
25
- * @param cb The callback to call when the connection is closed.
26
- */
27
- abstract addCloseListener(cb: () => void): void;
28
- /**
29
- * Handle adding a callback for when an error is received.
30
- * This should only be used for this.logging errors, all cleanup
31
- * should be delegated to addCloseListener.
32
- *
33
- * The implementer should take care such that the implemented
34
- * connection will call both the close and error callbacks
35
- * on an error.
36
- *
37
- * @param cb The callback to call when an error is received.
38
- */
39
- abstract addErrorListener(cb: (err: Error) => void): void;
40
- /**
41
- * Sends a message over the connection.
42
- * @param msg The message to send.
43
- * @returns true if the message was sent, false otherwise.
44
- */
45
- abstract send(msg: Uint8Array): boolean;
46
- /**
47
- * Closes the connection.
48
- */
49
- abstract close(): void;
50
- }
51
- interface SessionOptions {
52
- /**
53
- * Frequency at which to send heartbeat acknowledgements
54
- */
55
- heartbeatIntervalMs: number;
56
- /**
57
- * Number of elapsed heartbeats without a response message before we consider
58
- * the connection dead.
59
- */
60
- heartbeatsUntilDead: number;
61
- /**
62
- * Duration to wait between connection disconnect and actual session disconnect
63
- */
64
- sessionDisconnectGraceMs: number;
65
- /**
66
- * The codec to use for encoding/decoding messages over the wire
67
- */
68
- codec: Codec;
69
- }
70
- /**
71
- * A session is a higher-level abstraction that operates over the span of potentially multiple transport-level connections
72
- * - It’s responsible for tracking any metadata for a particular client that might need to be persisted across connections (i.e. the sendBuffer, ack, seq)
73
- * - This will only be considered disconnected if
74
- * - the server tells the client that we’ve reconnected but it doesn’t recognize us anymore (server definitely died) or
75
- * - we hit a grace period after a connection disconnect
76
- */
77
- declare class Session<ConnType extends Connection> {
78
- private codec;
79
- private options;
80
- readonly telemetry: TelemetryInfo;
81
- /**
82
- * The buffer of messages that have been sent but not yet acknowledged.
83
- */
84
- private sendBuffer;
85
- /**
86
- * The active connection associated with this session
87
- */
88
- connection?: ConnType;
89
- /**
90
- * A connection that is currently undergoing handshaking. Used to distinguish between the active
91
- * connection, but still be able to close it if needed.
92
- */
93
- private handshakingConnection?;
94
- readonly from: TransportClientId;
95
- readonly to: TransportClientId;
96
- /**
97
- * The unique ID of this session.
98
- */
99
- readonly id: string;
100
- /**
101
- * What the other side advertised as their session ID
102
- * for this session.
103
- */
104
- advertisedSessionId?: string;
105
- /**
106
- * Number of messages we've sent along this session (excluding handshake and acks)
107
- */
108
- private seq;
109
- /**
110
- * Number of unique messages we've received this session (excluding handshake and acks)
111
- */
112
- private ack;
113
- /**
114
- * The grace period between when the inner connection is disconnected
115
- * and when we should consider the entire session disconnected.
116
- */
117
- private disconnectionGrace?;
118
- /**
119
- * Number of heartbeats we've sent without a response.
120
- */
121
- private heartbeatMisses;
122
- /**
123
- * The interval for sending heartbeats.
124
- */
125
- private heartbeat;
126
- private log?;
127
- constructor(conn: ConnType | undefined, from: TransportClientId, to: TransportClientId, options: SessionOptions, propagationCtx?: PropagationContext);
128
- bindLogger(log: Logger): void;
129
- get loggingMetadata(): MessageMetadata;
130
- /**
131
- * Sends a message over the session's connection.
132
- * If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
133
- *
134
- * @param msg The partial message to be sent, which will be constructed into a full message.
135
- * @param addToSendBuff Whether to add the message to the send buffer for retry.
136
- * @returns The full transport ID of the message that was attempted to be sent.
137
- */
138
- send(msg: PartialTransportMessage): string;
139
- sendHeartbeat(): void;
140
- resetBufferedMessages(): void;
141
- sendBufferedMessages(conn: ConnType): void;
142
- updateBookkeeping(ack: number, seq: number): void;
143
- private closeStaleConnection;
144
- replaceWithNewConnection(newConn: ConnType, isTransparentReconnect: boolean): void;
145
- replaceWithNewHandshakingConnection(newConn: ConnType): void;
146
- beginGrace(cb: () => void): void;
147
- cancelGrace(): void;
148
- /**
149
- * Used to close the handshaking connection, if set.
150
- */
151
- closeHandshakingConnection(expectedHandshakingConn?: ConnType): void;
152
- close(): void;
153
- get connected(): boolean;
154
- get nextExpectedAck(): number;
155
- get nextExpectedSeq(): number;
156
- /**
157
- * Check that the peer's next expected seq number matches something that is in our send buffer
158
- * _or_ matches our actual next seq.
159
- */
160
- nextExpectedSeqInRange(nextExpectedSeq: number): boolean;
161
- advanceAckForTesting(by: number): void;
162
- constructMsg<Payload>(partialMsg: PartialTransportMessage<Payload>): TransportMessage<Payload>;
163
- inspectSendBuffer(): ReadonlyArray<OpaqueTransportMessage>;
164
- }
165
-
166
- type ConnectionStatus = 'connect' | 'disconnect';
167
- declare const ProtocolError: {
168
- readonly RetriesExceeded: "conn_retry_exceeded";
169
- readonly HandshakeFailed: "handshake_failed";
170
- readonly MessageOrderingViolated: "message_ordering_violated";
171
- };
172
- type ProtocolErrorType = (typeof ProtocolError)[keyof typeof ProtocolError];
173
- interface EventMap {
174
- message: OpaqueTransportMessage;
175
- connectionStatus: {
176
- status: ConnectionStatus;
177
- conn: Connection;
178
- };
179
- sessionStatus: {
180
- status: ConnectionStatus;
181
- session: Session<Connection>;
182
- };
183
- protocolError: {
184
- type: ProtocolErrorType;
185
- message: string;
186
- };
187
- transportStatus: {
188
- status: TransportStatus;
189
- };
190
- }
191
- type EventTypes = keyof EventMap;
192
- type EventHandler<K extends EventTypes> = (event: EventMap[K]) => unknown;
193
- declare class EventDispatcher<T extends EventTypes> {
194
- private eventListeners;
195
- removeAllListeners(): void;
196
- numberOfListeners<K extends T>(eventType: K): number;
197
- addEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
198
- removeEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
199
- dispatchEvent<K extends T>(eventType: K, event: EventMap[K]): void;
200
- }
201
-
202
- /**
203
- * Options to control the backoff and retry behavior of the client transport's connection behaviour.
204
- *
205
- * River implements exponential backoff with jitter to prevent flooding the server
206
- * when there's an issue with connection establishment.
207
- *
208
- * The backoff is calculated via the following:
209
- * backOff = min(jitter + {@link baseIntervalMs} * 2 ^ budget_consumed, {@link maxBackoffMs})
210
- *
211
- * We use a leaky bucket rate limit with a budget of {@link attemptBudgetCapacity} reconnection attempts.
212
- * Budget only starts to restore after a successful handshake at a rate of one budget per {@link budgetRestoreIntervalMs}.
213
- */
214
- interface ConnectionRetryOptions {
215
- /**
216
- * The base interval to wait before retrying a connection.
217
- */
218
- baseIntervalMs: number;
219
- /**
220
- * The maximum random jitter to add to the total backoff time.
221
- */
222
- maxJitterMs: number;
223
- /**
224
- * The maximum amount of time to wait before retrying a connection.
225
- * This does not include the jitter.
226
- */
227
- maxBackoffMs: number;
228
- /**
229
- * The max number of times to attempt a connection before a successful handshake.
230
- * This persists across connections but starts restoring budget after a successful handshake.
231
- * The restoration interval depends on {@link budgetRestoreIntervalMs}
232
- */
233
- attemptBudgetCapacity: number;
234
- /**
235
- * After a successful connection attempt, how long to wait before we restore a single budget.
236
- */
237
- budgetRestoreIntervalMs: number;
238
- }
239
- declare class LeakyBucketRateLimit {
240
- private budgetConsumed;
241
- private intervalHandles;
242
- private readonly options;
243
- constructor(options: ConnectionRetryOptions);
244
- getBackoffMs(user: TransportClientId): number;
245
- get totalBudgetRestoreTime(): number;
246
- consumeBudget(user: TransportClientId): void;
247
- getBudgetConsumed(user: TransportClientId): number;
248
- hasBudget(user: TransportClientId): boolean;
249
- startRestoringBudget(user: TransportClientId): void;
250
- private stopLeak;
251
- close(): void;
252
- }
253
-
254
- type TransportOptions = SessionOptions;
255
- type ProvidedTransportOptions = Partial<TransportOptions>;
256
- type ClientTransportOptions = TransportOptions & ConnectionRetryOptions;
257
- type ProvidedClientTransportOptions = Partial<ClientTransportOptions>;
258
- type ServerTransportOptions = TransportOptions;
259
- type ProvidedServerTransportOptions = Partial<ServerTransportOptions>;
260
-
261
- /**
262
- * Represents the possible states of a transport.
263
- * @property {'open'} open - The transport is open and operational (note that this doesn't mean it is actively connected)
264
- * @property {'closed'} closed - The transport is permanently closed and cannot be reopened.
265
- */
266
- type TransportStatus = 'open' | 'closed';
267
- /**
268
- * Transports manage the lifecycle (creation/deletion) of sessions and connections. Its responsibilities include:
269
- *
270
- * 1) Constructing a new {@link Session} and {@link Connection} on {@link TransportMessage}s from new clients.
271
- * After constructing the {@link Connection}, {@link onConnect} is called which adds it to the connection map.
272
- * 2) Delegating message listening of the connection to the newly created {@link Connection}.
273
- * From this point on, the {@link Connection} is responsible for *reading* and *writing*
274
- * messages from the connection.
275
- * 3) When a connection is closed, the {@link Transport} calls {@link onDisconnect} which closes the
276
- * connection via {@link Connection.close} and removes it from the {@link connections} map.
277
-
278
- *
279
- * ```plaintext
280
- * ▲
281
- * incoming │
282
- * messages │
283
- * ▼
284
- * ┌─────────────┐ 1:N ┌───────────┐ 1:1* ┌────────────┐
285
- * │ Transport │ ◄─────► │ Session │ ◄─────► │ Connection │
286
- * └─────────────┘ └───────────┘ └────────────┘
287
- * ▲ * (may or may not be initialized yet)
288
- * │
289
- * ▼
290
- * ┌───────────┐
291
- * │ Message │
292
- * │ Listeners │
293
- * └───────────┘
294
- * ```
295
- * @abstract
296
- */
297
- declare abstract class Transport<ConnType extends Connection> {
298
- /**
299
- * The status of the transport.
300
- */
301
- private status;
302
- /**
303
- * The {@link Codec} used to encode and decode messages.
304
- */
305
- codec: Codec;
306
- /**
307
- * The client ID of this transport.
308
- */
309
- clientId: TransportClientId;
310
- /**
311
- * The map of {@link Session}s managed by this transport.
312
- */
313
- sessions: Map<TransportClientId, Session<ConnType>>;
314
- /**
315
- * The map of {@link Connection}s managed by this transport.
316
- */
317
- get connections(): Map<string, ConnType>;
318
- /**
319
- * The event dispatcher for handling events of type EventTypes.
320
- */
321
- eventDispatcher: EventDispatcher<EventTypes>;
322
- /**
323
- * The options for this transport.
324
- */
325
- protected options: TransportOptions;
326
- log?: Logger;
327
- /**
328
- * Creates a new Transport instance.
329
- * This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
330
- * @param codec The codec used to encode and decode messages.
331
- * @param clientId The client ID of this transport.
332
- */
333
- constructor(clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
334
- bindLogger(fn: LogFn | Logger, level?: LoggingLevel): void;
335
- /**
336
- * This is called immediately after a new connection is established and we
337
- * may or may not know the identity of the connected client.
338
- * It should attach all the necessary listeners to the connection for lifecycle
339
- * events (i.e. data, close, error)
340
- *
341
- * This method is implemented by {@link ClientTransport} and {@link ServerTransport}.
342
- */
343
- protected abstract handleConnection(conn: ConnType, to: TransportClientId): void;
344
- /**
345
- * Called when a new connection is established
346
- * and we know the identity of the connected client.
347
- * @param conn The connection object.
348
- */
349
- protected onConnect(conn: ConnType, session: Session<ConnType>, isTransparentReconnect: boolean): void;
350
- protected createSession(to: TransportClientId, conn?: ConnType, propagationCtx?: PropagationContext): Session<ConnType>;
351
- protected createNewSession({ to, conn, sessionId, propagationCtx, }: {
352
- to: TransportClientId;
353
- conn: ConnType;
354
- sessionId: string;
355
- propagationCtx?: PropagationContext;
356
- }): Session<ConnType>;
357
- protected getExistingSession({ to, sessionId, nextExpectedSeq, }: {
358
- to: TransportClientId;
359
- sessionId: string;
360
- nextExpectedSeq: number;
361
- }): false | Session<ConnType>;
362
- protected getOrCreateSession({ to, conn, handshakingConn, sessionId, propagationCtx, }: {
363
- to: TransportClientId;
364
- conn?: ConnType;
365
- handshakingConn?: ConnType;
366
- sessionId?: string;
367
- propagationCtx?: PropagationContext;
368
- }): {
369
- session: Session<ConnType>;
370
- isReconnect: boolean;
371
- isTransparentReconnect: boolean;
372
- };
373
- protected deleteSession({ session, closeHandshakingConnection, handshakingConn, }: {
374
- session: Session<ConnType>;
375
- closeHandshakingConnection: boolean;
376
- handshakingConn?: ConnType;
377
- }): void;
378
- /**
379
- * The downstream implementation needs to call this when a connection is closed.
380
- * @param conn The connection object.
381
- * @param connectedTo The peer we are connected to.
382
- */
383
- protected onDisconnect(conn: ConnType, session: Session<ConnType>): void;
384
- /**
385
- * Parses a message from a Uint8Array into a {@link OpaqueTransportMessage}.
386
- * @param msg The message to parse.
387
- * @returns The parsed message, or null if the message is malformed or invalid.
388
- */
389
- protected parseMsg(msg: Uint8Array, conn: ConnType): OpaqueTransportMessage | null;
390
- /**
391
- * Called when a message is received by this transport.
392
- * You generally shouldn't need to override this in downstream transport implementations.
393
- * @param msg The received message.
394
- */
395
- protected handleMsg(msg: OpaqueTransportMessage, conn: ConnType): void;
396
- /**
397
- * Adds a listener to this transport.
398
- * @param the type of event to listen for
399
- * @param handler The message handler to add.
400
- */
401
- addEventListener<K extends EventTypes, T extends EventHandler<K>>(type: K, handler: T): void;
402
- /**
403
- * Removes a listener from this transport.
404
- * @param the type of event to un-listen on
405
- * @param handler The message handler to remove.
406
- */
407
- removeEventListener<K extends EventTypes, T extends EventHandler<K>>(type: K, handler: T): void;
408
- /**
409
- * Sends a message over this transport, delegating to the appropriate connection to actually
410
- * send the message.
411
- * @param msg The message to send.
412
- * @returns The ID of the sent message or undefined if it wasn't sent
413
- */
414
- send(to: TransportClientId, msg: PartialTransportMessage): string;
415
- sendCloseStream(to: TransportClientId, streamId: string): string;
416
- protected protocolError(type: ProtocolErrorType, message: string): void;
417
- /**
418
- * Default close implementation for transports. You should override this in the downstream
419
- * implementation if you need to do any additional cleanup and call super.close() at the end.
420
- * Closes the transport. Any messages sent while the transport is closed will be silently discarded.
421
- */
422
- close(): void;
423
- getStatus(): TransportStatus;
424
- }
425
-
426
- /**
427
- * The context for services/procedures. This is used only on
428
- * the server.
429
- *
430
- * An important detail is that the state prop is always on
431
- * this interface and it shouldn't be changed, removed, or
432
- * extended. This prop is for the state of a service.
433
- *
434
- * You should use declaration merging to extend this interface
435
- * with whatever you need. For example, if you need to access
436
- * a database, you could do:
437
- *
438
- * ```ts
439
- * declare module '@replit/river' {
440
- * interface ServiceContext {
441
- * db: Database;
442
- * }
443
- * }
444
- * ```
445
- */
446
- interface ServiceContext {
447
- }
448
- /**
449
- * The parsed metadata schema for a service. This is the
450
- * return value of the {@link ServerHandshakeOptions.validate}
451
- * if the handshake extension is used.
452
-
453
- * You should use declaration merging to extend this interface
454
- * with the sanitized metadata.
455
- *
456
- * ```ts
457
- * declare module '@replit/river' {
458
- * interface ParsedMetadata {
459
- * userId: number;
460
- * }
461
- * }
462
- * ```
463
- */
464
- interface ParsedMetadata {
465
- }
466
- /**
467
- * The {@link ServiceContext} with state. This is what is passed to procedures.
468
- */
469
- type ServiceContextWithState<State> = ServiceContext & {
470
- state: State;
471
- };
472
- type ServiceContextWithTransportInfo<State> = ServiceContext & {
473
- state: State;
474
- to: TransportClientId;
475
- from: TransportClientId;
476
- streamId: string;
477
- session: Session<Connection>;
478
- metadata: ParsedMetadata;
479
- };
480
-
481
- type ConstructHandshake<T extends TSchema> = () => Static<T> | Promise<Static<T>>;
482
- type ValidateHandshake<T extends TSchema> = (metadata: Static<T>, previousParsedMetadata?: ParsedMetadata) => false | ParsedMetadata | Promise<false | ParsedMetadata>;
483
- interface ClientHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
484
- /**
485
- * Schema for the metadata that the client sends to the server
486
- * during the handshake.
487
- */
488
- schema: MetadataSchema;
489
- /**
490
- * Gets the {@link HandshakeRequestMetadata} to send to the server.
491
- */
492
- construct: ConstructHandshake<MetadataSchema>;
493
- }
494
- interface ServerHandshakeOptions<MetadataSchema extends TSchema = TSchema> {
495
- /**
496
- * Schema for the metadata that the server receives from the client
497
- * during the handshake.
498
- */
499
- schema: MetadataSchema;
500
- /**
501
- * Parses the {@link HandshakeRequestMetadata} sent by the client, transforming
502
- * it into {@link ParsedHandshakeMetadata}.
503
- *
504
- * May return `false` if the client should be rejected.
505
- *
506
- * @param metadata - The metadata sent by the client.
507
- * @param session - The session that the client would be associated with.
508
- * @param isReconnect - Whether the client is reconnecting to the session,
509
- * or if this is a new session.
510
- */
511
- validate: ValidateHandshake<MetadataSchema>;
512
- }
513
- declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions;
514
- declare function createServerHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, validate: ValidateHandshake<MetadataSchema>): ServerHandshakeOptions;
515
-
516
- export { Connection as C, EventMap as E, LeakyBucketRateLimit as L, ProvidedTransportOptions as P, Session as S, Transport as T, TransportStatus as a, ProvidedClientTransportOptions as b, ProvidedServerTransportOptions as c, EventTypes as d, EventHandler as e, ProtocolError as f, ProtocolErrorType as g, SessionOptions as h, ServiceContext as i, ClientTransportOptions as j, ClientHandshakeOptions as k, ServerTransportOptions as l, ServerHandshakeOptions as m, ParsedMetadata as n, ServiceContextWithState as o, ServiceContextWithTransportInfo as p, createClientHandshakeOptions as q, createServerHandshakeOptions as r };
@@ -1,24 +0,0 @@
1
- import { C as Connection, T as Transport, l as ServerTransportOptions, m as ServerHandshakeOptions, S as Session, n as ParsedMetadata, c as ProvidedServerTransportOptions } from './handshake-75d0124f.js';
2
- import { c as TransportClientId } from './index-ea74cdbb.js';
3
-
4
- declare abstract class ServerTransport<ConnType extends Connection> extends Transport<ConnType> {
5
- /**
6
- * The options for this transport.
7
- */
8
- protected options: ServerTransportOptions;
9
- /**
10
- * Optional handshake options for the server.
11
- */
12
- handshakeExtensions?: ServerHandshakeOptions;
13
- /**
14
- * A map of session handshake data for each session.
15
- */
16
- sessionHandshakeMetadata: WeakMap<Session<ConnType>, ParsedMetadata>;
17
- constructor(clientId: TransportClientId, providedOptions?: ProvidedServerTransportOptions);
18
- extendHandshake(options: ServerHandshakeOptions): void;
19
- protected handleConnection(conn: ConnType): void;
20
- private validateHandshakeMetadata;
21
- receiveHandshakeRequestMessage(data: Uint8Array, conn: ConnType): Promise<Session<ConnType> | false>;
22
- }
23
-
24
- export { ServerTransport as S };