INNER CODE UNIT · TypeScript

intervalMs

JuliusBrussee/caveman · packages/device-auth/src/index.ts:146

  let intervalMs = Math.max(0, Number(code.interval ?? 5)) * 1000;
  const deadline = Date.now() + code.expires_in * 1000;
  while (Date.now() < deadline) {
    let payload: Record<string, unknown>;
    let status = 0;
    let retryAfterMs = 0;
    try {
      const response = await fetcher(`${baseURL}/api/v1/auth/device/token`, {
        method: "POST",
        redirect: "manual",
        headers: { "content-type": "application/json", "x-cave-client": options.client },
        body: JSON.stringify({ device_code: code.device_code }),
        signal: requestSignal(options.signal, 5000),
      });
      status = response.status;
      const retryAfter = response.headers.get("retry-after");
      if (retryAfter !== null) {
        const seconds = Number(retryAfter);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…