@conto_finance/sdk 0.5.2 → 0.5.4

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Conto is a buyer-side control layer. Integrate it in the agent owner's runtime or payment tools;
4
4
  the owner or budget holder sets policy before the agent pays.
5
- See [buyer-side control](https://conto.finance/docs/guides/buyer-side-control) for the authorization
5
+ See [buyer-side control](https://conto.finance/docs/introduction/concepts) for the authorization
6
6
  and execution boundary.
7
7
 
8
8
  TypeScript SDK for Conto. Use it when you control the agent runtime and want typed access to
@@ -69,6 +69,7 @@ interface BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig {
69
69
  maxSessions?: number;
70
70
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
71
71
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
72
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
72
73
  /** Dedicated service credential. Conto and Browserbase API keys are rejected. */
73
74
  token: string;
74
75
  maxBodyBytes?: number;
@@ -69,6 +69,7 @@ interface BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig {
69
69
  maxSessions?: number;
70
70
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
71
71
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
72
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
72
73
  /** Dedicated service credential. Conto and Browserbase API keys are rejected. */
73
74
  token: string;
74
75
  maxBodyBytes?: number;
@@ -585,6 +585,12 @@ function createGuardedPlaywrightCheckoutRuntime(config) {
585
585
  "dispatchAttemptId",
586
586
  255
587
587
  );
588
+ if (config.claimDispatchAttempt && !await config.claimDispatchAttempt(dispatchAttemptId)) {
589
+ throw Object.assign(
590
+ new Error("This dispatch attempt has already started. Reconcile before another action."),
591
+ { code: "CONFLICT", status: 409 }
592
+ );
593
+ }
588
594
  return config.conto.runGuardedCheckoutWithDriver(input, {
589
595
  dispatchAttemptId,
590
596
  driver: adapter.driver
@@ -919,6 +925,7 @@ function createGuardedPlaywrightCheckoutRuntimeHost(config) {
919
925
  pageForSession: browserSessions.pageForSession,
920
926
  targetStore,
921
927
  dispatchAttemptFor: config.dispatchAttemptFor,
928
+ claimDispatchAttempt: config.claimDispatchAttempt,
922
929
  clickTimeoutMs: config.clickTimeoutMs,
923
930
  popupTimeoutMs: config.popupTimeoutMs,
924
931
  targetTtlMs: config.targetTtlMs,
@@ -1242,7 +1249,7 @@ function safeRuntimeError(error) {
1242
1249
  return httpJson(error.status, { code: error.code });
1243
1250
  }
1244
1251
  const record = error && typeof error === "object" ? error : void 0;
1245
- const candidateCode = record?.code;
1252
+ const candidateCode = record?.code === "POLICY_VIOLATION" ? "POLICY_DENIED" : record?.code === "APPROVAL_REQUIRED" ? "REQUIRES_APPROVAL" : record?.code;
1246
1253
  const code = typeof candidateCode === "string" && SAFE_RUNTIME_ERROR_CODES.has(candidateCode) ? candidateCode : "SERVER_ERROR";
1247
1254
  let status = typeof record?.status === "number" ? record.status : code.startsWith("BROWSER_") ? 409 : 500;
1248
1255
  if (!Number.isInteger(status) || status < 400 || status > 599) status = 409;
@@ -1928,6 +1935,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
1928
1935
  },
1929
1936
  targetStore: config.targetStore,
1930
1937
  dispatchAttemptFor: config.dispatchAttemptFor,
1938
+ claimDispatchAttempt: config.claimDispatchAttempt,
1931
1939
  token: config.token,
1932
1940
  maxBodyBytes: config.maxBodyBytes,
1933
1941
  clickTimeoutMs: config.clickTimeoutMs,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createGuardedPlaywrightCheckoutRuntimeHost
3
- } from "./chunk-HM4EG5MH.mjs";
3
+ } from "./chunk-VSIO6PYA.mjs";
4
4
  import "./chunk-O5RAAB2U.mjs";
5
- import "./chunk-B7F5QLE5.mjs";
5
+ import "./chunk-WSIKPUZJ.mjs";
6
6
 
7
7
  // src/browserbase.ts
8
8
  import { createHmac, timingSafeEqual } from "crypto";
@@ -551,6 +551,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
551
551
  },
552
552
  targetStore: config.targetStore,
553
553
  dispatchAttemptFor: config.dispatchAttemptFor,
554
+ claimDispatchAttempt: config.claimDispatchAttempt,
554
555
  token: config.token,
555
556
  maxBodyBytes: config.maxBodyBytes,
556
557
  clickTimeoutMs: config.clickTimeoutMs,
@@ -1,4 +1,4 @@
1
- import "./chunk-B7F5QLE5.mjs";
1
+ import "./chunk-WSIKPUZJ.mjs";
2
2
 
3
3
  // src/checkout-verifier.ts
4
4
  import { createHash, randomUUID } from "crypto";
@@ -447,6 +447,12 @@ function createGuardedPlaywrightCheckoutRuntime(config) {
447
447
  "dispatchAttemptId",
448
448
  255
449
449
  );
450
+ if (config.claimDispatchAttempt && !await config.claimDispatchAttempt(dispatchAttemptId)) {
451
+ throw Object.assign(
452
+ new Error("This dispatch attempt has already started. Reconcile before another action."),
453
+ { code: "CONFLICT", status: 409 }
454
+ );
455
+ }
450
456
  return config.conto.runGuardedCheckoutWithDriver(input, {
451
457
  dispatchAttemptId,
452
458
  driver: adapter.driver
@@ -781,6 +787,7 @@ function createGuardedPlaywrightCheckoutRuntimeHost(config) {
781
787
  pageForSession: browserSessions.pageForSession,
782
788
  targetStore,
783
789
  dispatchAttemptFor: config.dispatchAttemptFor,
790
+ claimDispatchAttempt: config.claimDispatchAttempt,
784
791
  clickTimeoutMs: config.clickTimeoutMs,
785
792
  popupTimeoutMs: config.popupTimeoutMs,
786
793
  targetTtlMs: config.targetTtlMs,
@@ -1104,7 +1111,7 @@ function safeRuntimeError(error) {
1104
1111
  return httpJson(error.status, { code: error.code });
1105
1112
  }
1106
1113
  const record = error && typeof error === "object" ? error : void 0;
1107
- const candidateCode = record?.code;
1114
+ const candidateCode = record?.code === "POLICY_VIOLATION" ? "POLICY_DENIED" : record?.code === "APPROVAL_REQUIRED" ? "REQUIRES_APPROVAL" : record?.code;
1108
1115
  const code = typeof candidateCode === "string" && SAFE_RUNTIME_ERROR_CODES.has(candidateCode) ? candidateCode : "SERVER_ERROR";
1109
1116
  let status = typeof record?.status === "number" ? record.status : code.startsWith("BROWSER_") ? 409 : 500;
1110
1117
  if (!Number.isInteger(status) || status < 400 || status > 599) status = 409;
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
7
10
  var __commonJS = (cb, mod) => function __require() {
8
11
  try {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -27,8 +30,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
31
  mod
29
32
  ));
33
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
34
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
35
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
36
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
30
37
 
31
38
  export {
32
39
  __commonJS,
33
- __toESM
40
+ __toESM,
41
+ __privateGet,
42
+ __privateAdd,
43
+ __privateSet
34
44
  };
package/dist/index.d.mts CHANGED
@@ -673,7 +673,7 @@ interface StripeLinkCheckoutReadinessResult {
673
673
  readonly readiness: StripeLinkCheckoutReadiness;
674
674
  }
675
675
  declare class ContoAdmin {
676
- private orgApiKey;
676
+ #private;
677
677
  private baseUrl;
678
678
  private timeout;
679
679
  agents: AgentsClient;
@@ -1486,6 +1486,90 @@ interface ConnectedCardListResult {
1486
1486
  /** Masked drawable cards and their active mandates. No PAN or provider token. */
1487
1487
  cards: ConnectedCardDrawable[];
1488
1488
  }
1489
+ /**
1490
+ * The opaque single-use token a test-card draw returns once. Not card data, and
1491
+ * accepted only by {@link TestCardsClient.checkout}. Handle it the way you would
1492
+ * a live credential: keep it out of logs, errors, and model context.
1493
+ */
1494
+ interface TestCardCredential {
1495
+ token: string;
1496
+ format: 'test_token';
1497
+ }
1498
+ interface TestCardDrawResult {
1499
+ environment: 'test';
1500
+ requestId: string;
1501
+ minted: boolean;
1502
+ replayed: boolean;
1503
+ decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
1504
+ reasons: string[];
1505
+ reconciliationRequired?: boolean;
1506
+ /** Present only on the response that issues it. A replay never returns it again. */
1507
+ testCredential?: TestCardCredential;
1508
+ credentialExpiresAt?: string;
1509
+ notice?: string;
1510
+ }
1511
+ interface TestMerchantProduct {
1512
+ sku: string;
1513
+ name: string;
1514
+ unitAmountMinor: number;
1515
+ }
1516
+ interface TestMerchant {
1517
+ key: string;
1518
+ name: string;
1519
+ categoryCode: string;
1520
+ countryCode: string;
1521
+ products: TestMerchantProduct[];
1522
+ }
1523
+ interface TestCardDrawable extends ConnectedCardDrawable {
1524
+ environment: 'test';
1525
+ label: string;
1526
+ }
1527
+ interface TestCardListResult {
1528
+ environment: 'test';
1529
+ cards: TestCardDrawable[];
1530
+ merchants: TestMerchant[];
1531
+ }
1532
+ interface TestCheckoutInput {
1533
+ requestId: string;
1534
+ /** The `testCredential.token` from the draw. */
1535
+ credential: string;
1536
+ /** Items from the test merchant's catalog. Omit to buy one line for the authorized amount. */
1537
+ items?: Array<{
1538
+ sku: string;
1539
+ quantity: number;
1540
+ }>;
1541
+ }
1542
+ interface TestCardReceipt {
1543
+ environment: 'test';
1544
+ simulated: true;
1545
+ settlementMode: 'test';
1546
+ notice: string;
1547
+ orderId: string;
1548
+ orderNumber: string;
1549
+ requestId: string;
1550
+ transactionId: string;
1551
+ agentId: string;
1552
+ cardId: string;
1553
+ merchant: {
1554
+ key: string;
1555
+ name: string;
1556
+ };
1557
+ items: Array<{
1558
+ sku: string;
1559
+ name: string;
1560
+ quantity: number;
1561
+ unitAmountMinor: number;
1562
+ amountMinor: number;
1563
+ }>;
1564
+ amountMinor: number;
1565
+ currency: string;
1566
+ createdAt: string;
1567
+ }
1568
+ interface TestCheckoutResult extends TestCardReceipt {
1569
+ /** True when this credential already completed this checkout. Nothing new was recorded. */
1570
+ replayed: boolean;
1571
+ status: 'COMPLETED';
1572
+ }
1489
1573
  interface StripeLinkPaymentMethod {
1490
1574
  id: string;
1491
1575
  type: string;
@@ -2023,6 +2107,12 @@ interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
2023
2107
  };
2024
2108
  }
2025
2109
  interface MppRecordInput extends ProtocolRecordGrant {
2110
+ /**
2111
+ * Amount the service charged. Must be positive, except `0` on a session's
2112
+ * closing record (`closeSession: true`) when the session charged nothing
2113
+ * more. That close needs `grantId` and `grantSignature` and takes no
2114
+ * `txHash`, `paymentReceipt`, or `batchItems`.
2115
+ */
2026
2116
  amount: number;
2027
2117
  currency?: string;
2028
2118
  recipientAddress: string;
@@ -2047,12 +2137,21 @@ interface MppRecordInput extends ProtocolRecordGrant {
2047
2137
  resourceUrl: string;
2048
2138
  credentialId: string;
2049
2139
  }>;
2140
+ /**
2141
+ * Send true on the final record of a session (`intent: 'session'`). Conto
2142
+ * closes the session and releases the unused part of its grant. Send it
2143
+ * with `amount: 0` when the session has nothing more to charge. Repeating
2144
+ * that close returns the same result.
2145
+ */
2146
+ closeSession?: boolean;
2050
2147
  }
2051
2148
  interface MppRecordResult extends ProtocolRecordGrantResult {
2052
2149
  recorded: true;
2053
2150
  txHash?: string;
2054
2151
  explorerUrl?: string;
2055
2152
  sessionId?: string;
2153
+ /** True when a record with `amount: 0` closed the session. No transaction was recorded. */
2154
+ sessionClosed?: true;
2056
2155
  }
2057
2156
  interface ProtocolBudgetResult {
2058
2157
  spend: {
@@ -2157,12 +2256,13 @@ interface ContoRequestOptions {
2157
2256
  maxRetries?: number;
2158
2257
  }
2159
2258
  declare class Conto {
2160
- private apiKey;
2259
+ #private;
2161
2260
  private baseUrl;
2162
2261
  private timeout;
2163
2262
  payments: PaymentsClient;
2164
2263
  cards: CardsClient;
2165
2264
  connectedCards: ConnectedCardsClient;
2265
+ testCards: TestCardsClient;
2166
2266
  x402: X402Client;
2167
2267
  mpp: MppClient;
2168
2268
  constructor(config: ContoConfig);
@@ -2340,6 +2440,37 @@ declare class ConnectedCardsClient {
2340
2440
  }>;
2341
2441
  list(): Promise<ConnectedCardListResult>;
2342
2442
  }
2443
+ /**
2444
+ * Test cards: try card controls with simulated purchases. See the section
2445
+ * comment above {@link TestCardCredential}.
2446
+ */
2447
+ declare class TestCardsClient {
2448
+ private client;
2449
+ constructor(client: Conto);
2450
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
2451
+ list(): Promise<TestCardListResult>;
2452
+ /**
2453
+ * Request a single-use test credential. Same rules as
2454
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
2455
+ * no automatic transport retry, and after a human approves a review, resend
2456
+ * the identical request with the same key.
2457
+ */
2458
+ draw(input: ConnectedCardDrawInput): Promise<TestCardDrawResult>;
2459
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
2460
+ acknowledgeDelivery(requestId: string): Promise<{
2461
+ environment: 'test';
2462
+ acknowledged: boolean;
2463
+ settlementVerified: false;
2464
+ }>;
2465
+ /**
2466
+ * Complete a simulated purchase at the Conto test merchant with the test
2467
+ * credential. Retrying with the same draw and credential returns the same
2468
+ * receipt with `replayed: true`, so this call is safe to retry.
2469
+ */
2470
+ checkout(input: TestCheckoutInput): Promise<TestCheckoutResult>;
2471
+ /** Read back one of this agent's simulated receipts. */
2472
+ receipt(orderId: string): Promise<TestCardReceipt>;
2473
+ }
2343
2474
  /** Client for payment operations */
2344
2475
  declare class PaymentsClient {
2345
2476
  private client;
@@ -2477,4 +2608,4 @@ declare class MppClient {
2477
2608
  }): Promise<ProtocolServicesResult>;
2478
2609
  }
2479
2610
 
2480
- 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 };
2611
+ 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 TestCardCredential, type TestCardDrawResult, type TestCardDrawable, type TestCardListResult, type TestCardReceipt, TestCardsClient, type TestCheckoutInput, type TestCheckoutResult, type TestMerchant, type TestMerchantProduct, 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
@@ -673,7 +673,7 @@ interface StripeLinkCheckoutReadinessResult {
673
673
  readonly readiness: StripeLinkCheckoutReadiness;
674
674
  }
675
675
  declare class ContoAdmin {
676
- private orgApiKey;
676
+ #private;
677
677
  private baseUrl;
678
678
  private timeout;
679
679
  agents: AgentsClient;
@@ -1486,6 +1486,90 @@ interface ConnectedCardListResult {
1486
1486
  /** Masked drawable cards and their active mandates. No PAN or provider token. */
1487
1487
  cards: ConnectedCardDrawable[];
1488
1488
  }
1489
+ /**
1490
+ * The opaque single-use token a test-card draw returns once. Not card data, and
1491
+ * accepted only by {@link TestCardsClient.checkout}. Handle it the way you would
1492
+ * a live credential: keep it out of logs, errors, and model context.
1493
+ */
1494
+ interface TestCardCredential {
1495
+ token: string;
1496
+ format: 'test_token';
1497
+ }
1498
+ interface TestCardDrawResult {
1499
+ environment: 'test';
1500
+ requestId: string;
1501
+ minted: boolean;
1502
+ replayed: boolean;
1503
+ decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
1504
+ reasons: string[];
1505
+ reconciliationRequired?: boolean;
1506
+ /** Present only on the response that issues it. A replay never returns it again. */
1507
+ testCredential?: TestCardCredential;
1508
+ credentialExpiresAt?: string;
1509
+ notice?: string;
1510
+ }
1511
+ interface TestMerchantProduct {
1512
+ sku: string;
1513
+ name: string;
1514
+ unitAmountMinor: number;
1515
+ }
1516
+ interface TestMerchant {
1517
+ key: string;
1518
+ name: string;
1519
+ categoryCode: string;
1520
+ countryCode: string;
1521
+ products: TestMerchantProduct[];
1522
+ }
1523
+ interface TestCardDrawable extends ConnectedCardDrawable {
1524
+ environment: 'test';
1525
+ label: string;
1526
+ }
1527
+ interface TestCardListResult {
1528
+ environment: 'test';
1529
+ cards: TestCardDrawable[];
1530
+ merchants: TestMerchant[];
1531
+ }
1532
+ interface TestCheckoutInput {
1533
+ requestId: string;
1534
+ /** The `testCredential.token` from the draw. */
1535
+ credential: string;
1536
+ /** Items from the test merchant's catalog. Omit to buy one line for the authorized amount. */
1537
+ items?: Array<{
1538
+ sku: string;
1539
+ quantity: number;
1540
+ }>;
1541
+ }
1542
+ interface TestCardReceipt {
1543
+ environment: 'test';
1544
+ simulated: true;
1545
+ settlementMode: 'test';
1546
+ notice: string;
1547
+ orderId: string;
1548
+ orderNumber: string;
1549
+ requestId: string;
1550
+ transactionId: string;
1551
+ agentId: string;
1552
+ cardId: string;
1553
+ merchant: {
1554
+ key: string;
1555
+ name: string;
1556
+ };
1557
+ items: Array<{
1558
+ sku: string;
1559
+ name: string;
1560
+ quantity: number;
1561
+ unitAmountMinor: number;
1562
+ amountMinor: number;
1563
+ }>;
1564
+ amountMinor: number;
1565
+ currency: string;
1566
+ createdAt: string;
1567
+ }
1568
+ interface TestCheckoutResult extends TestCardReceipt {
1569
+ /** True when this credential already completed this checkout. Nothing new was recorded. */
1570
+ replayed: boolean;
1571
+ status: 'COMPLETED';
1572
+ }
1489
1573
  interface StripeLinkPaymentMethod {
1490
1574
  id: string;
1491
1575
  type: string;
@@ -2023,6 +2107,12 @@ interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
2023
2107
  };
2024
2108
  }
2025
2109
  interface MppRecordInput extends ProtocolRecordGrant {
2110
+ /**
2111
+ * Amount the service charged. Must be positive, except `0` on a session's
2112
+ * closing record (`closeSession: true`) when the session charged nothing
2113
+ * more. That close needs `grantId` and `grantSignature` and takes no
2114
+ * `txHash`, `paymentReceipt`, or `batchItems`.
2115
+ */
2026
2116
  amount: number;
2027
2117
  currency?: string;
2028
2118
  recipientAddress: string;
@@ -2047,12 +2137,21 @@ interface MppRecordInput extends ProtocolRecordGrant {
2047
2137
  resourceUrl: string;
2048
2138
  credentialId: string;
2049
2139
  }>;
2140
+ /**
2141
+ * Send true on the final record of a session (`intent: 'session'`). Conto
2142
+ * closes the session and releases the unused part of its grant. Send it
2143
+ * with `amount: 0` when the session has nothing more to charge. Repeating
2144
+ * that close returns the same result.
2145
+ */
2146
+ closeSession?: boolean;
2050
2147
  }
2051
2148
  interface MppRecordResult extends ProtocolRecordGrantResult {
2052
2149
  recorded: true;
2053
2150
  txHash?: string;
2054
2151
  explorerUrl?: string;
2055
2152
  sessionId?: string;
2153
+ /** True when a record with `amount: 0` closed the session. No transaction was recorded. */
2154
+ sessionClosed?: true;
2056
2155
  }
2057
2156
  interface ProtocolBudgetResult {
2058
2157
  spend: {
@@ -2157,12 +2256,13 @@ interface ContoRequestOptions {
2157
2256
  maxRetries?: number;
2158
2257
  }
2159
2258
  declare class Conto {
2160
- private apiKey;
2259
+ #private;
2161
2260
  private baseUrl;
2162
2261
  private timeout;
2163
2262
  payments: PaymentsClient;
2164
2263
  cards: CardsClient;
2165
2264
  connectedCards: ConnectedCardsClient;
2265
+ testCards: TestCardsClient;
2166
2266
  x402: X402Client;
2167
2267
  mpp: MppClient;
2168
2268
  constructor(config: ContoConfig);
@@ -2340,6 +2440,37 @@ declare class ConnectedCardsClient {
2340
2440
  }>;
2341
2441
  list(): Promise<ConnectedCardListResult>;
2342
2442
  }
2443
+ /**
2444
+ * Test cards: try card controls with simulated purchases. See the section
2445
+ * comment above {@link TestCardCredential}.
2446
+ */
2447
+ declare class TestCardsClient {
2448
+ private client;
2449
+ constructor(client: Conto);
2450
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
2451
+ list(): Promise<TestCardListResult>;
2452
+ /**
2453
+ * Request a single-use test credential. Same rules as
2454
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
2455
+ * no automatic transport retry, and after a human approves a review, resend
2456
+ * the identical request with the same key.
2457
+ */
2458
+ draw(input: ConnectedCardDrawInput): Promise<TestCardDrawResult>;
2459
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
2460
+ acknowledgeDelivery(requestId: string): Promise<{
2461
+ environment: 'test';
2462
+ acknowledged: boolean;
2463
+ settlementVerified: false;
2464
+ }>;
2465
+ /**
2466
+ * Complete a simulated purchase at the Conto test merchant with the test
2467
+ * credential. Retrying with the same draw and credential returns the same
2468
+ * receipt with `replayed: true`, so this call is safe to retry.
2469
+ */
2470
+ checkout(input: TestCheckoutInput): Promise<TestCheckoutResult>;
2471
+ /** Read back one of this agent's simulated receipts. */
2472
+ receipt(orderId: string): Promise<TestCardReceipt>;
2473
+ }
2343
2474
  /** Client for payment operations */
2344
2475
  declare class PaymentsClient {
2345
2476
  private client;
@@ -2477,4 +2608,4 @@ declare class MppClient {
2477
2608
  }): Promise<ProtocolServicesResult>;
2478
2609
  }
2479
2610
 
2480
- 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 };
2611
+ 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 TestCardCredential, type TestCardDrawResult, type TestCardDrawable, type TestCardListResult, type TestCardReceipt, TestCardsClient, type TestCheckoutInput, type TestCheckoutResult, type TestMerchant, type TestMerchantProduct, 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
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  try {
10
13
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -33,13 +36,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
36
  mod
34
37
  ));
35
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
40
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
41
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
42
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
43
 
37
44
  // package.json
38
45
  var require_package = __commonJS({
39
46
  "package.json"(exports2, module2) {
40
47
  module2.exports = {
41
48
  name: "@conto_finance/sdk",
42
- version: "0.5.2",
49
+ version: "0.5.4",
43
50
  description: "Conto SDK for AI agent payment authorization",
44
51
  main: "./dist/index.js",
45
52
  module: "./dist/index.mjs",
@@ -154,6 +161,7 @@ __export(index_exports, {
154
161
  ControlledExternalCardPaymentTool: () => ControlledExternalCardPaymentTool,
155
162
  ExternalCardConfirmationPendingError: () => ExternalCardConfirmationPendingError,
156
163
  Giro: () => Conto,
164
+ TestCardsClient: () => TestCardsClient,
157
165
  canonicalizeBrowserCheckoutTarget: () => canonicalizeBrowserCheckoutTarget,
158
166
  createVerifiedBrowserCheckoutDriver: () => createVerifiedBrowserCheckoutDriver,
159
167
  default: () => index_default,
@@ -175,7 +183,15 @@ var PUBLIC_PAYMENT_REASONS = /* @__PURE__ */ new Set([
175
183
  "This payment requires approval before it can proceed.",
176
184
  "No usable wallet is linked to this agent.",
177
185
  "This payee needs review before payments to it can proceed automatically.",
178
- "A reviewer declined this payment."
186
+ "A reviewer declined this payment.",
187
+ "This payment is missing a category, which a payment control requires.",
188
+ "This payment is missing the recipient country, which a payment control requires.",
189
+ "This payment is missing the target contract address, which a payment control requires.",
190
+ "This payment is missing the service URL, which a payment control requires.",
191
+ "This payment is missing a session ID, which a payment control requires.",
192
+ "This payment is missing the x402 facilitator, which a payment control requires.",
193
+ "This payment is missing the MPP intent, which a payment control requires.",
194
+ "This payment is missing the MPP payment method, which a payment control requires."
179
195
  ]);
180
196
  function customerPaymentReasons(value) {
181
197
  return Array.isArray(value) ? [
@@ -503,8 +519,11 @@ var ContoAdminError = class extends Error {
503
519
  this.retryGuidance = metadata.retryGuidance;
504
520
  }
505
521
  };
522
+ var _orgApiKey;
506
523
  var ContoAdmin = class {
507
524
  constructor(config) {
525
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
526
+ __privateAdd(this, _orgApiKey);
508
527
  if (!config.orgApiKey) {
509
528
  throw new Error("Organization API key is required");
510
529
  }
@@ -518,7 +537,7 @@ var ContoAdmin = class {
518
537
  "Invalid API key format. Expected organization API key starting with conto_xxx..."
519
538
  );
520
539
  }
521
- this.orgApiKey = config.orgApiKey;
540
+ __privateSet(this, _orgApiKey, config.orgApiKey);
522
541
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
523
542
  assertSecureBaseUrl(this.baseUrl);
524
543
  this.timeout = config.timeout || 3e4;
@@ -542,7 +561,7 @@ var ContoAdmin = class {
542
561
  {
543
562
  method: normalizedMethod,
544
563
  headers: {
545
- Authorization: `Bearer ${this.orgApiKey}`,
564
+ Authorization: `Bearer ${__privateGet(this, _orgApiKey)}`,
546
565
  "Content-Type": "application/json",
547
566
  "User-Agent": `@conto_finance/sdk-admin/${import_package_version.SDK_PACKAGE_VERSION}`
548
567
  },
@@ -582,6 +601,7 @@ var ContoAdmin = class {
582
601
  }
583
602
  }
584
603
  };
604
+ _orgApiKey = new WeakMap();
585
605
  var PaymentRailsClient = class {
586
606
  constructor(client) {
587
607
  this.client = client;
@@ -1019,14 +1039,6 @@ var TeamClient = class {
1019
1039
  };
1020
1040
 
1021
1041
  // src/index.ts
1022
- if (process.env.SENTRY_DSN) {
1023
- Sentry2.init({
1024
- dsn: process.env.SENTRY_DSN,
1025
- environment: process.env.NODE_ENV || "production",
1026
- tracesSampleRate: 0.05,
1027
- enableLogs: true
1028
- });
1029
- }
1030
1042
  function isValidBrowserActionObservation(value) {
1031
1043
  if (!value || typeof value !== "object") return false;
1032
1044
  const observation = value;
@@ -1128,21 +1140,25 @@ function rethrowAmbiguousCommerceMutation(error, executionId, action) {
1128
1140
  }
1129
1141
  throw error;
1130
1142
  }
1143
+ var _apiKey;
1131
1144
  var Conto = class {
1132
1145
  constructor(config) {
1146
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
1147
+ __privateAdd(this, _apiKey);
1133
1148
  if (!config.apiKey) {
1134
1149
  throw new Error("API key is required");
1135
1150
  }
1136
1151
  if (!config.apiKey.startsWith("conto_agent_")) {
1137
1152
  throw new Error("Invalid API key format. Expected conto_agent_xxx...");
1138
1153
  }
1139
- this.apiKey = config.apiKey;
1154
+ __privateSet(this, _apiKey, config.apiKey);
1140
1155
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
1141
1156
  assertSecureBaseUrl(this.baseUrl);
1142
1157
  this.timeout = config.timeout || 3e4;
1143
1158
  this.payments = new PaymentsClient(this);
1144
1159
  this.cards = new CardsClient(this);
1145
1160
  this.connectedCards = new ConnectedCardsClient(this);
1161
+ this.testCards = new TestCardsClient(this);
1146
1162
  this.x402 = new X402Client(this);
1147
1163
  this.mpp = new MppClient(this);
1148
1164
  }
@@ -1434,7 +1450,7 @@ var Conto = class {
1434
1450
  {
1435
1451
  method: normalizedMethod,
1436
1452
  headers: {
1437
- Authorization: `Bearer ${this.apiKey}`,
1453
+ Authorization: `Bearer ${__privateGet(this, _apiKey)}`,
1438
1454
  "Content-Type": "application/json",
1439
1455
  "User-Agent": `@conto_finance/sdk/${import_package_version2.SDK_PACKAGE_VERSION}`
1440
1456
  },
@@ -1474,6 +1490,7 @@ var Conto = class {
1474
1490
  }
1475
1491
  }
1476
1492
  };
1493
+ _apiKey = new WeakMap();
1477
1494
  var CardsClient = class {
1478
1495
  constructor(client) {
1479
1496
  this.client = client;
@@ -1710,6 +1727,65 @@ var ConnectedCardsClient = class {
1710
1727
  return this.client.request("GET", "/api/sdk/connected-cards");
1711
1728
  }
1712
1729
  };
1730
+ var TestCardsClient = class {
1731
+ constructor(client) {
1732
+ this.client = client;
1733
+ }
1734
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
1735
+ async list() {
1736
+ return this.client.request("GET", "/api/sdk/connected-cards/test");
1737
+ }
1738
+ /**
1739
+ * Request a single-use test credential. Same rules as
1740
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
1741
+ * no automatic transport retry, and after a human approves a review, resend
1742
+ * the identical request with the same key.
1743
+ */
1744
+ async draw(input) {
1745
+ const idempotencyKey = input.idempotencyKey?.trim();
1746
+ if (!idempotencyKey || idempotencyKey.length < 8 || idempotencyKey.length > 128) {
1747
+ throw new ContoError("idempotencyKey must contain 8 to 128 characters", {
1748
+ code: "INVALID_IDEMPOTENCY_KEY",
1749
+ status: 0,
1750
+ retryGuidance: "Generate one stable identifier per purchase and reuse it only to resume the same purchase."
1751
+ });
1752
+ }
1753
+ return this.client.request("POST", "/api/sdk/connected-cards/test/draws", {
1754
+ ...input,
1755
+ idempotencyKey,
1756
+ currency: input.currency ?? "USD"
1757
+ });
1758
+ }
1759
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
1760
+ async acknowledgeDelivery(requestId) {
1761
+ return this.client.request(
1762
+ "POST",
1763
+ `/api/sdk/connected-cards/test/draws/${encodeURIComponent(requestId)}/acknowledge`,
1764
+ {},
1765
+ { idempotent: true }
1766
+ );
1767
+ }
1768
+ /**
1769
+ * Complete a simulated purchase at the Conto test merchant with the test
1770
+ * credential. Retrying with the same draw and credential returns the same
1771
+ * receipt with `replayed: true`, so this call is safe to retry.
1772
+ */
1773
+ async checkout(input) {
1774
+ return this.client.request(
1775
+ "POST",
1776
+ "/api/sdk/connected-cards/test/checkout",
1777
+ { ...input },
1778
+ { idempotent: true }
1779
+ );
1780
+ }
1781
+ /** Read back one of this agent's simulated receipts. */
1782
+ async receipt(orderId) {
1783
+ return this.client.request(
1784
+ "GET",
1785
+ `/api/sdk/connected-cards/test/orders/${encodeURIComponent(orderId)}`
1786
+ );
1787
+ }
1788
+ };
1713
1789
  function approvalRetryGuidance(requestId) {
1714
1790
  const id = JSON.stringify(requestId);
1715
1791
  return `An approver in Conto executes the payment when they approve it. After approval, call payments.execute(${id}) or payments.status(${id}) to get the receipt. Do not request the payment again.`;
@@ -2033,6 +2109,7 @@ var index_default = Conto;
2033
2109
  ControlledExternalCardPaymentTool,
2034
2110
  ExternalCardConfirmationPendingError,
2035
2111
  Giro,
2112
+ TestCardsClient,
2036
2113
  canonicalizeBrowserCheckoutTarget,
2037
2114
  createVerifiedBrowserCheckoutDriver,
2038
2115
  fingerprintBrowserCheckoutTarget
package/dist/index.mjs CHANGED
@@ -6,15 +6,18 @@ import {
6
6
  } from "./chunk-O5RAAB2U.mjs";
7
7
  import {
8
8
  __commonJS,
9
+ __privateAdd,
10
+ __privateGet,
11
+ __privateSet,
9
12
  __toESM
10
- } from "./chunk-B7F5QLE5.mjs";
13
+ } from "./chunk-WSIKPUZJ.mjs";
11
14
 
12
15
  // package.json
13
16
  var require_package = __commonJS({
14
17
  "package.json"(exports, module) {
15
18
  module.exports = {
16
19
  name: "@conto_finance/sdk",
17
- version: "0.5.2",
20
+ version: "0.5.4",
18
21
  description: "Conto SDK for AI agent payment authorization",
19
22
  main: "./dist/index.js",
20
23
  module: "./dist/index.mjs",
@@ -131,7 +134,15 @@ var PUBLIC_PAYMENT_REASONS = /* @__PURE__ */ new Set([
131
134
  "This payment requires approval before it can proceed.",
132
135
  "No usable wallet is linked to this agent.",
133
136
  "This payee needs review before payments to it can proceed automatically.",
134
- "A reviewer declined this payment."
137
+ "A reviewer declined this payment.",
138
+ "This payment is missing a category, which a payment control requires.",
139
+ "This payment is missing the recipient country, which a payment control requires.",
140
+ "This payment is missing the target contract address, which a payment control requires.",
141
+ "This payment is missing the service URL, which a payment control requires.",
142
+ "This payment is missing a session ID, which a payment control requires.",
143
+ "This payment is missing the x402 facilitator, which a payment control requires.",
144
+ "This payment is missing the MPP intent, which a payment control requires.",
145
+ "This payment is missing the MPP payment method, which a payment control requires."
135
146
  ]);
136
147
  function customerPaymentReasons(value) {
137
148
  return Array.isArray(value) ? [
@@ -342,8 +353,11 @@ var ContoAdminError = class extends Error {
342
353
  this.retryGuidance = metadata.retryGuidance;
343
354
  }
344
355
  };
356
+ var _orgApiKey;
345
357
  var ContoAdmin = class {
346
358
  constructor(config) {
359
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
360
+ __privateAdd(this, _orgApiKey);
347
361
  if (!config.orgApiKey) {
348
362
  throw new Error("Organization API key is required");
349
363
  }
@@ -357,7 +371,7 @@ var ContoAdmin = class {
357
371
  "Invalid API key format. Expected organization API key starting with conto_xxx..."
358
372
  );
359
373
  }
360
- this.orgApiKey = config.orgApiKey;
374
+ __privateSet(this, _orgApiKey, config.orgApiKey);
361
375
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
362
376
  assertSecureBaseUrl(this.baseUrl);
363
377
  this.timeout = config.timeout || 3e4;
@@ -381,7 +395,7 @@ var ContoAdmin = class {
381
395
  {
382
396
  method: normalizedMethod,
383
397
  headers: {
384
- Authorization: `Bearer ${this.orgApiKey}`,
398
+ Authorization: `Bearer ${__privateGet(this, _orgApiKey)}`,
385
399
  "Content-Type": "application/json",
386
400
  "User-Agent": `@conto_finance/sdk-admin/${import_package_version.SDK_PACKAGE_VERSION}`
387
401
  },
@@ -421,6 +435,7 @@ var ContoAdmin = class {
421
435
  }
422
436
  }
423
437
  };
438
+ _orgApiKey = new WeakMap();
424
439
  var PaymentRailsClient = class {
425
440
  constructor(client) {
426
441
  this.client = client;
@@ -858,14 +873,6 @@ var TeamClient = class {
858
873
  };
859
874
 
860
875
  // src/index.ts
861
- if (process.env.SENTRY_DSN) {
862
- Sentry2.init({
863
- dsn: process.env.SENTRY_DSN,
864
- environment: process.env.NODE_ENV || "production",
865
- tracesSampleRate: 0.05,
866
- enableLogs: true
867
- });
868
- }
869
876
  function isValidBrowserActionObservation(value) {
870
877
  if (!value || typeof value !== "object") return false;
871
878
  const observation = value;
@@ -967,21 +974,25 @@ function rethrowAmbiguousCommerceMutation(error, executionId, action) {
967
974
  }
968
975
  throw error;
969
976
  }
977
+ var _apiKey;
970
978
  var Conto = class {
971
979
  constructor(config) {
980
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
981
+ __privateAdd(this, _apiKey);
972
982
  if (!config.apiKey) {
973
983
  throw new Error("API key is required");
974
984
  }
975
985
  if (!config.apiKey.startsWith("conto_agent_")) {
976
986
  throw new Error("Invalid API key format. Expected conto_agent_xxx...");
977
987
  }
978
- this.apiKey = config.apiKey;
988
+ __privateSet(this, _apiKey, config.apiKey);
979
989
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
980
990
  assertSecureBaseUrl(this.baseUrl);
981
991
  this.timeout = config.timeout || 3e4;
982
992
  this.payments = new PaymentsClient(this);
983
993
  this.cards = new CardsClient(this);
984
994
  this.connectedCards = new ConnectedCardsClient(this);
995
+ this.testCards = new TestCardsClient(this);
985
996
  this.x402 = new X402Client(this);
986
997
  this.mpp = new MppClient(this);
987
998
  }
@@ -1273,7 +1284,7 @@ var Conto = class {
1273
1284
  {
1274
1285
  method: normalizedMethod,
1275
1286
  headers: {
1276
- Authorization: `Bearer ${this.apiKey}`,
1287
+ Authorization: `Bearer ${__privateGet(this, _apiKey)}`,
1277
1288
  "Content-Type": "application/json",
1278
1289
  "User-Agent": `@conto_finance/sdk/${import_package_version2.SDK_PACKAGE_VERSION}`
1279
1290
  },
@@ -1313,6 +1324,7 @@ var Conto = class {
1313
1324
  }
1314
1325
  }
1315
1326
  };
1327
+ _apiKey = new WeakMap();
1316
1328
  var CardsClient = class {
1317
1329
  constructor(client) {
1318
1330
  this.client = client;
@@ -1549,6 +1561,65 @@ var ConnectedCardsClient = class {
1549
1561
  return this.client.request("GET", "/api/sdk/connected-cards");
1550
1562
  }
1551
1563
  };
1564
+ var TestCardsClient = class {
1565
+ constructor(client) {
1566
+ this.client = client;
1567
+ }
1568
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
1569
+ async list() {
1570
+ return this.client.request("GET", "/api/sdk/connected-cards/test");
1571
+ }
1572
+ /**
1573
+ * Request a single-use test credential. Same rules as
1574
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
1575
+ * no automatic transport retry, and after a human approves a review, resend
1576
+ * the identical request with the same key.
1577
+ */
1578
+ async draw(input) {
1579
+ const idempotencyKey = input.idempotencyKey?.trim();
1580
+ if (!idempotencyKey || idempotencyKey.length < 8 || idempotencyKey.length > 128) {
1581
+ throw new ContoError("idempotencyKey must contain 8 to 128 characters", {
1582
+ code: "INVALID_IDEMPOTENCY_KEY",
1583
+ status: 0,
1584
+ retryGuidance: "Generate one stable identifier per purchase and reuse it only to resume the same purchase."
1585
+ });
1586
+ }
1587
+ return this.client.request("POST", "/api/sdk/connected-cards/test/draws", {
1588
+ ...input,
1589
+ idempotencyKey,
1590
+ currency: input.currency ?? "USD"
1591
+ });
1592
+ }
1593
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
1594
+ async acknowledgeDelivery(requestId) {
1595
+ return this.client.request(
1596
+ "POST",
1597
+ `/api/sdk/connected-cards/test/draws/${encodeURIComponent(requestId)}/acknowledge`,
1598
+ {},
1599
+ { idempotent: true }
1600
+ );
1601
+ }
1602
+ /**
1603
+ * Complete a simulated purchase at the Conto test merchant with the test
1604
+ * credential. Retrying with the same draw and credential returns the same
1605
+ * receipt with `replayed: true`, so this call is safe to retry.
1606
+ */
1607
+ async checkout(input) {
1608
+ return this.client.request(
1609
+ "POST",
1610
+ "/api/sdk/connected-cards/test/checkout",
1611
+ { ...input },
1612
+ { idempotent: true }
1613
+ );
1614
+ }
1615
+ /** Read back one of this agent's simulated receipts. */
1616
+ async receipt(orderId) {
1617
+ return this.client.request(
1618
+ "GET",
1619
+ `/api/sdk/connected-cards/test/orders/${encodeURIComponent(orderId)}`
1620
+ );
1621
+ }
1622
+ };
1552
1623
  function approvalRetryGuidance(requestId) {
1553
1624
  const id = JSON.stringify(requestId);
1554
1625
  return `An approver in Conto executes the payment when they approve it. After approval, call payments.execute(${id}) or payments.status(${id}) to get the receipt. Do not request the payment again.`;
@@ -1871,6 +1942,7 @@ export {
1871
1942
  ControlledExternalCardPaymentTool,
1872
1943
  ExternalCardConfirmationPendingError,
1873
1944
  Conto as Giro,
1945
+ TestCardsClient,
1874
1946
  canonicalizeBrowserCheckoutTarget,
1875
1947
  createVerifiedBrowserCheckoutDriver,
1876
1948
  index_default as default,
@@ -91,6 +91,8 @@ interface GuardedPlaywrightCheckoutRuntimeConfig extends PlaywrightCheckoutAdapt
91
91
  browserSessionId: string;
92
92
  targetFingerprint: string;
93
93
  }): Promise<string>;
94
+ /** Atomically starts an attempt once across runtime instances. Never release after a failure. */
95
+ claimDispatchAttempt?(dispatchAttemptId: string): Promise<boolean>;
94
96
  }
95
97
  /**
96
98
  * Safe façade to expose as the agent's checkout capability. It intentionally
@@ -191,6 +193,7 @@ interface GuardedPlaywrightCheckoutRuntimeHostConfig {
191
193
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
192
194
  /** Atomically loads or creates one stable attempt for the checkout intent. */
193
195
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
196
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
194
197
  /** Dedicated service credential. Conto API keys are rejected. */
195
198
  token: string;
196
199
  maxBodyBytes?: number;
@@ -91,6 +91,8 @@ interface GuardedPlaywrightCheckoutRuntimeConfig extends PlaywrightCheckoutAdapt
91
91
  browserSessionId: string;
92
92
  targetFingerprint: string;
93
93
  }): Promise<string>;
94
+ /** Atomically starts an attempt once across runtime instances. Never release after a failure. */
95
+ claimDispatchAttempt?(dispatchAttemptId: string): Promise<boolean>;
94
96
  }
95
97
  /**
96
98
  * Safe façade to expose as the agent's checkout capability. It intentionally
@@ -191,6 +193,7 @@ interface GuardedPlaywrightCheckoutRuntimeHostConfig {
191
193
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
192
194
  /** Atomically loads or creates one stable attempt for the checkout intent. */
193
195
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
196
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
194
197
  /** Dedicated service credential. Conto API keys are rejected. */
195
198
  token: string;
196
199
  maxBodyBytes?: number;
@@ -585,6 +585,12 @@ function createGuardedPlaywrightCheckoutRuntime(config) {
585
585
  "dispatchAttemptId",
586
586
  255
587
587
  );
588
+ if (config.claimDispatchAttempt && !await config.claimDispatchAttempt(dispatchAttemptId)) {
589
+ throw Object.assign(
590
+ new Error("This dispatch attempt has already started. Reconcile before another action."),
591
+ { code: "CONFLICT", status: 409 }
592
+ );
593
+ }
588
594
  return config.conto.runGuardedCheckoutWithDriver(input, {
589
595
  dispatchAttemptId,
590
596
  driver: adapter.driver
@@ -919,6 +925,7 @@ function createGuardedPlaywrightCheckoutRuntimeHost(config) {
919
925
  pageForSession: browserSessions.pageForSession,
920
926
  targetStore,
921
927
  dispatchAttemptFor: config.dispatchAttemptFor,
928
+ claimDispatchAttempt: config.claimDispatchAttempt,
922
929
  clickTimeoutMs: config.clickTimeoutMs,
923
930
  popupTimeoutMs: config.popupTimeoutMs,
924
931
  targetTtlMs: config.targetTtlMs,
@@ -1242,7 +1249,7 @@ function safeRuntimeError(error) {
1242
1249
  return httpJson(error.status, { code: error.code });
1243
1250
  }
1244
1251
  const record = error && typeof error === "object" ? error : void 0;
1245
- const candidateCode = record?.code;
1252
+ const candidateCode = record?.code === "POLICY_VIOLATION" ? "POLICY_DENIED" : record?.code === "APPROVAL_REQUIRED" ? "REQUIRES_APPROVAL" : record?.code;
1246
1253
  const code = typeof candidateCode === "string" && SAFE_RUNTIME_ERROR_CODES.has(candidateCode) ? candidateCode : "SERVER_ERROR";
1247
1254
  let status = typeof record?.status === "number" ? record.status : code.startsWith("BROWSER_") ? 409 : 500;
1248
1255
  if (!Number.isInteger(status) || status < 400 || status > 599) status = 409;
@@ -7,9 +7,9 @@ import {
7
7
  createPlaywrightCdpSessionRegistry,
8
8
  createPlaywrightCheckoutAdapter,
9
9
  createPlaywrightSessionObserver
10
- } from "./chunk-HM4EG5MH.mjs";
10
+ } from "./chunk-VSIO6PYA.mjs";
11
11
  import "./chunk-O5RAAB2U.mjs";
12
- import "./chunk-B7F5QLE5.mjs";
12
+ import "./chunk-WSIKPUZJ.mjs";
13
13
  export {
14
14
  createEncryptedPlaywrightCheckoutTargetStore,
15
15
  createGuardedPlaywrightCheckoutHttpHandler,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Conto SDK for AI agent payment authorization",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",