@keystrokehq/cli 0.1.108 → 0.1.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist-BFOvwXwm.mjs.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -3418,6 +3418,11 @@ function sleep$1(ms) {
|
|
|
3418
3418
|
function isDeviceTokenError(value) {
|
|
3419
3419
|
return typeof value === "object" && value !== null && "error" in value && typeof value.error === "string";
|
|
3420
3420
|
}
|
|
3421
|
+
/** Better Auth (and some proxies) return this instead of OAuth slow_down. */
|
|
3422
|
+
function isRateLimitedError(error) {
|
|
3423
|
+
if (error.status === 429) return true;
|
|
3424
|
+
return typeof error.message === "string" && error.message.toLowerCase().includes("too many requests");
|
|
3425
|
+
}
|
|
3421
3426
|
async function runDeviceLogin(options) {
|
|
3422
3427
|
const client = createCliAuthClient(options.baseURL);
|
|
3423
3428
|
const codeResult = await client.device.code({ client_id: options.clientId });
|
|
@@ -3458,13 +3463,13 @@ async function runDeviceLogin(options) {
|
|
|
3458
3463
|
await sleep$1(pollIntervalMs);
|
|
3459
3464
|
continue;
|
|
3460
3465
|
}
|
|
3461
|
-
if (oauthError?.error === "
|
|
3466
|
+
if (oauthError?.error === "expired_token") throw new Error("Device code expired. Run auth login again.");
|
|
3467
|
+
if (oauthError?.error === "access_denied") throw new Error("Device authorization was denied.");
|
|
3468
|
+
if (oauthError?.error === "slow_down" || isRateLimitedError(errorPayload)) {
|
|
3462
3469
|
pollIntervalMs += 5e3;
|
|
3463
3470
|
await sleep$1(pollIntervalMs);
|
|
3464
3471
|
continue;
|
|
3465
3472
|
}
|
|
3466
|
-
if (oauthError?.error === "expired_token") throw new Error("Device code expired. Run auth login again.");
|
|
3467
|
-
if (oauthError?.error === "access_denied") throw new Error("Device authorization was denied.");
|
|
3468
3473
|
throw new Error(oauthError?.error_description ?? errorPayload.message ?? "Device login failed");
|
|
3469
3474
|
}
|
|
3470
3475
|
throw new Error("Device code expired. Run auth login again.");
|