@tenuo/core 0.2.4-beta.0
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 +187 -0
- package/README.md +62 -0
- package/dist/api.d.ts +270 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +8 -0
- package/dist/api.js.map +1 -0
- package/dist/client.d.ts +18 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +417 -0
- package/dist/client.js.map +1 -0
- package/dist/constraints.d.ts +11 -0
- package/dist/constraints.d.ts.map +1 -0
- package/dist/constraints.js +32 -0
- package/dist/constraints.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +37 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/package.json +1 -0
- package/dist/generated/tenuo_wasm.d.ts +290 -0
- package/dist/generated/tenuo_wasm.js +1415 -0
- package/dist/generated/tenuo_wasm_bg.wasm +0 -0
- package/dist/generated/tenuo_wasm_bg.wasm.d.ts +58 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +4 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +258 -0
- package/dist/mcp.js.map +1 -0
- package/dist/nonce.d.ts +11 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/nonce.js +28 -0
- package/dist/nonce.js.map +1 -0
- package/dist/session.d.ts +19 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +50 -0
- package/dist/session.js.map +1 -0
- package/dist/wasm.d.ts +107 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +64 -0
- package/dist/wasm.js.map +1 -0
- package/package.json +64 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { createMcp } from "./mcp.js";
|
|
3
|
+
import { AuthorizationDeniedError, ApprovalRequiredError, TenuoConfigurationError, TenuoError } from "./errors.js";
|
|
4
|
+
import { Session, isSession, nativeSession } from "./session.js";
|
|
5
|
+
import { createDevContext, createVerifierContext, importSessionFromChain, importSessionFromWire, loadWasm, } from "./wasm.js";
|
|
6
|
+
const currentSession = new AsyncLocalStorage();
|
|
7
|
+
const toolPolicies = new WeakMap();
|
|
8
|
+
const wrappedInners = new WeakSet();
|
|
9
|
+
function nodeEnv() {
|
|
10
|
+
if (typeof process === "undefined") {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return process.env.NODE_ENV;
|
|
14
|
+
}
|
|
15
|
+
function allowDev() {
|
|
16
|
+
if (typeof process === "undefined") {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return process.env.TENUO_ALLOW_DEV === "1";
|
|
20
|
+
}
|
|
21
|
+
export function devRoot(options) {
|
|
22
|
+
const root = {
|
|
23
|
+
kind: "dev-root",
|
|
24
|
+
...(options?.allowInProduction === true ? { allowInProduction: true } : {}),
|
|
25
|
+
};
|
|
26
|
+
if (!devRootAllowed(root)) {
|
|
27
|
+
throw new TenuoConfigurationError(devRootBlockedMessage());
|
|
28
|
+
}
|
|
29
|
+
return root;
|
|
30
|
+
}
|
|
31
|
+
function devRootAllowed(root) {
|
|
32
|
+
if (root.allowInProduction === true || allowDev()) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const env = nodeEnv();
|
|
36
|
+
return env === "development" || env === "test";
|
|
37
|
+
}
|
|
38
|
+
function devRootBlockedMessage() {
|
|
39
|
+
return "createTenuo.devRoot() is for development. Set NODE_ENV=development or test, pass devRoot({ allowInProduction: true }), or TENUO_ALLOW_DEV=1. Unset NODE_ENV is not treated as development.";
|
|
40
|
+
}
|
|
41
|
+
function normalizeHex(value) {
|
|
42
|
+
const hex = value.trim().toLowerCase().replace(/^0x/, "");
|
|
43
|
+
if (!/^[0-9a-f]{64}$/.test(hex)) {
|
|
44
|
+
throw new TenuoConfigurationError("Trusted root must be a 32-byte hex public key (64 hex characters)");
|
|
45
|
+
}
|
|
46
|
+
return hex;
|
|
47
|
+
}
|
|
48
|
+
export function publicKeyFromEnv(name) {
|
|
49
|
+
if (name.length === 0) {
|
|
50
|
+
throw new TenuoConfigurationError("publicKeyFromEnv() requires an environment variable name");
|
|
51
|
+
}
|
|
52
|
+
if (typeof process === "undefined") {
|
|
53
|
+
throw new TenuoConfigurationError(`Environment variable ${name} is not available. Tenuo fails closed without a trusted root.`);
|
|
54
|
+
}
|
|
55
|
+
const value = process.env[name];
|
|
56
|
+
if (value === undefined || value.length === 0) {
|
|
57
|
+
throw new TenuoConfigurationError(`Environment variable ${name} is not set or empty. Tenuo fails closed without a trusted root.`);
|
|
58
|
+
}
|
|
59
|
+
return { kind: "public-key", source: "env", hex: normalizeHex(value) };
|
|
60
|
+
}
|
|
61
|
+
export function publicKeyFromHex(hex) {
|
|
62
|
+
return { kind: "public-key", source: "hex", hex: normalizeHex(hex) };
|
|
63
|
+
}
|
|
64
|
+
export function publicKeyFromBytes(bytes) {
|
|
65
|
+
if (bytes.length !== 32) {
|
|
66
|
+
throw new TenuoConfigurationError("publicKeyFromBytes() requires a 32-byte public key");
|
|
67
|
+
}
|
|
68
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
69
|
+
return { kind: "public-key", source: "bytes", hex };
|
|
70
|
+
}
|
|
71
|
+
function normalizeSecretHex(value) {
|
|
72
|
+
const hex = value.trim().toLowerCase().replace(/^0x/, "");
|
|
73
|
+
if (!/^[0-9a-f]{64}$/.test(hex)) {
|
|
74
|
+
throw new TenuoConfigurationError("Holder key must be a 32-byte hex secret (64 hex characters)");
|
|
75
|
+
}
|
|
76
|
+
return hex;
|
|
77
|
+
}
|
|
78
|
+
function hexToBytes(hex) {
|
|
79
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
80
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
81
|
+
bytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
82
|
+
}
|
|
83
|
+
return bytes;
|
|
84
|
+
}
|
|
85
|
+
export function holderKeyFromEnv(name) {
|
|
86
|
+
if (name.length === 0) {
|
|
87
|
+
throw new TenuoConfigurationError("holderKeyFromEnv() requires an environment variable name");
|
|
88
|
+
}
|
|
89
|
+
if (typeof process === "undefined") {
|
|
90
|
+
throw new TenuoConfigurationError(`Environment variable ${name} is not available. Tenuo fails closed without a holder key.`);
|
|
91
|
+
}
|
|
92
|
+
const value = process.env[name];
|
|
93
|
+
if (value === undefined || value.length === 0) {
|
|
94
|
+
throw new TenuoConfigurationError(`Environment variable ${name} is not set or empty. Tenuo fails closed without a holder key.`);
|
|
95
|
+
}
|
|
96
|
+
return hexToBytes(normalizeSecretHex(value));
|
|
97
|
+
}
|
|
98
|
+
export function holderKeyFromHex(hex) {
|
|
99
|
+
return hexToBytes(normalizeSecretHex(hex));
|
|
100
|
+
}
|
|
101
|
+
function rootHexes(options) {
|
|
102
|
+
const handles = [];
|
|
103
|
+
if (options.root !== undefined && options.root.kind === "public-key") {
|
|
104
|
+
handles.push(options.root);
|
|
105
|
+
}
|
|
106
|
+
for (const root of options.trustedRoots ?? []) {
|
|
107
|
+
handles.push(root);
|
|
108
|
+
}
|
|
109
|
+
return handles.map((h) => h.hex);
|
|
110
|
+
}
|
|
111
|
+
function hasTrustAnchor(options) {
|
|
112
|
+
if (options.root !== undefined) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return (options.trustedRoots?.length ?? 0) > 0;
|
|
116
|
+
}
|
|
117
|
+
function capabilityName(inner, policy) {
|
|
118
|
+
if (policy.capability !== undefined && policy.capability.length > 0) {
|
|
119
|
+
return policy.capability;
|
|
120
|
+
}
|
|
121
|
+
const named = inner;
|
|
122
|
+
if (typeof named.name === "string" && named.name.length > 0) {
|
|
123
|
+
return named.name;
|
|
124
|
+
}
|
|
125
|
+
if (typeof named.id === "string" && named.id.length > 0) {
|
|
126
|
+
return named.id;
|
|
127
|
+
}
|
|
128
|
+
throw new TenuoConfigurationError("tenuo.tool() needs a capability name (policy.capability, or tool.name / tool.id)");
|
|
129
|
+
}
|
|
130
|
+
class TenuoClient {
|
|
131
|
+
context;
|
|
132
|
+
canMint;
|
|
133
|
+
mcp;
|
|
134
|
+
constructor(options) {
|
|
135
|
+
if (options.root?.kind === "dev-root") {
|
|
136
|
+
this.context = createDevContext();
|
|
137
|
+
this.canMint = true;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.context = createVerifierContext(rootHexes(options));
|
|
141
|
+
this.canMint = false;
|
|
142
|
+
}
|
|
143
|
+
if (options.revocationList !== undefined) {
|
|
144
|
+
this.context.loadRevocationList(normalizeWireBytes(options.revocationList));
|
|
145
|
+
}
|
|
146
|
+
this.mcp = createMcp(this.context, (decision, tool) => applyDecision(decision, tool));
|
|
147
|
+
}
|
|
148
|
+
tool(inner, policy) {
|
|
149
|
+
if (toolPolicies.has(inner) || wrappedInners.has(inner)) {
|
|
150
|
+
throw new TenuoConfigurationError("tenuo.tool() already wrapped this tool");
|
|
151
|
+
}
|
|
152
|
+
const capability = capabilityName(inner, policy);
|
|
153
|
+
const original = inner.execute;
|
|
154
|
+
const execute = async (args, callOptions) => {
|
|
155
|
+
const session = resolveSession(callOptions);
|
|
156
|
+
const decision = this.context.authorize(nativeSession(session), capability, args, approvalsFrom(callOptions), policy.allow, requestIdFrom(callOptions));
|
|
157
|
+
emitReceipt(callOptions, decision.receipt);
|
|
158
|
+
if (decision.outcome === "allow") {
|
|
159
|
+
return original(plainArgs(decision.args), forwardExecuteOptions(callOptions));
|
|
160
|
+
}
|
|
161
|
+
if (decision.outcome === "approval_required") {
|
|
162
|
+
throw new ApprovalRequiredError(decision.tool ?? capability, decision.required ?? 1, decision.received ?? 0, decision.message);
|
|
163
|
+
}
|
|
164
|
+
throw new AuthorizationDeniedError(decision.code ?? "TENUO_TOOL_NOT_AUTHORIZED", explainDeny(decision.message ?? "Authorization denied", decision.field), decision.field);
|
|
165
|
+
};
|
|
166
|
+
const wrapped = Object.assign(Object.create(Object.getPrototypeOf(inner)), inner, {
|
|
167
|
+
execute,
|
|
168
|
+
});
|
|
169
|
+
wrappedInners.add(inner);
|
|
170
|
+
toolPolicies.set(wrapped, { capability, allow: { ...policy.allow } });
|
|
171
|
+
return wrapped;
|
|
172
|
+
}
|
|
173
|
+
session(input) {
|
|
174
|
+
const allow = collectSessionAllow(input);
|
|
175
|
+
if (Object.keys(allow).length === 0) {
|
|
176
|
+
throw new TenuoConfigurationError("tenuo.session() requires tools from tenuo.tool() or at least one capability in allow");
|
|
177
|
+
}
|
|
178
|
+
if (!this.canMint) {
|
|
179
|
+
throw new TenuoConfigurationError("session() mints a warrant and needs a local issuer. Use createTenuo({ root: createTenuo.devRoot() }).");
|
|
180
|
+
}
|
|
181
|
+
const ttl = input.ttlSeconds ?? 0;
|
|
182
|
+
if (input.requireApproval !== undefined) {
|
|
183
|
+
if (input.requireApproval.approvers.length === 0) {
|
|
184
|
+
throw new TenuoConfigurationError("requireApproval.approvers must not be empty");
|
|
185
|
+
}
|
|
186
|
+
if (input.requireApproval.min < 1) {
|
|
187
|
+
throw new TenuoConfigurationError("requireApproval.min must be at least 1");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const native = this.context.mint(allow, ttl, requireApprovalJson(input.requireApproval));
|
|
191
|
+
return new Session(native);
|
|
192
|
+
}
|
|
193
|
+
sessionFromWire(input) {
|
|
194
|
+
if (!(input.holderKey instanceof Uint8Array) || input.holderKey.length !== 32) {
|
|
195
|
+
throw new TenuoConfigurationError("sessionFromWire() requires a 32-byte holderKey");
|
|
196
|
+
}
|
|
197
|
+
if (typeof input.warrant === "string" && input.warrant.trim().length === 0) {
|
|
198
|
+
throw new TenuoConfigurationError("sessionFromWire() requires a warrant");
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
if (typeof input.warrant === "string") {
|
|
202
|
+
return new Session(importSessionFromWire(input.warrant, input.holderKey));
|
|
203
|
+
}
|
|
204
|
+
if (input.warrant.length === 0) {
|
|
205
|
+
throw new TenuoConfigurationError("sessionFromWire() requires a warrant");
|
|
206
|
+
}
|
|
207
|
+
return new Session(importSessionFromChain([...input.warrant], input.holderKey));
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
throw importWireError(error);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
withSession(session, fn) {
|
|
214
|
+
if (!isSession(session)) {
|
|
215
|
+
throw new TenuoConfigurationError("withSession() requires a Tenuo Session, not a plain object");
|
|
216
|
+
}
|
|
217
|
+
return currentSession.run(session, fn);
|
|
218
|
+
}
|
|
219
|
+
narrow(session, allow) {
|
|
220
|
+
if (Object.keys(allow).length === 0) {
|
|
221
|
+
throw new TenuoConfigurationError("tenuo.narrow() requires a non-empty allow policy");
|
|
222
|
+
}
|
|
223
|
+
if (!isSession(session)) {
|
|
224
|
+
throw new TenuoConfigurationError("narrow() requires a Tenuo Session, not a plain object");
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
return new Session(this.context.narrow(nativeSession(session), allow));
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
231
|
+
if (message.startsWith("TENUO_CHAIN_INVALID")) {
|
|
232
|
+
throw new AuthorizationDeniedError("TENUO_CHAIN_INVALID", message);
|
|
233
|
+
}
|
|
234
|
+
throw new TenuoConfigurationError(message);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
revoke(list) {
|
|
238
|
+
this.context.loadRevocationList(normalizeWireBytes(list));
|
|
239
|
+
}
|
|
240
|
+
ready() {
|
|
241
|
+
loadWasm();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function plainArgs(value) {
|
|
245
|
+
if (value instanceof Map) {
|
|
246
|
+
return Object.fromEntries(value);
|
|
247
|
+
}
|
|
248
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
249
|
+
return { ...value };
|
|
250
|
+
}
|
|
251
|
+
return {};
|
|
252
|
+
}
|
|
253
|
+
function requireApprovalJson(require) {
|
|
254
|
+
if (require === undefined) {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
const payload = {
|
|
258
|
+
approvers: require.approvers.map((approver) => approver.hex),
|
|
259
|
+
min: require.min,
|
|
260
|
+
};
|
|
261
|
+
if (require.tools !== undefined) {
|
|
262
|
+
payload.tools = [...require.tools];
|
|
263
|
+
}
|
|
264
|
+
return payload;
|
|
265
|
+
}
|
|
266
|
+
function applyDecision(decision, tool) {
|
|
267
|
+
if (decision.outcome === "allow") {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (decision.outcome === "approval_required") {
|
|
271
|
+
throw new ApprovalRequiredError(decision.tool ?? tool, decision.required ?? 1, decision.received ?? 0, decision.message);
|
|
272
|
+
}
|
|
273
|
+
throw new AuthorizationDeniedError(decision.code ?? "TENUO_TOOL_NOT_AUTHORIZED", explainDeny(decision.message ?? "Authorization denied", decision.field), decision.field);
|
|
274
|
+
}
|
|
275
|
+
function explainDeny(message, field) {
|
|
276
|
+
if (!message.includes("unknown field not allowed")) {
|
|
277
|
+
return message;
|
|
278
|
+
}
|
|
279
|
+
const named = field !== undefined && field.length > 0 ? `'${field}'` : "this argument";
|
|
280
|
+
return `${message}. Zero-trust: name ${named} in allow (e.g. ${named}: pattern("*")), or drop it from the call. Empty allow: {} adds no extra ceiling.`;
|
|
281
|
+
}
|
|
282
|
+
function forwardExecuteOptions(callOptions) {
|
|
283
|
+
if (callOptions === null || typeof callOptions !== "object") {
|
|
284
|
+
return callOptions;
|
|
285
|
+
}
|
|
286
|
+
const rest = {};
|
|
287
|
+
for (const [key, value] of Object.entries(callOptions)) {
|
|
288
|
+
if (key === "session" ||
|
|
289
|
+
key === "approvals" ||
|
|
290
|
+
key === "onReceipt" ||
|
|
291
|
+
key === "requestId") {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
rest[key] = value;
|
|
295
|
+
}
|
|
296
|
+
return Object.keys(rest).length === 0 ? undefined : rest;
|
|
297
|
+
}
|
|
298
|
+
function importWireError(error) {
|
|
299
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
300
|
+
if (message.startsWith("TENUO_CHAIN_INVALID") || message.includes("invalid warrant")) {
|
|
301
|
+
return new TenuoError("TENUO_CHAIN_INVALID", message);
|
|
302
|
+
}
|
|
303
|
+
if (message.startsWith("TENUO_SIGNATURE_INVALID")) {
|
|
304
|
+
return new TenuoError("TENUO_SIGNATURE_INVALID", message);
|
|
305
|
+
}
|
|
306
|
+
if (message.startsWith("TENUO_UNTRUSTED_ROOT")) {
|
|
307
|
+
return new TenuoError("TENUO_UNTRUSTED_ROOT", message);
|
|
308
|
+
}
|
|
309
|
+
return new TenuoConfigurationError(message);
|
|
310
|
+
}
|
|
311
|
+
function normalizeWireBytes(value) {
|
|
312
|
+
if (typeof value === "string") {
|
|
313
|
+
return value;
|
|
314
|
+
}
|
|
315
|
+
return Array.from(value, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
316
|
+
}
|
|
317
|
+
function emitReceipt(callOptions, receipt) {
|
|
318
|
+
if (receipt === undefined || callOptions === null || typeof callOptions !== "object") {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (!("onReceipt" in callOptions)) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const onReceipt = callOptions.onReceipt;
|
|
325
|
+
if (typeof onReceipt !== "function") {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
const result = onReceipt(receipt);
|
|
330
|
+
if (result !== null && typeof result === "object" && "then" in result && typeof result.then === "function") {
|
|
331
|
+
void Promise.resolve(result).catch(() => undefined);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
// Receipt hooks must not deny or fail the tool.
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function requestIdFrom(callOptions) {
|
|
339
|
+
if (callOptions !== null && typeof callOptions === "object" && "requestId" in callOptions) {
|
|
340
|
+
const value = callOptions.requestId;
|
|
341
|
+
if (typeof value === "string" && value.length > 0) {
|
|
342
|
+
return value;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
function approvalsFrom(callOptions) {
|
|
348
|
+
if (callOptions !== null && typeof callOptions === "object" && "approvals" in callOptions) {
|
|
349
|
+
return callOptions.approvals;
|
|
350
|
+
}
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
function resolveSession(callOptions) {
|
|
354
|
+
if (callOptions !== null && typeof callOptions === "object" && "session" in callOptions) {
|
|
355
|
+
const explicit = callOptions.session;
|
|
356
|
+
if (!isSession(explicit)) {
|
|
357
|
+
throw new TenuoConfigurationError("options.session must be a Tenuo Session");
|
|
358
|
+
}
|
|
359
|
+
return explicit;
|
|
360
|
+
}
|
|
361
|
+
const ambient = currentSession.getStore();
|
|
362
|
+
if (ambient === undefined) {
|
|
363
|
+
throw new TenuoConfigurationError("No session. Wrap the call in tenuo.withSession(session, ...) or pass { session }.");
|
|
364
|
+
}
|
|
365
|
+
return ambient;
|
|
366
|
+
}
|
|
367
|
+
function collectSessionAllow(input) {
|
|
368
|
+
const allow = { ...(input.allow ?? {}) };
|
|
369
|
+
for (const tool of input.tools ?? []) {
|
|
370
|
+
if (tool === null || typeof tool !== "object") {
|
|
371
|
+
throw new TenuoConfigurationError("session({ tools }) requires tools from tenuo.tool()");
|
|
372
|
+
}
|
|
373
|
+
const policy = toolPolicies.get(tool);
|
|
374
|
+
if (policy === undefined) {
|
|
375
|
+
throw new TenuoConfigurationError("session({ tools }) requires tools from tenuo.tool()");
|
|
376
|
+
}
|
|
377
|
+
const existing = allow[policy.capability];
|
|
378
|
+
if (existing !== undefined && !sameAllow(existing, policy.allow)) {
|
|
379
|
+
throw new TenuoConfigurationError(`session() allow and tools disagree on ${policy.capability}`);
|
|
380
|
+
}
|
|
381
|
+
allow[policy.capability] = policy.allow;
|
|
382
|
+
}
|
|
383
|
+
return allow;
|
|
384
|
+
}
|
|
385
|
+
function sameAllow(left, right) {
|
|
386
|
+
return JSON.stringify(sortedAllow(left)) === JSON.stringify(sortedAllow(right));
|
|
387
|
+
}
|
|
388
|
+
function sortedAllow(allow) {
|
|
389
|
+
const keys = Object.keys(allow).sort();
|
|
390
|
+
const out = {};
|
|
391
|
+
for (const key of keys) {
|
|
392
|
+
const value = allow[key];
|
|
393
|
+
if (value !== undefined) {
|
|
394
|
+
out[key] = value;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return out;
|
|
398
|
+
}
|
|
399
|
+
function createTenuoImpl(options = {}) {
|
|
400
|
+
if (!hasTrustAnchor(options)) {
|
|
401
|
+
throw new TenuoConfigurationError("createTenuo() requires trustedRoots or root: createTenuo.devRoot(). An empty trust set is not a configuration.");
|
|
402
|
+
}
|
|
403
|
+
if (options.root?.kind === "dev-root" && !devRootAllowed(options.root)) {
|
|
404
|
+
throw new TenuoConfigurationError(devRootBlockedMessage());
|
|
405
|
+
}
|
|
406
|
+
loadWasm();
|
|
407
|
+
return new TenuoClient(options);
|
|
408
|
+
}
|
|
409
|
+
export const createTenuo = Object.assign(createTenuoImpl, {
|
|
410
|
+
devRoot,
|
|
411
|
+
publicKeyFromEnv,
|
|
412
|
+
publicKeyFromHex,
|
|
413
|
+
publicKeyFromBytes,
|
|
414
|
+
holderKeyFromEnv,
|
|
415
|
+
holderKeyFromHex,
|
|
416
|
+
});
|
|
417
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAerD,OAAO,EAAE,SAAS,EAAE,MAAM,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AAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAOpB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IACjC,OAAO;IACP,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;CACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EmailConstraint, ExactConstraint, MaxConstraint, OneOfConstraint, PatternConstraint, UnderConstraint } from "./api.ts";
|
|
2
|
+
/** Directory prefix. Evaluated in core as Subpath — not a string prefix check in TS. */
|
|
3
|
+
export declare function under(root: string): UnderConstraint;
|
|
4
|
+
export declare function email(options: {
|
|
5
|
+
domain: string;
|
|
6
|
+
}): EmailConstraint;
|
|
7
|
+
export declare function max(value: number): MaxConstraint;
|
|
8
|
+
export declare function oneOf(values: readonly string[]): OneOfConstraint;
|
|
9
|
+
export declare function pattern(pattern: string): PatternConstraint;
|
|
10
|
+
export declare function exact(value: string | number | boolean): ExactConstraint;
|
|
11
|
+
//# sourceMappingURL=constraints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../src/constraints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,wFAAwF;AACxF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAKnD;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CAElE;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAKhD;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,eAAe,CAKhE;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAK1D;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAEvE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Directory prefix. Evaluated in core as Subpath — not a string prefix check in TS. */
|
|
2
|
+
export function under(root) {
|
|
3
|
+
if (!root.startsWith("/")) {
|
|
4
|
+
throw new Error("tenuo.under() expects an absolute path (start with /)");
|
|
5
|
+
}
|
|
6
|
+
return { kind: "under", root };
|
|
7
|
+
}
|
|
8
|
+
export function email(options) {
|
|
9
|
+
return { kind: "email", domain: options.domain };
|
|
10
|
+
}
|
|
11
|
+
export function max(value) {
|
|
12
|
+
if (!Number.isFinite(value)) {
|
|
13
|
+
throw new Error("tenuo.max() requires a finite number");
|
|
14
|
+
}
|
|
15
|
+
return { kind: "max", value };
|
|
16
|
+
}
|
|
17
|
+
export function oneOf(values) {
|
|
18
|
+
if (values.length === 0) {
|
|
19
|
+
throw new Error("tenuo.oneOf() requires at least one value");
|
|
20
|
+
}
|
|
21
|
+
return { kind: "oneOf", values };
|
|
22
|
+
}
|
|
23
|
+
export function pattern(pattern) {
|
|
24
|
+
if (pattern.length === 0) {
|
|
25
|
+
throw new Error("tenuo.pattern() requires a non-empty pattern");
|
|
26
|
+
}
|
|
27
|
+
return { kind: "pattern", pattern };
|
|
28
|
+
}
|
|
29
|
+
export function exact(value) {
|
|
30
|
+
return { kind: "exact", value };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=constraints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraints.js","sourceRoot":"","sources":["../src/constraints.ts"],"names":[],"mappings":"AASA,wFAAwF;AACxF,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAA2B;IAC/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,KAAa;IAC/B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,MAAyB;IAC7C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,KAAgC;IACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TenuoErrorCode } from "./api.ts";
|
|
2
|
+
export declare class TenuoError extends Error {
|
|
3
|
+
readonly code: TenuoErrorCode;
|
|
4
|
+
constructor(code: TenuoErrorCode, message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class TenuoConfigurationError extends TenuoError {
|
|
7
|
+
constructor(message: string, code?: TenuoErrorCode);
|
|
8
|
+
}
|
|
9
|
+
export declare class AuthorizationDeniedError extends TenuoError {
|
|
10
|
+
readonly field?: string;
|
|
11
|
+
constructor(code: TenuoErrorCode, message: string, field?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class ApprovalRequiredError extends TenuoError {
|
|
14
|
+
readonly tool: string;
|
|
15
|
+
readonly required: number;
|
|
16
|
+
readonly received: number;
|
|
17
|
+
constructor(tool: string, required: number, received: number, message?: string);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;gBAElB,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;CAKlD;AAED,qBAAa,uBAAwB,SAAQ,UAAU;gBACzC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,cAAsC;CAI1E;AAED,qBAAa,wBAAyB,SAAQ,UAAU;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAOlE;AAED,qBAAa,qBAAsB,SAAQ,UAAU;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAO/E"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class TenuoError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(code, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "TenuoError";
|
|
6
|
+
this.code = code;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class TenuoConfigurationError extends TenuoError {
|
|
10
|
+
constructor(message, code = "TENUO_CONFIGURATION") {
|
|
11
|
+
super(code, message);
|
|
12
|
+
this.name = "TenuoConfigurationError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class AuthorizationDeniedError extends TenuoError {
|
|
16
|
+
field;
|
|
17
|
+
constructor(code, message, field) {
|
|
18
|
+
super(code, message);
|
|
19
|
+
this.name = "AuthorizationDeniedError";
|
|
20
|
+
if (field !== undefined) {
|
|
21
|
+
this.field = field;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class ApprovalRequiredError extends TenuoError {
|
|
26
|
+
tool;
|
|
27
|
+
required;
|
|
28
|
+
received;
|
|
29
|
+
constructor(tool, required, received, message) {
|
|
30
|
+
super("TENUO_APPROVAL_REQUIRED", message ?? `Approval required for ${tool}`);
|
|
31
|
+
this.name = "ApprovalRequiredError";
|
|
32
|
+
this.tool = tool;
|
|
33
|
+
this.required = required;
|
|
34
|
+
this.received = received;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,CAAiB;IAE9B,YAAY,IAAoB,EAAE,OAAe;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GA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