コンテンツにスキップ

CreateX402HandlerParams

このコンテンツはまだ日本語訳がありません。

Defined in: src/x402/server.ts:92

Parameters for createX402Handler.

Properties

facilitator

readonly facilitator: Facilitator

Defined in: src/x402/server.ts:94

Facilitator that performs verify and settle (self or HTTP-proxied).


handler

readonly handler: X402InnerHandler

Defined in: src/x402/server.ts:109

The protected business-logic handler. Invoked after settlement.


hooks?

readonly optional hooks?: ObservabilityHooks

Defined in: src/x402/server.ts:121

Optional observability callbacks. The handler emits onPaymentRequired each time it returns a 402, and onPaymentAccepted after a settled payment unlocks the inner handler. Hooks are fire-and-forget — see ObservabilityHooks.


idempotency?

readonly optional idempotency?: IdempotencyServerConfig

Defined in: src/x402/server.ts:131

Reasoning-step idempotency (M5-1, Half A). Default-on: when omitted, an in-memory store deduplicates re-sent / concurrent paid requests — replaying the cached response and closing the verify→settle TOCTOU. Pass { store: "none" } to disable, or a shared store (Redis/SQL adapter) for multi-replica deployments (the in-memory default is single-process). Fund-correctness never depends on this store — the on-chain EIP-3009 nonce is the backstop.


requirementsFor

readonly requirementsFor: (request) => readonly X402PaymentRequirements[] | Promise<readonly X402PaymentRequirements[] | null> | null

Defined in: src/x402/server.ts:102

Returns the X402PaymentRequirements that apply to this request.

  • Return one or more entries to require payment (client picks one).
  • Return null or [] to skip the payment flow entirely for this request — the inner handler is invoked with context = null.

Parameters

request

Request

Returns

readonly X402PaymentRequirements[] | Promise<readonly X402PaymentRequirements[] | null> | null


resourceFor?

readonly optional resourceFor?: (request) => X402ResourceInfo | Promise<X402ResourceInfo>

Defined in: src/x402/server.ts:114

Optional builder for the X402ResourceInfo echoed in the 402 response. Defaults to { url: request.url }.

Parameters

request

Request

Returns

X402ResourceInfo | Promise<X402ResourceInfo>