@certkor/certone 0.0.0-stage → 0.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.
Files changed (103) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +140 -2
  3. package/dist/cjs/binary.d.ts +8 -0
  4. package/dist/cjs/binary.d.ts.map +1 -0
  5. package/dist/cjs/binary.js +39 -0
  6. package/dist/cjs/binary.js.map +1 -0
  7. package/dist/cjs/client.d.ts +66 -0
  8. package/dist/cjs/client.d.ts.map +1 -0
  9. package/dist/cjs/client.js +401 -0
  10. package/dist/cjs/client.js.map +1 -0
  11. package/dist/cjs/common.d.ts +7 -0
  12. package/dist/cjs/common.d.ts.map +1 -0
  13. package/dist/cjs/common.js +22 -0
  14. package/dist/cjs/common.js.map +1 -0
  15. package/dist/cjs/errors.d.ts +53 -0
  16. package/dist/cjs/errors.d.ts.map +1 -0
  17. package/dist/cjs/errors.js +74 -0
  18. package/dist/cjs/errors.js.map +1 -0
  19. package/dist/cjs/index.d.ts +8 -0
  20. package/dist/cjs/index.d.ts.map +1 -0
  21. package/dist/cjs/index.js +27 -0
  22. package/dist/cjs/index.js.map +1 -0
  23. package/dist/cjs/index.node.d.ts +7 -0
  24. package/dist/cjs/index.node.d.ts.map +1 -0
  25. package/dist/cjs/index.node.js +26 -0
  26. package/dist/cjs/index.node.js.map +1 -0
  27. package/dist/cjs/package.json +1 -0
  28. package/dist/cjs/sha256.d.ts +13 -0
  29. package/dist/cjs/sha256.d.ts.map +1 -0
  30. package/dist/cjs/sha256.js +25 -0
  31. package/dist/cjs/sha256.js.map +1 -0
  32. package/dist/cjs/sha256.node.d.ts +13 -0
  33. package/dist/cjs/sha256.node.d.ts.map +1 -0
  34. package/dist/cjs/sha256.node.js +40 -0
  35. package/dist/cjs/sha256.node.js.map +1 -0
  36. package/dist/cjs/types.d.ts +234 -0
  37. package/dist/cjs/types.d.ts.map +1 -0
  38. package/dist/cjs/types.js +12 -0
  39. package/dist/cjs/types.js.map +1 -0
  40. package/dist/cjs/validate.d.ts +24 -0
  41. package/dist/cjs/validate.d.ts.map +1 -0
  42. package/dist/cjs/validate.js +202 -0
  43. package/dist/cjs/validate.js.map +1 -0
  44. package/dist/cjs/version.d.ts +3 -0
  45. package/dist/cjs/version.d.ts.map +1 -0
  46. package/dist/cjs/version.js +6 -0
  47. package/dist/cjs/version.js.map +1 -0
  48. package/dist/esm/binary.d.ts +8 -0
  49. package/dist/esm/binary.d.ts.map +1 -0
  50. package/dist/esm/binary.js +34 -0
  51. package/dist/esm/binary.js.map +1 -0
  52. package/dist/esm/client.d.ts +66 -0
  53. package/dist/esm/client.d.ts.map +1 -0
  54. package/dist/esm/client.js +397 -0
  55. package/dist/esm/client.js.map +1 -0
  56. package/dist/esm/common.d.ts +7 -0
  57. package/dist/esm/common.d.ts.map +1 -0
  58. package/dist/esm/common.js +6 -0
  59. package/dist/esm/common.js.map +1 -0
  60. package/dist/esm/errors.d.ts +53 -0
  61. package/dist/esm/errors.d.ts.map +1 -0
  62. package/dist/esm/errors.js +69 -0
  63. package/dist/esm/errors.js.map +1 -0
  64. package/dist/esm/index.d.ts +8 -0
  65. package/dist/esm/index.d.ts.map +1 -0
  66. package/dist/esm/index.js +8 -0
  67. package/dist/esm/index.js.map +1 -0
  68. package/dist/esm/index.node.d.ts +7 -0
  69. package/dist/esm/index.node.d.ts.map +1 -0
  70. package/dist/esm/index.node.js +7 -0
  71. package/dist/esm/index.node.js.map +1 -0
  72. package/dist/esm/sha256.d.ts +13 -0
  73. package/dist/esm/sha256.d.ts.map +1 -0
  74. package/dist/esm/sha256.js +21 -0
  75. package/dist/esm/sha256.js.map +1 -0
  76. package/dist/esm/sha256.node.d.ts +13 -0
  77. package/dist/esm/sha256.node.d.ts.map +1 -0
  78. package/dist/esm/sha256.node.js +36 -0
  79. package/dist/esm/sha256.node.js.map +1 -0
  80. package/dist/esm/types.d.ts +234 -0
  81. package/dist/esm/types.d.ts.map +1 -0
  82. package/dist/esm/types.js +11 -0
  83. package/dist/esm/types.js.map +1 -0
  84. package/dist/esm/validate.d.ts +24 -0
  85. package/dist/esm/validate.d.ts.map +1 -0
  86. package/dist/esm/validate.js +193 -0
  87. package/dist/esm/validate.js.map +1 -0
  88. package/dist/esm/version.d.ts +3 -0
  89. package/dist/esm/version.d.ts.map +1 -0
  90. package/dist/esm/version.js +3 -0
  91. package/dist/esm/version.js.map +1 -0
  92. package/package.json +83 -4
  93. package/src/binary.ts +35 -0
  94. package/src/client.ts +480 -0
  95. package/src/common.ts +48 -0
  96. package/src/errors.ts +105 -0
  97. package/src/index.node.ts +6 -0
  98. package/src/index.ts +7 -0
  99. package/src/sha256.node.ts +36 -0
  100. package/src/sha256.ts +26 -0
  101. package/src/types.ts +260 -0
  102. package/src/validate.ts +214 -0
  103. package/src/version.ts +2 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,141 @@
1
- # Temporary Holding Version
1
+ # CertOne JavaScript/TypeScript SDK
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A typed client for the CertOne control-plane API, for Node.js (18 or later) and browsers. It
4
+ implements the cross-language contract in [`SPEC.md`](../SPEC.md). No runtime dependencies:
5
+ it uses the platform `fetch`, `FormData`, `Blob` and Web Crypto (or `node:crypto` on Node.js).
6
+ Ships ESM and CommonJS builds with type declarations.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @certkor/certone
12
+ ```
13
+
14
+ ## Node.js
15
+
16
+ ```ts
17
+ import { readFile } from "node:fs/promises";
18
+ import { CertOneClient, inputDigest } from "@certkor/certone";
19
+
20
+ const certone = new CertOneClient({ baseUrl: "https://api.yourco.com", token: process.env.CERTONE_API_KEY });
21
+ const snapshot = await readFile("project.tar.gz");
22
+
23
+ const check = await certone.submitCheck(snapshot, { asset: "Fraud Scorer", environment: "ci", failOn: "high" });
24
+ const report = await certone.waitForReport(check.scan_run.id); // also covers queued scans
25
+ const doc = await certone.getReportDocument(report.id); // verdict, summary, issues[]
26
+ console.log(report.verdict_status, report.by_severity, doc.issues[0]?.description);
27
+ ```
28
+
29
+ CommonJS works the same way: `const { CertOneClient } = require("@certkor/certone")`.
30
+
31
+ ## Browser
32
+
33
+ ```ts
34
+ import { CertOneClient } from "@certkor/certone";
35
+
36
+ const certone = new CertOneClient({ baseUrl: "https://api.yourco.com", token: () => session.idToken() });
37
+ const file = fileInput.files[0]; // a .tar.gz picked in <input type="file">
38
+ const check = await certone.submitCheck(file, { asset: "Fraud Scorer", environment: "api" });
39
+ const systems = await certone.listSystems();
40
+ ```
41
+
42
+ Bundlers pick the browser build automatically (no Node.js imports). Use an OIDC ID token from your
43
+ identity provider in the browser rather than a long-lived API key. The control plane must allow
44
+ your origin (CORS). `inputDigest`/`sha256Hex` need a secure context (`https`) in browsers.
45
+
46
+ ## Authentication
47
+
48
+ `token` is a tenant API key (`ck_…`, Organization → API keys in the console) or an OIDC ID token,
49
+ sent as `Authorization: Bearer <token>`. Pass a function instead of a string to supply a fresh
50
+ token on every request. The token is kept in a private field and never appears in errors, logs or
51
+ `JSON.stringify(client)`; a token with whitespace or control characters (for example a trailing
52
+ `\r` from a CRLF env file) is rejected before any request is sent.
53
+
54
+ ## Operations
55
+
56
+ | Method | HTTP | Returns |
57
+ |---|---|---|
58
+ | `submitCheck(snapshot, options?)` | `POST /v1/checks` (multipart) | `CheckResult` |
59
+ | `submitProcess(snapshot, options?)` | `POST /v1/process` (multipart, `tee`) | `ProcessResult` (`queued: true`, `report: null` on the confidential pool) |
60
+ | `getScan(scanId)` | `GET /v1/scans/{id}` | `ScanRun` |
61
+ | `waitForReport(scanId, { timeoutMs, intervalMs, signal })` | polls the scan, then `GET /v1/scans/{id}/report` | `Report` |
62
+ | `getReportDocument(reportId)` | `GET /v1/reports/{id}/document` | `ReportDocument` |
63
+ | `getAttestation(reportId)` | `GET /v1/reports/{id}/attestation` | `Attestation` (404 when the verdict did not pass) |
64
+ | `ingestReport(report, options?)` | `POST /v1/checks/report` (JSON) | `CheckResult` |
65
+ | `listSystems()` | `GET /v1/systems` | `AISystem[]` |
66
+
67
+ `reportId` is the report record's `id` (for example `report.id`), not the engine's `report_id`.
68
+ A snapshot is a `.tar.gz` given as a `Blob`/`File`, `ArrayBuffer`, `Uint8Array` or Node `Buffer`.
69
+ Response objects keep the API's snake_case field names and ISO-8601 timestamps, and are checked
70
+ at runtime against the documented shape.
71
+
72
+ Scan options (all optional, server defaults apply when omitted): `asset`, `environment`
73
+ (`ci | jupyter | vscode | edge | api | cloud | cli`, default `api`), `countryCode` (default `ZZ`),
74
+ `failOn` (`low | medium | high | none`, default `high`), `packs` (array or comma-separated),
75
+ `snapshotRef`, `commitHash`, `filename`; `submitProcess` adds `tee` (default `amd_sev_snp`).
76
+
77
+ ## Run at source
78
+
79
+ Evaluate where the model lives and submit only the report. `inputDigest` binds the attestation to
80
+ the exact bytes the report covers:
81
+
82
+ ```ts
83
+ const result = await certone.ingestReport(engineReport, {
84
+ asset: "Fraud Scorer", environment: "edge", countryCode: "EU",
85
+ inputDigest: await inputDigest(snapshot), // "sha256:<hex>"
86
+ });
87
+ const attestation = await certone.getAttestation(result.report!.id);
88
+ ```
89
+
90
+ ## Errors, timeouts and cancellation
91
+
92
+ Every failure rejects with `CertOneError`:
93
+
94
+ ```ts
95
+ import { CertOneError } from "@certkor/certone";
96
+
97
+ try {
98
+ await certone.getAttestation(report.id);
99
+ } catch (err) {
100
+ if (CertOneError.is(err) && err.kind === "http" && err.status === 404) {
101
+ console.log("no attestation:", err.detail); // the verdict did not pass
102
+ } else {
103
+ throw err;
104
+ }
105
+ }
106
+ ```
107
+
108
+ | `kind` | When | Fields |
109
+ |---|---|---|
110
+ | `http` | status >= 400 | `status`, `detail` (the API's `detail`), `responseBody` |
111
+ | `network` | no response (DNS, TLS, connection refused, CORS) | `cause` |
112
+ | `timeout` | request timeout, or the `waitForReport` deadline | `scanId` for waits |
113
+ | `aborted` | your `AbortSignal` fired | `cause` = the abort reason |
114
+ | `scan_failed` | `waitForReport` saw the scan fail | `detail` = the scan's `error`, `scanId` |
115
+ | `invalid_response` | a 2xx body that is not the documented JSON | `status`, `responseBody` |
116
+
117
+ `method` and `url` identify the request. `CertOneError.is(err)` also recognises errors from another
118
+ copy of the package (for example the CJS and ESM builds side by side). Invalid arguments throw
119
+ `TypeError`/`RangeError` before anything is sent.
120
+
121
+ Each request times out after 30 s (`timeoutMs` on the client or per call). `waitForReport` polls
122
+ every 2 s for up to 900 s. Every method accepts `{ signal }` to cancel. Inject `fetch` to add a
123
+ proxy, retries or custom TLS:
124
+
125
+ ```ts
126
+ new CertOneClient({ baseUrl, token, timeoutMs: 120_000, fetch: myFetch, headers: { "x-request-id": id } });
127
+ ```
128
+
129
+ ## Quickstart and development
130
+
131
+ `examples/quickstart.mjs` (and the typed `examples/quickstart.ts`) run the SPEC conformance flow:
132
+ check, wait, document, run-at-source ingest, attestation, systems. Configure with
133
+ `CERTONE_API_URL`, `CERTONE_API_KEY`, `CERTONE_SNAPSHOT` and `CERTONE_REPORT_JSON`.
134
+
135
+ ```bash
136
+ npm ci && npm run check # strict typecheck, ESM+CJS build, unit tests, package type lint
137
+ js/ci/run.sh # the same plus the live quickstart, in Docker on Node 18/20/22/24
138
+ js/ci/run.sh --offline # without the conformance control plane
139
+ ```
140
+
141
+ The live conformance run needs a CertOne test environment; Certkor AI provides one to partners on request. The offline tests (`ci/run.sh --offline`) need nothing else.
@@ -0,0 +1,8 @@
1
+ import type { BinaryInput } from "./types.js";
2
+ /** Wrap any supported binary input as a `Blob` for a multipart upload (no copy for Blobs). */
3
+ export declare function toBlob(input: BinaryInput, type?: string): Blob;
4
+ /** The input's bytes, reading a `Blob` fully into memory. */
5
+ export declare function toBytes(input: BinaryInput): Promise<Uint8Array<ArrayBuffer>>;
6
+ /** Lower-case hex encoding. */
7
+ export declare function toHex(bytes: ArrayBuffer | Uint8Array): string;
8
+ //# sourceMappingURL=binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../src/binary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgB9C,8FAA8F;AAC9F,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,SAAqB,GAAG,IAAI,CAG1E;AAED,6DAA6D;AAC7D,wBAAsB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAGlF;AAED,+BAA+B;AAC/B,wBAAgB,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,CAK7D"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBlob = toBlob;
4
+ exports.toBytes = toBytes;
5
+ exports.toHex = toHex;
6
+ function isBlob(value) {
7
+ return typeof Blob !== "undefined" && value instanceof Blob;
8
+ }
9
+ /** A view over the input's bytes backed by a plain `ArrayBuffer` (copies only shared memory). */
10
+ function bytesView(input) {
11
+ if (input instanceof ArrayBuffer)
12
+ return new Uint8Array(input);
13
+ if (ArrayBuffer.isView(input)) {
14
+ const view = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
15
+ return input.buffer instanceof ArrayBuffer ? view : view.slice();
16
+ }
17
+ throw new TypeError("expected a Blob, ArrayBuffer or ArrayBufferView (Uint8Array, Buffer, ...)");
18
+ }
19
+ /** Wrap any supported binary input as a `Blob` for a multipart upload (no copy for Blobs). */
20
+ function toBlob(input, type = "application/gzip") {
21
+ if (isBlob(input))
22
+ return input;
23
+ return new Blob([bytesView(input)], { type });
24
+ }
25
+ /** The input's bytes, reading a `Blob` fully into memory. */
26
+ async function toBytes(input) {
27
+ if (isBlob(input))
28
+ return new Uint8Array(await input.arrayBuffer());
29
+ return bytesView(input);
30
+ }
31
+ /** Lower-case hex encoding. */
32
+ function toHex(bytes) {
33
+ const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
34
+ let out = "";
35
+ for (const byte of view)
36
+ out += byte.toString(16).padStart(2, "0");
37
+ return out;
38
+ }
39
+ //# sourceMappingURL=binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.js","sourceRoot":"","sources":["../../src/binary.ts"],"names":[],"mappings":";;AAiBA,wBAGC;AAGD,0BAGC;AAGD,sBAKC;AAhCD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,KAAK,YAAY,IAAI,CAAC;AAC9D,CAAC;AAED,iGAAiG;AACjG,SAAS,SAAS,CAAC,KAAoC;IACrD,IAAI,KAAK,YAAY,WAAW;QAAE,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/D,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9E,OAAO,KAAK,CAAC,MAAM,YAAY,WAAW,CAAC,CAAC,CAAE,IAAgC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAChG,CAAC;IACD,MAAM,IAAI,SAAS,CAAC,2EAA2E,CAAC,CAAC;AACnG,CAAC;AAED,8FAA8F;AAC9F,SAAgB,MAAM,CAAC,KAAkB,EAAE,IAAI,GAAG,kBAAkB;IAClE,IAAI,MAAM,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAChC,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,6DAA6D;AACtD,KAAK,UAAU,OAAO,CAAC,KAAkB;IAC9C,IAAI,MAAM,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IACpE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,+BAA+B;AAC/B,SAAgB,KAAK,CAAC,KAA+B;IACnD,MAAM,IAAI,GAAG,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACzE,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,IAAI;QAAE,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { AISystem, Attestation, BinaryInput, CertOneClientOptions, CheckResult, IngestOptions, ProcessOptions, ProcessResult, Report, ReportDocument, RequestOptions, ScanOptions, ScanRun, WaitOptions } from "./types.js";
2
+ /** Default per-request timeout (SPEC: 30 s). */
3
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
4
+ /** Default `waitForReport` deadline (SPEC: 900 s). */
5
+ export declare const DEFAULT_WAIT_TIMEOUT_MS = 900000;
6
+ /** Default `waitForReport` poll interval (SPEC: 2 s). */
7
+ export declare const DEFAULT_POLL_INTERVAL_MS = 2000;
8
+ /**
9
+ * Client for the CertOne control-plane REST API (`SPEC.md`).
10
+ *
11
+ * ```ts
12
+ * const certone = new CertOneClient({ baseUrl: "https://api.yourco.com", token: process.env.CERTONE_API_KEY });
13
+ * const { scan_run, report } = await certone.submitCheck(snapshotBytes, { asset: "Fraud Scorer" });
14
+ * ```
15
+ *
16
+ * Every method rejects with {@link CertOneError} on HTTP errors (status >= 400), network
17
+ * failures, timeouts, aborts and malformed responses. The token is held in a private field and is
18
+ * never included in errors, logs or `JSON.stringify(client)`.
19
+ */
20
+ export declare class CertOneClient {
21
+ #private;
22
+ /** Normalised base URL (no trailing slash). */
23
+ readonly baseUrl: string;
24
+ /** Per-request timeout in milliseconds. */
25
+ readonly timeoutMs: number;
26
+ constructor(options: CertOneClientOptions);
27
+ /** `POST /v1/checks`: static compliance check of a project snapshot (`.tar.gz`). */
28
+ submitCheck(snapshot: BinaryInput, options?: ScanOptions): Promise<CheckResult>;
29
+ /**
30
+ * `POST /v1/process`: full processing (static + dynamic) on the confidential worker pool. On the
31
+ * asynchronous pool the result has `queued: true` and `report: null`; use {@link waitForReport}.
32
+ */
33
+ submitProcess(snapshot: BinaryInput, options?: ProcessOptions): Promise<ProcessResult>;
34
+ /** `GET /v1/scans/{id}`. */
35
+ getScan(scanId: string, options?: RequestOptions): Promise<ScanRun>;
36
+ /**
37
+ * Polls `GET /v1/scans/{id}` until the scan is `succeeded` or `failed`, then returns its report
38
+ * (`GET /v1/scans/{id}/report`). A `failed` scan rejects with kind `scan_failed` carrying the
39
+ * scan's `error`; exceeding `timeoutMs` rejects with kind `timeout`.
40
+ */
41
+ waitForReport(scanId: string, options?: WaitOptions): Promise<Report>;
42
+ /**
43
+ * `GET /v1/reports/{id}/document`: the full engine report (`verdict`, `summary`, `issues`).
44
+ * `reportId` is the report record's `id` (for example `report.id`), not the engine `report_id`.
45
+ */
46
+ getReportDocument(reportId: string, options?: RequestOptions): Promise<ReportDocument>;
47
+ /**
48
+ * `GET /v1/reports/{id}/attestation`: the conditional compliance attestation. Rejects with an
49
+ * `http` error of status 404 when the verdict did not pass (no attestation was issued).
50
+ */
51
+ getAttestation(reportId: string, options?: RequestOptions): Promise<Attestation>;
52
+ /**
53
+ * `POST /v1/checks/report`: submit an engine report computed where the model lives
54
+ * (run-at-source). The model and code never leave the caller's environment; pass
55
+ * `inputDigest: await inputDigest(snapshotBytes)` to bind the attestation to the exact input.
56
+ */
57
+ ingestReport(report: Readonly<Record<string, unknown>>, options?: IngestOptions): Promise<CheckResult>;
58
+ /** `GET /v1/systems`: the tenant's AI-system inventory with each system's posture. */
59
+ listSystems(options?: RequestOptions): Promise<AISystem[]>;
60
+ /** Never expose the token through `JSON.stringify(client)`. */
61
+ toJSON(): {
62
+ baseUrl: string;
63
+ timeoutMs: number;
64
+ };
65
+ }
66
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,WAAW,EAEX,aAAa,EACb,cAAc,EACd,aAAa,EACb,MAAM,EACN,cAAc,EACd,cAAc,EACd,WAAW,EACX,OAAO,EAEP,WAAW,EACZ,MAAM,YAAY,CAAC;AAWpB,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAC/C,yDAAyD;AACzD,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAqB9C;;;;;;;;;;;GAWG;AACH,qBAAa,aAAa;;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAMf,OAAO,EAAE,oBAAoB;IAoCzC,oFAAoF;IAC9E,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;IAQzF;;;OAGG;IACG,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IAShG,4BAA4B;IACtB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAO7E;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiC/E;;;OAGG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAOhG;;;OAGG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IAO1F;;;;OAIG;IACG,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IA0BhH,sFAAsF;IAChF,WAAW,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIpE,+DAA+D;IAC/D,MAAM,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;CAmHjD"}