-
Notifications
You must be signed in to change notification settings - Fork 883
feat: add x402 payment-gated proxy template #830
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
11d91cb to
2bdd43a
Compare
|
|
Preview link not generated: you must be on a branch, not on a fork. |
1 similar comment
|
Preview link not generated: you must be on a branch, not on a fork. |
deloreyj
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.
One change on the tests and an image, and we should be good to go!
| @@ -0,0 +1,72 @@ | |||
| import { test, expect } from "./fixtures"; | |||
|
|
|||
| test.describe("x402 Payment-Gated Proxy Template", () => { | |||
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.
The playwright tests are primarily meant to be a minimal smoke test to ensure the templates run after maintenance like dependency updates. With that in mind, I'm hesitant to test the full API in this spec file since it requires an actual wallet address. Could you keep the health endpoint tests here and move the others into a test file within the template itself?
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.
We don't actually test the full api, we stop before making the payment. So, there is no wallet requirement.
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.
Do the playwright tests run for you locally? When I try to run them I get 500s for the protected endpoints with this error
✘ [ERROR] InvalidAddressError: Address "0xYOUR_WALLET_ADDRESS_HERE" is invalid.
- Address must be a hex value of 20 bytes (40 hex characters).
- Address must match its checksum counterpart.
Version: [email protected]
at getAddress (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/viem/utils/address/getAddress.ts:79:11)
at paymentMiddleware2 (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]_@[email protected][email protected]_typescri_551d0b8b9e34c36381373de6d91ed451/node_modules/x402-hono/src/index.ts:141:16)
at null.<anonymous> (file:///Users/jdelorey/code/templates/x402-proxy-template/src/auth.ts:48:16)
at null.<anonymous> (file:///Users/jdelorey/code/templates/x402-proxy-template/src/auth.ts:95:48)
at null.<anonymous> (file:///Users/jdelorey/code/templates/x402-proxy-template/src/index.ts:77:24)
at dispatch (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/compose.js:22:23)
at null.<anonymous> (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/compose.js:5:12)
at null.<anonymous> (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/hono-base.js:201:31)
at #dispatch (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/hono-base.js:211:5)
at Hono2.fetch (file:///Users/jdelorey/code/templates/node_modules/.pnpm/[email protected]/node_modules/hono/dist/hono-base.js:214:17) {
details: undefined,
docsPath: undefined,
metaMessages: [
'- Address must be a hex value of 20 bytes (40 hex characters).',
'- Address must match its checksum counterpart.'
],
shortMessage: 'Address "0xYOUR_WALLET_ADDRESS_HERE" is invalid.',
version: '2.40.3'
}
[wrangler:info] GET /__x402/protected 500 Internal Server Error (59ms)
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.
My bad, I had some local changes that made the test pass. I've replaced the default wallet with the usual dummy address that is still valid.
Didn't you run into the missing JWT_SECRET issue or did you remember to copy the .dev.vars.example file?
c54b721 to
0c4ad15
Compare
|
|
Preview link not generated: you must be on a branch, not on a fork. |
|
|
Preview link not generated: you must be on a branch, not on a fork. |
Description
A transparent proxy template with payment-gated routes using the x402 protocol and stateless JWT cookie authentication. Includes built-in test endpoints for health checks and payment flow demonstration.
Checklist
-templatepackage.jsonis populated<!-- dash-content-start -->and<!-- dash-content-end -->to designate the Dash readme preview.gitignorefile existspackage.jsoncontains adeploycommandpackage.jsoncontainsprivate: trueand noversionfieldExample
package.json