@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
73 lines • 2.76 kB
TypeScript
import { HTTPFacilitatorClient } from "@x402/core/server";
/** CDP facilitator base URL. */
export declare const CDP_FACILITATOR_URL = "https://api.cdp.coinbase.com/platform/v2/x402";
/**
* Args for {@link createCdpFacilitatorClient}.
*/
export interface CdpFacilitatorClientArgs {
/**
* CDP API key ID. Falls back to the `CDP_API_KEY_ID` environment variable.
*/
apiKeyId?: string;
/**
* CDP API key secret. Falls back to the `CDP_API_KEY_SECRET` environment variable.
*/
apiKeySecret?: string;
/**
* Override the facilitator base URL. Defaults to the CDP production endpoint
* (`https://api.cdp.coinbase.com/platform/v2/x402`).
*
* The hostname and per-operation paths are derived from this URL, so JWT
* signing is automatically bound to the correct host and paths. Use this
* to point at a staging, canary, or local facilitator without changing
* any other configuration.
*
* @example
* ```typescript
* const facilitator = createCdpFacilitatorClient({
* baseUrl: "https://api.staging.cdp.coinbase.com/platform/v2/x402",
* });
* ```
*/
baseUrl?: string;
}
/**
* Creates a CDP-authenticated x402 facilitator client.
*
* The returned client is pre-configured with the CDP hosted facilitator URL
* and CDP JWT-based authentication. It implements the `HTTPFacilitatorClient`
* interface from `@x402/core/server` and can be passed directly to
* `x402ResourceServer` as a drop-in replacement for a self-hosted facilitator.
*
* Credentials are resolved in order: explicit args → `CDP_API_KEY_ID` /
* `CDP_API_KEY_SECRET` environment variables.
*
* @param args - Optional credential overrides.
* @returns A configured `HTTPFacilitatorClient` ready for use with `x402ResourceServer`.
* @throws {Error} If neither explicit args nor environment variables provide credentials.
*
* @example
* Drop-in replacement for a self-hosted facilitator:
* ```typescript
* import { createCdpFacilitatorClient } from "@coinbase/cdp-sdk/x402";
* import { x402ResourceServer } from "@x402/core/server";
* import { ExactEvmScheme } from "@x402/evm/exact/server";
*
* // Set CDP_API_KEY_ID and CDP_API_KEY_SECRET in your environment
* const facilitator = createCdpFacilitatorClient();
*
* const server = new x402ResourceServer(facilitator)
* .register("eip155:8453", new ExactEvmScheme());
* ```
*
* @example
* Explicit credentials:
* ```typescript
* const facilitator = createCdpFacilitatorClient({
* apiKeyId: "my-key-id",
* apiKeySecret: "my-key-secret",
* });
* ```
*/
export declare function createCdpFacilitatorClient(args?: CdpFacilitatorClientArgs): HTTPFacilitatorClient;
//# sourceMappingURL=facilitator.d.ts.map