@tinycloud/cli 1.0.0-beta.18 → 1.0.0-beta.19
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/legacy-entry.js +31 -0
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +1 -1
- package/skills/tc-cli/AUTH.md +1 -1
package/dist/legacy-entry.js
CHANGED
|
@@ -14594,6 +14594,34 @@ function errorDescription(value) {
|
|
|
14594
14594
|
const description = value?.errorDescription ?? value?.error_description;
|
|
14595
14595
|
return typeof description === "string" && description.length > 0 ? description : void 0;
|
|
14596
14596
|
}
|
|
14597
|
+
function retryAfterSeconds(response) {
|
|
14598
|
+
const value = response.headers.get("retry-after");
|
|
14599
|
+
if (!value) return void 0;
|
|
14600
|
+
let seconds;
|
|
14601
|
+
if (/^\d+$/.test(value)) {
|
|
14602
|
+
seconds = Number(value);
|
|
14603
|
+
if (!Number.isSafeInteger(seconds)) return void 0;
|
|
14604
|
+
} else {
|
|
14605
|
+
if (!/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:0[1-9]|[12]\d|3[01]) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} (?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d GMT$/.test(value)) {
|
|
14606
|
+
return void 0;
|
|
14607
|
+
}
|
|
14608
|
+
const retryAt = Date.parse(value);
|
|
14609
|
+
if (!Number.isFinite(retryAt) || new Date(retryAt).toUTCString() !== value) return void 0;
|
|
14610
|
+
seconds = Math.ceil((retryAt - Date.now()) / 1e3);
|
|
14611
|
+
}
|
|
14612
|
+
return seconds > 0 && seconds <= 600 ? seconds : void 0;
|
|
14613
|
+
}
|
|
14614
|
+
function deviceAuthRateLimit(response) {
|
|
14615
|
+
const retrySeconds = retryAfterSeconds(response);
|
|
14616
|
+
return new CLIError(
|
|
14617
|
+
"DEVICE_AUTH_RATE_LIMITED",
|
|
14618
|
+
"OpenKey rate limited device sign-in requests from this network",
|
|
14619
|
+
ExitCode.ERROR,
|
|
14620
|
+
{
|
|
14621
|
+
hint: `OpenKey allows 5 device sign-in requests per 10 minutes from this network; wait up to 10 minutes, then retry once. The limit is shared by every agent on this network.${retrySeconds !== void 0 ? ` Retry after ${retrySeconds} seconds.` : ""}`
|
|
14622
|
+
}
|
|
14623
|
+
);
|
|
14624
|
+
}
|
|
14597
14625
|
function publicSessionJwk(value) {
|
|
14598
14626
|
const publicJwk = publicJwkForDelegation(value);
|
|
14599
14627
|
const record = publicJwk;
|
|
@@ -14774,6 +14802,9 @@ async function acquireDeviceDelegation(input) {
|
|
|
14774
14802
|
if (!startResponse.ok) {
|
|
14775
14803
|
const code2 = errorCode(startValue);
|
|
14776
14804
|
const description = errorDescription(startValue);
|
|
14805
|
+
if (startResponse.status === 429 && code2 === "rate_limited") {
|
|
14806
|
+
throw deviceAuthRateLimit(startResponse);
|
|
14807
|
+
}
|
|
14777
14808
|
if (code2 === "invalid_scope") {
|
|
14778
14809
|
throw new CLIError(
|
|
14779
14810
|
"SCOPE_REJECTED",
|