{"version":3,"file":"rotate.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/settings/frontend-token/rotate.ts"],"sourcesContent":["/** POST /_emdash/api/settings/frontend-token/rotate — mint a new frontend token; the old one stops working. */\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, apiSuccess, handleError } from \"#api/error.js\";\nimport { rotateFrontendToken } from \"../../../../../auth/frontend-account.js\";\n\nexport const prerender = false;\n\nexport const POST: APIRoute = async ({ locals }) => {\n\tconst { emdash, user } = locals;\n\tconst denied = requirePerm(user, \"settings:manage\");\n\tif (denied) return denied;\n\tif (!emdash?.db) return apiError(\"NOT_AVAILABLE\", \"Database not available\", 503);\n\ttry {\n\t\tconst account = await rotateFrontendToken(emdash.db);\n\t\treturn apiSuccess({ token: account.token });\n\t} catch (error) {\n\t\treturn handleError(error);\n\t}\n};\n"],"mappings":";;;;;;;;;;AAOA,MAAa,YAAY;AAEzB,MAAa,OAAiB,OAAO,EAAE,aAAa;CACnD,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,SAAS,YAAY,MAAM,kBAAkB;AACnD,KAAI,OAAQ,QAAO;AACnB,KAAI,CAAC,QAAQ,GAAI,QAAO,SAAS,iBAAiB,0BAA0B,IAAI;AAChF,KAAI;AAEH,SAAO,WAAW,EAAE,QADJ,MAAM,oBAAoB,OAAO,GAAG,EACjB,OAAO,CAAC;UACnC,OAAO;AACf,SAAO,YAAY,MAAM"}