@vorim/sdk 3.12.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/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/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/package.json +91 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import { P as PermissionScope } from '../types-zzK9YOoa.cjs';
|
|
3
|
+
|
|
4
|
+
type MarqetaOperation = 'createCard' | 'velocityControl' | 'jitFunding' | 'suspendCard';
|
|
5
|
+
interface MarqetaConfig {
|
|
6
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
7
|
+
agentId: string;
|
|
8
|
+
/** The person/team the agent acts for. Recorded and default escalation target. */
|
|
9
|
+
humanId?: string;
|
|
10
|
+
/** Attenuation: cap a single JIT authorization, in minor units (cents). Omit
|
|
11
|
+
* for no per-authorization ceiling. */
|
|
12
|
+
maxAuthorizationAmount?: number;
|
|
13
|
+
/** Over the ceiling, escalate to a named approver instead of declining.
|
|
14
|
+
* Default false (over-ceiling declines: fail-closed spend). */
|
|
15
|
+
escalateOverCeiling?: boolean;
|
|
16
|
+
/** Named approver for an over-ceiling authorization. Defaults to humanId. */
|
|
17
|
+
approverId?: string;
|
|
18
|
+
/** Max wait for an escalation, ms. Default 1800. */
|
|
19
|
+
escalationTimeoutMs?: number;
|
|
20
|
+
/** Minimum trust score before a card op. Default 0. */
|
|
21
|
+
minTrustScore?: number;
|
|
22
|
+
/** Fail closed (decline/deny on any Vorim error) or fail open. Default 'closed'. */
|
|
23
|
+
onError?: 'closed' | 'open';
|
|
24
|
+
}
|
|
25
|
+
interface MarqetaCardMeta {
|
|
26
|
+
cardToken?: string;
|
|
27
|
+
inputHash?: string;
|
|
28
|
+
}
|
|
29
|
+
interface MarqetaJitRequest {
|
|
30
|
+
/** The Marqeta transaction / GPA order token. */
|
|
31
|
+
token?: string;
|
|
32
|
+
cardToken?: string;
|
|
33
|
+
/** The pending amount, in minor units (cents). Checked against the ceiling. */
|
|
34
|
+
amount: number;
|
|
35
|
+
currency?: string;
|
|
36
|
+
merchant?: string;
|
|
37
|
+
}
|
|
38
|
+
type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-declined' | 'over-ceiling-declined';
|
|
39
|
+
interface MarqetaReceipt {
|
|
40
|
+
authorized: boolean;
|
|
41
|
+
agentId: string;
|
|
42
|
+
humanId?: string;
|
|
43
|
+
operation: string;
|
|
44
|
+
cardToken?: string;
|
|
45
|
+
amount?: number;
|
|
46
|
+
currency?: string;
|
|
47
|
+
authOutcome?: AuthOutcome;
|
|
48
|
+
approverId?: string;
|
|
49
|
+
result: 'success' | 'denied' | 'declined' | 'error';
|
|
50
|
+
scope: PermissionScope;
|
|
51
|
+
reason?: string;
|
|
52
|
+
decisionId?: string;
|
|
53
|
+
recorded: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** The JIT funding decision: whether to fund the authorization, plus the signed
|
|
56
|
+
* receipt. Shape the Marqeta gateway response from `approve`. */
|
|
57
|
+
interface JitDecision {
|
|
58
|
+
approve: boolean;
|
|
59
|
+
/** When declined, a short reason to surface in the gateway response. */
|
|
60
|
+
declineReason?: string;
|
|
61
|
+
receipt: MarqetaReceipt;
|
|
62
|
+
}
|
|
63
|
+
declare class VorimMarqeta {
|
|
64
|
+
private sdk;
|
|
65
|
+
private agentId;
|
|
66
|
+
private humanId?;
|
|
67
|
+
private maxAuthorizationAmount?;
|
|
68
|
+
private escalateOverCeiling;
|
|
69
|
+
private approverId?;
|
|
70
|
+
private escalationTimeoutMs;
|
|
71
|
+
private minTrustScore;
|
|
72
|
+
private onError;
|
|
73
|
+
constructor(sdk: VorimSDK, config: MarqetaConfig);
|
|
74
|
+
private scopeFor;
|
|
75
|
+
private guardLifecycle;
|
|
76
|
+
/** Guard creating a card. Requires agent:write. */
|
|
77
|
+
guardedCreateCard<T>(meta: MarqetaCardMeta, run: () => Promise<T>): Promise<{
|
|
78
|
+
receipt: MarqetaReceipt;
|
|
79
|
+
value?: T | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
/** Guard setting a velocity control (amount/count per window). agent:write. */
|
|
82
|
+
guardedVelocityControl<T>(meta: MarqetaCardMeta, run: () => Promise<T>): Promise<{
|
|
83
|
+
receipt: MarqetaReceipt;
|
|
84
|
+
value?: T | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
/** Guard suspending a card. Requires agent:write. */
|
|
87
|
+
guardedSuspendCard<T>(meta: MarqetaCardMeta, run: () => Promise<T>): Promise<{
|
|
88
|
+
receipt: MarqetaReceipt;
|
|
89
|
+
value?: T | undefined;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Decide a real-time Marqeta JIT Funding authorization. Call from your JIT
|
|
93
|
+
* gateway and shape the Marqeta gateway response from `decision.approve`.
|
|
94
|
+
* Within the ceiling approves; above it declines (fail-closed) or escalates to
|
|
95
|
+
* a named approver. Every decision is signed.
|
|
96
|
+
*/
|
|
97
|
+
guardedJitFunding(req: MarqetaJitRequest): Promise<JitDecision>;
|
|
98
|
+
private escalate;
|
|
99
|
+
private recordLifecycle;
|
|
100
|
+
private recordJit;
|
|
101
|
+
private lifecycleReceipt;
|
|
102
|
+
private jitDecision;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a VorimMarqeta guard around a Vorim SDK instance.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* import createVorim from '@vorim/sdk';
|
|
110
|
+
* import { createVorimMarqeta } from '@vorim/sdk/integrations/marqeta';
|
|
111
|
+
*
|
|
112
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
113
|
+
* const marqeta = createVorimMarqeta(vorim, { agentId: 'agid_abc123', maxAuthorizationAmount: 20000 });
|
|
114
|
+
*
|
|
115
|
+
* const decision = await marqeta.guardedJitFunding({ token: 'gpa_1', amount: 4999 });
|
|
116
|
+
* // shape the Marqeta gateway response from decision.approve; decision.receipt is signed.
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare function createVorimMarqeta(sdk: VorimSDK, config: MarqetaConfig): VorimMarqeta;
|
|
120
|
+
|
|
121
|
+
export { type AuthOutcome, type JitDecision, type MarqetaCardMeta, type MarqetaConfig, type MarqetaJitRequest, type MarqetaOperation, type MarqetaReceipt, VorimMarqeta, createVorimMarqeta };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import { P as PermissionScope } from '../types-zzK9YOoa.js';
|
|
3
|
+
|
|
4
|
+
type MarqetaOperation = 'createCard' | 'velocityControl' | 'jitFunding' | 'suspendCard';
|
|
5
|
+
interface MarqetaConfig {
|
|
6
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
7
|
+
agentId: string;
|
|
8
|
+
/** The person/team the agent acts for. Recorded and default escalation target. */
|
|
9
|
+
humanId?: string;
|
|
10
|
+
/** Attenuation: cap a single JIT authorization, in minor units (cents). Omit
|
|
11
|
+
* for no per-authorization ceiling. */
|
|
12
|
+
maxAuthorizationAmount?: number;
|
|
13
|
+
/** Over the ceiling, escalate to a named approver instead of declining.
|
|
14
|
+
* Default false (over-ceiling declines: fail-closed spend). */
|
|
15
|
+
escalateOverCeiling?: boolean;
|
|
16
|
+
/** Named approver for an over-ceiling authorization. Defaults to humanId. */
|
|
17
|
+
approverId?: string;
|
|
18
|
+
/** Max wait for an escalation, ms. Default 1800. */
|
|
19
|
+
escalationTimeoutMs?: number;
|
|
20
|
+
/** Minimum trust score before a card op. Default 0. */
|
|
21
|
+
minTrustScore?: number;
|
|
22
|
+
/** Fail closed (decline/deny on any Vorim error) or fail open. Default 'closed'. */
|
|
23
|
+
onError?: 'closed' | 'open';
|
|
24
|
+
}
|
|
25
|
+
interface MarqetaCardMeta {
|
|
26
|
+
cardToken?: string;
|
|
27
|
+
inputHash?: string;
|
|
28
|
+
}
|
|
29
|
+
interface MarqetaJitRequest {
|
|
30
|
+
/** The Marqeta transaction / GPA order token. */
|
|
31
|
+
token?: string;
|
|
32
|
+
cardToken?: string;
|
|
33
|
+
/** The pending amount, in minor units (cents). Checked against the ceiling. */
|
|
34
|
+
amount: number;
|
|
35
|
+
currency?: string;
|
|
36
|
+
merchant?: string;
|
|
37
|
+
}
|
|
38
|
+
type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-declined' | 'over-ceiling-declined';
|
|
39
|
+
interface MarqetaReceipt {
|
|
40
|
+
authorized: boolean;
|
|
41
|
+
agentId: string;
|
|
42
|
+
humanId?: string;
|
|
43
|
+
operation: string;
|
|
44
|
+
cardToken?: string;
|
|
45
|
+
amount?: number;
|
|
46
|
+
currency?: string;
|
|
47
|
+
authOutcome?: AuthOutcome;
|
|
48
|
+
approverId?: string;
|
|
49
|
+
result: 'success' | 'denied' | 'declined' | 'error';
|
|
50
|
+
scope: PermissionScope;
|
|
51
|
+
reason?: string;
|
|
52
|
+
decisionId?: string;
|
|
53
|
+
recorded: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** The JIT funding decision: whether to fund the authorization, plus the signed
|
|
56
|
+
* receipt. Shape the Marqeta gateway response from `approve`. */
|
|
57
|
+
interface JitDecision {
|
|
58
|
+
approve: boolean;
|
|
59
|
+
/** When declined, a short reason to surface in the gateway response. */
|
|
60
|
+
declineReason?: string;
|
|
61
|
+
receipt: MarqetaReceipt;
|
|
62
|
+
}
|
|
63
|
+
declare class VorimMarqeta {
|
|
64
|
+
private sdk;
|
|
65
|
+
private agentId;
|
|
66
|
+
private humanId?;
|
|
67
|
+
private maxAuthorizationAmount?;
|
|
68
|
+
private escalateOverCeiling;
|
|
69
|
+
private approverId?;
|
|
70
|
+
private escalationTimeoutMs;
|
|
71
|
+
private minTrustScore;
|
|
72
|
+
private onError;
|
|
73
|
+
constructor(sdk: VorimSDK, config: MarqetaConfig);
|
|
74
|
+
private scopeFor;
|
|
75
|
+
private guardLifecycle;
|
|
76
|
+
/** Guard creating a card. Requires agent:write. */
|
|
77
|
+
guardedCreateCard<T>(meta: MarqetaCardMeta, run: () => Promise<T>): Promise<{
|
|
78
|
+
receipt: MarqetaReceipt;
|
|
79
|
+
value?: T | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
/** Guard setting a velocity control (amount/count per window). agent:write. */
|
|
82
|
+
guardedVelocityControl<T>(meta: MarqetaCardMeta, run: () => Promise<T>): Promise<{
|
|
83
|
+
receipt: MarqetaReceipt;
|
|
84
|
+
value?: T | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
/** Guard suspending a card. Requires agent:write. */
|
|
87
|
+
guardedSuspendCard<T>(meta: MarqetaCardMeta, run: () => Promise<T>): Promise<{
|
|
88
|
+
receipt: MarqetaReceipt;
|
|
89
|
+
value?: T | undefined;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Decide a real-time Marqeta JIT Funding authorization. Call from your JIT
|
|
93
|
+
* gateway and shape the Marqeta gateway response from `decision.approve`.
|
|
94
|
+
* Within the ceiling approves; above it declines (fail-closed) or escalates to
|
|
95
|
+
* a named approver. Every decision is signed.
|
|
96
|
+
*/
|
|
97
|
+
guardedJitFunding(req: MarqetaJitRequest): Promise<JitDecision>;
|
|
98
|
+
private escalate;
|
|
99
|
+
private recordLifecycle;
|
|
100
|
+
private recordJit;
|
|
101
|
+
private lifecycleReceipt;
|
|
102
|
+
private jitDecision;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a VorimMarqeta guard around a Vorim SDK instance.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* import createVorim from '@vorim/sdk';
|
|
110
|
+
* import { createVorimMarqeta } from '@vorim/sdk/integrations/marqeta';
|
|
111
|
+
*
|
|
112
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
113
|
+
* const marqeta = createVorimMarqeta(vorim, { agentId: 'agid_abc123', maxAuthorizationAmount: 20000 });
|
|
114
|
+
*
|
|
115
|
+
* const decision = await marqeta.guardedJitFunding({ token: 'gpa_1', amount: 4999 });
|
|
116
|
+
* // shape the Marqeta gateway response from decision.approve; decision.receipt is signed.
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare function createVorimMarqeta(sdk: VorimSDK, config: MarqetaConfig): VorimMarqeta;
|
|
120
|
+
|
|
121
|
+
export { type AuthOutcome, type JitDecision, type MarqetaCardMeta, type MarqetaConfig, type MarqetaJitRequest, type MarqetaOperation, type MarqetaReceipt, VorimMarqeta, createVorimMarqeta };
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// src/integrations/marqeta.ts
|
|
2
|
+
var OPERATION_SCOPE = {
|
|
3
|
+
createCard: "agent:write",
|
|
4
|
+
velocityControl: "agent:write",
|
|
5
|
+
suspendCard: "agent:write",
|
|
6
|
+
jitFunding: "agent:transact"
|
|
7
|
+
};
|
|
8
|
+
var VorimMarqeta = 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] Marqeta 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("marqeta operation failed"), {
|
|
68
|
+
vorimReceipt: this.lifecycleReceipt(operation, meta, true, "error", e?.message, recorded)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Guard creating a card. Requires agent:write. */
|
|
73
|
+
guardedCreateCard(meta, run) {
|
|
74
|
+
return this.guardLifecycle("createCard", meta, run);
|
|
75
|
+
}
|
|
76
|
+
/** Guard setting a velocity control (amount/count per window). agent:write. */
|
|
77
|
+
guardedVelocityControl(meta, run) {
|
|
78
|
+
return this.guardLifecycle("velocityControl", meta, run);
|
|
79
|
+
}
|
|
80
|
+
/** Guard suspending a card. Requires agent:write. */
|
|
81
|
+
guardedSuspendCard(meta, run) {
|
|
82
|
+
return this.guardLifecycle("suspendCard", meta, run);
|
|
83
|
+
}
|
|
84
|
+
// --- JIT funding decision (the signing checkpoint) -------------------------
|
|
85
|
+
/**
|
|
86
|
+
* Decide a real-time Marqeta JIT Funding authorization. Call from your JIT
|
|
87
|
+
* gateway and shape the Marqeta gateway response from `decision.approve`.
|
|
88
|
+
* Within the ceiling approves; above it declines (fail-closed) or escalates to
|
|
89
|
+
* a named approver. Every decision is signed.
|
|
90
|
+
*/
|
|
91
|
+
async guardedJitFunding(req) {
|
|
92
|
+
const overCeiling = this.maxAuthorizationAmount != null && typeof req.amount === "number" && req.amount > this.maxAuthorizationAmount;
|
|
93
|
+
let approve = false;
|
|
94
|
+
let outcome = "within";
|
|
95
|
+
let reason;
|
|
96
|
+
let approverId;
|
|
97
|
+
let decisionId;
|
|
98
|
+
try {
|
|
99
|
+
if (this.minTrustScore > 0) {
|
|
100
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
101
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
102
|
+
const rec = await this.recordJit(req, "declined", {
|
|
103
|
+
reason: `trust score below ${this.minTrustScore}`,
|
|
104
|
+
authOutcome: overCeiling ? "over-ceiling-declined" : "within"
|
|
105
|
+
});
|
|
106
|
+
return this.jitDecision(req, false, `trust score below ${this.minTrustScore}`, overCeiling ? "over-ceiling-declined" : "within", void 0, void 0, rec);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (overCeiling) {
|
|
110
|
+
if (this.escalateOverCeiling) {
|
|
111
|
+
const esc = await this.escalate(req);
|
|
112
|
+
approve = esc.approved;
|
|
113
|
+
outcome = esc.approved ? "escalated-approved" : "escalated-declined";
|
|
114
|
+
approverId = this.approverId;
|
|
115
|
+
decisionId = esc.decisionId;
|
|
116
|
+
reason = esc.approved ? void 0 : esc.reason ?? "named approver declined";
|
|
117
|
+
} else {
|
|
118
|
+
approve = false;
|
|
119
|
+
outcome = "over-ceiling-declined";
|
|
120
|
+
reason = `authorization ${req.amount} exceeds this agent's ceiling of ${this.maxAuthorizationAmount}`;
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
const perm = await this.sdk.check(this.agentId, "agent:transact");
|
|
124
|
+
approve = perm.allowed;
|
|
125
|
+
outcome = "within";
|
|
126
|
+
reason = perm.allowed ? void 0 : perm.reason ?? "missing scope agent:transact";
|
|
127
|
+
}
|
|
128
|
+
} catch (e) {
|
|
129
|
+
approve = this.onError === "open";
|
|
130
|
+
reason = approve ? "vorim unreachable, failed open" : `vorim unreachable: ${e?.message ?? "error"}`;
|
|
131
|
+
outcome = overCeiling ? "over-ceiling-declined" : "within";
|
|
132
|
+
}
|
|
133
|
+
const recorded = await this.recordJit(req, approve ? "success" : "declined", { reason, authOutcome: outcome, approverId, decisionId });
|
|
134
|
+
return this.jitDecision(req, approve, reason, outcome, approverId, decisionId, recorded);
|
|
135
|
+
}
|
|
136
|
+
async escalate(req) {
|
|
137
|
+
const decision = await this.sdk.beforeAction(
|
|
138
|
+
{
|
|
139
|
+
agentId: this.agentId,
|
|
140
|
+
actionType: "api_request",
|
|
141
|
+
actionTarget: "marqeta:jitFunding",
|
|
142
|
+
requiredScope: "agent:transact",
|
|
143
|
+
payload: { amount: req.amount, currency: req.currency, limit: this.maxAuthorizationAmount, card_token: req.cardToken, token: req.token },
|
|
144
|
+
context: { integration: "marqeta", requires_named_approver: true, approver_hint: this.approverId, merchant: req.merchant }
|
|
145
|
+
},
|
|
146
|
+
{ throwOnDeny: false }
|
|
147
|
+
);
|
|
148
|
+
if (decision.decision === "escalate") {
|
|
149
|
+
const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });
|
|
150
|
+
const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
|
|
151
|
+
return { approved, reason: approved ? void 0 : "named approver declined", decisionId: decision.decisionId };
|
|
152
|
+
}
|
|
153
|
+
if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
|
|
154
|
+
if (decision.decision === "fallback")
|
|
155
|
+
return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
|
|
156
|
+
return { approved: false, reason: decision.reason ?? "declined", decisionId: decision.decisionId };
|
|
157
|
+
}
|
|
158
|
+
// --- audit -----------------------------------------------------------------
|
|
159
|
+
async recordLifecycle(operation, meta, result, reason) {
|
|
160
|
+
try {
|
|
161
|
+
await this.sdk.emit(
|
|
162
|
+
{
|
|
163
|
+
agent_id: this.agentId,
|
|
164
|
+
event_type: "api_request",
|
|
165
|
+
action: `marqeta:${operation}${meta.cardToken ? " " + meta.cardToken : ""}`,
|
|
166
|
+
resource: meta.cardToken || "marqeta",
|
|
167
|
+
permission: this.scopeFor(operation),
|
|
168
|
+
result,
|
|
169
|
+
input_hash: meta.inputHash,
|
|
170
|
+
metadata: {
|
|
171
|
+
integration: "marqeta",
|
|
172
|
+
operation,
|
|
173
|
+
acts_for_human: this.humanId,
|
|
174
|
+
...reason ? { reason } : {}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{ sign: true }
|
|
178
|
+
);
|
|
179
|
+
return true;
|
|
180
|
+
} catch {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async recordJit(req, result, extra) {
|
|
185
|
+
try {
|
|
186
|
+
await this.sdk.emit(
|
|
187
|
+
{
|
|
188
|
+
agent_id: this.agentId,
|
|
189
|
+
event_type: "api_request",
|
|
190
|
+
action: `marqeta:jitFunding${req.token ? " " + req.token : ""}`,
|
|
191
|
+
resource: req.cardToken || "marqeta",
|
|
192
|
+
permission: "agent:transact",
|
|
193
|
+
// A card decline is a policy denial in audit terms; the receipt keeps
|
|
194
|
+
// the card-domain word 'declined', the signed event uses the enum.
|
|
195
|
+
result: result === "declined" ? "denied" : result,
|
|
196
|
+
metadata: {
|
|
197
|
+
integration: "marqeta",
|
|
198
|
+
operation: "jitFunding",
|
|
199
|
+
acts_for_human: this.humanId,
|
|
200
|
+
amount: req.amount,
|
|
201
|
+
...req.currency ? { currency: req.currency } : {},
|
|
202
|
+
...req.merchant ? { merchant: req.merchant } : {},
|
|
203
|
+
...extra.authOutcome ? { auth_outcome: extra.authOutcome } : {},
|
|
204
|
+
...extra.approverId ? { approver_id: extra.approverId } : {},
|
|
205
|
+
...extra.decisionId ? { decision_id: extra.decisionId } : {},
|
|
206
|
+
...extra.reason ? { reason: extra.reason } : {}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{ sign: true }
|
|
210
|
+
);
|
|
211
|
+
return true;
|
|
212
|
+
} catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
lifecycleReceipt(operation, meta, authorized, result, reason, recorded) {
|
|
217
|
+
return {
|
|
218
|
+
authorized,
|
|
219
|
+
agentId: this.agentId,
|
|
220
|
+
humanId: this.humanId,
|
|
221
|
+
operation,
|
|
222
|
+
cardToken: meta.cardToken,
|
|
223
|
+
result,
|
|
224
|
+
scope: this.scopeFor(operation),
|
|
225
|
+
reason,
|
|
226
|
+
recorded
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
jitDecision(req, approve, reason, authOutcome, approverId, decisionId, recorded) {
|
|
230
|
+
return {
|
|
231
|
+
approve,
|
|
232
|
+
declineReason: approve ? void 0 : reason ?? "declined by Vorim policy",
|
|
233
|
+
receipt: {
|
|
234
|
+
authorized: approve,
|
|
235
|
+
agentId: this.agentId,
|
|
236
|
+
humanId: this.humanId,
|
|
237
|
+
operation: "jitFunding",
|
|
238
|
+
cardToken: req.cardToken,
|
|
239
|
+
amount: req.amount,
|
|
240
|
+
currency: req.currency,
|
|
241
|
+
authOutcome,
|
|
242
|
+
approverId,
|
|
243
|
+
result: approve ? "success" : "declined",
|
|
244
|
+
scope: "agent:transact",
|
|
245
|
+
reason,
|
|
246
|
+
decisionId,
|
|
247
|
+
recorded
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
function createVorimMarqeta(sdk, config) {
|
|
253
|
+
return new VorimMarqeta(sdk, config);
|
|
254
|
+
}
|
|
255
|
+
export {
|
|
256
|
+
VorimMarqeta,
|
|
257
|
+
createVorimMarqeta
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=marqeta.js.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":";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;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,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