{"version":3,"file":"oauth-authorization-server.mjs","names":[],"sources":["../../../../../src/astro/routes/api/well-known/oauth-authorization-server.ts"],"sourcesContent":["/**\n * GET /.well-known/oauth-authorization-server/_emdash\n *\n * RFC 8414 Authorization Server Metadata. The path follows the RFC 8414\n * convention: the issuer's pathname (/_emdash) is appended after\n * /.well-known/oauth-authorization-server, so MCP clients can discover\n * it automatically from the authorization_servers URL.\n *\n * Public, unauthenticated.\n */\n\nimport type { APIRoute } from \"astro\";\n// @ts-ignore - virtual module\nimport virtualConfig from \"virtual:emdash/config\";\n\nimport { getPublicOrigin } from \"#api/public-url.js\";\nimport { builtinPolicies } from \"@premium-cms/auth\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ url, locals }) => {\n\t// Same fallback as oauth-protected-resource.ts (#2016).\n\tconst origin = getPublicOrigin(url, locals.emdash?.config ?? virtualConfig);\n\tconst issuer = `${origin}/_emdash`;\n\n\treturn Response.json(\n\t\t{\n\t\t\tissuer,\n\t\t\tauthorization_endpoint: `${origin}/_emdash/oauth/authorize`,\n\t\t\ttoken_endpoint: `${origin}/_emdash/api/oauth/token`,\n\t\t\t// OAuth scopes are policy slugs; the built-in ones are always present.\n\t\t\tscopes_supported: builtinPolicies().map((p) => p.slug),\n\t\t\tresponse_types_supported: [\"code\"],\n\t\t\tgrant_types_supported: [\n\t\t\t\t\"authorization_code\",\n\t\t\t\t\"refresh_token\",\n\t\t\t\t\"urn:ietf:params:oauth:grant-type:device_code\",\n\t\t\t],\n\t\t\tcode_challenge_methods_supported: [\"S256\"],\n\t\t\tregistration_endpoint: `${origin}/_emdash/api/oauth/register`,\n\t\t\ttoken_endpoint_auth_methods_supported: [\"none\"],\n\t\t\tdevice_authorization_endpoint: `${origin}/_emdash/api/oauth/device/code`,\n\t\t},\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"Cache-Control\": \"public, max-age=3600\",\n\t\t\t\t\"Access-Control-Allow-Origin\": \"*\",\n\t\t\t},\n\t\t},\n\t);\n};\n"],"mappings":";;;;;AAkBA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,KAAK,aAAa;CAEvD,MAAM,SAAS,gBAAgB,KAAK,OAAO,QAAQ,UAAU,cAAc;CAC3E,MAAM,SAAS,GAAG,OAAO;AAEzB,QAAO,SAAS,KACf;EACC;EACA,wBAAwB,GAAG,OAAO;EAClC,gBAAgB,GAAG,OAAO;EAE1B,kBAAkB,iBAAiB,CAAC,KAAK,MAAM,EAAE,KAAK;EACtD,0BAA0B,CAAC,OAAO;EAClC,uBAAuB;GACtB;GACA;GACA;GACA;EACD,kCAAkC,CAAC,OAAO;EAC1C,uBAAuB,GAAG,OAAO;EACjC,uCAAuC,CAAC,OAAO;EAC/C,+BAA+B,GAAG,OAAO;EACzC,EACD,EACC,SAAS;EACR,iBAAiB;EACjB,+BAA+B;EAC/B,EACD,CACD"}