{"version":3,"file":"mode.mjs","names":[],"sources":["../../../../../src/astro/routes/api/auth/mode.ts"],"sourcesContent":["/**\n * GET /_emdash/api/auth/mode\n *\n * Public endpoint that returns the active authentication mode.\n * Used by the login page to determine which login UI to render.\n *\n * Unlike the full manifest endpoint, this is intentionally public\n * and returns only the auth mode — no collection schemas, plugin\n * info, or other internal details.\n */\n\nimport type { APIRoute } from \"astro\";\n\nimport { apiSuccess } from \"#api/error.js\";\nimport { getAuthMode } from \"#auth/mode.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ locals }) => {\n\tconst { emdash } = locals;\n\n\tconst authMode = getAuthMode(emdash?.config);\n\n\t// Only check signup for passkey auth (external providers handle their own)\n\tlet signupEnabled = false;\n\tif (emdash?.db && authMode.type === \"passkey\") {\n\t\ttry {\n\t\t\tconst { sql } = await import(\"kysely\");\n\t\t\tconst result = await sql<{ cnt: unknown }>`\n\t\t\t\tSELECT COUNT(*) as cnt FROM allowed_domains WHERE enabled = 1\n\t\t\t`.execute(emdash.db);\n\t\t\tsignupEnabled = Number(result.rows[0]?.cnt ?? 0) > 0;\n\t\t} catch {\n\t\t\t// Table may not exist yet\n\t\t}\n\t}\n\n\t// Collect pluggable auth providers (from authProviders config)\n\tconst providers = (emdash?.config?.authProviders ?? []).map((p) => ({\n\t\tid: p.id,\n\t\tlabel: p.label,\n\t}));\n\n\treturn apiSuccess({\n\t\tauthMode: authMode.type === \"external\" ? authMode.providerType : \"passkey\",\n\t\tsignupEnabled,\n\t\tproviders,\n\t});\n};\n"],"mappings":";;;;;;AAgBA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,aAAa;CAClD,MAAM,EAAE,WAAW;CAEnB,MAAM,WAAW,YAAY,QAAQ,OAAO;CAG5C,IAAI,gBAAgB;AACpB,KAAI,QAAQ,MAAM,SAAS,SAAS,UACnC,KAAI;EACH,MAAM,EAAE,QAAQ,MAAM,OAAO;EAC7B,MAAM,SAAS,MAAM,GAAqB;;KAExC,QAAQ,OAAO,GAAG;AACpB,kBAAgB,OAAO,OAAO,KAAK,IAAI,OAAO,EAAE,GAAG;SAC5C;CAMT,MAAM,aAAa,QAAQ,QAAQ,iBAAiB,EAAE,EAAE,KAAK,OAAO;EACnE,IAAI,EAAE;EACN,OAAO,EAAE;EACT,EAAE;AAEH,QAAO,WAAW;EACjB,UAAU,SAAS,SAAS,aAAa,SAAS,eAAe;EACjE;EACA;EACA,CAAC"}