@tinfoilsh/verifier 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.
- package/README.md +40 -0
- package/dist/attestation.d.ts +19 -0
- package/dist/attestation.d.ts.map +1 -0
- package/dist/attestation.js +127 -0
- package/dist/attestation.js.map +1 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +127 -0
- package/dist/client.js.map +1 -0
- package/dist/github.d.ts +22 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +69 -0
- package/dist/github.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/router.d.ts +2 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +13 -0
- package/dist/router.js.map +1 -0
- package/dist/sev/cert-chain.d.ts +22 -0
- package/dist/sev/cert-chain.d.ts.map +1 -0
- package/dist/sev/cert-chain.js +314 -0
- package/dist/sev/cert-chain.js.map +1 -0
- package/dist/sev/certs.d.ts +3 -0
- package/dist/sev/certs.d.ts.map +1 -0
- package/dist/sev/certs.js +77 -0
- package/dist/sev/certs.js.map +1 -0
- package/dist/sev/constants.d.ts +21 -0
- package/dist/sev/constants.d.ts.map +1 -0
- package/dist/sev/constants.js +22 -0
- package/dist/sev/constants.js.map +1 -0
- package/dist/sev/index.d.ts +10 -0
- package/dist/sev/index.d.ts.map +1 -0
- package/dist/sev/index.js +9 -0
- package/dist/sev/index.js.map +1 -0
- package/dist/sev/report.d.ts +52 -0
- package/dist/sev/report.d.ts.map +1 -0
- package/dist/sev/report.js +258 -0
- package/dist/sev/report.js.map +1 -0
- package/dist/sev/types.d.ts +35 -0
- package/dist/sev/types.d.ts.map +1 -0
- package/dist/sev/types.js +2 -0
- package/dist/sev/types.js.map +1 -0
- package/dist/sev/utils.d.ts +8 -0
- package/dist/sev/utils.d.ts.map +1 -0
- package/dist/sev/utils.js +59 -0
- package/dist/sev/utils.js.map +1 -0
- package/dist/sev/validation.d.ts +39 -0
- package/dist/sev/validation.d.ts.map +1 -0
- package/dist/sev/validation.js +323 -0
- package/dist/sev/validation.js.map +1 -0
- package/dist/sev/verify.d.ts +11 -0
- package/dist/sev/verify.d.ts.map +1 -0
- package/dist/sev/verify.js +140 -0
- package/dist/sev/verify.js.map +1 -0
- package/dist/sigstore.d.ts +13 -0
- package/dist/sigstore.d.ts.map +1 -0
- package/dist/sigstore.js +80 -0
- package/dist/sigstore.js.map +1 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +64 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @tinfoilsh/verifier
|
|
2
|
+
|
|
3
|
+
Browser-compatible TypeScript library for verifying AMD SEV-SNP attestation reports and Sigstore code provenance.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tinfoilsh/verifier
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Verifier } from '@tinfoilsh/verifier';
|
|
15
|
+
|
|
16
|
+
const verifier = new Verifier({ serverURL: 'https://enclave.example.com' });
|
|
17
|
+
const attestation = await verifier.verify();
|
|
18
|
+
|
|
19
|
+
console.log(attestation.measurement);
|
|
20
|
+
console.log(attestation.tlsPublicKeyFingerprint);
|
|
21
|
+
console.log(attestation.hpkePublicKey);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- AMD SEV-SNP attestation verification (VCEK certificate chain validation)
|
|
27
|
+
- Sigstore code provenance verification (Fulcio + Rekor)
|
|
28
|
+
- TUF-based trusted root updates
|
|
29
|
+
- Works in Node.js and browsers (uses Web Crypto API)
|
|
30
|
+
|
|
31
|
+
### TODOs
|
|
32
|
+
- [ ] add support for TDX attestation verification
|
|
33
|
+
|
|
34
|
+
## Development
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run build
|
|
38
|
+
npm test
|
|
39
|
+
npm run test:browser
|
|
40
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AttestationDocument, AttestationResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the attestation document from a given enclave hostname.
|
|
4
|
+
*
|
|
5
|
+
* @param host - The hostname of the enclave
|
|
6
|
+
* @returns The attestation document
|
|
7
|
+
* @throws Error if the request fails
|
|
8
|
+
*/
|
|
9
|
+
export declare function fetchAttestation(host: string): Promise<AttestationDocument>;
|
|
10
|
+
/**
|
|
11
|
+
* Checks the attestation document against its trust root
|
|
12
|
+
* and returns the inner measurements.
|
|
13
|
+
*
|
|
14
|
+
* @param doc - The attestation document to verify
|
|
15
|
+
* @returns The verification result
|
|
16
|
+
* @throws Error if verification fails or format is unsupported
|
|
17
|
+
*/
|
|
18
|
+
export declare function verifyAttestation(doc: AttestationDocument): Promise<AttestationResponse>;
|
|
19
|
+
//# sourceMappingURL=attestation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../src/attestation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAU3E;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAcjF;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAM9F"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { PredicateType } from './types.js';
|
|
2
|
+
import { Report } from './sev/report.js';
|
|
3
|
+
import { CertificateChain } from './sev/cert-chain.js';
|
|
4
|
+
import { verifyAttestation as verifyAttestationInternal } from './sev/verify.js';
|
|
5
|
+
import { bytesToHex } from './sev/utils.js';
|
|
6
|
+
import { validateReport, defaultValidationOptions } from './sev/validation.js';
|
|
7
|
+
const ATTESTATION_ENDPOINT = '/.well-known/tinfoil-attestation';
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the attestation document from a given enclave hostname.
|
|
10
|
+
*
|
|
11
|
+
* @param host - The hostname of the enclave
|
|
12
|
+
* @returns The attestation document
|
|
13
|
+
* @throws Error if the request fails
|
|
14
|
+
*/
|
|
15
|
+
export async function fetchAttestation(host) {
|
|
16
|
+
const url = `https://${host}${ATTESTATION_ENDPOINT}`;
|
|
17
|
+
const response = await fetch(url);
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(`Failed to fetch attestation: ${response.status} ${response.statusText}`);
|
|
20
|
+
}
|
|
21
|
+
const docDict = await response.json();
|
|
22
|
+
return {
|
|
23
|
+
format: docDict.format,
|
|
24
|
+
body: docDict.body,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks the attestation document against its trust root
|
|
29
|
+
* and returns the inner measurements.
|
|
30
|
+
*
|
|
31
|
+
* @param doc - The attestation document to verify
|
|
32
|
+
* @returns The verification result
|
|
33
|
+
* @throws Error if verification fails or format is unsupported
|
|
34
|
+
*/
|
|
35
|
+
export async function verifyAttestation(doc) {
|
|
36
|
+
if (doc.format === PredicateType.SevGuestV2) {
|
|
37
|
+
return verifySevAttestationV2(doc.body);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw new Error(`Unsupported attestation format: ${doc.format}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Verify SEV attestation document and return verification result.
|
|
45
|
+
*
|
|
46
|
+
* @param attestationDoc - Base64 encoded attestation document
|
|
47
|
+
* @returns Verification result
|
|
48
|
+
* @throws Error if verification fails
|
|
49
|
+
*/
|
|
50
|
+
async function verifySevAttestationV2(attestationDoc) {
|
|
51
|
+
const report = await verifySevReport(attestationDoc, true);
|
|
52
|
+
const measurement = {
|
|
53
|
+
type: PredicateType.SevGuestV2,
|
|
54
|
+
registers: [bytesToHex(report.measurement)],
|
|
55
|
+
};
|
|
56
|
+
const keys = report.reportData;
|
|
57
|
+
const tlsKeyFp = bytesToHex(keys.slice(0, 32));
|
|
58
|
+
const hpkePublicKey = bytesToHex(keys.slice(32, 64));
|
|
59
|
+
return {
|
|
60
|
+
measurement,
|
|
61
|
+
tlsPublicKeyFingerprint: tlsKeyFp,
|
|
62
|
+
hpkePublicKey,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Verify SEV attestation document and return verification result.
|
|
67
|
+
*
|
|
68
|
+
* @param attestationDoc - Base64 encoded attestation document
|
|
69
|
+
* @param isCompressed - Whether the document is gzip compressed
|
|
70
|
+
* @returns The parsed and verified report
|
|
71
|
+
* @throws Error if verification fails
|
|
72
|
+
*/
|
|
73
|
+
async function verifySevReport(attestationDoc, isCompressed) {
|
|
74
|
+
let attDocBytes;
|
|
75
|
+
try {
|
|
76
|
+
attDocBytes = base64ToBytes(attestationDoc);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
throw new Error('Failed to decode base64', { cause: e });
|
|
80
|
+
}
|
|
81
|
+
if (isCompressed) {
|
|
82
|
+
attDocBytes = await decompressGzip(attDocBytes);
|
|
83
|
+
}
|
|
84
|
+
let report;
|
|
85
|
+
try {
|
|
86
|
+
report = new Report(attDocBytes);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
throw new Error('Failed to parse report', { cause: e });
|
|
90
|
+
}
|
|
91
|
+
const chain = await CertificateChain.fromReport(report);
|
|
92
|
+
let res;
|
|
93
|
+
try {
|
|
94
|
+
res = await verifyAttestationInternal(chain, report);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
throw new Error('Failed to verify attestation', { cause: e });
|
|
98
|
+
}
|
|
99
|
+
if (!res) {
|
|
100
|
+
throw new Error('Attestation verification failed!');
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
validateReport(report, chain, defaultValidationOptions);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
throw new Error('Failed to validate report', { cause: e });
|
|
107
|
+
}
|
|
108
|
+
return report;
|
|
109
|
+
}
|
|
110
|
+
function base64ToBytes(base64) {
|
|
111
|
+
const binaryString = atob(base64);
|
|
112
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
113
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
114
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
115
|
+
}
|
|
116
|
+
return bytes;
|
|
117
|
+
}
|
|
118
|
+
async function decompressGzip(data) {
|
|
119
|
+
const stream = new Response(data.buffer).body;
|
|
120
|
+
if (!stream) {
|
|
121
|
+
throw new Error('Failed to create stream from data');
|
|
122
|
+
}
|
|
123
|
+
const decompressedStream = stream.pipeThrough(new DecompressionStream('gzip'));
|
|
124
|
+
const decompressed = await new Response(decompressedStream).arrayBuffer();
|
|
125
|
+
return new Uint8Array(decompressed);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=attestation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.js","sourceRoot":"","sources":["../src/attestation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,qBA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|
|
|
1
|
+
import type { AttestationResponse, VerificationDocument } from './types.js';
|
|
2
|
+
export interface VerifierOptions {
|
|
3
|
+
serverURL: string;
|
|
4
|
+
configRepo?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class Verifier {
|
|
7
|
+
private enclave;
|
|
8
|
+
private configRepo;
|
|
9
|
+
private verificationDocument?;
|
|
10
|
+
constructor(options: VerifierOptions);
|
|
11
|
+
verify(): Promise<AttestationResponse>;
|
|
12
|
+
private saveFailedVerificationDocument;
|
|
13
|
+
getVerificationDocument(): VerificationDocument | undefined;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA+C,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKzH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAuB;gBAExC,OAAO,EAAE,eAAe;IAQ9B,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC;IA0F5C,OAAO,CAAC,8BAA8B;IAiBtC,uBAAuB,IAAI,oBAAoB,GAAG,SAAS;CAG5D"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { verifyAttestation as verifyAmdAttestation, fetchAttestation } from './attestation.js';
|
|
2
|
+
import { fetchLatestDigest, fetchAttestationBundle } from './github.js';
|
|
3
|
+
import { verifyAttestation as verifySigstoreAttestation } from './sigstore.js';
|
|
4
|
+
import { compareMeasurements, FormatMismatchError, MeasurementMismatchError, measurementFingerprint } from './types.js';
|
|
5
|
+
import { getRouterAddress } from './router.js';
|
|
6
|
+
const DEFAULT_CONFIG_REPO = 'tinfoilsh/confidential-model-router';
|
|
7
|
+
export class Verifier {
|
|
8
|
+
enclave;
|
|
9
|
+
configRepo;
|
|
10
|
+
verificationDocument;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
if (!options.serverURL) {
|
|
13
|
+
throw new Error("serverURL is required for Verifier");
|
|
14
|
+
}
|
|
15
|
+
this.enclave = new URL(options.serverURL).hostname;
|
|
16
|
+
this.configRepo = options.configRepo || DEFAULT_CONFIG_REPO;
|
|
17
|
+
}
|
|
18
|
+
async verify() {
|
|
19
|
+
const steps = {
|
|
20
|
+
fetchDigest: { status: 'pending' },
|
|
21
|
+
verifyCode: { status: 'pending' },
|
|
22
|
+
verifyEnclave: { status: 'pending' },
|
|
23
|
+
compareMeasurements: { status: 'pending' },
|
|
24
|
+
};
|
|
25
|
+
try {
|
|
26
|
+
if (!this.enclave) {
|
|
27
|
+
this.enclave = await getRouterAddress();
|
|
28
|
+
}
|
|
29
|
+
// Step 1: Verify Enclave
|
|
30
|
+
let attestationDoc;
|
|
31
|
+
let amdVerification;
|
|
32
|
+
try {
|
|
33
|
+
attestationDoc = await fetchAttestation(this.enclave);
|
|
34
|
+
amdVerification = await verifyAmdAttestation(attestationDoc);
|
|
35
|
+
steps.verifyEnclave = { status: 'success' };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
steps.verifyEnclave = { status: 'failed', error: error.message };
|
|
39
|
+
this.saveFailedVerificationDocument(steps);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
// Step 2: Fetch Digest
|
|
43
|
+
let digest;
|
|
44
|
+
try {
|
|
45
|
+
digest = await fetchLatestDigest(this.configRepo);
|
|
46
|
+
steps.fetchDigest = { status: 'success' };
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
steps.fetchDigest = { status: 'failed', error: error.message };
|
|
50
|
+
this.saveFailedVerificationDocument(steps);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
// Step 3: Verify Code
|
|
54
|
+
let codeMeasurements;
|
|
55
|
+
try {
|
|
56
|
+
const sigstoreBundle = await fetchAttestationBundle(this.configRepo, digest);
|
|
57
|
+
codeMeasurements = await verifySigstoreAttestation(sigstoreBundle, digest, this.configRepo);
|
|
58
|
+
steps.verifyCode = { status: 'success' };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
steps.verifyCode = { status: 'failed', error: error.message };
|
|
62
|
+
this.saveFailedVerificationDocument(steps);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
// Step 4: Compare Measurements
|
|
66
|
+
try {
|
|
67
|
+
compareMeasurements(codeMeasurements, amdVerification.measurement);
|
|
68
|
+
steps.compareMeasurements = { status: 'success' };
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error instanceof FormatMismatchError) {
|
|
72
|
+
steps.compareMeasurements = { status: 'failed', error: error.message };
|
|
73
|
+
}
|
|
74
|
+
else if (error instanceof MeasurementMismatchError) {
|
|
75
|
+
steps.compareMeasurements = { status: 'failed', error: error.message };
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
steps.compareMeasurements = { status: 'failed', error: error.message };
|
|
79
|
+
}
|
|
80
|
+
this.saveFailedVerificationDocument(steps);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
// Build successful verification document
|
|
84
|
+
this.verificationDocument = {
|
|
85
|
+
configRepo: this.configRepo,
|
|
86
|
+
enclaveHost: this.enclave,
|
|
87
|
+
releaseDigest: digest,
|
|
88
|
+
codeMeasurement: codeMeasurements,
|
|
89
|
+
enclaveMeasurement: amdVerification,
|
|
90
|
+
tlsPublicKey: amdVerification.tlsPublicKeyFingerprint || '',
|
|
91
|
+
hpkePublicKey: amdVerification.hpkePublicKey || '',
|
|
92
|
+
codeFingerprint: await measurementFingerprint(codeMeasurements),
|
|
93
|
+
enclaveFingerprint: await measurementFingerprint(amdVerification.measurement),
|
|
94
|
+
selectedRouterEndpoint: this.enclave,
|
|
95
|
+
securityVerified: true,
|
|
96
|
+
steps
|
|
97
|
+
};
|
|
98
|
+
return amdVerification;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (!this.verificationDocument) {
|
|
102
|
+
this.saveFailedVerificationDocument(steps);
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
saveFailedVerificationDocument(steps) {
|
|
108
|
+
this.verificationDocument = {
|
|
109
|
+
configRepo: this.configRepo,
|
|
110
|
+
enclaveHost: this.enclave || '',
|
|
111
|
+
releaseDigest: '',
|
|
112
|
+
codeMeasurement: { type: '', registers: [] },
|
|
113
|
+
enclaveMeasurement: { measurement: { type: '', registers: [] } },
|
|
114
|
+
tlsPublicKey: '',
|
|
115
|
+
hpkePublicKey: '',
|
|
116
|
+
codeFingerprint: '',
|
|
117
|
+
enclaveFingerprint: '',
|
|
118
|
+
selectedRouterEndpoint: this.enclave || '',
|
|
119
|
+
securityVerified: false,
|
|
120
|
+
steps
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
getVerificationDocument() {
|
|
124
|
+
return this.verificationDocument;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,IAAI,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CA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K,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC/B,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,8BAA8B,CAAC,KAAoC;QACzE,IAAI,CAAC,oBAAoB,GAAG;YAC1B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;YAC/B,aAAa,EAAE,EAAE;YACjB,eAAe,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAC5C,kBAAkB,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE;YAChE,YAAY,EAAE,EAAE;YAChB,aAAa,EAAE,EAAE;YACjB,eAAe,EAAE,EAAE;YACnB,kBAAkB,EAAE,EAAE;YACtB,sBAAsB,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;YAC1C,gBAAgB,EAAE,KAAK;YACvB,KAAK;SACN,CAAC;IACJ,CAAC;IAED,uBAAuB;QACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
package/dist/github.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Release {
|
|
2
|
+
tag_name: string;
|
|
3
|
+
body: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Gets the latest release and attestation digest of a repo.
|
|
7
|
+
*
|
|
8
|
+
* @param repo - The GitHub repository in format "owner/repo"
|
|
9
|
+
* @returns The digest string
|
|
10
|
+
* @throws Error if there's any error fetching or parsing the data
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchLatestDigest(repo: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches the sigstore bundle from a repo for a given repo and EIF hash.
|
|
15
|
+
*
|
|
16
|
+
* @param repo - The GitHub repository in format "owner/repo"
|
|
17
|
+
* @param digest - The EIF hash/digest
|
|
18
|
+
* @returns The sigstore bundle JSON object
|
|
19
|
+
* @throws Error if there's any error fetching or parsing the data
|
|
20
|
+
*/
|
|
21
|
+
export declare function fetchAttestationBundle(repo: string, digest: string): Promise<unknown>;
|
|
22
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCrE;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAwB3F"}
|
package/dist/github.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the latest release and attestation digest of a repo.
|
|
3
|
+
*
|
|
4
|
+
* @param repo - The GitHub repository in format "owner/repo"
|
|
5
|
+
* @returns The digest string
|
|
6
|
+
* @throws Error if there's any error fetching or parsing the data
|
|
7
|
+
*/
|
|
8
|
+
export async function fetchLatestDigest(repo) {
|
|
9
|
+
const url = `https://api-github-proxy.tinfoil.sh/repos/${repo}/releases/latest`;
|
|
10
|
+
const releaseResponse = await fetch(url);
|
|
11
|
+
if (!releaseResponse.ok) {
|
|
12
|
+
throw new Error(`Failed to fetch release: ${releaseResponse.status} ${releaseResponse.statusText}`);
|
|
13
|
+
}
|
|
14
|
+
const responseData = await releaseResponse.json();
|
|
15
|
+
const tagName = responseData.tag_name;
|
|
16
|
+
const body = responseData.body;
|
|
17
|
+
// Backwards compatibility for old EIF releases
|
|
18
|
+
const eifRegex = /EIF hash: ([a-fA-F0-9]{64})/;
|
|
19
|
+
const eifMatches = eifRegex.exec(body);
|
|
20
|
+
if (eifMatches) {
|
|
21
|
+
return eifMatches[1];
|
|
22
|
+
}
|
|
23
|
+
// Other format to fetch Digest
|
|
24
|
+
const digestRegex = /Digest: `([a-fA-F0-9]{64})`/;
|
|
25
|
+
const digestMatches = digestRegex.exec(body);
|
|
26
|
+
if (digestMatches) {
|
|
27
|
+
return digestMatches[1];
|
|
28
|
+
}
|
|
29
|
+
// Fallback option: fetch digest from github special endpoint
|
|
30
|
+
const digestUrl = `https://github-proxy.tinfoil.sh/${repo}/releases/download/${tagName}/tinfoil.hash`;
|
|
31
|
+
const response = await fetch(digestUrl);
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error(`Failed to fetch attestation digest: ${response.status} ${response.statusText}`);
|
|
34
|
+
}
|
|
35
|
+
return (await response.text()).trim();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fetches the sigstore bundle from a repo for a given repo and EIF hash.
|
|
39
|
+
*
|
|
40
|
+
* @param repo - The GitHub repository in format "owner/repo"
|
|
41
|
+
* @param digest - The EIF hash/digest
|
|
42
|
+
* @returns The sigstore bundle JSON object
|
|
43
|
+
* @throws Error if there's any error fetching or parsing the data
|
|
44
|
+
*/
|
|
45
|
+
export async function fetchAttestationBundle(repo, digest) {
|
|
46
|
+
const url = `https://api-github-proxy.tinfoil.sh/repos/${repo}/attestations/sha256:${digest}`;
|
|
47
|
+
let bundleResponse;
|
|
48
|
+
try {
|
|
49
|
+
bundleResponse = await fetch(url);
|
|
50
|
+
if (!bundleResponse.ok) {
|
|
51
|
+
throw new Error(`HTTP ${bundleResponse.status} ${bundleResponse.statusText}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
throw new Error(`Error fetching attestation from ${url}`, { cause: e });
|
|
56
|
+
}
|
|
57
|
+
let responseData;
|
|
58
|
+
try {
|
|
59
|
+
responseData = await bundleResponse.json();
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
throw new Error(`Error decoding JSON response from ${url}`, { cause: e });
|
|
63
|
+
}
|
|
64
|
+
if (!responseData.attestations?.[0]?.bundle) {
|
|
65
|
+
throw new Error(`Invalid attestation response format from ${url}. Response: ${JSON.stringify(responseData)}`);
|
|
66
|
+
}
|
|
67
|
+
return responseData.attestations[0].bundle;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAClD,MAAM,GAAG,GAAG,6CAA6C,IAAI,kBAAkB,CAAC;IAChF,MAAM,eAAe,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEzC,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,4BAA4B,eAAe,CAAC,MAAM,IAAI,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;IACtG,CAAC;IAED,MAAM,YAAY,GAAY,MAAM,eAAe,CAAC,IAAI,EAAE,CAAC;IAC3D,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC;IACtC,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;IAE/B,+CAA+C;IAC/C,MAAM,QAAQ,GAAG,6BAA6B,CAAC;IAC/C,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,+BAA+B;IAC/B,MAAM,WAAW,GAAG,6BAA6B,CAAC;IAClD,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAA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,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,eAAe,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAChH,CAAC;IACD,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { verifyAttestation, fetchAttestation } from './attestation.js';
|
|
2
|
+
export { Verifier } from './client.js';
|
|
3
|
+
export { getRouterAddress } from './router.js';
|
|
4
|
+
export { fetchLatestDigest, fetchAttestationBundle } from './github.js';
|
|
5
|
+
export { PredicateType, compareMeasurements, measurementFingerprint, AttestationError, FormatMismatchError, MeasurementMismatchError } from './types.js';
|
|
6
|
+
export type { AttestationDocument, AttestationMeasurement, AttestationResponse, VerificationDocument, VerificationStepState, HardwareMeasurement } from './types.js';
|
|
7
|
+
export type { VerifierOptions } from './client.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACzJ,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACrK,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { verifyAttestation, fetchAttestation } from './attestation.js';
|
|
2
|
+
export { Verifier } from './client.js';
|
|
3
|
+
export { getRouterAddress } from './router.js';
|
|
4
|
+
export { fetchLatestDigest, fetchAttestationBundle } from './github.js';
|
|
5
|
+
export { PredicateType, compareMeasurements, measurementFingerprint, AttestationError, FormatMismatchError, MeasurementMismatchError } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAexD"}
|
package/dist/router.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export async function getRouterAddress() {
|
|
2
|
+
const url = 'https://atc.tinfoil.sh/routers?platform=snp';
|
|
3
|
+
const response = await fetch(url);
|
|
4
|
+
if (!response.ok) {
|
|
5
|
+
throw new Error(`Failed to fetch routers: ${response.status} ${response.statusText}`);
|
|
6
|
+
}
|
|
7
|
+
const routers = await response.json();
|
|
8
|
+
if (routers.length === 0) {
|
|
9
|
+
throw new Error('No routers found in the response');
|
|
10
|
+
}
|
|
11
|
+
return routers[Math.floor(Math.random() * routers.length)];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,GAAG,GAAG,6CAA6C,CAAC;IAC1D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,OAAO,GAAa,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEhD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Report } from './report.js';
|
|
2
|
+
import type { TCBParts } from './types.js';
|
|
3
|
+
import { X509Certificate } from '@freedomofpress/sigstore-browser';
|
|
4
|
+
export declare class CertificateChain {
|
|
5
|
+
ark: X509Certificate;
|
|
6
|
+
ask: X509Certificate;
|
|
7
|
+
vcek: X509Certificate;
|
|
8
|
+
constructor(ark: X509Certificate, ask: X509Certificate, vcek: X509Certificate);
|
|
9
|
+
static fromReport(report: Report): Promise<CertificateChain>;
|
|
10
|
+
verifyChain(): Promise<boolean>;
|
|
11
|
+
validateVcekTcb(tcb: TCBParts): void;
|
|
12
|
+
validateVcekHwid(chipId: Uint8Array): void;
|
|
13
|
+
private validateArkFormat;
|
|
14
|
+
private validateAskFormat;
|
|
15
|
+
private validateVcekFormat;
|
|
16
|
+
private validateAmdLocation;
|
|
17
|
+
private getSignatureAlgorithmOid;
|
|
18
|
+
private getPublicKeyInfo;
|
|
19
|
+
private decodeExtensionInteger;
|
|
20
|
+
get vcekPublicKey(): Promise<CryptoKey>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=cert-chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cert-chain.d.ts","sourceRoot":"","sources":["../../src/sev/cert-chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AA4BnE,qBAAa,gBAAgB;IAElB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,eAAe;IACpB,IAAI,EAAE,eAAe;gBAFrB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,eAAe;WAGjB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2C5D,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAyCrC,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IA0CpC,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAY1C,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,kBAAkB;IA2D1B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,sBAAsB;IAM9B,IAAI,aAAa,IAAI,OAAO,CAAC,SAAS,CAAC,CAEtC;CACF"}
|