soxogvv commited on
Commit
daa21c8
Β·
verified Β·
1 Parent(s): 0961a21

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +13 -1
app.js CHANGED
@@ -23,6 +23,17 @@ app.use(express.static(path.join(__dirname, 'public')));
23
  // ── Session store ─────────────────────────────────────────────────────────────
24
  const sessions = new Set();
25
 
 
 
 
 
 
 
 
 
 
 
 
26
  // ── ANSI stripper ─────────────────────────────────────────────────────────────
27
  function stripAnsi(str) {
28
  // eslint-disable-next-line no-control-regex
@@ -340,7 +351,8 @@ app.get('/api/shellular/qr-data', requireAuth, (_req, res) => {
340
  // ── Start ──────────────────────────────────────────────────────────────────────
341
  app.listen(PORT, '0.0.0.0', () => {
342
  console.log(`Shellular Web UI β†’ http://0.0.0.0:${PORT}`);
343
- startSyncPy(); // 🐍 Launch sync.py on server start
 
344
  });
345
 
346
  // ── Graceful shutdown ──────────────────────────────────────────────────────────
 
23
  // ── Session store ─────────────────────────────────────────────────────────────
24
  const sessions = new Set();
25
 
26
+ // Persistent auto-token derived from SECRET_KEY β€” survives restarts on the
27
+ // client side (stored in sessionStorage) and is always valid server-side.
28
+ const AUTO_TOKEN = crypto.createHash('sha256').update(`auto:${SECRET_KEY}`).digest('hex');
29
+ sessions.add(AUTO_TOKEN);
30
+
31
+ // Unauthenticated endpoint β€” lets the frontend self-authenticate after a
32
+ // container restart without the user having to type the key again.
33
+ app.get('/api/auto-token', (_req, res) => {
34
+ res.json({ token: AUTO_TOKEN });
35
+ });
36
+
37
  // ── ANSI stripper ─────────────────────────────────────────────────────────────
38
  function stripAnsi(str) {
39
  // eslint-disable-next-line no-control-regex
 
351
  // ── Start ──────────────────────────────────────────────────────────────────────
352
  app.listen(PORT, '0.0.0.0', () => {
353
  console.log(`Shellular Web UI β†’ http://0.0.0.0:${PORT}`);
354
+ startSyncPy(); // 🐍 Launch sync.py on server start
355
+ startShellular(); // πŸš€ Auto-start shellular on boot so QR is ready immediately
356
  });
357
 
358
  // ── Graceful shutdown ──────────────────────────────────────────────────────────