tinfoil 1.1.8 → 1.1.10
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 +201 -0
- package/dist/ai-sdk-provider.d.ts +8 -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/encrypted-body-fetch.d.ts +1 -1
- package/dist/encrypted-body-fetch.d.ts.map +1 -1
- package/dist/encrypted-body-fetch.js +6 -2
- package/dist/encrypted-body-fetch.js.map +1 -1
- package/dist/secure-client.d.ts +16 -0
- package/dist/secure-client.d.ts.map +1 -1
- package/dist/secure-client.js +9 -2
- package/dist/secure-client.js.map +1 -1
- package/dist/secure-fetch.d.ts +5 -1
- package/dist/secure-fetch.d.ts.map +1 -1
- package/dist/secure-fetch.js +10 -3
- package/dist/secure-fetch.js.map +1 -1
- package/dist/tinfoil-ai.d.ts +11 -0
- package/dist/tinfoil-ai.d.ts.map +1 -1
- package/dist/tinfoil-ai.js +1 -0
- package/dist/tinfoil-ai.js.map +1 -1
- package/dist/user-cache-secret-store.browser.d.ts +7 -0
- package/dist/user-cache-secret-store.browser.d.ts.map +1 -0
- package/dist/user-cache-secret-store.browser.js +9 -0
- package/dist/user-cache-secret-store.browser.js.map +1 -0
- package/dist/user-cache-secret-store.d.ts +19 -0
- package/dist/user-cache-secret-store.d.ts.map +1 -0
- package/dist/user-cache-secret-store.js +160 -0
- package/dist/user-cache-secret-store.js.map +1 -0
- package/dist/user-cache-secret.d.ts +62 -0
- package/dist/user-cache-secret.d.ts.map +1 -0
- package/dist/user-cache-secret.js +399 -0
- package/dist/user-cache-secret.js.map +1 -0
- package/package.json +22 -22
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,14 @@ 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
|
+
* attempts to generate a secret persisted at `~/.tinfoil/user_cache_secret`
|
|
18
|
+
* in Node.js. Browsers cannot persist it and use a process-lifetime
|
|
19
|
+
* in-memory secret instead. Empty values are treated as unset.
|
|
20
|
+
*/
|
|
21
|
+
userCacheSecret?: string;
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
24
|
* 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;
|
|
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,yGAyB1F"}
|
package/dist/ai-sdk-provider.js
CHANGED
|
@@ -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;
|
|
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,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,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;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;
|
|
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;AAIhF,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,CAgB7E;AAED,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,GACjB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,WAAW,CAAA;CAAE,CAuBrC;AAED,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.
|
|
@@ -58,7 +59,7 @@ export async function encryptedBodyRequest(input, hpkePublicKey, init, transport
|
|
|
58
59
|
return actualTransport.request(requestUrl, requestInit);
|
|
59
60
|
}
|
|
60
61
|
const ENCLAVE_URL_HEADER = 'X-Tinfoil-Enclave-Url';
|
|
61
|
-
export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
|
|
62
|
+
export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL, userCacheSecret = "") {
|
|
62
63
|
const base = new URL(baseURL);
|
|
63
64
|
const baseOrigin = base.origin;
|
|
64
65
|
const needsEnclaveHeader = !!enclaveURL && new URL(enclaveURL).origin !== baseOrigin;
|
|
@@ -87,7 +88,10 @@ export function createEncryptedBodyFetch(baseURL, hpkePublicKey, enclaveURL) {
|
|
|
87
88
|
if (needsEnclaveHeader) {
|
|
88
89
|
headers.set(ENCLAVE_URL_HEADER, enclaveURL);
|
|
89
90
|
}
|
|
90
|
-
|
|
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);
|
|
91
95
|
const transportInstance = await getOrCreateTransport();
|
|
92
96
|
return encryptedBodyRequest(targetUrl.toString(), hpkePublicKey, initWithHeader, transportInstance);
|
|
93
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;
|
|
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;AAC/D,OAAO,EAAE,oCAAoC,EAAE,MAAM,wBAAwB,CAAC;AAG9E,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,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEjD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,UAAU,CAAC,sDAAsD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACzD,IAAI,WAAW,KAAK,QAAQ,CAAC,eAAe,EAAE,CAAC;QAC7C,MAAM,IAAI,UAAU,CAAC,mEAAmE,QAAQ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,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACxF,CAAC;YACD,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC;YACzC,OAAO,SAAS,CAAC,uBAAuB,EAAE,CAAC;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"}
|
package/dist/secure-client.d.ts
CHANGED
|
@@ -40,6 +40,22 @@ 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
|
+
* Under the same authenticated API identity, requests carrying the same
|
|
46
|
+
* secret share cached prompt prefixes; requests carrying different
|
|
47
|
+
* identities or secrets cannot observe each other's cache timing.
|
|
48
|
+
*
|
|
49
|
+
* Defaults to the TINFOIL_USER_CACHE_SECRET environment variable when set,
|
|
50
|
+
* otherwise attempts to generate a secret persisted at
|
|
51
|
+
* `~/.tinfoil/user_cache_secret` in Node.js (shared with other Tinfoil SDKs
|
|
52
|
+
* using the same home directory). Browsers cannot persist it and use a
|
|
53
|
+
* process-lifetime in-memory secret instead. Empty values are treated as
|
|
54
|
+
* unset. A non-empty
|
|
55
|
+
* `user_cache_secret` field already present in a request body wins over this
|
|
56
|
+
* option.
|
|
57
|
+
*/
|
|
58
|
+
userCacheSecret?: string;
|
|
43
59
|
}
|
|
44
60
|
/**
|
|
45
61
|
* Low-level secure client providing a verified fetch function for custom HTTP requests.
|
|
@@ -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;
|
|
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;AAMtH,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,KAAK,EAAE,MAAM,IAAI,CAAC;AAG9B,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAK7D;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,0FAA0F;IAC1F,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAE1B,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,EAAE,MAAM,CA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bp";
|
|
|
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). */
|
|
@@ -104,6 +105,7 @@ export class SecureClient {
|
|
|
104
105
|
configRepo: options.configRepo ?? TINFOIL_CONFIG.DEFAULT_ROUTER_REPO,
|
|
105
106
|
transport: options.transport || 'ehbp',
|
|
106
107
|
attestationBundleURL: options.attestationBundleURL,
|
|
108
|
+
userCacheSecret: options.userCacheSecret,
|
|
107
109
|
};
|
|
108
110
|
this.verificationDocument = createPendingVerificationDocument(this.config.configRepo);
|
|
109
111
|
}
|
|
@@ -228,10 +230,15 @@ export class SecureClient {
|
|
|
228
230
|
return this.resolvedEnclaveURL ? `${this.resolvedEnclaveURL}/v1/` : undefined;
|
|
229
231
|
}
|
|
230
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 values fall through to the attempted persisted or generated default.
|
|
237
|
+
const userCacheSecret = await resolveUserCacheSecret(this.config.userCacheSecret);
|
|
231
238
|
if (this.config.transport === 'tls') {
|
|
232
|
-
return await createSecureFetch(this.resolvedBaseURL, undefined, tlsPublicKeyFingerprint, this.resolvedEnclaveURL);
|
|
239
|
+
return await createSecureFetch(this.resolvedBaseURL, undefined, tlsPublicKeyFingerprint, this.resolvedEnclaveURL, userCacheSecret);
|
|
233
240
|
}
|
|
234
|
-
return await createSecureFetch(this.resolvedBaseURL, hpkePublicKey, undefined, this.resolvedEnclaveURL);
|
|
241
|
+
return await createSecureFetch(this.resolvedBaseURL, hpkePublicKey, undefined, this.resolvedEnclaveURL, userCacheSecret);
|
|
235
242
|
}
|
|
236
243
|
/**
|
|
237
244
|
* Secure fetch function that encrypts request bodies end-to-end.
|
|
@@ -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;
|
|
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,wBAAwB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAIlD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,4DAA4D;AAC5D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AA+DjC,S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AAE,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
package/dist/secure-fetch.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/secure-fetch.js
CHANGED
|
@@ -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
|
|
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
|
},
|
package/dist/secure-fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secure-fetch.js","sourceRoot":"","sources":["../src/secure-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAwB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"secure-fetch.js","sourceRoot":"","sources":["../src/secure-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAwB,MAAM,2BAA2B,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,aAAsB,EACtB,uBAAgC,EAChC,UAAmB,EACnB,kBAA0B,EAAE;IAE5B,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,wBAAwB,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;IACvF,CAAC;IAED,IAAI,aAAa,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,kBAAkB,CAC1B,wFAAwF;YACxF,iEAAiE,CAClE,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC7B,MAAM,IAAI,kBAAkB,CAC1B,mFAAmF,CACpF,CAAC;IACJ,CAAC;IAED,6EAA6E;IAC7E,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;IACjF,OAAO;QACL,yEAAyE;QACzE,oEAAoE;QACpE,KAAK,EAAE,mBAAmB,CAAC,WAAW,EAAE,OAAO,EAAE,eAAe,CAAC;QACjE,KAAK,CAAC,uBAAuB;YAC3B,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;QACvF,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/tinfoil-ai.d.ts
CHANGED
|
@@ -53,6 +53,17 @@ export interface TinfoilAIOptions {
|
|
|
53
53
|
transport?: TransportMode;
|
|
54
54
|
/** URL to fetch the attestation bundle from. */
|
|
55
55
|
attestationBundleURL?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Secret scoping the router's prompt cache for this client's requests
|
|
58
|
+
* (e.g. one stable value per end user). Defaults to the
|
|
59
|
+
* TINFOIL_USER_CACHE_SECRET environment variable, otherwise attempts to
|
|
60
|
+
* generate a secret persisted at `~/.tinfoil/user_cache_secret` in Node.js.
|
|
61
|
+
* Browsers cannot persist it and use a process-lifetime in-memory secret
|
|
62
|
+
* instead. Empty values are treated as unset. A non-empty
|
|
63
|
+
* string field set in a request body wins; an empty per-request string is
|
|
64
|
+
* replaced with this value.
|
|
65
|
+
*/
|
|
66
|
+
userCacheSecret?: string;
|
|
56
67
|
/** Additional OpenAI client options (passed through to underlying client) */
|
|
57
68
|
[key: string]: any;
|
|
58
69
|
}
|
package/dist/tinfoil-ai.d.ts.map
CHANGED
|
@@ -1 +1 @@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
* to persist the secret in, so resolution attempts a process-lifetime
|
|
4
|
+
* in-memory secret.
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadOrPersistUserCacheSecret(_generateSecret: () => string): string | null;
|
|
7
|
+
//# sourceMappingURL=user-cache-secret-store.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-cache-secret-store.browser.d.ts","sourceRoot":"","sources":["../src/user-cache-secret-store.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,4BAA4B,CAAC,eAAe,EAAE,MAAM,MAAM,GAAG,MAAM,GAAG,IAAI,CAEzF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser build of the user-cache-secret store. Browsers have no filesystem
|
|
3
|
+
* to persist the secret in, so resolution attempts a process-lifetime
|
|
4
|
+
* in-memory secret.
|
|
5
|
+
*/
|
|
6
|
+
export function loadOrPersistUserCacheSecret(_generateSecret) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=user-cache-secret-store.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-cache-secret-store.browser.js","sourceRoot":"","sources":["../src/user-cache-secret-store.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,4BAA4B,CAAC,eAA6B;IACxE,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js persistence for the user cache secret. The other Tinfoil SDKs use
|
|
3
|
+
* the same file, so one machine gets one cache namespace across tools. The
|
|
4
|
+
* browser build swaps this module for a stub (see package.json's `browser`
|
|
5
|
+
* field) — browsers have no filesystem, so resolution attempts a
|
|
6
|
+
* process-lifetime in-memory secret.
|
|
7
|
+
*/
|
|
8
|
+
/** Directory under the home directory holding the secret file (mode 0700). */
|
|
9
|
+
export declare const USER_CACHE_SECRET_DIR_NAME = ".tinfoil";
|
|
10
|
+
/** Secret file name under the directory (mode 0600). */
|
|
11
|
+
export declare const USER_CACHE_SECRET_FILE_NAME = "user_cache_secret";
|
|
12
|
+
/**
|
|
13
|
+
* Returns the secret persisted under the user's home directory, generating
|
|
14
|
+
* (via `generateSecret`) and persisting one on first use. Returns null when
|
|
15
|
+
* the home directory is unavailable or unwritable — the caller attempts a
|
|
16
|
+
* process-lifetime in-memory secret. Never throws.
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadOrPersistUserCacheSecret(generateSecret: () => string): string | null;
|
|
19
|
+
//# sourceMappingURL=user-cache-secret-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-cache-secret-store.d.ts","sourceRoot":"","sources":["../src/user-cache-secret-store.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,aAAa,CAAC;AAErD,wDAAwD;AACxD,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAiE/D;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,cAAc,EAAE,MAAM,MAAM,GAAG,MAAM,GAAG,IAAI,CA+ExF"}
|