respond with relative code expiration time

This commit is contained in:
miloschwartz
2025-12-01 12:36:02 -05:00
parent 92125611e9
commit 8c62dfa706
3 changed files with 10 additions and 8 deletions

View File

@@ -22,7 +22,7 @@ export type StartDeviceWebAuthBody = z.infer<typeof bodySchema>;
export type StartDeviceWebAuthResponse = {
code: string;
expiresAt: number;
expiresInSeconds: number;
};
// Helper function to generate device code in format A1AJ-N5JD
@@ -131,10 +131,13 @@ export async function startDeviceWebAuth(
createdAt: Date.now()
});
// calculate relative expiration in seconds
const expiresInSeconds = Math.floor((expiresAt - Date.now()) / 1000);
return response<StartDeviceWebAuthResponse>(res, {
data: {
code,
expiresAt
expiresInSeconds
},
success: true,
error: false,