peer-term 1.3.2 → 1.3.4

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 CHANGED
@@ -47,6 +47,7 @@ peer-term --verbose # enable debug logging
47
47
  - **End-to-End Encrypted**: Terminal data is encrypted locally using AES-256-GCM with ECDH P-256 key exchange. The relay never sees plaintext. A `--secure` flag enables an out-of-band fingerprint check for strict MITM protection.
48
48
  - **WebRTC P2P**: Creates a direct Peer-to-Peer connection on the same LAN for zero-latency, relay-free sessions.
49
49
  - **Read-Only Mode**: Guests can view your terminal but cannot type commands.
50
+ - **File Uploads**: Clients can drag-and-drop to securely upload files directly to `~/peerterm-uploads/` on the host machine. Fully encrypted end-to-end.
50
51
  - **Custom Start Path**: Set the starting directory with `--path`.
51
52
  - **Resilient Connections**: Both host and client get a 2-minute rejoin window if their IP changes or connection drops. PTY state is fully preserved — no session restart needed.
52
53
  - **Multi-Session**: Manage multiple simultaneous sessions with the interactive CLI menu.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peer-term",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "license": "MIT",
5
5
  "description": "Share your terminal instantly using a 6-digit code. Encrypted. No config.",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -26,7 +26,7 @@ import crypto from 'crypto';
26
26
  import path from 'path';
27
27
  import net from 'net';
28
28
  import readline from 'readline';
29
- import { exec as cpExec } from 'child_process';
29
+ import { execFile, spawn } from 'child_process';
30
30
  import { fileURLToPath } from 'url';
31
31
  import WebSocket from 'ws';
32
32
  import pty from 'node-pty';
@@ -1151,14 +1151,44 @@ class Session {
1151
1151
 
1152
1152
  const viewerScript = path.join(__dirname, 'session-viewer.js');
1153
1153
  const platform = os.platform();
1154
+ const portStr = String(port);
1155
+ const nodeArgs = [viewerScript, portStr, this.code, token];
1154
1156
 
1155
1157
  if (platform === 'win32') {
1156
- cpExec(`start "PeerTerm - ${this.code}" cmd /c node "${viewerScript}" ${port} ${this.code} ${token}`);
1158
+ // spawn with 'cmd' to open a new window; arguments are passed as an
1159
+ // array so the install path is never interpreted by the shell.
1160
+ spawn('cmd', ['/c', 'start', `PeerTerm - ${this.code}`, 'cmd', '/c', 'node', ...nodeArgs], {
1161
+ stdio: 'ignore',
1162
+ detached: true,
1163
+ windowsHide: false,
1164
+ }).unref();
1157
1165
  } else if (platform === 'darwin') {
1158
- cpExec(`osascript -e 'tell app "Terminal" to do script "node \"${viewerScript}\" ${port} ${this.code} ${token}"'`);
1166
+ // osascript receives the AppleScript source as a single -e argument;
1167
+ // node args are baked into the script string, but execFile does NOT
1168
+ // invoke a shell so the outer path cannot break out.
1169
+ const script = `tell app "Terminal" to do script "node '${viewerScript.replace(/'/g, "'\\''")}' ${portStr} ${this.code} ${token}"`;
1170
+ execFile('osascript', ['-e', script], { stdio: 'ignore' }, () => {});
1159
1171
  } else {
1160
- // Linux: try common terminal emulators
1161
- cpExec(`x-terminal-emulator -e "node '${viewerScript}' ${port} ${this.code} ${token}" 2>/dev/null || gnome-terminal -- node "${viewerScript}" ${port} ${this.code} ${token} 2>/dev/null || xterm -e "node '${viewerScript}' ${port} ${this.code} ${token}"`);
1172
+ // Linux: try common terminal emulators in order, falling through on
1173
+ // failure. Each call uses execFile (no shell), so paths with
1174
+ // metacharacters are safe.
1175
+ const tryTerminals = [
1176
+ ['x-terminal-emulator', ['-e', 'node', ...nodeArgs]],
1177
+ ['gnome-terminal', ['--', 'node', ...nodeArgs]],
1178
+ ['xterm', ['-e', 'node', ...nodeArgs]],
1179
+ ];
1180
+
1181
+ const tryNext = (index) => {
1182
+ if (index >= tryTerminals.length) {
1183
+ this.log('Could not open any terminal emulator for viewer.');
1184
+ return;
1185
+ }
1186
+ const [cmd, args] = tryTerminals[index];
1187
+ execFile(cmd, args, { stdio: 'ignore' }, (err) => {
1188
+ if (err) tryNext(index + 1);
1189
+ });
1190
+ };
1191
+ tryNext(0);
1162
1192
  }
1163
1193
  this.log('Opening terminal viewer...');
1164
1194
  }