{"_id":"@darkhorseone/x402-core","name":"@darkhorseone/x402-core","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@darkhorseone/x402-core","version":"1.0.0","description":"Core framework-agnostic implementation of the x402 HTTP payment protocol.","author":{"name":"DarkhorseOne Limited"},"repository":{"type":"git","url":"git+https://github.com/DarkhorseOne/x402-core.git"},"homepage":"https://github.com/DarkhorseOne/x402-core","bugs":{"url":"https://github.com/DarkhorseOne/x402-core/issues"},"keywords":["x402","payment","protocol","middleware","framework-agnostic"],"main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"build":"tsc -p tsconfig.json","test":"vitest run"},"license":"MIT","devDependencies":{"@types/node":"^20.12.7","typescript":"^5.4.5","vitest":"^4.0.15"},"_id":"@darkhorseone/x402-core@1.0.0","gitHead":"9641454399e074aae6ea515ec2aa38351829d715","_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-cWL9Bmd06EJULWTpxtm1G+2yryf48P7h++4uwtf/oAqKFIvj4UqkIcLOqxZV/xXnth1jbWLbQgKQ0LqL4U6oSQ==","shasum":"da2ae2573443919b88a0641b9d8b4494ab2f07a2","tarball":"https://registry.npmjs.org/@darkhorseone/x402-core/-/x402-core-1.0.0.tgz","fileCount":61,"unpackedSize":76791,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDCr3hluYagTMW+kmTW845NLw0PGmQB+YTOEv333Bj/eAiAc9ey14uU0hSmfxy6XiDoNCVVcq0gZu4muf5oRllWIDg=="}]},"_npmUser":{"name":"nick-ma","email":"honeyday.mj@gmail.com"},"directories":{},"maintainers":[{"name":"nick-ma","email":"honeyday.mj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402-core_1.0.0_1765498601273_0.11487928408505677"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-12T00:16:41.140Z","1.0.0":"2025-12-12T00:16:41.427Z","modified":"2025-12-12T00:16:41.801Z"},"maintainers":[{"name":"nick-ma","email":"honeyday.mj@gmail.com"}],"description":"Core framework-agnostic implementation of the x402 HTTP payment protocol.","homepage":"https://github.com/DarkhorseOne/x402-core","keywords":["x402","payment","protocol","middleware","framework-agnostic"],"repository":{"type":"git","url":"git+https://github.com/DarkhorseOne/x402-core.git"},"author":{"name":"DarkhorseOne Limited"},"bugs":{"url":"https://github.com/DarkhorseOne/x402-core/issues"},"license":"MIT","readme":"# x402-core\n\nFramework-agnostic core for the x402 HTTP payment standard. This package builds `402 Payment Required` responses, extracts payment credentials, and verifies payments through a facilitator API — all without any framework or storage dependencies (Phase 0 is fully stateless).\n\n## Status\n- Phase 0 scope only: no DB, Redis, queues, or credit fallback; `fallbackMode` must be `\"deny\"`.\n- Node.js ≥ 20, TypeScript ≥ 5, strict mode enabled.\n\n## Install\n```bash\nnpm install @darkhorseone/x402-core\n```\n\n## Quick Start\n```ts\nimport {\n  PaymentRequirementBuilder,\n  PaymentCredentialExtractor,\n  HttpFacilitatorAdapter,\n  type X402Config,\n} from \"@darkhorseone/x402-core\";\n\nconst config: X402Config = {\n  facilitatorUrl: \"https://facilitator.example.com\",\n  defaultNetwork: \"base-mainnet\",\n  defaultAsset: \"USDC\",\n  sellerWallet: \"0x123...\",\n  fallbackMode: \"deny\",\n};\n\nconst builder = new PaymentRequirementBuilder(config);\nconst requirement = builder.build({ price: \"1.0\", description: \"API access\" });\n\nconst extractor = new PaymentCredentialExtractor();\nconst credential = extractor.extract(request); // header, body, or query param\n\nconst facilitator = new HttpFacilitatorAdapter(config);\nconst result = await facilitator.verifyPayment(credential);\n```\n\n## Project Layout\n- `src/config/` config types and helpers (e.g., `X402Config`).\n- `src/payment/` payment requirement builder, credential extraction, verification interfaces.\n- `src/facilitator/` facilitator client contracts and HTTP adapter.\n- `src/errors/` typed errors (`PaymentRequiredError`, `PaymentInvalidError`, etc.).\n- `src/utils/` shared utilities (logger, request ids).\n- `docs/DESIGN.md` architecture and Phase 0 scope; `docs/DEV_STANDARDS.md` coding/testing standards.\n\n## Configuration (core fields)\n`X402Config` includes `facilitatorUrl`, `defaultNetwork`, `defaultAsset`, `sellerWallet`, optional `apiKey`, and optional `tenantResolver`/`logger`. Phase 0 enforces `fallbackMode: \"deny\"`. Use `validateConfig(config)` to guard required fields early.\n\n## Development\n- `npm run build` — compile with `tsc` (ES2022 output, declarations + source maps to `dist/`).\n- `npm test` — run Vitest suite (credential extraction, requirement builder, verifier, HTTP facilitator adapter).\n- Export new modules through `src/index.ts` to keep the public API consistent.\n\n## Error Handling\nUse the provided typed errors from `src/errors/` rather than generic `Error`. Facilitator outages should map to `PaymentNetworkError`.\n\n## Contributing\nFollow the architecture and style rules in `docs/DESIGN.md` and `docs/DEV_STANDARDS.md`. Keep implementations stateless, framework-agnostic, and free of external runtime dependencies.\n","readmeFilename":"README.md","_rev":"1-efe1cf239d53d80b76e0d7ec95f32148"}