@ethanfly/sshx 1.0.0 → 1.2.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/README.md +162 -0
- package/dist/cli/connect.d.ts +1 -0
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +7 -8
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +19 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/sync.d.ts +15 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +235 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/core/config.d.ts +8 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +15 -8
- package/dist/core/config.js.map +1 -1
- package/dist/core/metrics.d.ts +87 -0
- package/dist/core/metrics.d.ts.map +1 -0
- package/dist/core/metrics.js +276 -0
- package/dist/core/metrics.js.map +1 -0
- package/dist/core/split-session.d.ts +42 -0
- package/dist/core/split-session.d.ts.map +1 -0
- package/dist/core/split-session.js +223 -0
- package/dist/core/split-session.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/sync/crypto.d.ts +25 -0
- package/dist/sync/crypto.d.ts.map +1 -0
- package/dist/sync/crypto.js +69 -0
- package/dist/sync/crypto.js.map +1 -0
- package/dist/sync/manager.d.ts +54 -0
- package/dist/sync/manager.d.ts.map +1 -0
- package/dist/sync/manager.js +140 -0
- package/dist/sync/manager.js.map +1 -0
- package/dist/sync/provider.d.ts +63 -0
- package/dist/sync/provider.d.ts.map +1 -0
- package/dist/sync/provider.js +269 -0
- package/dist/sync/provider.js.map +1 -0
- package/dist/tui/app.d.ts +1 -0
- package/dist/tui/app.d.ts.map +1 -1
- package/dist/tui/app.js +22 -0
- package/dist/tui/app.js.map +1 -1
- package/dist/tui/screen.d.ts.map +1 -1
- package/dist/tui/screen.js +32 -19
- package/dist/tui/screen.js.map +1 -1
- package/dist/tui/screens/hosts.js +1 -1
- package/dist/tui/screens/hosts.js.map +1 -1
- package/dist/tui/sidebar.d.ts +19 -0
- package/dist/tui/sidebar.d.ts.map +1 -0
- package/dist/tui/sidebar.js +284 -0
- package/dist/tui/sidebar.js.map +1 -0
- package/package.json +11 -12
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import EventEmitter from 'node:events';
|
|
2
|
+
import { execCommand } from './exec.js';
|
|
3
|
+
export class MetricsCollector extends EventEmitter {
|
|
4
|
+
client;
|
|
5
|
+
intervalMs;
|
|
6
|
+
timer;
|
|
7
|
+
isCollecting = false;
|
|
8
|
+
lastSampleTime = 0;
|
|
9
|
+
lastCpuTotal = 0;
|
|
10
|
+
lastCpuIdle = 0;
|
|
11
|
+
lastSocketStat = new Map();
|
|
12
|
+
lastNetStat = new Map();
|
|
13
|
+
cachedMetrics;
|
|
14
|
+
// Multi-value lines use ';' between entries and '|' between fields.
|
|
15
|
+
static COLLECTOR_SCRIPT = String.raw `
|
|
16
|
+
U=$(whoami 2>/dev/null || echo "$USER")
|
|
17
|
+
H=$(hostname -s 2>/dev/null || hostname 2>/dev/null || echo "localhost")
|
|
18
|
+
OS=$(grep -m1 '^PRETTY_NAME=' /etc/os-release 2>/dev/null | cut -d= -f2- | tr -d '"' || uname -s)
|
|
19
|
+
UP=$(uptime 2>/dev/null | sed -e 's/.*up //' -e 's/,.*//')
|
|
20
|
+
IP=$(hostname -I 2>/dev/null | awk '{print $1}' || ip route get 1.1.1.1 2>/dev/null | awk '{print $7}' || echo "")
|
|
21
|
+
LOAD=$(cat /proc/loadavg 2>/dev/null | awk '{print $1, $2, $3}' || uptime | sed 's/.*load average: //')
|
|
22
|
+
CPUM=$(grep -m1 "model name" /proc/cpuinfo 2>/dev/null | cut -d: -f2 | sed -e 's/^[ \t]*//' || sysctl -n machdep.cpu.brand_string 2>/dev/null || echo "CPU")
|
|
23
|
+
CPUC=$(grep -c "^processor" /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo "1")
|
|
24
|
+
CPUSTAT=$(grep '^cpu ' /proc/stat 2>/dev/null || echo "")
|
|
25
|
+
CPUSOCK=$(awk 'FILENAME == "/proc/stat" { if ($1 ~ /^cpu[0-9]/) { c = substr($1, 4); p = (c in pkg) ? pkg[c] : 0; n[p]++; idle[p] += $5 + $6; for (i = 2; i <= NF; i++) tot[p] += $i } next } { split(FILENAME, a, "/"); pkg[substr(a[6], 4)] = $1 } END { for (p in tot) printf "%s|%d|%.0f|%.0f;", p, n[p], tot[p], idle[p] }' /sys/devices/system/cpu/cpu[0-9]*/topology/physical_package_id /proc/stat 2>/dev/null)
|
|
26
|
+
|
|
27
|
+
if [ -f /proc/meminfo ]; then
|
|
28
|
+
MT=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo)
|
|
29
|
+
MA=$(awk '/MemAvailable/ {print int($2/1024)}' /proc/meminfo)
|
|
30
|
+
[ -z "$MA" ] && MA=$(awk '/MemFree/ {print int($2/1024)}' /proc/meminfo)
|
|
31
|
+
MU=$((MT - MA))
|
|
32
|
+
else
|
|
33
|
+
MT=0; MU=0
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
DISKS=$(LC_ALL=C df -P -k 2>/dev/null | awk 'NR > 1 && $2 + 0 > 0 { d = $1; m = $6; for (i = 7; i <= NF; i++) m = m " " $i; if (d !~ /[\/:]/ || d ~ /^\/dev\/loop/ || (d in seen)) next; if (m ~ /^\/(boot|snap)(\/|$)/ || m ~ /^\/var\/lib\/(docker|kubelet|containers)\// || m ~ /^\/(System\/Volumes|private\/var\/vm)\//) next; seen[d] = 1; printf "%s|%.0f|%.0f|%.0f;", m, $2, $3, $4 }')
|
|
37
|
+
|
|
38
|
+
NETIP=$(ip -o addr show 2>/dev/null | awk '{ n = $2; sub(/@.*/, "", n); split($4, a, "/"); if ($3 == "inet" && !(n in v4)) v4[n] = a[1]; else if ($3 == "inet6" && a[1] !~ /^fe80/ && !(n in v6)) v6[n] = a[1] } END { for (n in v4) printf "%s=%s ", n, v4[n]; for (n in v6) if (!(n in v4)) printf "%s=%s ", n, v6[n] }')
|
|
39
|
+
NETS=$(awk -v ips="$NETIP" 'BEGIN { c = split(ips, arr, " "); for (i = 1; i <= c; i++) { split(arr[i], kv, "="); ip[kv[1]] = kv[2] } } NR > 2 { s = $0; sub(/^[ \t]+/, "", s); n = s; sub(/:.*/, "", n); sub(/^[^:]*:/, "", s); split(s, f, " "); if (n ~ /^(lo|veth|docker|br-|virbr|vnet|cni|flannel|cali|kube-|tunl|dummy|ifb|lxc|podman)/) next; st = "unknown"; fn = "/sys/class/net/" n "/operstate"; if ((getline v < fn) > 0) st = v; close(fn); printf "%s|%.0f|%.0f|%s|%s;", n, f[1], f[9], ip[n], st }' /proc/net/dev 2>/dev/null)
|
|
40
|
+
|
|
41
|
+
if command -v nvidia-smi >/dev/null 2>&1; then
|
|
42
|
+
GPUS=$(nvidia-smi --query-gpu=index,name,memory.used,memory.total,utilization.gpu,temperature.gpu --format=csv,noheader,nounits 2>/dev/null | tr '\n' ';')
|
|
43
|
+
else
|
|
44
|
+
GPUS=""
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
printf "USER=%s\nHOST=%s\nOS=%s\nUP=%s\nIP=%s\nLOAD=%s\nCPUM=%s\nCPUC=%s\nCPUSTAT=%s\nCPUSOCK=%s\nMT=%s\nMU=%s\nDISKS=%s\nNETS=%s\nGPUS=%s\n" \
|
|
48
|
+
"$U" "$H" "$OS" "$UP" "$IP" "$LOAD" "$CPUM" "$CPUC" "$CPUSTAT" "$CPUSOCK" "$MT" "$MU" "$DISKS" "$NETS" "$GPUS"
|
|
49
|
+
`.trim();
|
|
50
|
+
constructor(client, intervalMs = 2500) {
|
|
51
|
+
super();
|
|
52
|
+
this.client = client;
|
|
53
|
+
this.intervalMs = intervalMs;
|
|
54
|
+
}
|
|
55
|
+
getLatest() {
|
|
56
|
+
return this.cachedMetrics;
|
|
57
|
+
}
|
|
58
|
+
start() {
|
|
59
|
+
if (this.timer)
|
|
60
|
+
return;
|
|
61
|
+
this.poll(); // first poll immediately
|
|
62
|
+
this.timer = setInterval(() => this.poll(), this.intervalMs);
|
|
63
|
+
}
|
|
64
|
+
stop() {
|
|
65
|
+
if (this.timer) {
|
|
66
|
+
clearInterval(this.timer);
|
|
67
|
+
this.timer = undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async poll() {
|
|
71
|
+
if (this.isCollecting)
|
|
72
|
+
return;
|
|
73
|
+
this.isCollecting = true;
|
|
74
|
+
try {
|
|
75
|
+
const res = await execCommand(this.client, MetricsCollector.COLLECTOR_SCRIPT, { timeout: 4000 });
|
|
76
|
+
if (res.exitCode === 0) {
|
|
77
|
+
const metrics = this.parseOutput(res.stdout);
|
|
78
|
+
this.cachedMetrics = metrics;
|
|
79
|
+
this.emit('update', metrics);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
this.emit('error', err);
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
this.isCollecting = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
parseOutput(stdout) {
|
|
90
|
+
const lines = stdout.split('\n');
|
|
91
|
+
const map = new Map();
|
|
92
|
+
for (const line of lines) {
|
|
93
|
+
const idx = line.indexOf('=');
|
|
94
|
+
if (idx > 0) {
|
|
95
|
+
map.set(line.slice(0, idx).trim(), line.slice(idx + 1).trim());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const now = Date.now();
|
|
99
|
+
const dt = this.lastSampleTime > 0 ? (now - this.lastSampleTime) / 1000 : 0;
|
|
100
|
+
this.lastSampleTime = now;
|
|
101
|
+
// Parse CPU %
|
|
102
|
+
let cpuUsagePercent = 0;
|
|
103
|
+
const cpuStat = map.get('CPUSTAT') || '';
|
|
104
|
+
if (cpuStat.startsWith('cpu')) {
|
|
105
|
+
const parts = cpuStat.trim().split(/\s+/).slice(1).map(Number);
|
|
106
|
+
if (parts.length >= 4) {
|
|
107
|
+
const idle = parts[3] + (parts[4] || 0); // idle + iowait
|
|
108
|
+
const total = parts.reduce((a, b) => a + b, 0);
|
|
109
|
+
if (this.lastCpuTotal > 0 && total > this.lastCpuTotal) {
|
|
110
|
+
cpuUsagePercent = usageBetween(total - this.lastCpuTotal, idle - this.lastCpuIdle);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// Fallback to load average calculation
|
|
114
|
+
const loadParts = (map.get('LOAD') || '').split(/\s+/).map(Number);
|
|
115
|
+
const cores = Number(map.get('CPUC')) || 1;
|
|
116
|
+
if (loadParts[0] !== undefined) {
|
|
117
|
+
cpuUsagePercent = Math.min(100, Math.round((loadParts[0] / cores) * 1000) / 10);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
this.lastCpuTotal = total;
|
|
121
|
+
this.lastCpuIdle = idle;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Parse per-socket CPU: id|threads|total|idle
|
|
125
|
+
const sockets = [];
|
|
126
|
+
for (const [idStr, threadsStr, totalStr, idleStr] of splitEntries(map.get('CPUSOCK'))) {
|
|
127
|
+
const id = Number(idStr);
|
|
128
|
+
const total = Number(totalStr) || 0;
|
|
129
|
+
const idle = Number(idleStr) || 0;
|
|
130
|
+
const prev = this.lastSocketStat.get(id);
|
|
131
|
+
const usagePercent = prev && total > prev.total ? usageBetween(total - prev.total, idle - prev.idle) : 0;
|
|
132
|
+
this.lastSocketStat.set(id, { total, idle });
|
|
133
|
+
sockets.push({ id, threads: Number(threadsStr) || 0, usagePercent });
|
|
134
|
+
}
|
|
135
|
+
sockets.sort((a, b) => a.id - b.id);
|
|
136
|
+
// Parse Memory
|
|
137
|
+
const mt = Number(map.get('MT')) || 0;
|
|
138
|
+
const mu = Number(map.get('MU')) || 0;
|
|
139
|
+
const memPercent = mt > 0 ? Math.round((mu / mt) * 1000) / 10 : 0;
|
|
140
|
+
// Parse Disks: mount|totalKB|usedKB|availKB
|
|
141
|
+
const disks = splitEntries(map.get('DISKS')).map(([mount, totalStr, usedStr, availStr]) => {
|
|
142
|
+
const total = Number(totalStr) || 0;
|
|
143
|
+
const used = Number(usedStr) || 0;
|
|
144
|
+
const avail = Number(availStr) || 0;
|
|
145
|
+
return {
|
|
146
|
+
mount,
|
|
147
|
+
total: formatKB(total),
|
|
148
|
+
used: formatKB(used),
|
|
149
|
+
avail: formatKB(avail),
|
|
150
|
+
// Same rounding df uses for Use%
|
|
151
|
+
percent: used + avail > 0 ? Math.ceil((used * 100) / (used + avail)) : 0,
|
|
152
|
+
sizeKB: total
|
|
153
|
+
};
|
|
154
|
+
})
|
|
155
|
+
// Root first, then the larger volumes
|
|
156
|
+
.sort((a, b) => Number(b.mount === '/') - Number(a.mount === '/') || b.sizeKB - a.sizeKB)
|
|
157
|
+
.map(({ sizeKB: _sizeKB, ...disk }) => disk);
|
|
158
|
+
// Parse Network interfaces: name|rxBytes|txBytes|ip|operstate
|
|
159
|
+
const networks = [];
|
|
160
|
+
const seenNics = new Set();
|
|
161
|
+
for (const [name, rxStr, txStr, ip, state] of splitEntries(map.get('NETS'))) {
|
|
162
|
+
const rx = Number(rxStr) || 0;
|
|
163
|
+
const tx = Number(txStr) || 0;
|
|
164
|
+
const prev = this.lastNetStat.get(name);
|
|
165
|
+
this.lastNetStat.set(name, { rx, tx });
|
|
166
|
+
seenNics.add(name);
|
|
167
|
+
// Interfaces that are down and unaddressed are just noise
|
|
168
|
+
if (!ip && state !== 'up' && state !== 'unknown')
|
|
169
|
+
continue;
|
|
170
|
+
let rxBytesSec = 0;
|
|
171
|
+
let txBytesSec = 0;
|
|
172
|
+
if (prev && dt > 0) {
|
|
173
|
+
rxBytesSec = Math.max(0, Math.round((rx - prev.rx) / dt));
|
|
174
|
+
txBytesSec = Math.max(0, Math.round((tx - prev.tx) / dt));
|
|
175
|
+
}
|
|
176
|
+
networks.push({
|
|
177
|
+
name,
|
|
178
|
+
ip: ip || undefined,
|
|
179
|
+
state,
|
|
180
|
+
rxBytesSec,
|
|
181
|
+
txBytesSec,
|
|
182
|
+
rxFormatted: formatSpeed(rxBytesSec),
|
|
183
|
+
txFormatted: formatSpeed(txBytesSec)
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
for (const name of this.lastNetStat.keys()) {
|
|
187
|
+
if (!seenNics.has(name))
|
|
188
|
+
this.lastNetStat.delete(name);
|
|
189
|
+
}
|
|
190
|
+
// Addressed interfaces first, keeping kernel order otherwise
|
|
191
|
+
networks.sort((a, b) => Number(Boolean(b.ip)) - Number(Boolean(a.ip)));
|
|
192
|
+
const rxBytesSec = networks.reduce((sum, n) => sum + n.rxBytesSec, 0);
|
|
193
|
+
const txBytesSec = networks.reduce((sum, n) => sum + n.txBytesSec, 0);
|
|
194
|
+
// Parse GPUs: index, name, memory.used, memory.total, utilization.gpu, temperature.gpu
|
|
195
|
+
const gpus = [];
|
|
196
|
+
for (const entry of (map.get('GPUS') || '').split(';')) {
|
|
197
|
+
const gParts = entry.split(',').map(s => s.trim());
|
|
198
|
+
if (gParts.length < 6)
|
|
199
|
+
continue;
|
|
200
|
+
const [utilStr, tempStr] = gParts.slice(-2);
|
|
201
|
+
const [vramUsedStr, vramTotalStr] = gParts.slice(-4, -2);
|
|
202
|
+
const vramUsed = Number(vramUsedStr) || 0;
|
|
203
|
+
const vramTotal = Number(vramTotalStr) || 0;
|
|
204
|
+
const index = parseInt(gParts[0], 10);
|
|
205
|
+
gpus.push({
|
|
206
|
+
index: Number.isNaN(index) ? gpus.length : index,
|
|
207
|
+
model: gParts.slice(1, -4).join(',') || 'NVIDIA GPU',
|
|
208
|
+
vramUsedMB: vramUsed,
|
|
209
|
+
vramTotalMB: vramTotal,
|
|
210
|
+
vramPercent: vramTotal > 0 ? Math.round((vramUsed / vramTotal) * 100) : 0,
|
|
211
|
+
utilPercent: Number(utilStr) || 0,
|
|
212
|
+
temp: Number(tempStr) || 0
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
user: map.get('USER') || 'unknown',
|
|
217
|
+
hostname: map.get('HOST') || 'localhost',
|
|
218
|
+
ip: map.get('IP') || networks.find(n => n.ip)?.ip || '',
|
|
219
|
+
os: map.get('OS') || 'Linux',
|
|
220
|
+
uptime: map.get('UP') || '',
|
|
221
|
+
cpu: {
|
|
222
|
+
model: map.get('CPUM') || 'CPU',
|
|
223
|
+
cores: Number(map.get('CPUC')) || 1,
|
|
224
|
+
load: map.get('LOAD') || '',
|
|
225
|
+
usagePercent: cpuUsagePercent,
|
|
226
|
+
sockets
|
|
227
|
+
},
|
|
228
|
+
memory: {
|
|
229
|
+
totalMB: mt,
|
|
230
|
+
usedMB: mu,
|
|
231
|
+
percent: memPercent
|
|
232
|
+
},
|
|
233
|
+
disk: disks[0] || { mount: '/', total: 'N/A', used: 'N/A', avail: 'N/A', percent: 0 },
|
|
234
|
+
disks,
|
|
235
|
+
network: {
|
|
236
|
+
rxBytesSec,
|
|
237
|
+
txBytesSec,
|
|
238
|
+
rxFormatted: formatSpeed(rxBytesSec),
|
|
239
|
+
txFormatted: formatSpeed(txBytesSec)
|
|
240
|
+
},
|
|
241
|
+
networks,
|
|
242
|
+
gpu: gpus[0],
|
|
243
|
+
gpus,
|
|
244
|
+
updatedAt: now
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function splitEntries(raw) {
|
|
249
|
+
return (raw || '')
|
|
250
|
+
.split(';')
|
|
251
|
+
.filter(entry => entry.trim())
|
|
252
|
+
.map(entry => entry.split('|').map(s => s.trim()));
|
|
253
|
+
}
|
|
254
|
+
function usageBetween(deltaTotal, deltaIdle) {
|
|
255
|
+
if (deltaTotal <= 0)
|
|
256
|
+
return 0;
|
|
257
|
+
return Math.max(0, Math.min(100, Math.round((1 - deltaIdle / deltaTotal) * 1000) / 10));
|
|
258
|
+
}
|
|
259
|
+
function formatKB(kb) {
|
|
260
|
+
const units = ['K', 'M', 'G', 'T', 'P'];
|
|
261
|
+
let value = kb;
|
|
262
|
+
let unit = 0;
|
|
263
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
264
|
+
value /= 1024;
|
|
265
|
+
unit++;
|
|
266
|
+
}
|
|
267
|
+
return `${value < 10 && unit > 0 ? value.toFixed(1) : Math.round(value)}${units[unit]}`;
|
|
268
|
+
}
|
|
269
|
+
function formatSpeed(bytesPerSec) {
|
|
270
|
+
if (bytesPerSec < 1024)
|
|
271
|
+
return `${bytesPerSec} B/s`;
|
|
272
|
+
if (bytesPerSec < 1024 * 1024)
|
|
273
|
+
return `${(bytesPerSec / 1024).toFixed(1)} KB/s`;
|
|
274
|
+
return `${(bytesPerSec / (1024 * 1024)).toFixed(1)} MB/s`;
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/core/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAwExC,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACxC,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,KAAK,CAAkB;IACvB,YAAY,GAAG,KAAK,CAAC;IACrB,cAAc,GAAG,CAAC,CAAC;IACnB,YAAY,GAAG,CAAC,CAAC;IACjB,WAAW,GAAG,CAAC,CAAC;IAChB,cAAc,GAAG,IAAI,GAAG,EAA2C,CAAC;IACpE,WAAW,GAAG,IAAI,GAAG,EAAsC,CAAC;IAC5D,aAAa,CAAiB;IAEtC,oEAAoE;IAC5D,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC7C,CAAC,IAAI,EAAE,CAAC;IAEP,YAAY,MAAc,EAAE,UAAU,GAA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AAC,CAAC,CAAC,OAAO,CAAC;IAChF,OAAO,GAAG,CAAC,WAAW,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Client } from 'ssh2';
|
|
2
|
+
import { InteractiveSession, SessionOptions } from './session.js';
|
|
3
|
+
export interface SplitSessionOptions extends SessionOptions {
|
|
4
|
+
enableSidebar?: boolean;
|
|
5
|
+
sidebarWidth?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manages an interactive split-pane SSH session:
|
|
9
|
+
* - Left pane: interactive remote PTY shell
|
|
10
|
+
* - Right pane: live server resource monitor (IP, user, CPU, RAM, Disk, Net, GPU)
|
|
11
|
+
* - Hotkeys: F2 or Ctrl+O to toggle sidebar expand/collapse
|
|
12
|
+
*/
|
|
13
|
+
export declare class SplitSession {
|
|
14
|
+
private session;
|
|
15
|
+
private collector?;
|
|
16
|
+
private client;
|
|
17
|
+
private options;
|
|
18
|
+
private sidebarVisible;
|
|
19
|
+
private sidebarWidth;
|
|
20
|
+
private lastMetrics?;
|
|
21
|
+
private isDestroyed;
|
|
22
|
+
private enteredAltScreen;
|
|
23
|
+
constructor(client: Client, options?: SplitSessionOptions);
|
|
24
|
+
getSession(): InteractiveSession;
|
|
25
|
+
private computeShellCols;
|
|
26
|
+
/**
|
|
27
|
+
* Start the interactive split session
|
|
28
|
+
*/
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Attach terminal stdin and stdout with split-pane multiplexing
|
|
32
|
+
*/
|
|
33
|
+
attachToLocalProcess(): void;
|
|
34
|
+
toggleSidebar(): void;
|
|
35
|
+
private enableTerminalMargins;
|
|
36
|
+
private disableTerminalMargins;
|
|
37
|
+
/**
|
|
38
|
+
* Draw the right-hand sidebar at its fixed column offset without moving the shell cursor
|
|
39
|
+
*/
|
|
40
|
+
drawSidebar(): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=split-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-session.d.ts","sourceRoot":"","sources":["../../src/core/split-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAIlE,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAmB;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAsB;IAErC,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,gBAAgB,CAAS;IAEjC,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,EAmB5D;IAEM,UAAU,IAAI,kBAAkB,CAEtC;IAED,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBlC;IAED;;OAEG;IACI,oBAAoB,IAAI,IAAI,CA0FlC;IAEM,aAAa,IAAI,IAAI,CA4B3B;IAED,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,sBAAsB;IAM9B;;OAEG;IACI,WAAW,IAAI,IAAI,CAwCzB;CACF"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { InteractiveSession } from './session.js';
|
|
2
|
+
import { MetricsCollector } from './metrics.js';
|
|
3
|
+
import { SidebarRenderer, defaultSidebarTheme } from '../tui/sidebar.js';
|
|
4
|
+
/**
|
|
5
|
+
* Manages an interactive split-pane SSH session:
|
|
6
|
+
* - Left pane: interactive remote PTY shell
|
|
7
|
+
* - Right pane: live server resource monitor (IP, user, CPU, RAM, Disk, Net, GPU)
|
|
8
|
+
* - Hotkeys: F2 or Ctrl+O to toggle sidebar expand/collapse
|
|
9
|
+
*/
|
|
10
|
+
export class SplitSession {
|
|
11
|
+
session;
|
|
12
|
+
collector;
|
|
13
|
+
client;
|
|
14
|
+
options;
|
|
15
|
+
sidebarVisible;
|
|
16
|
+
sidebarWidth;
|
|
17
|
+
lastMetrics;
|
|
18
|
+
isDestroyed = false;
|
|
19
|
+
enteredAltScreen = false;
|
|
20
|
+
constructor(client, options = {}) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
const totalCols = process.stdout.columns || 80;
|
|
24
|
+
this.sidebarWidth = options.sidebarWidth || 34;
|
|
25
|
+
// Default to visible if terminal is wide enough (>= 90 cols)
|
|
26
|
+
const wantsSidebar = options.enableSidebar !== false;
|
|
27
|
+
this.sidebarVisible = wantsSidebar && totalCols >= 90;
|
|
28
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
29
|
+
const rows = process.stdout.rows || 24;
|
|
30
|
+
this.session = new InteractiveSession(client, {
|
|
31
|
+
...options,
|
|
32
|
+
cols: leftCols,
|
|
33
|
+
rows
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
getSession() {
|
|
37
|
+
return this.session;
|
|
38
|
+
}
|
|
39
|
+
computeShellCols(totalCols) {
|
|
40
|
+
if (!this.sidebarVisible) {
|
|
41
|
+
return totalCols;
|
|
42
|
+
}
|
|
43
|
+
// Shell takes remaining columns minus 1 for margin/separator
|
|
44
|
+
return Math.max(30, totalCols - this.sidebarWidth - 1);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Start the interactive split session
|
|
48
|
+
*/
|
|
49
|
+
async start() {
|
|
50
|
+
await this.session.start();
|
|
51
|
+
// Start background metrics collector over multiplexed SSH channel
|
|
52
|
+
try {
|
|
53
|
+
this.collector = new MetricsCollector(this.client, 2500);
|
|
54
|
+
this.collector.on('update', (metrics) => {
|
|
55
|
+
this.lastMetrics = metrics;
|
|
56
|
+
if (this.sidebarVisible && !this.isDestroyed) {
|
|
57
|
+
this.drawSidebar();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
this.collector.start();
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Metrics collector is non-fatal; continue shell
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Attach terminal stdin and stdout with split-pane multiplexing
|
|
68
|
+
*/
|
|
69
|
+
attachToLocalProcess() {
|
|
70
|
+
const stdin = process.stdin;
|
|
71
|
+
const stdout = process.stdout;
|
|
72
|
+
const totalCols = stdout.columns || 80;
|
|
73
|
+
const totalRows = stdout.rows || 24;
|
|
74
|
+
if (this.sidebarVisible && stdout.isTTY) {
|
|
75
|
+
// Enter alternate screen buffer & clear to prevent previous terminal scrollback from showing
|
|
76
|
+
stdout.write('\x1b[?1049h\x1b[2J\x1b[H');
|
|
77
|
+
this.enteredAltScreen = true;
|
|
78
|
+
this.drawSidebar();
|
|
79
|
+
this.enableTerminalMargins();
|
|
80
|
+
}
|
|
81
|
+
// Set raw mode
|
|
82
|
+
if (stdin.isTTY) {
|
|
83
|
+
stdin.setRawMode(true);
|
|
84
|
+
stdin.resume();
|
|
85
|
+
}
|
|
86
|
+
// Handle terminal resize
|
|
87
|
+
const onResize = () => {
|
|
88
|
+
const cols = stdout.columns || 80;
|
|
89
|
+
const rows = stdout.rows || 24;
|
|
90
|
+
if (this.sidebarVisible && cols < 85) {
|
|
91
|
+
// Automatically hide sidebar on narrow terminals
|
|
92
|
+
this.sidebarVisible = false;
|
|
93
|
+
this.disableTerminalMargins();
|
|
94
|
+
}
|
|
95
|
+
const leftCols = this.computeShellCols(cols);
|
|
96
|
+
this.session.resize(leftCols, rows);
|
|
97
|
+
if (this.sidebarVisible) {
|
|
98
|
+
this.drawSidebar();
|
|
99
|
+
this.enableTerminalMargins();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.disableTerminalMargins();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
if (stdout.isTTY) {
|
|
106
|
+
stdout.on('resize', onResize);
|
|
107
|
+
}
|
|
108
|
+
// Stdin interceptor: listen for F2 or Ctrl+O to toggle sidebar
|
|
109
|
+
const onStdinData = (chunk) => {
|
|
110
|
+
const str = chunk.toString('utf8');
|
|
111
|
+
// F2: \x1bOQ or \x1b[12~ | Ctrl+O: \x0f
|
|
112
|
+
if (str === '\x1bOQ' || str === '\x1b[12~' || str === '\x0f') {
|
|
113
|
+
this.toggleSidebar();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.session.write(chunk);
|
|
117
|
+
};
|
|
118
|
+
stdin.on('data', onStdinData);
|
|
119
|
+
// Shell output to stdout
|
|
120
|
+
this.session.on('data', (chunk) => {
|
|
121
|
+
stdout.write(chunk);
|
|
122
|
+
});
|
|
123
|
+
// Cleanup on session close
|
|
124
|
+
this.session.once('close', () => {
|
|
125
|
+
this.isDestroyed = true;
|
|
126
|
+
if (this.collector) {
|
|
127
|
+
this.collector.stop();
|
|
128
|
+
}
|
|
129
|
+
this.disableTerminalMargins();
|
|
130
|
+
if (this.enteredAltScreen && stdout.isTTY) {
|
|
131
|
+
// Exit alternate screen buffer, cleanly restoring user's original terminal
|
|
132
|
+
stdout.write('\x1b[?1049l');
|
|
133
|
+
this.enteredAltScreen = false;
|
|
134
|
+
}
|
|
135
|
+
if (stdin.isTTY) {
|
|
136
|
+
stdin.setRawMode(false);
|
|
137
|
+
stdin.pause();
|
|
138
|
+
}
|
|
139
|
+
stdin.removeListener('data', onStdinData);
|
|
140
|
+
if (stdout.isTTY) {
|
|
141
|
+
stdout.removeListener('resize', onResize);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
toggleSidebar() {
|
|
146
|
+
const stdout = process.stdout;
|
|
147
|
+
const totalCols = stdout.columns || 80;
|
|
148
|
+
const totalRows = stdout.rows || 24;
|
|
149
|
+
if (!this.sidebarVisible) {
|
|
150
|
+
// Cannot enable if terminal is too narrow
|
|
151
|
+
if (totalCols < 75) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.sidebarVisible = true;
|
|
155
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
156
|
+
if (!this.enteredAltScreen && stdout.isTTY) {
|
|
157
|
+
stdout.write('\x1b[?1049h');
|
|
158
|
+
this.enteredAltScreen = true;
|
|
159
|
+
}
|
|
160
|
+
stdout.write('\x1b[2J\x1b[H');
|
|
161
|
+
this.drawSidebar();
|
|
162
|
+
this.enableTerminalMargins();
|
|
163
|
+
this.session.resize(leftCols, totalRows);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.sidebarVisible = false;
|
|
167
|
+
this.disableTerminalMargins();
|
|
168
|
+
// Clear screen and resize shell to 100%
|
|
169
|
+
stdout.write('\x1b[2J\x1b[H');
|
|
170
|
+
this.session.resize(totalCols, totalRows);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
enableTerminalMargins() {
|
|
174
|
+
if (!process.stdout.isTTY)
|
|
175
|
+
return;
|
|
176
|
+
const totalCols = process.stdout.columns || 80;
|
|
177
|
+
const totalRows = process.stdout.rows || 24;
|
|
178
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
179
|
+
// DECLRMM enable (\x1b[?69h), set vertical margin (\x1b[1;{totalRows}r), set horizontal margin (\x1b[1;{leftCols}s)
|
|
180
|
+
process.stdout.write(`\x1b[?69h\x1b[1;${totalRows}r\x1b[1;${leftCols}s`);
|
|
181
|
+
}
|
|
182
|
+
disableTerminalMargins() {
|
|
183
|
+
if (!process.stdout.isTTY)
|
|
184
|
+
return;
|
|
185
|
+
// DECLRMM disable (\x1b[?69l), reset scrolling region (\x1b[r)
|
|
186
|
+
process.stdout.write(`\x1b[?69l\x1b[r`);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Draw the right-hand sidebar at its fixed column offset without moving the shell cursor
|
|
190
|
+
*/
|
|
191
|
+
drawSidebar() {
|
|
192
|
+
if (!this.sidebarVisible || this.isDestroyed || !process.stdout.isTTY)
|
|
193
|
+
return;
|
|
194
|
+
const stdout = process.stdout;
|
|
195
|
+
const totalCols = stdout.columns || 80;
|
|
196
|
+
const totalRows = stdout.rows || 24;
|
|
197
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
198
|
+
const sideStartCol = leftCols + 2; // +1 separator, +2 content
|
|
199
|
+
if (sideStartCol > totalCols - 10)
|
|
200
|
+
return;
|
|
201
|
+
const lines = SidebarRenderer.render(this.lastMetrics, this.sidebarWidth, totalRows, defaultSidebarTheme);
|
|
202
|
+
let buf = '';
|
|
203
|
+
// 1. Save cursor & hide cursor while updating sidebar
|
|
204
|
+
buf += '\x1b7\x1b[?25l';
|
|
205
|
+
// 2. Temporarily disable horizontal margin so cursor can move outside leftCols
|
|
206
|
+
buf += '\x1b[?69l';
|
|
207
|
+
// 3. Temporarily disable auto-wrap mode (DECAWM) to guarantee zero wrap-around to column 1
|
|
208
|
+
buf += '\x1b[?7l';
|
|
209
|
+
for (let r = 1; r <= Math.min(lines.length, totalRows); r++) {
|
|
210
|
+
const line = lines[r - 1];
|
|
211
|
+
// Position cursor at row r, column sideStartCol
|
|
212
|
+
buf += `\x1b[${r};${sideStartCol}H${line}`;
|
|
213
|
+
}
|
|
214
|
+
// 4. Re-enable auto-wrap mode for shell
|
|
215
|
+
buf += '\x1b[?7h';
|
|
216
|
+
// 5. Re-enable horizontal margin for shell
|
|
217
|
+
buf += `\x1b[?69h\x1b[1;${totalRows}r\x1b[1;${leftCols}s`;
|
|
218
|
+
// 6. Restore cursor & show cursor
|
|
219
|
+
buf += '\x1b8\x1b[?25h';
|
|
220
|
+
stdout.write(buf);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=split-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-session.js","sourceRoot":"","sources":["../../src/core/split-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAOzE;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACf,OAAO,CAAqB;IAC5B,SAAS,CAAoB;IAC7B,MAAM,CAAS;IACf,OAAO,CAAsB;IAE7B,cAAc,CAAU;IACxB,YAAY,CAAS;IACrB,WAAW,CAAiB;IAC5B,WAAW,GAAG,KAAK,CAAC;IACpB,gBAAgB,GAAG,KAAK,CAAC;IAEjC,YAAY,MAAc,EAAE,OAAO,GAAwB,EAAE;QAC3D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;QAE/C,6DAA6D;QAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,KAAK,KAAK,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,YAAY,IAAI,SAAS,IAAI,EAAE,CAAC;QAEtD,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAkB,CAAC,MAAM,EAAE;YAC5C,GAAG,OAAO;YACV,IAAI,EAA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AC;QACb,sDAAsD;QACtD,GAAG,IAAI,gBAAgB,CAAC;QACxB,+EAA+E;QAC/E,GAAG,IAAI,WAAW,CAAC;QACnB,2FAA2F;QAC3F,GAAG,IAAI,UAAU,CAAC;QAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,gDAAgD;YAChD,GAAG,IAAI,QAAQ,CAAC,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QAC7C,CAAC;QAED,wCAAwC;QACxC,GAAG,IAAI,UAAU,CAAC;QAClB,2CAA2C;QAC3C,GAAG,IAAI,mBAAmB,SAAS,WAAW,QAAQ,GAAG,CAAC;QAC1D,kCAAkC;QAClC,GAAG,IAAI,gBAAgB,CAAC;QAExB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export * from './core/keygen.js';
|
|
|
4
4
|
export * from './core/client.js';
|
|
5
5
|
export * from './core/exec.js';
|
|
6
6
|
export * from './core/session.js';
|
|
7
|
+
export * from './core/split-session.js';
|
|
8
|
+
export * from './core/metrics.js';
|
|
7
9
|
export * from './core/sftp.js';
|
|
8
10
|
export * from './core/tunnel.js';
|
|
11
|
+
export * from './sync/crypto.js';
|
|
12
|
+
export * from './sync/provider.js';
|
|
13
|
+
export * from './sync/manager.js';
|
|
14
|
+
export * from './tui/sidebar.js';
|
|
9
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,12 @@ export * from './core/keygen.js';
|
|
|
4
4
|
export * from './core/client.js';
|
|
5
5
|
export * from './core/exec.js';
|
|
6
6
|
export * from './core/session.js';
|
|
7
|
+
export * from './core/split-session.js';
|
|
8
|
+
export * from './core/metrics.js';
|
|
7
9
|
export * from './core/sftp.js';
|
|
8
10
|
export * from './core/tunnel.js';
|
|
11
|
+
export * from './sync/crypto.js';
|
|
12
|
+
export * from './sync/provider.js';
|
|
13
|
+
export * from './sync/manager.js';
|
|
14
|
+
export * from './tui/sidebar.js';
|
|
9
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface EncryptedPayload {
|
|
2
|
+
version: 1;
|
|
3
|
+
algorithm: 'aes-256-gcm';
|
|
4
|
+
kdf: 'scrypt';
|
|
5
|
+
salt: string;
|
|
6
|
+
iv: string;
|
|
7
|
+
tag: string;
|
|
8
|
+
ciphertext: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
itemCount?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Encrypt plaintext data using AES-256-GCM with a user-supplied passphrase.
|
|
14
|
+
* Key derivation uses scrypt with a unique random salt per encryption.
|
|
15
|
+
*/
|
|
16
|
+
export declare function encryptPayload(plaintext: string, passphrase: string, itemCount?: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Decrypt an AES-256-GCM encrypted payload back into plaintext string.
|
|
19
|
+
* Throws friendly error on incorrect passphrase or tampered data.
|
|
20
|
+
*/
|
|
21
|
+
export declare function decryptPayload(encryptedJson: string, passphrase: string): {
|
|
22
|
+
plaintext: string;
|
|
23
|
+
payload: EncryptedPayload;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/sync/crypto.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,aAAa,CAAC;IACzB,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BhG;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAmC1H"}
|