tinfoil 0.8.5 → 0.8.7
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/dist/ai-sdk-provider.js +1 -1
- package/dist/encrypted-body-fetch.js +27 -80
- package/dist/esm/ai-sdk-provider.js +1 -1
- package/dist/esm/encrypted-body-fetch.js +27 -80
- package/dist/esm/index.browser.d.ts +3 -3
- package/dist/esm/index.browser.js +3 -3
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +3 -3
- package/dist/esm/secure-client.js +2 -21
- package/dist/esm/secure-fetch.browser.d.ts +1 -0
- package/dist/esm/secure-fetch.browser.js +10 -0
- package/dist/esm/secure-fetch.d.ts +1 -0
- package/dist/esm/secure-fetch.js +22 -0
- package/dist/esm/{client.browser.js → tinfoilai.js} +10 -5
- package/dist/index.browser.d.ts +3 -3
- package/dist/index.browser.js +5 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -6
- package/dist/secure-client.js +2 -21
- package/dist/secure-fetch.browser.d.ts +1 -0
- package/dist/secure-fetch.browser.js +13 -0
- package/dist/secure-fetch.d.ts +1 -0
- package/dist/secure-fetch.js +25 -0
- package/dist/{client.browser.js → tinfoilai.js} +10 -5
- package/package.json +7 -3
- package/dist/client.d.ts +0 -123
- package/dist/client.js +0 -218
- package/dist/esm/client.d.ts +0 -123
- package/dist/esm/client.js +0 -211
- package/dist/esm/secure-client.browser.d.ts +0 -20
- package/dist/esm/secure-client.browser.js +0 -57
- package/dist/secure-client.browser.d.ts +0 -20
- package/dist/secure-client.browser.js +0 -61
- /package/dist/{client.browser.d.ts → esm/tinfoilai.d.ts} +0 -0
- /package/dist/{esm/client.browser.d.ts → tinfoilai.d.ts} +0 -0
|
@@ -5,8 +5,9 @@ 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("
|
|
8
|
+
const secure_client_1 = require("./secure-client");
|
|
9
9
|
const config_1 = require("./config");
|
|
10
|
+
const env_1 = require("./env");
|
|
10
11
|
function createAsyncProxy(promise) {
|
|
11
12
|
return new Proxy({}, {
|
|
12
13
|
get(target, prop) {
|
|
@@ -34,14 +35,16 @@ class TinfoilAI {
|
|
|
34
35
|
const openAIOptions = { ...options };
|
|
35
36
|
// In browser builds, never read secrets from process.env to avoid
|
|
36
37
|
// leaking credentials into client bundles. Require explicit apiKey.
|
|
37
|
-
if (
|
|
38
|
+
if (options.apiKey) {
|
|
38
39
|
openAIOptions.apiKey = options.apiKey;
|
|
39
40
|
}
|
|
41
|
+
else if (!(0, env_1.isRealBrowser)() && process.env.TINFOIL_API_KEY) {
|
|
42
|
+
openAIOptions.apiKey = process.env.TINFOIL_API_KEY;
|
|
43
|
+
}
|
|
40
44
|
this.apiKey = openAIOptions.apiKey;
|
|
41
45
|
this.baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
|
|
42
46
|
this.enclaveURL = options.enclaveURL || config_1.TINFOIL_CONFIG.ENCLAVE_URL;
|
|
43
47
|
this.configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
|
|
44
|
-
// Create the secure client for handling transport security
|
|
45
48
|
this.secureClient = new secure_client_1.SecureClient({
|
|
46
49
|
baseURL: this.baseURL,
|
|
47
50
|
enclaveURL: this.enclaveURL,
|
|
@@ -71,8 +74,9 @@ class TinfoilAI {
|
|
|
71
74
|
baseURL: this.baseURL,
|
|
72
75
|
fetch: this.secureClient.fetch,
|
|
73
76
|
};
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
if ((0, env_1.isRealBrowser)() || options.dangerouslyAllowBrowser === true) {
|
|
78
|
+
clientOptions.dangerouslyAllowBrowser = true;
|
|
79
|
+
}
|
|
76
80
|
return new openai_1.default(clientOptions);
|
|
77
81
|
}
|
|
78
82
|
async ensureReady() {
|
|
@@ -118,6 +122,7 @@ class TinfoilAI {
|
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
exports.TinfoilAI = TinfoilAI;
|
|
125
|
+
// Namespace declaration merge to add OpenAI types to TinfoilAI
|
|
121
126
|
(function (TinfoilAI) {
|
|
122
127
|
TinfoilAI.Chat = openai_1.default.Chat;
|
|
123
128
|
TinfoilAI.Audio = openai_1.default.Audio;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinfoil",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "Tinfoil secure OpenAI client wrapper",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
},
|
|
20
20
|
"./client": {
|
|
21
21
|
"types": "./dist/client.d.ts",
|
|
22
|
-
"browser": "./dist/esm/client.browser.js",
|
|
23
22
|
"import": "./dist/esm/client.js",
|
|
24
23
|
"require": "./dist/client.js"
|
|
25
24
|
},
|
|
@@ -45,9 +44,14 @@
|
|
|
45
44
|
},
|
|
46
45
|
"./secure-client": {
|
|
47
46
|
"types": "./dist/secure-client.d.ts",
|
|
48
|
-
"browser": "./dist/esm/secure-client.browser.js",
|
|
49
47
|
"import": "./dist/esm/secure-client.js",
|
|
50
48
|
"require": "./dist/secure-client.js"
|
|
49
|
+
},
|
|
50
|
+
"./secure-fetch": {
|
|
51
|
+
"types": "./dist/secure-fetch.d.ts",
|
|
52
|
+
"browser": "./dist/esm/secure-fetch.browser.js",
|
|
53
|
+
"import": "./dist/esm/secure-fetch.js",
|
|
54
|
+
"require": "./dist/secure-fetch.js"
|
|
51
55
|
}
|
|
52
56
|
},
|
|
53
57
|
"scripts": {
|
package/dist/client.d.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
import type { Audio, Beta, Chat, Embeddings, Files, FineTuning, Images, Models, Moderations, Responses } from "openai/resources";
|
|
3
|
-
import type { VerificationDocument } from "./verifier";
|
|
4
|
-
/**
|
|
5
|
-
* TinfoilAI is a wrapper around the OpenAI API client that adds additional
|
|
6
|
-
* security measures through enclave verification and an EHBP-secured transport.
|
|
7
|
-
*
|
|
8
|
-
* It provides:
|
|
9
|
-
* - Automatic verification of Tinfoil secure enclaves
|
|
10
|
-
* - EHBP-enforced transport security for each request
|
|
11
|
-
* - Type-safe access to OpenAI's chat completion APIs
|
|
12
|
-
*/
|
|
13
|
-
interface TinfoilAIOptions {
|
|
14
|
-
apiKey?: string;
|
|
15
|
-
/** Override the inference API base URL */
|
|
16
|
-
baseURL?: string;
|
|
17
|
-
/** Override the URL used to fetch the ENCLAVE key (defaults to baseURL) */
|
|
18
|
-
enclaveURL?: string;
|
|
19
|
-
/** Override the config GitHub repository */
|
|
20
|
-
configRepo?: string;
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
}
|
|
23
|
-
export declare class TinfoilAI {
|
|
24
|
-
private client?;
|
|
25
|
-
private clientPromise;
|
|
26
|
-
private readyPromise?;
|
|
27
|
-
private configRepo?;
|
|
28
|
-
private secureClient;
|
|
29
|
-
private verificationDocument?;
|
|
30
|
-
apiKey?: string;
|
|
31
|
-
baseURL?: string;
|
|
32
|
-
enclaveURL?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a new TinfoilAI instance.
|
|
35
|
-
* @param options - Configuration options including apiKey and other OpenAI client options
|
|
36
|
-
*/
|
|
37
|
-
constructor(options?: TinfoilAIOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Ensures the client is ready to use.
|
|
40
|
-
* @returns Promise that resolves when the client is initialized
|
|
41
|
-
*/
|
|
42
|
-
ready(): Promise<void>;
|
|
43
|
-
private initClient;
|
|
44
|
-
private createOpenAIClient;
|
|
45
|
-
/**
|
|
46
|
-
* Helper method to ensure the OpenAI client is initialized before use.
|
|
47
|
-
* Automatically calls ready() if needed.
|
|
48
|
-
* @returns The initialized OpenAI client
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
private ensureReady;
|
|
52
|
-
/**
|
|
53
|
-
* Returns the full verification document produced during client initialization.
|
|
54
|
-
*/
|
|
55
|
-
getVerificationDocument(): Promise<VerificationDocument>;
|
|
56
|
-
/**
|
|
57
|
-
* Access to OpenAI's chat completions API for creating chat conversations.
|
|
58
|
-
* Automatically initializes the client if needed.
|
|
59
|
-
*/
|
|
60
|
-
get chat(): Chat;
|
|
61
|
-
/**
|
|
62
|
-
* Access to OpenAI's files API for managing files used with the API.
|
|
63
|
-
* Automatically initializes the client if needed.
|
|
64
|
-
*/
|
|
65
|
-
get files(): Files;
|
|
66
|
-
/**
|
|
67
|
-
* Access to OpenAI's fine-tuning API for creating and managing fine-tuned models.
|
|
68
|
-
* Automatically initializes the client if needed.
|
|
69
|
-
*/
|
|
70
|
-
get fineTuning(): FineTuning;
|
|
71
|
-
/**
|
|
72
|
-
* Access to OpenAI's image generation and editing API.
|
|
73
|
-
* Automatically initializes the client if needed.
|
|
74
|
-
*/
|
|
75
|
-
get images(): Images;
|
|
76
|
-
/**
|
|
77
|
-
* Access to OpenAI's audio API for speech-to-text and text-to-speech.
|
|
78
|
-
* Automatically initializes the client if needed.
|
|
79
|
-
*/
|
|
80
|
-
get audio(): Audio;
|
|
81
|
-
/**
|
|
82
|
-
* Access to the Responses API, supporting response creation, streaming, and parsing.
|
|
83
|
-
* Automatically initializes the client if needed.
|
|
84
|
-
*/
|
|
85
|
-
get responses(): Responses;
|
|
86
|
-
/**
|
|
87
|
-
* Access to OpenAI's embeddings API for creating vector embeddings of text.
|
|
88
|
-
* Automatically initializes the client if needed.
|
|
89
|
-
*/
|
|
90
|
-
get embeddings(): Embeddings;
|
|
91
|
-
/**
|
|
92
|
-
* Access to OpenAI's models API for listing and managing available models.
|
|
93
|
-
* Automatically initializes the client if needed.
|
|
94
|
-
*/
|
|
95
|
-
get models(): Models;
|
|
96
|
-
/**
|
|
97
|
-
* Access to OpenAI's content moderation API.
|
|
98
|
-
* Automatically initializes the client if needed.
|
|
99
|
-
*/
|
|
100
|
-
get moderations(): Moderations;
|
|
101
|
-
/**
|
|
102
|
-
* Access to OpenAI's beta features.
|
|
103
|
-
* Automatically initializes the client if needed.
|
|
104
|
-
*/
|
|
105
|
-
get beta(): Beta;
|
|
106
|
-
}
|
|
107
|
-
export declare namespace TinfoilAI {
|
|
108
|
-
export import Chat = OpenAI.Chat;
|
|
109
|
-
export import Audio = OpenAI.Audio;
|
|
110
|
-
export import Beta = OpenAI.Beta;
|
|
111
|
-
export import Batches = OpenAI.Batches;
|
|
112
|
-
export import Completions = OpenAI.Completions;
|
|
113
|
-
export import Embeddings = OpenAI.Embeddings;
|
|
114
|
-
export import Files = OpenAI.Files;
|
|
115
|
-
export import FineTuning = OpenAI.FineTuning;
|
|
116
|
-
export import Images = OpenAI.Images;
|
|
117
|
-
export import Models = OpenAI.Models;
|
|
118
|
-
export import Moderations = OpenAI.Moderations;
|
|
119
|
-
export import Responses = OpenAI.Responses;
|
|
120
|
-
export import Uploads = OpenAI.Uploads;
|
|
121
|
-
export import VectorStores = OpenAI.VectorStores;
|
|
122
|
-
}
|
|
123
|
-
export {};
|
package/dist/client.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TinfoilAI = void 0;
|
|
7
|
-
const openai_1 = __importDefault(require("openai"));
|
|
8
|
-
const secure_client_1 = require("tinfoil/secure-client");
|
|
9
|
-
const config_1 = require("./config");
|
|
10
|
-
const env_1 = require("./env");
|
|
11
|
-
/**
|
|
12
|
-
* Creates a proxy that allows property access and method calls on a Promise before it resolves.
|
|
13
|
-
* This enables a more ergonomic API where you can chain properties and methods without explicitly
|
|
14
|
-
* awaiting the promise first.
|
|
15
|
-
*
|
|
16
|
-
* @param promise - A Promise that will resolve to an object
|
|
17
|
-
* @returns A proxied version of the promised object that allows immediate property/method access
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // Instead of:
|
|
21
|
-
* const client = await getClient();
|
|
22
|
-
* const result = await client.someProperty.someMethod();
|
|
23
|
-
*
|
|
24
|
-
* // You can write:
|
|
25
|
-
* const client = createAsyncProxy(getClient());
|
|
26
|
-
* const result = await client.someProperty.someMethod();
|
|
27
|
-
*
|
|
28
|
-
* @template T - The type of object that the promise resolves to
|
|
29
|
-
*/
|
|
30
|
-
function createAsyncProxy(promise) {
|
|
31
|
-
return new Proxy({}, {
|
|
32
|
-
get(target, prop) {
|
|
33
|
-
return new Proxy(() => { }, {
|
|
34
|
-
get(_, nestedProp) {
|
|
35
|
-
return (...args) => promise.then((obj) => {
|
|
36
|
-
const value = obj[prop][nestedProp];
|
|
37
|
-
return typeof value === "function"
|
|
38
|
-
? value.apply(obj[prop], args)
|
|
39
|
-
: value;
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
apply(_, __, args) {
|
|
43
|
-
return promise.then((obj) => {
|
|
44
|
-
const value = obj[prop];
|
|
45
|
-
return typeof value === "function" ? value.apply(obj, args) : value;
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
class TinfoilAI {
|
|
53
|
-
/**
|
|
54
|
-
* Creates a new TinfoilAI instance.
|
|
55
|
-
* @param options - Configuration options including apiKey and other OpenAI client options
|
|
56
|
-
*/
|
|
57
|
-
constructor(options = {}) {
|
|
58
|
-
// Set apiKey from options or environment variable
|
|
59
|
-
const openAIOptions = { ...options };
|
|
60
|
-
if (options.apiKey || process.env.TINFOIL_API_KEY) {
|
|
61
|
-
openAIOptions.apiKey = options.apiKey || process.env.TINFOIL_API_KEY;
|
|
62
|
-
}
|
|
63
|
-
// Store properties for compatibility
|
|
64
|
-
this.apiKey = openAIOptions.apiKey;
|
|
65
|
-
this.baseURL = options.baseURL || config_1.TINFOIL_CONFIG.INFERENCE_BASE_URL;
|
|
66
|
-
this.enclaveURL = options.enclaveURL || config_1.TINFOIL_CONFIG.ENCLAVE_URL;
|
|
67
|
-
this.configRepo = options.configRepo || config_1.TINFOIL_CONFIG.INFERENCE_PROXY_REPO;
|
|
68
|
-
this.secureClient = new secure_client_1.SecureClient({
|
|
69
|
-
baseURL: this.baseURL,
|
|
70
|
-
enclaveURL: this.enclaveURL,
|
|
71
|
-
configRepo: this.configRepo,
|
|
72
|
-
});
|
|
73
|
-
this.clientPromise = this.initClient(openAIOptions);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Ensures the client is ready to use.
|
|
77
|
-
* @returns Promise that resolves when the client is initialized
|
|
78
|
-
*/
|
|
79
|
-
async ready() {
|
|
80
|
-
if (!this.readyPromise) {
|
|
81
|
-
this.readyPromise = (async () => {
|
|
82
|
-
this.client = await this.clientPromise;
|
|
83
|
-
})();
|
|
84
|
-
}
|
|
85
|
-
return this.readyPromise;
|
|
86
|
-
}
|
|
87
|
-
async initClient(options) {
|
|
88
|
-
return this.createOpenAIClient(options);
|
|
89
|
-
}
|
|
90
|
-
async createOpenAIClient(options = {}) {
|
|
91
|
-
await this.secureClient.ready();
|
|
92
|
-
this.verificationDocument = await this.secureClient.getVerificationDocument();
|
|
93
|
-
if (!this.verificationDocument) {
|
|
94
|
-
throw new Error("Verification document not available after successful verification");
|
|
95
|
-
}
|
|
96
|
-
const clientOptions = {
|
|
97
|
-
...options,
|
|
98
|
-
baseURL: this.baseURL,
|
|
99
|
-
fetch: this.secureClient.fetch,
|
|
100
|
-
};
|
|
101
|
-
// Enable dangerouslyAllowBrowser in Node.js with WASM (which makes OpenAI SDK think we're in a browser)
|
|
102
|
-
// OR if explicitly set by the user (for legitimate browser usage like playgrounds)
|
|
103
|
-
if (!(0, env_1.isRealBrowser)() || options.dangerouslyAllowBrowser === true) {
|
|
104
|
-
clientOptions.dangerouslyAllowBrowser = true;
|
|
105
|
-
}
|
|
106
|
-
return new openai_1.default(clientOptions);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Helper method to ensure the OpenAI client is initialized before use.
|
|
110
|
-
* Automatically calls ready() if needed.
|
|
111
|
-
* @returns The initialized OpenAI client
|
|
112
|
-
* @private
|
|
113
|
-
*/
|
|
114
|
-
async ensureReady() {
|
|
115
|
-
await this.ready();
|
|
116
|
-
// We can safely assert this now because ready() must have completed
|
|
117
|
-
return this.client;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Returns the full verification document produced during client initialization.
|
|
121
|
-
*/
|
|
122
|
-
async getVerificationDocument() {
|
|
123
|
-
await this.ready();
|
|
124
|
-
if (!this.verificationDocument) {
|
|
125
|
-
throw new Error("Verification document unavailable: client not verified yet");
|
|
126
|
-
}
|
|
127
|
-
return this.verificationDocument;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Access to OpenAI's chat completions API for creating chat conversations.
|
|
131
|
-
* Automatically initializes the client if needed.
|
|
132
|
-
*/
|
|
133
|
-
get chat() {
|
|
134
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.chat));
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Access to OpenAI's files API for managing files used with the API.
|
|
138
|
-
* Automatically initializes the client if needed.
|
|
139
|
-
*/
|
|
140
|
-
get files() {
|
|
141
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.files));
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Access to OpenAI's fine-tuning API for creating and managing fine-tuned models.
|
|
145
|
-
* Automatically initializes the client if needed.
|
|
146
|
-
*/
|
|
147
|
-
get fineTuning() {
|
|
148
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.fineTuning));
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Access to OpenAI's image generation and editing API.
|
|
152
|
-
* Automatically initializes the client if needed.
|
|
153
|
-
*/
|
|
154
|
-
get images() {
|
|
155
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.images));
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Access to OpenAI's audio API for speech-to-text and text-to-speech.
|
|
159
|
-
* Automatically initializes the client if needed.
|
|
160
|
-
*/
|
|
161
|
-
get audio() {
|
|
162
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.audio));
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Access to the Responses API, supporting response creation, streaming, and parsing.
|
|
166
|
-
* Automatically initializes the client if needed.
|
|
167
|
-
*/
|
|
168
|
-
get responses() {
|
|
169
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.responses));
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Access to OpenAI's embeddings API for creating vector embeddings of text.
|
|
173
|
-
* Automatically initializes the client if needed.
|
|
174
|
-
*/
|
|
175
|
-
get embeddings() {
|
|
176
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.embeddings));
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Access to OpenAI's models API for listing and managing available models.
|
|
180
|
-
* Automatically initializes the client if needed.
|
|
181
|
-
*/
|
|
182
|
-
get models() {
|
|
183
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.models));
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Access to OpenAI's content moderation API.
|
|
187
|
-
* Automatically initializes the client if needed.
|
|
188
|
-
*/
|
|
189
|
-
get moderations() {
|
|
190
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.moderations));
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Access to OpenAI's beta features.
|
|
194
|
-
* Automatically initializes the client if needed.
|
|
195
|
-
*/
|
|
196
|
-
get beta() {
|
|
197
|
-
return createAsyncProxy(this.ensureReady().then((client) => client.beta));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
exports.TinfoilAI = TinfoilAI;
|
|
201
|
-
// Namespace declaration merge to add OpenAI types to TinfoilAI
|
|
202
|
-
(function (TinfoilAI) {
|
|
203
|
-
// Re-export all OpenAI namespace types
|
|
204
|
-
TinfoilAI.Chat = openai_1.default.Chat;
|
|
205
|
-
TinfoilAI.Audio = openai_1.default.Audio;
|
|
206
|
-
TinfoilAI.Beta = openai_1.default.Beta;
|
|
207
|
-
TinfoilAI.Batches = openai_1.default.Batches;
|
|
208
|
-
TinfoilAI.Completions = openai_1.default.Completions;
|
|
209
|
-
TinfoilAI.Embeddings = openai_1.default.Embeddings;
|
|
210
|
-
TinfoilAI.Files = openai_1.default.Files;
|
|
211
|
-
TinfoilAI.FineTuning = openai_1.default.FineTuning;
|
|
212
|
-
TinfoilAI.Images = openai_1.default.Images;
|
|
213
|
-
TinfoilAI.Models = openai_1.default.Models;
|
|
214
|
-
TinfoilAI.Moderations = openai_1.default.Moderations;
|
|
215
|
-
TinfoilAI.Responses = openai_1.default.Responses;
|
|
216
|
-
TinfoilAI.Uploads = openai_1.default.Uploads;
|
|
217
|
-
TinfoilAI.VectorStores = openai_1.default.VectorStores;
|
|
218
|
-
})(TinfoilAI || (exports.TinfoilAI = TinfoilAI = {}));
|
package/dist/esm/client.d.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
import type { Audio, Beta, Chat, Embeddings, Files, FineTuning, Images, Models, Moderations, Responses } from "openai/resources";
|
|
3
|
-
import type { VerificationDocument } from "./verifier";
|
|
4
|
-
/**
|
|
5
|
-
* TinfoilAI is a wrapper around the OpenAI API client that adds additional
|
|
6
|
-
* security measures through enclave verification and an EHBP-secured transport.
|
|
7
|
-
*
|
|
8
|
-
* It provides:
|
|
9
|
-
* - Automatic verification of Tinfoil secure enclaves
|
|
10
|
-
* - EHBP-enforced transport security for each request
|
|
11
|
-
* - Type-safe access to OpenAI's chat completion APIs
|
|
12
|
-
*/
|
|
13
|
-
interface TinfoilAIOptions {
|
|
14
|
-
apiKey?: string;
|
|
15
|
-
/** Override the inference API base URL */
|
|
16
|
-
baseURL?: string;
|
|
17
|
-
/** Override the URL used to fetch the ENCLAVE key (defaults to baseURL) */
|
|
18
|
-
enclaveURL?: string;
|
|
19
|
-
/** Override the config GitHub repository */
|
|
20
|
-
configRepo?: string;
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
}
|
|
23
|
-
export declare class TinfoilAI {
|
|
24
|
-
private client?;
|
|
25
|
-
private clientPromise;
|
|
26
|
-
private readyPromise?;
|
|
27
|
-
private configRepo?;
|
|
28
|
-
private secureClient;
|
|
29
|
-
private verificationDocument?;
|
|
30
|
-
apiKey?: string;
|
|
31
|
-
baseURL?: string;
|
|
32
|
-
enclaveURL?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a new TinfoilAI instance.
|
|
35
|
-
* @param options - Configuration options including apiKey and other OpenAI client options
|
|
36
|
-
*/
|
|
37
|
-
constructor(options?: TinfoilAIOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Ensures the client is ready to use.
|
|
40
|
-
* @returns Promise that resolves when the client is initialized
|
|
41
|
-
*/
|
|
42
|
-
ready(): Promise<void>;
|
|
43
|
-
private initClient;
|
|
44
|
-
private createOpenAIClient;
|
|
45
|
-
/**
|
|
46
|
-
* Helper method to ensure the OpenAI client is initialized before use.
|
|
47
|
-
* Automatically calls ready() if needed.
|
|
48
|
-
* @returns The initialized OpenAI client
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
private ensureReady;
|
|
52
|
-
/**
|
|
53
|
-
* Returns the full verification document produced during client initialization.
|
|
54
|
-
*/
|
|
55
|
-
getVerificationDocument(): Promise<VerificationDocument>;
|
|
56
|
-
/**
|
|
57
|
-
* Access to OpenAI's chat completions API for creating chat conversations.
|
|
58
|
-
* Automatically initializes the client if needed.
|
|
59
|
-
*/
|
|
60
|
-
get chat(): Chat;
|
|
61
|
-
/**
|
|
62
|
-
* Access to OpenAI's files API for managing files used with the API.
|
|
63
|
-
* Automatically initializes the client if needed.
|
|
64
|
-
*/
|
|
65
|
-
get files(): Files;
|
|
66
|
-
/**
|
|
67
|
-
* Access to OpenAI's fine-tuning API for creating and managing fine-tuned models.
|
|
68
|
-
* Automatically initializes the client if needed.
|
|
69
|
-
*/
|
|
70
|
-
get fineTuning(): FineTuning;
|
|
71
|
-
/**
|
|
72
|
-
* Access to OpenAI's image generation and editing API.
|
|
73
|
-
* Automatically initializes the client if needed.
|
|
74
|
-
*/
|
|
75
|
-
get images(): Images;
|
|
76
|
-
/**
|
|
77
|
-
* Access to OpenAI's audio API for speech-to-text and text-to-speech.
|
|
78
|
-
* Automatically initializes the client if needed.
|
|
79
|
-
*/
|
|
80
|
-
get audio(): Audio;
|
|
81
|
-
/**
|
|
82
|
-
* Access to the Responses API, supporting response creation, streaming, and parsing.
|
|
83
|
-
* Automatically initializes the client if needed.
|
|
84
|
-
*/
|
|
85
|
-
get responses(): Responses;
|
|
86
|
-
/**
|
|
87
|
-
* Access to OpenAI's embeddings API for creating vector embeddings of text.
|
|
88
|
-
* Automatically initializes the client if needed.
|
|
89
|
-
*/
|
|
90
|
-
get embeddings(): Embeddings;
|
|
91
|
-
/**
|
|
92
|
-
* Access to OpenAI's models API for listing and managing available models.
|
|
93
|
-
* Automatically initializes the client if needed.
|
|
94
|
-
*/
|
|
95
|
-
get models(): Models;
|
|
96
|
-
/**
|
|
97
|
-
* Access to OpenAI's content moderation API.
|
|
98
|
-
* Automatically initializes the client if needed.
|
|
99
|
-
*/
|
|
100
|
-
get moderations(): Moderations;
|
|
101
|
-
/**
|
|
102
|
-
* Access to OpenAI's beta features.
|
|
103
|
-
* Automatically initializes the client if needed.
|
|
104
|
-
*/
|
|
105
|
-
get beta(): Beta;
|
|
106
|
-
}
|
|
107
|
-
export declare namespace TinfoilAI {
|
|
108
|
-
export import Chat = OpenAI.Chat;
|
|
109
|
-
export import Audio = OpenAI.Audio;
|
|
110
|
-
export import Beta = OpenAI.Beta;
|
|
111
|
-
export import Batches = OpenAI.Batches;
|
|
112
|
-
export import Completions = OpenAI.Completions;
|
|
113
|
-
export import Embeddings = OpenAI.Embeddings;
|
|
114
|
-
export import Files = OpenAI.Files;
|
|
115
|
-
export import FineTuning = OpenAI.FineTuning;
|
|
116
|
-
export import Images = OpenAI.Images;
|
|
117
|
-
export import Models = OpenAI.Models;
|
|
118
|
-
export import Moderations = OpenAI.Moderations;
|
|
119
|
-
export import Responses = OpenAI.Responses;
|
|
120
|
-
export import Uploads = OpenAI.Uploads;
|
|
121
|
-
export import VectorStores = OpenAI.VectorStores;
|
|
122
|
-
}
|
|
123
|
-
export {};
|