( message: string, ok: boolean, reason: McpOauthCallbackReason, serverId?: string )
| 40 | } |
| 41 | |
| 42 | function htmlClose( |
| 43 | message: string, |
| 44 | ok: boolean, |
| 45 | reason: McpOauthCallbackReason, |
| 46 | serverId?: string |
| 47 | ): NextResponse { |
| 48 | const safeMessage = escapeHtml(message) |
| 49 | const title = ok ? 'Connected' : 'Connection failed' |
| 50 | const body = `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title></head><body style="font-family: system-ui; padding: 24px"><p>${safeMessage}</p><script> |
| 51 | try { window.opener && window.opener.postMessage({ type: 'mcp-oauth', ok: ${ok ? 'true' : 'false'}, serverId: ${jsonLiteral(serverId)}, reason: ${jsonLiteral(reason)} }, window.location.origin) } catch (e) {} |
| 52 | setTimeout(function () { window.close() }, 800) |
| 53 | </script></body></html>` |
| 54 | return new NextResponse(body, { |
| 55 | headers: { 'Content-Type': 'text/html; charset=utf-8' }, |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | export const GET = withRouteHandler(async (request: NextRequest) => { |
| 60 | const parsed = await parseRequest(mcpOauthCallbackContract, request, {}) |
no test coverage detected