@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,
|
|
@@ -745,6 +773,49 @@ var Transport = class {
|
|
|
745
773
|
});
|
|
746
774
|
return session;
|
|
747
775
|
}
|
|
776
|
+
createNewSession({
|
|
777
|
+
to,
|
|
778
|
+
conn,
|
|
779
|
+
sessionId,
|
|
780
|
+
propagationCtx
|
|
781
|
+
}) {
|
|
782
|
+
let session = this.sessions.get(to);
|
|
783
|
+
if (session !== void 0) {
|
|
784
|
+
this.log?.info(
|
|
785
|
+
`session for ${to} already exists, replacing it with a new session as requested`,
|
|
786
|
+
session.loggingMetadata
|
|
787
|
+
);
|
|
788
|
+
this.deleteSession({
|
|
789
|
+
session,
|
|
790
|
+
closeHandshakingConnection: false
|
|
791
|
+
});
|
|
792
|
+
session = void 0;
|
|
793
|
+
}
|
|
794
|
+
session = this.createSession(to, conn, propagationCtx);
|
|
795
|
+
session.advertisedSessionId = sessionId;
|
|
796
|
+
this.log?.info(`created new session for ${to}`, session.loggingMetadata);
|
|
797
|
+
return session;
|
|
798
|
+
}
|
|
799
|
+
getExistingSession({
|
|
800
|
+
to,
|
|
801
|
+
sessionId,
|
|
802
|
+
nextExpectedSeq
|
|
803
|
+
}) {
|
|
804
|
+
const session = this.sessions.get(to);
|
|
805
|
+
if (
|
|
806
|
+
// reject this request if there was no previous session to replace
|
|
807
|
+
session === void 0 || // or if both parties do not agree about the next expected sequence number
|
|
808
|
+
session.nextExpectedAck < nextExpectedSeq || // or if both parties do not agree on the advertised session id
|
|
809
|
+
session.advertisedSessionId !== sessionId
|
|
810
|
+
) {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
this.log?.info(
|
|
814
|
+
`reused existing session for ${to}`,
|
|
815
|
+
session.loggingMetadata
|
|
816
|
+
);
|
|
817
|
+
return session;
|
|
818
|
+
}
|
|
748
819
|
getOrCreateSession({
|
|
749
820
|
to,
|
|
750
821
|
conn,
|
|
@@ -1133,9 +1204,13 @@ var ServerTransport = class extends Transport {
|
|
|
1133
1204
|
message: "malformed handshake meta"
|
|
1134
1205
|
});
|
|
1135
1206
|
const reason = "received malformed handshake metadata";
|
|
1136
|
-
const responseMsg = handshakeResponseMessage(
|
|
1137
|
-
|
|
1138
|
-
|
|
1207
|
+
const responseMsg = handshakeResponseMessage({
|
|
1208
|
+
from: this.clientId,
|
|
1209
|
+
to: from,
|
|
1210
|
+
status: {
|
|
1211
|
+
ok: false,
|
|
1212
|
+
reason
|
|
1213
|
+
}
|
|
1139
1214
|
});
|
|
1140
1215
|
conn.send(this.codec.toBuffer(responseMsg));
|
|
1141
1216
|
this.log?.warn(`received malformed handshake metadata from ${from}`, {
|
|
@@ -1159,9 +1234,13 @@ var ServerTransport = class extends Transport {
|
|
|
1159
1234
|
code: import_api4.SpanStatusCode.ERROR,
|
|
1160
1235
|
message: reason
|
|
1161
1236
|
});
|
|
1162
|
-
const responseMsg = handshakeResponseMessage(
|
|
1163
|
-
|
|
1164
|
-
|
|
1237
|
+
const responseMsg = handshakeResponseMessage({
|
|
1238
|
+
from: this.clientId,
|
|
1239
|
+
to: from,
|
|
1240
|
+
status: {
|
|
1241
|
+
ok: false,
|
|
1242
|
+
reason
|
|
1243
|
+
}
|
|
1165
1244
|
});
|
|
1166
1245
|
conn.send(this.codec.toBuffer(responseMsg));
|
|
1167
1246
|
this.log?.warn(`rejected handshake from ${from}`, {
|
|
@@ -1193,9 +1272,13 @@ var ServerTransport = class extends Transport {
|
|
|
1193
1272
|
message: "invalid handshake request"
|
|
1194
1273
|
});
|
|
1195
1274
|
const reason = "received invalid handshake msg";
|
|
1196
|
-
const responseMsg2 = handshakeResponseMessage(
|
|
1197
|
-
|
|
1198
|
-
|
|
1275
|
+
const responseMsg2 = handshakeResponseMessage({
|
|
1276
|
+
from: this.clientId,
|
|
1277
|
+
to: parsed.from,
|
|
1278
|
+
status: {
|
|
1279
|
+
ok: false,
|
|
1280
|
+
reason
|
|
1281
|
+
}
|
|
1199
1282
|
});
|
|
1200
1283
|
conn.send(this.codec.toBuffer(responseMsg2));
|
|
1201
1284
|
this.log?.warn(reason, {
|
|
@@ -1221,9 +1304,13 @@ var ServerTransport = class extends Transport {
|
|
|
1221
1304
|
message: "incorrect protocol version"
|
|
1222
1305
|
});
|
|
1223
1306
|
const reason = `incorrect version (got: ${gotVersion} wanted ${PROTOCOL_VERSION})`;
|
|
1224
|
-
const responseMsg2 = handshakeResponseMessage(
|
|
1225
|
-
|
|
1226
|
-
|
|
1307
|
+
const responseMsg2 = handshakeResponseMessage({
|
|
1308
|
+
from: this.clientId,
|
|
1309
|
+
to: parsed.from,
|
|
1310
|
+
status: {
|
|
1311
|
+
ok: false,
|
|
1312
|
+
reason
|
|
1313
|
+
}
|
|
1227
1314
|
});
|
|
1228
1315
|
conn.send(this.codec.toBuffer(responseMsg2));
|
|
1229
1316
|
this.log?.warn(
|
|
@@ -1243,20 +1330,67 @@ var ServerTransport = class extends Transport {
|
|
|
1243
1330
|
if (parsedMetadata === false) {
|
|
1244
1331
|
return false;
|
|
1245
1332
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1333
|
+
let session;
|
|
1334
|
+
let isTransparentReconnect;
|
|
1335
|
+
if (!parsed.payload.expectedSessionState) {
|
|
1336
|
+
({ session, isTransparentReconnect } = this.getOrCreateSession({
|
|
1337
|
+
to: parsed.from,
|
|
1338
|
+
conn,
|
|
1339
|
+
sessionId: parsed.payload.sessionId,
|
|
1340
|
+
propagationCtx: parsed.tracing
|
|
1341
|
+
}));
|
|
1342
|
+
} else if (parsed.payload.expectedSessionState.reconnect) {
|
|
1343
|
+
const existingSession = this.getExistingSession({
|
|
1344
|
+
to: parsed.from,
|
|
1345
|
+
sessionId: parsed.payload.sessionId,
|
|
1346
|
+
nextExpectedSeq: parsed.payload.expectedSessionState.nextExpectedSeq
|
|
1347
|
+
});
|
|
1348
|
+
if (existingSession === false) {
|
|
1349
|
+
conn.telemetry?.span.setStatus({
|
|
1350
|
+
code: import_api4.SpanStatusCode.ERROR,
|
|
1351
|
+
message: SESSION_STATE_MISMATCH
|
|
1352
|
+
});
|
|
1353
|
+
const reason = SESSION_STATE_MISMATCH;
|
|
1354
|
+
const responseMsg2 = handshakeResponseMessage({
|
|
1355
|
+
from: this.clientId,
|
|
1356
|
+
to: parsed.from,
|
|
1357
|
+
status: {
|
|
1358
|
+
ok: false,
|
|
1359
|
+
reason
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
conn.send(this.codec.toBuffer(responseMsg2));
|
|
1363
|
+
this.log?.warn(
|
|
1364
|
+
`'received handshake msg with incompatible existing session state: ${parsed.payload.sessionId}`,
|
|
1365
|
+
{ ...conn.loggingMetadata, clientId: this.clientId }
|
|
1366
|
+
);
|
|
1367
|
+
this.protocolError(ProtocolError.HandshakeFailed, reason);
|
|
1368
|
+
return false;
|
|
1369
|
+
}
|
|
1370
|
+
session = existingSession;
|
|
1371
|
+
isTransparentReconnect = false;
|
|
1372
|
+
} else {
|
|
1373
|
+
const createdSession = this.createNewSession({
|
|
1374
|
+
to: parsed.from,
|
|
1375
|
+
conn,
|
|
1376
|
+
sessionId: parsed.payload.sessionId,
|
|
1377
|
+
propagationCtx: parsed.tracing
|
|
1378
|
+
});
|
|
1379
|
+
session = createdSession;
|
|
1380
|
+
isTransparentReconnect = false;
|
|
1381
|
+
}
|
|
1252
1382
|
this.sessionHandshakeMetadata.set(session, parsedMetadata);
|
|
1253
1383
|
this.log?.debug(
|
|
1254
1384
|
`handshake from ${parsed.from} ok, responding with handshake success`,
|
|
1255
1385
|
conn.loggingMetadata
|
|
1256
1386
|
);
|
|
1257
|
-
const responseMsg = handshakeResponseMessage(
|
|
1258
|
-
|
|
1259
|
-
|
|
1387
|
+
const responseMsg = handshakeResponseMessage({
|
|
1388
|
+
from: this.clientId,
|
|
1389
|
+
to: parsed.from,
|
|
1390
|
+
status: {
|
|
1391
|
+
ok: true,
|
|
1392
|
+
sessionId: session.id
|
|
1393
|
+
}
|
|
1260
1394
|
});
|
|
1261
1395
|
conn.send(this.codec.toBuffer(responseMsg));
|
|
1262
1396
|
this.onConnect(conn, session, isTransparentReconnect);
|