@vorim/sdk 3.8.0 → 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.cjs +280 -0
- package/dist/integrations/hermes.cjs.map +1 -0
- package/dist/integrations/hermes.d.cts +60 -0
- package/dist/integrations/hermes.d.ts +60 -0
- package/dist/integrations/hermes.js +242 -0
- package/dist/integrations/hermes.js.map +1 -0
- 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 +83 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import '../types-zzK9YOoa.js';
|
|
3
|
+
|
|
4
|
+
interface PayPalConfig {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
minTrustScore?: number;
|
|
8
|
+
requiredScope?: string;
|
|
9
|
+
}
|
|
10
|
+
interface PayPalOrderRequest {
|
|
11
|
+
/** The Vorim agent id creating the order / capturing the payment. */
|
|
12
|
+
agentId: string;
|
|
13
|
+
/** The merchant / seller the order is with. */
|
|
14
|
+
merchant?: string;
|
|
15
|
+
/** Amount in the smallest currency unit (e.g. cents). */
|
|
16
|
+
amount?: number;
|
|
17
|
+
/** Currency code (e.g. 'USD'). */
|
|
18
|
+
currency?: string;
|
|
19
|
+
/** Optional PayPal intent hint ('CAPTURE' | 'AUTHORIZE'). Informational. */
|
|
20
|
+
intent?: 'CAPTURE' | 'AUTHORIZE';
|
|
21
|
+
/** Per-call override of the trust threshold. */
|
|
22
|
+
minTrustScore?: number;
|
|
23
|
+
}
|
|
24
|
+
interface PayPalAuthorization {
|
|
25
|
+
authorized: boolean;
|
|
26
|
+
agentId: string;
|
|
27
|
+
trustScore: number;
|
|
28
|
+
status: string;
|
|
29
|
+
reason?: string;
|
|
30
|
+
scopeVerified: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare class VorimPayPal {
|
|
33
|
+
private sdk;
|
|
34
|
+
private minTrustScore;
|
|
35
|
+
private requiredScope;
|
|
36
|
+
/** One-time guard so the no-auth confused-deputy warning logs at most once. */
|
|
37
|
+
private static _warnedNoAuth;
|
|
38
|
+
constructor(sdk: VorimSDK, config?: Partial<PayPalConfig>);
|
|
39
|
+
/**
|
|
40
|
+
* Verify an agent is authorized to create a PayPal order / capture a payment.
|
|
41
|
+
* Same gate as the other payment integrations: transact scope → active
|
|
42
|
+
* status → trust threshold. Every outcome (allow or deny) is audit-logged.
|
|
43
|
+
*/
|
|
44
|
+
authorizeOrder(req: PayPalOrderRequest): Promise<PayPalAuthorization>;
|
|
45
|
+
/** Log that a PayPal order was created. */
|
|
46
|
+
logOrderCreated(agentId: string, orderId: string, req?: Partial<PayPalOrderRequest>): Promise<void>;
|
|
47
|
+
/** Log that a PayPal payment was captured (money moved). */
|
|
48
|
+
logPaymentCaptured(agentId: string, orderId: string, captureId?: string, req?: Partial<PayPalOrderRequest>): Promise<void>;
|
|
49
|
+
/** Log that a refund was issued against an order/capture. */
|
|
50
|
+
logRefundIssued(agentId: string, captureId: string, refundId?: string, req?: Partial<PayPalOrderRequest>): Promise<void>;
|
|
51
|
+
/** Log that a PayPal order/payment failed or was declined. */
|
|
52
|
+
logOrderFailed(agentId: string, orderId: string, reason?: string, req?: Partial<PayPalOrderRequest>): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Express/Connect middleware that gates a PayPal order-creation endpoint on
|
|
55
|
+
* agent authorization.
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
|
|
58
|
+
* only; it does NOT prove the HTTP caller controls that agent. Authenticate
|
|
59
|
+
* the caller-to-agent binding upstream, or pass `authenticate`. When omitted,
|
|
60
|
+
* a one-time 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 VorimPayPal instance.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import createVorim from '@vorim/sdk';
|
|
75
|
+
* import { createVorimPayPal } from '@vorim/sdk/integrations/paypal-agent';
|
|
76
|
+
*
|
|
77
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
78
|
+
* const pp = createVorimPayPal(vorim, { minTrustScore: 70 });
|
|
79
|
+
*
|
|
80
|
+
* const auth = await pp.authorizeOrder({ agentId: 'agid_abc123', merchant: 'shop', amount: 4999, currency: 'USD' });
|
|
81
|
+
*
|
|
82
|
+
* app.post('/paypal/orders', pp.middleware(), createOrderHandler);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare function createVorimPayPal(sdk: VorimSDK, config?: Partial<PayPalConfig>): VorimPayPal;
|
|
86
|
+
|
|
87
|
+
export { type PayPalAuthorization, type PayPalConfig, type PayPalOrderRequest, VorimPayPal, createVorimPayPal };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// src/integrations/paypal-agent.ts
|
|
2
|
+
var VorimPayPal = class _VorimPayPal {
|
|
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 create a PayPal order / capture a payment.
|
|
15
|
+
* Same gate as the other payment integrations: transact scope → active
|
|
16
|
+
* status → trust threshold. Every outcome (allow or deny) is audit-logged.
|
|
17
|
+
*/
|
|
18
|
+
async authorizeOrder(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, "paypal.order.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, "paypal.order.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, "paypal.order.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, "paypal.order.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, "paypal.order.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 PayPal order was created. */
|
|
84
|
+
async logOrderCreated(agentId, orderId, req) {
|
|
85
|
+
await this.logEvent(agentId, "paypal.order.created", "success", req, { order_id: orderId });
|
|
86
|
+
}
|
|
87
|
+
/** Log that a PayPal payment was captured (money moved). */
|
|
88
|
+
async logPaymentCaptured(agentId, orderId, captureId, req) {
|
|
89
|
+
await this.logEvent(agentId, "paypal.payment.captured", "success", req, { order_id: orderId, capture_id: captureId });
|
|
90
|
+
}
|
|
91
|
+
/** Log that a refund was issued against an order/capture. */
|
|
92
|
+
async logRefundIssued(agentId, captureId, refundId, req) {
|
|
93
|
+
await this.logEvent(agentId, "paypal.refund.issued", "success", req, { capture_id: captureId, refund_id: refundId });
|
|
94
|
+
}
|
|
95
|
+
/** Log that a PayPal order/payment failed or was declined. */
|
|
96
|
+
async logOrderFailed(agentId, orderId, reason, req) {
|
|
97
|
+
await this.logEvent(agentId, "paypal.order.failed", "error", req, { order_id: orderId, fail_reason: reason });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Express/Connect middleware that gates a PayPal order-creation endpoint on
|
|
101
|
+
* agent authorization.
|
|
102
|
+
*
|
|
103
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
|
|
104
|
+
* only; it does NOT prove the HTTP caller controls that agent. Authenticate
|
|
105
|
+
* the caller-to-agent binding upstream, or pass `authenticate`. When omitted,
|
|
106
|
+
* a one-time warning is logged.
|
|
107
|
+
*/
|
|
108
|
+
middleware(options) {
|
|
109
|
+
const header = options?.agentIdHeader ?? "x-vorim-agent-id";
|
|
110
|
+
const threshold = options?.minTrustScore ?? this.minTrustScore;
|
|
111
|
+
const authenticate = options?.authenticate;
|
|
112
|
+
if (!authenticate && !_VorimPayPal._warnedNoAuth) {
|
|
113
|
+
_VorimPayPal._warnedNoAuth = true;
|
|
114
|
+
console.warn(
|
|
115
|
+
"[vorim] VorimPayPal.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`."
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return async (req, res, next) => {
|
|
119
|
+
const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
|
|
120
|
+
if (!agentId) {
|
|
121
|
+
res.status(401).json({
|
|
122
|
+
error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` }
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (authenticate) {
|
|
127
|
+
let bound = false;
|
|
128
|
+
try {
|
|
129
|
+
bound = await authenticate(agentId, req);
|
|
130
|
+
} catch {
|
|
131
|
+
bound = false;
|
|
132
|
+
}
|
|
133
|
+
if (!bound) {
|
|
134
|
+
res.status(401).json({
|
|
135
|
+
error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" }
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const auth = await this.authorizeOrder({
|
|
141
|
+
agentId,
|
|
142
|
+
merchant: req.body?.merchant || "",
|
|
143
|
+
amount: req.body?.amount || 0,
|
|
144
|
+
currency: req.body?.currency || "USD",
|
|
145
|
+
minTrustScore: threshold
|
|
146
|
+
});
|
|
147
|
+
if (!auth.authorized) {
|
|
148
|
+
res.status(403).json({
|
|
149
|
+
error: {
|
|
150
|
+
code: "UNAUTHORIZED_AGENT",
|
|
151
|
+
message: auth.reason || "Agent not authorized for PayPal transactions",
|
|
152
|
+
trust_score: auth.trustScore,
|
|
153
|
+
status: auth.status
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
req.vorimAuthorization = auth;
|
|
159
|
+
next();
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
async logEvent(agentId, action, result, req, metadata) {
|
|
163
|
+
try {
|
|
164
|
+
await this.sdk.emit({
|
|
165
|
+
agent_id: agentId,
|
|
166
|
+
event_type: "api_request",
|
|
167
|
+
action,
|
|
168
|
+
result,
|
|
169
|
+
resource: req?.merchant || "",
|
|
170
|
+
metadata: {
|
|
171
|
+
merchant: req?.merchant || "",
|
|
172
|
+
amount: req?.amount || 0,
|
|
173
|
+
currency: req?.currency || "",
|
|
174
|
+
intent: req?.intent || "",
|
|
175
|
+
...metadata
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
function createVorimPayPal(sdk, config) {
|
|
183
|
+
return new VorimPayPal(sdk, config);
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
VorimPayPal,
|
|
187
|
+
createVorimPayPal
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=paypal-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/paypal-agent.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — PayPal Agent Toolkit Integration\n//\n// PayPal ships an open Agent Toolkit (npm @paypal/agent-toolkit, PyPI\n// paypal-agent-toolkit) and MCP server that let AI agents drive PayPal's\n// Orders v2 lifecycle: create an order, capture (or authorize) payment, and\n// issue refunds. The tools are exposed as discrete, named calls.\n//\n// This integration adds Vorim's identity, permission, and audit layer IN FRONT\n// of those calls: before an agent creates an order or captures a payment, it\n// verifies the agent holds `transact`, is active, and clears a trust\n// threshold, and it records the order → capture → refund lifecycle on a signed,\n// tamper-evident audit trail. It does NOT move money or hold PayPal\n// credentials — the PayPal toolkit does the payment; Vorim authorizes and\n// attests.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimPayPal } from '@vorim/sdk/integrations/paypal-agent';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const pp = createVorimPayPal(vorim, { minTrustScore: 60 });\n//\n// // Before an agent creates a PayPal order:\n// const auth = await pp.authorizeOrder({\n// agentId: 'agid_abc123',\n// merchant: 'acme-store',\n// amount: 4999,\n// currency: 'USD',\n// });\n// if (auth.authorized) {\n// const order = await paypalToolkit.createOrder(...); // your PayPal call\n// await pp.logOrderCreated(auth.agentId, order.id, { merchant, amount });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport interface PayPalConfig {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n}\n\nexport interface PayPalOrderRequest {\n /** The Vorim agent id creating the order / capturing the payment. */\n agentId: string;\n /** The merchant / seller the order is with. */\n merchant?: string;\n /** Amount in the smallest currency unit (e.g. cents). */\n amount?: number;\n /** Currency code (e.g. 'USD'). */\n currency?: string;\n /** Optional PayPal intent hint ('CAPTURE' | 'AUTHORIZE'). Informational. */\n intent?: 'CAPTURE' | 'AUTHORIZE';\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface PayPalAuthorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimPayPal {\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<PayPalConfig>) {\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 create a PayPal order / capture a payment.\n * Same gate as the other payment integrations: transact scope → active\n * status → trust threshold. Every outcome (allow or deny) is audit-logged.\n */\n async authorizeOrder(req: PayPalOrderRequest): Promise<PayPalAuthorization> {\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, 'paypal.order.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, 'paypal.order.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, 'paypal.order.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, 'paypal.order.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, 'paypal.order.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 PayPal order was created. */\n async logOrderCreated(agentId: string, orderId: string, req?: Partial<PayPalOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'paypal.order.created', 'success', req, { order_id: orderId });\n }\n\n /** Log that a PayPal payment was captured (money moved). */\n async logPaymentCaptured(agentId: string, orderId: string, captureId?: string, req?: Partial<PayPalOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'paypal.payment.captured', 'success', req, { order_id: orderId, capture_id: captureId });\n }\n\n /** Log that a refund was issued against an order/capture. */\n async logRefundIssued(agentId: string, captureId: string, refundId?: string, req?: Partial<PayPalOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'paypal.refund.issued', 'success', req, { capture_id: captureId, refund_id: refundId });\n }\n\n /** Log that a PayPal order/payment failed or was declined. */\n async logOrderFailed(agentId: string, orderId: string, reason?: string, req?: Partial<PayPalOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'paypal.order.failed', 'error', req, { order_id: orderId, fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware that gates a PayPal order-creation endpoint on\n * 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. Authenticate\n * the caller-to-agent binding upstream, or pass `authenticate`. When omitted,\n * a one-time 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 && !VorimPayPal._warnedNoAuth) {\n VorimPayPal._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimPayPal.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.authorizeOrder({\n agentId,\n merchant: req.body?.merchant || '',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'USD',\n minTrustScore: threshold,\n });\n\n if (!auth.authorized) {\n res.status(403).json({\n error: {\n code: 'UNAUTHORIZED_AGENT',\n message: auth.reason || 'Agent not authorized for PayPal transactions',\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<PayPalOrderRequest>,\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?.merchant || '',\n metadata: {\n merchant: req?.merchant || '',\n amount: req?.amount || 0,\n currency: req?.currency || '',\n intent: req?.intent || '',\n ...metadata,\n },\n });\n } catch {\n // Never block the payment flow on an audit hiccup.\n }\n }\n}\n\n/**\n * Create a VorimPayPal instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimPayPal } from '@vorim/sdk/integrations/paypal-agent';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const pp = createVorimPayPal(vorim, { minTrustScore: 70 });\n *\n * const auth = await pp.authorizeOrder({ agentId: 'agid_abc123', merchant: 'shop', amount: 4999, currency: 'USD' });\n *\n * app.post('/paypal/orders', pp.middleware(), createOrderHandler);\n * ```\n */\nexport function createVorimPayPal(sdk: VorimSDK, config?: Partial<PayPalConfig>): VorimPayPal {\n return new VorimPayPal(sdk, config);\n}\n"],"mappings":";AAqEO,IAAM,cAAN,MAAM,aAAY;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAER,OAAe,gBAAgB;AAAA,EAE/B,YAAY,KAAe,QAAgC;AACzD,SAAK,MAAM;AACX,SAAK,gBAAgB,QAAQ,iBAAiB;AAC9C,SAAK,gBA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AAA,EAEA,MAAc,SACZ,SACA,QACA,QACA,KACA,UACe;AACf,QAAI;AACF,YAAM,KAAK,IAAI,KAAK;AAAA,QAClB,UAAU;AAAA,QACV,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA,UAAU,KAAK,YAAY;AAAA,QAC3B,UAAU;AAAA,UACR,UAAU,KAAK,YAAY;AAAA,UAC3B,QAAQ,KAAK,UAAU;AAAA,UACvB,UAAU,KAAK,YAAY;AAAA,UAC3B,QAAQ,KAAK,UAAU;AAAA,UACvB,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAkBO,SAAS,kBAAkB,KAAe,QAA6C;AAC5F,SAAO,IAAI,YAAY,KAAK,MAAM;AACpC;","names":[]}
|
|
@@ -0,0 +1,166 @@
|
|
|
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/skyfire.ts
|
|
21
|
+
var skyfire_exports = {};
|
|
22
|
+
__export(skyfire_exports, {
|
|
23
|
+
VorimSkyfire: () => VorimSkyfire,
|
|
24
|
+
createVorimSkyfire: () => createVorimSkyfire
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(skyfire_exports);
|
|
27
|
+
var VorimSkyfire = class _VorimSkyfire {
|
|
28
|
+
sdk;
|
|
29
|
+
minTrustScore;
|
|
30
|
+
requiredScope;
|
|
31
|
+
static _warnedNoAuth = false;
|
|
32
|
+
constructor(sdk, config) {
|
|
33
|
+
this.sdk = sdk;
|
|
34
|
+
this.minTrustScore = config?.minTrustScore ?? 50;
|
|
35
|
+
this.requiredScope = config?.requiredScope ?? "agent:transact";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Verify an agent is authorized to mint a Skyfire token. A 'kya' (identity-
|
|
39
|
+
* only) token needs the scope but carries no amount; 'pay' / 'kya-pay' carry
|
|
40
|
+
* a spend amount. Same gate throughout: scope → active status → trust.
|
|
41
|
+
*/
|
|
42
|
+
async authorizeToken(req) {
|
|
43
|
+
const threshold = req.minTrustScore ?? this.minTrustScore;
|
|
44
|
+
const action = `skyfire.token.${req.tokenType ?? "kya-pay"}.authorize`;
|
|
45
|
+
try {
|
|
46
|
+
const perm = await this.sdk.check(req.agentId, this.requiredScope);
|
|
47
|
+
if (!perm.allowed) {
|
|
48
|
+
await this.logEvent(req.agentId, action, "denied", req, { reason: `Missing ${this.requiredScope}` });
|
|
49
|
+
return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
await this.logEvent(req.agentId, action, "denied", req, { reason: e.message });
|
|
53
|
+
return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Permission check failed: ${e.message}`, scopeVerified: false };
|
|
54
|
+
}
|
|
55
|
+
let score = 0;
|
|
56
|
+
let status = "unknown";
|
|
57
|
+
try {
|
|
58
|
+
const trust = await this.sdk.verify(req.agentId);
|
|
59
|
+
score = trust.trust_score ?? 0;
|
|
60
|
+
status = trust.status ?? "unknown";
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
if (status !== "active") {
|
|
64
|
+
await this.logEvent(req.agentId, action, "denied", req, { reason: `Status: ${status}` });
|
|
65
|
+
return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };
|
|
66
|
+
}
|
|
67
|
+
if (score < threshold) {
|
|
68
|
+
await this.logEvent(req.agentId, action, "denied", req, { reason: `Score ${score} < ${threshold}` });
|
|
69
|
+
return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };
|
|
70
|
+
}
|
|
71
|
+
await this.logEvent(req.agentId, action, "success", req, { trust_score: score });
|
|
72
|
+
return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };
|
|
73
|
+
}
|
|
74
|
+
/** Log that a Skyfire token was minted. */
|
|
75
|
+
async logTokenCreated(agentId, tokenId, req) {
|
|
76
|
+
await this.logEvent(agentId, `skyfire.token.${req?.tokenType ?? "kya-pay"}.created`, "success", req, { token_id: tokenId });
|
|
77
|
+
}
|
|
78
|
+
/** Log that a seller charged a Skyfire token. */
|
|
79
|
+
async logTokenCharged(agentId, tokenId, amountCharged, req) {
|
|
80
|
+
await this.logEvent(agentId, "skyfire.token.charged", "success", req, { token_id: tokenId, amount_charged: amountCharged });
|
|
81
|
+
}
|
|
82
|
+
/** Log that a Skyfire token charge failed or was rejected. */
|
|
83
|
+
async logTokenRejected(agentId, tokenId, reason, req) {
|
|
84
|
+
await this.logEvent(agentId, "skyfire.token.rejected", "error", req, { token_id: tokenId, reject_reason: reason });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Express/Connect middleware that gates a token-mint endpoint on agent
|
|
88
|
+
* authorization.
|
|
89
|
+
*
|
|
90
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; pass
|
|
91
|
+
* `authenticate` to verify the caller-to-agent binding. When omitted, a
|
|
92
|
+
* one-time warning is logged.
|
|
93
|
+
*/
|
|
94
|
+
middleware(options) {
|
|
95
|
+
const header = options?.agentIdHeader ?? "x-vorim-agent-id";
|
|
96
|
+
const threshold = options?.minTrustScore ?? this.minTrustScore;
|
|
97
|
+
const authenticate = options?.authenticate;
|
|
98
|
+
if (!authenticate && !_VorimSkyfire._warnedNoAuth) {
|
|
99
|
+
_VorimSkyfire._warnedNoAuth = true;
|
|
100
|
+
console.warn(
|
|
101
|
+
"[vorim] VorimSkyfire.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). Pass `authenticate`."
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return async (req, res, next) => {
|
|
105
|
+
const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
|
|
106
|
+
if (!agentId) {
|
|
107
|
+
res.status(401).json({ error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` } });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (authenticate) {
|
|
111
|
+
let bound = false;
|
|
112
|
+
try {
|
|
113
|
+
bound = await authenticate(agentId, req);
|
|
114
|
+
} catch {
|
|
115
|
+
bound = false;
|
|
116
|
+
}
|
|
117
|
+
if (!bound) {
|
|
118
|
+
res.status(401).json({ error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" } });
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const auth = await this.authorizeToken({
|
|
123
|
+
agentId,
|
|
124
|
+
tokenType: req.body?.tokenType || "kya-pay",
|
|
125
|
+
sellerServiceId: req.body?.sellerServiceId || "",
|
|
126
|
+
amount: req.body?.amount || 0,
|
|
127
|
+
currency: req.body?.currency || "usd",
|
|
128
|
+
minTrustScore: threshold
|
|
129
|
+
});
|
|
130
|
+
if (!auth.authorized) {
|
|
131
|
+
res.status(403).json({ error: { code: "UNAUTHORIZED_AGENT", message: auth.reason || "Agent not authorized to mint a Skyfire token", trust_score: auth.trustScore, status: auth.status } });
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
req.vorimAuthorization = auth;
|
|
135
|
+
next();
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async logEvent(agentId, action, result, req, metadata) {
|
|
139
|
+
try {
|
|
140
|
+
await this.sdk.emit({
|
|
141
|
+
agent_id: agentId,
|
|
142
|
+
event_type: "api_request",
|
|
143
|
+
action,
|
|
144
|
+
result,
|
|
145
|
+
resource: req?.sellerServiceId || "",
|
|
146
|
+
metadata: {
|
|
147
|
+
token_type: req?.tokenType || "",
|
|
148
|
+
seller_service_id: req?.sellerServiceId || "",
|
|
149
|
+
amount: req?.amount || 0,
|
|
150
|
+
currency: req?.currency || "",
|
|
151
|
+
...metadata
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
} catch {
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
function createVorimSkyfire(sdk, config) {
|
|
159
|
+
return new VorimSkyfire(sdk, config);
|
|
160
|
+
}
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
VorimSkyfire,
|
|
164
|
+
createVorimSkyfire
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=skyfire.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/skyfire.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Skyfire (KYA + KYAPay) Integration\n//\n// Skyfire is an agent trust + payments stack: an agent mints a token\n// (POST /api/v1/tokens) of type 'kya' (identity), 'pay' (payment), or\n// 'kya-pay' (combined), scoped to a seller + amount + expiry, then the seller\n// charges it (POST /api/v1/tokens/charge).\n//\n// This integration adds Vorim's identity, permission, and audit layer IN FRONT\n// of Skyfire token creation: before an agent mints a pay / kya-pay token, it\n// verifies the agent holds `transact`, is active, and clears a trust threshold,\n// then records the token + charge lifecycle on a signed, tamper-evident audit\n// trail. It does NOT mint Skyfire tokens or hold Skyfire keys — Skyfire does\n// the payment; Vorim authorizes and attests.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimSkyfire } from '@vorim/sdk/integrations/skyfire';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const skyfire = createVorimSkyfire(vorim, { minTrustScore: 60 });\n//\n// const auth = await skyfire.authorizeToken({\n// agentId: 'agid_abc123',\n// tokenType: 'kya-pay',\n// sellerServiceId: 'svc_...',\n// amount: 500,\n// currency: 'usd',\n// });\n// if (auth.authorized) {\n// // ... mint the Skyfire token, then:\n// await skyfire.logTokenCreated(auth.agentId, tokenId, { tokenType: 'kya-pay' });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport type SkyfireTokenType = 'kya' | 'pay' | 'kya-pay';\n\nexport interface SkyfireConfig {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n}\n\nexport interface SkyfireTokenRequest {\n /** The Vorim agent id minting the token. */\n agentId: string;\n /** Skyfire token type: kya (identity only), pay, or kya-pay (combined). */\n tokenType?: SkyfireTokenType;\n /** The seller/service the token is scoped to. */\n sellerServiceId?: string;\n /** Token amount in the smallest currency unit (required for pay / kya-pay). */\n amount?: number;\n /** Currency code. */\n currency?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface SkyfireAuthorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimSkyfire {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<SkyfireConfig>) {\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 mint a Skyfire token. A 'kya' (identity-\n * only) token needs the scope but carries no amount; 'pay' / 'kya-pay' carry\n * a spend amount. Same gate throughout: scope → active status → trust.\n */\n async authorizeToken(req: SkyfireTokenRequest): Promise<SkyfireAuthorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\n const action = `skyfire.token.${req.tokenType ?? 'kya-pay'}.authorize`;\n\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, action, 'denied', req, { reason: `Missing ${this.requiredScope}` });\n return { authorized: false, agentId: req.agentId, trustScore: 0, status: 'unknown', reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };\n }\n } catch (e: any) {\n await this.logEvent(req.agentId, action, 'denied', req, { reason: e.message });\n return { authorized: false, agentId: req.agentId, trustScore: 0, status: 'unknown', reason: `Permission check failed: ${e.message}`, scopeVerified: false };\n }\n\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 { /* treated as not-active below */ }\n\n if (status !== 'active') {\n await this.logEvent(req.agentId, action, 'denied', req, { reason: `Status: ${status}` });\n return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };\n }\n\n if (score < threshold) {\n await this.logEvent(req.agentId, action, 'denied', req, { reason: `Score ${score} < ${threshold}` });\n return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };\n }\n\n await this.logEvent(req.agentId, action, 'success', req, { trust_score: score });\n return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };\n }\n\n /** Log that a Skyfire token was minted. */\n async logTokenCreated(agentId: string, tokenId: string, req?: Partial<SkyfireTokenRequest>): Promise<void> {\n await this.logEvent(agentId, `skyfire.token.${req?.tokenType ?? 'kya-pay'}.created`, 'success', req, { token_id: tokenId });\n }\n\n /** Log that a seller charged a Skyfire token. */\n async logTokenCharged(agentId: string, tokenId: string, amountCharged?: number, req?: Partial<SkyfireTokenRequest>): Promise<void> {\n await this.logEvent(agentId, 'skyfire.token.charged', 'success', req, { token_id: tokenId, amount_charged: amountCharged });\n }\n\n /** Log that a Skyfire token charge failed or was rejected. */\n async logTokenRejected(agentId: string, tokenId: string, reason?: string, req?: Partial<SkyfireTokenRequest>): Promise<void> {\n await this.logEvent(agentId, 'skyfire.token.rejected', 'error', req, { token_id: tokenId, reject_reason: reason });\n }\n\n /**\n * Express/Connect middleware that gates a token-mint endpoint on agent\n * authorization.\n *\n * ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; pass\n * `authenticate` to verify the caller-to-agent binding. When omitted, a\n * one-time 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 && !VorimSkyfire._warnedNoAuth) {\n VorimSkyfire._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimSkyfire.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). 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 if (!agentId) {\n res.status(401).json({ error: { code: 'MISSING_AGENT_ID', message: `Agent ID required in ${header} header` } });\n return;\n }\n if (authenticate) {\n let bound = false;\n try { bound = await authenticate(agentId, req); } catch { bound = false; }\n if (!bound) {\n res.status(401).json({ error: { code: 'AGENT_BINDING_UNVERIFIED', message: 'Caller is not authenticated as the named agent' } });\n return;\n }\n }\n const auth = await this.authorizeToken({\n agentId,\n tokenType: (req.body?.tokenType as SkyfireTokenType) || 'kya-pay',\n sellerServiceId: req.body?.sellerServiceId || '',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'usd',\n minTrustScore: threshold,\n });\n if (!auth.authorized) {\n res.status(403).json({ error: { code: 'UNAUTHORIZED_AGENT', message: auth.reason || 'Agent not authorized to mint a Skyfire token', trust_score: auth.trustScore, status: auth.status } });\n return;\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<SkyfireTokenRequest>,\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?.sellerServiceId || '',\n metadata: {\n token_type: req?.tokenType || '',\n seller_service_id: req?.sellerServiceId || '',\n amount: req?.amount || 0,\n currency: req?.currency || '',\n ...metadata,\n },\n });\n } catch { /* never block the payment flow */ }\n }\n}\n\n/**\n * Create a VorimSkyfire instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimSkyfire } from '@vorim/sdk/integrations/skyfire';\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const skyfire = createVorimSkyfire(vorim, { minTrustScore: 70 });\n * const auth = await skyfire.authorizeToken({ agentId: 'agid_abc', tokenType: 'pay', amount: 500 });\n * ```\n */\nexport function createVorimSkyfire(sdk: VorimSDK, config?: Partial<SkyfireConfig>): VorimSkyfire {\n return new VorimSkyfire(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsEO,IAAM,eAAN,MAAM,cAAa;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACR,OAAe,gBAAgB;AAAA,EAE/B,YAAY,KAAe,QAAiC;AAC1D,SAAK,MAAM;AACX,SAAK,gBAAgB,QAAQ,iBAAiB;AA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,UAC3C,QAAQ,KAAK,UAAU;AAAA,UACvB,UAAU,KAAK,YAAY;AAAA,UAC3B,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AAAA,IAAqC;AAAA,EAC/C;AACF;AAcO,SAAS,mBAAmB,KAAe,QAA+C;AAC/F,SAAO,IAAI,aAAa,KAAK,MAAM;AACrC;","names":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import '../types-zzK9YOoa.cjs';
|
|
3
|
+
|
|
4
|
+
type SkyfireTokenType = 'kya' | 'pay' | 'kya-pay';
|
|
5
|
+
interface SkyfireConfig {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
minTrustScore?: number;
|
|
9
|
+
requiredScope?: string;
|
|
10
|
+
}
|
|
11
|
+
interface SkyfireTokenRequest {
|
|
12
|
+
/** The Vorim agent id minting the token. */
|
|
13
|
+
agentId: string;
|
|
14
|
+
/** Skyfire token type: kya (identity only), pay, or kya-pay (combined). */
|
|
15
|
+
tokenType?: SkyfireTokenType;
|
|
16
|
+
/** The seller/service the token is scoped to. */
|
|
17
|
+
sellerServiceId?: string;
|
|
18
|
+
/** Token amount in the smallest currency unit (required for pay / kya-pay). */
|
|
19
|
+
amount?: number;
|
|
20
|
+
/** Currency code. */
|
|
21
|
+
currency?: string;
|
|
22
|
+
/** Per-call override of the trust threshold. */
|
|
23
|
+
minTrustScore?: number;
|
|
24
|
+
}
|
|
25
|
+
interface SkyfireAuthorization {
|
|
26
|
+
authorized: boolean;
|
|
27
|
+
agentId: string;
|
|
28
|
+
trustScore: number;
|
|
29
|
+
status: string;
|
|
30
|
+
reason?: string;
|
|
31
|
+
scopeVerified: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare class VorimSkyfire {
|
|
34
|
+
private sdk;
|
|
35
|
+
private minTrustScore;
|
|
36
|
+
private requiredScope;
|
|
37
|
+
private static _warnedNoAuth;
|
|
38
|
+
constructor(sdk: VorimSDK, config?: Partial<SkyfireConfig>);
|
|
39
|
+
/**
|
|
40
|
+
* Verify an agent is authorized to mint a Skyfire token. A 'kya' (identity-
|
|
41
|
+
* only) token needs the scope but carries no amount; 'pay' / 'kya-pay' carry
|
|
42
|
+
* a spend amount. Same gate throughout: scope → active status → trust.
|
|
43
|
+
*/
|
|
44
|
+
authorizeToken(req: SkyfireTokenRequest): Promise<SkyfireAuthorization>;
|
|
45
|
+
/** Log that a Skyfire token was minted. */
|
|
46
|
+
logTokenCreated(agentId: string, tokenId: string, req?: Partial<SkyfireTokenRequest>): Promise<void>;
|
|
47
|
+
/** Log that a seller charged a Skyfire token. */
|
|
48
|
+
logTokenCharged(agentId: string, tokenId: string, amountCharged?: number, req?: Partial<SkyfireTokenRequest>): Promise<void>;
|
|
49
|
+
/** Log that a Skyfire token charge failed or was rejected. */
|
|
50
|
+
logTokenRejected(agentId: string, tokenId: string, reason?: string, req?: Partial<SkyfireTokenRequest>): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Express/Connect middleware that gates a token-mint endpoint on agent
|
|
53
|
+
* authorization.
|
|
54
|
+
*
|
|
55
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; pass
|
|
56
|
+
* `authenticate` to verify the caller-to-agent binding. When omitted, a
|
|
57
|
+
* one-time warning is logged.
|
|
58
|
+
*/
|
|
59
|
+
middleware(options?: {
|
|
60
|
+
agentIdHeader?: string;
|
|
61
|
+
minTrustScore?: number;
|
|
62
|
+
authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
|
|
63
|
+
}): (req: any, res: any, next: any) => Promise<void>;
|
|
64
|
+
private logEvent;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a VorimSkyfire instance.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* import createVorim from '@vorim/sdk';
|
|
72
|
+
* import { createVorimSkyfire } from '@vorim/sdk/integrations/skyfire';
|
|
73
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
74
|
+
* const skyfire = createVorimSkyfire(vorim, { minTrustScore: 70 });
|
|
75
|
+
* const auth = await skyfire.authorizeToken({ agentId: 'agid_abc', tokenType: 'pay', amount: 500 });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare function createVorimSkyfire(sdk: VorimSDK, config?: Partial<SkyfireConfig>): VorimSkyfire;
|
|
79
|
+
|
|
80
|
+
export { type SkyfireAuthorization, type SkyfireConfig, type SkyfireTokenRequest, type SkyfireTokenType, VorimSkyfire, createVorimSkyfire };
|