@apilift/cli 1.5.2 → 1.5.3-dev.1792314011.35e5b85595e90273e189e53c1f0f3cf89400cdae

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/apilift.js CHANGED
@@ -29031,6 +29031,26 @@ var init_session = __esm({
29031
29031
  }
29032
29032
  });
29033
29033
 
29034
+ // src/browser-response.ts
29035
+ import { createHash as createHash3 } from "node:crypto";
29036
+ async function browserResponseBody(client, scopeId, value, maxBytes = 48 * 1024 * 1024) {
29037
+ if (value.bodyArtifact !== void 0) {
29038
+ const artifact = value.bodyArtifact;
29039
+ if (value.body != null || !artifact || typeof artifact.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(artifact.sha256) || !Number.isInteger(artifact.bytes) || Number(artifact.bytes) < 1 || Number(artifact.bytes) > maxBytes || artifact.encoding !== "utf-8") throw new Error("Chrome returned invalid response evidence metadata");
29040
+ const bytes = await client.blob(scopeId, artifact.sha256);
29041
+ if (!bytes || bytes.length !== artifact.bytes || createHash3("sha256").update(bytes).digest("hex") !== artifact.sha256) throw new Error("Chrome response evidence is missing or failed its integrity check");
29042
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
29043
+ }
29044
+ if (value.body == null) return null;
29045
+ if (typeof value.body !== "string" || Buffer.byteLength(value.body, "utf8") > maxBytes) throw new Error("Chrome did not return complete response evidence");
29046
+ return value.body;
29047
+ }
29048
+ var init_browser_response = __esm({
29049
+ "src/browser-response.ts"() {
29050
+ "use strict";
29051
+ }
29052
+ });
29053
+
29034
29054
  // src/timings.ts
29035
29055
  import { appendFileSync } from "node:fs";
29036
29056
  import { resolve } from "node:path";
@@ -31012,7 +31032,7 @@ var init_drafts = __esm({
31012
31032
  }
31013
31033
  saveRequestAttempt(draftId, fingerprint2, state, responsePath, responseDigest) {
31014
31034
  this.requestAttempts();
31015
- this.state.db.prepare("INSERT INTO discovery_request_attempt (draft_id,fingerprint,state,response_path,response_digest) VALUES (?,?,?,?,?) ON CONFLICT(draft_id,fingerprint) DO UPDATE SET state=excluded.state,response_path=COALESCE(excluded.response_path,discovery_request_attempt.response_path),response_digest=COALESCE(excluded.response_digest,discovery_request_attempt.response_digest)").run(draftId, fingerprint2, state, responsePath ?? null, responseDigest ?? null);
31035
+ this.state.db.prepare("INSERT INTO discovery_request_attempt (draft_id,fingerprint,state,response_path,response_digest) VALUES (?,?,?,?,?) ON CONFLICT(draft_id,fingerprint) DO UPDATE SET state=excluded.state,response_path=CASE WHEN excluded.state='possibly-dispatched' AND excluded.response_path IS NULL THEN NULL ELSE COALESCE(excluded.response_path,discovery_request_attempt.response_path) END,response_digest=CASE WHEN excluded.state='possibly-dispatched' AND excluded.response_path IS NULL THEN NULL ELSE COALESCE(excluded.response_digest,discovery_request_attempt.response_digest) END").run(draftId, fingerprint2, state, responsePath ?? null, responseDigest ?? null);
31016
31036
  }
31017
31037
  artifactPath(draftId, name) {
31018
31038
  const directory = join5(this.root, "draft-evidence", draftId, randomUUID4());
@@ -31162,7 +31182,7 @@ ${JSON.stringify({ remove: true, expectedVersion: input2.baseVersion }, null, 2)
31162
31182
  });
31163
31183
 
31164
31184
  // src/discovery/credential-draft.ts
31165
- import { createHash as createHash3 } from "node:crypto";
31185
+ import { createHash as createHash4 } from "node:crypto";
31166
31186
  import { readFileSync as readFileSync5 } from "node:fs";
31167
31187
  function readCredentialDraft(filePath) {
31168
31188
  const parsed = parseDraftEnvelope(readFileSync5(filePath, "utf8"));
@@ -31173,7 +31193,7 @@ function readCredentialDraft(filePath) {
31173
31193
  }
31174
31194
  const transport = checked.definition;
31175
31195
  if (!transport.description.trim()) throw new Error(`Research credential acquisition and edit /definition/description in ${filePath}. Run discover check before secure setup`);
31176
- return { transport, fingerprint: createHash3("sha256").update(canonicalJson(transport)).digest("hex") };
31196
+ return { transport, fingerprint: createHash4("sha256").update(canonicalJson(transport)).digest("hex") };
31177
31197
  }
31178
31198
  var init_credential_draft = __esm({
31179
31199
  "src/discovery/credential-draft.ts"() {
@@ -31767,7 +31787,7 @@ var init_process = __esm({
31767
31787
  });
31768
31788
 
31769
31789
  // src/capture-server/client.ts
31770
- import { createHash as createHash4 } from "node:crypto";
31790
+ import { createHash as createHash5 } from "node:crypto";
31771
31791
  import { chmodSync as chmodSync5, existsSync as existsSync3, mkdirSync as mkdirSync6, readFileSync as readFileSync6, rmSync as rmSync4 } from "node:fs";
31772
31792
  import { dirname as dirname3, join as join6 } from "node:path";
31773
31793
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
@@ -31944,7 +31964,7 @@ var init_client2 = __esm({
31944
31964
  throw Object.assign(new Error(issue2.error?.message ?? `Capture server HTTP ${response.status}`), { code: issue2.error?.code ?? "capture-server-error" });
31945
31965
  }
31946
31966
  const bytes = Buffer.from(await response.arrayBuffer());
31947
- if (createHash4("sha256").update(bytes).digest("hex") !== digest2) throw Object.assign(new Error("Selected body digest does not match stored bytes"), { code: "blob-integrity" });
31967
+ if (createHash5("sha256").update(bytes).digest("hex") !== digest2) throw Object.assign(new Error("Selected body digest does not match stored bytes"), { code: "blob-integrity" });
31948
31968
  return bytes;
31949
31969
  }
31950
31970
  openScope(input2) {
@@ -32036,6 +32056,16 @@ var init_demand = __esm({
32036
32056
  // src/commands/browser.ts
32037
32057
  import { realpathSync } from "node:fs";
32038
32058
  import { dirname as dirname4, join as join8 } from "node:path";
32059
+ async function releaseStoppedCaptureForUse(state, sessionId, appId, client) {
32060
+ if (!state.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='discovery_capture'").get()) return;
32061
+ const rows = state.db.prepare("SELECT c.draft_id,c.scope_id FROM discovery_capture c JOIN discovery_draft d ON d.id=c.draft_id WHERE d.owner_session_id=? AND d.app_id=? AND c.phase='closed' AND c.scope_id IS NOT NULL").all(sessionId, appId);
32062
+ if (!rows.length) return;
32063
+ const active2 = new Set((await client.scopes()).scopes.map((scope2) => scope2.id));
32064
+ for (const row of rows) {
32065
+ if (active2.has(row.scope_id)) await client.retainScope(row.scope_id);
32066
+ state.db.prepare("UPDATE discovery_capture SET evidence_scope_id=COALESCE(evidence_scope_id,scope_id),scope_id=NULL WHERE draft_id=? AND scope_id=? AND phase='closed'").run(row.draft_id, row.scope_id);
32067
+ }
32068
+ }
32039
32069
  async function checkTabOwnership(client, origin, tab, app2, prefix, retry) {
32040
32070
  const state = await client.scopes();
32041
32071
  const active2 = state.scopes.filter((scope2) => scope2.pageOrigin === origin && scope2.kind !== "inspect");
@@ -32829,9 +32859,10 @@ async function sendBrowser(root, appId, contextName, pageOrigin, effect2, transp
32829
32859
  }
32830
32860
  if (!Number.isInteger(value.status) || value.bodyState && value.bodyState !== "complete") throw new Error("Chrome did not return complete response evidence");
32831
32861
  if (selection.timings && Number.isFinite(value.ms) && value.ms >= 0) selection.timings.appMs += value.ms;
32832
- const body = [204, 205, 304].includes(value.status) ? null : value.body ?? null;
32833
- const response = new Response(body, { status: value.status });
32834
- return { response, body: !response.ok ? null : decodedBody(value.body ?? "", response.status, allowNonJsonProbe) };
32862
+ const evidence = await browserResponseBody(client, scope2.id, value);
32863
+ const body = [204, 205, 304].includes(value.status) ? null : evidence;
32864
+ const response = new Response(body, { status: value.status, headers: value.headers });
32865
+ return { response, body: !response.ok && !response.headers.get("content-type")?.includes("json") ? null : decodedBody(evidence ?? "", response.status, allowNonJsonProbe) };
32835
32866
  }
32836
32867
  if (held.status === "uncertain") throw new Error("Chrome execution outcome is uncertain");
32837
32868
  await new Promise((resolve10) => setTimeout(resolve10, client.legacyBridge ? 200 : 10));
@@ -33022,6 +33053,7 @@ Inspect current action documentation: ${prefix(`actions show ${appName} ${action
33022
33053
  let diagnostic;
33023
33054
  let output2;
33024
33055
  try {
33056
+ if (liveBrowser) await releaseStoppedCaptureForUse(state, session.id, bundle2.app.id, liveBrowser);
33025
33057
  const primary = await sendRequest(prepared, action.effect);
33026
33058
  if (!primary.response.ok) {
33027
33059
  outcome = primary.response.status >= 500 ? "app-outage" : "caller-error";
@@ -33199,12 +33231,12 @@ async function executeDraftVerification(input2) {
33199
33231
  };
33200
33232
  try {
33201
33233
  const primary = input2.primaryEvidence ? { response: new Response(null, { status: input2.primaryEvidence.status }), body: input2.primaryEvidence.body } : await sendConfigured(prepared, input2.kind === "action" ? action.effect : "read");
33202
- if (!primary.response.ok) return { ok: false, message: `The app returned HTTP ${primary.response.status}${input2.kind === "transport" || action && "effect" in action && action.effect === "read" ? "" : ". Inspect its state before retrying a mutation"}`, exitCode: 4, dispatched, clientRejected: primary.response.status >= 400 && primary.response.status < 500 };
33203
- if (!input2.primaryEvidence && input2.kind === "action" && transport.mode === "direct" && dispatchStarted) input2.onDirectBaseline?.(Math.max(0, performance.now() - dispatchStarted), JSON.stringify({ method: prepared.init.method, url: prepared.url.toString(), body: prepared.init.body ?? null }), JSON.stringify(primary.body), dispatchAt, (/* @__PURE__ */ new Date()).toISOString());
33204
33234
  if (!input2.primaryEvidence && input2.onPrimary) {
33205
33235
  const saved = privateEvidence({ status: primary.response.status, body: primary.body, inputs: values, generated }, knownCredentials);
33206
33236
  input2.onPrimary({ ...saved.value, redacted: saved.redacted });
33207
33237
  }
33238
+ if (!primary.response.ok) return { ok: false, message: `The app returned HTTP ${primary.response.status}${input2.kind === "transport" || action && "effect" in action && action.effect === "read" ? "" : ". Inspect its state before retrying a mutation"}`, exitCode: 4, dispatched, clientRejected: primary.response.status >= 400 && primary.response.status < 500 };
33239
+ if (!input2.primaryEvidence && input2.kind === "action" && transport.mode === "direct" && dispatchStarted) input2.onDirectBaseline?.(Math.max(0, performance.now() - dispatchStarted), JSON.stringify({ method: prepared.init.method, url: prepared.url.toString(), body: prepared.init.body ?? null }), JSON.stringify(primary.body), dispatchAt, (/* @__PURE__ */ new Date()).toISOString());
33208
33240
  if (input2.kind === "transport") {
33209
33241
  const selected = probe.response.path !== void 0 ? pointer2(primary.body, probe.response.path) : primary.body;
33210
33242
  if (probe.response.schema && !ajv3.compile(probe.response.schema)(selected)) return { ok: false, message: "Probe response does not match its declared schema", exitCode: 12, dispatched };
@@ -33236,6 +33268,7 @@ var init_run = __esm({
33236
33268
  "src/commands/run.ts"() {
33237
33269
  "use strict";
33238
33270
  init_catalog();
33271
+ init_browser_response();
33239
33272
  init_definitions();
33240
33273
  init_json();
33241
33274
  init_timings();
@@ -34035,7 +34068,7 @@ function inferResponseSchema(value, limit = 2e4) {
34035
34068
  function rankCandidates(entries, inputs, effect2, allowedOrigins = []) {
34036
34069
  const samples = [...new Set(Object.values(inputs).filter((value) => ["string", "number", "boolean"].includes(typeof value)).map((value) => canonicalJson(value)))];
34037
34070
  const score = ({ entry: entry2 }) => {
34038
- let value = 0;
34071
+ let value = 0, authorizedOrigin = 0;
34039
34072
  const url3 = String(entry2.url ?? ""), body = typeof entry2.reqBody === "string" ? entry2.reqBody : "";
34040
34073
  const observed = /* @__PURE__ */ new Set();
34041
34074
  const collect = (item) => {
@@ -34052,7 +34085,7 @@ function rankCandidates(entries, inputs, effect2, allowedOrigins = []) {
34052
34085
  }
34053
34086
  try {
34054
34087
  const target = new URL(url3);
34055
- if (allowedOrigins.includes(target.origin)) value += 25;
34088
+ if (allowedOrigins.includes(target.origin)) authorizedOrigin = 1;
34056
34089
  for (const item of [...target.pathname.split("/").map(decodeURIComponent), ...target.searchParams.values()]) {
34057
34090
  observed.add(canonicalJson(item));
34058
34091
  for (const sample of samples) if (String(JSON.parse(sample)) === item) observed.add(sample);
@@ -34061,15 +34094,22 @@ function rankCandidates(entries, inputs, effect2, allowedOrigins = []) {
34061
34094
  }
34062
34095
  value += samples.filter((sample) => observed.has(sample)).length * 100;
34063
34096
  const methods = effect2 === "create" ? ["POST"] : effect2 === "update" ? ["PATCH", "PUT", "POST"] : effect2 === "delete" ? ["DELETE"] : [];
34064
- if (methods.includes(String(entry2.method))) value += effect2 === "update" && entry2.method === "POST" ? 10 : 30;
34097
+ const matchesEffect = methods.includes(String(entry2.method)) ? 1 : 0;
34098
+ if (matchesEffect) value += effect2 === "update" && entry2.method === "POST" ? 10 : 30;
34065
34099
  const contentType = Object.entries(entry2.resHeaders ?? {}).find(([key]) => key.toLowerCase() === "content-type")?.[1];
34066
34100
  if (String(contentType ?? "").includes("json") || typeof entry2.resBody === "string" && /^\s*(?:\[|{)/.test(entry2.resBody)) value += 20;
34067
34101
  if (Number(entry2.status) >= 200 && Number(entry2.status) < 300) value += 5;
34068
34102
  if (/\.(?:js|css|png|jpg|svg|woff2?)(?:[?#]|$)/i.test(url3)) value -= 50;
34069
34103
  if (entry2.method === "OPTIONS") value -= 50;
34070
- return value;
34104
+ return [authorizedOrigin, authorizedOrigin ? matchesEffect : 0, value];
34071
34105
  };
34072
- return [...entries].sort((a, b) => score(b) - score(a) || b.seq - a.seq).slice(0, 5);
34106
+ return entries.map((item) => ({ item, score: score(item) })).sort((a, b) => {
34107
+ for (let index = 0; index < a.score.length; index++) {
34108
+ const difference = b.score[index] - a.score[index];
34109
+ if (difference) return difference;
34110
+ }
34111
+ return b.item.seq - a.item.seq;
34112
+ }).slice(0, 5).map(({ item }) => item);
34073
34113
  }
34074
34114
  var sensitive, browserHeader, protectedValue;
34075
34115
  var init_capture_derivation = __esm({
@@ -34084,7 +34124,7 @@ var init_capture_derivation = __esm({
34084
34124
 
34085
34125
  // src/commands/discover.ts
34086
34126
  import { existsSync as existsSync4, mkdirSync as mkdirSync9, readFileSync as readFileSync8, renameSync as renameSync3, writeFileSync as writeFileSync8 } from "node:fs";
34087
- import { createHash as createHash5, randomUUID as randomUUID9 } from "node:crypto";
34127
+ import { createHash as createHash6, randomUUID as randomUUID9 } from "node:crypto";
34088
34128
  import { dirname as dirname6, join as join12 } from "node:path";
34089
34129
  async function currentResource(api, appId, kind, name) {
34090
34130
  try {
@@ -34875,14 +34915,15 @@ Review it and publish; no app request was sent.
34875
34915
  if (!previous?.responsePath) return fail5("No saved primary response matches this request, inputs and connection. No app request was sent. Restore the original test definition or inspect the app through a read; do not repeat an uncertain write.\n", 12);
34876
34916
  try {
34877
34917
  const saved = readFileSync8(previous.responsePath, "utf8");
34878
- if (createHash5("sha256").update(saved).digest("hex") !== previous.responseDigest) throw new Error("Saved response changed");
34918
+ if (createHash6("sha256").update(saved).digest("hex") !== previous.responseDigest) throw new Error("Saved response changed");
34879
34919
  primaryEvidence = JSON.parse(saved);
34920
+ if (primaryEvidence.status < 200 || primaryEvidence.status >= 300) return fail5("No saved successful primary response matches this request. No app request was sent. Inspect the saved rejection and correct the request before testing again.\n", 12);
34880
34921
  if (primaryEvidence.redacted) return fail5("Saved evidence contains redacted credentials and cannot be reused as proof. No app request was sent; inspect the intended state through an authorized read.\n", 12);
34881
34922
  } catch {
34882
34923
  return fail5("The saved primary response is unavailable. No app request was sent; inspect the app through a read.\n", 12);
34883
34924
  }
34884
34925
  }
34885
- let responsePath = previous?.responsePath;
34926
+ let responsePath = proofOnly ? previous?.responsePath : void 0;
34886
34927
  let readbackPath;
34887
34928
  const savePrivate = (value, name) => {
34888
34929
  const path2 = store.artifactPath(draft.id, name);
@@ -34893,7 +34934,7 @@ Review it and publish; no app request was sent.
34893
34934
  if (write && !proofOnly) store.saveRequestAttempt(draft.id, primaryFingerprint, "possibly-dispatched");
34894
34935
  const executed = await executeDraftVerification({ api, state, session, root, fetcher, appId: draft.appId, appSlug: draft.appSlug, kind: draft.kind, name: draft.name, action, transport, commandPrefix: command4(invocation, "").trim(), browserTab: envelope.capture?.tab || void 0, probeOrigin: envelope.verification?.probeOrigin, sampleInputs: envelope.verification?.inputs ?? {}, primaryEvidence, onPrimary: (saved) => {
34895
34936
  responsePath = savePrivate(saved, "primary.json");
34896
- store.saveRequestAttempt(draft.id, primaryFingerprint, "possibly-dispatched", responsePath, createHash5("sha256").update(readFileSync8(responsePath)).digest("hex"));
34937
+ store.saveRequestAttempt(draft.id, primaryFingerprint, "possibly-dispatched", responsePath, createHash6("sha256").update(readFileSync8(responsePath)).digest("hex"));
34897
34938
  }, onReadback: (body) => {
34898
34939
  readbackPath = savePrivate(body, "readback.json");
34899
34940
  }, onDispatch: () => withBaselines(root, (baselines) => baselines.closeObservation(draft.id, "dispatch")), onDirectBaseline: (durationMs, request2, response, startedAt, finishedAt) => {
@@ -34905,7 +34946,7 @@ Review it and publish; no app request was sent.
34905
34946
  File: ${draft.filePath}
34906
34947
  ${responsePath ? `Saved primary response and test inputs: ${responsePath}
34907
34948
  ` : ""}${readbackPath ? `Saved readback: ${readbackPath}
34908
- ` : ""}${write && responsePath ? `Repair the response/proof, then check without repeating the write: ${proofCommand}
34949
+ ` : ""}${write && responsePath && !executed.clientRejected ? `Repair the response/proof, then check without repeating the write: ${proofCommand}
34909
34950
  ` : ""}`, executed.exitCode, executed.dispatched);
34910
34951
  }
34911
34952
  withBaselines(root, (baselines) => baselines.finishPreparation(session.id, draft.appSlug, draft.appId, transport.mode));
@@ -35901,7 +35942,7 @@ var init_main2 = __esm({
35901
35942
  });
35902
35943
 
35903
35944
  // src/plugin.ts
35904
- import { createHash as createHash6 } from "node:crypto";
35945
+ import { createHash as createHash7 } from "node:crypto";
35905
35946
  import { cpSync, existsSync as existsSync5, mkdirSync as mkdirSync10, readFileSync as readFileSync9, readdirSync, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "node:fs";
35906
35947
  import { homedir as homedir2 } from "node:os";
35907
35948
  import { dirname as dirname8, join as join14, resolve as resolve7 } from "node:path";
@@ -35919,7 +35960,7 @@ function files(root, relative = "") {
35919
35960
  }).sort();
35920
35961
  }
35921
35962
  function digest(root) {
35922
- const hash4 = createHash6("sha256");
35963
+ const hash4 = createHash7("sha256");
35923
35964
  for (const path2 of files(root)) hash4.update(path2).update("\0").update(readFileSync9(join14(root, path2))).update("\0");
35924
35965
  return hash4.digest("hex");
35925
35966
  }
@@ -36249,7 +36290,7 @@ var init_analytics2 = __esm({
36249
36290
 
36250
36291
  // src/usage/ownership.ts
36251
36292
  import { mkdirSync as mkdirSync11, chmodSync as chmodSync7, existsSync as existsSync6, readFileSync as readFileSync10, writeFileSync as writeFileSync10, renameSync as renameSync5, unlinkSync as unlinkSync3, statSync as statSync3 } from "node:fs";
36252
- import { createHash as createHash7, randomUUID as randomUUID12 } from "node:crypto";
36293
+ import { createHash as createHash8, randomUUID as randomUUID12 } from "node:crypto";
36253
36294
  import { join as join15, dirname as dirname9, isAbsolute as isAbsolute2 } from "node:path";
36254
36295
  import { DatabaseSync as DatabaseSync6 } from "node:sqlite";
36255
36296
  function requestCollectorTarget(root, entry2, env) {
@@ -36305,7 +36346,7 @@ var init_ownership = __esm({
36305
36346
  "use strict";
36306
36347
  ownerLifetimeMs = 6e4;
36307
36348
  targetFile = (root) => join15(root, "usage", "collector-target.json");
36308
- sourceFingerprint = (entry2) => createHash7("sha256").update(readFileSync10(entry2)).digest("hex");
36349
+ sourceFingerprint = (entry2) => createHash8("sha256").update(readFileSync10(entry2)).digest("hex");
36309
36350
  runtimeKeys = ["APILIFT_URL", "CODEX_HOME", "CLAUDE_CONFIG_DIR", "APILIFT_BIN", "APILIFT_DEV_PLUGIN_ROOT"];
36310
36351
  ownerFile = (root) => join15(root, "usage", "collector-owner.json");
36311
36352
  }
@@ -38376,7 +38417,7 @@ var init_compat2 = __esm({
38376
38417
  });
38377
38418
 
38378
38419
  // src/native-host/registration.ts
38379
- import { createHash as createHash8, randomUUID as randomUUID13 } from "node:crypto";
38420
+ import { createHash as createHash9, randomUUID as randomUUID13 } from "node:crypto";
38380
38421
  import { execFileSync as execFileSync2 } from "node:child_process";
38381
38422
  import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync11 } from "node:fs";
38382
38423
  import { homedir as homedir3, platform as platform2 } from "node:os";
@@ -38523,7 +38564,7 @@ var fingerprint, hostNames, validId, posixQuote, absoluteEnv;
38523
38564
  var init_registration = __esm({
38524
38565
  "src/native-host/registration.ts"() {
38525
38566
  "use strict";
38526
- fingerprint = (bytes) => createHash8("sha256").update(bytes).digest("hex");
38567
+ fingerprint = (bytes) => createHash9("sha256").update(bytes).digest("hex");
38527
38568
  hostNames = /* @__PURE__ */ new Set(["com.apilift.browser", "com.apilift.browser.dev"]);
38528
38569
  validId = /^[a-p]{32}$/;
38529
38570
  posixQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
@@ -38696,18 +38737,12 @@ var init_update = __esm({
38696
38737
  });
38697
38738
 
38698
38739
  // src/setup-check.ts
38699
- import { createHash as createHash9, randomUUID as randomUUID14 } from "node:crypto";
38740
+ import { randomUUID as randomUUID14 } from "node:crypto";
38700
38741
  import { existsSync as existsSync8, readFileSync as readFileSync12, realpathSync as realpathSync3, writeFileSync as writeFileSync13 } from "node:fs";
38701
38742
  import { dirname as dirname12, join as join18 } from "node:path";
38702
38743
  async function setupCheckBody(client, scopeId, value) {
38703
- if (typeof value.body === "string") return Buffer.byteLength(value.body, "utf8") <= maxCheckBodyBytes ? value.body : null;
38704
- if (value.body != null) return null;
38705
- const artifact = value.bodyArtifact;
38706
- if (!artifact || typeof artifact.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(artifact.sha256) || !Number.isInteger(artifact.bytes) || Number(artifact.bytes) < 1 || Number(artifact.bytes) > maxCheckBodyBytes || artifact.encoding !== "utf-8") return null;
38707
38744
  try {
38708
- const bytes = await client.blob(scopeId, artifact.sha256);
38709
- if (!bytes || bytes.length !== artifact.bytes || createHash9("sha256").update(bytes).digest("hex") !== artifact.sha256) return null;
38710
- return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
38745
+ return await browserResponseBody(client, scopeId, value, maxCheckBodyBytes);
38711
38746
  } catch {
38712
38747
  return null;
38713
38748
  }
@@ -38808,6 +38843,7 @@ var init_setup_check = __esm({
38808
38843
  "src/setup-check.ts"() {
38809
38844
  "use strict";
38810
38845
  init_version();
38846
+ init_browser_response();
38811
38847
  init_client2();
38812
38848
  init_demand();
38813
38849
  init_registration();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apilift",
3
- "version": "1.5.2",
3
+ "version": "1.5.3-dev.1792314011.35e5b85595e90273e189e53c1f0f3cf89400cdae",
4
4
  "description": "Use logged-in apps and discover missing actions with Apilift.",
5
5
  "author": {
6
6
  "name": "Apilift"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apilift",
3
- "version": "1.5.2",
3
+ "version": "1.5.3-dev.1792314011.35e5b85595e90273e189e53c1f0f3cf89400cdae",
4
4
  "description": "Use logged-in apps and discover missing actions with Apilift.",
5
5
  "author": {
6
6
  "name": "Apilift"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apilift/cli",
3
- "version": "1.5.2",
3
+ "version": "1.5.3-dev.1792314011.35e5b85595e90273e189e53c1f0f3cf89400cdae",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -36,7 +36,7 @@
36
36
  "engines": {
37
37
  "node": ">=24.16.0 <27"
38
38
  },
39
- "gitHead": "9b4a54e01dc6675ecf959fc5a8b1090d54af0a9e",
39
+ "gitHead": "35e5b85595e90273e189e53c1f0f3cf89400cdae",
40
40
  "repository": {
41
41
  "type": "git",
42
42
  "url": "git+https://github.com/egor-sergeev/apilift.git",