@zeke-02/tinfoil 0.0.4 → 0.0.5
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/esm/secure-fetch.mjs +2 -12
- package/dist/secure-fetch.js +2 -12
- package/package.json +1 -1
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import { createEncryptedBodyFetch } from "./encrypted-body-fetch.mjs";
|
|
2
|
-
import { createPinnedTlsFetch } from "./pinned-tls-fetch.mjs";
|
|
3
|
-
import { isRealBrowser } from "./env.mjs";
|
|
4
2
|
export function createSecureFetch(baseURL, enclaveURL, hpkePublicKey, tlsPublicKeyFingerprint) {
|
|
5
3
|
let fetchFunction;
|
|
6
4
|
if (hpkePublicKey) {
|
|
7
5
|
fetchFunction = createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL);
|
|
8
6
|
}
|
|
9
7
|
else {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throw new Error("HPKE public key not available and TLS-only verification is not supported in browsers. " +
|
|
13
|
-
"Only HPKE-enabled enclaves can be used in browser environments.");
|
|
14
|
-
}
|
|
15
|
-
// Node.js environment: fall back to TLS-only verification using pinned TLS fetch
|
|
16
|
-
if (!tlsPublicKeyFingerprint) {
|
|
17
|
-
throw new Error("Neither HPKE public key nor TLS public key fingerprint available for verification");
|
|
18
|
-
}
|
|
19
|
-
fetchFunction = createPinnedTlsFetch(baseURL, tlsPublicKeyFingerprint);
|
|
8
|
+
throw new Error("HPKE public key not available and TLS-only verification is not supported in browsers. " +
|
|
9
|
+
"Only HPKE-enabled enclaves can be used in browser environments.");
|
|
20
10
|
}
|
|
21
11
|
return fetchFunction;
|
|
22
12
|
}
|
package/dist/secure-fetch.js
CHANGED
|
@@ -2,24 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSecureFetch = createSecureFetch;
|
|
4
4
|
const encrypted_body_fetch_1 = require("./encrypted-body-fetch");
|
|
5
|
-
const pinned_tls_fetch_1 = require("./pinned-tls-fetch");
|
|
6
|
-
const env_1 = require("./env");
|
|
7
5
|
function createSecureFetch(baseURL, enclaveURL, hpkePublicKey, tlsPublicKeyFingerprint) {
|
|
8
6
|
let fetchFunction;
|
|
9
7
|
if (hpkePublicKey) {
|
|
10
8
|
fetchFunction = (0, encrypted_body_fetch_1.createEncryptedBodyFetch)(baseURL, hpkePublicKey, enclaveURL);
|
|
11
9
|
}
|
|
12
10
|
else {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error("HPKE public key not available and TLS-only verification is not supported in browsers. " +
|
|
16
|
-
"Only HPKE-enabled enclaves can be used in browser environments.");
|
|
17
|
-
}
|
|
18
|
-
// Node.js environment: fall back to TLS-only verification using pinned TLS fetch
|
|
19
|
-
if (!tlsPublicKeyFingerprint) {
|
|
20
|
-
throw new Error("Neither HPKE public key nor TLS public key fingerprint available for verification");
|
|
21
|
-
}
|
|
22
|
-
fetchFunction = (0, pinned_tls_fetch_1.createPinnedTlsFetch)(baseURL, tlsPublicKeyFingerprint);
|
|
11
|
+
throw new Error("HPKE public key not available and TLS-only verification is not supported in browsers. " +
|
|
12
|
+
"Only HPKE-enabled enclaves can be used in browser environments.");
|
|
23
13
|
}
|
|
24
14
|
return fetchFunction;
|
|
25
15
|
}
|