Extensions

extensions/types

github.com/x402-foundation/x402/go/v2/extensions/types

import "github.com/x402-foundation/x402/go/v2/extensions/types"

Constants

Payment identifier validation constants

Source: extensions/types/types.go:22

const (
	PAYMENT_ID_MIN_LENGTH = 16
	PAYMENT_ID_MAX_LENGTH = 128
)

Extension identifier constant for the Payment Identifier extension

Source: extensions/types/types.go:18

const PAYMENT_IDENTIFIER = "payment-identifier"

Source: extensions/types/types.go:42

const (
	MethodPOST  BodyMethods = "POST"
	MethodPUT   BodyMethods = "PUT"
	MethodPATCH BodyMethods = "PATCH"
)

Source: extensions/types/types.go:51

const (
	BodyTypeJSON     BodyType = "json"
	BodyTypeFormData BodyType = "form-data"
	BodyTypeText     BodyType = "text"
)

Source: extensions/types/types.go:99

const (
	TransportStreamableHTTP McpTransport = "streamable-http"
	TransportSSE            McpTransport = "sse"
)

Source: extensions/types/types.go:33

const (
	MethodGET    QueryParamMethods = "GET"
	MethodHEAD   QueryParamMethods = "HEAD"
	MethodDELETE QueryParamMethods = "DELETE"
)

Variables

BAZAAR is the extension identifier for the Bazaar discovery extension.

Source: extensions/types/types.go:11

var BAZAAR = x402.NewFacilitatorExtension("bazaar")

ColonParamRegex matches :paramName route segments (Express style). Shared across http/server.go and extensions/bazaar/server.go to avoid drift.

Source: extensions/types/types.go:15

var ColonParamRegex = regexp.MustCompile(`:([a-zA-Z_][a-zA-Z0-9_]*)`)

PAYMENT_ID_PATTERN is a regex pattern for valid payment identifier characters

Source: extensions/types/types.go:27

var PAYMENT_ID_PATTERN = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)

Functions

func IsBodyMethod(method string) bool

Source: extensions/types/types.go:240

IsBodyMethod checks if a string is a body method

func IsQueryMethod(method string) bool

Source: extensions/types/types.go:231

IsQueryMethod checks if a string is a query parameter method

Types

type BodyDiscoveryExtension

Source: extensions/types/types.go:195

BodyDiscoveryExtension represents a discovery extension for body methods

type BodyDiscoveryExtension struct {
	Info   BodyDiscoveryInfo `json:"info"`
	Schema JSONSchema        `json:"schema"`
}
Fields
  • Info BodyDiscoveryInfo `json:"info"`
  • Schema JSONSchema `json:"schema"`

type BodyDiscoveryInfo

Source: extensions/types/types.go:72

BodyDiscoveryInfo represents discovery info for body methods (POST, PUT, PATCH)

type BodyDiscoveryInfo struct {
	Input  BodyInput   `json:"input"`
	Output *OutputInfo `json:"output,omitempty"`
}
Fields
  • Input BodyInput `json:"input"`
  • Output *OutputInfo `json:"output,omitempty"`

type BodyInput

Source: extensions/types/types.go:78

BodyInput represents input information for body methods

type BodyInput struct {
	Type        string                 `json:"type"` // "http"
	Method      BodyMethods            `json:"method"`
	BodyType    BodyType               `json:"bodyType"`
	Body        interface{}            `json:"body"`
	QueryParams map[string]interface{} `json:"queryParams,omitempty"`
	PathParams  map[string]interface{} `json:"pathParams,omitempty"`
	Headers     map[string]string      `json:"headers,omitempty"`
}
Fields
  • Type string `json:"type"`

    "http"

  • Method BodyMethods `json:"method"`
  • BodyType BodyType `json:"bodyType"`
  • Body interface{} `json:"body"`
  • QueryParams map[string]interface{} `json:"queryParams,omitempty"`
  • PathParams map[string]interface{} `json:"pathParams,omitempty"`
  • Headers map[string]string `json:"headers,omitempty"`

type BodyMethods

Source: extensions/types/types.go:39

BodyMethods are HTTP methods that use request bodies

type BodyMethods string

type BodyType

Source: extensions/types/types.go:48

BodyType represents the type of request body

type BodyType string

type DeclareBodyDiscoveryConfig

Source: extensions/types/types.go:216

DeclareBodyDiscoveryConfig is the configuration for declaring a body discovery extension

type DeclareBodyDiscoveryConfig struct {
	Method      BodyMethods   // HTTP method
	Input       interface{}   // Example input data
	InputSchema JSONSchema    // JSON Schema for the input
	BodyType    BodyType      // Body type (json, form-data, text)
	Output      *OutputConfig // Output configuration
}
Fields
  • Method BodyMethods

    HTTP method

  • Input interface{}

    Example input data

  • InputSchema JSONSchema

    JSON Schema for the input

  • BodyType BodyType

    Body type (json, form-data, text)

  • Output *OutputConfig

    Output configuration

type DeclareMcpDiscoveryConfig

Source: extensions/types/types.go:126

DeclareMcpDiscoveryConfig is the configuration for declaring an MCP discovery extension

type DeclareMcpDiscoveryConfig struct {
	ToolName    string       // MCP tool name
	Description string       // Human-readable description
	Transport   McpTransport // Transport protocol (streamable-http, sse)
	InputSchema interface{}  // JSON Schema for the tool's input
	Example     interface{}  // Example input
	Output      *OutputConfig
}
Fields
  • ToolName string

    MCP tool name

  • Description string

    Human-readable description

  • Transport McpTransport

    Transport protocol (streamable-http, sse)

  • InputSchema interface{}

    JSON Schema for the tool's input

  • Example interface{}

    Example input

  • Output *OutputConfig

type DeclareQueryDiscoveryConfig

Source: extensions/types/types.go:208

DeclareQueryDiscoveryConfig is the configuration for declaring a query discovery extension

type DeclareQueryDiscoveryConfig struct {
	Method      QueryParamMethods      // HTTP method
	Input       map[string]interface{} // Example input data
	InputSchema JSONSchema             // JSON Schema for the input
	Output      *OutputConfig          // Output configuration
}
Fields
  • Method QueryParamMethods

    HTTP method

  • Input map[string]interface{}

    Example input data

  • InputSchema JSONSchema

    JSON Schema for the input

  • Output *OutputConfig

    Output configuration

type DiscoveryExtension

Source: extensions/types/types.go:201

DiscoveryExtension is a union type that can be either Query or Body discovery extension

type DiscoveryExtension struct {
	Info          DiscoveryInfo `json:"info"`
	Schema        JSONSchema    `json:"schema"`
	RouteTemplate string        `json:"routeTemplate,omitempty"`
}
Fields
  • Info DiscoveryInfo `json:"info"`
  • Schema JSONSchema `json:"schema"`
  • RouteTemplate string `json:"routeTemplate,omitempty"`

type DiscoveryInfo

Source: extensions/types/types.go:136

DiscoveryInfo is a union type that can be either Query or Body discovery info

type DiscoveryInfo struct {
	Input  interface{} `json:"input"`
	Output *OutputInfo `json:"output,omitempty"`
}
Fields
  • Input interface{} `json:"input"`
  • Output *OutputInfo `json:"output,omitempty"`

func UnmarshalJSON(data []byte) error

Source: extensions/types/types.go:142

UnmarshalJSON custom unmarshaler to handle the union type

type JSONSchema

Source: extensions/types/types.go:186

JSONSchema represents a JSON Schema object

type JSONSchema map[string]interface{}

type McpDiscoveryExtension

Source: extensions/types/types.go:120

McpDiscoveryExtension represents a discovery extension for MCP tools

type McpDiscoveryExtension struct {
	Info   McpDiscoveryInfo `json:"info"`
	Schema JSONSchema       `json:"schema"`
}
Fields
  • Info McpDiscoveryInfo `json:"info"`
  • Schema JSONSchema `json:"schema"`

type McpDiscoveryInfo

Source: extensions/types/types.go:114

McpDiscoveryInfo represents discovery info for MCP tools

type McpDiscoveryInfo struct {
	Input  McpInput    `json:"input"`
	Output *OutputInfo `json:"output,omitempty"`
}
Fields
  • Input McpInput `json:"input"`
  • Output *OutputInfo `json:"output,omitempty"`

type McpInput

Source: extensions/types/types.go:104

McpInput represents input information for MCP tool discovery

type McpInput struct {
	Type        string       `json:"type"` // "mcp"
	ToolName    string       `json:"toolName"`
	Description string       `json:"description,omitempty"`
	Transport   McpTransport `json:"transport,omitempty"`
	InputSchema interface{}  `json:"inputSchema"`
	Example     interface{}  `json:"example,omitempty"`
}
Fields
  • Type string `json:"type"`

    "mcp"

  • ToolName string `json:"toolName"`
  • Description string `json:"description,omitempty"`
  • Transport McpTransport `json:"transport,omitempty"`
  • InputSchema interface{} `json:"inputSchema"`
  • Example interface{} `json:"example,omitempty"`

type McpTransport

Source: extensions/types/types.go:96

McpTransport represents the transport protocol for MCP tools

type McpTransport string

type OutputConfig

Source: extensions/types/types.go:225

OutputConfig represents output configuration

type OutputConfig struct {
	Example interface{} // Example output data
	Schema  JSONSchema  // JSON Schema for the output example
}
Fields
  • Example interface{}

    Example output data

  • Schema JSONSchema

    JSON Schema for the output example

type OutputInfo

Source: extensions/types/types.go:89

OutputInfo represents output information

type OutputInfo struct {
	Type    string      `json:"type,omitempty"`    // e.g., "json"
	Format  string      `json:"format,omitempty"`  // e.g., "application/json"
	Example interface{} `json:"example,omitempty"` // Example response
}
Fields
  • Type string `json:"type,omitempty"`

    e.g., "json"

  • Format string `json:"format,omitempty"`

    e.g., "application/json"

  • Example interface{} `json:"example,omitempty"`

    Example response

type QueryDiscoveryExtension

Source: extensions/types/types.go:189

QueryDiscoveryExtension represents a discovery extension for query methods

type QueryDiscoveryExtension struct {
	Info   QueryDiscoveryInfo `json:"info"`
	Schema JSONSchema         `json:"schema"`
}
Fields
  • Info QueryDiscoveryInfo `json:"info"`
  • Schema JSONSchema `json:"schema"`

type QueryDiscoveryInfo

Source: extensions/types/types.go:57

QueryDiscoveryInfo represents discovery info for query parameter methods (GET, HEAD, DELETE)

type QueryDiscoveryInfo struct {
	Input  QueryInput  `json:"input"`
	Output *OutputInfo `json:"output,omitempty"`
}
Fields
  • Input QueryInput `json:"input"`
  • Output *OutputInfo `json:"output,omitempty"`

type QueryInput

Source: extensions/types/types.go:63

QueryInput represents input information for query parameter methods

type QueryInput struct {
	Type        string                 `json:"type"` // "http"
	Method      QueryParamMethods      `json:"method"`
	QueryParams map[string]interface{} `json:"queryParams,omitempty"`
	PathParams  map[string]interface{} `json:"pathParams,omitempty"`
	Headers     map[string]string      `json:"headers,omitempty"`
}
Fields
  • Type string `json:"type"`

    "http"

  • Method QueryParamMethods `json:"method"`
  • QueryParams map[string]interface{} `json:"queryParams,omitempty"`
  • PathParams map[string]interface{} `json:"pathParams,omitempty"`
  • Headers map[string]string `json:"headers,omitempty"`

type QueryParamMethods

Source: extensions/types/types.go:30

QueryParamMethods are HTTP methods that use query parameters

type QueryParamMethods string