tinfoil 0.8.4 → 0.8.5

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 (39) hide show
  1. package/dist/ai-sdk-provider.d.ts +1 -1
  2. package/dist/ai-sdk-provider.js +3 -3
  3. package/dist/client.browser.d.ts +2 -2
  4. package/dist/client.browser.js +4 -4
  5. package/dist/client.d.ts +3 -3
  6. package/dist/client.js +3 -3
  7. package/dist/config.d.ts +4 -3
  8. package/dist/config.js +4 -3
  9. package/dist/encrypted-body-fetch.d.ts +2 -2
  10. package/dist/encrypted-body-fetch.js +4 -4
  11. package/dist/esm/ai-sdk-provider.d.ts +1 -1
  12. package/dist/esm/ai-sdk-provider.js +3 -3
  13. package/dist/esm/client.browser.d.ts +2 -2
  14. package/dist/esm/client.browser.js +3 -3
  15. package/dist/esm/client.d.ts +3 -3
  16. package/dist/esm/client.js +3 -3
  17. package/dist/esm/config.d.ts +4 -3
  18. package/dist/esm/config.js +4 -3
  19. package/dist/esm/encrypted-body-fetch.d.ts +2 -2
  20. package/dist/esm/encrypted-body-fetch.js +4 -4
  21. package/dist/esm/index.browser.d.ts +1 -1
  22. package/dist/esm/index.browser.js +1 -1
  23. package/dist/esm/index.d.ts +1 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/secure-client.browser.d.ts +2 -2
  26. package/dist/esm/secure-client.browser.js +3 -3
  27. package/dist/esm/secure-client.d.ts +2 -2
  28. package/dist/esm/secure-client.js +5 -4
  29. package/dist/esm/verifier.js +2 -2
  30. package/dist/index.browser.d.ts +1 -1
  31. package/dist/index.browser.js +3 -2
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/secure-client.browser.d.ts +2 -2
  35. package/dist/secure-client.browser.js +3 -3
  36. package/dist/secure-client.d.ts +2 -2
  37. package/dist/secure-client.js +5 -4
  38. package/dist/verifier.js +2 -2
  39. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  interface CreateTinfoilAIOptions {
2
2
  baseURL?: string;
3
- hpkeKeyURL?: string;
3
+ enclaveURL?: string;
4
4
  configRepo?: string;
5
5
  }
6
6
  export declare function createTinfoilAI(apiKey: string, options?: CreateTinfoilAIOptions): Promise<import("@ai-sdk/openai-compatible").OpenAICompatibleProvider<string, string, string, string>>;
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTinfoilAI = createTinfoilAI;
4
4
  const openai_compatible_1 = require("@ai-sdk/openai-compatible");
5
5
  const config_1 = require("./config");
6
- const secure_client_1 = require("./secure-client");
6
+ const secure_client_1 = require("tinfoil/secure-client");
7
7
  async function createTinfoilAI(apiKey, options = {}) {
8
8
  const baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
9
- const hpkeKeyURL = options.hpkeKeyURL || config_1.TINFOIL_CONFIG.HPKE_KEY_URL;
9
+ const enclaveURL = options.enclaveURL || config_1.TINFOIL_CONFIG.ENCLAVE_URL;
10
10
  const configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
11
11
  const secureClient = new secure_client_1.SecureClient({
12
12
  baseURL,
13
- hpkeKeyURL,
13
+ enclaveURL,
14
14
  configRepo,
15
15
  });
16
16
  await secureClient.ready();
@@ -4,7 +4,7 @@ import type { VerificationDocument } from "./verifier";
4
4
  interface TinfoilAIOptions {
5
5
  apiKey?: string;
6
6
  baseURL?: string;
7
- hpkeKeyURL?: string;
7
+ enclaveURL?: string;
8
8
  configRepo?: string;
9
9
  [key: string]: any;
10
10
  }
@@ -17,7 +17,7 @@ export declare class TinfoilAI {
17
17
  private verificationDocument?;
18
18
  apiKey?: string;
19
19
  baseURL?: string;
20
- hpkeKeyURL?: string;
20
+ enclaveURL?: string;
21
21
  constructor(options?: TinfoilAIOptions);
22
22
  ready(): Promise<void>;
23
23
  private initClient;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TinfoilAI = void 0;
7
7
  const openai_1 = __importDefault(require("openai"));
8
- const secure_client_browser_1 = require("./secure-client.browser");
8
+ const secure_client_1 = require("tinfoil/secure-client");
9
9
  const config_1 = require("./config");
10
10
  function createAsyncProxy(promise) {
11
11
  return new Proxy({}, {
@@ -39,12 +39,12 @@ class TinfoilAI {
39
39
  }
40
40
  this.apiKey = openAIOptions.apiKey;
41
41
  this.baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
42
- this.hpkeKeyURL = options.hpkeKeyURL || config_1.TINFOIL_CONFIG.HPKE_KEY_URL;
42
+ this.enclaveURL = options.enclaveURL || config_1.TINFOIL_CONFIG.ENCLAVE_URL;
43
43
  this.configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
44
44
  // Create the secure client for handling transport security
45
- this.secureClient = new secure_client_browser_1.SecureClient({
45
+ this.secureClient = new secure_client_1.SecureClient({
46
46
  baseURL: this.baseURL,
47
- hpkeKeyURL: this.hpkeKeyURL,
47
+ enclaveURL: this.enclaveURL,
48
48
  configRepo: this.configRepo,
49
49
  });
50
50
  this.clientPromise = this.initClient(openAIOptions);
package/dist/client.d.ts CHANGED
@@ -14,8 +14,8 @@ interface TinfoilAIOptions {
14
14
  apiKey?: string;
15
15
  /** Override the inference API base URL */
16
16
  baseURL?: string;
17
- /** Override the URL used to fetch the HPKE key (defaults to baseURL) */
18
- hpkeKeyURL?: string;
17
+ /** Override the URL used to fetch the ENCLAVE key (defaults to baseURL) */
18
+ enclaveURL?: string;
19
19
  /** Override the config GitHub repository */
20
20
  configRepo?: string;
21
21
  [key: string]: any;
@@ -29,7 +29,7 @@ export declare class TinfoilAI {
29
29
  private verificationDocument?;
30
30
  apiKey?: string;
31
31
  baseURL?: string;
32
- hpkeKeyURL?: string;
32
+ enclaveURL?: string;
33
33
  /**
34
34
  * Creates a new TinfoilAI instance.
35
35
  * @param options - Configuration options including apiKey and other OpenAI client options
package/dist/client.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TinfoilAI = void 0;
7
7
  const openai_1 = __importDefault(require("openai"));
8
- const secure_client_1 = require("./secure-client");
8
+ const secure_client_1 = require("tinfoil/secure-client");
9
9
  const config_1 = require("./config");
10
10
  const env_1 = require("./env");
11
11
  /**
@@ -63,11 +63,11 @@ class TinfoilAI {
63
63
  // Store properties for compatibility
64
64
  this.apiKey = openAIOptions.apiKey;
65
65
  this.baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
66
- this.hpkeKeyURL = options.hpkeKeyURL || config_1.TINFOIL_CONFIG.HPKE_KEY_URL;
66
+ this.enclaveURL = options.enclaveURL || config_1.TINFOIL_CONFIG.ENCLAVE_URL;
67
67
  this.configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
68
68
  this.secureClient = new secure_client_1.SecureClient({
69
69
  baseURL: this.baseURL,
70
- hpkeKeyURL: this.hpkeKeyURL,
70
+ enclaveURL: this.enclaveURL,
71
71
  configRepo: this.configRepo,
72
72
  });
73
73
  this.clientPromise = this.initClient(openAIOptions);
package/dist/config.d.ts CHANGED
@@ -7,11 +7,12 @@ export declare const TINFOIL_CONFIG: {
7
7
  */
8
8
  readonly INFERENCE_BASE_URL: "https://inference.tinfoil.sh/v1/";
9
9
  /**
10
- * The URL used to fetch the HPKE server public key (via EHBP .well-known endpoint).
11
- * Defaults to the same value as `INFERENCE_BASE_URL` so hpkeKeyURL and baseURL share
10
+ * The URL used to fetch the enclave server public key (via EHBP .well-known endpoint).
11
+ * and the attestation (vial the attestation .well-known endpoint too).
12
+ * Defaults to the same value as `INFERENCE_BASE_URL` so enclaveURL and baseURL share
12
13
  * the same default. Callers may override independently if key discovery is hosted elsewhere.
13
14
  */
14
- readonly HPKE_KEY_URL: "https://inference.tinfoil.sh/v1/";
15
+ readonly ENCLAVE_URL: "https://inference.tinfoil.sh/v1/";
15
16
  /**
16
17
  * The GitHub repository for the confidential inference proxy
17
18
  */
package/dist/config.js CHANGED
@@ -10,11 +10,12 @@ exports.TINFOIL_CONFIG = {
10
10
  */
11
11
  INFERENCE_BASE_URL: "https://inference.tinfoil.sh/v1/",
12
12
  /**
13
- * The URL used to fetch the HPKE server public key (via EHBP .well-known endpoint).
14
- * Defaults to the same value as `INFERENCE_BASE_URL` so hpkeKeyURL and baseURL share
13
+ * The URL used to fetch the enclave server public key (via EHBP .well-known endpoint).
14
+ * and the attestation (vial the attestation .well-known endpoint too).
15
+ * Defaults to the same value as `INFERENCE_BASE_URL` so enclaveURL and baseURL share
15
16
  * the same default. Callers may override independently if key discovery is hosted elsewhere.
16
17
  */
17
- HPKE_KEY_URL: "https://inference.tinfoil.sh/v1/",
18
+ ENCLAVE_URL: "https://inference.tinfoil.sh/v1/",
18
19
  /**
19
20
  * The GitHub repository for the confidential inference proxy
20
21
  */
@@ -3,8 +3,8 @@ export declare function normalizeEncryptedBodyRequestArgs(input: RequestInfo | U
3
3
  url: string;
4
4
  init?: RequestInit;
5
5
  };
6
- export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey: string, init?: RequestInit, hpkeKeyURL?: string): Promise<Response>;
7
- export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey: string, hpkeKeyURL?: string): typeof fetch;
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;
8
8
  export declare function __setEhbpModuleForTests(module: EhbpModule | undefined): void;
9
9
  export declare function __resetEhbpModuleStateForTests(): void;
10
10
  export {};
@@ -64,12 +64,12 @@ function normalizeEncryptedBodyRequestArgs(input, init) {
64
64
  init: { ...derivedInit, ...init },
65
65
  };
66
66
  }
67
- async function encryptedBodyRequest(input, hpkePublicKey, init, hpkeKeyURL) {
67
+ async function encryptedBodyRequest(input, hpkePublicKey, init, enclaveURL) {
68
68
  const { url: requestUrl, init: requestInit } = normalizeEncryptedBodyRequestArgs(input, init);
69
69
  const u = new URL(requestUrl);
70
70
  const { origin } = u;
71
71
  // Determine which origin to fetch the HPKE key from (may be different from request origin)
72
- const keyOrigin = hpkeKeyURL ? new URL(hpkeKeyURL).origin : origin;
72
+ const keyOrigin = enclaveURL ? new URL(enclaveURL).origin : origin;
73
73
  // If key origin matches request origin, use the standard transport (fetches keys from origin)
74
74
  // Otherwise, build a composite transport that routes to `origin` but uses the key fetched from `keyOrigin`.
75
75
  const transport = keyOrigin === origin
@@ -91,11 +91,11 @@ async function encryptedBodyRequest(input, hpkePublicKey, init, hpkeKeyURL) {
91
91
  }
92
92
  return transport.request(requestUrl, requestInit);
93
93
  }
94
- function createEncryptedBodyFetch(baseURL, hpkePublicKey, hpkeKeyURL) {
94
+ function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
95
95
  return (async (input, init) => {
96
96
  const normalized = normalizeEncryptedBodyRequestArgs(input, init);
97
97
  const targetUrl = new URL(normalized.url, baseURL);
98
- return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, hpkeKeyURL);
98
+ return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, enclaveURL);
99
99
  });
100
100
  }
101
101
  // Private helper functions
@@ -1,6 +1,6 @@
1
1
  interface CreateTinfoilAIOptions {
2
2
  baseURL?: string;
3
- hpkeKeyURL?: string;
3
+ enclaveURL?: string;
4
4
  configRepo?: string;
5
5
  }
6
6
  export declare function createTinfoilAI(apiKey: string, options?: CreateTinfoilAIOptions): Promise<import("@ai-sdk/openai-compatible").OpenAICompatibleProvider<string, string, string, string>>;
@@ -1,13 +1,13 @@
1
1
  import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
2
2
  import { TINFOIL_CONFIG } from "./config";
3
- import { SecureClient } from "./secure-client";
3
+ import { SecureClient } from "tinfoil/secure-client";
4
4
  export async function createTinfoilAI(apiKey, options = {}) {
5
5
  const baseURL = options.baseURL || TINFOIL_CONFIG.INFERENCE_BASE_URL;
6
- const hpkeKeyURL = options.hpkeKeyURL || TINFOIL_CONFIG.HPKE_KEY_URL;
6
+ const enclaveURL = options.enclaveURL || TINFOIL_CONFIG.ENCLAVE_URL;
7
7
  const configRepo = options.configRepo || TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
8
8
  const secureClient = new SecureClient({
9
9
  baseURL,
10
- hpkeKeyURL,
10
+ enclaveURL,
11
11
  configRepo,
12
12
  });
13
13
  await secureClient.ready();
@@ -4,7 +4,7 @@ import type { VerificationDocument } from "./verifier";
4
4
  interface TinfoilAIOptions {
5
5
  apiKey?: string;
6
6
  baseURL?: string;
7
- hpkeKeyURL?: string;
7
+ enclaveURL?: string;
8
8
  configRepo?: string;
9
9
  [key: string]: any;
10
10
  }
@@ -17,7 +17,7 @@ export declare class TinfoilAI {
17
17
  private verificationDocument?;
18
18
  apiKey?: string;
19
19
  baseURL?: string;
20
- hpkeKeyURL?: string;
20
+ enclaveURL?: string;
21
21
  constructor(options?: TinfoilAIOptions);
22
22
  ready(): Promise<void>;
23
23
  private initClient;
@@ -1,5 +1,5 @@
1
1
  import OpenAI from "openai";
2
- import { SecureClient } from "./secure-client.browser";
2
+ import { SecureClient } from "tinfoil/secure-client";
3
3
  import { TINFOIL_CONFIG } from "./config";
4
4
  function createAsyncProxy(promise) {
5
5
  return new Proxy({}, {
@@ -33,12 +33,12 @@ export class TinfoilAI {
33
33
  }
34
34
  this.apiKey = openAIOptions.apiKey;
35
35
  this.baseURL = options.baseURL || TINFOIL_CONFIG.INFERENCE_BASE_URL;
36
- this.hpkeKeyURL = options.hpkeKeyURL || TINFOIL_CONFIG.HPKE_KEY_URL;
36
+ this.enclaveURL = options.enclaveURL || TINFOIL_CONFIG.ENCLAVE_URL;
37
37
  this.configRepo = options.configRepo || TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
38
38
  // Create the secure client for handling transport security
39
39
  this.secureClient = new SecureClient({
40
40
  baseURL: this.baseURL,
41
- hpkeKeyURL: this.hpkeKeyURL,
41
+ enclaveURL: this.enclaveURL,
42
42
  configRepo: this.configRepo,
43
43
  });
44
44
  this.clientPromise = this.initClient(openAIOptions);
@@ -14,8 +14,8 @@ interface TinfoilAIOptions {
14
14
  apiKey?: string;
15
15
  /** Override the inference API base URL */
16
16
  baseURL?: string;
17
- /** Override the URL used to fetch the HPKE key (defaults to baseURL) */
18
- hpkeKeyURL?: string;
17
+ /** Override the URL used to fetch the ENCLAVE key (defaults to baseURL) */
18
+ enclaveURL?: string;
19
19
  /** Override the config GitHub repository */
20
20
  configRepo?: string;
21
21
  [key: string]: any;
@@ -29,7 +29,7 @@ export declare class TinfoilAI {
29
29
  private verificationDocument?;
30
30
  apiKey?: string;
31
31
  baseURL?: string;
32
- hpkeKeyURL?: string;
32
+ enclaveURL?: string;
33
33
  /**
34
34
  * Creates a new TinfoilAI instance.
35
35
  * @param options - Configuration options including apiKey and other OpenAI client options
@@ -1,5 +1,5 @@
1
1
  import OpenAI from "openai";
2
- import { SecureClient } from "./secure-client";
2
+ import { SecureClient } from "tinfoil/secure-client";
3
3
  import { TINFOIL_CONFIG } from "./config";
4
4
  import { isRealBrowser } from "./env";
5
5
  /**
@@ -57,11 +57,11 @@ export class TinfoilAI {
57
57
  // Store properties for compatibility
58
58
  this.apiKey = openAIOptions.apiKey;
59
59
  this.baseURL = options.baseURL || TINFOIL_CONFIG.INFERENCE_BASE_URL;
60
- this.hpkeKeyURL = options.hpkeKeyURL || TINFOIL_CONFIG.HPKE_KEY_URL;
60
+ this.enclaveURL = options.enclaveURL || TINFOIL_CONFIG.ENCLAVE_URL;
61
61
  this.configRepo = options.configRepo || TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
62
62
  this.secureClient = new SecureClient({
63
63
  baseURL: this.baseURL,
64
- hpkeKeyURL: this.hpkeKeyURL,
64
+ enclaveURL: this.enclaveURL,
65
65
  configRepo: this.configRepo,
66
66
  });
67
67
  this.clientPromise = this.initClient(openAIOptions);
@@ -7,11 +7,12 @@ export declare const TINFOIL_CONFIG: {
7
7
  */
8
8
  readonly INFERENCE_BASE_URL: "https://inference.tinfoil.sh/v1/";
9
9
  /**
10
- * The URL used to fetch the HPKE server public key (via EHBP .well-known endpoint).
11
- * Defaults to the same value as `INFERENCE_BASE_URL` so hpkeKeyURL and baseURL share
10
+ * The URL used to fetch the enclave server public key (via EHBP .well-known endpoint).
11
+ * and the attestation (vial the attestation .well-known endpoint too).
12
+ * Defaults to the same value as `INFERENCE_BASE_URL` so enclaveURL and baseURL share
12
13
  * the same default. Callers may override independently if key discovery is hosted elsewhere.
13
14
  */
14
- readonly HPKE_KEY_URL: "https://inference.tinfoil.sh/v1/";
15
+ readonly ENCLAVE_URL: "https://inference.tinfoil.sh/v1/";
15
16
  /**
16
17
  * The GitHub repository for the confidential inference proxy
17
18
  */
@@ -7,11 +7,12 @@ export const TINFOIL_CONFIG = {
7
7
  */
8
8
  INFERENCE_BASE_URL: "https://inference.tinfoil.sh/v1/",
9
9
  /**
10
- * The URL used to fetch the HPKE server public key (via EHBP .well-known endpoint).
11
- * Defaults to the same value as `INFERENCE_BASE_URL` so hpkeKeyURL and baseURL share
10
+ * The URL used to fetch the enclave server public key (via EHBP .well-known endpoint).
11
+ * and the attestation (vial the attestation .well-known endpoint too).
12
+ * Defaults to the same value as `INFERENCE_BASE_URL` so enclaveURL and baseURL share
12
13
  * the same default. Callers may override independently if key discovery is hosted elsewhere.
13
14
  */
14
- HPKE_KEY_URL: "https://inference.tinfoil.sh/v1/",
15
+ ENCLAVE_URL: "https://inference.tinfoil.sh/v1/",
15
16
  /**
16
17
  * The GitHub repository for the confidential inference proxy
17
18
  */
@@ -3,8 +3,8 @@ export declare function normalizeEncryptedBodyRequestArgs(input: RequestInfo | U
3
3
  url: string;
4
4
  init?: RequestInit;
5
5
  };
6
- export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey: string, init?: RequestInit, hpkeKeyURL?: string): Promise<Response>;
7
- export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey: string, hpkeKeyURL?: string): typeof fetch;
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;
8
8
  export declare function __setEhbpModuleForTests(module: EhbpModule | undefined): void;
9
9
  export declare function __resetEhbpModuleStateForTests(): void;
10
10
  export {};
@@ -24,12 +24,12 @@ export function normalizeEncryptedBodyRequestArgs(input, init) {
24
24
  init: { ...derivedInit, ...init },
25
25
  };
26
26
  }
27
- export async function encryptedBodyRequest(input, hpkePublicKey, init, hpkeKeyURL) {
27
+ export async function encryptedBodyRequest(input, hpkePublicKey, init, enclaveURL) {
28
28
  const { url: requestUrl, init: requestInit } = normalizeEncryptedBodyRequestArgs(input, init);
29
29
  const u = new URL(requestUrl);
30
30
  const { origin } = u;
31
31
  // Determine which origin to fetch the HPKE key from (may be different from request origin)
32
- const keyOrigin = hpkeKeyURL ? new URL(hpkeKeyURL).origin : origin;
32
+ const keyOrigin = enclaveURL ? new URL(enclaveURL).origin : origin;
33
33
  // If key origin matches request origin, use the standard transport (fetches keys from origin)
34
34
  // Otherwise, build a composite transport that routes to `origin` but uses the key fetched from `keyOrigin`.
35
35
  const transport = keyOrigin === origin
@@ -51,11 +51,11 @@ export async function encryptedBodyRequest(input, hpkePublicKey, init, hpkeKeyUR
51
51
  }
52
52
  return transport.request(requestUrl, requestInit);
53
53
  }
54
- export function createEncryptedBodyFetch(baseURL, hpkePublicKey, hpkeKeyURL) {
54
+ export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
55
55
  return (async (input, init) => {
56
56
  const normalized = normalizeEncryptedBodyRequestArgs(input, init);
57
57
  const targetUrl = new URL(normalized.url, baseURL);
58
- return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, hpkeKeyURL);
58
+ return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, enclaveURL);
59
59
  });
60
60
  }
61
61
  // Private helper functions
@@ -4,4 +4,4 @@ export * from "./verifier";
4
4
  export * from "./verification-runner";
5
5
  export * from "./ai-sdk-provider";
6
6
  export * from "./config";
7
- export * from "./secure-client";
7
+ export { SecureClient } from "tinfoil/secure-client";
@@ -5,4 +5,4 @@ export * from "./verifier";
5
5
  export * from "./verification-runner";
6
6
  export * from "./ai-sdk-provider";
7
7
  export * from "./config";
8
- export * from "./secure-client";
8
+ export { SecureClient } from "tinfoil/secure-client";
@@ -4,5 +4,5 @@ export * from "./verifier";
4
4
  export * from "./verification-runner";
5
5
  export * from "./ai-sdk-provider";
6
6
  export * from "./config";
7
- export * from "./secure-client";
7
+ export * from "tinfoil/secure-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
@@ -6,7 +6,7 @@ export * from "./verifier";
6
6
  export * from "./verification-runner";
7
7
  export * from "./ai-sdk-provider";
8
8
  export * from "./config";
9
- export * from "./secure-client";
9
+ export * from "tinfoil/secure-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,7 +1,7 @@
1
1
  import type { VerificationDocument } from "./verifier";
2
2
  interface SecureClientOptions {
3
3
  baseURL?: string;
4
- hpkeKeyURL?: string;
4
+ enclaveURL?: string;
5
5
  configRepo?: string;
6
6
  }
7
7
  export declare class SecureClient {
@@ -9,7 +9,7 @@ export declare class SecureClient {
9
9
  private verificationDocument;
10
10
  private _fetch;
11
11
  private readonly baseURL?;
12
- private readonly hpkeKeyURL?;
12
+ private readonly enclaveURL?;
13
13
  private readonly configRepo?;
14
14
  constructor(options?: SecureClientOptions);
15
15
  ready(): Promise<void>;
@@ -8,7 +8,7 @@ export class SecureClient {
8
8
  this.verificationDocument = null;
9
9
  this._fetch = null;
10
10
  this.baseURL = options.baseURL || TINFOIL_CONFIG.INFERENCE_BASE_URL;
11
- this.hpkeKeyURL = options.hpkeKeyURL || TINFOIL_CONFIG.HPKE_KEY_URL;
11
+ this.enclaveURL = options.enclaveURL || TINFOIL_CONFIG.ENCLAVE_URL;
12
12
  this.configRepo = options.configRepo || TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
13
13
  }
14
14
  async ready() {
@@ -19,7 +19,7 @@ export class SecureClient {
19
19
  }
20
20
  async initSecureClient() {
21
21
  const verifier = new Verifier({
22
- serverURL: this.baseURL,
22
+ serverURL: this.enclaveURL,
23
23
  configRepo: this.configRepo,
24
24
  });
25
25
  await verifier.verify();
@@ -36,7 +36,7 @@ export class SecureClient {
36
36
  }
37
37
  throw new Error("HPKE public key is required in browser environments");
38
38
  }
39
- this._fetch = createEncryptedBodyFetch(this.baseURL, hpkePublicKey, this.hpkeKeyURL);
39
+ this._fetch = createEncryptedBodyFetch(this.baseURL, hpkePublicKey, this.enclaveURL);
40
40
  }
41
41
  async getVerificationDocument() {
42
42
  if (!this.initPromise) {
@@ -1,7 +1,7 @@
1
1
  import type { VerificationDocument } from "./verifier";
2
2
  interface SecureClientOptions {
3
3
  baseURL?: string;
4
- hpkeKeyURL?: string;
4
+ enclaveURL?: string;
5
5
  configRepo?: string;
6
6
  }
7
7
  export declare class SecureClient {
@@ -9,7 +9,7 @@ export declare class SecureClient {
9
9
  private verificationDocument;
10
10
  private _fetch;
11
11
  private readonly baseURL?;
12
- private readonly hpkeKeyURL?;
12
+ private readonly enclaveURL?;
13
13
  private readonly configRepo?;
14
14
  constructor(options?: SecureClientOptions);
15
15
  ready(): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { Verifier } from "./verifier";
2
- import { TINFOIL_CONFIG } from "./config";
3
2
  import { createEncryptedBodyFetch } from "./encrypted-body-fetch";
4
3
  import { createPinnedTlsFetch } from "./pinned-tls-fetch";
4
+ import { TINFOIL_CONFIG } from "./config";
5
5
  import { isRealBrowser } from "./env";
6
6
  export class SecureClient {
7
7
  constructor(options = {}) {
@@ -9,7 +9,7 @@ export class SecureClient {
9
9
  this.verificationDocument = null;
10
10
  this._fetch = null;
11
11
  this.baseURL = options.baseURL || TINFOIL_CONFIG.INFERENCE_BASE_URL;
12
- this.hpkeKeyURL = options.hpkeKeyURL || TINFOIL_CONFIG.HPKE_KEY_URL;
12
+ this.enclaveURL = options.enclaveURL || TINFOIL_CONFIG.ENCLAVE_URL;
13
13
  this.configRepo = options.configRepo || TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
14
14
  }
15
15
  async ready() {
@@ -20,7 +20,7 @@ export class SecureClient {
20
20
  }
21
21
  async initSecureClient() {
22
22
  const verifier = new Verifier({
23
- serverURL: this.baseURL,
23
+ serverURL: this.enclaveURL,
24
24
  configRepo: this.configRepo,
25
25
  });
26
26
  await verifier.verify();
@@ -29,11 +29,12 @@ export class SecureClient {
29
29
  throw new Error("Verification document not available after successful verification");
30
30
  }
31
31
  this.verificationDocument = doc;
32
+ // Extract keys from the verification document
32
33
  const { hpkePublicKey, tlsPublicKeyFingerprint } = this.verificationDocument.enclaveMeasurement;
33
34
  let fetchFunction;
34
35
  if (hpkePublicKey) {
35
36
  // HPKE available: use encrypted body fetch
36
- fetchFunction = createEncryptedBodyFetch(this.baseURL, hpkePublicKey, this.hpkeKeyURL);
37
+ fetchFunction = createEncryptedBodyFetch(this.baseURL, hpkePublicKey, this.enclaveURL);
37
38
  }
38
39
  else {
39
40
  // HPKE not available: check if we're in a browser
@@ -417,8 +417,8 @@ export class Verifier {
417
417
  // Compare measurements using platform-specific logic
418
418
  const measurementsMatchError = compareMeasurementsError(codeMeasurement, attestation.measurement);
419
419
  if (measurementsMatchError) {
420
- throw new Error(`Measurement verification failed: Code measurement (${codeMeasurement.type}) ` +
421
- `does not match runtime measurement (${attestation.measurement.type}): ${measurementsMatchError.message}`);
420
+ throw new Error(`Verification failed: measurements did not match.\nCode measurement (${codeMeasurement.type}: ${codeMeasurement.registers})\n` +
421
+ `Runtime measurement (${attestation.measurement.type}: ${attestation.measurement.registers}:)\n ${measurementsMatchError.message}`);
422
422
  }
423
423
  // Persist a full verification document for later retrieval by clients
424
424
  this.lastVerificationDocument = {
@@ -4,4 +4,4 @@ export * from "./verifier";
4
4
  export * from "./verification-runner";
5
5
  export * from "./ai-sdk-provider";
6
6
  export * from "./config";
7
- export * from "./secure-client";
7
+ export { SecureClient } from "tinfoil/secure-client";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.default = exports.TinfoilAI = void 0;
17
+ exports.SecureClient = exports.default = exports.TinfoilAI = void 0;
18
18
  // Browser-safe entry point: avoids Node built-ins
19
19
  var client_browser_1 = require("./client.browser");
20
20
  Object.defineProperty(exports, "TinfoilAI", { enumerable: true, get: function () { return client_browser_1.TinfoilAI; } });
@@ -24,4 +24,5 @@ __exportStar(require("./verifier"), exports);
24
24
  __exportStar(require("./verification-runner"), exports);
25
25
  __exportStar(require("./ai-sdk-provider"), exports);
26
26
  __exportStar(require("./config"), exports);
27
- __exportStar(require("./secure-client"), exports);
27
+ var secure_client_1 = require("tinfoil/secure-client");
28
+ Object.defineProperty(exports, "SecureClient", { enumerable: true, get: function () { return secure_client_1.SecureClient; } });
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export * from "./verifier";
4
4
  export * from "./verification-runner";
5
5
  export * from "./ai-sdk-provider";
6
6
  export * from "./config";
7
- export * from "./secure-client";
7
+ export * from "tinfoil/secure-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/index.js CHANGED
@@ -25,7 +25,7 @@ __exportStar(require("./verifier"), exports);
25
25
  __exportStar(require("./verification-runner"), exports);
26
26
  __exportStar(require("./ai-sdk-provider"), exports);
27
27
  __exportStar(require("./config"), exports);
28
- __exportStar(require("./secure-client"), exports);
28
+ __exportStar(require("tinfoil/secure-client"), exports);
29
29
  // Re-export OpenAI utility types and classes that users might need
30
30
  // Using public exports from the main OpenAI package instead of deep imports
31
31
  var openai_1 = require("openai");
@@ -1,7 +1,7 @@
1
1
  import type { VerificationDocument } from "./verifier";
2
2
  interface SecureClientOptions {
3
3
  baseURL?: string;
4
- hpkeKeyURL?: string;
4
+ enclaveURL?: string;
5
5
  configRepo?: string;
6
6
  }
7
7
  export declare class SecureClient {
@@ -9,7 +9,7 @@ export declare class SecureClient {
9
9
  private verificationDocument;
10
10
  private _fetch;
11
11
  private readonly baseURL?;
12
- private readonly hpkeKeyURL?;
12
+ private readonly enclaveURL?;
13
13
  private readonly configRepo?;
14
14
  constructor(options?: SecureClientOptions);
15
15
  ready(): Promise<void>;
@@ -11,7 +11,7 @@ class SecureClient {
11
11
  this.verificationDocument = null;
12
12
  this._fetch = null;
13
13
  this.baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
14
- this.hpkeKeyURL = options.hpkeKeyURL || config_1.TINFOIL_CONFIG.HPKE_KEY_URL;
14
+ this.enclaveURL = options.enclaveURL || config_1.TINFOIL_CONFIG.ENCLAVE_URL;
15
15
  this.configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
16
16
  }
17
17
  async ready() {
@@ -22,7 +22,7 @@ class SecureClient {
22
22
  }
23
23
  async initSecureClient() {
24
24
  const verifier = new verifier_1.Verifier({
25
- serverURL: this.baseURL,
25
+ serverURL: this.enclaveURL,
26
26
  configRepo: this.configRepo,
27
27
  });
28
28
  await verifier.verify();
@@ -39,7 +39,7 @@ class SecureClient {
39
39
  }
40
40
  throw new Error("HPKE public key is required in browser environments");
41
41
  }
42
- this._fetch = (0, encrypted_body_fetch_1.createEncryptedBodyFetch)(this.baseURL, hpkePublicKey, this.hpkeKeyURL);
42
+ this._fetch = (0, encrypted_body_fetch_1.createEncryptedBodyFetch)(this.baseURL, hpkePublicKey, this.enclaveURL);
43
43
  }
44
44
  async getVerificationDocument() {
45
45
  if (!this.initPromise) {
@@ -1,7 +1,7 @@
1
1
  import type { VerificationDocument } from "./verifier";
2
2
  interface SecureClientOptions {
3
3
  baseURL?: string;
4
- hpkeKeyURL?: string;
4
+ enclaveURL?: string;
5
5
  configRepo?: string;
6
6
  }
7
7
  export declare class SecureClient {
@@ -9,7 +9,7 @@ export declare class SecureClient {
9
9
  private verificationDocument;
10
10
  private _fetch;
11
11
  private readonly baseURL?;
12
- private readonly hpkeKeyURL?;
12
+ private readonly enclaveURL?;
13
13
  private readonly configRepo?;
14
14
  constructor(options?: SecureClientOptions);
15
15
  ready(): Promise<void>;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SecureClient = void 0;
4
4
  const verifier_1 = require("./verifier");
5
- const config_1 = require("./config");
6
5
  const encrypted_body_fetch_1 = require("./encrypted-body-fetch");
7
6
  const pinned_tls_fetch_1 = require("./pinned-tls-fetch");
7
+ const config_1 = require("./config");
8
8
  const env_1 = require("./env");
9
9
  class SecureClient {
10
10
  constructor(options = {}) {
@@ -12,7 +12,7 @@ class SecureClient {
12
12
  this.verificationDocument = null;
13
13
  this._fetch = null;
14
14
  this.baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
15
- this.hpkeKeyURL = options.hpkeKeyURL || config_1.TINFOIL_CONFIG.HPKE_KEY_URL;
15
+ this.enclaveURL = options.enclaveURL || config_1.TINFOIL_CONFIG.ENCLAVE_URL;
16
16
  this.configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
17
17
  }
18
18
  async ready() {
@@ -23,7 +23,7 @@ class SecureClient {
23
23
  }
24
24
  async initSecureClient() {
25
25
  const verifier = new verifier_1.Verifier({
26
- serverURL: this.baseURL,
26
+ serverURL: this.enclaveURL,
27
27
  configRepo: this.configRepo,
28
28
  });
29
29
  await verifier.verify();
@@ -32,11 +32,12 @@ class SecureClient {
32
32
  throw new Error("Verification document not available after successful verification");
33
33
  }
34
34
  this.verificationDocument = doc;
35
+ // Extract keys from the verification document
35
36
  const { hpkePublicKey, tlsPublicKeyFingerprint } = this.verificationDocument.enclaveMeasurement;
36
37
  let fetchFunction;
37
38
  if (hpkePublicKey) {
38
39
  // HPKE available: use encrypted body fetch
39
- fetchFunction = (0, encrypted_body_fetch_1.createEncryptedBodyFetch)(this.baseURL, hpkePublicKey, this.hpkeKeyURL);
40
+ fetchFunction = (0, encrypted_body_fetch_1.createEncryptedBodyFetch)(this.baseURL, hpkePublicKey, this.enclaveURL);
40
41
  }
41
42
  else {
42
43
  // HPKE not available: check if we're in a browser
package/dist/verifier.js CHANGED
@@ -456,8 +456,8 @@ class Verifier {
456
456
  // Compare measurements using platform-specific logic
457
457
  const measurementsMatchError = compareMeasurementsError(codeMeasurement, attestation.measurement);
458
458
  if (measurementsMatchError) {
459
- throw new Error(`Measurement verification failed: Code measurement (${codeMeasurement.type}) ` +
460
- `does not match runtime measurement (${attestation.measurement.type}): ${measurementsMatchError.message}`);
459
+ throw new Error(`Verification failed: measurements did not match.\nCode measurement (${codeMeasurement.type}: ${codeMeasurement.registers})\n` +
460
+ `Runtime measurement (${attestation.measurement.type}: ${attestation.measurement.registers}:)\n ${measurementsMatchError.message}`);
461
461
  }
462
462
  // Persist a full verification document for later retrieval by clients
463
463
  this.lastVerificationDocument = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinfoil",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Tinfoil secure OpenAI client wrapper",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -54,7 +54,7 @@
54
54
  "build": "npm run build:cjs && npm run build:esm",
55
55
  "build:cjs": "tsc && cp src/wasm-exec.js dist/",
56
56
  "build:esm": "tsc -p tsconfig.esm.json && cp src/wasm-exec.js dist/esm/",
57
- "test": "bash -lc 'rm -rf .node-tests && tsc -p tsconfig.node-test.json && cp src/wasm-exec.js .node-tests/ && node --test $(find .node-tests -name \"*.test.js\" -print)'",
57
+ "test": "bash -lc 'rm -rf dist .node-tests && npm run build:cjs && tsc -p tsconfig.node-test.json && cp src/wasm-exec.js .node-tests/ && node --test $(find .node-tests -name \"*.test.js\" -print)'",
58
58
  "lint": "eslint src/**/*.ts",
59
59
  "prepublishOnly": "npm run build"
60
60
  },