@mmmbuto/nexuscrew 0.8.5 → 0.8.6

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.
@@ -289,12 +289,32 @@ function settingsRoutes(deps = {}) {
289
289
  // persisted hashed, 0600, for ten minutes only. Il `label` nel payload e'
290
290
  // l'etichetta umana con cui il peer vedra' questo dispositivo: default sensato
291
291
  // (mai 'localhost' crudo), sovrascrivibile dal form.
292
+ // v2: il creatore puo' includere l'Host/alias SSH raggiungibile (+ slug + porta
293
+ // SSH opzionale) cosicché il ricevente incolla/scansiona UN solo link e precompila
294
+ // tutto. NIENTE segreti: solo routing. L'invite one-time resta l'unica credenziale.
292
295
  r.post('/peering/invite', mutGate, (req, res) => {
293
296
  try {
294
- const label = nodesStore.sanitizeLabel(req.body && req.body.label, defaultDeviceName());
297
+ const b = req.body || {};
298
+ const label = nodesStore.sanitizeLabel(b.label, defaultDeviceName());
299
+ const extra = {};
300
+ if (typeof b.ssh === 'string' && b.ssh.trim()) {
301
+ const ssh = nodesStore.parseSshTarget(b.ssh.trim());
302
+ if (!ssh) return send(res, 400, { error: 'ssh non valido (atteso user@host o alias)' });
303
+ extra.ssh = ssh.value;
304
+ }
305
+ if (b.sshPort !== undefined && b.sshPort !== null && b.sshPort !== '') {
306
+ if (!nodesStore.isPort(Number(b.sshPort))) return send(res, 400, { error: 'sshPort non valida (1..65535)' });
307
+ extra.sshPort = Number(b.sshPort);
308
+ }
309
+ if (extra.sshPort && !extra.ssh) return send(res, 400, { error: 'sshPort richiede un target SSH' });
310
+ if (typeof b.name === 'string' && b.name.trim()) {
311
+ if (!nodesStore.NODE_NAME_RE.test(b.name.trim())) return send(res, 400, { error: 'name non valido (a-z 0-9 -, max 32)' });
312
+ extra.name = b.name.trim();
313
+ }
314
+ if (extra.ssh && !extra.name) extra.name = nodesStore.toSlug(label);
295
315
  const st = nodesStore.loadOrInitStore(nodesPath);
296
316
  send(res, 200, peering.createInvite({
297
- invitesPath, instanceId: st.nodeId, port: cfg.port, label,
317
+ invitesPath, instanceId: st.nodeId, port: cfg.port, label, ...extra,
298
318
  }));
299
319
  } catch (e) { send(res, 500, { error: String(e.message || e) }); }
300
320
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmmbuto/nexuscrew",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "Faithful browser tmux client — attach to live sessions over a real PTY, localhost-only, mobile-easy",
5
5
  "main": "lib/server.js",
6
6
  "bin": {