-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(extensions): SIWX Extension #921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implements CAIP-122 compliant wallet-based identity assertions for x402 v2. - Add SIWX types following CAIP-122 standard - Server-side: declareSIWxExtension() for 402 response generation - Client-side: createSIWxPayload() for proof creation and signing - Message construction following CAIP-122 format - Header encoding/parsing (base64 per x402 v2 spec) - Validation: temporal, domain binding, nonce checking - Verification: cryptographic signature validation via siwe library - JSON Schema generation for payload validation - Test coverage for core flows
🟡 Heimdall Review Status
|
|
@sragss is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
…Solana CAIP-2 compliant; rm clockskew slop
CarsonRoscoe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work @sragss, thank you, will give this a review shortly
|
Thanks for your contribution @sragss, excited for this! @CarsonRoscoe shall we have a spec document for extensions as well, like we have for schemes and transports? There is none for the discovery extension, but might be worth to add, especially for 3rd party sdk devs |
|
@phdargen Agreed, we should have a top level /specs/extensions folder with specs per extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sragss!
This is looking really good. Very happy with it from my readings,
My two asks are:
- Can you add a
/specs/extensions/sign-in-with-x.mdfile outlining the spec as implemented? This will become the north start to ensure Go/Python implementations remain compatible - Can you integrate these into an example for testing. For example, a
/examples/typescript/clients/sign-in-with-x(using fetch) and/examples/typescript/servers/sign-in-with-x(using express) example that can be run to showcase how a client/server could leverage this extension to prove a client already paid? I'm imagining when running these examples, the flow would be that the server caches payments in memory, and is able to skip payments for clients who already paid. Then the first client run would make payment, while the second one would get the resource without needing payment due to siwx?
Please include a run of the client & server examples in your PR afterwards, we'll consider it additional testing
Great work, I think the examples & spec are all that I need to feel comfortable merging :)
Update lockfile to include @types/node added to client example. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Done. Update 1/17/25
Implementation note: we use conditional middleware in the Example logs Client |
fa2e3c7 to
8f445df
Compare
Adds a fetch wrapper for SIWX authentication that mirrors the wrapFetchWithPayment pattern from @x402/fetch. The wrapper automatically handles 402 responses with SIWX extension info. Changes: - Add fetch.ts with wrapFetchWithSIWx function - Export wrapFetchWithSIWx from sign-in-with-x index - Add DOM lib to tsconfig for Request/Response types - Simplify client example to use the new wrapper - Add .prettierignore and eslint globals to match other examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
8f445df to
24f0eb2
Compare
Implements CAIP-122 compliant Sign-In-With-X (SIWX) extension for x402 v2 protocol aligned with CHANGELOG-v2.md and sign-in-with-x/TODO.md.
Supported Signature Schemes
eip191- personal_sign (EOAs)eip1271- Smart contract walletseip6492- Counterfactual smart walletssiws- Sign-In-With-SolanaMissing: EIP-712 + Stellar.
Note the interface for using Smart Wallets is a bit odd, didn't want to bake the RPC into a generic extension.
Update 1/17/25
spec.mdwrapFetchWithSIWxexported from@x402/extensions/siwxto matchwrapFetchWithPayexamples/typescript/{client,server}/sign-in-with-xImplementation note: we use conditional middleware in the
serverexample. I considered putting special logic intopaymentMiddlewarebut decided that was against the premise of optional extensions. Another pattern that could be clean would be to put askipIf: (req) => boollambda as an optional param in thepaymentMiddlewarewhich takes the simple SIWx verification function.Example logs
Server
Client