Skip to content

feat: add attestation extension for third-party verification#26

Closed
A1igator wants to merge 2 commits into
mainfrom
A1igator/attestation-extension
Closed

feat: add attestation extension for third-party verification#26
A1igator wants to merge 2 commits into
mainfrom
A1igator/attestation-extension

Conversation

@A1igator
Copy link
Copy Markdown
Contributor

Summary

  • Generic attestation extension for third-party verification in x402 payment flows
  • Works with any scheme (escrow, exact, etc.) — not escrow-specific
  • No operatorAddress parameter — attestor manages its own identity
  • Two hooks: enrichPaymentRequiredResponse (identity in 402) + enrichSettlementResponse (acknowledgment in 200)

Usage

import { createAttestationExtension, declareAttestationExtension } from "@x402r/evm/extensions/attestation";

// Merchant setup
const resourceServer = new x402ResourceServer(facilitatorClient)
  .registerExtension(createAttestationExtension("https://arbiter.example.com"));

// Route config (only escrow routes, or any route)
app.use(paymentMiddleware({
  "GET /weather": {
    accepts: [{ scheme: "escrow", ... }],
    ...declareAttestationExtension(),
  },
}, resourceServer));

Attestor API

The extension expects two endpoints on the attestor:

  • GET /identity — returns signed AttestationIdentity (role, operator, info, signature)
  • POST /verify — accepts { responseBody, transaction, network, contentHash }, returns { acknowledgment } with signed AttestationAcknowledgment

Signing utilities

For attestor implementors:

  • signAttestationIdentity(account, operator, role, info) — EIP-712 signed identity
  • signAttestationAcknowledgment(account, { operator, transaction, network, contentHash }) — EIP-712 signed acknowledgment

Test plan

  • Typecheck passes
  • Build passes
  • Integration test with garbage detector example

🤖 Generated with Claude Code

A1igator and others added 2 commits March 22, 2026 20:00
Generic extension for third-party attestations in x402 payment flows.
Works with any scheme (escrow, exact, etc.).

Server extension (merchant):
- createAttestationExtension(attestorUrl) — registers extension
- declareAttestationExtension() — scopes to specific routes
- enrichPaymentRequiredResponse: fetches signed identity from attestor
- enrichSettlementResponse: fetches signed acknowledgment from attestor

Signing utilities (attestor):
- signAttestationIdentity() — EIP-712 signed identity (role + info)
- signAttestationAcknowledgment() — EIP-712 signed ack (contentHash)

Export: @x402r/evm/extensions/attestation

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add eslint-disable for no-undef (Buffer, fetch are Node globals).
Auto-format with prettier.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@A1igator A1igator closed this Mar 23, 2026
@A1igator A1igator deleted the A1igator/attestation-extension branch March 23, 2026 03:09
@A1igator A1igator restored the A1igator/attestation-extension branch March 23, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant