feat(ui): glass layout, icon actions and new icon set (#21)
CD — Deployment / deploy (push) Successful in 33s

PR automatique de feat/ui-glass-layout-icons vers main.

---------

Co-authored-by: xEsiah <[email protected]>
Reviewed-on: #21
Reviewed-by: Esiah <[email protected]>
Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #21.
This commit is contained in:
Gitea Actions
2026-11-03 22:37:34 +00:00
committed by Esiah
co-authored by Esiah
parent 3542b33c89
commit 82cd712252
79 changed files with 1485 additions and 746 deletions
+2 -1
View File
@@ -19,7 +19,8 @@ CLOUD_DB_DIR=../db
CLOUD_MEDIA_DIR=../media CLOUD_MEDIA_DIR=../media
# --- Session (obligatoire pour toute API) ------------------------------- # --- Session (obligatoire pour toute API) -------------------------------
# Secret de chiffrement des sessions. Obligatoire, 32 caracteres minimum. # Secret qui poivre (HMAC-SHA-256) les jetons de session stockes en base.
# Obligatoire, 32 caracteres minimum. Le changer invalide toutes les sessions.
# Generation : # Generation :
# node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))" # node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"
SESSION_SECRET= SESSION_SECRET=
+1 -1
View File
@@ -32,7 +32,7 @@ L'app répond sur **`http://localhost:8083`** (variable `COHAISE_HTTP_PORT`).
| `COHAISE_DB_PORT` | port MariaDB | `3407` | | `COHAISE_DB_PORT` | port MariaDB | `3407` |
| `CLOUD_DB_USER` / `CLOUD_DB_PASSWORD` | identifiants base | — | | `CLOUD_DB_USER` / `CLOUD_DB_PASSWORD` | identifiants base | — |
| `CLOUD_DB_ROOT_PASSWORD` | root, pour la sauvegarde | — | | `CLOUD_DB_ROOT_PASSWORD` | root, pour la sauvegarde | — |
| `SESSION_SECRET` | signature des sessions, obligatoire | — | | `SESSION_SECRET` | poivre HMAC des sessions, obligatoire | — |
Le démarrage échoue avec la liste exacte des variables manquantes ou mal formées, Le démarrage échoue avec la liste exacte des variables manquantes ou mal formées,
avant l'ouverture d'aucun port. C'est voulu. avant l'ouverture d'aucun port. C'est voulu.
+16 -3
View File
@@ -25,13 +25,13 @@ void startService({
registerAuthRoutes(app, db, config); registerAuthRoutes(app, db, config);
registerAccountRoutes(app, db, config); registerAccountRoutes(app, db, config);
registerChatRoutes(app, db, config); registerChatRoutes(app, db, config);
registerDirectoryRoutes(app, db); registerDirectoryRoutes(app, db, config);
registerFolderRoutes(app, db, config); registerFolderRoutes(app, db, config);
registerFileRoutes(app, db, config); registerFileRoutes(app, db, config);
registerUploadRoutes(app, db, config); registerUploadRoutes(app, db, config);
registerMediaRoutes(app, db); registerMediaRoutes(app, db, config);
registerTrashRoutes(app, db, config); registerTrashRoutes(app, db, config);
registerSearchRoutes(app, db); registerSearchRoutes(app, db, config);
registerAdminRoutes(app, db, config); registerAdminRoutes(app, db, config);
}, },
onReady: async ({ db, config, logger }) => { onReady: async ({ db, config, logger }) => {
@@ -48,5 +48,18 @@ void startService({
logger.error("purge des envois inacheves", { error: String(error) }), logger.error("purge des envois inacheves", { error: String(error) }),
); );
}, 60 * 60 * 1000).unref(); }, 60 * 60 * 1000).unref();
// Sessions expirees et corbeille hors retention : sans ce balayage, elles
// ne disparaissent qu'au redemarrage. Les jetons expires sont deja refuses
// a chaque requete ; il s'agit ici d'eviter une table qui grossit sans fin
// et de faire respecter la retention de la corbeille sans redemarrage.
setInterval(() => {
void purgeExpiredSessions(db).catch((error: unknown) =>
logger.error("purge des sessions expirees", { error: String(error) }),
);
void purgeExpiredTrash(db, config).catch((error: unknown) =>
logger.error("purge de la corbeille", { error: String(error) }),
);
}, 60 * 60 * 1000).unref();
}, },
}); });
+50 -12
View File
@@ -1,4 +1,11 @@
import { createHash, randomBytes, randomUUID, scrypt as scryptCallback, timingSafeEqual } from "node:crypto"; import {
createHash,
createHmac,
randomBytes,
randomUUID,
scrypt as scryptCallback,
timingSafeEqual,
} from "node:crypto";
import { promisify } from "node:util"; import { promisify } from "node:util";
import type { Context, Next } from "hono"; import type { Context, Next } from "hono";
import { getCookie, setCookie, deleteCookie } from "hono/cookie"; import { getCookie, setCookie, deleteCookie } from "hono/cookie";
@@ -48,6 +55,17 @@ export const verifyPassword = async (password: string, stored: string): Promise<
export const sha256 = (value: string): string => createHash("sha256").update(value).digest("hex"); export const sha256 = (value: string): string => createHash("sha256").update(value).digest("hex");
/**
* Empreinte du jeton de session : SHA-256 poivre par SESSION_SECRET.
*
* Sans ce poivre, une ecriture frauduleuse dans `user_sessions` suffirait a
* forger une session : l'attaquant connaitrait le hachage a poser. Le secret
* vit hors de la base, donc une fuite de la base seule ne donne aucune session
* ouvrable.
*/
export const sessionTokenHash = (token: string, secret: string): string =>
createHmac("sha256", secret).update(token).digest("hex");
/** /**
* Portrait de l'utilisateur porte par la session. * Portrait de l'utilisateur porte par la session.
* *
@@ -74,15 +92,17 @@ export interface SessionMeta {
export const SESSION_COOKIE = "cohaise_session"; export const SESSION_COOKIE = "cohaise_session";
/** /**
* Le jeton brut part dans le cookie, son empreinte SHA-256 dans la base. * Le jeton brut part dans le cookie, son empreinte HMAC-SHA-256 (poivree par
* Une copie de la base ne donne donc aucune session ouvrable : il faudrait * SESSION_SECRET) dans la base. Une copie de la base ne donne donc aucune
* en plus la table des cookies, qui n'existe pas. * session ouvrable : il faudrait en plus la table des cookies, qui n'existe pas,
* et le secret, qui vit hors de la base.
*/ */
export const createSession = async ( export const createSession = async (
db: Db, db: Db,
userId: string, userId: string,
meta: SessionMeta, meta: SessionMeta,
ttlHours: number, ttlHours: number,
secret: string,
): Promise<{ token: string; expiresAt: Date }> => { ): Promise<{ token: string; expiresAt: Date }> => {
const token = randomBytes(32).toString("base64url"); const token = randomBytes(32).toString("base64url");
const expiresAt = new Date(Date.now() + ttlHours * 3600_000); const expiresAt = new Date(Date.now() + ttlHours * 3600_000);
@@ -93,7 +113,7 @@ export const createSession = async (
[ [
randomUUID(), randomUUID(),
userId, userId,
sha256(token), sessionTokenHash(token, secret),
meta.ipAddress ?? null, meta.ipAddress ?? null,
meta.userAgent?.slice(0, 255) ?? null, meta.userAgent?.slice(0, 255) ?? null,
expiresAt, expiresAt,
@@ -102,7 +122,11 @@ export const createSession = async (
return { token, expiresAt }; return { token, expiresAt };
}; };
export const resolveSession = async (db: Db, token: string): Promise<SessionUser | null> => { export const resolveSession = async (
db: Db,
token: string,
secret: string,
): Promise<SessionUser | null> => {
const row = await db.one<SessionUser & { last_seen_at: string }>( const row = await db.one<SessionUser & { last_seen_at: string }>(
`SELECT u.id, u.email, u.first_name, u.last_name, `SELECT u.id, u.email, u.first_name, u.last_name,
r.slug AS role_slug, r.name AS role_name, r.slug AS role_slug, r.name AS role_name,
@@ -116,20 +140,20 @@ export const resolveSession = async (db: Db, token: string): Promise<SessionUser
AND s.expires_at > UTC_TIMESTAMP() AND s.expires_at > UTC_TIMESTAMP()
AND u.deleted_at IS NULL AND u.deleted_at IS NULL
AND u.is_active = 1`, AND u.is_active = 1`,
[sha256(token)], [sessionTokenHash(token, secret)],
); );
if (!row) return null; if (!row) return null;
// Etat vu, avec un decalage de 60 s pour ne pas ecrire a chaque requete. // Etat vu, avec un decalage de 60 s pour ne pas ecrire a chaque requete.
await db.exec( await db.exec(
"UPDATE user_sessions SET last_seen_at = UTC_TIMESTAMP() WHERE token_hash = ? AND last_seen_at < UTC_TIMESTAMP(3) - INTERVAL 60 SECOND", "UPDATE user_sessions SET last_seen_at = UTC_TIMESTAMP() WHERE token_hash = ? AND last_seen_at < UTC_TIMESTAMP(3) - INTERVAL 60 SECOND",
[sha256(token)], [sessionTokenHash(token, secret)],
); );
return row; return row;
}; };
export const revokeSession = async (db: Db, token: string): Promise<void> => { export const revokeSession = async (db: Db, token: string, secret: string): Promise<void> => {
await db.exec("UPDATE user_sessions SET revoked_at = UTC_TIMESTAMP() WHERE token_hash = ?", [ await db.exec("UPDATE user_sessions SET revoked_at = UTC_TIMESTAMP() WHERE token_hash = ?", [
sha256(token), sessionTokenHash(token, secret),
]); ]);
}; };
@@ -183,11 +207,11 @@ export interface AuthState {
/** Lit le cookie et attache l'utilisateur, sans exiger qu'il existe. */ /** Lit le cookie et attache l'utilisateur, sans exiger qu'il existe. */
export const attachUser = export const attachUser =
(db: Db) => (db: Db, secret: string) =>
async (context: Context, next: Next): Promise<void> => { async (context: Context, next: Next): Promise<void> => {
const token = getCookie(context, SESSION_COOKIE); const token = getCookie(context, SESSION_COOKIE);
if (token) { if (token) {
const user = await resolveSession(db, token); const user = await resolveSession(db, token, secret);
if (user) { if (user) {
context.set("user", user); context.set("user", user);
context.set("token", token); context.set("token", token);
@@ -198,9 +222,23 @@ export const attachUser =
await next(); await next();
}; };
/**
* Routes encore accessibles lorsqu'un changement de mot de passe est impose :
* lire son profil, changer le mot de passe, se deconnecter. Tout le reste est
* refuse cote serveur, et pas seulement par la redirection du client.
*/
const PASSWORD_CHANGE_ALLOWED = new Set([
"/api/cloud/auth/me",
"/api/cloud/auth/change-password",
"/api/cloud/auth/logout",
]);
export const requireAuth = async (context: Context, next: Next): Promise<void> => { export const requireAuth = async (context: Context, next: Next): Promise<void> => {
const user = context.get("user") as SessionUser | undefined; const user = context.get("user") as SessionUser | undefined;
if (!user) throw AppError.unauthorized(); if (!user) throw AppError.unauthorized();
if (user.must_change_password === 1 && !PASSWORD_CHANGE_ALLOWED.has(context.req.path)) {
throw AppError.forbidden("Vous devez changer votre mot de passe avant de continuer.");
}
await next(); await next();
}; };
+56
View File
@@ -75,6 +75,62 @@ export const clientIp = (context: Context, trustProxy: boolean): string | null =
return address ? address.slice(0, 45) : null; return address ? address.slice(0, 45) : null;
}; };
/** Taille maximale d'un corps JSON. Les envois de fichiers ont leur propre flux borne. */
export const JSON_BODY_MAX_BYTES = 1024 * 1024;
/**
* Lit le corps de la requete en memoire, avec une borne dure sur les octets
* reellement recus. `content-length` est verifie d'abord pour refuser tot, mais
* la lecture bornee est la vraie garantie : un client peut mentir sur l'en-tete
* et envoyer davantage que ce qu'il annonce.
*/
export const readBodyCapped = async (context: Context, maxBytes: number): Promise<Buffer> => {
const declared = Number(context.req.header("content-length") ?? "");
if (Number.isFinite(declared) && declared > maxBytes) {
throw AppError.payloadTooLarge("Corps de requete trop volumineux.");
}
const body = context.req.raw.body;
if (body === null) return Buffer.alloc(0);
const chunks: Uint8Array[] = [];
let received = 0;
const reader = body.getReader();
try {
for (;;) {
const { done, value } = await reader.read();
if (done) break;
received += value.byteLength;
if (received > maxBytes) {
await reader.cancel().catch(() => undefined);
throw AppError.payloadTooLarge("Corps de requete trop volumineux.");
}
chunks.push(value);
}
} finally {
reader.releaseLock();
}
return Buffer.concat(chunks);
};
/**
* Parse le corps JSON avec la meme borne. Un corps absent ou illisible rend
* `null`, comme l'ancien `req.json().catch(() => null)` : les routes continuent
* de repondre par leur validation zod habituelle.
*/
export const readJson = async (
context: Context,
maxBytes = JSON_BODY_MAX_BYTES,
): Promise<unknown> => {
const buffer = await readBodyCapped(context, maxBytes);
if (buffer.byteLength === 0) return null;
try {
return JSON.parse(buffer.toString("utf8")) as unknown;
} catch {
return null;
}
};
/** Dependances remises aux routes metier au montage. */ /** Dependances remises aux routes metier au montage. */
export interface RouteDeps { export interface RouteDeps {
db: Db; db: Db;
+4
View File
@@ -11,6 +11,9 @@ export {
createApp, createApp,
createLogger, createLogger,
clientIp, clientIp,
JSON_BODY_MAX_BYTES,
readBodyCapped,
readJson,
type App, type App,
type AppEnv, type AppEnv,
type AppOptions, type AppOptions,
@@ -29,6 +32,7 @@ export {
purgeExpiredSessions, purgeExpiredSessions,
revokeSession, revokeSession,
SESSION_COOKIE, SESSION_COOKIE,
sessionTokenHash,
setSessionCookie, setSessionCookie,
sha256, sha256,
verifyPassword, verifyPassword,
+12 -1
View File
@@ -48,6 +48,17 @@ export const classify = (mime: string | null): MediaKind => {
export const isImage = (mime: string | null): boolean => export const isImage = (mime: string | null): boolean =>
(mime ?? "").toLowerCase().startsWith("image/"); (mime ?? "").toLowerCase().startsWith("image/");
/**
* Le SVG est une image au sens MIME, mais pas une image sure a decoder :
* librsvg peut resolvere des references externes et son moteur est une surface
* d'attaque supplementaire. Il est deja exclu de l'apercu en ligne ; on ne le
* passe pas non plus a sharp pour la vignette. Le fichier reste telechargeable.
*/
const isRasterImage = (mime: string | null): boolean => {
const value = (mime ?? "").toLowerCase();
return value.startsWith("image/") && value !== "image/svg+xml";
};
export const thumbnailRelativePath = (fileId: string): string => export const thumbnailRelativePath = (fileId: string): string =>
path.posix.join("thumbnails", `${fileId}.webp`); path.posix.join("thumbnails", `${fileId}.webp`);
@@ -99,7 +110,7 @@ export const indexMedia = async (
): Promise<void> => { ): Promise<void> => {
const kind = classify(mimeType); const kind = classify(mimeType);
if (!isImage(mimeType)) { if (!isRasterImage(mimeType)) {
await db.exec( await db.exec(
`INSERT INTO media_metadata (file_id, kind) VALUES (?, ?) `INSERT INTO media_metadata (file_id, kind) VALUES (?, ?)
ON DUPLICATE KEY UPDATE kind = VALUES(kind)`, ON DUPLICATE KEY UPDATE kind = VALUES(kind)`,
+14 -11
View File
@@ -15,8 +15,11 @@ import {
hashPassword, hashPassword,
link, link,
rateLimitKey, rateLimitKey,
readBodyCapped,
readJson,
renderMail, renderMail,
requireAuth, requireAuth,
sessionTokenHash,
sha256, sha256,
verifyPassword, verifyPassword,
type App, type App,
@@ -69,8 +72,8 @@ const emailChangeInput = z.object({
}); });
export const registerAccountRoutes = (app: App, db: Db, config: Config): void => { export const registerAccountRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/account/*", attachUser(db)); app.use("/api/cloud/account/*", attachUser(db, config.SESSION_SECRET));
app.use("/api/cloud/account", attachUser(db)); app.use("/api/cloud/account", attachUser(db, config.SESSION_SECRET));
const mailer = createMailer(config); const mailer = createMailer(config);
const brand = branding(config); const brand = branding(config);
const limiter = createRateLimiter(config.RATE_LIMIT_LOGIN_MAX, config.RATE_LIMIT_LOGIN_WINDOW_MS); const limiter = createRateLimiter(config.RATE_LIMIT_LOGIN_MAX, config.RATE_LIMIT_LOGIN_WINDOW_MS);
@@ -85,7 +88,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
app.patch("/api/cloud/account/profile", requireAuth, async (context) => { app.patch("/api/cloud/account/profile", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
const data = parse(profileInput, await context.req.json().catch(() => null)); const data = parse(profileInput, await readJson(context));
await db.exec("UPDATE users SET first_name = ?, last_name = ? WHERE id = ?", [ await db.exec("UPDATE users SET first_name = ?, last_name = ? WHERE id = ?", [
data.first_name, data.first_name,
data.last_name, data.last_name,
@@ -107,7 +110,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
app.patch("/api/cloud/account/preferences", requireAuth, async (context) => { app.patch("/api/cloud/account/preferences", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
const data = parse(preferencesInput, await context.req.json().catch(() => null)); const data = parse(preferencesInput, await readJson(context));
await db.exec("UPDATE users SET theme = ?, language = ? WHERE id = ?", [ await db.exec("UPDATE users SET theme = ?, language = ? WHERE id = ?", [
data.theme, data.theme,
data.language, data.language,
@@ -118,7 +121,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
app.get("/api/cloud/account/sessions", requireAuth, async (context) => { app.get("/api/cloud/account/sessions", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
const current = sha256(context.get("token") ?? ""); const current = sessionTokenHash(context.get("token") ?? "", config.SESSION_SECRET);
const rows = await db.query<{ const rows = await db.query<{
id: string; id: string;
token_hash: string; token_hash: string;
@@ -160,7 +163,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
app.delete("/api/cloud/account/sessions", requireAuth, async (context) => { app.delete("/api/cloud/account/sessions", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
const current = sha256(context.get("token") ?? ""); const current = sessionTokenHash(context.get("token") ?? "", config.SESSION_SECRET);
await db.exec( await db.exec(
"UPDATE user_sessions SET revoked_at = UTC_TIMESTAMP() WHERE user_id = ? AND token_hash <> ? AND revoked_at IS NULL", "UPDATE user_sessions SET revoked_at = UTC_TIMESTAMP() WHERE user_id = ? AND token_hash <> ? AND revoked_at IS NULL",
[user.id, current], [user.id, current],
@@ -178,7 +181,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
throw AppError.payloadTooLarge("L'image ne doit pas depasser 8 Mo."); throw AppError.payloadTooLarge("L'image ne doit pas depasser 8 Mo.");
} }
const source = Buffer.from(await context.req.arrayBuffer()); const source = await readBodyCapped(context, AVATAR_MAX_BYTES);
let processed: Buffer; let processed: Buffer;
try { try {
processed = await sharp(source, { failOn: "none" }) processed = await sharp(source, { failOn: "none" })
@@ -274,7 +277,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
}); });
app.post("/api/cloud/account/forgot-password", async (context) => { app.post("/api/cloud/account/forgot-password", async (context) => {
const data = parse(forgotInput, await context.req.json().catch(() => null)); const data = parse(forgotInput, await readJson(context));
throttle(context, `forgot:${data.email.toLowerCase()}`); throttle(context, `forgot:${data.email.toLowerCase()}`);
const user = await db.one<{ id: string; email: string }>( const user = await db.one<{ id: string; email: string }>(
@@ -312,7 +315,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
}); });
app.post("/api/cloud/account/reset-password", async (context) => { app.post("/api/cloud/account/reset-password", async (context) => {
const data = parse(resetInput, await context.req.json().catch(() => null)); const data = parse(resetInput, await readJson(context));
throttle(context, "reset"); throttle(context, "reset");
const row = await db.one<{ id: string; user_id: string }>( const row = await db.one<{ id: string; user_id: string }>(
@@ -362,7 +365,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
app.post("/api/cloud/account/email-change", requireAuth, async (context) => { app.post("/api/cloud/account/email-change", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
const data = parse(emailChangeInput, await context.req.json().catch(() => null)); const data = parse(emailChangeInput, await readJson(context));
throttle(context, `email:${user.id}`); throttle(context, `email:${user.id}`);
const row = await db.one<{ password_hash: string }>( const row = await db.one<{ password_hash: string }>(
@@ -419,7 +422,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
app.post("/api/cloud/account/email-change/confirm", async (context) => { app.post("/api/cloud/account/email-change/confirm", async (context) => {
const data = parse( const data = parse(
z.object({ token: z.string().min(10).max(400) }), z.object({ token: z.string().min(10).max(400) }),
await context.req.json().catch(() => null), await readJson(context),
); );
const row = await db.one<{ id: string; user_id: string; new_email: string }>( const row = await db.one<{ id: string; user_id: string; new_email: string }>(
+11 -10
View File
@@ -1,4 +1,4 @@
import { randomUUID } from "node:crypto"; import { randomInt, randomUUID } from "node:crypto";
import { z } from "zod"; import { z } from "zod";
import { import {
AppError, AppError,
@@ -10,6 +10,7 @@ import {
link, link,
renderMail, renderMail,
requireAuth, requireAuth,
readJson,
type App, type App,
type Config, type Config,
type Db, type Db,
@@ -116,10 +117,10 @@ const humanBytes = (bytes: number): string => {
/** Mot de passe aleatoire, lisible a la frappe, sans caractere ambigu. */ /** Mot de passe aleatoire, lisible a la frappe, sans caractere ambigu. */
const generatePasswordValue = (): string => { const generatePasswordValue = (): string => {
const alphabet = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; const alphabet = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
const bytes = new Uint8Array(18); // randomInt borne directement l'intervalle : pas de biais modulo, contrairement
globalThis.crypto.getRandomValues(bytes); // a `octet % longueur` qui favorise les premiers caracteres de l'alphabet.
let out = ""; let out = "";
for (const byte of bytes) out += alphabet[byte % alphabet.length]; for (let index = 0; index < 18; index += 1) out += alphabet[randomInt(alphabet.length)];
return out; return out;
}; };
@@ -208,8 +209,8 @@ const rehomeUserFolders = async (db: Db, userId: string): Promise<{ kept: number
}; };
export const registerAdminRoutes = (app: App, db: Db, config: Config): void => { export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/admin/*", attachUser(db)); app.use("/api/cloud/admin/*", attachUser(db, config.SESSION_SECRET));
app.use("/api/cloud/admin", attachUser(db)); app.use("/api/cloud/admin", attachUser(db, config.SESSION_SECRET));
const mailer = createMailer(config); const mailer = createMailer(config);
const brand = branding(config); const brand = branding(config);
@@ -285,7 +286,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
app.post("/api/cloud/admin/users", requireAuth, async (context) => { app.post("/api/cloud/admin/users", requireAuth, async (context) => {
requireAdmin(context); requireAdmin(context);
const data = parse(createUserSchema, await context.req.json().catch(() => null)); const data = parse(createUserSchema, await readJson(context));
const role = await db.one<{ id: number }>("SELECT id FROM roles WHERE slug = ?", [data.role_slug]); const role = await db.one<{ id: number }>("SELECT id FROM roles WHERE slug = ?", [data.role_slug]);
if (!role) throw AppError.badRequest("Role inconnu."); if (!role) throw AppError.badRequest("Role inconnu.");
@@ -339,7 +340,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
const existing = await db.one<AdminUserRow>(`${SELECT_USER} WHERE u.id = ? AND u.deleted_at IS NULL`, [id]); const existing = await db.one<AdminUserRow>(`${SELECT_USER} WHERE u.id = ? AND u.deleted_at IS NULL`, [id]);
if (!existing) throw AppError.notFound("Compte introuvable."); if (!existing) throw AppError.notFound("Compte introuvable.");
const data = parse(updateUserSchema, await context.req.json().catch(() => null)); const data = parse(updateUserSchema, await readJson(context));
if (data.role_slug !== undefined && data.role_slug !== existing.role_slug) { if (data.role_slug !== undefined && data.role_slug !== existing.role_slug) {
const role = await db.one<{ id: number }>("SELECT id FROM roles WHERE slug = ?", [data.role_slug]); const role = await db.one<{ id: number }>("SELECT id FROM roles WHERE slug = ?", [data.role_slug]);
@@ -465,7 +466,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
app.post("/api/cloud/admin/storage-locations", requireAuth, async (context) => { app.post("/api/cloud/admin/storage-locations", requireAuth, async (context) => {
requireAdmin(context); requireAdmin(context);
const data = parse(createLocationSchema, await context.req.json().catch(() => null)); const data = parse(createLocationSchema, await readJson(context));
if (data.quota_bytes !== undefined && data.quota_bytes !== null) { if (data.quota_bytes !== undefined && data.quota_bytes !== null) {
await assertQuotaFits(data.quota_bytes); await assertQuotaFits(data.quota_bytes);
} }
@@ -488,7 +489,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
requireAdmin(context); requireAdmin(context);
const id = Number(context.req.param("id")); const id = Number(context.req.param("id"));
if (!Number.isInteger(id) || id <= 0) throw AppError.notFound("Emplacement introuvable."); if (!Number.isInteger(id) || id <= 0) throw AppError.notFound("Emplacement introuvable.");
const data = parse(updateLocationSchema, await context.req.json().catch(() => null)); const data = parse(updateLocationSchema, await readJson(context));
const row = await db.one<{ used_bytes: number }>( const row = await db.one<{ used_bytes: number }>(
"SELECT used_bytes FROM storage_locations WHERE id = ? AND deleted_at IS NULL", "SELECT used_bytes FROM storage_locations WHERE id = ? AND deleted_at IS NULL",
+8 -6
View File
@@ -10,10 +10,11 @@ import {
hashPassword, hashPassword,
isHttpsRequest, isHttpsRequest,
rateLimitKey, rateLimitKey,
readJson,
requireAuth, requireAuth,
revokeSession, revokeSession,
sessionTokenHash,
setSessionCookie, setSessionCookie,
sha256,
verifyPassword, verifyPassword,
type App, type App,
type Config, type Config,
@@ -87,7 +88,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
context.header("cache-control", "no-store"); context.header("cache-control", "no-store");
}); });
app.use("/api/cloud/*", attachUser(db)); app.use("/api/cloud/*", attachUser(db, config.SESSION_SECRET));
const limiter = createRateLimiter(config.RATE_LIMIT_LOGIN_MAX, config.RATE_LIMIT_LOGIN_WINDOW_MS); const limiter = createRateLimiter(config.RATE_LIMIT_LOGIN_MAX, config.RATE_LIMIT_LOGIN_WINDOW_MS);
app.post("/api/cloud/auth/login", async (context) => { app.post("/api/cloud/auth/login", async (context) => {
@@ -98,7 +99,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
throw AppError.unprocessable("Trop de tentatives de connexion. Reessayez dans une minute."); throw AppError.unprocessable("Trop de tentatives de connexion. Reessayez dans une minute.");
} }
const parsed = credentials.safeParse(await context.req.json().catch(() => null)); const parsed = credentials.safeParse(await readJson(context));
if (!parsed.success) throw AppError.badRequest("Identifiants invalides."); if (!parsed.success) throw AppError.badRequest("Identifiants invalides.");
const { email, password } = parsed.data; const { email, password } = parsed.data;
@@ -120,6 +121,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
userAgent: context.req.header("user-agent"), userAgent: context.req.header("user-agent"),
}, },
config.SESSION_TTL_HOURS, config.SESSION_TTL_HOURS,
config.SESSION_SECRET,
); );
await db.exec("UPDATE users SET last_login_at = UTC_TIMESTAMP() WHERE id = ?", [row.id]); await db.exec("UPDATE users SET last_login_at = UTC_TIMESTAMP() WHERE id = ?", [row.id]);
@@ -135,7 +137,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
app.post("/api/cloud/auth/logout", requireAuth, async (context) => { app.post("/api/cloud/auth/logout", requireAuth, async (context) => {
const token = context.get("token"); const token = context.get("token");
if (token) await revokeSession(db, token); if (token) await revokeSession(db, token, config.SESSION_SECRET);
clearSessionCookie(context); clearSessionCookie(context);
return context.json({ ok: true }); return context.json({ ok: true });
}); });
@@ -159,7 +161,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
*/ */
app.post("/api/cloud/auth/change-password", requireAuth, async (context) => { app.post("/api/cloud/auth/change-password", requireAuth, async (context) => {
const session = currentUser(context); const session = currentUser(context);
const parsed = changePassword.safeParse(await context.req.json().catch(() => null)); const parsed = changePassword.safeParse(await readJson(context));
if (!parsed.success) { if (!parsed.success) {
throw AppError.badRequest("Le nouveau mot de passe doit contenir au moins 8 caracteres."); throw AppError.badRequest("Le nouveau mot de passe doit contenir au moins 8 caracteres.");
} }
@@ -189,7 +191,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
`UPDATE user_sessions `UPDATE user_sessions
SET revoked_at = UTC_TIMESTAMP() SET revoked_at = UTC_TIMESTAMP()
WHERE user_id = ? AND revoked_at IS NULL AND token_hash <> ?`, WHERE user_id = ? AND revoked_at IS NULL AND token_hash <> ?`,
[session.id, sha256(context.get("token") ?? "")], [session.id, sessionTokenHash(context.get("token") ?? "", config.SESSION_SECRET)],
); );
return context.json({ ok: true }); return context.json({ ok: true });
+3 -2
View File
@@ -3,6 +3,7 @@ import {
AppError, AppError,
createRateLimiter, createRateLimiter,
currentUser, currentUser,
readJson,
requireAuth, requireAuth,
type App, type App,
type Config, type Config,
@@ -258,7 +259,7 @@ export const registerChatRoutes = (app: App, db: Db, config: Config): void => {
if (!limiter.allow(user.id)) { if (!limiter.allow(user.id)) {
throw AppError.unprocessable("Vous envoyez des messages trop rapidement."); throw AppError.unprocessable("Vous envoyez des messages trop rapidement.");
} }
const parsed = sendInput.safeParse(await context.req.json().catch(() => null)); const parsed = sendInput.safeParse(await readJson(context));
if (!parsed.success) { if (!parsed.success) {
throw AppError.badRequest(parsed.error.issues[0]?.message ?? "Message invalide."); throw AppError.badRequest(parsed.error.issues[0]?.message ?? "Message invalide.");
} }
@@ -292,7 +293,7 @@ export const registerChatRoutes = (app: App, db: Db, config: Config): void => {
throw AppError.unprocessable("Vous envoyez des messages trop rapidement."); throw AppError.unprocessable("Vous envoyez des messages trop rapidement.");
} }
const parsed = editInput.safeParse(await context.req.json().catch(() => null)); const parsed = editInput.safeParse(await readJson(context));
if (!parsed.success) { if (!parsed.success) {
throw AppError.badRequest(parsed.error.issues[0]?.message ?? "Message invalide."); throw AppError.badRequest(parsed.error.issues[0]?.message ?? "Message invalide.");
} }
+3 -2
View File
@@ -3,6 +3,7 @@ import {
currentUser, currentUser,
requireAuth, requireAuth,
type App, type App,
type Config,
type Db, type Db,
} from "../lib/index.js"; } from "../lib/index.js";
@@ -11,8 +12,8 @@ import {
* destinataire lors d'un partage. La session courante est exclue : on ne se * destinataire lors d'un partage. La session courante est exclue : on ne se
* partage pas un dossier a soi-meme. Aucune donnee sensible n'est exposee. * partage pas un dossier a soi-meme. Aucune donnee sensible n'est exposee.
*/ */
export const registerDirectoryRoutes = (app: App, db: Db): void => { export const registerDirectoryRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/directory", attachUser(db)); app.use("/api/cloud/directory", attachUser(db, config.SESSION_SECRET));
app.get("/api/cloud/directory", requireAuth, async (context) => { app.get("/api/cloud/directory", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
+5 -4
View File
@@ -8,6 +8,7 @@ import {
currentUser, currentUser,
requireAuth, requireAuth,
requireRole, requireRole,
readJson,
type App, type App,
type Config, type Config,
type Db, type Db,
@@ -206,8 +207,8 @@ const serveFile = ({ absolute, size, mime, disposition, range }: ServeOptions):
}; };
export const registerFileRoutes = (app: App, db: Db, config: Config): void => { export const registerFileRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/files/*", attachUser(db)); app.use("/api/cloud/files/*", attachUser(db, config.SESSION_SECRET));
app.use("/api/cloud/files", attachUser(db)); app.use("/api/cloud/files", attachUser(db, config.SESSION_SECRET));
/** /**
* Depot en un seul passage. Le corps n'est pas un formulaire multipart mais * Depot en un seul passage. Le corps n'est pas un formulaire multipart mais
@@ -589,7 +590,7 @@ export const registerFileRoutes = (app: App, db: Db, config: Config): void => {
(row.folder_id !== null && (await canWriteExplicit(db, user, row.folder_id))); (row.folder_id !== null && (await canWriteExplicit(db, user, row.folder_id)));
if (!permitted) throw AppError.notFound("Fichier introuvable."); if (!permitted) throw AppError.notFound("Fichier introuvable.");
const { name: rawName } = parse(renameInput, await context.req.json().catch(() => null)); const { name: rawName } = parse(renameInput, await readJson(context));
const name = assertName(rawName); const name = assertName(rawName);
try { try {
@@ -624,7 +625,7 @@ export const registerFileRoutes = (app: App, db: Db, config: Config): void => {
(row.folder_id !== null && (await canWriteExplicit(db, user, row.folder_id))); (row.folder_id !== null && (await canWriteExplicit(db, user, row.folder_id)));
if (!canLeave) throw AppError.notFound("Fichier introuvable."); if (!canLeave) throw AppError.notFound("Fichier introuvable.");
const { folderId } = parse(moveInput, await context.req.json().catch(() => null)); const { folderId } = parse(moveInput, await readJson(context));
const destination = folderId ?? null; const destination = folderId ?? null;
if (destination !== null && !(await canWrite(db, user, destination))) { if (destination !== null && !(await canWrite(db, user, destination))) {
+7 -6
View File
@@ -6,6 +6,7 @@ import {
currentUser, currentUser,
requireAuth, requireAuth,
requireRole, requireRole,
readJson,
type App, type App,
type Config, type Config,
type Db, type Db,
@@ -102,8 +103,8 @@ const subtreeIds = async (db: Db, rootId: string): Promise<string[]> => {
}; };
export const registerFolderRoutes = (app: App, db: Db, config: Config): void => { export const registerFolderRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/folders/*", attachUser(db)); app.use("/api/cloud/folders/*", attachUser(db, config.SESSION_SECRET));
app.use("/api/cloud/folders", attachUser(db)); app.use("/api/cloud/folders", attachUser(db, config.SESSION_SECRET));
app.get("/api/cloud/folders", requireAuth, async (context) => { app.get("/api/cloud/folders", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
@@ -149,7 +150,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
const user = currentUser(context); const user = currentUser(context);
const { name: rawName, parentId } = parse( const { name: rawName, parentId } = parse(
createFolder, createFolder,
await context.req.json().catch(() => null), await readJson(context),
); );
const name = assertName(rawName); const name = assertName(rawName);
@@ -222,7 +223,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
if (!existing) throw AppError.notFound("Dossier introuvable."); if (!existing) throw AppError.notFound("Dossier introuvable.");
if (!(await canManageFolder(db, user, id))) throw AppError.notFound("Dossier introuvable."); if (!(await canManageFolder(db, user, id))) throw AppError.notFound("Dossier introuvable.");
const data = parse(updateFolder, await context.req.json().catch(() => null)); const data = parse(updateFolder, await readJson(context));
const name = assertName(data.name); const name = assertName(data.name);
try { try {
@@ -249,7 +250,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
if (existing.is_system === 1) throw AppError.forbidden("Le dossier public ne peut pas etre deplace."); if (existing.is_system === 1) throw AppError.forbidden("Le dossier public ne peut pas etre deplace.");
if (!(await canManageFolder(db, user, id))) throw AppError.notFound("Dossier introuvable."); if (!(await canManageFolder(db, user, id))) throw AppError.notFound("Dossier introuvable.");
const { parentId } = parse(moveFolder, await context.req.json().catch(() => null)); const { parentId } = parse(moveFolder, await readJson(context));
if (parentId !== null && parentId !== undefined) { if (parentId !== null && parentId !== undefined) {
if (!(await canWrite(db, user, parentId))) { if (!(await canWrite(db, user, parentId))) {
@@ -350,7 +351,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
const { email, level, expiresAt } = parse( const { email, level, expiresAt } = parse(
permissionInput, permissionInput,
await context.req.json().catch(() => null), await readJson(context),
); );
const target = await db.one<{ id: string }>( const target = await db.one<{ id: string }>(
+3 -2
View File
@@ -4,6 +4,7 @@ import {
currentUser, currentUser,
requireAuth, requireAuth,
type App, type App,
type Config,
type Db, type Db,
} from "../lib/index.js"; } from "../lib/index.js";
@@ -15,8 +16,8 @@ import {
const KINDS = ["image", "video", "audio", "document", "archive", "other"] as const; const KINDS = ["image", "video", "audio", "document", "archive", "other"] as const;
export const registerMediaRoutes = (app: App, db: Db): void => { export const registerMediaRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/media", attachUser(db)); app.use("/api/cloud/media", attachUser(db, config.SESSION_SECRET));
app.get("/api/cloud/media", requireAuth, async (context) => { app.get("/api/cloud/media", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
+3 -2
View File
@@ -4,6 +4,7 @@ import {
currentUser, currentUser,
requireAuth, requireAuth,
type App, type App,
type Config,
type Db, type Db,
} from "../lib/index.js"; } from "../lib/index.js";
@@ -19,8 +20,8 @@ const escapeLike = (value: string): string =>
const LIMIT = 100; const LIMIT = 100;
export const registerSearchRoutes = (app: App, db: Db): void => { export const registerSearchRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/search", attachUser(db)); app.use("/api/cloud/search", attachUser(db, config.SESSION_SECRET));
app.get("/api/cloud/search", requireAuth, async (context) => { app.get("/api/cloud/search", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
+2 -2
View File
@@ -158,8 +158,8 @@ const publicFolder = (row: TrashFolderRow) => ({
}); });
export const registerTrashRoutes = (app: App, db: Db, config: Config): void => { export const registerTrashRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/trash/*", attachUser(db)); app.use("/api/cloud/trash/*", attachUser(db, config.SESSION_SECRET));
app.use("/api/cloud/trash", attachUser(db)); app.use("/api/cloud/trash", attachUser(db, config.SESSION_SECRET));
app.get("/api/cloud/trash", requireAuth, async (context) => { app.get("/api/cloud/trash", requireAuth, async (context) => {
const user = currentUser(context); const user = currentUser(context);
+4 -3
View File
@@ -8,6 +8,7 @@ import {
currentUser, currentUser,
requireAuth, requireAuth,
requireRole, requireRole,
readJson,
type App, type App,
type Config, type Config,
type Db, type Db,
@@ -143,8 +144,8 @@ const assertNameFree = async (
}; };
export const registerUploadRoutes = (app: App, db: Db, config: Config): void => { export const registerUploadRoutes = (app: App, db: Db, config: Config): void => {
app.use("/api/cloud/uploads/*", attachUser(db)); app.use("/api/cloud/uploads/*", attachUser(db, config.SESSION_SECRET));
app.use("/api/cloud/uploads", attachUser(db)); app.use("/api/cloud/uploads", attachUser(db, config.SESSION_SECRET));
app.post( app.post(
"/api/cloud/uploads", "/api/cloud/uploads",
@@ -152,7 +153,7 @@ export const registerUploadRoutes = (app: App, db: Db, config: Config): void =>
requireRole("admin", "user"), requireRole("admin", "user"),
async (context) => { async (context) => {
const user = currentUser(context); const user = currentUser(context);
const data = parse(createInput, await context.req.json().catch(() => null)); const data = parse(createInput, await readJson(context));
const name = assertName(data.name); const name = assertName(data.name);
const folderId = data.folderId ?? null; const folderId = data.folderId ?? null;
const size = data.size; const size = data.size;
-5
View File
@@ -24,9 +24,6 @@ x-app: &app
x-migrate-build: &migrate-build x-migrate-build: &migrate-build
context: . context: .
dockerfile: docker/Dockerfile.api dockerfile: docker/Dockerfile.api
# Le build utilise le reseau de l'hote : le demon Docker resout parfois un
# DNS mort (routeur), ce qui casse `npm ci` dans le conteneur.
network: host
args: args:
APP_DIR: backend APP_DIR: backend
@@ -37,7 +34,6 @@ services:
context: . context: .
dockerfile: docker/Dockerfile.app dockerfile: docker/Dockerfile.app
target: export target: export
network: host
args: args:
APP_DIR: frontend APP_DIR: frontend
volumes: volumes:
@@ -117,7 +113,6 @@ services:
build: build:
context: . context: .
dockerfile: docker/Dockerfile.api dockerfile: docker/Dockerfile.api
network: host
args: args:
APP_DIR: backend APP_DIR: backend
image: cohaise-cloud-api image: cohaise-cloud-api
+2
View File
@@ -63,6 +63,8 @@ server {
} }
location @spa { location @spa {
include /etc/nginx/snippets/security-headers.conf;
include /etc/nginx/snippets/cache-no-cache.conf;
try_files /index.html =404; try_files /index.html =404;
} }
} }
+4 -2
View File
@@ -68,8 +68,10 @@ Le design system vit dans `frontend/src/ui`.
- **`.env` ≠ `.env.example`** : comparer avant de conclure à un bug de port. - **`.env` ≠ `.env.example`** : comparer avant de conclure à un bug de port.
- **README de paquet périmés** — utiliser ce dossier `docs/`. - **README de paquet périmés** — utiliser ce dossier `docs/`.
- **Build Docker et DNS** : les `build:` passent par `network: host` ; si `npm ci` - **Build Docker et DNS** : les `build:` utilisent le réseau Docker par défaut.
échoue par `EAI_AGAIN`, le résolveur du démon est en cause. `network: host` est évité : Compose 5.6 / Buildx 0.38 refuse alors le build
(`additional privileges requested`), sans transmettre `--allow=network.host`.
Si `npm ci` échoue par `EAI_AGAIN`, corriger le DNS du démon Docker.
- **Limitation de débit active** (applicatif + nginx) : un test en rafale peut - **Limitation de débit active** (applicatif + nginx) : un test en rafale peut
recevoir `419`/`503` côté API ou `503` nginx — ce n'est pas un bug. recevoir `419`/`503` côté API ou `503` nginx — ce n'est pas un bug.
- Après `make up`, vérifier l'ordre : `migrate` doit être `exited (0)` avant que - Après `make up`, vérifier l'ordre : `migrate` doit être `exited (0)` avant que
+2 -1
View File
@@ -44,7 +44,8 @@ app-build (publish.sh, terminé avant nginx)
- `migrate` monte `./backend/migrations:/migrations:ro`. - `migrate` monte `./backend/migrations:/migrations:ro`.
- `api` refuse de démarrer si une migration appliquée a été modifiée (dérive de - `api` refuse de démarrer si une migration appliquée a été modifiée (dérive de
checksum). `onReady` purge les sessions et la corbeille expirées. checksum). `onReady` purge les sessions, la corbeille et les envois inachevés,
puis un balayage horaire reprend ces purges sans redémarrage.
- stockage : `app_data` (volume Docker, HTML), `$CLOUD_DB_DIR` (MariaDB) et - stockage : `app_data` (volume Docker, HTML), `$CLOUD_DB_DIR` (MariaDB) et
`$CLOUD_MEDIA_DIR` (fichiers) en bind mounts hôte. `$CLOUD_MEDIA_DIR` (fichiers) en bind mounts hôte.
+1 -1
View File
@@ -26,7 +26,7 @@ pose problème (`backend/src/lib/config.ts`).
| `CLOUD_DB_DIR` | dossier hôte des données MariaDB | `../db` | | `CLOUD_DB_DIR` | dossier hôte des données MariaDB | `../db` |
| `CLOUD_MEDIA_DIR` | dossier hôte des médias | `../media` | | `CLOUD_MEDIA_DIR` | dossier hôte des médias | `../media` |
| `CLOUD_DB_CONNECTION_LIMIT` | taille du pool | `8` | | `CLOUD_DB_CONNECTION_LIMIT` | taille du pool | `8` |
| `SESSION_SECRET` | **obligatoire**, ≥ 32 car. | — | | `SESSION_SECRET` | **obligatoire**, ≥ 32 car., poivre HMAC des jetons de session | — |
| `SESSION_TTL_HOURS` | durée de session | `336` | | `SESSION_TTL_HOURS` | durée de session | `336` |
| `PUBLIC_ORIGIN` | **obligatoire**, URL absolue servant aux liens courriel | — | | `PUBLIC_ORIGIN` | **obligatoire**, URL absolue servant aux liens courriel | — |
| `CLOUD_CORS_ORIGIN` | origines CORS (vide = CORS off) | vide | | `CLOUD_CORS_ORIGIN` | origines CORS (vide = CORS off) | vide |
+13 -2
View File
@@ -7,10 +7,11 @@
| Mesure | Détail | | Mesure | Détail |
| --- | --- | | --- | --- |
| Mots de passe | `scrypt` natif `node:crypto` (`N=16384, r=8, p=1`, keylen 64, sel 16 o.), comparaison `timingSafeEqual` | | Mots de passe | `scrypt` natif `node:crypto` (`N=16384, r=8, p=1`, keylen 64, sel 16 o.), comparaison `timingSafeEqual` |
| Stockage session | jeton aléatoire 32 o. côté client, **SHA-256** en base | | Stockage session | jeton aléatoire 32 o. côté client, **HMAC-SHA-256 poivré par `SESSION_SECRET`** en base |
| Cookie | `cohaise_session`, `httpOnly`, `SameSite=Lax`, `path=/`, `secure` selon le schéma réel | | Cookie | `cohaise_session`, `httpOnly`, `SameSite=Lax`, `path=/`, `secure` selon le schéma réel |
| Expiration | `SESSION_TTL_HOURS` (336 h) ; `revoked_at`, `is_active`, `deleted_at` vérifiés à chaque résolution | | Expiration | `SESSION_TTL_HOURS` (336 h) ; `revoked_at`, `is_active`, `deleted_at` vérifiés à chaque résolution |
| Révocation | logout, purge au démarrage, **toutes les autres sessions** au changement de mot de passe, gestion des sessions ouvertes depuis le compte | | Révocation | logout, purge au démarrage et **toutes les heures**, **toutes les autres sessions** au changement de mot de passe, gestion des sessions ouvertes depuis le compte |
| Changement imposé | `must_change_password` vérifié dans `requireAuth` : seules `auth/me`, `auth/change-password` et `auth/logout` restent accessibles, la redirection du front n'est qu'un confort |
| Anti-énumération | hash factice pour une adresse inconnue ; les flux « mot de passe oublié » répondent toujours `{ ok: true }` sans révéler l'existence du compte | | Anti-énumération | hash factice pour une adresse inconnue ; les flux « mot de passe oublié » répondent toujours `{ ok: true }` sans révéler l'existence du compte |
| Jetons à usage unique | réinitialisation de mot de passe et changement d'adresse stockés **hachés**, avec expiration | | Jetons à usage unique | réinitialisation de mot de passe et changement d'adresse stockés **hachés**, avec expiration |
| Changement d'adresse | mot de passe actuel exigé, confirmation **à la nouvelle adresse** avant application | | Changement d'adresse | mot de passe actuel exigé, confirmation **à la nouvelle adresse** avant application |
@@ -24,6 +25,14 @@
- **Edge nginx** : zones `limit_req` `login` (15 r/min, burst 5) et `api` - **Edge nginx** : zones `limit_req` `login` (15 r/min, burst 5) et `api`
(60 r/s, burst élevé) — voir `docker/nginx/cloud.conf`. (60 r/s, burst élevé) — voir `docker/nginx/cloud.conf`.
### Limites d'entrée
- Les corps JSON passent par `readJson` : **1 Mio** maximum, lecture bornée
même si `content-length` ment (le flux est coupé au-delà).
- L'avatar passe par `readBodyCapped` : **8 Mio** maximum, même garantie.
- Les envois de fichiers ont leur propre flux borné (`storage.ts`), indépendant
de `client_max_body_size` de nginx.
### Droits d'accès ### Droits d'accès
Calculés **en base à chaque requête**, depuis la session — jamais depuis un Calculés **en base à chaque requête**, depuis la session — jamais depuis un
@@ -84,6 +93,8 @@ aucun HTML utilisateur n'est injecté dans les messages.
une **liste blanche** de types (`image/*` hors `image/svg+xml`, `video/*`, une **liste blanche** de types (`image/*` hors `image/svg+xml`, `video/*`,
`audio/*`, `application/pdf`, `text/plain`) — jamais de HTML/SVG qui `audio/*`, `application/pdf`, `text/plain`) — jamais de HTML/SVG qui
s'exécuterait dans l'origine. Les deux routes gèrent `Range` (206 / 416). s'exécuterait dans l'origine. Les deux routes gèrent `Range` (206 / 416).
- Vignettes : le SVG est aussi exclu du passage à `sharp`/librsvg ; il reste
téléchargeable, mais n'est jamais décodé côté serveur.
## Hors périmètre (assumé) ## Hors périmètre (assumé)
+3 -1
View File
@@ -14,12 +14,14 @@
"react": "^19.3.0", "react": "^19.3.0",
"react-dom": "^19.3.0", "react-dom": "^19.3.0",
"react-router-dom": "^7.18.4", "react-router-dom": "^7.18.4",
"tailwind-merge": "^3.7.0" "tailwind-merge": "^3.7.0",
"three": "^0.187.0"
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/vite": "^4.3.3", "@tailwindcss/vite": "^4.3.3",
"@types/react": "^19.3.0", "@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0", "@types/react-dom": "^19.3.0",
"@types/three": "^0.187.0",
"@vitejs/plugin-react": "^6.1.1", "@vitejs/plugin-react": "^6.1.1",
"tailwindcss": "^4.3.3", "tailwindcss": "^4.3.3",
"typescript": "^7.0.2", "typescript": "^7.0.2",
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

+10 -5
View File
@@ -2,6 +2,7 @@ import { Navigate, Outlet, Route, Routes } from "react-router-dom";
import { Spinner } from "./ui/index.js"; import { Spinner } from "./ui/index.js";
import { useSession } from "./lib/session.js"; import { useSession } from "./lib/session.js";
import { AppShell } from "./components/AppShell.js"; import { AppShell } from "./components/AppShell.js";
import { AuthLayout } from "./components/AuthLayout.js";
import { Login } from "./pages/Login.js"; import { Login } from "./pages/Login.js";
import { ForgotPassword } from "./pages/ForgotPassword.js"; import { ForgotPassword } from "./pages/ForgotPassword.js";
import { ResetPassword } from "./pages/ResetPassword.js"; import { ResetPassword } from "./pages/ResetPassword.js";
@@ -42,13 +43,17 @@ const RequireAdmin = () => {
export const App = () => ( export const App = () => (
<Routes> <Routes>
<Route path="/login" element={<Login />} /> <Route element={<AuthLayout />}>
<Route path="/forgot-password" element={<ForgotPassword />} /> <Route path="/login" element={<Login />} />
<Route path="/reset-password" element={<ResetPassword />} /> <Route path="/forgot-password" element={<ForgotPassword />} />
<Route path="/confirm-email" element={<ConfirmEmail />} /> <Route path="/reset-password" element={<ResetPassword />} />
<Route path="/confirm-email" element={<ConfirmEmail />} />
</Route>
<Route element={<RequireAuth />}> <Route element={<RequireAuth />}>
<Route path="/change-password" element={<ChangePassword />} /> <Route element={<AuthLayout />}>
<Route path="/change-password" element={<ChangePassword />} />
</Route>
<Route element={<RequireReady />}> <Route element={<RequireReady />}>
<Route element={<AppShell />}> <Route element={<AppShell />}>
+76 -37
View File
@@ -1,9 +1,10 @@
import { useState } from "react"; import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
import { NavLink, Outlet } from "react-router-dom"; import { NavLink, Outlet } from "react-router-dom";
import { Button, cn } from "../ui/index.js"; import { cn } from "../ui/index.js";
import { useSession } from "../lib/session.js"; import { useSession } from "../lib/session.js";
import { useI18n } from "../lib/i18n.js"; import { useI18n } from "../lib/i18n.js";
import { Avatar } from "./Avatar.js"; import { Avatar } from "./Avatar.js";
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
import { import {
ActivityIcon, ActivityIcon,
CloseIcon, CloseIcon,
@@ -18,6 +19,7 @@ import {
StarIcon, StarIcon,
TrashIcon, TrashIcon,
} from "./icons.js"; } from "./icons.js";
import { IconAction } from "./IconAction.js";
interface NavItem { interface NavItem {
to: string; to: string;
@@ -49,10 +51,27 @@ const navClass = ({ isActive }: { isActive: boolean }) =>
: "text-muted-foreground hover:bg-surface-hover hover:text-foreground", : "text-muted-foreground hover:bg-surface-hover hover:text-foreground",
); );
type PageHeaderContextValue = {
header: ReactNode | null;
setHeader: (header: ReactNode | null) => void;
};
const PageHeaderContext = createContext<PageHeaderContextValue | null>(null);
export const usePageHeader = (header: ReactNode | null) => {
const ctx = useContext(PageHeaderContext);
useEffect(() => {
if (!ctx) return;
ctx.setHeader(header);
return () => ctx.setHeader(null);
}, [ctx, header]);
};
export const AppShell = () => { export const AppShell = () => {
const { user, logout } = useSession(); const { user, logout } = useSession();
const { t } = useI18n(); const { t } = useI18n();
const [menuOpen, setMenuOpen] = useState(false); const [menuOpen, setMenuOpen] = useState(false);
const [pageHeader, setPageHeader] = useState<ReactNode | null>(null);
if (!user) return null; if (!user) return null;
const isAdmin = user.role_slug === "admin"; const isAdmin = user.role_slug === "admin";
@@ -88,24 +107,12 @@ export const AppShell = () => {
}; };
return ( return (
<div className="flex h-dvh overflow-hidden bg-background"> <PageHeaderContext.Provider value={{ header: pageHeader, setHeader: setPageHeader }}>
<aside className="hidden w-60 shrink-0 flex-col gap-1 overflow-y-auto border-r border-border bg-surface p-3 lg:flex"> <div className="relative grid h-dvh grid-cols-[auto_1fr] grid-rows-[auto_1fr] overflow-hidden bg-background">
<div className="px-1 py-2">{brand}</div> <ColorBendsBackdrop variant="shell" />
{NAV.map(renderLink)}
{isAdmin ? (
<>
<p className="mt-3 px-3 py-1 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
{t("Administration")}
</p>
{ADMIN_NAV.map(renderLink)}
</>
) : null}
<div className="mt-auto pt-3">{renderLink(ACCOUNT_NAV)}</div>
</aside>
<div className="flex min-w-0 flex-1 flex-col"> <header className="relative z-50 col-span-2 row-start-1 border-b border-border/50 bg-surface/70 backdrop-blur-md">
<header className="z-20 shrink-0 border-b border-border bg-surface"> <div className="flex w-full items-center justify-between gap-4 px-4 py-3">
<div className="mx-auto flex w-full max-w-5xl items-center justify-between gap-4 px-4 py-3">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<button <button
type="button" type="button"
@@ -116,7 +123,7 @@ export const AppShell = () => {
> >
{menuOpen ? <CloseIcon className="h-5 w-5" /> : <MenuIcon className="h-5 w-5" />} {menuOpen ? <CloseIcon className="h-5 w-5" /> : <MenuIcon className="h-5 w-5" />}
</button> </button>
<span className="lg:hidden">{brand}</span> {brand}
</div> </div>
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
@@ -135,30 +142,62 @@ export const AppShell = () => {
hasAvatar={user.has_avatar} hasAvatar={user.has_avatar}
avatarUpdatedAt={user.avatar_updated_at} avatarUpdatedAt={user.avatar_updated_at}
/> />
<Button <IconAction
variant="secondary" label={t("Déconnexion")}
size="sm" icon={<LogoutIcon className="h-4 w-4" />}
iconLeading={<LogoutIcon className="h-3.5 w-3.5" />}
onClick={() => void logout()} onClick={() => void logout()}
> />
<span className="hidden sm:inline">{t("Déconnexion")}</span>
</Button>
</div> </div>
</div> </div>
{menuOpen ? (
<nav className="flex flex-col gap-1 border-t border-border px-3 py-2 lg:hidden">
{allNav.map(renderLink)}
</nav>
) : null}
</header> </header>
<div className="min-h-0 flex-1 overflow-y-auto"> <aside className="relative z-40 col-start-1 row-start-2 hidden w-60 flex-col gap-1 overflow-y-auto border-r border-border/50 bg-surface/70 p-3 backdrop-blur-md lg:flex">
<main className="mx-auto w-full max-w-5xl px-4 py-6"> {NAV.map(renderLink)}
<Outlet /> {isAdmin ? (
</main> <>
<p className="mt-3 px-3 py-1 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
{t("Administration")}
</p>
{ADMIN_NAV.map(renderLink)}
</>
) : null}
<div className="mt-auto pt-3">{renderLink(ACCOUNT_NAV)}</div>
</aside>
{menuOpen ? (
<div className="lg:hidden">
<div className="fixed inset-0 z-40 bg-black/50 backdrop-blur-sm" onClick={() => setMenuOpen(false)} aria-hidden="true" />
<nav className="fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-lg transition-transform duration-300 sm:absolute sm:inset-y-0 sm:left-0 sm:w-72 sm:inset-x-auto">
<div className="flex items-center justify-between border-b border-border/50 px-4 py-3">
{brand}
<button
type="button"
className="text-muted-foreground"
aria-label={t("Fermer le menu")}
onClick={() => setMenuOpen(false)}
>
<CloseIcon className="h-5 w-5" />
</button>
</div>
<div className="flex flex-1 flex-col gap-1 overflow-y-auto p-3">
{allNav.map(renderLink)}
</div>
</nav>
</div>
) : null}
<div className="relative z-10 col-start-2 row-start-2 min-h-0 overflow-hidden">
<div className="h-full w-full bg-surface/30 backdrop-blur-lg">
<div className="flex h-full flex-col">
{pageHeader ? <div className="relative z-30 shrink-0">{pageHeader}</div> : null}
<main className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 pb-6 pt-4 [scrollbar-gutter:stable]">
<Outlet />
</main>
</div>
</div>
</div> </div>
</div> </div>
</div> </PageHeaderContext.Provider>
); );
}; };
+20
View File
@@ -0,0 +1,20 @@
import { Outlet } from "react-router-dom";
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
/**
* Coque des ecrans d'authentification : fond carmin animé, puis une colonne
* centree qui contient la page courante. Le degrade garantit la lisibilite des
* cartes et des champs par-dessus le shader, dans les deux themes.
*/
export const AuthLayout = () => (
<main className="relative flex min-h-dvh items-center justify-center overflow-hidden bg-background px-4 py-10">
<ColorBendsBackdrop variant="auth" />
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-gradient-to-b from-background/10 via-background/40 to-background/80 dark:from-background/25 dark:via-background/50 dark:to-background/85"
/>
<div className="relative z-10 flex w-full justify-center">
<Outlet />
</div>
</main>
);
+12
View File
@@ -0,0 +1,12 @@
.color-bends-container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.color-bends-container canvas {
display: block;
width: 100%;
height: 100%;
}
+438
View File
@@ -0,0 +1,438 @@
import { useEffect, useRef, type CSSProperties } from "react";
import {
Clock,
Mesh,
OrthographicCamera,
PlaneGeometry,
Scene,
ShaderMaterial,
SRGBColorSpace,
Vector2,
Vector3,
WebGLRenderer,
type IUniform,
} from "three";
import "./ColorBends.css";
/**
* Fond anime "ColorBends" (React Bits), porte en TypeScript pour le projet.
*
* Le rendu est un shader plein ecran : aucune image, aucun appel reseau. Le
* composant respecte `prefers-reduced-motion` en figeant le shader apres une
* premiere image, et libere le contexte WebGL au demontage.
*/
const MAX_COLORS = 8;
const frag = `
#define MAX_COLORS ${MAX_COLORS}
uniform vec2 uCanvas;
uniform float uTime;
uniform float uSpeed;
uniform vec2 uRot;
uniform int uColorCount;
uniform vec3 uColors[MAX_COLORS];
uniform int uTransparent;
uniform float uScale;
uniform float uFrequency;
uniform float uWarpStrength;
uniform vec2 uPointer;
uniform float uMouseInfluence;
uniform float uParallax;
uniform float uNoise;
uniform int uIterations;
uniform float uIntensity;
uniform float uBandWidth;
varying vec2 vUv;
void main() {
float t = uTime * uSpeed;
vec2 p = vUv * 2.0 - 1.0;
p += uPointer * uParallax * 0.1;
vec2 rp = vec2(p.x * uRot.x - p.y * uRot.y, p.x * uRot.y + p.y * uRot.x);
vec2 q = vec2(rp.x * (uCanvas.x / uCanvas.y), rp.y);
q /= max(uScale, 0.0001);
q /= 0.5 + 0.2 * dot(q, q);
q += 0.2 * cos(t) - 7.56;
vec2 toward = (uPointer - rp);
q += toward * uMouseInfluence * 0.2;
for (int j = 0; j < 5; j++) {
if (j >= uIterations - 1) break;
vec2 rr = sin(1.5 * (q.yx * uFrequency) + 2.0 * cos(q * uFrequency));
q += (rr - q) * 0.15;
}
vec3 col = vec3(0.0);
float a = 1.0;
if (uColorCount > 0) {
vec2 s = q;
vec3 sumCol = vec3(0.0);
float cover = 0.0;
for (int i = 0; i < MAX_COLORS; ++i) {
if (i >= uColorCount) break;
s -= 0.01;
vec2 r = sin(1.5 * (s.yx * uFrequency) + 2.0 * cos(s * uFrequency));
float m0 = length(r + sin(5.0 * r.y * uFrequency - 3.0 * t + float(i)) / 4.0);
float kBelow = clamp(uWarpStrength, 0.0, 1.0);
float kMix = pow(kBelow, 0.3);
float gain = 1.0 + max(uWarpStrength - 1.0, 0.0);
vec2 disp = (r - s) * kBelow;
vec2 warped = s + disp * gain;
float m1 = length(warped + sin(5.0 * warped.y * uFrequency - 3.0 * t + float(i)) / 4.0);
float m = mix(m0, m1, kMix);
float w = 1.0 - exp(-uBandWidth / exp(uBandWidth * m));
sumCol += uColors[i] * w;
cover = max(cover, w);
}
col = clamp(sumCol, 0.0, 1.0);
a = uTransparent > 0 ? cover : 1.0;
} else {
vec2 s = q;
for (int k = 0; k < 3; ++k) {
s -= 0.01;
vec2 r = sin(1.5 * (s.yx * uFrequency) + 2.0 * cos(s * uFrequency));
float m0 = length(r + sin(5.0 * r.y * uFrequency - 3.0 * t + float(k)) / 4.0);
float kBelow = clamp(uWarpStrength, 0.0, 1.0);
float kMix = pow(kBelow, 0.3);
float gain = 1.0 + max(uWarpStrength - 1.0, 0.0);
vec2 disp = (r - s) * kBelow;
vec2 warped = s + disp * gain;
float m1 = length(warped + sin(5.0 * warped.y * uFrequency - 3.0 * t + float(k)) / 4.0);
float m = mix(m0, m1, kMix);
col[k] = 1.0 - exp(-uBandWidth / exp(uBandWidth * m));
}
a = uTransparent > 0 ? max(max(col.r, col.g), col.b) : 1.0;
}
col *= uIntensity;
if (uNoise > 0.0001) {
float n = fract(sin(dot(gl_FragCoord.xy + vec2(uTime), vec2(12.9898, 78.233))) * 43758.5453123);
col += (n - 0.5) * uNoise;
col = clamp(col, 0.0, 1.0);
}
vec3 rgb = (uTransparent > 0) ? col * a : col;
gl_FragColor = vec4(rgb, a);
}
`;
const vert = `
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = vec4(position, 1.0);
}
`;
export interface ColorBendsProps {
className?: string;
style?: CSSProperties;
rotation?: number;
speed?: number;
colors?: string[];
transparent?: boolean;
autoRotate?: number;
scale?: number;
frequency?: number;
warpStrength?: number;
mouseInfluence?: number;
parallax?: number;
noise?: number;
iterations?: number;
intensity?: number;
bandWidth?: number;
}
interface ColorBendsUniforms {
uCanvas: IUniform<Vector2>;
uTime: IUniform<number>;
uSpeed: IUniform<number>;
uRot: IUniform<Vector2>;
uColorCount: IUniform<number>;
uColors: IUniform<Vector3[]>;
uTransparent: IUniform<number>;
uScale: IUniform<number>;
uFrequency: IUniform<number>;
uWarpStrength: IUniform<number>;
uPointer: IUniform<Vector2>;
uMouseInfluence: IUniform<number>;
uParallax: IUniform<number>;
uNoise: IUniform<number>;
uIterations: IUniform<number>;
uIntensity: IUniform<number>;
uBandWidth: IUniform<number>;
}
const toVec3 = (hex: string): Vector3 => {
const value = hex.replace("#", "").trim();
const channels =
value.length === 3
? [
parseInt(value.slice(0, 1).repeat(2), 16),
parseInt(value.slice(1, 2).repeat(2), 16),
parseInt(value.slice(2, 3).repeat(2), 16),
]
: [
parseInt(value.slice(0, 2), 16),
parseInt(value.slice(2, 4), 16),
parseInt(value.slice(4, 6), 16),
];
return new Vector3(channels[0]! / 255, channels[1]! / 255, channels[2]! / 255);
};
export default function ColorBends({
className,
style,
rotation = 90,
speed = 0.2,
colors = [],
transparent = true,
autoRotate = 0,
scale = 1,
frequency = 1,
warpStrength = 1,
mouseInfluence = 1,
parallax = 0.5,
noise = 0.15,
iterations = 1,
intensity = 1.5,
bandWidth = 6,
}: ColorBendsProps) {
const containerRef = useRef<HTMLDivElement>(null);
const rendererRef = useRef<WebGLRenderer | null>(null);
const rafRef = useRef<number | null>(null);
const renderOnceRef = useRef<(() => void) | null>(null);
const materialRef = useRef<ShaderMaterial | null>(null);
const resizeObserverRef = useRef<ResizeObserver | null>(null);
const rotationRef = useRef(rotation);
const autoRotateRef = useRef(autoRotate);
const pointerTargetRef = useRef(new Vector2(0, 0));
const pointerCurrentRef = useRef(new Vector2(0, 0));
const pointerSmoothRef = useRef(8);
useEffect(() => {
const container = containerRef.current;
if (!container) return;
let renderer: WebGLRenderer;
try {
renderer = new WebGLRenderer({
antialias: false,
powerPreference: "high-performance",
alpha: true,
});
} catch {
// Pas de WebGL (navigateur ancien, materiel bloque) : le fond reste
// simplement absent, l'ecran et le formulaire continuent de fonctionner.
return;
}
const scene = new Scene();
const camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
const geometry = new PlaneGeometry(2, 2);
const uColors = Array.from({ length: MAX_COLORS }, () => new Vector3(0, 0, 0));
const material = new ShaderMaterial({
vertexShader: vert,
fragmentShader: frag,
uniforms: {
uCanvas: { value: new Vector2(1, 1) },
uTime: { value: 0 },
uSpeed: { value: speed },
uRot: { value: new Vector2(1, 0) },
uColorCount: { value: 0 },
uColors: { value: uColors },
uTransparent: { value: transparent ? 1 : 0 },
uScale: { value: scale },
uFrequency: { value: frequency },
uWarpStrength: { value: warpStrength },
uPointer: { value: new Vector2(0, 0) },
uMouseInfluence: { value: mouseInfluence },
uParallax: { value: parallax },
uNoise: { value: noise },
uIterations: { value: iterations },
uIntensity: { value: intensity },
uBandWidth: { value: bandWidth },
} satisfies ColorBendsUniforms,
premultipliedAlpha: true,
transparent: true,
});
materialRef.current = material;
const mesh = new Mesh(geometry, material);
scene.add(mesh);
rendererRef.current = renderer;
renderer.outputColorSpace = SRGBColorSpace;
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setClearColor(0x000000, transparent ? 0 : 1);
renderer.domElement.style.width = "100%";
renderer.domElement.style.height = "100%";
renderer.domElement.style.display = "block";
container.appendChild(renderer.domElement);
const clock = new Clock();
const motion = window.matchMedia("(prefers-reduced-motion: reduce)");
let reducedMotion = motion.matches;
const handleResize = () => {
const width = container.clientWidth || 1;
const height = container.clientHeight || 1;
renderer.setSize(width, height, false);
material.uniforms.uCanvas!.value.set(width, height);
if (reducedMotion) renderer.render(scene, camera);
};
const renderFrame = () => {
const delta = clock.getDelta();
const elapsed = clock.elapsedTime;
material.uniforms.uTime!.value = elapsed;
const degrees = (rotationRef.current % 360) + autoRotateRef.current * elapsed;
const radians = (degrees * Math.PI) / 180;
material.uniforms.uRot!.value.set(Math.cos(radians), Math.sin(radians));
const current = pointerCurrentRef.current;
current.lerp(pointerTargetRef.current, Math.min(1, delta * pointerSmoothRef.current));
material.uniforms.uPointer!.value.copy(current);
renderer.render(scene, camera);
};
renderOnceRef.current = renderFrame;
const stop = () => {
if (rafRef.current !== null) {
cancelAnimationFrame(rafRef.current);
rafRef.current = null;
}
};
const loop = () => {
renderFrame();
rafRef.current = requestAnimationFrame(loop);
};
const start = () => {
if (!reducedMotion && rafRef.current === null) {
clock.start();
rafRef.current = requestAnimationFrame(loop);
}
};
handleResize();
if (typeof ResizeObserver !== "undefined") {
const observer = new ResizeObserver(handleResize);
observer.observe(container);
resizeObserverRef.current = observer;
} else {
window.addEventListener("resize", handleResize);
}
const handleMotionChange = () => {
reducedMotion = motion.matches;
if (reducedMotion) {
stop();
renderFrame();
} else {
start();
}
};
motion.addEventListener("change", handleMotionChange);
if (reducedMotion) renderFrame();
else start();
return () => {
stop();
motion.removeEventListener("change", handleMotionChange);
if (resizeObserverRef.current) resizeObserverRef.current.disconnect();
else window.removeEventListener("resize", handleResize);
geometry.dispose();
material.dispose();
renderer.dispose();
renderer.forceContextLoss();
if (renderer.domElement.parentElement === container) {
container.removeChild(renderer.domElement);
}
materialRef.current = null;
rendererRef.current = null;
renderOnceRef.current = null;
resizeObserverRef.current = null;
};
// Les uniformes sont mis a jour par l'effet suivant ; ce premier montage ne
// depend donc que du conteneur et ne recree jamais le contexte WebGL.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
const material = materialRef.current;
if (!material) return;
rotationRef.current = rotation;
autoRotateRef.current = autoRotate;
material.uniforms.uSpeed!.value = speed;
material.uniforms.uScale!.value = scale;
material.uniforms.uFrequency!.value = frequency;
material.uniforms.uWarpStrength!.value = warpStrength;
material.uniforms.uMouseInfluence!.value = mouseInfluence;
material.uniforms.uParallax!.value = parallax;
material.uniforms.uNoise!.value = noise;
material.uniforms.uIterations!.value = iterations;
material.uniforms.uIntensity!.value = intensity;
material.uniforms.uBandWidth!.value = bandWidth;
const parsed = colors.filter(Boolean).slice(0, MAX_COLORS).map(toVec3);
const target = material.uniforms.uColors!.value as Vector3[];
for (let index = 0; index < MAX_COLORS; index += 1) {
const vector = target[index]!;
if (index < parsed.length) vector.copy(parsed[index]!);
else vector.set(0, 0, 0);
}
material.uniforms.uColorCount!.value = parsed.length;
material.uniforms.uTransparent!.value = transparent ? 1 : 0;
if (rendererRef.current) rendererRef.current.setClearColor(0x000000, transparent ? 0 : 1);
// Sans boucle (prefers-reduced-motion), les uniformes viennent de changer :
// il faut une image de plus pour que la palette soit réellement appliquée.
if (rafRef.current === null) renderOnceRef.current?.();
}, [
rotation,
autoRotate,
speed,
scale,
frequency,
warpStrength,
mouseInfluence,
parallax,
noise,
iterations,
intensity,
bandWidth,
colors,
transparent,
]);
useEffect(() => {
const container = containerRef.current;
if (!container) return;
const handlePointerMove = (event: PointerEvent) => {
const rect = container.getBoundingClientRect();
const x = ((event.clientX - rect.left) / (rect.width || 1)) * 2 - 1;
const y = -(((event.clientY - rect.top) / (rect.height || 1)) * 2 - 1);
pointerTargetRef.current.set(x, y);
};
// Ecoute au niveau de la fenetre : le fond peut etre recouvert par la
// coque ou par une carte, et doit reagir quand meme au mouvement.
window.addEventListener("pointermove", handlePointerMove, { passive: true });
return () => {
window.removeEventListener("pointermove", handlePointerMove);
};
}, []);
return <div ref={containerRef} className={`color-bends-container ${className ?? ""}`} style={style} />;
}
@@ -0,0 +1,86 @@
import { lazy, Suspense } from "react";
import { COHAISE_BENDS } from "./colorBendsPalette.js";
import type { ColorBendsProps } from "./ColorBends.js";
const ColorBends = lazy(() => import("./ColorBends.js"));
type BackdropVariant = "auth" | "shell" | "chat";
type BackdropPreset = Omit<ColorBendsProps, "colors" | "transparent" | "className"> & {
className: string;
};
/**
* Fond carmin partage par les ecrans d'authentification, la coque connectee
* et le salon de discussion. Le composant WebGL reste charge a la demande :
* seuls les presets sont dans le bundle initial.
*/
const PRESETS: Record<BackdropVariant, BackdropPreset> = {
auth: {
className: "opacity-[0.55] dark:opacity-[0.7]",
rotation: 90,
speed: 0.18,
scale: 1,
frequency: 1,
warpStrength: 1,
mouseInfluence: 0.6,
parallax: 0.4,
noise: 0.08,
iterations: 2,
intensity: 1.15,
bandWidth: 5,
},
shell: {
className: "opacity-[0.85] dark:opacity-[0.9]",
rotation: 90,
speed: 0.18,
scale: 1,
frequency: 1,
warpStrength: 1,
mouseInfluence: 0.6,
parallax: 0.4,
noise: 0.08,
iterations: 2,
intensity: 1.3,
bandWidth: 5,
},
chat: {
className: "opacity-[0.3] dark:opacity-[0.42]",
rotation: 90,
speed: 0.1,
scale: 1.05,
frequency: 0.95,
warpStrength: 0.9,
mouseInfluence: 0.3,
parallax: 0.25,
noise: 0.05,
iterations: 1,
intensity: 0.8,
bandWidth: 4.5,
},
};
export const ColorBendsBackdrop = ({
variant,
className,
}: {
variant: BackdropVariant;
className?: string;
}) => {
const { className: presetClassName, ...preset } = PRESETS[variant];
return (
<div
aria-hidden="true"
className={`pointer-events-none absolute inset-0 z-0 ${className ?? ""}`}
>
<Suspense fallback={null}>
<ColorBends
{...preset}
colors={COHAISE_BENDS}
transparent
className={presetClassName}
/>
</Suspense>
</div>
);
};
+13 -11
View File
@@ -21,6 +21,7 @@ import { getLocale } from "../lib/locale.js";
import { useSession } from "../lib/session.js"; import { useSession } from "../lib/session.js";
import { useConfirm } from "./confirm.js"; import { useConfirm } from "./confirm.js";
import { Avatar } from "./Avatar.js"; import { Avatar } from "./Avatar.js";
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
import { IconAction } from "./IconAction.js"; import { IconAction } from "./IconAction.js";
import { Alert, Badge, EmptyState } from "./feedback.js"; import { Alert, Badge, EmptyState } from "./feedback.js";
import { import {
@@ -359,8 +360,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
); );
return ( return (
<div className="fixed inset-0 z-40 flex flex-col bg-background"> <div className="fixed inset-0 z-40 flex flex-col overflow-hidden bg-background">
<div className="relative flex h-full min-h-0"> <ColorBendsBackdrop variant="chat" />
<div className="relative z-10 flex h-full min-h-0">
<aside <aside
className={cn( className={cn(
"absolute inset-y-0 left-0 z-20 flex w-64 flex-col border-r border-border bg-surface transition-transform md:static md:z-auto md:translate-x-0", "absolute inset-y-0 left-0 z-20 flex w-64 flex-col border-r border-border bg-surface transition-transform md:static md:z-auto md:translate-x-0",
@@ -437,7 +439,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
type="button" type="button"
onClick={onClose} onClick={onClose}
aria-label={t("Fermer la discussion")} aria-label={t("Fermer la discussion")}
className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none" className="rounded-md p-1 text-muted-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
> >
<CloseIcon className="h-5 w-5" /> <CloseIcon className="h-5 w-5" />
</button> </button>
@@ -672,15 +674,15 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
aria-label={t("Votre message")} aria-label={t("Votre message")}
className="max-h-40 min-h-[2.5rem] flex-1 resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground placeholder:text-subtle-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none" className="max-h-40 min-h-[2.5rem] flex-1 resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground placeholder:text-subtle-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
/> />
<Button <IconAction
type="submit" label={t("Envoyer")}
size="md" icon={<SendIcon className="h-4 w-4" />}
isLoading={sending} isLoading={sending}
disabled={draft.trim().length === 0} onClick={(event) => {
iconLeading={<SendIcon className="h-4 w-4" />} event.preventDefault();
> void send(event as any);
<span className="hidden sm:inline">{t("Envoyer")}</span> }}
</Button> />
</form> </form>
</section> </section>
</div> </div>
+2 -2
View File
@@ -23,8 +23,8 @@ export const IconAction = ({
disabled={isLoading} disabled={isLoading}
onClick={onClick} onClick={onClick}
className={cn( className={cn(
"relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors", "group relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-all",
"hover:bg-surface-hover hover:text-foreground disabled:pointer-events-none disabled:opacity-50", "hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm backdrop-blur-sm disabled:pointer-events-none disabled:opacity-50",
tone === "danger" && "hover:text-destructive", tone === "danger" && "hover:text-destructive",
)} )}
> >
@@ -0,0 +1,2 @@
/** Palette carmin de la marque, alignee sur `tokens.css`. */
export const COHAISE_BENDS = ["#b71c1c", "#c92a2a", "#8f1116", "#5e0a14"];
+32 -15
View File
@@ -10,7 +10,8 @@ import {
} from "../lib/api.js"; } from "../lib/api.js";
import { useI18n } from "../lib/i18n.js"; import { useI18n } from "../lib/i18n.js";
import { Alert, Modal } from "./feedback.js"; import { Alert, Modal } from "./feedback.js";
import { TrashIcon } from "./icons.js"; import { PlusIcon, TrashIcon } from "./icons.js";
import { IconAction } from "./IconAction.js";
const LEVELS = ["read", "write", "admin"] as const; const LEVELS = ["read", "write", "admin"] as const;
const LEVEL_LABEL: Record<string, string> = { const LEVEL_LABEL: Record<string, string> = {
@@ -69,13 +70,21 @@ export const CreateFolderDialog = ({
onChange={(event) => setName(event.target.value)} onChange={(event) => setName(event.target.value)}
/> />
{error ? <Alert>{error}</Alert> : null} {error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end gap-2"> <div className="flex justify-end gap-1">
<Button variant="ghost" size="md" onClick={onClose}> <IconAction
{t("Annuler")} label={t("Annuler")}
</Button> icon={<img src="/icons/close.png" alt="" className="h-4 w-4 object-contain" />}
<Button type="submit" size="md" isLoading={busy}> onClick={onClose}
{t("Créer")} />
</Button> <IconAction
label={t("Créer")}
icon={<PlusIcon className="h-4 w-4" />}
isLoading={busy}
onClick={(e) => {
e.preventDefault();
void submit(e as any);
}}
/>
</div> </div>
</form> </form>
</Modal> </Modal>
@@ -234,13 +243,21 @@ export const MoveDialog = ({
</label> </label>
)} )}
{error ? <Alert>{error}</Alert> : null} {error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end gap-2"> <div className="flex justify-end gap-1">
<Button variant="ghost" size="md" onClick={onClose}> <IconAction
{t("Annuler")} label={t("Annuler")}
</Button> icon={<img src="/icons/close.png" alt="" className="h-4 w-4 object-contain" />}
<Button type="submit" size="md" isLoading={busy} disabled={entries === null}> onClick={onClose}
{t("Déplacer")} />
</Button> <IconAction
label={t("Déplacer")}
icon={<img src="/icons/move.png" alt="" className="h-4 w-4 object-contain" />}
isLoading={busy}
onClick={(e) => {
e.preventDefault();
void submit(e as any);
}}
/>
</div> </div>
</form> </form>
</Modal> </Modal>
+26 -18
View File
@@ -1,7 +1,8 @@
import { useEffect, type ReactNode } from "react"; import { useEffect, useMemo, type ReactNode } from "react";
import { cn } from "../ui/index.js"; import { cn } from "../ui/index.js";
import { useI18n } from "../lib/i18n.js"; import { useI18n } from "../lib/i18n.js";
import { CloseIcon } from "./icons.js"; import { CloseIcon } from "./icons.js";
import { usePageHeader } from "./AppShell.js";
export const Modal = ({ export const Modal = ({
open, open,
@@ -52,7 +53,7 @@ export const Modal = ({
type="button" type="button"
onClick={onClose} onClick={onClose}
aria-label={t("Fermer")} aria-label={t("Fermer")}
className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none" className="rounded-md p-1 text-muted-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
> >
<CloseIcon className="h-5 w-5" /> <CloseIcon className="h-5 w-5" />
</button> </button>
@@ -97,22 +98,29 @@ export const PageHeader = ({
description?: string; description?: string;
actions?: ReactNode; actions?: ReactNode;
toolbar?: ReactNode; toolbar?: ReactNode;
}) => ( }) => {
<header className="sticky top-0 z-10 -mx-4 flex flex-col gap-3 border-b border-border bg-background px-4 py-4"> const header = useMemo(
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between"> () => (
<div> <header className="flex flex-col gap-3 border-b border-border/50 bg-surface/70 px-4 py-4 backdrop-blur-md">
<h1 className="font-display text-base font-semibold uppercase tracking-label text-foreground"> <div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
{title} <div>
</h1> <h1 className="font-display text-base font-semibold uppercase tracking-label text-foreground">
{description ? ( {title}
<p className="mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground">{description}</p> </h1>
) : null} {description ? (
</div> <p className="mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground">{description}</p>
{actions ? <div className="flex flex-wrap items-center gap-2">{actions}</div> : null} ) : null}
</div> </div>
{toolbar ? <div className="flex flex-col gap-3">{toolbar}</div> : null} {actions ? <div className="flex flex-wrap items-center gap-2">{actions}</div> : null}
</header> </div>
); {toolbar ? <div className="flex flex-col gap-3">{toolbar}</div> : null}
</header>
),
[title, description, actions, toolbar],
);
usePageHeader(header);
return null;
};
export const EmptyState = ({ export const EmptyState = ({
icon, icon,
+53 -126
View File
@@ -1,221 +1,148 @@
import type { SVGProps } from "react"; import type { ImgHTMLAttributes } from "react";
type IconProps = SVGProps<SVGSVGElement>; type IconProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt"> & {
filled?: boolean;
};
const base = (props: IconProps) => ({ const ImgIcon = ({
viewBox: "0 0 24 24", src,
fill: "none", className = "",
stroke: "currentColor", ...props
strokeWidth: 1.6, }: { src: string } & IconProps) => (
strokeLinecap: "round" as const, <img
strokeLinejoin: "round" as const, src={src}
"aria-hidden": true, alt=""
...props, aria-hidden="true"
}); className={`inline-block h-4 w-4 object-contain ${className}`}
{...props}
/>
);
export const FolderIcon = (props: IconProps) => ( export const FolderIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/folder.png" {...props} />
<path d="M3 7.5A1.5 1.5 0 0 1 4.5 6h4l2 2.5h7A1.5 1.5 0 0 1 19 10v7.5A1.5 1.5 0 0 1 17.5 19h-13A1.5 1.5 0 0 1 3 17.5Z" />
</svg>
); );
export const FileIcon = (props: IconProps) => ( export const FileIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/document.png" {...props} />
<path d="M6 3.5h7l5 5v12A1.5 1.5 0 0 1 16.5 22h-10A1.5 1.5 0 0 1 5 20.5v-16A1.5 1.5 0 0 1 6 3Z" />
<path d="M13 3.5v5h5" />
</svg>
); );
export const ImageIcon = (props: IconProps) => ( export const ImageIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/picture.png" {...props} />
<rect x="3" y="4" width="18" height="16" rx="2" />
<circle cx="8.5" cy="9.5" r="1.5" />
<path d="m4 17 4.5-4.5a1.5 1.5 0 0 1 2.1 0L15 17m1.5-2 1.2-1.2a1.5 1.5 0 0 1 2.1 0L21 15" />
</svg>
); );
export const PlayIcon = (props: IconProps) => ( export const PlayIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/file.png" {...props} />
<path d="M8 5.5v13l11-6.5Z" fill="currentColor" stroke="none" />
</svg>
); );
export const AudioIcon = (props: IconProps) => ( export const AudioIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/file.png" {...props} />
<path d="M9 17V5l10-2v12" />
<circle cx="6.5" cy="17.5" r="2.5" />
<circle cx="16.5" cy="15.5" r="2.5" />
</svg>
); );
export const ArchiveIcon = (props: IconProps) => ( export const ArchiveIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/folder.png" {...props} />
<path d="M3 7.5A1.5 1.5 0 0 1 4.5 6h4l2 2.5h7A1.5 1.5 0 0 1 19 10v7.5A1.5 1.5 0 0 1 17.5 19h-13A1.5 1.5 0 0 1 3 17.5Z" />
<path d="M11 11.5h2m-2 3h2m-2 3h2" />
</svg>
); );
export const UploadIcon = (props: IconProps) => ( export const UploadIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/upload.png" {...props} />
<path d="M12 16V4m0 0L7.5 8.5M12 4l4.5 4.5M4 17v1.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V17" />
</svg>
); );
export const DownloadIcon = (props: IconProps) => ( export const DownloadIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/download.png" {...props} />
<path d="M12 4v12m0 0-4.5-4.5M12 16l4.5-4.5M4 17v1.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V17" />
</svg>
); );
export const PlusIcon = (props: IconProps) => ( export const PlusIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/plus.png" {...props} />
<path d="M12 5v14M5 12h14" />
</svg>
); );
export const TrashIcon = (props: IconProps) => ( export const TrashIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/trash-can.png" {...props} />
<path d="M4 7h16M9 7V5.5A1.5 1.5 0 0 1 10.5 4h3A1.5 1.5 0 0 1 15 5.5V7m-8 0 .7 11.1A1.5 1.5 0 0 0 9.2 19.6h5.6a1.5 1.5 0 0 0 1.5-1.5L17 7" />
</svg>
); );
export const RestoreIcon = (props: IconProps) => ( export const RestoreIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/synchronize.png" {...props} />
<path d="M4 12a8 8 0 1 0 2.3-5.6M4 4v4h4" />
</svg>
); );
export const RefreshIcon = (props: IconProps) => ( export const RefreshIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/synchronize.png" {...props} />
<path d="M20 12a8 8 0 1 1-2.3-5.6M20 4v4h-4" />
</svg>
); );
export const StarIcon = ({ filled, ...props }: IconProps & { filled?: boolean }) => ( export const StarIcon = (props: IconProps) => (
<svg {...base(props)} fill={filled ? "currentColor" : "none"}> <ImgIcon src="/icons/favorite.png" {...props} />
<path d="m12 3.5 2.6 5.3 5.9.9-4.2 4.1 1 5.8L12 20.8l-5.3 2.8 1-5.8L3.5 14l5.9-.9Z" />
</svg>
); );
export const SearchIcon = (props: IconProps) => ( export const SearchIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/search.png" {...props} />
<circle cx="11" cy="11" r="7" />
<path d="m20 20-3.5-3.5" />
</svg>
); );
export const UsersIcon = (props: IconProps) => ( export const UsersIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/accounts.png" {...props} />
<circle cx="9" cy="8" r="3.5" />
<path d="M3.5 20a5.5 5.5 0 0 1 11 0M16 5.5a3 3 0 0 1 0 6M16.5 20a5.5 1.5 0 0 0-2.2-4.3" />
</svg>
); );
export const SettingsIcon = (props: IconProps) => ( export const SettingsIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/personal-settings.png" {...props} />
<circle cx="12" cy="12" r="3" />
<path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2 2 2 0 1 1-4 0 1.7 1.7 0 0 0-2.9-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 2.6 15a2 2 0 1 1 0-4 1.7 1.7 0 0 0 1.2-2.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 9 4.6a2 2 0 1 1 4 0 1.7 1.7 0 0 0 2.9 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0 1.2 2.9 2 2 0 1 1 0 4 1.7 1.7 0 0 0-1.5 1Z" />
</svg>
); );
export const LogoutIcon = (props: IconProps) => ( export const LogoutIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/sign-out.png" {...props} />
<path d="M15 4h2.5A1.5 1.5 0 0 1 19 5.5v13a1.5 1.5 0 0 1-1.5 1.5H15M10 8l-4 4 4 4M6 12h9" />
</svg>
); );
export const ShieldIcon = (props: IconProps) => ( export const ShieldIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/accounts.png" {...props} />
<path d="M12 3 5 6v5c0 4.3 3 8.2 7 9.5 4-1.3 7-5.2 7-9.5V6Z" />
<path d="m9 12 2 2 4-4" />
</svg>
); );
export const HardDriveIcon = (props: IconProps) => ( export const HardDriveIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/storage.png" {...props} />
<rect x="3" y="4" width="18" height="16" rx="2" />
<path d="M3 14h18M7 17h.01M11 17h.01" />
</svg>
); );
export const ActivityIcon = (props: IconProps) => ( export const ActivityIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/activity.png" {...props} />
<path d="M3 12h4l3 8 4-16 3 8h4" />
</svg>
); );
export const SearchNavIcon = (props: IconProps) => ( export const SearchNavIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/search.png" {...props} />
<circle cx="11" cy="11" r="7" />
<path d="m20 20-3.5-3.5" />
</svg>
); );
export const ShareIcon = (props: IconProps) => ( export const ShareIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/share.png" {...props} />
<circle cx="18" cy="5" r="2.5" />
<circle cx="6" cy="12" r="2.5" />
<circle cx="18" cy="19" r="2.5" />
<path d="m8.2 10.8 7.6-4.6M8.2 13.2l7.6 4.6" />
</svg>
); );
export const MenuIcon = (props: IconProps) => ( export const MenuIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/menu.png" {...props} />
<path d="M4 7h16M4 12h16M4 17h16" />
</svg>
); );
export const CloseIcon = (props: IconProps) => ( export const CloseIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/close.png" {...props} />
<path d="M6 6l12 12M18 6 6 18" />
</svg>
); );
export const ArrowLeftIcon = (props: IconProps) => ( export const ArrowLeftIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/back.png" {...props} />
<path d="M19 12H5M11 18l-6-6 6-6" />
</svg>
); );
export const ArrowRightIcon = (props: IconProps) => ( export const ArrowRightIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon
<path d="M5 12h14M13 6l6 6-6 6" /> src="/icons/back.png"
</svg> {...props}
style={{ transform: "rotate(180deg)", ...((props.style as any) || {}) }}
/>
); );
export const PenIcon = (props: IconProps) => ( export const PenIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/edit-pencil.png" {...props} />
<path d="M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17v3Z" />
<path d="m13.5 6.5 3 3" />
</svg>
); );
/** Epingle : tete du pushpin en haut, pointe en bas. */ /** Epingle : tete du pushpin en haut, pointe en bas. */
export const PinIcon = (props: IconProps) => ( export const PinIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/file.png" {...props} />
<path d="M9 3.5h6l-.8 5.2 3.3 3.1H6.5l3.3-3.1Z" />
<path d="M12 11.8V20.5" />
</svg>
); );
export const MoveIcon = (props: IconProps) => ( export const MoveIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/synchronize.png" {...props} />
<path d="M12 4v16M4 12h16" />
<path d="m9 7 3-3 3 3M9 17l3 3 3-3M7 9l-3 3 3 3M17 9l3 3-3 3" />
</svg>
); );
export const ChatIcon = (props: IconProps) => ( export const ChatIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/speech-bubble.png" {...props} />
<path d="M20 15.5a1.5 1.5 0 0 1-1.5 1.5H8l-4 3.5V6.5A1.5 1.5 0 0 1 5.5 5h13A1.5 1.5 0 0 1 20 6.5Z" />
<path d="M8 9.5h8M8 13h5" />
</svg>
); );
export const SendIcon = (props: IconProps) => ( export const SendIcon = (props: IconProps) => (
<svg {...base(props)}> <ImgIcon src="/icons/send.png" {...props} />
<path d="M4.5 12 20 4.5 15 20l-3.5-6.5L4.5 12Z" />
<path d="m11.5 13.5 4-4" />
</svg>
); );
+20 -20
View File
@@ -129,13 +129,11 @@ export const AdminUsers = () => {
title={t("Comptes")} title={t("Comptes")}
description={t("Créer des membres, ajustez leurs quotas et gérez les accès.")} description={t("Créer des membres, ajustez leurs quotas et gérez les accès.")}
actions={ actions={
<Button <IconAction
size="sm" label={t("Nouveau membre")}
iconLeading={<PlusIcon className="h-3.5 w-3.5" />} icon={<PlusIcon className="h-4 w-4" />}
onClick={() => setCreateOpen(true)} onClick={() => setCreateOpen(true)}
> />
{t("Nouveau membre")}
</Button>
} }
toolbar={ toolbar={
<> <>
@@ -210,18 +208,20 @@ export const AdminUsers = () => {
</span> </span>
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<Button variant="ghost" size="sm" onClick={() => setEdit(user)}> <IconAction
{t("Modifier")} label={t("Modifier")}
</Button> icon={<img src="/icons/edit-pencil.png" alt="" className="h-4 w-4 object-contain" />}
onClick={() => setEdit(user)}
/>
<IconAction <IconAction
label={user.is_active ? t("Désactiver") : t("Réactiver")} label={user.is_active ? t("Désactiver") : t("Réactiver")}
icon={<HardDriveIcon className="h-4 w-4" />} icon={<img src="/icons/deactivate.png" alt="" className="h-4 w-4 object-contain" />}
isLoading={busy === user.id} isLoading={busy === user.id}
onClick={() => void toggleActive(user)} onClick={() => void toggleActive(user)}
/> />
<IconAction <IconAction
label={t("Réinitialiser le mot de passe")} label={t("Réinitialiser le mot de passe")}
icon={<ActivityIcon className="h-4 w-4" />} icon={<img src="/icons/password-reset.png" alt="" className="h-4 w-4 object-contain" />}
isLoading={busy === user.id} isLoading={busy === user.id}
onClick={() => void resetPassword(user)} onClick={() => void resetPassword(user)}
/> />
@@ -505,13 +505,11 @@ export const AdminStorage = () => {
title={t("Emplacements de stockage")} title={t("Emplacements de stockage")}
description={t("Volumes montés utilisés pour stocker les fichiers.")} description={t("Volumes montés utilisés pour stocker les fichiers.")}
actions={ actions={
<Button <IconAction
size="sm" label={t("Nouvel emplacement")}
iconLeading={<PlusIcon className="h-3.5 w-3.5" />} icon={<PlusIcon className="h-4 w-4" />}
onClick={() => setCreateOpen(true)} onClick={() => setCreateOpen(true)}
> />
{t("Nouvel emplacement")}
</Button>
} }
/> />
@@ -544,9 +542,11 @@ export const AdminStorage = () => {
: t("{used} Go utilisés", { used: toGb(location.used_bytes) })} : t("{used} Go utilisés", { used: toGb(location.used_bytes) })}
</span> </span>
</span> </span>
<Button variant="ghost" size="sm" onClick={() => void toggle(location)}> <IconAction
{location.is_active ? t("Désactiver") : t("Réactiver")} label={location.is_active ? t("Désactiver") : t("Réactiver")}
</Button> icon={<img src={location.is_active ? "/icons/close.png" : "/icons/synchronize.png"} alt="" className="h-4 w-4 object-contain" />}
onClick={() => void toggle(location)}
/>
</li> </li>
))} ))}
</ul> </ul>
+51 -76
View File
@@ -5,7 +5,7 @@ import {
useState, useState,
type DragEvent, type DragEvent,
} from "react"; } from "react";
import { Button, Card, Spinner, cn } from "../ui/index.js"; import { Card, Spinner, cn } from "../ui/index.js";
import { import {
ApiError, ApiError,
api, api,
@@ -17,7 +17,7 @@ import { useSession } from "../lib/session.js";
import { useI18n } from "../lib/i18n.js"; import { useI18n } from "../lib/i18n.js";
import { getLocale } from "../lib/locale.js"; import { getLocale } from "../lib/locale.js";
import { mediaKind } from "../lib/media.js"; import { mediaKind } from "../lib/media.js";
import { Badge, EmptyState, PageHeader } from "../components/feedback.js"; import { EmptyState, PageHeader } from "../components/feedback.js";
import { useConfirm } from "../components/confirm.js"; import { useConfirm } from "../components/confirm.js";
import { MediaViewer } from "../components/MediaViewer.js"; import { MediaViewer } from "../components/MediaViewer.js";
import { MediaThumb } from "../components/MediaThumb.js"; import { MediaThumb } from "../components/MediaThumb.js";
@@ -33,8 +33,8 @@ import {
import { import {
ArrowLeftIcon, ArrowLeftIcon,
ChatIcon, ChatIcon,
CloseIcon,
DownloadIcon, DownloadIcon,
FolderIcon,
PenIcon, PenIcon,
PlusIcon, PlusIcon,
RefreshIcon, RefreshIcon,
@@ -538,32 +538,22 @@ export const Browser = () => {
</ol> </ol>
</nav> </nav>
<Button <IconAction
variant="secondary" label={t("Rafraîchir")}
size="sm" icon={<RefreshIcon className="h-4 w-4" />}
iconLeading={<RefreshIcon className="h-3.5 w-3.5" />}
isLoading={refreshing} isLoading={refreshing}
onClick={() => void manualRefresh()} onClick={() => void manualRefresh()}
> />
{t("Rafraîchir")}
</Button>
{current.id ? ( {current.id ? (
<Button <IconAction
variant="secondary" label={t("Discussion")}
size="sm" icon={<ChatIcon className="h-4 w-4" />}
iconLeading={<ChatIcon className="h-3.5 w-3.5" />} badge={currentUnread}
onClick={() => onClick={() =>
setChat({ id: current.id as string, name: current.name }) setChat({ id: current.id as string, name: current.name })
} }
> />
<span className="inline-flex items-center gap-2">
{t("Discussion")}
{currentUnread > 0 ? (
<Badge tone="accent">{currentUnread}</Badge>
) : null}
</span>
</Button>
) : null} ) : null}
</div> </div>
} }
@@ -619,7 +609,7 @@ export const Browser = () => {
) : null} ) : null}
{canWrite ? ( {canWrite ? (
<div className="flex gap-2"> <div className="flex gap-1">
<input <input
ref={fileInputRef} ref={fileInputRef}
type="file" type="file"
@@ -627,25 +617,17 @@ export const Browser = () => {
className="sr-only" className="sr-only"
onChange={(event) => void upload(event.target.files)} onChange={(event) => void upload(event.target.files)}
/> />
<Button <IconAction
variant="secondary" label={uploading && uploadProgress ? t("Envoi {current}/{total}…", uploadProgress) : t("Envoyer")}
size="sm" icon={<UploadIcon className="h-4 w-4" />}
iconLeading={<UploadIcon className="h-3.5 w-3.5" />}
isLoading={uploading} isLoading={uploading}
onClick={() => fileInputRef.current?.click()} onClick={() => fileInputRef.current?.click()}
> />
{uploading && uploadProgress <IconAction
? t("Envoi {current}/{total}…", uploadProgress) label={t("Nouveau dossier")}
: t("Envoyer")} icon={<PlusIcon className="h-4 w-4" />}
</Button>
<Button
variant="secondary"
size="sm"
iconLeading={<PlusIcon className="h-3.5 w-3.5" />}
onClick={() => setDialog({ kind: "create" })} onClick={() => setDialog({ kind: "create" })}
> />
{t("Nouveau dossier")}
</Button>
</div> </div>
) : null} ) : null}
</div> </div>
@@ -681,25 +663,21 @@ export const Browser = () => {
{canWrite && selectedItems.length > 0 ? ( {canWrite && selectedItems.length > 0 ? (
<div className="fixed bottom-3 left-1/2 z-40 w-[calc(100%-1rem)] max-w-xl -translate-x-1/2 px-1 sm:bottom-4 sm:w-auto"> <div className="fixed bottom-3 left-1/2 z-40 w-[calc(100%-1rem)] max-w-xl -translate-x-1/2 px-1 sm:bottom-4 sm:w-auto">
<div className="flex flex-col items-center justify-center gap-2 rounded-lg border border-border-strong bg-surface px-3 py-2 shadow-lg sm:flex-row sm:flex-wrap sm:items-center sm:justify-center"> <div className="flex flex-col items-center justify-center gap-2 rounded-lg border border-border-strong bg-surface/80 px-3 py-2 shadow-lg backdrop-blur-md sm:flex-row sm:flex-wrap sm:items-center sm:justify-center">
<p className="text-center text-sm font-medium text-foreground"> <p className="text-center text-sm font-medium text-foreground">
{t("{count} élément(s) sélectionné(s).", { {t("{count} élément(s) sélectionné(s).", {
count: selectedItems.length, count: selectedItems.length,
})} })}
</p> </p>
<div className="flex flex-wrap items-center justify-center gap-2"> <div className="flex flex-wrap items-center justify-center gap-1">
<Button <IconAction
size="sm" label={t("Déplacer")}
variant="secondary" icon={<img src="/icons/move.png" alt="" className="h-4 w-4 object-contain" />}
onClick={() => onClick={() => setDialog({ kind: "moveMany", targets: selectedItems })}
setDialog({ kind: "moveMany", targets: selectedItems }) />
} <IconAction
> label={t("Télécharger")}
{t("Déplacer")} icon={<DownloadIcon className="h-4 w-4" />}
</Button>
<Button
size="sm"
variant="secondary"
onClick={() => { onClick={() => {
const files = selectedItems.filter((t) => t.type === "file"); const files = selectedItems.filter((t) => t.type === "file");
if (files.length === 0) { if (files.length === 0) {
@@ -716,19 +694,18 @@ export const Browser = () => {
toast.info(t("Les dossiers n'ont pas été téléchargés.")); toast.info(t("Les dossiers n'ont pas été téléchargés."));
} }
}} }}
> />
{t("Télécharger")} <IconAction
</Button> label={t("Supprimer")}
<Button icon={<TrashIcon className="h-4 w-4" />}
size="sm" tone="danger"
variant="destructive"
onClick={() => void removeSelected()} onClick={() => void removeSelected()}
> />
{t("Supprimer")} <IconAction
</Button> label={t("Annuler la sélection")}
<Button size="sm" variant="ghost" onClick={clearSelection}> icon={<CloseIcon className="h-4 w-4" />}
{t("Annuler la sélection")} onClick={clearSelection}
</Button> />
</div> </div>
</div> </div>
</div> </div>
@@ -740,7 +717,7 @@ export const Browser = () => {
</div> </div>
) : empty ? ( ) : empty ? (
<EmptyState <EmptyState
icon={<FolderIcon className="h-8 w-8" />} icon={<img src="/icons/opened-folder.png" alt="" className="h-8 w-8 object-contain" />}
title={t("Emplacement vide")} title={t("Emplacement vide")}
description={t( description={t(
"Créez un sous-dossier ou envoyez un fichier pour commencer.", "Créez un sous-dossier ou envoyez un fichier pour commencer.",
@@ -762,7 +739,7 @@ export const Browser = () => {
onDrop={(event) => onFolderDrop(event, folder)} onDrop={(event) => onFolderDrop(event, folder)}
onClick={() => toggleSelection(`f:${folder.id}`)} onClick={() => toggleSelection(`f:${folder.id}`)}
className={cn( className={cn(
"group relative flex items-center gap-1 rounded-lg border border-border bg-surface p-2 transition-colors hover:border-border-strong hover:bg-surface-hover cursor-pointer", "group relative flex items-center gap-1 rounded-xl border border-border/50 bg-surface/60 p-2 backdrop-blur-md transition-all hover:-translate-y-1 hover:border-border-strong hover:bg-surface/80 hover:shadow-lg cursor-pointer",
dropTargetId === folder.id && dropTargetId === folder.id &&
"border-accent bg-accent/10 ring-1 ring-accent/50", "border-accent bg-accent/10 ring-1 ring-accent/50",
selected.has(`f:${folder.id}`) && selected.has(`f:${folder.id}`) &&
@@ -798,7 +775,7 @@ export const Browser = () => {
className="flex min-w-0 flex-1 items-center gap-3 rounded-sm p-1 text-left focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none" className="flex min-w-0 flex-1 items-center gap-3 rounded-sm p-1 text-left focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
> >
<span className="shrink-0 text-accent"> <span className="shrink-0 text-accent">
<FolderIcon className="h-5 w-5" /> <img src="/icons/opened-folder.png" alt="" className="h-5 w-5 object-contain" />
</span> </span>
<span className="min-w-0 flex-1"> <span className="min-w-0 flex-1">
<span className="block truncate text-sm font-medium text-foreground"> <span className="block truncate text-sm font-medium text-foreground">
@@ -879,7 +856,7 @@ export const Browser = () => {
{t("Rien à afficher pour ce filtre.")} {t("Rien à afficher pour ce filtre.")}
</p> </p>
) : ( ) : (
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface"> <ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
{visibleFiles.map((file, index) => ( {visibleFiles.map((file, index) => (
<li <li
key={file.id} key={file.id}
@@ -943,8 +920,7 @@ export const Browser = () => {
} }
icon={ icon={
<StarIcon <StarIcon
className="h-4 w-4" className={`h-4 w-4 ${file.is_starred ? "text-accent" : "opacity-60"}`}
{...(file.is_starred ? { filled: true } : {})}
/> />
} }
onClick={(event) => { onClick={(event) => {
@@ -956,13 +932,12 @@ export const Browser = () => {
<a <a
href={api.downloadUrl(file.id)} href={api.downloadUrl(file.id)}
download={file.name} download={file.name}
className="inline-flex h-8 items-center gap-1.5 rounded-sm border border-border-strong bg-surface px-3 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground transition-colors hover:bg-surface-hover" aria-label={t("Télécharger {name}", { name: file.name })}
title={t("Télécharger {name}", { name: file.name })}
className="inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/50 bg-surface/60 text-muted-foreground backdrop-blur-sm transition-all hover:-translate-y-0.5 hover:bg-surface/80 hover:text-foreground hover:shadow-sm"
onClick={(event) => event.stopPropagation()} onClick={(event) => event.stopPropagation()}
> >
<DownloadIcon className="h-3.5 w-3.5" /> <DownloadIcon className="h-4 w-4" />
<span className="hidden sm:inline">
{t("Télécharger")}
</span>
</a> </a>
{canWrite ? ( {canWrite ? (
+74 -76
View File
@@ -36,83 +36,81 @@ export const ChangePassword = () => {
}; };
return ( return (
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10"> <div className="w-full max-w-sm">
<div className="w-full max-w-sm"> <header className="mb-6 text-center">
<header className="mb-6 text-center"> <div className="flex items-center justify-center gap-3">
<div className="flex items-center justify-center gap-3"> <img
<img src="/icon.png"
src="/icon.png" alt=""
alt="" className="h-12 w-12 rounded-xl ring-1 ring-black/5"
className="h-12 w-12 rounded-xl ring-1 ring-black/5" />
/> <div className="text-left">
<div className="text-left"> <p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent"> CoHaiSe
CoHaiSe </p>
</p> <h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground"> {t("Nouveau mot de passe")}
{t("Nouveau mot de passe")} </h1>
</h1>
</div>
</div> </div>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground"> </div>
{t("Bienvenue {name}. Ce mot de passe a été défini par un administrateur : choisissez le vôtre.", { name: user?.first_name ?? "" })} <p className="mt-2 text-sm leading-relaxed text-muted-foreground">
</p> {t("Bienvenue {name}. Ce mot de passe a été défini par un administrateur : choisissez le vôtre.", { name: user?.first_name ?? "" })}
</header> </p>
</header>
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>{t("Changement requis")}</CardTitle> <CardTitle>{t("Changement requis")}</CardTitle>
<CardDescription> <CardDescription>
{t("Les autres sessions ouvertes sur ce compte seront fermées.")} {t("Les autres sessions ouvertes sur ce compte seront fermées.")}
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}> <form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
<Input <Input
label={t("Mot de passe actuel")} label={t("Mot de passe actuel")}
type="password" type="password"
autoComplete="current-password" autoComplete="current-password"
required required
autoFocus autoFocus
value={current} value={current}
onChange={(event) => setCurrent(event.target.value)} onChange={(event) => setCurrent(event.target.value)}
/> />
<Input <Input
label={t("Nouveau mot de passe")} label={t("Nouveau mot de passe")}
type="password" type="password"
autoComplete="new-password" autoComplete="new-password"
required required
minLength={8} minLength={8}
hint={t("8 caractères minimum.")} hint={t("8 caractères minimum.")}
value={next} value={next}
onChange={(event) => setNext(event.target.value)} onChange={(event) => setNext(event.target.value)}
/> />
<Input <Input
label={t("Confirmation")} label={t("Confirmation")}
type="password" type="password"
autoComplete="new-password" autoComplete="new-password"
required required
minLength={8} minLength={8}
value={confirm} value={confirm}
onChange={(event) => setConfirm(event.target.value)} onChange={(event) => setConfirm(event.target.value)}
/> />
{error ? <Alert>{error}</Alert> : null} {error ? <Alert>{error}</Alert> : null}
<Button type="submit" size="lg" fullWidth isLoading={busy}> <Button type="submit" size="lg" fullWidth isLoading={busy}>
{t("Enregistrer")} {t("Enregistrer")}
</Button> </Button>
<Button <Button
type="button" type="button"
variant="ghost" variant="ghost"
size="md" size="md"
fullWidth fullWidth
onClick={() => void logout()} onClick={() => void logout()}
> >
{t("Se déconnecter")} {t("Se déconnecter")}
</Button> </Button>
</form> </form>
</CardContent> </CardContent>
</Card> </Card>
</div> </div>
</main>
); );
}; };
+48 -50
View File
@@ -36,57 +36,55 @@ export const ConfirmEmail = () => {
}, [token, refresh]); }, [token, refresh]);
return ( return (
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10"> <div className="w-full max-w-sm">
<div className="w-full max-w-sm"> <header className="mb-6 text-center">
<header className="mb-6 text-center"> <div className="flex items-center justify-center gap-3">
<div className="flex items-center justify-center gap-3"> <img
<img src="/icon.png"
src="/icon.png" alt=""
alt="" className="h-12 w-12 rounded-xl ring-1 ring-black/5"
className="h-12 w-12 rounded-xl ring-1 ring-black/5" />
/> <div className="text-left">
<div className="text-left"> <p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent"> CoHaiSe
CoHaiSe </p>
</p> <h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground"> {t("Changement d'adresse")}
{t("Changement d'adresse")} </h1>
</h1>
</div>
</div> </div>
</header> </div>
</header>
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>{t("Confirmation")}</CardTitle> <CardTitle>{t("Confirmation")}</CardTitle>
</CardHeader> </CardHeader>
<CardContent className="flex flex-col gap-4"> <CardContent className="flex flex-col gap-4">
{state === "loading" ? ( {state === "loading" ? (
<div className="flex justify-center py-4"> <div className="flex justify-center py-4">
<Spinner size="md" /> <Spinner size="md" />
</div> </div>
) : state === "success" ? ( ) : state === "success" ? (
<> <>
<Alert tone="success">{t("Votre adresse e-mail a été mise à jour.")}</Alert> <Alert tone="success">{t("Votre adresse e-mail a été mise à jour.")}</Alert>
<Link to="/files"> <Link to="/files">
<Button size="lg" fullWidth> <Button size="lg" fullWidth>
{t("Accéder à mes fichiers")} {t("Accéder à mes fichiers")}
</Button> </Button>
</Link> </Link>
</> </>
) : ( ) : (
<> <>
<Alert>{error}</Alert> <Alert>{error}</Alert>
<Link to="/profile"> <Link to="/profile">
<Button size="lg" fullWidth> <Button size="lg" fullWidth>
{t("Mon compte")} {t("Mon compte")}
</Button> </Button>
</Link> </Link>
</> </>
)} )}
</CardContent> </CardContent>
</Card> </Card>
</div> </div>
</main>
); );
}; };
+6 -5
View File
@@ -60,7 +60,7 @@ export const Favorites = () => {
description={t("Étoilez un fichier dans l'explorateur pour le retrouver ici.")} description={t("Étoilez un fichier dans l'explorateur pour le retrouver ici.")}
/> />
) : ( ) : (
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface"> <ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
{files.map((file, index) => ( {files.map((file, index) => (
<li key={file.id} className="flex items-center gap-2 px-3 py-2.5"> <li key={file.id} className="flex items-center gap-2 px-3 py-2.5">
<button <button
@@ -85,17 +85,18 @@ export const Favorites = () => {
<IconAction <IconAction
label={t("Retirer l'étoile de {name}", { name: file.name })} label={t("Retirer l'étoile de {name}", { name: file.name })}
icon={<StarIcon className="h-4 w-4" filled />} icon={<StarIcon className="h-4 w-4" />}
onClick={() => void unstar(file)} onClick={() => void unstar(file)}
/> />
<a <a
href={api.downloadUrl(file.id)} href={api.downloadUrl(file.id)}
download={file.name} download={file.name}
className="inline-flex h-8 items-center gap-1.5 rounded-sm border border-border-strong bg-surface px-3 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground transition-colors hover:bg-surface-hover" aria-label={t("Télécharger {name}", { name: file.name })}
title={t("Télécharger {name}", { name: file.name })}
className="inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/50 bg-surface/60 text-muted-foreground backdrop-blur-sm transition-all hover:-translate-y-0.5 hover:bg-surface/80 hover:text-foreground hover:shadow-sm"
> >
<DownloadIcon className="h-3.5 w-3.5" /> <DownloadIcon className="h-4 w-4" />
<span className="hidden sm:inline">{t("Télécharger")}</span>
</a> </a>
</li> </li>
))} ))}
+65 -67
View File
@@ -27,75 +27,73 @@ export const ForgotPassword = () => {
}; };
return ( return (
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10"> <div className="w-full max-w-sm">
<div className="w-full max-w-sm"> <header className="mb-6 text-center">
<header className="mb-6 text-center"> <div className="flex items-center justify-center gap-3">
<div className="flex items-center justify-center gap-3"> <img
<img src="/icon.png"
src="/icon.png" alt=""
alt="" className="h-12 w-12 rounded-xl ring-1 ring-black/5"
className="h-12 w-12 rounded-xl ring-1 ring-black/5" />
/> <div className="text-left">
<div className="text-left"> <p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent"> CoHaiSe
CoHaiSe </p>
</p> <h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground"> {t("Mot de passe oublié")}
{t("Mot de passe oublié")} </h1>
</h1>
</div>
</div> </div>
</header> </div>
</header>
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>{t("Réinitialisation")}</CardTitle> <CardTitle>{t("Réinitialisation")}</CardTitle>
<CardDescription> <CardDescription>
{t("Nous vous enverrons un lien valable une heure.")} {t("Nous vous enverrons un lien valable une heure.")}
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
{sent ? ( {sent ? (
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
<Alert tone="success"> <Alert tone="success">
{t("Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.")} {t("Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.")}
</Alert> </Alert>
<Link <Link
to="/login" to="/login"
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline" className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
>
{t("Retour à la connexion")}
</Link>
</div>
) : (
<form
className="flex flex-col gap-4"
onSubmit={(event) => void submit(event)}
> >
<Input {t("Retour à la connexion")}
label={t("Adresse e-mail")} </Link>
type="email" </div>
autoComplete="email" ) : (
required <form
autoFocus className="flex flex-col gap-4"
value={email} onSubmit={(event) => void submit(event)}
onChange={(event) => setEmail(event.target.value)} >
/> <Input
{error ? <Alert>{error}</Alert> : null} label={t("Adresse e-mail")}
<Button type="submit" size="lg" fullWidth isLoading={busy}> type="email"
{t("Envoyer le lien")} autoComplete="email"
</Button> required
<Link autoFocus
to="/login" value={email}
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline" onChange={(event) => setEmail(event.target.value)}
> />
{t("Retour à la connexion")} {error ? <Alert>{error}</Alert> : null}
</Link> <Button type="submit" size="lg" fullWidth isLoading={busy}>
</form> {t("Envoyer le lien")}
)} </Button>
</CardContent> <Link
</Card> to="/login"
</div> className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
</main> >
{t("Retour à la connexion")}
</Link>
</form>
)}
</CardContent>
</Card>
</div>
); );
}; };
+62 -64
View File
@@ -32,71 +32,69 @@ export const Login = () => {
}; };
return ( return (
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10"> <div className="w-full max-w-sm">
<div className="w-full max-w-sm"> <header className="mb-6 text-center">
<header className="mb-6 text-center"> <div className="flex items-center justify-center gap-3">
<div className="flex items-center justify-center gap-3"> <img
<img src="/icon.png"
src="/icon.png" alt=""
alt="" className="h-12 w-12 rounded-xl ring-1 ring-black/5"
className="h-12 w-12 rounded-xl ring-1 ring-black/5" />
/> <div className="text-left">
<div className="text-left"> <p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent"> CoHaiSe
CoHaiSe </p>
</p> <h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground"> Cloud
Cloud </h1>
</h1>
</div>
</div> </div>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground"> </div>
{t("Connectez-vous pour accéder à vos fichiers.")} <p className="mt-2 text-sm leading-relaxed text-muted-foreground">
</p> {t("Connectez-vous pour accéder à vos fichiers.")}
</header>
<Card>
<CardHeader>
<CardTitle>{t("Connexion")}</CardTitle>
<CardDescription>{t("Votre session reste ouverte 14 jours.")}</CardDescription>
</CardHeader>
<CardContent>
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
<Input
label={t("Adresse e-mail")}
type="email"
autoComplete="username"
required
autoFocus
value={email}
onChange={(event) => setEmail(event.target.value)}
/>
<Input
label={t("Mot de passe")}
type="password"
autoComplete="current-password"
required
value={password}
onChange={(event) => setPassword(event.target.value)}
{...(error ? { error } : {})}
/>
<Button type="submit" size="lg" fullWidth isLoading={busy}>
{t("Se connecter")}
</Button>
</form>
</CardContent>
</Card>
<p className="mt-4 text-center text-xs text-muted-foreground">
<Link
to="/forgot-password"
className="underline-offset-2 hover:text-foreground hover:underline"
>
{t("Mot de passe oublié ?")}
</Link>
</p> </p>
</div> </header>
</main>
<Card>
<CardHeader>
<CardTitle>{t("Connexion")}</CardTitle>
<CardDescription>{t("Votre session reste ouverte 14 jours.")}</CardDescription>
</CardHeader>
<CardContent>
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
<Input
label={t("Adresse e-mail")}
type="email"
autoComplete="username"
required
autoFocus
value={email}
onChange={(event) => setEmail(event.target.value)}
/>
<Input
label={t("Mot de passe")}
type="password"
autoComplete="current-password"
required
value={password}
onChange={(event) => setPassword(event.target.value)}
{...(error ? { error } : {})}
/>
<Button type="submit" size="lg" fullWidth isLoading={busy}>
{t("Se connecter")}
</Button>
</form>
</CardContent>
</Card>
<p className="mt-4 text-center text-xs text-muted-foreground">
<Link
to="/forgot-password"
className="underline-offset-2 hover:text-foreground hover:underline"
>
{t("Mot de passe oublié ?")}
</Link>
</p>
</div>
); );
}; };
+74 -76
View File
@@ -34,84 +34,82 @@ export const ResetPassword = () => {
}; };
return ( return (
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10"> <div className="w-full max-w-sm">
<div className="w-full max-w-sm"> <header className="mb-6 text-center">
<header className="mb-6 text-center"> <div className="flex items-center justify-center gap-3">
<div className="flex items-center justify-center gap-3"> <img
<img src="/icon.png"
src="/icon.png" alt=""
alt="" className="h-12 w-12 rounded-xl ring-1 ring-black/5"
className="h-12 w-12 rounded-xl ring-1 ring-black/5" />
/> <div className="text-left">
<div className="text-left"> <p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent"> CoHaiSe
CoHaiSe </p>
</p> <h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground"> {t("Nouveau mot de passe")}
{t("Nouveau mot de passe")} </h1>
</h1>
</div>
</div> </div>
</header> </div>
</header>
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>{t("Réinitialisation")}</CardTitle> <CardTitle>{t("Réinitialisation")}</CardTitle>
<CardDescription>{t("Choisissez un mot de passe robuste.")}</CardDescription> <CardDescription>{t("Choisissez un mot de passe robuste.")}</CardDescription>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
{!token ? ( {!token ? (
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
<Alert>{t("Ce lien est incomplet ou invalide.")}</Alert> <Alert>{t("Ce lien est incomplet ou invalide.")}</Alert>
<Link <Link
to="/forgot-password" to="/forgot-password"
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline" className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
> >
{t("Demander un nouveau lien")} {t("Demander un nouveau lien")}
</Link> </Link>
</div> </div>
) : done ? ( ) : done ? (
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
<Alert tone="success"> <Alert tone="success">
{t("Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.")} {t("Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.")}
</Alert> </Alert>
<Link to="/login"> <Link to="/login">
<Button size="lg" fullWidth> <Button size="lg" fullWidth>
{t("Se connecter")} {t("Se connecter")}
</Button>
</Link>
</div>
) : (
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
<Input
label={t("Nouveau mot de passe")}
type="password"
autoComplete="new-password"
required
minLength={8}
autoFocus
hint={t("8 caractères minimum.")}
value={password}
onChange={(event) => setPassword(event.target.value)}
/>
<Input
label={t("Confirmation")}
type="password"
autoComplete="new-password"
required
minLength={8}
value={confirm}
onChange={(event) => setConfirm(event.target.value)}
/>
{error ? <Alert>{error}</Alert> : null}
<Button type="submit" size="lg" fullWidth isLoading={busy}>
{t("Réinitialiser")}
</Button> </Button>
</form> </Link>
)} </div>
</CardContent> ) : (
</Card> <form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
</div> <Input
</main> label={t("Nouveau mot de passe")}
type="password"
autoComplete="new-password"
required
minLength={8}
autoFocus
hint={t("8 caractères minimum.")}
value={password}
onChange={(event) => setPassword(event.target.value)}
/>
<Input
label={t("Confirmation")}
type="password"
autoComplete="new-password"
required
minLength={8}
value={confirm}
onChange={(event) => setConfirm(event.target.value)}
/>
{error ? <Alert>{error}</Alert> : null}
<Button type="submit" size="lg" fullWidth isLoading={busy}>
{t("Réinitialiser")}
</Button>
</form>
)}
</CardContent>
</Card>
</div>
); );
}; };
+13 -10
View File
@@ -1,7 +1,8 @@
import { useState, type FormEvent } from "react"; import { useState, type FormEvent } from "react";
import { Button, Input, Spinner } from "../ui/index.js"; import { Input, Spinner } from "../ui/index.js";
import { ApiError, api, formatBytes, type Folder, type UploadedFile } from "../lib/api.js"; import { ApiError, api, formatBytes, type Folder, type UploadedFile } from "../lib/api.js";
import { Alert, EmptyState, PageHeader } from "../components/feedback.js"; import { Alert, EmptyState, PageHeader } from "../components/feedback.js";
import { IconAction } from "../components/IconAction.js";
import { DownloadIcon, FileIcon, FolderIcon, SearchIcon } from "../components/icons.js"; import { DownloadIcon, FileIcon, FolderIcon, SearchIcon } from "../components/icons.js";
import { useI18n } from "../lib/i18n.js"; import { useI18n } from "../lib/i18n.js";
@@ -56,14 +57,16 @@ export const Search = () => {
onChange={(event) => setQ(event.target.value)} onChange={(event) => setQ(event.target.value)}
/> />
</div> </div>
<Button <IconAction
type="submit" label={t("Rechercher")}
size="md" icon={<SearchIcon className="h-4 w-4" />}
isLoading={loading} isLoading={loading}
iconLeading={<SearchIcon className="h-3.5 w-3.5" />} onClick={(e) => {
> e.preventDefault();
{t("Rechercher")} const form = e.currentTarget.closest('form');
</Button> form?.requestSubmit();
}}
/>
</form> </form>
} }
/> />
@@ -87,7 +90,7 @@ export const Search = () => {
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground"> <h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
{t("Dossiers")} {t("Dossiers")}
</h2> </h2>
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface"> <ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
{results.folders.map((folder) => ( {results.folders.map((folder) => (
<li key={folder.id} className="flex items-center gap-3 px-3 py-2.5"> <li key={folder.id} className="flex items-center gap-3 px-3 py-2.5">
<span className="shrink-0 text-accent"> <span className="shrink-0 text-accent">
@@ -107,7 +110,7 @@ export const Search = () => {
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground"> <h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
{t("Fichiers")} {t("Fichiers")}
</h2> </h2>
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface"> <ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
{results.files.map((file) => ( {results.files.map((file) => (
<li key={file.id} className="flex items-center gap-3 px-3 py-2.5"> <li key={file.id} className="flex items-center gap-3 px-3 py-2.5">
<span className="shrink-0 text-muted-foreground"> <span className="shrink-0 text-muted-foreground">
+2 -2
View File
@@ -121,7 +121,7 @@ export const Trash = () => {
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground"> <h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
{t("Dossiers")} {t("Dossiers")}
</h2> </h2>
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface"> <ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
{data.folders.map((folder) => ( {data.folders.map((folder) => (
<li key={folder.id} className="flex items-center gap-3 px-3 py-2.5"> <li key={folder.id} className="flex items-center gap-3 px-3 py-2.5">
<span className="shrink-0 text-accent"> <span className="shrink-0 text-accent">
@@ -165,7 +165,7 @@ export const Trash = () => {
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground"> <h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
{t("Fichiers")} {t("Fichiers")}
</h2> </h2>
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface"> <ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
{data.files.map((file) => ( {data.files.map((file) => (
<li key={file.id} className="flex items-center gap-3 px-3 py-2.5"> <li key={file.id} className="flex items-center gap-3 px-3 py-2.5">
<span className="shrink-0 text-muted-foreground"> <span className="shrink-0 text-muted-foreground">
+2 -2
View File
@@ -5,8 +5,8 @@ import type { SpinnerSize } from "./Spinner.js";
const variantClasses = { const variantClasses = {
primary: "bg-primary text-primary-foreground hover:bg-primary-hover", primary: "bg-primary text-primary-foreground hover:bg-primary-hover",
secondary: "border border-border-strong bg-surface text-foreground hover:bg-surface-hover", secondary: "rounded-lg border border-border-strong bg-surface/60 text-foreground backdrop-blur-sm transition-all hover:-translate-y-0.5 hover:bg-surface/80 hover:shadow-md",
ghost: "text-foreground hover:bg-surface-hover", ghost: "rounded-lg text-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/50 hover:shadow-sm",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive-hover", destructive: "bg-destructive text-destructive-foreground hover:bg-destructive-hover",
} as const; } as const;
+2 -2
View File
@@ -4,8 +4,8 @@ import { cn } from "../lib/cn.js";
export const Card = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => ( export const Card = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
<div <div
className={cn( className={cn(
"relative overflow-hidden rounded-lg border border-border bg-surface text-foreground shadow-sm", "relative overflow-hidden rounded-xl border border-border/50 bg-surface/60 text-foreground shadow-sm backdrop-blur-md",
"transition-colors duration-base ease-out-soft", "transition-all duration-base ease-out-soft hover:-translate-y-1 hover:shadow-lg",
className, className,
)} )}
{...props} {...props}
+1 -1
View File
@@ -47,7 +47,7 @@ export const Input = ({
aria-invalid={isInvalid} aria-invalid={isInvalid}
aria-describedby={isInvalid || hint ? messageId : undefined} aria-describedby={isInvalid || hint ? messageId : undefined}
className={cn( className={cn(
"w-full rounded-sm border bg-surface text-foreground placeholder:text-subtle-foreground", "w-full rounded-lg border bg-surface/60 text-foreground placeholder:text-subtle-foreground backdrop-blur-sm",
"transition-[background-color,border-color,box-shadow] duration-fast ease-out-soft", "transition-[background-color,border-color,box-shadow] duration-fast ease-out-soft",
"focus-visible:ring-ring focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none", "focus-visible:ring-ring focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none",
"disabled:cursor-not-allowed disabled:bg-surface-muted disabled:opacity-60", "disabled:cursor-not-allowed disabled:bg-surface-muted disabled:opacity-60",
+66 -1
View File
@@ -47,12 +47,14 @@
"react": "^19.3.0", "react": "^19.3.0",
"react-dom": "^19.3.0", "react-dom": "^19.3.0",
"react-router-dom": "^7.18.4", "react-router-dom": "^7.18.4",
"tailwind-merge": "^3.7.0" "tailwind-merge": "^3.7.0",
"three": "^0.187.0"
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/vite": "^4.3.3", "@tailwindcss/vite": "^4.3.3",
"@types/react": "^19.3.0", "@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0", "@types/react-dom": "^19.3.0",
"@types/three": "^0.187.0",
"@vitejs/plugin-react": "^6.1.1", "@vitejs/plugin-react": "^6.1.1",
"tailwindcss": "^4.3.3", "tailwindcss": "^4.3.3",
"typescript": "^7.0.2", "typescript": "^7.0.2",
@@ -67,6 +69,13 @@
"resolved": "frontend", "resolved": "frontend",
"link": true "link": true
}, },
"node_modules/@dimforge/rapier3d-compat": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz",
"integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==",
"dev": true,
"license": "Apache-2.0"
},
"node_modules/@emnapi/runtime": { "node_modules/@emnapi/runtime": {
"version": "1.11.3", "version": "1.11.3",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
@@ -1183,6 +1192,13 @@
"vite": "^5.2.0 || ^6 || ^7 || ^8" "vite": "^5.2.0 || ^6 || ^7 || ^8"
} }
}, },
"node_modules/@tweenjs/tween.js": {
"version": "23.1.3",
"resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz",
"integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "24.19.2", "version": "24.19.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
@@ -1222,6 +1238,35 @@
"@types/react": "^19.3.0" "@types/react": "^19.3.0"
} }
}, },
"node_modules/@types/stats.js": {
"version": "0.17.4",
"resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz",
"integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/three": {
"version": "0.187.0",
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.187.0.tgz",
"integrity": "sha512-v+vKNarUtk4n2QRZ4+CN5ygMM0ARUjXjIQl0R/unMUfmStFeVqGbgqarbrpoGTXRZoulSH16ePrVJVxPJEbMUA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@dimforge/rapier3d-compat": "~0.12.0",
"@tweenjs/tween.js": "~23.1.3",
"@types/stats.js": "*",
"@types/webxr": ">=0.5.17",
"fflate": "~0.8.3",
"meshoptimizer": "~1.1.1"
}
},
"node_modules/@types/webxr": {
"version": "0.5.24",
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz",
"integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==",
"dev": true,
"license": "MIT"
},
"node_modules/@typescript/typescript-aix-ppc64": { "node_modules/@typescript/typescript-aix-ppc64": {
"version": "7.0.2", "version": "7.0.2",
"resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz",
@@ -1671,6 +1716,13 @@
} }
} }
}, },
"node_modules/fflate": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz",
"integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==",
"dev": true,
"license": "MIT"
},
"node_modules/fsevents": { "node_modules/fsevents": {
"version": "2.3.3", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -2035,6 +2087,13 @@
"@jridgewell/sourcemap-codec": "^1.5.5" "@jridgewell/sourcemap-codec": "^1.5.5"
} }
}, },
"node_modules/meshoptimizer": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz",
"integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==",
"dev": true,
"license": "MIT"
},
"node_modules/mysql2": { "node_modules/mysql2": {
"version": "3.24.6", "version": "3.24.6",
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.24.6.tgz", "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.24.6.tgz",
@@ -2373,6 +2432,12 @@
"url": "https://opencollective.com/webpack" "url": "https://opencollective.com/webpack"
} }
}, },
"node_modules/three": {
"version": "0.187.0",
"resolved": "https://registry.npmjs.org/three/-/three-0.187.0.tgz",
"integrity": "sha512-Qiu7R+Cmh8CstZsY1uJOSWnVlfo7ZtNLV7mF8Jltk3LB3AtDu9cRZlcnRKkAk8Y4z6KKw35z7Y7Urd7jWY8etA==",
"license": "MIT"
},
"node_modules/tinyglobby": { "node_modules/tinyglobby": {
"version": "0.2.17", "version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",