peer-term 1.2.8 → 1.2.10
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/README.md +0 -6
- package/package.json +1 -1
- package/src/index.js +28 -10
package/README.md
CHANGED
|
@@ -14,12 +14,6 @@ This will start a terminal sharing session and give you a 6-digit code.
|
|
|
14
14
|
|
|
15
15
|
Share this code with your peer. They can view your terminal by going to https://peer-term-relay-production-9b7a.up.railway.app or https://peer-term-relay.onrender.com and entering the code.
|
|
16
16
|
|
|
17
|
-
If you started the session with `--secure`, both sides will show a short security fingerprint. Compare it over a trusted channel. If it matches, authorize the session in the host CLI:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
a <code>
|
|
21
|
-
```
|
|
22
|
-
|
|
23
17
|
## Global Installation
|
|
24
18
|
|
|
25
19
|
If you prefer to install it globally:
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -326,6 +326,7 @@ class Session {
|
|
|
326
326
|
this.awaitingRejoin = false;
|
|
327
327
|
this.destroyed = false;
|
|
328
328
|
this.intentionalClose = false;
|
|
329
|
+
this.ptyOutputQueue = Promise.resolve();
|
|
329
330
|
this.reconnectTimer = null;
|
|
330
331
|
this.createdAt = Date.now();
|
|
331
332
|
this.relayUrl = null; // Track which relay URL we connected to
|
|
@@ -708,22 +709,14 @@ class Session {
|
|
|
708
709
|
env: process.env,
|
|
709
710
|
});
|
|
710
711
|
|
|
711
|
-
this.ptyProcess.onData(
|
|
712
|
+
this.ptyProcess.onData((data) => {
|
|
712
713
|
// Mirror PTY output to local viewer terminal
|
|
713
714
|
if (this.viewerSocket) {
|
|
714
715
|
try { this.viewerSocket.write(data); } catch {}
|
|
715
716
|
}
|
|
716
717
|
|
|
717
718
|
if (!this.sharedKey) return;
|
|
718
|
-
|
|
719
|
-
const payload = await encrypt(this.sharedKey, data);
|
|
720
|
-
// Phase 4: Route through DataChannel if active, else relay
|
|
721
|
-
if (this.useDataChannel && this.webrtc && this.webrtc.isActive()) {
|
|
722
|
-
this.webrtc.send(payload);
|
|
723
|
-
} else if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
724
|
-
this.ws.send(JSON.stringify({ type: 'data', payload }));
|
|
725
|
-
}
|
|
726
|
-
} catch {}
|
|
719
|
+
this._queuePtyOutput(data, this.sharedKey);
|
|
727
720
|
});
|
|
728
721
|
|
|
729
722
|
this.ptyProcess.onExit(({ exitCode }) => {
|
|
@@ -739,6 +732,31 @@ class Session {
|
|
|
739
732
|
}
|
|
740
733
|
|
|
741
734
|
// ─── Local TCP viewer for host terminal ─────────────────────────────
|
|
735
|
+
_queuePtyOutput(data, sharedKey) {
|
|
736
|
+
this.ptyOutputQueue = this.ptyOutputQueue
|
|
737
|
+
.then(() => this._sendPtyOutput(data, sharedKey))
|
|
738
|
+
.catch((err) => {
|
|
739
|
+
this.logDebug(`Failed to send PTY output: ${err.message}`);
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
async _sendPtyOutput(data, sharedKey) {
|
|
744
|
+
if (this.destroyed || !sharedKey || sharedKey !== this.sharedKey) return;
|
|
745
|
+
|
|
746
|
+
const payload = await encrypt(sharedKey, data);
|
|
747
|
+
if (this.destroyed || sharedKey !== this.sharedKey) return;
|
|
748
|
+
|
|
749
|
+
// Phase 4: Route through DataChannel if active, else relay
|
|
750
|
+
if (this.useDataChannel && this.webrtc && this.webrtc.isActive()) {
|
|
751
|
+
this.webrtc.send(payload);
|
|
752
|
+
} else if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
753
|
+
// Backpressure: drop chunk if relay can't keep up (1.25 MB buffer limit)
|
|
754
|
+
if (this.ws.bufferedAmount < 1.25 * 1024 * 1024) {
|
|
755
|
+
this.ws.send(JSON.stringify({ type: 'data', payload }));
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
742
760
|
_startViewerServer() {
|
|
743
761
|
this.viewerServer = net.createServer((socket) => {
|
|
744
762
|
// Close any existing viewer connection before accepting a new one
|