Statusphere, but in atcute and SvelteKit
atproto svelte sveltekit drizzle atcute typescript

refactor: ensure cookie value is a DID

mary.my.id 62e82381 7aad04c5

verified
+7 -1
+7 -1
src/lib/server/auth/index.ts
··· 2 2 3 3 import { Client } from '@atcute/client'; 4 4 import type { Did } from '@atcute/lexicons'; 5 + import { isDid } from '@atcute/lexicons/syntax'; 5 6 import { 6 7 AuthMethodUnsatisfiableError, 7 8 TokenInvalidError, ··· 48 49 return locals.auth; 49 50 } 50 51 51 - const did = getSignedCookie(cookies, SESSION_COOKIE) as Did | null; 52 + const did = getSignedCookie(cookies, SESSION_COOKIE); 52 53 if (!did) { 54 + error(401, `not signed in`); 55 + } 56 + 57 + if (!isDid(did)) { 58 + cookies.delete(SESSION_COOKIE, { path: '/' }); 53 59 error(401, `not signed in`); 54 60 } 55 61