Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): handle corrupt password cookies gracefully

Richie McIlroye18f2f256a44
diff --git a/apps/web/lib/server.ts b/apps/web/lib/server.ts
index 8d744a397..dce31de2e 100644
--- a/apps/web/lib/server.ts
+++ b/apps/web/lib/server.ts
@@ -51,7 +51,14 @@ const CookiePasswordAttachmentLive = Layer.effect(
const password = Option.fromNullable(
yield* Effect.promise(async () => {
const pw = (await cookies()).get("x-cap-password")?.value;
- if (pw) return decrypt(pw);
+ if (!pw) return undefined;
+ try {
+ return await decrypt(pw);
+ } catch {
+ // Corrupt or stale cookie (e.g. rotated encryption key) — treat
+ // as absent rather than crashing the page with a defect.
+ return undefined;
+ }
}),
);
return { password };