feat: x402 micropayment gate for voice sessions#1
Merged
SwarnimWalavalkar merged 1 commit intodevfolioco:mainfrom Mar 19, 2026
Merged
Conversation
Gate voice sessions behind Delve's x402 payment infrastructure. Users connect a wallet, sign an ERC-3009 USDC authorization, and receive a single-use JWT that unlocks LiveKit access. API changes: - connection-details route validates JWT (jose) when VOICE_SESSION_JWT_SECRET is set - Single-use enforcement via in-memory jti Set (cleared every 15 min) - Without the secret, free access is preserved (dev mode) Frontend changes: - PaymentGate component shown before voice session when NEXT_PUBLIC_DELVE_API_URL is set - useVoiceSession hook manages wallet → sign → pay → session flow - Ported x402 payment header builder from unified-webapp (lib/payment/) - wagmi/AppKit init updated to support payment gate independent of Zora minting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
SwarnimWalavalkar
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Architecture
What changed
API (
client/app/api/connection-details/route.ts)VOICE_SESSION_JWT_SECRETis set, requires a valid session JWT via?session_token=query param orAuthorization: Bearerheadersession_type === "voice", expiration, and single-usejtiSet<string>cleared every 15 minutes402(no token),401(invalid/expired),409(already used)Frontend (
client/app/talk/page.tsx+ new components)PaymentGatecomponent renders before voice session whenNEXT_PUBLIC_DELVE_API_URLis setDISCONNECTED → WALLET_CONNECTED → SIGNING → PAYMENT_PENDING → SESSION_READY → voice beginsuseVoiceSessionhook manages the full wallet → sign → pay → token flowlib/payment/) from unified-webapp (ERC-3009 TransferWithAuthorization)Wallet config (
config/wagmi.ts,context/AppKitContext.tsx)Dependencies
josefor JWT verification in the API routeSetup
Environment Variables (
client/.env.local)To enable the payment gate:
client/.env.localVOICE_SESSION_JWT_SECRETand exposesPOST /paid/voice/sessionpnpm install && pnpm devTo keep free access (dev/testing):
NEXT_PUBLIC_DELVE_API_URL— the payment gate is bypassed entirelyVOICE_SESSION_JWT_SECRET— the API route skips JWT validationTest plan
VOICE_SESSION_JWT_SECRETset but no token:/api/connection-detailsreturns 402🤖 Generated with Claude Code