@agenticcli/shipguard 0.8.0 → 0.8.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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "secrets": "58c191e144049b09abc0b59ec76a9f902a0634a439aedac97afffa4c3aa51918",
3
- "auth": "58c191e144049b09abc0b59ec76a9f902a0634a439aedac97afffa4c3aa51918",
4
- "database": "58c191e144049b09abc0b59ec76a9f902a0634a439aedac97afffa4c3aa51918",
5
- "deployment": "58c191e144049b09abc0b59ec76a9f902a0634a439aedac97afffa4c3aa51918",
6
- "payments": "58c191e144049b09abc0b59ec76a9f902a0634a439aedac97afffa4c3aa51918"
2
+ "secrets": "860c45ff272d99ca2e1d8eddfdab015d17854fb9bc51d0fa953471cd4bdac694",
3
+ "auth": "860c45ff272d99ca2e1d8eddfdab015d17854fb9bc51d0fa953471cd4bdac694",
4
+ "database": "860c45ff272d99ca2e1d8eddfdab015d17854fb9bc51d0fa953471cd4bdac694",
5
+ "deployment": "860c45ff272d99ca2e1d8eddfdab015d17854fb9bc51d0fa953471cd4bdac694",
6
+ "payments": "860c45ff272d99ca2e1d8eddfdab015d17854fb9bc51d0fa953471cd4bdac694"
7
7
  }
@@ -207,6 +207,62 @@ async function exchangeApiKeyForToken(apiKey, apiUrl) {
207
207
  };
208
208
  return body.access_token;
209
209
  }
210
+ var RefreshUnavailableError = class extends Error {
211
+ constructor(message, retryAfterSeconds) {
212
+ super(message);
213
+ this.retryAfterSeconds = retryAfterSeconds;
214
+ this.name = "RefreshUnavailableError";
215
+ }
216
+ retryAfterSeconds;
217
+ };
218
+ var REFRESH_MAX_TRIES = 3;
219
+ var REFRESH_MAX_WAIT_SECONDS = 10;
220
+ var sleepMs = (ms) => new Promise((r) => setTimeout(r, ms));
221
+ async function readBodyQuietly(res) {
222
+ try {
223
+ const probe = typeof res.clone === "function" ? res.clone() : res;
224
+ return await probe.json();
225
+ } catch {
226
+ return null;
227
+ }
228
+ }
229
+ async function fetchRefreshWithRetry(apiUrl, refreshToken) {
230
+ let lastWait = 1;
231
+ for (let attempt = 1; ; attempt++) {
232
+ const backoff = 2 ** (attempt - 1);
233
+ let res;
234
+ let detail;
235
+ let wait = backoff;
236
+ let sleepSeconds = Math.random() * backoff;
237
+ try {
238
+ res = await fetch(`${apiUrl}/api/auth/device/refresh`, {
239
+ method: "POST",
240
+ headers: { "Content-Type": "application/json" },
241
+ body: JSON.stringify({ refresh_token: refreshToken })
242
+ });
243
+ const transient = res.status === 429 || res.status === 408 || res.status === 425 || res.status >= 500;
244
+ if (res.ok || !transient) return res;
245
+ if (res.status >= 500 && isPlatformUnavailable(res, await readBodyQuietly(res))) return res;
246
+ const retryAfter = parseRetryAfterSeconds(res.headers);
247
+ if (retryAfter !== void 0) {
248
+ wait = Math.max(retryAfter, backoff);
249
+ sleepSeconds = wait;
250
+ }
251
+ detail = `HTTP ${res.status}`;
252
+ } catch (err) {
253
+ detail = err instanceof Error ? err.message : String(err);
254
+ }
255
+ lastWait = wait;
256
+ if (attempt >= REFRESH_MAX_TRIES || wait > REFRESH_MAX_WAIT_SECONDS) {
257
+ throw new RefreshUnavailableError(
258
+ `Token refresh is rate limited or temporarily unavailable (${detail}); your login is kept, try again in ${lastWait} s.`,
259
+ lastWait
260
+ );
261
+ }
262
+ console.error(`[shipguard] Token refresh got ${detail}; retrying in ${wait} s (attempt ${attempt}/${REFRESH_MAX_TRIES}).`);
263
+ await sleepMs(sleepSeconds * 1e3);
264
+ }
265
+ }
210
266
  async function getAuthToken(apiUrl) {
211
267
  const apiKey = process.env.SHIPGUARD_API_KEY;
212
268
  if (apiKey) {
@@ -222,11 +278,7 @@ async function getAuthToken(apiUrl) {
222
278
  if (creds.refreshToken && creds.apiUrl) {
223
279
  try {
224
280
  assertTrustedApiUrl(creds.apiUrl);
225
- const res = await fetch(`${creds.apiUrl}/api/auth/device/refresh`, {
226
- method: "POST",
227
- headers: { "Content-Type": "application/json" },
228
- body: JSON.stringify({ refresh_token: creds.refreshToken })
229
- });
281
+ const res = await fetchRefreshWithRetry(creds.apiUrl, creds.refreshToken);
230
282
  if (res.ok) {
231
283
  const { access_token, refresh_token, expires_in } = await res.json();
232
284
  await saveCredentials({
@@ -237,13 +289,7 @@ async function getAuthToken(apiUrl) {
237
289
  });
238
290
  return access_token;
239
291
  }
240
- let refusedBody = null;
241
- try {
242
- const probe = typeof res.clone === "function" ? res.clone() : res;
243
- refusedBody = await probe.json();
244
- } catch {
245
- refusedBody = null;
246
- }
292
+ const refusedBody = await readBodyQuietly(res);
247
293
  if (isPlatformUnavailable(res, refusedBody)) {
248
294
  throw new PlatformUnavailableError(
249
295
  typeof refusedBody?.error === "string" ? refusedBody.error : PLATFORM_UNAVAILABLE_DEFAULT_MESSAGE,
@@ -255,6 +301,7 @@ async function getAuthToken(apiUrl) {
255
301
  );
256
302
  } catch (err) {
257
303
  if (err instanceof PlatformUnavailableError) throw err;
304
+ if (err instanceof RefreshUnavailableError) throw err;
258
305
  const detail = err instanceof Error ? err.message : String(err);
259
306
  console.error(
260
307
  `[shipguard] Token refresh failed \u2014 you will be asked to log in again. Reason: ${detail}`
@@ -3413,6 +3460,9 @@ async function fetchProRules(frameworks, categories, apiUrl, scanId, floorPath)
3413
3460
  if (err instanceof PlatformUnavailableError) {
3414
3461
  throw new ProFetchError("PLATFORM_UNAVAILABLE", err.message, { retryAfterSeconds: err.retryAfterSeconds });
3415
3462
  }
3463
+ if (err instanceof RefreshUnavailableError) {
3464
+ throw new ProFetchError("RATE_LIMITED", err.message, { retryAfterSeconds: err.retryAfterSeconds });
3465
+ }
3416
3466
  throw err;
3417
3467
  }
3418
3468
  if (!token) throw new ProFetchError("AUTH_FAILED", "Not authenticated. Run `shipguard login` first.");
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.0",
2
+ "version": "0.8.1",
3
3
  "packageName": "@agenticcli/shipguard",
4
4
  "license": "Elastic-2.0",
5
5
  "licenseDisplay": "ELv2",
@@ -142,5 +142,5 @@
142
142
  ],
143
143
  "installSnippet": "npx @agenticcli/shipguard scan --changed --strict --json",
144
144
  "re2Engine": true,
145
- "generatedAt": "2026-10-21T08:40:16.734Z"
145
+ "generatedAt": "2026-10-21T12:43:20.985Z"
146
146
  }
package/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  secretsCheck,
25
25
  validateBundleCompile,
26
26
  writeSecureFileSync
27
- } from "./chunk-VJBU6FNW.js";
27
+ } from "./chunk-BGWAAJ5S.js";
28
28
  import {
29
29
  DEFAULT_MAX_FILES,
30
30
  DEFAULT_MAX_FILE_SIZE_BYTES,
@@ -4149,7 +4149,7 @@ function sendTelemetry(input, opts = {}) {
4149
4149
 
4150
4150
  // src/commands/scan.ts
4151
4151
  var LEARN_MORE = `Docs ${goLink("docs")} \xB7 Site ${goLink("site")} \xB7 Pricing ${goLink("pricing")} \xB7 Issues https://github.com/agenticcli/shipguard/issues`;
4152
- var CLI_VERSION = true ? "0.8.0" : process.env.npm_package_version ?? "0.0.0-dev";
4152
+ var CLI_VERSION = true ? "0.8.1" : process.env.npm_package_version ?? "0.0.0-dev";
4153
4153
  function resolveExitCode(opts) {
4154
4154
  if (opts.strict && (opts.blockingCount > 0 || opts.degraded === true || opts.recommendation === "DO_NOT_SHIP")) {
4155
4155
  return EXIT_CODES.BLOCKED;
@@ -4360,7 +4360,7 @@ async function runScan(ctx) {
4360
4360
  logger.info("Detecting stack...");
4361
4361
  }
4362
4362
  try {
4363
- const { fetchProRules } = await import("./pro-scanner-5GYWJ7AS.js");
4363
+ const { fetchProRules } = await import("./pro-scanner-ZKL6L5L6.js");
4364
4364
  const { hasConfig, generateConfig } = await import("./config-generator-4MK6PGY5.js");
4365
4365
  const frameworks = detectedFrameworks;
4366
4366
  if (!hasConfig(cwd)) {
@@ -4742,7 +4742,7 @@ function loginCommand() {
4742
4742
  Visit: ${safeUrl.href}`);
4743
4743
  } else {
4744
4744
  logger.warn("\nThe server sent a verification URL that is not a safe link to the ShipGuard server, so it was not opened or shown.");
4745
- logger.info(`Open ${apiUrl}/activate in your browser yourself.`);
4745
+ logger.info(`Open ${apiUrl}/auth/device in your browser yourself.`);
4746
4746
  }
4747
4747
  logger.info(`Enter code: ${String(user_code).replace(/[^\x20-\x7E]/g, "")}
4748
4748
  `);
@@ -4831,7 +4831,7 @@ function statusCommand() {
4831
4831
  // src/commands/history.ts
4832
4832
  import { Command as Command6 } from "commander";
4833
4833
  import { resolve as resolve5 } from "path";
4834
- var CLI_VERSION2 = true ? "0.8.0" : process.env.npm_package_version ?? "0.0.0-dev";
4834
+ var CLI_VERSION2 = true ? "0.8.1" : process.env.npm_package_version ?? "0.0.0-dev";
4835
4835
  function historyCommand() {
4836
4836
  return new Command6("history").description("Show recent local scan history for this repo (read-only; --json for machine output)").argument("[path]", "Path to project root (defaults to current directory)").option("--json", "Output as JSON").option("--limit <n>", "Number of recent scans to show", (v) => Number.parseInt(v, 10) || 10, 10).action(async (scanPath, opts) => {
4837
4837
  const cwd = scanPath ? resolve5(scanPath) : process.cwd();
@@ -5153,7 +5153,7 @@ Exit codes:
5153
5153
 
5154
5154
  // src/commands/schema.ts
5155
5155
  import { Command as Command8 } from "commander";
5156
- var CLI_VERSION3 = true ? "0.8.0" : process.env.npm_package_version ?? "0.0.0-dev";
5156
+ var CLI_VERSION3 = true ? "0.8.1" : process.env.npm_package_version ?? "0.0.0-dev";
5157
5157
  var CURRENT_SCHEMA_VERSION2 = "5";
5158
5158
  function buildSchemaContract(limits) {
5159
5159
  const src = (value, fallback) => value === fallback ? "default" : "policy";
@@ -5506,7 +5506,7 @@ if (rawArgs[0] === "?") {
5506
5506
  process.argv = [process.argv[0], process.argv[1], "help"];
5507
5507
  }
5508
5508
  program.name("shipguard").description("CLI-first release gate for AI-built apps").version(
5509
- true ? "0.8.0" : process.env.npm_package_version ?? "0.0.0-dev"
5509
+ true ? "0.8.1" : process.env.npm_package_version ?? "0.0.0-dev"
5510
5510
  ).helpCommand(false).addHelpText("after", `
5511
5511
  Learn more:
5512
5512
  Docs ${goLink("docs")}
@@ -7,7 +7,7 @@ import {
7
7
  runProRules,
8
8
  runProRulesWithDispatch,
9
9
  validateBundleCompile
10
- } from "./chunk-VJBU6FNW.js";
10
+ } from "./chunk-BGWAAJ5S.js";
11
11
  import "./chunk-KGIK7XNK.js";
12
12
  export {
13
13
  NoRulesAppliedError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticcli/shipguard",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "CLI-first release gate for AI-built apps",
5
5
  "type": "module",
6
6
  "main": "./dist/cli.js",