@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,9 +1,9 @@
1
- import { c as TransportClientId } from '../../../message-e6c560fd.js';
1
+ import { c as TransportClientId } from '../../../message-57296605.js';
2
2
  import { WebSocketServer } from 'ws';
3
- import { W as WebSocketConnection } from '../../../connection-ef50ac3a.js';
3
+ import { W as WebSocketConnection } from '../../../connection-07e97a79.js';
4
4
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
5
- import { S as ServerTransport } from '../../../server-f8228636.js';
6
- import { c as ProvidedServerTransportOptions } from '../../../handshake-12d57161.js';
5
+ import { S as ServerTransport } from '../../../server-e304daec.js';
6
+ import { c as ProvidedServerTransportOptions } from '../../../handshake-8752f79e.js';
7
7
  import '@sinclair/typebox/value';
8
8
  import '@sinclair/typebox';
9
9
  import '@opentelemetry/api';
@@ -1,9 +1,9 @@
1
- import { c as TransportClientId } from '../../../message-e6c560fd.js';
1
+ import { c as TransportClientId } from '../../../message-57296605.js';
2
2
  import { WebSocketServer } from 'ws';
3
- import { W as WebSocketConnection } from '../../../connection-ef50ac3a.js';
3
+ import { W as WebSocketConnection } from '../../../connection-07e97a79.js';
4
4
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
5
- import { S as ServerTransport } from '../../../server-f8228636.js';
6
- import { c as ProvidedServerTransportOptions } from '../../../handshake-12d57161.js';
5
+ import { S as ServerTransport } from '../../../server-e304daec.js';
6
+ import { c as ProvidedServerTransportOptions } from '../../../handshake-8752f79e.js';
7
7
  import '@sinclair/typebox/value';
8
8
  import '@sinclair/typebox';
9
9
  import '@opentelemetry/api';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  ServerTransport
3
- } from "../../../chunk-QXMZJ7LF.js";
3
+ } from "../../../chunk-IVNX5H6C.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/server.ts
@@ -255,11 +255,20 @@ var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
255
255
  var HandshakeErrorRetriableResponseCodes = import_typebox.Type.Union([
256
256
  import_typebox.Type.Literal("SESSION_STATE_MISMATCH")
257
257
  ]);
258
+ var HandshakeErrorCustomHandlerFatalResponseCodes = import_typebox.Type.Union([
259
+ // The custom validation handler rejected the handler because the client is unsupported.
260
+ import_typebox.Type.Literal("REJECTED_UNSUPPORTED_CLIENT"),
261
+ // The custom validation handler rejected the handshake.
262
+ import_typebox.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
263
+ ]);
258
264
  var HandshakeErrorFatalResponseCodes = import_typebox.Type.Union([
265
+ HandshakeErrorCustomHandlerFatalResponseCodes,
266
+ // The ciient sent a handshake that doesn't comply with the extended handshake metadata.
259
267
  import_typebox.Type.Literal("MALFORMED_HANDSHAKE_META"),
268
+ // The ciient sent a handshake that doesn't comply with ControlMessageHandshakeRequestSchema.
260
269
  import_typebox.Type.Literal("MALFORMED_HANDSHAKE"),
261
- import_typebox.Type.Literal("PROTOCOL_VERSION_MISMATCH"),
262
- import_typebox.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
270
+ // The client's protocol version does not match the server's.
271
+ import_typebox.Type.Literal("PROTOCOL_VERSION_MISMATCH")
263
272
  ]);
264
273
  var HandshakeErrorResponseCodes = import_typebox.Type.Union([
265
274
  HandshakeErrorRetriableResponseCodes,
@@ -564,7 +573,7 @@ var SessionNoConnection = class extends IdentifiedSession {
564
573
  var import_api = require("@opentelemetry/api");
565
574
 
566
575
  // package.json
567
- var version = "0.25.2";
576
+ var version = "0.26.1";
568
577
 
569
578
  // tracing/index.ts
570
579
  function getPropagationContext(ctx) {
@@ -615,7 +624,10 @@ var SessionWaitingForHandshake = class extends CommonSession {
615
624
  onHandshakeData = (msg) => {
616
625
  const parsedMsg = this.parseMsg(msg);
617
626
  if (parsedMsg === null) {
618
- this.listeners.onInvalidHandshake("could not parse message");
627
+ this.listeners.onInvalidHandshake(
628
+ "could not parse message",
629
+ "MALFORMED_HANDSHAKE"
630
+ );
619
631
  return;
620
632
  }
621
633
  this.listeners.onHandshake(parsedMsg);
@@ -661,7 +673,10 @@ var SessionHandshaking = class extends IdentifiedSession {
661
673
  onHandshakeData = (msg) => {
662
674
  const parsedMsg = this.parseMsg(msg);
663
675
  if (parsedMsg === null) {
664
- this.listeners.onInvalidHandshake("could not parse message");
676
+ this.listeners.onInvalidHandshake(
677
+ "could not parse message",
678
+ "MALFORMED_HANDSHAKE"
679
+ );
665
680
  return;
666
681
  }
667
682
  this.listeners.onHandshake(parsedMsg);
@@ -1151,8 +1166,8 @@ var Transport = class {
1151
1166
  removeEventListener(type, handler) {
1152
1167
  this.eventDispatcher.removeEventListener(type, handler);
1153
1168
  }
1154
- protocolError(type, message) {
1155
- this.eventDispatcher.dispatchEvent("protocolError", { type, message });
1169
+ protocolError(message) {
1170
+ this.eventDispatcher.dispatchEvent("protocolError", message);
1156
1171
  }
1157
1172
  /**
1158
1173
  * Default close implementation for transports. You should override this in the downstream
@@ -1416,13 +1431,17 @@ var ClientTransport = class extends Transport {
1416
1431
  onHandshake: (msg) => {
1417
1432
  this.onHandshakeResponse(handshakingSession, msg);
1418
1433
  },
1419
- onInvalidHandshake: (reason) => {
1434
+ onInvalidHandshake: (reason, code) => {
1420
1435
  this.log?.error(
1421
1436
  `invalid handshake: ${reason}`,
1422
1437
  handshakingSession.loggingMetadata
1423
1438
  );
1424
1439
  this.deleteSession(session);
1425
- this.protocolError(ProtocolError.HandshakeFailed, reason);
1440
+ this.protocolError({
1441
+ type: ProtocolError.HandshakeFailed,
1442
+ code,
1443
+ message: reason
1444
+ });
1426
1445
  },
1427
1446
  onHandshakeTimeout: () => {
1428
1447
  this.log?.error(
@@ -1471,7 +1490,11 @@ var ClientTransport = class extends Transport {
1471
1490
  this.tryReconnecting(session.to);
1472
1491
  } else {
1473
1492
  this.deleteSession(session);
1474
- this.protocolError(ProtocolError.HandshakeFailed, reason);
1493
+ this.protocolError({
1494
+ type: ProtocolError.HandshakeFailed,
1495
+ code: msg.payload.status.code,
1496
+ message: reason
1497
+ });
1475
1498
  }
1476
1499
  return;
1477
1500
  }
@@ -1505,7 +1528,10 @@ var ClientTransport = class extends Transport {
1505
1528
  onMessage: (msg2) => this.handleMsg(msg2),
1506
1529
  onInvalidMessage: (reason) => {
1507
1530
  this.deleteSession(connectedSession);
1508
- this.protocolError(ProtocolError.MessageOrderingViolated, reason);
1531
+ this.protocolError({
1532
+ type: ProtocolError.MessageOrderingViolated,
1533
+ message: reason
1534
+ });
1509
1535
  }
1510
1536
  });
1511
1537
  this.updateSession(connectedSession);
@@ -1536,7 +1562,10 @@ var ClientTransport = class extends Transport {
1536
1562
  const budgetConsumed = this.retryBudget.getBudgetConsumed();
1537
1563
  const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
1538
1564
  this.log?.error(errMsg, session.loggingMetadata);
1539
- this.protocolError(ProtocolError.RetriesExceeded, errMsg);
1565
+ this.protocolError({
1566
+ type: ProtocolError.RetriesExceeded,
1567
+ message: errMsg
1568
+ });
1540
1569
  return;
1541
1570
  }
1542
1571
  const backoffMs = this.retryBudget.getBackoffMs();
@@ -1743,13 +1772,17 @@ var ServerTransport = class extends Transport {
1743
1772
  receivedHandshake = true;
1744
1773
  void this.onHandshakeRequest(pendingSession, msg);
1745
1774
  },
1746
- onInvalidHandshake: (reason) => {
1775
+ onInvalidHandshake: (reason, code) => {
1747
1776
  this.log?.error(
1748
1777
  `invalid handshake: ${reason}`,
1749
1778
  pendingSession.loggingMetadata
1750
1779
  );
1751
1780
  this.deletePendingSession(pendingSession);
1752
- this.protocolError(ProtocolError.HandshakeFailed, reason);
1781
+ this.protocolError({
1782
+ type: ProtocolError.HandshakeFailed,
1783
+ code,
1784
+ message: reason
1785
+ });
1753
1786
  }
1754
1787
  },
1755
1788
  this.options,
@@ -1774,7 +1807,11 @@ var ServerTransport = class extends Transport {
1774
1807
  }
1775
1808
  })
1776
1809
  );
1777
- this.protocolError(ProtocolError.HandshakeFailed, reason);
1810
+ this.protocolError({
1811
+ type: ProtocolError.HandshakeFailed,
1812
+ code,
1813
+ message: reason
1814
+ });
1778
1815
  this.deletePendingSession(session);
1779
1816
  }
1780
1817
  async onHandshakeRequest(session, msg) {
@@ -1936,7 +1973,10 @@ var ServerTransport = class extends Transport {
1936
1973
  },
1937
1974
  onMessage: (msg2) => this.handleMsg(msg2),
1938
1975
  onInvalidMessage: (reason) => {
1939
- this.protocolError(ProtocolError.MessageOrderingViolated, reason);
1976
+ this.protocolError({
1977
+ type: ProtocolError.MessageOrderingViolated,
1978
+ message: reason
1979
+ });
1940
1980
  this.deleteSession(connectedSession);
1941
1981
  }
1942
1982
  }
@@ -1947,43 +1987,43 @@ var ServerTransport = class extends Transport {
1947
1987
  connectedSession.startActiveHeartbeat();
1948
1988
  }
1949
1989
  async validateHandshakeMetadata(handshakingSession, existingSession, rawMetadata, from) {
1950
- let parsedMetadata = {};
1951
- if (this.handshakeExtensions) {
1952
- if (!import_value3.Value.Check(this.handshakeExtensions.schema, rawMetadata)) {
1953
- this.rejectHandshakeRequest(
1954
- handshakingSession,
1955
- from,
1956
- "received malformed handshake metadata",
1957
- "MALFORMED_HANDSHAKE_META",
1958
- {
1959
- ...handshakingSession.loggingMetadata,
1960
- connectedTo: from,
1961
- validationErrors: [
1962
- ...import_value3.Value.Errors(this.handshakeExtensions.schema, rawMetadata)
1963
- ]
1964
- }
1965
- );
1966
- return false;
1967
- }
1968
- const previousParsedMetadata = existingSession ? this.sessionHandshakeMetadata.get(existingSession.to) : void 0;
1969
- parsedMetadata = await this.handshakeExtensions.validate(
1970
- rawMetadata,
1971
- previousParsedMetadata
1990
+ if (!this.handshakeExtensions) {
1991
+ return {};
1992
+ }
1993
+ if (!import_value3.Value.Check(this.handshakeExtensions.schema, rawMetadata)) {
1994
+ this.rejectHandshakeRequest(
1995
+ handshakingSession,
1996
+ from,
1997
+ "received malformed handshake metadata",
1998
+ "MALFORMED_HANDSHAKE_META",
1999
+ {
2000
+ ...handshakingSession.loggingMetadata,
2001
+ connectedTo: from,
2002
+ validationErrors: [
2003
+ ...import_value3.Value.Errors(this.handshakeExtensions.schema, rawMetadata)
2004
+ ]
2005
+ }
1972
2006
  );
1973
- if (parsedMetadata === false) {
1974
- this.rejectHandshakeRequest(
1975
- handshakingSession,
1976
- from,
1977
- "rejected by handshake handler",
1978
- "REJECTED_BY_CUSTOM_HANDLER",
1979
- {
1980
- ...handshakingSession.loggingMetadata,
1981
- connectedTo: from,
1982
- clientId: this.clientId
1983
- }
1984
- );
1985
- return false;
1986
- }
2007
+ return false;
2008
+ }
2009
+ const previousParsedMetadata = existingSession ? this.sessionHandshakeMetadata.get(existingSession.to) : void 0;
2010
+ const parsedMetadata = await this.handshakeExtensions.validate(
2011
+ rawMetadata,
2012
+ previousParsedMetadata
2013
+ );
2014
+ if (import_value3.Value.Check(HandshakeErrorCustomHandlerFatalResponseCodes, parsedMetadata)) {
2015
+ this.rejectHandshakeRequest(
2016
+ handshakingSession,
2017
+ from,
2018
+ "rejected by handshake handler",
2019
+ parsedMetadata,
2020
+ {
2021
+ ...handshakingSession.loggingMetadata,
2022
+ connectedTo: from,
2023
+ clientId: this.clientId
2024
+ }
2025
+ );
2026
+ return false;
1987
2027
  }
1988
2028
  return parsedMetadata;
1989
2029
  }