(code: string)
| 127 | }): boolean { |
| 128 | return new Date(request.expires_at) < new Date() || request.status === 'expired'; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Approve a device authorization request. |
| 133 | */ |
| 134 | export async function approveDeviceAuthRequest(code: string, userId: string): Promise<void> { |
| 135 | const now = new Date().toISOString(); |
| 136 | const [approved] = await db |
| 137 | .update(device_auth_requests) |
| 138 | .set({ |
| 139 | status: 'approved', |
| 140 | kilo_user_id: userId, |
| 141 | approved_at: now, |
| 142 | }) |
| 143 | .where( |
| 144 | and( |
| 145 | eq(device_auth_requests.code, code), |
| 146 | eq(device_auth_requests.status, 'pending'), |
| 147 | gt(device_auth_requests.expires_at, now) |
no test coverage detected