skillgrove 0.1.0 → 0.1.1
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/lib/api.mjs +6 -0
- package/package.json +1 -1
package/lib/api.mjs
CHANGED
|
@@ -157,6 +157,12 @@ export async function login({ agent, say, open = true }) {
|
|
|
157
157
|
client_id: CLIENT_ID,
|
|
158
158
|
},
|
|
159
159
|
});
|
|
160
|
+
if (res.status === 429) {
|
|
161
|
+
// Rate-limited (a shared IP address, or an older server's limit): wait and keep polling.
|
|
162
|
+
const retryAfter = Number(res.headers.get('x-retry-after') ?? res.headers.get('retry-after'));
|
|
163
|
+
await sleep(Math.min(Math.max(Number.isFinite(retryAfter) ? retryAfter : 0, 5), 60) * 1000);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
160
166
|
const data = await res.json().catch(() => ({}));
|
|
161
167
|
if (res.ok && data.access_token) {
|
|
162
168
|
const issued = await json(
|