This commit is contained in:
Anaïs Saraiva
2026-08-15 00:54:04 +02:00
parent ad469460a4
commit f735c64e62
9 changed files with 97 additions and 29 deletions
+6 -1
View File
@@ -3,7 +3,7 @@ import { hasValidAuth, renderPasswordForm } from "../auth";
import { notFound } from "../http";
import { log } from "../log";
import { contentDisposition, fileIdFromKey, KEY_PATTERN, secretMatches } from "../security";
import type { Storage } from "../storage";
import { isExpired, type Storage } from "../storage";
export async function handleDownload(
req: Request,
@@ -17,6 +17,11 @@ export async function handleDownload(
const meta = await storage.readMetadata(id);
if (!meta) return notFound();
if (isExpired(meta)) {
await storage.delete(id);
log("info", `download rejected id=${id} expired`);
return notFound();
}
if (!secretMatches(meta.downloadKeyHash, rawKey)) return notFound();
if (!hasValidAuth(req, secret, rawKey)) {