/** * Delegation API for managing payment delegations (crypto and card schemes). * * Provides access to the user's enrolled payment methods and delegations * for use with the nvm:erc4337 and nvm:card-delegation x402 schemes. */ import { BasePaymentsAPI } from '../api/base-payments.js'; import { CreateDelegationPayload, CreateDelegationResponse, PaymentOptions } from '../common/types.js'; /** * Card-delegation providers exposed by the SDK. Use this when you want to * restrict to card-shape entries only (e.g., filtering the heterogeneous * list returned by {@link DelegationAPI.listPaymentMethods}). */ export type CardProvider = 'stripe' | 'braintree' | 'visa'; /** * All delegation providers, including the crypto path. Matches the * server-side union and aligns with {@link CreateDelegationPayload.provider}. */ export type DelegationProvider = CardProvider | 'erc4337'; /** * Summary of a user's enrolled payment method. * * The list returned by {@link DelegationAPI.listPaymentMethods} is * heterogeneous: it includes enrolled cards (`provider` in * `stripe` / `braintree` / `visa`) AND, when the user has a smart account * configured, an entry for the user's ERC-4337 wallet * (`provider: 'erc4337'`, `type: 'crypto_wallet'`, `brand: 'ethereum'`). * Filter on `provider` when callers only want one shape. */ export interface PaymentMethodSummary { /** Payment method ID (Stripe 'pm_...', Braintree vault token, Visa Agentic * token id, or — for the erc4337 entry — the smart-account address) */ id: string; /** Payment method type ('card' | 'crypto_wallet' | 'paypal' | …) */ type: string; /** Card brand (e.g., 'visa', 'mastercard'), 'ethereum' for the erc4337 * entry, or payment method type ('paypal', 'venmo') */ brand: string; /** Last 4 digits (cards), trailing 4 chars of the wallet address * (erc4337), or email/username (PayPal/Venmo) */ last4: string; /** Expiration month (0 for non-card methods) */ expMonth: number; /** Expiration year (0 for non-card methods) */ expYear: number; /** Human-readable alias, if set */ alias?: string | null; /** One of 'stripe' | 'braintree' | 'visa' | 'erc4337' */ provider?: DelegationProvider; /** Current status ('Active' or 'Revoked') */ status?: string; /** NVM API Key IDs allowed to use this payment method, or null if unrestricted */ allowedApiKeyIds?: string[] | null; } /** * Summary of a delegation (card or crypto spending). */ export interface DelegationSummary { delegationId: string; provider: string; providerPaymentMethodId: string; status: string; spendingLimitCents: string; amountSpentCents: string; remainingBudgetCents: string; currency: string; transactionCount: number; expiresAt: string; createdAt: string; apiKeyId: string | null; } /** * Paginated list of delegations returned by the API. */ export interface DelegationListResponse { delegations: DelegationSummary[]; totalResults: number; page: number; offset: number; } /** * Summary of an agent's purchasing power via card delegations. */ export interface PurchasingPower { cards: PaymentMethodSummary[]; delegations: DelegationSummary[]; totalRemainingBudgetCents: number; currency: string; } /** * DTO for updating a payment method's alias and allowed API keys. */ export interface UpdatePaymentMethodDto { alias?: string; allowedApiKeyIds?: string[] | null; } /** * Options for listing payment methods or delegations. */ export interface ListOptions { /** When true, return only items accessible to the requesting API key */ accessible?: boolean; /** * Restrict the result to payment methods backed by this provider * (e.g. `'stripe'`). Server-side filter for * {@link DelegationAPI.listPaymentMethods}; omit to return methods from every * provider (default). Has no effect on {@link DelegationAPI.listDelegations}. */ provider?: DelegationProvider; } /** * API for managing payment methods and delegations (card and crypto). */ export declare class DelegationAPI extends BasePaymentsAPI { static getInstance(options: PaymentOptions): DelegationAPI; /** * List the user's enrolled payment methods for card delegation. * When `accessible: true`, only cards accessible to the requesting API key are returned. * When `provider` is set, only methods backed by that provider are returned * (server-side filter); omit it to return methods from every provider. */ listPaymentMethods(options?: ListOptions): Promise; /** * List the user's existing delegations. * When `accessible: true`, only usable delegations (Active, non-expired, with budget) are returned. */ listDelegations(options?: ListOptions): Promise; /** * Get the agent's purchasing power — accessible cards, active delegations, * and combined remaining budget. */ getPurchasingPower(): Promise; /** * Create a new delegation for any supported provider (stripe, braintree, * visa, or erc4337). * * Note: Visa delegations require a per-delegation device-binding ceremony * (FIDO/passkey + assuranceData) that must be performed in the browser * via the Nevermined webapp. The SDK can list and consume an already- * created Visa delegation but cannot create one programmatically. * * @param payload - The delegation creation parameters * @returns The created delegation ID (and token for card delegations) */ createDelegation(payload: CreateDelegationPayload): Promise; /** * Update a payment method's alias and/or allowed API keys. */ updatePaymentMethod(paymentMethodId: string, dto: UpdatePaymentMethodDto): Promise; private fetchJSON; } //# sourceMappingURL=delegation-api.d.ts.map