@vorim/sdk 3.8.1 → 3.9.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/dist/index.cjs +208 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -3
- package/dist/index.d.ts +133 -3
- package/dist/index.js +208 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.d.cts +1 -1
- package/dist/integrations/anthropic.d.ts +1 -1
- package/dist/integrations/ap2.cjs +218 -0
- package/dist/integrations/ap2.cjs.map +1 -0
- package/dist/integrations/ap2.d.cts +95 -0
- package/dist/integrations/ap2.d.ts +95 -0
- package/dist/integrations/ap2.js +192 -0
- package/dist/integrations/ap2.js.map +1 -0
- package/dist/integrations/bank-rails.cjs +173 -0
- package/dist/integrations/bank-rails.cjs.map +1 -0
- package/dist/integrations/bank-rails.d.cts +87 -0
- package/dist/integrations/bank-rails.d.ts +87 -0
- package/dist/integrations/bank-rails.js +147 -0
- package/dist/integrations/bank-rails.js.map +1 -0
- package/dist/integrations/circle.cjs +159 -0
- package/dist/integrations/circle.cjs.map +1 -0
- package/dist/integrations/circle.d.cts +75 -0
- package/dist/integrations/circle.d.ts +75 -0
- package/dist/integrations/circle.js +133 -0
- package/dist/integrations/circle.js.map +1 -0
- package/dist/integrations/crewai.d.cts +1 -1
- package/dist/integrations/crewai.d.ts +1 -1
- package/dist/integrations/hermes.d.cts +1 -1
- package/dist/integrations/hermes.d.ts +1 -1
- package/dist/integrations/langchain.d.cts +1 -1
- package/dist/integrations/langchain.d.ts +1 -1
- package/dist/integrations/langgraph.d.cts +1 -1
- package/dist/integrations/langgraph.d.ts +1 -1
- package/dist/integrations/llamaindex.d.cts +1 -1
- package/dist/integrations/llamaindex.d.ts +1 -1
- package/dist/integrations/nekuda.cjs +165 -0
- package/dist/integrations/nekuda.cjs.map +1 -0
- package/dist/integrations/nekuda.d.cts +79 -0
- package/dist/integrations/nekuda.d.ts +79 -0
- package/dist/integrations/nekuda.js +139 -0
- package/dist/integrations/nekuda.js.map +1 -0
- package/dist/integrations/openai.d.cts +1 -1
- package/dist/integrations/openai.d.ts +1 -1
- package/dist/integrations/paypal-agent.cjs +215 -0
- package/dist/integrations/paypal-agent.cjs.map +1 -0
- package/dist/integrations/paypal-agent.d.cts +87 -0
- package/dist/integrations/paypal-agent.d.ts +87 -0
- package/dist/integrations/paypal-agent.js +189 -0
- package/dist/integrations/paypal-agent.js.map +1 -0
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.cjs +166 -0
- package/dist/integrations/skyfire.cjs.map +1 -0
- package/dist/integrations/skyfire.d.cts +80 -0
- package/dist/integrations/skyfire.d.ts +80 -0
- package/dist/integrations/skyfire.js +140 -0
- package/dist/integrations/skyfire.js.map +1 -0
- package/dist/integrations/stripe-acp.d.cts +1 -1
- package/dist/integrations/stripe-acp.d.ts +1 -1
- package/dist/integrations/ucp.d.cts +1 -1
- package/dist/integrations/ucp.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.cts +1 -1
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/x402.cjs +211 -0
- package/dist/integrations/x402.cjs.map +1 -0
- package/dist/integrations/x402.d.cts +87 -0
- package/dist/integrations/x402.d.ts +87 -0
- package/dist/integrations/x402.js +185 -0
- package/dist/integrations/x402.js.map +1 -0
- package/dist/{types-Cb6V-boJ.d.cts → types-zzK9YOoa.d.cts} +86 -1
- package/dist/{types-Cb6V-boJ.d.ts → types-zzK9YOoa.d.ts} +86 -1
- package/package.json +71 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/x402.ts
|
|
21
|
+
var x402_exports = {};
|
|
22
|
+
__export(x402_exports, {
|
|
23
|
+
VorimX402: () => VorimX402,
|
|
24
|
+
createVorimX402: () => createVorimX402
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(x402_exports);
|
|
27
|
+
var VorimX402 = class _VorimX402 {
|
|
28
|
+
sdk;
|
|
29
|
+
minTrustScore;
|
|
30
|
+
requiredScope;
|
|
31
|
+
/** One-time guard so the no-auth confused-deputy warning logs at most once. */
|
|
32
|
+
static _warnedNoAuth = false;
|
|
33
|
+
constructor(sdk, config) {
|
|
34
|
+
this.sdk = sdk;
|
|
35
|
+
this.minTrustScore = config?.minTrustScore ?? 50;
|
|
36
|
+
this.requiredScope = config?.requiredScope ?? "agent:transact";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Verify an agent is authorized to settle an x402 payment. Same gate as the
|
|
40
|
+
* ACP integration: transact scope → active status → trust threshold. Every
|
|
41
|
+
* outcome (allow or deny) is recorded on the audit trail.
|
|
42
|
+
*/
|
|
43
|
+
async authorizePayment(req) {
|
|
44
|
+
const threshold = req.minTrustScore ?? this.minTrustScore;
|
|
45
|
+
try {
|
|
46
|
+
const perm = await this.sdk.check(req.agentId, this.requiredScope);
|
|
47
|
+
if (!perm.allowed) {
|
|
48
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Missing ${this.requiredScope}` });
|
|
49
|
+
return {
|
|
50
|
+
authorized: false,
|
|
51
|
+
agentId: req.agentId,
|
|
52
|
+
trustScore: 0,
|
|
53
|
+
status: "unknown",
|
|
54
|
+
reason: `Agent does not have ${this.requiredScope} permission`,
|
|
55
|
+
scopeVerified: false
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: e.message });
|
|
60
|
+
return {
|
|
61
|
+
authorized: false,
|
|
62
|
+
agentId: req.agentId,
|
|
63
|
+
trustScore: 0,
|
|
64
|
+
status: "unknown",
|
|
65
|
+
reason: `Permission check failed: ${e.message}`,
|
|
66
|
+
scopeVerified: false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
let score = 0;
|
|
70
|
+
let status = "unknown";
|
|
71
|
+
try {
|
|
72
|
+
const trust = await this.sdk.verify(req.agentId);
|
|
73
|
+
score = trust.trust_score ?? 0;
|
|
74
|
+
status = trust.status ?? "unknown";
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
if (status !== "active") {
|
|
78
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Status: ${status}` });
|
|
79
|
+
return {
|
|
80
|
+
authorized: false,
|
|
81
|
+
agentId: req.agentId,
|
|
82
|
+
trustScore: score,
|
|
83
|
+
status,
|
|
84
|
+
reason: `Agent is ${status}, not active`,
|
|
85
|
+
scopeVerified: true
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (score < threshold) {
|
|
89
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Score ${score} < ${threshold}` });
|
|
90
|
+
return {
|
|
91
|
+
authorized: false,
|
|
92
|
+
agentId: req.agentId,
|
|
93
|
+
trustScore: score,
|
|
94
|
+
status,
|
|
95
|
+
reason: `Trust score ${score} is below minimum ${threshold}`,
|
|
96
|
+
scopeVerified: true
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
await this.logEvent(req.agentId, "x402.authorize", "success", req, { trust_score: score });
|
|
100
|
+
return {
|
|
101
|
+
authorized: true,
|
|
102
|
+
agentId: req.agentId,
|
|
103
|
+
trustScore: score,
|
|
104
|
+
status,
|
|
105
|
+
scopeVerified: true
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** Log that a 402 payment was settled (proof-of-payment accepted). */
|
|
109
|
+
async logPaymentSettled(agentId, paymentId, req) {
|
|
110
|
+
await this.logEvent(agentId, "x402.settled", "success", req, { payment_id: paymentId });
|
|
111
|
+
}
|
|
112
|
+
/** Log that a 402 payment failed or was rejected by the resource server. */
|
|
113
|
+
async logPaymentFailed(agentId, paymentId, reason, req) {
|
|
114
|
+
await this.logEvent(agentId, "x402.failed", "error", req, { payment_id: paymentId, fail_reason: reason });
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Express/Connect middleware for a resource server that gates paid endpoints
|
|
118
|
+
* on agent authorization.
|
|
119
|
+
*
|
|
120
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
|
|
121
|
+
* only; it does NOT prove the HTTP caller controls that agent (any client can
|
|
122
|
+
* send any agent id in the header). Authenticate the caller-to-agent binding
|
|
123
|
+
* upstream, or pass `authenticate` — an async hook that returns true only if
|
|
124
|
+
* the request genuinely speaks for `agentId`. When omitted, a one-time
|
|
125
|
+
* warning is logged.
|
|
126
|
+
*/
|
|
127
|
+
middleware(options) {
|
|
128
|
+
const header = options?.agentIdHeader ?? "x-vorim-agent-id";
|
|
129
|
+
const threshold = options?.minTrustScore ?? this.minTrustScore;
|
|
130
|
+
const authenticate = options?.authenticate;
|
|
131
|
+
if (!authenticate && !_VorimX402._warnedNoAuth) {
|
|
132
|
+
_VorimX402._warnedNoAuth = true;
|
|
133
|
+
console.warn(
|
|
134
|
+
"[vorim] VorimX402.middleware() called without an `authenticate` hook: it authorizes the agent NAMED in the header but does not verify the caller controls that agent (confused-deputy risk). Authenticate the caller-to-agent binding upstream or pass `authenticate`."
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return async (req, res, next) => {
|
|
138
|
+
const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
|
|
139
|
+
if (!agentId) {
|
|
140
|
+
res.status(401).json({
|
|
141
|
+
error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` }
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (authenticate) {
|
|
146
|
+
let bound = false;
|
|
147
|
+
try {
|
|
148
|
+
bound = await authenticate(agentId, req);
|
|
149
|
+
} catch {
|
|
150
|
+
bound = false;
|
|
151
|
+
}
|
|
152
|
+
if (!bound) {
|
|
153
|
+
res.status(401).json({
|
|
154
|
+
error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" }
|
|
155
|
+
});
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const auth = await this.authorizePayment({
|
|
160
|
+
agentId,
|
|
161
|
+
resource: req.originalUrl || req.url || "",
|
|
162
|
+
amount: req.body?.amount || 0,
|
|
163
|
+
currency: req.body?.currency || "USDC",
|
|
164
|
+
payTo: req.body?.payTo || "",
|
|
165
|
+
minTrustScore: threshold
|
|
166
|
+
});
|
|
167
|
+
if (!auth.authorized) {
|
|
168
|
+
res.status(402).json({
|
|
169
|
+
error: {
|
|
170
|
+
code: "UNAUTHORIZED_AGENT",
|
|
171
|
+
message: auth.reason || "Agent not authorized for x402 payment",
|
|
172
|
+
trust_score: auth.trustScore,
|
|
173
|
+
status: auth.status
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
req.vorimAuthorization = auth;
|
|
179
|
+
next();
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async logEvent(agentId, action, result, req, metadata) {
|
|
183
|
+
try {
|
|
184
|
+
await this.sdk.emit({
|
|
185
|
+
agent_id: agentId,
|
|
186
|
+
event_type: "api_request",
|
|
187
|
+
action,
|
|
188
|
+
result,
|
|
189
|
+
resource: req?.resource || "",
|
|
190
|
+
metadata: {
|
|
191
|
+
resource: req?.resource || "",
|
|
192
|
+
amount: req?.amount || 0,
|
|
193
|
+
currency: req?.currency || "",
|
|
194
|
+
pay_to: req?.payTo || "",
|
|
195
|
+
scheme: req?.scheme || "",
|
|
196
|
+
...metadata
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
} catch {
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
function createVorimX402(sdk, config) {
|
|
204
|
+
return new VorimX402(sdk, config);
|
|
205
|
+
}
|
|
206
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
207
|
+
0 && (module.exports = {
|
|
208
|
+
VorimX402,
|
|
209
|
+
createVorimX402
|
|
210
|
+
});
|
|
211
|
+
//# sourceMappingURL=x402.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/x402.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — x402 Integration\n//\n// x402 is an open, HTTP-native payment standard (revived around the HTTP 402\n// \"Payment Required\" status) for machine-to-machine and agentic payments: a\n// server answers a request with 402 + payment requirements, the client pays,\n// and retries with proof of payment. It's a natural fit for AI agents paying\n// per-request for APIs, data, or compute.\n//\n// This integration adds Vorim's identity, permission, and audit layer IN FRONT\n// of an x402 payment: before an agent settles a 402 challenge, it verifies the\n// agent holds the `transact` scope, is active, and clears a trust threshold,\n// then records the payment lifecycle on a signed, tamper-evident audit trail.\n// It does NOT move money or hold keys — it authorizes and attests.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimX402 } from '@vorim/sdk/integrations/x402';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const x402 = createVorimX402(vorim, { minTrustScore: 60 });\n//\n// // A 402 came back from a resource server. Before paying, authorize:\n// const auth = await x402.authorizePayment({\n// agentId: 'agid_abc123',\n// resource: 'https://api.example.com/v1/report',\n// amount: 1000, // smallest currency unit (e.g. 1000 = $0.01 at 6dp, or 1000 cents)\n// currency: 'USDC',\n// payTo: '0xSeller...',\n// });\n// if (auth.authorized) {\n// // ... settle the x402 challenge, then:\n// await x402.logPaymentSettled(auth.agentId, paymentId, { resource, amount });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport interface X402Config {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n}\n\nexport interface X402PaymentRequest {\n /** The Vorim agent id that will make the payment. */\n agentId: string;\n /** The resource / endpoint being paid for (the thing behind the 402). */\n resource?: string;\n /** Amount in the smallest unit of the currency/asset. */\n amount?: number;\n /** Asset or currency code (e.g. 'USDC', 'usd'). */\n currency?: string;\n /** The recipient address / account the payment settles to. */\n payTo?: string;\n /** The x402 scheme / network hint (e.g. 'exact', 'base-sepolia'). Informational. */\n scheme?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface X402Authorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimX402 {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n /** One-time guard so the no-auth confused-deputy warning logs at most once. */\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<X402Config>) {\n this.sdk = sdk;\n this.minTrustScore = config?.minTrustScore ?? 50;\n this.requiredScope = config?.requiredScope ?? 'agent:transact';\n }\n\n /**\n * Verify an agent is authorized to settle an x402 payment. Same gate as the\n * ACP integration: transact scope → active status → trust threshold. Every\n * outcome (allow or deny) is recorded on the audit trail.\n */\n async authorizePayment(req: X402PaymentRequest): Promise<X402Authorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\n\n // 1. Permission: the agent must hold the transact scope.\n try {\n const perm = await this.sdk.check(req.agentId, this.requiredScope as any);\n if (!(perm as any).allowed) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Missing ${this.requiredScope}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: 0,\n status: 'unknown',\n reason: `Agent does not have ${this.requiredScope} permission`,\n scopeVerified: false,\n };\n }\n } catch (e: any) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: e.message });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: 0,\n status: 'unknown',\n reason: `Permission check failed: ${e.message}`,\n scopeVerified: false,\n };\n }\n\n // 2. Trust: verify the agent's public standing.\n let score = 0;\n let status = 'unknown';\n try {\n const trust = await this.sdk.verify(req.agentId);\n score = (trust as any).trust_score ?? 0;\n status = (trust as any).status ?? 'unknown';\n } catch {\n // Trust verification failed — treated as not-active below.\n }\n\n if (status !== 'active') {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Status: ${status}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: score,\n status,\n reason: `Agent is ${status}, not active`,\n scopeVerified: true,\n };\n }\n\n if (score < threshold) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Score ${score} < ${threshold}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: score,\n status,\n reason: `Trust score ${score} is below minimum ${threshold}`,\n scopeVerified: true,\n };\n }\n\n await this.logEvent(req.agentId, 'x402.authorize', 'success', req, { trust_score: score });\n\n return {\n authorized: true,\n agentId: req.agentId,\n trustScore: score,\n status,\n scopeVerified: true,\n };\n }\n\n /** Log that a 402 payment was settled (proof-of-payment accepted). */\n async logPaymentSettled(agentId: string, paymentId: string, req?: Partial<X402PaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'x402.settled', 'success', req, { payment_id: paymentId });\n }\n\n /** Log that a 402 payment failed or was rejected by the resource server. */\n async logPaymentFailed(agentId: string, paymentId: string, reason?: string, req?: Partial<X402PaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'x402.failed', 'error', req, { payment_id: paymentId, fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware for a resource server that gates paid endpoints\n * on agent authorization.\n *\n * ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing\n * only; it does NOT prove the HTTP caller controls that agent (any client can\n * send any agent id in the header). Authenticate the caller-to-agent binding\n * upstream, or pass `authenticate` — an async hook that returns true only if\n * the request genuinely speaks for `agentId`. When omitted, a one-time\n * warning is logged.\n */\n middleware(options?: {\n agentIdHeader?: string;\n minTrustScore?: number;\n authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;\n }) {\n const header = options?.agentIdHeader ?? 'x-vorim-agent-id';\n const threshold = options?.minTrustScore ?? this.minTrustScore;\n const authenticate = options?.authenticate;\n\n if (!authenticate && !VorimX402._warnedNoAuth) {\n VorimX402._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimX402.middleware() called without an `authenticate` hook: ' +\n 'it authorizes the agent NAMED in the header but does not verify the ' +\n 'caller controls that agent (confused-deputy risk). Authenticate the ' +\n 'caller-to-agent binding upstream or pass `authenticate`.'\n );\n }\n\n return async (req: any, res: any, next: any) => {\n const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || '';\n\n if (!agentId) {\n res.status(401).json({\n error: { code: 'MISSING_AGENT_ID', message: `Agent ID required in ${header} header` },\n });\n return;\n }\n\n if (authenticate) {\n let bound = false;\n try {\n bound = await authenticate(agentId, req);\n } catch {\n bound = false;\n }\n if (!bound) {\n res.status(401).json({\n error: { code: 'AGENT_BINDING_UNVERIFIED', message: 'Caller is not authenticated as the named agent' },\n });\n return;\n }\n }\n\n const auth = await this.authorizePayment({\n agentId,\n resource: req.originalUrl || req.url || '',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'USDC',\n payTo: req.body?.payTo || '',\n minTrustScore: threshold,\n });\n\n if (!auth.authorized) {\n // 402 is the semantically correct status for x402 payment gating.\n res.status(402).json({\n error: {\n code: 'UNAUTHORIZED_AGENT',\n message: auth.reason || 'Agent not authorized for x402 payment',\n trust_score: auth.trustScore,\n status: auth.status,\n },\n });\n return;\n }\n\n req.vorimAuthorization = auth;\n next();\n };\n }\n\n private async logEvent(\n agentId: string,\n action: string,\n result: 'success' | 'denied' | 'error',\n req?: Partial<X402PaymentRequest>,\n metadata?: Record<string, any>,\n ): Promise<void> {\n try {\n await this.sdk.emit({\n agent_id: agentId,\n event_type: 'api_request',\n action,\n result,\n resource: req?.resource || '',\n metadata: {\n resource: req?.resource || '',\n amount: req?.amount || 0,\n currency: req?.currency || '',\n pay_to: req?.payTo || '',\n scheme: req?.scheme || '',\n ...metadata,\n },\n });\n } catch {\n // Never block the payment flow on an audit hiccup.\n }\n }\n}\n\n/**\n * Create a VorimX402 instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimX402 } from '@vorim/sdk/integrations/x402';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const x402 = createVorimX402(vorim, { minTrustScore: 70 });\n *\n * const auth = await x402.authorizePayment({ agentId: 'agid_abc123', resource: '/report', amount: 1000, currency: 'USDC' });\n *\n * app.get('/paid-endpoint', x402.middleware(), handler);\n * ```\n */\nexport function createVorimX402(sdk: VorimSDK, config?: Partial<X402Config>): VorimX402 {\n return new VorimX402(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuEO,IAAM,YAAN,MAAM,WAAU;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAER,OAAe,gBAAgB;AAAA,EAE/B,YAAY,KAAe,QAA8B;AACvD,SAAK,MAAM;AACX,SAAK,gBAAgB,QAAQ,iBAAiB;AAC9C,SAAK,gBAAgB,QAAQ,iBAAiB;AAAA,EAChD;AAAA;AAAA;AAAA;AA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AS;AAAA,UACtB,QAAQ,KAAK,UAAU;AAAA,UACvB,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAkBO,SAAS,gBAAgB,KAAe,QAAyC;AACtF,SAAO,IAAI,UAAU,KAAK,MAAM;AAClC;","names":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import '../types-zzK9YOoa.cjs';
|
|
3
|
+
|
|
4
|
+
interface X402Config {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
minTrustScore?: number;
|
|
8
|
+
requiredScope?: string;
|
|
9
|
+
}
|
|
10
|
+
interface X402PaymentRequest {
|
|
11
|
+
/** The Vorim agent id that will make the payment. */
|
|
12
|
+
agentId: string;
|
|
13
|
+
/** The resource / endpoint being paid for (the thing behind the 402). */
|
|
14
|
+
resource?: string;
|
|
15
|
+
/** Amount in the smallest unit of the currency/asset. */
|
|
16
|
+
amount?: number;
|
|
17
|
+
/** Asset or currency code (e.g. 'USDC', 'usd'). */
|
|
18
|
+
currency?: string;
|
|
19
|
+
/** The recipient address / account the payment settles to. */
|
|
20
|
+
payTo?: string;
|
|
21
|
+
/** The x402 scheme / network hint (e.g. 'exact', 'base-sepolia'). Informational. */
|
|
22
|
+
scheme?: string;
|
|
23
|
+
/** Per-call override of the trust threshold. */
|
|
24
|
+
minTrustScore?: number;
|
|
25
|
+
}
|
|
26
|
+
interface X402Authorization {
|
|
27
|
+
authorized: boolean;
|
|
28
|
+
agentId: string;
|
|
29
|
+
trustScore: number;
|
|
30
|
+
status: string;
|
|
31
|
+
reason?: string;
|
|
32
|
+
scopeVerified: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare class VorimX402 {
|
|
35
|
+
private sdk;
|
|
36
|
+
private minTrustScore;
|
|
37
|
+
private requiredScope;
|
|
38
|
+
/** One-time guard so the no-auth confused-deputy warning logs at most once. */
|
|
39
|
+
private static _warnedNoAuth;
|
|
40
|
+
constructor(sdk: VorimSDK, config?: Partial<X402Config>);
|
|
41
|
+
/**
|
|
42
|
+
* Verify an agent is authorized to settle an x402 payment. Same gate as the
|
|
43
|
+
* ACP integration: transact scope → active status → trust threshold. Every
|
|
44
|
+
* outcome (allow or deny) is recorded on the audit trail.
|
|
45
|
+
*/
|
|
46
|
+
authorizePayment(req: X402PaymentRequest): Promise<X402Authorization>;
|
|
47
|
+
/** Log that a 402 payment was settled (proof-of-payment accepted). */
|
|
48
|
+
logPaymentSettled(agentId: string, paymentId: string, req?: Partial<X402PaymentRequest>): Promise<void>;
|
|
49
|
+
/** Log that a 402 payment failed or was rejected by the resource server. */
|
|
50
|
+
logPaymentFailed(agentId: string, paymentId: string, reason?: string, req?: Partial<X402PaymentRequest>): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Express/Connect middleware for a resource server that gates paid endpoints
|
|
53
|
+
* on agent authorization.
|
|
54
|
+
*
|
|
55
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
|
|
56
|
+
* only; it does NOT prove the HTTP caller controls that agent (any client can
|
|
57
|
+
* send any agent id in the header). Authenticate the caller-to-agent binding
|
|
58
|
+
* upstream, or pass `authenticate` — an async hook that returns true only if
|
|
59
|
+
* the request genuinely speaks for `agentId`. When omitted, a one-time
|
|
60
|
+
* warning is logged.
|
|
61
|
+
*/
|
|
62
|
+
middleware(options?: {
|
|
63
|
+
agentIdHeader?: string;
|
|
64
|
+
minTrustScore?: number;
|
|
65
|
+
authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
|
|
66
|
+
}): (req: any, res: any, next: any) => Promise<void>;
|
|
67
|
+
private logEvent;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a VorimX402 instance.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import createVorim from '@vorim/sdk';
|
|
75
|
+
* import { createVorimX402 } from '@vorim/sdk/integrations/x402';
|
|
76
|
+
*
|
|
77
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
78
|
+
* const x402 = createVorimX402(vorim, { minTrustScore: 70 });
|
|
79
|
+
*
|
|
80
|
+
* const auth = await x402.authorizePayment({ agentId: 'agid_abc123', resource: '/report', amount: 1000, currency: 'USDC' });
|
|
81
|
+
*
|
|
82
|
+
* app.get('/paid-endpoint', x402.middleware(), handler);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare function createVorimX402(sdk: VorimSDK, config?: Partial<X402Config>): VorimX402;
|
|
86
|
+
|
|
87
|
+
export { VorimX402, type X402Authorization, type X402Config, type X402PaymentRequest, createVorimX402 };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import '../types-zzK9YOoa.js';
|
|
3
|
+
|
|
4
|
+
interface X402Config {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
minTrustScore?: number;
|
|
8
|
+
requiredScope?: string;
|
|
9
|
+
}
|
|
10
|
+
interface X402PaymentRequest {
|
|
11
|
+
/** The Vorim agent id that will make the payment. */
|
|
12
|
+
agentId: string;
|
|
13
|
+
/** The resource / endpoint being paid for (the thing behind the 402). */
|
|
14
|
+
resource?: string;
|
|
15
|
+
/** Amount in the smallest unit of the currency/asset. */
|
|
16
|
+
amount?: number;
|
|
17
|
+
/** Asset or currency code (e.g. 'USDC', 'usd'). */
|
|
18
|
+
currency?: string;
|
|
19
|
+
/** The recipient address / account the payment settles to. */
|
|
20
|
+
payTo?: string;
|
|
21
|
+
/** The x402 scheme / network hint (e.g. 'exact', 'base-sepolia'). Informational. */
|
|
22
|
+
scheme?: string;
|
|
23
|
+
/** Per-call override of the trust threshold. */
|
|
24
|
+
minTrustScore?: number;
|
|
25
|
+
}
|
|
26
|
+
interface X402Authorization {
|
|
27
|
+
authorized: boolean;
|
|
28
|
+
agentId: string;
|
|
29
|
+
trustScore: number;
|
|
30
|
+
status: string;
|
|
31
|
+
reason?: string;
|
|
32
|
+
scopeVerified: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare class VorimX402 {
|
|
35
|
+
private sdk;
|
|
36
|
+
private minTrustScore;
|
|
37
|
+
private requiredScope;
|
|
38
|
+
/** One-time guard so the no-auth confused-deputy warning logs at most once. */
|
|
39
|
+
private static _warnedNoAuth;
|
|
40
|
+
constructor(sdk: VorimSDK, config?: Partial<X402Config>);
|
|
41
|
+
/**
|
|
42
|
+
* Verify an agent is authorized to settle an x402 payment. Same gate as the
|
|
43
|
+
* ACP integration: transact scope → active status → trust threshold. Every
|
|
44
|
+
* outcome (allow or deny) is recorded on the audit trail.
|
|
45
|
+
*/
|
|
46
|
+
authorizePayment(req: X402PaymentRequest): Promise<X402Authorization>;
|
|
47
|
+
/** Log that a 402 payment was settled (proof-of-payment accepted). */
|
|
48
|
+
logPaymentSettled(agentId: string, paymentId: string, req?: Partial<X402PaymentRequest>): Promise<void>;
|
|
49
|
+
/** Log that a 402 payment failed or was rejected by the resource server. */
|
|
50
|
+
logPaymentFailed(agentId: string, paymentId: string, reason?: string, req?: Partial<X402PaymentRequest>): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Express/Connect middleware for a resource server that gates paid endpoints
|
|
53
|
+
* on agent authorization.
|
|
54
|
+
*
|
|
55
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
|
|
56
|
+
* only; it does NOT prove the HTTP caller controls that agent (any client can
|
|
57
|
+
* send any agent id in the header). Authenticate the caller-to-agent binding
|
|
58
|
+
* upstream, or pass `authenticate` — an async hook that returns true only if
|
|
59
|
+
* the request genuinely speaks for `agentId`. When omitted, a one-time
|
|
60
|
+
* warning is logged.
|
|
61
|
+
*/
|
|
62
|
+
middleware(options?: {
|
|
63
|
+
agentIdHeader?: string;
|
|
64
|
+
minTrustScore?: number;
|
|
65
|
+
authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
|
|
66
|
+
}): (req: any, res: any, next: any) => Promise<void>;
|
|
67
|
+
private logEvent;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a VorimX402 instance.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import createVorim from '@vorim/sdk';
|
|
75
|
+
* import { createVorimX402 } from '@vorim/sdk/integrations/x402';
|
|
76
|
+
*
|
|
77
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
78
|
+
* const x402 = createVorimX402(vorim, { minTrustScore: 70 });
|
|
79
|
+
*
|
|
80
|
+
* const auth = await x402.authorizePayment({ agentId: 'agid_abc123', resource: '/report', amount: 1000, currency: 'USDC' });
|
|
81
|
+
*
|
|
82
|
+
* app.get('/paid-endpoint', x402.middleware(), handler);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare function createVorimX402(sdk: VorimSDK, config?: Partial<X402Config>): VorimX402;
|
|
86
|
+
|
|
87
|
+
export { VorimX402, type X402Authorization, type X402Config, type X402PaymentRequest, createVorimX402 };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// src/integrations/x402.ts
|
|
2
|
+
var VorimX402 = class _VorimX402 {
|
|
3
|
+
sdk;
|
|
4
|
+
minTrustScore;
|
|
5
|
+
requiredScope;
|
|
6
|
+
/** One-time guard so the no-auth confused-deputy warning logs at most once. */
|
|
7
|
+
static _warnedNoAuth = false;
|
|
8
|
+
constructor(sdk, config) {
|
|
9
|
+
this.sdk = sdk;
|
|
10
|
+
this.minTrustScore = config?.minTrustScore ?? 50;
|
|
11
|
+
this.requiredScope = config?.requiredScope ?? "agent:transact";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Verify an agent is authorized to settle an x402 payment. Same gate as the
|
|
15
|
+
* ACP integration: transact scope → active status → trust threshold. Every
|
|
16
|
+
* outcome (allow or deny) is recorded on the audit trail.
|
|
17
|
+
*/
|
|
18
|
+
async authorizePayment(req) {
|
|
19
|
+
const threshold = req.minTrustScore ?? this.minTrustScore;
|
|
20
|
+
try {
|
|
21
|
+
const perm = await this.sdk.check(req.agentId, this.requiredScope);
|
|
22
|
+
if (!perm.allowed) {
|
|
23
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Missing ${this.requiredScope}` });
|
|
24
|
+
return {
|
|
25
|
+
authorized: false,
|
|
26
|
+
agentId: req.agentId,
|
|
27
|
+
trustScore: 0,
|
|
28
|
+
status: "unknown",
|
|
29
|
+
reason: `Agent does not have ${this.requiredScope} permission`,
|
|
30
|
+
scopeVerified: false
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: e.message });
|
|
35
|
+
return {
|
|
36
|
+
authorized: false,
|
|
37
|
+
agentId: req.agentId,
|
|
38
|
+
trustScore: 0,
|
|
39
|
+
status: "unknown",
|
|
40
|
+
reason: `Permission check failed: ${e.message}`,
|
|
41
|
+
scopeVerified: false
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let score = 0;
|
|
45
|
+
let status = "unknown";
|
|
46
|
+
try {
|
|
47
|
+
const trust = await this.sdk.verify(req.agentId);
|
|
48
|
+
score = trust.trust_score ?? 0;
|
|
49
|
+
status = trust.status ?? "unknown";
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
if (status !== "active") {
|
|
53
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Status: ${status}` });
|
|
54
|
+
return {
|
|
55
|
+
authorized: false,
|
|
56
|
+
agentId: req.agentId,
|
|
57
|
+
trustScore: score,
|
|
58
|
+
status,
|
|
59
|
+
reason: `Agent is ${status}, not active`,
|
|
60
|
+
scopeVerified: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (score < threshold) {
|
|
64
|
+
await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Score ${score} < ${threshold}` });
|
|
65
|
+
return {
|
|
66
|
+
authorized: false,
|
|
67
|
+
agentId: req.agentId,
|
|
68
|
+
trustScore: score,
|
|
69
|
+
status,
|
|
70
|
+
reason: `Trust score ${score} is below minimum ${threshold}`,
|
|
71
|
+
scopeVerified: true
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
await this.logEvent(req.agentId, "x402.authorize", "success", req, { trust_score: score });
|
|
75
|
+
return {
|
|
76
|
+
authorized: true,
|
|
77
|
+
agentId: req.agentId,
|
|
78
|
+
trustScore: score,
|
|
79
|
+
status,
|
|
80
|
+
scopeVerified: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Log that a 402 payment was settled (proof-of-payment accepted). */
|
|
84
|
+
async logPaymentSettled(agentId, paymentId, req) {
|
|
85
|
+
await this.logEvent(agentId, "x402.settled", "success", req, { payment_id: paymentId });
|
|
86
|
+
}
|
|
87
|
+
/** Log that a 402 payment failed or was rejected by the resource server. */
|
|
88
|
+
async logPaymentFailed(agentId, paymentId, reason, req) {
|
|
89
|
+
await this.logEvent(agentId, "x402.failed", "error", req, { payment_id: paymentId, fail_reason: reason });
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Express/Connect middleware for a resource server that gates paid endpoints
|
|
93
|
+
* on agent authorization.
|
|
94
|
+
*
|
|
95
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
|
|
96
|
+
* only; it does NOT prove the HTTP caller controls that agent (any client can
|
|
97
|
+
* send any agent id in the header). Authenticate the caller-to-agent binding
|
|
98
|
+
* upstream, or pass `authenticate` — an async hook that returns true only if
|
|
99
|
+
* the request genuinely speaks for `agentId`. When omitted, a one-time
|
|
100
|
+
* warning is logged.
|
|
101
|
+
*/
|
|
102
|
+
middleware(options) {
|
|
103
|
+
const header = options?.agentIdHeader ?? "x-vorim-agent-id";
|
|
104
|
+
const threshold = options?.minTrustScore ?? this.minTrustScore;
|
|
105
|
+
const authenticate = options?.authenticate;
|
|
106
|
+
if (!authenticate && !_VorimX402._warnedNoAuth) {
|
|
107
|
+
_VorimX402._warnedNoAuth = true;
|
|
108
|
+
console.warn(
|
|
109
|
+
"[vorim] VorimX402.middleware() called without an `authenticate` hook: it authorizes the agent NAMED in the header but does not verify the caller controls that agent (confused-deputy risk). Authenticate the caller-to-agent binding upstream or pass `authenticate`."
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return async (req, res, next) => {
|
|
113
|
+
const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
|
|
114
|
+
if (!agentId) {
|
|
115
|
+
res.status(401).json({
|
|
116
|
+
error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` }
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (authenticate) {
|
|
121
|
+
let bound = false;
|
|
122
|
+
try {
|
|
123
|
+
bound = await authenticate(agentId, req);
|
|
124
|
+
} catch {
|
|
125
|
+
bound = false;
|
|
126
|
+
}
|
|
127
|
+
if (!bound) {
|
|
128
|
+
res.status(401).json({
|
|
129
|
+
error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" }
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const auth = await this.authorizePayment({
|
|
135
|
+
agentId,
|
|
136
|
+
resource: req.originalUrl || req.url || "",
|
|
137
|
+
amount: req.body?.amount || 0,
|
|
138
|
+
currency: req.body?.currency || "USDC",
|
|
139
|
+
payTo: req.body?.payTo || "",
|
|
140
|
+
minTrustScore: threshold
|
|
141
|
+
});
|
|
142
|
+
if (!auth.authorized) {
|
|
143
|
+
res.status(402).json({
|
|
144
|
+
error: {
|
|
145
|
+
code: "UNAUTHORIZED_AGENT",
|
|
146
|
+
message: auth.reason || "Agent not authorized for x402 payment",
|
|
147
|
+
trust_score: auth.trustScore,
|
|
148
|
+
status: auth.status
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
req.vorimAuthorization = auth;
|
|
154
|
+
next();
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async logEvent(agentId, action, result, req, metadata) {
|
|
158
|
+
try {
|
|
159
|
+
await this.sdk.emit({
|
|
160
|
+
agent_id: agentId,
|
|
161
|
+
event_type: "api_request",
|
|
162
|
+
action,
|
|
163
|
+
result,
|
|
164
|
+
resource: req?.resource || "",
|
|
165
|
+
metadata: {
|
|
166
|
+
resource: req?.resource || "",
|
|
167
|
+
amount: req?.amount || 0,
|
|
168
|
+
currency: req?.currency || "",
|
|
169
|
+
pay_to: req?.payTo || "",
|
|
170
|
+
scheme: req?.scheme || "",
|
|
171
|
+
...metadata
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
} catch {
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
function createVorimX402(sdk, config) {
|
|
179
|
+
return new VorimX402(sdk, config);
|
|
180
|
+
}
|
|
181
|
+
export {
|
|
182
|
+
VorimX402,
|
|
183
|
+
createVorimX402
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=x402.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/x402.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — x402 Integration\n//\n// x402 is an open, HTTP-native payment standard (revived around the HTTP 402\n// \"Payment Required\" status) for machine-to-machine and agentic payments: a\n// server answers a request with 402 + payment requirements, the client pays,\n// and retries with proof of payment. It's a natural fit for AI agents paying\n// per-request for APIs, data, or compute.\n//\n// This integration adds Vorim's identity, permission, and audit layer IN FRONT\n// of an x402 payment: before an agent settles a 402 challenge, it verifies the\n// agent holds the `transact` scope, is active, and clears a trust threshold,\n// then records the payment lifecycle on a signed, tamper-evident audit trail.\n// It does NOT move money or hold keys — it authorizes and attests.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimX402 } from '@vorim/sdk/integrations/x402';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const x402 = createVorimX402(vorim, { minTrustScore: 60 });\n//\n// // A 402 came back from a resource server. Before paying, authorize:\n// const auth = await x402.authorizePayment({\n// agentId: 'agid_abc123',\n// resource: 'https://api.example.com/v1/report',\n// amount: 1000, // smallest currency unit (e.g. 1000 = $0.01 at 6dp, or 1000 cents)\n// currency: 'USDC',\n// payTo: '0xSeller...',\n// });\n// if (auth.authorized) {\n// // ... settle the x402 challenge, then:\n// await x402.logPaymentSettled(auth.agentId, paymentId, { resource, amount });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport interface X402Config {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n}\n\nexport interface X402PaymentRequest {\n /** The Vorim agent id that will make the payment. */\n agentId: string;\n /** The resource / endpoint being paid for (the thing behind the 402). */\n resource?: string;\n /** Amount in the smallest unit of the currency/asset. */\n amount?: number;\n /** Asset or currency code (e.g. 'USDC', 'usd'). */\n currency?: string;\n /** The recipient address / account the payment settles to. */\n payTo?: string;\n /** The x402 scheme / network hint (e.g. 'exact', 'base-sepolia'). Informational. */\n scheme?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface X402Authorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimX402 {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n /** One-time guard so the no-auth confused-deputy warning logs at most once. */\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<X402Config>) {\n this.sdk = sdk;\n this.minTrustScore = config?.minTrustScore ?? 50;\n this.requiredScope = config?.requiredScope ?? 'agent:transact';\n }\n\n /**\n * Verify an agent is authorized to settle an x402 payment. Same gate as the\n * ACP integration: transact scope → active status → trust threshold. Every\n * outcome (allow or deny) is recorded on the audit trail.\n */\n async authorizePayment(req: X402PaymentRequest): Promise<X402Authorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\n\n // 1. Permission: the agent must hold the transact scope.\n try {\n const perm = await this.sdk.check(req.agentId, this.requiredScope as any);\n if (!(perm as any).allowed) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Missing ${this.requiredScope}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: 0,\n status: 'unknown',\n reason: `Agent does not have ${this.requiredScope} permission`,\n scopeVerified: false,\n };\n }\n } catch (e: any) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: e.message });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: 0,\n status: 'unknown',\n reason: `Permission check failed: ${e.message}`,\n scopeVerified: false,\n };\n }\n\n // 2. Trust: verify the agent's public standing.\n let score = 0;\n let status = 'unknown';\n try {\n const trust = await this.sdk.verify(req.agentId);\n score = (trust as any).trust_score ?? 0;\n status = (trust as any).status ?? 'unknown';\n } catch {\n // Trust verification failed — treated as not-active below.\n }\n\n if (status !== 'active') {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Status: ${status}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: score,\n status,\n reason: `Agent is ${status}, not active`,\n scopeVerified: true,\n };\n }\n\n if (score < threshold) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Score ${score} < ${threshold}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: score,\n status,\n reason: `Trust score ${score} is below minimum ${threshold}`,\n scopeVerified: true,\n };\n }\n\n await this.logEvent(req.agentId, 'x402.authorize', 'success', req, { trust_score: score });\n\n return {\n authorized: true,\n agentId: req.agentId,\n trustScore: score,\n status,\n scopeVerified: true,\n };\n }\n\n /** Log that a 402 payment was settled (proof-of-payment accepted). */\n async logPaymentSettled(agentId: string, paymentId: string, req?: Partial<X402PaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'x402.settled', 'success', req, { payment_id: paymentId });\n }\n\n /** Log that a 402 payment failed or was rejected by the resource server. */\n async logPaymentFailed(agentId: string, paymentId: string, reason?: string, req?: Partial<X402PaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'x402.failed', 'error', req, { payment_id: paymentId, fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware for a resource server that gates paid endpoints\n * on agent authorization.\n *\n * ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing\n * only; it does NOT prove the HTTP caller controls that agent (any client can\n * send any agent id in the header). Authenticate the caller-to-agent binding\n * upstream, or pass `authenticate` — an async hook that returns true only if\n * the request genuinely speaks for `agentId`. When omitted, a one-time\n * warning is logged.\n */\n middleware(options?: {\n agentIdHeader?: string;\n minTrustScore?: number;\n authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;\n }) {\n const header = options?.agentIdHeader ?? 'x-vorim-agent-id';\n const threshold = options?.minTrustScore ?? this.minTrustScore;\n const authenticate = options?.authenticate;\n\n if (!authenticate && !VorimX402._warnedNoAuth) {\n VorimX402._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimX402.middleware() called without an `authenticate` hook: ' +\n 'it authorizes the agent NAMED in the header but does not verify the ' +\n 'caller controls that agent (confused-deputy risk). Authenticate the ' +\n 'caller-to-agent binding upstream or pass `authenticate`.'\n );\n }\n\n return async (req: any, res: any, next: any) => {\n const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || '';\n\n if (!agentId) {\n res.status(401).json({\n error: { code: 'MISSING_AGENT_ID', message: `Agent ID required in ${header} header` },\n });\n return;\n }\n\n if (authenticate) {\n let bound = false;\n try {\n bound = await authenticate(agentId, req);\n } catch {\n bound = false;\n }\n if (!bound) {\n res.status(401).json({\n error: { code: 'AGENT_BINDING_UNVERIFIED', message: 'Caller is not authenticated as the named agent' },\n });\n return;\n }\n }\n\n const auth = await this.authorizePayment({\n agentId,\n resource: req.originalUrl || req.url || '',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'USDC',\n payTo: req.body?.payTo || '',\n minTrustScore: threshold,\n });\n\n if (!auth.authorized) {\n // 402 is the semantically correct status for x402 payment gating.\n res.status(402).json({\n error: {\n code: 'UNAUTHORIZED_AGENT',\n message: auth.reason || 'Agent not authorized for x402 payment',\n trust_score: auth.trustScore,\n status: auth.status,\n },\n });\n return;\n }\n\n req.vorimAuthorization = auth;\n next();\n };\n }\n\n private async logEvent(\n agentId: string,\n action: string,\n result: 'success' | 'denied' | 'error',\n req?: Partial<X402PaymentRequest>,\n metadata?: Record<string, any>,\n ): Promise<void> {\n try {\n await this.sdk.emit({\n agent_id: agentId,\n event_type: 'api_request',\n action,\n result,\n resource: req?.resource || '',\n metadata: {\n resource: req?.resource || '',\n amount: req?.amount || 0,\n currency: req?.currency || '',\n pay_to: req?.payTo || '',\n scheme: req?.scheme || '',\n ...metadata,\n },\n });\n } catch {\n // Never block the payment flow on an audit hiccup.\n }\n }\n}\n\n/**\n * Create a VorimX402 instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimX402 } from '@vorim/sdk/integrations/x402';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const x402 = createVorimX402(vorim, { minTrustScore: 70 });\n *\n * const auth = await x402.authorizePayment({ agentId: 'agid_abc123', resource: '/report', amount: 1000, currency: 'USDC' });\n *\n * app.get('/paid-endpoint', x402.middleware(), handler);\n * ```\n */\nexport function createVorimX402(sdk: VorimSDK, config?: Partial<X402Config>): VorimX402 {\n return new VorimX402(sdk, config);\n}\n"],"mappings":";AAuEO,IAAM,YAAN,MAAM,WAAU;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAER,OAAe,gBAAgB;AAAA,EAE/B,YAAY,KAAe,QAA8B;AACvD,SAAK,MAAM;AACX,SAAK,gBAAgB,QAAQ,iBAAiB;AAC9C,SAAK,gBAAgB,QAAQ,iB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