Import v2 base (unchanged files)

This commit is contained in:
load-v3
2026-08-13 12:45:29 +00:00
parent 81f2168717
commit 290976a6cc
39 changed files with 9948 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
/* Simple token auth for final mode. */
const crypto = require('crypto');
const tokens = new Map(); // token -> expiry
const TTL = 12 * 60 * 60 * 1000;
module.exports = {
login(password) {
const expected = process.env.ADMIN_PASSWORD;
if (!expected || password !== expected) return null;
const t = crypto.randomBytes(24).toString('hex');
tokens.set(t, Date.now() + TTL);
return t;
},
check(t) {
if (!t) return false;
const exp = tokens.get(t);
if (!exp) return false;
if (Date.now() > exp) { tokens.delete(t); return false; }
return true;
},
};