@vorim/sdk 3.11.0 → 3.15.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.js +1 -1
- package/dist/integrations/cloudflare.cjs +134 -0
- package/dist/integrations/cloudflare.cjs.map +1 -0
- package/dist/integrations/cloudflare.d.cts +93 -0
- package/dist/integrations/cloudflare.d.ts +93 -0
- package/dist/integrations/cloudflare.js +108 -0
- package/dist/integrations/cloudflare.js.map +1 -0
- package/dist/integrations/coinbase-cdp.cjs +230 -0
- package/dist/integrations/coinbase-cdp.cjs.map +1 -0
- package/dist/integrations/coinbase-cdp.d.cts +169 -0
- package/dist/integrations/coinbase-cdp.d.ts +169 -0
- package/dist/integrations/coinbase-cdp.js +204 -0
- package/dist/integrations/coinbase-cdp.js.map +1 -0
- package/dist/integrations/fhir.cjs +304 -0
- package/dist/integrations/fhir.cjs.map +1 -0
- package/dist/integrations/fhir.d.cts +185 -0
- package/dist/integrations/fhir.d.ts +185 -0
- package/dist/integrations/fhir.js +278 -0
- package/dist/integrations/fhir.js.map +1 -0
- package/dist/integrations/guidewire.cjs +363 -0
- package/dist/integrations/guidewire.cjs.map +1 -0
- package/dist/integrations/guidewire.d.cts +258 -0
- package/dist/integrations/guidewire.d.ts +258 -0
- package/dist/integrations/guidewire.js +337 -0
- package/dist/integrations/guidewire.js.map +1 -0
- package/dist/integrations/legal.cjs +339 -0
- package/dist/integrations/legal.cjs.map +1 -0
- package/dist/integrations/legal.d.cts +225 -0
- package/dist/integrations/legal.d.ts +225 -0
- package/dist/integrations/legal.js +313 -0
- package/dist/integrations/legal.js.map +1 -0
- package/dist/integrations/life-sciences.cjs +335 -0
- package/dist/integrations/life-sciences.cjs.map +1 -0
- package/dist/integrations/life-sciences.d.cts +214 -0
- package/dist/integrations/life-sciences.d.ts +214 -0
- package/dist/integrations/life-sciences.js +309 -0
- package/dist/integrations/life-sciences.js.map +1 -0
- package/dist/integrations/lithic.cjs +290 -0
- package/dist/integrations/lithic.cjs.map +1 -0
- package/dist/integrations/lithic.d.cts +130 -0
- package/dist/integrations/lithic.d.ts +130 -0
- package/dist/integrations/lithic.js +264 -0
- package/dist/integrations/lithic.js.map +1 -0
- package/dist/integrations/marqeta.cjs +285 -0
- package/dist/integrations/marqeta.cjs.map +1 -0
- package/dist/integrations/marqeta.d.cts +121 -0
- package/dist/integrations/marqeta.d.ts +121 -0
- package/dist/integrations/marqeta.js +259 -0
- package/dist/integrations/marqeta.js.map +1 -0
- package/dist/integrations/ramp.cjs +206 -0
- package/dist/integrations/ramp.cjs.map +1 -0
- package/dist/integrations/ramp.d.cts +139 -0
- package/dist/integrations/ramp.d.ts +139 -0
- package/dist/integrations/ramp.js +180 -0
- package/dist/integrations/ramp.js.map +1 -0
- package/dist/integrations/shopify.cjs +203 -0
- package/dist/integrations/shopify.cjs.map +1 -0
- package/dist/integrations/shopify.d.cts +175 -0
- package/dist/integrations/shopify.d.ts +175 -0
- package/dist/integrations/shopify.js +177 -0
- package/dist/integrations/shopify.js.map +1 -0
- package/dist/integrations/stripe-issuing.cjs +316 -0
- package/dist/integrations/stripe-issuing.cjs.map +1 -0
- package/dist/integrations/stripe-issuing.d.cts +154 -0
- package/dist/integrations/stripe-issuing.d.ts +154 -0
- package/dist/integrations/stripe-issuing.js +290 -0
- package/dist/integrations/stripe-issuing.js.map +1 -0
- package/dist/integrations/web-bot-auth.cjs +143 -0
- package/dist/integrations/web-bot-auth.cjs.map +1 -0
- package/dist/integrations/web-bot-auth.d.cts +51 -0
- package/dist/integrations/web-bot-auth.d.ts +51 -0
- package/dist/integrations/web-bot-auth.js +108 -0
- package/dist/integrations/web-bot-auth.js.map +1 -0
- package/package.json +121 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// src/integrations/lithic.ts
|
|
2
|
+
var OPERATION_SCOPE = {
|
|
3
|
+
createCard: "agent:write",
|
|
4
|
+
updateCard: "agent:write",
|
|
5
|
+
authRule: "agent:write",
|
|
6
|
+
asaDecision: "agent:transact"
|
|
7
|
+
};
|
|
8
|
+
var VorimLithic = class {
|
|
9
|
+
sdk;
|
|
10
|
+
agentId;
|
|
11
|
+
humanId;
|
|
12
|
+
maxAuthorizationAmount;
|
|
13
|
+
escalateOverCeiling;
|
|
14
|
+
approverId;
|
|
15
|
+
escalationTimeoutMs;
|
|
16
|
+
minTrustScore;
|
|
17
|
+
onError;
|
|
18
|
+
constructor(sdk, config) {
|
|
19
|
+
if (!config?.agentId) throw new Error("[vorim] Lithic integration requires an agentId.");
|
|
20
|
+
this.sdk = sdk;
|
|
21
|
+
this.agentId = config.agentId;
|
|
22
|
+
this.humanId = config.humanId;
|
|
23
|
+
this.maxAuthorizationAmount = config.maxAuthorizationAmount;
|
|
24
|
+
this.escalateOverCeiling = config.escalateOverCeiling ?? false;
|
|
25
|
+
this.approverId = config.approverId ?? config.humanId;
|
|
26
|
+
this.escalationTimeoutMs = config.escalationTimeoutMs ?? 1800;
|
|
27
|
+
this.minTrustScore = config.minTrustScore ?? 0;
|
|
28
|
+
this.onError = config.onError ?? "closed";
|
|
29
|
+
}
|
|
30
|
+
scopeFor(operation) {
|
|
31
|
+
return OPERATION_SCOPE[operation] ?? "agent:write";
|
|
32
|
+
}
|
|
33
|
+
// --- card lifecycle --------------------------------------------------------
|
|
34
|
+
async guardLifecycle(operation, meta, run) {
|
|
35
|
+
const scope = this.scopeFor(operation);
|
|
36
|
+
let authorized = true;
|
|
37
|
+
let reason;
|
|
38
|
+
try {
|
|
39
|
+
if (this.minTrustScore > 0) {
|
|
40
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
41
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
42
|
+
authorized = false;
|
|
43
|
+
reason = `trust score below ${this.minTrustScore}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (authorized) {
|
|
47
|
+
const perm = await this.sdk.check(this.agentId, scope);
|
|
48
|
+
if (!perm.allowed) {
|
|
49
|
+
authorized = false;
|
|
50
|
+
reason = perm.reason ?? `missing scope ${scope}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
authorized = this.onError === "open";
|
|
55
|
+
reason = authorized ? "vorim unreachable, failed open" : `vorim unreachable: ${e?.message ?? "error"}`;
|
|
56
|
+
}
|
|
57
|
+
if (!authorized) {
|
|
58
|
+
const recorded = await this.recordLifecycle(operation, meta, "denied", reason);
|
|
59
|
+
return { receipt: this.lifecycleReceipt(operation, meta, false, "denied", reason, recorded) };
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const value = await run();
|
|
63
|
+
const recorded = await this.recordLifecycle(operation, meta, "success");
|
|
64
|
+
return { receipt: this.lifecycleReceipt(operation, meta, true, "success", void 0, recorded), value };
|
|
65
|
+
} catch (e) {
|
|
66
|
+
const recorded = await this.recordLifecycle(operation, meta, "error", e?.message);
|
|
67
|
+
throw Object.assign(e ?? new Error("lithic operation failed"), {
|
|
68
|
+
vorimReceipt: this.lifecycleReceipt(operation, meta, true, "error", e?.message, recorded)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Guard creating a card (POST /v1/cards). Requires agent:write. Use
|
|
73
|
+
* cardType SINGLE_USE for one-shot spend or MERCHANT_LOCKED to pin a merchant. */
|
|
74
|
+
guardedCreateCard(meta, run) {
|
|
75
|
+
return this.guardLifecycle("createCard", meta, run);
|
|
76
|
+
}
|
|
77
|
+
/** Guard updating a card's spend limit or state (PATCH /v1/cards/{token}),
|
|
78
|
+
* e.g. state PAUSED. Requires agent:write. */
|
|
79
|
+
guardedUpdateSpendLimit(meta, run) {
|
|
80
|
+
return this.guardLifecycle("updateCard", meta, run);
|
|
81
|
+
}
|
|
82
|
+
/** Guard creating an auth rule (velocity/MCC/amount guardrail). agent:write. */
|
|
83
|
+
guardedCreateAuthRule(meta, run) {
|
|
84
|
+
return this.guardLifecycle("authRule", meta, run);
|
|
85
|
+
}
|
|
86
|
+
// --- Auth Stream Access decision (the signing checkpoint) ------------------
|
|
87
|
+
/**
|
|
88
|
+
* Decide a real-time Lithic authorization. Call from your ASA endpoint and
|
|
89
|
+
* return `{ result: decision.result, token }` to Lithic. Within the ceiling
|
|
90
|
+
* approves; above it declines (fail-closed) or escalates to a named approver.
|
|
91
|
+
* Every decision is signed.
|
|
92
|
+
*/
|
|
93
|
+
async guardedAsaDecision(req) {
|
|
94
|
+
const overCeiling = this.maxAuthorizationAmount != null && typeof req.amount === "number" && req.amount > this.maxAuthorizationAmount;
|
|
95
|
+
let approve = false;
|
|
96
|
+
let outcome = "within";
|
|
97
|
+
let reason;
|
|
98
|
+
let approverId;
|
|
99
|
+
let decisionId;
|
|
100
|
+
try {
|
|
101
|
+
if (this.minTrustScore > 0) {
|
|
102
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
103
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
104
|
+
const rec = await this.recordAsa(req, "declined", {
|
|
105
|
+
reason: `trust score below ${this.minTrustScore}`,
|
|
106
|
+
authOutcome: overCeiling ? "over-ceiling-declined" : "within"
|
|
107
|
+
});
|
|
108
|
+
return this.asaDecision(req, false, `trust score below ${this.minTrustScore}`, overCeiling ? "over-ceiling-declined" : "within", void 0, void 0, rec);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (overCeiling) {
|
|
112
|
+
if (this.escalateOverCeiling) {
|
|
113
|
+
const esc = await this.escalate(req);
|
|
114
|
+
approve = esc.approved;
|
|
115
|
+
outcome = esc.approved ? "escalated-approved" : "escalated-declined";
|
|
116
|
+
approverId = this.approverId;
|
|
117
|
+
decisionId = esc.decisionId;
|
|
118
|
+
reason = esc.approved ? void 0 : esc.reason ?? "named approver declined";
|
|
119
|
+
} else {
|
|
120
|
+
approve = false;
|
|
121
|
+
outcome = "over-ceiling-declined";
|
|
122
|
+
reason = `authorization ${req.amount} exceeds this agent's ceiling of ${this.maxAuthorizationAmount}`;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
const perm = await this.sdk.check(this.agentId, "agent:transact");
|
|
126
|
+
approve = perm.allowed;
|
|
127
|
+
outcome = "within";
|
|
128
|
+
reason = perm.allowed ? void 0 : perm.reason ?? "missing scope agent:transact";
|
|
129
|
+
}
|
|
130
|
+
} catch (e) {
|
|
131
|
+
approve = this.onError === "open";
|
|
132
|
+
reason = approve ? "vorim unreachable, failed open" : `vorim unreachable: ${e?.message ?? "error"}`;
|
|
133
|
+
outcome = overCeiling ? "over-ceiling-declined" : "within";
|
|
134
|
+
}
|
|
135
|
+
const recorded = await this.recordAsa(req, approve ? "success" : "declined", { reason, authOutcome: outcome, approverId, decisionId });
|
|
136
|
+
return this.asaDecision(req, approve, reason, outcome, approverId, decisionId, recorded);
|
|
137
|
+
}
|
|
138
|
+
async escalate(req) {
|
|
139
|
+
const decision = await this.sdk.beforeAction(
|
|
140
|
+
{
|
|
141
|
+
agentId: this.agentId,
|
|
142
|
+
actionType: "api_request",
|
|
143
|
+
actionTarget: "lithic:asaDecision",
|
|
144
|
+
requiredScope: "agent:transact",
|
|
145
|
+
payload: { amount: req.amount, currency: req.currency, limit: this.maxAuthorizationAmount, card_token: req.cardToken, token: req.token },
|
|
146
|
+
context: { integration: "lithic", requires_named_approver: true, approver_hint: this.approverId, merchant: req.merchant }
|
|
147
|
+
},
|
|
148
|
+
{ throwOnDeny: false }
|
|
149
|
+
);
|
|
150
|
+
if (decision.decision === "escalate") {
|
|
151
|
+
const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });
|
|
152
|
+
const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
|
|
153
|
+
return { approved, reason: approved ? void 0 : "named approver declined", decisionId: decision.decisionId };
|
|
154
|
+
}
|
|
155
|
+
if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
|
|
156
|
+
if (decision.decision === "fallback")
|
|
157
|
+
return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
|
|
158
|
+
return { approved: false, reason: decision.reason ?? "declined", decisionId: decision.decisionId };
|
|
159
|
+
}
|
|
160
|
+
// --- audit -----------------------------------------------------------------
|
|
161
|
+
async recordLifecycle(operation, meta, result, reason) {
|
|
162
|
+
try {
|
|
163
|
+
await this.sdk.emit(
|
|
164
|
+
{
|
|
165
|
+
agent_id: this.agentId,
|
|
166
|
+
event_type: "api_request",
|
|
167
|
+
action: `lithic:${operation}${meta.cardToken ? " " + meta.cardToken : ""}`,
|
|
168
|
+
resource: meta.cardToken || "lithic",
|
|
169
|
+
permission: this.scopeFor(operation),
|
|
170
|
+
result,
|
|
171
|
+
input_hash: meta.inputHash,
|
|
172
|
+
metadata: {
|
|
173
|
+
integration: "lithic",
|
|
174
|
+
operation,
|
|
175
|
+
acts_for_human: this.humanId,
|
|
176
|
+
...meta.cardType ? { card_type: meta.cardType } : {},
|
|
177
|
+
...meta.spendLimit != null ? { spend_limit: meta.spendLimit } : {},
|
|
178
|
+
...reason ? { reason } : {}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{ sign: true }
|
|
182
|
+
);
|
|
183
|
+
return true;
|
|
184
|
+
} catch {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async recordAsa(req, result, extra) {
|
|
189
|
+
try {
|
|
190
|
+
await this.sdk.emit(
|
|
191
|
+
{
|
|
192
|
+
agent_id: this.agentId,
|
|
193
|
+
event_type: "api_request",
|
|
194
|
+
action: `lithic:asaDecision${req.token ? " " + req.token : ""}`,
|
|
195
|
+
resource: req.cardToken || "lithic",
|
|
196
|
+
permission: "agent:transact",
|
|
197
|
+
// A card decline is a policy denial in audit terms; the receipt keeps
|
|
198
|
+
// the card-domain word 'declined', the signed event uses the enum.
|
|
199
|
+
result: result === "declined" ? "denied" : result,
|
|
200
|
+
metadata: {
|
|
201
|
+
integration: "lithic",
|
|
202
|
+
operation: "asaDecision",
|
|
203
|
+
acts_for_human: this.humanId,
|
|
204
|
+
amount: req.amount,
|
|
205
|
+
...req.currency ? { currency: req.currency } : {},
|
|
206
|
+
...req.merchant ? { merchant: req.merchant } : {},
|
|
207
|
+
...extra.authOutcome ? { auth_outcome: extra.authOutcome } : {},
|
|
208
|
+
...extra.approverId ? { approver_id: extra.approverId } : {},
|
|
209
|
+
...extra.decisionId ? { decision_id: extra.decisionId } : {},
|
|
210
|
+
...extra.reason ? { reason: extra.reason } : {}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{ sign: true }
|
|
214
|
+
);
|
|
215
|
+
return true;
|
|
216
|
+
} catch {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
lifecycleReceipt(operation, meta, authorized, result, reason, recorded) {
|
|
221
|
+
return {
|
|
222
|
+
authorized,
|
|
223
|
+
agentId: this.agentId,
|
|
224
|
+
humanId: this.humanId,
|
|
225
|
+
operation,
|
|
226
|
+
cardToken: meta.cardToken,
|
|
227
|
+
cardType: meta.cardType,
|
|
228
|
+
result,
|
|
229
|
+
scope: this.scopeFor(operation),
|
|
230
|
+
reason,
|
|
231
|
+
recorded
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
asaDecision(req, approve, reason, authOutcome, approverId, decisionId, recorded) {
|
|
235
|
+
return {
|
|
236
|
+
result: approve ? "APPROVED" : "DECLINED",
|
|
237
|
+
approve,
|
|
238
|
+
receipt: {
|
|
239
|
+
authorized: approve,
|
|
240
|
+
agentId: this.agentId,
|
|
241
|
+
humanId: this.humanId,
|
|
242
|
+
operation: "asaDecision",
|
|
243
|
+
cardToken: req.cardToken,
|
|
244
|
+
amount: req.amount,
|
|
245
|
+
currency: req.currency,
|
|
246
|
+
authOutcome,
|
|
247
|
+
approverId,
|
|
248
|
+
result: approve ? "success" : "declined",
|
|
249
|
+
scope: "agent:transact",
|
|
250
|
+
reason,
|
|
251
|
+
decisionId,
|
|
252
|
+
recorded
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
function createVorimLithic(sdk, config) {
|
|
258
|
+
return new VorimLithic(sdk, config);
|
|
259
|
+
}
|
|
260
|
+
export {
|
|
261
|
+
VorimLithic,
|
|
262
|
+
createVorimLithic
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=lithic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/lithic.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Lithic (card issuing with Auth Stream Access) Integration\n//\n// This guards an AI agent that spends on a Lithic-issued card. It gates and\n// signs card creation/updates and — the novel part — the real-time Auth Stream\n// Access (ASA) decision on every transaction. Lithic POSTs each authorization to\n// your ASA endpoint and you respond APPROVED or declined; this layer makes that\n// decision against the agent's delegated ceiling, escalates above it to a named\n// approver, and signs a tamper-evident record of the approve/decline.\n//\n// LITHIC'S AGENT-PERFECT PRIMITIVES\n// SINGLE_USE cards map to one-shot delegated spend; MERCHANT_LOCKED cards pin an\n// agent to one merchant. spend_limit + spend_limit_duration\n// (TRANSACTION/MONTHLY/ANNUALLY/FOREVER) are Lithic's own controls; Vorim\n// tightens below them per agent and signs every ASA decision.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// create / update / pause a card -> agent:write\n// ASA decision (a spend) -> agent:transact + amount ceiling\n// create an auth rule -> agent:write\n//\n// This layer never holds the Lithic api-key and never calls Lithic itself. For\n// card ops you pass the Lithic call as a closure; for the ASA decision you pass\n// the amount and this layer returns the signed APPROVED/decline you send back.\n//\n// COMPLIANCE FRAMING (honest)\n// PCI DSS Requirement 10 mandates tamper-evident audit logs, NOT cryptographic\n// signatures. A signed record of each ASA decision satisfies that intent. Say\n// \"tamper-evident, signed record of every authorization\", never \"required by\n// PCI\".\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimLithic } from '@vorim/sdk/integrations/lithic';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const lithic = createVorimLithic(vorim, {\n// agentId: 'agid_abc123',\n// maxAuthorizationAmount: 20000, // approve up to $200.00 (cents) per txn\n// escalateOverCeiling: true, approverId: 'finance_ops',\n// });\n//\n// // create a single-use card (you pass the Lithic call):\n// await lithic.guardedCreateCard(\n// { cardType: 'SINGLE_USE', spendLimit: 5000 },\n// () => lithicClient.cards.create({ type: 'SINGLE_USE', spend_limit: 5000 }),\n// );\n//\n// // ASA webhook decision:\n// const decision = await lithic.guardedAsaDecision({ token: 'txn_...', amount: 4999 });\n// // return { result: decision.result, token } to Lithic; decision.receipt is signed.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** Lithic card types. SINGLE_USE and MERCHANT_LOCKED are the agent-friendly\n * ones (one-shot / merchant-pinned delegated spend). */\nexport type LithicCardType = 'VIRTUAL' | 'SINGLE_USE' | 'MERCHANT_LOCKED';\n\nexport type LithicOperation = 'createCard' | 'updateCard' | 'asaDecision' | 'authRule';\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n createCard: 'agent:write',\n updateCard: 'agent:write',\n authRule: 'agent:write',\n asaDecision: 'agent:transact',\n};\n\nexport interface LithicConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The person/team the agent acts for. Recorded and default escalation target. */\n humanId?: string;\n /** Attenuation: cap a single ASA authorization, in minor units (cents). Omit\n * for no per-authorization ceiling. */\n maxAuthorizationAmount?: number;\n /** Over the ceiling, escalate to a named approver instead of declining.\n * Default false: over-ceiling is a signed decline (fail-closed spend). */\n escalateOverCeiling?: boolean;\n /** Named approver for an over-ceiling authorization. Defaults to humanId. */\n approverId?: string;\n /** Max wait for an escalation, ms. Default 1800 (Lithic's ASA budget is tight). */\n escalationTimeoutMs?: number;\n /** Minimum trust score before a card op. Default 0. */\n minTrustScore?: number;\n /** Fail closed (decline/deny on any Vorim error) or fail open. Default 'closed'. */\n onError?: 'closed' | 'open';\n}\n\nexport interface LithicCardMeta {\n cardToken?: string;\n cardType?: LithicCardType;\n /** The Lithic spend_limit set on the card, in cents. Recorded. */\n spendLimit?: number;\n inputHash?: string;\n}\n\nexport interface LithicAsaRequest {\n /** The Lithic transaction token. Echoed back in the ASA response. */\n token?: string;\n cardToken?: string;\n /** The pending amount, in minor units (cents). Checked against the ceiling. */\n amount: number;\n currency?: string;\n merchant?: string;\n}\n\nexport type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-declined' | 'over-ceiling-declined';\n\nexport interface LithicReceipt {\n authorized: boolean;\n agentId: string;\n humanId?: string;\n operation: string;\n cardToken?: string;\n cardType?: LithicCardType;\n amount?: number;\n currency?: string;\n authOutcome?: AuthOutcome;\n approverId?: string;\n result: 'success' | 'denied' | 'declined' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\n/** The ASA decision: the Lithic result string to return, plus the signed\n * receipt. Return `{ result: decision.result, token }` to Lithic. */\nexport interface AsaDecision {\n /** 'APPROVED' to approve; 'DECLINED' otherwise (any non-APPROVED declines). */\n result: 'APPROVED' | 'DECLINED';\n approve: boolean;\n receipt: LithicReceipt;\n}\n\nexport class VorimLithic {\n private sdk: VorimSDK;\n private agentId: string;\n private humanId?: string;\n private maxAuthorizationAmount?: number;\n private escalateOverCeiling: boolean;\n private approverId?: string;\n private escalationTimeoutMs: number;\n private minTrustScore: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: LithicConfig) {\n if (!config?.agentId) throw new Error('[vorim] Lithic integration requires an agentId.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.humanId = config.humanId;\n this.maxAuthorizationAmount = config.maxAuthorizationAmount;\n this.escalateOverCeiling = config.escalateOverCeiling ?? false;\n this.approverId = config.approverId ?? config.humanId;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 1800;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.onError = config.onError ?? 'closed';\n }\n\n private scopeFor(operation: string): PermissionScope {\n return OPERATION_SCOPE[operation] ?? 'agent:write';\n }\n\n // --- card lifecycle --------------------------------------------------------\n\n private async guardLifecycle<T>(\n operation: string,\n meta: LithicCardMeta,\n run: () => Promise<T>,\n ): Promise<{ receipt: LithicReceipt; value?: T }> {\n const scope = this.scopeFor(operation);\n let authorized = true;\n let reason: string | undefined;\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n authorized = false;\n reason = `trust score below ${this.minTrustScore}`;\n }\n }\n if (authorized) {\n const perm = await this.sdk.check(this.agentId, scope);\n if (!perm.allowed) {\n authorized = false;\n reason = perm.reason ?? `missing scope ${scope}`;\n }\n }\n } catch (e: any) {\n authorized = this.onError === 'open';\n reason = authorized ? 'vorim unreachable, failed open' : `vorim unreachable: ${e?.message ?? 'error'}`;\n }\n\n if (!authorized) {\n const recorded = await this.recordLifecycle(operation, meta, 'denied', reason);\n return { receipt: this.lifecycleReceipt(operation, meta, false, 'denied', reason, recorded) };\n }\n try {\n const value = await run();\n const recorded = await this.recordLifecycle(operation, meta, 'success');\n return { receipt: this.lifecycleReceipt(operation, meta, true, 'success', undefined, recorded), value };\n } catch (e: any) {\n const recorded = await this.recordLifecycle(operation, meta, 'error', e?.message);\n throw Object.assign(e ?? new Error('lithic operation failed'), {\n vorimReceipt: this.lifecycleReceipt(operation, meta, true, 'error', e?.message, recorded),\n });\n }\n }\n\n /** Guard creating a card (POST /v1/cards). Requires agent:write. Use\n * cardType SINGLE_USE for one-shot spend or MERCHANT_LOCKED to pin a merchant. */\n guardedCreateCard<T>(meta: LithicCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('createCard', meta, run);\n }\n\n /** Guard updating a card's spend limit or state (PATCH /v1/cards/{token}),\n * e.g. state PAUSED. Requires agent:write. */\n guardedUpdateSpendLimit<T>(meta: LithicCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('updateCard', meta, run);\n }\n\n /** Guard creating an auth rule (velocity/MCC/amount guardrail). agent:write. */\n guardedCreateAuthRule<T>(meta: LithicCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('authRule', meta, run);\n }\n\n // --- Auth Stream Access decision (the signing checkpoint) ------------------\n\n /**\n * Decide a real-time Lithic authorization. Call from your ASA endpoint and\n * return `{ result: decision.result, token }` to Lithic. Within the ceiling\n * approves; above it declines (fail-closed) or escalates to a named approver.\n * Every decision is signed.\n */\n async guardedAsaDecision(req: LithicAsaRequest): Promise<AsaDecision> {\n const overCeiling =\n this.maxAuthorizationAmount != null && typeof req.amount === 'number' && req.amount > this.maxAuthorizationAmount;\n\n let approve = false;\n let outcome: AuthOutcome = 'within';\n let reason: string | undefined;\n let approverId: string | undefined;\n let decisionId: string | undefined;\n\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n const rec = await this.recordAsa(req, 'declined', {\n reason: `trust score below ${this.minTrustScore}`,\n authOutcome: overCeiling ? 'over-ceiling-declined' : 'within',\n });\n return this.asaDecision(req, false, `trust score below ${this.minTrustScore}`, overCeiling ? 'over-ceiling-declined' : 'within', undefined, undefined, rec);\n }\n }\n\n if (overCeiling) {\n if (this.escalateOverCeiling) {\n const esc = await this.escalate(req);\n approve = esc.approved;\n outcome = esc.approved ? 'escalated-approved' : 'escalated-declined';\n approverId = this.approverId;\n decisionId = esc.decisionId;\n reason = esc.approved ? undefined : (esc.reason ?? 'named approver declined');\n } else {\n approve = false;\n outcome = 'over-ceiling-declined';\n reason = `authorization ${req.amount} exceeds this agent's ceiling of ${this.maxAuthorizationAmount}`;\n }\n } else {\n const perm = await this.sdk.check(this.agentId, 'agent:transact');\n approve = perm.allowed;\n outcome = 'within';\n reason = perm.allowed ? undefined : (perm.reason ?? 'missing scope agent:transact');\n }\n } catch (e: any) {\n approve = this.onError === 'open';\n reason = approve ? 'vorim unreachable, failed open' : `vorim unreachable: ${e?.message ?? 'error'}`;\n outcome = overCeiling ? 'over-ceiling-declined' : 'within';\n }\n\n const recorded = await this.recordAsa(req, approve ? 'success' : 'declined', { reason, authOutcome: outcome, approverId, decisionId });\n return this.asaDecision(req, approve, reason, outcome, approverId, decisionId, recorded);\n }\n\n private async escalate(req: LithicAsaRequest): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: 'lithic:asaDecision',\n requiredScope: 'agent:transact',\n payload: { amount: req.amount, currency: req.currency, limit: this.maxAuthorizationAmount, card_token: req.cardToken, token: req.token },\n context: { integration: 'lithic', requires_named_approver: true, approver_hint: this.approverId, merchant: req.merchant },\n },\n { throwOnDeny: false },\n );\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return { approved, reason: approved ? undefined : 'named approver declined', decisionId: decision.decisionId };\n }\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'declined', decisionId: decision.decisionId };\n }\n\n // --- audit -----------------------------------------------------------------\n\n private async recordLifecycle(\n operation: string,\n meta: LithicCardMeta,\n result: 'success' | 'denied' | 'error',\n reason?: string,\n ): Promise<boolean> {\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `lithic:${operation}${meta.cardToken ? ' ' + meta.cardToken : ''}`,\n resource: meta.cardToken || 'lithic',\n permission: this.scopeFor(operation),\n result,\n input_hash: meta.inputHash,\n metadata: {\n integration: 'lithic',\n operation,\n acts_for_human: this.humanId,\n ...(meta.cardType ? { card_type: meta.cardType } : {}),\n ...(meta.spendLimit != null ? { spend_limit: meta.spendLimit } : {}),\n ...(reason ? { reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n private async recordAsa(\n req: LithicAsaRequest,\n result: 'success' | 'declined',\n extra: { reason?: string; authOutcome?: AuthOutcome; approverId?: string; decisionId?: string },\n ): Promise<boolean> {\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `lithic:asaDecision${req.token ? ' ' + req.token : ''}`,\n resource: req.cardToken || 'lithic',\n permission: 'agent:transact',\n // A card decline is a policy denial in audit terms; the receipt keeps\n // the card-domain word 'declined', the signed event uses the enum.\n result: result === 'declined' ? 'denied' : result,\n metadata: {\n integration: 'lithic',\n operation: 'asaDecision',\n acts_for_human: this.humanId,\n amount: req.amount,\n ...(req.currency ? { currency: req.currency } : {}),\n ...(req.merchant ? { merchant: req.merchant } : {}),\n ...(extra.authOutcome ? { auth_outcome: extra.authOutcome } : {}),\n ...(extra.approverId ? { approver_id: extra.approverId } : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n private lifecycleReceipt(\n operation: string,\n meta: LithicCardMeta,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n reason: string | undefined,\n recorded: boolean,\n ): LithicReceipt {\n return {\n authorized,\n agentId: this.agentId,\n humanId: this.humanId,\n operation,\n cardToken: meta.cardToken,\n cardType: meta.cardType,\n result,\n scope: this.scopeFor(operation),\n reason,\n recorded,\n };\n }\n\n private asaDecision(\n req: LithicAsaRequest,\n approve: boolean,\n reason: string | undefined,\n authOutcome: AuthOutcome,\n approverId: string | undefined,\n decisionId: string | undefined,\n recorded: boolean,\n ): AsaDecision {\n return {\n result: approve ? 'APPROVED' : 'DECLINED',\n approve,\n receipt: {\n authorized: approve,\n agentId: this.agentId,\n humanId: this.humanId,\n operation: 'asaDecision',\n cardToken: req.cardToken,\n amount: req.amount,\n currency: req.currency,\n authOutcome,\n approverId,\n result: approve ? 'success' : 'declined',\n scope: 'agent:transact',\n reason,\n decisionId,\n recorded,\n },\n };\n }\n}\n\n/**\n * Create a VorimLithic guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimLithic } from '@vorim/sdk/integrations/lithic';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const lithic = createVorimLithic(vorim, { agentId: 'agid_abc123', maxAuthorizationAmount: 20000 });\n *\n * const decision = await lithic.guardedAsaDecision({ token: 'txn_1', amount: 4999 });\n * // return { result: decision.result, token: 'txn_1' } to Lithic; decision.receipt is signed.\n * ```\n */\nexport function createVorimLithic(sdk: VorimSDK, config: LithicConfig): VorimLithic {\n return new VorimLithic(sdk, config);\n}\n"],"mappings":";AA8DA,IAAM,kBAAmD;AAAA,EACvD,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,aAAa;AACf;AAsEO,IAAM,cAAN,MAAkB;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,KAAe,QAAsB;AAC/C,QAAI,CAAC,QAAQ,QAAS,OAAM,IAAI,MAAM,iDAAiD;AACvF,SAAK,MAAM;AACX,SAAK,UAAU,OAAO;AACtB,SAAK,UAAU,OAAO;AACtB,SAAK,yBAAyB,OAAO;AACrC,SAAK,sBAAsB,OAAO,uBAAuB;AACzD,SAAK,aAAa,OAAO,cAAc,OAAO;AAC9C,SAAK,sBAAsB,OAAO,uBAAuB;AACzD,SAAK,gBAAgB,OAAO,iBAAiB;AAC7C,SAAK,UAAU,OAAO,WAAW;AAAA,EACnC;AAAA,EAEQ,SAAS,WAAoC;AACnD,WAAO,gBAAgB,SAAS,KAAK;AAAA,EACvC;AAAA;AAAA,EAIA,MAAc,eACZ,WACA,MACA,KACgD;AAChD,UAAM,QAAQ,KAAK,SAAS,SAA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,SAAS,kBAAkB,KAAe,QAAmC;AAClF,SAAO,IAAI,YAAY,KAAK,MAAM;AACpC;","names":[]}
|
|
@@ -0,0 +1,285 @@
|
|
|
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/marqeta.ts
|
|
21
|
+
var marqeta_exports = {};
|
|
22
|
+
__export(marqeta_exports, {
|
|
23
|
+
VorimMarqeta: () => VorimMarqeta,
|
|
24
|
+
createVorimMarqeta: () => createVorimMarqeta
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(marqeta_exports);
|
|
27
|
+
var OPERATION_SCOPE = {
|
|
28
|
+
createCard: "agent:write",
|
|
29
|
+
velocityControl: "agent:write",
|
|
30
|
+
suspendCard: "agent:write",
|
|
31
|
+
jitFunding: "agent:transact"
|
|
32
|
+
};
|
|
33
|
+
var VorimMarqeta = class {
|
|
34
|
+
sdk;
|
|
35
|
+
agentId;
|
|
36
|
+
humanId;
|
|
37
|
+
maxAuthorizationAmount;
|
|
38
|
+
escalateOverCeiling;
|
|
39
|
+
approverId;
|
|
40
|
+
escalationTimeoutMs;
|
|
41
|
+
minTrustScore;
|
|
42
|
+
onError;
|
|
43
|
+
constructor(sdk, config) {
|
|
44
|
+
if (!config?.agentId) throw new Error("[vorim] Marqeta integration requires an agentId.");
|
|
45
|
+
this.sdk = sdk;
|
|
46
|
+
this.agentId = config.agentId;
|
|
47
|
+
this.humanId = config.humanId;
|
|
48
|
+
this.maxAuthorizationAmount = config.maxAuthorizationAmount;
|
|
49
|
+
this.escalateOverCeiling = config.escalateOverCeiling ?? false;
|
|
50
|
+
this.approverId = config.approverId ?? config.humanId;
|
|
51
|
+
this.escalationTimeoutMs = config.escalationTimeoutMs ?? 1800;
|
|
52
|
+
this.minTrustScore = config.minTrustScore ?? 0;
|
|
53
|
+
this.onError = config.onError ?? "closed";
|
|
54
|
+
}
|
|
55
|
+
scopeFor(operation) {
|
|
56
|
+
return OPERATION_SCOPE[operation] ?? "agent:write";
|
|
57
|
+
}
|
|
58
|
+
// --- card lifecycle --------------------------------------------------------
|
|
59
|
+
async guardLifecycle(operation, meta, run) {
|
|
60
|
+
const scope = this.scopeFor(operation);
|
|
61
|
+
let authorized = true;
|
|
62
|
+
let reason;
|
|
63
|
+
try {
|
|
64
|
+
if (this.minTrustScore > 0) {
|
|
65
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
66
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
67
|
+
authorized = false;
|
|
68
|
+
reason = `trust score below ${this.minTrustScore}`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (authorized) {
|
|
72
|
+
const perm = await this.sdk.check(this.agentId, scope);
|
|
73
|
+
if (!perm.allowed) {
|
|
74
|
+
authorized = false;
|
|
75
|
+
reason = perm.reason ?? `missing scope ${scope}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
authorized = this.onError === "open";
|
|
80
|
+
reason = authorized ? "vorim unreachable, failed open" : `vorim unreachable: ${e?.message ?? "error"}`;
|
|
81
|
+
}
|
|
82
|
+
if (!authorized) {
|
|
83
|
+
const recorded = await this.recordLifecycle(operation, meta, "denied", reason);
|
|
84
|
+
return { receipt: this.lifecycleReceipt(operation, meta, false, "denied", reason, recorded) };
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const value = await run();
|
|
88
|
+
const recorded = await this.recordLifecycle(operation, meta, "success");
|
|
89
|
+
return { receipt: this.lifecycleReceipt(operation, meta, true, "success", void 0, recorded), value };
|
|
90
|
+
} catch (e) {
|
|
91
|
+
const recorded = await this.recordLifecycle(operation, meta, "error", e?.message);
|
|
92
|
+
throw Object.assign(e ?? new Error("marqeta operation failed"), {
|
|
93
|
+
vorimReceipt: this.lifecycleReceipt(operation, meta, true, "error", e?.message, recorded)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Guard creating a card. Requires agent:write. */
|
|
98
|
+
guardedCreateCard(meta, run) {
|
|
99
|
+
return this.guardLifecycle("createCard", meta, run);
|
|
100
|
+
}
|
|
101
|
+
/** Guard setting a velocity control (amount/count per window). agent:write. */
|
|
102
|
+
guardedVelocityControl(meta, run) {
|
|
103
|
+
return this.guardLifecycle("velocityControl", meta, run);
|
|
104
|
+
}
|
|
105
|
+
/** Guard suspending a card. Requires agent:write. */
|
|
106
|
+
guardedSuspendCard(meta, run) {
|
|
107
|
+
return this.guardLifecycle("suspendCard", meta, run);
|
|
108
|
+
}
|
|
109
|
+
// --- JIT funding decision (the signing checkpoint) -------------------------
|
|
110
|
+
/**
|
|
111
|
+
* Decide a real-time Marqeta JIT Funding authorization. Call from your JIT
|
|
112
|
+
* gateway and shape the Marqeta gateway response from `decision.approve`.
|
|
113
|
+
* Within the ceiling approves; above it declines (fail-closed) or escalates to
|
|
114
|
+
* a named approver. Every decision is signed.
|
|
115
|
+
*/
|
|
116
|
+
async guardedJitFunding(req) {
|
|
117
|
+
const overCeiling = this.maxAuthorizationAmount != null && typeof req.amount === "number" && req.amount > this.maxAuthorizationAmount;
|
|
118
|
+
let approve = false;
|
|
119
|
+
let outcome = "within";
|
|
120
|
+
let reason;
|
|
121
|
+
let approverId;
|
|
122
|
+
let decisionId;
|
|
123
|
+
try {
|
|
124
|
+
if (this.minTrustScore > 0) {
|
|
125
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
126
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
127
|
+
const rec = await this.recordJit(req, "declined", {
|
|
128
|
+
reason: `trust score below ${this.minTrustScore}`,
|
|
129
|
+
authOutcome: overCeiling ? "over-ceiling-declined" : "within"
|
|
130
|
+
});
|
|
131
|
+
return this.jitDecision(req, false, `trust score below ${this.minTrustScore}`, overCeiling ? "over-ceiling-declined" : "within", void 0, void 0, rec);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (overCeiling) {
|
|
135
|
+
if (this.escalateOverCeiling) {
|
|
136
|
+
const esc = await this.escalate(req);
|
|
137
|
+
approve = esc.approved;
|
|
138
|
+
outcome = esc.approved ? "escalated-approved" : "escalated-declined";
|
|
139
|
+
approverId = this.approverId;
|
|
140
|
+
decisionId = esc.decisionId;
|
|
141
|
+
reason = esc.approved ? void 0 : esc.reason ?? "named approver declined";
|
|
142
|
+
} else {
|
|
143
|
+
approve = false;
|
|
144
|
+
outcome = "over-ceiling-declined";
|
|
145
|
+
reason = `authorization ${req.amount} exceeds this agent's ceiling of ${this.maxAuthorizationAmount}`;
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
const perm = await this.sdk.check(this.agentId, "agent:transact");
|
|
149
|
+
approve = perm.allowed;
|
|
150
|
+
outcome = "within";
|
|
151
|
+
reason = perm.allowed ? void 0 : perm.reason ?? "missing scope agent:transact";
|
|
152
|
+
}
|
|
153
|
+
} catch (e) {
|
|
154
|
+
approve = this.onError === "open";
|
|
155
|
+
reason = approve ? "vorim unreachable, failed open" : `vorim unreachable: ${e?.message ?? "error"}`;
|
|
156
|
+
outcome = overCeiling ? "over-ceiling-declined" : "within";
|
|
157
|
+
}
|
|
158
|
+
const recorded = await this.recordJit(req, approve ? "success" : "declined", { reason, authOutcome: outcome, approverId, decisionId });
|
|
159
|
+
return this.jitDecision(req, approve, reason, outcome, approverId, decisionId, recorded);
|
|
160
|
+
}
|
|
161
|
+
async escalate(req) {
|
|
162
|
+
const decision = await this.sdk.beforeAction(
|
|
163
|
+
{
|
|
164
|
+
agentId: this.agentId,
|
|
165
|
+
actionType: "api_request",
|
|
166
|
+
actionTarget: "marqeta:jitFunding",
|
|
167
|
+
requiredScope: "agent:transact",
|
|
168
|
+
payload: { amount: req.amount, currency: req.currency, limit: this.maxAuthorizationAmount, card_token: req.cardToken, token: req.token },
|
|
169
|
+
context: { integration: "marqeta", requires_named_approver: true, approver_hint: this.approverId, merchant: req.merchant }
|
|
170
|
+
},
|
|
171
|
+
{ throwOnDeny: false }
|
|
172
|
+
);
|
|
173
|
+
if (decision.decision === "escalate") {
|
|
174
|
+
const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });
|
|
175
|
+
const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
|
|
176
|
+
return { approved, reason: approved ? void 0 : "named approver declined", decisionId: decision.decisionId };
|
|
177
|
+
}
|
|
178
|
+
if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
|
|
179
|
+
if (decision.decision === "fallback")
|
|
180
|
+
return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
|
|
181
|
+
return { approved: false, reason: decision.reason ?? "declined", decisionId: decision.decisionId };
|
|
182
|
+
}
|
|
183
|
+
// --- audit -----------------------------------------------------------------
|
|
184
|
+
async recordLifecycle(operation, meta, result, reason) {
|
|
185
|
+
try {
|
|
186
|
+
await this.sdk.emit(
|
|
187
|
+
{
|
|
188
|
+
agent_id: this.agentId,
|
|
189
|
+
event_type: "api_request",
|
|
190
|
+
action: `marqeta:${operation}${meta.cardToken ? " " + meta.cardToken : ""}`,
|
|
191
|
+
resource: meta.cardToken || "marqeta",
|
|
192
|
+
permission: this.scopeFor(operation),
|
|
193
|
+
result,
|
|
194
|
+
input_hash: meta.inputHash,
|
|
195
|
+
metadata: {
|
|
196
|
+
integration: "marqeta",
|
|
197
|
+
operation,
|
|
198
|
+
acts_for_human: this.humanId,
|
|
199
|
+
...reason ? { reason } : {}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{ sign: true }
|
|
203
|
+
);
|
|
204
|
+
return true;
|
|
205
|
+
} catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async recordJit(req, result, extra) {
|
|
210
|
+
try {
|
|
211
|
+
await this.sdk.emit(
|
|
212
|
+
{
|
|
213
|
+
agent_id: this.agentId,
|
|
214
|
+
event_type: "api_request",
|
|
215
|
+
action: `marqeta:jitFunding${req.token ? " " + req.token : ""}`,
|
|
216
|
+
resource: req.cardToken || "marqeta",
|
|
217
|
+
permission: "agent:transact",
|
|
218
|
+
// A card decline is a policy denial in audit terms; the receipt keeps
|
|
219
|
+
// the card-domain word 'declined', the signed event uses the enum.
|
|
220
|
+
result: result === "declined" ? "denied" : result,
|
|
221
|
+
metadata: {
|
|
222
|
+
integration: "marqeta",
|
|
223
|
+
operation: "jitFunding",
|
|
224
|
+
acts_for_human: this.humanId,
|
|
225
|
+
amount: req.amount,
|
|
226
|
+
...req.currency ? { currency: req.currency } : {},
|
|
227
|
+
...req.merchant ? { merchant: req.merchant } : {},
|
|
228
|
+
...extra.authOutcome ? { auth_outcome: extra.authOutcome } : {},
|
|
229
|
+
...extra.approverId ? { approver_id: extra.approverId } : {},
|
|
230
|
+
...extra.decisionId ? { decision_id: extra.decisionId } : {},
|
|
231
|
+
...extra.reason ? { reason: extra.reason } : {}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
{ sign: true }
|
|
235
|
+
);
|
|
236
|
+
return true;
|
|
237
|
+
} catch {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
lifecycleReceipt(operation, meta, authorized, result, reason, recorded) {
|
|
242
|
+
return {
|
|
243
|
+
authorized,
|
|
244
|
+
agentId: this.agentId,
|
|
245
|
+
humanId: this.humanId,
|
|
246
|
+
operation,
|
|
247
|
+
cardToken: meta.cardToken,
|
|
248
|
+
result,
|
|
249
|
+
scope: this.scopeFor(operation),
|
|
250
|
+
reason,
|
|
251
|
+
recorded
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
jitDecision(req, approve, reason, authOutcome, approverId, decisionId, recorded) {
|
|
255
|
+
return {
|
|
256
|
+
approve,
|
|
257
|
+
declineReason: approve ? void 0 : reason ?? "declined by Vorim policy",
|
|
258
|
+
receipt: {
|
|
259
|
+
authorized: approve,
|
|
260
|
+
agentId: this.agentId,
|
|
261
|
+
humanId: this.humanId,
|
|
262
|
+
operation: "jitFunding",
|
|
263
|
+
cardToken: req.cardToken,
|
|
264
|
+
amount: req.amount,
|
|
265
|
+
currency: req.currency,
|
|
266
|
+
authOutcome,
|
|
267
|
+
approverId,
|
|
268
|
+
result: approve ? "success" : "declined",
|
|
269
|
+
scope: "agent:transact",
|
|
270
|
+
reason,
|
|
271
|
+
decisionId,
|
|
272
|
+
recorded
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
function createVorimMarqeta(sdk, config) {
|
|
278
|
+
return new VorimMarqeta(sdk, config);
|
|
279
|
+
}
|
|
280
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
281
|
+
0 && (module.exports = {
|
|
282
|
+
VorimMarqeta,
|
|
283
|
+
createVorimMarqeta
|
|
284
|
+
});
|
|
285
|
+
//# sourceMappingURL=marqeta.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/marqeta.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Marqeta (enterprise issuing with JIT Funding) Integration\n//\n// This guards an AI agent that spends on a Marqeta-issued card. It gates and\n// signs card creation, velocity controls, and — the novel part — the Just-in-\n// Time (JIT) Funding gateway decision on every authorization. Marqeta calls your\n// gateway on each authorization and you approve/decline in real time; this layer\n// makes that decision against the agent's delegated ceiling, escalates above it\n// to a named approver, and signs a tamper-evident record of the decision.\n//\n// SAME SHAPE AS LITHIC ASA\n// Marqeta's JIT gateway is architecturally the same as Lithic's Auth Stream\n// Access: a real-time approve/decline checkpoint Vorim sits in front of. Most\n// enterprise/regulated buyers already run Marqeta, so the signed JIT decision is\n// the enterprise version of the same story.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// create card / velocity control / suspend -> agent:write\n// JIT funding decision (a spend) -> agent:transact + amount ceiling\n//\n// This layer never holds Marqeta credentials and never calls Marqeta itself. For\n// card ops you pass the Marqeta call as a closure; for the JIT decision you pass\n// the amount and this layer returns the signed approve/decline you send back.\n//\n// COMPLIANCE FRAMING (honest)\n// PCI DSS Requirement 10 mandates tamper-evident audit logs, NOT cryptographic\n// signatures. A signed JIT decision satisfies that intent. Say \"tamper-evident,\n// signed record of every authorization\", never \"required by PCI\".\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimMarqeta } from '@vorim/sdk/integrations/marqeta';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const marqeta = createVorimMarqeta(vorim, {\n// agentId: 'agid_abc123',\n// maxAuthorizationAmount: 20000,\n// escalateOverCeiling: true, approverId: 'finance_ops',\n// });\n//\n// // JIT funding gateway decision:\n// const decision = await marqeta.guardedJitFunding({ token: 'gpa_...', amount: 4999 });\n// // return { jit_funding: { method: 'pgfs.authorization', ... , decline_reason: ... } }\n// // shaped from decision.approve; decision.receipt is signed.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\nexport type MarqetaOperation = 'createCard' | 'velocityControl' | 'jitFunding' | 'suspendCard';\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n createCard: 'agent:write',\n velocityControl: 'agent:write',\n suspendCard: 'agent:write',\n jitFunding: 'agent:transact',\n};\n\nexport interface MarqetaConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The person/team the agent acts for. Recorded and default escalation target. */\n humanId?: string;\n /** Attenuation: cap a single JIT authorization, in minor units (cents). Omit\n * for no per-authorization ceiling. */\n maxAuthorizationAmount?: number;\n /** Over the ceiling, escalate to a named approver instead of declining.\n * Default false (over-ceiling declines: fail-closed spend). */\n escalateOverCeiling?: boolean;\n /** Named approver for an over-ceiling authorization. Defaults to humanId. */\n approverId?: string;\n /** Max wait for an escalation, ms. Default 1800. */\n escalationTimeoutMs?: number;\n /** Minimum trust score before a card op. Default 0. */\n minTrustScore?: number;\n /** Fail closed (decline/deny on any Vorim error) or fail open. Default 'closed'. */\n onError?: 'closed' | 'open';\n}\n\nexport interface MarqetaCardMeta {\n cardToken?: string;\n inputHash?: string;\n}\n\nexport interface MarqetaJitRequest {\n /** The Marqeta transaction / GPA order token. */\n token?: string;\n cardToken?: string;\n /** The pending amount, in minor units (cents). Checked against the ceiling. */\n amount: number;\n currency?: string;\n merchant?: string;\n}\n\nexport type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-declined' | 'over-ceiling-declined';\n\nexport interface MarqetaReceipt {\n authorized: boolean;\n agentId: string;\n humanId?: string;\n operation: string;\n cardToken?: string;\n amount?: number;\n currency?: string;\n authOutcome?: AuthOutcome;\n approverId?: string;\n result: 'success' | 'denied' | 'declined' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\n/** The JIT funding decision: whether to fund the authorization, plus the signed\n * receipt. Shape the Marqeta gateway response from `approve`. */\nexport interface JitDecision {\n approve: boolean;\n /** When declined, a short reason to surface in the gateway response. */\n declineReason?: string;\n receipt: MarqetaReceipt;\n}\n\nexport class VorimMarqeta {\n private sdk: VorimSDK;\n private agentId: string;\n private humanId?: string;\n private maxAuthorizationAmount?: number;\n private escalateOverCeiling: boolean;\n private approverId?: string;\n private escalationTimeoutMs: number;\n private minTrustScore: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: MarqetaConfig) {\n if (!config?.agentId) throw new Error('[vorim] Marqeta integration requires an agentId.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.humanId = config.humanId;\n this.maxAuthorizationAmount = config.maxAuthorizationAmount;\n this.escalateOverCeiling = config.escalateOverCeiling ?? false;\n this.approverId = config.approverId ?? config.humanId;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 1800;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.onError = config.onError ?? 'closed';\n }\n\n private scopeFor(operation: string): PermissionScope {\n return OPERATION_SCOPE[operation] ?? 'agent:write';\n }\n\n // --- card lifecycle --------------------------------------------------------\n\n private async guardLifecycle<T>(\n operation: string,\n meta: MarqetaCardMeta,\n run: () => Promise<T>,\n ): Promise<{ receipt: MarqetaReceipt; value?: T }> {\n const scope = this.scopeFor(operation);\n let authorized = true;\n let reason: string | undefined;\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n authorized = false;\n reason = `trust score below ${this.minTrustScore}`;\n }\n }\n if (authorized) {\n const perm = await this.sdk.check(this.agentId, scope);\n if (!perm.allowed) {\n authorized = false;\n reason = perm.reason ?? `missing scope ${scope}`;\n }\n }\n } catch (e: any) {\n authorized = this.onError === 'open';\n reason = authorized ? 'vorim unreachable, failed open' : `vorim unreachable: ${e?.message ?? 'error'}`;\n }\n\n if (!authorized) {\n const recorded = await this.recordLifecycle(operation, meta, 'denied', reason);\n return { receipt: this.lifecycleReceipt(operation, meta, false, 'denied', reason, recorded) };\n }\n try {\n const value = await run();\n const recorded = await this.recordLifecycle(operation, meta, 'success');\n return { receipt: this.lifecycleReceipt(operation, meta, true, 'success', undefined, recorded), value };\n } catch (e: any) {\n const recorded = await this.recordLifecycle(operation, meta, 'error', e?.message);\n throw Object.assign(e ?? new Error('marqeta operation failed'), {\n vorimReceipt: this.lifecycleReceipt(operation, meta, true, 'error', e?.message, recorded),\n });\n }\n }\n\n /** Guard creating a card. Requires agent:write. */\n guardedCreateCard<T>(meta: MarqetaCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('createCard', meta, run);\n }\n\n /** Guard setting a velocity control (amount/count per window). agent:write. */\n guardedVelocityControl<T>(meta: MarqetaCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('velocityControl', meta, run);\n }\n\n /** Guard suspending a card. Requires agent:write. */\n guardedSuspendCard<T>(meta: MarqetaCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('suspendCard', meta, run);\n }\n\n // --- JIT funding decision (the signing checkpoint) -------------------------\n\n /**\n * Decide a real-time Marqeta JIT Funding authorization. Call from your JIT\n * gateway and shape the Marqeta gateway response from `decision.approve`.\n * Within the ceiling approves; above it declines (fail-closed) or escalates to\n * a named approver. Every decision is signed.\n */\n async guardedJitFunding(req: MarqetaJitRequest): Promise<JitDecision> {\n const overCeiling =\n this.maxAuthorizationAmount != null && typeof req.amount === 'number' && req.amount > this.maxAuthorizationAmount;\n\n let approve = false;\n let outcome: AuthOutcome = 'within';\n let reason: string | undefined;\n let approverId: string | undefined;\n let decisionId: string | undefined;\n\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n const rec = await this.recordJit(req, 'declined', {\n reason: `trust score below ${this.minTrustScore}`,\n authOutcome: overCeiling ? 'over-ceiling-declined' : 'within',\n });\n return this.jitDecision(req, false, `trust score below ${this.minTrustScore}`, overCeiling ? 'over-ceiling-declined' : 'within', undefined, undefined, rec);\n }\n }\n\n if (overCeiling) {\n if (this.escalateOverCeiling) {\n const esc = await this.escalate(req);\n approve = esc.approved;\n outcome = esc.approved ? 'escalated-approved' : 'escalated-declined';\n approverId = this.approverId;\n decisionId = esc.decisionId;\n reason = esc.approved ? undefined : (esc.reason ?? 'named approver declined');\n } else {\n approve = false;\n outcome = 'over-ceiling-declined';\n reason = `authorization ${req.amount} exceeds this agent's ceiling of ${this.maxAuthorizationAmount}`;\n }\n } else {\n const perm = await this.sdk.check(this.agentId, 'agent:transact');\n approve = perm.allowed;\n outcome = 'within';\n reason = perm.allowed ? undefined : (perm.reason ?? 'missing scope agent:transact');\n }\n } catch (e: any) {\n approve = this.onError === 'open';\n reason = approve ? 'vorim unreachable, failed open' : `vorim unreachable: ${e?.message ?? 'error'}`;\n outcome = overCeiling ? 'over-ceiling-declined' : 'within';\n }\n\n const recorded = await this.recordJit(req, approve ? 'success' : 'declined', { reason, authOutcome: outcome, approverId, decisionId });\n return this.jitDecision(req, approve, reason, outcome, approverId, decisionId, recorded);\n }\n\n private async escalate(req: MarqetaJitRequest): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: 'marqeta:jitFunding',\n requiredScope: 'agent:transact',\n payload: { amount: req.amount, currency: req.currency, limit: this.maxAuthorizationAmount, card_token: req.cardToken, token: req.token },\n context: { integration: 'marqeta', requires_named_approver: true, approver_hint: this.approverId, merchant: req.merchant },\n },\n { throwOnDeny: false },\n );\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return { approved, reason: approved ? undefined : 'named approver declined', decisionId: decision.decisionId };\n }\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'declined', decisionId: decision.decisionId };\n }\n\n // --- audit -----------------------------------------------------------------\n\n private async recordLifecycle(\n operation: string,\n meta: MarqetaCardMeta,\n result: 'success' | 'denied' | 'error',\n reason?: string,\n ): Promise<boolean> {\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `marqeta:${operation}${meta.cardToken ? ' ' + meta.cardToken : ''}`,\n resource: meta.cardToken || 'marqeta',\n permission: this.scopeFor(operation),\n result,\n input_hash: meta.inputHash,\n metadata: {\n integration: 'marqeta',\n operation,\n acts_for_human: this.humanId,\n ...(reason ? { reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n private async recordJit(\n req: MarqetaJitRequest,\n result: 'success' | 'declined',\n extra: { reason?: string; authOutcome?: AuthOutcome; approverId?: string; decisionId?: string },\n ): Promise<boolean> {\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `marqeta:jitFunding${req.token ? ' ' + req.token : ''}`,\n resource: req.cardToken || 'marqeta',\n permission: 'agent:transact',\n // A card decline is a policy denial in audit terms; the receipt keeps\n // the card-domain word 'declined', the signed event uses the enum.\n result: result === 'declined' ? 'denied' : result,\n metadata: {\n integration: 'marqeta',\n operation: 'jitFunding',\n acts_for_human: this.humanId,\n amount: req.amount,\n ...(req.currency ? { currency: req.currency } : {}),\n ...(req.merchant ? { merchant: req.merchant } : {}),\n ...(extra.authOutcome ? { auth_outcome: extra.authOutcome } : {}),\n ...(extra.approverId ? { approver_id: extra.approverId } : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n private lifecycleReceipt(\n operation: string,\n meta: MarqetaCardMeta,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n reason: string | undefined,\n recorded: boolean,\n ): MarqetaReceipt {\n return {\n authorized,\n agentId: this.agentId,\n humanId: this.humanId,\n operation,\n cardToken: meta.cardToken,\n result,\n scope: this.scopeFor(operation),\n reason,\n recorded,\n };\n }\n\n private jitDecision(\n req: MarqetaJitRequest,\n approve: boolean,\n reason: string | undefined,\n authOutcome: AuthOutcome,\n approverId: string | undefined,\n decisionId: string | undefined,\n recorded: boolean,\n ): JitDecision {\n return {\n approve,\n declineReason: approve ? undefined : (reason ?? 'declined by Vorim policy'),\n receipt: {\n authorized: approve,\n agentId: this.agentId,\n humanId: this.humanId,\n operation: 'jitFunding',\n cardToken: req.cardToken,\n amount: req.amount,\n currency: req.currency,\n authOutcome,\n approverId,\n result: approve ? 'success' : 'declined',\n scope: 'agent:transact',\n reason,\n decisionId,\n recorded,\n },\n };\n }\n}\n\n/**\n * Create a VorimMarqeta guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimMarqeta } from '@vorim/sdk/integrations/marqeta';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const marqeta = createVorimMarqeta(vorim, { agentId: 'agid_abc123', maxAuthorizationAmount: 20000 });\n *\n * const decision = await marqeta.guardedJitFunding({ token: 'gpa_1', amount: 4999 });\n * // shape the Marqeta gateway response from decision.approve; decision.receipt is signed.\n * ```\n */\nexport function createVorimMarqeta(sdk: VorimSDK, config: MarqetaConfig): VorimMarqeta {\n return new VorimMarqeta(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDA,IAAM,kBAAmD;AAAA,EACvD,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,YAAY;AACd;AAkEO,IAAM,eAAN,MAAmB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,KAAe,QAAuB;AAChD,QAAI,CAAC,QAAQ,QAAS,OAAM,IAAI,MAAM,kDAAkD;AACxF,SAAK,MAAM;AACX,SAAK,UAAU,OAAO;AACtB,SAAK,UAAU,OAAO;AACt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