tinfoil 1.2.2 → 1.2.3
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 +57 -0
- package/dist/ai-sdk-provider.d.ts.map +1 -1
- package/dist/ai-sdk-provider.js +1 -0
- package/dist/ai-sdk-provider.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Tinfoil TypeScript Client
|
|
2
|
+
|
|
3
|
+
[](https://github.com/tinfoilsh/tinfoil-js/actions)
|
|
4
|
+
[](https://npmjs.org/package/tinfoil)
|
|
5
|
+
[](https://docs.tinfoil.sh/sdk/javascript-sdk)
|
|
6
|
+
|
|
7
|
+
A TypeScript client for verifiably private AI inference with Tinfoil. It wraps the [OpenAI Node client](https://github.com/openai/openai-node) with the same API, and before sending any request it verifies the enclave's attestation and encrypts the request body to the attested key using [EHBP](https://docs.tinfoil.sh/resources/ehbp), so only the verified enclave can read it. Works in Node (22.23.4+, 24.22.1+, or 26.12.1+), browsers, Electron, and Bun, and supports the [Vercel AI SDK](https://sdk.vercel.ai/).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install tinfoil
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { TinfoilAI } from "tinfoil";
|
|
19
|
+
|
|
20
|
+
const client = new TinfoilAI({
|
|
21
|
+
apiKey: "<YOUR_API_KEY>", // or set TINFOIL_API_KEY
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Enclave verification and encryption happen automatically.
|
|
25
|
+
const completion = await client.chat.completions.create({
|
|
26
|
+
messages: [{ role: "user", content: "Hello!" }],
|
|
27
|
+
model: "gpt-oss-120b", // see https://docs.tinfoil.sh/models/chat
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Never put `apiKey` in browser code: route browser requests through a [proxy server](https://docs.tinfoil.sh/guides/proxy-server) that adds the key, and authenticate the browser with `bearerToken`. Multi-user services must scope prompt caches to each end user with `userCacheSecret` or a per-request `user_cache_secret`; see [Prompt caching](https://docs.tinfoil.sh/sdk/prompt-caching).
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
- [JavaScript SDK documentation](https://docs.tinfoil.sh/sdk/javascript-sdk), including `SecureClient` and verification documents. Realtime transcription over WebSockets is covered in [Processing audio](https://docs.tinfoil.sh/guides/processing-audio).
|
|
36
|
+
- [Examples](packages/tinfoil/examples/), including the Vercel AI SDK on the server and in React.
|
|
37
|
+
- The resources `TinfoilAI` exposes, such as `chat`, `responses`, `embeddings`, and `audio`, keep the OpenAI methods and types; see the [OpenAI Node client documentation](https://github.com/openai/openai-node).
|
|
38
|
+
|
|
39
|
+
## Development
|
|
40
|
+
|
|
41
|
+
This is a monorepo: `packages/tinfoil` is the SDK (published as `tinfoil`) and `packages/verifier` is the attestation verifier (published as `@tinfoilsh/verifier`).
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install
|
|
45
|
+
npm run build
|
|
46
|
+
npm test # unit tests
|
|
47
|
+
npm run test:all # unit, integration, and browser tests
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Reporting Vulnerabilities
|
|
51
|
+
|
|
52
|
+
Please report security vulnerabilities by either:
|
|
53
|
+
|
|
54
|
+
- Emailing [security@tinfoil.sh](mailto:security@tinfoil.sh)
|
|
55
|
+
- Opening an issue on GitHub on this repository
|
|
56
|
+
|
|
57
|
+
We aim to respond to (legitimate) security reports within 24 hours.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-sdk-provider.d.ts","sourceRoot":"","sources":["../src/ai-sdk-provider.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,
|
|
1
|
+
{"version":3,"file":"ai-sdk-provider.d.ts","sourceRoot":"","sources":["../src/ai-sdk-provider.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,yGA0B1F"}
|
package/dist/ai-sdk-provider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-sdk-provider.js","sourceRoot":"","sources":["../src/ai-sdk-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA4BnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,KAAK,UAAU,eA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MAAM,CAAC;IAC5B,IAAI,CAAC,cAAc,IAAI,CAAC,aAAa,EAAE,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QACzG,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC/C,CAAC;IACD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,kBAAkB,CAAC,4FAA4F,CAAC,CAAC;IAC7H,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,eAAe,EAAE,OAAO,CAAC,eAAe;KACzC,CAAC,CAAC;IAEH,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;IAE3B,OAAO,sBAAsB,CAAC;QAC5B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY,CAAC,UAAU,EAAG;QACnC,MAAM,EAAE,cAAc;QACtB,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,yBAAyB,EAAE,IAAI;KAChC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinfoil",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Tinfoil secure OpenAI client wrapper",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
"lint": "eslint src/**/*.ts",
|
|
40
40
|
"check:es2020": "acorn --ecma2020 --module --silent dist/*.js",
|
|
41
41
|
"clean": "rm -rf dist",
|
|
42
|
+
"prepack": "cp ../../README.md README.md",
|
|
43
|
+
"postpack": "rm README.md",
|
|
42
44
|
"prepublishOnly": "npm run build"
|
|
43
45
|
},
|
|
44
46
|
"files": [
|
|
@@ -58,12 +60,12 @@
|
|
|
58
60
|
"author": "Tinfoil",
|
|
59
61
|
"license": "Apache-2.0",
|
|
60
62
|
"engines": {
|
|
61
|
-
"node": ">=
|
|
63
|
+
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
62
64
|
},
|
|
63
65
|
"dependencies": {
|
|
64
66
|
"@ai-sdk/openai-compatible": "^3.0.7",
|
|
65
67
|
"@freedomofpress/sigstore-browser": "^0.1.14",
|
|
66
|
-
"@tinfoilsh/verifier": "1.2.
|
|
68
|
+
"@tinfoilsh/verifier": "1.2.3",
|
|
67
69
|
"@types/ws": "^8.18.1",
|
|
68
70
|
"ehbp": "^0.3.3",
|
|
69
71
|
"openai": "^6.46.0",
|