@conto_finance/sdk 0.1.0 → 0.3.1
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/README.md +147 -2
- package/dist/index.d.mts +802 -141
- package/dist/index.d.ts +802 -141
- package/dist/index.js +714 -133
- package/dist/index.mjs +709 -133
- package/package.json +8 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
interface ApiErrorMetadata {
|
|
2
|
+
code: string;
|
|
3
|
+
status: number;
|
|
4
|
+
requestId?: string;
|
|
5
|
+
retryAfter?: number;
|
|
6
|
+
retryGuidance?: string;
|
|
7
|
+
actionUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
/**
|
|
2
11
|
* Conto Admin SDK
|
|
3
12
|
*
|
|
@@ -24,6 +33,7 @@
|
|
|
24
33
|
* await admin.agents.assignPolicy(agentId, policy.id);
|
|
25
34
|
* ```
|
|
26
35
|
*/
|
|
36
|
+
|
|
27
37
|
interface ContoAdminConfig {
|
|
28
38
|
/** Your organization API key (conto_xxx...) */
|
|
29
39
|
orgApiKey: string;
|
|
@@ -32,9 +42,13 @@ interface ContoAdminConfig {
|
|
|
32
42
|
/** Request timeout in milliseconds. Defaults to 30000 */
|
|
33
43
|
timeout?: number;
|
|
34
44
|
}
|
|
35
|
-
|
|
36
|
-
code: string;
|
|
37
|
-
status: number;
|
|
45
|
+
declare class ContoAdminError extends Error {
|
|
46
|
+
readonly code: string;
|
|
47
|
+
readonly status: number;
|
|
48
|
+
readonly requestId?: string;
|
|
49
|
+
readonly retryAfter?: number;
|
|
50
|
+
readonly retryGuidance?: string;
|
|
51
|
+
constructor(message: string, metadata: ApiErrorMetadata);
|
|
38
52
|
}
|
|
39
53
|
interface PaginationParams {
|
|
40
54
|
limit?: number;
|
|
@@ -53,7 +67,9 @@ type AgentRiskTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
|
53
67
|
type AgentAttestationMode = 'KEY_ONLY' | 'SIGNED_REQUEST' | 'SIGNED_REQUEST_WITH_CONTEXT';
|
|
54
68
|
type DelegationType = 'FULL' | 'LIMITED' | 'VIEW_ONLY' | 'PREAPPROVED' | 'ALLOWLIST';
|
|
55
69
|
type ChainType = 'EVM' | 'SOLANA';
|
|
56
|
-
type
|
|
70
|
+
type CustomerCustodyMode = 'MANAGED' | 'EXTERNAL' | 'SMART_CONTRACT';
|
|
71
|
+
/** @deprecated Use CustomerCustodyMode. */
|
|
72
|
+
type CustodyType = CustomerCustodyMode;
|
|
57
73
|
type WalletType = 'EOA' | 'SMART_WALLET' | 'MULTISIG';
|
|
58
74
|
type WalletStatus = 'ACTIVE' | 'FROZEN' | 'CLOSED' | 'ARCHIVED';
|
|
59
75
|
type PolicyType = 'SPEND_LIMIT' | 'MERCHANT' | 'TIME_WINDOW' | 'CATEGORY' | 'VELOCITY' | 'COMPOSITE' | 'GEOGRAPHIC' | 'APPROVAL_THRESHOLD' | 'COUNTERPARTY' | 'BUDGET_ALLOCATION' | 'WHITELIST' | 'EXPIRATION' | 'CONTRACT_ALLOWLIST' | 'BLACKOUT_PERIOD';
|
|
@@ -72,25 +88,37 @@ interface Agent {
|
|
|
72
88
|
riskTier?: AgentRiskTier;
|
|
73
89
|
publicKey: string;
|
|
74
90
|
status: AgentStatus;
|
|
75
|
-
externalId: string | null;
|
|
76
91
|
attestationMode?: AgentAttestationMode;
|
|
77
92
|
identityTags?: string[];
|
|
78
|
-
|
|
93
|
+
externalId: string | null;
|
|
94
|
+
allowedContexts: string[];
|
|
95
|
+
webhookConfigured: boolean;
|
|
96
|
+
/** Callback query and fragment values are redacted in API responses. */
|
|
97
|
+
callbackUrl: string | null;
|
|
79
98
|
owner?: {
|
|
80
99
|
membershipId: string;
|
|
81
|
-
role: string;
|
|
82
|
-
userId?: string | null;
|
|
83
100
|
name?: string | null;
|
|
84
|
-
email?: string | null;
|
|
85
101
|
} | null;
|
|
86
|
-
|
|
87
|
-
|
|
102
|
+
setup: {
|
|
103
|
+
status: 'READY' | 'ACTION_REQUIRED';
|
|
104
|
+
issueCount: number;
|
|
105
|
+
issues: Array<{
|
|
106
|
+
code: 'OWNER_REQUIRED' | 'IDENTITY_SLUG_REQUIRED' | 'PURPOSE_REQUIRED';
|
|
107
|
+
field: 'ownerMembershipId' | 'agentIdSlug' | 'purpose';
|
|
108
|
+
severity: 'BLOCKING' | 'RECOMMENDED';
|
|
109
|
+
message: string;
|
|
110
|
+
}>;
|
|
111
|
+
};
|
|
88
112
|
createdAt: string;
|
|
89
113
|
updatedAt: string;
|
|
114
|
+
linkedWalletCount: number;
|
|
115
|
+
transactionCount: number;
|
|
90
116
|
wallets?: AgentWalletLink[];
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
117
|
+
nextSteps?: Record<'createSdkKey' | 'linkWallet' | 'assignPolicy', {
|
|
118
|
+
method: 'POST';
|
|
119
|
+
path: string;
|
|
120
|
+
description: string;
|
|
121
|
+
}>;
|
|
94
122
|
}
|
|
95
123
|
interface CreateAgentInput {
|
|
96
124
|
name: string;
|
|
@@ -106,6 +134,7 @@ interface CreateAgentInput {
|
|
|
106
134
|
attestationMode?: AgentAttestationMode;
|
|
107
135
|
identityTags?: string[];
|
|
108
136
|
allowedContexts?: string[];
|
|
137
|
+
callbackUrl?: string;
|
|
109
138
|
}
|
|
110
139
|
interface UpdateAgentInput {
|
|
111
140
|
name?: string;
|
|
@@ -120,6 +149,7 @@ interface UpdateAgentInput {
|
|
|
120
149
|
attestationMode?: AgentAttestationMode;
|
|
121
150
|
identityTags?: string[] | null;
|
|
122
151
|
allowedContexts?: string[];
|
|
152
|
+
callbackUrl?: string | null;
|
|
123
153
|
}
|
|
124
154
|
interface ListAgentsParams extends PaginationParams {
|
|
125
155
|
status?: string;
|
|
@@ -132,23 +162,26 @@ interface ListAgentsResponse {
|
|
|
132
162
|
offset: number;
|
|
133
163
|
}
|
|
134
164
|
interface FreezeAgentInput {
|
|
135
|
-
reason: string;
|
|
136
165
|
freezeWallets?: boolean;
|
|
137
166
|
}
|
|
138
167
|
interface UnfreezeAgentInput {
|
|
139
|
-
reason: string;
|
|
140
168
|
unfreezeWallets?: boolean;
|
|
141
|
-
resetCounters?: boolean;
|
|
142
169
|
}
|
|
143
170
|
interface AgentWalletLink {
|
|
144
171
|
id: string;
|
|
145
|
-
agentId: string;
|
|
146
172
|
walletId: string;
|
|
147
173
|
delegationType: DelegationType;
|
|
148
|
-
spendLimitPerTx: number;
|
|
149
|
-
spendLimitDaily: number;
|
|
174
|
+
spendLimitPerTx: number | null;
|
|
175
|
+
spendLimitDaily: number | null;
|
|
150
176
|
spendLimitWeekly: number | null;
|
|
151
177
|
spendLimitMonthly: number | null;
|
|
178
|
+
spentToday: number;
|
|
179
|
+
spentThisWeek: number;
|
|
180
|
+
spentThisMonth: number;
|
|
181
|
+
allowedHoursStart: number;
|
|
182
|
+
allowedHoursEnd: number;
|
|
183
|
+
allowedDays: string[];
|
|
184
|
+
timezone: string;
|
|
152
185
|
isActive: boolean;
|
|
153
186
|
wallet?: {
|
|
154
187
|
id: string;
|
|
@@ -156,13 +189,203 @@ interface AgentWalletLink {
|
|
|
156
189
|
address: string;
|
|
157
190
|
usdcBalance: number;
|
|
158
191
|
status: string;
|
|
159
|
-
|
|
192
|
+
custodyMode?: CustomerCustodyMode;
|
|
160
193
|
};
|
|
194
|
+
createdAt: string;
|
|
195
|
+
updatedAt: string;
|
|
196
|
+
}
|
|
197
|
+
interface AdminExternalCardOverlayEnforcement {
|
|
198
|
+
enforcementMode: 'POLICY_OVERLAY';
|
|
199
|
+
integrationMode: 'SDK_REQUIRED';
|
|
200
|
+
canBypass: true;
|
|
201
|
+
credentialStored: false;
|
|
202
|
+
credentialReleased: false;
|
|
203
|
+
executionResponsibility: 'CUSTOMER';
|
|
204
|
+
transactionVerification: 'SELF_REPORTED';
|
|
205
|
+
}
|
|
206
|
+
interface ExternalCard {
|
|
207
|
+
id: string;
|
|
208
|
+
name: string;
|
|
209
|
+
last4: string;
|
|
210
|
+
brand: 'VISA' | 'MASTERCARD' | 'AMEX' | 'DISCOVER' | 'OTHER' | null;
|
|
211
|
+
cardType: 'VIRTUAL' | 'PHYSICAL';
|
|
212
|
+
fundingType: 'DEBIT' | 'CREDIT';
|
|
213
|
+
status: 'ACTIVE' | 'PAUSED' | 'LOCKED' | 'EXPIRED' | 'CANCELLED';
|
|
214
|
+
isActive: boolean;
|
|
215
|
+
spendLimitDaily: number;
|
|
216
|
+
spendLimitWeekly: number | null;
|
|
217
|
+
spendLimitMonthly: number | null;
|
|
218
|
+
spendLimitPerTx: number;
|
|
219
|
+
spentToday: number;
|
|
220
|
+
spentThisWeek: number;
|
|
221
|
+
spentThisMonth: number;
|
|
222
|
+
remainingToday: number;
|
|
223
|
+
agentCount: number;
|
|
224
|
+
transactionCount: number;
|
|
225
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
226
|
+
createdAt: string;
|
|
227
|
+
updatedAt: string;
|
|
228
|
+
}
|
|
229
|
+
interface RegisterExternalCardInput {
|
|
230
|
+
name: string;
|
|
231
|
+
last4: string;
|
|
232
|
+
brand?: 'VISA' | 'MASTERCARD' | 'AMEX' | 'DISCOVER' | 'OTHER';
|
|
233
|
+
cardType?: 'VIRTUAL' | 'PHYSICAL';
|
|
234
|
+
fundingType?: 'DEBIT' | 'CREDIT';
|
|
235
|
+
spendLimitDaily?: number;
|
|
236
|
+
spendLimitWeekly?: number;
|
|
237
|
+
spendLimitMonthly?: number;
|
|
238
|
+
spendLimitPerTx?: number;
|
|
239
|
+
notes?: string;
|
|
240
|
+
}
|
|
241
|
+
interface AssignExternalCardInput {
|
|
242
|
+
cardId: string;
|
|
243
|
+
spendLimitDaily?: number;
|
|
244
|
+
spendLimitWeekly?: number;
|
|
245
|
+
spendLimitMonthly?: number;
|
|
246
|
+
spendLimitPerTx?: number;
|
|
247
|
+
allowedDays?: Array<'Sun' | 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat'>;
|
|
248
|
+
allowedHoursStart?: number;
|
|
249
|
+
allowedHoursEnd?: number;
|
|
250
|
+
timezone: string;
|
|
251
|
+
allowedCategories?: string[];
|
|
252
|
+
blockedCategories?: string[];
|
|
253
|
+
allowedMerchants?: string[];
|
|
254
|
+
blockedMerchants?: string[];
|
|
255
|
+
activeFrom?: string | null;
|
|
256
|
+
activeUntil?: string | null;
|
|
257
|
+
}
|
|
258
|
+
type UpdateExternalCardAssignmentInput = Partial<Omit<AssignExternalCardInput, 'cardId'>>;
|
|
259
|
+
interface AgentExternalCard {
|
|
260
|
+
id: string;
|
|
261
|
+
cardId: string;
|
|
262
|
+
cardName: string;
|
|
263
|
+
last4: string;
|
|
264
|
+
brand: string | null;
|
|
265
|
+
cardType: string;
|
|
266
|
+
fundingType: string;
|
|
267
|
+
cardStatus: string;
|
|
268
|
+
accessStatus: 'ACTIVE' | 'PAUSED' | 'REVOKED';
|
|
269
|
+
spendLimitDaily: number;
|
|
270
|
+
spendLimitWeekly: number | null;
|
|
271
|
+
spendLimitMonthly: number | null;
|
|
272
|
+
spendLimitPerTx: number;
|
|
273
|
+
spentToday: number;
|
|
274
|
+
spentThisWeek: number;
|
|
275
|
+
spentThisMonth: number;
|
|
276
|
+
remainingToday: number;
|
|
277
|
+
allowedDays: string[];
|
|
278
|
+
allowedHoursStart: number;
|
|
279
|
+
allowedHoursEnd: number;
|
|
280
|
+
timezone: string;
|
|
281
|
+
allowedCategories: string[] | null;
|
|
282
|
+
blockedCategories: string[] | null;
|
|
283
|
+
allowedMerchants: string[] | null;
|
|
284
|
+
blockedMerchants: string[] | null;
|
|
285
|
+
activeFrom: string | null;
|
|
286
|
+
activeUntil: string | null;
|
|
287
|
+
isActive: boolean;
|
|
288
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
289
|
+
createdAt: string;
|
|
290
|
+
}
|
|
291
|
+
interface RevokeExternalCardAssignmentResult {
|
|
292
|
+
unassigned: true;
|
|
293
|
+
cardId: string;
|
|
294
|
+
agentId: string;
|
|
295
|
+
revokedApprovals: number;
|
|
296
|
+
executingRequests: number;
|
|
297
|
+
reconciliationRequired: boolean;
|
|
298
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
299
|
+
}
|
|
300
|
+
interface PauseExternalCardAssignmentResult {
|
|
301
|
+
accessStatus: 'PAUSED';
|
|
302
|
+
cardId: string;
|
|
303
|
+
agentId: string;
|
|
304
|
+
revokedApprovals: number;
|
|
305
|
+
executingRequests: number;
|
|
306
|
+
reconciliationRequired: boolean;
|
|
307
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
308
|
+
}
|
|
309
|
+
type ExternalCardRequestStatus = 'APPROVED' | 'EXECUTING' | 'CONFIRMING' | 'COMPLETED' | 'DENIED' | 'EXPIRED' | 'CANCELLED';
|
|
310
|
+
interface ExternalCardOverlayRequest {
|
|
311
|
+
requestId: string;
|
|
312
|
+
status: ExternalCardRequestStatus;
|
|
313
|
+
decision: string;
|
|
314
|
+
amount: number;
|
|
315
|
+
currency: string;
|
|
316
|
+
merchantName: string | null;
|
|
317
|
+
merchantId: string | null;
|
|
318
|
+
merchantCategory: string | null;
|
|
319
|
+
purpose: string | null;
|
|
320
|
+
expiresAt: string | null;
|
|
321
|
+
executionClaimedAt: string | null;
|
|
322
|
+
reconciliationRequired: boolean;
|
|
323
|
+
nextAction: 'BEGIN_EXECUTION' | 'CONFIRM_OR_RECONCILE' | 'POLL' | 'NONE';
|
|
324
|
+
transactionId: string | null;
|
|
325
|
+
transaction: {
|
|
326
|
+
id: string;
|
|
327
|
+
status: string;
|
|
328
|
+
amount: number;
|
|
329
|
+
currency: string;
|
|
330
|
+
externalTxId: string | null;
|
|
331
|
+
authorizedAt: string | null;
|
|
332
|
+
} | null;
|
|
333
|
+
card: {
|
|
334
|
+
id: string;
|
|
335
|
+
name: string;
|
|
336
|
+
last4: string;
|
|
337
|
+
brand: string | null;
|
|
338
|
+
};
|
|
339
|
+
agent: {
|
|
340
|
+
id: string;
|
|
341
|
+
name: string;
|
|
342
|
+
};
|
|
343
|
+
createdAt: string;
|
|
344
|
+
updatedAt: string;
|
|
345
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
346
|
+
}
|
|
347
|
+
interface ListExternalCardRequestsInput {
|
|
348
|
+
status?: ExternalCardRequestStatus;
|
|
349
|
+
limit?: number;
|
|
350
|
+
}
|
|
351
|
+
interface ListExternalCardRequestsResponse {
|
|
352
|
+
requests: ExternalCardOverlayRequest[];
|
|
353
|
+
summary: Partial<Record<ExternalCardRequestStatus, number>>;
|
|
354
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
355
|
+
}
|
|
356
|
+
interface ResolveExternalCardRequestInput {
|
|
357
|
+
resolution: 'EXECUTED' | 'NOT_EXECUTED';
|
|
358
|
+
reason: string;
|
|
359
|
+
externalTxId?: string;
|
|
360
|
+
authorizationCode?: string;
|
|
361
|
+
actualAmount?: number;
|
|
362
|
+
merchantDetails?: {
|
|
363
|
+
name?: string;
|
|
364
|
+
id?: string;
|
|
365
|
+
category?: string;
|
|
366
|
+
address?: string;
|
|
367
|
+
city?: string;
|
|
368
|
+
state?: string;
|
|
369
|
+
country?: string;
|
|
370
|
+
postalCode?: string;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
interface ResolveExternalCardRequestResult {
|
|
374
|
+
resolved: true;
|
|
375
|
+
requestId?: string;
|
|
376
|
+
status: string;
|
|
377
|
+
reservationReleased?: boolean;
|
|
378
|
+
releasedAmount?: number;
|
|
379
|
+
confirmed?: true;
|
|
380
|
+
replayed?: boolean;
|
|
381
|
+
transactionId?: string;
|
|
382
|
+
amount?: number;
|
|
383
|
+
currency?: string;
|
|
384
|
+
verificationStatus?: 'SELF_REPORTED';
|
|
385
|
+
enforcement?: AdminExternalCardOverlayEnforcement;
|
|
161
386
|
}
|
|
162
387
|
interface OrganizationMember {
|
|
163
388
|
id: string;
|
|
164
|
-
organizationId: string;
|
|
165
|
-
userId: string;
|
|
166
389
|
role: 'OWNER' | 'ADMIN' | 'MANAGER' | 'VIEWER' | 'MEMBER';
|
|
167
390
|
createdAt: string;
|
|
168
391
|
updatedAt: string;
|
|
@@ -215,24 +438,20 @@ interface Wallet {
|
|
|
215
438
|
chainType: ChainType;
|
|
216
439
|
chainId: string;
|
|
217
440
|
walletType: WalletType;
|
|
218
|
-
|
|
441
|
+
custodyMode: CustomerCustodyMode;
|
|
219
442
|
usdcBalance: number;
|
|
220
443
|
status: WalletStatus;
|
|
221
|
-
externalWalletId: string | null;
|
|
222
|
-
organizationId: string;
|
|
223
444
|
createdAt: string;
|
|
224
445
|
updatedAt: string;
|
|
446
|
+
linkedAgentCount?: number;
|
|
225
447
|
}
|
|
226
448
|
interface CreateWalletInput {
|
|
227
449
|
name: string;
|
|
228
450
|
chainType?: ChainType;
|
|
229
451
|
chainId?: string;
|
|
230
|
-
|
|
452
|
+
custodyMode?: Extract<CustomerCustodyMode, 'MANAGED' | 'EXTERNAL'>;
|
|
231
453
|
walletType?: WalletType;
|
|
232
454
|
address?: string;
|
|
233
|
-
externalWalletId?: string;
|
|
234
|
-
importAddress?: string;
|
|
235
|
-
isWatchOnly?: boolean;
|
|
236
455
|
}
|
|
237
456
|
interface UpdateWalletInput {
|
|
238
457
|
name?: string;
|
|
@@ -256,7 +475,7 @@ interface ProvisionWalletResult {
|
|
|
256
475
|
address: string;
|
|
257
476
|
chainId: string;
|
|
258
477
|
chainType: string;
|
|
259
|
-
|
|
478
|
+
custodyMode: CustomerCustodyMode;
|
|
260
479
|
balance: number;
|
|
261
480
|
currency: string;
|
|
262
481
|
};
|
|
@@ -286,21 +505,32 @@ interface PolicyRule {
|
|
|
286
505
|
value: string;
|
|
287
506
|
action: RuleAction;
|
|
288
507
|
createdAt: string;
|
|
508
|
+
updatedAt: string;
|
|
289
509
|
}
|
|
290
510
|
interface Policy {
|
|
291
511
|
id: string;
|
|
292
512
|
name: string;
|
|
293
513
|
description: string | null;
|
|
294
514
|
policyType: PolicyType;
|
|
515
|
+
scope: 'organization' | 'assigned';
|
|
295
516
|
priority: number;
|
|
296
517
|
isActive: boolean;
|
|
297
|
-
organizationId: string;
|
|
298
518
|
rules?: PolicyRule[];
|
|
519
|
+
assignedAgents?: Array<{
|
|
520
|
+
id: string;
|
|
521
|
+
name: string;
|
|
522
|
+
}>;
|
|
523
|
+
assignedWallets?: Array<{
|
|
524
|
+
id: string;
|
|
525
|
+
name: string;
|
|
526
|
+
}>;
|
|
299
527
|
createdAt: string;
|
|
300
528
|
updatedAt: string;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
529
|
+
}
|
|
530
|
+
interface AssignedPolicy {
|
|
531
|
+
policyId: string;
|
|
532
|
+
assignedAt: string;
|
|
533
|
+
policy: Policy;
|
|
304
534
|
}
|
|
305
535
|
interface CreatePolicyInput {
|
|
306
536
|
name: string;
|
|
@@ -308,6 +538,7 @@ interface CreatePolicyInput {
|
|
|
308
538
|
description?: string;
|
|
309
539
|
priority?: number;
|
|
310
540
|
isActive?: boolean;
|
|
541
|
+
scope?: 'organization' | 'assigned';
|
|
311
542
|
rules?: CreatePolicyRuleInput[];
|
|
312
543
|
agentIds?: string[];
|
|
313
544
|
}
|
|
@@ -316,6 +547,7 @@ interface UpdatePolicyInput {
|
|
|
316
547
|
description?: string;
|
|
317
548
|
priority?: number;
|
|
318
549
|
isActive?: boolean;
|
|
550
|
+
scope?: 'organization' | 'assigned';
|
|
319
551
|
}
|
|
320
552
|
interface ListPoliciesParams extends PaginationParams {
|
|
321
553
|
}
|
|
@@ -343,13 +575,73 @@ declare class ContoAdmin {
|
|
|
343
575
|
private timeout;
|
|
344
576
|
agents: AgentsClient;
|
|
345
577
|
wallets: WalletsClient;
|
|
578
|
+
cards: AdminCardsClient;
|
|
346
579
|
policies: PoliciesClient;
|
|
347
580
|
team: TeamClient;
|
|
348
581
|
constructor(config: ContoAdminConfig);
|
|
349
|
-
private fetchWithRetry;
|
|
350
582
|
/** Make an authenticated request to the Conto API */
|
|
351
583
|
request<T>(method: string, path: string, body?: Record<string, unknown>): Promise<T>;
|
|
352
584
|
}
|
|
585
|
+
declare class AdminCardsClient {
|
|
586
|
+
private client;
|
|
587
|
+
constructor(client: ContoAdmin);
|
|
588
|
+
/** List masked external-card aliases. No card credentials are returned. */
|
|
589
|
+
list(): Promise<{
|
|
590
|
+
cards: ExternalCard[];
|
|
591
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
592
|
+
}>;
|
|
593
|
+
/** Register a masked alias for a customer card. Never pass PAN or CVC. */
|
|
594
|
+
register(input: RegisterExternalCardInput): Promise<{
|
|
595
|
+
card: ExternalCard;
|
|
596
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
597
|
+
}>;
|
|
598
|
+
/** Assign a card alias and cooperative policy controls to an agent. */
|
|
599
|
+
assignToAgent(agentId: string, input: AssignExternalCardInput): Promise<{
|
|
600
|
+
agentCard: AgentExternalCard;
|
|
601
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
602
|
+
}>;
|
|
603
|
+
listForAgent(agentId: string): Promise<{
|
|
604
|
+
cards: AgentExternalCard[];
|
|
605
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
606
|
+
}>;
|
|
607
|
+
/** Update limits, merchant rules, hours, and optional start or end dates. */
|
|
608
|
+
updateAgentAssignment(agentId: string, cardId: string, input: UpdateExternalCardAssignmentInput): Promise<{
|
|
609
|
+
agentCard: AgentExternalCard;
|
|
610
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
611
|
+
}>;
|
|
612
|
+
/** Pause an assignment and cancel its unused approvals. */
|
|
613
|
+
pauseForAgent(agentId: string, cardId: string): Promise<PauseExternalCardAssignmentResult>;
|
|
614
|
+
/** Resume a paused assignment when its alias and date range permit it. */
|
|
615
|
+
resumeForAgent(agentId: string, cardId: string): Promise<{
|
|
616
|
+
agentCard: AgentExternalCard;
|
|
617
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
618
|
+
}>;
|
|
619
|
+
/**
|
|
620
|
+
* Revoke an agent's overlay assignment. Unused grants are cancelled; claimed
|
|
621
|
+
* executions remain visible for reconciliation.
|
|
622
|
+
*/
|
|
623
|
+
revokeFromAgent(agentId: string, cardId: string): Promise<RevokeExternalCardAssignmentResult>;
|
|
624
|
+
/** List overlay requests, including executions that need receipt reconciliation. */
|
|
625
|
+
listRequests(input?: ListExternalCardRequestsInput): Promise<ListExternalCardRequestsResponse>;
|
|
626
|
+
/**
|
|
627
|
+
* Resolve a claimed execution after checking the customer's processor or
|
|
628
|
+
* receipt. Resolving NOT_EXECUTED releases the reserved policy amount.
|
|
629
|
+
*/
|
|
630
|
+
resolveRequest(requestId: string, input: ResolveExternalCardRequestInput): Promise<ResolveExternalCardRequestResult>;
|
|
631
|
+
/** Pause the Conto-controlled path and revoke live overlay grants. */
|
|
632
|
+
pause(cardId: string): Promise<{
|
|
633
|
+
card: Pick<ExternalCard, 'id' | 'name' | 'last4' | 'brand' | 'fundingType' | 'status' | 'isActive' | 'updatedAt'>;
|
|
634
|
+
revokedApprovals: number;
|
|
635
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
636
|
+
}>;
|
|
637
|
+
/** Resume the Conto-controlled path. This does not activate a card at its issuer. */
|
|
638
|
+
resume(cardId: string): Promise<{
|
|
639
|
+
card: Pick<ExternalCard, 'id' | 'name' | 'last4' | 'brand' | 'fundingType' | 'status' | 'isActive' | 'updatedAt'>;
|
|
640
|
+
revokedApprovals: number;
|
|
641
|
+
enforcement: AdminExternalCardOverlayEnforcement;
|
|
642
|
+
}>;
|
|
643
|
+
private setState;
|
|
644
|
+
}
|
|
353
645
|
declare class AgentsClient {
|
|
354
646
|
private client;
|
|
355
647
|
constructor(client: ContoAdmin);
|
|
@@ -366,9 +658,13 @@ declare class AgentsClient {
|
|
|
366
658
|
message: string;
|
|
367
659
|
}>;
|
|
368
660
|
/** Freeze an agent, blocking all transactions */
|
|
369
|
-
freeze(agentId: string, input: FreezeAgentInput): Promise<
|
|
661
|
+
freeze(agentId: string, input: FreezeAgentInput): Promise<{
|
|
662
|
+
frozen: boolean;
|
|
663
|
+
}>;
|
|
370
664
|
/** Unfreeze an agent, restoring transaction ability */
|
|
371
|
-
unfreeze(agentId: string, input: UnfreezeAgentInput): Promise<
|
|
665
|
+
unfreeze(agentId: string, input: UnfreezeAgentInput): Promise<{
|
|
666
|
+
frozen: boolean;
|
|
667
|
+
}>;
|
|
372
668
|
/** List wallets linked to an agent */
|
|
373
669
|
listWallets(agentId: string): Promise<{
|
|
374
670
|
wallets: AgentWalletLink[];
|
|
@@ -381,10 +677,10 @@ declare class AgentsClient {
|
|
|
381
677
|
}>;
|
|
382
678
|
/** List policies assigned to an agent */
|
|
383
679
|
listPolicies(agentId: string): Promise<{
|
|
384
|
-
policies:
|
|
680
|
+
policies: AssignedPolicy[];
|
|
385
681
|
}>;
|
|
386
682
|
/** Assign a policy to an agent */
|
|
387
|
-
assignPolicy(agentId: string, policyId: string
|
|
683
|
+
assignPolicy(agentId: string, policyId: string): Promise<AssignedPolicy>;
|
|
388
684
|
/** Unassign a policy from an agent */
|
|
389
685
|
unassignPolicy(agentId: string, policyId: string): Promise<{
|
|
390
686
|
success: boolean;
|
|
@@ -403,7 +699,7 @@ declare class WalletsClient {
|
|
|
403
699
|
constructor(client: ContoAdmin);
|
|
404
700
|
/** List wallets in the organization */
|
|
405
701
|
list(params?: ListWalletsParams): Promise<ListWalletsResponse>;
|
|
406
|
-
/** Create a
|
|
702
|
+
/** Create a managed wallet or register an external address. */
|
|
407
703
|
create(input: CreateWalletInput): Promise<Wallet>;
|
|
408
704
|
/** Get a single wallet by ID */
|
|
409
705
|
get(walletId: string): Promise<Wallet>;
|
|
@@ -462,7 +758,6 @@ declare class TeamClient {
|
|
|
462
758
|
constructor(client: ContoAdmin);
|
|
463
759
|
/** List organization memberships for the authenticated organization */
|
|
464
760
|
listMembers(): Promise<{
|
|
465
|
-
organizationId: string;
|
|
466
761
|
members: OrganizationMember[];
|
|
467
762
|
}>;
|
|
468
763
|
}
|
|
@@ -491,10 +786,11 @@ declare class TeamClient {
|
|
|
491
786
|
* // Execute if approved
|
|
492
787
|
* if (request.status === 'APPROVED') {
|
|
493
788
|
* const result = await conto.payments.execute(request.requestId);
|
|
494
|
-
* console.log(`Payment sent: ${result.txHash}`);
|
|
789
|
+
* console.log(result.receipt?.txHash ? `Payment sent: ${result.receipt.txHash}` : `Payment ${result.status}`);
|
|
495
790
|
* }
|
|
496
791
|
* ```
|
|
497
792
|
*/
|
|
793
|
+
|
|
498
794
|
interface ContoConfig {
|
|
499
795
|
/** Your agent's SDK API key (conto_agent_xxx...) */
|
|
500
796
|
apiKey: string;
|
|
@@ -514,8 +810,20 @@ interface PaymentRequestInput {
|
|
|
514
810
|
purpose?: string;
|
|
515
811
|
/** Spend category for analytics */
|
|
516
812
|
category?: string;
|
|
517
|
-
/**
|
|
518
|
-
context?:
|
|
813
|
+
/** Typed invoice context associated with the payment */
|
|
814
|
+
context?: {
|
|
815
|
+
invoice?: {
|
|
816
|
+
vendorId?: string;
|
|
817
|
+
vendorAddress?: string;
|
|
818
|
+
id?: string;
|
|
819
|
+
hash?: string;
|
|
820
|
+
sourceUrl?: string;
|
|
821
|
+
payload?: unknown;
|
|
822
|
+
expectedAmount?: number | string;
|
|
823
|
+
currency?: string;
|
|
824
|
+
dueDate?: string;
|
|
825
|
+
};
|
|
826
|
+
};
|
|
519
827
|
/** Specific wallet ID to use (optional) */
|
|
520
828
|
walletId?: string;
|
|
521
829
|
/** Payment urgency */
|
|
@@ -533,132 +841,454 @@ interface PaymentRequestResult {
|
|
|
533
841
|
/** Unique request ID - use this to execute or check status */
|
|
534
842
|
requestId: string;
|
|
535
843
|
/** Current status */
|
|
536
|
-
status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | '
|
|
537
|
-
/**
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
availableBalance: number;
|
|
546
|
-
};
|
|
844
|
+
status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | 'ACTION_REQUIRED' | 'PROCESSING';
|
|
845
|
+
/** Requested amount */
|
|
846
|
+
amount: number;
|
|
847
|
+
/** Currency selected for the payment */
|
|
848
|
+
currency: string;
|
|
849
|
+
/** Recipient wallet address */
|
|
850
|
+
recipient: string;
|
|
851
|
+
/** Customer-facing custody model for the selected payment wallet */
|
|
852
|
+
custodyMode?: CustomerCustodyMode;
|
|
547
853
|
/** When the approval expires (ISO timestamp) */
|
|
548
854
|
expiresAt?: string;
|
|
549
|
-
/**
|
|
855
|
+
/** Customer-facing explanation when action is required or the payment is denied */
|
|
550
856
|
reasons: string[];
|
|
551
|
-
/**
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
explorerUrl: string;
|
|
561
|
-
};
|
|
562
|
-
/** URL to execute this payment (convenience) */
|
|
563
|
-
executeUrl?: string;
|
|
564
|
-
/** Session ID for tracking (used in x402/MPP flows) */
|
|
565
|
-
sessionId?: string | null;
|
|
566
|
-
/** Explanation of why this wallet was selected */
|
|
567
|
-
walletSelectionReason?: string;
|
|
568
|
-
/** If autoExecute was true and approved, contains the execution result */
|
|
569
|
-
execution?: {
|
|
857
|
+
/** Approval workflow reference when a team decision is required */
|
|
858
|
+
approvalRequestId?: string;
|
|
859
|
+
/** Stable URL for polling and reconciliation */
|
|
860
|
+
statusUrl: string;
|
|
861
|
+
/** Next URL to follow for the returned status */
|
|
862
|
+
actionUrl?: string;
|
|
863
|
+
/** Public receipt data when execution has started */
|
|
864
|
+
receipt?: {
|
|
865
|
+
/** Stable Conto transaction ID for status checks and reconciliation */
|
|
570
866
|
transactionId: string;
|
|
571
867
|
txHash: string;
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
/** If autoExecute failed, the payment is still approved and can be executed manually */
|
|
576
|
-
autoExecuteError?: {
|
|
577
|
-
error: string;
|
|
578
|
-
code?: string;
|
|
579
|
-
};
|
|
580
|
-
/** Human-readable recovery hint for denied requests */
|
|
581
|
-
hint?: string;
|
|
582
|
-
/** Additional structured context for recovery or debugging */
|
|
583
|
-
context?: {
|
|
584
|
-
wallets?: Array<{
|
|
585
|
-
id: string;
|
|
586
|
-
address: string;
|
|
587
|
-
chainId?: string | null;
|
|
588
|
-
custodyType?: string | null;
|
|
589
|
-
balance: number;
|
|
590
|
-
}>;
|
|
591
|
-
nextSteps?: string[];
|
|
868
|
+
/** Whether this receipt represents live settlement or a test-mode payment */
|
|
869
|
+
settlementMode: 'live' | 'test';
|
|
870
|
+
explorerUrl?: string;
|
|
592
871
|
};
|
|
593
872
|
}
|
|
594
|
-
interface PolicyViolation {
|
|
595
|
-
type: string;
|
|
596
|
-
limit: number;
|
|
597
|
-
current: number;
|
|
598
|
-
message: string;
|
|
599
|
-
}
|
|
600
873
|
interface PaymentExecuteResult {
|
|
601
|
-
/**
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
|
|
605
|
-
/** Transaction status */
|
|
606
|
-
status: 'CONFIRMING' | 'CONFIRMED' | 'FAILED';
|
|
874
|
+
/** Payment request ID */
|
|
875
|
+
requestId: string;
|
|
876
|
+
/** Customer-facing execution state */
|
|
877
|
+
status: 'processing' | 'completed';
|
|
607
878
|
/** Amount sent */
|
|
608
879
|
amount: number;
|
|
609
880
|
/** Currency (USDC) */
|
|
610
881
|
currency: string;
|
|
611
882
|
/** Recipient address */
|
|
612
883
|
recipient: string;
|
|
613
|
-
/**
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
884
|
+
/** Public transaction receipt */
|
|
885
|
+
receipt: {
|
|
886
|
+
/** Stable Conto transaction ID for status checks and reconciliation */
|
|
887
|
+
transactionId: string;
|
|
888
|
+
txHash: string;
|
|
889
|
+
/** Whether this receipt represents live settlement or a test-mode payment */
|
|
890
|
+
settlementMode: 'live' | 'test';
|
|
891
|
+
explorerUrl?: string;
|
|
618
892
|
};
|
|
619
|
-
/** Block explorer URL */
|
|
620
|
-
explorerUrl: string;
|
|
621
893
|
}
|
|
622
894
|
interface PaymentStatusResult {
|
|
623
895
|
requestId: string;
|
|
624
|
-
status:
|
|
625
|
-
policyResult: string;
|
|
896
|
+
status: 'approved' | 'declined' | 'review_required' | 'action_required' | 'reconciliation_required' | 'processing' | 'completed' | 'failed' | 'expired';
|
|
626
897
|
amount: number;
|
|
627
898
|
currency: string;
|
|
628
899
|
recipient: string;
|
|
629
|
-
recipientName
|
|
900
|
+
recipientName: string | null;
|
|
901
|
+
purpose: string | null;
|
|
902
|
+
category: string | null;
|
|
903
|
+
expiresAt: string | null;
|
|
904
|
+
createdAt: string;
|
|
905
|
+
action: {
|
|
906
|
+
type: 'complete_verification';
|
|
907
|
+
url: string;
|
|
908
|
+
} | null;
|
|
909
|
+
transaction: {
|
|
910
|
+
/** Stable Conto transaction ID */
|
|
911
|
+
id: string;
|
|
912
|
+
txHash: string | null;
|
|
913
|
+
status: 'processing' | 'completed' | 'failed';
|
|
914
|
+
confirmedAt: string | null;
|
|
915
|
+
blockNumber: number | null;
|
|
916
|
+
chain: {
|
|
917
|
+
type: 'evm' | 'solana';
|
|
918
|
+
id: string;
|
|
919
|
+
};
|
|
920
|
+
explorerUrl: string | null;
|
|
921
|
+
detailsUrl: string;
|
|
922
|
+
} | null;
|
|
923
|
+
}
|
|
924
|
+
interface ExternalCardOverlayEnforcement {
|
|
925
|
+
enforcementMode: 'POLICY_OVERLAY';
|
|
926
|
+
integrationMode: 'SDK_REQUIRED';
|
|
927
|
+
canBypass: true;
|
|
928
|
+
credentialStored: false;
|
|
929
|
+
credentialReleased: false;
|
|
930
|
+
executionResponsibility: 'CUSTOMER';
|
|
931
|
+
transactionVerification: 'SELF_REPORTED';
|
|
932
|
+
}
|
|
933
|
+
interface ExternalCardApprovalInput {
|
|
934
|
+
/** Stable caller-generated identifier, reused for every retry of this purchase intent. */
|
|
935
|
+
idempotencyKey: string;
|
|
936
|
+
cardId: string;
|
|
937
|
+
amount: number;
|
|
938
|
+
currency?: 'USD';
|
|
939
|
+
merchantName: string;
|
|
940
|
+
merchantId?: string;
|
|
941
|
+
merchantCategory?: string;
|
|
942
|
+
merchantAddress?: string;
|
|
943
|
+
merchantCountry?: string;
|
|
630
944
|
purpose?: string;
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
945
|
+
context?: Record<string, unknown>;
|
|
946
|
+
}
|
|
947
|
+
interface ExternalCardApprovalResult {
|
|
948
|
+
approved: boolean;
|
|
949
|
+
decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | 'EXECUTING' | 'CONFIRMING' | 'COMPLETED' | 'EXPIRED' | 'CANCELLED';
|
|
950
|
+
requestId: string;
|
|
951
|
+
approvalToken?: string;
|
|
952
|
+
expiresAt?: string;
|
|
953
|
+
reasons: string[];
|
|
954
|
+
replayed: boolean;
|
|
955
|
+
transactionId?: string | null;
|
|
956
|
+
card: {
|
|
957
|
+
last4: string;
|
|
958
|
+
brand: string | null;
|
|
959
|
+
cardholderName: string | null;
|
|
634
960
|
};
|
|
961
|
+
limits?: {
|
|
962
|
+
remainingDaily: number;
|
|
963
|
+
remainingPerTransaction: number;
|
|
964
|
+
};
|
|
965
|
+
enforcement: ExternalCardOverlayEnforcement;
|
|
966
|
+
}
|
|
967
|
+
interface ExternalCardExecutionClaimResult {
|
|
968
|
+
requestId: string;
|
|
969
|
+
claimed: boolean;
|
|
970
|
+
replayed: boolean;
|
|
971
|
+
state: string;
|
|
972
|
+
reconciliationRequired: boolean;
|
|
973
|
+
claimedAt?: string;
|
|
974
|
+
enforcement: ExternalCardOverlayEnforcement;
|
|
975
|
+
}
|
|
976
|
+
interface ExternalCardRequestStatusResult {
|
|
977
|
+
requestId: string;
|
|
978
|
+
status: string;
|
|
979
|
+
decision: string;
|
|
980
|
+
amount: number;
|
|
981
|
+
currency: string;
|
|
982
|
+
merchantName: string | null;
|
|
983
|
+
merchantId: string | null;
|
|
984
|
+
merchantCategory: string | null;
|
|
985
|
+
purpose: string | null;
|
|
986
|
+
reasons: string[];
|
|
635
987
|
requiresApproval: boolean;
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
988
|
+
reviewed: boolean;
|
|
989
|
+
expiresAt: string | null;
|
|
990
|
+
executionClaimedAt: string | null;
|
|
991
|
+
reconciliationRequired: boolean;
|
|
992
|
+
nextAction: 'WAIT_FOR_APPROVAL' | 'BEGIN_EXECUTION' | 'CONFIRM_OR_RECONCILE' | 'POLL' | 'NONE';
|
|
993
|
+
transactionId: string | null;
|
|
994
|
+
transaction: {
|
|
642
995
|
id: string;
|
|
643
|
-
txHash: string;
|
|
644
996
|
status: string;
|
|
645
|
-
|
|
646
|
-
|
|
997
|
+
amount: number;
|
|
998
|
+
currency: string;
|
|
999
|
+
externalTxId: string | null;
|
|
1000
|
+
authorizedAt: string | null;
|
|
1001
|
+
} | null;
|
|
1002
|
+
enforcement: ExternalCardOverlayEnforcement;
|
|
1003
|
+
}
|
|
1004
|
+
interface ExternalCardConfirmationInput {
|
|
1005
|
+
approvalToken: string;
|
|
1006
|
+
/** Customer receipt, processor, or authorization reference. Never send PAN or CVC. */
|
|
1007
|
+
externalTxId: string;
|
|
1008
|
+
authorizationCode?: string;
|
|
1009
|
+
actualAmount?: number;
|
|
1010
|
+
/**
|
|
1011
|
+
* Verification/enrichment only. Policy-bearing merchant fields must match
|
|
1012
|
+
* the approval; confirmation cannot substitute the merchant, MCC, or country.
|
|
1013
|
+
*/
|
|
1014
|
+
merchantDetails?: {
|
|
1015
|
+
name?: string;
|
|
1016
|
+
id?: string;
|
|
1017
|
+
category?: string;
|
|
1018
|
+
address?: string;
|
|
1019
|
+
city?: string;
|
|
1020
|
+
state?: string;
|
|
1021
|
+
country?: string;
|
|
1022
|
+
postalCode?: string;
|
|
647
1023
|
};
|
|
648
1024
|
}
|
|
649
|
-
interface
|
|
650
|
-
|
|
651
|
-
|
|
1025
|
+
interface ExternalCardConfirmationResult {
|
|
1026
|
+
confirmed: true;
|
|
1027
|
+
replayed: boolean;
|
|
1028
|
+
transactionId: string;
|
|
1029
|
+
status: string;
|
|
1030
|
+
amount: number;
|
|
1031
|
+
currency: string;
|
|
1032
|
+
verificationStatus: 'SELF_REPORTED';
|
|
1033
|
+
enforcement: ExternalCardOverlayEnforcement;
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Input delivered to the customer's credential-using executor. The callback is
|
|
1037
|
+
* invoked only after Conto approves the purchase. It deliberately excludes the
|
|
1038
|
+
* Conto approval token and all card credential fields.
|
|
1039
|
+
*/
|
|
1040
|
+
interface ApprovedExternalCardExecution {
|
|
1041
|
+
requestId: string;
|
|
1042
|
+
cardId: string;
|
|
1043
|
+
amount: number;
|
|
1044
|
+
currency: 'USD';
|
|
1045
|
+
merchantName: string;
|
|
1046
|
+
merchantId?: string;
|
|
1047
|
+
merchantCategory?: string;
|
|
1048
|
+
merchantAddress?: string;
|
|
1049
|
+
merchantCountry?: string;
|
|
1050
|
+
purpose?: string;
|
|
1051
|
+
context?: Record<string, unknown>;
|
|
1052
|
+
}
|
|
1053
|
+
interface ExternalCardExecutionResult<TReceipt = unknown> {
|
|
1054
|
+
externalTxId: string;
|
|
1055
|
+
authorizationCode?: string;
|
|
1056
|
+
actualAmount?: number;
|
|
1057
|
+
merchantDetails?: ExternalCardConfirmationInput['merchantDetails'];
|
|
1058
|
+
receipt: TReceipt;
|
|
1059
|
+
}
|
|
1060
|
+
type ExternalCardExecutor<TReceipt = unknown> = (approvedPurchase: ApprovedExternalCardExecution) => Promise<ExternalCardExecutionResult<TReceipt>>;
|
|
1061
|
+
interface ControlledExternalCardPaymentResult<TReceipt = unknown> {
|
|
1062
|
+
approval: ExternalCardApprovalResult;
|
|
1063
|
+
confirmation: ExternalCardConfirmationResult;
|
|
1064
|
+
receipt: TReceipt;
|
|
1065
|
+
}
|
|
1066
|
+
interface ProtocolPreAuthorizeResult {
|
|
1067
|
+
authorized: boolean;
|
|
1068
|
+
decision: 'approved' | 'declined' | 'review_required';
|
|
1069
|
+
message: string;
|
|
1070
|
+
}
|
|
1071
|
+
interface X402PreAuthorizeInput {
|
|
1072
|
+
amount: number;
|
|
1073
|
+
recipientAddress: string;
|
|
1074
|
+
resourceUrl: string;
|
|
1075
|
+
context?: {
|
|
1076
|
+
department?: string;
|
|
1077
|
+
project?: string;
|
|
1078
|
+
};
|
|
1079
|
+
/** Customer-supplied ID used to group authorization, recording, and spend reporting. */
|
|
1080
|
+
sessionId?: string;
|
|
1081
|
+
}
|
|
1082
|
+
interface X402PreAuthorizeResult extends ProtocolPreAuthorizeResult {
|
|
1083
|
+
x402: {
|
|
1084
|
+
serviceDomain?: string;
|
|
1085
|
+
amount: number;
|
|
1086
|
+
sessionId?: string;
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
interface X402RecordInput {
|
|
1090
|
+
amount: number;
|
|
1091
|
+
currency?: string;
|
|
1092
|
+
recipientAddress: string;
|
|
1093
|
+
txHash: string;
|
|
1094
|
+
resourceUrl: string;
|
|
1095
|
+
/** Stable x402 payment identifier. Reuse this value to reconcile an ambiguous failure. */
|
|
1096
|
+
paymentId: string;
|
|
1097
|
+
/** Customer-supplied ID used to group related x402 payments. */
|
|
1098
|
+
sessionId?: string;
|
|
1099
|
+
context?: {
|
|
1100
|
+
department?: string;
|
|
1101
|
+
project?: string;
|
|
1102
|
+
};
|
|
1103
|
+
batchItems?: Array<{
|
|
1104
|
+
amount: number;
|
|
1105
|
+
resourceUrl: string;
|
|
1106
|
+
paymentId: string;
|
|
1107
|
+
}>;
|
|
1108
|
+
}
|
|
1109
|
+
interface X402RecordResult {
|
|
1110
|
+
recorded: true;
|
|
1111
|
+
confirmed: true;
|
|
1112
|
+
txHash: string;
|
|
1113
|
+
explorerUrl: string;
|
|
1114
|
+
sessionId?: string;
|
|
1115
|
+
}
|
|
1116
|
+
interface MppPreAuthorizeInput {
|
|
1117
|
+
amount: number;
|
|
1118
|
+
recipientAddress: string;
|
|
1119
|
+
resourceUrl: string;
|
|
1120
|
+
context?: {
|
|
1121
|
+
department?: string;
|
|
1122
|
+
project?: string;
|
|
1123
|
+
};
|
|
1124
|
+
intent?: 'charge' | 'session';
|
|
1125
|
+
depositAmount?: number;
|
|
1126
|
+
/** Customer-supplied ID used to group authorization, recording, and spend reporting. */
|
|
1127
|
+
sessionId?: string;
|
|
1128
|
+
}
|
|
1129
|
+
interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
|
|
1130
|
+
mpp: {
|
|
1131
|
+
serviceDomain?: string;
|
|
1132
|
+
amount: number;
|
|
1133
|
+
sessionId?: string;
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
interface MppRecordInput {
|
|
1137
|
+
amount: number;
|
|
1138
|
+
currency?: string;
|
|
1139
|
+
recipientAddress: string;
|
|
1140
|
+
txHash?: string;
|
|
1141
|
+
resourceUrl: string;
|
|
1142
|
+
/** Stable MPP credential identifier. Reuse this value to reconcile an ambiguous failure. */
|
|
1143
|
+
credentialId: string;
|
|
1144
|
+
/** Customer-supplied ID used to group related MPP payments. */
|
|
1145
|
+
sessionId?: string;
|
|
1146
|
+
context?: {
|
|
1147
|
+
department?: string;
|
|
1148
|
+
project?: string;
|
|
1149
|
+
};
|
|
1150
|
+
paymentReceipt?: string;
|
|
1151
|
+
intent?: 'charge' | 'session';
|
|
1152
|
+
batchItems?: Array<{
|
|
1153
|
+
amount: number;
|
|
1154
|
+
resourceUrl: string;
|
|
1155
|
+
credentialId: string;
|
|
1156
|
+
}>;
|
|
1157
|
+
}
|
|
1158
|
+
interface MppRecordResult {
|
|
1159
|
+
recorded: true;
|
|
1160
|
+
txHash?: string;
|
|
1161
|
+
explorerUrl?: string;
|
|
1162
|
+
sessionId?: string;
|
|
1163
|
+
}
|
|
1164
|
+
interface ProtocolBudgetResult {
|
|
1165
|
+
spend: {
|
|
1166
|
+
daily: {
|
|
1167
|
+
calls: number;
|
|
1168
|
+
amount: number;
|
|
1169
|
+
};
|
|
1170
|
+
weekly: {
|
|
1171
|
+
calls: number;
|
|
1172
|
+
amount: number;
|
|
1173
|
+
};
|
|
1174
|
+
monthly: {
|
|
1175
|
+
calls: number;
|
|
1176
|
+
amount: number;
|
|
1177
|
+
};
|
|
1178
|
+
session: {
|
|
1179
|
+
sessionId: string;
|
|
1180
|
+
calls: number;
|
|
1181
|
+
amount: number;
|
|
1182
|
+
} | null;
|
|
1183
|
+
};
|
|
1184
|
+
limits: {
|
|
1185
|
+
daily: number | null;
|
|
1186
|
+
weekly: number | null;
|
|
1187
|
+
monthly: number | null;
|
|
1188
|
+
perPayment: number | null;
|
|
1189
|
+
};
|
|
1190
|
+
trend: {
|
|
1191
|
+
spendPerHour: number;
|
|
1192
|
+
callsPerHour: number;
|
|
1193
|
+
averageCost: number;
|
|
1194
|
+
estimatedHoursRemaining: number | null;
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
type X402BudgetResult = ProtocolBudgetResult;
|
|
1198
|
+
type MppBudgetResult = ProtocolBudgetResult;
|
|
1199
|
+
interface ProtocolServiceSummary {
|
|
1200
|
+
domain: string;
|
|
1201
|
+
name: string | null;
|
|
1202
|
+
totalCalls: number;
|
|
1203
|
+
totalSpend: number;
|
|
1204
|
+
averageCost: number;
|
|
1205
|
+
lastUsedAt: string | null;
|
|
1206
|
+
recent: {
|
|
1207
|
+
calls: number;
|
|
1208
|
+
spend: number;
|
|
1209
|
+
averageCost: number;
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
interface ProtocolServicesResult {
|
|
1213
|
+
services: ProtocolServiceSummary[];
|
|
1214
|
+
summary: {
|
|
1215
|
+
serviceCount: number;
|
|
1216
|
+
totalCalls: number;
|
|
1217
|
+
totalSpend: number;
|
|
1218
|
+
averageCost: number;
|
|
1219
|
+
};
|
|
1220
|
+
period: '24h' | '7d' | '30d' | '90d';
|
|
1221
|
+
}
|
|
1222
|
+
declare class ContoError extends Error {
|
|
1223
|
+
readonly code: string;
|
|
1224
|
+
readonly status: number;
|
|
1225
|
+
readonly requestId?: string;
|
|
1226
|
+
readonly retryAfter?: number;
|
|
1227
|
+
readonly retryGuidance?: string;
|
|
1228
|
+
readonly actionUrl?: string;
|
|
1229
|
+
constructor(message: string, metadata: ApiErrorMetadata);
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* The customer executor returned a receipt, but Conto did not acknowledge the
|
|
1233
|
+
* confirmation. Persist confirmationInput and retry cards.confirm(); never run
|
|
1234
|
+
* the customer executor again for this request.
|
|
1235
|
+
*/
|
|
1236
|
+
declare class ExternalCardConfirmationPendingError<TReceipt = unknown> extends ContoError {
|
|
1237
|
+
readonly confirmationInput: ExternalCardConfirmationInput;
|
|
1238
|
+
readonly receipt: TReceipt;
|
|
1239
|
+
constructor(requestId: string, confirmationInput: ExternalCardConfirmationInput, receipt: TReceipt);
|
|
1240
|
+
}
|
|
1241
|
+
interface ContoRequestOptions {
|
|
1242
|
+
/** Set only when repeating this request cannot create an additional side effect. */
|
|
1243
|
+
idempotent?: boolean;
|
|
1244
|
+
/** Number of retries after the initial attempt. Defaults to 3. */
|
|
1245
|
+
maxRetries?: number;
|
|
652
1246
|
}
|
|
653
1247
|
declare class Conto {
|
|
654
1248
|
private apiKey;
|
|
655
1249
|
private baseUrl;
|
|
656
1250
|
private timeout;
|
|
657
1251
|
payments: PaymentsClient;
|
|
1252
|
+
cards: CardsClient;
|
|
1253
|
+
x402: X402Client;
|
|
1254
|
+
mpp: MppClient;
|
|
658
1255
|
constructor(config: ContoConfig);
|
|
659
|
-
private fetchWithRetry;
|
|
660
1256
|
/** Make an authenticated request to the Giro API */
|
|
661
|
-
request<T>(method: string, path: string, body?: Record<string, unknown
|
|
1257
|
+
request<T>(method: string, path: string, body?: Record<string, unknown>, options?: ContoRequestOptions): Promise<T>;
|
|
1258
|
+
}
|
|
1259
|
+
/** Agent client for the cooperative external-card policy overlay. */
|
|
1260
|
+
declare class CardsClient {
|
|
1261
|
+
private client;
|
|
1262
|
+
constructor(client: Conto);
|
|
1263
|
+
approve(input: ExternalCardApprovalInput): Promise<ExternalCardApprovalResult>;
|
|
1264
|
+
confirm(requestId: string, input: ExternalCardConfirmationInput): Promise<ExternalCardConfirmationResult>;
|
|
1265
|
+
/**
|
|
1266
|
+
* Atomically claim the approved intent before customer code accesses or uses
|
|
1267
|
+
* the card credential. A request can be claimed only once.
|
|
1268
|
+
*/
|
|
1269
|
+
begin(requestId: string, input: {
|
|
1270
|
+
approvalToken: string;
|
|
1271
|
+
}): Promise<ExternalCardExecutionClaimResult>;
|
|
1272
|
+
/** Read execution and reconciliation state without exposing card credentials. */
|
|
1273
|
+
status(requestId: string): Promise<ExternalCardRequestStatusResult>;
|
|
1274
|
+
/**
|
|
1275
|
+
* Create a reference payment tool whose executor callback is unreachable
|
|
1276
|
+
* until Conto has returned a live approval grant.
|
|
1277
|
+
*
|
|
1278
|
+
* @deprecated Use the separate `@conto_finance/card-access` product package for
|
|
1279
|
+
* customer-hosted card enforcement. This helper remains for compatibility.
|
|
1280
|
+
*/
|
|
1281
|
+
controlled<TReceipt>(executor: ExternalCardExecutor<TReceipt>): ControlledExternalCardPaymentTool<TReceipt>;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Cooperative control for an existing customer credential store. The executor is
|
|
1285
|
+
* customer-owned and remains bypassable if another code path can call it.
|
|
1286
|
+
*/
|
|
1287
|
+
declare class ControlledExternalCardPaymentTool<TReceipt = unknown> {
|
|
1288
|
+
private cardsClient;
|
|
1289
|
+
private executor;
|
|
1290
|
+
constructor(cardsClient: CardsClient, executor: ExternalCardExecutor<TReceipt>);
|
|
1291
|
+
pay(input: ExternalCardApprovalInput): Promise<ControlledExternalCardPaymentResult<TReceipt>>;
|
|
662
1292
|
}
|
|
663
1293
|
/** Client for payment operations */
|
|
664
1294
|
declare class PaymentsClient {
|
|
@@ -704,8 +1334,11 @@ declare class PaymentsClient {
|
|
|
704
1334
|
* @example
|
|
705
1335
|
* ```typescript
|
|
706
1336
|
* const result = await conto.payments.execute(request.requestId);
|
|
707
|
-
* console.log(`
|
|
708
|
-
* console.log(`
|
|
1337
|
+
* console.log(`Status: ${result.status}`);
|
|
1338
|
+
* console.log(`Conto transaction: ${result.receipt.transactionId}`);
|
|
1339
|
+
* console.log(`Settlement mode: ${result.receipt.settlementMode}`);
|
|
1340
|
+
* console.log(`Transaction: ${result.receipt.txHash}`);
|
|
1341
|
+
* if (result.receipt.explorerUrl) console.log(`Explorer: ${result.receipt.explorerUrl}`);
|
|
709
1342
|
* ```
|
|
710
1343
|
*/
|
|
711
1344
|
execute(requestId: string): Promise<PaymentExecuteResult>;
|
|
@@ -717,8 +1350,8 @@ declare class PaymentsClient {
|
|
|
717
1350
|
* @example
|
|
718
1351
|
* ```typescript
|
|
719
1352
|
* const status = await conto.payments.status(requestId);
|
|
720
|
-
* if (status.transaction?.status === '
|
|
721
|
-
* console.log('Payment confirmed
|
|
1353
|
+
* if (status.transaction?.status === 'completed') {
|
|
1354
|
+
* console.log('Payment confirmed', status.transaction.txHash);
|
|
722
1355
|
* }
|
|
723
1356
|
* ```
|
|
724
1357
|
*/
|
|
@@ -737,7 +1370,9 @@ declare class PaymentsClient {
|
|
|
737
1370
|
* recipientAddress: '0x...',
|
|
738
1371
|
* purpose: 'Service fee'
|
|
739
1372
|
* });
|
|
740
|
-
* console.log(`
|
|
1373
|
+
* console.log(`Payment status: ${result.status}`);
|
|
1374
|
+
* console.log(`Conto transaction: ${result.receipt.transactionId}`);
|
|
1375
|
+
* console.log(`Transaction: ${result.receipt.txHash}`);
|
|
741
1376
|
* } catch (error) {
|
|
742
1377
|
* if (error.code === 'REQUIRES_APPROVAL') {
|
|
743
1378
|
* console.log('Payment needs human approval');
|
|
@@ -749,5 +1384,31 @@ declare class PaymentsClient {
|
|
|
749
1384
|
*/
|
|
750
1385
|
pay(input: PaymentRequestInput): Promise<PaymentExecuteResult>;
|
|
751
1386
|
}
|
|
1387
|
+
declare class X402Client {
|
|
1388
|
+
private client;
|
|
1389
|
+
constructor(client: Conto);
|
|
1390
|
+
preAuthorize(input: X402PreAuthorizeInput): Promise<X402PreAuthorizeResult>;
|
|
1391
|
+
record(input: X402RecordInput): Promise<X402RecordResult>;
|
|
1392
|
+
budget(options?: {
|
|
1393
|
+
sessionId?: string;
|
|
1394
|
+
}): Promise<X402BudgetResult>;
|
|
1395
|
+
services(options?: {
|
|
1396
|
+
period?: '24h' | '7d' | '30d' | '90d';
|
|
1397
|
+
limit?: number;
|
|
1398
|
+
}): Promise<ProtocolServicesResult>;
|
|
1399
|
+
}
|
|
1400
|
+
declare class MppClient {
|
|
1401
|
+
private client;
|
|
1402
|
+
constructor(client: Conto);
|
|
1403
|
+
preAuthorize(input: MppPreAuthorizeInput): Promise<MppPreAuthorizeResult>;
|
|
1404
|
+
record(input: MppRecordInput): Promise<MppRecordResult>;
|
|
1405
|
+
budget(options?: {
|
|
1406
|
+
sessionId?: string;
|
|
1407
|
+
}): Promise<MppBudgetResult>;
|
|
1408
|
+
services(options?: {
|
|
1409
|
+
period?: '24h' | '7d' | '30d' | '90d';
|
|
1410
|
+
limit?: number;
|
|
1411
|
+
}): Promise<ProtocolServicesResult>;
|
|
1412
|
+
}
|
|
752
1413
|
|
|
753
|
-
export { type Agent, type AgentStatus, type AgentType, type AgentWalletLink, type ChainType, Conto, ContoAdmin, type ContoAdminConfig,
|
|
1414
|
+
export { type AdminExternalCardOverlayEnforcement, type Agent, type AgentExternalCard, type AgentStatus, type AgentType, type AgentWalletLink, type ApprovedExternalCardExecution, type AssignExternalCardInput, type AssignedPolicy, CardsClient, type ChainType, Conto, ContoAdmin, type ContoAdminConfig, ContoAdminError, type ContoConfig, ContoError, type ContoRequestOptions, type ControlledExternalCardPaymentResult, ControlledExternalCardPaymentTool, type CreateAgentInput, type CreatePolicyInput, type CreatePolicyRuleInput, type CreateSdkKeyInput, type CreateSdkKeyResult, type CreateWalletInput, type CustodyType, type CustomerCustodyMode, type DelegationType, type ExternalCard, type ExternalCardApprovalInput, type ExternalCardApprovalResult, type ExternalCardConfirmationInput, ExternalCardConfirmationPendingError, type ExternalCardConfirmationResult, type ExternalCardExecutionClaimResult, type ExternalCardExecutionResult, type ExternalCardExecutor, type ExternalCardOverlayEnforcement, type ExternalCardRequestStatusResult, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, ContoError as GiroError, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListWalletsParams, type ListWalletsResponse, type MppBudgetResult, type MppPreAuthorizeInput, type MppPreAuthorizeResult, type MppRecordInput, type MppRecordResult, type OrganizationMember, type PaginatedResponse, type PaginationParams, type PauseExternalCardAssignmentResult, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type ProtocolBudgetResult, type ProtocolPreAuthorizeResult, type ProtocolServiceSummary, type ProtocolServicesResult, type ProvisionWalletResult, type RefreshBalanceResult, type RegisterExternalCardInput, type RuleAction, type RuleOperator, type RuleType, type SdkKey, type SdkKeyType, type UnfreezeAgentInput, type UpdateAgentInput, type UpdateExternalCardAssignmentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, type X402BudgetResult, type X402PreAuthorizeInput, type X402PreAuthorizeResult, type X402RecordInput, type X402RecordResult, Conto as default };
|