@zksecurity/zkao-sdk 0.25.0-next.17 → 0.27.0-next.18

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.d.ts CHANGED
@@ -762,8 +762,10 @@ interface components {
762
762
  Error: {
763
763
  error: {
764
764
  /** @enum {string} */
765
- code: "unauthorized" | "forbidden" | "not_found" | "bad_request" | "conflict" | "insufficient_credits" | "repository_initializing" | "diff_base_required" | "diff_base_not_allowed" | "diff_base_invalid" | "diff_empty" | "rate_limited" | "internal";
765
+ code: "unauthorized" | "forbidden" | "not_found" | "bad_request" | "conflict" | "insufficient_credits" | "budget_below_minimum" | "repository_initializing" | "diff_base_required" | "diff_base_not_allowed" | "diff_base_invalid" | "diff_empty" | "rate_limited" | "internal";
766
766
  message: string;
767
+ /** @description budget_below_minimum only: the least the launch could have reserved, in credits. A diff scan's first scan of a repository also builds its overview, so its minimum is higher. */
768
+ minimumCredits?: number;
767
769
  };
768
770
  };
769
771
  /** @enum {string} */
@@ -1070,7 +1072,7 @@ interface components {
1070
1072
  };
1071
1073
  LaunchScanRequest: {
1072
1074
  repositoryId: string;
1073
- /** @description Max budget for the scan, in credits. Reserved at launch. Omit it to launch at the budget zkao recommends for this scan type and scope on this repository. That is the last such scan's budget, or half again when that scan ran short of it, never above twice the scan type's minimum. A first scan starts at twice the minimum. A diff scan is sized from its change instead: the minimum for up to 500 changed lines, then in proportion, up to three times the minimum. */
1075
+ /** @description Max budget for the scan, in credits. Reserved at launch. Omit it to launch at the budget zkao recommends for this scan type and scope on this repository. A Flash or Max scan of the code is sized from the audit areas it reads: the selected areas, or every area in the repository map. One area gets the minimum, and the budget grows with the square root of the area count. With no map, or with `auditScope`, it is twice the minimum. It is half again the last budget when the last scan of the same scope ran short of it. A diff scan is sized from its change instead: the minimum for up to 500 changed lines, then in proportion, up to three times the minimum. Other scan types use the last such scan's budget, or half again when that scan ran short of it, and a first scan starts at twice the minimum. Except for a diff, the recommendation never exceeds twice the minimum. A budget below the minimum is refused with `400` `budget_below_minimum`, whose `minimumCredits` names it. */
1074
1076
  creditBudget?: number;
1075
1077
  /** @description A preset ref from /scan-presets. Defaults to the first active preset. */
1076
1078
  presetRef?: string;
@@ -1079,7 +1081,7 @@ interface components {
1079
1081
  /** @description Pin a specific commit SHA (7-40 hex chars). */
1080
1082
  commitHash?: string | null;
1081
1083
  commitMessage?: string | null;
1082
- /** @description What a diff scan's change is measured from: a commit SHA, branch, or tag. Required by a diff scan preset and refused by every other. The scan records the merge base of this and the scanned commit. */
1084
+ /** @description What a diff scan's change is measured from: a commit SHA, branch, or tag. Required by a diff scan preset and refused by every other. The scan records the merge base of this and the scanned commit. When no earlier scan of the repository built its overview, the diff scan builds one first, and its minimum and recommended budgets rise. */
1083
1085
  baseCommit?: string | null;
1084
1086
  /** @description Options for Recheck open findings. Omit to reassess eligible Not started findings on the selected branch. Fresh rechecks require the branch's latest commit and reject a pinned commit or audit scope. */
1085
1087
  backlogRecheck?: {
@@ -1104,6 +1106,8 @@ interface components {
1104
1106
  queued: boolean;
1105
1107
  /** @description The budget the scan was launched with, in credits. */
1106
1108
  creditBudget: number;
1109
+ /** @description True when no earlier scan of the repository built its overview, so this diff scan builds one first. It takes longer, and its minimum and recommended budgets are higher. */
1110
+ buildsOverview: boolean;
1107
1111
  };
1108
1112
  RepositoryGuidance: {
1109
1113
  repositoryId: string;
@@ -2677,7 +2681,9 @@ type WaitForScanOptions = {
2677
2681
  declare class ZkaoApiError extends Error {
2678
2682
  readonly status: number;
2679
2683
  readonly code: string;
2680
- constructor(status: number, code: string, message: string);
2684
+ /** `budget_below_minimum` only: the least the launch could reserve, in credits. */
2685
+ readonly minimumCredits?: number;
2686
+ constructor(status: number, code: string, message: string, minimumCredits?: number);
2681
2687
  }
2682
2688
  /**
2683
2689
  * Typed client for one zkao project. Every call is scoped to the project the
package/dist/index.js CHANGED
@@ -81,11 +81,16 @@ function isTerminalScanStatus(status) {
81
81
  var ZkaoApiError = class extends Error {
82
82
  status;
83
83
  code;
84
- constructor(status, code, message) {
84
+ /** `budget_below_minimum` only: the least the launch could reserve, in credits. */
85
+ minimumCredits;
86
+ constructor(status, code, message, minimumCredits) {
85
87
  super(message);
86
88
  this.name = "ZkaoApiError";
87
89
  this.status = status;
88
90
  this.code = code;
91
+ if (minimumCredits !== void 0) {
92
+ this.minimumCredits = minimumCredits;
93
+ }
89
94
  }
90
95
  };
91
96
  function unwrap(result) {
@@ -93,10 +98,12 @@ function unwrap(result) {
93
98
  return result.data;
94
99
  }
95
100
  const envelope = result.error;
101
+ const minimumCredits = envelope?.error?.minimumCredits;
96
102
  throw new ZkaoApiError(
97
103
  result.response.status,
98
104
  envelope?.error?.code ?? "error",
99
- envelope?.error?.message ?? result.response.statusText
105
+ envelope?.error?.message ?? result.response.statusText,
106
+ typeof minimumCredits === "number" ? minimumCredits : void 0
100
107
  );
101
108
  }
102
109
  async function getTokenInfo(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zksecurity/zkao-sdk",
3
- "version": "0.25.0-next.17",
3
+ "version": "0.27.0-next.18",
4
4
  "description": "TypeScript SDK for the zkao Project API",
5
5
  "license": "MIT",
6
6
  "author": "zkSecurity",