{"_id":"@blueagent/x402-guard","name":"@blueagent/x402-guard","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@blueagent/x402-guard","version":"1.0.0","description":"Security middleware for x402 payments — check before you pay","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"tsc","prepublishOnly":"tsc"},"keywords":["x402","security","blueagent","web3","ai-agents","usdc","base"],"license":"MIT","dependencies":{"viem":"^2.0.0","x402-fetch":"^0.3.0"},"devDependencies":{"@types/node":"^20.0.0","typescript":"^5.4.0"},"repository":{"type":"git","url":"git+https://github.com/madebyshun/blueagent-x402-services.git"},"_id":"@blueagent/x402-guard@1.0.0","gitHead":"b5e7795344785c8ca8bd6c745621e49cab2eec0e","bugs":{"url":"https://github.com/madebyshun/blueagent-x402-services/issues"},"homepage":"https://github.com/madebyshun/blueagent-x402-services#readme","_nodeVersion":"22.22.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-81XlbRUsNlAxXn8NNiYFNv0OjS2c6PwHzfKlbnMmX/Jw14v78t4gT0+l1NHGEb8xkhd8vtOSznN0LqqbnreWUQ==","shasum":"d35a1649def6d8e6481d71b43dd2a221af3cd5b1","tarball":"https://registry.npmjs.org/@blueagent/x402-guard/-/x402-guard-1.0.0.tgz","fileCount":11,"unpackedSize":24038,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCl+uTTP8TWZYRzIYOiH2vPSGhf70Rc3s+11VjfZLFB7AIhAJ56tOADhjnPnSMi9gpDvZwIePdSy2JzN1RSr4wMstl3"}]},"_npmUser":{"name":"madebyshun","email":"ststudios.hr@gmail.com"},"directories":{},"maintainers":[{"name":"madebyshun","email":"ststudios.hr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402-guard_1.0.0_1777569816557_0.05010291080327556"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-30T17:23:36.452Z","1.0.0":"2026-04-30T17:23:36.692Z","modified":"2026-04-30T17:23:36.922Z"},"maintainers":[{"name":"madebyshun","email":"ststudios.hr@gmail.com"}],"description":"Security middleware for x402 payments — check before you pay","homepage":"https://github.com/madebyshun/blueagent-x402-services#readme","keywords":["x402","security","blueagent","web3","ai-agents","usdc","base"],"repository":{"type":"git","url":"git+https://github.com/madebyshun/blueagent-x402-services.git"},"bugs":{"url":"https://github.com/madebyshun/blueagent-x402-services/issues"},"license":"MIT","readme":"# @blueagent/x402-guard\n\nSecurity middleware for x402 payments — check before you pay.\n\nRuns BlueAgent security checks (honeypot detection, phishing scan, contract trust, risk gate) on payment recipients before your agent sends USDC via x402.\n\n## Install\n\n```bash\nnpm install @blueagent/x402-guard\n```\n\n## Quick Start\n\n```ts\nimport { X402Guard } from '@blueagent/x402-guard'\n\nconst guard = new X402Guard({\n  wallet: process.env.PRIVATE_KEY!, // 0x...\n})\n\n// Check an address before paying\nconst result = await guard.check('0xRecipientAddress')\nif (!result.allowed) {\n  console.log('Blocked:', result.verdict, result.score)\n}\n```\n\n## Wrap fetch (recommended)\n\nAutomatically intercepts x402 payment flows and checks the recipient before your agent pays:\n\n```ts\nimport { X402Guard, X402GuardError } from '@blueagent/x402-guard'\n\nconst guard = new X402Guard({\n  wallet: process.env.PRIVATE_KEY!,\n  checks: ['honeypot', 'phishing', 'risk-gate'],\n  blockOn: 'SUSPICIOUS',\n})\n\nconst safeFetch = guard.wrapFetch(fetch)\n\ntry {\n  const res = await safeFetch('https://some-api.com/endpoint')\n  // payment was checked and sent safely\n} catch (err) {\n  if (err instanceof X402GuardError) {\n    console.log('Blocked payment:', err.result.verdict)\n  }\n}\n```\n\n## Express Middleware\n\nProtect your x402 server from suspicious agents paying you:\n\n```ts\nimport express from 'express'\nimport { X402Guard } from '@blueagent/x402-guard'\n\nconst guard = new X402Guard({ wallet: process.env.PRIVATE_KEY! })\nconst app = express()\n\napp.use(guard.middleware())\n\napp.post('/my-service', (req, res) => {\n  // only reached if the paying agent passed the guard\n  res.json({ result: 'ok' })\n})\n```\n\n## Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `wallet` | `string` | required | Private key (`0x...`) to pay for checks via x402 |\n| `checks` | `CheckName[]` | `['honeypot', 'risk-gate']` | Which checks to run |\n| `blockOn` | `Verdict` | `'SUSPICIOUS'` | Block if verdict is at or above this level |\n| `timeout` | `number` | `5000` | Timeout per check in ms |\n| `onBlock` | `(result) => void` | `() => {}` | Called when a payment is blocked |\n\n## Checks\n\n| Check | What it detects |\n|-------|----------------|\n| `honeypot` | Token/contract honeypot traps |\n| `phishing` | Known phishing addresses |\n| `contract-trust` | Contract risk score (unverified, risky patterns) |\n| `risk-gate` | Aggregate risk decision (BLOCK / WARN / APPROVE) |\n\n## Verdicts\n\n`SAFE` → `WARN` → `SUSPICIOUS` → `BLOCK` → `HONEYPOT` (ascending risk)\n\nBy default, `SUSPICIOUS` and above are blocked. Set `blockOn: 'BLOCK'` to only block confirmed threats.\n\n## Powered by\n\n[BlueAgent x402 Cloud](https://blueagent.dev) — 31 AI-agent security and intelligence tools on Base, paid per-call via the x402 protocol.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-d24620c9f430155d26bd00ba3aeaed53"}