(request: Request)
| 8 | import { |
| 9 | buildDeviceAuthVerificationUrl, |
| 10 | getDeviceAuthAppModeFromRequestUrl, |
| 11 | } from '@/app/device-auth/device-auth-url'; |
| 12 | import { withRestTiming } from '@/lib/observability/request-timing'; |
| 13 | |
| 14 | export const POST = withRestTiming('/api/device-auth/codes', async (request: Request) => { |
| 15 | const headersList = await headers(); |
| 16 | const userAgent = headersList.get('user-agent') || undefined; |
| 17 | const ipAddress = headersList.get('x-forwarded-for') || undefined; |
| 18 | |
| 19 | try { |
| 20 | const { code, userCode, deviceCode, expiresAt } = await createDeviceAuthRequest({ |
| 21 | userAgent, |
| 22 | ipAddress, |
| 23 | }); |
| 24 | |
| 25 | const verificationUrl = buildDeviceAuthVerificationUrl(APP_URL, userCode, { |
| 26 | app: getDeviceAuthAppModeFromRequestUrl(request.url), |
| 27 | }); |
| 28 | |
| 29 | return NextResponse.json({ |
| 30 | code, |
| 31 | user_code: userCode, |
| 32 | device_code: deviceCode, |
nothing calls this directly
no test coverage detected