@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/LICENSE
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
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 made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as defined by the copyright owner, any
|
|
48
|
+
work of authorship, including the original version of the Work and
|
|
49
|
+
any modifications or additions to that Work or Derivative Works of
|
|
50
|
+
the Work, submitted to the Licensor for inclusion in the Work by the
|
|
51
|
+
copyright owner or by an individual or Legal Entity authorized to
|
|
52
|
+
submit on behalf of the copyright owner. For the purposes of this
|
|
53
|
+
definition, "submitted" means any form of electronic, verbal, or
|
|
54
|
+
written communication sent to the Licensor or its representatives,
|
|
55
|
+
including but not limited to communication on electronic mailing lists,
|
|
56
|
+
source code control systems, and issue tracking systems that are managed
|
|
57
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
58
|
+
improving the Work, but excluding communication that is conspicuously
|
|
59
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
60
|
+
Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
63
|
+
whom a Contribution has been received by the Licensor and included
|
|
64
|
+
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 the combined work 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 cross-claim
|
|
83
|
+
or counterclaim in a lawsuit) alleging that the Work or any
|
|
84
|
+
Contribution embodied within the Work constitutes direct or contributory
|
|
85
|
+
patent infringement, then any patent licenses granted to You under
|
|
86
|
+
this License for that Work shall terminate as of the date such
|
|
87
|
+
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,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, You must include a readable copy of the
|
|
108
|
+
attribution notices contained within such NOTICE file, in
|
|
109
|
+
at least one of the following places: within a NOTICE text
|
|
110
|
+
file distributed as part of the Derivative Works; within
|
|
111
|
+
the Source form or documentation, if provided along with the
|
|
112
|
+
Derivative Works; or, within a display generated by the
|
|
113
|
+
Derivative Works, if and wherever such third-party notices
|
|
114
|
+
normally appear. The contents of the NOTICE file are for
|
|
115
|
+
informational purposes only and do not modify the License.
|
|
116
|
+
You may add Your own attribution notices within Derivative
|
|
117
|
+
Works that You distribute, alongside or as an addendum to
|
|
118
|
+
the NOTICE text from the Work, provided that such additional
|
|
119
|
+
attribution notices cannot be construed as modifying the License.
|
|
120
|
+
|
|
121
|
+
You may add Your own license statement for Your modifications and
|
|
122
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
123
|
+
publish, distribute, sublicense, and/or sell copies of the
|
|
124
|
+
Derivative Works, and to permit persons to whom the Derivative Works
|
|
125
|
+
are furnished to do so, subject to Your terms.
|
|
126
|
+
|
|
127
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
128
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
129
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
130
|
+
this License, without any additional terms or conditions.
|
|
131
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
132
|
+
the terms of any separate license agreement you may have executed
|
|
133
|
+
with Licensor regarding such Contributions.
|
|
134
|
+
|
|
135
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
136
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
137
|
+
except as required for reasonable and customary use in describing the
|
|
138
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
139
|
+
|
|
140
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
141
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
142
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
143
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
144
|
+
implied, including, without limitation, any warranties or conditions
|
|
145
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
146
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
147
|
+
appropriateness of using or reproducing the Work and assume any
|
|
148
|
+
risks associated with Your exercise of permissions under this License.
|
|
149
|
+
|
|
150
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
151
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
152
|
+
unless required by applicable law (such as deliberate and grossly
|
|
153
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
154
|
+
liable to You for damages, including any direct, indirect, special,
|
|
155
|
+
incidental, or exemplary damages of any character arising as a
|
|
156
|
+
result of this License or out of the use or inability to use the
|
|
157
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
158
|
+
work stoppage, computer failure or malfunction, or all other
|
|
159
|
+
commercial damages or losses), even if such Contributor has been
|
|
160
|
+
advised of the possibility of such damages.
|
|
161
|
+
|
|
162
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
163
|
+
the Work or Derivative Works thereof, You may offer, and charge a
|
|
164
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
165
|
+
liability obligations and/or rights consistent with this License.
|
|
166
|
+
However, in accepting such obligations, You may offer such obligations
|
|
167
|
+
only on Your own behalf and on Your sole responsibility, not on
|
|
168
|
+
behalf of any other Contributor, and only if You agree to indemnify,
|
|
169
|
+
defend, and hold each Contributor harmless for any liability
|
|
170
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
171
|
+
of your accepting any such warranty or additional liability.
|
|
172
|
+
|
|
173
|
+
END OF TERMS AND CONDITIONS
|
|
174
|
+
|
|
175
|
+
Copyright 2025-2026 Tenuo Contributors
|
|
176
|
+
|
|
177
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
178
|
+
you may not use this file except in compliance with the License.
|
|
179
|
+
You may obtain a copy of the License at
|
|
180
|
+
|
|
181
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
182
|
+
|
|
183
|
+
Unless required by applicable law or agreed to in writing, software
|
|
184
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
185
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
186
|
+
See the License for the specific language governing permissions and
|
|
187
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# `@tenuo/core`
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for Tenuo. Authorization decisions run in the Rust core (WASM).
|
|
4
|
+
|
|
5
|
+
> Beta: install this package from the npm `beta` dist-tag. The authorization
|
|
6
|
+
> semantics match Tenuo, but the TypeScript API may still change before the
|
|
7
|
+
> first stable npm tag.
|
|
8
|
+
|
|
9
|
+
Requires **Node 20+**. This package is not a browser or Workers runtime. There is
|
|
10
|
+
no Vercel AI SDK adapter and no Mastra adapter. `tenuo.tool()` wraps any
|
|
11
|
+
`{ execute }` object, including a Vercel `tool()`, but that is not a supported
|
|
12
|
+
integration.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm i @tenuo/core@beta
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { createTenuo, under } from "@tenuo/core";
|
|
20
|
+
|
|
21
|
+
const tenuo = createTenuo({ root: createTenuo.devRoot() });
|
|
22
|
+
const readFile = tenuo.tool(
|
|
23
|
+
{ execute: async ({ path }: { path: string }) => `contents of ${path}` },
|
|
24
|
+
{ capability: "read_file", allow: { path: under("/data") } },
|
|
25
|
+
);
|
|
26
|
+
const session = tenuo.session({ tools: [readFile] });
|
|
27
|
+
|
|
28
|
+
await tenuo.withSession(session, async () => {
|
|
29
|
+
await readFile.execute({ path: "/data/q3.pdf" }); // allowed
|
|
30
|
+
await readFile.execute({ path: "/etc/passwd" }); // denied — execute does not run
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Host schemas (Zod or otherwise) answer **valid**. Tool `allow` is the host ceiling.
|
|
35
|
+
The session is what this agent may do. Rust AND's both. `allow` is zero-trust:
|
|
36
|
+
every call argument must be named in the policy. `allow: {}` adds no extra
|
|
37
|
+
ceiling. `devRoot()` requires `NODE_ENV=development` or `test`,
|
|
38
|
+
`devRoot({ allowInProduction: true })`, or `TENUO_ALLOW_DEV=1`. Unset
|
|
39
|
+
`NODE_ENV` is not treated as development.
|
|
40
|
+
|
|
41
|
+
Production loads an issued warrant and a trusted root:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const tenuo = createTenuo({
|
|
45
|
+
trustedRoots: [createTenuo.publicKeyFromEnv("TENUO_ROOT_PUBLIC_KEY")],
|
|
46
|
+
});
|
|
47
|
+
const session = tenuo.sessionFromWire({
|
|
48
|
+
warrant: process.env.TENUO_WARRANT!,
|
|
49
|
+
holderKey: createTenuo.holderKeyFromEnv("TENUO_HOLDER_SECRET"),
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
MCP wire helpers live on `tenuo.mcp` (`attach` / `verify` / `handler`). They do
|
|
54
|
+
not depend on an MCP framework. For the official v2 server, use `@tenuo/mcp`.
|
|
55
|
+
For `@modelcontextprotocol/sdk` v1, copy the recipe in `examples/mcp/host.ts`.
|
|
56
|
+
`verify` / `handler` can take an optional `nonceStore` (`memoryNonceStore()`,
|
|
57
|
+
or an async Redis `checkAndRecord`) to reject an exact replayed PoP; that is
|
|
58
|
+
opt-in. PoP v1 is otherwise replayable in-window, including approval-gated
|
|
59
|
+
calls. Pass `nonceStore` on those tools if an approval must be one-use.
|
|
60
|
+
|
|
61
|
+
See the [workspace README](../../README.md) for the full API, refuse list, and
|
|
62
|
+
how to rebuild WASM from this monorepo.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frozen public contract for `@tenuo/core`.
|
|
3
|
+
*
|
|
4
|
+
* Names and shapes here are the review surface — do not grow this file with
|
|
5
|
+
* protocol vocabulary (`Warrant`, `mint`, `guard`) as the lead API.
|
|
6
|
+
*/
|
|
7
|
+
export type TenuoErrorCode = "TENUO_NOT_READY" | "TENUO_CONFIGURATION" | "TENUO_CONSTRAINT_VIOLATION" | "TENUO_TOOL_NOT_AUTHORIZED" | "TENUO_WARRANT_EXPIRED" | "TENUO_UNTRUSTED_ROOT" | "TENUO_INVALID_POP" | "TENUO_SIGNATURE_INVALID" | "TENUO_CHAIN_INVALID" | "TENUO_REVOKED" | "TENUO_APPROVAL_REQUIRED" | "TENUO_INSUFFICIENT_APPROVALS" | "TENUO_CANONICALIZATION" | "TENUO_NOT_IMPLEMENTED";
|
|
8
|
+
/** Path-traversal-safe prefix. Core evaluates this; TypeScript does not. */
|
|
9
|
+
export type UnderConstraint = {
|
|
10
|
+
readonly kind: "under";
|
|
11
|
+
readonly root: string;
|
|
12
|
+
};
|
|
13
|
+
export type EmailConstraint = {
|
|
14
|
+
readonly kind: "email";
|
|
15
|
+
readonly domain: string;
|
|
16
|
+
};
|
|
17
|
+
export type MaxConstraint = {
|
|
18
|
+
readonly kind: "max";
|
|
19
|
+
readonly value: number;
|
|
20
|
+
};
|
|
21
|
+
export type OneOfConstraint = {
|
|
22
|
+
readonly kind: "oneOf";
|
|
23
|
+
readonly values: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export type PatternConstraint = {
|
|
26
|
+
readonly kind: "pattern";
|
|
27
|
+
readonly pattern: string;
|
|
28
|
+
};
|
|
29
|
+
export type ExactConstraint = {
|
|
30
|
+
readonly kind: "exact";
|
|
31
|
+
readonly value: string | number | boolean;
|
|
32
|
+
};
|
|
33
|
+
export type ConstraintExpr = UnderConstraint | EmailConstraint | MaxConstraint | OneOfConstraint | PatternConstraint | ExactConstraint;
|
|
34
|
+
/** Per-argument allow policy. Not a Zod schema. */
|
|
35
|
+
export type AllowPolicy = {
|
|
36
|
+
readonly [field: string]: ConstraintExpr;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Framework tool shape we wrap. No dependency on `ai` / Mastra.
|
|
40
|
+
* `parameters` is host-schema (usually Zod) and is never treated as authority.
|
|
41
|
+
*/
|
|
42
|
+
export type ToolLike<TArgs extends Record<string, unknown> = Record<string, unknown>, TResult = unknown> = {
|
|
43
|
+
readonly description?: string;
|
|
44
|
+
readonly parameters?: unknown;
|
|
45
|
+
execute: (args: TArgs, options?: unknown) => TResult | Promise<TResult>;
|
|
46
|
+
};
|
|
47
|
+
export type ToolPolicy = {
|
|
48
|
+
/**
|
|
49
|
+
* Host ceiling. AND'd with the session in Rust.
|
|
50
|
+
* Non-empty maps are zero-trust: every call argument must be named here.
|
|
51
|
+
* `{}` means no extra ceiling (session/warrant only).
|
|
52
|
+
*/
|
|
53
|
+
readonly allow: AllowPolicy;
|
|
54
|
+
readonly capability?: string;
|
|
55
|
+
};
|
|
56
|
+
/** Compile-time brand only — never assigned at runtime. Do not `in`/`has` this key. */
|
|
57
|
+
declare const protectedBrand: unique symbol;
|
|
58
|
+
export type ExecuteOptions = {
|
|
59
|
+
readonly session?: Session;
|
|
60
|
+
/** Already-signed approval envelopes (hex, standard base64, or CBOR bytes). */
|
|
61
|
+
readonly approvals?: readonly (string | Uint8Array)[];
|
|
62
|
+
/**
|
|
63
|
+
* Signed evidence of the decision. Not a security hook.
|
|
64
|
+
* Exceptions (sync or rejected Promise) are isolated and never deny or
|
|
65
|
+
* fail the tool.
|
|
66
|
+
*/
|
|
67
|
+
readonly onReceipt?: (receipt: string) => void | Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Correlation handle written to the receipt. Use whatever id the host
|
|
70
|
+
* already has — a JSON-RPC id, a trace or span id — so a receipt can be
|
|
71
|
+
* matched against your own logs. Not an identity: nothing enforces
|
|
72
|
+
* uniqueness, and distinguishing repeated calls is the receipt chain's job.
|
|
73
|
+
*/
|
|
74
|
+
readonly requestId?: string;
|
|
75
|
+
};
|
|
76
|
+
type ExtraExecuteOptions<T extends {
|
|
77
|
+
execute: (args: never) => unknown;
|
|
78
|
+
}> = T["execute"] extends (args: never, options?: infer O) => unknown ? unknown extends O ? object : Omit<NonNullable<O>, keyof ExecuteOptions> : object;
|
|
79
|
+
/** Wrapped tool. `execute` still authorizes; optional `{ session }` overrides ALS. */
|
|
80
|
+
export type ProtectedTool<T extends {
|
|
81
|
+
execute: (args: never) => unknown;
|
|
82
|
+
}> = Omit<T, "execute"> & {
|
|
83
|
+
execute: (args: Parameters<T["execute"]>[0], options?: ExecuteOptions & ExtraExecuteOptions<T>) => Promise<Awaited<ReturnType<T["execute"]>>>;
|
|
84
|
+
readonly [protectedBrand]: true;
|
|
85
|
+
};
|
|
86
|
+
/** Whole-tool approval gate. Host collects SignedApproval bytes; Rust decides. */
|
|
87
|
+
export type RequireApproval = {
|
|
88
|
+
readonly approvers: readonly PublicKeyHandle[];
|
|
89
|
+
readonly min: number;
|
|
90
|
+
readonly tools?: readonly string[];
|
|
91
|
+
};
|
|
92
|
+
export type SessionAllow = {
|
|
93
|
+
readonly [capability: string]: AllowPolicy;
|
|
94
|
+
};
|
|
95
|
+
export type SessionInput = {
|
|
96
|
+
/** Capability map. Optional when `tools` is set. */
|
|
97
|
+
readonly allow?: SessionAllow;
|
|
98
|
+
/** Wrapped tools from `tenuo.tool()`. Their `allow` is minted into the session. */
|
|
99
|
+
readonly tools?: readonly object[];
|
|
100
|
+
readonly ttlSeconds?: number;
|
|
101
|
+
readonly requireApproval?: RequireApproval;
|
|
102
|
+
};
|
|
103
|
+
export type DevRoot = {
|
|
104
|
+
readonly kind: "dev-root";
|
|
105
|
+
/**
|
|
106
|
+
* Required when `NODE_ENV` is unset or is not `development` / `test`.
|
|
107
|
+
* Unset `NODE_ENV` is not treated as development.
|
|
108
|
+
*/
|
|
109
|
+
readonly allowInProduction?: boolean;
|
|
110
|
+
};
|
|
111
|
+
export type PublicKeyHandle = {
|
|
112
|
+
readonly kind: "public-key";
|
|
113
|
+
readonly source: "env" | "hex" | "bytes";
|
|
114
|
+
readonly hex: string;
|
|
115
|
+
};
|
|
116
|
+
export type WarrantPart = {
|
|
117
|
+
readonly payload_hex: string;
|
|
118
|
+
readonly signature_hex: string;
|
|
119
|
+
};
|
|
120
|
+
export type SessionFromWireInput = {
|
|
121
|
+
readonly warrant: string | readonly string[] | readonly WarrantPart[];
|
|
122
|
+
readonly holderKey: Uint8Array;
|
|
123
|
+
};
|
|
124
|
+
/** Field-level (`{ path: under("/data") }`) or per-capability (`{ read_file: { path: ... } }`). */
|
|
125
|
+
export type NarrowInput = AllowPolicy | SessionAllow;
|
|
126
|
+
export type CreateTenuoOptions = {
|
|
127
|
+
readonly trustedRoots?: readonly PublicKeyHandle[];
|
|
128
|
+
readonly root?: DevRoot | PublicKeyHandle;
|
|
129
|
+
/** Published SignedRevocationList (hex or standard base64). Verified against a trusted root. */
|
|
130
|
+
readonly revocationList?: string | Uint8Array;
|
|
131
|
+
};
|
|
132
|
+
export type ApprovalRequest = {
|
|
133
|
+
readonly tool: string;
|
|
134
|
+
readonly required: number;
|
|
135
|
+
readonly received: number;
|
|
136
|
+
};
|
|
137
|
+
export type Decision = {
|
|
138
|
+
readonly outcome: "allow";
|
|
139
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
140
|
+
} | {
|
|
141
|
+
readonly outcome: "deny";
|
|
142
|
+
readonly code: TenuoErrorCode;
|
|
143
|
+
readonly field?: string;
|
|
144
|
+
} | {
|
|
145
|
+
readonly outcome: "approval_required";
|
|
146
|
+
readonly request: ApprovalRequest;
|
|
147
|
+
};
|
|
148
|
+
export interface Session {
|
|
149
|
+
readonly [Symbol.toStringTag]: "TenuoSession";
|
|
150
|
+
/** Warrant tokens, root first. Does not include the holder secret. */
|
|
151
|
+
toWire(): readonly string[];
|
|
152
|
+
/** SHA-256 of `(warrant_id, tool, canonical args)`. App-level idempotency, not PoP. */
|
|
153
|
+
dedupKey(tool: string, args: Readonly<Record<string, unknown>>): string;
|
|
154
|
+
}
|
|
155
|
+
export interface Tenuo {
|
|
156
|
+
/**
|
|
157
|
+
* Wrap any `{ execute }` tool (Vercel AI SDK, Mastra, plain object).
|
|
158
|
+
* `parameters` / Zod stay on the inner tool and are never treated as authority.
|
|
159
|
+
*/
|
|
160
|
+
tool<T extends {
|
|
161
|
+
execute: (args: never) => unknown;
|
|
162
|
+
}>(inner: T, policy: ToolPolicy): ProtectedTool<T>;
|
|
163
|
+
session(input: SessionInput): Session;
|
|
164
|
+
/** Import a warrant minted elsewhere (Rust / Python / another process). */
|
|
165
|
+
sessionFromWire(input: SessionFromWireInput): Session;
|
|
166
|
+
withSession<R>(session: Session, fn: () => R): R;
|
|
167
|
+
narrow(session: Session, allow: NarrowInput): Session;
|
|
168
|
+
/** Load a published SignedRevocationList. Rust verifies the issuer against trusted roots. */
|
|
169
|
+
revoke(list: string | Uint8Array): void;
|
|
170
|
+
/** MCP `_meta.tenuo` attach / verify. No MCP SDK dependency. */
|
|
171
|
+
readonly mcp: TenuoMcp;
|
|
172
|
+
ready(): void;
|
|
173
|
+
}
|
|
174
|
+
/** Wire envelope Python and TypeScript both read from `params._meta`. */
|
|
175
|
+
export type TenuoMcpMeta = {
|
|
176
|
+
readonly tenuo: {
|
|
177
|
+
readonly warrant: string;
|
|
178
|
+
readonly signature: string;
|
|
179
|
+
readonly approvals?: readonly string[];
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
export type McpAttachOptions = {
|
|
183
|
+
readonly approvals?: readonly (string | Uint8Array)[];
|
|
184
|
+
readonly onReceipt?: (receipt: string) => void | Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Correlation handle written to the receipt. Use whatever id the host
|
|
187
|
+
* already has — a JSON-RPC id, a trace or span id — so a receipt can be
|
|
188
|
+
* matched against your own logs. Not an identity: nothing enforces
|
|
189
|
+
* uniqueness, and distinguishing repeated calls is the receipt chain's job.
|
|
190
|
+
*/
|
|
191
|
+
readonly requestId?: string;
|
|
192
|
+
};
|
|
193
|
+
/** Host ceiling and optional receipt hook on `mcp.handler()`. */
|
|
194
|
+
export type McpHandlerPolicy = {
|
|
195
|
+
readonly allow?: AllowPolicy;
|
|
196
|
+
readonly onReceipt?: (receipt: string) => void | Promise<void>;
|
|
197
|
+
readonly nonceStore?: NonceStore;
|
|
198
|
+
/**
|
|
199
|
+
* Isolated. Called when `nonceStore.checkAndRecord` throws or rejects.
|
|
200
|
+
* The client only ever sees "Replay store unavailable".
|
|
201
|
+
*/
|
|
202
|
+
readonly onNonceStoreError?: (error: unknown) => void | Promise<void>;
|
|
203
|
+
};
|
|
204
|
+
export type McpVerifyOptions = {
|
|
205
|
+
readonly allow?: AllowPolicy;
|
|
206
|
+
readonly onReceipt?: (receipt: string) => void | Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Opt-in exact-PoP replay check. `checkAndRecord` may return a Promise
|
|
209
|
+
* (Redis). A rejected Promise fails closed. In-memory stores do not work
|
|
210
|
+
* across processes. PoP v1 is otherwise replayable in-window, including
|
|
211
|
+
* envelopes that already carry approvals.
|
|
212
|
+
*/
|
|
213
|
+
readonly nonceStore?: NonceStore;
|
|
214
|
+
/**
|
|
215
|
+
* Isolated. Called when `nonceStore.checkAndRecord` throws or rejects.
|
|
216
|
+
* The client only ever sees "Replay store unavailable".
|
|
217
|
+
*/
|
|
218
|
+
readonly onNonceStoreError?: (error: unknown) => void | Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Correlation handle written to the receipt. Use whatever id the host
|
|
221
|
+
* already has — a JSON-RPC id, a trace or span id — so a receipt can be
|
|
222
|
+
* matched against your own logs. Not an identity: nothing enforces
|
|
223
|
+
* uniqueness, and distinguishing repeated calls is the receipt chain's job.
|
|
224
|
+
*/
|
|
225
|
+
readonly requestId?: string;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Returns true if the PoP is fresh and recorded; false if this exact token
|
|
229
|
+
* was already consumed. Async stores (Redis) return `Promise<boolean>`.
|
|
230
|
+
* `verify()` / handlers await the result. Never return a Promise from a
|
|
231
|
+
* store that is only consulted synchronously — that used to fail open.
|
|
232
|
+
*/
|
|
233
|
+
export type NonceStore = {
|
|
234
|
+
checkAndRecord(popSignature: string): boolean | Promise<boolean>;
|
|
235
|
+
};
|
|
236
|
+
export type McpCallParams = {
|
|
237
|
+
readonly name: string;
|
|
238
|
+
readonly arguments: Readonly<Record<string, unknown>>;
|
|
239
|
+
readonly _meta: TenuoMcpMeta;
|
|
240
|
+
};
|
|
241
|
+
export type McpJsonRpcError = {
|
|
242
|
+
readonly code: -32602 | -32001 | -32002;
|
|
243
|
+
readonly message: string;
|
|
244
|
+
readonly data?: {
|
|
245
|
+
readonly tenuo?: {
|
|
246
|
+
readonly code: TenuoErrorCode;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
export interface TenuoMcp {
|
|
251
|
+
/** Local authorize, then put warrant + PoP on `_meta.tenuo`. */
|
|
252
|
+
attach(session: Session, name: string, args: Readonly<Record<string, unknown>>, options?: McpAttachOptions): McpCallParams;
|
|
253
|
+
/**
|
|
254
|
+
* Server path. Verifies a presented warrant + PoP. Tool handler must not
|
|
255
|
+
* run unless this returns.
|
|
256
|
+
*/
|
|
257
|
+
verify(name: string, args: Readonly<Record<string, unknown>>, meta: unknown, options?: McpVerifyOptions): Promise<Readonly<Record<string, unknown>>>;
|
|
258
|
+
/** Wrap a handler: verify from `extra._meta` / `extra.meta`, then execute. */
|
|
259
|
+
handler<TArgs extends Record<string, unknown>, TResult>(name: string, execute: (args: TArgs) => TResult | Promise<TResult>): (args: TArgs, extra?: {
|
|
260
|
+
readonly _meta?: unknown;
|
|
261
|
+
readonly meta?: unknown;
|
|
262
|
+
}) => Promise<TResult>;
|
|
263
|
+
handler<TArgs extends Record<string, unknown>, TResult>(name: string, policy: McpHandlerPolicy, execute: (args: TArgs) => TResult | Promise<TResult>): (args: TArgs, extra?: {
|
|
264
|
+
readonly _meta?: unknown;
|
|
265
|
+
readonly meta?: unknown;
|
|
266
|
+
}) => Promise<TResult>;
|
|
267
|
+
jsonRpcError(error: unknown): McpJsonRpcError;
|
|
268
|
+
}
|
|
269
|
+
export {};
|
|
270
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,cAAc,GACtB,iBAAiB,GACjB,qBAAqB,GACrB,4BAA4B,GAC5B,2BAA2B,GAC3B,uBAAuB,GACvB,sBAAsB,GACtB,mBAAmB,GACnB,yBAAyB,GACzB,qBAAqB,GACrB,eAAe,GACf,yBAAyB,GACzB,8BAA8B,GAC9B,wBAAwB,GACxB,uBAAuB,CAAC;AAE5B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C;IAC9C,8EAA8E;IAC9E,OAAO,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EACpD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GACnD,CACD,IAAI,EAAE,KAAK,EACX,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,KAC1D,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EACpD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GACnD,CACD,IAAI,EAAE,KAAK,EACX,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,KAC1D,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAAC;CAC/C"}
|
package/dist/api.js
ADDED
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CreateTenuoOptions, DevRoot, PublicKeyHandle, Tenuo } from "./api.ts";
|
|
2
|
+
export declare function devRoot(options?: {
|
|
3
|
+
readonly allowInProduction?: boolean;
|
|
4
|
+
}): DevRoot;
|
|
5
|
+
export declare function publicKeyFromEnv(name: string): PublicKeyHandle;
|
|
6
|
+
export declare function publicKeyFromHex(hex: string): PublicKeyHandle;
|
|
7
|
+
export declare function publicKeyFromBytes(bytes: Uint8Array): PublicKeyHandle;
|
|
8
|
+
export declare function holderKeyFromEnv(name: string): Uint8Array;
|
|
9
|
+
export declare function holderKeyFromHex(hex: string): Uint8Array;
|
|
10
|
+
export declare const createTenuo: ((options?: CreateTenuoOptions) => Tenuo) & {
|
|
11
|
+
devRoot: typeof devRoot;
|
|
12
|
+
publicKeyFromEnv: typeof publicKeyFromEnv;
|
|
13
|
+
publicKeyFromHex: typeof publicKeyFromHex;
|
|
14
|
+
publicKeyFromBytes: typeof publicKeyFromBytes;
|
|
15
|
+
holderKeyFromEnv: typeof holderKeyFromEnv;
|
|
16
|
+
holderKeyFromHex: typeof holderKeyFromHex;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,OAAO,EAEP,eAAe,EAIf,KAAK,EAIN,MAAM,UAAU,CAAC;AA+BlB,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CASnF;AAwBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAgB9D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CAMrE;AAoBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAgBzD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAExD;AA6XD,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,KAAK,CAAC,GAAG;IACpE,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,kBAAkB,EAAE,OAAO,kBAAkB,CAAC;IAC9C,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;CAQ1C,CAAC"}
|