import { createBobbinClient } from "#lib/api/client.ts"; import { NUDGE_COOKIE } from "#lib/auth/onboarding.ts"; import { migrationPending } from "#lib/migration/status.ts"; import { getPublicConfig } from "#lib/server/config.ts"; import type { LayoutServerLoad } from "./$types"; export const load: LayoutServerLoad = async ({ cookies, fetch, platform }) => { const did = cookies.get("tangled.currentDid"); const handle = cookies.get("tangled.currentHandle"); const publicConfig = getPublicConfig(platform); // fail open, oauth writes go to the real pds either way const pending = did ? await migrationPending( createBobbinClient({ serviceUrl: publicConfig.bobbinUrl, fetch }), did, publicConfig ).catch(() => false) : false; return { publicConfig, auth: did ? { did, handle: handle ?? did } : null, migrationPending: pending, onboardingNudge: did !== undefined && cookies.get(NUDGE_COOKIE) === did }; };