tinfoil 0.8.3 → 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 (47) hide show
  1. package/dist/ai-sdk-provider.d.ts +1 -11
  2. package/dist/ai-sdk-provider.js +9 -151
  3. package/dist/client.browser.d.ts +3 -2
  4. package/dist/client.browser.js +13 -28
  5. package/dist/client.d.ts +4 -3
  6. package/dist/client.js +13 -153
  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 -11
  12. package/dist/esm/ai-sdk-provider.js +9 -148
  13. package/dist/esm/client.browser.d.ts +3 -2
  14. package/dist/esm/client.browser.js +13 -28
  15. package/dist/esm/client.d.ts +4 -3
  16. package/dist/esm/client.js +13 -153
  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 +2 -1
  22. package/dist/esm/index.browser.js +2 -1
  23. package/dist/esm/index.d.ts +1 -0
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/pinned-tls-fetch.d.ts +1 -0
  26. package/dist/esm/pinned-tls-fetch.js +110 -0
  27. package/dist/esm/secure-client.browser.d.ts +20 -0
  28. package/dist/esm/secure-client.browser.js +57 -0
  29. package/dist/esm/secure-client.d.ts +20 -0
  30. package/dist/esm/secure-client.js +69 -0
  31. package/dist/esm/verifier.js +2 -2
  32. package/dist/index.browser.d.ts +2 -1
  33. package/dist/index.browser.js +4 -2
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +1 -0
  36. package/dist/pinned-tls-fetch.d.ts +1 -0
  37. package/dist/pinned-tls-fetch.js +116 -0
  38. package/dist/secure-client.browser.d.ts +20 -0
  39. package/dist/secure-client.browser.js +61 -0
  40. package/dist/secure-client.d.ts +20 -0
  41. package/dist/secure-client.js +73 -0
  42. package/dist/verifier.js +2 -2
  43. package/package.json +8 -3
  44. package/dist/ai-sdk-provider.browser.d.ts +0 -7
  45. package/dist/ai-sdk-provider.browser.js +0 -30
  46. package/dist/esm/ai-sdk-provider.browser.d.ts +0 -7
  47. package/dist/esm/ai-sdk-provider.browser.js +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinfoil",
3
- "version": "0.8.3",
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",
@@ -25,7 +25,6 @@
25
25
  },
26
26
  "./ai-sdk-provider": {
27
27
  "types": "./dist/ai-sdk-provider.d.ts",
28
- "browser": "./dist/esm/ai-sdk-provider.browser.js",
29
28
  "import": "./dist/esm/ai-sdk-provider.js",
30
29
  "require": "./dist/ai-sdk-provider.js"
31
30
  },
@@ -43,13 +42,19 @@
43
42
  "types": "./dist/config.d.ts",
44
43
  "import": "./dist/esm/config.js",
45
44
  "require": "./dist/config.js"
45
+ },
46
+ "./secure-client": {
47
+ "types": "./dist/secure-client.d.ts",
48
+ "browser": "./dist/esm/secure-client.browser.js",
49
+ "import": "./dist/esm/secure-client.js",
50
+ "require": "./dist/secure-client.js"
46
51
  }
47
52
  },
48
53
  "scripts": {
49
54
  "build": "npm run build:cjs && npm run build:esm",
50
55
  "build:cjs": "tsc && cp src/wasm-exec.js dist/",
51
56
  "build:esm": "tsc -p tsconfig.esm.json && cp src/wasm-exec.js dist/esm/",
52
- "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)'",
53
58
  "lint": "eslint src/**/*.ts",
54
59
  "prepublishOnly": "npm run build"
55
60
  },
@@ -1,7 +0,0 @@
1
- interface CreateTinfoilAIOptions {
2
- baseURL?: string;
3
- hpkeKeyURL?: string;
4
- configRepo?: string;
5
- }
6
- export declare function createTinfoilAI(apiKey: string, options?: CreateTinfoilAIOptions): Promise<import("@ai-sdk/openai-compatible").OpenAICompatibleProvider<string, string, string, string>>;
7
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTinfoilAI = createTinfoilAI;
4
- const openai_compatible_1 = require("@ai-sdk/openai-compatible");
5
- const config_1 = require("./config");
6
- const encrypted_body_fetch_1 = require("./encrypted-body-fetch");
7
- const verifier_1 = require("./verifier");
8
- const env_1 = require("./env");
9
- async function createTinfoilAI(apiKey, options = {}) {
10
- const baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
11
- const hpkeKeyURL = options.hpkeKeyURL || config_1.TINFOIL_CONFIG.HPKE_KEY_URL;
12
- const configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
13
- const verifier = new verifier_1.Verifier({ serverURL: baseURL, configRepo });
14
- const attestationResponse = await verifier.verify();
15
- const hpkePublicKey = attestationResponse.hpkePublicKey;
16
- if (!hpkePublicKey) {
17
- if ((0, env_1.isRealBrowser)()) {
18
- throw new Error("HPKE public key not available and TLS-only verification is not supported in browsers. " +
19
- "Only HPKE-enabled enclaves can be used in browser environments.");
20
- }
21
- throw new Error("HPKE public key is required in browser environments");
22
- }
23
- const fetchFunction = (0, encrypted_body_fetch_1.createEncryptedBodyFetch)(baseURL, hpkePublicKey, hpkeKeyURL);
24
- return (0, openai_compatible_1.createOpenAICompatible)({
25
- name: "tinfoil",
26
- baseURL: baseURL.replace(/\/$/, ""),
27
- apiKey: apiKey,
28
- fetch: fetchFunction,
29
- });
30
- }
@@ -1,7 +0,0 @@
1
- interface CreateTinfoilAIOptions {
2
- baseURL?: string;
3
- hpkeKeyURL?: string;
4
- configRepo?: string;
5
- }
6
- export declare function createTinfoilAI(apiKey: string, options?: CreateTinfoilAIOptions): Promise<import("@ai-sdk/openai-compatible").OpenAICompatibleProvider<string, string, string, string>>;
7
- export {};
@@ -1,27 +0,0 @@
1
- import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
2
- import { TINFOIL_CONFIG } from "./config";
3
- import { createEncryptedBodyFetch } from "./encrypted-body-fetch";
4
- import { Verifier } from "./verifier";
5
- import { isRealBrowser } from "./env";
6
- export async function createTinfoilAI(apiKey, options = {}) {
7
- const baseURL = options.baseURL || TINFOIL_CONFIG.INFERENCE_BASE_URL;
8
- const hpkeKeyURL = options.hpkeKeyURL || TINFOIL_CONFIG.HPKE_KEY_URL;
9
- const configRepo = options.configRepo || TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
10
- const verifier = new Verifier({ serverURL: baseURL, configRepo });
11
- const attestationResponse = await verifier.verify();
12
- const hpkePublicKey = attestationResponse.hpkePublicKey;
13
- if (!hpkePublicKey) {
14
- if (isRealBrowser()) {
15
- throw new Error("HPKE public key not available and TLS-only verification is not supported in browsers. " +
16
- "Only HPKE-enabled enclaves can be used in browser environments.");
17
- }
18
- throw new Error("HPKE public key is required in browser environments");
19
- }
20
- const fetchFunction = createEncryptedBodyFetch(baseURL, hpkePublicKey, hpkeKeyURL);
21
- return createOpenAICompatible({
22
- name: "tinfoil",
23
- baseURL: baseURL.replace(/\/$/, ""),
24
- apiKey: apiKey,
25
- fetch: fetchFunction,
26
- });
27
- }