@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
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Issuer + authorizer for `createTenuo({ root: devRoot() })`.
|
|
6
|
+
* Verifier-only contexts have `issuer: None` and cannot mint.
|
|
7
|
+
*/
|
|
8
|
+
export class SdkContext {
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* Sign PoP and authorize in one call. Never returns allow without a core allow.
|
|
13
|
+
*
|
|
14
|
+
* `tool_allow` is the wrapper ceiling (`tenuo.tool(..., { allow })`). Null/undefined
|
|
15
|
+
* means no extra ceiling. Session and ceiling are AND'd; Rust decides both.
|
|
16
|
+
*/
|
|
17
|
+
authorize(session: SdkSession, tool: string, args_json: any, approvals: any, tool_allow: any, request_id?: string | null): any;
|
|
18
|
+
/**
|
|
19
|
+
* Test / replay seam. Not exposed on `createTenuo` or `execute`.
|
|
20
|
+
*/
|
|
21
|
+
authorizeAsOf(session: SdkSession, tool: string, args_json: any, as_of: number, approvals: any, tool_allow: any): any;
|
|
22
|
+
/**
|
|
23
|
+
* Authorize a warrant + PoP presented on the wire. No holder secret.
|
|
24
|
+
*
|
|
25
|
+
* `tool_allow` is the server host ceiling (`mcp.handler(..., { allow })`).
|
|
26
|
+
* Null/undefined: no extra ceiling. Empty object: open.
|
|
27
|
+
*/
|
|
28
|
+
authorizePresented(warrants: any, tool: string, args_json: any, pop: string, approvals: any, tool_allow: any, request_id?: string | null): any;
|
|
29
|
+
/**
|
|
30
|
+
* Authorizer-only context. `mint()` fails; import a session from the wire.
|
|
31
|
+
*/
|
|
32
|
+
static fromTrustedRoots(roots: any): SdkContext;
|
|
33
|
+
/**
|
|
34
|
+
* Load a published SignedRevocationList. The SRL must be signed by a trusted root.
|
|
35
|
+
*/
|
|
36
|
+
loadRevocationList(wire: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Mint a short-lived session from an allow map:
|
|
39
|
+
* `{ "read_file": { "path": { "kind": "under", "root": "/data" } } }`
|
|
40
|
+
*
|
|
41
|
+
* `require_approval` is optional:
|
|
42
|
+
* `{ "approvers": ["hex..."], "min": 2, "tools": ["transfer"] }`
|
|
43
|
+
*/
|
|
44
|
+
mint(allow_json: any, ttl_seconds: number, require_approval: any): SdkSession;
|
|
45
|
+
/**
|
|
46
|
+
* Attenuate the leaf. The current holder signs; the same holder keeps the child.
|
|
47
|
+
*/
|
|
48
|
+
narrow(session: SdkSession, allow_json: any): SdkSession;
|
|
49
|
+
constructor();
|
|
50
|
+
/**
|
|
51
|
+
* Holder PoP only. Does not authorize. Used to fill `_meta.tenuo.signature`.
|
|
52
|
+
*/
|
|
53
|
+
signPop(session: SdkSession, tool: string, args_json: any): string;
|
|
54
|
+
/**
|
|
55
|
+
* Test / host seam. Signs an SRL with the local issuer. Does not load it.
|
|
56
|
+
*/
|
|
57
|
+
signRevocationList(ids: any): string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Opaque warrant chain (root first) + leaf holder key. Not JSON-serializable from JS.
|
|
62
|
+
*/
|
|
63
|
+
export class SdkSession {
|
|
64
|
+
private constructor();
|
|
65
|
+
free(): void;
|
|
66
|
+
[Symbol.dispose](): void;
|
|
67
|
+
/**
|
|
68
|
+
* Application idempotency key: SHA-256 of `(warrant_id, tool, canonical args)`.
|
|
69
|
+
* Not a PoP. MCP replay uses the PoP signature, not this key.
|
|
70
|
+
*/
|
|
71
|
+
dedupKey(tool: string, args_json: any): string;
|
|
72
|
+
/**
|
|
73
|
+
* Test / interop seam. Not on the public TypeScript Session type.
|
|
74
|
+
*/
|
|
75
|
+
exportWire(): any;
|
|
76
|
+
/**
|
|
77
|
+
* Import a chain: string[] of wire tokens, or `{ payload_hex, signature_hex }[]`.
|
|
78
|
+
*/
|
|
79
|
+
static fromChain(parts: any, holder_secret: Uint8Array): SdkSession;
|
|
80
|
+
/**
|
|
81
|
+
* Reconstruct a warrant from published payload + signature hex (A.14).
|
|
82
|
+
*/
|
|
83
|
+
static fromParts(payload_hex: string, signature_hex: string, holder_secret: Uint8Array): SdkSession;
|
|
84
|
+
/**
|
|
85
|
+
* Import a published warrant (base64 or envelope hex) plus the holder secret.
|
|
86
|
+
*/
|
|
87
|
+
static fromWire(warrant: string, holder_secret: Uint8Array): SdkSession;
|
|
88
|
+
/**
|
|
89
|
+
* CBOR warrant stack as standard base64. Matches Python `encode_warrant_stack`.
|
|
90
|
+
*/
|
|
91
|
+
toStackWire(): string;
|
|
92
|
+
/**
|
|
93
|
+
* Warrant tokens, root first. Does not include the holder secret.
|
|
94
|
+
*/
|
|
95
|
+
toWire(): any;
|
|
96
|
+
/**
|
|
97
|
+
* Warrant IDs, root first. Test / revoke seam.
|
|
98
|
+
*/
|
|
99
|
+
warrantIds(): any;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function check_access(warrant_b64: string, tool: string, args_json: any, trusted_root_hex: string, dry_run: boolean): any;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Check authorization with a real PoP signature
|
|
106
|
+
*/
|
|
107
|
+
export function check_access_with_pop(warrant_b64: string, tool: string, args_json: any, trusted_root_hex: string, pop_signature_hex: string): any;
|
|
108
|
+
|
|
109
|
+
export function check_chain_access(warrant_b64_list: string[], tool: string, args_json: any, trusted_root_hex: string, dry_run: boolean): any;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Check a warrant chain with signed approvals and optional revocation list.
|
|
113
|
+
*
|
|
114
|
+
* Extends `check_chain_access` with:
|
|
115
|
+
* - `approvals_b64`: JS array of base64-encoded CBOR `SignedApproval` blobs for M-of-N
|
|
116
|
+
* approval verification (pass `[]` if not needed).
|
|
117
|
+
* - `srl_b64`: optional base64-encoded CBOR `SignedRevocationList`. When provided, the
|
|
118
|
+
* SRL is verified (using the trusted root as its issuer) and applied before chain checks.
|
|
119
|
+
* Pass `null`/`undefined` to skip revocation checking.
|
|
120
|
+
*/
|
|
121
|
+
export function check_chain_access_with_approvals(warrant_b64_list: string[], tool: string, args_json: any, trusted_root_hex: string, approvals_b64: any, srl_b64?: string | null): any;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Check if a warrant ID appears in a signed revocation list.
|
|
125
|
+
*
|
|
126
|
+
* Does not verify the SRL signature — call `verify_srl` first if you need
|
|
127
|
+
* signature assurance. Returns `{ revoked, error? }`.
|
|
128
|
+
*/
|
|
129
|
+
export function check_revocation(warrant_id: string, srl_cbor_b64: string): any;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Compute the canonical request hash for a (warrant, tool, args) tuple.
|
|
133
|
+
*
|
|
134
|
+
* The hash is SHA-256(warrant_id | tool | CBOR(sorted_args) | holder_key) and is
|
|
135
|
+
* what every SignedApproval must cover. Use this to build the payload for
|
|
136
|
+
* POST /v1/approvals/requests so the backend can verify it matches.
|
|
137
|
+
*
|
|
138
|
+
* Returns `{ "hash": "<hex>" }` on success, or `{ "hash": null, "error": "..." }` on failure.
|
|
139
|
+
*/
|
|
140
|
+
export function compute_request_hash_wasm(warrant_b64: string, tool: string, args_json: any): any;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Create a self-signed root Issuer warrant for use as a persistent trust anchor.
|
|
144
|
+
* This is called once during plugin setup and stored on disk.
|
|
145
|
+
* The Issuer warrant's keypair replaces per-session signing keys — all Execution
|
|
146
|
+
* warrants (depth ≥ 1) are derived from it, enabling proper WASM chain verification
|
|
147
|
+
* across plugin restarts.
|
|
148
|
+
*
|
|
149
|
+
* Config: { signing_key_hex?: string, issuable_tools: string[], max_issue_depth?: number, ttl_seconds?: number }
|
|
150
|
+
*/
|
|
151
|
+
export function create_issuer_warrant(config_json: any): any;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Create a fresh sample warrant with the given tool and TTL
|
|
155
|
+
* This generates new keys each time, ensuring the warrant is never expired
|
|
156
|
+
*/
|
|
157
|
+
export function create_sample_warrant(tool: string, constraint_field: string, constraint_pattern: string, ttl_seconds: bigint): any;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Create a warrant from the full builder config (multiple tools, multiple constraints)
|
|
161
|
+
* This is more flexible than create_sample_warrant
|
|
162
|
+
*/
|
|
163
|
+
export function create_warrant_from_config(config_json: any): any;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Decode a PEM chain (or single warrant) and return detailed chain analysis
|
|
167
|
+
*/
|
|
168
|
+
export function decode_pem_chain_wasm(input: string): any;
|
|
169
|
+
|
|
170
|
+
export function decode_warrant(base64_warrant: string): any;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Evaluate whether a tool call requires approval based on the warrant's embedded approval gates.
|
|
174
|
+
*
|
|
175
|
+
* Returns `{ approval_required: true/false, tool, error }`.
|
|
176
|
+
* This reads `extensions["tenuo.approval_gates"]` from the warrant, parses it,
|
|
177
|
+
* and runs the gate evaluation logic from tenuo-core.
|
|
178
|
+
*/
|
|
179
|
+
export function evaluate_approval_gates(warrant_b64: string, tool: string, args_json: any): any;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Generate a new Ed25519 keypair for testing PoP
|
|
183
|
+
*/
|
|
184
|
+
export function generate_keypair(): any;
|
|
185
|
+
|
|
186
|
+
export function init_panic_hook(): void;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Parse a `TENUO_CONNECT_TOKEN` string into its component fields.
|
|
190
|
+
*
|
|
191
|
+
* The token is a base64url-encoded JSON blob: `{ v, e, k, a?, t? }`.
|
|
192
|
+
* This WASM binding keeps the parsing canonical so TypeScript doesn't need
|
|
193
|
+
* to duplicate the decode logic.
|
|
194
|
+
*
|
|
195
|
+
* Returns `{ endpoint, apiKey, agentId?, registrationToken?, error? }`.
|
|
196
|
+
*/
|
|
197
|
+
export function parse_connect_token(token: string): any;
|
|
198
|
+
|
|
199
|
+
export function sdkInspectParts(payload_hex: string, signature_hex: string): any;
|
|
200
|
+
|
|
201
|
+
export function sdkInspectWarrant(wire: string): any;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Test / host seam. Signs a SignedApproval envelope; does not authorize.
|
|
205
|
+
*/
|
|
206
|
+
export function sdkSignApproval(session: SdkSession, tool: string, args_json: any, approver_secret: Uint8Array, external_id: string, as_of?: number | null): string;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Test seam. Signs the published generator envelope (not the in-memory SRL codec).
|
|
210
|
+
*/
|
|
211
|
+
export function sdkSignPublishedRevocationList(ids: any, version: number, issuer_secret: Uint8Array): string;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Test / host seam. Signs an SRL with a provided issuer secret. Does not load it.
|
|
215
|
+
*/
|
|
216
|
+
export function sdkSignRevocationList(ids: any, issuer_secret: Uint8Array): string;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Signature authenticity only. Not authorization.
|
|
220
|
+
*/
|
|
221
|
+
export function sdkVerifyReceipt(wire: string): any;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Verify a receipt's embedded warrant chain against trusted roots, at the
|
|
225
|
+
* receipt's own decision instant.
|
|
226
|
+
*
|
|
227
|
+
* This is the root-anchored half of receipt verification: it needs no trust
|
|
228
|
+
* in `signer_key` at all, because the chain is signed by the root and the
|
|
229
|
+
* holder, not by the enforcement point. The signature over the receipt is
|
|
230
|
+
* still checked first — an unauthenticated payload is never parsed into a
|
|
231
|
+
* chain to verify.
|
|
232
|
+
*
|
|
233
|
+
* A deny receipt whose chain fails with the same error it states is
|
|
234
|
+
* *corroborated*: the embedded authority independently supports the refusal.
|
|
235
|
+
* A deny whose chain verifies is not inconsistent — constraint and
|
|
236
|
+
* possession failures deny over a valid chain, and chain-level verification
|
|
237
|
+
* does not evaluate those.
|
|
238
|
+
*/
|
|
239
|
+
export function sdkVerifyReceiptChain(wire: string, roots: any): any;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Create a Proof-of-Possession signature for a warrant
|
|
243
|
+
*/
|
|
244
|
+
export function sign(private_key_hex: string, warrant_b64: string, tool: string, args_json: any): any;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Sign an authorization receipt for audit ingestion.
|
|
248
|
+
*
|
|
249
|
+
* Produces the same CBOR+Ed25519 format used by the authorizer binary, allowing
|
|
250
|
+
* browser/Node plugins to generate verifiable forensic receipts.
|
|
251
|
+
*
|
|
252
|
+
* `payload_json` — `{ authorizer_id, warrant_chain_b64, action, outcome, timestamp, root_principal? }`
|
|
253
|
+
* `authorizer_key_hex` — hex-encoded Ed25519 private key (32 bytes).
|
|
254
|
+
*
|
|
255
|
+
* Returns `{ signature_hex, signing_payload_cbor_hex, error? }`.
|
|
256
|
+
*/
|
|
257
|
+
export function sign_receipt(payload_json: any, authorizer_key_hex: string): any;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Verify that enough valid signed approvals cover a known request hash.
|
|
261
|
+
*
|
|
262
|
+
* Use this when you already have a pre-computed `request_hash_hex` and want
|
|
263
|
+
* to check the approval set independently of tool/args re-parsing.
|
|
264
|
+
*
|
|
265
|
+
* `warrant_b64` — the leaf warrant (provides `required_approvers` and threshold).
|
|
266
|
+
* `request_hash_hex` — hex-encoded 32-byte hash from `compute_request_hash_wasm`.
|
|
267
|
+
* `approvals_b64` — JS array of base64-encoded CBOR `SignedApproval` blobs.
|
|
268
|
+
*
|
|
269
|
+
* Returns `{ satisfied, valid_count, required, error? }`.
|
|
270
|
+
*/
|
|
271
|
+
export function verify_approval_set(warrant_b64: string, request_hash_hex: string, approvals_b64: any): any;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Verify a single signed approval blob and return its payload.
|
|
275
|
+
*
|
|
276
|
+
* `approval_cbor_b64` — base64-encoded CBOR `SignedApproval`.
|
|
277
|
+
*
|
|
278
|
+
* Returns `{ valid, approver_hex, request_hash_hex, approved_at, expires_at, error? }`.
|
|
279
|
+
*/
|
|
280
|
+
export function verify_signed_approval(approval_cbor_b64: string): any;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Verify a signed revocation list and return its metadata.
|
|
284
|
+
*
|
|
285
|
+
* `srl_cbor_b64` — base64-encoded CBOR `SignedRevocationList`.
|
|
286
|
+
* `expected_issuer_hex` — hex-encoded Ed25519 public key of the expected SRL issuer.
|
|
287
|
+
*
|
|
288
|
+
* Returns `{ valid, version, revoked_count, issued_at, error? }`.
|
|
289
|
+
*/
|
|
290
|
+
export function verify_srl(srl_cbor_b64: string, expected_issuer_hex: string): any;
|