ws402
Version:
WebSocket implementation of X402 protocol for pay-as-you-go digital resources with automatic refunds
147 lines (122 loc) โข 7.02 kB
Markdown
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.1.4] - 2025-01-13
### Fixed
- ๐ง **Solana RPC compatibility** - Replaced WebSocket subscriptions with HTTP polling for better RPC provider compatibility
- ๐ **Base58 private key parsing** - Added built-in base58 decoder, eliminating external bs58 dependency requirement
- โก **Transaction verification** - Implemented retry logic (up to 10 attempts) with 2-second intervals for blockchain transaction fetching
- ๐ **Refund confirmations** - Changed from `sendAndConfirmTransaction` to manual polling for Alchemy and other RPC providers without WebSocket support
- ๐ฏ **Transaction structure** - Simplified reference tracking by adding it as readonly key to main instruction instead of creating separate empty instruction
- ๐ฐ **Payment amounts** - Fixed display formatting with proper lamports to SOL conversion
- ๐ก๏ธ **Error handling** - Improved error messages and fallbacks throughout entire payment flow
- ๐ **Browser compatibility** - Replaced Node.js `Buffer` with browser-native `Uint8Array`
### Added
- ๐ **Enhanced logging** - Added detailed transaction fetching status and retry attempt tracking
- ๐ **Debug information** - Comprehensive debug output for payment verification process
- โฑ๏ธ **Configurable timeouts** - Transaction verification with exponential backoff and maximum retry limits
- ๐ **RPC endpoint proxy** - Added `/blockhash` server endpoint for secure blockhash retrieval without exposing API keys to clients
- ๐ **Better error messages** - User-friendly error messages for common issues (insufficient balance, network errors, etc.)
### Changed
- ๐ฆ **Dependencies** - Removed hard dependency on bs58 package (now uses built-in base58 decoder)
- ๐ **Connection method** - Improved compatibility with various Solana RPC providers (Alchemy, Helius, QuickNode, public endpoints)
- ๐ต **Default pricing** - Reduced example pricing from 0.03 SOL to 0.003 SOL for more accessible testing
- ๐ **Security** - Merchant RPC endpoint only used server-side via `/blockhash` proxy, never exposed to client
### Technical Details
- **RPC provider support** - Works with any Solana RPC provider, including those without WebSocket support (Alchemy, Helius)
- **Transaction confirmation** - Uses HTTP polling-based confirmation (getSignatureStatus) instead of WebSocket subscriptions (signatureSubscribe)
- **Payment verification** - Retry logic handles transaction propagation delays across RPC nodes
- **Refund system** - Automatic refunds work reliably even with rate-limited or WebSocket-less RPC endpoints
- **Client architecture** - Browser client uses Phantom's built-in transaction handling, only needs blockhash from server
- **Base58 encoding** - Custom implementation included to avoid dependency issues in different environments
### Developer Experience
- ๐ **Easier setup** - Fewer dependencies to install and configure
- ๐ **Better debugging** - Detailed logs show exactly where in the process things succeed or fail
- ๐ **Clearer errors** - Actionable error messages guide users to solutions
- ๐ง **More flexible** - Works with any Solana RPC provider, not just ones with full WebSocket support
## [0.1.0] - 2025-01-12
### Added
#### Core Features
- โจ Initial release of WS402 library
- ๐ Core WS402 protocol implementation
- ๐ WebSocket session management with real-time tracking
- โก Real-time usage metering (time, bytes, messages)
- ๐ฐ Automatic refund system for unused balance
- ๐ Payment provider interface with multiple implementations
- ๐ Comprehensive session lifecycle management
- ๐ฏ Event system for monitoring and callbacks
- ๐ TypeScript support with full type definitions
- ๐ ๏ธ Express middleware helpers for easy integration
#### Payment Providers
- ๐งช **MockPaymentProvider** - For development and testing
- โก **BasePaymentProvider** - Base blockchain (Ethereum L2) integration
- Native ETH payments on Base network
- ERC20 token support (USDC, etc.)
- On-chain payment verification
- Automatic on-chain refunds
- Support for Base mainnet, Goerli, and Sepolia testnets
- Low fees (~$0.01) and fast confirmations (2-5 seconds)
- ๐ **SolanaPaymentProvider** - Solana blockchain integration
- Native SOL payments
- SPL token support (USDC, USDT, etc.)
- Solana Pay QR code generation
- On-chain payment verification
- Automatic on-chain refunds
- Ultra-low fees (~$0.0001) and sub-second confirmations
- Support for mainnet-beta, devnet, and testnet
- ๐ฆ **ProxyPaymentProvider** - Centralized gateway architecture
- Delegates payment operations to external gateway
- No private keys on WS402 servers
- Horizontal scalability for enterprise deployments
- Retry logic with exponential backoff
- Health check monitoring
- API key authentication
#### Architecture & Security
- ๐๏ธ Proxy architecture for enterprise deployments
- ๐ Secure private key management with environment variables
- ๐ก๏ธ Comprehensive security documentation
- ๐ก Payment gateway server implementation
- ๐ Automatic refund processing on blockchain
- โ๏ธ Configurable conversion rates and pricing
#### Examples & Documentation
- ๐ Complete working examples for all providers
- ๐จ HTML client implementations with wallet integrations
- ๐ Comprehensive documentation
- ๐จ TypeScript compilation with development tools
---
## Future Plans
### [0.2.0] - Planned Q1 2025
- ๐ Bitcoin Lightning Network support
- ๐ Enhanced metrics and analytics dashboard
- ๐งช Comprehensive test suite with Jest
- ๐ Session persistence and resumption
- โก Rate limiting and throttling
- ๐ Additional blockchain integrations
- ๐ฑ Client SDK libraries (JavaScript, Python, Go)
### [0.3.0] - Planned Q2 2025
- ๐ฎ WebRTC support for real-time communications
- ๐ Distribution pool for maintainer rewards
- ๐ Multi-signature wallet support
- ๐ GraphQL API endpoint
- ๐ Built-in analytics and reporting
### [1.0.0] - Planned Q3 2025
- ๐ Production-ready stable release
- ๐ข Enterprise features and SLA guarantees
- ๐ Advanced security auditing
- ๐ Comprehensive benchmarking
- ๐ Multi-region deployment support
---
## Links
- ๐ฆ NPM Package: https://npmjs.com/package/ws402
- ๐ป GitHub Repository: https://github.com/ws402/ws402
- ๐ Website: https://ws402.org
- ๐ Documentation: https://docs.ws402.org
- ๐ฌ Community Discord: https://discord.gg/ws402
- ๐ฆ Twitter/X: https://x.com/ws402org
- ๐ Farcaster: https://farcaster.xyz/ws402
---
[Unreleased]: https://github.com/ws402/ws402/compare/v0.1.4...HEAD
[0.1.4]: https://github.com/ws402/ws402/compare/v0.1.0...v0.1.4
[0.1.0]: https://github.com/ws402/ws402/releases/tag/v0.1.0