@vorim/sdk 3.9.0 → 3.10.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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/modern-treasury.cjs +178 -0
- package/dist/integrations/modern-treasury.cjs.map +1 -0
- package/dist/integrations/modern-treasury.d.cts +90 -0
- package/dist/integrations/modern-treasury.d.ts +90 -0
- package/dist/integrations/modern-treasury.js +152 -0
- package/dist/integrations/modern-treasury.js.map +1 -0
- package/dist/integrations/plaid.cjs +174 -0
- package/dist/integrations/plaid.cjs.map +1 -0
- package/dist/integrations/plaid.d.cts +86 -0
- package/dist/integrations/plaid.d.ts +86 -0
- package/dist/integrations/plaid.js +148 -0
- package/dist/integrations/plaid.js.map +1 -0
- package/package.json +21 -1
|
@@ -0,0 +1,178 @@
|
|
|
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/modern-treasury.ts
|
|
21
|
+
var modern_treasury_exports = {};
|
|
22
|
+
__export(modern_treasury_exports, {
|
|
23
|
+
VorimModernTreasury: () => VorimModernTreasury,
|
|
24
|
+
createVorimModernTreasury: () => createVorimModernTreasury
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(modern_treasury_exports);
|
|
27
|
+
var VorimModernTreasury = class _VorimModernTreasury {
|
|
28
|
+
sdk;
|
|
29
|
+
minTrustScore;
|
|
30
|
+
requiredScope;
|
|
31
|
+
environment;
|
|
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
|
+
this.environment = config?.environment ?? "sandbox";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Verify an agent is authorized to create a Modern Treasury payment order, to
|
|
41
|
+
* run before POST /api/payment_orders. Gate: transact scope → active status →
|
|
42
|
+
* trust threshold. Every outcome is audit-logged with the environment tag.
|
|
43
|
+
*/
|
|
44
|
+
async authorizePaymentOrder(req) {
|
|
45
|
+
const threshold = req.minTrustScore ?? this.minTrustScore;
|
|
46
|
+
try {
|
|
47
|
+
const perm = await this.sdk.check(req.agentId, this.requiredScope);
|
|
48
|
+
if (!perm.allowed) {
|
|
49
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: `Missing ${this.requiredScope}` });
|
|
50
|
+
return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: e.message });
|
|
54
|
+
return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Permission check failed: ${e.message}`, scopeVerified: false };
|
|
55
|
+
}
|
|
56
|
+
let score = 0;
|
|
57
|
+
let status = "unknown";
|
|
58
|
+
try {
|
|
59
|
+
const trust = await this.sdk.verify(req.agentId);
|
|
60
|
+
score = trust.trust_score ?? 0;
|
|
61
|
+
status = trust.status ?? "unknown";
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
if (status !== "active") {
|
|
65
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: `Status: ${status}` });
|
|
66
|
+
return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };
|
|
67
|
+
}
|
|
68
|
+
if (score < threshold) {
|
|
69
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: `Score ${score} < ${threshold}` });
|
|
70
|
+
return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };
|
|
71
|
+
}
|
|
72
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "success", req, { trust_score: score });
|
|
73
|
+
return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };
|
|
74
|
+
}
|
|
75
|
+
/** Log that a payment order was created (may enter needs_approval). */
|
|
76
|
+
async logPaymentOrderCreated(agentId, orderId, req) {
|
|
77
|
+
await this.logEvent(agentId, "mt.payment_order.created", "success", req, { payment_order_id: orderId });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Log an approval-status update, driven by Modern Treasury's approval webhook.
|
|
81
|
+
* `status` is typically 'approved', 'needs_approval', or 'denied'.
|
|
82
|
+
*/
|
|
83
|
+
async logApprovalUpdated(agentId, orderId, status, approver, req) {
|
|
84
|
+
const result = status === "approved" ? "success" : status === "denied" ? "denied" : "success";
|
|
85
|
+
await this.logEvent(agentId, "mt.payment_order.approval", result, req, { payment_order_id: orderId, approval_status: status, approver });
|
|
86
|
+
}
|
|
87
|
+
/** Log that a payment order completed (money moved). */
|
|
88
|
+
async logPaymentOrderCompleted(agentId, orderId, req) {
|
|
89
|
+
await this.logEvent(agentId, "mt.payment_order.completed", "success", req, { payment_order_id: orderId });
|
|
90
|
+
}
|
|
91
|
+
/** Log that a payment order was returned, failed, or cancelled. */
|
|
92
|
+
async logPaymentOrderFailed(agentId, orderId, reason, req) {
|
|
93
|
+
await this.logEvent(agentId, "mt.payment_order.failed", "error", req, { payment_order_id: orderId, fail_reason: reason });
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Express/Connect middleware that gates a payment-order endpoint on agent
|
|
97
|
+
* authorization.
|
|
98
|
+
*
|
|
99
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; pass
|
|
100
|
+
* `authenticate` to verify the caller-to-agent binding. This gates real money
|
|
101
|
+
* movement in production — wiring `authenticate` is strongly recommended, and
|
|
102
|
+
* it complements (does not replace) Modern Treasury's Approval Rules.
|
|
103
|
+
*/
|
|
104
|
+
middleware(options) {
|
|
105
|
+
const header = options?.agentIdHeader ?? "x-vorim-agent-id";
|
|
106
|
+
const threshold = options?.minTrustScore ?? this.minTrustScore;
|
|
107
|
+
const authenticate = options?.authenticate;
|
|
108
|
+
if (!authenticate && !_VorimModernTreasury._warnedNoAuth) {
|
|
109
|
+
_VorimModernTreasury._warnedNoAuth = true;
|
|
110
|
+
console.warn(
|
|
111
|
+
"[vorim] VorimModernTreasury.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). This gates money movement \u2014 pass `authenticate`."
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return async (req, res, next) => {
|
|
115
|
+
const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
|
|
116
|
+
if (!agentId) {
|
|
117
|
+
res.status(401).json({ error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` } });
|
|
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({ error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" } });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const auth = await this.authorizePaymentOrder({
|
|
133
|
+
agentId,
|
|
134
|
+
paymentType: req.body?.paymentType || "ach",
|
|
135
|
+
amount: req.body?.amount || 0,
|
|
136
|
+
currency: req.body?.currency || "usd",
|
|
137
|
+
counterparty: req.body?.counterparty || "",
|
|
138
|
+
minTrustScore: threshold
|
|
139
|
+
});
|
|
140
|
+
if (!auth.authorized) {
|
|
141
|
+
res.status(403).json({ error: { code: "UNAUTHORIZED_AGENT", message: auth.reason || "Agent not authorized to move money", trust_score: auth.trustScore, status: auth.status } });
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
req.vorimAuthorization = auth;
|
|
145
|
+
next();
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
async logEvent(agentId, action, result, req, metadata) {
|
|
149
|
+
try {
|
|
150
|
+
await this.sdk.emit({
|
|
151
|
+
agent_id: agentId,
|
|
152
|
+
event_type: "api_request",
|
|
153
|
+
action,
|
|
154
|
+
result,
|
|
155
|
+
resource: req?.counterparty || "",
|
|
156
|
+
metadata: {
|
|
157
|
+
provider: "modern_treasury",
|
|
158
|
+
environment: this.environment,
|
|
159
|
+
payment_type: req?.paymentType || "",
|
|
160
|
+
amount: req?.amount || 0,
|
|
161
|
+
currency: req?.currency || "",
|
|
162
|
+
counterparty: req?.counterparty || "",
|
|
163
|
+
...metadata
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
} catch {
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
function createVorimModernTreasury(sdk, config) {
|
|
171
|
+
return new VorimModernTreasury(sdk, config);
|
|
172
|
+
}
|
|
173
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
174
|
+
0 && (module.exports = {
|
|
175
|
+
VorimModernTreasury,
|
|
176
|
+
createVorimModernTreasury
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=modern-treasury.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/modern-treasury.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Modern Treasury Integration (SANDBOX-READY)\n//\n// ⚠️ SANDBOX / EVALUATION. Modern Treasury moves real money (ACH, wire, RTP,\n// book, check, stablecoin) via Payment Orders, but PRODUCTION requires KYB and\n// a bank relationship — an agent cannot self-onboard. This wrapper is fully\n// usable against Modern Treasury's self-serve SANDBOX today and drops onto\n// production once KYB completes. The `environment` field defaults to 'sandbox'\n// and is recorded on every audit event.\n//\n// Wrap point: POST /api/payment_orders (\"an instruction to move money\"), which\n// can enter a `needs_approval` state under Approval Rules (Modern Treasury's\n// native segregation-of-duties). This layer verifies the AGENT (transact scope,\n// active, trust) before the payment order is created and signs the order →\n// approval → completion lifecycle. Because Modern Treasury's approval is\n// dashboard/webhook-driven, the reliable programmatic seam is at CREATION plus\n// consuming the approval webhook — the logApprovalUpdated method is for those\n// webhooks. It does NOT call Modern Treasury or move money — it authorizes and\n// attests.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimModernTreasury } from '@vorim/sdk/integrations/modern-treasury';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const mt = createVorimModernTreasury(vorim, { environment: 'sandbox', minTrustScore: 70 });\n//\n// const auth = await mt.authorizePaymentOrder({\n// agentId: 'agid_abc123',\n// paymentType: 'ach',\n// amount: 25000, // smallest unit (cents)\n// currency: 'usd',\n// counterparty: 'cp_...',\n// });\n// if (auth.authorized) {\n// // ... POST /api/payment_orders, then:\n// await mt.logPaymentOrderCreated(auth.agentId, orderId, { amount: 25000 });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport type MTEnvironment = 'sandbox' | 'production';\nexport type MTPaymentType = 'ach' | 'wire' | 'rtp' | 'book' | 'check' | 'card' | 'stablecoin';\n\nexport interface ModernTreasuryConfig {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n /** 'sandbox' (default) or 'production'. Recorded on every audit event. */\n environment?: MTEnvironment;\n}\n\nexport interface MTPaymentOrderRequest {\n /** The Vorim agent id creating the payment order. */\n agentId: string;\n /** Payment rail / type. */\n paymentType?: MTPaymentType;\n /** Amount in the smallest currency unit (cents). */\n amount?: number;\n /** Currency code. */\n currency?: string;\n /** The counterparty reference the order pays. */\n counterparty?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface MTAuthorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimModernTreasury {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n private environment: MTEnvironment;\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>) {\n this.sdk = sdk;\n this.minTrustScore = config?.minTrustScore ?? 50;\n this.requiredScope = config?.requiredScope ?? 'agent:transact';\n this.environment = config?.environment ?? 'sandbox';\n }\n\n /**\n * Verify an agent is authorized to create a Modern Treasury payment order, to\n * run before POST /api/payment_orders. Gate: transact scope → active status →\n * trust threshold. Every outcome is audit-logged with the environment tag.\n */\n async authorizePaymentOrder(req: MTPaymentOrderRequest): Promise<MTAuthorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', 'success', req, { trust_score: score });\n return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };\n }\n\n /** Log that a payment order was created (may enter needs_approval). */\n async logPaymentOrderCreated(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'mt.payment_order.created', 'success', req, { payment_order_id: orderId });\n }\n\n /**\n * Log an approval-status update, driven by Modern Treasury's approval webhook.\n * `status` is typically 'approved', 'needs_approval', or 'denied'.\n */\n async logApprovalUpdated(agentId: string, orderId: string, status: string, approver?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n const result = status === 'approved' ? 'success' : status === 'denied' ? 'denied' : 'success';\n await this.logEvent(agentId, 'mt.payment_order.approval', result, req, { payment_order_id: orderId, approval_status: status, approver });\n }\n\n /** Log that a payment order completed (money moved). */\n async logPaymentOrderCompleted(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'mt.payment_order.completed', 'success', req, { payment_order_id: orderId });\n }\n\n /** Log that a payment order was returned, failed, or cancelled. */\n async logPaymentOrderFailed(agentId: string, orderId: string, reason?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'mt.payment_order.failed', 'error', req, { payment_order_id: orderId, fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware that gates a payment-order 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. This gates real money\n * movement in production — wiring `authenticate` is strongly recommended, and\n * it complements (does not replace) Modern Treasury's Approval Rules.\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 && !VorimModernTreasury._warnedNoAuth) {\n VorimModernTreasury._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimModernTreasury.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). This gates money ' +\n 'movement — 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.authorizePaymentOrder({\n agentId,\n paymentType: (req.body?.paymentType as MTPaymentType) || 'ach',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'usd',\n counterparty: req.body?.counterparty || '',\n minTrustScore: threshold,\n });\n if (!auth.authorized) {\n res.status(403).json({ error: { code: 'UNAUTHORIZED_AGENT', message: auth.reason || 'Agent not authorized to move money', 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<MTPaymentOrderRequest>,\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?.counterparty || '',\n metadata: {\n provider: 'modern_treasury',\n environment: this.environment,\n payment_type: req?.paymentType || '',\n amount: req?.amount || 0,\n currency: req?.currency || '',\n counterparty: req?.counterparty || '',\n ...metadata,\n },\n });\n } catch { /* never block the payment flow */ }\n }\n}\n\n/**\n * Create a VorimModernTreasury instance (sandbox by default).\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimModernTreasury } from '@vorim/sdk/integrations/modern-treasury';\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const mt = createVorimModernTreasury(vorim, { environment: 'sandbox', minTrustScore: 70 });\n * const auth = await mt.authorizePaymentOrder({ agentId: 'agid_abc', paymentType: 'ach', amount: 25000, counterparty: 'cp_1' });\n * ```\n */\nexport function createVorimModernTreasury(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>): VorimModernTreasury {\n return new VorimModernTreasury(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8EO,IAAM,sBAAN,MAAM,qBAAoB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACR,OAAe,gBAAgB;AAAA,EAE/B,YAAY,KAAe,QAAwC;AACjE,SAAK,MAAM;AACX,SAAK,gBAAgB,QAAQ,iBAAiB;AAC9C,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ACf,QAAI;AACF,YAAM,KAAK,IAAI,KAAK;AAAA,QAClB,UAAU;AAAA,QACV,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA,UAAU,KAAK,gBAAgB;AAAA,QAC/B,UAAU;AAAA,UACR,UAAU;AAAA,UACV,aAAa,KAAK;AAAA,UAClB,cAAc,KAAK,eAAe;AAAA,UAClC,QAAQ,KAAK,UAAU;AAAA,UACvB,UAAU,KAAK,YAAY;AAAA,UAC3B,cAAc,KAAK,gBAAgB;AAAA,UACnC,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AAAA,IAAqC;AAAA,EAC/C;AACF;AAcO,SAAS,0BAA0B,KAAe,QAA6D;AACpH,SAAO,IAAI,oBAAoB,KAAK,MAAM;AAC5C;","names":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import '../types-zzK9YOoa.cjs';
|
|
3
|
+
|
|
4
|
+
type MTEnvironment = 'sandbox' | 'production';
|
|
5
|
+
type MTPaymentType = 'ach' | 'wire' | 'rtp' | 'book' | 'check' | 'card' | 'stablecoin';
|
|
6
|
+
interface ModernTreasuryConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
minTrustScore?: number;
|
|
10
|
+
requiredScope?: string;
|
|
11
|
+
/** 'sandbox' (default) or 'production'. Recorded on every audit event. */
|
|
12
|
+
environment?: MTEnvironment;
|
|
13
|
+
}
|
|
14
|
+
interface MTPaymentOrderRequest {
|
|
15
|
+
/** The Vorim agent id creating the payment order. */
|
|
16
|
+
agentId: string;
|
|
17
|
+
/** Payment rail / type. */
|
|
18
|
+
paymentType?: MTPaymentType;
|
|
19
|
+
/** Amount in the smallest currency unit (cents). */
|
|
20
|
+
amount?: number;
|
|
21
|
+
/** Currency code. */
|
|
22
|
+
currency?: string;
|
|
23
|
+
/** The counterparty reference the order pays. */
|
|
24
|
+
counterparty?: string;
|
|
25
|
+
/** Per-call override of the trust threshold. */
|
|
26
|
+
minTrustScore?: number;
|
|
27
|
+
}
|
|
28
|
+
interface MTAuthorization {
|
|
29
|
+
authorized: boolean;
|
|
30
|
+
agentId: string;
|
|
31
|
+
trustScore: number;
|
|
32
|
+
status: string;
|
|
33
|
+
reason?: string;
|
|
34
|
+
scopeVerified: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare class VorimModernTreasury {
|
|
37
|
+
private sdk;
|
|
38
|
+
private minTrustScore;
|
|
39
|
+
private requiredScope;
|
|
40
|
+
private environment;
|
|
41
|
+
private static _warnedNoAuth;
|
|
42
|
+
constructor(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>);
|
|
43
|
+
/**
|
|
44
|
+
* Verify an agent is authorized to create a Modern Treasury payment order, to
|
|
45
|
+
* run before POST /api/payment_orders. Gate: transact scope → active status →
|
|
46
|
+
* trust threshold. Every outcome is audit-logged with the environment tag.
|
|
47
|
+
*/
|
|
48
|
+
authorizePaymentOrder(req: MTPaymentOrderRequest): Promise<MTAuthorization>;
|
|
49
|
+
/** Log that a payment order was created (may enter needs_approval). */
|
|
50
|
+
logPaymentOrderCreated(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Log an approval-status update, driven by Modern Treasury's approval webhook.
|
|
53
|
+
* `status` is typically 'approved', 'needs_approval', or 'denied'.
|
|
54
|
+
*/
|
|
55
|
+
logApprovalUpdated(agentId: string, orderId: string, status: string, approver?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
56
|
+
/** Log that a payment order completed (money moved). */
|
|
57
|
+
logPaymentOrderCompleted(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
58
|
+
/** Log that a payment order was returned, failed, or cancelled. */
|
|
59
|
+
logPaymentOrderFailed(agentId: string, orderId: string, reason?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Express/Connect middleware that gates a payment-order endpoint on agent
|
|
62
|
+
* authorization.
|
|
63
|
+
*
|
|
64
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; pass
|
|
65
|
+
* `authenticate` to verify the caller-to-agent binding. This gates real money
|
|
66
|
+
* movement in production — wiring `authenticate` is strongly recommended, and
|
|
67
|
+
* it complements (does not replace) Modern Treasury's Approval Rules.
|
|
68
|
+
*/
|
|
69
|
+
middleware(options?: {
|
|
70
|
+
agentIdHeader?: string;
|
|
71
|
+
minTrustScore?: number;
|
|
72
|
+
authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
|
|
73
|
+
}): (req: any, res: any, next: any) => Promise<void>;
|
|
74
|
+
private logEvent;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a VorimModernTreasury instance (sandbox by default).
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import createVorim from '@vorim/sdk';
|
|
82
|
+
* import { createVorimModernTreasury } from '@vorim/sdk/integrations/modern-treasury';
|
|
83
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
84
|
+
* const mt = createVorimModernTreasury(vorim, { environment: 'sandbox', minTrustScore: 70 });
|
|
85
|
+
* const auth = await mt.authorizePaymentOrder({ agentId: 'agid_abc', paymentType: 'ach', amount: 25000, counterparty: 'cp_1' });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function createVorimModernTreasury(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>): VorimModernTreasury;
|
|
89
|
+
|
|
90
|
+
export { type MTAuthorization, type MTEnvironment, type MTPaymentOrderRequest, type MTPaymentType, type ModernTreasuryConfig, VorimModernTreasury, createVorimModernTreasury };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import '../types-zzK9YOoa.js';
|
|
3
|
+
|
|
4
|
+
type MTEnvironment = 'sandbox' | 'production';
|
|
5
|
+
type MTPaymentType = 'ach' | 'wire' | 'rtp' | 'book' | 'check' | 'card' | 'stablecoin';
|
|
6
|
+
interface ModernTreasuryConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
minTrustScore?: number;
|
|
10
|
+
requiredScope?: string;
|
|
11
|
+
/** 'sandbox' (default) or 'production'. Recorded on every audit event. */
|
|
12
|
+
environment?: MTEnvironment;
|
|
13
|
+
}
|
|
14
|
+
interface MTPaymentOrderRequest {
|
|
15
|
+
/** The Vorim agent id creating the payment order. */
|
|
16
|
+
agentId: string;
|
|
17
|
+
/** Payment rail / type. */
|
|
18
|
+
paymentType?: MTPaymentType;
|
|
19
|
+
/** Amount in the smallest currency unit (cents). */
|
|
20
|
+
amount?: number;
|
|
21
|
+
/** Currency code. */
|
|
22
|
+
currency?: string;
|
|
23
|
+
/** The counterparty reference the order pays. */
|
|
24
|
+
counterparty?: string;
|
|
25
|
+
/** Per-call override of the trust threshold. */
|
|
26
|
+
minTrustScore?: number;
|
|
27
|
+
}
|
|
28
|
+
interface MTAuthorization {
|
|
29
|
+
authorized: boolean;
|
|
30
|
+
agentId: string;
|
|
31
|
+
trustScore: number;
|
|
32
|
+
status: string;
|
|
33
|
+
reason?: string;
|
|
34
|
+
scopeVerified: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare class VorimModernTreasury {
|
|
37
|
+
private sdk;
|
|
38
|
+
private minTrustScore;
|
|
39
|
+
private requiredScope;
|
|
40
|
+
private environment;
|
|
41
|
+
private static _warnedNoAuth;
|
|
42
|
+
constructor(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>);
|
|
43
|
+
/**
|
|
44
|
+
* Verify an agent is authorized to create a Modern Treasury payment order, to
|
|
45
|
+
* run before POST /api/payment_orders. Gate: transact scope → active status →
|
|
46
|
+
* trust threshold. Every outcome is audit-logged with the environment tag.
|
|
47
|
+
*/
|
|
48
|
+
authorizePaymentOrder(req: MTPaymentOrderRequest): Promise<MTAuthorization>;
|
|
49
|
+
/** Log that a payment order was created (may enter needs_approval). */
|
|
50
|
+
logPaymentOrderCreated(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Log an approval-status update, driven by Modern Treasury's approval webhook.
|
|
53
|
+
* `status` is typically 'approved', 'needs_approval', or 'denied'.
|
|
54
|
+
*/
|
|
55
|
+
logApprovalUpdated(agentId: string, orderId: string, status: string, approver?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
56
|
+
/** Log that a payment order completed (money moved). */
|
|
57
|
+
logPaymentOrderCompleted(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
58
|
+
/** Log that a payment order was returned, failed, or cancelled. */
|
|
59
|
+
logPaymentOrderFailed(agentId: string, orderId: string, reason?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Express/Connect middleware that gates a payment-order endpoint on agent
|
|
62
|
+
* authorization.
|
|
63
|
+
*
|
|
64
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; pass
|
|
65
|
+
* `authenticate` to verify the caller-to-agent binding. This gates real money
|
|
66
|
+
* movement in production — wiring `authenticate` is strongly recommended, and
|
|
67
|
+
* it complements (does not replace) Modern Treasury's Approval Rules.
|
|
68
|
+
*/
|
|
69
|
+
middleware(options?: {
|
|
70
|
+
agentIdHeader?: string;
|
|
71
|
+
minTrustScore?: number;
|
|
72
|
+
authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
|
|
73
|
+
}): (req: any, res: any, next: any) => Promise<void>;
|
|
74
|
+
private logEvent;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a VorimModernTreasury instance (sandbox by default).
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import createVorim from '@vorim/sdk';
|
|
82
|
+
* import { createVorimModernTreasury } from '@vorim/sdk/integrations/modern-treasury';
|
|
83
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
84
|
+
* const mt = createVorimModernTreasury(vorim, { environment: 'sandbox', minTrustScore: 70 });
|
|
85
|
+
* const auth = await mt.authorizePaymentOrder({ agentId: 'agid_abc', paymentType: 'ach', amount: 25000, counterparty: 'cp_1' });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function createVorimModernTreasury(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>): VorimModernTreasury;
|
|
89
|
+
|
|
90
|
+
export { type MTAuthorization, type MTEnvironment, type MTPaymentOrderRequest, type MTPaymentType, type ModernTreasuryConfig, VorimModernTreasury, createVorimModernTreasury };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// src/integrations/modern-treasury.ts
|
|
2
|
+
var VorimModernTreasury = class _VorimModernTreasury {
|
|
3
|
+
sdk;
|
|
4
|
+
minTrustScore;
|
|
5
|
+
requiredScope;
|
|
6
|
+
environment;
|
|
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
|
+
this.environment = config?.environment ?? "sandbox";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Verify an agent is authorized to create a Modern Treasury payment order, to
|
|
16
|
+
* run before POST /api/payment_orders. Gate: transact scope → active status →
|
|
17
|
+
* trust threshold. Every outcome is audit-logged with the environment tag.
|
|
18
|
+
*/
|
|
19
|
+
async authorizePaymentOrder(req) {
|
|
20
|
+
const threshold = req.minTrustScore ?? this.minTrustScore;
|
|
21
|
+
try {
|
|
22
|
+
const perm = await this.sdk.check(req.agentId, this.requiredScope);
|
|
23
|
+
if (!perm.allowed) {
|
|
24
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: `Missing ${this.requiredScope}` });
|
|
25
|
+
return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: e.message });
|
|
29
|
+
return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Permission check failed: ${e.message}`, scopeVerified: false };
|
|
30
|
+
}
|
|
31
|
+
let score = 0;
|
|
32
|
+
let status = "unknown";
|
|
33
|
+
try {
|
|
34
|
+
const trust = await this.sdk.verify(req.agentId);
|
|
35
|
+
score = trust.trust_score ?? 0;
|
|
36
|
+
status = trust.status ?? "unknown";
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
if (status !== "active") {
|
|
40
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: `Status: ${status}` });
|
|
41
|
+
return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };
|
|
42
|
+
}
|
|
43
|
+
if (score < threshold) {
|
|
44
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "denied", req, { reason: `Score ${score} < ${threshold}` });
|
|
45
|
+
return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };
|
|
46
|
+
}
|
|
47
|
+
await this.logEvent(req.agentId, "mt.payment_order.authorize", "success", req, { trust_score: score });
|
|
48
|
+
return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };
|
|
49
|
+
}
|
|
50
|
+
/** Log that a payment order was created (may enter needs_approval). */
|
|
51
|
+
async logPaymentOrderCreated(agentId, orderId, req) {
|
|
52
|
+
await this.logEvent(agentId, "mt.payment_order.created", "success", req, { payment_order_id: orderId });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Log an approval-status update, driven by Modern Treasury's approval webhook.
|
|
56
|
+
* `status` is typically 'approved', 'needs_approval', or 'denied'.
|
|
57
|
+
*/
|
|
58
|
+
async logApprovalUpdated(agentId, orderId, status, approver, req) {
|
|
59
|
+
const result = status === "approved" ? "success" : status === "denied" ? "denied" : "success";
|
|
60
|
+
await this.logEvent(agentId, "mt.payment_order.approval", result, req, { payment_order_id: orderId, approval_status: status, approver });
|
|
61
|
+
}
|
|
62
|
+
/** Log that a payment order completed (money moved). */
|
|
63
|
+
async logPaymentOrderCompleted(agentId, orderId, req) {
|
|
64
|
+
await this.logEvent(agentId, "mt.payment_order.completed", "success", req, { payment_order_id: orderId });
|
|
65
|
+
}
|
|
66
|
+
/** Log that a payment order was returned, failed, or cancelled. */
|
|
67
|
+
async logPaymentOrderFailed(agentId, orderId, reason, req) {
|
|
68
|
+
await this.logEvent(agentId, "mt.payment_order.failed", "error", req, { payment_order_id: orderId, fail_reason: reason });
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Express/Connect middleware that gates a payment-order endpoint on agent
|
|
72
|
+
* authorization.
|
|
73
|
+
*
|
|
74
|
+
* ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; pass
|
|
75
|
+
* `authenticate` to verify the caller-to-agent binding. This gates real money
|
|
76
|
+
* movement in production — wiring `authenticate` is strongly recommended, and
|
|
77
|
+
* it complements (does not replace) Modern Treasury's Approval Rules.
|
|
78
|
+
*/
|
|
79
|
+
middleware(options) {
|
|
80
|
+
const header = options?.agentIdHeader ?? "x-vorim-agent-id";
|
|
81
|
+
const threshold = options?.minTrustScore ?? this.minTrustScore;
|
|
82
|
+
const authenticate = options?.authenticate;
|
|
83
|
+
if (!authenticate && !_VorimModernTreasury._warnedNoAuth) {
|
|
84
|
+
_VorimModernTreasury._warnedNoAuth = true;
|
|
85
|
+
console.warn(
|
|
86
|
+
"[vorim] VorimModernTreasury.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). This gates money movement \u2014 pass `authenticate`."
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return async (req, res, next) => {
|
|
90
|
+
const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
|
|
91
|
+
if (!agentId) {
|
|
92
|
+
res.status(401).json({ error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` } });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (authenticate) {
|
|
96
|
+
let bound = false;
|
|
97
|
+
try {
|
|
98
|
+
bound = await authenticate(agentId, req);
|
|
99
|
+
} catch {
|
|
100
|
+
bound = false;
|
|
101
|
+
}
|
|
102
|
+
if (!bound) {
|
|
103
|
+
res.status(401).json({ error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" } });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const auth = await this.authorizePaymentOrder({
|
|
108
|
+
agentId,
|
|
109
|
+
paymentType: req.body?.paymentType || "ach",
|
|
110
|
+
amount: req.body?.amount || 0,
|
|
111
|
+
currency: req.body?.currency || "usd",
|
|
112
|
+
counterparty: req.body?.counterparty || "",
|
|
113
|
+
minTrustScore: threshold
|
|
114
|
+
});
|
|
115
|
+
if (!auth.authorized) {
|
|
116
|
+
res.status(403).json({ error: { code: "UNAUTHORIZED_AGENT", message: auth.reason || "Agent not authorized to move money", trust_score: auth.trustScore, status: auth.status } });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
req.vorimAuthorization = auth;
|
|
120
|
+
next();
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async logEvent(agentId, action, result, req, metadata) {
|
|
124
|
+
try {
|
|
125
|
+
await this.sdk.emit({
|
|
126
|
+
agent_id: agentId,
|
|
127
|
+
event_type: "api_request",
|
|
128
|
+
action,
|
|
129
|
+
result,
|
|
130
|
+
resource: req?.counterparty || "",
|
|
131
|
+
metadata: {
|
|
132
|
+
provider: "modern_treasury",
|
|
133
|
+
environment: this.environment,
|
|
134
|
+
payment_type: req?.paymentType || "",
|
|
135
|
+
amount: req?.amount || 0,
|
|
136
|
+
currency: req?.currency || "",
|
|
137
|
+
counterparty: req?.counterparty || "",
|
|
138
|
+
...metadata
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
function createVorimModernTreasury(sdk, config) {
|
|
146
|
+
return new VorimModernTreasury(sdk, config);
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
VorimModernTreasury,
|
|
150
|
+
createVorimModernTreasury
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=modern-treasury.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/modern-treasury.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Modern Treasury Integration (SANDBOX-READY)\n//\n// ⚠️ SANDBOX / EVALUATION. Modern Treasury moves real money (ACH, wire, RTP,\n// book, check, stablecoin) via Payment Orders, but PRODUCTION requires KYB and\n// a bank relationship — an agent cannot self-onboard. This wrapper is fully\n// usable against Modern Treasury's self-serve SANDBOX today and drops onto\n// production once KYB completes. The `environment` field defaults to 'sandbox'\n// and is recorded on every audit event.\n//\n// Wrap point: POST /api/payment_orders (\"an instruction to move money\"), which\n// can enter a `needs_approval` state under Approval Rules (Modern Treasury's\n// native segregation-of-duties). This layer verifies the AGENT (transact scope,\n// active, trust) before the payment order is created and signs the order →\n// approval → completion lifecycle. Because Modern Treasury's approval is\n// dashboard/webhook-driven, the reliable programmatic seam is at CREATION plus\n// consuming the approval webhook — the logApprovalUpdated method is for those\n// webhooks. It does NOT call Modern Treasury or move money — it authorizes and\n// attests.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimModernTreasury } from '@vorim/sdk/integrations/modern-treasury';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const mt = createVorimModernTreasury(vorim, { environment: 'sandbox', minTrustScore: 70 });\n//\n// const auth = await mt.authorizePaymentOrder({\n// agentId: 'agid_abc123',\n// paymentType: 'ach',\n// amount: 25000, // smallest unit (cents)\n// currency: 'usd',\n// counterparty: 'cp_...',\n// });\n// if (auth.authorized) {\n// // ... POST /api/payment_orders, then:\n// await mt.logPaymentOrderCreated(auth.agentId, orderId, { amount: 25000 });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport type MTEnvironment = 'sandbox' | 'production';\nexport type MTPaymentType = 'ach' | 'wire' | 'rtp' | 'book' | 'check' | 'card' | 'stablecoin';\n\nexport interface ModernTreasuryConfig {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n /** 'sandbox' (default) or 'production'. Recorded on every audit event. */\n environment?: MTEnvironment;\n}\n\nexport interface MTPaymentOrderRequest {\n /** The Vorim agent id creating the payment order. */\n agentId: string;\n /** Payment rail / type. */\n paymentType?: MTPaymentType;\n /** Amount in the smallest currency unit (cents). */\n amount?: number;\n /** Currency code. */\n currency?: string;\n /** The counterparty reference the order pays. */\n counterparty?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface MTAuthorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimModernTreasury {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n private environment: MTEnvironment;\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>) {\n this.sdk = sdk;\n this.minTrustScore = config?.minTrustScore ?? 50;\n this.requiredScope = config?.requiredScope ?? 'agent:transact';\n this.environment = config?.environment ?? 'sandbox';\n }\n\n /**\n * Verify an agent is authorized to create a Modern Treasury payment order, to\n * run before POST /api/payment_orders. Gate: transact scope → active status →\n * trust threshold. Every outcome is audit-logged with the environment tag.\n */\n async authorizePaymentOrder(req: MTPaymentOrderRequest): Promise<MTAuthorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', '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, 'mt.payment_order.authorize', 'success', req, { trust_score: score });\n return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };\n }\n\n /** Log that a payment order was created (may enter needs_approval). */\n async logPaymentOrderCreated(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'mt.payment_order.created', 'success', req, { payment_order_id: orderId });\n }\n\n /**\n * Log an approval-status update, driven by Modern Treasury's approval webhook.\n * `status` is typically 'approved', 'needs_approval', or 'denied'.\n */\n async logApprovalUpdated(agentId: string, orderId: string, status: string, approver?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n const result = status === 'approved' ? 'success' : status === 'denied' ? 'denied' : 'success';\n await this.logEvent(agentId, 'mt.payment_order.approval', result, req, { payment_order_id: orderId, approval_status: status, approver });\n }\n\n /** Log that a payment order completed (money moved). */\n async logPaymentOrderCompleted(agentId: string, orderId: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'mt.payment_order.completed', 'success', req, { payment_order_id: orderId });\n }\n\n /** Log that a payment order was returned, failed, or cancelled. */\n async logPaymentOrderFailed(agentId: string, orderId: string, reason?: string, req?: Partial<MTPaymentOrderRequest>): Promise<void> {\n await this.logEvent(agentId, 'mt.payment_order.failed', 'error', req, { payment_order_id: orderId, fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware that gates a payment-order 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. This gates real money\n * movement in production — wiring `authenticate` is strongly recommended, and\n * it complements (does not replace) Modern Treasury's Approval Rules.\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 && !VorimModernTreasury._warnedNoAuth) {\n VorimModernTreasury._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimModernTreasury.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). This gates money ' +\n 'movement — 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.authorizePaymentOrder({\n agentId,\n paymentType: (req.body?.paymentType as MTPaymentType) || 'ach',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'usd',\n counterparty: req.body?.counterparty || '',\n minTrustScore: threshold,\n });\n if (!auth.authorized) {\n res.status(403).json({ error: { code: 'UNAUTHORIZED_AGENT', message: auth.reason || 'Agent not authorized to move money', 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<MTPaymentOrderRequest>,\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?.counterparty || '',\n metadata: {\n provider: 'modern_treasury',\n environment: this.environment,\n payment_type: req?.paymentType || '',\n amount: req?.amount || 0,\n currency: req?.currency || '',\n counterparty: req?.counterparty || '',\n ...metadata,\n },\n });\n } catch { /* never block the payment flow */ }\n }\n}\n\n/**\n * Create a VorimModernTreasury instance (sandbox by default).\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimModernTreasury } from '@vorim/sdk/integrations/modern-treasury';\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const mt = createVorimModernTreasury(vorim, { environment: 'sandbox', minTrustScore: 70 });\n * const auth = await mt.authorizePaymentOrder({ agentId: 'agid_abc', paymentType: 'ach', amount: 25000, counterparty: 'cp_1' });\n * ```\n */\nexport function createVorimModernTreasury(sdk: VorimSDK, config?: Partial<ModernTreasuryConfig>): VorimModernTreasury {\n return new VorimModernTreasury(sdk, config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