x402
x402 copied to clipboard
Add x402-middy package for AWS Lambda integration
Implement Middy middleware for AWS Lambda functions following x402 Payment Protocol:
- Support both EVM and Solana (SVM) networks
- Payment verification and settlement flow
- Coinbase Onramp session token integration
- Comprehensive test coverage (29 tests)
- Follow x402-express conventions
Description
This PR adds a new x402-middy package that provides Middy middleware for integrating the x402 Payment Protocol with AWS Lambda functions.
The implementation follows the same conventions and patterns as the existing x402-express package, adapted for the AWS Lambda/Middy ecosystem.
Key Features:
- Middy middleware for AWS Lambda functions (APIGatewayProxyEvent/APIGatewayProxyResult)
- Support for both EVM networks (Ethereum, Base, etc.) and Solana networks (SVM)
- Complete payment verification and settlement flow using x402 facilitator
- Optional Coinbase Onramp integration for session token generation
- Comprehensive documentation with Serverless Framework and AWS SAM examples
Files Added:
typescript/packages/x402-middy/src/index.ts- Main Middy middlewaretypescript/packages/x402-middy/src/session-token.ts- Lambda handler for Coinbase Onramp session tokenstypescript/packages/x402-middy/src/index.test.ts- Middleware tests (15 tests)typescript/packages/x402-middy/src/session-token.test.ts- Session token tests (14 tests)typescript/packages/x402-middy/README.md- Complete documentation with examples
Tests
All tests pass (29/29):
$ cd typescript/packages/x402-middy && pnpm test
✓ src/session-token.test.ts (14 tests)
✓ src/index.test.ts (15 tests)
Test Files 2 passed (2)
Tests 29 passed (29)
Test Coverage:
- Payment verification and settlement flow
- Error handling (verification errors, settlement failures)
- EVM and Solana network support
- Session token integration
- Browser paywall HTML rendering
- Edge cases (missing headers, invalid payments, unsuccessful settlements)
Checklist
- [x] I have formatted and linted my code
- [x] All new and existing tests pass
- [x] My commits are signed (required for merge)
🟡 Heimdall Review Status
| Requirement | Status | More Info | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Reviews |
🟡
0/1
|
Denominator calculation
|
@junbeomlee is attempting to deploy a commit to the Coinbase Team on Vercel.
A member of the Team first needs to authorize it.