INNER CODE UNIT · TypeScript
nextDevicePollIntervalMs
JuliusBrussee/caveman · packages/device-auth/src/index.ts:27
export function nextDevicePollIntervalMs(currentMs: number, errorCode?: string): number {
const current = Math.max(0, Number.isFinite(currentMs) ? currentMs : 0);
return errorCode === "slow_down" ? current + 5000 : current;
}
// DeviceAuthError carries the HTTP status and the server's error code so a
// caller can tell "sign-in is closed here" (403 cave_device_login_disabled, or
// 404 where the endpoint does not exist) from a broken network.
export class DeviceAuthError extends Error {
readonly status: number;
readonly code: string | undefined;
constructor(message: string, status: number, code: string | undefined) {
super(message);
this.name = "DeviceAuthError";
this.status = status;
this.code = code;
}
}