Partage en lecture seule par lien signé
- Lien /s/<jeton> : jeton = id aléatoire 128 bits + HMAC-SHA256 tronqué par la
clé du serveur (SHARE_SECRET, sinon DATA_DIR/.share-secret générée en 0600).
Valide si la signature est correcte, le lien présent dans .shares.json et non
expiré (1, 7, 30 jours ou sans expiration).
- API : GET/POST/DELETE /api/shares, POST /api/shares/revoke-all (renouvelle la
clé), GET /api/public/{jeton} hors authentification (nom, titre, logo, scène).
- Auth Basic : /s/, /api/public/, /healthz et les fichiers statiques du build
sont publics ; le reste de l'API et l'index restent protégés. Le serveur
statique ne liste plus les répertoires. X-Robots-Tag: noindex sur les liens.
- Les liens suivent renommages et déplacements, disparaissent à la suppression.
- Interface : dialogue Partager (barre du haut, menu de l'explorateur), section
Liens de partage dans Paramètres, vue publique Excalidraw en lecture seule
avec téléchargement et bascule clair/sombre.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H6J7vKwXx7uopxKhWfFJpm
This commit is contained in:
1 parent
c1ea1e84a7
commit
50d40cd929
18 files changed
+1076
-12
No files matched your search
@@ -57,6 +57,23 @@ export interface Version {
|
||||
size: number;
|
||||
}
|
||||
|
||||
/** Lien de partage en lecture seule (token : à placer dans /s/<token>). */
|
||||
export interface Share {
|
||||
id: string;
|
||||
token: string;
|
||||
path: string;
|
||||
created: string;
|
||||
expires?: string;
|
||||
}
|
||||
|
||||
/** Schéma partagé tel que servi sans authentification. */
|
||||
export interface PublicScene {
|
||||
name: string;
|
||||
title: string;
|
||||
logo?: string;
|
||||
scene: { elements?: unknown[]; appState?: Record<string, unknown>; files?: Record<string, unknown> };
|
||||
}
|
||||
|
||||
export class ApiError extends Error {
|
||||
constructor(public status: number, message: string) {
|
||||
super(message);
|
||||
@@ -151,6 +168,27 @@ export const api = {
|
||||
|
||||
versionUrl: (path: string, id: string) => `/api/history/version?path=${q(path)}&id=${q(id)}`,
|
||||
|
||||
/** Liens d'un schéma, ou tous les liens si path est omis. */
|
||||
shares: async (path?: string): Promise<Share[]> =>
|
||||
(await request(`/api/shares${path ? `?path=${q(path)}` : ""}`)).json(),
|
||||
|
||||
/** days = 0 : lien sans expiration. */
|
||||
createShare: async (path: string, days: number): Promise<Share> =>
|
||||
(await request("/api/shares", json({ path, days }))).json(),
|
||||
|
||||
revokeShare: async (id: string): Promise<void> => {
|
||||
await request(`/api/shares?id=${q(id)}`, { method: "DELETE" });
|
||||
},
|
||||
|
||||
revokeAllShares: async (): Promise<void> => {
|
||||
await request("/api/shares/revoke-all", { method: "POST" });
|
||||
},
|
||||
|
||||
publicScene: async (token: string): Promise<PublicScene> =>
|
||||
(await request(`/api/public/${q(token)}`)).json(),
|
||||
|
||||
shareUrl: (token: string) => `${location.origin}/s/${token}`,
|
||||
|
||||
readLibrary: async (): Promise<unknown> => (await request("/api/library")).json(),
|
||||
|
||||
writeLibrary: async (body: string): Promise<void> => {
|
||||
|
||||
Reference in new issue
Block a user