@conto_finance/sdk 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -839,6 +839,311 @@ declare function verifyPurchaseWebhook(input: {
839
839
  data: PurchaseEvent;
840
840
  };
841
841
 
842
+ /**
843
+ * Shared budgets: one limit that several agents draw on, set in Spending controls.
844
+ *
845
+ * `conto.spending` uses an agent key. `admin.spending` is for the budget holder and uses an
846
+ * organization API key. Exact amounts are decimal strings. These APIs never give agents authority
847
+ * to raise ceilings.
848
+ */
849
+ /**
850
+ * File bytes. `new Blob()`, `new File()` and `new Response()` accept them on every supported
851
+ * TypeScript, with or without the DOM lib.
852
+ */
853
+ type DownloadBytes = ReturnType<Uint8Array['slice']> & {
854
+ readonly buffer: ArrayBuffer;
855
+ };
856
+ type SpendingRequester = {
857
+ download(path: string): Promise<DownloadBytes>;
858
+ request<T>(method: string, path: string, body?: Record<string, unknown> | FormData): Promise<T>;
859
+ };
860
+ interface BudgetSnapshot {
861
+ id: string;
862
+ name: string;
863
+ scope: string;
864
+ currency: string;
865
+ period: 'ONCE' | 'MONTHLY';
866
+ periodStart: string;
867
+ periodEnd: string;
868
+ authorizationStartsAt?: string;
869
+ authorizationEndsAt?: string;
870
+ amount: string;
871
+ held: string;
872
+ settled: string;
873
+ refunded: string;
874
+ available: string;
875
+ status: string;
876
+ isActive: boolean;
877
+ version: number;
878
+ requiresTask: boolean;
879
+ taskRequestId: string | null;
880
+ participantIds?: string[];
881
+ }
882
+ interface TaskInput {
883
+ purpose: string;
884
+ amount: string;
885
+ currency: string;
886
+ expiresAt: string;
887
+ permittedMerchants?: string[];
888
+ permittedSourceIds?: string[];
889
+ }
890
+ interface TaskSnapshot {
891
+ id: string;
892
+ purpose: string;
893
+ status: string;
894
+ amount: string;
895
+ currency: string;
896
+ expiresAt: string;
897
+ budgetId: string | null;
898
+ agentId: string;
899
+ participantIds: string[];
900
+ permittedMerchants: string[];
901
+ permittedSourceIds: string[];
902
+ }
903
+ /** A purchase against shared budgets. These are separate from Commerce `conto.purchases`. */
904
+ interface PurchaseSnapshot {
905
+ id: string;
906
+ agentId: string;
907
+ executionReference: string;
908
+ sourceType: string;
909
+ sourceId: string;
910
+ merchant: string;
911
+ purpose: string;
912
+ currency: string;
913
+ authorizedAmount: string;
914
+ heldAmount: string;
915
+ settledAmount: string;
916
+ refundedAmount: string;
917
+ status: string;
918
+ enforcementMode: string;
919
+ verification: string;
920
+ nextActions: string[];
921
+ taskRequestId: string | null;
922
+ department: string | null;
923
+ project: string | null;
924
+ accountingCode: string | null;
925
+ createdAt: string;
926
+ }
927
+ interface PurchaseDetail extends PurchaseSnapshot {
928
+ events: Array<{
929
+ id: string;
930
+ kind: string;
931
+ createdAt: string;
932
+ evidenceRef: string;
933
+ heldAmount: string;
934
+ settledAmount: string;
935
+ refundedAmount: string;
936
+ }>;
937
+ evidence: Array<{
938
+ id: string;
939
+ filename: string;
940
+ matchStatus: string;
941
+ createdAt: string;
942
+ }>;
943
+ }
944
+ interface PreviewInput {
945
+ amount: string;
946
+ currency: string;
947
+ sourceId: string;
948
+ merchant: string;
949
+ purpose?: string;
950
+ taskRequestId?: string;
951
+ purchaseKey?: string;
952
+ }
953
+ interface BudgetInput {
954
+ name: string;
955
+ scope: 'WORKSPACE' | 'AGENT' | 'AGENTS';
956
+ participantIds?: string[];
957
+ amount: string;
958
+ currency: string;
959
+ period: 'ONCE' | 'MONTHLY';
960
+ periodStart: string;
961
+ periodEnd: string;
962
+ requiresTask?: boolean;
963
+ }
964
+ declare class SpendingClient {
965
+ private client;
966
+ constructor(client: SpendingRequester);
967
+ /**
968
+ * CSV of this agent's purchases against budgets in its own organization. Fails with `reasonCode`
969
+ * `EXPORT_TOO_LARGE` above 10,000 purchases.
970
+ */
971
+ exportPurchases(): Promise<DownloadBytes>;
972
+ downloadEvidence(purchaseId: string, evidenceId: string): Promise<DownloadBytes>;
973
+ /** The budgets that cover this agent, with what is held, settled and available. */
974
+ budgets(): Promise<{
975
+ snapshotAt: string;
976
+ timezone: string;
977
+ budgets: BudgetSnapshot[];
978
+ buyerConnection?: {
979
+ revoked: boolean;
980
+ participantId: string;
981
+ };
982
+ }>;
983
+ tasks(cursor?: string): Promise<{
984
+ tasks: TaskSnapshot[];
985
+ nextCursor: string | null;
986
+ }>;
987
+ /**
988
+ * Ask the budget holder to approve a task budget. Once it is approved, pass its id as
989
+ * `context.taskRequestId` on `payments.request()` from a managed wallet, or as `taskRequestId` on
990
+ * `connectedCards.draw()`. A task's budget applies only to a payment or draw that names the task,
991
+ * and it stops nothing on other paths.
992
+ */
993
+ requestTask(input: TaskInput): Promise<{
994
+ id: string;
995
+ status: string;
996
+ nextActions: string[];
997
+ }>;
998
+ /** This agent's purchases against budgets in its own organization. Empty when none has applied. */
999
+ purchases(cursor?: string): Promise<{
1000
+ purchases: PurchaseSnapshot[];
1001
+ nextCursor: string | null;
1002
+ }>;
1003
+ purchase(purchaseId: string): Promise<PurchaseDetail>;
1004
+ /**
1005
+ * Check a purchase against shared budgets before requesting the payment. It holds nothing and
1006
+ * approves nothing. `sourceId` must be a managed wallet linked to this agent, and `currency` must
1007
+ * be that wallet's stablecoin, such as `USDC` on Base, `USDC.e` on Tempo or `pathUSD` on Tempo
1008
+ * Testnet. A purchase the budgets would refuse throws a `ContoError`.
1009
+ */
1010
+ preview(input: PreviewInput): Promise<{
1011
+ budgetCheck: string;
1012
+ configured: boolean;
1013
+ authorizationGranted: false;
1014
+ scope: "SHARED_BUDGET_ONLY";
1015
+ snapshotAt: string;
1016
+ nextActions: string[];
1017
+ }>;
1018
+ /**
1019
+ * Attach a PDF, PNG or JPEG of at most 2 MiB, with up to 10 files per purchase. Set the Blob's
1020
+ * `type` to `application/pdf`, `image/png` or `image/jpeg`. A Blob with no type, or with a type
1021
+ * that does not match the file's first bytes, fails with `reasonCode` `INVALID_FILE`.
1022
+ */
1023
+ attachEvidence(purchaseId: string, file: Blob, filename: string): Promise<{
1024
+ id: string;
1025
+ matchStatus: string;
1026
+ }>;
1027
+ }
1028
+ declare class AdminSpendingClient {
1029
+ private client;
1030
+ constructor(client: SpendingRequester);
1031
+ /**
1032
+ * CSV of the organization's purchases against shared budgets. Fails with `reasonCode`
1033
+ * `EXPORT_TOO_LARGE` above 10,000 purchases.
1034
+ */
1035
+ exportPurchases(): Promise<DownloadBytes>;
1036
+ /**
1037
+ * Attach a PDF, PNG or JPEG of at most 2 MiB, with up to 10 files per purchase. Set the Blob's
1038
+ * `type` to `application/pdf`, `image/png` or `image/jpeg`. A Blob with no type, or with a type
1039
+ * that does not match the file's first bytes, fails with `reasonCode` `INVALID_FILE`.
1040
+ */
1041
+ attachEvidence(purchaseId: string, file: Blob, filename: string): Promise<{
1042
+ id: string;
1043
+ matchStatus: string;
1044
+ }>;
1045
+ downloadEvidence(purchaseId: string, evidenceId: string): Promise<DownloadBytes>;
1046
+ budgets(): Promise<{
1047
+ snapshotAt: string;
1048
+ timezone: string;
1049
+ budgets: BudgetSnapshot[];
1050
+ buyerConnection?: {
1051
+ revoked: boolean;
1052
+ participantId: string;
1053
+ };
1054
+ }>;
1055
+ /**
1056
+ * Create a shared budget. Needs an organization API key with `policies:write`.
1057
+ *
1058
+ * While a budget exists, it stops x402, MPP, external wallet payments, agent-to-agent payments,
1059
+ * payment grants, checkout relay, hosted Stripe Link, guarded browser checkout
1060
+ * (`runGuardedCheckout()`), card overlays and checkout checkpoints, including
1061
+ * `checkout.getLinkCard()`, for every agent it covers. A paused, expired or not yet started budget
1062
+ * still stops them. Until its start date, while paused, and after its end date, it also refuses
1063
+ * the managed wallet payments and connected card draws it covers, for those agents. A start date
1064
+ * cannot be changed.
1065
+ * `deleteBudget()` ends a budget. Fails with `reasonCode`
1066
+ * `ENROLLMENT_RECONCILIATION_REQUIRED` while the organization or a participating agent has an
1067
+ * open commitment.
1068
+ */
1069
+ createBudget(input: BudgetInput): Promise<{
1070
+ id: string;
1071
+ version: number;
1072
+ }>;
1073
+ /**
1074
+ * Change a budget's amount or active state, or move its end date to a later time in the future.
1075
+ * Needs the budget's current `version`. A task budget can only change its active state. Pausing
1076
+ * stops new purchases on it, and does not lift what it stops on other payment paths.
1077
+ */
1078
+ updateBudget(budgetId: string, input: {
1079
+ version: number;
1080
+ amount?: string;
1081
+ isActive?: boolean;
1082
+ periodEnd?: string;
1083
+ }): Promise<{
1084
+ id: string;
1085
+ version: number;
1086
+ }>;
1087
+ /**
1088
+ * End a budget, so it stops applying on every path. Needs the budget's current `version`. Fails
1089
+ * with `reasonCode` `BUDGET_HAS_HOLDS` while a purchase holds spend against it, and `TASK_BUDGET`
1090
+ * for a task's budget, which ends by closing the task. A linked buyer with no budget left fails
1091
+ * with `reasonCode` `LINKED_BUDGET_REQUIRED`.
1092
+ */
1093
+ deleteBudget(budgetId: string, input: {
1094
+ version: number;
1095
+ }): Promise<{
1096
+ id: string;
1097
+ deleted: true;
1098
+ }>;
1099
+ tasks(cursor?: string): Promise<{
1100
+ tasks: TaskSnapshot[];
1101
+ nextCursor: string | null;
1102
+ }>;
1103
+ /** Approve, reject or close a task. Needs an organization API key with `policies:write`. */
1104
+ decideTask(taskId: string, input: {
1105
+ decision: 'APPROVE' | 'REJECT' | 'CLOSE';
1106
+ amount?: string;
1107
+ participantIds?: string[];
1108
+ }): Promise<{
1109
+ id: string;
1110
+ status: string;
1111
+ }>;
1112
+ purchases(cursor?: string): Promise<{
1113
+ purchases: PurchaseSnapshot[];
1114
+ nextCursor: string | null;
1115
+ }>;
1116
+ purchase(purchaseId: string): Promise<PurchaseDetail>;
1117
+ /** Record what happened to a purchase. Needs an API key with the `spending:reconcile` scope. */
1118
+ reconcile(purchaseId: string, input: {
1119
+ eventKey: string;
1120
+ kind: 'RELEASED' | 'SETTLED' | 'REFUNDED' | 'UNKNOWN';
1121
+ settledAmount?: string;
1122
+ refundedAmount?: string;
1123
+ final?: boolean;
1124
+ evidenceRef: string;
1125
+ }): Promise<PurchaseSnapshot | null>;
1126
+ accounting(purchaseId: string, input: {
1127
+ department: string | null;
1128
+ project: string | null;
1129
+ accountingCode: string | null;
1130
+ }): Promise<{
1131
+ id: string;
1132
+ department: string | null;
1133
+ project: string | null;
1134
+ accountingCode: string | null;
1135
+ }>;
1136
+ /** Record the amount, currency and merchant on a file. Conto does not take them from the file. */
1137
+ reviewEvidence(purchaseId: string, evidenceId: string, input: {
1138
+ amount: string;
1139
+ currency: string;
1140
+ merchant: string;
1141
+ }): Promise<{
1142
+ id: string;
1143
+ matchStatus: string;
1144
+ }>;
1145
+ }
1146
+
842
1147
  interface ApiErrorMetadata {
843
1148
  code: string;
844
1149
  status: number;
@@ -851,6 +1156,8 @@ interface ApiErrorMetadata {
851
1156
  message: string;
852
1157
  }>;
853
1158
  reasons?: string[];
1159
+ reasonCode?: string;
1160
+ nextActions?: string[];
854
1161
  }
855
1162
 
856
1163
  /**
@@ -894,6 +1201,9 @@ declare class ContoAdminError extends Error {
894
1201
  readonly requestId?: string;
895
1202
  readonly retryAfter?: number;
896
1203
  readonly retryGuidance?: string;
1204
+ readonly reasonCode?: string;
1205
+ readonly nextActions?: string[];
1206
+ readonly fieldErrors?: ApiErrorMetadata['fieldErrors'];
897
1207
  constructor(message: string, metadata: ApiErrorMetadata);
898
1208
  }
899
1209
  interface PaginationParams {
@@ -1506,6 +1816,7 @@ declare class ContoAdmin {
1506
1816
  #private;
1507
1817
  private baseUrl;
1508
1818
  private timeout;
1819
+ spending: AdminSpendingClient;
1509
1820
  agents: AgentsClient;
1510
1821
  wallets: WalletsClient;
1511
1822
  cards: AdminCardsClient;
@@ -1523,11 +1834,16 @@ declare class ContoAdmin {
1523
1834
  signal?: AbortSignal;
1524
1835
  lastEventId?: string;
1525
1836
  }): Promise<Response>;
1837
+ /**
1838
+ * Download a file from the Conto API as bytes. It retries like a read, and
1839
+ * failures throw ContoAdminError as request() does.
1840
+ */
1841
+ download(path: string): Promise<DownloadBytes>;
1526
1842
  /**
1527
1843
  * Make an authenticated request to the Conto API. Reads retry. A write retries
1528
1844
  * only when `idempotent` says the API deduplicates it, as purchase creation does.
1529
1845
  */
1530
- request<T>(method: string, path: string, body?: Record<string, unknown>, options?: {
1846
+ request<T>(method: string, path: string, body?: Record<string, unknown> | FormData, options?: {
1531
1847
  idempotent?: boolean;
1532
1848
  }): Promise<T>;
1533
1849
  }
@@ -1858,6 +2174,13 @@ interface PaymentRequestInput {
1858
2174
  currency?: string;
1859
2175
  dueDate?: string;
1860
2176
  };
2177
+ /** An approved shared budget task, from `conto.spending.requestTask()`. */
2178
+ taskRequestId?: string;
2179
+ /**
2180
+ * A stable id for this purchase against shared budgets. A key cannot be used again, even after
2181
+ * its purchase is released, so use a new key for a new attempt.
2182
+ */
2183
+ purchaseKey?: string;
1861
2184
  };
1862
2185
  /** Specific wallet ID to use (optional) */
1863
2186
  walletId?: string;
@@ -2023,7 +2346,8 @@ interface ExternalWalletApprovalInput {
2023
2346
  recipientName?: string;
2024
2347
  purpose?: string;
2025
2348
  category?: string;
2026
- context?: PaymentRequestInput['context'];
2349
+ /** A self-custody wallet cannot pay against a shared task, so the task fields are refused. */
2350
+ context?: Omit<NonNullable<PaymentRequestInput['context']>, 'taskRequestId' | 'purchaseKey'>;
2027
2351
  }
2028
2352
  interface ExternalWalletApprovalResult {
2029
2353
  approved: boolean;
@@ -2326,6 +2650,10 @@ interface ConnectedCardDrawInput {
2326
2650
  /** Only USD is supported. Defaults to USD. */
2327
2651
  currency?: 'USD';
2328
2652
  merchant: ConnectedCardDrawMerchant;
2653
+ /** Why the agent wants this purchase, up to 500 characters. Shown to the person reviewing it. */
2654
+ purpose?: string;
2655
+ /** An approved task, for a budget that requires one. Naming a task grants nothing. */
2656
+ taskRequestId?: string;
2329
2657
  }
2330
2658
  /**
2331
2659
  * Live single-use card material returned by {@link ConnectedCardsClient.draw}.
@@ -2355,6 +2683,8 @@ interface ConnectedCardDrawResult {
2355
2683
  replayed: boolean;
2356
2684
  decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
2357
2685
  reasons: string[];
2686
+ /** Present when a budget refused the draw, for example `TASK_REQUIRED`. */
2687
+ reasonCodes?: string[];
2358
2688
  /** Present when the draw outcome is ambiguous and needs reconciliation. */
2359
2689
  reconciliationRequired?: boolean;
2360
2690
  /**
@@ -2454,6 +2784,8 @@ interface TestCardDrawResult {
2454
2784
  replayed: boolean;
2455
2785
  decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
2456
2786
  reasons: string[];
2787
+ /** Present when a budget refused the draw, for example `TASK_REQUIRED`. */
2788
+ reasonCodes?: string[];
2457
2789
  reconciliationRequired?: boolean;
2458
2790
  /** Present only on the response that issues it. A replay never returns it again. */
2459
2791
  testCredential?: TestCardCredential;
@@ -2585,7 +2917,10 @@ interface ConfirmCheckoutCheckpointInput {
2585
2917
  currency?: 'USD';
2586
2918
  /** Observed final items. Supplied items are checked even when the total is unchanged. */
2587
2919
  lineItems?: CommerceLineItemInput[];
2588
- /** Observed final charges. Supplied charges are checked even when the total is unchanged. */
2920
+ /**
2921
+ * Observed final charges, such as subtotal, tax and shipping. Conto checks that the final
2922
+ * total matches. The other rows may differ from the ones passed to begin().
2923
+ */
2589
2924
  totals?: CommerceTotalInput[];
2590
2925
  /** Page where the payment is submitted: the merchant's site or the payment method's. */
2591
2926
  pageUrl?: string;
@@ -2643,6 +2978,33 @@ interface WaitForCheckoutApprovalOptions {
2643
2978
  signal?: AbortSignal;
2644
2979
  }
2645
2980
 
2981
+ /**
2982
+ * The Link card request is waiting for the person. Conto has already approved
2983
+ * the purchase, and Link has created the request.
2984
+ */
2985
+ interface LinkApprovalEvent {
2986
+ /** The checkpoint Conto approved. */
2987
+ checkpoint: CheckoutCheckpoint;
2988
+ /** The Link spend request id, such as lsrq_... */
2989
+ linkRequestId: string;
2990
+ /**
2991
+ * The Stripe Link page where the person can approve on the web while signed
2992
+ * in to Link, so they do not need the Link app. Only an HTTPS link.com address
2993
+ * is passed. Absent when Link gave none or it did not pass that check. The
2994
+ * person can still approve in the Link app.
2995
+ */
2996
+ approvalUrl?: string;
2997
+ /** When Link stops accepting approval, as an ISO 8601 time, when Link reports it. */
2998
+ approvalExpiresAt?: string;
2999
+ }
3000
+ /**
3001
+ * Called once when the Link card request is waiting for the person, after
3002
+ * Conto approved the purchase and before the SDK starts waiting. Show
3003
+ * approvalUrl to the person. The SDK does not wait for it to finish, and an
3004
+ * error it throws or rejects with does not affect the purchase. A retry that
3005
+ * resumes a waiting request calls it again with the same URL.
3006
+ */
3007
+ type LinkApprovalCallback = (event: LinkApprovalEvent) => void | Promise<void>;
2646
3008
  /**
2647
3009
  * A Link card for one purchase: the checkpoint begin input plus the Link
2648
3010
  * wallet that runs in your environment. The checkout method is always LINK.
@@ -2654,6 +3016,8 @@ interface GetLinkCardInput extends Omit<BeginCheckoutCheckpointInput, 'checkoutM
2654
3016
  ownerApprovalTimeoutMs?: number;
2655
3017
  /** How long to wait for the person to approve in Link. Defaults to 10 minutes. */
2656
3018
  linkApprovalTimeoutMs?: number;
3019
+ /** Called once with the Link approval page when the person needs to approve in Link. */
3020
+ onLinkApproval?: LinkApprovalCallback;
2657
3021
  signal?: AbortSignal;
2658
3022
  }
2659
3023
  /** A new Link card for a changed final total. */
@@ -2667,6 +3031,8 @@ interface ReplaceLinkCardInput {
2667
3031
  totals?: CommerceTotalInput[];
2668
3032
  ownerApprovalTimeoutMs?: number;
2669
3033
  linkApprovalTimeoutMs?: number;
3034
+ /** Called once with the Link approval page when the person needs to approve in Link. */
3035
+ onLinkApproval?: LinkApprovalCallback;
2670
3036
  signal?: AbortSignal;
2671
3037
  }
2672
3038
  interface LinkCardResult {
@@ -3307,6 +3673,8 @@ declare class ContoError extends Error {
3307
3673
  readonly actionUrl?: string;
3308
3674
  readonly fieldErrors?: ApiErrorMetadata['fieldErrors'];
3309
3675
  readonly reasons?: string[];
3676
+ readonly reasonCode?: string;
3677
+ readonly nextActions?: string[];
3310
3678
  readonly diagnostics?: SetupDiagnostics;
3311
3679
  constructor(message: string, metadata: ApiErrorMetadata, diagnostics?: unknown);
3312
3680
  }
@@ -3380,6 +3748,13 @@ declare class CheckoutApprovalTimeoutError extends ContoError {
3380
3748
  declare class LinkCardError extends ContoError {
3381
3749
  readonly checkpoint: CheckoutCheckpoint;
3382
3750
  readonly linkRequestId?: string;
3751
+ /**
3752
+ * The Stripe Link page where the person could approve the request, set when
3753
+ * the SDK stopped while the request was waiting for them. It works only while
3754
+ * the request is still open in Link. When holdReleased is true, Conto has
3755
+ * already cancelled the request.
3756
+ */
3757
+ readonly approvalUrl?: string;
3383
3758
  /** True when Conto cancelled the checkpoint and released the held spend. */
3384
3759
  readonly holdReleased: boolean;
3385
3760
  constructor(input: {
@@ -3387,6 +3762,7 @@ declare class LinkCardError extends ContoError {
3387
3762
  code: string;
3388
3763
  checkpoint: CheckoutCheckpoint;
3389
3764
  linkRequestId?: string;
3765
+ approvalUrl?: string;
3390
3766
  holdReleased: boolean;
3391
3767
  retryGuidance?: string;
3392
3768
  });
@@ -3419,6 +3795,7 @@ declare class Conto {
3419
3795
  private timeout;
3420
3796
  /** Lightweight checkpoints before the payment method opens and before payment. */
3421
3797
  checkout: CheckoutClient;
3798
+ spending: SpendingClient;
3422
3799
  payments: PaymentsClient;
3423
3800
  cards: CardsClient;
3424
3801
  connectedCards: ConnectedCardsClient;
@@ -3516,8 +3893,13 @@ declare class Conto {
3516
3893
  signal?: AbortSignal;
3517
3894
  lastEventId?: string;
3518
3895
  }): Promise<Response>;
3896
+ /**
3897
+ * Download a file from the Conto API as bytes. It retries like a read, and
3898
+ * failures throw ContoError as request() does.
3899
+ */
3900
+ download(path: string): Promise<DownloadBytes>;
3519
3901
  /** Make an authenticated request to the Conto API */
3520
- request<T>(method: string, path: string, body?: Record<string, unknown>, options?: ContoRequestOptions): Promise<T>;
3902
+ request<T>(method: string, path: string, body?: Record<string, unknown> | FormData, options?: ContoRequestOptions): Promise<T>;
3521
3903
  }
3522
3904
  /** Agent client for the cooperative external-card policy overlay. */
3523
3905
  declare class CardsClient {
@@ -3854,7 +4236,10 @@ declare class CheckoutClient {
3854
4236
  * 1. Conto runs checkpoint 1 and holds the spend. When a rule requires the
3855
4237
  * owner's approval, this waits for it.
3856
4238
  * 2. Only then does the wallet ask Link for a card for exactly the approved
3857
- * amount at this merchant. The person approves it in Link.
4239
+ * amount at this merchant. Conto records the Link request at once, so the
4240
+ * hold stays while the card may be usable. The person approves it in
4241
+ * Link. Pass onLinkApproval to get Link's approval page, so they can
4242
+ * approve on the web without the Link app.
3858
4243
  * 3. The card is returned. It never reaches Conto.
3859
4244
  *
3860
4245
  * Then fill in the card, call confirm(result.checkpoint, { amountMinor,
@@ -3867,7 +4252,9 @@ declare class CheckoutClient {
3867
4252
  * held spend and throws a LinkCardError. When Conto cannot cancel an open Link
3868
4253
  * request, it keeps the hold and throws LINK_CARD_NOT_CANCELLED with the
3869
4254
  * request id. Retrying with the same input resumes the same checkpoint and
3870
- * Link request.
4255
+ * Link request while Conto's approval is open. Once the stage is OUTCOME_UNKNOWN,
4256
+ * a retry throws CHECKOUT_CHECKPOINT_NOT_APPROVED: cancel the Link request, then
4257
+ * the checkpoint.
3871
4258
  */
3872
4259
  getLinkCard(input: GetLinkCardInput): Promise<LinkCardResult>;
3873
4260
  /**
@@ -3879,5 +4266,5 @@ declare class CheckoutClient {
3879
4266
  replaceLinkCard(previous: LinkCardResult, input: ReplaceLinkCardInput): Promise<LinkCardResult>;
3880
4267
  }
3881
4268
 
3882
- export { AdminPurchasingClient, BrowserActionFinalizationPendingError, BrowserCheckoutTargetVerificationError, CardsClient, CheckoutApprovalDeniedError, CheckoutApprovalExpiredError, CheckoutApprovalPendingError, CheckoutApprovalTimeoutError, CheckoutCheckpointClosedError, CheckoutClient, ConnectedCardsClient, Conto, ContoAdmin, ContoAdminError, ContoError, ControlledExternalCardPaymentTool, ExternalCardConfirmationPendingError, Conto as Giro, ContoError as GiroError, LinkCardCredential, LinkCardDeniedError, LinkCardError, LinkCardExpiredError, LinkCardTimeoutError, LinkWallet, LinkWalletUnavailableError, OrganizationPurchasesClient, OrganizationRecurringPurchasesClient, PurchasesClient, RecurringPurchasesClient, TestCardsClient, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget, isFinalPurchaseStatus, parseServerSentEvents, verifyPurchaseWebhook };
3883
- export type { AdminExternalCardOverlayEnforcement, Agent, AgentCheckoutAction, AgentCheckoutActionKind, AgentExternalCard, AgentSetupResult, AgentStatus, AgentType, AgentWalletLink, ApprovedExternalCardExecution, AssignExternalCardInput, AssignedPolicy, AuthorizeCheckoutActionResult, BeginCheckoutCheckpointInput, BeginCommerceExecutionInput, BrowserActionClaimResult, BrowserActionDispatchObservationInput, BrowserActionFinalizeResult, BrowserCheckoutAction, BrowserCheckoutTargetResolver, BrowserCheckoutTargetSnapshot, BrowserCheckoutTargetVerificationCode, CancellationOutcome, CanonicalBrowserCheckoutTargetSnapshot, ChainType, CheckoutActionAuthorization, CheckoutCheckpoint, CheckoutCheckpointApproval, CheckoutCheckpointMethod, CheckoutCheckpointNextAction, CheckoutCheckpointStage, CheckoutOutcome, CheckoutPaymentReference, CommerceCheckoutMethod, CommerceContextRequirement, CommerceExecution, CommerceExecutionAdapterKind, CommerceExecutionArtifactKind, CommerceExecutionChannel, CommerceExecutionConstraint, CommerceExecutionConstraintCoverage, CommerceExecutionConstraintCoverageLevel, CommerceExecutionDeliveryMode, CommerceExecutionEvidence, CommerceExecutionProvider, CommerceExecutionResult, CommerceExecutionSourceKind, CommerceExecutionStatus, CommerceFactConfidence, CommerceFactProvenanceInput, CommerceFactSource, CommerceFulfillmentInput, CommerceLineItemInput, CommerceProposalFactKey, CommerceProposalMissingFact, CommerceProposalResolution, CommerceProposalState, CommerceSettlementRail, CommerceTotalInput, CommerceTotalType, ComparePolicyVersionsResponse, ConfirmCheckoutCheckpointInput, ConnectedCardBrief, ConnectedCardCredential, ConnectedCardDrawInput, ConnectedCardDrawMerchant, ConnectedCardDrawResult, ConnectedCardDrawable, ConnectedCardListResult, ConnectedCardMandate, ConnectedCardMandateMerchant, ConnectedCardOutcomeReport, ConnectedCardOutcomeReportResult, ConnectedCardReference, ContoAdminConfig, ContoConfig, ContoRequestOptions, ControlledExternalCardPaymentResult, CreateAgentInput, CreatePolicyInput, CreatePolicyRuleInput, CreatePurchaseInput, CreateSdkKeyInput, CreateSdkKeyResult, CreateWalletInput, CustodyType, CustomerCustodyMode, CustomerWalletControlModel, CustomerWalletKeyAccess, DelegationType, ExecuteCommerceExecutionResult, ExternalCard, ExternalCardApprovalInput, ExternalCardApprovalResult, ExternalCardConfirmationInput, ExternalCardConfirmationResult, ExternalCardExecutionClaimResult, ExternalCardExecutionResult, ExternalCardExecutor, ExternalCardOverlayEnforcement, ExternalCardRequestStatusResult, ExternalWalletApprovalInput, ExternalWalletApprovalResult, ExternalWalletConfirmationInput, ExternalWalletConfirmationResult, FreezeAgentInput, GetLinkCardInput, ContoConfig as GiroConfig, GuardCheckoutResult, GuardedBrowserDispatchResult, GuardedCheckoutInput, LinkCardResult, LinkWalletInput, ListAgentsParams, ListAgentsResponse, ListPoliciesParams, ListPoliciesResponse, ListPolicyVersionsResponse, ListWalletsParams, ListWalletsResponse, MppBudgetResult, MppPreAuthorizeInput, MppPreAuthorizeResult, MppRecordInput, MppRecordResult, NormalizeCommerceProposalInput, OrganizationMember, PaginatedResponse, PaginationParams, PauseExternalCardAssignmentResult, PaymentExecuteResult, PaymentRequestInput, PaymentRequestResult, PaymentStatusResult, Policy, PolicyRule, PolicyType, PolicyVersionChangeType, PolicyVersionDetail, PolicyVersionDiff, PolicyVersionFieldChange, PolicyVersionSnapshot, PolicyVersionSnapshotRule, PolicyVersionSummary, PrivilegedBrowserCheckoutDriver, ProtocolBudgetResult, ProtocolPreAuthorizeResult, ProtocolRecordGrant, ProtocolRecordGrantResult, ProtocolServiceSummary, ProtocolServicesResult, ProveWalletOwnershipInput, ProvisionWalletResult, Purchase, PurchaseAction, PurchaseActionAuthority, PurchaseActionKind, PurchaseAllowance, PurchaseBuyer, PurchaseBuyerCompanyCard, PurchaseBuyerCompanyCardLimits, PurchaseBuyerKitchenContext, PurchaseCompanyCard, PurchaseDelegation, PurchaseEvent, PurchaseEventPage, PurchaseEvidence, PurchaseGrocery, PurchaseGroceryItem, PurchaseGroceryList, PurchaseHostedLink, PurchaseItem, PurchaseKitchenContext, PurchaseKitchenInventoryItem, PurchaseKitchenListItem, PurchaseKitchenPreferences, PurchaseKitchenRecipe, PurchaseKitchenUsual, PurchaseList, PurchaseMoney, PurchasePaymentMethod, PurchasePhase, PurchaseRequest, PurchaseResponseAck, PurchaseStatus, PurchasingCapabilities, PurchasingSettings, RecurringPurchase, RecurringPurchaseCycleResult, RecurringPurchaseCycleStatus, RefreshBalanceResult, RegisterExternalCardInput, ReplaceLinkCardInput, ReportCheckoutOutcomeInput, RollbackPolicyVersionResponse, RuleAction, RuleOperator, RuleType, RunGuardedCheckoutResult, SdkKey, SdkKeyType, SetupCapabilityState, SetupCardDiagnostics, SetupDiagnosticAction, SetupDiagnosticIssue, SetupDiagnosticIssueCode, SetupDiagnostics, SetupWalletDiagnostics, TestCardCredential, TestCardDrawResult, TestCardDrawable, TestCardListResult, TestCardReceipt, TestCheckoutInput, TestCheckoutResult, TestMerchant, TestMerchantProduct, UnfreezeAgentInput, UpdateAgentInput, UpdateExternalCardAssignmentInput, UpdatePolicyInput, UpdatePolicyRuleInput, UpdateWalletInput, VerifiedBrowserCheckoutTarget, WaitForCheckoutApprovalOptions, Wallet, WalletChainBalanceSnapshot, WalletOwnershipChallenge, WalletOwnershipProof, WalletStatus, WalletType, WatchPurchaseOptions, X402Authorization, X402BudgetResult, X402PayInput, X402PayResult, X402PaymentRequirements, X402PreAuthorizeInput, X402PreAuthorizeResult, X402RecordInput, X402RecordResult };
4269
+ export { AdminPurchasingClient, AdminSpendingClient, BrowserActionFinalizationPendingError, BrowserCheckoutTargetVerificationError, CardsClient, CheckoutApprovalDeniedError, CheckoutApprovalExpiredError, CheckoutApprovalPendingError, CheckoutApprovalTimeoutError, CheckoutCheckpointClosedError, CheckoutClient, ConnectedCardsClient, Conto, ContoAdmin, ContoAdminError, ContoError, ControlledExternalCardPaymentTool, ExternalCardConfirmationPendingError, Conto as Giro, ContoError as GiroError, LinkCardCredential, LinkCardDeniedError, LinkCardError, LinkCardExpiredError, LinkCardTimeoutError, LinkWallet, LinkWalletUnavailableError, OrganizationPurchasesClient, OrganizationRecurringPurchasesClient, PurchasesClient, RecurringPurchasesClient, SpendingClient, TestCardsClient, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget, isFinalPurchaseStatus, parseServerSentEvents, verifyPurchaseWebhook };
4270
+ export type { AdminExternalCardOverlayEnforcement, Agent, AgentCheckoutAction, AgentCheckoutActionKind, AgentExternalCard, AgentSetupResult, AgentStatus, AgentType, AgentWalletLink, ApprovedExternalCardExecution, AssignExternalCardInput, AssignedPolicy, AuthorizeCheckoutActionResult, BeginCheckoutCheckpointInput, BeginCommerceExecutionInput, BrowserActionClaimResult, BrowserActionDispatchObservationInput, BrowserActionFinalizeResult, BrowserCheckoutAction, BrowserCheckoutTargetResolver, BrowserCheckoutTargetSnapshot, BrowserCheckoutTargetVerificationCode, BudgetInput, BudgetSnapshot, CancellationOutcome, CanonicalBrowserCheckoutTargetSnapshot, ChainType, CheckoutActionAuthorization, CheckoutCheckpoint, CheckoutCheckpointApproval, CheckoutCheckpointMethod, CheckoutCheckpointNextAction, CheckoutCheckpointStage, CheckoutOutcome, CheckoutPaymentReference, CommerceCheckoutMethod, CommerceContextRequirement, CommerceExecution, CommerceExecutionAdapterKind, CommerceExecutionArtifactKind, CommerceExecutionChannel, CommerceExecutionConstraint, CommerceExecutionConstraintCoverage, CommerceExecutionConstraintCoverageLevel, CommerceExecutionDeliveryMode, CommerceExecutionEvidence, CommerceExecutionProvider, CommerceExecutionResult, CommerceExecutionSourceKind, CommerceExecutionStatus, CommerceFactConfidence, CommerceFactProvenanceInput, CommerceFactSource, CommerceFulfillmentInput, CommerceLineItemInput, CommerceProposalFactKey, CommerceProposalMissingFact, CommerceProposalResolution, CommerceProposalState, CommerceSettlementRail, CommerceTotalInput, CommerceTotalType, ComparePolicyVersionsResponse, ConfirmCheckoutCheckpointInput, ConnectedCardBrief, ConnectedCardCredential, ConnectedCardDrawInput, ConnectedCardDrawMerchant, ConnectedCardDrawResult, ConnectedCardDrawable, ConnectedCardListResult, ConnectedCardMandate, ConnectedCardMandateMerchant, ConnectedCardOutcomeReport, ConnectedCardOutcomeReportResult, ConnectedCardReference, ContoAdminConfig, ContoConfig, ContoRequestOptions, ControlledExternalCardPaymentResult, CreateAgentInput, CreatePolicyInput, CreatePolicyRuleInput, CreatePurchaseInput, CreateSdkKeyInput, CreateSdkKeyResult, CreateWalletInput, CustodyType, CustomerCustodyMode, CustomerWalletControlModel, CustomerWalletKeyAccess, DelegationType, DownloadBytes, ExecuteCommerceExecutionResult, ExternalCard, ExternalCardApprovalInput, ExternalCardApprovalResult, ExternalCardConfirmationInput, ExternalCardConfirmationResult, ExternalCardExecutionClaimResult, ExternalCardExecutionResult, ExternalCardExecutor, ExternalCardOverlayEnforcement, ExternalCardRequestStatusResult, ExternalWalletApprovalInput, ExternalWalletApprovalResult, ExternalWalletConfirmationInput, ExternalWalletConfirmationResult, FreezeAgentInput, GetLinkCardInput, ContoConfig as GiroConfig, GuardCheckoutResult, GuardedBrowserDispatchResult, GuardedCheckoutInput, LinkApprovalCallback, LinkApprovalEvent, LinkCardResult, LinkWalletInput, ListAgentsParams, ListAgentsResponse, ListPoliciesParams, ListPoliciesResponse, ListPolicyVersionsResponse, ListWalletsParams, ListWalletsResponse, MppBudgetResult, MppPreAuthorizeInput, MppPreAuthorizeResult, MppRecordInput, MppRecordResult, NormalizeCommerceProposalInput, OrganizationMember, PaginatedResponse, PaginationParams, PauseExternalCardAssignmentResult, PaymentExecuteResult, PaymentRequestInput, PaymentRequestResult, PaymentStatusResult, Policy, PolicyRule, PolicyType, PolicyVersionChangeType, PolicyVersionDetail, PolicyVersionDiff, PolicyVersionFieldChange, PolicyVersionSnapshot, PolicyVersionSnapshotRule, PolicyVersionSummary, PreviewInput, PrivilegedBrowserCheckoutDriver, ProtocolBudgetResult, ProtocolPreAuthorizeResult, ProtocolRecordGrant, ProtocolRecordGrantResult, ProtocolServiceSummary, ProtocolServicesResult, ProveWalletOwnershipInput, ProvisionWalletResult, Purchase, PurchaseAction, PurchaseActionAuthority, PurchaseActionKind, PurchaseAllowance, PurchaseBuyer, PurchaseBuyerCompanyCard, PurchaseBuyerCompanyCardLimits, PurchaseBuyerKitchenContext, PurchaseCompanyCard, PurchaseDelegation, PurchaseDetail, PurchaseEvent, PurchaseEventPage, PurchaseEvidence, PurchaseGrocery, PurchaseGroceryItem, PurchaseGroceryList, PurchaseHostedLink, PurchaseItem, PurchaseKitchenContext, PurchaseKitchenInventoryItem, PurchaseKitchenListItem, PurchaseKitchenPreferences, PurchaseKitchenRecipe, PurchaseKitchenUsual, PurchaseList, PurchaseMoney, PurchasePaymentMethod, PurchasePhase, PurchaseRequest, PurchaseResponseAck, PurchaseSnapshot, PurchaseStatus, PurchasingCapabilities, PurchasingSettings, RecurringPurchase, RecurringPurchaseCycleResult, RecurringPurchaseCycleStatus, RefreshBalanceResult, RegisterExternalCardInput, ReplaceLinkCardInput, ReportCheckoutOutcomeInput, RollbackPolicyVersionResponse, RuleAction, RuleOperator, RuleType, RunGuardedCheckoutResult, SdkKey, SdkKeyType, SetupCapabilityState, SetupCardDiagnostics, SetupDiagnosticAction, SetupDiagnosticIssue, SetupDiagnosticIssueCode, SetupDiagnostics, SetupWalletDiagnostics, SpendingRequester, TaskInput, TaskSnapshot, TestCardCredential, TestCardDrawResult, TestCardDrawable, TestCardListResult, TestCardReceipt, TestCheckoutInput, TestCheckoutResult, TestMerchant, TestMerchantProduct, UnfreezeAgentInput, UpdateAgentInput, UpdateExternalCardAssignmentInput, UpdatePolicyInput, UpdatePolicyRuleInput, UpdateWalletInput, VerifiedBrowserCheckoutTarget, WaitForCheckoutApprovalOptions, Wallet, WalletChainBalanceSnapshot, WalletOwnershipChallenge, WalletOwnershipProof, WalletStatus, WalletType, WatchPurchaseOptions, X402Authorization, X402BudgetResult, X402PayInput, X402PayResult, X402PaymentRequirements, X402PreAuthorizeInput, X402PreAuthorizeResult, X402RecordInput, X402RecordResult };