@proofline/sdk 5.11.3 → 6.1.0
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/README.md +15 -1
- package/dist/coverage.d.ts +21 -0
- package/dist/coverage.js +60 -0
- package/dist/exports.d.ts +2 -2
- package/dist/exports.js +11 -4
- package/dist/index.d.ts +7 -2
- package/dist/index.js +9 -3
- package/dist/schema.d.ts +20 -7
- package/dist/transport.d.ts +2 -1
- package/dist/transport.js +24 -9
- package/openapi.public.json +53 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ const client = new ProoflineClient({
|
|
|
15
15
|
});
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
When no token is passed, the client reads `PROOFLINE_TOKEN`, keeps it in memory, and redacts it from diagnostic output. The [SDK guide](https://proofline.sh/docs/sdks/) and [API reference](https://proofline.sh/docs/api/) cover every operation.
|
|
18
|
+
When no token is passed, the client reads `PROOFLINE_TOKEN`, keeps it in memory, and redacts it from diagnostic output. When no `baseUrl` is passed, it reads `PROOFLINE_BASE_URL` and otherwise uses `https://proofline.sh`, as the CLI and the MCP bridge do, so `new ProoflineClient()` works for the hosted service. An empty variable counts as unset, and a value that is not an HTTPS origin or a loopback HTTP origin is refused by name. The [SDK guide](https://proofline.sh/docs/sdks/) and [API reference](https://proofline.sh/docs/api/) cover every operation.
|
|
19
19
|
|
|
20
20
|
This repository is the published distribution of the Proofline TypeScript SDK. The public OpenAPI contract in `openapi.public.json` generates `src/operations.ts` and `src/schema.d.ts`. The transport in `src/transport.ts`, client helpers, and tests in `tests/` are hand-written. Open an [issue](https://github.com/prooflinedev/sdk-typescript/issues) for changes to the OpenAPI contract, generated code, or workflows. Pull requests are welcome for the hand-written parts.
|
|
21
21
|
|
|
@@ -57,6 +57,20 @@ const report = await client.uploadCoverageReports(
|
|
|
57
57
|
console.log(report.report_id, report.created);
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
To upload reports straight from disk, `uploadCoverageFiles` reads each file as UTF-8 text and names it by its path relative to `root`, which defaults to the working directory. Pass `{ path, name }` to choose a different report name.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const report = await client.uploadCoverageFiles(
|
|
64
|
+
{ path: { org_id: organizationId, repo_id: repositoryId } },
|
|
65
|
+
{
|
|
66
|
+
tested_sha: testedCommitSha,
|
|
67
|
+
files: ["coverage/lcov.info", { path: "go/cover.out", name: "go/coverage.out" }],
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
It throws a `TypeError` before sending anything when the SHA is abbreviated, the report count is outside 1 to 50, two reports share a name, a name escapes `root`, a file is not UTF-8 text, or the body would exceed 30 MiB. File system errors such as a missing report are thrown unchanged.
|
|
73
|
+
|
|
60
74
|
Send 1 to 50 LCOV, Cobertura XML, JaCoCo XML, or Go cover reports in a JSON body of at most 30 MiB. Each report name must be a unique relative path, and content must be the original report text. Repeating an identical upload returns the existing report with `created: false`. An upload receipt records evidence; it does not indicate that a coverage check is met.
|
|
61
75
|
|
|
62
76
|
## Review exports
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { UploadCoverageReportsBody } from "./operations.js";
|
|
2
|
+
export interface CoverageFile {
|
|
3
|
+
/** Path to the report on disk, absolute or relative to `root`. */
|
|
4
|
+
path: string;
|
|
5
|
+
/** Report name sent to the server. Defaults to `path` relative to `root`. */
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CoverageFilesUpload {
|
|
9
|
+
/** The full 40-character commit the tests ran on. */
|
|
10
|
+
tested_sha: string;
|
|
11
|
+
/** One to 50 report paths, or `{ path, name }` to choose the sent name. */
|
|
12
|
+
files: (string | CoverageFile)[];
|
|
13
|
+
/** Directory that report paths and default names resolve against. Defaults to the working directory. */
|
|
14
|
+
root?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads coverage reports from disk into an upload body, refusing locally what
|
|
18
|
+
* the server would refuse: an abbreviated SHA, a report count outside 1 to 50,
|
|
19
|
+
* duplicate or escaping names, non-UTF-8 content, or a body over 30 MiB.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readCoverageFiles(upload: CoverageFilesUpload): Promise<UploadCoverageReportsBody>;
|
package/dist/coverage.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
const MAX_REPORTS = 50;
|
|
4
|
+
const MAX_BODY_BYTES = 30 * 1024 * 1024;
|
|
5
|
+
// Keeps a byte-order mark and refuses invalid UTF-8, so content stays the report text as written.
|
|
6
|
+
const utf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
7
|
+
function reportName(name) {
|
|
8
|
+
const segments = name.split("/");
|
|
9
|
+
if (name === "" ||
|
|
10
|
+
name.includes("\\") ||
|
|
11
|
+
isAbsolute(name) ||
|
|
12
|
+
segments.some((segment) => segment === "" || segment === "." || segment === ".."))
|
|
13
|
+
throw new TypeError(`coverage report name ${JSON.stringify(name)} must be a relative path inside root`);
|
|
14
|
+
return name;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads coverage reports from disk into an upload body, refusing locally what
|
|
18
|
+
* the server would refuse: an abbreviated SHA, a report count outside 1 to 50,
|
|
19
|
+
* duplicate or escaping names, non-UTF-8 content, or a body over 30 MiB.
|
|
20
|
+
*/
|
|
21
|
+
export async function readCoverageFiles(upload) {
|
|
22
|
+
if (!/^[0-9a-f]{40}$/i.test(upload.tested_sha))
|
|
23
|
+
throw new TypeError("tested_sha must be a full 40-character commit SHA");
|
|
24
|
+
if (upload.files.length < 1 || upload.files.length > MAX_REPORTS)
|
|
25
|
+
throw new TypeError(`upload 1 to ${MAX_REPORTS} coverage reports`);
|
|
26
|
+
const root = resolve(upload.root ?? ".");
|
|
27
|
+
const files = upload.files.map((file) => {
|
|
28
|
+
const entry = typeof file === "string" ? { path: file } : file;
|
|
29
|
+
const path = resolve(root, entry.path);
|
|
30
|
+
const name = reportName(entry.name ?? relative(root, path).split(sep).join("/"));
|
|
31
|
+
return { path, name };
|
|
32
|
+
});
|
|
33
|
+
const names = new Set(files.map((file) => file.name));
|
|
34
|
+
if (names.size !== files.length)
|
|
35
|
+
throw new TypeError("coverage report names must be unique");
|
|
36
|
+
// Report bytes alone can exceed the body limit; check sizes before reading.
|
|
37
|
+
let bytes = 0;
|
|
38
|
+
for (const file of files) {
|
|
39
|
+
bytes += (await stat(file.path)).size;
|
|
40
|
+
if (bytes > MAX_BODY_BYTES)
|
|
41
|
+
throw new TypeError("coverage reports exceed the 30 MiB upload limit");
|
|
42
|
+
}
|
|
43
|
+
const reports = [];
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
let content;
|
|
46
|
+
try {
|
|
47
|
+
content = utf8.decode(await readFile(file.path));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (!(error instanceof TypeError))
|
|
51
|
+
throw error;
|
|
52
|
+
throw new TypeError(`coverage report ${file.name} is not UTF-8 text`);
|
|
53
|
+
}
|
|
54
|
+
reports.push({ name: file.name, content });
|
|
55
|
+
}
|
|
56
|
+
const body = { tested_sha: upload.tested_sha, reports };
|
|
57
|
+
if (Buffer.byteLength(JSON.stringify(body)) > MAX_BODY_BYTES)
|
|
58
|
+
throw new TypeError("coverage reports exceed the 30 MiB upload limit");
|
|
59
|
+
return body;
|
|
60
|
+
}
|
package/dist/exports.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export interface ExportPage {
|
|
|
4
4
|
format: "csv" | "ndjson";
|
|
5
5
|
text: string;
|
|
6
6
|
rows: Record<string, unknown>[];
|
|
7
|
-
version: 1;
|
|
7
|
+
version: 1 | 2;
|
|
8
8
|
settledUntil: string;
|
|
9
9
|
nextCursor: string | null;
|
|
10
10
|
}
|
|
11
|
-
export declare function decodeExport(text: string, headers: Headers, format: "csv" | "ndjson"): ExportPage;
|
|
11
|
+
export declare function decodeExport(text: string, headers: Headers, format: "csv" | "ndjson", dataset: string): ExportPage;
|
package/dist/exports.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { ProoflineError } from "./transport.js";
|
|
2
|
+
// Version 2 of the finding datasets adds code-lane rows. Version 1 stays accepted from servers
|
|
3
|
+
// that have not moved to version 2.
|
|
4
|
+
const versions = {
|
|
5
|
+
findings: ["1", "2"],
|
|
6
|
+
finding_validations: ["1", "2"],
|
|
7
|
+
};
|
|
2
8
|
function invalid() {
|
|
3
9
|
throw new ProoflineError(200, "urn:proofline:sdk:invalid-response", "the export body or metadata is invalid");
|
|
4
10
|
}
|
|
@@ -55,11 +61,12 @@ function csv(text) {
|
|
|
55
61
|
return Object.fromEntries(columns.map((name, i) => [name, row[i]]));
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
|
-
export function decodeExport(text, headers, format) {
|
|
64
|
+
export function decodeExport(text, headers, format, dataset) {
|
|
59
65
|
const media = format === "csv" ? "text/csv" : "application/x-ndjson";
|
|
60
66
|
const settledUntil = headers.get("x-proofline-export-settled-until");
|
|
67
|
+
const version = headers.get("x-proofline-export-version") ?? "";
|
|
61
68
|
if (headers.get("content-type")?.split(";")[0]?.trim() !== media ||
|
|
62
|
-
|
|
69
|
+
!(versions[dataset] ?? ["1"]).includes(version) ||
|
|
63
70
|
!settledUntil ||
|
|
64
71
|
!Number.isFinite(Date.parse(settledUntil)))
|
|
65
72
|
invalid();
|
|
@@ -77,7 +84,7 @@ export function decodeExport(text, headers, format) {
|
|
|
77
84
|
invalid();
|
|
78
85
|
return row;
|
|
79
86
|
});
|
|
80
|
-
if (rows.some((row) => String(row.dataset_version) !==
|
|
87
|
+
if (rows.some((row) => String(row.dataset_version) !== version))
|
|
81
88
|
invalid();
|
|
82
89
|
}
|
|
83
90
|
catch {
|
|
@@ -87,7 +94,7 @@ export function decodeExport(text, headers, format) {
|
|
|
87
94
|
format,
|
|
88
95
|
text,
|
|
89
96
|
rows,
|
|
90
|
-
version: 1,
|
|
97
|
+
version: version === "2" ? 2 : 1,
|
|
91
98
|
settledUntil,
|
|
92
99
|
nextCursor: headers.get("x-proofline-export-next-cursor"),
|
|
93
100
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { FixesClient } from "./fixes.js";
|
|
2
2
|
export type { ReverificationRequest } from "./fixes.js";
|
|
3
|
+
import { type CoverageFilesUpload } from "./coverage.js";
|
|
4
|
+
export type { CoverageFile, CoverageFilesUpload } from "./coverage.js";
|
|
3
5
|
import { McpClient } from "./mcp.js";
|
|
4
6
|
export type { McpTarget } from "./mcp.js";
|
|
5
7
|
import { KnowledgeClient } from "./knowledge.js";
|
|
6
8
|
export type { KnowledgeResult, RepositoryKnowledge } from "./knowledge.js";
|
|
7
9
|
import { type ExportPage, type ExportParameters } from "./exports.js";
|
|
8
10
|
export type { ExportPage, ExportParameters } from "./exports.js";
|
|
9
|
-
import { type ListReviewsParameters, Operations } from "./operations.js";
|
|
11
|
+
import { type ListReviewsParameters, Operations, type UploadCoverageReportsParameters } from "./operations.js";
|
|
10
12
|
import type { components } from "./schema.js";
|
|
11
13
|
import { type ClientOptions } from "./transport.js";
|
|
12
14
|
export type * from "./operations.js";
|
|
@@ -26,6 +28,7 @@ export interface AssessmentGaps {
|
|
|
26
28
|
checks: {
|
|
27
29
|
name: string;
|
|
28
30
|
outcome: string;
|
|
31
|
+
lifecycle: string;
|
|
29
32
|
detail: string | null;
|
|
30
33
|
unresolvedReason: string | null;
|
|
31
34
|
}[];
|
|
@@ -45,8 +48,10 @@ export declare class ProoflineClient extends Operations {
|
|
|
45
48
|
readonly mcp: McpClient;
|
|
46
49
|
readonly knowledge: KnowledgeClient;
|
|
47
50
|
readonly fixes: FixesClient;
|
|
48
|
-
constructor(options
|
|
51
|
+
constructor(options?: ClientOptions);
|
|
49
52
|
exportReviews(parameters: ExportParameters): Promise<ExportPage>;
|
|
53
|
+
/** Reads coverage reports from disk and uploads them in one request. */
|
|
54
|
+
uploadCoverageFiles(parameters: UploadCoverageReportsParameters, upload: CoverageFilesUpload): Promise<components["schemas"]["CoverageUploadResponse"]>;
|
|
50
55
|
iterReviews(parameters: ListReviewsParameters, options?: {
|
|
51
56
|
maxPages?: number;
|
|
52
57
|
maxItems?: number;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FixesClient } from "./fixes.js";
|
|
2
|
+
import { readCoverageFiles } from "./coverage.js";
|
|
2
3
|
import { McpClient } from "./mcp.js";
|
|
3
4
|
import { KnowledgeClient } from "./knowledge.js";
|
|
4
5
|
import { decodeExport, } from "./exports.js";
|
|
5
|
-
import { Operations } from "./operations.js";
|
|
6
|
+
import { Operations, } from "./operations.js";
|
|
6
7
|
import { sleep, Transport } from "./transport.js";
|
|
7
8
|
export { ProoflineError, SecretToken } from "./transport.js";
|
|
8
9
|
export class ProoflineClient extends Operations {
|
|
@@ -10,7 +11,7 @@ export class ProoflineClient extends Operations {
|
|
|
10
11
|
mcp;
|
|
11
12
|
knowledge;
|
|
12
13
|
fixes;
|
|
13
|
-
constructor(options) {
|
|
14
|
+
constructor(options = {}) {
|
|
14
15
|
const transport = new Transport(options);
|
|
15
16
|
super((method, path, parameters, body) => transport.request(method, path, parameters, undefined, body));
|
|
16
17
|
this.#transport = transport;
|
|
@@ -22,7 +23,11 @@ export class ProoflineClient extends Operations {
|
|
|
22
23
|
const format = parameters.query.format ?? "ndjson";
|
|
23
24
|
if (format !== "csv" && format !== "ndjson")
|
|
24
25
|
throw new TypeError("export format must be csv or ndjson");
|
|
25
|
-
return this.#transport.request("GET", "/api/v1/organizations/{org_id}/exports/{dataset}", parameters, undefined, undefined, (text, headers) => decodeExport(text, headers, format), format === "csv" ? "text/csv" : "application/x-ndjson");
|
|
26
|
+
return this.#transport.request("GET", "/api/v1/organizations/{org_id}/exports/{dataset}", parameters, undefined, undefined, (text, headers) => decodeExport(text, headers, format, parameters.path.dataset), format === "csv" ? "text/csv" : "application/x-ndjson");
|
|
27
|
+
}
|
|
28
|
+
/** Reads coverage reports from disk and uploads them in one request. */
|
|
29
|
+
async uploadCoverageFiles(parameters, upload) {
|
|
30
|
+
return this.uploadCoverageReports(parameters, await readCoverageFiles(upload));
|
|
26
31
|
}
|
|
27
32
|
async *iterReviews(parameters, options = {}) {
|
|
28
33
|
const maxPages = integerLimit(options.maxPages ?? 100, "maxPages");
|
|
@@ -286,6 +291,7 @@ function outcome(status, reviewUrl, review, reason) {
|
|
|
286
291
|
.map((check) => ({
|
|
287
292
|
name: check.name,
|
|
288
293
|
outcome: check.outcome,
|
|
294
|
+
lifecycle: check.lifecycle,
|
|
289
295
|
detail: check.detail ?? null,
|
|
290
296
|
unresolvedReason: check.unresolved_reason ?? null,
|
|
291
297
|
})),
|
package/dist/schema.d.ts
CHANGED
|
@@ -1761,6 +1761,8 @@ export interface components {
|
|
|
1761
1761
|
/** @description The recorded reference kind, or `text` for a kind this export does not recognize. */
|
|
1762
1762
|
kind: components["schemas"]["ExportEvidenceKind"];
|
|
1763
1763
|
};
|
|
1764
|
+
/** @description The review lane whose assessment recorded a finding. */
|
|
1765
|
+
ExportFindingLane: "ENVIRONMENT" | "CODE";
|
|
1764
1766
|
/** @enum {string} */
|
|
1765
1767
|
ExportFindingLifecycle: "NEW" | "UNCHANGED" | "RESOLVED" | "REINTRODUCED";
|
|
1766
1768
|
/** @enum {string} */
|
|
@@ -2119,14 +2121,15 @@ export interface components {
|
|
|
2119
2121
|
created_at: string;
|
|
2120
2122
|
/**
|
|
2121
2123
|
* Format: uint16
|
|
2122
|
-
* @description The row contract version, always `
|
|
2124
|
+
* @description The row contract version, always `2`.
|
|
2123
2125
|
*/
|
|
2124
2126
|
dataset_version: number;
|
|
2125
2127
|
/**
|
|
2126
2128
|
* Format: uuid
|
|
2127
|
-
* @description The environment of the assessment that recorded the finding
|
|
2129
|
+
* @description The environment of the assessment that recorded the finding, null for a code-lane
|
|
2130
|
+
* finding.
|
|
2128
2131
|
*/
|
|
2129
|
-
environment_id
|
|
2132
|
+
environment_id?: string | null;
|
|
2130
2133
|
/**
|
|
2131
2134
|
* Format: date-time
|
|
2132
2135
|
* @description When the decision expires, null when it records no expiry.
|
|
@@ -2137,6 +2140,8 @@ export interface components {
|
|
|
2137
2140
|
* @description The finding occurrence the validation applies to.
|
|
2138
2141
|
*/
|
|
2139
2142
|
finding_id: string;
|
|
2143
|
+
/** @description The lane of the assessment that recorded the finding. */
|
|
2144
|
+
lane: components["schemas"]["ExportFindingLane"];
|
|
2140
2145
|
/**
|
|
2141
2146
|
* Format: uuid
|
|
2142
2147
|
* @description The organization that owns the finding.
|
|
@@ -2169,7 +2174,7 @@ export interface components {
|
|
|
2169
2174
|
FindingsExportRow: {
|
|
2170
2175
|
/**
|
|
2171
2176
|
* Format: uuid
|
|
2172
|
-
* @description The environment assessment that recorded the finding.
|
|
2177
|
+
* @description The environment or code assessment that recorded the finding; `lane` says which.
|
|
2173
2178
|
*/
|
|
2174
2179
|
assessment_id: string;
|
|
2175
2180
|
/** @description The finding's claim, with supported credential shapes masked as `<REDACTED:kind>`. */
|
|
@@ -2181,14 +2186,14 @@ export interface components {
|
|
|
2181
2186
|
created_at: string;
|
|
2182
2187
|
/**
|
|
2183
2188
|
* Format: uint16
|
|
2184
|
-
* @description The row contract version, always `
|
|
2189
|
+
* @description The row contract version, always `2`.
|
|
2185
2190
|
*/
|
|
2186
2191
|
dataset_version: number;
|
|
2187
2192
|
/**
|
|
2188
2193
|
* Format: uuid
|
|
2189
|
-
* @description The environment the assessment covers.
|
|
2194
|
+
* @description The environment the assessment covers, null for a code-lane finding.
|
|
2190
2195
|
*/
|
|
2191
|
-
environment_id
|
|
2196
|
+
environment_id?: string | null;
|
|
2192
2197
|
/**
|
|
2193
2198
|
* @description The finding's evidence references in recorded order, each reduced to a kind and an
|
|
2194
2199
|
* opaque ID; an empty list means the finding records none.
|
|
@@ -2201,6 +2206,8 @@ export interface components {
|
|
|
2201
2206
|
finding_id: string;
|
|
2202
2207
|
/** @description The finding's stated impact, with supported credential shapes masked. */
|
|
2203
2208
|
impact: string;
|
|
2209
|
+
/** @description The lane of the assessment that recorded the finding. */
|
|
2210
|
+
lane: components["schemas"]["ExportFindingLane"];
|
|
2204
2211
|
/** @description The occurrence's recorded lifecycle state relative to earlier occurrences. */
|
|
2205
2212
|
lifecycle_state: components["schemas"]["ExportFindingLifecycle"];
|
|
2206
2213
|
/**
|
|
@@ -2341,6 +2348,12 @@ export interface components {
|
|
|
2341
2348
|
OpenItemsThreads: {
|
|
2342
2349
|
/** Format: date-time */
|
|
2343
2350
|
observed_at: string;
|
|
2351
|
+
/**
|
|
2352
|
+
* Format: uint64
|
|
2353
|
+
* @description The unresolved threads in `unresolved_count` that belong to a
|
|
2354
|
+
* finding `open_findings` already counts. Absent when none does.
|
|
2355
|
+
*/
|
|
2356
|
+
open_finding_threads?: number;
|
|
2344
2357
|
/** @constant */
|
|
2345
2358
|
status: "KNOWN";
|
|
2346
2359
|
/** Format: uint64 */
|
package/dist/transport.d.ts
CHANGED
|
@@ -33,7 +33,8 @@ export declare class ProoflineError extends Error {
|
|
|
33
33
|
[inspect](): string;
|
|
34
34
|
}
|
|
35
35
|
export interface ClientOptions {
|
|
36
|
-
|
|
36
|
+
/** Defaults to `PROOFLINE_BASE_URL`, then to `https://proofline.sh`. */
|
|
37
|
+
baseUrl?: string;
|
|
37
38
|
token?: string | SecretToken;
|
|
38
39
|
requestTimeoutMs?: number;
|
|
39
40
|
}
|
package/dist/transport.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const VERSION = "
|
|
1
|
+
const VERSION = "6.1.0";
|
|
2
|
+
const DEFAULT_BASE_URL = "https://proofline.sh";
|
|
2
3
|
const MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
3
4
|
const MAX_RETRIES = 3;
|
|
4
5
|
const MAX_RETRY_SECONDS = 60;
|
|
@@ -71,13 +72,19 @@ function environmentToken() {
|
|
|
71
72
|
? undefined
|
|
72
73
|
: process.env.PROOFLINE_TOKEN;
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
+
function environmentBaseUrl() {
|
|
76
|
+
if (typeof process === "undefined")
|
|
77
|
+
return undefined;
|
|
78
|
+
// An empty variable, as a CI template leaves behind, counts as unset.
|
|
79
|
+
return process.env.PROOFLINE_BASE_URL || undefined;
|
|
80
|
+
}
|
|
81
|
+
function origin(value, name) {
|
|
75
82
|
let url;
|
|
76
83
|
try {
|
|
77
84
|
url = new URL(value);
|
|
78
85
|
}
|
|
79
86
|
catch {
|
|
80
|
-
throw new TypeError(
|
|
87
|
+
throw new TypeError(`${name} must be an absolute HTTPS URL or loopback HTTP URL`);
|
|
81
88
|
}
|
|
82
89
|
const loopback = url.hostname === "localhost" ||
|
|
83
90
|
url.hostname === "[::1]" ||
|
|
@@ -88,10 +95,18 @@ function origin(value) {
|
|
|
88
95
|
url.search ||
|
|
89
96
|
url.hash ||
|
|
90
97
|
url.pathname !== "/") {
|
|
91
|
-
throw new TypeError(
|
|
98
|
+
throw new TypeError(`${name} must be an HTTPS origin or loopback HTTP origin without credentials`);
|
|
92
99
|
}
|
|
93
100
|
return url;
|
|
94
101
|
}
|
|
102
|
+
function configuredOrigin(baseUrl) {
|
|
103
|
+
if (baseUrl !== undefined)
|
|
104
|
+
return origin(baseUrl, "baseUrl");
|
|
105
|
+
const fromEnvironment = environmentBaseUrl();
|
|
106
|
+
return fromEnvironment === undefined
|
|
107
|
+
? origin(DEFAULT_BASE_URL, "baseUrl")
|
|
108
|
+
: origin(fromEnvironment, "PROOFLINE_BASE_URL");
|
|
109
|
+
}
|
|
95
110
|
function positive(value, name) {
|
|
96
111
|
if (!Number.isFinite(value) || value <= 0) {
|
|
97
112
|
throw new TypeError(`${name} must be a finite positive number`);
|
|
@@ -125,14 +140,14 @@ async function decoded(response, deadline, signal, waitTimeout, decode) {
|
|
|
125
140
|
data.set(chunk, offset);
|
|
126
141
|
offset += chunk.length;
|
|
127
142
|
}
|
|
128
|
-
const
|
|
143
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
129
144
|
if (response.ok)
|
|
130
|
-
return decode(
|
|
145
|
+
return decode(decoder.decode(data), response.headers);
|
|
131
146
|
try {
|
|
132
|
-
return JSON.parse(
|
|
147
|
+
return JSON.parse(decoder.decode(data));
|
|
133
148
|
}
|
|
134
149
|
catch {
|
|
135
|
-
// A complete HTTP refusal need not carry a JSON Problem to be retryable.
|
|
150
|
+
// A complete HTTP refusal need not carry a UTF-8 JSON Problem to be retryable.
|
|
136
151
|
return undefined;
|
|
137
152
|
}
|
|
138
153
|
}
|
|
@@ -270,7 +285,7 @@ export class Transport {
|
|
|
270
285
|
#token;
|
|
271
286
|
#timeout;
|
|
272
287
|
constructor(options) {
|
|
273
|
-
this.#base =
|
|
288
|
+
this.#base = configuredOrigin(options.baseUrl);
|
|
274
289
|
const token = options.token ?? environmentToken();
|
|
275
290
|
this.#token =
|
|
276
291
|
token instanceof SecretToken ? token : new SecretToken(token ?? "");
|
package/openapi.public.json
CHANGED
|
@@ -2412,6 +2412,21 @@
|
|
|
2412
2412
|
],
|
|
2413
2413
|
"type": "object"
|
|
2414
2414
|
},
|
|
2415
|
+
"ExportFindingLane": {
|
|
2416
|
+
"description": "The review lane whose assessment recorded a finding.",
|
|
2417
|
+
"oneOf": [
|
|
2418
|
+
{
|
|
2419
|
+
"const": "ENVIRONMENT",
|
|
2420
|
+
"description": "An environment assessment, which covers one environment.",
|
|
2421
|
+
"type": "string"
|
|
2422
|
+
},
|
|
2423
|
+
{
|
|
2424
|
+
"const": "CODE",
|
|
2425
|
+
"description": "The code assessment of the review's repository, which covers no environment.",
|
|
2426
|
+
"type": "string"
|
|
2427
|
+
}
|
|
2428
|
+
]
|
|
2429
|
+
},
|
|
2415
2430
|
"ExportFindingLifecycle": {
|
|
2416
2431
|
"enum": [
|
|
2417
2432
|
"NEW",
|
|
@@ -3268,16 +3283,19 @@
|
|
|
3268
3283
|
"type": "string"
|
|
3269
3284
|
},
|
|
3270
3285
|
"dataset_version": {
|
|
3271
|
-
"description": "The row contract version, always `
|
|
3286
|
+
"description": "The row contract version, always `2`.",
|
|
3272
3287
|
"format": "uint16",
|
|
3273
3288
|
"maximum": 65535,
|
|
3274
3289
|
"minimum": 0,
|
|
3275
3290
|
"type": "integer"
|
|
3276
3291
|
},
|
|
3277
3292
|
"environment_id": {
|
|
3278
|
-
"description": "The environment of the assessment that recorded the finding.",
|
|
3293
|
+
"description": "The environment of the assessment that recorded the finding, null for a code-lane\n finding.",
|
|
3279
3294
|
"format": "uuid",
|
|
3280
|
-
"type":
|
|
3295
|
+
"type": [
|
|
3296
|
+
"string",
|
|
3297
|
+
"null"
|
|
3298
|
+
]
|
|
3281
3299
|
},
|
|
3282
3300
|
"expires_at": {
|
|
3283
3301
|
"description": "When the decision expires, null when it records no expiry.",
|
|
@@ -3292,6 +3310,14 @@
|
|
|
3292
3310
|
"format": "uuid",
|
|
3293
3311
|
"type": "string"
|
|
3294
3312
|
},
|
|
3313
|
+
"lane": {
|
|
3314
|
+
"allOf": [
|
|
3315
|
+
{
|
|
3316
|
+
"$ref": "#/components/schemas/ExportFindingLane"
|
|
3317
|
+
}
|
|
3318
|
+
],
|
|
3319
|
+
"description": "The lane of the assessment that recorded the finding."
|
|
3320
|
+
},
|
|
3295
3321
|
"organization_id": {
|
|
3296
3322
|
"description": "The organization that owns the finding.",
|
|
3297
3323
|
"format": "uuid",
|
|
@@ -3338,7 +3364,7 @@
|
|
|
3338
3364
|
"validation_id",
|
|
3339
3365
|
"finding_id",
|
|
3340
3366
|
"review_id",
|
|
3341
|
-
"
|
|
3367
|
+
"lane",
|
|
3342
3368
|
"validation",
|
|
3343
3369
|
"source",
|
|
3344
3370
|
"created_at"
|
|
@@ -3349,7 +3375,7 @@
|
|
|
3349
3375
|
"description": "One immutable finding occurrence. Reference payloads and evidence values stay private.",
|
|
3350
3376
|
"properties": {
|
|
3351
3377
|
"assessment_id": {
|
|
3352
|
-
"description": "The environment assessment that recorded the finding.",
|
|
3378
|
+
"description": "The environment or code assessment that recorded the finding; `lane` says which.",
|
|
3353
3379
|
"format": "uuid",
|
|
3354
3380
|
"type": "string"
|
|
3355
3381
|
},
|
|
@@ -3363,16 +3389,19 @@
|
|
|
3363
3389
|
"type": "string"
|
|
3364
3390
|
},
|
|
3365
3391
|
"dataset_version": {
|
|
3366
|
-
"description": "The row contract version, always `
|
|
3392
|
+
"description": "The row contract version, always `2`.",
|
|
3367
3393
|
"format": "uint16",
|
|
3368
3394
|
"maximum": 65535,
|
|
3369
3395
|
"minimum": 0,
|
|
3370
3396
|
"type": "integer"
|
|
3371
3397
|
},
|
|
3372
3398
|
"environment_id": {
|
|
3373
|
-
"description": "The environment the assessment covers.",
|
|
3399
|
+
"description": "The environment the assessment covers, null for a code-lane finding.",
|
|
3374
3400
|
"format": "uuid",
|
|
3375
|
-
"type":
|
|
3401
|
+
"type": [
|
|
3402
|
+
"string",
|
|
3403
|
+
"null"
|
|
3404
|
+
]
|
|
3376
3405
|
},
|
|
3377
3406
|
"evidence_refs": {
|
|
3378
3407
|
"description": "The finding's evidence references in recorded order, each reduced to a kind and an\n opaque ID; an empty list means the finding records none.",
|
|
@@ -3390,6 +3419,14 @@
|
|
|
3390
3419
|
"description": "The finding's stated impact, with supported credential shapes masked.",
|
|
3391
3420
|
"type": "string"
|
|
3392
3421
|
},
|
|
3422
|
+
"lane": {
|
|
3423
|
+
"allOf": [
|
|
3424
|
+
{
|
|
3425
|
+
"$ref": "#/components/schemas/ExportFindingLane"
|
|
3426
|
+
}
|
|
3427
|
+
],
|
|
3428
|
+
"description": "The lane of the assessment that recorded the finding."
|
|
3429
|
+
},
|
|
3393
3430
|
"lifecycle_state": {
|
|
3394
3431
|
"allOf": [
|
|
3395
3432
|
{
|
|
@@ -3450,7 +3487,7 @@
|
|
|
3450
3487
|
"finding_id",
|
|
3451
3488
|
"review_id",
|
|
3452
3489
|
"assessment_id",
|
|
3453
|
-
"
|
|
3490
|
+
"lane",
|
|
3454
3491
|
"risk_domain",
|
|
3455
3492
|
"severity",
|
|
3456
3493
|
"lifecycle_state",
|
|
@@ -3692,6 +3729,12 @@
|
|
|
3692
3729
|
"format": "date-time",
|
|
3693
3730
|
"type": "string"
|
|
3694
3731
|
},
|
|
3732
|
+
"open_finding_threads": {
|
|
3733
|
+
"description": "The unresolved threads in `unresolved_count` that belong to a\n finding `open_findings` already counts. Absent when none does.",
|
|
3734
|
+
"format": "uint64",
|
|
3735
|
+
"minimum": 0,
|
|
3736
|
+
"type": "integer"
|
|
3737
|
+
},
|
|
3695
3738
|
"status": {
|
|
3696
3739
|
"const": "KNOWN",
|
|
3697
3740
|
"type": "string"
|
|
@@ -6231,7 +6274,7 @@
|
|
|
6231
6274
|
},
|
|
6232
6275
|
"info": {
|
|
6233
6276
|
"title": "Proofline Review API",
|
|
6234
|
-
"version": "
|
|
6277
|
+
"version": "6.1.0"
|
|
6235
6278
|
},
|
|
6236
6279
|
"openapi": "3.1.0",
|
|
6237
6280
|
"paths": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proofline/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Typed clients for the token-scoped Proofline review API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=22"
|
|
17
17
|
},
|
|
18
|
-
"packageManager": "pnpm@
|
|
18
|
+
"packageManager": "pnpm@12.19.0",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepack": "pnpm build"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@biomejs/biome": "2.6.
|
|
39
|
+
"@biomejs/biome": "2.6.8",
|
|
40
40
|
"@types/node": "22.20.5",
|
|
41
41
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
42
42
|
"openapi-typescript": "7.13.0",
|