tinfoil 1.1.7 → 1.1.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work, excluding
103
+ those notices that do not pertain to any part of the Derivative
104
+ Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one of
111
+ the following places: within a NOTICE text file distributed as
112
+ part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions for
125
+ use, reproduction, or distribution of Your modifications, or for any
126
+ such Derivative Works as a whole, provided Your use, reproduction,
127
+ and distribution of the Work otherwise complies with the conditions
128
+ stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Tinfoil
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -11,6 +11,13 @@ export interface CreateTinfoilAIOptions {
11
11
  configRepo?: string;
12
12
  /** URL to fetch the attestation bundle from. */
13
13
  attestationBundleURL?: string;
14
+ /**
15
+ * Secret scoping the router's prompt cache for this provider's requests.
16
+ * Defaults to the TINFOIL_USER_CACHE_SECRET environment variable, otherwise
17
+ * to a generated secret persisted at `~/.tinfoil/user_cache_secret`. Pass
18
+ * an empty string to disable prompt-cache scoping (tenant-wide caching).
19
+ */
20
+ userCacheSecret?: string;
14
21
  }
15
22
  /**
16
23
  * Create a Tinfoil provider for the Vercel AI SDK.
@@ -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;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,yGAwB1F"}
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;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,yGAyB1F"}
@@ -45,6 +45,7 @@ export async function createTinfoilAI(apiKey, options = {}) {
45
45
  baseURL: options.baseURL,
46
46
  configRepo: options.configRepo,
47
47
  attestationBundleURL: options.attestationBundleURL,
48
+ userCacheSecret: options.userCacheSecret,
48
49
  });
49
50
  await secureClient.ready();
50
51
  return createOpenAICompatible({
@@ -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;AAmBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAe,EAAE,UAAkC,EAAE;IACzF,kFAAkF;IAClF,IAAI,cAAc,GAAG,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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AE,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;KAC1B,CAAC,CAAC;AACL,CAAC"}
@@ -15,7 +15,7 @@ export declare function normalizeEncryptedBodyRequestArgs(input: RequestInfo | U
15
15
  init?: RequestInit;
16
16
  };
17
17
  export declare function encryptedBodyRequest(input: RequestInfo | URL, hpkePublicKey: string, init?: RequestInit, transportInstance?: Transport): Promise<Response>;
18
- export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey: string, enclaveURL?: string): SecureTransport;
18
+ export declare function createEncryptedBodyFetch(baseURL: string, hpkePublicKey: string, enclaveURL?: string, userCacheSecret?: string): SecureTransport;
19
19
  /**
20
20
  * WARNING: THIS FUNCTION IS INSECURE.
21
21
  *
@@ -1 +1 @@
1
- {"version":3,"file":"encrypted-body-fetch.d.ts","sourceRoot":"","sources":["../src/encrypted-body-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAY,KAAK,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGhF,YAAY,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,MAAM,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,uBAAuB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC1D;AAUD;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoB7E;AAED,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,WA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AED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,aAAa,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,WAAW,EAClB,iBAAiB,CAAC,EAAE,SAAS,GAC5B,OAAO,CAAC,QAAQ,CAAC,CAgBnB;AAID,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,eAAe,GAAE,MAAW,GAAG,eAAe,CAyDnJ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CA2CvG"}
@@ -1,5 +1,6 @@
1
1
  import { Identity, Transport, PROTOCOL } from "ehbp";
2
2
  import { ConfigurationError, FetchError } from "./verifier.js";
3
+ import { injectUserCacheSecretIntoRequestInit } from "./user-cache-secret.js";
3
4
  export { decryptResponseWithToken } from "ehbp";
4
5
  /**
5
6
  * Create an Identity from a raw public key hex string.
@@ -14,9 +15,6 @@ async function createIdentityFromPublicKeyHex(publicKeyHex) {
14
15
  */
15
16
  export async function getServerIdentity(enclaveURL) {
16
17
  const keysURL = new URL(PROTOCOL.KEYS_PATH, enclaveURL);
17
- if (keysURL.protocol !== 'https:') {
18
- throw new ConfigurationError(`HTTPS is required for key retrieval. Got ${keysURL.protocol}`);
19
- }
20
18
  const response = await fetch(keysURL.toString());
21
19
  if (!response.ok) {
22
20
  throw new FetchError(`Failed to fetch HPKE public key from enclave: HTTP ${response.status}`);
@@ -61,11 +59,8 @@ export async function encryptedBodyRequest(input, hpkePublicKey, init, transport
61
59
  return actualTransport.request(requestUrl, requestInit);
62
60
  }
63
61
  const ENCLAVE_URL_HEADER = 'X-Tinfoil-Enclave-Url';
64
- export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
62
+ export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL, userCacheSecret = "") {
65
63
  const base = new URL(baseURL);
66
- if (base.protocol !== 'https:') {
67
- throw new ConfigurationError(`baseURL must use HTTPS. Got: ${baseURL}`);
68
- }
69
64
  const baseOrigin = base.origin;
70
65
  const needsEnclaveHeader = !!enclaveURL && new URL(enclaveURL).origin !== baseOrigin;
71
66
  // Bind requests to the verified enclave and the configured proxy. EHBP only
@@ -93,7 +88,10 @@ export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
93
88
  if (needsEnclaveHeader) {
94
89
  headers.set(ENCLAVE_URL_HEADER, enclaveURL);
95
90
  }
96
- const initWithHeader = { ...normalized.init, headers };
91
+ // The prompt-cache scoping field is added here — inside the origin
92
+ // guard and before the EHBP transport seals the body — so it is
93
+ // encrypted with the rest of the request.
94
+ const initWithHeader = await injectUserCacheSecretIntoRequestInit({ ...normalized.init, headers }, targetUrl.pathname, userCacheSecret);
97
95
  const transportInstance = await getOrCreateTransport();
98
96
  return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, initWithHeader, transportInstance);
99
97
  },
@@ -1 +1 @@
1
- {"version":3,"file":"encrypted-body-fetch.js","sourceRoot":"","sources":["../src/encrypted-body-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAA6B,MAAM,MAAM,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,MAAM,CAAC;AAOhD;;;GAGG;AACH,KAAK,UAAU,8BAA8B,CAAC,YAAoB;IAChE,OAAO,QAAQ,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,UAAkB;IACxD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAExD,IAAI,OAAO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QAC7C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,+BAA+B,CAAC,MAAc,EAAE,SAAiB;IAC9E,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;IACzC,OAAO,IAAI,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,MAAc,EAAE,gBAAwB;IAC3E,MAAM,cAAc,GAAG,MAAM,8BAA8B,CAAC,gBAAgB,CAAC,CAAC;IAC9E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;IACzC,OAAO,IAAI,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC"}
@@ -20,8 +20,8 @@ export type TransportMode = 'ehbp' | 'tls';
20
20
  export interface SecureClientOptions {
21
21
  /**
22
22
  * Override the base URL for API requests.
23
- * When set, requests are sent to this URL instead of directly to the enclave.
24
- * Useful for proxying requests through your own backend.
23
+ * This may be a proxy URL when using EHBP or a custom path on the enclave
24
+ * origin when using TLS pinning.
25
25
  * @see https://docs.tinfoil.sh/guides/proxy-server
26
26
  */
27
27
  baseURL?: string;
@@ -40,6 +40,21 @@ export interface SecureClientOptions {
40
40
  transport?: TransportMode;
41
41
  /** URL to fetch the attestation bundle from. */
42
42
  attestationBundleURL?: string;
43
+ /**
44
+ * Secret scoping the router's prompt cache for this client's requests.
45
+ * Requests carrying the same secret share cached prompt prefixes; requests
46
+ * carrying different secrets cannot observe each other's cache timing. The
47
+ * router consumes the secret to derive the cache namespace and strips it —
48
+ * it never reaches the model.
49
+ *
50
+ * Defaults to the TINFOIL_USER_CACHE_SECRET environment variable when set,
51
+ * otherwise to a generated secret persisted at `~/.tinfoil/user_cache_secret`
52
+ * (shared with the other Tinfoil SDKs on the same machine). Pass an empty
53
+ * string to disable prompt-cache scoping entirely (tenant-wide caching).
54
+ * A `user_cache_secret` field already present in a request body always
55
+ * wins over this option.
56
+ */
57
+ userCacheSecret?: string;
43
58
  }
44
59
  /**
45
60
  * Low-level secure client providing a verified fetch function for custom HTTP requests.
@@ -139,6 +154,10 @@ export declare class SecureClient {
139
154
  * Get the URL of the enclave endpoint, or undefined before ready().
140
155
  */
141
156
  getEnclaveURL(): string | undefined;
157
+ /**
158
+ * Get the direct API base URL of the enclave, or undefined before ready().
159
+ */
160
+ getEnclaveBaseURL(): string | undefined;
142
161
  private createTransport;
143
162
  /**
144
163
  * Secure fetch function that encrypts request bodies end-to-end.
@@ -174,8 +193,8 @@ export declare class SecureClient {
174
193
  *
175
194
  * WebSockets can't be covered by EHBP (it only seals HTTP bodies), so they
176
195
  * are secured by connecting directly to the enclave with the TLS connection
177
- * pinned to the attested key. That rules out browsers (no TLS cert access)
178
- * and proxy baseURLs (the proxy's certificate would not match the pin).
196
+ * pinned to the attested key. That rules out browsers, which do not expose
197
+ * TLS certificate details.
179
198
  */
180
199
  private requireWebSocketCapability;
181
200
  /**
@@ -190,7 +209,7 @@ export declare class SecureClient {
190
209
  * Opens a WebSocket to the verified enclave with the TLS connection pinned
191
210
  * to the attested enclave key.
192
211
  *
193
- * Node.js only. Not supported with a proxy `baseURL`.
212
+ * Node.js only. Connections are made directly to the verified enclave.
194
213
  *
195
214
  * The returned socket is a standard `ws` WebSocket in the CONNECTING state;
196
215
  * pinning failures surface as an `error` event. A pin failure drops the cached
@@ -1 +1 @@
1
- {"version":3,"file":"secure-client.d.ts","sourceRoot":"","sources":["../src/secure-client.ts"],"names":[],"mappings":"AACA,OAAO,EAA8D,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAKtH,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,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QAAQ,CAAC,MAAM,CAOrB;IAGF,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,kBAAkB,CAAC,CAAS;IACpC,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,OAAO,CAAC,+BAA+B,CAAC,CAAS;gBAErC,OAAO,GAAE,mBAAwB;IAwC7C;;;;;;;OAOG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBnC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;;;;;;;;;;;;;OAmBG;IACI,KAAK,IAAI,IAAI;YAKN,gBAAgB;IAqC9B;;;;;OAKG;IACI,uBAAuB,IAAI,oBAAoB;IAItD;;;;OAIG;IACI,UAAU,IAAI,MAAM,GAAG,SAAS;IAIvC;;OAEG;IACI,aAAa,IAAI,MAAM,GAAG,SAAS;IAI1C;;OAEG;IACI,iBAAiB,IAAI,MAAM,GAAG,SAAS;YAIhC,eAAe;IAc7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAI,KAAK,IAAI,OAAO,KAAK,CAgBxB;IAED;;;;;;OAMG;IACU,uBAAuB,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAOrE;;;;;;;;OAQG;YACW,0BAA0B;IAexC;;;;;;OAMG;IACU,yBAAyB,IAAI,OAAO,CAAC,EAAE,CAAC,aAAa,CAAC;IAMnE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACU,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC;CAgCpG"}
@@ -2,6 +2,7 @@ import { KeyConfigMismatchError } from "ehbp";
2
2
  import { Verifier, ConfigurationError, FetchError, AttestationError } from "./verifier.js";
3
3
  import { TINFOIL_CONFIG } from "./config.js";
4
4
  import { createSecureFetch } from "./secure-fetch.js";
5
+ import { resolveUserCacheSecret } from "./user-cache-secret.js";
5
6
  import { fetchAttestationBundle } from "./atc.js";
6
7
  import { isRealBrowser } from "./env.js";
7
8
  /** Delay before retrying init on transient failure (ms). */
@@ -69,25 +70,29 @@ export class SecureClient {
69
70
  // --- Derived state (cleared on reset) ---
70
71
  this.initPromise = null;
71
72
  this._transport = null;
72
- // Validate every provided URL, including the empty string: URL resolution
73
+ // Validate provided URLs, including the empty string: URL resolution
73
74
  // keeps "" (via ??) rather than falling back, so an unguarded empty value
74
75
  // would surface later as a confusing "Invalid URL" instead of a clear error.
76
+ if (options.baseURL !== undefined) {
77
+ let baseURL;
78
+ try {
79
+ baseURL = new URL(options.baseURL);
80
+ }
81
+ catch (cause) {
82
+ throw new ConfigurationError(`baseURL must be a valid HTTP(S) URL. Got: ${options.baseURL}`, {
83
+ cause: cause,
84
+ });
85
+ }
86
+ if (baseURL.protocol !== "http:" && baseURL.protocol !== "https:") {
87
+ throw new ConfigurationError(`baseURL must be a valid HTTP(S) URL. Got: ${options.baseURL}`);
88
+ }
89
+ }
75
90
  if (options.enclaveURL !== undefined && !options.enclaveURL.startsWith("https://")) {
76
91
  throw new ConfigurationError(`enclaveURL must use HTTPS. Got: ${options.enclaveURL}`);
77
92
  }
78
- // A proxy base URL and the attestation bundle URL both carry security-critical
79
- // traffic (plaintext headers and the entire trust root), so they must be HTTPS.
80
- if (options.baseURL !== undefined && !options.baseURL.startsWith("https://")) {
81
- throw new ConfigurationError(`baseURL must use HTTPS. Got: ${options.baseURL}`);
82
- }
83
93
  if (options.attestationBundleURL !== undefined && !options.attestationBundleURL.startsWith("https://")) {
84
94
  throw new ConfigurationError(`attestationBundleURL must use HTTPS. Got: ${options.attestationBundleURL}`);
85
95
  }
86
- // Routing through a proxy base URL relies on EHBP sealing the body to the
87
- // enclave; TLS certificate pinning would reject the proxy's certificate.
88
- if (options.baseURL && options.transport === 'tls') {
89
- throw new ConfigurationError("baseURL is only supported with the 'ehbp' transport");
90
- }
91
96
  if (options.configRepo && !options.enclaveURL) {
92
97
  throw new ConfigurationError("configRepo requires enclaveURL — without it, ATC always uses the default router repo.");
93
98
  }
@@ -100,6 +105,7 @@ export class SecureClient {
100
105
  configRepo: options.configRepo ?? TINFOIL_CONFIG.DEFAULT_ROUTER_REPO,
101
106
  transport: options.transport || 'ehbp',
102
107
  attestationBundleURL: options.attestationBundleURL,
108
+ userCacheSecret: options.userCacheSecret,
103
109
  };
104
110
  this.verificationDocument = createPendingVerificationDocument(this.config.configRepo);
105
111
  }
@@ -174,8 +180,13 @@ export class SecureClient {
174
180
  });
175
181
  // Resolve enclaveURL: user-provided config takes precedence, otherwise from bundle
176
182
  this.resolvedEnclaveURL = this.config.enclaveURL ?? `https://${bundle.domain}`;
177
- // Resolve baseURL: user-provided config (proxy) takes precedence, otherwise from enclave
178
- this.resolvedBaseURL = this.config.baseURL ?? `${this.resolvedEnclaveURL}/v1/`;
183
+ // Resolve baseURL: user-provided config takes precedence, otherwise use the enclave API
184
+ this.resolvedBaseURL = this.config.baseURL ?? this.getEnclaveBaseURL();
185
+ if (this.config.transport === 'tls' &&
186
+ this.config.baseURL &&
187
+ new URL(this.resolvedBaseURL).origin !== new URL(this.resolvedEnclaveURL).origin) {
188
+ throw new ConfigurationError("TLS transport requires baseURL to use the verified enclave origin");
189
+ }
179
190
  const verifier = new Verifier({
180
191
  configRepo: this.config.configRepo,
181
192
  });
@@ -212,11 +223,22 @@ export class SecureClient {
212
223
  getEnclaveURL() {
213
224
  return this.resolvedEnclaveURL;
214
225
  }
226
+ /**
227
+ * Get the direct API base URL of the enclave, or undefined before ready().
228
+ */
229
+ getEnclaveBaseURL() {
230
+ return this.resolvedEnclaveURL ? `${this.resolvedEnclaveURL}/v1/` : undefined;
231
+ }
215
232
  async createTransport(hpkePublicKey, tlsPublicKeyFingerprint) {
233
+ // The prompt-cache scoping secret: the userCacheSecret option wins, then
234
+ // the TINFOIL_USER_CACHE_SECRET environment variable, then the secret
235
+ // persisted at ~/.tinfoil/user_cache_secret (generated on first use).
236
+ // Empty means disabled; resolution never throws.
237
+ const userCacheSecret = await resolveUserCacheSecret(this.config.userCacheSecret);
216
238
  if (this.config.transport === 'tls') {
217
- return await createSecureFetch(this.resolvedBaseURL, undefined, tlsPublicKeyFingerprint, this.resolvedEnclaveURL);
239
+ return await createSecureFetch(this.resolvedBaseURL, undefined, tlsPublicKeyFingerprint, this.resolvedEnclaveURL, userCacheSecret);
218
240
  }
219
- return await createSecureFetch(this.resolvedBaseURL, hpkePublicKey, undefined, this.resolvedEnclaveURL);
241
+ return await createSecureFetch(this.resolvedBaseURL, hpkePublicKey, undefined, this.resolvedEnclaveURL, userCacheSecret);
220
242
  }
221
243
  /**
222
244
  * Secure fetch function that encrypts request bodies end-to-end.
@@ -273,19 +295,14 @@ export class SecureClient {
273
295
  *
274
296
  * WebSockets can't be covered by EHBP (it only seals HTTP bodies), so they
275
297
  * are secured by connecting directly to the enclave with the TLS connection
276
- * pinned to the attested key. That rules out browsers (no TLS cert access)
277
- * and proxy baseURLs (the proxy's certificate would not match the pin).
298
+ * pinned to the attested key. That rules out browsers, which do not expose
299
+ * TLS certificate details.
278
300
  */
279
301
  async requireWebSocketCapability() {
280
302
  if (isRealBrowser()) {
281
303
  throw new ConfigurationError("Verified WebSockets are not supported in browser environments: browsers do not " +
282
304
  "expose TLS certificate details, so the connection cannot be pinned to the attested enclave key.");
283
305
  }
284
- if (this.config.baseURL) {
285
- throw new ConfigurationError("WebSockets are not supported with a proxy baseURL: the connection is pinned to the " +
286
- "enclave's attested TLS key, which a TLS-terminating proxy cannot present. " +
287
- "Use a client without baseURL for realtime connections.");
288
- }
289
306
  await this.ready();
290
307
  if (!this.attestedTlsPublicKeyFingerprint) {
291
308
  throw new AttestationError("Attestation did not include a TLS public key fingerprint");
@@ -308,7 +325,7 @@ export class SecureClient {
308
325
  * Opens a WebSocket to the verified enclave with the TLS connection pinned
309
326
  * to the attested enclave key.
310
327
  *
311
- * Node.js only. Not supported with a proxy `baseURL`.
328
+ * Node.js only. Connections are made directly to the verified enclave.
312
329
  *
313
330
  * The returned socket is a standard `ws` WebSocket in the CONNECTING state;
314
331
  * pinning failures surface as an `error` event. A pin failure drops the cached
@@ -1 +1 @@
1
- {"version":3,"file":"secure-client.js","sourceRoot":"","sources":["../src/secure-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAA6B,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAIlD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,4DAA4D;AAC5D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AA8CjC,SAAS,iCAAiC,CAAC,UAAkB;IAC3D,OAAO;QACL,UAAU;QACV,WAAW,EAAE,EAAE;QACf,aAAa,EAAE,EAAE;QACjB,eAAe,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;QAC5C,kBAAkB,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE;QAChE,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,EAAE;QACjB,eAAe,EAAE,EAAE;QACnB,kBAAkB,EAAE,EAAE;QACtB,sBAAsB,EAAE,EAAE;QAC1B,gBAAgB,EAAE,KAAK;QACvB,KAAK,EAAE;YACL,WAAW,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;YAClC,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;YACjC,aAAa,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;YACpC,mBAAmB,EAAE,EAAE,MAAM,EAAE,S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M,IAAI,kBAAkB,CAAC,6DAA6D,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACjH,CAAC;QACD,wEAAwE;QACxE,sDAAsD;QACtD,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAChC,MAAM,IAAI,kBAAkB,CAC1B,oCAAoC,MAAM,CAAC,IAAI,kDAAkD,WAAW,EAAE,CAC/G,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QAEpF,iFAAiF;QACjF,gFAAgF;QAChF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE;YAClC,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;gBACpC,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -6,7 +6,11 @@ import { type SecureTransport } from "./encrypted-body-fetch.js";
6
6
  * - In browsers: Only HPKE encryption is supported (requires hpkePublicKey)
7
7
  * - In Node.js/Bun: Also supports TLS certificate pinning when configured
8
8
  *
9
+ * A non-empty userCacheSecret is injected into eligible request bodies inside
10
+ * the sealing boundary (EHBP body encryption or the pinned TLS connection),
11
+ * so the secret never travels outside the protected channel.
12
+ *
9
13
  * The pinned-tls-fetch import is dynamic to keep Node.js-only code out of browser bundles.
10
14
  */
11
- export declare function createSecureFetch(baseURL: string, hpkePublicKey?: string, tlsPublicKeyFingerprint?: string, enclaveURL?: string): Promise<SecureTransport>;
15
+ export declare function createSecureFetch(baseURL: string, hpkePublicKey?: string, tlsPublicKeyFingerprint?: string, enclaveURL?: string, userCacheSecret?: string): Promise<SecureTransport>;
12
16
  //# sourceMappingURL=secure-fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secure-fetch.d.ts","sourceRoot":"","sources":["../src/secure-fetch.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE3F;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,MAAM,EAChC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CA2B1B"}
1
+ {"version":3,"file":"secure-fetch.d.ts","sourceRoot":"","sources":["../src/secure-fetch.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG3F;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,MAAM,EAChC,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,MAAW,GAC3B,OAAO,CAAC,eAAe,CAAC,CA6B1B"}
@@ -1,6 +1,7 @@
1
1
  import { isRealBrowser } from "./env.js";
2
2
  import { ConfigurationError } from "./verifier.js";
3
3
  import { createEncryptedBodyFetch } from "./encrypted-body-fetch.js";
4
+ import { withUserCacheSecret } from "./user-cache-secret.js";
4
5
  /**
5
6
  * Creates a secure fetch function with either HPKE encryption or TLS pinning.
6
7
  *
@@ -8,11 +9,15 @@ import { createEncryptedBodyFetch } from "./encrypted-body-fetch.js";
8
9
  * - In browsers: Only HPKE encryption is supported (requires hpkePublicKey)
9
10
  * - In Node.js/Bun: Also supports TLS certificate pinning when configured
10
11
  *
12
+ * A non-empty userCacheSecret is injected into eligible request bodies inside
13
+ * the sealing boundary (EHBP body encryption or the pinned TLS connection),
14
+ * so the secret never travels outside the protected channel.
15
+ *
11
16
  * The pinned-tls-fetch import is dynamic to keep Node.js-only code out of browser bundles.
12
17
  */
13
- export async function createSecureFetch(baseURL, hpkePublicKey, tlsPublicKeyFingerprint, enclaveURL) {
18
+ export async function createSecureFetch(baseURL, hpkePublicKey, tlsPublicKeyFingerprint, enclaveURL, userCacheSecret = "") {
14
19
  if (hpkePublicKey) {
15
- return createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL);
20
+ return createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL, userCacheSecret);
16
21
  }
17
22
  if (isRealBrowser()) {
18
23
  throw new ConfigurationError("HPKE public key not available and TLS-only verification is not supported in browsers. " +
@@ -25,7 +30,9 @@ export async function createSecureFetch(baseURL, hpkePublicKey, tlsPublicKeyFing
25
30
  const { createPinnedTlsFetch } = await import("./pinned-tls-fetch.js");
26
31
  const pinnedFetch = await createPinnedTlsFetch(baseURL, tlsPublicKeyFingerprint);
27
32
  return {
28
- fetch: pinnedFetch,
33
+ // The cache-secret layer wraps the pinned fetch, so the field it injects
34
+ // only ever travels over the connection pinned to the attested key.
35
+ fetch: withUserCacheSecret(pinnedFetch, baseURL, userCacheSecret),
29
36
  async getSessionRecoveryToken() {
30
37
  throw new Error('Session recovery tokens are only available in EHBP transport mode');
31
38
  },