@pollinations/cli 0.1.93 → 0.1.94
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/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var init_package = __esm({
|
|
|
19
19
|
"package.json"() {
|
|
20
20
|
package_default = {
|
|
21
21
|
name: "@pollinations/cli",
|
|
22
|
-
version: "0.1.
|
|
22
|
+
version: "0.1.94",
|
|
23
23
|
description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
|
|
24
24
|
type: "module",
|
|
25
25
|
bin: {
|
|
@@ -420,8 +420,8 @@ function profileName(profile) {
|
|
|
420
420
|
}
|
|
421
421
|
async function pollForToken(deviceCode, interval, expiresIn) {
|
|
422
422
|
const deadline = Date.now() + expiresIn * 1e3;
|
|
423
|
-
|
|
424
|
-
while (Date.now() < deadline) {
|
|
423
|
+
let pollMs = Math.max(interval, 5) * 1e3;
|
|
424
|
+
while (Date.now() + pollMs < deadline) {
|
|
425
425
|
await new Promise((r) => setTimeout(r, pollMs));
|
|
426
426
|
const res = await fetch(`${ENTER_URL}/api/device/token`, {
|
|
427
427
|
method: "POST",
|
|
@@ -433,8 +433,11 @@ async function pollForToken(deviceCode, interval, expiresIn) {
|
|
|
433
433
|
});
|
|
434
434
|
const body = await res.json();
|
|
435
435
|
if (res.ok && body.access_token) return body;
|
|
436
|
-
if (body.error === "
|
|
436
|
+
if (body.error === "slow_down") {
|
|
437
|
+
pollMs += 5e3;
|
|
437
438
|
continue;
|
|
439
|
+
}
|
|
440
|
+
if (body.error === "authorization_pending") continue;
|
|
438
441
|
return body;
|
|
439
442
|
}
|
|
440
443
|
return { error: "expired_token", error_description: "Device code expired" };
|