Dawnline 0.10.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions

- Portal redesigned from scratch. No header bar: the page opens with the
  server's name and the person's and fades under the edges. Device cards
  show the status, the last 7 days (hover a day for its figures) and a
  Connect or Update button; "Your access" folds into rows: what they can
  reach (with the names at home), data this month day by day, and when
  access ends. The page follows the system's light or dark theme
- Adding a device: pick the kind (PC, Mobile, Router, Other) and a name, or
  add it from the device itself with the page's QR code. The set-up sheet
  then shows the app for that system and the connection, waits for the
  first connection, says "<device> connected" and closes on its own
- Switching apps in the set-up sheet changes only what differs: the old
  words blur into the new ones, and the menu path is shown for iOS and
  Android in one line. Names, numbers and statuses that change on the page
  morph in place
- Dialogs open in the middle on a computer, on the same spring as the menu;
  buttons that wait for the router show a spinner at once
- A paused account gets one card that says so; the page's messages are
  short and no longer send people to the admin. A QR code of the page sits
  beside the breadcrumb, to open it on another device
- Allowed hours are shown in the visitor's own time zone
- The portal's Title setting is gone: the page and its tab take the
  server's name. A title set before is removed on upgrade
- The admin names .conf files after the server too, as the portal does
  (Outline-Home.conf); its device menu says "Download AmneziaWG config" and
  "Copy AmneziaVPN config", and its QR codes use the portal's round look in
  the admin's light or dark colours
- README rewritten, with screenshots made from a demo cast
  (scripts/capture-screenshots.mjs --demo)
This commit is contained in:
Aemeath committed 2026-10-19 21:07:14 +03:00
1 parent edeb1506fd
commit 4f12ca19e7
94 files changed
+8076 -5009

No files matched your search

+408
View File
@@ -0,0 +1,408 @@
// The pieces the set-up sheet is made of: store badges, the step that adds the
// connection (a link, the share sheet, a key or a file, as the app and the
// device allow), the panel that sends the connection to another device, the
// .conf for a router, the Download / Copy keys beside × and the line saying
// where an app scans a code. The rules behind them are setup.ts.
import type { ClientConfig, Device } from '../../shared/types';
import { h, ic, type Kid } from '../dom';
import { EASE_OUT, POP, SMOOTH, play } from '../motion';
import {
APP_NAME,
PLATFORM_LABEL,
importSteps,
keyFileName,
opensKeyLinks,
routerStore,
scanPath,
storeFor,
type AppId,
type Platform,
type Store,
} from '../setup';
import { accordion } from '../ui/accordion';
import { copy, download, sendFile, shareFile } from '../ui/feedback';
import { glass } from '../ui/glass';
import { menuLine, morphText, setText } from '../ui/morph';
import { hint } from '../ui/sheet';
export const APP_ICON: Record<AppId, string> = { vpn: 'amnezia', awg: 'amneziawg', wg: 'wireguard' };
/** The app a device was set up with last time, so the sheet reopens on it. */
const memo = (d: Device) => `dl.app.${d.id}`;
export function recallApp(d: Device): AppId | null {
try {
const v = localStorage.getItem(memo(d));
return v === 'vpn' || v === 'awg' || v === 'wg' ? v : null;
} catch {
return null;
}
}
export function rememberApp(d: Device, app: AppId) {
try {
localStorage.setItem(memo(d), app);
} catch {
/* private mode */
}
}
/** What the steps work with: the device, its configuration, the key, and the choices made. */
export interface SetupCtx {
d: Device;
cfg: ClientConfig;
key: string;
/** The platform this page is open on. */
pf: Platform;
/** "the phone": the device in a sentence. */
there: string;
app(): AppId;
/** The page is open on the device being set up. */
same(): boolean;
}
/**
* A badge: the mark in a tile, two lines, a chevron (an action) or the open
* mark (a store page, in a new tab). `primary`: the one thing to tap in step 2.
*/
export function badge(
st: { href?: string; top: string; main: string; mark: string; onclick?: (ev: Event) => void },
primary = false,
): HTMLElement {
const inner = [
h('span', { class: 'b-ic' }, ic(st.mark)),
h('span', { class: 'b-t' }, h('span', { class: 'b-top' }, st.top), h('span', { class: 'b-main' }, st.main)),
ic(st.onclick || st.href?.startsWith('vpn:') ? 'chevron' : 'open'),
];
const cls = `badge${primary ? ' primary' : ''}`;
if (st.onclick) return h('button', { type: 'button', class: cls, onclick: st.onclick }, inner);
// A vpn:// key opens the app in place: no new tab.
const app = st.href?.startsWith('vpn:');
return h('a', { class: cls, href: st.href, target: app ? null : '_blank', rel: 'noopener noreferrer' }, inner);
}
/** Where the app comes from: the store (and, on Android, the APK beside it), or a line to go and get it. */
export function storeBlock(app: AppId, os: Platform, router: boolean): Kid[] {
const st: Store | null = router ? routerStore(app) : storeFor(app, os);
if (!st) return [hint(`Get ${APP_NAME[app]} on the ${PLATFORM_LABEL[os]} and come back here.`)];
// Android: the store can fail (no Google Play, or it hides the app), so the APK sits beside it.
if (st.alt) return [h('div', { class: 'badges2' }, badge(st), badge(st.alt)), hint(st.alt.why)];
return [badge(st)];
}
const howto = (steps: [string, string][]) =>
h(
'ol',
{ class: 'howto' },
steps.map(([text, bold]) => h('li', {}, text.replace(/ → $/, ' ›'), bold ? [' ', h('b', {}, bold)] : null)),
);
const linkBtn = (label: string, run: (ev: Event) => void) => h('button', { type: 'button', onclick: run }, label);
/** Step 2: a link for AmneziaVPN, the file for the others, in the words of where they go. */
export function connectKids(c: SetupCtx): Kid[] {
const app = c.app();
const name = APP_NAME[app];
const hereHandheld = c.pf === 'ios' || c.pf === 'android';
// On the phone being set up, a link opens AmneziaVPN only on Android; an
// iPhone takes the key as a .vpn file from the share sheet.
const inHand = c.same() && hereHandheld;
const copyKey = (ev: Event) => copy(c.key, 'Key copied', ev.currentTarget);
const send = app === 'vpn' && inHand && !opensKeyLinks(c.pf) ? shareFile(keyFileName(c.cfg.filename), c.key) : null;
if (app === 'vpn' && inHand && (opensKeyLinks(c.pf) || send))
return [
send
? badge({ top: 'Then come back here and tap', main: 'Send to AmneziaVPN', mark: 'amnezia', onclick: () => void send() }, true)
: badge({ href: c.key, top: 'Then come back here and tap', main: 'Open in AmneziaVPN', mark: 'amnezia' }, true),
hint(
send ? 'Pick AmneziaVPN in the share sheet. Not there? ' : 'Nothing opened? ',
linkBtn('Copy the key', copyKey),
' and add it in the app.',
),
];
if (app === 'vpn')
return [
badge({ top: 'The connection as one key', main: 'Copy the key', mark: 'copy', onclick: copyKey }, true),
howto([
['Open AmneziaVPN', ''],
['Add server › ', 'Insert key'],
['Paste the key and connect', ''],
]),
];
const share = hereHandheld ? shareFile(c.cfg.filename, c.cfg.conf) : null;
return [
share
? badge(
{
top: c.same() ? `Straight into ${name}` : `Send it to the ${c.there}`,
main: 'Share the file',
mark: 'share',
onclick: () => void share(),
},
true,
)
: badge(
{
top: 'Then import it in the app',
main: 'Download the file',
mark: 'download',
onclick: () => download(c.cfg.filename, c.cfg.conf),
},
true,
),
// In the words of the app where the file goes: the phone in hand, or the computer's system.
howto(importSteps(app, c.pf, c.cfg.filename, !!share && c.same())),
];
}
/** A computer set up from elsewhere: the connection to send there, as the key or the file. */
export function sendKids(c: SetupCtx): Kid[] {
const app = c.app();
const btn = (icon: string, label: string, run: (ev: Event) => void) =>
h('button', { type: 'button', class: 'btn soft sm', onclick: run }, ic(icon), h('span', { class: 'lbl' }, label));
if (app === 'vpn') {
const file = keyFileName(c.cfg.filename);
const share = !!shareFile(file, c.key);
return [
h('p', { class: 'desc' }, `Send it to the ${c.there} in a message or a note, then in AmneziaVPN: Add server › Insert key.`),
h(
'div',
{ class: 'btnrow2' },
btn('copy', 'Copy the key', (ev) => copy(c.key, 'Key copied', ev.currentTarget)),
btn(share ? 'share' : 'download', share ? 'Share as a file' : 'Download the key', () => sendFile(file, c.key)),
),
];
}
const share = !!shareFile(c.cfg.filename, c.cfg.conf);
return [
h('p', { class: 'desc' }, `Send it to the ${c.there}, then import `, h('b', {}, c.cfg.filename), ` in ${APP_NAME[app]}.`),
h(
'div',
{ class: 'btnrow2' },
btn(share ? 'share' : 'download', share ? 'Share the file' : 'Download the file', () => sendFile(c.cfg.filename, c.cfg.conf)),
btn('copy', 'Copy the configuration', (ev) => copy(c.cfg.conf, 'Configuration copied', ev.currentTarget)),
),
];
}
/** One configuration line, highlighted; private and preshared keys masked unless shown. */
function confLine(line: string, reveal: boolean): Node {
if (/^\s*\[.+\]\s*$/.test(line)) return h('span', { class: 'sec' }, line);
const m = /^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(line);
if (!m) return document.createTextNode(line);
const secret = /^(\s*)(PrivateKey|PresharedKey)\b/.test(line);
return h('span', {}, h('span', { class: 'k' }, m[1]), ' ', secret && !reveal ? h('span', { class: 'mask' }, '••••••••••••••••') : m[2]);
}
/** The .conf for a router: a file card to download (or share), and the configuration folded, its keys hidden. */
export function filePane(cfg: ClientConfig): HTMLElement {
let reveal = false;
const pre = h('pre', { class: 'conf' });
const paint = () =>
pre.replaceChildren(...cfg.conf.split('\n').flatMap((l, i) => (i ? ['\n', confLine(l, reveal)] : [confLine(l, reveal)])));
paint();
const share = !!shareFile(cfg.filename, cfg.conf);
const eye = h(
'button',
{
type: 'button',
class: 'btn soft sm',
onclick: () => {
reveal = !reveal;
eye.replaceChildren(ic(reveal ? 'x' : 'key'), h('span', {}, reveal ? 'Hide key' : 'Show key'));
paint();
// A key shown comes into focus out of a blur; hidden again, the mask fades back.
pre.querySelectorAll('.mask, .k').forEach((x) =>
play(
x,
[
{ filter: 'blur(4px)', opacity: 0.4 },
{ filter: 'none', opacity: 1 },
],
{ duration: 320, easing: EASE_OUT },
),
);
},
},
ic('key'),
h('span', {}, 'Show key'),
);
const cp = h(
'button',
{ type: 'button', class: 'btn soft sm', onclick: (ev: Event) => copy(cfg.conf, 'Configuration copied', ev.currentTarget) },
ic('copy'),
h('span', { class: 'lbl' }, 'Copy'),
);
const card = h(
'div',
{ class: 'filecard' },
h(
'div',
{ class: 'fc-row' },
h('span', { class: 'filecard-ic' }, '.conf'),
h('span', { class: 't' }, h('span', { class: 'mono' }, cfg.filename), h('span', {}, 'For computers and routers')),
),
h(
'button',
{ type: 'button', class: 'btn accent sm block', onclick: () => sendFile(cfg.filename, cfg.conf) },
ic(share ? 'open' : 'download'),
h('span', {}, share ? 'Share file' : 'Download'),
),
);
const conf = accordion([{ icon: glass('file'), title: 'Configuration', body: [h('div', { class: 'confbar' }, eye, cp), pre] }], {
inset: true,
});
return h('div', { class: 'step-box' }, card, conf.el);
}
export interface ScanLine {
el: HTMLElement;
/** Another app picked: its name and its path morph in place. */
set(app: AppId): void;
}
/** "In AmneziaWG: + › Create from QR code", with both phone systems' wording where they differ. */
export function scanLine(app: AppId): ScanLine {
const name = h('span', { class: 'osm-p' }, APP_NAME[app]);
const path = menuLine(scanPath(app, 'ios'), scanPath(app, 'android'));
return {
el: h('span', { class: 'scanline' }, h('span', {}, 'In ', name, ':'), path.el),
set(a) {
morphText(name, APP_NAME[a], undefined, { whole: true });
path.set(scanPath(a, 'ios'), scanPath(a, 'android'));
},
};
}
export interface ConnPill {
el: HTMLElement;
/** The labels follow the app picked. */
sync(): void;
}
/**
* Beside ×: the connection itself, to download or copy, where the sheet offers
* neither (a phone or a tablet set up from elsewhere). One tooltip for both
* keys, under them: the first waits a beat; once one is up the next comes at
* once and the tooltip glides across. Copied: a check, and the tooltip says so.
*/
export function connPill(get: () => { text: string; msg: string; file: string; app: string }): ConnPill {
const tt = h('span', { class: 'tt' });
const tm = h('span', { class: 'tt-m' });
const tip = h('span', { class: 'hp-tip', 'aria-hidden': 'true' }, tt, tm);
const dl = h('button', { type: 'button', class: 'hp-b', onclick: () => sendFile(get().file, get().text) }, ic('download'));
const cp = h('button', { type: 'button', class: 'hp-b' }, ic('copy'));
const el = h('div', { class: 'hpill', role: 'group', 'aria-label': 'The connection', 'data-key': 'conn' }, dl, cp, tip);
let tipFor: HTMLElement | null = null;
let tipT = 0;
let warmUntil = 0;
const words = (b: HTMLElement) => (b === cp && cp.classList.contains('done') ? 'Copied' : (b.getAttribute('aria-label') ?? ''));
// Centred under its key, but never past the sheet's edge (× and its margin to the right).
const centre = (b: HTMLElement, t: string) => {
tm.textContent = t;
const w = tm.offsetWidth + 20;
return Math.min(b.offsetLeft + b.offsetWidth / 2, el.offsetWidth + 46 - w / 2);
};
const at = (x: number) => `translateX(${x}px) translateX(-50%)`;
const glideTo = (x: number) => {
const from = getComputedStyle(tip).transform;
tip.getAnimations().forEach((a) => a.cancel());
tip.style.transform = at(x);
play(tip, [{ transform: from }, { transform: at(x) }], { duration: SMOOTH.duration, easing: SMOOTH.easing });
};
// Another key's words, or "Copied": what the two share slides, the rest morphs; the pill glides with it.
const reword = (t: string) => morphText(tt, t);
const show = (b: HTMLElement) => {
clearTimeout(tipT);
if (tipFor === b && tip.classList.contains('on')) return;
tipFor = b;
if (tip.classList.contains('on')) {
const t = words(b);
glideTo(centre(b, t));
return reword(t);
}
const up = () => {
const t = words(b);
setText(tt, t);
const x = centre(b, t);
tip.getAnimations().forEach((a) => a.cancel());
tip.style.transform = at(x);
tip.classList.add('on');
play(
tip,
[
{ opacity: 0, transform: `${at(x)} translateY(-3px) scale(.96)`, filter: 'blur(3px)' },
{ opacity: 1, transform: at(x), filter: 'blur(0px)' },
],
{
duration: 220,
easing: EASE_OUT,
},
);
};
if (performance.now() < warmUntil) up();
else tipT = window.setTimeout(up, 420);
};
const hide = () => {
clearTimeout(tipT);
tipFor = null;
if (!tip.classList.contains('on')) return;
warmUntil = performance.now() + 500;
tip.classList.remove('on');
play(tip, [{ opacity: 1 }, { opacity: 0 }], { duration: 120, easing: 'ease-out' });
};
for (const b of [dl, cp]) {
b.addEventListener('pointerenter', (e) => {
if (e.pointerType === 'mouse') show(b);
});
b.addEventListener('focus', () => {
if (b.matches(':focus-visible')) show(b);
});
b.addEventListener('blur', hide);
}
el.addEventListener('pointerleave', hide);
const icon = (name: string) => {
const n = ic(name);
cp.querySelector('svg')!.replaceWith(n);
play(
n,
[
{ opacity: 0, transform: 'scale(.6)', filter: 'blur(3px)' },
{ opacity: 1, transform: 'none', filter: 'none' },
],
{ duration: POP.duration, easing: POP.easing },
);
};
// Copied: the key shows a check and the tooltip says so, then both go back.
const sayCopy = () => {
if (tipFor !== cp || !tip.classList.contains('on')) return;
const t = words(cp);
glideTo(centre(cp, t));
reword(t);
};
let back = 0;
cp.addEventListener('click', () => {
const c = get();
void copy(c.text, c.msg);
clearTimeout(back);
if (!cp.classList.contains('done')) {
cp.classList.add('done');
icon('check');
sayCopy();
}
back = window.setTimeout(() => {
cp.classList.remove('done');
icon('copy');
sayCopy();
}, 1600);
});
return {
el,
sync() {
const app = get().app;
dl.setAttribute('aria-label', `Download ${app} config`);
cp.setAttribute('aria-label', `Copy ${app} config`);
},
};
}