@vorim/sdk 3.12.0 → 3.16.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 +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.d.cts +1 -1
- package/dist/integrations/anthropic.d.ts +1 -1
- package/dist/integrations/ap2.d.cts +1 -1
- package/dist/integrations/ap2.d.ts +1 -1
- package/dist/integrations/aws-iam.cjs +225 -0
- package/dist/integrations/aws-iam.cjs.map +1 -0
- package/dist/integrations/aws-iam.d.cts +156 -0
- package/dist/integrations/aws-iam.d.ts +156 -0
- package/dist/integrations/aws-iam.js +199 -0
- package/dist/integrations/aws-iam.js.map +1 -0
- package/dist/integrations/bank-rails.d.cts +1 -1
- package/dist/integrations/bank-rails.d.ts +1 -1
- package/dist/integrations/circle.d.cts +1 -1
- package/dist/integrations/circle.d.ts +1 -1
- package/dist/integrations/cloudflare.d.cts +1 -1
- package/dist/integrations/cloudflare.d.ts +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/crewai.d.cts +1 -1
- package/dist/integrations/crewai.d.ts +1 -1
- package/dist/integrations/entra.cjs +225 -0
- package/dist/integrations/entra.cjs.map +1 -0
- package/dist/integrations/entra.d.cts +155 -0
- package/dist/integrations/entra.d.ts +155 -0
- package/dist/integrations/entra.js +199 -0
- package/dist/integrations/entra.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/hermes.d.cts +1 -1
- package/dist/integrations/hermes.d.ts +1 -1
- package/dist/integrations/langchain.d.cts +1 -1
- package/dist/integrations/langchain.d.ts +1 -1
- package/dist/integrations/langgraph.d.cts +1 -1
- package/dist/integrations/langgraph.d.ts +1 -1
- package/dist/integrations/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/llamaindex.d.cts +1 -1
- package/dist/integrations/llamaindex.d.ts +1 -1
- 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/modern-treasury.d.cts +1 -1
- package/dist/integrations/modern-treasury.d.ts +1 -1
- package/dist/integrations/nekuda.d.cts +1 -1
- package/dist/integrations/nekuda.d.ts +1 -1
- package/dist/integrations/okta.cjs +229 -0
- package/dist/integrations/okta.cjs.map +1 -0
- package/dist/integrations/okta.d.cts +172 -0
- package/dist/integrations/okta.d.ts +172 -0
- package/dist/integrations/okta.js +203 -0
- package/dist/integrations/okta.js.map +1 -0
- package/dist/integrations/openai.d.cts +1 -1
- package/dist/integrations/openai.d.ts +1 -1
- package/dist/integrations/paypal-agent.d.cts +1 -1
- package/dist/integrations/paypal-agent.d.ts +1 -1
- package/dist/integrations/plaid.d.cts +1 -1
- package/dist/integrations/plaid.d.ts +1 -1
- 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.d.cts +1 -1
- package/dist/integrations/shopify.d.ts +1 -1
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.d.cts +1 -1
- package/dist/integrations/skyfire.d.ts +1 -1
- package/dist/integrations/stripe-acp.d.cts +1 -1
- package/dist/integrations/stripe-acp.d.ts +1 -1
- 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/truanon.d.cts +1 -1
- package/dist/integrations/truanon.d.ts +1 -1
- package/dist/integrations/ucp.d.cts +1 -1
- package/dist/integrations/ucp.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.cts +1 -1
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/x402.d.cts +1 -1
- package/dist/integrations/x402.d.ts +1 -1
- package/dist/{types-zzK9YOoa.d.cts → types-Lp1iHEDz.d.cts} +21 -1
- package/dist/{types-zzK9YOoa.d.ts → types-Lp1iHEDz.d.ts} +21 -1
- package/package.json +121 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import { P as PermissionScope } from '../types-Lp1iHEDz.js';
|
|
3
|
+
|
|
4
|
+
/** The Stripe Issuing operations this guard classifies. */
|
|
5
|
+
type StripeIssuingOperation = 'issueCard' | 'updateCard' | 'authorize' | 'dispute';
|
|
6
|
+
interface StripeIssuingConfig {
|
|
7
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
8
|
+
agentId: string;
|
|
9
|
+
/** The person / team the agent acts for. Recorded on every receipt and used as
|
|
10
|
+
* the default escalation target. */
|
|
11
|
+
humanId?: string;
|
|
12
|
+
/** Attenuation: cap a single authorization (one card transaction), in the
|
|
13
|
+
* currency's minor unit (cents). Omit for no per-authorization ceiling. */
|
|
14
|
+
maxAuthorizationAmount?: number;
|
|
15
|
+
/** When an authorization exceeds the ceiling, escalate to a named approver and
|
|
16
|
+
* wait instead of declining outright. Requires the runtime decision plane.
|
|
17
|
+
* Default false: over-ceiling is a signed DECLINE (fail-closed spend). */
|
|
18
|
+
escalateOverCeiling?: boolean;
|
|
19
|
+
/** The named approver for an over-ceiling authorization (segregation of
|
|
20
|
+
* duties). Defaults to humanId. */
|
|
21
|
+
approverId?: string;
|
|
22
|
+
/** Max time to wait for an escalation decision, ms. Default 1800 (well inside
|
|
23
|
+
* Stripe's 2s authorization budget — an escalation that cannot resolve in
|
|
24
|
+
* time declines, and the human can pre-approve out of band). */
|
|
25
|
+
escalationTimeoutMs?: number;
|
|
26
|
+
/** Minimum trust score the agent must hold before a card op. Default 0. */
|
|
27
|
+
minTrustScore?: number;
|
|
28
|
+
/** Fail closed (deny/decline on any Vorim error) or fail open. Default
|
|
29
|
+
* 'closed' — for a spend decision, a check we cannot complete declines. */
|
|
30
|
+
onError?: 'closed' | 'open';
|
|
31
|
+
}
|
|
32
|
+
interface StripeIssuingCardMeta {
|
|
33
|
+
/** The card the op targets, when known. */
|
|
34
|
+
cardId?: string;
|
|
35
|
+
/** The Stripe cardholder id, for issueCard. */
|
|
36
|
+
cardholderId?: string;
|
|
37
|
+
currency?: string;
|
|
38
|
+
/** Optional hash of the request body. */
|
|
39
|
+
inputHash?: string;
|
|
40
|
+
}
|
|
41
|
+
interface StripeAuthorizationRequest {
|
|
42
|
+
/** The Stripe authorization id (iauth_...). */
|
|
43
|
+
authorizationId?: string;
|
|
44
|
+
/** The card the authorization is against. */
|
|
45
|
+
cardId?: string;
|
|
46
|
+
/** The pending amount, in the currency's minor unit (cents). Checked against
|
|
47
|
+
* maxAuthorizationAmount. */
|
|
48
|
+
amount: number;
|
|
49
|
+
currency?: string;
|
|
50
|
+
/** The merchant / MCC, recorded for the audit. */
|
|
51
|
+
merchant?: string;
|
|
52
|
+
}
|
|
53
|
+
/** How an authorization amount resolved. */
|
|
54
|
+
type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-declined' | 'over-ceiling-declined';
|
|
55
|
+
/** An offline-verifiable receipt for a Stripe Issuing op or authorization. */
|
|
56
|
+
interface StripeIssuingReceipt {
|
|
57
|
+
authorized: boolean;
|
|
58
|
+
agentId: string;
|
|
59
|
+
humanId?: string;
|
|
60
|
+
operation: string;
|
|
61
|
+
cardId?: string;
|
|
62
|
+
amount?: number;
|
|
63
|
+
currency?: string;
|
|
64
|
+
authOutcome?: AuthOutcome;
|
|
65
|
+
approverId?: string;
|
|
66
|
+
result: 'success' | 'denied' | 'declined' | 'error';
|
|
67
|
+
scope: PermissionScope;
|
|
68
|
+
reason?: string;
|
|
69
|
+
decisionId?: string;
|
|
70
|
+
recorded: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** The result of a real-time authorization decision: what to return to Stripe,
|
|
73
|
+
* plus the signed receipt. */
|
|
74
|
+
interface AuthorizationDecision {
|
|
75
|
+
/** True = return `{ approved: true }` to Stripe; false = decline. */
|
|
76
|
+
approve: boolean;
|
|
77
|
+
receipt: StripeIssuingReceipt;
|
|
78
|
+
}
|
|
79
|
+
declare class VorimStripeIssuing {
|
|
80
|
+
private sdk;
|
|
81
|
+
private agentId;
|
|
82
|
+
private humanId?;
|
|
83
|
+
private maxAuthorizationAmount?;
|
|
84
|
+
private escalateOverCeiling;
|
|
85
|
+
private approverId?;
|
|
86
|
+
private escalationTimeoutMs;
|
|
87
|
+
private minTrustScore;
|
|
88
|
+
private onError;
|
|
89
|
+
constructor(sdk: VorimSDK, config: StripeIssuingConfig);
|
|
90
|
+
private scopeFor;
|
|
91
|
+
/** Guard a card lifecycle op (issue / update / dispute). Verifies identity +
|
|
92
|
+
* scope, runs the Stripe call, signs a receipt. */
|
|
93
|
+
private guardLifecycle;
|
|
94
|
+
/** Guard issuing a virtual card (POST /v1/issuing/cards). Requires
|
|
95
|
+
* agent:write. Pass the Stripe cards.create call as `run`. */
|
|
96
|
+
guardedIssueCard<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>): Promise<{
|
|
97
|
+
receipt: StripeIssuingReceipt;
|
|
98
|
+
value?: T | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
/** Guard updating a card's spend limit or status (POST /v1/issuing/cards/{id}),
|
|
101
|
+
* e.g. `status: 'inactive'` to freeze. Requires agent:write. */
|
|
102
|
+
guardedUpdateSpend<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>): Promise<{
|
|
103
|
+
receipt: StripeIssuingReceipt;
|
|
104
|
+
value?: T | undefined;
|
|
105
|
+
}>;
|
|
106
|
+
/** Guard freezing a card (updateCard with status inactive). Convenience alias. */
|
|
107
|
+
guardedFreezeCard<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>): Promise<{
|
|
108
|
+
receipt: StripeIssuingReceipt;
|
|
109
|
+
value?: T | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
/** Guard filing a dispute (POST /v1/issuing/disputes). Requires agent:write. */
|
|
112
|
+
guardedDispute<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>): Promise<{
|
|
113
|
+
receipt: StripeIssuingReceipt;
|
|
114
|
+
value?: T | undefined;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Decide a real-time card authorization. Call this from your
|
|
118
|
+
* `issuing_authorization.request` webhook handler within Stripe's 2-second
|
|
119
|
+
* budget, then return `{ approved: decision.approve }` to Stripe. The
|
|
120
|
+
* authorization amount is checked against the agent's delegated ceiling: within
|
|
121
|
+
* it approves; above it either declines (fail-closed spend) or escalates to a
|
|
122
|
+
* named approver when escalateOverCeiling is on. Every decision is signed.
|
|
123
|
+
*/
|
|
124
|
+
guardedAuthorize(req: StripeAuthorizationRequest): Promise<AuthorizationDecision>;
|
|
125
|
+
private escalateAuthorization;
|
|
126
|
+
private recordLifecycle;
|
|
127
|
+
private recordAuthorization;
|
|
128
|
+
private lifecycleReceipt;
|
|
129
|
+
private authReceipt;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Create a VorimStripeIssuing guard around a Vorim SDK instance.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* import createVorim from '@vorim/sdk';
|
|
137
|
+
* import { createVorimStripeIssuing } from '@vorim/sdk/integrations/stripe-issuing';
|
|
138
|
+
*
|
|
139
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
140
|
+
* const issuing = createVorimStripeIssuing(vorim, {
|
|
141
|
+
* agentId: 'agid_abc123',
|
|
142
|
+
* maxAuthorizationAmount: 20000, // $200.00 per transaction
|
|
143
|
+
* escalateOverCeiling: true,
|
|
144
|
+
* approverId: 'finance_ops',
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // real-time authorization webhook:
|
|
148
|
+
* const decision = await issuing.guardedAuthorize({ authorizationId: 'iauth_1', amount: 4999, currency: 'usd' });
|
|
149
|
+
* // return { approved: decision.approve } to Stripe; decision.receipt is signed.
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function createVorimStripeIssuing(sdk: VorimSDK, config: StripeIssuingConfig): VorimStripeIssuing;
|
|
153
|
+
|
|
154
|
+
export { type AuthOutcome, type AuthorizationDecision, type StripeAuthorizationRequest, type StripeIssuingCardMeta, type StripeIssuingConfig, type StripeIssuingOperation, type StripeIssuingReceipt, VorimStripeIssuing, createVorimStripeIssuing };
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// src/integrations/stripe-issuing.ts
|
|
2
|
+
var OPERATION_SCOPE = {
|
|
3
|
+
issueCard: "agent:write",
|
|
4
|
+
updateCard: "agent:write",
|
|
5
|
+
dispute: "agent:write",
|
|
6
|
+
authorize: "agent:transact"
|
|
7
|
+
};
|
|
8
|
+
var VorimStripeIssuing = 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] Stripe Issuing 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 (issue / update / dispute) -----------------------------
|
|
34
|
+
/** Guard a card lifecycle op (issue / update / dispute). Verifies identity +
|
|
35
|
+
* scope, runs the Stripe call, signs a receipt. */
|
|
36
|
+
async guardLifecycle(operation, meta, run) {
|
|
37
|
+
const scope = this.scopeFor(operation);
|
|
38
|
+
let authorized = true;
|
|
39
|
+
let reason;
|
|
40
|
+
try {
|
|
41
|
+
if (this.minTrustScore > 0) {
|
|
42
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
43
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
44
|
+
authorized = false;
|
|
45
|
+
reason = `trust score below ${this.minTrustScore}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (authorized) {
|
|
49
|
+
const perm = await this.sdk.check(this.agentId, scope);
|
|
50
|
+
if (!perm.allowed) {
|
|
51
|
+
authorized = false;
|
|
52
|
+
reason = perm.reason ?? `missing scope ${scope}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
authorized = this.onError === "open";
|
|
57
|
+
reason = authorized ? "vorim unreachable, failed open" : `vorim unreachable: ${e?.message ?? "error"}`;
|
|
58
|
+
}
|
|
59
|
+
if (!authorized) {
|
|
60
|
+
const recorded = await this.recordLifecycle(operation, meta, "denied", reason);
|
|
61
|
+
return { receipt: this.lifecycleReceipt(operation, meta, false, "denied", reason, recorded) };
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const value = await run();
|
|
65
|
+
const recorded = await this.recordLifecycle(operation, meta, "success");
|
|
66
|
+
return { receipt: this.lifecycleReceipt(operation, meta, true, "success", void 0, recorded), value };
|
|
67
|
+
} catch (e) {
|
|
68
|
+
const recorded = await this.recordLifecycle(operation, meta, "error", e?.message);
|
|
69
|
+
throw Object.assign(e ?? new Error("stripe issuing operation failed"), {
|
|
70
|
+
vorimReceipt: this.lifecycleReceipt(operation, meta, true, "error", e?.message, recorded)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Guard issuing a virtual card (POST /v1/issuing/cards). Requires
|
|
75
|
+
* agent:write. Pass the Stripe cards.create call as `run`. */
|
|
76
|
+
guardedIssueCard(meta, run) {
|
|
77
|
+
return this.guardLifecycle("issueCard", meta, run);
|
|
78
|
+
}
|
|
79
|
+
/** Guard updating a card's spend limit or status (POST /v1/issuing/cards/{id}),
|
|
80
|
+
* e.g. `status: 'inactive'` to freeze. Requires agent:write. */
|
|
81
|
+
guardedUpdateSpend(meta, run) {
|
|
82
|
+
return this.guardLifecycle("updateCard", meta, run);
|
|
83
|
+
}
|
|
84
|
+
/** Guard freezing a card (updateCard with status inactive). Convenience alias. */
|
|
85
|
+
guardedFreezeCard(meta, run) {
|
|
86
|
+
return this.guardLifecycle("updateCard", meta, run);
|
|
87
|
+
}
|
|
88
|
+
/** Guard filing a dispute (POST /v1/issuing/disputes). Requires agent:write. */
|
|
89
|
+
guardedDispute(meta, run) {
|
|
90
|
+
return this.guardLifecycle("dispute", meta, run);
|
|
91
|
+
}
|
|
92
|
+
// --- real-time authorization (the signing checkpoint) ----------------------
|
|
93
|
+
/**
|
|
94
|
+
* Decide a real-time card authorization. Call this from your
|
|
95
|
+
* `issuing_authorization.request` webhook handler within Stripe's 2-second
|
|
96
|
+
* budget, then return `{ approved: decision.approve }` to Stripe. The
|
|
97
|
+
* authorization amount is checked against the agent's delegated ceiling: within
|
|
98
|
+
* it approves; above it either declines (fail-closed spend) or escalates to a
|
|
99
|
+
* named approver when escalateOverCeiling is on. Every decision is signed.
|
|
100
|
+
*/
|
|
101
|
+
async guardedAuthorize(req) {
|
|
102
|
+
const scope = "agent:transact";
|
|
103
|
+
const overCeiling = this.maxAuthorizationAmount != null && typeof req.amount === "number" && req.amount > this.maxAuthorizationAmount;
|
|
104
|
+
let approve = false;
|
|
105
|
+
let outcome = "within";
|
|
106
|
+
let reason;
|
|
107
|
+
let approverId;
|
|
108
|
+
let decisionId;
|
|
109
|
+
try {
|
|
110
|
+
if (this.minTrustScore > 0) {
|
|
111
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
112
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
113
|
+
const rec = await this.recordAuthorization(req, "declined", {
|
|
114
|
+
reason: `trust score below ${this.minTrustScore}`,
|
|
115
|
+
authOutcome: overCeiling ? "over-ceiling-declined" : "within"
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
approve: false,
|
|
119
|
+
receipt: this.authReceipt(req, false, "declined", `trust score below ${this.minTrustScore}`, overCeiling ? "over-ceiling-declined" : "within", void 0, void 0, rec)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (overCeiling) {
|
|
124
|
+
if (this.escalateOverCeiling) {
|
|
125
|
+
const esc = await this.escalateAuthorization(req);
|
|
126
|
+
approve = esc.approved;
|
|
127
|
+
outcome = esc.approved ? "escalated-approved" : "escalated-declined";
|
|
128
|
+
approverId = this.approverId;
|
|
129
|
+
decisionId = esc.decisionId;
|
|
130
|
+
reason = esc.approved ? void 0 : esc.reason ?? "named approver declined";
|
|
131
|
+
} else {
|
|
132
|
+
approve = false;
|
|
133
|
+
outcome = "over-ceiling-declined";
|
|
134
|
+
reason = `authorization ${req.amount} exceeds this agent's ceiling of ${this.maxAuthorizationAmount}`;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
const perm = await this.sdk.check(this.agentId, scope);
|
|
138
|
+
approve = perm.allowed;
|
|
139
|
+
outcome = "within";
|
|
140
|
+
reason = perm.allowed ? void 0 : perm.reason ?? `missing scope ${scope}`;
|
|
141
|
+
}
|
|
142
|
+
} catch (e) {
|
|
143
|
+
approve = this.onError === "open";
|
|
144
|
+
reason = approve ? "vorim unreachable, failed open" : `vorim unreachable: ${e?.message ?? "error"}`;
|
|
145
|
+
outcome = overCeiling ? "over-ceiling-declined" : "within";
|
|
146
|
+
}
|
|
147
|
+
const result = approve ? "success" : "declined";
|
|
148
|
+
const recorded = await this.recordAuthorization(req, result, { reason, authOutcome: outcome, approverId, decisionId });
|
|
149
|
+
return {
|
|
150
|
+
approve,
|
|
151
|
+
receipt: this.authReceipt(req, approve, result, reason, outcome, approverId, decisionId, recorded)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async escalateAuthorization(req) {
|
|
155
|
+
const decision = await this.sdk.beforeAction(
|
|
156
|
+
{
|
|
157
|
+
agentId: this.agentId,
|
|
158
|
+
actionType: "api_request",
|
|
159
|
+
actionTarget: "stripe-issuing:authorize",
|
|
160
|
+
requiredScope: "agent:transact",
|
|
161
|
+
payload: {
|
|
162
|
+
amount: req.amount,
|
|
163
|
+
currency: req.currency,
|
|
164
|
+
limit: this.maxAuthorizationAmount,
|
|
165
|
+
card_id: req.cardId,
|
|
166
|
+
authorization_id: req.authorizationId
|
|
167
|
+
},
|
|
168
|
+
context: {
|
|
169
|
+
integration: "stripe-issuing",
|
|
170
|
+
requires_named_approver: true,
|
|
171
|
+
approver_hint: this.approverId,
|
|
172
|
+
merchant: req.merchant
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{ throwOnDeny: false }
|
|
176
|
+
);
|
|
177
|
+
if (decision.decision === "escalate") {
|
|
178
|
+
const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, {
|
|
179
|
+
timeoutMs: this.escalationTimeoutMs
|
|
180
|
+
});
|
|
181
|
+
const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
|
|
182
|
+
return { approved, reason: approved ? void 0 : "named approver declined", decisionId: decision.decisionId };
|
|
183
|
+
}
|
|
184
|
+
if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
|
|
185
|
+
if (decision.decision === "fallback")
|
|
186
|
+
return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
|
|
187
|
+
return { approved: false, reason: decision.reason ?? "declined", decisionId: decision.decisionId };
|
|
188
|
+
}
|
|
189
|
+
// --- audit -----------------------------------------------------------------
|
|
190
|
+
async recordLifecycle(operation, meta, result, reason) {
|
|
191
|
+
const scope = this.scopeFor(operation);
|
|
192
|
+
try {
|
|
193
|
+
await this.sdk.emit(
|
|
194
|
+
{
|
|
195
|
+
agent_id: this.agentId,
|
|
196
|
+
event_type: "api_request",
|
|
197
|
+
action: `stripe-issuing:${operation}${meta.cardId ? " " + meta.cardId : ""}`,
|
|
198
|
+
resource: meta.cardId || meta.cardholderId || "stripe-issuing",
|
|
199
|
+
permission: scope,
|
|
200
|
+
result,
|
|
201
|
+
input_hash: meta.inputHash,
|
|
202
|
+
metadata: {
|
|
203
|
+
integration: "stripe-issuing",
|
|
204
|
+
operation,
|
|
205
|
+
acts_for_human: this.humanId,
|
|
206
|
+
...meta.currency ? { currency: meta.currency } : {},
|
|
207
|
+
...reason ? { reason } : {}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{ sign: true }
|
|
211
|
+
);
|
|
212
|
+
return true;
|
|
213
|
+
} catch {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async recordAuthorization(req, result, extra) {
|
|
218
|
+
try {
|
|
219
|
+
await this.sdk.emit(
|
|
220
|
+
{
|
|
221
|
+
agent_id: this.agentId,
|
|
222
|
+
event_type: "api_request",
|
|
223
|
+
action: `stripe-issuing:authorize${req.authorizationId ? " " + req.authorizationId : ""}`,
|
|
224
|
+
resource: req.cardId || "stripe-issuing",
|
|
225
|
+
permission: "agent:transact",
|
|
226
|
+
// A card decline is a policy denial in audit terms; the receipt keeps
|
|
227
|
+
// the card-domain word 'declined', the signed event uses the enum.
|
|
228
|
+
result: result === "declined" ? "denied" : result,
|
|
229
|
+
metadata: {
|
|
230
|
+
integration: "stripe-issuing",
|
|
231
|
+
operation: "authorize",
|
|
232
|
+
acts_for_human: this.humanId,
|
|
233
|
+
amount: req.amount,
|
|
234
|
+
...req.currency ? { currency: req.currency } : {},
|
|
235
|
+
...req.merchant ? { merchant: req.merchant } : {},
|
|
236
|
+
...extra.authOutcome ? { auth_outcome: extra.authOutcome } : {},
|
|
237
|
+
...extra.approverId ? { approver_id: extra.approverId } : {},
|
|
238
|
+
...extra.decisionId ? { decision_id: extra.decisionId } : {},
|
|
239
|
+
...extra.reason ? { reason: extra.reason } : {}
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
{ sign: true }
|
|
243
|
+
// every approve/decline is a signed, tamper-evident record
|
|
244
|
+
);
|
|
245
|
+
return true;
|
|
246
|
+
} catch {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
lifecycleReceipt(operation, meta, authorized, result, reason, recorded) {
|
|
251
|
+
return {
|
|
252
|
+
authorized,
|
|
253
|
+
agentId: this.agentId,
|
|
254
|
+
humanId: this.humanId,
|
|
255
|
+
operation,
|
|
256
|
+
cardId: meta.cardId,
|
|
257
|
+
currency: meta.currency,
|
|
258
|
+
result,
|
|
259
|
+
scope: this.scopeFor(operation),
|
|
260
|
+
reason,
|
|
261
|
+
recorded
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
authReceipt(req, authorized, result, reason, authOutcome, approverId, decisionId, recorded) {
|
|
265
|
+
return {
|
|
266
|
+
authorized,
|
|
267
|
+
agentId: this.agentId,
|
|
268
|
+
humanId: this.humanId,
|
|
269
|
+
operation: "authorize",
|
|
270
|
+
cardId: req.cardId,
|
|
271
|
+
amount: req.amount,
|
|
272
|
+
currency: req.currency,
|
|
273
|
+
authOutcome,
|
|
274
|
+
approverId,
|
|
275
|
+
result,
|
|
276
|
+
scope: "agent:transact",
|
|
277
|
+
reason,
|
|
278
|
+
decisionId,
|
|
279
|
+
recorded
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
function createVorimStripeIssuing(sdk, config) {
|
|
284
|
+
return new VorimStripeIssuing(sdk, config);
|
|
285
|
+
}
|
|
286
|
+
export {
|
|
287
|
+
VorimStripeIssuing,
|
|
288
|
+
createVorimStripeIssuing
|
|
289
|
+
};
|
|
290
|
+
//# sourceMappingURL=stripe-issuing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/stripe-issuing.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Stripe Issuing (virtual cards for agents) Integration\n//\n// This guards an AI agent that spends on a Stripe-issued virtual card. It gates\n// and signs the two moments that matter: issuing/updating a card (with spend\n// controls), and — the novel part — the REAL-TIME AUTHORIZATION on every\n// transaction. Stripe fires an `issuing_authorization.request` webhook (2-second\n// budget) for each purchase; this layer decides approve/decline against the\n// agent's delegated ceiling, escalates above it to a named approver, and signs a\n// tamper-evident record of the decision. No card rail produces a signed record\n// of every authorization; that is the story.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// issue / update / freeze a card -> agent:write\n// authorize a transaction (spend) -> agent:transact + amount ceiling\n// file a dispute -> agent:write\n//\n// This layer never holds the Stripe secret key and never calls Stripe itself.\n// For card lifecycle ops you pass the Stripe SDK call as a closure; for the\n// authorization webhook you pass the amount and this layer returns the signed\n// approve/decline you send back to Stripe.\n//\n// ATTENUATION (the wedge)\n// Stripe's own spending_controls cap the card. Vorim can TIGHTEN below them per\n// agent, add a per-authorization ceiling, and add segregation of duties: an\n// authorization above the agent's delegated limit is escalated to a named\n// approver instead of auto-approved. Every approve/decline is signed.\n//\n// COMPLIANCE FRAMING (honest)\n// PCI DSS Requirement 10 mandates tamper-evident audit logs, NOT cryptographic\n// signatures. A signed record of each authorization satisfies that intent and is\n// a stronger primitive than file-integrity monitoring. Say \"tamper-evident,\n// signed record of every authorization decision\", never \"required by PCI\".\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimStripeIssuing } from '@vorim/sdk/integrations/stripe-issuing';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const issuing = createVorimStripeIssuing(vorim, {\n// agentId: 'agid_abc123',\n// maxAuthorizationAmount: 20000, // approve up to $200.00 (cents) per txn\n// escalateOverCeiling: true, // above that -> named-approver decision\n// approverId: 'finance_ops',\n// });\n//\n// // 1) issue a card (you pass the Stripe call):\n// const { receipt, value } = await issuing.guardedIssueCard(\n// { cardholderId: 'ich_...', currency: 'usd' },\n// () => stripe.issuing.cards.create({ cardholder, currency, type: 'virtual' }),\n// );\n//\n// // 2) real-time authorization webhook:\n// const decision = await issuing.guardedAuthorize({\n// authorizationId: 'iauth_...', amount: 4999, currency: 'usd', merchant: 'MCC 5812',\n// });\n// // decision.approve is what you return to Stripe within 2s; decision.receipt is signed.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** The Stripe Issuing operations this guard classifies. */\nexport type StripeIssuingOperation =\n | 'issueCard' // POST /v1/issuing/cards\n | 'updateCard' // POST /v1/issuing/cards/{id} (spend limit / freeze)\n | 'authorize' // issuing_authorization.request webhook — the spend decision\n | 'dispute'; // POST /v1/issuing/disputes\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n issueCard: 'agent:write',\n updateCard: 'agent:write',\n dispute: 'agent:write',\n authorize: 'agent:transact',\n};\n\nexport interface StripeIssuingConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The person / team the agent acts for. Recorded on every receipt and used as\n * the default escalation target. */\n humanId?: string;\n /** Attenuation: cap a single authorization (one card transaction), in the\n * currency's minor unit (cents). Omit for no per-authorization ceiling. */\n maxAuthorizationAmount?: number;\n /** When an authorization exceeds the ceiling, escalate to a named approver and\n * wait instead of declining outright. Requires the runtime decision plane.\n * Default false: over-ceiling is a signed DECLINE (fail-closed spend). */\n escalateOverCeiling?: boolean;\n /** The named approver for an over-ceiling authorization (segregation of\n * duties). Defaults to humanId. */\n approverId?: string;\n /** Max time to wait for an escalation decision, ms. Default 1800 (well inside\n * Stripe's 2s authorization budget — an escalation that cannot resolve in\n * time declines, and the human can pre-approve out of band). */\n escalationTimeoutMs?: number;\n /** Minimum trust score the agent must hold before a card op. Default 0. */\n minTrustScore?: number;\n /** Fail closed (deny/decline on any Vorim error) or fail open. Default\n * 'closed' — for a spend decision, a check we cannot complete declines. */\n onError?: 'closed' | 'open';\n}\n\nexport interface StripeIssuingCardMeta {\n /** The card the op targets, when known. */\n cardId?: string;\n /** The Stripe cardholder id, for issueCard. */\n cardholderId?: string;\n currency?: string;\n /** Optional hash of the request body. */\n inputHash?: string;\n}\n\nexport interface StripeAuthorizationRequest {\n /** The Stripe authorization id (iauth_...). */\n authorizationId?: string;\n /** The card the authorization is against. */\n cardId?: string;\n /** The pending amount, in the currency's minor unit (cents). Checked against\n * maxAuthorizationAmount. */\n amount: number;\n currency?: string;\n /** The merchant / MCC, recorded for the audit. */\n merchant?: string;\n}\n\n/** How an authorization amount resolved. */\nexport type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-declined' | 'over-ceiling-declined';\n\n/** An offline-verifiable receipt for a Stripe Issuing op or authorization. */\nexport interface StripeIssuingReceipt {\n authorized: boolean;\n agentId: string;\n humanId?: string;\n operation: string;\n cardId?: 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 result of a real-time authorization decision: what to return to Stripe,\n * plus the signed receipt. */\nexport interface AuthorizationDecision {\n /** True = return `{ approved: true }` to Stripe; false = decline. */\n approve: boolean;\n receipt: StripeIssuingReceipt;\n}\n\nexport class VorimStripeIssuing {\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: StripeIssuingConfig) {\n if (!config?.agentId) throw new Error('[vorim] Stripe Issuing 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 (issue / update / dispute) -----------------------------\n\n /** Guard a card lifecycle op (issue / update / dispute). Verifies identity +\n * scope, runs the Stripe call, signs a receipt. */\n private async guardLifecycle<T>(\n operation: string,\n meta: StripeIssuingCardMeta,\n run: () => Promise<T>,\n ): Promise<{ receipt: StripeIssuingReceipt; 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('stripe issuing operation failed'), {\n vorimReceipt: this.lifecycleReceipt(operation, meta, true, 'error', e?.message, recorded),\n });\n }\n }\n\n /** Guard issuing a virtual card (POST /v1/issuing/cards). Requires\n * agent:write. Pass the Stripe cards.create call as `run`. */\n guardedIssueCard<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('issueCard', meta, run);\n }\n\n /** Guard updating a card's spend limit or status (POST /v1/issuing/cards/{id}),\n * e.g. `status: 'inactive'` to freeze. Requires agent:write. */\n guardedUpdateSpend<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('updateCard', meta, run);\n }\n\n /** Guard freezing a card (updateCard with status inactive). Convenience alias. */\n guardedFreezeCard<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('updateCard', meta, run);\n }\n\n /** Guard filing a dispute (POST /v1/issuing/disputes). Requires agent:write. */\n guardedDispute<T>(meta: StripeIssuingCardMeta, run: () => Promise<T>) {\n return this.guardLifecycle('dispute', meta, run);\n }\n\n // --- real-time authorization (the signing checkpoint) ----------------------\n\n /**\n * Decide a real-time card authorization. Call this from your\n * `issuing_authorization.request` webhook handler within Stripe's 2-second\n * budget, then return `{ approved: decision.approve }` to Stripe. The\n * authorization amount is checked against the agent's delegated ceiling: within\n * it approves; above it either declines (fail-closed spend) or escalates to a\n * named approver when escalateOverCeiling is on. Every decision is signed.\n */\n async guardedAuthorize(req: StripeAuthorizationRequest): Promise<AuthorizationDecision> {\n const scope: PermissionScope = 'agent:transact';\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 // Trust floor first.\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.recordAuthorization(req, 'declined', {\n reason: `trust score below ${this.minTrustScore}`,\n authOutcome: overCeiling ? 'over-ceiling-declined' : 'within',\n });\n return {\n approve: false,\n receipt: this.authReceipt(req, false, 'declined', `trust score below ${this.minTrustScore}`, overCeiling ? 'over-ceiling-declined' : 'within', undefined, undefined, rec),\n };\n }\n }\n\n if (overCeiling) {\n if (this.escalateOverCeiling) {\n const esc = await this.escalateAuthorization(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 // Fail-closed spend: over the ceiling with no escalation is a decline.\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 // Within ceiling: a permission check on the transact scope.\n const perm = await this.sdk.check(this.agentId, scope);\n approve = perm.allowed;\n outcome = 'within';\n reason = perm.allowed ? undefined : (perm.reason ?? `missing scope ${scope}`);\n }\n } catch (e: any) {\n // Fail closed by default: a check we cannot complete DECLINES the spend.\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 result: StripeIssuingReceipt['result'] = approve ? 'success' : 'declined';\n const recorded = await this.recordAuthorization(req, result, { reason, authOutcome: outcome, approverId, decisionId });\n return {\n approve,\n receipt: this.authReceipt(req, approve, result, reason, outcome, approverId, decisionId, recorded),\n };\n }\n\n private async escalateAuthorization(\n req: StripeAuthorizationRequest,\n ): 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: 'stripe-issuing:authorize',\n requiredScope: 'agent:transact',\n payload: {\n amount: req.amount,\n currency: req.currency,\n limit: this.maxAuthorizationAmount,\n card_id: req.cardId,\n authorization_id: req.authorizationId,\n },\n context: {\n integration: 'stripe-issuing',\n requires_named_approver: true,\n approver_hint: this.approverId,\n merchant: req.merchant,\n },\n },\n { throwOnDeny: false },\n );\n\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, {\n timeoutMs: this.escalationTimeoutMs,\n });\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: StripeIssuingCardMeta,\n result: 'success' | 'denied' | 'error',\n reason?: string,\n ): Promise<boolean> {\n const scope = this.scopeFor(operation);\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `stripe-issuing:${operation}${meta.cardId ? ' ' + meta.cardId : ''}`,\n resource: meta.cardId || meta.cardholderId || 'stripe-issuing',\n permission: scope,\n result,\n input_hash: meta.inputHash,\n metadata: {\n integration: 'stripe-issuing',\n operation,\n acts_for_human: this.humanId,\n ...(meta.currency ? { currency: meta.currency } : {}),\n ...(reason ? { reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n private async recordAuthorization(\n req: StripeAuthorizationRequest,\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: `stripe-issuing:authorize${req.authorizationId ? ' ' + req.authorizationId : ''}`,\n resource: req.cardId || 'stripe-issuing',\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: 'stripe-issuing',\n operation: 'authorize',\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 }, // every approve/decline is a signed, tamper-evident record\n );\n return true;\n } catch {\n return false;\n }\n }\n\n private lifecycleReceipt(\n operation: string,\n meta: StripeIssuingCardMeta,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n reason: string | undefined,\n recorded: boolean,\n ): StripeIssuingReceipt {\n return {\n authorized,\n agentId: this.agentId,\n humanId: this.humanId,\n operation,\n cardId: meta.cardId,\n currency: meta.currency,\n result,\n scope: this.scopeFor(operation),\n reason,\n recorded,\n };\n }\n\n private authReceipt(\n req: StripeAuthorizationRequest,\n authorized: boolean,\n result: 'success' | 'declined',\n reason: string | undefined,\n authOutcome: AuthOutcome,\n approverId: string | undefined,\n decisionId: string | undefined,\n recorded: boolean,\n ): StripeIssuingReceipt {\n return {\n authorized,\n agentId: this.agentId,\n humanId: this.humanId,\n operation: 'authorize',\n cardId: req.cardId,\n amount: req.amount,\n currency: req.currency,\n authOutcome,\n approverId,\n result,\n scope: 'agent:transact',\n reason,\n decisionId,\n recorded,\n };\n }\n}\n\n/**\n * Create a VorimStripeIssuing guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimStripeIssuing } from '@vorim/sdk/integrations/stripe-issuing';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const issuing = createVorimStripeIssuing(vorim, {\n * agentId: 'agid_abc123',\n * maxAuthorizationAmount: 20000, // $200.00 per transaction\n * escalateOverCeiling: true,\n * approverId: 'finance_ops',\n * });\n *\n * // real-time authorization webhook:\n * const decision = await issuing.guardedAuthorize({ authorizationId: 'iauth_1', amount: 4999, currency: 'usd' });\n * // return { approved: decision.approve } to Stripe; decision.receipt is signed.\n * ```\n */\nexport function createVorimStripeIssuing(sdk: VorimSDK, config: StripeIssuingConfig): VorimStripeIssuing {\n return new VorimStripeIssuing(sdk, config);\n}\n"],"mappings":";AAqEA,IAAM,kBAAmD;AAAA,EACvD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AACb;AAiFO,IAAM,qBAAN,MAAyB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,KAAe,QAA6B;AACtD,QAAI,CAAC,QAAQ,QAAS,OAAM,IAAI,MAAM,yDAAyD;AAC/F,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;AAAA;AAAA,EAMA,MAAc,eACZ,WACA,MACA,KACuD;AACvD,UAAM,QAAQ,KAAK,SAAS,SAAS;AACrC,QAAI,aAAa;AACjB,QAAI;AACJ,QAAI;AACF,UAAI,KAAK,gBAAgB,GAAG;AAC1B,cAAM,QAAQ,MAAM,KAAK,IAAI,OAAO,KAAK,OAAO;AAChD,aAAK,OAAO,eAAe,KAAK,KAAK,eAAe;AAClD,uBAAa;AACb,mBAAS,qBAAqB,KAAK,aAAa;AAAA,QAClD;AAAA,MACF;AACA,UAAI,YAAY;AACd,cAAM,OAAO,MAAM,KAAK,IAAI,MAAM,KAAK,SAAS,KAAK;AACrD,YAAI,CAAC,KA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
import { VorimSDK } from '../index.cjs';
|
|
2
|
-
import '../types-
|
|
2
|
+
import '../types-Lp1iHEDz.cjs';
|
|
3
3
|
|
|
4
4
|
/** TruAnon rank tiers, weakest to strongest. `Unknown` never meets a minimum. */
|
|
5
5
|
type TruAnonRank = 'Unknown' | 'Dangerous' | 'Cautioned' | 'Credible' | 'Reliable' | 'Genuine';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VorimSDK } from '../index.js';
|
|
2
|
-
import '../types-
|
|
2
|
+
import '../types-Lp1iHEDz.js';
|
|
3
3
|
|
|
4
4
|
/** TruAnon rank tiers, weakest to strongest. `Unknown` never meets a minimum. */
|
|
5
5
|
type TruAnonRank = 'Unknown' | 'Dangerous' | 'Cautioned' | 'Credible' | 'Reliable' | 'Genuine';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VorimSDK, ReplayInputs } from '../index.cjs';
|
|
2
|
-
import { P as PermissionScope } from '../types-
|
|
2
|
+
import { P as PermissionScope } from '../types-Lp1iHEDz.cjs';
|
|
3
3
|
import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.cjs';
|
|
4
4
|
|
|
5
5
|
interface VercelTool {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VorimSDK, ReplayInputs } from '../index.js';
|
|
2
|
-
import { P as PermissionScope } from '../types-
|
|
2
|
+
import { P as PermissionScope } from '../types-Lp1iHEDz.js';
|
|
3
3
|
import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.js';
|
|
4
4
|
|
|
5
5
|
interface VercelTool {
|
|
@@ -369,5 +369,25 @@ interface WorkflowProvenanceGraph {
|
|
|
369
369
|
events_truncated: boolean;
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
|
+
/** Read-only least-privilege analysis of an agent (see getCapabilityProfile). */
|
|
373
|
+
interface CapabilityProfile {
|
|
374
|
+
agentId: string;
|
|
375
|
+
/** The analysis window in days. */
|
|
376
|
+
windowDays: number;
|
|
377
|
+
/** How many audit events informed the analysis. */
|
|
378
|
+
eventsAnalyzed: number;
|
|
379
|
+
/** Scopes granted right now (live, non-revoked). */
|
|
380
|
+
granted: string[];
|
|
381
|
+
/** Distinct scopes actually recorded on the agent's audit events in the window. */
|
|
382
|
+
used: string[];
|
|
383
|
+
/** Granted but never used — candidates to revoke for least privilege. */
|
|
384
|
+
unused: string[];
|
|
385
|
+
/** Used but not currently granted — a gap to review. */
|
|
386
|
+
usedNotGranted: string[];
|
|
387
|
+
/** The suggested least-privilege set (exactly the scopes actually used). */
|
|
388
|
+
suggested: string[];
|
|
389
|
+
/** True when the current grants already equal the suggested set. */
|
|
390
|
+
alreadyLeastPrivilege: boolean;
|
|
391
|
+
}
|
|
372
392
|
|
|
373
|
-
export type { AgentRegistrationResult as A, BeforeActionInput as B, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, SharedMemoryWriteInput as S, TrustRecord as T, WorkflowProvenanceGraph as W, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, SharedMemoryEntry as f, SharedMemoryListResult as g, TokenBudgetInput as h, TokenBudget as i, BudgetSpend as j, AgentStatus as k, AuditEventType as l, AuditResult as m, BudgetEnforcement as n, BudgetScope as o, DecisionVerdict as p, WorkflowGraphEdge as q, WorkflowGraphEvent as r, WorkflowGraphNode as s };
|
|
393
|
+
export type { AgentRegistrationResult as A, BeforeActionInput as B, CapabilityProfile as C, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, SharedMemoryWriteInput as S, TrustRecord as T, WorkflowProvenanceGraph as W, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, SharedMemoryEntry as f, SharedMemoryListResult as g, TokenBudgetInput as h, TokenBudget as i, BudgetSpend as j, AgentStatus as k, AuditEventType as l, AuditResult as m, BudgetEnforcement as n, BudgetScope as o, DecisionVerdict as p, WorkflowGraphEdge as q, WorkflowGraphEvent as r, WorkflowGraphNode as s };
|
|
@@ -369,5 +369,25 @@ interface WorkflowProvenanceGraph {
|
|
|
369
369
|
events_truncated: boolean;
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
|
+
/** Read-only least-privilege analysis of an agent (see getCapabilityProfile). */
|
|
373
|
+
interface CapabilityProfile {
|
|
374
|
+
agentId: string;
|
|
375
|
+
/** The analysis window in days. */
|
|
376
|
+
windowDays: number;
|
|
377
|
+
/** How many audit events informed the analysis. */
|
|
378
|
+
eventsAnalyzed: number;
|
|
379
|
+
/** Scopes granted right now (live, non-revoked). */
|
|
380
|
+
granted: string[];
|
|
381
|
+
/** Distinct scopes actually recorded on the agent's audit events in the window. */
|
|
382
|
+
used: string[];
|
|
383
|
+
/** Granted but never used — candidates to revoke for least privilege. */
|
|
384
|
+
unused: string[];
|
|
385
|
+
/** Used but not currently granted — a gap to review. */
|
|
386
|
+
usedNotGranted: string[];
|
|
387
|
+
/** The suggested least-privilege set (exactly the scopes actually used). */
|
|
388
|
+
suggested: string[];
|
|
389
|
+
/** True when the current grants already equal the suggested set. */
|
|
390
|
+
alreadyLeastPrivilege: boolean;
|
|
391
|
+
}
|
|
372
392
|
|
|
373
|
-
export type { AgentRegistrationResult as A, BeforeActionInput as B, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, SharedMemoryWriteInput as S, TrustRecord as T, WorkflowProvenanceGraph as W, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, SharedMemoryEntry as f, SharedMemoryListResult as g, TokenBudgetInput as h, TokenBudget as i, BudgetSpend as j, AgentStatus as k, AuditEventType as l, AuditResult as m, BudgetEnforcement as n, BudgetScope as o, DecisionVerdict as p, WorkflowGraphEdge as q, WorkflowGraphEvent as r, WorkflowGraphNode as s };
|
|
393
|
+
export type { AgentRegistrationResult as A, BeforeActionInput as B, CapabilityProfile as C, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, SharedMemoryWriteInput as S, TrustRecord as T, WorkflowProvenanceGraph as W, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, SharedMemoryEntry as f, SharedMemoryListResult as g, TokenBudgetInput as h, TokenBudget as i, BudgetSpend as j, AgentStatus as k, AuditEventType as l, AuditResult as m, BudgetEnforcement as n, BudgetScope as o, DecisionVerdict as p, WorkflowGraphEdge as q, WorkflowGraphEvent as r, WorkflowGraphNode as s };
|