@replit/river 0.23.13 → 0.23.14
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/dist/{chunk-SX6HI63Q.js → chunk-BEALFLCB.js} +2 -2
- package/dist/{chunk-S4DUN7KK.js → chunk-D2DHRRBN.js} +41 -20
- package/dist/chunk-D2DHRRBN.js.map +1 -0
- package/dist/{chunk-ES4XO2XD.js → chunk-GCCRVSMR.js} +33 -4
- package/dist/chunk-GCCRVSMR.js.map +1 -0
- package/dist/{chunk-KFTGQ3QC.js → chunk-GN4YEXT7.js} +2 -2
- package/dist/{chunk-2FNLANTJ.js → chunk-O2AVDJCQ.js} +10 -2
- package/dist/{chunk-2FNLANTJ.js.map → chunk-O2AVDJCQ.js.map} +1 -1
- package/dist/{chunk-XM656KMN.js → chunk-OTVTKAN6.js} +46 -3
- package/dist/chunk-OTVTKAN6.js.map +1 -0
- package/dist/{chunk-ZUKDZY54.js → chunk-WUL63FR6.js} +89 -25
- package/dist/chunk-WUL63FR6.js.map +1 -0
- package/dist/{chunk-4QZOW4DH.js → chunk-YCLZWES2.js} +2 -2
- package/dist/{client-dd5c9dd0.d.ts → client-e13979ac.d.ts} +1 -1
- package/dist/{connection-39816c00.d.ts → connection-5d0978ce.d.ts} +1 -1
- package/dist/{connection-40318f22.d.ts → connection-e57e98ea.d.ts} +1 -1
- package/dist/{handshake-e428d1c8.d.ts → handshake-5665ffd3.d.ts} +13 -0
- package/dist/router/index.cjs +16 -1
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +7 -7
- package/dist/router/index.d.ts +7 -7
- package/dist/router/index.js +2 -2
- package/dist/{server-ebf80863.d.ts → server-1cfc88d1.d.ts} +1 -1
- package/dist/{services-f406b3aa.d.ts → services-86c4d10d.d.ts} +2 -2
- package/dist/transport/impls/uds/client.cjs +113 -18
- package/dist/transport/impls/uds/client.cjs.map +1 -1
- package/dist/transport/impls/uds/client.d.cts +3 -3
- package/dist/transport/impls/uds/client.d.ts +3 -3
- package/dist/transport/impls/uds/client.js +5 -5
- package/dist/transport/impls/uds/server.cjs +157 -23
- package/dist/transport/impls/uds/server.cjs.map +1 -1
- package/dist/transport/impls/uds/server.d.cts +3 -3
- package/dist/transport/impls/uds/server.d.ts +3 -3
- package/dist/transport/impls/uds/server.js +5 -5
- package/dist/transport/impls/ws/client.cjs +113 -18
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +3 -3
- package/dist/transport/impls/ws/client.d.ts +3 -3
- package/dist/transport/impls/ws/client.js +5 -5
- package/dist/transport/impls/ws/server.cjs +157 -23
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +3 -3
- package/dist/transport/impls/ws/server.d.ts +3 -3
- package/dist/transport/impls/ws/server.js +5 -5
- package/dist/transport/index.cjs +202 -40
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +3 -3
- package/dist/transport/index.d.ts +3 -3
- package/dist/transport/index.js +5 -5
- package/dist/util/testHelpers.cjs +9 -1
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +3 -3
- package/dist/util/testHelpers.d.ts +3 -3
- package/dist/util/testHelpers.js +3 -3
- package/package.json +13 -14
- package/dist/chunk-ES4XO2XD.js.map +0 -1
- package/dist/chunk-S4DUN7KK.js.map +0 -1
- package/dist/chunk-XM656KMN.js.map +0 -1
- package/dist/chunk-ZUKDZY54.js.map +0 -1
- /package/dist/{chunk-SX6HI63Q.js.map → chunk-BEALFLCB.js.map} +0 -0
- /package/dist/{chunk-KFTGQ3QC.js.map → chunk-GN4YEXT7.js.map} +0 -0
- /package/dist/{chunk-4QZOW4DH.js.map → chunk-YCLZWES2.js.map} +0 -0
|
@@ -59,6 +59,21 @@ var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
|
|
|
59
59
|
type: import_typebox.Type.Literal("HANDSHAKE_REQ"),
|
|
60
60
|
protocolVersion: import_typebox.Type.String(),
|
|
61
61
|
sessionId: import_typebox.Type.String(),
|
|
62
|
+
/**
|
|
63
|
+
* Specifies what the server's expected session state (from the pov of the client). This can be
|
|
64
|
+
* used by the server to know whether this is a new or a reestablished connection, and whether it
|
|
65
|
+
* is compatible with what it already has.
|
|
66
|
+
*/
|
|
67
|
+
expectedSessionState: import_typebox.Type.Optional(
|
|
68
|
+
import_typebox.Type.Object({
|
|
69
|
+
/**
|
|
70
|
+
* reconnect is set to true if the client explicitly wants to reestablish an existing
|
|
71
|
+
* connection.
|
|
72
|
+
*/
|
|
73
|
+
reconnect: import_typebox.Type.Boolean(),
|
|
74
|
+
nextExpectedSeq: import_typebox.Type.Integer()
|
|
75
|
+
})
|
|
76
|
+
),
|
|
62
77
|
metadata: import_typebox.Type.Optional(import_typebox.Type.Unknown())
|
|
63
78
|
});
|
|
64
79
|
var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
@@ -83,7 +98,12 @@ var ControlMessagePayloadSchema = import_typebox.Type.Union([
|
|
|
83
98
|
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
84
99
|
import_typebox.Type.Unknown()
|
|
85
100
|
);
|
|
86
|
-
|
|
101
|
+
var SESSION_STATE_MISMATCH = "session state mismatch";
|
|
102
|
+
function handshakeResponseMessage({
|
|
103
|
+
from,
|
|
104
|
+
to,
|
|
105
|
+
status
|
|
106
|
+
}) {
|
|
87
107
|
return {
|
|
88
108
|
id: (0, import_nanoid.nanoid)(),
|
|
89
109
|
from,
|
|
@@ -106,7 +126,7 @@ function isAck(controlFlag) {
|
|
|
106
126
|
var import_api = require("@opentelemetry/api");
|
|
107
127
|
|
|
108
128
|
// package.json
|
|
109
|
-
var version = "0.23.
|
|
129
|
+
var version = "0.23.14";
|
|
110
130
|
|
|
111
131
|
// tracing/index.ts
|
|
112
132
|
function createSessionTelemetryInfo(session, propagationCtx) {
|
|
@@ -411,9 +431,17 @@ var Session = class {
|
|
|
411
431
|
get connected() {
|
|
412
432
|
return this.connection !== void 0;
|
|
413
433
|
}
|
|
434
|
+
get nextExpectedAck() {
|
|
435
|
+
return this.seq;
|
|
436
|
+
}
|
|
414
437
|
get nextExpectedSeq() {
|
|
415
438
|
return this.ack;
|
|
416
439
|
}
|
|
440
|
+
// This is only used in tests to make the session misbehave.
|
|
441
|
+
/* @internal */
|
|
442
|
+
advanceAckForTesting(by) {
|
|
443
|
+
this.ack += by;
|
|
444
|
+
}
|
|
417
445
|
constructMsg(partialMsg) {
|
|
418
446
|
const msg = {
|
|
419
447
|
...partialMsg,
|
|
@@ -792,6 +820,49 @@ var Transport = class {
|
|
|
792
820
|
});
|
|
793
821
|
return session;
|
|
794
822
|
}
|
|
823
|
+
createNewSession({
|
|
824
|
+
to,
|
|
825
|
+
conn,
|
|
826
|
+
sessionId,
|
|
827
|
+
propagationCtx
|
|
828
|
+
}) {
|
|
829
|
+
let session = this.sessions.get(to);
|
|
830
|
+
if (session !== void 0) {
|
|
831
|
+
this.log?.info(
|
|
832
|
+
`session for ${to} already exists, replacing it with a new session as requested`,
|
|
833
|
+
session.loggingMetadata
|
|
834
|
+
);
|
|
835
|
+
this.deleteSession({
|
|
836
|
+
session,
|
|
837
|
+
closeHandshakingConnection: false
|
|
838
|
+
});
|
|
839
|
+
session = void 0;
|
|
840
|
+
}
|
|
841
|
+
session = this.createSession(to, conn, propagationCtx);
|
|
842
|
+
session.advertisedSessionId = sessionId;
|
|
843
|
+
this.log?.info(`created new session for ${to}`, session.loggingMetadata);
|
|
844
|
+
return session;
|
|
845
|
+
}
|
|
846
|
+
getExistingSession({
|
|
847
|
+
to,
|
|
848
|
+
sessionId,
|
|
849
|
+
nextExpectedSeq
|
|
850
|
+
}) {
|
|
851
|
+
const session = this.sessions.get(to);
|
|
852
|
+
if (
|
|
853
|
+
// reject this request if there was no previous session to replace
|
|
854
|
+
session === void 0 || // or if both parties do not agree about the next expected sequence number
|
|
855
|
+
session.nextExpectedAck < nextExpectedSeq || // or if both parties do not agree on the advertised session id
|
|
856
|
+
session.advertisedSessionId !== sessionId
|
|
857
|
+
) {
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
this.log?.info(
|
|
861
|
+
`reused existing session for ${to}`,
|
|
862
|
+
session.loggingMetadata
|
|
863
|
+
);
|
|
864
|
+
return session;
|
|
865
|
+
}
|
|
795
866
|
getOrCreateSession({
|
|
796
867
|
to,
|
|
797
868
|
conn,
|
|
@@ -1180,9 +1251,13 @@ var ServerTransport = class extends Transport {
|
|
|
1180
1251
|
message: "malformed handshake meta"
|
|
1181
1252
|
});
|
|
1182
1253
|
const reason = "received malformed handshake metadata";
|
|
1183
|
-
const responseMsg = handshakeResponseMessage(
|
|
1184
|
-
|
|
1185
|
-
|
|
1254
|
+
const responseMsg = handshakeResponseMessage({
|
|
1255
|
+
from: this.clientId,
|
|
1256
|
+
to: from,
|
|
1257
|
+
status: {
|
|
1258
|
+
ok: false,
|
|
1259
|
+
reason
|
|
1260
|
+
}
|
|
1186
1261
|
});
|
|
1187
1262
|
conn.send(this.codec.toBuffer(responseMsg));
|
|
1188
1263
|
this.log?.warn(`received malformed handshake metadata from ${from}`, {
|
|
@@ -1206,9 +1281,13 @@ var ServerTransport = class extends Transport {
|
|
|
1206
1281
|
code: import_api4.SpanStatusCode.ERROR,
|
|
1207
1282
|
message: reason
|
|
1208
1283
|
});
|
|
1209
|
-
const responseMsg = handshakeResponseMessage(
|
|
1210
|
-
|
|
1211
|
-
|
|
1284
|
+
const responseMsg = handshakeResponseMessage({
|
|
1285
|
+
from: this.clientId,
|
|
1286
|
+
to: from,
|
|
1287
|
+
status: {
|
|
1288
|
+
ok: false,
|
|
1289
|
+
reason
|
|
1290
|
+
}
|
|
1212
1291
|
});
|
|
1213
1292
|
conn.send(this.codec.toBuffer(responseMsg));
|
|
1214
1293
|
this.log?.warn(`rejected handshake from ${from}`, {
|
|
@@ -1240,9 +1319,13 @@ var ServerTransport = class extends Transport {
|
|
|
1240
1319
|
message: "invalid handshake request"
|
|
1241
1320
|
});
|
|
1242
1321
|
const reason = "received invalid handshake msg";
|
|
1243
|
-
const responseMsg2 = handshakeResponseMessage(
|
|
1244
|
-
|
|
1245
|
-
|
|
1322
|
+
const responseMsg2 = handshakeResponseMessage({
|
|
1323
|
+
from: this.clientId,
|
|
1324
|
+
to: parsed.from,
|
|
1325
|
+
status: {
|
|
1326
|
+
ok: false,
|
|
1327
|
+
reason
|
|
1328
|
+
}
|
|
1246
1329
|
});
|
|
1247
1330
|
conn.send(this.codec.toBuffer(responseMsg2));
|
|
1248
1331
|
this.log?.warn(reason, {
|
|
@@ -1268,9 +1351,13 @@ var ServerTransport = class extends Transport {
|
|
|
1268
1351
|
message: "incorrect protocol version"
|
|
1269
1352
|
});
|
|
1270
1353
|
const reason = `incorrect version (got: ${gotVersion} wanted ${PROTOCOL_VERSION})`;
|
|
1271
|
-
const responseMsg2 = handshakeResponseMessage(
|
|
1272
|
-
|
|
1273
|
-
|
|
1354
|
+
const responseMsg2 = handshakeResponseMessage({
|
|
1355
|
+
from: this.clientId,
|
|
1356
|
+
to: parsed.from,
|
|
1357
|
+
status: {
|
|
1358
|
+
ok: false,
|
|
1359
|
+
reason
|
|
1360
|
+
}
|
|
1274
1361
|
});
|
|
1275
1362
|
conn.send(this.codec.toBuffer(responseMsg2));
|
|
1276
1363
|
this.log?.warn(
|
|
@@ -1290,20 +1377,67 @@ var ServerTransport = class extends Transport {
|
|
|
1290
1377
|
if (parsedMetadata === false) {
|
|
1291
1378
|
return false;
|
|
1292
1379
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1380
|
+
let session;
|
|
1381
|
+
let isTransparentReconnect;
|
|
1382
|
+
if (!parsed.payload.expectedSessionState) {
|
|
1383
|
+
({ session, isTransparentReconnect } = this.getOrCreateSession({
|
|
1384
|
+
to: parsed.from,
|
|
1385
|
+
conn,
|
|
1386
|
+
sessionId: parsed.payload.sessionId,
|
|
1387
|
+
propagationCtx: parsed.tracing
|
|
1388
|
+
}));
|
|
1389
|
+
} else if (parsed.payload.expectedSessionState.reconnect) {
|
|
1390
|
+
const existingSession = this.getExistingSession({
|
|
1391
|
+
to: parsed.from,
|
|
1392
|
+
sessionId: parsed.payload.sessionId,
|
|
1393
|
+
nextExpectedSeq: parsed.payload.expectedSessionState.nextExpectedSeq
|
|
1394
|
+
});
|
|
1395
|
+
if (existingSession === false) {
|
|
1396
|
+
conn.telemetry?.span.setStatus({
|
|
1397
|
+
code: import_api4.SpanStatusCode.ERROR,
|
|
1398
|
+
message: SESSION_STATE_MISMATCH
|
|
1399
|
+
});
|
|
1400
|
+
const reason = SESSION_STATE_MISMATCH;
|
|
1401
|
+
const responseMsg2 = handshakeResponseMessage({
|
|
1402
|
+
from: this.clientId,
|
|
1403
|
+
to: parsed.from,
|
|
1404
|
+
status: {
|
|
1405
|
+
ok: false,
|
|
1406
|
+
reason
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
conn.send(this.codec.toBuffer(responseMsg2));
|
|
1410
|
+
this.log?.warn(
|
|
1411
|
+
`'received handshake msg with incompatible existing session state: ${parsed.payload.sessionId}`,
|
|
1412
|
+
{ ...conn.loggingMetadata, clientId: this.clientId }
|
|
1413
|
+
);
|
|
1414
|
+
this.protocolError(ProtocolError.HandshakeFailed, reason);
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
session = existingSession;
|
|
1418
|
+
isTransparentReconnect = false;
|
|
1419
|
+
} else {
|
|
1420
|
+
const createdSession = this.createNewSession({
|
|
1421
|
+
to: parsed.from,
|
|
1422
|
+
conn,
|
|
1423
|
+
sessionId: parsed.payload.sessionId,
|
|
1424
|
+
propagationCtx: parsed.tracing
|
|
1425
|
+
});
|
|
1426
|
+
session = createdSession;
|
|
1427
|
+
isTransparentReconnect = false;
|
|
1428
|
+
}
|
|
1299
1429
|
this.sessionHandshakeMetadata.set(session, parsedMetadata);
|
|
1300
1430
|
this.log?.debug(
|
|
1301
1431
|
`handshake from ${parsed.from} ok, responding with handshake success`,
|
|
1302
1432
|
conn.loggingMetadata
|
|
1303
1433
|
);
|
|
1304
|
-
const responseMsg = handshakeResponseMessage(
|
|
1305
|
-
|
|
1306
|
-
|
|
1434
|
+
const responseMsg = handshakeResponseMessage({
|
|
1435
|
+
from: this.clientId,
|
|
1436
|
+
to: parsed.from,
|
|
1437
|
+
status: {
|
|
1438
|
+
ok: true,
|
|
1439
|
+
sessionId: session.id
|
|
1440
|
+
}
|
|
1307
1441
|
});
|
|
1308
1442
|
conn.send(this.codec.toBuffer(responseMsg));
|
|
1309
1443
|
this.onConnect(conn, session, isTransparentReconnect);
|