@vantic/sdk 0.1.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 +202 -0
- package/README.md +42 -0
- package/dist/adapters.d.ts +66 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +67 -0
- package/dist/adapters.js.map +1 -0
- package/dist/credential.d.ts +51 -0
- package/dist/credential.d.ts.map +1 -0
- package/dist/credential.js +78 -0
- package/dist/credential.js.map +1 -0
- package/dist/crypto.d.ts +27 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +103 -0
- package/dist/crypto.js.map +1 -0
- package/dist/did.d.ts +54 -0
- package/dist/did.d.ts.map +1 -0
- package/dist/did.js +152 -0
- package/dist/did.js.map +1 -0
- package/dist/envelope.d.ts +23 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +31 -0
- package/dist/envelope.js.map +1 -0
- package/dist/gate.d.ts +48 -0
- package/dist/gate.d.ts.map +1 -0
- package/dist/gate.js +46 -0
- package/dist/gate.js.map +1 -0
- package/dist/guard.d.ts +53 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +76 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +23 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +141 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +5 -0
- package/dist/mcp.js.map +1 -0
- package/dist/receipt.d.ts +24 -0
- package/dist/receipt.d.ts.map +1 -0
- package/dist/receipt.js +41 -0
- package/dist/receipt.js.map +1 -0
- package/dist/revocation.d.ts +23 -0
- package/dist/revocation.d.ts.map +1 -0
- package/dist/revocation.js +30 -0
- package/dist/revocation.js.map +1 -0
- package/dist/types.d.ts +98 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/verify.d.ts +24 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +124 -0
- package/dist/verify.js.map +1 -0
- package/package.json +39 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vantic/sdk — Vantic Protocol v0.1 reference implementation.
|
|
3
|
+
*
|
|
4
|
+
* Signed delegation envelopes and receipt chains for autonomous agent transactions.
|
|
5
|
+
* See ../spec/SPEC.md.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export { generateKeyPair, canonicalize, sha256Hex, signObject, verifyObjectSignature } from "./crypto.js";
|
|
9
|
+
export { issueMandate, verifyMandateSignature, mandateHash, type IssueMandateParams } from "./envelope.js";
|
|
10
|
+
export { issueReceipt, receiptHash, verifyReceiptSignature, nextPrevHash, type IssueReceiptParams } from "./receipt.js";
|
|
11
|
+
export { verifyChain, authorize, counterpartyAllowed, type VerifyOptions } from "./verify.js";
|
|
12
|
+
export { checkMandate, type ResourceRequirement, type GateResult } from "./gate.js";
|
|
13
|
+
export { RevocationList } from "./revocation.js";
|
|
14
|
+
export { AgentWallet, GuardViolation, type SpendExecutor, type AgentWalletOptions } from "./guard.js";
|
|
15
|
+
export { guardTool, wrapMcpTool, type GuardedToolResponse, type GuardToolOptions, type McpTool, type McpToolResult, type WrapMcpOptions, } from "./adapters.js";
|
|
16
|
+
export { didKeyFromRaw, rawFromDidKey, keyIdToDidKey, didKeyToKeyId, identifierToRaw, isDidKey, isKeyId, resolveDidKey, didWebToUrl, buildDidWebDocument, createResolver, base58Encode, base58Decode, type DIDDocument, type VerificationMethod, type DidResolver, } from "./did.js";
|
|
17
|
+
export { issueSponsorCredential, verifySponsorCredential, type SponsorCredential, type CredentialProof, type IssueSponsorCredentialParams, type CredentialVerifyOptions, } from "./credential.js";
|
|
18
|
+
export { handleMcp, startStdioServer, type JsonRpcRequest, type JsonRpcResponse } from "./mcp-server.js";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,sBAAsB,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACxH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACtG,OAAO,EACL,SAAS,EACT,WAAW,EACX,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,QAAQ,EACR,OAAO,EACP,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,WAAW,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vantic/sdk — Vantic Protocol v0.1 reference implementation.
|
|
3
|
+
*
|
|
4
|
+
* Signed delegation envelopes and receipt chains for autonomous agent transactions.
|
|
5
|
+
* See ../spec/SPEC.md.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export { generateKeyPair, canonicalize, sha256Hex, signObject, verifyObjectSignature } from "./crypto.js";
|
|
9
|
+
export { issueMandate, verifyMandateSignature, mandateHash } from "./envelope.js";
|
|
10
|
+
export { issueReceipt, receiptHash, verifyReceiptSignature, nextPrevHash } from "./receipt.js";
|
|
11
|
+
export { verifyChain, authorize, counterpartyAllowed } from "./verify.js";
|
|
12
|
+
export { checkMandate } from "./gate.js";
|
|
13
|
+
export { RevocationList } from "./revocation.js";
|
|
14
|
+
export { AgentWallet, GuardViolation } from "./guard.js";
|
|
15
|
+
export { guardTool, wrapMcpTool, } from "./adapters.js";
|
|
16
|
+
export { didKeyFromRaw, rawFromDidKey, keyIdToDidKey, didKeyToKeyId, identifierToRaw, isDidKey, isKeyId, resolveDidKey, didWebToUrl, buildDidWebDocument, createResolver, base58Encode, base58Decode, } from "./did.js";
|
|
17
|
+
export { issueSponsorCredential, verifySponsorCredential, } from "./credential.js";
|
|
18
|
+
export { handleMcp, startStdioServer } from "./mcp-server.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,WAAW,EAA2B,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,sBAAsB,EAAE,YAAY,EAA2B,MAAM,cAAc,CAAC;AACxH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAsB,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,cAAc,EAA+C,MAAM,YAAY,CAAC;AACtG,OAAO,EACL,SAAS,EACT,WAAW,GAMZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,QAAQ,EACR,OAAO,EACP,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,YAAY,GAIb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAKxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAA6C,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface JsonRpcRequest {
|
|
2
|
+
jsonrpc: "2.0";
|
|
3
|
+
id?: string | number | null;
|
|
4
|
+
method: string;
|
|
5
|
+
params?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface JsonRpcResponse {
|
|
8
|
+
jsonrpc: "2.0";
|
|
9
|
+
id: string | number | null;
|
|
10
|
+
result?: unknown;
|
|
11
|
+
error?: {
|
|
12
|
+
code: number;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Pure MCP message handler. Returns a response, or null for notifications (no id / no reply).
|
|
18
|
+
* Testable without stdio.
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleMcp(req: JsonRpcRequest): JsonRpcResponse | null;
|
|
21
|
+
/** Start the stdio JSON-RPC loop (line-delimited). */
|
|
22
|
+
export declare function startStdioServer(): void;
|
|
23
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAoFA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AACD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,eAAe,GAAG,IAAI,CAiCrE;AAED,sDAAsD;AACtD,wBAAgB,gBAAgB,IAAI,IAAI,CAwBvC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vantic — an MCP server exposing stateless mandate-verification tools.
|
|
3
|
+
*
|
|
4
|
+
* Exposes Vantic's STATELESS verification primitives as MCP tools, so any MCP host
|
|
5
|
+
* (Claude Desktop, Cursor, agent frameworks) can check authority before an agent acts,
|
|
6
|
+
* with no code. Only safe operations are exposed — no private keys, no signing; key
|
|
7
|
+
* custody and receipt issuance stay client-side in the SDK.
|
|
8
|
+
*
|
|
9
|
+
* Zero dependencies: line-delimited JSON-RPC 2.0 over stdio (MCP stdio transport).
|
|
10
|
+
* As an MCP server, Vantic can be listed in MCP directories (the official registry,
|
|
11
|
+
* mcp.so, Smithery, awesome-mcp) so any MCP host can install it.
|
|
12
|
+
*/
|
|
13
|
+
import { authorize, verifyChain } from "./verify.js";
|
|
14
|
+
import { resolveDidKey } from "./did.js";
|
|
15
|
+
import { verifySponsorCredential } from "./credential.js";
|
|
16
|
+
const SERVER_NAME = "vantic";
|
|
17
|
+
const SERVER_VERSION = "0.1.0";
|
|
18
|
+
const DEFAULT_PROTOCOL = "2025-06-18";
|
|
19
|
+
const TOOLS = [
|
|
20
|
+
{
|
|
21
|
+
name: "mandate_authorize",
|
|
22
|
+
description: "Check whether a candidate agent action is authorized by a delegation envelope, given prior receipts. Returns a Verdict {ok, reasons, cumulativeSpend}. Call this BEFORE letting an agent spend.",
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: {
|
|
26
|
+
envelope: { type: "object", description: "The signed delegation envelope." },
|
|
27
|
+
priorReceipts: { type: "array", description: "Receipts already issued under this envelope (ordered).", items: { type: "object" } },
|
|
28
|
+
action: {
|
|
29
|
+
type: "object",
|
|
30
|
+
description: "The candidate action: { type, counterparty, amount (minor units), currency }.",
|
|
31
|
+
properties: { type: { type: "string" }, counterparty: { type: "string" }, amount: { type: "number" }, currency: { type: "string" } },
|
|
32
|
+
required: ["type", "counterparty", "amount", "currency"],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["envelope", "action"],
|
|
36
|
+
},
|
|
37
|
+
run: (a) => authorize(a.envelope, a.priorReceipts ?? [], a.action),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "mandate_verify_chain",
|
|
41
|
+
description: "Verify an envelope and its full receipt chain (the dispute-evidence bundle). Returns a Verdict.",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
envelope: { type: "object" },
|
|
46
|
+
receiptChain: { type: "array", items: { type: "object" } },
|
|
47
|
+
},
|
|
48
|
+
required: ["envelope"],
|
|
49
|
+
},
|
|
50
|
+
run: (a) => verifyChain(a.envelope, a.receiptChain ?? []),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "mandate_verify_credential",
|
|
54
|
+
description: "Verify a W3C sponsor Verifiable Credential (the human sponsor chain). Returns { ok, reasons }.",
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
credential: { type: "object" },
|
|
59
|
+
expectSubject: { type: "string", description: "Optional: require this subject DID." },
|
|
60
|
+
},
|
|
61
|
+
required: ["credential"],
|
|
62
|
+
},
|
|
63
|
+
run: (a) => verifySponsorCredential(a.credential, a.expectSubject ? { expectSubject: a.expectSubject } : {}),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "mandate_resolve_did",
|
|
67
|
+
description: "Resolve a did:key identifier to its W3C DID document.",
|
|
68
|
+
inputSchema: { type: "object", properties: { did: { type: "string" } }, required: ["did"] },
|
|
69
|
+
run: (a) => resolveDidKey(a.did),
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Pure MCP message handler. Returns a response, or null for notifications (no id / no reply).
|
|
74
|
+
* Testable without stdio.
|
|
75
|
+
*/
|
|
76
|
+
export function handleMcp(req) {
|
|
77
|
+
const isNotification = req.id === undefined || req.id === null;
|
|
78
|
+
const reply = (result) => ({ jsonrpc: "2.0", id: req.id ?? null, result });
|
|
79
|
+
const fail = (code, message) => ({ jsonrpc: "2.0", id: req.id ?? null, error: { code, message } });
|
|
80
|
+
switch (req.method) {
|
|
81
|
+
case "initialize":
|
|
82
|
+
return reply({
|
|
83
|
+
protocolVersion: req.params?.protocolVersion ?? DEFAULT_PROTOCOL,
|
|
84
|
+
capabilities: { tools: {} },
|
|
85
|
+
serverInfo: { name: SERVER_NAME, version: SERVER_VERSION },
|
|
86
|
+
});
|
|
87
|
+
case "notifications/initialized":
|
|
88
|
+
return null; // notification: no reply
|
|
89
|
+
case "ping":
|
|
90
|
+
return reply({});
|
|
91
|
+
case "tools/list":
|
|
92
|
+
return reply({ tools: TOOLS.map(({ name, description, inputSchema }) => ({ name, description, inputSchema })) });
|
|
93
|
+
case "tools/call": {
|
|
94
|
+
const name = req.params?.name;
|
|
95
|
+
const tool = TOOLS.find((t) => t.name === name);
|
|
96
|
+
if (!tool)
|
|
97
|
+
return isNotification ? null : fail(-32602, `unknown tool: ${name}`);
|
|
98
|
+
try {
|
|
99
|
+
const out = tool.run(req.params?.arguments ?? {});
|
|
100
|
+
return reply({ content: [{ type: "text", text: JSON.stringify(out, null, 2) }] });
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
return reply({ content: [{ type: "text", text: `error: ${e.message}` }], isError: true });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
default:
|
|
107
|
+
if (isNotification)
|
|
108
|
+
return null;
|
|
109
|
+
return fail(-32601, `method not found: ${req.method}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Start the stdio JSON-RPC loop (line-delimited). */
|
|
113
|
+
export function startStdioServer() {
|
|
114
|
+
let buffer = "";
|
|
115
|
+
process.stdin.setEncoding("utf8");
|
|
116
|
+
process.stdin.on("data", (chunk) => {
|
|
117
|
+
buffer += chunk;
|
|
118
|
+
let idx;
|
|
119
|
+
while ((idx = buffer.indexOf("\n")) >= 0) {
|
|
120
|
+
const lineRaw = buffer.slice(0, idx);
|
|
121
|
+
buffer = buffer.slice(idx + 1);
|
|
122
|
+
const line = lineRaw.trim();
|
|
123
|
+
if (!line)
|
|
124
|
+
continue;
|
|
125
|
+
let req;
|
|
126
|
+
try {
|
|
127
|
+
req = JSON.parse(line);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "parse error" } }) + "\n");
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const res = handleMcp(req);
|
|
134
|
+
if (res)
|
|
135
|
+
process.stdout.write(JSON.stringify(res) + "\n");
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
// eslint-disable-next-line no-console
|
|
139
|
+
console.error(`vantic MCP server ready (stdio) — tools: ${TOOLS.map((t) => t.name).join(", ")}`);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAI1D,MAAM,WAAW,GAAG,QAAQ,CAAC;AAC7B,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAStC,MAAM,KAAK,GAAc;IACvB;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EACT,iMAAiM;QACnM,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE;gBAC5E,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,wDAAwD,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;gBAClI,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oB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C,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;gBAC3H,SAAS;YACX,CAAC;YACD,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,GAAG;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC,CAAC;IACH,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,4CAA4C,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnG,CAAC"}
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":""}
|
package/dist/mcp.js
ADDED
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":";AACA,6EAA6E;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Action, type Mandate, type Outcome, type Receipt } from "./types.js";
|
|
2
|
+
export interface IssueReceiptParams {
|
|
3
|
+
/** The signed envelope this action is taken under. */
|
|
4
|
+
envelope: Mandate;
|
|
5
|
+
/** Agent's PKCS#8 PEM private key — signs the receipt. Must match envelope.agent. */
|
|
6
|
+
agentPrivateKeyPem: string;
|
|
7
|
+
action: Action;
|
|
8
|
+
/** SHA-256 (hex) of the previous receipt in this envelope's chain, or null for the first. */
|
|
9
|
+
prevReceiptHash?: string | null;
|
|
10
|
+
outcome?: Outcome;
|
|
11
|
+
now?: Date;
|
|
12
|
+
}
|
|
13
|
+
/** Create and sign a receipt bound to `envelope`. */
|
|
14
|
+
export declare function issueReceipt(params: IssueReceiptParams): Receipt;
|
|
15
|
+
/** SHA-256 (hex) of the canonical signed receipt — the link for the next receipt in the chain. */
|
|
16
|
+
export declare function receiptHash(receipt: Receipt): string;
|
|
17
|
+
/** Verify the receipt's signature is a valid Ed25519 signature by its `agent`. */
|
|
18
|
+
export declare function verifyReceiptSignature(receipt: Receipt): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Convenience for building a chain: given prior receipts (in order), return the hash to
|
|
21
|
+
* put in the next receipt's `prevReceiptHash`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function nextPrevHash(chain: Receipt[]): string | null;
|
|
24
|
+
//# sourceMappingURL=receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipt.d.ts","sourceRoot":"","sources":["../src/receipt.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpG,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,QAAQ,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAehE;AAED,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAG5D"}
|
package/dist/receipt.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Receipt: a signed, hash-chained record of an action taken under an envelope.
|
|
3
|
+
* See spec §5.
|
|
4
|
+
*/
|
|
5
|
+
import { canonicalize, newId, sha256Hex, signObject, verifyObjectSignature } from "./crypto.js";
|
|
6
|
+
import { mandateHash } from "./envelope.js";
|
|
7
|
+
import { MANDATE_VERSION } from "./types.js";
|
|
8
|
+
/** Create and sign a receipt bound to `envelope`. */
|
|
9
|
+
export function issueReceipt(params) {
|
|
10
|
+
const now = params.now ?? new Date();
|
|
11
|
+
const base = {
|
|
12
|
+
version: MANDATE_VERSION,
|
|
13
|
+
id: newId(),
|
|
14
|
+
mandateId: params.envelope.id,
|
|
15
|
+
mandateHash: mandateHash(params.envelope),
|
|
16
|
+
agent: params.envelope.agent,
|
|
17
|
+
action: params.action,
|
|
18
|
+
timestamp: now.toISOString(),
|
|
19
|
+
prevReceiptHash: params.prevReceiptHash ?? null,
|
|
20
|
+
outcome: params.outcome ?? "pending",
|
|
21
|
+
};
|
|
22
|
+
const signature = signObject(base, params.envelope.agent, params.agentPrivateKeyPem);
|
|
23
|
+
return { ...base, signature };
|
|
24
|
+
}
|
|
25
|
+
/** SHA-256 (hex) of the canonical signed receipt — the link for the next receipt in the chain. */
|
|
26
|
+
export function receiptHash(receipt) {
|
|
27
|
+
return sha256Hex(canonicalize(receipt));
|
|
28
|
+
}
|
|
29
|
+
/** Verify the receipt's signature is a valid Ed25519 signature by its `agent`. */
|
|
30
|
+
export function verifyReceiptSignature(receipt) {
|
|
31
|
+
return verifyObjectSignature(receipt, receipt.agent);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convenience for building a chain: given prior receipts (in order), return the hash to
|
|
35
|
+
* put in the next receipt's `prevReceiptHash`.
|
|
36
|
+
*/
|
|
37
|
+
export function nextPrevHash(chain) {
|
|
38
|
+
const last = chain[chain.length - 1];
|
|
39
|
+
return last ? receiptHash(last) : null;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipt.js","sourceRoot":"","sources":["../src/receipt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAyD,MAAM,YAAY,CAAC;AAcpG,qDAAqD;AACrD,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;IACrC,MAAM,IAAI,GAAY;QACpB,OAAO,EAAE,eAAe;QACxB,EAAE,EAAE,KAAK,EAAE;QACX,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC7B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC;QACzC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,GAAG,CAAC,WAAW,EAAE;QAC5B,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,IAAI;QAC/C,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,SAAS;KACrC,CAAC;IACF,MAAM,SAAS,GAAG,UAAU,CAAC,IAA0C,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAC3H,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO,qBAAqB,CAAC,OAA6C,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Revocation — a simple in-memory revocation list for mandates.
|
|
3
|
+
*
|
|
4
|
+
* You maintain a list of revoked mandate ids and pass its `isRevoked` to verification via
|
|
5
|
+
* `VerifyOptions.isRevoked`; verification then rejects any revoked mandate. A production
|
|
6
|
+
* deployment backs this with a persisted / fetched status list (e.g. resolved from a
|
|
7
|
+
* mandate's `revocation.url`) — that transport is a v1.0 item (see ROADMAP).
|
|
8
|
+
*/
|
|
9
|
+
export declare class RevocationList {
|
|
10
|
+
private readonly revoked;
|
|
11
|
+
constructor(revokedMandateIds?: string[]);
|
|
12
|
+
/** Revoke a mandate by its id. */
|
|
13
|
+
revoke(mandateId: string): void;
|
|
14
|
+
/** Un-revoke a mandate (e.g. if added in error). */
|
|
15
|
+
restore(mandateId: string): void;
|
|
16
|
+
/** True if the mandate's id is revoked. Shape matches `VerifyOptions.isRevoked`. */
|
|
17
|
+
isRevoked: (mandate: {
|
|
18
|
+
id: string;
|
|
19
|
+
}) => boolean;
|
|
20
|
+
/** Number of revoked ids. */
|
|
21
|
+
get size(): number;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=revocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revocation.d.ts","sourceRoot":"","sources":["../src/revocation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,iBAAiB,GAAE,MAAM,EAAO;IAI5C,kCAAkC;IAClC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/B,oDAAoD;IACpD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIhC,oFAAoF;IACpF,SAAS,GAAI,SAAS;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAiC;IAE/E,6BAA6B;IAC7B,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Revocation — a simple in-memory revocation list for mandates.
|
|
3
|
+
*
|
|
4
|
+
* You maintain a list of revoked mandate ids and pass its `isRevoked` to verification via
|
|
5
|
+
* `VerifyOptions.isRevoked`; verification then rejects any revoked mandate. A production
|
|
6
|
+
* deployment backs this with a persisted / fetched status list (e.g. resolved from a
|
|
7
|
+
* mandate's `revocation.url`) — that transport is a v1.0 item (see ROADMAP).
|
|
8
|
+
*/
|
|
9
|
+
export class RevocationList {
|
|
10
|
+
revoked = new Set();
|
|
11
|
+
constructor(revokedMandateIds = []) {
|
|
12
|
+
for (const id of revokedMandateIds)
|
|
13
|
+
this.revoked.add(id);
|
|
14
|
+
}
|
|
15
|
+
/** Revoke a mandate by its id. */
|
|
16
|
+
revoke(mandateId) {
|
|
17
|
+
this.revoked.add(mandateId);
|
|
18
|
+
}
|
|
19
|
+
/** Un-revoke a mandate (e.g. if added in error). */
|
|
20
|
+
restore(mandateId) {
|
|
21
|
+
this.revoked.delete(mandateId);
|
|
22
|
+
}
|
|
23
|
+
/** True if the mandate's id is revoked. Shape matches `VerifyOptions.isRevoked`. */
|
|
24
|
+
isRevoked = (mandate) => this.revoked.has(mandate.id);
|
|
25
|
+
/** Number of revoked ids. */
|
|
26
|
+
get size() {
|
|
27
|
+
return this.revoked.size;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=revocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revocation.js","sourceRoot":"","sources":["../src/revocation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACR,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAE7C,YAAY,oBAA8B,EAAE;QAC1C,KAAK,MAAM,EAAE,IAAI,iBAAiB;YAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,kCAAkC;IAClC,MAAM,CAAC,SAAiB;QACtB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED,oDAAoD;IACpD,OAAO,CAAC,SAAiB;QACvB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED,oFAAoF;IACpF,SAAS,GAAG,CAAC,OAAuB,EAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAE/E,6BAA6B;IAC7B,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vantic Protocol v0.1 — core types.
|
|
3
|
+
* See ../../spec/SPEC.md for the normative definitions.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MANDATE_VERSION: "mandate/0.1";
|
|
6
|
+
export type MandateVersion = typeof MANDATE_VERSION;
|
|
7
|
+
/** RFC 3339 / ISO 8601 timestamp, e.g. "2026-07-29T12:00:00.000Z". */
|
|
8
|
+
export type ISO8601 = string;
|
|
9
|
+
/** A key id of the form `key:<base64url raw ed25519 public key>`. */
|
|
10
|
+
export type KeyId = string;
|
|
11
|
+
export interface KeyPair {
|
|
12
|
+
/** Public key id: `key:<x>`. Safe to share; this is the agent/principal identifier. */
|
|
13
|
+
publicKey: KeyId;
|
|
14
|
+
/** The same key as a W3C `did:key:z...` identifier. Interchangeable with `publicKey`. */
|
|
15
|
+
did: string;
|
|
16
|
+
/** PKCS#8 PEM private key. Secret. */
|
|
17
|
+
privateKeyPem: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Signature {
|
|
20
|
+
alg: "Ed25519";
|
|
21
|
+
/** Key id of the signer. */
|
|
22
|
+
by: KeyId;
|
|
23
|
+
/** base64url-encoded Ed25519 signature. */
|
|
24
|
+
value: string;
|
|
25
|
+
}
|
|
26
|
+
/** Rolling spend cap: at most `amount` minor units of `currency` per `windowSeconds`. */
|
|
27
|
+
export interface BudgetLimit {
|
|
28
|
+
/** ISO 4217 currency code, e.g. "USD". */
|
|
29
|
+
currency: string;
|
|
30
|
+
/** Integer, in the currency's minor unit (e.g. cents). */
|
|
31
|
+
amount: number;
|
|
32
|
+
/** Rolling window length in seconds (e.g. 604800 = 7 days). */
|
|
33
|
+
windowSeconds: number;
|
|
34
|
+
}
|
|
35
|
+
/** All fields optional; an omitted field means "unconstrained on this dimension". */
|
|
36
|
+
export interface Scope {
|
|
37
|
+
budget?: BudgetLimit;
|
|
38
|
+
/** Per-transaction ceiling, integer minor units. */
|
|
39
|
+
maxPerTransaction?: number;
|
|
40
|
+
/** Whitelist of allowed `action.type` values. */
|
|
41
|
+
allowedActions?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Whitelist of counterparty identifiers. Each entry is either an exact match
|
|
44
|
+
* (`"etsy.com"`) or a leading-wildcard domain suffix (`"*.shop.example"`).
|
|
45
|
+
*/
|
|
46
|
+
allowedCounterparties?: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface Mandate {
|
|
49
|
+
version: MandateVersion;
|
|
50
|
+
id: string;
|
|
51
|
+
/** The agent authorized to act. */
|
|
52
|
+
agent: KeyId;
|
|
53
|
+
/** The principal (human/org sponsor) granting authority. */
|
|
54
|
+
principal: KeyId;
|
|
55
|
+
issuedAt: ISO8601;
|
|
56
|
+
expiresAt: ISO8601;
|
|
57
|
+
scope: Scope;
|
|
58
|
+
revocation?: {
|
|
59
|
+
url?: string;
|
|
60
|
+
};
|
|
61
|
+
/** Present on issued envelopes; signed by `principal`. */
|
|
62
|
+
signature?: Signature;
|
|
63
|
+
}
|
|
64
|
+
export interface Action {
|
|
65
|
+
/** e.g. "purchase", "subscribe". Constrained by scope.allowedActions. */
|
|
66
|
+
type: string;
|
|
67
|
+
/** Counterparty identifier (domain or id). Constrained by scope.allowedCounterparties. */
|
|
68
|
+
counterparty: string;
|
|
69
|
+
/** Integer, minor units of `currency`. */
|
|
70
|
+
amount: number;
|
|
71
|
+
currency: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
}
|
|
74
|
+
export type Outcome = "pending" | "settled" | "failed" | "disputed";
|
|
75
|
+
export interface Receipt {
|
|
76
|
+
version: MandateVersion;
|
|
77
|
+
id: string;
|
|
78
|
+
mandateId: string;
|
|
79
|
+
/** SHA-256 (hex) of the canonical signed envelope this receipt acts under. */
|
|
80
|
+
mandateHash: string;
|
|
81
|
+
agent: KeyId;
|
|
82
|
+
action: Action;
|
|
83
|
+
timestamp: ISO8601;
|
|
84
|
+
/** SHA-256 (hex) of the previous receipt in this envelope's chain; null for the first. */
|
|
85
|
+
prevReceiptHash: string | null;
|
|
86
|
+
outcome: Outcome;
|
|
87
|
+
/** Present on issued receipts; signed by `agent`. */
|
|
88
|
+
signature?: Signature;
|
|
89
|
+
}
|
|
90
|
+
/** Result of a verification or authorization check. */
|
|
91
|
+
export interface Verdict {
|
|
92
|
+
ok: boolean;
|
|
93
|
+
/** Human-readable failure reasons; empty iff ok. */
|
|
94
|
+
reasons: string[];
|
|
95
|
+
/** Spend within the budget window at evaluation time (minor units), if a budget is set. */
|
|
96
|
+
cumulativeSpend?: number;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAG,aAAsB,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,OAAO,eAAe,CAAC;AAEpD,sEAAsE;AACtE,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,qEAAqE;AACrE,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B,MAAM,WAAW,OAAO;IACtB,uFAAuF;IACvF,SAAS,EAAE,KAAK,CAAC;IACjB,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B;IAC5B,EAAE,EAAE,KAAK,CAAC;IACV,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,yFAAyF;AACzF,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,qFAAqF;AACrF,MAAM,WAAW,KAAK;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,OAA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AAM,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,aAAsB,CAAC"}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Action, Mandate, Receipt, Verdict } from "./types.js";
|
|
2
|
+
export interface VerifyOptions {
|
|
3
|
+
/** Evaluation time. Defaults to now. */
|
|
4
|
+
now?: Date;
|
|
5
|
+
/** Pluggable revocation check. Return true if the mandate is revoked. */
|
|
6
|
+
isRevoked?: (env: Mandate) => boolean;
|
|
7
|
+
/** Tolerance (seconds) applied to issuedAt/expiresAt to absorb clock differences. Default 0. */
|
|
8
|
+
clockSkewSeconds?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Counterparty matcher: exact match or leading-wildcard domain suffix (`*.shop.example`). */
|
|
11
|
+
export declare function counterpartyAllowed(allowed: string[] | undefined, counterparty: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Full verification of an envelope and its ordered receipt chain (spec §6).
|
|
14
|
+
* This is what a verifier runs on a dispute-evidence bundle.
|
|
15
|
+
*/
|
|
16
|
+
export declare function verifyChain(env: Mandate, receipts: Receipt[], opts?: VerifyOptions): Verdict;
|
|
17
|
+
/**
|
|
18
|
+
* Pre-transaction authorization (the gateway path). Given the envelope, the prior
|
|
19
|
+
* receipt chain, and a candidate action, decide whether the agent may proceed.
|
|
20
|
+
* Validates the envelope, the existing chain, the candidate's static scope, and the
|
|
21
|
+
* budget *including* the candidate.
|
|
22
|
+
*/
|
|
23
|
+
export declare function authorize(env: Mandate, priorReceipts: Receipt[], candidate: Action, opts?: VerifyOptions): Verdict;
|
|
24
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAS,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,yEAAyE;IACzE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;IACtC,gGAAgG;IAChG,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAUhG;AA4CD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CA6BhG;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,OAAO,EACZ,aAAa,EAAE,OAAO,EAAE,EACxB,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,aAAkB,GACvB,OAAO,CAuBT"}
|