peer-term 1.4.0 → 1.4.2
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/package.json +4 -2
- package/src/index.js +1 -1
- package/src/ui.js +25 -1
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peer-term",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "Share your terminal instantly using a 6-digit code. Encrypted. No config.",
|
|
5
|
+
"description": "Share your terminal instantly using a 6-digit code or QR code. Encrypted. No config.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/jay6205/Peer_Term",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"terminal-streaming",
|
|
30
30
|
"browser-shell",
|
|
31
31
|
"terminal-emulator",
|
|
32
|
+
"qr-code",
|
|
32
33
|
"xterm",
|
|
33
34
|
"xtermjs",
|
|
34
35
|
"cli",
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
"minimist": "^1.2.8",
|
|
88
89
|
"node-datachannel": "^0.32.3",
|
|
89
90
|
"node-pty": "^1.0.0",
|
|
91
|
+
"qrcode-terminal": "^0.12.0",
|
|
90
92
|
"ws": "^8.18.0"
|
|
91
93
|
}
|
|
92
94
|
}
|
package/src/index.js
CHANGED
|
@@ -338,7 +338,7 @@ class Session {
|
|
|
338
338
|
case 'code': {
|
|
339
339
|
this.code = msg.code;
|
|
340
340
|
this.hostToken = msg.hostToken || null;
|
|
341
|
-
printSessionBox({
|
|
341
|
+
await printSessionBox({
|
|
342
342
|
code: this.code,
|
|
343
343
|
expiry: formatDuration(this.expiryMs),
|
|
344
344
|
rejoinWindow: formatDuration(this.rejoinMs),
|
package/src/ui.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import fs from 'fs';
|
|
12
12
|
import path from 'path';
|
|
13
13
|
import { fileURLToPath } from 'url';
|
|
14
|
+
import qrcode from 'qrcode-terminal';
|
|
14
15
|
|
|
15
16
|
const __filename = fileURLToPath(import.meta.url);
|
|
16
17
|
const __dirname = path.dirname(__filename);
|
|
@@ -47,9 +48,10 @@ export function printBanner() {
|
|
|
47
48
|
* @param {string} [opts.startPath] - Starting directory for the session
|
|
48
49
|
* @param {string} [opts.shareUrl] - URL to share (e.g. "https://peerterm.dev")
|
|
49
50
|
*/
|
|
50
|
-
export function printSessionBox({ code, expiry, rejoinWindow, mode, shell, startPath, shareUrl }) {
|
|
51
|
+
export async function printSessionBox({ code, expiry, rejoinWindow, mode, shell, startPath, shareUrl }) {
|
|
51
52
|
const spacedCode = code.split('').join(' ');
|
|
52
53
|
const url = shareUrl || 'https://peerterm.dev';
|
|
54
|
+
const joinUrl = `${url}?code=${code}`;
|
|
53
55
|
|
|
54
56
|
// Truncate long shell paths to keep box readable
|
|
55
57
|
const shellDisplay = shell.length > 24 ? '...' + shell.slice(-21) : shell;
|
|
@@ -90,6 +92,28 @@ export function printSessionBox({ code, expiry, rejoinWindow, mode, shell, start
|
|
|
90
92
|
console.log(` │${emptyLine}│`);
|
|
91
93
|
console.log(` └${hr}┘`);
|
|
92
94
|
console.log('');
|
|
95
|
+
|
|
96
|
+
// Render QR code for instant scan-to-join
|
|
97
|
+
try {
|
|
98
|
+
const qrString = await new Promise((resolve) => {
|
|
99
|
+
qrcode.generate(joinUrl, { small: true }, (qr) => {
|
|
100
|
+
resolve(qr);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log(' Scan to join:');
|
|
105
|
+
console.log('');
|
|
106
|
+
// Indent each QR line for alignment with the box
|
|
107
|
+
const qrLines = qrString.split('\n');
|
|
108
|
+
for (const line of qrLines) {
|
|
109
|
+
if (line.length > 0) console.log(` ${line}`);
|
|
110
|
+
}
|
|
111
|
+
console.log('');
|
|
112
|
+
console.log(` Or open: ${joinUrl}`);
|
|
113
|
+
console.log('');
|
|
114
|
+
} catch {
|
|
115
|
+
// QR generation failed — not critical, code is still shown in the box
|
|
116
|
+
}
|
|
93
117
|
}
|
|
94
118
|
|
|
95
119
|
// ─── Help Text ───────────────────────────────────────────────────────────────
|