@replit/river 0.25.2 → 0.26.1

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 (53) hide show
  1. package/dist/{chunk-GDHQCPWW.js → chunk-4W5LENT2.js} +2 -2
  2. package/dist/{chunk-GDHQCPWW.js.map → chunk-4W5LENT2.js.map} +1 -1
  3. package/dist/{chunk-PF74DCPQ.js → chunk-6UVTCZ6K.js} +5 -5
  4. package/dist/chunk-6UVTCZ6K.js.map +1 -0
  5. package/dist/{chunk-ZWMWRM23.js → chunk-AYIMQWS7.js} +2 -2
  6. package/dist/{chunk-QXMZJ7LF.js → chunk-IVNX5H6C.js} +56 -44
  7. package/dist/chunk-IVNX5H6C.js.map +1 -0
  8. package/dist/{chunk-Q3PZBJXR.js → chunk-M43R4RPL.js} +10 -4
  9. package/dist/chunk-M43R4RPL.js.map +1 -0
  10. package/dist/{chunk-EHD2JJBW.js → chunk-UQOD22AN.js} +14 -4
  11. package/dist/chunk-UQOD22AN.js.map +1 -0
  12. package/dist/{chunk-ONIPHO7J.js → chunk-XRI2BXMM.js} +23 -9
  13. package/dist/chunk-XRI2BXMM.js.map +1 -0
  14. package/dist/{client-edc8e2de.d.ts → client-0f636b3a.d.ts} +2 -2
  15. package/dist/{connection-ef50ac3a.d.ts → connection-07e97a79.d.ts} +1 -1
  16. package/dist/{handshake-12d57161.d.ts → handshake-8752f79e.d.ts} +10 -6
  17. package/dist/logging/index.d.cts +1 -1
  18. package/dist/logging/index.d.ts +1 -1
  19. package/dist/{message-e6c560fd.d.ts → message-57296605.d.ts} +3 -1
  20. package/dist/router/index.cjs +12 -3
  21. package/dist/router/index.cjs.map +1 -1
  22. package/dist/router/index.d.cts +8 -8
  23. package/dist/router/index.d.ts +8 -8
  24. package/dist/router/index.js +2 -2
  25. package/dist/{server-f8228636.d.ts → server-e304daec.d.ts} +2 -2
  26. package/dist/{services-4b9e5232.d.ts → services-fc99aae1.d.ts} +3 -3
  27. package/dist/transport/impls/ws/client.cjs +41 -12
  28. package/dist/transport/impls/ws/client.cjs.map +1 -1
  29. package/dist/transport/impls/ws/client.d.cts +4 -4
  30. package/dist/transport/impls/ws/client.d.ts +4 -4
  31. package/dist/transport/impls/ws/client.js +5 -5
  32. package/dist/transport/impls/ws/server.cjs +73 -47
  33. package/dist/transport/impls/ws/server.cjs.map +1 -1
  34. package/dist/transport/impls/ws/server.d.cts +4 -4
  35. package/dist/transport/impls/ws/server.d.ts +4 -4
  36. package/dist/transport/impls/ws/server.js +5 -5
  37. package/dist/transport/index.cjs +92 -52
  38. package/dist/transport/index.cjs.map +1 -1
  39. package/dist/transport/index.d.cts +4 -4
  40. package/dist/transport/index.d.ts +4 -4
  41. package/dist/transport/index.js +5 -5
  42. package/dist/util/testHelpers.cjs +20 -5
  43. package/dist/util/testHelpers.cjs.map +1 -1
  44. package/dist/util/testHelpers.d.cts +4 -4
  45. package/dist/util/testHelpers.d.ts +4 -4
  46. package/dist/util/testHelpers.js +3 -3
  47. package/package.json +1 -1
  48. package/dist/chunk-EHD2JJBW.js.map +0 -1
  49. package/dist/chunk-ONIPHO7J.js.map +0 -1
  50. package/dist/chunk-PF74DCPQ.js.map +0 -1
  51. package/dist/chunk-Q3PZBJXR.js.map +0 -1
  52. package/dist/chunk-QXMZJ7LF.js.map +0 -1
  53. /package/dist/{chunk-ZWMWRM23.js.map → chunk-AYIMQWS7.js.map} +0 -0
@@ -1,7 +1,7 @@
1
- import { C as ClientTransport } from '../../../client-edc8e2de.js';
2
- import { c as TransportClientId } from '../../../message-e6c560fd.js';
3
- import { b as ProvidedClientTransportOptions } from '../../../handshake-12d57161.js';
4
- import { W as WebSocketConnection } from '../../../connection-ef50ac3a.js';
1
+ import { C as ClientTransport } from '../../../client-0f636b3a.js';
2
+ import { c as TransportClientId } from '../../../message-57296605.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../handshake-8752f79e.js';
4
+ import { W as WebSocketConnection } from '../../../connection-07e97a79.js';
5
5
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
6
6
  import '@sinclair/typebox/value';
7
7
  import '@sinclair/typebox';
@@ -1,7 +1,7 @@
1
- import { C as ClientTransport } from '../../../client-edc8e2de.js';
2
- import { c as TransportClientId } from '../../../message-e6c560fd.js';
3
- import { b as ProvidedClientTransportOptions } from '../../../handshake-12d57161.js';
4
- import { W as WebSocketConnection } from '../../../connection-ef50ac3a.js';
1
+ import { C as ClientTransport } from '../../../client-0f636b3a.js';
2
+ import { c as TransportClientId } from '../../../message-57296605.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../handshake-8752f79e.js';
4
+ import { W as WebSocketConnection } from '../../../connection-07e97a79.js';
5
5
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
6
6
  import '@sinclair/typebox/value';
7
7
  import '@sinclair/typebox';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  ClientTransport
3
- } from "../../../chunk-ONIPHO7J.js";
3
+ } from "../../../chunk-XRI2BXMM.js";
4
4
  import {
5
5
  WebSocketConnection
6
- } from "../../../chunk-ZWMWRM23.js";
7
- import "../../../chunk-PF74DCPQ.js";
6
+ } from "../../../chunk-AYIMQWS7.js";
7
+ import "../../../chunk-6UVTCZ6K.js";
8
8
  import "../../../chunk-TAH2GVTJ.js";
9
- import "../../../chunk-Q3PZBJXR.js";
10
- import "../../../chunk-EHD2JJBW.js";
9
+ import "../../../chunk-M43R4RPL.js";
10
+ import "../../../chunk-UQOD22AN.js";
11
11
  import "../../../chunk-4PVU7J25.js";
12
12
 
13
13
  // transport/impls/ws/client.ts
@@ -196,11 +196,20 @@ var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
196
196
  var HandshakeErrorRetriableResponseCodes = import_typebox.Type.Union([
197
197
  import_typebox.Type.Literal("SESSION_STATE_MISMATCH")
198
198
  ]);
199
+ var HandshakeErrorCustomHandlerFatalResponseCodes = import_typebox.Type.Union([
200
+ // The custom validation handler rejected the handler because the client is unsupported.
201
+ import_typebox.Type.Literal("REJECTED_UNSUPPORTED_CLIENT"),
202
+ // The custom validation handler rejected the handshake.
203
+ import_typebox.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
204
+ ]);
199
205
  var HandshakeErrorFatalResponseCodes = import_typebox.Type.Union([
206
+ HandshakeErrorCustomHandlerFatalResponseCodes,
207
+ // The ciient sent a handshake that doesn't comply with the extended handshake metadata.
200
208
  import_typebox.Type.Literal("MALFORMED_HANDSHAKE_META"),
209
+ // The ciient sent a handshake that doesn't comply with ControlMessageHandshakeRequestSchema.
201
210
  import_typebox.Type.Literal("MALFORMED_HANDSHAKE"),
202
- import_typebox.Type.Literal("PROTOCOL_VERSION_MISMATCH"),
203
- import_typebox.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
211
+ // The client's protocol version does not match the server's.
212
+ import_typebox.Type.Literal("PROTOCOL_VERSION_MISMATCH")
204
213
  ]);
205
214
  var HandshakeErrorResponseCodes = import_typebox.Type.Union([
206
215
  HandshakeErrorRetriableResponseCodes,
@@ -636,7 +645,7 @@ var SessionNoConnection = class extends IdentifiedSession {
636
645
  var import_api = require("@opentelemetry/api");
637
646
 
638
647
  // package.json
639
- var version = "0.25.2";
648
+ var version = "0.26.1";
640
649
 
641
650
  // tracing/index.ts
642
651
  function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
@@ -678,7 +687,10 @@ var SessionWaitingForHandshake = class extends CommonSession {
678
687
  onHandshakeData = (msg) => {
679
688
  const parsedMsg = this.parseMsg(msg);
680
689
  if (parsedMsg === null) {
681
- this.listeners.onInvalidHandshake("could not parse message");
690
+ this.listeners.onInvalidHandshake(
691
+ "could not parse message",
692
+ "MALFORMED_HANDSHAKE"
693
+ );
682
694
  return;
683
695
  }
684
696
  this.listeners.onHandshake(parsedMsg);
@@ -724,7 +736,10 @@ var SessionHandshaking = class extends IdentifiedSession {
724
736
  onHandshakeData = (msg) => {
725
737
  const parsedMsg = this.parseMsg(msg);
726
738
  if (parsedMsg === null) {
727
- this.listeners.onInvalidHandshake("could not parse message");
739
+ this.listeners.onInvalidHandshake(
740
+ "could not parse message",
741
+ "MALFORMED_HANDSHAKE"
742
+ );
728
743
  return;
729
744
  }
730
745
  this.listeners.onHandshake(parsedMsg);
@@ -1214,8 +1229,8 @@ var Transport = class {
1214
1229
  removeEventListener(type, handler) {
1215
1230
  this.eventDispatcher.removeEventListener(type, handler);
1216
1231
  }
1217
- protocolError(type, message) {
1218
- this.eventDispatcher.dispatchEvent("protocolError", { type, message });
1232
+ protocolError(message) {
1233
+ this.eventDispatcher.dispatchEvent("protocolError", message);
1219
1234
  }
1220
1235
  /**
1221
1236
  * Default close implementation for transports. You should override this in the downstream
@@ -1420,13 +1435,17 @@ var ServerTransport = class extends Transport {
1420
1435
  receivedHandshake = true;
1421
1436
  void this.onHandshakeRequest(pendingSession, msg);
1422
1437
  },
1423
- onInvalidHandshake: (reason) => {
1438
+ onInvalidHandshake: (reason, code) => {
1424
1439
  this.log?.error(
1425
1440
  `invalid handshake: ${reason}`,
1426
1441
  pendingSession.loggingMetadata
1427
1442
  );
1428
1443
  this.deletePendingSession(pendingSession);
1429
- this.protocolError(ProtocolError.HandshakeFailed, reason);
1444
+ this.protocolError({
1445
+ type: ProtocolError.HandshakeFailed,
1446
+ code,
1447
+ message: reason
1448
+ });
1430
1449
  }
1431
1450
  },
1432
1451
  this.options,
@@ -1451,7 +1470,11 @@ var ServerTransport = class extends Transport {
1451
1470
  }
1452
1471
  })
1453
1472
  );
1454
- this.protocolError(ProtocolError.HandshakeFailed, reason);
1473
+ this.protocolError({
1474
+ type: ProtocolError.HandshakeFailed,
1475
+ code,
1476
+ message: reason
1477
+ });
1455
1478
  this.deletePendingSession(session);
1456
1479
  }
1457
1480
  async onHandshakeRequest(session, msg) {
@@ -1613,7 +1636,10 @@ var ServerTransport = class extends Transport {
1613
1636
  },
1614
1637
  onMessage: (msg2) => this.handleMsg(msg2),
1615
1638
  onInvalidMessage: (reason) => {
1616
- this.protocolError(ProtocolError.MessageOrderingViolated, reason);
1639
+ this.protocolError({
1640
+ type: ProtocolError.MessageOrderingViolated,
1641
+ message: reason
1642
+ });
1617
1643
  this.deleteSession(connectedSession);
1618
1644
  }
1619
1645
  }
@@ -1624,43 +1650,43 @@ var ServerTransport = class extends Transport {
1624
1650
  connectedSession.startActiveHeartbeat();
1625
1651
  }
1626
1652
  async validateHandshakeMetadata(handshakingSession, existingSession, rawMetadata, from) {
1627
- let parsedMetadata = {};
1628
- if (this.handshakeExtensions) {
1629
- if (!import_value2.Value.Check(this.handshakeExtensions.schema, rawMetadata)) {
1630
- this.rejectHandshakeRequest(
1631
- handshakingSession,
1632
- from,
1633
- "received malformed handshake metadata",
1634
- "MALFORMED_HANDSHAKE_META",
1635
- {
1636
- ...handshakingSession.loggingMetadata,
1637
- connectedTo: from,
1638
- validationErrors: [
1639
- ...import_value2.Value.Errors(this.handshakeExtensions.schema, rawMetadata)
1640
- ]
1641
- }
1642
- );
1643
- return false;
1644
- }
1645
- const previousParsedMetadata = existingSession ? this.sessionHandshakeMetadata.get(existingSession.to) : void 0;
1646
- parsedMetadata = await this.handshakeExtensions.validate(
1647
- rawMetadata,
1648
- previousParsedMetadata
1653
+ if (!this.handshakeExtensions) {
1654
+ return {};
1655
+ }
1656
+ if (!import_value2.Value.Check(this.handshakeExtensions.schema, rawMetadata)) {
1657
+ this.rejectHandshakeRequest(
1658
+ handshakingSession,
1659
+ from,
1660
+ "received malformed handshake metadata",
1661
+ "MALFORMED_HANDSHAKE_META",
1662
+ {
1663
+ ...handshakingSession.loggingMetadata,
1664
+ connectedTo: from,
1665
+ validationErrors: [
1666
+ ...import_value2.Value.Errors(this.handshakeExtensions.schema, rawMetadata)
1667
+ ]
1668
+ }
1649
1669
  );
1650
- if (parsedMetadata === false) {
1651
- this.rejectHandshakeRequest(
1652
- handshakingSession,
1653
- from,
1654
- "rejected by handshake handler",
1655
- "REJECTED_BY_CUSTOM_HANDLER",
1656
- {
1657
- ...handshakingSession.loggingMetadata,
1658
- connectedTo: from,
1659
- clientId: this.clientId
1660
- }
1661
- );
1662
- return false;
1663
- }
1670
+ return false;
1671
+ }
1672
+ const previousParsedMetadata = existingSession ? this.sessionHandshakeMetadata.get(existingSession.to) : void 0;
1673
+ const parsedMetadata = await this.handshakeExtensions.validate(
1674
+ rawMetadata,
1675
+ previousParsedMetadata
1676
+ );
1677
+ if (import_value2.Value.Check(HandshakeErrorCustomHandlerFatalResponseCodes, parsedMetadata)) {
1678
+ this.rejectHandshakeRequest(
1679
+ handshakingSession,
1680
+ from,
1681
+ "rejected by handshake handler",
1682
+ parsedMetadata,
1683
+ {
1684
+ ...handshakingSession.loggingMetadata,
1685
+ connectedTo: from,
1686
+ clientId: this.clientId
1687
+ }
1688
+ );
1689
+ return false;
1664
1690
  }
1665
1691
  return parsedMetadata;
1666
1692
  }