{"_id":"@abbox/guard","name":"@abbox/guard","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@abbox/guard","version":"1.0.0","description":"Official SDK for integrating Abbox Guard into your application","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build","test":"echo \"Error: no test specified\" && exit 1"},"keywords":["abbox","guard","ai","security","policy","compliance"],"author":{"name":"Abbox"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/elchuzade/abbox-guard-sdk.git"},"bugs":{"url":"https://github.com/elchuzade/abbox-guard-sdk/issues"},"homepage":"https://github.com/elchuzade/abbox-guard-sdk#readme","engines":{"node":">=18.0.0"},"devDependencies":{"@types/node":"^20.0.0","typescript":"^5.0.0"},"_id":"@abbox/guard@1.0.0","gitHead":"2cde12d25604b7bc264c80850f0664791723ecb8","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-CILu7NOmB0Q8YpG9LO2v8icQwmv3ToVfbKHHkgG08i5GpzvZc+EJwtSoqA3yG54GA+q/vDqCF+wsdB5djJC2mA==","shasum":"031969de4c75464993458d6841735ad8f9ac6c11","tarball":"https://registry.npmjs.org/@abbox/guard/-/guard-1.0.0.tgz","fileCount":6,"unpackedSize":18409,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC0E/8QOxTe3UnlG2gYJWCtkhvZjhEBn4hkTC0e2Iv9nAIhAJDNedV4q8J/WvEoNURGAVe2MrSTWGPJRynS153ZRppC"}]},"_npmUser":{"name":"elchuzade","email":"elchuzade@gmail.com"},"directories":{},"maintainers":[{"name":"elchuzade","email":"elchuzade@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/guard_1.0.0_1769554797344_0.9740207538167627"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-27T22:59:57.264Z","1.0.0":"2026-01-27T22:59:57.492Z","modified":"2026-01-27T22:59:57.685Z"},"maintainers":[{"name":"elchuzade","email":"elchuzade@gmail.com"}],"description":"Official SDK for integrating Abbox Guard into your application","homepage":"https://github.com/elchuzade/abbox-guard-sdk#readme","keywords":["abbox","guard","ai","security","policy","compliance"],"repository":{"type":"git","url":"git+https://github.com/elchuzade/abbox-guard-sdk.git"},"author":{"name":"Abbox"},"bugs":{"url":"https://github.com/elchuzade/abbox-guard-sdk/issues"},"license":"MIT","readme":"# @abbox/guard\n\nOfficial SDK for integrating [Abbox Guard](https://abbox.com) into your application. Protect your AI prompts with policy-based validation in just a few lines of code.\n\n## Installation\n\n```bash\nnpm install @abbox/guard\n```\n\n## Quick Start\n\n```typescript\nimport { checkWithAbboxGuard } from \"@abbox/guard\";\n\n// Set environment variable\n// ABBOX_API_KEY=abbox_live_your_key_id_your_secret\n\nconst decision = await checkWithAbboxGuard({\n  prompt: \"Show me all customer emails\",\n  source: \"my-app\",\n  actorId: \"user-123\",\n});\n\nif (decision.decision === \"block\") {\n  console.log(\"Blocked:\", decision.reason);\n}\n```\n\n## Features\n\n- ✅ **Simple API** - One function call to check prompts\n- ✅ **Type-Safe** - Full TypeScript support\n- ✅ **Zero Dependencies** - Uses standard fetch API\n- ✅ **Flexible** - Works with any framework\n- ✅ **Error Handling** - Fail-open and fail-closed patterns\n- ✅ **Timeout Support** - Configurable request timeouts\n\n## Usage\n\n### Basic Example\n\n```typescript\nimport { checkWithAbboxGuard, shouldBlock } from \"@abbox/guard\";\n\napp.post(\"/api/chat\", async (req, res) => {\n  const { prompt, userId } = req.body;\n\n  const decision = await checkWithAbboxGuard({\n    prompt,\n    source: \"my-app\",\n    actorId: userId,\n  });\n\n  if (shouldBlock(decision)) {\n    return res.status(403).json({\n      error: \"prompt_blocked\",\n      reason: decision.reason,\n    });\n  }\n\n  // Continue with AI processing...\n});\n```\n\n### With Suggested Rewrite\n\n```typescript\nimport { checkWithAbboxGuard, hasSuggestedRewrite } from \"@abbox/guard\";\n\nconst decision = await checkWithAbboxGuard({\n  prompt: userPrompt,\n  source: \"my-app\",\n  actorId: userId,\n});\n\nif (hasSuggestedRewrite(decision)) {\n  return res.json({\n    requiresRewrite: true,\n    suggestedRewrite: decision.suggested_rewrite,\n    reason: decision.reason,\n  });\n}\n```\n\n### Fail-Open Pattern (Allow on Error)\n\n```typescript\nimport { checkWithAbboxGuardFailOpen } from \"@abbox/guard\";\n\n// If Guard is unavailable, allows the request\nconst decision = await checkWithAbboxGuardFailOpen({\n  prompt: userPrompt,\n  source: \"my-app\",\n  actorId: userId,\n});\n// Will never throw - always returns a decision\n```\n\n### Fail-Closed Pattern (Block on Error)\n\n```typescript\nimport { checkWithAbboxGuardFailClosed } from \"@abbox/guard\";\n\ntry {\n  const decision = await checkWithAbboxGuardFailClosed({\n    prompt: userPrompt,\n    source: \"my-app\",\n    actorId: userId,\n  });\n} catch (error) {\n  // Block request if Guard is unavailable\n  return res.status(503).json({ error: \"Policy check unavailable\" });\n}\n```\n\n### Custom Configuration\n\n```typescript\nimport { checkWithAbboxGuard } from \"@abbox/guard\";\n\nconst decision = await checkWithAbboxGuard(\n  {\n    prompt: userPrompt,\n    source: \"my-app\",\n    actorId: userId,\n    timeout: 10000, // 10 second timeout\n  },\n  {\n    apiKey: \"custom-key\", // Override env var\n    baseUrl: \"https://custom-api.abbox.com\", // Override default URL\n  },\n);\n```\n\n## API Reference\n\n### `checkWithAbboxGuard(options, config?)`\n\nMain function to check a prompt with Abbox Guard.\n\n**Parameters:**\n\n- `options.prompt` (required) - The user prompt to evaluate\n- `options.source` (required) - Your application identifier\n- `options.actorId` (required) - User/session identifier\n- `options.metadata` (optional) - Additional context\n- `options.timeout` (optional) - Request timeout in ms (default: 5000)\n- `config.apiKey` (optional) - Override `ABBOX_API_KEY` env var\n- `config.baseUrl` (optional) - Override `ABBOX_API_BASE_URL` env var\n\n**Returns:** `Promise<AbboxGuardDecision>`\n\n**Throws:** Error if API call fails\n\n### `shouldBlock(decision)`\n\nHelper to check if a decision should block the request.\n\n**Returns:** `boolean`\n\n### `hasSuggestedRewrite(decision)`\n\nHelper to check if a decision has a suggested rewrite.\n\n**Returns:** `boolean`\n\n### `checkWithAbboxGuardFailOpen(options, config?)`\n\nSame as `checkWithAbboxGuard` but allows requests if Guard is unavailable.\n\n**Returns:** `Promise<AbboxGuardDecision>` (never throws)\n\n### `checkWithAbboxGuardFailClosed(options, config?)`\n\nSame as `checkWithAbboxGuard` but blocks requests if Guard is unavailable.\n\n**Throws:** Error if Guard is unavailable\n\n## Environment Variables\n\n- `ABBOX_API_KEY` - Your Abbox API key (required)\n- `ABBOX_API_BASE_URL` - Abbox API URL (default: `https://api.abbox.com`)\n\n## Response Format\n\n```typescript\ninterface AbboxGuardDecision {\n  decision: \"allow\" | \"block\";\n  reason: string;\n  intent: { type: string; [key: string]: any };\n  policy: { id: string; version: number } | null;\n  suggested_rewrite: string | null;\n}\n```\n\n## Requirements\n\n- Node.js >= 18.0.0\n- No additional dependencies\n\n## License\n\nMIT\n\n## Support\n\n- Documentation: [docs.abbox.com](https://abbox.com/docs)\n- Dashboard: [app.abbox.com](https://app.abbox.com)\n- Issues: [GitHub Issues](https://github.com/elchuzade/abbox-guard-sdk/issues)\n","readmeFilename":"README.md","_rev":"1-bb65317004a8d9ce3924e8818e5bf4cb"}