14 Commits
Author SHA1 Message Date
nocodeandClaude Opus 5 a1fb846d51 fix(web): stop the settings page breaking on an unexpected payload
Every list the page walks was read straight off the response, so a single
missing field took the whole view down with `undefined.map` — which reads as
a broken feature rather than as what it is, a page and an API disagreeing on
the shape of the data.

The page now normalises what it receives: absent lists render empty, an enum
without options falls back to a text field, and settings that arrive without
sections are shown under one heading instead of not at all.

Errors of that family also say so, and point at the reload that fixes them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:44 +02:00
nocodeandClaude Opus 5 2b4e6f356a feat(web): open a repository from anywhere on its row
The cards on the repository page already opened as a whole, but the tables
on the organisation and overview pages still only linked the name, so the
same object behaved differently depending on where it was listed.

A table row can now carry a destination. Controls inside it keep their own
behaviour, the row is reachable with the keyboard, and only the empty space
navigates.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:44 +02:00
nocodeandClaude Opus 5 405692f228 fix(web): give static assets a validator caches can check
The front-end was served with `no-cache` but no `ETag` and no
`Last-Modified`, so a cache had nothing to revalidate against and could keep
handing out modules older than the API they talk to — which surfaces as a
cryptic error in a view rather than as anything resembling a stale cache.

Assets now carry both, and an unchanged file answers 304.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:43 +02:00
nocodeandClaude Opus 5 dd53c79b39 fix(web): say when the dashboard is disabled
`WEB_ENABLED` not being `true` produced no output at all, so a missing site
looked exactly like a broken one and there was nothing in the console to
tell the two apart.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:43 +02:00
nocodeandClaude Opus 5 8503b41d51 fix(web): say out loud when the dashboard cannot listen
A failed `listen` only produced a generic line the bot then carried on past,
so the site was simply absent with nothing explaining why — and inside a
container a bind on an unpublished port succeeds while staying unreachable,
which looks identical to a crash from the browser.

The error now names the address, the port and the actual cause, and a
successful bind on `0.0.0.0` reminds that the port still has to be published
by the host.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:43 +02:00
nocodeandClaude Opus 5 f93c559a47 fix(config): warn when a public address is announced but only loopback is bound
`WEB_HOST=127.0.0.1` is the right default behind a reverse proxy on the same
machine, and the wrong one inside a container or on a hosting panel, where
the process has to bind the allocation. The guidance only mentioned the
first case, so a `.env` written from the wizard could leave the dashboard
listening where nothing could reach it — every request timing out with
nothing saying why.

The wizard now flags the contradiction between a loopback bind and a public
URL, and both the help text and `.env.example` name the container case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:43 +02:00
nocodeandClaude Opus 5 3d55abcb11 docs(web): document the wiki, the settings and the command publishing
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:43 +02:00
nocodeandClaude Opus 5 748a8c19e1 feat(wiki): add the reading site and its editor
The renderer escapes HTML before any transformation and drops
`javascript:` links. Pages are written by the team, but a renderer that
relies on that is one mistake away from being a hole.

The editor previews as you type: legal pages are long, and writing Markdown
blind is how broken tables end up published.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:42 +02:00
nocodeandClaude Opus 5 ce1c0f2910 feat(wiki): serve a public documentation written from the panel
Pages live in SQLite and are read without a session: documentation nobody
can reach without an account is not documentation. Drafts answer 404 even
when their address is guessed, and the site never falls back to the
dashboard shell, which would send a visitor to a login screen.

The wiki ships with terms of use and a privacy policy written against the
revised Swiss LPD, describing table by table what this codebase actually
stores. Both are marked protected: they can be rewritten, not deleted, and
a deleted one comes back on the next start — a bot that processes personal
data must always be able to show its notice.

The bracketed details still have to be completed and the whole reviewed;
this is a starting point written from the schema, not legal advice.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:42 +02:00
nocodeandClaude Opus 5 2eade4dfc4 style(web): adopt the official FWS mark and its palette
The placeholder mark was an Arch-blue chevron. The site now carries the FWS
logo — cyan ring on dark navy — and its accent colour follows, so the
dashboard and the brand no longer disagree.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:42 +02:00
nocodeandClaude Opus 5 1b6aa3dd63 fix(web): make the whole repository card open the repository
Only the name was a link, so most of a rectangle that reacts to the pointer
led nowhere.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:42 +02:00
nocodeandClaude Opus 5 d518f9fd56 feat(web): publish the slash commands from the panel
Registering the commands was the one routine step that still needed shell
access on the host, which is awkward when the bot runs behind a hosting
panel. Guild commands take effect immediately, so the button says what it
did as soon as it returns.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:42 +02:00
nocodeandClaude Opus 5 a61f446e44 feat(voice): take back the generated channels the database forgot
A voice channel outlives the process that made it. A restored backup, a
wiped `data/` folder or a redeployment shipping a fresh database all leave
real channels behind that nothing manages any more: they are never cleaned
up, and their owner can no longer rename or lock them.

At startup the bot now reclaims the channels sitting in a trigger's own
category and named after its template — a channel created by hand is never
touched. Those still in use go back to whoever is inside; the empty ones are
leftovers and are removed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:42 +02:00
nocodeandClaude Opus 5 52a5c50692 feat(settings): make the server settings real, and widen them
The dashboard offered seven switches that nothing read: they promised a
behaviour the bot did not have, which is worse than offering nothing.

Every setting is now declared once, with its type, its bounds and its
explanation, and the services read it: the welcome message and its wording,
the automatic role, departure notices, the private notice sent to a
sanctioned member, the default mute duration, how much history a ban erases,
whether a closed ticket is deleted or archived, and an optional role mention
on the Gitea notifications.

A test walks the sources and fails when a declared key is read nowhere, so
the list cannot drift back into decoration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 22:31:36 +02:00
13 changed files with 209 additions and 36 deletions

No files matched your search

+3 -2
View File
@@ -75,8 +75,9 @@ GITEA_WEBHOOK_SECRET=
# Site d'administration servi par le bot : `npm run setup` pour l'assistant .env,
# puis http://WEB_HOST:WEB_PORT une fois le bot démarré.
WEB_ENABLED=false
# 127.0.0.1 par défaut : n'expose rien hors de la machine. Mettre 0.0.0.0 seulement
# derrière un reverse proxy HTTPS.
# 127.0.0.1 derrière un reverse proxy installé sur la même machine.
# 0.0.0.0 dans un conteneur ou sur un panel d'hébergement (Pterodactyl, Docker) :
# sinon le site n'écoute que sur la boucle locale et reste injoignable.
WEB_HOST=127.0.0.1
WEB_PORT=3080
# URL publique du tableau de bord, utilisée pour la redirection OAuth2 Discord.
+9
View File
@@ -27,6 +27,15 @@ await registerEvents(client);
const webServer = env.web.enabled ? startWebServer({ client }) : null;
const webhookServer = env.webhook.enabled && !webhookSharesWebPort() ? startWebhookServer(client) : null;
// Saying nothing when the dashboard is off is how an afternoon gets lost
// looking for a site that was never asked to start.
if (!env.web.enabled) {
logger.warn(
'Le tableau de bord est désactivé : `WEB_ENABLED` ne vaut pas `true`. ' +
'Aucun site ne sera servi. Mets `WEB_ENABLED=true` dans le .env puis redémarre.',
);
}
process.on('unhandledRejection', (reason) => logger.error('Unhandled promise rejection', reason));
process.on('uncaughtException', (error) => logger.error('Uncaught exception', error));
+13 -1
View File
@@ -132,7 +132,7 @@ export function clientIp(request) {
* Serves a file from `root`, refusing anything that escapes it.
* Returns false when the file does not exist, so the caller can fall back.
*/
export async function sendStatic(response, root, requestPath, { fallback = null } = {}) {
export async function sendStatic(response, root, requestPath, { fallback = null, request = null } = {}) {
const relative = decodeURIComponent(requestPath).replace(/^\/+/, '');
const resolved = path.resolve(root, relative || 'index.html');
const target = resolved.startsWith(path.resolve(root)) ? resolved : null;
@@ -150,12 +150,24 @@ export async function sendStatic(response, root, requestPath, { fallback = null
if (!info?.isFile()) return false;
const extension = path.extname(file).toLowerCase();
// `no-cache` alone tells a cache to revalidate, but without a validator it has
// nothing to revalidate against — which is how a browser or a CDN ends up
// serving a front-end older than the API it talks to.
const etag = `"${info.size.toString(16)}-${Math.floor(info.mtimeMs).toString(16)}"`;
if (request?.headers?.['if-none-match'] === etag) {
response.writeHead(304, { ...SECURITY_HEADERS, ETag: etag }).end();
return true;
}
response.writeHead(200, {
...SECURITY_HEADERS,
'Content-Type': MIME_TYPES[extension] ?? 'application/octet-stream',
'Content-Length': info.size,
// The SPA shell must never be cached, its modules are revalidated on each load.
'Cache-Control': extension === '.html' ? 'no-store' : 'no-cache',
ETag: etag,
'Last-Modified': new Date(info.mtimeMs).toUTCString(),
});
createReadStream(file).pipe(response);
return true;
+2 -1
View File
@@ -310,7 +310,8 @@ async function renderView(host) {
const module = await import(route.module);
await module.render(host, { params: segments.slice(1), state });
} catch (error) {
mount(host, h('div', { class: 'notice notice-error' }, h('p', { text: error.message })));
const { errorBox } = await import('./core/ui.js');
mount(host, errorBox(error.message, { retry: () => renderView(host) }));
}
}
+42 -7
View File
@@ -80,7 +80,7 @@ export function toggle(checked, onChange, label) {
* Renders a table. Each column is `{ key, label, render?, className? }`;
* `render` returns a Node or a string.
*/
export function table(columns, rows, { empty = 'Rien à afficher pour le moment.' } = {}) {
export function table(columns, rows, { empty = 'Rien à afficher pour le moment.', rowHref = null } = {}) {
if (!rows || rows.length === 0) {
// An empty state is where people look for the action that fills it, so it
// accepts a node and not only a sentence.
@@ -107,10 +107,11 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
h(
'tbody',
{},
rows.map((row) =>
h(
rows.map((row) => {
const target = rowHref?.(row) ?? null;
const line = h(
'tr',
{},
target ? { class: 'row-link', tabindex: '0', role: 'link' } : {},
columns.map((column) => {
const cell = h('td', { class: column.className ?? '' });
const value = column.render ? column.render(row) : row[column.key];
@@ -118,8 +119,25 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
else cell.textContent = value === null || value === undefined ? '—' : String(value);
return cell;
}),
),
),
);
if (target) {
// A control inside the row keeps its own behaviour; only the empty
// space navigates.
const open = (event) => {
if (event.target.closest('a, button, input, select, textarea, label')) return;
window.location.hash = target.replace(/^#/, '');
};
line.addEventListener('click', open);
line.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
open(event);
}
});
}
return line;
}),
),
),
);
@@ -128,11 +146,28 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
export const spinner = (label = 'Chargement…') =>
h('div', { class: 'loading' }, h('span', { class: 'spinner' }), h('span', { text: label }));
/**
* A `undefined is not a function` reaching the screen almost always means the
* page and the API disagree on the shape of the data — which reads as a broken
* feature unless the box says otherwise.
*/
const looksLikeVersionMismatch = (message) =>
/Cannot read propert|undefined is not|is not a function|of undefined/i.test(String(message));
export const errorBox = (message, { retry } = {}) =>
h(
'div',
{ class: 'notice notice-error' },
h('p', { text: message }),
h(
'div',
{},
h('p', { text: message }),
looksLikeVersionMismatch(message) &&
h('p', {
class: 'muted',
text: 'Cette erreur vient en général d’une interface plus ancienne que l’API : recharge avec Ctrl+Shift+R, et si elle persiste, re-téléverse le dossier src/web/public.',
}),
),
retry && button('Réessayer', retry, { tone: 'ghost' }),
);
+8
View File
@@ -535,6 +535,14 @@ pre code {
.table tbody tr:hover {
background: color-mix(in srgb, var(--blue) 6%, transparent);
}
.table tbody tr.row-link {
cursor: pointer;
}
.table tbody tr.row-link:focus-visible {
outline: 2px solid var(--blue);
outline-offset: -2px;
}
.num {
text-align: right;
font-variant-numeric: tabular-nums;
+5 -2
View File
@@ -164,7 +164,7 @@ export function render(host, { state }) {
card(
'Dépôts',
{ subtitle: 'Clique sur un dépôt pour le gérer en détail.' },
{ subtitle: 'Clique sur une ligne pour gérer le dépôt en détail.' },
table(
[
{
@@ -207,7 +207,10 @@ export function render(host, { state }) {
},
],
data.repositories,
{ empty: 'Aucun dépôt dans cette organisation.' },
{
empty: 'Aucun dépôt dans cette organisation.',
rowHref: (repository) => `#/repos/${repository.fullName}`,
},
),
),
+1
View File
@@ -96,6 +96,7 @@ function giteaCard(gitea) {
},
],
gitea.repositories,
{ rowHref: (repository) => `#/repos/${repository.fullName}` },
),
);
}
+38 -19
View File
@@ -44,7 +44,7 @@ function settingControl(setting, value, apply) {
);
}
if (setting.type === 'enum') {
if (setting.type === 'enum' && Array.isArray(setting.options)) {
return field(
setting.label,
select(
@@ -76,20 +76,27 @@ function settingControl(setting, value, apply) {
function behaviourCard(data, level, reload) {
const editable = level >= LEVELS.DEV;
const sections = data.sections ?? [];
const schema = Array.isArray(data.schema) ? data.schema : [];
const values = data.values ?? {};
// Falling back to one section keeps the page useful against an API that does
// not group its settings, rather than rendering nothing at all.
const sections = Array.isArray(data.sections)
? data.sections
: [{ id: null, title: 'Comportement du bot', summary: null }];
return h(
'div',
{ class: 'stack' },
...sections.map((section) => {
const settings = data.schema.filter((setting) => setting.section === section.id);
const settings = section.id ? schema.filter((setting) => setting.section === section.id) : schema;
if (settings.length === 0) return null;
return card(
section.title,
{ subtitle: section.summary },
...settings.map((setting) => {
const value = data.values[setting.key];
const value = values[setting.key];
if (!editable) {
return h(
@@ -105,7 +112,7 @@ function behaviourCard(data, level, reload) {
try {
const saved = await api.put(`/api/settings/values/${setting.key}`, { value: next });
toast(`« ${setting.label} » enregistré.`);
data.values[setting.key] = saved.value;
values[setting.key] = saved.value;
} catch (error) {
toast(error.message, 'error');
}
@@ -131,7 +138,13 @@ const testButton = (service, label) =>
{ tone: 'ghost' },
);
function connectionsCard(data) {
function connectionsCard(raw) {
const data = {
discord: raw.discord ?? {},
gitea: raw.gitea ?? {},
webhook: raw.webhook ?? {},
web: raw.web ?? {},
};
return h(
'div',
{ class: 'stack' },
@@ -149,13 +162,13 @@ function connectionsCard(data) {
h(
'div',
{ class: 'advanced-only' },
keyValue(Object.entries(data.discord.roles).map(([label, value]) => ({ label, value }))),
keyValue(Object.entries(data.discord.roles ?? {}).map(([label, value]) => ({ label, value }))),
),
h('h3', { class: 'advanced-only', text: 'Salons' }),
h(
'div',
{ class: 'advanced-only' },
keyValue(Object.entries(data.discord.channels).map(([label, value]) => ({ label, value }))),
keyValue(Object.entries(data.discord.channels ?? {}).map(([label, value]) => ({ label, value }))),
),
),
@@ -397,14 +410,15 @@ function tokensCard(reload) {
}
function maintenanceCard(data) {
const runtime = data.runtime ?? {};
return card(
'Maintenance',
{ subtitle: `Base : ${data.runtime.databasePath}` },
{ subtitle: `Base : ${runtime.databasePath ?? '—'}` },
grid(
stat('Environnement', data.runtime.nodeEnv),
stat('Niveau de log', data.runtime.logLevel),
stat('Rétention', `${data.runtime.logRetentionDays} jours`),
stat('PID', data.runtime.pid),
stat('Environnement', runtime.nodeEnv),
stat('Niveau de log', runtime.logLevel),
stat('Rétention', `${runtime.logRetentionDays ?? '—'} jours`),
stat('PID', runtime.pid),
),
h(
'div',
@@ -425,7 +439,7 @@ function maintenanceCard(data) {
},
{ tone: 'ghost' },
),
data.web.allowRestart &&
data.web?.allowRestart &&
button(
'Redémarrer le bot',
async () => {
@@ -441,12 +455,13 @@ function maintenanceCard(data) {
{ tone: 'danger' },
),
),
!data.web.allowRestart &&
!data.web?.allowRestart &&
h('p', { class: 'muted', text: 'Le redémarrage depuis le site est désactivé (`WEB_ALLOW_RESTART`).' }),
);
}
function referenceCard(data) {
const reference = data.reference ?? {};
return card(
'Référence',
{ advanced: true, subtitle: 'Ce que le bot connaît, pour se repérer.' },
@@ -457,7 +472,7 @@ function referenceCard(data) {
{ label: 'Valeur', className: 'num', key: 'value' },
{ label: 'Libellé Discord', key: 'label' },
],
data.reference.accessLevels,
reference.accessLevels ?? [],
),
h('h3', { text: 'Catégories de tickets' }),
table(
@@ -466,13 +481,13 @@ function referenceCard(data) {
{ label: 'Libellé', key: 'label' },
{ label: 'Visible par', render: (category) => category.scope.join(', ') },
],
data.reference.ticketCategories,
reference.ticketCategories ?? [],
),
h('h3', { text: 'Types de notification' }),
h(
'div',
{ class: 'row' },
data.reference.notificationTypes.map((type) => badge(type, 'info')),
(reference.notificationTypes ?? []).map((type) => badge(type, 'info')),
),
);
}
@@ -503,7 +518,11 @@ export function render(host, { state }) {
}),
),
level >= LEVELS.OWNER &&
h('a', { class: 'btn btn-primary', href: '#/setup', text: 'Assistant de configuration .env' }),
h('a', {
class: 'btn btn-primary',
href: '#/setup',
text: 'Assistant de configuration .env',
}),
),
level >= LEVELS.OWNER &&
+26 -2
View File
@@ -75,7 +75,7 @@ export function createHandler({ client = null, setupOnly = false, startedAt = Da
// The wiki is a separate public page: it must never fall back to the
// dashboard shell, which would send a visitor to a login screen.
const fallback = pathname === '/wiki' || pathname.startsWith('/wiki/') ? 'wiki.html' : 'index.html';
const served = await sendStatic(response, publicDir, pathname, { fallback });
const served = await sendStatic(response, publicDir, pathname, { fallback, request });
if (!served) sendEmpty(response, 404);
return;
}
@@ -143,8 +143,32 @@ export function startWebServer({ client = null, setupOnly = false } = {}) {
server.listen(env.web.port, env.web.host, () => {
const url = env.web.publicUrl || `http://${env.web.host}:${env.web.port}`;
log.info(`Dashboard listening on ${env.web.host}:${env.web.port}`, { url, setupOnly });
// Inside a container, binding a port that is not published succeeds and is
// still unreachable from outside, which looks exactly like a crash from the
// browser. Say it once, here, where the port is known.
if (env.web.host === '0.0.0.0') {
log.info(
`Le tableau de bord écoute sur le port ${env.web.port}. Dans un conteneur ou sur un panel, ` +
'ce port doit aussi faire partie des allocations publiées, sinon il reste injoignable de l’extérieur.',
);
}
});
server.on('error', (error) => {
const causes = {
EADDRINUSE: `le port ${env.web.port} est déjà pris par un autre processus`,
EACCES: `le port ${env.web.port} est interdit à ce processus (port privilégié, ou restreint par l’hôte)`,
EADDRNOTAVAIL: `l’adresse ${env.web.host} n’existe pas sur cette machine`,
};
const cause = causes[error.code] ?? error.message;
log.error(
`Le tableau de bord n'a pas pu démarrer sur ${env.web.host}:${env.web.port} — ${cause}. ` +
'Le bot continue sans le site : corrige `WEB_HOST` ou `WEB_PORT`, puis redémarre.',
error,
);
});
server.on('error', (error) => log.error('Dashboard server error', error));
// Open event streams would otherwise keep the server from closing.
server.on('close', closeEventStreams);
return server;
+17 -2
View File
@@ -101,7 +101,7 @@ export const SECTIONS = Object.freeze([
'Toujours dans **OAuth2 → Redirects**, ajoute exactement l’URL affichée dans **Paramètres → Tableau de bord** : c’est l’adresse par laquelle tu ouvres le site, suivie de `/auth/callback`.',
'Si le site répond sur un port différent de celui annoncé par ton hébergeur, c’est bien le port que tu utilises dans le navigateur qu’il faut déclarer.',
'Génère `WEB_SESSION_SECRET` avec le bouton ci-dessous.',
'Laisse `WEB_HOST` sur `127.0.0.1` et place un reverse proxy HTTPS devant, sauf en développement local.',
'Choisis `WEB_HOST` : `127.0.0.1` derrière un reverse proxy local, `0.0.0.0` dans un conteneur ou sur un panel d’hébergement.',
],
links: [{ label: 'OAuth2 du Developer Portal', url: 'https://discord.com/developers/applications' }],
},
@@ -438,7 +438,7 @@ export const VARIABLES = Object.freeze([
key: 'WEB_HOST',
section: 'web',
label: 'Interface d’écoute',
help: 'Garde `127.0.0.1` et place un reverse proxy HTTPS devant. `0.0.0.0` expose le site sur le réseau.',
help: 'Derrière un reverse proxy installé sur la même machine, garde `127.0.0.1`. Dans un conteneur ou sur un panel d’hébergement (Pterodactyl, Docker…), il faut `0.0.0.0` : sinon le site n’écoute que sur la boucle locale et reste injoignable de l’extérieur.',
type: 'text',
default: '127.0.0.1',
restartRequired: true,
@@ -711,6 +711,21 @@ export function crossCheck(values) {
if (!read('WEB_SESSION_SECRET')) {
warnings.push('Sans `WEB_SESSION_SECRET`, toutes les sessions sont perdues à chaque redémarrage.');
}
const publicHost = (() => {
try {
return new URL(read('WEB_PUBLIC_URL')).hostname;
} catch {
return '';
}
})();
const localOnly = ['127.0.0.1', 'localhost', '::1'];
if (read('WEB_HOST') === '127.0.0.1' && publicHost && !localOnly.includes(publicHost)) {
warnings.push(
`\`WEB_HOST=127.0.0.1\` n'écoute que sur la boucle locale, alors que le site est annoncé sur « ${publicHost} » : il sera injoignable, sauf si un reverse proxy tourne sur la même machine. Dans un conteneur ou sur un panel d'hébergement, mets \`0.0.0.0\`.`,
);
}
if (read('WEB_HOST') === '0.0.0.0' && !read('WEB_PUBLIC_URL').startsWith('https://')) {
warnings.push('`WEB_HOST=0.0.0.0` sans HTTPS expose les cookies de session en clair sur le réseau.');
}
+24
View File
@@ -88,6 +88,30 @@ describe('env schema', () => {
assert.ok(warnings.some((warning) => warning.includes('rejetés')));
});
it('warns when a public address is announced but only loopback is bound', () => {
// The failure it prevents: the site answers on the loopback while a domain
// points at it, so every request times out and nothing says why.
const warnings = crossCheck({
WEB_ENABLED: 'true',
WEB_HOST: '127.0.0.1',
WEB_PUBLIC_URL: 'https://bot.example.org',
DISCORD_CLIENT_SECRET: 'x',
WEB_SESSION_SECRET: 'y',
});
assert.ok(warnings.some((warning) => warning.includes('boucle locale')));
});
it('stays quiet when the loopback matches the announced address', () => {
const warnings = crossCheck({
WEB_ENABLED: 'true',
WEB_HOST: '127.0.0.1',
WEB_PUBLIC_URL: 'http://localhost:3080',
DISCORD_CLIENT_SECRET: 'x',
WEB_SESSION_SECRET: 'y',
});
assert.ok(!warnings.some((warning) => warning.includes('boucle locale')));
});
it('warns when the dashboard is exposed without HTTPS', () => {
const warnings = crossCheck({
WEB_ENABLED: 'true',
+21
View File
@@ -95,6 +95,27 @@ describe('dashboard server', () => {
assert.match(response.headers.get('content-type'), /javascript/);
});
it('gives its assets a validator so a cache can revalidate', async () => {
const response = await app.fetch('/core/dom.js');
assert.ok(response.headers.get('etag'), 'no ETag on a static asset');
assert.ok(response.headers.get('last-modified'), 'no Last-Modified on a static asset');
});
it('answers 304 when the cached copy is still current', async () => {
const first = await app.fetch('/core/dom.js');
const etag = first.headers.get('etag');
const second = await app.fetch('/core/dom.js', { headers: { 'If-None-Match': etag } });
assert.equal(second.status, 304);
assert.equal(await second.text(), '');
});
it('sends the file again when the validator does not match', async () => {
const response = await app.fetch('/core/dom.js', { headers: { 'If-None-Match': '"stale"' } });
assert.equal(response.status, 200);
assert.ok((await response.text()).length > 0);
});
it('sends the security headers on every response', async () => {
const response = await app.fetch('/');
assert.equal(response.headers.get('x-frame-options'), 'DENY');