This commit is contained in:
st committed 2026-10-19 17:08:44 -05:00
commit 2bbacd2c7d
8 files changed
+582

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
__pycache__/
*.pyc
test-results/
+58
View File
@@ -0,0 +1,58 @@
# amnesia website
Static account portal with a compact, full-window layout inspired by the supplied
bitchbot.cc reference: top navigation, small title bars, nested charcoal borders,
outlined Verdana text and thin purple accent lines. Login and account pages use
plain forms and data rows instead of marketing copy and oversized statistic cards.
The reference was used for visual direction; its scripts and assets are not bundled.
Browser code has no dependencies,
external fonts, analytics, API secrets or build step. User-visible labels follow
the client's lowercase style; entered names and license labels preserve their case.
## Local use
From `D:\projects\amnesia`, run:
```powershell
python website/run-local.py
```
Open **http://127.0.0.1:5173**. On a fresh local database, the setup screen creates
the first administrator. Choose your own username/password; there are no default
credentials. Ctrl+C stops both local servers. State persists in `licensing/data/`.
Both `127.0.0.1` and `localhost` work on the configured website port in local
development. Production still requires the exact configured HTTPS origin.
Python 3.10+ is required. Local development needs no pip packages.
The projects can also run separately:
```powershell
python licensing/run.py --dev
python website/serve.py
```
## Screens
- Sign in, create account and first local administrator setup.
- Account overview with immutable numeric UID, license status and linked device.
- License redemption and history; duration begins on redemption.
- Device status, HWID-reset requests and password changes.
- Administrator license creation/revocation; full keys are shown only once.
- Member search, disable/enable accounts, approve HWID resets.
- Recent audit log. Admin actions are enforced by the API, not just hidden in UI.
Browser sessions use HttpOnly, SameSite cookies and CSRF tokens. Tokens stay out
of localStorage. The frontend uses the same-origin `/api/` path in development
and production. It never asks the browser to fabricate a hardware fingerprint;
hardware binding happens through the native licensing API.
## Apache hosting
Copy `website/public/` to `/srv/amnesia/website/public` and follow
[`../licensing/README.md`](../licensing/README.md). Apache serves these files and
forwards `/api/` to the licensing service. Production has no browser-based initial
administrator setup; use the included provisioning command on your VPS.
No VPS deployment or Minecraft client/injector integration is performed by this
project. The full first-device activation/verification API and a standalone
consumer example are included in the licensing project.
+224
View File
@@ -0,0 +1,224 @@
'use strict';
const app = document.querySelector('#app');
const state = {account:null, csrf:null, setup:false, auth:'login', page:'overview', me:null, admin:null, lastKey:null, connected:false};
const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const uid = value => String(value).padStart(6,'0');
const date = value => value ? new Date(value * 1000).toLocaleDateString(undefined,{year:'numeric',month:'short',day:'numeric'}) : '—';
const time = value => value ? new Date(value * 1000).toLocaleString() : 'never';
const active = licenses => licenses.find(l => l.status === 'active' && !l.expires_at) || licenses.filter(l => l.status === 'active').sort((a,b) => b.expires_at-a.expires_at)[0];
const badge = status => `<span class="status-tag ${status === 'active' || status === 'enabled' ? 'good' : status === 'revoked' || status === 'disabled' || status === 'expired' ? 'bad' : ''}">${esc(status)}</span>`;
const button = (action, label, extra='', style='') => `<button type="button" class="button ${style}" data-action="${action}" ${extra}>${label}</button>`;
const field = (label, name, type='text', attributes='', hint='') => `<label class="field"><span>${label}</span><input class="input" name="${name}" type="${type}" ${attributes}>${hint ? `<small>${hint}</small>` : ''}</label>`;
const panel = (title, content, extra='') => `<section class="panel ${extra}"><h2 class="panel-title">${title}</h2><div class="panel-body">${content}</div></section>`;
const detail = (label,value) => `<div class="detail"><dt>${label}</dt><dd>${value}</dd></div>`;
const stat = (label,value,hint,compact=false) => `<div class="stat"><small>${label}</small><strong class="${compact?'compact':''}">${esc(value)}</strong><span>${esc(hint)}</span></div>`;
const heading = (title,description,extra='') => `<header class="page-heading"><div><div class="eyebrow">amnesia / ${esc(state.page.replace('admin-',''))}</div><h1>${title}</h1><p>${description}</p></div>${extra}</header>`;
const errorSlot = '<div class="form-error" role="alert"></div>';
function toast(message,error=false) {
const node = document.createElement('div');node.className=`toast ${error?'error':''}`;node.textContent=message;
const container=document.querySelector('#toasts');container.append(node);
while(container.children.length>4)container.firstElementChild.remove();
setTimeout(()=>{node.classList.add('leaving');setTimeout(()=>node.remove(),220);},5000);
}
async function api(path, data) {
const options={credentials:'same-origin',headers:{},signal:AbortSignal.timeout(20000)};
if(data !== undefined) {
options.method='POST';options.headers['Content-Type']='application/json';options.body=JSON.stringify(data);
if(state.csrf)options.headers['X-CSRF-Token']=state.csrf;
}
let response;
try {response=await fetch(`/api${path}`,options);} catch(error) {
state.connected=false;throw new Error(error.name==='TimeoutError'?'the service took too long to respond':'cannot reach the licensing service');
}
state.connected=true;
const result=await response.json().catch(()=>({error:'the service returned an unexpected response'}));
if(!response.ok) {
if(response.status===401 && state.account && !path.includes('/auth/login')) {
state.account=null;state.csrf=null;state.me=null;state.admin=null;state.lastKey=null;render();
}
throw new Error(result.error || 'request failed');
}
return result;
}
async function refresh() {
const [me,admin]=await Promise.all([api('/account'),state.account.role==='admin'?api('/admin/overview'):Promise.resolve(null)]);
state.me=me;state.account=me.account;state.admin=admin;
}
function nav() {
if(!state.account)return `<div class="nav-label">account</div><nav class="nav" aria-label="account"><button class="active" type="button">${state.setup?'initial setup':'sign in'}</button></nav>`;
const item=(id,label)=>`<button type="button" class="${state.page===id?'active':''}" data-page="${id}" ${state.page===id?'aria-current="page"':''}>${label}</button>`;
return `<div class="nav-label">account</div><nav class="nav" aria-label="account">${item('overview','overview')}${item('licenses','my licenses')}${item('security','device & security')}</nav>${state.account.role==='admin'?`<div class="nav-label">administration</div><nav class="nav" aria-label="administration">${item('admin-licenses','license manager')}${item('admin-accounts','members')}${item('activity','activity log')}</nav>`:''}`;
}
function authView() {
const setup=state.setup, register=state.auth==='register';
const title=setup?'initial setup':register?'register':'login';
return `<div class="auth-layout">
<section class="panel auth-form">
<h1 class="panel-title">${title}</h1>
${!setup?`<div class="auth-tabs"><button type="button" data-auth="login" class="${!register?'active':''}">login</button><button type="button" data-auth="register" class="${register?'active':''}">register</button></div>`:''}
<form class="form" data-form="${setup?'setup':register?'register':'login'}">
${field('account name','username','text','required minlength="3" maxlength="24" pattern="[a-zA-Z0-9_]{3,24}" autocomplete="username"')}
${field('password','password','password',`required minlength="12" maxlength="128" autocomplete="${register||setup?'new-password':'current-password'}"`)}
${register||setup?field('confirm password','confirm','password','required minlength="12" maxlength="128" autocomplete="new-password"'):''}
${errorSlot}
<button class="button primary" type="submit">${setup?'create administrator':register?'create account':'login'}</button>
</form>
<div class="auth-foot">${setup?'the first account receives administrator access.':register?'license keys are redeemed after registration.':'use your amnesia account credentials.'}</div>
</section>
<section class="panel auth-copy">
<h2 class="panel-title">account information</h2>
<div class="panel-body"><dl class="details">
${detail('account names','3–24 letters, numbers or underscores.')}
${detail('passwords','12–128 characters.')}
${detail('uid','assigned at registration.')}
${detail('licenses','redeem a key from the licenses page.')}
${detail('hardware','linked on your first licensed client login.')}
</dl></div>
</section>
</div>`;
}
function overview() {
const a=state.me.account,l=active(state.me.licenses);
return heading('account','account and license information',badge(l?'active':'unlicensed'))+
`<div class="columns">
${panel('account',`<dl class="details">
${detail('account name',esc(a.username))}
${detail('uid',`<span class="uid">${uid(a.uid)}</span>`)}
${detail('registered',date(a.created_at))}
${detail('group',esc(a.role))}
${detail('last client login',esc(time(a.last_seen)))}
</dl>`)}
${panel('license',`<dl class="details">
${detail('status',badge(l?'active':'unlicensed'))}
${detail('license',l?esc(l.label):'none')}
${detail('expires',l?(l.expires_at?date(l.expires_at):'lifetime'):'—')}
${detail('device',a.hwid_bound?esc(a.device_name):'not linked')}
</dl><div class="button-row section-gap">
${button('navigate',l?'licenses':'redeem key','data-target="licenses"')}
${button('navigate','device settings','data-target="security"')}
</div>`)}
</div>`+
(state.admin?panel('statistics',`<div class="stats four">
${stat('members',state.admin.counts.accounts,'')}
${stat('active licenses',state.admin.counts.active_licenses,'')}
${stat('unused keys',state.admin.counts.issued_keys,'')}
${stat('reset requests',state.admin.counts.reset_requests,'')}
</div>`,'section-gap'):'');
}
function licenseRows(licenses,admin=false) {
if(!licenses.length)return `<div class="empty">${admin?'no licenses issued yet':'no licenses on this account'}<p>${admin?'create a key above to get started.':'redeem your first key above.'}</p></div>`;
return `<div class="table-wrap"><table><thead><tr><th>license</th>${admin?'<th>account uid</th>':''}<th>status</th><th>expires</th>${admin?'<th>action</th>':''}</tr></thead><tbody>${licenses.map(l=>`<tr data-search="${esc(`${l.label} ${l.key_hint} ${l.account_uid??''} ${l.status}`.toLowerCase())}"><td>${esc(l.label)}<span class="sub uid">${esc(l.key_hint)}</span></td>${admin?`<td class="uid">${l.account_uid?uid(l.account_uid):'unclaimed'}</td>`:''}<td>${badge(l.status)}</td><td>${l.expires_at?date(l.expires_at):!l.activated_at?(l.status==='issued'?(l.duration_days?`${l.duration_days} days on redemption`:'lifetime on redemption'):'not redeemed'):'lifetime'}</td>${admin?`<td>${l.status!=='revoked'?button('revoke','revoke',`data-id="${esc(l.id)}"`,'small danger'):'—'}</td>`:''}</tr>`).join('')}</tbody></table></div>`;
}
function licensesView() {
return heading('licenses','redeem a key to attach access to your account.')+panel('redeem a license',`<form class="form" data-form="redeem"><div class="inline-form">${field('license key','key','text','required maxlength="128" autocomplete="off" spellcheck="false" placeholder="AMN-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX"')}<button class="button primary" type="submit">redeem key</button></div>${errorSlot}<p class="form-note">license time begins when you redeem it. redeemed keys cannot be transferred to another account.</p></form>`)+`<section class="panel section-gap"><h2 class="panel-title">license history <small>${state.me.licenses.length} total</small></h2>${licenseRows(state.me.licenses)}</section>`;
}
function security() {
const a=state.me.account,request=state.me.reset_request;
return heading('device & security','manage your linked hardware and keep your account private.')+`<div class="columns">${panel('linked device',`<dl class="details">${detail('device',a.hwid_bound?esc(a.device_name):'not linked')}${detail('linked on',date(a.bound_at))}${detail('last seen',esc(time(a.last_seen)))}${detail('hardware tie',a.hwid_bound?'bound to this account':'awaiting first client sign-in')}</dl><div class="note section-gap">${a.hwid_bound?'hardware details stay private. a keyed fingerprint is used to recognize your device.':'your device is linked automatically the first time you sign in through the client with an active license.'}</div><form class="form section-gap" data-form="hwid-reset"><label class="field"><span>request a hardware reset</span><textarea class="input" name="reason" required minlength="5" maxlength="240" placeholder="tell us what changed" ${!a.hwid_bound?'disabled':''}></textarea></label>${request?`<p class="form-note">request pending since ${date(request.requested_at)}. submitting again updates your request.</p>`:''}${errorSlot}<button type="submit" class="button" ${!a.hwid_bound?'disabled':''}>${request?'update request':'request reset'}</button></form>`)}${panel('change password',`<p>changing your password signs out all browser and client sessions, including this one.</p><form class="form" data-form="password">${field('current password','current_password','password','required maxlength="128" autocomplete="current-password"')}${field('new password','new_password','password','required minlength="12" maxlength="128" autocomplete="new-password"')}${field('confirm new password','confirm','password','required minlength="12" maxlength="128" autocomplete="new-password"')}${errorSlot}<button type="submit" class="button primary">update password</button></form>`)}</div>`;
}
function adminLicenses() {
return heading('license manager','issue a key, track its owner, or revoke access.')+panel('create a license',`<form class="form" data-form="issue"><div class="columns">${field('label','label','text','required maxlength="60" value="amnesia access"')}${field('duration in days','duration_days','number','required min="1" max="3650" value="30"')}</div><div class="button-row"><label class="form-note"><input type="checkbox" name="lifetime"> lifetime access</label><button class="button primary" type="submit">create license key</button></div>${errorSlot}</form>${state.lastKey?`<div class="key-result"><p>key created — copy it now. the full key is only shown once.</p><code id="new-key">${esc(state.lastKey)}</code>${button('copy-key','copy key','','small')}</div>`:''}`)+`<section class="panel section-gap"><h2 class="panel-title">licenses <input class="input search" aria-label="filter licenses" data-filter placeholder="filter licenses…"></h2>${licenseRows(state.admin.licenses,true)}</section>`;
}
function members() {
const requests=new Map(state.admin.reset_requests.map(r=>[r.account_uid,r]));
return heading('members','accounts, linked devices and hardware reset requests.',`<span class="status-tag">${state.admin.counts.accounts} accounts</span>`)+`<section class="panel"><h2 class="panel-title">members <input class="input search" aria-label="filter members" data-filter placeholder="filter members…"></h2><div class="table-wrap"><table><thead><tr><th>account</th><th>status</th><th>device</th><th>actions</th></tr></thead><tbody>${state.admin.accounts.map(a=>`<tr data-search="${esc(`${a.username} ${uid(a.uid)} ${requests.has(a.uid)?'reset pending':''}`.toLowerCase())}"><td>${esc(a.username)}<span class="sub uid">uid ${uid(a.uid)} / ${esc(a.role)}</span></td><td>${badge(a.enabled?'enabled':'disabled')}</td><td>${a.hwid_bound?esc(a.device_name):'not linked'}${requests.has(a.uid)?`<span class="sub">reset requested: ${esc(requests.get(a.uid).reason)}</span>`:''}</td><td><div class="table-actions">${a.hwid_bound||requests.has(a.uid)?button('reset-hwid',requests.has(a.uid)?'approve reset':'reset hwid',`data-uid="${a.uid}"`,'small'):''}${a.uid!==state.account.uid?button('account-status',a.enabled?'disable':'enable',`data-uid="${a.uid}" data-enabled="${a.enabled?'false':'true'}"`,'small'):'<small>you</small>'}</div></td></tr>`).join('')}</tbody></table></div></section><p class="form-note section-gap">resetting a hardware tie immediately invalidates client sessions. the next client sign-in links a new device.</p>`;
}
function activity() {
return heading('activity log','account and licensing changes, recorded as they happen.')+`<section class="panel"><h2 class="panel-title">recent activity <small>latest 100 events</small></h2><div class="table-wrap"><table><thead><tr><th>event</th><th>actor</th><th>subject</th><th>time</th></tr></thead><tbody>${state.admin.audit.map(row=>`<tr><td>${esc(row.action.replaceAll('.',' / ').replaceAll('_',' '))}</td><td>${esc(row.username||'system')}</td><td class="uid">${esc(row.subject)}</td><td>${esc(time(row.created_at))}</td></tr>`).join('')}</tbody></table></div></section>`;
}
function render() {
document.title=`amnesia // ${state.account?state.page.replace('admin-',''):'account'}`;
const views={overview,licenses:licensesView,security,'admin-licenses':adminLicenses,'admin-accounts':members,activity};
const body=state.account&&state.me?(views[state.page]||overview)():authView();
app.removeAttribute('aria-busy');
app.innerHTML=`<aside class="sidebar"><div class="brand"><img src="/assets/logo.svg" alt=""><div><div class="brand-name">amnesia</div><small>account portal</small></div></div>${nav()}<div class="sidebar-bottom"><div class="connection ${state.connected?'':'offline'}">${state.connected?'service connected':'service unavailable'}</div></div></aside><section class="workspace"><header class="toolbar"><div class="breadcrumb">amnesia <span>/</span> <span>${state.account?esc(state.page.replace('admin-','')):state.setup?'setup':'account'}</span></div><div class="toolbar-account">${state.account?`<span class="username">${esc(state.account.username)}</span><span class="uid">#${uid(state.account.uid)}</span>${button('logout','sign out','','quiet')}`:'<span>member access</span>'}</div></header><div class="content">${body}</div></section>`;
}
async function confirmAction(message) {
const dialog=document.querySelector('#confirm-dialog');document.querySelector('#confirm-message').textContent=message;
return new Promise(resolve=>{dialog.returnValue='cancel';dialog.addEventListener('close',()=>resolve(dialog.returnValue==='confirm'),{once:true});dialog.showModal();});
}
document.addEventListener('click',async event=>{
const target=event.target.closest('button');if(!target)return;
if(target.dataset.auth){state.auth=target.dataset.auth;render();return;}
if(target.dataset.page||target.dataset.action==='navigate') {
state.page=target.dataset.page||target.dataset.target;state.lastKey=null;render();return;
}
const action=target.dataset.action;if(!action)return;
try {
if(action==='copy-key') {
if(!state.lastKey)return;
await navigator.clipboard.writeText(state.lastKey);toast('license key copied');return;
}
if(action==='logout') {
await api('/auth/logout',{});state.account=null;state.csrf=null;state.me=null;state.admin=null;state.lastKey=null;state.auth='login';render();return;
}
const messages={revoke:'revoke this license? its client sessions will stop working immediately.','reset-hwid':'reset this hardware tie? existing client sessions will end and the next sign-in can link a new device.','account-status':target.dataset.enabled==='true'?'enable this account again?':'disable this account? all browser and client sessions will end.'};
if(!messages[action]||!await confirmAction(messages[action]))return;
target.disabled=true;
if(action==='revoke'){await api(`/admin/licenses/${target.dataset.id}/revoke`,{});state.lastKey=null;}
if(action==='reset-hwid')await api(`/admin/accounts/${target.dataset.uid}/reset-hwid`,{});
if(action==='account-status')await api(`/admin/accounts/${target.dataset.uid}/status`,{enabled:target.dataset.enabled==='true'});
await refresh();render();toast(action==='reset-hwid'?'hardware tie reset':action==='revoke'?'license revoked':'account updated');
} catch(error){target.disabled=false;toast(error.message,true);}
});
document.addEventListener('input',event=>{
if(event.target.matches('[data-filter]')) {
const term=event.target.value.toLowerCase();document.querySelectorAll('tr[data-search]').forEach(row=>{row.hidden=!row.dataset.search.includes(term);});
}
});
document.addEventListener('change',event=>{
if(event.target.name==='lifetime') {
const days=event.target.form.elements.duration_days;days.disabled=event.target.checked;days.required=!event.target.checked;
}
});
document.addEventListener('submit',async event=>{
const form=event.target;if(!form.matches('[data-form]'))return;event.preventDefault();
const kind=form.dataset.form,fields=Object.fromEntries(new FormData(form)),submit=form.querySelector('[type="submit"]'),error=form.querySelector('.form-error');
error.textContent='';submit.disabled=true;
try {
if(['login','register','setup'].includes(kind)) {
if(kind!=='login'&&fields.password!==fields.confirm)throw new Error('passwords do not match');
const result=await api(kind==='setup'?'/setup':`/auth/${kind}`,{username:fields.username,password:fields.password});
state.account=result.account;state.csrf=result.csrf;state.setup=false;state.page='overview';await refresh();render();toast(kind==='login'?'signed in':'account created');return;
}
if(kind==='redeem')await api('/licenses/redeem',{key:fields.key});
if(kind==='hwid-reset')await api('/account/hwid-reset',{reason:fields.reason});
if(kind==='issue') {
const result=await api('/admin/licenses',{label:fields.label,duration_days:fields.lifetime?null:Number(fields.duration_days)});state.lastKey=result.key;
}
if(kind==='password') {
if(fields.new_password!==fields.confirm)throw new Error('passwords do not match');
await api('/account/password',{current_password:fields.current_password,new_password:fields.new_password});
state.account=null;state.csrf=null;state.me=null;state.admin=null;state.lastKey=null;state.auth='login';render();toast('password changed. sign in again.');return;
}
await refresh();render();toast(kind==='redeem'?'license activated':kind==='issue'?'license key created':'hardware reset requested');
} catch(problem){error.textContent=problem.message;submit.disabled=false;}
});
async function boot() {
try {
const result=await api('/session');state.account=result.account;state.csrf=result.csrf;state.setup=result.setup_required;
if(state.account)await refresh();render();
} catch(error) {
state.connected=false;render();toast(error.message,true);
}
}
boot();
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 174 199"><path fill="#7a459c" d="M87 0 174 50 87 101 0 50Z"/><path fill="#787878" d="m0 50 87 51v98L0 148Z"/><path fill="#101010" d="m87 101 87-51v98l-87 51Z"/></svg>

After

Width:  |  Height:  |  Size: 220 B

+25
View File
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Your amnesia account, licenses and linked device.">
<title>amnesia // account</title>
<link rel="icon" href="/assets/logo.svg" type="image/svg+xml">
<link rel="stylesheet" href="/style.css">
<script src="/app.js" defer></script>
</head>
<body>
<main class="shell" id="app" aria-busy="true">
<div class="initial-state">connecting to amnesia…</div>
</main>
<footer class="page-footer"><span>amnesia</span><span>account panel</span></footer>
<div class="toasts" id="toasts" role="status" aria-live="polite"></div>
<dialog id="confirm-dialog" class="confirm-dialog">
<form method="dialog"><h2 id="confirm-title">confirm action</h2><p id="confirm-message"></p>
<div class="button-row"><button value="cancel" class="button">cancel</button><button value="confirm" class="button primary">confirm</button></div>
</form>
</dialog>
<noscript>This account portal requires JavaScript.</noscript>
</body>
</html>
+168
View File
@@ -0,0 +1,168 @@
:root {
color-scheme: dark;
--bg: #282828; --surface: #323232; --raised: #191919; --ink: #eee;
--muted: #aaa; --dim: #858585; --purple: #7f48a3; --line: #191919;
--danger: #df7777; --good: #a8c99a;
font: 12px Verdana, Arial, sans-serif; font-synthesis: none;
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--purple) #191919; }
body { margin: 0; height: 100svh; min-height: 300px; padding: 8px; display: flex; flex-direction: column; gap: 7px; background: #404040; color: var(--ink); }
button, input, select, textarea { font: inherit; border-radius: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 1px solid #b48acd; outline-offset: 2px; }
a { color: inherit; }
h1, h2, h3, p, dl { margin: 0; }
h1, h2, h3 { font-size: 12px; font-weight: bold; }
p { line-height: 1.65; color: #bbb; }
small, .eyebrow { font-size: 10px; color: var(--dim); }
strong { font-weight: normal; }
h1, h2, h3, button, .brand-name, .breadcrumb, .toolbar-account, .page-footer, .status-tag, .panel-title, th, td, .detail, .stat, .form-note, .field>span, .auth-copy p { text-shadow: -1px -1px 0 #111, 1px -1px 0 #111, -1px 1px 0 #111, 1px 1px 0 #111; }
/* Thin chrome and nested borders inspired by the saved site. */
.shell { min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.sidebar { flex: none; display: flex; align-items: center; min-height: 34px; padding: 2px 8px; gap: 9px; position: relative; border: 1px solid #191919; outline: 1px solid #323232; outline-offset: -2px; background: linear-gradient(#323232, #282828); box-shadow: 0 0 4px #0006; border-top: 2px solid var(--purple); }
.brand { display: flex; gap: 7px; align-items: center; flex: none; padding-right: 12px; margin-right: 2px; border-right: 1px solid #111; }
.brand img { width: 18px; height: 21px; }
.brand-name { font-size: 13px; font-weight: bold; }
.brand small, .nav-label { display: none; }
.nav { display: flex; gap: 3px; flex: none; }
.nav[aria-label="administration"] { padding-left: 9px; border-left: 1px solid #111; }
.nav button { padding: 4px 7px; border: 1px solid transparent; background: none; font-size: 11px; white-space: nowrap; }
.nav button:hover { color: #b180ce; }
.nav button.active { border-color: #191919; box-shadow: inset 0 1px #414141; background: linear-gradient(#3b3b3b, #303030); color: white; }
.sidebar-bottom { margin-left: auto; padding-left: 8px; white-space: nowrap; color: var(--muted); font-size: 10px; }
.connection::before { content: ''; display: inline-block; width: 4px; height: 4px; background: #99b48c; margin: 0 7px 2px 0; }
.connection.offline::before { background: var(--danger); }
.workspace { min-height: 0; flex: 1; display: flex; flex-direction: column; border: 1px solid #191919; border-top: 2px solid var(--purple); outline: 1px solid #323232; outline-offset: -2px; background: linear-gradient(#323232, #282828 50px); box-shadow: 0 0 4px #0006; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 27px; flex: none; padding: 4px 8px; background: #191919; border-bottom: 1px solid #323232; font-size: 10px; }
.breadcrumb { display: flex; align-items: center; gap: 7px; color: #999; }
.breadcrumb span:last-child { color: #ddd; }
.toolbar-account { display: flex; gap: 11px; align-items: center; }
.uid { font-family: Consolas, monospace; color: #ccc; }
.content { padding: 6px; overflow: auto; flex: 1; min-height: 0; }
.initial-state { border: 1px solid #191919; background: #282828; padding: 15px; }
.page-footer { min-height: 24px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 3px 8px; font-size: 10px; color: #aaa; background: linear-gradient(#323232, #282828); border: 1px solid #191919; border-top: 2px solid var(--purple); outline: 1px solid #323232; outline-offset: -2px; }
/* Compact section headers and data rows rather than oversized dashboard tiles. */
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 4px 9px; }
.page-heading h1 { font-size: 12px; }
.page-heading p { font-size: 10px; margin-top: 3px; }
.page-heading .eyebrow { display: none; }
.status-tag { font-size: 10px; white-space: nowrap; color: #ccc; }
.status-tag.good { color: var(--good); }
.status-tag.bad { color: var(--danger); }
.stats { display: flex; flex-wrap: wrap; border: 1px solid #191919; padding: 3px; gap: 4px; margin-bottom: 6px; background: #282828; }
.stat { display: flex; align-items: center; flex: 1 1 180px; gap: 7px; padding: 6px; min-width: 0; font-size: 11px; border: 1px solid #191919; background: linear-gradient(#363636, #2d2d2d); box-shadow: inset 0 0 0 1px #3b3b3b; }
.stat>small { color: #aaa; white-space: nowrap; font-size: 10px; }
.stat>small::after { content: ':'; }
.stat>strong { font-size: 11px; color: white; overflow-wrap: anywhere; }
.stat>span { display: none; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; align-items: start; }
.panel { min-width: 0; border: 1px solid #191919; background: linear-gradient(#323232, #282828 50px); box-shadow: inset 0 0 0 1px #373737; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 7px; background: #191919; border-bottom: 1px solid #383838; color: #ddd; font-size: 11px; font-weight: normal; min-height: 25px; }
.panel-body { padding: 9px; }
.panel-body>p { font-size: 11px; margin-bottom: 12px; }
.details { display: grid; }
.detail { display: flex; justify-content: space-between; align-items: start; gap: 15px; padding: 6px 3px; font-size: 11px; border-bottom: 1px solid #353535; }
.detail:last-child { border-bottom: 0; }
.detail dt { color: #aaa; }
.detail dd { margin: 0; max-width: 70%; overflow-wrap: anywhere; text-align: right; }
.section-gap { margin-top: 6px; }
.guide { border-left: 2px solid var(--purple); padding-left: 9px; margin-top: 12px; display: grid; gap: 8px; }
.guide p { font-size: 10px; }
.guide strong { color: #ddd; }
.note { margin-top: 10px; border-left: 2px solid #654078; background: #303030; padding: 8px; color: #aaa; font-size: 10px; line-height: 1.65; }
.button { border: 1px solid #121212; padding: 5px 10px; min-height: 25px; background: linear-gradient(#444, #303030); box-shadow: inset 0 0 0 1px #4b4b4b; font-size: 11px; }
.button:hover { background: linear-gradient(#505050, #393939); }
.button:active { background: #2b2b2b; box-shadow: inset 0 0 0 1px #353535; }
.button.primary { background: linear-gradient(#80519b, #573869); box-shadow: inset 0 0 0 1px #9264ac; }
.button.primary:hover { background: linear-gradient(#9160ad, #65417b); }
.button.danger { color: #df9999; }
.button.small { font-size: 10px; padding: 3px 7px; min-height: 22px; }
.button.quiet { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; font-size: 10px; color: #bbb; }
.button.quiet:hover { color: #b787d0; }
.button-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.button-row.end { justify-content: flex-end; }
.form { display: grid; gap: 11px; }
.field { display: grid; gap: 5px; }
.field>span { color: #bbb; font-size: 11px; }
.field>small { font-size: 10px; line-height: 1.6; }
.input { width: 100%; min-width: 0; border: 1px solid #191919; background: #252525; box-shadow: inset 0 0 0 1px #363636; color: white; font-size: 11px; min-height: 27px; padding: 5px 7px; }
.input::placeholder { color: #777; }
.input:focus { outline: 1px solid #79508f; outline-offset: 0; }
.field textarea { min-height: 70px; resize: vertical; }
.form-error { color: var(--danger); font-size: 11px; line-height: 1.5; }
.form-error:empty { display: none; }
.form-note { font-size: 10px; line-height: 1.7; color: #aaa; }
.inline-form { display: flex; align-items: end; gap: 6px; }
.inline-form>.field { flex: 1; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 11px; }
th { background: #2b2b2b; color: #aaa; font-size: 10px; font-weight: normal; padding: 7px 9px; border-bottom: 1px solid #191919; white-space: nowrap; }
td { border-bottom: 1px solid #373737; padding: 8px 9px; vertical-align: middle; color: #ddd; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #ffffff04; }
td .sub { display: block; margin-top: 4px; color: #999; font-size: 10px; line-height: 1.6; }
.table-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.empty { color: #bbb; padding: 20px 10px; font-size: 11px; }
.empty p { font-size: 10px; margin-top: 5px; }
.search { width: 190px; max-width: 50%; min-height: 23px; padding: 3px 6px; font-size: 10px; }
.key-result { background: #28232c; border: 1px solid #75448c; padding: 10px; margin-top: 10px; }
.key-result p { font-size: 10px; }
.key-result code { display: block; font-size: 12px; padding: 10px 0; overflow-wrap: anywhere; }
/* Plain member login with account rules alongside it. */
.auth-layout { width: min(720px, 100%); margin: 36px auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; }
.auth-form { grid-column: 1; grid-row: 1; }
.auth-copy { grid-column: 2; grid-row: 1; }
.auth-copy .detail { flex-direction: column; gap: 3px; padding: 8px 0; }
.auth-copy .detail dd { max-width: 100%; text-align: left; font-size: 10px; color: #aaa; }
.auth-tabs { display: flex; gap: 3px; padding: 5px; border-bottom: 1px solid #191919; background: #303030; }
.auth-tabs button { font-size: 11px; padding: 4px 9px; background: none; border: 1px solid transparent; }
.auth-tabs button.active { border-color: #191919; background: linear-gradient(#444, #333); box-shadow: inset 0 0 0 1px #4c4c4c; }
.auth-form .form { padding: 11px; }
.auth-form .button.primary { justify-self: start; }
.auth-foot { padding: 0 11px 11px; font-size: 10px; color: #999; line-height: 1.6; }
.toasts { position: fixed; left: 13px; bottom: 42px; max-width: min(400px, calc(100vw - 26px)); display: grid; gap: 4px; z-index: 20; }
.toast { padding: 8px 10px; background: linear-gradient(#383838, #282828); border: 1px solid #191919; border-left: 2px solid var(--purple); font-size: 11px; line-height: 1.6; animation: toast-in .18s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.leaving { opacity: 0; transition: opacity .18s; }
.confirm-dialog { padding: 14px; max-width: 390px; color: #eee; background: linear-gradient(#383838, #282828 50px); border: 1px solid #191919; border-top: 2px solid var(--purple); box-shadow: inset 0 0 0 1px #444; border-radius: 0; }
.confirm-dialog::backdrop { background: #0008; }
.confirm-dialog h2 { margin-bottom: 10px; font-size: 12px; }
.confirm-dialog p { font-size: 11px; margin-bottom: 15px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
@media (max-width: 900px) {
.sidebar { flex-wrap: wrap; gap: 3px 5px; padding: 4px 6px; }
.brand { padding-right: 8px; }
.sidebar-bottom { padding: 3px; }
.nav button { padding: 4px 5px; font-size: 10px; }
.nav[aria-label="administration"] { padding-left: 4px; }
}
@media (max-width: 600px) {
body { padding: 5px; gap: 5px; }
.shell { gap: 6px; }
.sidebar { gap: 4px; }
.sidebar-bottom { display: none; }
.brand { border: 0; padding-right: 5px; }
.brand-name { font-size: 12px; }
.brand img { width: 15px; height: 18px; }
.nav { flex-wrap: wrap; gap: 2px; }
.toolbar { font-size: 9px; }
.toolbar-account { gap: 7px; }
.toolbar-account .username { max-width: 95px; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 4px; }
.columns, .auth-layout { grid-template-columns: 1fr; }
.auth-layout { margin: 6px auto; max-width: 380px; }
.auth-copy, .auth-form { grid-column: auto; grid-row: auto; }
.auth-form { order: -1; }
.auth-copy { order: 1; }
.page-heading { align-items: start; }
.inline-form { align-items: stretch; flex-direction: column; }
.inline-form .button { align-self: start; }
.stat { flex-basis: 140px; padding: 5px; }
.detail { font-size: 10px; }
.confirm-dialog { margin: auto 12px; max-width: calc(100% - 24px); }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation: none!important; transition: none!important; scroll-behavior: auto!important; }
}
+37
View File
@@ -0,0 +1,37 @@
"""Start both local projects. Ctrl+C stops both services."""
import argparse
import os
from pathlib import Path
import subprocess
import sys
import time
ROOT=Path(__file__).resolve().parent
def main():
parser=argparse.ArgumentParser()
parser.add_argument("--port",type=int,default=5173)
parser.add_argument("--api-port",type=int,default=8787)
parser.add_argument("--data-dir",type=Path,default=ROOT.parent/"licensing"/"data")
args=parser.parse_args()
environment=os.environ.copy()
environment["AMNESIA_ORIGIN"]=f"http://127.0.0.1:{args.port}"
environment["AMNESIA_DATA"]=str(args.data_dir.resolve())
processes=[]
try:
processes.append(subprocess.Popen([sys.executable,"-u",str(ROOT.parent/"licensing"/"run.py"),"--dev","--port",str(args.api_port)],env=environment))
processes.append(subprocess.Popen([sys.executable,"-u",str(ROOT/"serve.py"),"--port",str(args.port),"--api-port",str(args.api_port)],env=environment))
print(f"Open http://127.0.0.1:{args.port} — press Ctrl+C to stop both projects.",flush=True)
while all(process.poll() is None for process in processes):time.sleep(.25)
except KeyboardInterrupt:
pass
finally:
for process in processes:
if process.poll() is None:process.terminate()
for process in processes:
try:process.wait(timeout=5)
except subprocess.TimeoutExpired:process.kill();process.wait()
if __name__=="__main__":main()
+66
View File
@@ -0,0 +1,66 @@
"""Local static preview with a same-origin API proxy; use Apache in production."""
import argparse
import http.client
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
class Handler(SimpleHTTPRequestHandler):
api_port = 8787
def end_headers(self):
self.send_header("X-Content-Type-Options", "nosniff")
self.send_header("Referrer-Policy", "same-origin")
self.send_header("Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'")
super().end_headers()
def proxy(self):
try:
length = int(self.headers.get("Content-Length", "0"))
except ValueError:
self.send_error(400)
return
if length > 16384 or length < 0:
self.send_error(413)
return
headers = {name:self.headers[name] for name in ("Content-Type","Cookie","Origin","X-CSRF-Token","Authorization") if name in self.headers}
connection = http.client.HTTPConnection("127.0.0.1", self.api_port, timeout=20)
try:
connection.request(self.command, self.path, self.rfile.read(length) if length else None, headers)
response = connection.getresponse()
data = response.read()
self.send_response(response.status)
for name,value in response.getheaders():
if name.lower() in ("content-type","set-cookie","retry-after","cache-control"):
self.send_header(name,value)
self.send_header("Content-Length",str(len(data)))
self.end_headers()
self.wfile.write(data)
except OSError:
self.send_error(502,"licensing service unavailable")
finally:
connection.close()
def do_GET(self):
if self.path.startswith("/api/"):
self.proxy()
else:
super().do_GET()
def do_POST(self):
if self.path.startswith("/api/"):
self.proxy()
else:
self.send_error(405)
if __name__ == "__main__":
parser=argparse.ArgumentParser()
parser.add_argument("--port",type=int,default=5173)
parser.add_argument("--api-port",type=int,default=8787)
args=parser.parse_args()
Handler.api_port=args.api_port
handler=partial(Handler,directory=str(Path(__file__).parent / "public"))
print(f"Website: http://127.0.0.1:{args.port}",flush=True)
ThreadingHTTPServer(("127.0.0.1",args.port),handler).serve_forever()