@zeke-02/tinfoil 0.0.10 → 0.0.11

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.
@@ -5,5 +5,9 @@ export declare function normalizeEncryptedBodyRequestArgs(input: RequestInfo | U
5
5
  init?: RequestInit;
6
6
  };
7
7
  export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey?: string, init?: RequestInit, enclaveURL?: string, transportInstance?: EhbpTransport): Promise<Response>;
8
- export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey?: string, enclaveURL?: string): typeof fetch;
8
+ type FetchWithResponse = typeof fetch & {
9
+ Response: typeof Response;
10
+ };
11
+ export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey?: string, enclaveURL?: string): FetchWithResponse;
9
12
  export declare function getTransportForOrigin(origin: string, keyOrigin: string): Promise<EhbpTransport>;
13
+ export {};
@@ -82,13 +82,17 @@ function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
82
82
  }
83
83
  return transportPromise;
84
84
  };
85
- return (async (input, init) => {
85
+ const secureFetch = (async (input, init) => {
86
86
  const normalized = normalizeEncryptedBodyRequestArgs(input, init);
87
87
  const targetUrl = new URL(normalized.url, baseURL);
88
88
  // Get the dedicated transport instance for this fetch function
89
89
  const transportInstance = await getOrCreateTransport();
90
90
  return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, enclaveURL, transportInstance);
91
91
  });
92
+ // Expose Response constructor for OpenAI SDK's FormData support detection
93
+ // This prevents the SDK from making a test request to 'data:,' which would fail through EHBP
94
+ secureFetch.Response = Response;
95
+ return secureFetch;
92
96
  }
93
97
  async function getTransportForOrigin(origin, keyOrigin) {
94
98
  if (typeof globalThis !== "undefined") {
@@ -5,5 +5,9 @@ export declare function normalizeEncryptedBodyRequestArgs(input: RequestInfo | U
5
5
  init?: RequestInit;
6
6
  };
7
7
  export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey?: string, init?: RequestInit, enclaveURL?: string, transportInstance?: EhbpTransport): Promise<Response>;
8
- export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey?: string, enclaveURL?: string): typeof fetch;
8
+ type FetchWithResponse = typeof fetch & {
9
+ Response: typeof Response;
10
+ };
11
+ export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey?: string, enclaveURL?: string): FetchWithResponse;
9
12
  export declare function getTransportForOrigin(origin: string, keyOrigin: string): Promise<EhbpTransport>;
13
+ export {};
@@ -75,13 +75,17 @@ export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
75
75
  }
76
76
  return transportPromise;
77
77
  };
78
- return (async (input, init) => {
78
+ const secureFetch = (async (input, init) => {
79
79
  const normalized = normalizeEncryptedBodyRequestArgs(input, init);
80
80
  const targetUrl = new URL(normalized.url, baseURL);
81
81
  // Get the dedicated transport instance for this fetch function
82
82
  const transportInstance = await getOrCreateTransport();
83
83
  return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, enclaveURL, transportInstance);
84
84
  });
85
+ // Expose Response constructor for OpenAI SDK's FormData support detection
86
+ // This prevents the SDK from making a test request to 'data:,' which would fail through EHBP
87
+ secureFetch.Response = Response;
88
+ return secureFetch;
85
89
  }
86
90
  export async function getTransportForOrigin(origin, keyOrigin) {
87
91
  if (typeof globalThis !== "undefined") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeke-02/tinfoil",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Tinfoil secure OpenAI client wrapper for Tauri v2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.mjs",
@@ -59,7 +59,7 @@
59
59
  "build": "npm run build:cjs && npm run build:esm",
60
60
  "build:cjs": "tsc && cp src/wasm-exec.js dist/",
61
61
  "build:esm": "tsc -p tsconfig.esm.json && node scripts/convert-to-mjs.js && cp src/wasm-exec.js dist/esm/",
62
- "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)'",
62
+ "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/ && cp -r src/__tests__/fixtures .node-tests/__tests__/ && node --test $(find .node-tests -name \"*.test.js\" -print)'",
63
63
  "lint": "eslint src/**/*.ts",
64
64
  "prepublishOnly": "npm run build"
65
65
  },
@@ -86,7 +86,7 @@
86
86
  "dependencies": {
87
87
  "@ai-sdk/openai-compatible": "^1.0.10",
88
88
  "@tauri-apps/plugin-http": "^2.5.2",
89
- "@zeke-02/ehbp": "^0.0.5",
89
+ "@zeke-02/ehbp": "^0.0.6",
90
90
  "ai": "^5.0.19",
91
91
  "dotenv": "^17.2.1",
92
92
  "openai": "^5.13.1",