@rstreamlabs/webtty 1.9.1 → 1.11.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.
package/dist/node.mjs CHANGED
@@ -33,20 +33,30 @@ import {
33
33
  verifyWebTTYServerProofTranscript,
34
34
  webTTYClientProofTranscriptBytes,
35
35
  webTTYE2EKeyID,
36
+ webTTYFIPSCompatibleKeyEnvelopeSuite,
37
+ webTTYFIPSCompatiblePayloadSuite,
36
38
  webTTYRecordedEventEncryptedPayload,
37
39
  webTTYServerProofTranscriptBytes,
38
40
  webTTYSigningKeyID
39
- } from "./chunk-QOAMHBHC.mjs";
41
+ } from "./chunk-E7OURVTY.mjs";
40
42
 
41
43
  // src/local-e2e.ts
42
44
  var localKeyFileVersion = 1;
43
45
  var localKeyFileCryptoSuite = "webtty-e2e-x25519-hpke-aes-256-gcm-v1";
46
+ var localKeyFileFIPSCompatibleCryptoSuite = "webtty-e2e-p256-hkdf-sha256-aes-256-gcm-random-nonce-v1";
44
47
  var x25519PublicKeySize = 32;
48
+ var p256PublicKeySize = 65;
45
49
  var payloadKeyIDSize = 16;
46
50
  var knownServerKeyEnv = "RSTREAM_WEBTTY_KNOWN_SERVER_KEY";
47
51
  var knownServersFileEnv = "RSTREAM_WEBTTY_KNOWN_SERVERS_FILE";
48
52
  async function defaultWebTTYKnownServersPath(env) {
49
53
  const path = await nodePath();
54
+ const dataDir = cleanString((env ?? defaultEnv()).RSTREAM_DATA_DIR);
55
+ if (dataDir !== void 0) {
56
+ if (!path.isAbsolute(dataDir))
57
+ throw new Error("RSTREAM_DATA_DIR must be an absolute path.");
58
+ return path.join(dataDir, "webtty", "known_servers.json");
59
+ }
50
60
  return path.join(
51
61
  await homeDir(env ?? defaultEnv()),
52
62
  ".rstream",
@@ -69,9 +79,8 @@ async function parseWebTTYKnownServerKey(value) {
69
79
  validateSigningKeyMaterial(parts[2] ?? "", parts[3] ?? "");
70
80
  }
71
81
  if (parts.length === 1) {
72
- const publicKey2 = decodeFixedKeyMaterial(
82
+ const publicKey2 = decodeEncryptionPublicKey(
73
83
  parts[0] ?? "",
74
- x25519PublicKeySize,
75
84
  "known WebTTY server public key"
76
85
  );
77
86
  return { keyId: await webTTYE2EKeyID(publicKey2), publicKey: publicKey2 };
@@ -81,9 +90,8 @@ async function parseWebTTYKnownServerKey(value) {
81
90
  payloadKeyIDSize,
82
91
  "known WebTTY server key id"
83
92
  );
84
- const publicKey = decodeFixedKeyMaterial(
93
+ const publicKey = decodeEncryptionPublicKey(
85
94
  parts[1] ?? "",
86
- x25519PublicKeySize,
87
95
  "known WebTTY server public key"
88
96
  );
89
97
  const expectedKeyId = await webTTYE2EKeyID(publicKey);
@@ -178,7 +186,7 @@ function decodeWebTTYKnownServerKeysFile(data, filePath) {
178
186
  );
179
187
  }
180
188
  const cryptoSuite = parsed.crypto_suite;
181
- if (cryptoSuite !== localKeyFileCryptoSuite) {
189
+ if (cryptoSuite !== localKeyFileCryptoSuite && cryptoSuite !== localKeyFileFIPSCompatibleCryptoSuite) {
182
190
  throw new Error(
183
191
  `unsupported known WebTTY server keys crypto suite ${String(cryptoSuite)}`
184
192
  );
@@ -288,6 +296,16 @@ function decodeFixedKeyMaterial(value, size, label) {
288
296
  }
289
297
  return decoded;
290
298
  }
299
+ function decodeEncryptionPublicKey(value, label) {
300
+ const decoded = decodeWebTTYE2EKeyMaterial(value.trim());
301
+ if (decoded.byteLength === x25519PublicKeySize) return decoded;
302
+ if (decoded.byteLength === p256PublicKeySize && decoded[0] === 4) {
303
+ return decoded;
304
+ }
305
+ throw new Error(
306
+ `${label} must decode to a ${x25519PublicKeySize}-byte X25519 key or an uncompressed ${p256PublicKeySize}-byte P-256 point`
307
+ );
308
+ }
291
309
  function validateSigningKeyMaterial(keyID, publicKey) {
292
310
  decodeFixedKeyMaterial(keyID, 32, "known WebTTY server signing key id");
293
311
  decodeWebTTYE2EKeyMaterial(publicKey.trim());
@@ -390,7 +408,7 @@ function objectField(value, key) {
390
408
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
391
409
  return void 0;
392
410
  }
393
- return Object.fromEntries(Object.entries(value))[key];
411
+ return Reflect.get(value, key);
394
412
  }
395
413
  function stringRecord(value) {
396
414
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -405,6 +423,21 @@ function stringRecord(value) {
405
423
  function errorMessage(error) {
406
424
  return error instanceof Error ? error.message : String(error);
407
425
  }
426
+
427
+ // src/node-websocket.ts
428
+ import WebSocket from "ws";
429
+ var nodeWebSocketFactory = (url, options) => {
430
+ const socketOptions = {
431
+ closeTimeout: 1e3,
432
+ handshakeTimeout: 1e4,
433
+ maxPayload: options.maxMessageSize,
434
+ perMessageDeflate: false
435
+ };
436
+ const socket = new WebSocket(url, socketOptions);
437
+ socket.binaryType = "arraybuffer";
438
+ socket.on("error", () => void 0);
439
+ return socket;
440
+ };
408
441
  export {
409
442
  WebTTY,
410
443
  WebTTYCommand,
@@ -431,6 +464,7 @@ export {
431
464
  hashWebTTYServerProofTranscript,
432
465
  hashWebTTYSessionKeyGrant,
433
466
  loadWebTTYKnownServerKeysFile,
467
+ nodeWebSocketFactory,
434
468
  openWebTTYCommand,
435
469
  parseWebDAVMultiStatus,
436
470
  parseWebTTYKnownServerKey,
@@ -445,6 +479,8 @@ export {
445
479
  verifyWebTTYServerProofTranscript,
446
480
  webTTYClientProofTranscriptBytes,
447
481
  webTTYE2EKeyID,
482
+ webTTYFIPSCompatibleKeyEnvelopeSuite,
483
+ webTTYFIPSCompatiblePayloadSuite,
448
484
  webTTYRecordedEventEncryptedPayload,
449
485
  webTTYServerProofTranscriptBytes,
450
486
  webTTYSigningKeyID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstreamlabs/webtty",
3
- "version": "1.9.1",
3
+ "version": "1.11.0",
4
4
  "description": "Client-side implementation of the rstream WebTTY protocol.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,18 +41,20 @@
41
41
  "type-check": "tsc --noEmit"
42
42
  },
43
43
  "devDependencies": {
44
- "@turbo/gen": "^2.10.6",
44
+ "@turbo/gen": "^2.10.11",
45
45
  "@types/node": "^26",
46
+ "@types/ws": "^8.18.1",
46
47
  "eslint": "9.39.5",
47
48
  "eslint-config": "*",
48
- "protobufjs-cli": "^2.6.1",
49
+ "protobufjs-cli": "^2.6.2",
49
50
  "tsup": "^8.5.1",
50
51
  "typescript": "6.0.3",
51
- "typescript-config": "*",
52
- "ws": "^8.21.1"
52
+ "typescript-config": "*"
53
53
  },
54
54
  "dependencies": {
55
- "protobufjs": "^8.7.1"
55
+ "protobufjs": "^8.7.2",
56
+ "ws": "^8.21.3",
57
+ "@rstreamlabs/filesystem": "^0.2.0"
56
58
  },
57
59
  "publishConfig": {
58
60
  "access": "public"