@conto_finance/sdk 0.4.0 → 0.5.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/README.md +55 -10
- package/dist/browserbase.d.mts +3 -1
- package/dist/browserbase.d.ts +3 -1
- package/dist/browserbase.js +8 -3
- package/dist/browserbase.mjs +7 -3
- package/dist/index.d.mts +91 -11
- package/dist/index.d.ts +91 -11
- package/dist/index.js +17 -10
- package/dist/index.mjs +17 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# @conto_finance/sdk
|
|
2
2
|
|
|
3
|
+
Conto is a buyer-side control layer. Integrate it in the agent owner's runtime or payment tools;
|
|
4
|
+
the owner or budget holder sets policy before the agent pays. Merchants do not install Conto.
|
|
5
|
+
See [buyer-side control](https://conto.finance/docs/guides/buyer-side-control) for the authorization
|
|
6
|
+
and execution boundary.
|
|
7
|
+
|
|
3
8
|
TypeScript SDK for Conto. Use it when you control the agent runtime and want typed access to
|
|
4
9
|
payment requests, payment execution, and organization-level provisioning.
|
|
5
10
|
|
|
@@ -144,14 +149,16 @@ const result = await conto.payments.pay({
|
|
|
144
149
|
```typescript
|
|
145
150
|
const paymentId = crypto.randomUUID();
|
|
146
151
|
|
|
147
|
-
await conto.x402.preAuthorize({
|
|
152
|
+
const decision = await conto.x402.preAuthorize({
|
|
148
153
|
amount: 0.01,
|
|
149
154
|
recipientAddress: '0x...',
|
|
150
155
|
resourceUrl: 'https://api.example.com/v1/search',
|
|
151
156
|
paymentId,
|
|
152
157
|
sessionId: 'session_123',
|
|
153
158
|
});
|
|
159
|
+
if (!decision.authorized) throw new Error(decision.message);
|
|
154
160
|
|
|
161
|
+
// Sign and settle the x402 payment, then record it with the grant.
|
|
155
162
|
await conto.x402.record({
|
|
156
163
|
amount: 0.01,
|
|
157
164
|
recipientAddress: '0x...',
|
|
@@ -159,18 +166,53 @@ await conto.x402.record({
|
|
|
159
166
|
paymentId,
|
|
160
167
|
txHash: '0x...',
|
|
161
168
|
sessionId: 'session_123',
|
|
169
|
+
grantId: decision.grantId,
|
|
170
|
+
grantSignature: decision.grantSignature,
|
|
162
171
|
});
|
|
163
172
|
|
|
164
173
|
const budget = await conto.x402.budget();
|
|
165
174
|
```
|
|
166
175
|
|
|
176
|
+
An approved `preAuthorize` returns a single-use grant (`grantId`, `grantSignature`,
|
|
177
|
+
`grantExpiresAt`) for that wallet, recipient, and amount, and reserves the amount against the
|
|
178
|
+
agent's spend limits for 10 minutes. Pass the grant to `record`. A record without a valid,
|
|
179
|
+
unexpired grant is still accepted because the payment already settled, but Conto flags it as a
|
|
180
|
+
policy bypass and raises a critical alert. Organizations can also have the agent frozen
|
|
181
|
+
automatically. The record response then includes `policyBypass: true`, `bypassReason`, and
|
|
182
|
+
`agentFrozen`.
|
|
183
|
+
|
|
184
|
+
For a Privy-managed EVM wallet, `conto.x402.pay` replaces `preAuthorize`. Pass the same fields
|
|
185
|
+
plus the accepted 402 requirements; when approved, Conto signs the payment and returns the header
|
|
186
|
+
to retry with:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
const paid = await conto.x402.pay({
|
|
190
|
+
amount: 0.01,
|
|
191
|
+
recipientAddress: requirements.payTo,
|
|
192
|
+
resourceUrl: 'https://api.example.com/v1/search',
|
|
193
|
+
paymentId,
|
|
194
|
+
paymentRequirements: requirements, // accepted entry from the 402 challenge
|
|
195
|
+
});
|
|
196
|
+
if (!paid.authorized) throw new Error(paid.message);
|
|
197
|
+
|
|
198
|
+
const response = await fetch('https://api.example.com/v1/search', {
|
|
199
|
+
headers: { [paid.paymentHeaderName!]: paid.xPaymentHeader! },
|
|
200
|
+
});
|
|
201
|
+
// Then record with paid.grantId, paid.grantSignature, and the settlement txHash.
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
`pay` is not retried automatically: each grant is signed once, and a repeat returns
|
|
205
|
+
`GRANT_ALREADY_SIGNED`. External wallets get `MANAGED_SIGNING_UNAVAILABLE`.
|
|
206
|
+
|
|
167
207
|
The MPP client mirrors the same shape with `conto.mpp.preAuthorize`, `conto.mpp.record`,
|
|
168
|
-
`conto.mpp.budget`, and `conto.mpp.services`.
|
|
208
|
+
`conto.mpp.budget`, and `conto.mpp.services`. An MPP session grant is a ceiling: several
|
|
209
|
+
`record` calls with the same `sessionId` may draw it down until it is used up or expires.
|
|
169
210
|
|
|
170
|
-
## Stripe Link Checkout Commerce
|
|
211
|
+
## Stripe Link Checkout Commerce (test only)
|
|
171
212
|
|
|
172
|
-
|
|
173
|
-
|
|
213
|
+
`LINK_CHECKOUT` is test-only and works only with a merchant enrolled with Conto. It is not a
|
|
214
|
+
general merchant integration. It evaluates policy before creating an ordinary Stripe-hosted
|
|
215
|
+
Checkout Session with card and Link enabled. It needs no private Link SDK permission,
|
|
174
216
|
Link connection, saved payment-method ID, SPT, or LPT.
|
|
175
217
|
|
|
176
218
|
Commerce execution responses separate the provider-neutral `executionChannel`, optional
|
|
@@ -224,15 +266,16 @@ fallback, surfaced as `actualPaymentMethod: 'CARD'`; it is a valid payment but n
|
|
|
224
266
|
The read-only `getCommerceExecution` projection redacts action URLs; use the initial begin result or
|
|
225
267
|
the `payments:confirm` refresh path while action remains required.
|
|
226
268
|
The server resolves the exact merchant name, Stripe account, and return URLs from configuration, so
|
|
227
|
-
the caller cannot redirect the approved purchase. This path
|
|
228
|
-
channel, not unrelated Checkout pages or the consumer's Link wallet. See
|
|
269
|
+
the caller cannot redirect the approved purchase. This path covers only that enrolled merchant's
|
|
270
|
+
Conto channel, not unrelated Checkout pages or the consumer's Link wallet. See
|
|
229
271
|
`docs/STRIPE_LINK_CHECKOUT_ADAPTER.md` for configuration, webhook, drill, and reconciliation
|
|
230
272
|
requirements.
|
|
231
273
|
|
|
232
274
|
## Agent checkout guard
|
|
233
275
|
|
|
234
|
-
For
|
|
235
|
-
`executionMethod: 'BROWSER_CHECKOUT'`.
|
|
276
|
+
For browser checkouts on supported rails (Link, card, Shop Pay, or PayPal), use
|
|
277
|
+
`runGuardedCheckout` with `executionMethod: 'BROWSER_CHECKOUT'`. Other rails and checkout flows are
|
|
278
|
+
not covered. It binds and atomically authorizes one exact Link, card,
|
|
236
279
|
Shop Pay, or PayPal browser action without requiring merchant or private provider integration. The
|
|
237
280
|
privileged browser executor must be available only through this wrapper; an unrestricted click or
|
|
238
281
|
payment tool would bypass the control. Persist its stable dispatch attempt before calling the helper; it owns authorization,
|
|
@@ -502,7 +545,9 @@ The SDK automatically adds an idempotency key to wallet payment authorization
|
|
|
502
545
|
requests. Provide your own stable `idempotencyKey` when a retry may happen in
|
|
503
546
|
another process or job attempt. External-card approvals always require a stable
|
|
504
547
|
caller-supplied `idempotencyKey`; card approval and confirmation are safe to
|
|
505
|
-
retry. x402 and MPP pre-authorization calls
|
|
548
|
+
retry. x402 and MPP pre-authorization calls issue a grant and reserve spend. A retry
|
|
549
|
+
with the same `paymentId` (x402) or `challengeId`/`credentialId` (MPP) returns the
|
|
550
|
+
same live grant instead of reserving again.
|
|
506
551
|
Record calls require an explicit stable `paymentId` or `credentialId` so an
|
|
507
552
|
ambiguous failure can be reconciled safely.
|
|
508
553
|
|
package/dist/browserbase.d.mts
CHANGED
|
@@ -2,6 +2,8 @@ import { Browser } from 'playwright-core';
|
|
|
2
2
|
import { GuardedPlaywrightCheckoutHttpHandler, PlaywrightSessionObservation, GuardedPlaywrightCheckoutClient, PlaywrightCdpSessionRegistryConfig, EncryptedPlaywrightCheckoutTargetStoreConfig, GuardedPlaywrightCheckoutRuntimeConfig } from './playwright.mjs';
|
|
3
3
|
import './index.mjs';
|
|
4
4
|
|
|
5
|
+
/** Exact provider endpoints verified against Browserbase's session API; never use a wildcard. */
|
|
6
|
+
declare const BROWSERBASE_CONNECT_ORIGINS: readonly string[];
|
|
5
7
|
type BrowserbaseSessionStatus = 'PENDING' | 'RUNNING' | 'ERROR' | 'TIMED_OUT' | 'COMPLETED';
|
|
6
8
|
type BrowserbaseSessionBindingState = 'ACTIVE' | 'REVOKED';
|
|
7
9
|
type BrowserbaseSessionLifecycleOwner = 'CONTO_RUNTIME' | 'AGENT_HOST';
|
|
@@ -136,4 +138,4 @@ declare function createBrowserbaseSessionHandoffAssertion(input: BrowserbaseSess
|
|
|
136
138
|
*/
|
|
137
139
|
declare function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config: BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig): BrowserbaseGuardedPlaywrightCheckoutRuntimeHost;
|
|
138
140
|
|
|
139
|
-
export { type BrowserbaseAttachedSession, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHost, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig, type BrowserbaseOwnedLiveView, type BrowserbaseOwnedSession, type BrowserbaseSessionBinding, type BrowserbaseSessionBindingState, type BrowserbaseSessionBindingStore, type BrowserbaseSessionConfig, BrowserbaseSessionError, type BrowserbaseSessionErrorCode, type BrowserbaseSessionHandoff, type BrowserbaseSessionHandoffAssertionInput, type BrowserbaseSessionLifecycleOwner, type BrowserbaseSessionStatus, createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost, createBrowserbaseSessionHandoffAssertion };
|
|
141
|
+
export { BROWSERBASE_CONNECT_ORIGINS, type BrowserbaseAttachedSession, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHost, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig, type BrowserbaseOwnedLiveView, type BrowserbaseOwnedSession, type BrowserbaseSessionBinding, type BrowserbaseSessionBindingState, type BrowserbaseSessionBindingStore, type BrowserbaseSessionConfig, BrowserbaseSessionError, type BrowserbaseSessionErrorCode, type BrowserbaseSessionHandoff, type BrowserbaseSessionHandoffAssertionInput, type BrowserbaseSessionLifecycleOwner, type BrowserbaseSessionStatus, createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost, createBrowserbaseSessionHandoffAssertion };
|
package/dist/browserbase.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Browser } from 'playwright-core';
|
|
|
2
2
|
import { GuardedPlaywrightCheckoutHttpHandler, PlaywrightSessionObservation, GuardedPlaywrightCheckoutClient, PlaywrightCdpSessionRegistryConfig, EncryptedPlaywrightCheckoutTargetStoreConfig, GuardedPlaywrightCheckoutRuntimeConfig } from './playwright.js';
|
|
3
3
|
import './index.js';
|
|
4
4
|
|
|
5
|
+
/** Exact provider endpoints verified against Browserbase's session API; never use a wildcard. */
|
|
6
|
+
declare const BROWSERBASE_CONNECT_ORIGINS: readonly string[];
|
|
5
7
|
type BrowserbaseSessionStatus = 'PENDING' | 'RUNNING' | 'ERROR' | 'TIMED_OUT' | 'COMPLETED';
|
|
6
8
|
type BrowserbaseSessionBindingState = 'ACTIVE' | 'REVOKED';
|
|
7
9
|
type BrowserbaseSessionLifecycleOwner = 'CONTO_RUNTIME' | 'AGENT_HOST';
|
|
@@ -136,4 +138,4 @@ declare function createBrowserbaseSessionHandoffAssertion(input: BrowserbaseSess
|
|
|
136
138
|
*/
|
|
137
139
|
declare function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config: BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig): BrowserbaseGuardedPlaywrightCheckoutRuntimeHost;
|
|
138
140
|
|
|
139
|
-
export { type BrowserbaseAttachedSession, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHost, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig, type BrowserbaseOwnedLiveView, type BrowserbaseOwnedSession, type BrowserbaseSessionBinding, type BrowserbaseSessionBindingState, type BrowserbaseSessionBindingStore, type BrowserbaseSessionConfig, BrowserbaseSessionError, type BrowserbaseSessionErrorCode, type BrowserbaseSessionHandoff, type BrowserbaseSessionHandoffAssertionInput, type BrowserbaseSessionLifecycleOwner, type BrowserbaseSessionStatus, createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost, createBrowserbaseSessionHandoffAssertion };
|
|
141
|
+
export { BROWSERBASE_CONNECT_ORIGINS, type BrowserbaseAttachedSession, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHost, type BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig, type BrowserbaseOwnedLiveView, type BrowserbaseOwnedSession, type BrowserbaseSessionBinding, type BrowserbaseSessionBindingState, type BrowserbaseSessionBindingStore, type BrowserbaseSessionConfig, BrowserbaseSessionError, type BrowserbaseSessionErrorCode, type BrowserbaseSessionHandoff, type BrowserbaseSessionHandoffAssertionInput, type BrowserbaseSessionLifecycleOwner, type BrowserbaseSessionStatus, createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost, createBrowserbaseSessionHandoffAssertion };
|
package/dist/browserbase.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/browserbase.ts
|
|
21
21
|
var browserbase_exports = {};
|
|
22
22
|
__export(browserbase_exports, {
|
|
23
|
+
BROWSERBASE_CONNECT_ORIGINS: () => BROWSERBASE_CONNECT_ORIGINS,
|
|
23
24
|
BrowserbaseSessionError: () => BrowserbaseSessionError,
|
|
24
25
|
createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost: () => createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost,
|
|
25
26
|
createBrowserbaseSessionHandoffAssertion: () => createBrowserbaseSessionHandoffAssertion
|
|
@@ -1382,7 +1383,10 @@ function createGuardedPlaywrightCheckoutHttpHandler(config) {
|
|
|
1382
1383
|
|
|
1383
1384
|
// src/browserbase.ts
|
|
1384
1385
|
var BROWSERBASE_API_ORIGIN = "https://api.browserbase.com";
|
|
1385
|
-
var
|
|
1386
|
+
var BROWSERBASE_CONNECT_ORIGINS = Object.freeze([
|
|
1387
|
+
"wss://connect.browserbase.com",
|
|
1388
|
+
"wss://connect.usw2.browserbase.com"
|
|
1389
|
+
]);
|
|
1386
1390
|
var BROWSERBASE_LIVE_VIEW_DOMAIN = "browserbase.com";
|
|
1387
1391
|
var DEFAULT_SESSION_TIMEOUT_SECONDS = 900;
|
|
1388
1392
|
var MIN_SESSION_TIMEOUT_SECONDS = 60;
|
|
@@ -1508,7 +1512,7 @@ function secureConnectUrl(value) {
|
|
|
1508
1512
|
const normalized = providerText(value, "connectUrl", 4096);
|
|
1509
1513
|
try {
|
|
1510
1514
|
const url = new URL(normalized);
|
|
1511
|
-
if (url.protocol !== "wss:" || url.origin
|
|
1515
|
+
if (url.protocol !== "wss:" || !BROWSERBASE_CONNECT_ORIGINS.includes(url.origin) || url.username || url.password || url.hash) {
|
|
1512
1516
|
throw new Error("unsafe Browserbase connect URL");
|
|
1513
1517
|
}
|
|
1514
1518
|
return url.toString();
|
|
@@ -1911,7 +1915,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
|
|
|
1911
1915
|
const host = createGuardedPlaywrightCheckoutRuntimeHost({
|
|
1912
1916
|
conto: config.conto,
|
|
1913
1917
|
browserSessions: {
|
|
1914
|
-
allowedConnectOrigins:
|
|
1918
|
+
allowedConnectOrigins: BROWSERBASE_CONNECT_ORIGINS,
|
|
1915
1919
|
connectUrlForSession: manager.connectUrlForSession,
|
|
1916
1920
|
connectOverCDP: config.connectOverCDP,
|
|
1917
1921
|
selectPage: config.selectPage,
|
|
@@ -1974,6 +1978,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
|
|
|
1974
1978
|
}
|
|
1975
1979
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1976
1980
|
0 && (module.exports = {
|
|
1981
|
+
BROWSERBASE_CONNECT_ORIGINS,
|
|
1977
1982
|
BrowserbaseSessionError,
|
|
1978
1983
|
createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost,
|
|
1979
1984
|
createBrowserbaseSessionHandoffAssertion
|
package/dist/browserbase.mjs
CHANGED
|
@@ -7,7 +7,10 @@ import "./chunk-B7F5QLE5.mjs";
|
|
|
7
7
|
// src/browserbase.ts
|
|
8
8
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
9
9
|
var BROWSERBASE_API_ORIGIN = "https://api.browserbase.com";
|
|
10
|
-
var
|
|
10
|
+
var BROWSERBASE_CONNECT_ORIGINS = Object.freeze([
|
|
11
|
+
"wss://connect.browserbase.com",
|
|
12
|
+
"wss://connect.usw2.browserbase.com"
|
|
13
|
+
]);
|
|
11
14
|
var BROWSERBASE_LIVE_VIEW_DOMAIN = "browserbase.com";
|
|
12
15
|
var DEFAULT_SESSION_TIMEOUT_SECONDS = 900;
|
|
13
16
|
var MIN_SESSION_TIMEOUT_SECONDS = 60;
|
|
@@ -133,7 +136,7 @@ function secureConnectUrl(value) {
|
|
|
133
136
|
const normalized = providerText(value, "connectUrl", 4096);
|
|
134
137
|
try {
|
|
135
138
|
const url = new URL(normalized);
|
|
136
|
-
if (url.protocol !== "wss:" || url.origin
|
|
139
|
+
if (url.protocol !== "wss:" || !BROWSERBASE_CONNECT_ORIGINS.includes(url.origin) || url.username || url.password || url.hash) {
|
|
137
140
|
throw new Error("unsafe Browserbase connect URL");
|
|
138
141
|
}
|
|
139
142
|
return url.toString();
|
|
@@ -536,7 +539,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
|
|
|
536
539
|
const host = createGuardedPlaywrightCheckoutRuntimeHost({
|
|
537
540
|
conto: config.conto,
|
|
538
541
|
browserSessions: {
|
|
539
|
-
allowedConnectOrigins:
|
|
542
|
+
allowedConnectOrigins: BROWSERBASE_CONNECT_ORIGINS,
|
|
540
543
|
connectUrlForSession: manager.connectUrlForSession,
|
|
541
544
|
connectOverCDP: config.connectOverCDP,
|
|
542
545
|
selectPage: config.selectPage,
|
|
@@ -598,6 +601,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
|
|
|
598
601
|
});
|
|
599
602
|
}
|
|
600
603
|
export {
|
|
604
|
+
BROWSERBASE_CONNECT_ORIGINS,
|
|
601
605
|
BrowserbaseSessionError,
|
|
602
606
|
createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost,
|
|
603
607
|
createBrowserbaseSessionHandoffAssertion
|
package/dist/index.d.mts
CHANGED
|
@@ -1131,7 +1131,7 @@ interface PaymentRequestResult {
|
|
|
1131
1131
|
/** Unique request ID - use this to execute or check status */
|
|
1132
1132
|
requestId: string;
|
|
1133
1133
|
/** Current status */
|
|
1134
|
-
status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | '
|
|
1134
|
+
status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | 'PROCESSING';
|
|
1135
1135
|
/** Requested amount */
|
|
1136
1136
|
amount: number;
|
|
1137
1137
|
/** Currency selected for the payment */
|
|
@@ -1187,7 +1187,7 @@ interface PaymentStatusResult {
|
|
|
1187
1187
|
requestId: string;
|
|
1188
1188
|
/** Unknown for legacy records without execution evidence, or before execution. */
|
|
1189
1189
|
settlementMode: 'live' | 'test' | 'unknown';
|
|
1190
|
-
status: 'approved' | 'declined' | 'review_required' | '
|
|
1190
|
+
status: 'approved' | 'declined' | 'review_required' | 'reconciliation_required' | 'processing' | 'completed' | 'failed' | 'expired';
|
|
1191
1191
|
amount: number;
|
|
1192
1192
|
currency: string;
|
|
1193
1193
|
recipient: string;
|
|
@@ -1196,10 +1196,7 @@ interface PaymentStatusResult {
|
|
|
1196
1196
|
category: string | null;
|
|
1197
1197
|
expiresAt: string | null;
|
|
1198
1198
|
createdAt: string;
|
|
1199
|
-
action:
|
|
1200
|
-
type: 'complete_verification';
|
|
1201
|
-
url: string;
|
|
1202
|
-
} | null;
|
|
1199
|
+
action: null;
|
|
1203
1200
|
transaction: {
|
|
1204
1201
|
/** Stable Conto transaction ID */
|
|
1205
1202
|
id: string;
|
|
@@ -1858,6 +1855,31 @@ interface ProtocolPreAuthorizeResult {
|
|
|
1858
1855
|
authorized: boolean;
|
|
1859
1856
|
decision: 'approved' | 'declined' | 'review_required';
|
|
1860
1857
|
message: string;
|
|
1858
|
+
/**
|
|
1859
|
+
* Present when authorized. Pass grantId and grantSignature to record(). A
|
|
1860
|
+
* record without a valid, unexpired grant is accepted but treated as a policy
|
|
1861
|
+
* bypass: the payment is flagged and the owner is alerted. The organization
|
|
1862
|
+
* can also have the agent frozen automatically.
|
|
1863
|
+
*/
|
|
1864
|
+
grantId?: string;
|
|
1865
|
+
grantSignature?: string;
|
|
1866
|
+
/** ISO timestamp. Record the payment before this time. */
|
|
1867
|
+
grantExpiresAt?: string;
|
|
1868
|
+
}
|
|
1869
|
+
interface ProtocolRecordGrant {
|
|
1870
|
+
/** grantId from the approved preAuthorize() response. */
|
|
1871
|
+
grantId?: string;
|
|
1872
|
+
/** grantSignature from the approved preAuthorize() response. */
|
|
1873
|
+
grantSignature?: string;
|
|
1874
|
+
}
|
|
1875
|
+
interface ProtocolRecordGrantResult {
|
|
1876
|
+
/** Grant consumed by this record. */
|
|
1877
|
+
grantId?: string;
|
|
1878
|
+
/** True when the payment was recorded without a valid grant. */
|
|
1879
|
+
policyBypass?: true;
|
|
1880
|
+
bypassReason?: 'GRANT_MISSING' | 'GRANT_INVALID' | 'GRANT_EXPIRED';
|
|
1881
|
+
/** True when the organization freezes agents on bypass and this record froze it. */
|
|
1882
|
+
agentFrozen?: boolean;
|
|
1861
1883
|
}
|
|
1862
1884
|
interface X402PreAuthorizeInput {
|
|
1863
1885
|
amount: number;
|
|
@@ -1884,7 +1906,55 @@ interface X402PreAuthorizeResult extends ProtocolPreAuthorizeResult {
|
|
|
1884
1906
|
sessionId?: string;
|
|
1885
1907
|
};
|
|
1886
1908
|
}
|
|
1887
|
-
|
|
1909
|
+
/** The accepted entry from a 402 challenge (x402 "exact" scheme on EVM). */
|
|
1910
|
+
interface X402PaymentRequirements {
|
|
1911
|
+
scheme: 'exact' | (string & {});
|
|
1912
|
+
/** Network as the challenge sent it: CAIP-2 (eip155:8453) or an x402 v1 name (base). */
|
|
1913
|
+
network: string;
|
|
1914
|
+
/** v1: amount in token base units, as an integer string. */
|
|
1915
|
+
maxAmountRequired?: string;
|
|
1916
|
+
/** v2: amount in token base units, as an integer string. */
|
|
1917
|
+
amount?: string;
|
|
1918
|
+
/** Token contract. Conto signs only for managed USDC. */
|
|
1919
|
+
asset: string;
|
|
1920
|
+
payTo: string;
|
|
1921
|
+
maxTimeoutSeconds: number;
|
|
1922
|
+
resource?: string;
|
|
1923
|
+
/** EIP-712 domain of the token. */
|
|
1924
|
+
extra?: {
|
|
1925
|
+
name?: string;
|
|
1926
|
+
version?: string;
|
|
1927
|
+
[key: string]: unknown;
|
|
1928
|
+
};
|
|
1929
|
+
[key: string]: unknown;
|
|
1930
|
+
}
|
|
1931
|
+
interface X402PayInput extends X402PreAuthorizeInput {
|
|
1932
|
+
/** x402 protocol version of the challenge. Defaults to 1. */
|
|
1933
|
+
x402Version?: 1 | 2;
|
|
1934
|
+
paymentRequirements: X402PaymentRequirements;
|
|
1935
|
+
}
|
|
1936
|
+
interface X402Authorization {
|
|
1937
|
+
from: string;
|
|
1938
|
+
to: string;
|
|
1939
|
+
value: string;
|
|
1940
|
+
validAfter: string;
|
|
1941
|
+
validBefore: string;
|
|
1942
|
+
nonce: string;
|
|
1943
|
+
}
|
|
1944
|
+
interface X402PayResult extends ProtocolPreAuthorizeResult {
|
|
1945
|
+
x402: {
|
|
1946
|
+
serviceDomain?: string;
|
|
1947
|
+
amount: number;
|
|
1948
|
+
sessionId?: string;
|
|
1949
|
+
};
|
|
1950
|
+
/** Present when authorized: send as this header when retrying the resource request. */
|
|
1951
|
+
paymentHeaderName?: 'X-PAYMENT' | 'PAYMENT-SIGNATURE';
|
|
1952
|
+
/** Present when authorized: base64 payment payload signed by Conto. */
|
|
1953
|
+
xPaymentHeader?: string;
|
|
1954
|
+
/** Present when authorized: the EIP-3009 authorization Conto signed. */
|
|
1955
|
+
authorization?: X402Authorization;
|
|
1956
|
+
}
|
|
1957
|
+
interface X402RecordInput extends ProtocolRecordGrant {
|
|
1888
1958
|
amount: number;
|
|
1889
1959
|
currency?: string;
|
|
1890
1960
|
recipientAddress: string;
|
|
@@ -1908,7 +1978,7 @@ interface X402RecordInput {
|
|
|
1908
1978
|
paymentId: string;
|
|
1909
1979
|
}>;
|
|
1910
1980
|
}
|
|
1911
|
-
interface X402RecordResult {
|
|
1981
|
+
interface X402RecordResult extends ProtocolRecordGrantResult {
|
|
1912
1982
|
recorded: true;
|
|
1913
1983
|
confirmed: true;
|
|
1914
1984
|
txHash: string;
|
|
@@ -1939,7 +2009,7 @@ interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
|
|
|
1939
2009
|
sessionId?: string;
|
|
1940
2010
|
};
|
|
1941
2011
|
}
|
|
1942
|
-
interface MppRecordInput {
|
|
2012
|
+
interface MppRecordInput extends ProtocolRecordGrant {
|
|
1943
2013
|
amount: number;
|
|
1944
2014
|
currency?: string;
|
|
1945
2015
|
recipientAddress: string;
|
|
@@ -1965,7 +2035,7 @@ interface MppRecordInput {
|
|
|
1965
2035
|
credentialId: string;
|
|
1966
2036
|
}>;
|
|
1967
2037
|
}
|
|
1968
|
-
interface MppRecordResult {
|
|
2038
|
+
interface MppRecordResult extends ProtocolRecordGrantResult {
|
|
1969
2039
|
recorded: true;
|
|
1970
2040
|
txHash?: string;
|
|
1971
2041
|
explorerUrl?: string;
|
|
@@ -2359,6 +2429,16 @@ declare class X402Client {
|
|
|
2359
2429
|
private client;
|
|
2360
2430
|
constructor(client: Conto);
|
|
2361
2431
|
preAuthorize(input: X402PreAuthorizeInput): Promise<X402PreAuthorizeResult>;
|
|
2432
|
+
/**
|
|
2433
|
+
* Conto-signed x402 for Privy-managed EVM wallets. Conto evaluates the
|
|
2434
|
+
* payment exactly like preAuthorize() and, only when approved, signs the
|
|
2435
|
+
* EIP-3009 authorization for the approved payee and amount. Retry the
|
|
2436
|
+
* resource request with `paymentHeaderName: xPaymentHeader`, then call
|
|
2437
|
+
* record() with the returned grant. Not retried automatically: a grant is
|
|
2438
|
+
* signed at most once, and a repeat returns 409 GRANT_ALREADY_SIGNED.
|
|
2439
|
+
* External wallets get 409 MANAGED_SIGNING_UNAVAILABLE; use preAuthorize().
|
|
2440
|
+
*/
|
|
2441
|
+
pay(input: X402PayInput): Promise<X402PayResult>;
|
|
2362
2442
|
record(input: X402RecordInput): Promise<X402RecordResult>;
|
|
2363
2443
|
budget(options?: {
|
|
2364
2444
|
sessionId?: string;
|
|
@@ -2382,4 +2462,4 @@ declare class MppClient {
|
|
|
2382
2462
|
}): Promise<ProtocolServicesResult>;
|
|
2383
2463
|
}
|
|
2384
2464
|
|
|
2385
|
-
export { type AdminExternalCardOverlayEnforcement, type Agent, type AgentCheckoutAction, type AgentCheckoutActionKind, type AgentExternalCard, type AgentSetupResult, type AgentStatus, type AgentType, type AgentWalletLink, type ApprovedExternalCardExecution, type AssignExternalCardInput, type AssignedPolicy, type AuthorizeCheckoutActionResult, type BeginCommerceExecutionInput, type BrowserActionClaimResult, type BrowserActionDispatchObservationInput, BrowserActionFinalizationPendingError, type BrowserActionFinalizeResult, type BrowserCheckoutAction, type BrowserCheckoutTargetResolver, type BrowserCheckoutTargetSnapshot, type BrowserCheckoutTargetVerificationCode, BrowserCheckoutTargetVerificationError, type CanonicalBrowserCheckoutTargetSnapshot, CardsClient, type ChainType, type CheckoutActionAuthorization, type CommerceCheckoutMethod, type CommerceContextRequirement, type CommerceExecution, type CommerceExecutionAdapterKind, type CommerceExecutionArtifactKind, type CommerceExecutionChannel, type CommerceExecutionConstraint, type CommerceExecutionConstraintCoverage, type CommerceExecutionConstraintCoverageLevel, type CommerceExecutionDeliveryMode, type CommerceExecutionEvidence, type CommerceExecutionProvider, type CommerceExecutionResult, type CommerceExecutionSourceKind, type CommerceExecutionStatus, type CommerceFactConfidence, type CommerceFactProvenanceInput, type CommerceFactSource, type CommerceFulfillmentInput, type CommerceLineItemInput, type CommerceProposalFactKey, type CommerceProposalMissingFact, type CommerceProposalResolution, type CommerceProposalState, type CommerceSettlementRail, type CommerceTotalInput, type CommerceTotalType, type ComparePolicyVersionsResponse, type ConnectedCardBrief, type ConnectedCardCredential, type ConnectedCardDrawInput, type ConnectedCardDrawMerchant, type ConnectedCardDrawResult, type ConnectedCardDrawable, type ConnectedCardListResult, type ConnectedCardMandate, type ConnectedCardMandateMerchant, type ConnectedCardReference, ConnectedCardsClient, 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 CustomerWalletControlModel, type CustomerWalletKeyAccess, type DelegationType, type ExecuteCommerceExecutionResult, type ExternalCard, type ExternalCardApprovalInput, type ExternalCardApprovalResult, type ExternalCardConfirmationInput, ExternalCardConfirmationPendingError, type ExternalCardConfirmationResult, type ExternalCardExecutionClaimResult, type ExternalCardExecutionResult, type ExternalCardExecutor, type ExternalCardOverlayEnforcement, type ExternalCardRequestStatusResult, type ExternalWalletApprovalInput, type ExternalWalletApprovalResult, type ExternalWalletConfirmationInput, type ExternalWalletConfirmationResult, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, ContoError as GiroError, type GuardCheckoutResult, type GuardedBrowserDispatchResult, type GuardedCheckoutInput, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListPolicyVersionsResponse, type ListStripeLinkPaymentMethodsResult, type ListWalletsParams, type ListWalletsResponse, type MppBudgetResult, type MppPreAuthorizeInput, type MppPreAuthorizeResult, type MppRecordInput, type MppRecordResult, type NormalizeCommerceProposalInput, type OrganizationMember, type PaginatedResponse, type PaginationParams, type PauseExternalCardAssignmentResult, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type PolicyVersionChangeType, type PolicyVersionDetail, type PolicyVersionDiff, type PolicyVersionFieldChange, type PolicyVersionSnapshot, type PolicyVersionSnapshotRule, type PolicyVersionSummary, type PrivilegedBrowserCheckoutDriver, type ProtocolBudgetResult, type ProtocolPreAuthorizeResult, type ProtocolServiceSummary, type ProtocolServicesResult, type ProvisionWalletResult, type RefreshBalanceResult, type RegisterExternalCardInput, type RollbackPolicyVersionResponse, type RuleAction, type RuleOperator, type RuleType, type RunGuardedCheckoutResult, type SdkKey, type SdkKeyType, type StripeLinkCheckoutReadiness, type StripeLinkCheckoutReadinessResult, type StripeLinkCheckoutReadinessStatus, type StripeLinkCheckoutVerification, type StripeLinkPaymentMethod, type UnfreezeAgentInput, type UpdateAgentInput, type UpdateExternalCardAssignmentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type VerifiedBrowserCheckoutTarget, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, type X402BudgetResult, type X402PreAuthorizeInput, type X402PreAuthorizeResult, type X402RecordInput, type X402RecordResult, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget };
|
|
2465
|
+
export { type AdminExternalCardOverlayEnforcement, type Agent, type AgentCheckoutAction, type AgentCheckoutActionKind, type AgentExternalCard, type AgentSetupResult, type AgentStatus, type AgentType, type AgentWalletLink, type ApprovedExternalCardExecution, type AssignExternalCardInput, type AssignedPolicy, type AuthorizeCheckoutActionResult, type BeginCommerceExecutionInput, type BrowserActionClaimResult, type BrowserActionDispatchObservationInput, BrowserActionFinalizationPendingError, type BrowserActionFinalizeResult, type BrowserCheckoutAction, type BrowserCheckoutTargetResolver, type BrowserCheckoutTargetSnapshot, type BrowserCheckoutTargetVerificationCode, BrowserCheckoutTargetVerificationError, type CanonicalBrowserCheckoutTargetSnapshot, CardsClient, type ChainType, type CheckoutActionAuthorization, type CommerceCheckoutMethod, type CommerceContextRequirement, type CommerceExecution, type CommerceExecutionAdapterKind, type CommerceExecutionArtifactKind, type CommerceExecutionChannel, type CommerceExecutionConstraint, type CommerceExecutionConstraintCoverage, type CommerceExecutionConstraintCoverageLevel, type CommerceExecutionDeliveryMode, type CommerceExecutionEvidence, type CommerceExecutionProvider, type CommerceExecutionResult, type CommerceExecutionSourceKind, type CommerceExecutionStatus, type CommerceFactConfidence, type CommerceFactProvenanceInput, type CommerceFactSource, type CommerceFulfillmentInput, type CommerceLineItemInput, type CommerceProposalFactKey, type CommerceProposalMissingFact, type CommerceProposalResolution, type CommerceProposalState, type CommerceSettlementRail, type CommerceTotalInput, type CommerceTotalType, type ComparePolicyVersionsResponse, type ConnectedCardBrief, type ConnectedCardCredential, type ConnectedCardDrawInput, type ConnectedCardDrawMerchant, type ConnectedCardDrawResult, type ConnectedCardDrawable, type ConnectedCardListResult, type ConnectedCardMandate, type ConnectedCardMandateMerchant, type ConnectedCardReference, ConnectedCardsClient, 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 CustomerWalletControlModel, type CustomerWalletKeyAccess, type DelegationType, type ExecuteCommerceExecutionResult, type ExternalCard, type ExternalCardApprovalInput, type ExternalCardApprovalResult, type ExternalCardConfirmationInput, ExternalCardConfirmationPendingError, type ExternalCardConfirmationResult, type ExternalCardExecutionClaimResult, type ExternalCardExecutionResult, type ExternalCardExecutor, type ExternalCardOverlayEnforcement, type ExternalCardRequestStatusResult, type ExternalWalletApprovalInput, type ExternalWalletApprovalResult, type ExternalWalletConfirmationInput, type ExternalWalletConfirmationResult, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, ContoError as GiroError, type GuardCheckoutResult, type GuardedBrowserDispatchResult, type GuardedCheckoutInput, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListPolicyVersionsResponse, type ListStripeLinkPaymentMethodsResult, type ListWalletsParams, type ListWalletsResponse, type MppBudgetResult, type MppPreAuthorizeInput, type MppPreAuthorizeResult, type MppRecordInput, type MppRecordResult, type NormalizeCommerceProposalInput, type OrganizationMember, type PaginatedResponse, type PaginationParams, type PauseExternalCardAssignmentResult, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type PolicyVersionChangeType, type PolicyVersionDetail, type PolicyVersionDiff, type PolicyVersionFieldChange, type PolicyVersionSnapshot, type PolicyVersionSnapshotRule, type PolicyVersionSummary, type PrivilegedBrowserCheckoutDriver, type ProtocolBudgetResult, type ProtocolPreAuthorizeResult, type ProtocolRecordGrant, type ProtocolRecordGrantResult, type ProtocolServiceSummary, type ProtocolServicesResult, type ProvisionWalletResult, type RefreshBalanceResult, type RegisterExternalCardInput, type RollbackPolicyVersionResponse, type RuleAction, type RuleOperator, type RuleType, type RunGuardedCheckoutResult, type SdkKey, type SdkKeyType, type StripeLinkCheckoutReadiness, type StripeLinkCheckoutReadinessResult, type StripeLinkCheckoutReadinessStatus, type StripeLinkCheckoutVerification, type StripeLinkPaymentMethod, type UnfreezeAgentInput, type UpdateAgentInput, type UpdateExternalCardAssignmentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type VerifiedBrowserCheckoutTarget, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, type X402Authorization, type X402BudgetResult, type X402PayInput, type X402PayResult, type X402PaymentRequirements, type X402PreAuthorizeInput, type X402PreAuthorizeResult, type X402RecordInput, type X402RecordResult, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget };
|
package/dist/index.d.ts
CHANGED
|
@@ -1131,7 +1131,7 @@ interface PaymentRequestResult {
|
|
|
1131
1131
|
/** Unique request ID - use this to execute or check status */
|
|
1132
1132
|
requestId: string;
|
|
1133
1133
|
/** Current status */
|
|
1134
|
-
status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | '
|
|
1134
|
+
status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | 'PROCESSING';
|
|
1135
1135
|
/** Requested amount */
|
|
1136
1136
|
amount: number;
|
|
1137
1137
|
/** Currency selected for the payment */
|
|
@@ -1187,7 +1187,7 @@ interface PaymentStatusResult {
|
|
|
1187
1187
|
requestId: string;
|
|
1188
1188
|
/** Unknown for legacy records without execution evidence, or before execution. */
|
|
1189
1189
|
settlementMode: 'live' | 'test' | 'unknown';
|
|
1190
|
-
status: 'approved' | 'declined' | 'review_required' | '
|
|
1190
|
+
status: 'approved' | 'declined' | 'review_required' | 'reconciliation_required' | 'processing' | 'completed' | 'failed' | 'expired';
|
|
1191
1191
|
amount: number;
|
|
1192
1192
|
currency: string;
|
|
1193
1193
|
recipient: string;
|
|
@@ -1196,10 +1196,7 @@ interface PaymentStatusResult {
|
|
|
1196
1196
|
category: string | null;
|
|
1197
1197
|
expiresAt: string | null;
|
|
1198
1198
|
createdAt: string;
|
|
1199
|
-
action:
|
|
1200
|
-
type: 'complete_verification';
|
|
1201
|
-
url: string;
|
|
1202
|
-
} | null;
|
|
1199
|
+
action: null;
|
|
1203
1200
|
transaction: {
|
|
1204
1201
|
/** Stable Conto transaction ID */
|
|
1205
1202
|
id: string;
|
|
@@ -1858,6 +1855,31 @@ interface ProtocolPreAuthorizeResult {
|
|
|
1858
1855
|
authorized: boolean;
|
|
1859
1856
|
decision: 'approved' | 'declined' | 'review_required';
|
|
1860
1857
|
message: string;
|
|
1858
|
+
/**
|
|
1859
|
+
* Present when authorized. Pass grantId and grantSignature to record(). A
|
|
1860
|
+
* record without a valid, unexpired grant is accepted but treated as a policy
|
|
1861
|
+
* bypass: the payment is flagged and the owner is alerted. The organization
|
|
1862
|
+
* can also have the agent frozen automatically.
|
|
1863
|
+
*/
|
|
1864
|
+
grantId?: string;
|
|
1865
|
+
grantSignature?: string;
|
|
1866
|
+
/** ISO timestamp. Record the payment before this time. */
|
|
1867
|
+
grantExpiresAt?: string;
|
|
1868
|
+
}
|
|
1869
|
+
interface ProtocolRecordGrant {
|
|
1870
|
+
/** grantId from the approved preAuthorize() response. */
|
|
1871
|
+
grantId?: string;
|
|
1872
|
+
/** grantSignature from the approved preAuthorize() response. */
|
|
1873
|
+
grantSignature?: string;
|
|
1874
|
+
}
|
|
1875
|
+
interface ProtocolRecordGrantResult {
|
|
1876
|
+
/** Grant consumed by this record. */
|
|
1877
|
+
grantId?: string;
|
|
1878
|
+
/** True when the payment was recorded without a valid grant. */
|
|
1879
|
+
policyBypass?: true;
|
|
1880
|
+
bypassReason?: 'GRANT_MISSING' | 'GRANT_INVALID' | 'GRANT_EXPIRED';
|
|
1881
|
+
/** True when the organization freezes agents on bypass and this record froze it. */
|
|
1882
|
+
agentFrozen?: boolean;
|
|
1861
1883
|
}
|
|
1862
1884
|
interface X402PreAuthorizeInput {
|
|
1863
1885
|
amount: number;
|
|
@@ -1884,7 +1906,55 @@ interface X402PreAuthorizeResult extends ProtocolPreAuthorizeResult {
|
|
|
1884
1906
|
sessionId?: string;
|
|
1885
1907
|
};
|
|
1886
1908
|
}
|
|
1887
|
-
|
|
1909
|
+
/** The accepted entry from a 402 challenge (x402 "exact" scheme on EVM). */
|
|
1910
|
+
interface X402PaymentRequirements {
|
|
1911
|
+
scheme: 'exact' | (string & {});
|
|
1912
|
+
/** Network as the challenge sent it: CAIP-2 (eip155:8453) or an x402 v1 name (base). */
|
|
1913
|
+
network: string;
|
|
1914
|
+
/** v1: amount in token base units, as an integer string. */
|
|
1915
|
+
maxAmountRequired?: string;
|
|
1916
|
+
/** v2: amount in token base units, as an integer string. */
|
|
1917
|
+
amount?: string;
|
|
1918
|
+
/** Token contract. Conto signs only for managed USDC. */
|
|
1919
|
+
asset: string;
|
|
1920
|
+
payTo: string;
|
|
1921
|
+
maxTimeoutSeconds: number;
|
|
1922
|
+
resource?: string;
|
|
1923
|
+
/** EIP-712 domain of the token. */
|
|
1924
|
+
extra?: {
|
|
1925
|
+
name?: string;
|
|
1926
|
+
version?: string;
|
|
1927
|
+
[key: string]: unknown;
|
|
1928
|
+
};
|
|
1929
|
+
[key: string]: unknown;
|
|
1930
|
+
}
|
|
1931
|
+
interface X402PayInput extends X402PreAuthorizeInput {
|
|
1932
|
+
/** x402 protocol version of the challenge. Defaults to 1. */
|
|
1933
|
+
x402Version?: 1 | 2;
|
|
1934
|
+
paymentRequirements: X402PaymentRequirements;
|
|
1935
|
+
}
|
|
1936
|
+
interface X402Authorization {
|
|
1937
|
+
from: string;
|
|
1938
|
+
to: string;
|
|
1939
|
+
value: string;
|
|
1940
|
+
validAfter: string;
|
|
1941
|
+
validBefore: string;
|
|
1942
|
+
nonce: string;
|
|
1943
|
+
}
|
|
1944
|
+
interface X402PayResult extends ProtocolPreAuthorizeResult {
|
|
1945
|
+
x402: {
|
|
1946
|
+
serviceDomain?: string;
|
|
1947
|
+
amount: number;
|
|
1948
|
+
sessionId?: string;
|
|
1949
|
+
};
|
|
1950
|
+
/** Present when authorized: send as this header when retrying the resource request. */
|
|
1951
|
+
paymentHeaderName?: 'X-PAYMENT' | 'PAYMENT-SIGNATURE';
|
|
1952
|
+
/** Present when authorized: base64 payment payload signed by Conto. */
|
|
1953
|
+
xPaymentHeader?: string;
|
|
1954
|
+
/** Present when authorized: the EIP-3009 authorization Conto signed. */
|
|
1955
|
+
authorization?: X402Authorization;
|
|
1956
|
+
}
|
|
1957
|
+
interface X402RecordInput extends ProtocolRecordGrant {
|
|
1888
1958
|
amount: number;
|
|
1889
1959
|
currency?: string;
|
|
1890
1960
|
recipientAddress: string;
|
|
@@ -1908,7 +1978,7 @@ interface X402RecordInput {
|
|
|
1908
1978
|
paymentId: string;
|
|
1909
1979
|
}>;
|
|
1910
1980
|
}
|
|
1911
|
-
interface X402RecordResult {
|
|
1981
|
+
interface X402RecordResult extends ProtocolRecordGrantResult {
|
|
1912
1982
|
recorded: true;
|
|
1913
1983
|
confirmed: true;
|
|
1914
1984
|
txHash: string;
|
|
@@ -1939,7 +2009,7 @@ interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
|
|
|
1939
2009
|
sessionId?: string;
|
|
1940
2010
|
};
|
|
1941
2011
|
}
|
|
1942
|
-
interface MppRecordInput {
|
|
2012
|
+
interface MppRecordInput extends ProtocolRecordGrant {
|
|
1943
2013
|
amount: number;
|
|
1944
2014
|
currency?: string;
|
|
1945
2015
|
recipientAddress: string;
|
|
@@ -1965,7 +2035,7 @@ interface MppRecordInput {
|
|
|
1965
2035
|
credentialId: string;
|
|
1966
2036
|
}>;
|
|
1967
2037
|
}
|
|
1968
|
-
interface MppRecordResult {
|
|
2038
|
+
interface MppRecordResult extends ProtocolRecordGrantResult {
|
|
1969
2039
|
recorded: true;
|
|
1970
2040
|
txHash?: string;
|
|
1971
2041
|
explorerUrl?: string;
|
|
@@ -2359,6 +2429,16 @@ declare class X402Client {
|
|
|
2359
2429
|
private client;
|
|
2360
2430
|
constructor(client: Conto);
|
|
2361
2431
|
preAuthorize(input: X402PreAuthorizeInput): Promise<X402PreAuthorizeResult>;
|
|
2432
|
+
/**
|
|
2433
|
+
* Conto-signed x402 for Privy-managed EVM wallets. Conto evaluates the
|
|
2434
|
+
* payment exactly like preAuthorize() and, only when approved, signs the
|
|
2435
|
+
* EIP-3009 authorization for the approved payee and amount. Retry the
|
|
2436
|
+
* resource request with `paymentHeaderName: xPaymentHeader`, then call
|
|
2437
|
+
* record() with the returned grant. Not retried automatically: a grant is
|
|
2438
|
+
* signed at most once, and a repeat returns 409 GRANT_ALREADY_SIGNED.
|
|
2439
|
+
* External wallets get 409 MANAGED_SIGNING_UNAVAILABLE; use preAuthorize().
|
|
2440
|
+
*/
|
|
2441
|
+
pay(input: X402PayInput): Promise<X402PayResult>;
|
|
2362
2442
|
record(input: X402RecordInput): Promise<X402RecordResult>;
|
|
2363
2443
|
budget(options?: {
|
|
2364
2444
|
sessionId?: string;
|
|
@@ -2382,4 +2462,4 @@ declare class MppClient {
|
|
|
2382
2462
|
}): Promise<ProtocolServicesResult>;
|
|
2383
2463
|
}
|
|
2384
2464
|
|
|
2385
|
-
export { type AdminExternalCardOverlayEnforcement, type Agent, type AgentCheckoutAction, type AgentCheckoutActionKind, type AgentExternalCard, type AgentSetupResult, type AgentStatus, type AgentType, type AgentWalletLink, type ApprovedExternalCardExecution, type AssignExternalCardInput, type AssignedPolicy, type AuthorizeCheckoutActionResult, type BeginCommerceExecutionInput, type BrowserActionClaimResult, type BrowserActionDispatchObservationInput, BrowserActionFinalizationPendingError, type BrowserActionFinalizeResult, type BrowserCheckoutAction, type BrowserCheckoutTargetResolver, type BrowserCheckoutTargetSnapshot, type BrowserCheckoutTargetVerificationCode, BrowserCheckoutTargetVerificationError, type CanonicalBrowserCheckoutTargetSnapshot, CardsClient, type ChainType, type CheckoutActionAuthorization, type CommerceCheckoutMethod, type CommerceContextRequirement, type CommerceExecution, type CommerceExecutionAdapterKind, type CommerceExecutionArtifactKind, type CommerceExecutionChannel, type CommerceExecutionConstraint, type CommerceExecutionConstraintCoverage, type CommerceExecutionConstraintCoverageLevel, type CommerceExecutionDeliveryMode, type CommerceExecutionEvidence, type CommerceExecutionProvider, type CommerceExecutionResult, type CommerceExecutionSourceKind, type CommerceExecutionStatus, type CommerceFactConfidence, type CommerceFactProvenanceInput, type CommerceFactSource, type CommerceFulfillmentInput, type CommerceLineItemInput, type CommerceProposalFactKey, type CommerceProposalMissingFact, type CommerceProposalResolution, type CommerceProposalState, type CommerceSettlementRail, type CommerceTotalInput, type CommerceTotalType, type ComparePolicyVersionsResponse, type ConnectedCardBrief, type ConnectedCardCredential, type ConnectedCardDrawInput, type ConnectedCardDrawMerchant, type ConnectedCardDrawResult, type ConnectedCardDrawable, type ConnectedCardListResult, type ConnectedCardMandate, type ConnectedCardMandateMerchant, type ConnectedCardReference, ConnectedCardsClient, 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 CustomerWalletControlModel, type CustomerWalletKeyAccess, type DelegationType, type ExecuteCommerceExecutionResult, type ExternalCard, type ExternalCardApprovalInput, type ExternalCardApprovalResult, type ExternalCardConfirmationInput, ExternalCardConfirmationPendingError, type ExternalCardConfirmationResult, type ExternalCardExecutionClaimResult, type ExternalCardExecutionResult, type ExternalCardExecutor, type ExternalCardOverlayEnforcement, type ExternalCardRequestStatusResult, type ExternalWalletApprovalInput, type ExternalWalletApprovalResult, type ExternalWalletConfirmationInput, type ExternalWalletConfirmationResult, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, ContoError as GiroError, type GuardCheckoutResult, type GuardedBrowserDispatchResult, type GuardedCheckoutInput, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListPolicyVersionsResponse, type ListStripeLinkPaymentMethodsResult, type ListWalletsParams, type ListWalletsResponse, type MppBudgetResult, type MppPreAuthorizeInput, type MppPreAuthorizeResult, type MppRecordInput, type MppRecordResult, type NormalizeCommerceProposalInput, type OrganizationMember, type PaginatedResponse, type PaginationParams, type PauseExternalCardAssignmentResult, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type PolicyVersionChangeType, type PolicyVersionDetail, type PolicyVersionDiff, type PolicyVersionFieldChange, type PolicyVersionSnapshot, type PolicyVersionSnapshotRule, type PolicyVersionSummary, type PrivilegedBrowserCheckoutDriver, type ProtocolBudgetResult, type ProtocolPreAuthorizeResult, type ProtocolServiceSummary, type ProtocolServicesResult, type ProvisionWalletResult, type RefreshBalanceResult, type RegisterExternalCardInput, type RollbackPolicyVersionResponse, type RuleAction, type RuleOperator, type RuleType, type RunGuardedCheckoutResult, type SdkKey, type SdkKeyType, type StripeLinkCheckoutReadiness, type StripeLinkCheckoutReadinessResult, type StripeLinkCheckoutReadinessStatus, type StripeLinkCheckoutVerification, type StripeLinkPaymentMethod, type UnfreezeAgentInput, type UpdateAgentInput, type UpdateExternalCardAssignmentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type VerifiedBrowserCheckoutTarget, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, type X402BudgetResult, type X402PreAuthorizeInput, type X402PreAuthorizeResult, type X402RecordInput, type X402RecordResult, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget };
|
|
2465
|
+
export { type AdminExternalCardOverlayEnforcement, type Agent, type AgentCheckoutAction, type AgentCheckoutActionKind, type AgentExternalCard, type AgentSetupResult, type AgentStatus, type AgentType, type AgentWalletLink, type ApprovedExternalCardExecution, type AssignExternalCardInput, type AssignedPolicy, type AuthorizeCheckoutActionResult, type BeginCommerceExecutionInput, type BrowserActionClaimResult, type BrowserActionDispatchObservationInput, BrowserActionFinalizationPendingError, type BrowserActionFinalizeResult, type BrowserCheckoutAction, type BrowserCheckoutTargetResolver, type BrowserCheckoutTargetSnapshot, type BrowserCheckoutTargetVerificationCode, BrowserCheckoutTargetVerificationError, type CanonicalBrowserCheckoutTargetSnapshot, CardsClient, type ChainType, type CheckoutActionAuthorization, type CommerceCheckoutMethod, type CommerceContextRequirement, type CommerceExecution, type CommerceExecutionAdapterKind, type CommerceExecutionArtifactKind, type CommerceExecutionChannel, type CommerceExecutionConstraint, type CommerceExecutionConstraintCoverage, type CommerceExecutionConstraintCoverageLevel, type CommerceExecutionDeliveryMode, type CommerceExecutionEvidence, type CommerceExecutionProvider, type CommerceExecutionResult, type CommerceExecutionSourceKind, type CommerceExecutionStatus, type CommerceFactConfidence, type CommerceFactProvenanceInput, type CommerceFactSource, type CommerceFulfillmentInput, type CommerceLineItemInput, type CommerceProposalFactKey, type CommerceProposalMissingFact, type CommerceProposalResolution, type CommerceProposalState, type CommerceSettlementRail, type CommerceTotalInput, type CommerceTotalType, type ComparePolicyVersionsResponse, type ConnectedCardBrief, type ConnectedCardCredential, type ConnectedCardDrawInput, type ConnectedCardDrawMerchant, type ConnectedCardDrawResult, type ConnectedCardDrawable, type ConnectedCardListResult, type ConnectedCardMandate, type ConnectedCardMandateMerchant, type ConnectedCardReference, ConnectedCardsClient, 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 CustomerWalletControlModel, type CustomerWalletKeyAccess, type DelegationType, type ExecuteCommerceExecutionResult, type ExternalCard, type ExternalCardApprovalInput, type ExternalCardApprovalResult, type ExternalCardConfirmationInput, ExternalCardConfirmationPendingError, type ExternalCardConfirmationResult, type ExternalCardExecutionClaimResult, type ExternalCardExecutionResult, type ExternalCardExecutor, type ExternalCardOverlayEnforcement, type ExternalCardRequestStatusResult, type ExternalWalletApprovalInput, type ExternalWalletApprovalResult, type ExternalWalletConfirmationInput, type ExternalWalletConfirmationResult, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, ContoError as GiroError, type GuardCheckoutResult, type GuardedBrowserDispatchResult, type GuardedCheckoutInput, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListPolicyVersionsResponse, type ListStripeLinkPaymentMethodsResult, type ListWalletsParams, type ListWalletsResponse, type MppBudgetResult, type MppPreAuthorizeInput, type MppPreAuthorizeResult, type MppRecordInput, type MppRecordResult, type NormalizeCommerceProposalInput, type OrganizationMember, type PaginatedResponse, type PaginationParams, type PauseExternalCardAssignmentResult, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type PolicyVersionChangeType, type PolicyVersionDetail, type PolicyVersionDiff, type PolicyVersionFieldChange, type PolicyVersionSnapshot, type PolicyVersionSnapshotRule, type PolicyVersionSummary, type PrivilegedBrowserCheckoutDriver, type ProtocolBudgetResult, type ProtocolPreAuthorizeResult, type ProtocolRecordGrant, type ProtocolRecordGrantResult, type ProtocolServiceSummary, type ProtocolServicesResult, type ProvisionWalletResult, type RefreshBalanceResult, type RegisterExternalCardInput, type RollbackPolicyVersionResponse, type RuleAction, type RuleOperator, type RuleType, type RunGuardedCheckoutResult, type SdkKey, type SdkKeyType, type StripeLinkCheckoutReadiness, type StripeLinkCheckoutReadinessResult, type StripeLinkCheckoutReadinessStatus, type StripeLinkCheckoutVerification, type StripeLinkPaymentMethod, type UnfreezeAgentInput, type UpdateAgentInput, type UpdateExternalCardAssignmentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type VerifiedBrowserCheckoutTarget, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, type X402Authorization, type X402BudgetResult, type X402PayInput, type X402PayResult, type X402PaymentRequirements, type X402PreAuthorizeInput, type X402PreAuthorizeResult, type X402RecordInput, type X402RecordResult, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget };
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var require_package = __commonJS({
|
|
|
39
39
|
"package.json"(exports2, module2) {
|
|
40
40
|
module2.exports = {
|
|
41
41
|
name: "@conto_finance/sdk",
|
|
42
|
-
version: "0.
|
|
42
|
+
version: "0.5.0",
|
|
43
43
|
description: "Conto SDK for AI agent payment authorization",
|
|
44
44
|
main: "./dist/index.js",
|
|
45
45
|
module: "./dist/index.mjs",
|
|
@@ -1880,15 +1880,6 @@ var PaymentsClient = class {
|
|
|
1880
1880
|
retryGuidance: "Wait for approval, then execute the same request ID."
|
|
1881
1881
|
});
|
|
1882
1882
|
}
|
|
1883
|
-
if (request.status === "ACTION_REQUIRED") {
|
|
1884
|
-
throw new ContoError("Payment requires an additional action", {
|
|
1885
|
-
code: "ACTION_REQUIRED",
|
|
1886
|
-
status: 402,
|
|
1887
|
-
requestId: request.requestId,
|
|
1888
|
-
actionUrl: request.actionUrl,
|
|
1889
|
-
retryGuidance: request.actionUrl ? `Complete the required action at ${request.actionUrl}, then check the payment status.` : "Complete the required action, then check the payment status."
|
|
1890
|
-
});
|
|
1891
|
-
}
|
|
1892
1883
|
if (request.status === "PROCESSING") {
|
|
1893
1884
|
throw new ContoError("Payment is processing", {
|
|
1894
1885
|
code: "PAYMENT_PROCESSING",
|
|
@@ -1912,6 +1903,22 @@ var X402Client = class {
|
|
|
1912
1903
|
{ idempotent: true }
|
|
1913
1904
|
);
|
|
1914
1905
|
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Conto-signed x402 for Privy-managed EVM wallets. Conto evaluates the
|
|
1908
|
+
* payment exactly like preAuthorize() and, only when approved, signs the
|
|
1909
|
+
* EIP-3009 authorization for the approved payee and amount. Retry the
|
|
1910
|
+
* resource request with `paymentHeaderName: xPaymentHeader`, then call
|
|
1911
|
+
* record() with the returned grant. Not retried automatically: a grant is
|
|
1912
|
+
* signed at most once, and a repeat returns 409 GRANT_ALREADY_SIGNED.
|
|
1913
|
+
* External wallets get 409 MANAGED_SIGNING_UNAVAILABLE; use preAuthorize().
|
|
1914
|
+
*/
|
|
1915
|
+
async pay(input) {
|
|
1916
|
+
return this.client.request(
|
|
1917
|
+
"POST",
|
|
1918
|
+
"/api/sdk/x402/pay",
|
|
1919
|
+
input
|
|
1920
|
+
);
|
|
1921
|
+
}
|
|
1915
1922
|
async record(input) {
|
|
1916
1923
|
const paymentId = requireFinancialIdentifier(input.paymentId, "paymentId");
|
|
1917
1924
|
const requestInput = {
|
package/dist/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ var require_package = __commonJS({
|
|
|
14
14
|
"package.json"(exports, module) {
|
|
15
15
|
module.exports = {
|
|
16
16
|
name: "@conto_finance/sdk",
|
|
17
|
-
version: "0.
|
|
17
|
+
version: "0.5.0",
|
|
18
18
|
description: "Conto SDK for AI agent payment authorization",
|
|
19
19
|
main: "./dist/index.js",
|
|
20
20
|
module: "./dist/index.mjs",
|
|
@@ -1719,15 +1719,6 @@ var PaymentsClient = class {
|
|
|
1719
1719
|
retryGuidance: "Wait for approval, then execute the same request ID."
|
|
1720
1720
|
});
|
|
1721
1721
|
}
|
|
1722
|
-
if (request.status === "ACTION_REQUIRED") {
|
|
1723
|
-
throw new ContoError("Payment requires an additional action", {
|
|
1724
|
-
code: "ACTION_REQUIRED",
|
|
1725
|
-
status: 402,
|
|
1726
|
-
requestId: request.requestId,
|
|
1727
|
-
actionUrl: request.actionUrl,
|
|
1728
|
-
retryGuidance: request.actionUrl ? `Complete the required action at ${request.actionUrl}, then check the payment status.` : "Complete the required action, then check the payment status."
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
1722
|
if (request.status === "PROCESSING") {
|
|
1732
1723
|
throw new ContoError("Payment is processing", {
|
|
1733
1724
|
code: "PAYMENT_PROCESSING",
|
|
@@ -1751,6 +1742,22 @@ var X402Client = class {
|
|
|
1751
1742
|
{ idempotent: true }
|
|
1752
1743
|
);
|
|
1753
1744
|
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Conto-signed x402 for Privy-managed EVM wallets. Conto evaluates the
|
|
1747
|
+
* payment exactly like preAuthorize() and, only when approved, signs the
|
|
1748
|
+
* EIP-3009 authorization for the approved payee and amount. Retry the
|
|
1749
|
+
* resource request with `paymentHeaderName: xPaymentHeader`, then call
|
|
1750
|
+
* record() with the returned grant. Not retried automatically: a grant is
|
|
1751
|
+
* signed at most once, and a repeat returns 409 GRANT_ALREADY_SIGNED.
|
|
1752
|
+
* External wallets get 409 MANAGED_SIGNING_UNAVAILABLE; use preAuthorize().
|
|
1753
|
+
*/
|
|
1754
|
+
async pay(input) {
|
|
1755
|
+
return this.client.request(
|
|
1756
|
+
"POST",
|
|
1757
|
+
"/api/sdk/x402/pay",
|
|
1758
|
+
input
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1754
1761
|
async record(input) {
|
|
1755
1762
|
const paymentId = requireFinancialIdentifier(input.paymentId, "paymentId");
|
|
1756
1763
|
const requestInput = {
|