@zeke-02/tinfoil 0.0.8 → 0.0.9
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.
|
@@ -6,6 +6,7 @@ exports.encryptedBodyRequest = encryptedBodyRequest;
|
|
|
6
6
|
exports.createEncryptedBodyFetch = createEncryptedBodyFetch;
|
|
7
7
|
exports.getTransportForOrigin = getTransportForOrigin;
|
|
8
8
|
const ehbp_1 = require("@zeke-02/ehbp");
|
|
9
|
+
const fetch_adapter_1 = require("./fetch-adapter");
|
|
9
10
|
// Public API
|
|
10
11
|
async function getHPKEKey(enclaveURL) {
|
|
11
12
|
const url = new URL(enclaveURL);
|
|
@@ -13,7 +14,8 @@ async function getHPKEKey(enclaveURL) {
|
|
|
13
14
|
if (keysURL.protocol !== "https:") {
|
|
14
15
|
throw new Error(`HTTPS is required for remote key retrieval. Invalid protocol: ${keysURL.protocol}`);
|
|
15
16
|
}
|
|
16
|
-
const
|
|
17
|
+
const fetchFn = (0, fetch_adapter_1.getFetch)();
|
|
18
|
+
const response = await fetchFn(keysURL.toString());
|
|
17
19
|
if (!response.ok) {
|
|
18
20
|
throw new Error(`Failed to get server public key: ${response.status}`);
|
|
19
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Identity, Transport, PROTOCOL } from "@zeke-02/ehbp";
|
|
2
|
+
import { getFetch } from "./fetch-adapter.mjs";
|
|
2
3
|
// Public API
|
|
3
4
|
export async function getHPKEKey(enclaveURL) {
|
|
4
5
|
const url = new URL(enclaveURL);
|
|
@@ -6,7 +7,8 @@ export async function getHPKEKey(enclaveURL) {
|
|
|
6
7
|
if (keysURL.protocol !== "https:") {
|
|
7
8
|
throw new Error(`HTTPS is required for remote key retrieval. Invalid protocol: ${keysURL.protocol}`);
|
|
8
9
|
}
|
|
9
|
-
const
|
|
10
|
+
const fetchFn = getFetch();
|
|
11
|
+
const response = await fetchFn(keysURL.toString());
|
|
10
12
|
if (!response.ok) {
|
|
11
13
|
throw new Error(`Failed to get server public key: ${response.status}`);
|
|
12
14
|
}
|
|
@@ -124,7 +124,6 @@ export class SecureClient {
|
|
|
124
124
|
}
|
|
125
125
|
catch (error) {
|
|
126
126
|
if (this.verificationDocument) {
|
|
127
|
-
console.log("secure-client error", error);
|
|
128
127
|
const errorMessage = error.message;
|
|
129
128
|
if (errorMessage.includes("HPKE public key mismatch")) {
|
|
130
129
|
this.verificationDocument.steps.verifyHPKEKey = {
|
package/dist/esm/verifier.mjs
CHANGED
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
* - `suppressWasmLogs(suppress?)` → void - control WASM log output
|
|
66
66
|
*/
|
|
67
67
|
import { TINFOIL_CONFIG } from "./config.mjs";
|
|
68
|
+
import { getFetch } from "./fetch-adapter.mjs";
|
|
68
69
|
let cachedTextEncoder = null;
|
|
69
70
|
function getTextEncoder() {
|
|
70
71
|
if (!cachedTextEncoder) {
|
|
@@ -118,7 +119,8 @@ export class Verifier {
|
|
|
118
119
|
await initializeWasmGlobals();
|
|
119
120
|
const goInstance = new globalThis.Go();
|
|
120
121
|
// Load WASM module
|
|
121
|
-
const
|
|
122
|
+
const fetchFn = getFetch();
|
|
123
|
+
const wasmResponse = await fetchFn(Verifier.defaultWasmUrl);
|
|
122
124
|
if (!wasmResponse.ok) {
|
|
123
125
|
throw new Error(`Failed to fetch WASM: ${wasmResponse.status} ${wasmResponse.statusText}`);
|
|
124
126
|
}
|
package/dist/secure-client.js
CHANGED
|
@@ -127,7 +127,6 @@ class SecureClient {
|
|
|
127
127
|
}
|
|
128
128
|
catch (error) {
|
|
129
129
|
if (this.verificationDocument) {
|
|
130
|
-
console.log("secure-client error", error);
|
|
131
130
|
const errorMessage = error.message;
|
|
132
131
|
if (errorMessage.includes("HPKE public key mismatch")) {
|
|
133
132
|
this.verificationDocument.steps.verifyHPKEKey = {
|
package/dist/verifier.js
CHANGED
|
@@ -102,6 +102,7 @@ exports.suppressWasmLogs = suppressWasmLogs;
|
|
|
102
102
|
* - `suppressWasmLogs(suppress?)` → void - control WASM log output
|
|
103
103
|
*/
|
|
104
104
|
const config_1 = require("./config");
|
|
105
|
+
const fetch_adapter_1 = require("./fetch-adapter");
|
|
105
106
|
let cachedTextEncoder = null;
|
|
106
107
|
function getTextEncoder() {
|
|
107
108
|
if (!cachedTextEncoder) {
|
|
@@ -155,7 +156,8 @@ class Verifier {
|
|
|
155
156
|
await initializeWasmGlobals();
|
|
156
157
|
const goInstance = new globalThis.Go();
|
|
157
158
|
// Load WASM module
|
|
158
|
-
const
|
|
159
|
+
const fetchFn = (0, fetch_adapter_1.getFetch)();
|
|
160
|
+
const wasmResponse = await fetchFn(Verifier.defaultWasmUrl);
|
|
159
161
|
if (!wasmResponse.ok) {
|
|
160
162
|
throw new Error(`Failed to fetch WASM: ${wasmResponse.status} ${wasmResponse.statusText}`);
|
|
161
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeke-02/tinfoil",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Tinfoil secure OpenAI client wrapper for Tauri v2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -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.
|
|
89
|
+
"@zeke-02/ehbp": "^0.0.4",
|
|
90
90
|
"ai": "^5.0.19",
|
|
91
91
|
"dotenv": "^17.2.1",
|
|
92
92
|
"openai": "^5.13.1",
|