@tinfoilsh/verifier 1.3.0 → 2.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +29 -17
  2. package/dist/document/collateral/collateral.d.ts +76 -0
  3. package/dist/document/collateral/collateral.d.ts.map +1 -0
  4. package/dist/document/collateral/collateral.js +175 -0
  5. package/dist/document/collateral/collateral.js.map +1 -0
  6. package/dist/document/collateral/config.d.ts +24 -0
  7. package/dist/document/collateral/config.d.ts.map +1 -0
  8. package/dist/document/collateral/config.js +46 -0
  9. package/dist/document/collateral/config.js.map +1 -0
  10. package/dist/document/collateral/runtime.d.ts +20 -0
  11. package/dist/document/collateral/runtime.d.ts.map +1 -0
  12. package/dist/document/collateral/runtime.js +37 -0
  13. package/dist/document/collateral/runtime.js.map +1 -0
  14. package/dist/document/collateral/sev.d.ts +13 -0
  15. package/dist/document/collateral/sev.d.ts.map +1 -0
  16. package/dist/document/collateral/sev.js +26 -0
  17. package/dist/document/collateral/sev.js.map +1 -0
  18. package/dist/document/collateral/sigstore.d.ts +19 -0
  19. package/dist/document/collateral/sigstore.d.ts.map +1 -0
  20. package/dist/document/collateral/sigstore.js +31 -0
  21. package/dist/document/collateral/sigstore.js.map +1 -0
  22. package/dist/document/collateral/tdx.d.ts +14 -0
  23. package/dist/document/collateral/tdx.d.ts.map +1 -0
  24. package/dist/document/collateral/tdx.js +44 -0
  25. package/dist/document/collateral/tdx.js.map +1 -0
  26. package/dist/document/document.d.ts +112 -0
  27. package/dist/document/document.d.ts.map +1 -0
  28. package/dist/document/document.js +387 -0
  29. package/dist/document/document.js.map +1 -0
  30. package/dist/errors.d.ts +44 -76
  31. package/dist/errors.d.ts.map +1 -1
  32. package/dist/errors.js +52 -81
  33. package/dist/errors.js.map +1 -1
  34. package/dist/index.d.ts +31 -10
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +70 -10
  37. package/dist/index.js.map +1 -1
  38. package/dist/internal/bytes.d.ts +13 -0
  39. package/dist/internal/bytes.d.ts.map +1 -0
  40. package/dist/internal/bytes.js +37 -0
  41. package/dist/internal/bytes.js.map +1 -0
  42. package/dist/internal/canonical.js +89 -0
  43. package/dist/internal/canonical.js.map +1 -0
  44. package/dist/internal/endorsement/approval.js +467 -0
  45. package/dist/internal/endorsement/approval.js.map +1 -0
  46. package/dist/internal/endorsement/freshness.js +122 -0
  47. package/dist/internal/endorsement/freshness.js.map +1 -0
  48. package/dist/internal/endorsement/provenance.js +256 -0
  49. package/dist/internal/endorsement/provenance.js.map +1 -0
  50. package/dist/internal/endorsement/reference.d.ts +32 -0
  51. package/dist/internal/endorsement/reference.d.ts.map +1 -0
  52. package/dist/internal/endorsement/reference.js +37 -0
  53. package/dist/internal/endorsement/reference.js.map +1 -0
  54. package/dist/internal/endorsement/registry-certificate.js +147 -0
  55. package/dist/internal/endorsement/registry-certificate.js.map +1 -0
  56. package/dist/internal/endorsement/runtime.js +52 -0
  57. package/dist/internal/endorsement/runtime.js.map +1 -0
  58. package/dist/internal/endorsement/time.js +26 -0
  59. package/dist/internal/endorsement/time.js.map +1 -0
  60. package/dist/internal/json/decode.js +151 -0
  61. package/dist/internal/json/decode.js.map +1 -0
  62. package/dist/internal/json/index.d.ts +68 -0
  63. package/dist/internal/json/index.d.ts.map +1 -0
  64. package/dist/internal/json/index.js +486 -0
  65. package/dist/internal/json/index.js.map +1 -0
  66. package/dist/internal/policy/artifact.js +191 -0
  67. package/dist/internal/policy/artifact.js.map +1 -0
  68. package/dist/internal/policy/sev.js +157 -0
  69. package/dist/internal/policy/sev.js.map +1 -0
  70. package/dist/internal/policy/shape.js +31 -0
  71. package/dist/internal/policy/shape.js.map +1 -0
  72. package/dist/internal/policy/tdx.js +55 -0
  73. package/dist/internal/policy/tdx.js.map +1 -0
  74. package/dist/internal/quote/config.js +53 -0
  75. package/dist/internal/quote/config.js.map +1 -0
  76. package/dist/internal/quote/legacy.js +67 -0
  77. package/dist/internal/quote/legacy.js.map +1 -0
  78. package/dist/internal/quote/quote.js +139 -0
  79. package/dist/internal/quote/quote.js.map +1 -0
  80. package/dist/internal/quote/resolve.js +88 -0
  81. package/dist/internal/quote/resolve.js.map +1 -0
  82. package/dist/internal/quote/sev/authenticate.js +125 -0
  83. package/dist/internal/quote/sev/authenticate.js.map +1 -0
  84. package/dist/internal/quote/sev/expectations.js +288 -0
  85. package/dist/internal/quote/sev/expectations.js.map +1 -0
  86. package/dist/internal/quote/sev/identity.js +13 -0
  87. package/dist/internal/quote/sev/identity.js.map +1 -0
  88. package/dist/internal/quote/sev/report.js +224 -0
  89. package/dist/internal/quote/sev/report.js.map +1 -0
  90. package/dist/internal/quote/sev/tcb.js +110 -0
  91. package/dist/internal/quote/sev/tcb.js.map +1 -0
  92. package/dist/internal/quote/sev/vcek.js +299 -0
  93. package/dist/internal/quote/sev/vcek.js.map +1 -0
  94. package/dist/internal/quote/tdx/abi.js +161 -0
  95. package/dist/internal/quote/tdx/abi.js.map +1 -0
  96. package/dist/internal/quote/tdx/authenticate.js +343 -0
  97. package/dist/internal/quote/tdx/authenticate.js.map +1 -0
  98. package/dist/internal/quote/tdx/identity.js +11 -0
  99. package/dist/internal/quote/tdx/identity.js.map +1 -0
  100. package/dist/internal/quote/tdx/pck.js +133 -0
  101. package/dist/internal/quote/tdx/pck.js.map +1 -0
  102. package/dist/internal/quote/tdx/pcs.js +482 -0
  103. package/dist/internal/quote/tdx/pcs.js.map +1 -0
  104. package/dist/internal/rfc3339.js +24 -0
  105. package/dist/internal/rfc3339.js.map +1 -0
  106. package/dist/internal/runtime/config.js +61 -0
  107. package/dist/internal/runtime/config.js.map +1 -0
  108. package/dist/internal/runtime/manifest.js +82 -0
  109. package/dist/internal/runtime/manifest.js.map +1 -0
  110. package/dist/internal/semver.js +124 -0
  111. package/dist/internal/semver.js.map +1 -0
  112. package/dist/internal/sigstore/bundle.js +205 -0
  113. package/dist/internal/sigstore/bundle.js.map +1 -0
  114. package/dist/internal/sigstore/certificate.js +220 -0
  115. package/dist/internal/sigstore/certificate.js.map +1 -0
  116. package/dist/internal/sigstore/certified.js +56 -0
  117. package/dist/internal/sigstore/certified.js.map +1 -0
  118. package/dist/internal/sigstore/keyed.js +556 -0
  119. package/dist/internal/sigstore/keyed.js.map +1 -0
  120. package/dist/internal/sigstore/timestamp.js +421 -0
  121. package/dist/internal/sigstore/timestamp.js.map +1 -0
  122. package/dist/internal/sigstore/trusted-root.js +144 -0
  123. package/dist/internal/sigstore/trusted-root.js.map +1 -0
  124. package/dist/internal/x509/certificate.js +521 -0
  125. package/dist/internal/x509/certificate.js.map +1 -0
  126. package/dist/internal/x509/crl.js +116 -0
  127. package/dist/internal/x509/crl.js.map +1 -0
  128. package/dist/internal/x509/der.js +409 -0
  129. package/dist/internal/x509/der.js.map +1 -0
  130. package/dist/measurement.d.ts +47 -0
  131. package/dist/measurement.d.ts.map +1 -0
  132. package/dist/measurement.js +92 -0
  133. package/dist/measurement.js.map +1 -0
  134. package/dist/trust/amd-genoa-chain.js +4 -0
  135. package/dist/trust/amd-genoa-chain.js.map +1 -0
  136. package/dist/trust/amd-turin-chain.js +4 -0
  137. package/dist/trust/amd-turin-chain.js.map +1 -0
  138. package/dist/trust/intel-sgx-root.js +4 -0
  139. package/dist/trust/intel-sgx-root.js.map +1 -0
  140. package/dist/trust/signing-keys.js +7 -0
  141. package/dist/trust/signing-keys.js.map +1 -0
  142. package/dist/trust/sigstore-trusted-root.js +4 -0
  143. package/dist/trust/sigstore-trusted-root.js.map +1 -0
  144. package/dist/verification.d.ts +134 -0
  145. package/dist/verification.d.ts.map +1 -0
  146. package/dist/verification.js +129 -0
  147. package/dist/verification.js.map +1 -0
  148. package/dist/verifier.d.ts +115 -0
  149. package/dist/verifier.d.ts.map +1 -0
  150. package/dist/verifier.js +565 -0
  151. package/dist/verifier.js.map +1 -0
  152. package/dist/version.js +2 -3
  153. package/dist/version.js.map +1 -1
  154. package/package.json +20 -12
  155. package/dist/attestation.d.ts +0 -14
  156. package/dist/attestation.d.ts.map +0 -1
  157. package/dist/attestation.js +0 -117
  158. package/dist/attestation.js.map +0 -1
  159. package/dist/bundle.d.ts +0 -15
  160. package/dist/bundle.d.ts.map +0 -1
  161. package/dist/bundle.js +0 -134
  162. package/dist/bundle.js.map +0 -1
  163. package/dist/cert-verify.d.ts +0 -30
  164. package/dist/cert-verify.d.ts.map +0 -1
  165. package/dist/cert-verify.js +0 -132
  166. package/dist/cert-verify.js.map +0 -1
  167. package/dist/client.d.ts +0 -17
  168. package/dist/client.d.ts.map +0 -1
  169. package/dist/client.js +0 -135
  170. package/dist/client.js.map +0 -1
  171. package/dist/dcode.d.ts +0 -7
  172. package/dist/dcode.d.ts.map +0 -1
  173. package/dist/dcode.js +0 -35
  174. package/dist/dcode.js.map +0 -1
  175. package/dist/json.d.ts +0 -3
  176. package/dist/json.d.ts.map +0 -1
  177. package/dist/json.js +0 -4
  178. package/dist/json.js.map +0 -1
  179. package/dist/sev/cert-chain.d.ts +0 -22
  180. package/dist/sev/cert-chain.d.ts.map +0 -1
  181. package/dist/sev/cert-chain.js +0 -253
  182. package/dist/sev/cert-chain.js.map +0 -1
  183. package/dist/sev/certs.d.ts +0 -3
  184. package/dist/sev/certs.d.ts.map +0 -1
  185. package/dist/sev/certs.js +0 -77
  186. package/dist/sev/certs.js.map +0 -1
  187. package/dist/sev/constants.d.ts +0 -20
  188. package/dist/sev/constants.d.ts.map +0 -1
  189. package/dist/sev/constants.js +0 -22
  190. package/dist/sev/constants.js.map +0 -1
  191. package/dist/sev/report.d.ts +0 -52
  192. package/dist/sev/report.d.ts.map +0 -1
  193. package/dist/sev/report.js +0 -228
  194. package/dist/sev/report.js.map +0 -1
  195. package/dist/sev/types.d.ts +0 -35
  196. package/dist/sev/types.d.ts.map +0 -1
  197. package/dist/sev/types.js +0 -2
  198. package/dist/sev/types.js.map +0 -1
  199. package/dist/sev/utils.d.ts +0 -7
  200. package/dist/sev/utils.d.ts.map +0 -1
  201. package/dist/sev/utils.js +0 -59
  202. package/dist/sev/utils.js.map +0 -1
  203. package/dist/sev/validation.d.ts +0 -39
  204. package/dist/sev/validation.d.ts.map +0 -1
  205. package/dist/sev/validation.js +0 -324
  206. package/dist/sev/validation.js.map +0 -1
  207. package/dist/sev/verify.d.ts +0 -11
  208. package/dist/sev/verify.d.ts.map +0 -1
  209. package/dist/sev/verify.js +0 -141
  210. package/dist/sev/verify.js.map +0 -1
  211. package/dist/sigstore-trusted-root.d.ts +0 -94
  212. package/dist/sigstore-trusted-root.d.ts.map +0 -1
  213. package/dist/sigstore-trusted-root.js +0 -127
  214. package/dist/sigstore-trusted-root.js.map +0 -1
  215. package/dist/sigstore.d.ts +0 -18
  216. package/dist/sigstore.d.ts.map +0 -1
  217. package/dist/sigstore.js +0 -115
  218. package/dist/sigstore.js.map +0 -1
  219. package/dist/types.d.ts +0 -94
  220. package/dist/types.d.ts.map +0 -1
  221. package/dist/types.js +0 -73
  222. package/dist/types.js.map +0 -1
  223. package/dist/version.d.ts +0 -4
  224. package/dist/version.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @tinfoilsh/verifier
2
2
 
3
- Browser-compatible TypeScript library for verifying AMD SEV-SNP attestation reports and Sigstore code provenance.
3
+ Verifies Tinfoil attestation documents in TypeScript, on Node, Bun and in browsers: the enclave's hardware quote (AMD SEV-SNP or Intel TDX), the Sigstore provenance of the code and platform it runs, the freshness of those endorsements, and the policy that ties the quote's measurements to the release. The verifier opens no connections, keeps no state between calls, and uses WebCrypto only.
4
4
 
5
- **Most users should use the main [`tinfoil`](https://www.npmjs.com/package/tinfoil) package instead.** It includes this verifier and runs it automatically. Use this package directly for standalone verification, custom verification flows, or audit tooling.
5
+ **Most users should use the main [`tinfoil`](https://www.npmjs.com/package/tinfoil) package instead.** Its clients fetch the document, run this verifier and bind every request to the verified enclave. Use this package directly for standalone verification, custom verification flows, or audit tooling. Coming from 1.x? See [Migrating from 1.x to 2.0](https://github.com/tinfoilsh/tinfoil-js/blob/main/MIGRATION.md).
6
6
 
7
7
  ## Installation
8
8
 
@@ -13,28 +13,39 @@ npm install @tinfoilsh/verifier
13
13
  ## Quick Start
14
14
 
15
15
  ```typescript
16
- import { Verifier } from '@tinfoilsh/verifier';
16
+ import { Verifier, randomNonce, toHex } from "@tinfoilsh/verifier";
17
17
 
18
- const verifier = new Verifier({
19
- serverURL: 'https://enclave.example.com',
20
- configRepo: 'tinfoilsh/confidential-model-router',
21
- });
22
- const attestation = await verifier.verify();
18
+ // Embedded production trust roots and signing keys, 7-day freshness bound.
19
+ const verifier = await Verifier.create();
23
20
 
24
- console.log(attestation.measurement);
25
- console.log(attestation.tlsPublicKeyFingerprint);
26
- console.log(attestation.hpkePublicKey);
21
+ // The enclave serves its document for a nonce you choose, which the
22
+ // attestation endpoint takes as lowercase hex in the query string.
23
+ const nonce = randomNonce();
24
+ const response = await fetch(`https://inference.tinfoil.sh/.well-known/tinfoil-attestation?nonce=${toHex(nonce)}`);
25
+ const document = new Uint8Array(await response.arrayBuffer());
27
26
 
28
- // Per-step results and measurements
29
- const doc = verifier.getVerificationDocument();
30
- console.log(doc?.securityVerified);
27
+ const verification = await verifier.verifyV3(document, nonce, "tinfoilsh/confidential-model-router");
28
+
29
+ verification.codeDigest; // the verified release
30
+ verification.enclaveMeasurement; // the quote's authenticated registers
31
+ verification.tlsPublicKeyFP; // the endorsed TLS key (SPKI SHA-256), if any
32
+ verification.hpkePublicKey; // the endorsed HPKE key, if any
33
+ verification.freshnessExpiresAt; // when a cached verification stops authorizing requests
31
34
  ```
32
35
 
33
- `verifyBundle(bundle)` verifies an attestation bundle you already hold. Failed verification throws `AttestationError`, a failed fetch in `verify()` throws `FetchError`, and missing options throw `ConfigurationError`.
36
+ `verifyV3` samples the clock once and judges every time-bound check at that instant; `verifyV3At(document, nonce, repo, when)` uses `when` instead. The `repo` pin is `owner/name[@tag][@sha256:digest]` (`parseReference` validates one), and `checkRepoVerifiability(repo)` rejects a pin the verifier could never accept, without a document.
37
+
38
+ `Verifier.create(options)` configures the policy: `pinnedRegisters` must match the enclave's registers, `freshnessMaxAgeMs` bounds witness age, `configSigningKeys` and `freshnessSigningKeys` replace the public trust in the config and approval signers, `configRegistryIDs` names exactly the registries whose certified config approvals are accepted in place of the public registry alone (list `PUBLIC_REGISTRY_ID` among them, `[PUBLIC_REGISTRY_ID, ...mine]`, to keep accepting the public one), `configAuthorizer` lets the caller authorize the config itself, and `embeddedReferences` supplies caller-trusted reference values for the config (`config` is either `{ bytes, name? }` or, when the bytes are not disclosed, `{ digest, runtime, name? }` with the config's SHA-256 and the runtime release it pins), runtime or platform. An option that cannot be honoured is a `UsageError`.
39
+
40
+ A `Verification` is a frozen object of `readonly` properties: `codeDigest`, `codeTag`, `configRepo`, `codeMeasurement` (the registers the release fixes), `enclaveMeasurement`, `cryptoMaterial` and `cryptoMaterialData(id, format)` for every endorsed key, `config`, `runtime` and `platform` for what a config-based verification accepted and where each reference came from, and `metadata` for the verifier's name and version and when it ran. Register bytes and `Date` values are shared, not copied, and must not be mutated. `JSON.stringify(verification)` (or `toJSON()`) gives the same facts as plain JSON, with registers as lowercase hex and times as ISO 8601 strings.
41
+
42
+ ### Errors
43
+
44
+ Every error is a `VerifyError`, except from the hex helpers: `fromHex` verifies nothing, so it throws a plain `Error` for anything but lowercase hex of even length, the form `toHex` writes. A `UsageError` means the verifier was built or called with invalid inputs, so retrying won't help. A `VerificationError` means the document must not be trusted; its `layer` names the check that failed: `envelope` (document shape and nonce binding), `provenance` (code, config and platform endorsements and their freshness), `quote` (the hardware quote) or `policy` (the measurements against the release). Those are the layers today; a later version may add one, so treat a `layer` you don't recognize as a rejection at a stage you have no name for. The verifier fails closed: an internal failure inside a layer (a bug, an exhausted resource) is reported as a `VerificationError` at that layer with the underlying error as `cause`, so an unfamiliar message at a layer may be the verifier itself failing rather than the document; inspect `cause` before treating it as a verdict on the document.
34
45
 
35
- Obtaining `tlsPublicKeyFingerprint` does not pin anything: a custom transport must compare it with the live peer certificate's SPKI on every new TLS connection, in addition to normal hostname and certificate validation.
46
+ ### Pinning
36
47
 
37
- Release metadata and attestation bundles are fetched through Tinfoil-hosted GitHub proxy endpoints, so verification fails in environments that cannot reach them.
48
+ Reading `tlsPublicKeyFP` pins nothing: a transport must compare it with the live peer certificate's SPKI fingerprint on every new TLS connection, in addition to normal hostname and certificate validation; `certPubkeyFP(certDer)` computes the same form from a DER certificate. Likewise `hpkePublicKey` only identifies the key request bodies must be sealed to.
38
49
 
39
50
  See [Attestation architecture](https://docs.tinfoil.sh/verification/attestation-architecture) and [Verification in Tinfoil](https://docs.tinfoil.sh/verification/verification-in-tinfoil) for what gets verified.
40
51
 
@@ -44,6 +55,7 @@ See [Attestation architecture](https://docs.tinfoil.sh/verification/attestation-
44
55
  npm run build
45
56
  npm test
46
57
  npm run test:browser
58
+ npm run test:conformance # the shared tinfoil-conformance fixtures; set TINFOIL_CONFORMANCE_FIXTURES to its vectors/v3
47
59
  ```
48
60
 
49
61
  ## Reporting Vulnerabilities
@@ -0,0 +1,76 @@
1
+ import { type JsonObject, type JsonValue } from "../../internal/json/index.js";
2
+ import { type ConfigEndorsement } from "./config.js";
3
+ import { type RuntimeCollateral } from "./runtime.js";
4
+ import { type AmdCrl, type AmdVcek } from "./sev.js";
5
+ import { type Freshness, type SigstoreRef } from "./sigstore.js";
6
+ import { type IntelPcs } from "./tdx.js";
7
+ export declare const FORMAT_V2 = "https://tinfoil.sh/predicate/attestation-collaterals/v2";
8
+ export declare const FORMAT_V3 = "https://tinfoil.sh/predicate/attestation-collaterals/v3";
9
+ export declare const AMD_VCEK_V1_FORMAT = "https://tinfoil.sh/collateral/amd-vcek/v1";
10
+ export declare const AMD_CRL_V1_FORMAT = "https://tinfoil.sh/collateral/amd-crl/v1";
11
+ export declare const INTEL_PCS_V1_FORMAT = "https://tinfoil.sh/collateral/intel-pcs/v1";
12
+ export declare const NVIDIA_GPU_V1_FORMAT = "https://tinfoil.sh/collateral/nvidia-gpu/v1";
13
+ export declare const SIGSTORE_CODE_V1_FORMAT = "https://tinfoil.sh/collateral/sigstore-code/v1";
14
+ export declare const SIGSTORE_PLATFORM_V1_FORMAT = "https://tinfoil.sh/collateral/sigstore-platform/v1";
15
+ export declare const SIGSTORE_FRESHNESS_V1_FORMAT = "https://tinfoil.sh/collateral/sigstore-freshness/v1";
16
+ export declare const ARTIFACT_FRESHNESS_V1_FORMAT = "https://tinfoil.sh/collateral/artifact-freshness/v1";
17
+ export declare const CONFIG_ENDORSEMENT_V1_FORMAT = "https://tinfoil.sh/collateral/config-endorsement/v1";
18
+ /** A config endorsement that may carry a registry issuer certificate and omit the config bytes. */
19
+ export declare const CONFIG_ENDORSEMENT_V2_FORMAT = "https://tinfoil.sh/collateral/config-endorsement/v2";
20
+ export declare const CONFIG_V1_FORMAT = "https://tinfoil.sh/collateral/config/v1";
21
+ export declare const ROLE_ENDORSEMENT = "endorsement";
22
+ export declare const ROLE_REFERENCE_VALUES = "reference-values";
23
+ export declare const SUBJECT_CPU = "cpu";
24
+ export declare const FRESHNESS_ID_CODE = "code-freshness";
25
+ export declare const FRESHNESS_ID_PLATFORM = "platform-freshness";
26
+ export declare const FRESHNESS_ID_RUNTIME = "runtime-freshness";
27
+ export declare const CONFIG_ID = "tinfoil-config";
28
+ /** One wire collateral record. `data` stays undecoded until its format is known; undefined when absent. */
29
+ export interface Entry {
30
+ readonly id: string;
31
+ readonly role: string;
32
+ readonly format: string;
33
+ readonly subjects?: readonly string[];
34
+ readonly data: JsonValue | undefined;
35
+ }
36
+ /** Thrown (or wrapped) when a required collateral entry is absent. */
37
+ export declare class NotFoundError extends Error {
38
+ constructor(what: string);
39
+ }
40
+ /** Vendor collateral for the reserved "cpu" subject. */
41
+ export interface CpuEndorsements {
42
+ readonly amdVcek?: AmdVcek;
43
+ readonly amdCrl?: AmdCrl;
44
+ readonly intelPcs?: IntelPcs;
45
+ }
46
+ /** Decoded collateral: the first entry per purpose, freshness by id. */
47
+ export interface CollateralSet {
48
+ readonly cpu: CpuEndorsements;
49
+ readonly sigstoreCode?: SigstoreRef;
50
+ readonly sigstorePlatform?: SigstoreRef;
51
+ readonly config?: ConfigEndorsement;
52
+ readonly runtime?: RuntimeCollateral;
53
+ readonly freshness: ReadonlyMap<string, Freshness>;
54
+ readonly configPlatform?: SigstoreRef;
55
+ }
56
+ /**
57
+ * Decodes the wire array into entries; an entry with a member outside the
58
+ * known set rejects. null decodes as no entries.
59
+ */
60
+ export declare function decodeEntries(v: JsonValue | undefined): Entry[];
61
+ /**
62
+ * Validates every entry's shape, decodes known role+format pairs, and
63
+ * enforces reserved ids. An entry with no decoder for its role and format is
64
+ * shape-checked and dropped. An endorsement entry serves the CPU only when its
65
+ * subjects include "cpu".
66
+ */
67
+ export declare function decode(entries: readonly Entry[]): CollateralSet;
68
+ /**
69
+ * Strictly decodes an entry's data object with the given member set (any
70
+ * other member rejects) and reads its fields with `read`. Any shape or type
71
+ * error from either step carries the entry's context.
72
+ */
73
+ export declare function unmarshalData<T>(entry: Entry, label: string, known: readonly string[], read: (data: JsonObject) => T): T;
74
+ /** The single config-platform reference (id "platform"). */
75
+ export declare function configPlatform(set: CollateralSet): SigstoreRef;
76
+ //# sourceMappingURL=collateral.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collateral.d.ts","sourceRoot":"","sources":["../../../src/document/collateral/collateral.ts"],"names":[],"mappings":"AAMA,OAAO,EAAa,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAA6D,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjH,OAAO,EAA+B,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EAAsC,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAkB,KAAK,QAAQ,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wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAED,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAGnD,QAAQ,CAAC,cAAc,CAAC,EAAE,WAAW,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,KAAK,EAAE,CAY/D;AAKD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,aAAa,CAwD/D;AAkBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,CAAC,GAAG,CAAC,CAMxH;AAED,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,WAAW,CAM9D"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * The document's collateral array: untrusted transport for vendor
3
+ * endorsements, reference values and freshness proofs. Every entry is
4
+ * authenticated by its own signature chain later; decoding only checks shape.
5
+ */
6
+ import { arr, object, raw, str } from "../../internal/json/decode.js";
7
+ import { JsonError } from "../../internal/json/index.js";
8
+ import { decodeConfigEndorsement } from "./config.js";
9
+ import { decodeRuntime, PLATFORM_ID, RUNTIME_ID, RUNTIME_V1_FORMAT } from "./runtime.js";
10
+ import { decodeAmdCrl, decodeAmdVcek } from "./sev.js";
11
+ import { decodeFreshness, decodeSigstoreRef } from "./sigstore.js";
12
+ import { decodeIntelPcs } from "./tdx.js";
13
+ export const FORMAT_V2 = "https://tinfoil.sh/predicate/attestation-collaterals/v2";
14
+ export const FORMAT_V3 = "https://tinfoil.sh/predicate/attestation-collaterals/v3";
15
+ export const AMD_VCEK_V1_FORMAT = "https://tinfoil.sh/collateral/amd-vcek/v1";
16
+ export const AMD_CRL_V1_FORMAT = "https://tinfoil.sh/collateral/amd-crl/v1";
17
+ export const INTEL_PCS_V1_FORMAT = "https://tinfoil.sh/collateral/intel-pcs/v1";
18
+ export const NVIDIA_GPU_V1_FORMAT = "https://tinfoil.sh/collateral/nvidia-gpu/v1";
19
+ export const SIGSTORE_CODE_V1_FORMAT = "https://tinfoil.sh/collateral/sigstore-code/v1";
20
+ export const SIGSTORE_PLATFORM_V1_FORMAT = "https://tinfoil.sh/collateral/sigstore-platform/v1";
21
+ export const SIGSTORE_FRESHNESS_V1_FORMAT = "https://tinfoil.sh/collateral/sigstore-freshness/v1";
22
+ export const ARTIFACT_FRESHNESS_V1_FORMAT = "https://tinfoil.sh/collateral/artifact-freshness/v1";
23
+ export const CONFIG_ENDORSEMENT_V1_FORMAT = "https://tinfoil.sh/collateral/config-endorsement/v1";
24
+ /** A config endorsement that may carry a registry issuer certificate and omit the config bytes. */
25
+ export const CONFIG_ENDORSEMENT_V2_FORMAT = "https://tinfoil.sh/collateral/config-endorsement/v2";
26
+ export const CONFIG_V1_FORMAT = "https://tinfoil.sh/collateral/config/v1";
27
+ export const ROLE_ENDORSEMENT = "endorsement";
28
+ export const ROLE_REFERENCE_VALUES = "reference-values";
29
+ export const SUBJECT_CPU = "cpu";
30
+ export const FRESHNESS_ID_CODE = "code-freshness";
31
+ export const FRESHNESS_ID_PLATFORM = "platform-freshness";
32
+ export const FRESHNESS_ID_RUNTIME = "runtime-freshness";
33
+ export const CONFIG_ID = "tinfoil-config";
34
+ /** Thrown (or wrapped) when a required collateral entry is absent. */
35
+ export class NotFoundError extends Error {
36
+ constructor(what) {
37
+ super(`collateral entry not found: ${what}`);
38
+ this.name = "NotFoundError";
39
+ }
40
+ }
41
+ /**
42
+ * Decodes the wire array into entries; an entry with a member outside the
43
+ * known set rejects. null decodes as no entries.
44
+ */
45
+ export function decodeEntries(v) {
46
+ if (v === undefined || v === null)
47
+ return [];
48
+ if (!Array.isArray(v))
49
+ throw new JsonError("collateral must be an array");
50
+ return v.map((item) => {
51
+ const o = object(item, "collateral entry", ["id", "role", "format", "subjects", "data"]);
52
+ const subjects = arr(o, "subjects")?.map((s) => {
53
+ if (s === null)
54
+ return "";
55
+ if (typeof s !== "string")
56
+ throw new JsonError("collateral subjects must be strings");
57
+ return s;
58
+ });
59
+ return { id: str(o, "id"), role: str(o, "role"), format: str(o, "format"), subjects, data: raw(o, "data") };
60
+ });
61
+ }
62
+ /** The formats a config entry may carry. */
63
+ const CONFIG_FORMATS = [CONFIG_ENDORSEMENT_V1_FORMAT, CONFIG_ENDORSEMENT_V2_FORMAT, CONFIG_V1_FORMAT];
64
+ /**
65
+ * Validates every entry's shape, decodes known role+format pairs, and
66
+ * enforces reserved ids. An entry with no decoder for its role and format is
67
+ * shape-checked and dropped. An endorsement entry serves the CPU only when its
68
+ * subjects include "cpu".
69
+ */
70
+ export function decode(entries) {
71
+ validate(entries);
72
+ const cpu = {};
73
+ const freshness = new Map();
74
+ let sigstoreCode;
75
+ let sigstorePlatform;
76
+ let config;
77
+ let runtime;
78
+ let configPlatform;
79
+ let platformCount = 0;
80
+ for (const entry of entries) {
81
+ const forCpu = entry.subjects?.includes(SUBJECT_CPU) ?? false;
82
+ if (entry.id === PLATFORM_ID || entry.format === SIGSTORE_PLATFORM_V1_FORMAT)
83
+ platformCount++;
84
+ if (entry.id === CONFIG_ID || CONFIG_FORMATS.includes(entry.format)) {
85
+ if (entry.id !== CONFIG_ID || !CONFIG_FORMATS.includes(entry.format) || entry.role !== ROLE_REFERENCE_VALUES) {
86
+ throw new Error(`conflicting collateral entry for "${CONFIG_ID}"`);
87
+ }
88
+ config = decodeConfigEndorsement(entry);
89
+ }
90
+ else if (entry.id === RUNTIME_ID || entry.format === RUNTIME_V1_FORMAT) {
91
+ if (entry.id !== RUNTIME_ID || entry.format !== RUNTIME_V1_FORMAT || entry.role !== ROLE_REFERENCE_VALUES) {
92
+ throw new Error(`conflicting collateral entry for "${RUNTIME_ID}"`);
93
+ }
94
+ runtime = decodeRuntime(entry);
95
+ }
96
+ else if (entry.format === ARTIFACT_FRESHNESS_V1_FORMAT || entry.id === FRESHNESS_ID_RUNTIME) {
97
+ if ((entry.id !== FRESHNESS_ID_PLATFORM && entry.id !== FRESHNESS_ID_RUNTIME) ||
98
+ entry.format !== ARTIFACT_FRESHNESS_V1_FORMAT ||
99
+ entry.role !== ROLE_REFERENCE_VALUES) {
100
+ throw new Error(`conflicting artifact freshness collateral "${entry.id}"`);
101
+ }
102
+ freshness.set(entry.id, decodeFreshness(entry));
103
+ }
104
+ else if (entry.role === ROLE_ENDORSEMENT && entry.format === AMD_VCEK_V1_FORMAT) {
105
+ const v = decodeAmdVcek(entry);
106
+ if (forCpu && cpu.amdVcek === undefined)
107
+ cpu.amdVcek = v;
108
+ }
109
+ else if (entry.role === ROLE_ENDORSEMENT && entry.format === AMD_CRL_V1_FORMAT) {
110
+ const v = decodeAmdCrl(entry);
111
+ if (forCpu && cpu.amdCrl === undefined)
112
+ cpu.amdCrl = v;
113
+ }
114
+ else if (entry.role === ROLE_ENDORSEMENT && entry.format === INTEL_PCS_V1_FORMAT) {
115
+ const v = decodeIntelPcs(entry);
116
+ if (forCpu && cpu.intelPcs === undefined)
117
+ cpu.intelPcs = v;
118
+ }
119
+ else if (entry.role === ROLE_REFERENCE_VALUES && entry.format === SIGSTORE_CODE_V1_FORMAT) {
120
+ const v = decodeSigstoreRef(entry);
121
+ sigstoreCode ?? (sigstoreCode = v);
122
+ }
123
+ else if (entry.role === ROLE_REFERENCE_VALUES && entry.format === SIGSTORE_PLATFORM_V1_FORMAT) {
124
+ const v = decodeSigstoreRef(entry);
125
+ sigstorePlatform ?? (sigstorePlatform = v);
126
+ if (entry.id === PLATFORM_ID)
127
+ configPlatform = v;
128
+ }
129
+ else if (entry.role === ROLE_REFERENCE_VALUES && entry.format === SIGSTORE_FRESHNESS_V1_FORMAT) {
130
+ // validate already rejected duplicate ids.
131
+ freshness.set(entry.id, decodeFreshness(entry));
132
+ }
133
+ }
134
+ return { cpu, sigstoreCode, sigstorePlatform, config, runtime, freshness, platformCount, configPlatform };
135
+ }
136
+ function validate(entries) {
137
+ const seen = new Set();
138
+ entries.forEach((entry, i) => {
139
+ if (entry.id === "" || entry.format === "")
140
+ throw new Error(`collateral entry ${i} is incomplete`);
141
+ if (seen.has(entry.id))
142
+ throw new Error(`duplicate collateral entry id "${entry.id}"`);
143
+ seen.add(entry.id);
144
+ if (entry.role !== ROLE_ENDORSEMENT && entry.role !== ROLE_REFERENCE_VALUES) {
145
+ throw new Error(`collateral entry "${entry.id}" has unknown role "${entry.role}"`);
146
+ }
147
+ // Every entry's data must be exactly one JSON object, known format or not.
148
+ if (!(entry.data instanceof Map)) {
149
+ throw new Error(`collateral entry "${entry.id}" data is not a valid JSON object`);
150
+ }
151
+ });
152
+ }
153
+ /**
154
+ * Strictly decodes an entry's data object with the given member set (any
155
+ * other member rejects) and reads its fields with `read`. Any shape or type
156
+ * error from either step carries the entry's context.
157
+ */
158
+ export function unmarshalData(entry, label, known, read) {
159
+ try {
160
+ return read(object(entry.data ?? null, `${label} data`, known));
161
+ }
162
+ catch (err) {
163
+ throw new Error(`parsing ${label} collateral entry "${entry.id}": ${err.message}`);
164
+ }
165
+ }
166
+ /** The single config-platform reference (id "platform"). */
167
+ export function configPlatform(set) {
168
+ if (set.platformCount === 0)
169
+ throw new NotFoundError("no platform reference-values entry");
170
+ if (set.platformCount !== 1 || set.configPlatform === undefined) {
171
+ throw new Error("conflicting platform collateral for config verification");
172
+ }
173
+ return set.configPlatform;
174
+ }
175
+ //# sourceMappingURL=collateral.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collateral.js","sourceRoot":"","sources":["../../../src/document/collateral/collateral.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,SAAS,EAAmC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAA0B,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAA0B,MAAM,cAAc,CAAC;AACjH,OAAO,EAAE,YAAY,EAAE,aAAa,EAA6B,MAAM,UAAU,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAoC,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,cAAc,EAAiB,MAAM,UAAU,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,yDAAyD,CAAC;AACnF,MAAM,CAAC,MAAM,SAAS,GAAG,yDAAyD,CAAC;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,2CAA2C,CAAC;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC;AAC5E,MAAM,CAAC,MAAM,mBAAmB,GAAG,4CAA4C,CAAC;AAChF,MAAM,CAAC,MAAM,oBAAoB,GAAG,6CAA6C,CAAC;AAClF,MAAM,CAAC,MAAM,uBAAuB,GAAG,gDAAgD,CAAC;AACxF,MAAM,CAAC,MAAM,2BAA2B,GAAG,oDAAoD,CAAC;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,qDAAq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jC,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,CAAC,EAAE,mCAAmC,CAAC,CAAC;QACpF,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAI,KAAY,EAAE,KAAa,EAAE,KAAwB,EAAE,IAA6B;IACnH,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,GAAG,KAAK,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;IAClE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,WAAW,KAAK,sBAAsB,KAAK,CAAC,EAAE,MAAO,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IAChG,CAAC;AACH,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,cAAc,CAAC,GAAkB;IAC/C,IAAI,GAAG,CAAC,aAAa,KAAK,CAAC;QAAE,MAAM,IAAI,aAAa,CAAC,oCAAoC,CAAC,CAAC;IAC3F,IAAI,GAAG,CAAC,aAAa,KAAK,CAAC,IAAI,GAAG,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,GAAG,CAAC,cAAc,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type Entry } from "./collateral.js";
2
+ /**
3
+ * Decoded, unauthenticated config material. Plain config/v1 collateral has no
4
+ * reference or bundle and requires caller authorization; a signed reference
5
+ * must match the independently verified endorsement. Only v2 endorsement
6
+ * collateral may carry a registry issuer certificate or omit the config
7
+ * bytes (a digest-only deployment).
8
+ */
9
+ export interface ConfigEndorsement {
10
+ /** "sha256:<hex>" endorsement reference; "" for plain config/v1. */
11
+ readonly reference: string;
12
+ /** The exact config bytes; absent for a digest-only v2 endorsement. */
13
+ readonly config?: Uint8Array;
14
+ /**
15
+ * The sigstore_bundle member's JSON text as sent, byte for byte as it
16
+ * appears in the document; undefined when absent. `JSON.parse` turns it
17
+ * into a plain object.
18
+ */
19
+ readonly bundle?: string;
20
+ /** The DER certificate of the registry issuer that certified the signing certificate, when present. */
21
+ readonly issuer?: Uint8Array;
22
+ }
23
+ export declare function decodeConfigEndorsement(entry: Entry): ConfigEndorsement;
24
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/document/collateral/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE5G;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,uGAAuG;IACvG,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAC9B;AAID,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,KAAK,GAAG,iBAAiB,CAkCvE"}
@@ -0,0 +1,46 @@
1
+ import { decodeBase64, decodeLowerHex } from "../../internal/canonical.js";
2
+ import { raw, str } from "../../internal/json/decode.js";
3
+ import { sourceText } from "../../internal/json/index.js";
4
+ import { CONFIG_ENDORSEMENT_V2_FORMAT, CONFIG_V1_FORMAT, unmarshalData } from "./collateral.js";
5
+ const MEMBERS = ["endorsement_ref", "config_base64", "sigstore_bundle", "issuer_certificate_der"];
6
+ export function decodeConfigEndorsement(entry) {
7
+ const c = unmarshalData(entry, entry.format, MEMBERS, (o) => ({
8
+ reference: str(o, "endorsement_ref"),
9
+ configBase64: str(o, "config_base64"),
10
+ bundle: raw(o, "sigstore_bundle"),
11
+ issuerBase64: str(o, "issuer_certificate_der"),
12
+ }));
13
+ const { reference } = c;
14
+ if (c.issuerBase64 !== "" && entry.format !== CONFIG_ENDORSEMENT_V2_FORMAT) {
15
+ throw new Error("issuer certificates require v2 config collateral");
16
+ }
17
+ let bundle;
18
+ if (entry.format === CONFIG_V1_FORMAT) {
19
+ // A non-empty reference or any sigstore_bundle member, including an explicit null, counts as an endorsement.
20
+ if (reference !== "" || c.bundle !== undefined) {
21
+ throw new Error("plain config collateral cannot contain an endorsement");
22
+ }
23
+ }
24
+ else {
25
+ if (!reference.startsWith("sha256:"))
26
+ throw new Error("endorsement_ref must be a SHA-256 reference");
27
+ decodeLowerHex("endorsement_ref", reference.slice("sha256:".length), 32);
28
+ if (!(c.bundle instanceof Map))
29
+ throw new Error("sigstore_bundle must be an object");
30
+ // The bundle travels on as the member's source text; the approval
31
+ // verifier parses it again, strictly, when it needs the tree.
32
+ bundle = sourceText(c.bundle);
33
+ if (bundle === undefined)
34
+ throw new Error("sigstore_bundle has no source text");
35
+ }
36
+ const issuer = c.issuerBase64 === "" ? undefined : decodeBase64("issuer_certificate_der", c.issuerBase64);
37
+ const optional = { ...(bundle === undefined ? {} : { bundle }), ...(issuer === undefined ? {} : { issuer }) };
38
+ if (entry.format === CONFIG_ENDORSEMENT_V2_FORMAT && c.configBase64 === "") {
39
+ return { reference, ...optional };
40
+ }
41
+ const config = decodeBase64("config_base64", c.configBase64);
42
+ if (config.length === 0)
43
+ throw new Error("config_base64 must not be empty");
44
+ return { reference, config, ...optional };
45
+ }
46
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/document/collateral/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,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E,CAAC,CAAC;QACzE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,YAAY,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACrF,kEAAkE;QAClE,8DAA8D;QAC9D,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAClF,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,wBAAwB,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC;IAC1G,MAAM,QAAQ,GAAG,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC9G,IAAI,KAAK,CAAC,MAAM,KAAK,4BAA4B,IAAI,CAAC,CAAC,YAAY,KAAK,EAAE,EAAE,CAAC;QAC3E,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,CAAC;IACpC,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC;IAC7D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Reference } from "../../internal/endorsement/reference.js";
2
+ import type { JsonValue } from "../../internal/json/index.js";
3
+ import { type Entry } from "./collateral.js";
4
+ export declare const RUNTIME_REPO = "tinfoilsh/cvmimage";
5
+ export declare const RUNTIME_ID = "runtime";
6
+ export declare const RUNTIME_V1_FORMAT = "https://tinfoil.sh/collateral/igvm-runtime/v1";
7
+ export declare const PLATFORM_ID = "platform";
8
+ /** A runtime release pin: a runtime release is named the same way as a code release. */
9
+ export type RuntimeReference = Reference;
10
+ /** Repo must be cvmimage, tag a full semver, digest 32-byte lowercase hex. */
11
+ export declare function validateRuntimeReference(r: RuntimeReference): void;
12
+ /** Field-by-field equality of two runtime references; used by the provenance layer's runtime authentication. */
13
+ export declare function runtimeReferenceEqual(a: RuntimeReference, b: RuntimeReference): boolean;
14
+ /** Decoded runtime collateral. */
15
+ export interface RuntimeCollateral extends RuntimeReference {
16
+ readonly manifest: Uint8Array;
17
+ readonly bundle: JsonValue;
18
+ }
19
+ export declare function decodeRuntime(entry: Entry): RuntimeCollateral;
20
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/document/collateral/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAiB,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE5D,eAAO,MAAM,YAAY,uBAAuB,CAAC;AACjD,eAAO,MAAM,UAAU,YAAY,CAAC;AACpC,eAAO,MAAM,iBAAiB,kDAAkD,CAAC;AACjF,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC,wFAAwF;AACxF,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAEzC,8EAA8E;AAC9E,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAMlE;AAED,gHAAgH;AAChH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAEvF;AAED,kCAAkC;AAClC,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,iBAAiB,CAa7D"}
@@ -0,0 +1,37 @@
1
+ import { decodeBase64, decodeLowerHex } from "../../internal/canonical.js";
2
+ import { raw, str } from "../../internal/json/decode.js";
3
+ import * as semver from "../../internal/semver.js";
4
+ import { unmarshalData } from "./collateral.js";
5
+ export const RUNTIME_REPO = "tinfoilsh/cvmimage";
6
+ export const RUNTIME_ID = "runtime";
7
+ export const RUNTIME_V1_FORMAT = "https://tinfoil.sh/collateral/igvm-runtime/v1";
8
+ export const PLATFORM_ID = "platform";
9
+ /** Repo must be cvmimage, tag a full semver, digest 32-byte lowercase hex. */
10
+ export function validateRuntimeReference(r) {
11
+ if (r.repo !== RUNTIME_REPO)
12
+ throw new Error(`runtime repository must be ${RUNTIME_REPO}`);
13
+ if (!semver.isValid(r.tag) || semver.canonical(r.tag) + semver.build(r.tag) !== r.tag) {
14
+ throw new Error("runtime tag must be a full semantic version");
15
+ }
16
+ decodeLowerHex("runtime digest", r.digest, 32);
17
+ }
18
+ /** Field-by-field equality of two runtime references; used by the provenance layer's runtime authentication. */
19
+ export function runtimeReferenceEqual(a, b) {
20
+ return a.repo === b.repo && a.tag === b.tag && a.digest === b.digest;
21
+ }
22
+ export function decodeRuntime(entry) {
23
+ const c = unmarshalData(entry, entry.format, ["repo", "tag", "digest", "manifest_base64", "sigstore_bundle"], (o) => ({
24
+ ref: { repo: str(o, "repo"), tag: str(o, "tag"), digest: str(o, "digest") },
25
+ manifestBase64: str(o, "manifest_base64"),
26
+ bundle: raw(o, "sigstore_bundle"),
27
+ }));
28
+ const { ref, bundle } = c;
29
+ validateRuntimeReference(ref);
30
+ // An empty manifest is accepted here: decoding checks shape only, and it
31
+ // fails the manifest digest check when the runtime is authenticated.
32
+ const manifest = decodeBase64("manifest_base64", c.manifestBase64);
33
+ if (!(bundle instanceof Map))
34
+ throw new Error("sigstore_bundle must be an object");
35
+ return { ...ref, manifest, bundle };
36
+ }
37
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/document/collateral/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAc,MAAM,iBAAiB,CAAC;AAE5D,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AACpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,+CAA+C,CAAC;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AAKtC,8EAA8E;AAC9E,MAAM,UAAU,wBAAwB,CAAC,CAAmB;IAC1D,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,YAAY,EAAE,CAAC,CAAC;IAC3F,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QACtF,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,cAAc,CAAC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;A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2
+ /** Decoded amd-vcek collateral; the chain is ASK then ARK. */
3
+ export interface AmdVcek {
4
+ readonly vcekDer: Uint8Array;
5
+ readonly certChainPem: string;
6
+ }
7
+ /** Decoded amd-crl collateral. */
8
+ export interface AmdCrl {
9
+ readonly crlDer: Uint8Array;
10
+ }
11
+ export declare function decodeAmdVcek(entry: Entry): AmdVcek;
12
+ export declare function decodeAmdCrl(entry: Entry): AmdCrl;
13
+ //# sourceMappingURL=sev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sev.d.ts","sourceRoot":"","sources":["../../../src/document/collateral/sev.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE5D,8DAA8D;AAC9D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,kCAAkC;AAClC,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CASnD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAGjD"}
@@ -0,0 +1,26 @@
1
+ import { str } from "../../internal/json/decode.js";
2
+ import { decodeBase64 } from "../../internal/canonical.js";
3
+ import { unmarshalData } from "./collateral.js";
4
+ export function decodeAmdVcek(entry) {
5
+ const data = unmarshalData(entry, "amd-vcek", ["vcek_der_base64", "cert_chain_pem"], (o) => ({
6
+ vcekDerBase64: str(o, "vcek_der_base64"),
7
+ certChainPem: str(o, "cert_chain_pem"),
8
+ }));
9
+ return {
10
+ vcekDer: withEntry("amd-vcek", entry, () => decodeBase64("vcek_der_base64", data.vcekDerBase64)),
11
+ certChainPem: data.certChainPem,
12
+ };
13
+ }
14
+ export function decodeAmdCrl(entry) {
15
+ const crl = unmarshalData(entry, "amd-crl", ["crl_der_base64"], (o) => str(o, "crl_der_base64"));
16
+ return { crlDer: withEntry("amd-crl", entry, () => decodeBase64("crl_der_base64", crl)) };
17
+ }
18
+ function withEntry(label, entry, f) {
19
+ try {
20
+ return f();
21
+ }
22
+ catch (err) {
23
+ throw new Error(`${label} collateral entry "${entry.id}": ${err.message}`);
24
+ }
25
+ }
26
+ //# sourceMappingURL=sev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sev.js","sourceRoot":"","sources":["../../../src/document/collateral/sev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAc,MAAM,iBAAiB,CAAC;AAa5D,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3F,aAAa,EAAE,GAAG,CAAC,CAAC,EAAE,iBAAiB,CAAC;QACxC,YAAY,EAAE,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC;KACvC,CAAC,CAAC,CAAC;IACJ,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAChG,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAY;IACvC,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACjG,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;AAC5F,CAAC;AAED,SAAS,SAAS,CAAI,KAAa,EAAE,KAAY,EAAE,CAAU;IAC3D,IAAI,CAAC;QACH,OAAO,CAAC,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,sBAAsB,KAAK,CAAC,EAAE,MAAO,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { JsonValue } from "../../internal/json/index.js";
2
+ import { type Entry } from "./collateral.js";
3
+ /** A Sigstore reference-values entry. Repo and tag are hints; the bundle authenticates. */
4
+ export interface SigstoreRef {
5
+ readonly repo: string;
6
+ readonly tag: string;
7
+ readonly digest: string;
8
+ readonly bundle: JsonValue;
9
+ }
10
+ /** A freshness witness or approval bundle. */
11
+ export interface Freshness {
12
+ readonly format: string;
13
+ readonly bundle: JsonValue;
14
+ }
15
+ /** Requires a non-empty digest and a bundle. */
16
+ export declare function decodeSigstoreRef(entry: Entry): SigstoreRef;
17
+ /** Requires a bundle; records the entry's format. */
18
+ export declare function decodeFreshness(entry: Entry): Freshness;
19
+ //# sourceMappingURL=sigstore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sigstore.d.ts","sourceRoot":"","sources":["../../../src/document/collateral/sigstore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAiB,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE5D,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAa3D;AAED,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAGvD"}
@@ -0,0 +1,31 @@
1
+ import { raw, str } from "../../internal/json/decode.js";
2
+ import { unmarshalData } from "./collateral.js";
3
+ /** Requires a non-empty digest and a bundle. */
4
+ export function decodeSigstoreRef(entry) {
5
+ const data = unmarshalData(entry, entry.format, ["repo", "tag", "digest", "sigstore_bundle"], (o) => ({
6
+ repo: str(o, "repo"),
7
+ tag: str(o, "tag"),
8
+ digest: str(o, "digest"),
9
+ bundle: raw(o, "sigstore_bundle"),
10
+ }));
11
+ const digest = data.digest;
12
+ // Tag is an optional hint and repo is checked by provenance where it
13
+ // matters; the digest and bundle are what verification needs.
14
+ if (digest === "")
15
+ throw new Error(`${entry.format} collateral entry "${entry.id}" is missing digest`);
16
+ const bundle = requireBundle(entry, data.bundle);
17
+ return { repo: data.repo, tag: data.tag, digest, bundle };
18
+ }
19
+ /** Requires a bundle; records the entry's format. */
20
+ export function decodeFreshness(entry) {
21
+ const bundle = unmarshalData(entry, entry.format, ["sigstore_bundle"], (o) => raw(o, "sigstore_bundle"));
22
+ return { format: entry.format, bundle: requireBundle(entry, bundle) };
23
+ }
24
+ /** Rejects a missing or null sigstore_bundle. Whether it verifies is for provenance to judge. */
25
+ function requireBundle(entry, bundle) {
26
+ if (bundle === undefined || bundle === null) {
27
+ throw new Error(`${entry.format} collateral entry "${entry.id}" is missing sigstore_bundle`);
28
+ }
29
+ return bundle;
30
+ }
31
+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