{"_id":"@bit-gpt/h402-hono","name":"@bit-gpt/h402-hono","dist-tags":{"latest":"0.0.8"},"versions":{"0.0.8":{"name":"@bit-gpt/h402-hono","version":"0.0.8","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/index.d.ts","keywords":[],"license":"Apache-2.0","author":{"name":"BitGPT"},"repository":{"type":"git","url":"git+https://github.com/bit-gpt/h402.git"},"description":"h402 Payment Protocol","devDependencies":{"@eslint/js":"^9.24.0","@types/node":"^22.13.4","@typescript-eslint/eslint-plugin":"^8.29.1","@typescript-eslint/parser":"^8.29.1","eslint":"^9.24.0","eslint-plugin-import":"^2.31.0","eslint-plugin-jsdoc":"^50.6.9","eslint-plugin-prettier":"^5.2.6","prettier":"3.5.2","tsup":"^8.4.0","tsx":"^4.19.2","typescript":"^5.7.3","vite-tsconfig-paths":"^5.1.4","vite":"^6.2.6"},"dependencies":{"hono":"^4.7.1","viem":"^2.21.26","zod":"^3.24.2","@bit-gpt/h402":"^0.0.22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.mts","default":"./dist/esm/index.mjs"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.js"}}},"scripts":{"start":"tsx --env-file=.env index.ts","build":"tsup","watch":"tsc --watch","format":"prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"","format:check":"prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"","lint":"eslint . --ext .ts --fix","lint:check":"eslint . --ext .ts"},"_id":"@bit-gpt/h402-hono@0.0.8","bugs":{"url":"https://github.com/bit-gpt/h402/issues"},"homepage":"https://github.com/bit-gpt/h402#readme","_integrity":"sha512-ua9yy7DLkw6vZToMGkDRwAwCGANgDxFVdU+PQ5GEWdE63btnFvJfyIxGJ/2xEo9QT/MhiLy4Pmc4fRiZrz0kAQ==","_resolved":"/tmp/e42642a806961039adb0c1a4cdf18bc5/bit-gpt-h402-hono-0.0.8.tgz","_from":"file:bit-gpt-h402-hono-0.0.8.tgz","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-ua9yy7DLkw6vZToMGkDRwAwCGANgDxFVdU+PQ5GEWdE63btnFvJfyIxGJ/2xEo9QT/MhiLy4Pmc4fRiZrz0kAQ==","shasum":"2c3c6827376133e33643edc1035e06ddc810f1b9","tarball":"https://registry.npmjs.org/@bit-gpt/h402-hono/-/h402-hono-0.0.8.tgz","fileCount":9,"unpackedSize":63841,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEZNmvnINfy6EZSn3oV+6hqnXKXrFuchUhHgGYJ0sJ88AiAqBeiE64LQQK/U8fFMtritgvsz4BbtHnXUf4I/X7VDMA=="}]},"_npmUser":{"name":"bit-gpt","email":"dan@bitgpt.xyz"},"directories":{},"maintainers":[{"name":"bit-gpt","email":"dan@bitgpt.xyz"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/h402-hono_0.0.8_1762531378497_0.8322961157941746"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-07T16:02:58.350Z","0.0.8":"2025-11-07T16:02:58.700Z","modified":"2025-11-07T16:02:59.029Z"},"maintainers":[{"name":"bit-gpt","email":"dan@bitgpt.xyz"}],"description":"h402 Payment Protocol","homepage":"https://github.com/bit-gpt/h402#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/bit-gpt/h402.git"},"author":{"name":"BitGPT"},"bugs":{"url":"https://github.com/bit-gpt/h402/issues"},"license":"Apache-2.0","readme":"# h402-hono\n\nHono middleware integration for the x402 Payment Protocol. This package allows you to easily add paywall functionality to your Hono applications using the x402 protocol.\n\n## Installation\n\n```bash\nnpm install @bit-gpt/h402-hono\n```\n\n## Quick Start\n\n## Single Network Example\n\n```typescript\nimport { Hono } from \"hono\";\nimport { paymentMiddleware } from \"@bit-gpt/h402-hono\";\n\nconst app = new Hono();\n\n// Configure the payment middleware\napp.use(paymentMiddleware(\n  {\n    \"/protected-route\": createRouteConfigFromPrice(\"$0.1\", \"bsc\", \"0xYourEVMAddress\") // This doesn't work with Arkade Network\n  }\n));\n\n// Implement your route\napp.get(\"/protected-route\", (c) => {\n  return c.json({ message: \"This content is behind a paywall\" });\n});\n\nserve({\n  fetch: app.fetch,\n  port: 3000\n});\n```\n\n## Multiple Networks Example\n\n```typescript\nimport { Hono } from \"hono\";\nimport { paymentMiddleware } from \"@bit-gpt/h402-hono\";\n\nconst app = new Hono();\n\n// Configure the payment middleware\napp.use(\n  paymentMiddleware(\n    {\n      \"/protected-route\": {\n        paymentRequirements: [\n          {\n            scheme: \"exact\",\n            namespace: \"evm\",\n            tokenAddress: \"0x55d398326f99059ff775485246999027b3197955\", // USDT on BSC\n            amountRequired: 0.01,\n            amountRequiredFormat: \"humanReadable\",\n            networkId: \"56\",\n            payToAddress: \"0xYourEVMAddress\",\n            description: \"Premium content access with USDT on BSC\",\n            tokenDecimals: 18,\n            tokenSymbol: \"USDT\",\n          },\n          {\n            scheme: \"exact\",\n            namespace: \"evm\",\n            tokenAddress: \"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2\", // USDT on Base\n            amountRequired: 0.01, \n            amountRequiredFormat: \"humanReadable\", \n            networkId: \"8453\", \n            payToAddress: \"0xYourEVMAddress\",\n            description: \"Premium content access with USDT on Base\",\n            tokenDecimals: 6,\n            tokenSymbol: \"USDT\",\n          },\n          {\n            scheme: \"exact\",\n            namespace: \"solana\",\n            tokenAddress: \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\", // USDC on Solana\n            amountRequired: 0.01,\n            amountRequiredFormat: \"humanReadable\",\n            networkId: \"mainnet\",\n            payToAddress: \"YourSolanaAddress\",\n            description: \"Premium content access with USDC on Solana\",\n            tokenDecimals: 6,\n            tokenSymbol: \"USDC\",\n          },\n          {\n            scheme: \"exact\",\n            namespace: \"arkade\",\n            amountRequired: 0.00001, // Amount should be more than dust amount otherwise it will be rejected\n            amountRequiredFormat: \"humanReadable\",\n            networkId: \"bitcoin\",\n            payToAddress: \"YourArkadeAddress\",\n            description: \"Premium content access with BTC via Arkade\",\n            tokenSymbol: \"BTC\",\n            tokenDecimals: 8,\n          },\n        ],\n      },\n    }\n  ),\n);\n\n// Implement your route\napp.get(\"/protected-route\", (c) => {\n  return c.json({ message: \"This content is behind a paywall\" });\n});\n\nserve({\n  fetch: app.fetch,\n  port: 3000\n});\n```\n\n## Configuration\n\nThe `paymentMiddleware` function accepts three parameters:\n\n1. `routes`: Route configurations for protected endpoints (required)\n2. `facilitator`: (Optional) Configuration for the h402 facilitator service\n\nSee the Middleware Options section below for detailed configuration options.\n\n## Middleware Options\n\nThe middleware supports various configuration options:\n\n### Route Configuration\n\n```typescript\ntype RoutesConfig = Record<string, RouteConfig>;\n\ntype RouteConfig = {\n  paymentRequirements: PaymentRequirements[];\n};\n```\n\nEach route can be configured with either:\n- A simple `Price` (string like `\"$0.01\"` or `Money` type) - this will be automatically converted to a `RouteConfig`\n- A full `RouteConfig` object with detailed `paymentRequirements` array\n\n### Facilitator Configuration\n\n```typescript\ntype FacilitatorConfig = {\n  url: Resource;                      // URL of the h402 facilitator service\n  createAuthHeaders?: CreateHeaders;  // Optional function to create authentication headers\n};\n```\n","readmeFilename":"README.md","_rev":"1-78c5ac5b60711f63284de1312debc3fc"}