tinfoil 0.8.7 → 0.9.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.
package/README.md CHANGED
@@ -3,7 +3,9 @@
3
3
  [![Build Status](https://github.com/tinfoilsh/tinfoil-node/actions/workflows/test.yml/badge.svg)](https://github.com/tinfoilsh/tinfoil-node/actions)
4
4
  [![NPM version](https://img.shields.io/npm/v/tinfoil.svg)](https://npmjs.org/package/tinfoil)
5
5
 
6
- A Node.js wrapper around the OpenAI client that verifies enclave attestation and routes OpenAI-bound traffic through an [EHBP](https://github.com/tinfoilsh/encrypted-http-body-protocol)-secured transport when using Tinfoil inference. EHBP encrypts all payloads directly to an attested enclave using [HPKE (RFC 9180)](https://www.rfc-editor.org/rfc/rfc9180.html).
6
+ This client library provides secure and convenient access to the Tinfoil Priavate Inference endpoints from TypeScript or JavaScript.
7
+
8
+ It is a wrapper around the OpenAI client that verifies enclave attestation and routes traffic to the Tinfoil Private Inference endpoints through an [EHBP](https://github.com/tinfoilsh/encrypted-http-body-protocol)-secured transport. EHBP encrypts all payloads directly to an attested enclave using [HPKE (RFC 9180)](https://www.rfc-editor.org/rfc/rfc9180.html).
7
9
 
8
10
  ## Installation
9
11
 
@@ -54,7 +56,7 @@ const client = new TinfoilAI({
54
56
  await client.ready();
55
57
 
56
58
  const completion = await client.chat.completions.create({
57
- model: 'llama-free',
59
+ model: 'llama3-3-70b',
58
60
  messages: [{ role: 'user', content: 'Hello!' }]
59
61
  });
60
62
  ```
@@ -63,19 +65,14 @@ const completion = await client.chat.completions.create({
63
65
 
64
66
  - Modern browsers with ES2020 support
65
67
  - WebAssembly support for enclave verification
66
- - Secure context (HTTPS or localhost) with WebCrypto SubtleCrypto (required by EHBP)
67
-
68
- > **Note**
69
- > The EHBP transport now accepts `http://` origins (for example when developing against a `localhost` proxy). Payloads remain HPKE-encrypted end to end, while TLS-only fallback logic continues to require HTTPS because it relies on certificate pinning.
70
68
 
71
69
 
72
70
  ## Verification helpers
73
71
 
74
72
  This package exposes verification helpers that load the Go-based WebAssembly verifier once per process and provide structured, stepwise attestation results you can use in applications (e.g., to show progress, log transitions, or gate features).
75
73
 
76
- The verification functionality is split into two modules:
77
- - `verifier.ts`: Core verification logic with low-level attestation methods
78
- - `verification-runner.ts`: Higher-level orchestration with state management and subscriptions
74
+ The verification functionality is contained in `verifier.ts`.
75
+
79
76
 
80
77
  ### Core Verifier API
81
78
 
@@ -96,76 +93,6 @@ const code = await verifier.verifyCode("tinfoilsh/repo", "digest-hash");
96
93
  const digest = await verifier.fetchLatestDigest("tinfoilsh/repo");
97
94
  ```
98
95
 
99
- ### High-level Orchestration API
100
-
101
- - `loadVerifier()` boots the verifier with state management and returns an enhanced client.
102
- - `client.subscribe(callback)` subscribes to real-time verification state updates.
103
- - `client.runVerification({ configRepo?, serverURL?, releaseDigest?, onUpdate? })` orchestrates the full flow and returns a structured result with step statuses and a comparison outcome. Both `configRepo` and `serverURL` default to values from `TINFOIL_CONFIG`.
104
-
105
- ### End-to-end orchestration
106
-
107
- ```typescript
108
- import { loadVerifier, TINFOIL_CONFIG } from "tinfoil";
109
-
110
- const verifier = await loadVerifier();
111
-
112
- const result = await verifier.runVerification({
113
- onUpdate: (state) => {
114
- // Receive stepwise updates: pending -> loading -> success/error
115
- // Useful for logging or progress indicators
116
- console.log("verification update:", state);
117
- },
118
- // Optional: override defaults if needed
119
- // configRepo: "tinfoilsh/confidential-inference-proxy",
120
- // serverURL: "https://inference.tinfoil.sh",
121
- // releaseDigest: "<specific-release-sha256>",
122
- });
123
-
124
- if (result.verification.status === "success" && result.verification.securityVerified) {
125
- console.log("Measurements match. Digest:", result.releaseDigest);
126
- } else {
127
- console.error("Verification failed:", result);
128
- }
129
- ```
130
-
131
- `runVerification` returns:
132
-
133
- ```typescript
134
- type VerificationResult = {
135
- code: { status: StepStatus; measurement?: AttestationMeasurement; error?: string };
136
- runtime: {
137
- status: StepStatus;
138
- measurement?: AttestationMeasurement;
139
- tlsPublicKeyFingerprint?: string;
140
- hpkePublicKey?: string;
141
- error?: string;
142
- };
143
- verification: { status: StepStatus; securityVerified?: boolean; error?: string };
144
- releaseDigest: string;
145
- };
146
- ```
147
-
148
- ### Subscribe to state updates
149
-
150
- ```typescript
151
- const verifier = await loadVerifier();
152
- const unsubscribe = verifier.subscribe((state) => {
153
- console.log("state:", state);
154
- });
155
-
156
- // Run verification with default config (recommended)
157
- await verifier.runVerification();
158
-
159
- // Or override specific parameters if needed
160
- // await verifier.runVerification({
161
- // configRepo: "tinfoilsh/confidential-inference-proxy",
162
- // serverURL: "https://inference.tinfoil.sh",
163
- // releaseDigest: "<specific-release-sha256>",
164
- // });
165
-
166
- unsubscribe();
167
- ```
168
-
169
96
  ## Testing
170
97
 
171
98
  The project includes both unit tests and integration tests:
@@ -176,8 +103,6 @@ The project includes both unit tests and integration tests:
176
103
  npm test
177
104
  ```
178
105
 
179
- This runs the test suite with unit tests and mocked components. These tests don't require network access and run quickly.
180
-
181
106
  ### Running Integration Tests
182
107
 
183
108
  ```bash
@@ -191,38 +116,9 @@ This runs the full test suite including integration tests that:
191
116
 
192
117
  Integration tests are skipped by default to keep the test suite fast and avoid network dependencies during development.
193
118
 
194
- ## Running the Chat Example
195
-
196
- The chat example demonstrates both streaming chat completions and real-time attestation verification with a visual progress UI.
197
-
198
- 1. Clone the repository
199
-
200
- 2. Install dependencies:
201
-
202
- ```bash
203
- npm install
204
- ```
205
-
206
- 3. Optionally create a `.env` file with your configuration:
207
-
208
- ```bash
209
- TINFOIL_API_KEY=<YOUR_API_KEY>
210
- # Optional: Enable WASM debug logs
211
- # TINFOIL_ENABLE_WASM_LOGS=true
212
- ```
213
-
214
- 4. Run the example:
215
-
216
- ```bash
217
- cd examples/chat
218
- npx ts-node main.ts
219
- ```
119
+ ## Running examples
220
120
 
221
- The example will:
222
- - Display a real-time verification progress showing each attestation step
223
- - Verify the enclave's runtime and code measurements
224
- - Compare measurements using platform-specific logic
225
- - Stream chat completions through the verified secure channel
121
+ See [examples/README.md](https://github.com/tinfoilsh/tinfoil-node/blob/main/examples/README.md).
226
122
 
227
123
  ## API Documentation
228
124
 
@@ -1,10 +1,11 @@
1
1
  type EhbpModule = typeof import("ehbp");
2
+ export declare function getHPKEKey(enclaveURL: string): Promise<CryptoKey>;
2
3
  export declare function normalizeEncryptedBodyRequestArgs(input: RequestInfo | URL, init?: RequestInit): {
3
4
  url: string;
4
5
  init?: RequestInit;
5
6
  };
6
- export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey: string, init?: RequestInit, enclaveURL?: string): Promise<Response>;
7
- export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey: string, enclaveURL?: string): typeof fetch;
7
+ export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey?: string, init?: RequestInit, enclaveURL?: string): Promise<Response>;
8
+ export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey?: string, enclaveURL?: string): typeof fetch;
8
9
  export declare function __setEhbpModuleForTests(module: EhbpModule | undefined): void;
9
10
  export declare function __resetEhbpModuleStateForTests(): void;
10
11
  export {};
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getHPKEKey = getHPKEKey;
36
37
  exports.normalizeEncryptedBodyRequestArgs = normalizeEncryptedBodyRequestArgs;
37
38
  exports.encryptedBodyRequest = encryptedBodyRequest;
38
39
  exports.createEncryptedBodyFetch = createEncryptedBodyFetch;
@@ -43,6 +44,25 @@ let transport = null;
43
44
  let ehbpModulePromise = null;
44
45
  let ehbpModuleOverride;
45
46
  // Public API
47
+ async function getHPKEKey(enclaveURL) {
48
+ const { Identity, PROTOCOL } = await getEhbpModule();
49
+ const url = new URL(enclaveURL);
50
+ const keysURL = new URL(PROTOCOL.KEYS_PATH, enclaveURL);
51
+ if (keysURL.protocol !== 'https:') {
52
+ throw new Error(`HTTPS is required for remote key retrieval. Invalid protocol: ${keysURL.protocol}`);
53
+ }
54
+ const response = await fetch(keysURL.toString());
55
+ if (!response.ok) {
56
+ throw new Error(`Failed to get server public key: ${response.status}`);
57
+ }
58
+ const contentType = response.headers.get('content-type');
59
+ if (contentType !== PROTOCOL.KEYS_MEDIA_TYPE) {
60
+ throw new Error(`Invalid content type: ${contentType}`);
61
+ }
62
+ const keysData = new Uint8Array(await response.arrayBuffer());
63
+ const serverIdentity = await Identity.unmarshalPublicConfig(keysData);
64
+ return serverIdentity.getPublicKey();
65
+ }
46
66
  function normalizeEncryptedBodyRequestArgs(input, init) {
47
67
  if (typeof input === "string") {
48
68
  return { url: input, init };
@@ -72,9 +92,11 @@ async function encryptedBodyRequest(input, hpkePublicKey, init, enclaveURL) {
72
92
  transport = getTransportForOrigin(origin, keyOrigin);
73
93
  }
74
94
  const transportInstance = await transport;
75
- const transportKeyHash = await transportInstance.getServerPublicKeyHex();
76
- if (transportKeyHash !== hpkePublicKey) {
77
- throw new Error(`HPKE public key mismatch. Expected: ${hpkePublicKey}, Got: ${transportKeyHash}`);
95
+ if (hpkePublicKey) {
96
+ const transportKeyHash = await transportInstance.getServerPublicKeyHex();
97
+ if (transportKeyHash !== hpkePublicKey) {
98
+ throw new Error(`HPKE public key mismatch. Expected: ${hpkePublicKey}, Got: ${transportKeyHash}`);
99
+ }
78
100
  }
79
101
  return transportInstance.request(requestUrl, requestInit);
80
102
  }
@@ -112,7 +134,7 @@ function getEhbpModule() {
112
134
  return ehbpModulePromise;
113
135
  }
114
136
  async function getTransportForOrigin(origin, keyOrigin) {
115
- const { Identity, createTransport, Transport } = await getEhbpModule();
137
+ const { Identity, Transport } = await getEhbpModule();
116
138
  // Ensure secure browser context
117
139
  if (typeof globalThis !== 'undefined') {
118
140
  const isSecure = globalThis.isSecureContext !== false;
@@ -122,12 +144,8 @@ async function getTransportForOrigin(origin, keyOrigin) {
122
144
  throw new Error(`EHBP requires a secure browser context: ${reason}`);
123
145
  }
124
146
  }
125
- // Create a single client identity to use for both key discovery and requests
126
147
  const clientIdentity = await Identity.generate();
127
- // Fetch the server's HPKE public key from the dedicated key origin.
128
- // TODO: clean up this code. EHBP should make it easy to fetch the key without creating a transport object.
129
- const keyTransport = await createTransport(keyOrigin, clientIdentity);
130
- const serverPublicKey = keyTransport.getServerPublicKey();
148
+ const serverPublicKey = await getHPKEKey(keyOrigin);
131
149
  const requestHost = new URL(origin).host;
132
150
  return new Transport(clientIdentity, requestHost, serverPublicKey);
133
151
  }
@@ -1,10 +1,11 @@
1
1
  type EhbpModule = typeof import("ehbp");
2
+ export declare function getHPKEKey(enclaveURL: string): Promise<CryptoKey>;
2
3
  export declare function normalizeEncryptedBodyRequestArgs(input: RequestInfo | URL, init?: RequestInit): {
3
4
  url: string;
4
5
  init?: RequestInit;
5
6
  };
6
- export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey: string, init?: RequestInit, enclaveURL?: string): Promise<Response>;
7
- export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey: string, enclaveURL?: string): typeof fetch;
7
+ export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey?: string, init?: RequestInit, enclaveURL?: string): Promise<Response>;
8
+ export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey?: string, enclaveURL?: string): typeof fetch;
8
9
  export declare function __setEhbpModuleForTests(module: EhbpModule | undefined): void;
9
10
  export declare function __resetEhbpModuleStateForTests(): void;
10
11
  export {};
@@ -3,6 +3,25 @@ let transport = null;
3
3
  let ehbpModulePromise = null;
4
4
  let ehbpModuleOverride;
5
5
  // Public API
6
+ export async function getHPKEKey(enclaveURL) {
7
+ const { Identity, PROTOCOL } = await getEhbpModule();
8
+ const url = new URL(enclaveURL);
9
+ const keysURL = new URL(PROTOCOL.KEYS_PATH, enclaveURL);
10
+ if (keysURL.protocol !== 'https:') {
11
+ throw new Error(`HTTPS is required for remote key retrieval. Invalid protocol: ${keysURL.protocol}`);
12
+ }
13
+ const response = await fetch(keysURL.toString());
14
+ if (!response.ok) {
15
+ throw new Error(`Failed to get server public key: ${response.status}`);
16
+ }
17
+ const contentType = response.headers.get('content-type');
18
+ if (contentType !== PROTOCOL.KEYS_MEDIA_TYPE) {
19
+ throw new Error(`Invalid content type: ${contentType}`);
20
+ }
21
+ const keysData = new Uint8Array(await response.arrayBuffer());
22
+ const serverIdentity = await Identity.unmarshalPublicConfig(keysData);
23
+ return serverIdentity.getPublicKey();
24
+ }
6
25
  export function normalizeEncryptedBodyRequestArgs(input, init) {
7
26
  if (typeof input === "string") {
8
27
  return { url: input, init };
@@ -32,9 +51,11 @@ export async function encryptedBodyRequest(input, hpkePublicKey, init, enclaveUR
32
51
  transport = getTransportForOrigin(origin, keyOrigin);
33
52
  }
34
53
  const transportInstance = await transport;
35
- const transportKeyHash = await transportInstance.getServerPublicKeyHex();
36
- if (transportKeyHash !== hpkePublicKey) {
37
- throw new Error(`HPKE public key mismatch. Expected: ${hpkePublicKey}, Got: ${transportKeyHash}`);
54
+ if (hpkePublicKey) {
55
+ const transportKeyHash = await transportInstance.getServerPublicKeyHex();
56
+ if (transportKeyHash !== hpkePublicKey) {
57
+ throw new Error(`HPKE public key mismatch. Expected: ${hpkePublicKey}, Got: ${transportKeyHash}`);
58
+ }
38
59
  }
39
60
  return transportInstance.request(requestUrl, requestInit);
40
61
  }
@@ -72,7 +93,7 @@ function getEhbpModule() {
72
93
  return ehbpModulePromise;
73
94
  }
74
95
  async function getTransportForOrigin(origin, keyOrigin) {
75
- const { Identity, createTransport, Transport } = await getEhbpModule();
96
+ const { Identity, Transport } = await getEhbpModule();
76
97
  // Ensure secure browser context
77
98
  if (typeof globalThis !== 'undefined') {
78
99
  const isSecure = globalThis.isSecureContext !== false;
@@ -82,12 +103,8 @@ async function getTransportForOrigin(origin, keyOrigin) {
82
103
  throw new Error(`EHBP requires a secure browser context: ${reason}`);
83
104
  }
84
105
  }
85
- // Create a single client identity to use for both key discovery and requests
86
106
  const clientIdentity = await Identity.generate();
87
- // Fetch the server's HPKE public key from the dedicated key origin.
88
- // TODO: clean up this code. EHBP should make it easy to fetch the key without creating a transport object.
89
- const keyTransport = await createTransport(keyOrigin, clientIdentity);
90
- const serverPublicKey = keyTransport.getServerPublicKey();
107
+ const serverPublicKey = await getHPKEKey(keyOrigin);
91
108
  const requestHost = new URL(origin).host;
92
109
  return new Transport(clientIdentity, requestHost, serverPublicKey);
93
110
  }
@@ -1,7 +1,7 @@
1
1
  export { TinfoilAI } from "./tinfoilai";
2
2
  export { TinfoilAI as default } from "./tinfoilai";
3
3
  export * from "./verifier";
4
- export * from "./verification-runner";
5
4
  export * from "./ai-sdk-provider";
6
5
  export * from "./config";
7
6
  export { SecureClient } from "./secure-client";
7
+ export { UnverifiedClient } from "./unverified-client";
@@ -2,7 +2,7 @@
2
2
  export { TinfoilAI } from "./tinfoilai";
3
3
  export { TinfoilAI as default } from "./tinfoilai";
4
4
  export * from "./verifier";
5
- export * from "./verification-runner";
6
5
  export * from "./ai-sdk-provider";
7
6
  export * from "./config";
8
7
  export { SecureClient } from "./secure-client";
8
+ export { UnverifiedClient } from "./unverified-client";
@@ -1,8 +1,8 @@
1
1
  export { TinfoilAI } from "./tinfoilai";
2
2
  export { TinfoilAI as default } from "./tinfoilai";
3
3
  export * from "./verifier";
4
- export * from "./verification-runner";
5
4
  export * from "./ai-sdk-provider";
6
5
  export * from "./config";
7
6
  export { SecureClient } from "./secure-client";
7
+ export { UnverifiedClient } from "./unverified-client";
8
8
  export { type Uploadable, toFile, APIPromise, PagePromise, OpenAIError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "openai";
package/dist/esm/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // Re-export the TinfoilAI class
2
2
  export { TinfoilAI } from "./tinfoilai";
3
3
  export { TinfoilAI as default } from "./tinfoilai";
4
- // Export verifier and loader
4
+ // Export verifier
5
5
  export * from "./verifier";
6
- export * from "./verification-runner";
7
6
  export * from "./ai-sdk-provider";
8
7
  export * from "./config";
9
8
  export { SecureClient } from "./secure-client";
9
+ export { UnverifiedClient } from "./unverified-client";
10
10
  // Re-export OpenAI utility types and classes that users might need
11
11
  // Using public exports from the main OpenAI package instead of deep imports
12
12
  export { toFile, APIPromise, PagePromise, OpenAIError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "openai";
@@ -1 +1 @@
1
- export declare function createPinnedTlsFetch(expectedFingerprintHex: string): typeof fetch;
1
+ export declare function createPinnedTlsFetch(baseURL: string, expectedFingerprintHex: string): typeof fetch;
@@ -2,15 +2,15 @@ import https from "https";
2
2
  import { checkServerIdentity as tlsCheckServerIdentity } from "tls";
3
3
  import { X509Certificate, createHash } from "crypto";
4
4
  import { Readable } from "stream";
5
- export function createPinnedTlsFetch(expectedFingerprintHex) {
5
+ export function createPinnedTlsFetch(baseURL, expectedFingerprintHex) {
6
6
  return (async (input, init) => {
7
- // Normalize URL
7
+ // Normalize URL with base URL support
8
8
  const makeURL = (value) => {
9
9
  if (typeof value === "string")
10
- return new URL(value);
10
+ return new URL(value, baseURL);
11
11
  if (value instanceof URL)
12
12
  return value;
13
- return new URL(value.url);
13
+ return new URL(value.url, baseURL);
14
14
  };
15
15
  const url = makeURL(input);
16
16
  if (url.protocol !== "https:") {
@@ -16,7 +16,7 @@ export function createSecureFetch(baseURL, enclaveURL, hpkePublicKey, tlsPublicK
16
16
  if (!tlsPublicKeyFingerprint) {
17
17
  throw new Error("Neither HPKE public key nor TLS public key fingerprint available for verification");
18
18
  }
19
- fetchFunction = createPinnedTlsFetch(tlsPublicKeyFingerprint);
19
+ fetchFunction = createPinnedTlsFetch(baseURL, tlsPublicKeyFingerprint);
20
20
  }
21
21
  return fetchFunction;
22
22
  }
@@ -0,0 +1,18 @@
1
+ interface UnverifiedClientOptions {
2
+ baseURL?: string;
3
+ enclaveURL?: string;
4
+ configRepo?: string;
5
+ }
6
+ export declare class UnverifiedClient {
7
+ private initPromise;
8
+ private _fetch;
9
+ private readonly baseURL;
10
+ private readonly enclaveURL;
11
+ private readonly configRepo;
12
+ constructor(options?: UnverifiedClientOptions);
13
+ ready(): Promise<void>;
14
+ private initUnverifiedClient;
15
+ getVerificationDocument(): Promise<void>;
16
+ get fetch(): typeof fetch;
17
+ }
18
+ export {};
@@ -0,0 +1,33 @@
1
+ import { TINFOIL_CONFIG } from "./config";
2
+ import { createEncryptedBodyFetch } from "./encrypted-body-fetch";
3
+ export class UnverifiedClient {
4
+ constructor(options = {}) {
5
+ this.initPromise = null;
6
+ this._fetch = null;
7
+ this.baseURL = options.baseURL || TINFOIL_CONFIG.INFERENCE_BASE_URL;
8
+ this.enclaveURL = options.enclaveURL || TINFOIL_CONFIG.ENCLAVE_URL;
9
+ this.configRepo = options.configRepo || TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
10
+ }
11
+ async ready() {
12
+ if (!this.initPromise) {
13
+ this.initPromise = this.initUnverifiedClient();
14
+ }
15
+ return this.initPromise;
16
+ }
17
+ async initUnverifiedClient() {
18
+ this._fetch = createEncryptedBodyFetch(this.baseURL, undefined, this.enclaveURL);
19
+ }
20
+ async getVerificationDocument() {
21
+ if (!this.initPromise) {
22
+ await this.ready();
23
+ }
24
+ await this.initPromise;
25
+ throw new Error("Verification document unavailable: this version of the client is unverified");
26
+ }
27
+ get fetch() {
28
+ return async (input, init) => {
29
+ await this.ready();
30
+ return this._fetch(input, init);
31
+ };
32
+ }
33
+ }
@@ -15,7 +15,15 @@ export interface AttestationResponse {
15
15
  measurement: AttestationMeasurement;
16
16
  }
17
17
  /**
18
- * Full verification document produced by a successful verify() call
18
+ * State of an intermediate verification step
19
+ */
20
+ export interface VerificationStepState {
21
+ status: 'pending' | 'success' | 'failed';
22
+ error?: string;
23
+ }
24
+ /**
25
+ * Full verification document produced by a verify() call
26
+ * Includes state tracking for all intermediate steps
19
27
  */
20
28
  export interface VerificationDocument {
21
29
  configRepo: string;
@@ -23,7 +31,13 @@ export interface VerificationDocument {
23
31
  releaseDigest: string;
24
32
  codeMeasurement: AttestationMeasurement;
25
33
  enclaveMeasurement: AttestationResponse;
26
- match: boolean;
34
+ securityVerified: boolean;
35
+ steps: {
36
+ fetchDigest: VerificationStepState;
37
+ verifyCode: VerificationStepState;
38
+ verifyEnclave: VerificationStepState;
39
+ compareMeasurements: VerificationStepState;
40
+ };
27
41
  }
28
42
  export interface MeasurementComparisonResult {
29
43
  match: boolean;
@@ -64,10 +78,10 @@ export declare class Verifier {
64
78
  configRepo?: string;
65
79
  });
66
80
  /**
67
- * Initialize the WebAssembly module
68
- * This loads the Go runtime and makes verification functions available
81
+ * Execute a function with a fresh WASM instance that auto-cleans up
82
+ * This ensures Go runtime doesn't keep the process alive
69
83
  */
70
- static initializeWasm(): Promise<void>;
84
+ private static executeWithWasm;
71
85
  /**
72
86
  * Fetch the latest release digest from GitHub
73
87
  * @param configRepo - Repository name (e.g., "tinfoilsh/confidential-inference-proxy")
@@ -99,9 +113,15 @@ export declare class Verifier {
99
113
  * 4. Compares measurements using platform-specific logic (see `compareMeasurements()`)
100
114
  * 5. Returns the attestation response if verification succeeds
101
115
  *
116
+ * The WASM runtime is automatically initialized and cleaned up within this method.
117
+ *
102
118
  * @throws Error if measurements don't match or verification fails
103
119
  */
104
120
  verify(): Promise<AttestationResponse>;
121
+ /**
122
+ * Internal verification logic that runs within WASM context
123
+ */
124
+ private verifyInternal;
105
125
  /**
106
126
  * Returns the full verification document from the last successful verify() call
107
127
  */