@great-arrow/cli 0.1.50 → 0.1.51
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 +31 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9399,7 +9399,7 @@ function isNodeError(value) {
|
|
|
9399
9399
|
|
|
9400
9400
|
// src/lib/version.ts
|
|
9401
9401
|
var CLI_PACKAGE_NAME = "@great-arrow/cli";
|
|
9402
|
-
var CLI_VERSION = "0.1.
|
|
9402
|
+
var CLI_VERSION = "0.1.51";
|
|
9403
9403
|
var GAD_INSTALL_VERSION = "2026.08.08";
|
|
9404
9404
|
var GAD_INSTALL_MIN_VERSION = "2026.06.22";
|
|
9405
9405
|
var GAD_INSTALL_HEADER = "X-GAD-Install-Version";
|
|
@@ -10414,14 +10414,14 @@ async function storedPairOtherThan(ours) {
|
|
|
10414
10414
|
debugSwallow("refresh.reread", err);
|
|
10415
10415
|
}
|
|
10416
10416
|
if (stored?.kind !== "oauth") return null;
|
|
10417
|
+
if (stored.credential.clientId !== ours.clientId || stored.credential.apiUrl.replace(/\/$/, "") !== ours.apiUrl.replace(/\/$/, "")) {
|
|
10418
|
+
throw networkError(
|
|
10419
|
+
"The stored session changed while renewing it.",
|
|
10420
|
+
"Retry the command with the current session."
|
|
10421
|
+
);
|
|
10422
|
+
}
|
|
10417
10423
|
return stored.credential.refreshToken === ours.refreshToken ? null : stored.credential;
|
|
10418
10424
|
}
|
|
10419
|
-
async function rotatedByAnotherProcess(ours) {
|
|
10420
|
-
const theirs = await storedPairOtherThan(ours);
|
|
10421
|
-
if (!theirs) return null;
|
|
10422
|
-
if (Date.now() >= theirs.accessExpiresAt - REFRESH_SKEW_MS) return null;
|
|
10423
|
-
return theirs;
|
|
10424
|
-
}
|
|
10425
10425
|
async function resolveAuth() {
|
|
10426
10426
|
const config = await loadConfig();
|
|
10427
10427
|
const configApiUrl = config.api_url || DEFAULT_API_URL;
|
|
@@ -10512,20 +10512,37 @@ async function ensureFreshAccessToken(credential) {
|
|
|
10512
10512
|
}
|
|
10513
10513
|
async function doRefresh(credential) {
|
|
10514
10514
|
const held = await acquireRefreshLock();
|
|
10515
|
+
let current = credential;
|
|
10515
10516
|
try {
|
|
10516
|
-
const theirs = await
|
|
10517
|
-
if (theirs)
|
|
10517
|
+
const theirs = await storedPairOtherThan(credential);
|
|
10518
|
+
if (theirs) {
|
|
10519
|
+
current = theirs;
|
|
10520
|
+
if (Date.now() < current.accessExpiresAt - REFRESH_SKEW_MS)
|
|
10521
|
+
return current;
|
|
10522
|
+
}
|
|
10523
|
+
if (!held) {
|
|
10524
|
+
throw networkError(
|
|
10525
|
+
"Session renewal is already in progress.",
|
|
10526
|
+
"Retry shortly; your saved session has been kept."
|
|
10527
|
+
);
|
|
10528
|
+
}
|
|
10518
10529
|
const refreshed = await refreshTokens({
|
|
10519
|
-
apiUrl:
|
|
10520
|
-
clientId:
|
|
10521
|
-
refreshToken:
|
|
10530
|
+
apiUrl: current.apiUrl,
|
|
10531
|
+
clientId: current.clientId,
|
|
10532
|
+
refreshToken: current.refreshToken
|
|
10522
10533
|
});
|
|
10523
10534
|
await saveOAuthCredential(refreshed);
|
|
10524
10535
|
return refreshed;
|
|
10525
10536
|
} catch (err) {
|
|
10526
10537
|
if (err instanceof RefreshRejected) {
|
|
10527
|
-
const theirs = await storedPairOtherThan(
|
|
10528
|
-
if (theirs)
|
|
10538
|
+
const theirs = await storedPairOtherThan(current);
|
|
10539
|
+
if (theirs) {
|
|
10540
|
+
if (Date.now() < theirs.accessExpiresAt) return theirs;
|
|
10541
|
+
throw networkError(
|
|
10542
|
+
"Another process updated the session during renewal.",
|
|
10543
|
+
"Retry shortly; your saved session has been kept."
|
|
10544
|
+
);
|
|
10545
|
+
}
|
|
10529
10546
|
await clearStoredCredential();
|
|
10530
10547
|
throw sessionExpired();
|
|
10531
10548
|
}
|