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