tinfoil 0.10.9 → 0.10.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.
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/tinfoilsh/tinfoil-node/actions)
|
|
4
4
|
[](https://npmjs.org/package/tinfoil)
|
|
5
|
+
[](https://docs.tinfoil.sh/sdk/node-sdk)
|
|
5
6
|
|
|
6
|
-
This client library provides secure and convenient access to the Tinfoil
|
|
7
|
+
This client library provides secure and convenient access to the Tinfoil Private Inference endpoints from TypeScript or JavaScript.
|
|
7
8
|
|
|
8
9
|
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).
|
|
9
10
|
|
|
@@ -167,6 +168,8 @@ See [examples/README.md](https://github.com/tinfoilsh/tinfoil-node/blob/main/exa
|
|
|
167
168
|
|
|
168
169
|
## API Documentation
|
|
169
170
|
|
|
171
|
+
For complete documentation on using the Tinfoil Node SDK, including advanced examples and API reference, visit the [official documentation](https://docs.tinfoil.sh/sdk/node-sdk).
|
|
172
|
+
|
|
170
173
|
This library mirrors the official OpenAI Node.js client for common endpoints (e.g., chat, images, embeddings) and types, and is designed to feel familiar. Some less commonly used surfaces may not be fully covered. See the [OpenAI client](https://github.com/openai/openai-node) for complete API usage and documentation.
|
|
171
174
|
|
|
172
175
|
## Reporting Vulnerabilities
|
|
@@ -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
|
-
|
|
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 {};
|
|
@@ -78,13 +78,17 @@ function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
|
|
|
78
78
|
}
|
|
79
79
|
return transportPromise;
|
|
80
80
|
};
|
|
81
|
-
|
|
81
|
+
const secureFetch = (async (input, init) => {
|
|
82
82
|
const normalized = normalizeEncryptedBodyRequestArgs(input, init);
|
|
83
83
|
const targetUrl = new URL(normalized.url, baseURL);
|
|
84
84
|
// Get the dedicated transport instance for this fetch function
|
|
85
85
|
const transportInstance = await getOrCreateTransport();
|
|
86
86
|
return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, enclaveURL, transportInstance);
|
|
87
87
|
});
|
|
88
|
+
// Expose Response constructor for OpenAI SDK's FormData support detection
|
|
89
|
+
// This prevents the SDK from making a test request to 'data:,' which would fail through EHBP
|
|
90
|
+
secureFetch.Response = Response;
|
|
91
|
+
return secureFetch;
|
|
88
92
|
}
|
|
89
93
|
async function getTransportForOrigin(origin, keyOrigin) {
|
|
90
94
|
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
|
-
|
|
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 {};
|
|
@@ -71,13 +71,17 @@ export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
|
|
|
71
71
|
}
|
|
72
72
|
return transportPromise;
|
|
73
73
|
};
|
|
74
|
-
|
|
74
|
+
const secureFetch = (async (input, init) => {
|
|
75
75
|
const normalized = normalizeEncryptedBodyRequestArgs(input, init);
|
|
76
76
|
const targetUrl = new URL(normalized.url, baseURL);
|
|
77
77
|
// Get the dedicated transport instance for this fetch function
|
|
78
78
|
const transportInstance = await getOrCreateTransport();
|
|
79
79
|
return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, normalized.init, enclaveURL, transportInstance);
|
|
80
80
|
});
|
|
81
|
+
// Expose Response constructor for OpenAI SDK's FormData support detection
|
|
82
|
+
// This prevents the SDK from making a test request to 'data:,' which would fail through EHBP
|
|
83
|
+
secureFetch.Response = Response;
|
|
84
|
+
return secureFetch;
|
|
81
85
|
}
|
|
82
86
|
export async function getTransportForOrigin(origin, keyOrigin) {
|
|
83
87
|
if (typeof globalThis !== 'undefined') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinfoil",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.11",
|
|
4
4
|
"description": "Tinfoil secure OpenAI client wrapper",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"build": "npm run build:cjs && npm run build:esm",
|
|
54
54
|
"build:cjs": "tsc && cp src/wasm-exec.js dist/",
|
|
55
55
|
"build:esm": "tsc -p tsconfig.esm.json && node scripts/convert-to-mjs.js && cp src/wasm-exec.js dist/esm/",
|
|
56
|
-
"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)'",
|
|
56
|
+
"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)'",
|
|
57
57
|
"lint": "eslint src/**/*.ts",
|
|
58
58
|
"prepublishOnly": "npm run build"
|
|
59
59
|
},
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@ai-sdk/openai-compatible": "^1.0.10",
|
|
82
82
|
"ai": "^5.0.19",
|
|
83
83
|
"dotenv": "^17.2.1",
|
|
84
|
-
"ehbp": "^0.0.
|
|
84
|
+
"ehbp": "^0.0.6",
|
|
85
85
|
"openai": "^5.13.1",
|
|
86
86
|
"ts-node": "^10.9.2"
|
|
87
87
|
},
|