import type { AuctionResult, CreateAuctionParams, RefundRequestResult, RequestRefundParams } from './types.js'; export interface M2CClientOptions { /** * Your secret key (`sec_...`). Server-side only - never ship this in a * client app. This SDK targets the secret-key surface: a publishable key * returns the minimal auction response (no `vendor_id` / `clearing_rate`), * which this client rejects, so pass a secret key here. */ secretKey: string; /** API base URL. Defaults to the production host. Override for local dev. */ baseUrl?: string; /** Per-request timeout in milliseconds. Defaults to 10000. */ timeoutMs?: number; /** * Injectable fetch, primarily for testing. Defaults to the global `fetch` * (Node 18+). Must be WHATWG-compatible. */ fetch?: typeof fetch; /** * Permit an `http://` baseUrl to a non-loopback host. Off by default * because plain http would put the secret key on the wire in cleartext; * loopback http needs no opt-in. For unusual dev topologies (e.g. a * TLS-terminating gateway on a private network) only. */ allowInsecureBaseUrl?: boolean; } /** Per-call options for {@link M2CClient.createAuction}. */ export interface CreateAuctionOptions { /** * Value for the `Idempotency-Key` request header (1-255 printable ASCII). * A retried auction with the same key replays the original outcome instead * of running a fresh, separately billed auction with a potentially * different winner - so generate one key per logical checkout and reuse it * across retries of `retryable` errors. */ idempotencyKey?: string; } export declare class M2CClient { private readonly secretKey; private readonly baseUrl; private readonly timeoutMs; private readonly fetchImpl; constructor(options: M2CClientOptions); /** * Run an auction and return the winning vendor's checkout URL plus pricing * detail. * * When calling on behalf of an end-user device, pass `customerIp` so geo * resolves to the user, not your server. * * @throws {M2CApiError} on a non-2xx response. Auction 404 codes distinguish * no eligible vendors, no bids, and no valid bids; no checkout was returned. * @throws {M2CError} before any request is sent when pricing inputs or * `options.idempotencyKey` fail client-side validation. */ createAuction(params: CreateAuctionParams, options?: CreateAuctionOptions): Promise; /** * Request a refund for a completed conversion. M2C relays a signed request to * the winning vendor, which executes it at its PSP and confirms back on the * conversion webhook - your authoritative refund signal. Multiple partial refunds * may be requested until the cumulative total reaches the refundable amount; a * retry with the same `idempotencyKey` is idempotent. * * @throws {M2CApiError} on a non-2xx response: 404 (`not_found`: conversion not * found or not yours - distinct from the auction's `no_winner`), 409 (`conflict`: * idempotency-key mismatch, vendor unsupported, or not in a refundable state), 422 * (`unprocessable`: window expired or period archived), 400 (`bad_request`: * missing/invalid idempotency key or amount over the refundable total). None are retryable. * @throws {M2CError} before any request is sent on client-side validation. */ requestRefund(requestId: string, params: RequestRefundParams): Promise; private post; }