{"_id":"@dreamind-tools/mosparo-hook","_rev":"4-79a1be5e0cde0b3a18b2df8e4ccc6f56","name":"@dreamind-tools/mosparo-hook","dist-tags":{"latest":"0.5.4"},"versions":{"0.5.0":{"name":"@dreamind-tools/mosparo-hook","version":"0.5.0","license":"MIT","_id":"@dreamind-tools/mosparo-hook@0.5.0","maintainers":[{"name":"polimich","email":"michael.polivka1@gmail.com"}],"homepage":"https://github.com/dreamindsro/mosparo-hook#readme","bugs":{"url":"https://github.com/dreamindsro/mosparo-hook/issues"},"dist":{"shasum":"69cd8ca4fe13b523d3bb26cb7ba726b2260ef322","tarball":"https://registry.npmjs.org/@dreamind-tools/mosparo-hook/-/mosparo-hook-0.5.0.tgz","fileCount":11,"integrity":"sha512-1R6I6S5Nz9Jpy3Lkd8duZA36nEt4FsHm+CVA0G+HP1QU2XO2LH5I4WMSH0hi+0nuuE8fLqdBFkWhSoGVv9oqbA==","signatures":[{"sig":"MEUCIQDSSdceJf5HHut01sENtvRhYHnCRWT3Wr5+nzyGdR/LhAIgZc/Do2Y+u6kXqc9JDxPIdHi1SFmOeQChfJs7NbPD/wk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34723},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./server":{"import":{"types":"./dist/server.d.ts","default":"./dist/server.js"},"require":{"types":"./dist/server.d.cts","default":"./dist/server.cjs"}}},"gitHead":"b964becc0e8b3eb10c1c0d3fdb7e322ff69b3939","scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"polimich","email":"michael.polivka1@gmail.com"},"repository":{"url":"git+https://github.com/dreamindsro/mosparo-hook.git","type":"git"},"_npmVersion":"10.9.0","description":"React/Next.js integration for mosparo spam protection","directories":{},"_nodeVersion":"22.11.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.15.1+sha1.8adba2d20330c02d3856e18c4eb3819d1d3ca6aa","devDependencies":{"tsup":"^8.0.0","react":"^19.0.0","react-dom":"^19.0.0","typescript":"^5.5.0","@types/node":"^25.5.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0","@mosparo/api-client":"^1.2.0"},"peerDependencies":{"react":"^18 || ^19","react-dom":"^18 || ^19","@mosparo/api-client":"^1.2.0"},"peerDependenciesMeta":{"@mosparo/api-client":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/mosparo-hook_0.5.0_1775049936343_0.7766088976927692","host":"s3://npm-registry-packages-npm-production"}},"0.5.2":{"name":"@dreamind-tools/mosparo-hook","version":"0.5.2","keywords":["mosparo","spam","captcha","react","nextjs","form","spam-protection","anti-spam"],"license":"MIT","_id":"@dreamind-tools/mosparo-hook@0.5.2","maintainers":[{"name":"polimich","email":"michael.polivka1@gmail.com"}],"homepage":"https://github.com/dreamindsro/mosparo-hook#readme","bugs":{"url":"https://github.com/dreamindsro/mosparo-hook/issues"},"dist":{"shasum":"124dba4ac95f82e4effb777de94cb1e9bdb46baa","tarball":"https://registry.npmjs.org/@dreamind-tools/mosparo-hook/-/mosparo-hook-0.5.2.tgz","fileCount":11,"integrity":"sha512-C2oJ7h+4WwuFEBq8TRkgOQstNLti5H7XC8qr60zLxHNlH/Nlwmfybs/6g3j6vfrZyb65xTELjeRB3iMLoQKGkA==","signatures":[{"sig":"MEYCIQDgjw4GkoU2fYlDvnNjV2XaRv18S2pzXjCHsGLfVkDGtAIhALRkbZrYH5z5/fHi/rgRePkHnxa+l07sF8t9dIuOLKyx","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35148},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./server":{"import":{"types":"./dist/server.d.ts","default":"./dist/server.js"},"require":{"types":"./dist/server.d.cts","default":"./dist/server.cjs"}}},"gitHead":"cb1f977b5e2b0612f25c503238e44c9b26ff079b","scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"polimich","email":"michael.polivka1@gmail.com"},"repository":{"url":"git+https://github.com/dreamindsro/mosparo-hook.git","type":"git"},"_npmVersion":"10.9.0","description":"React/Next.js integration for mosparo spam protection","directories":{},"_nodeVersion":"22.11.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.15.1+sha1.8adba2d20330c02d3856e18c4eb3819d1d3ca6aa","devDependencies":{"tsup":"^8.0.0","react":"^19.0.0","react-dom":"^19.0.0","typescript":"^5.5.0","@types/node":"^25.5.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0","@mosparo/api-client":"^1.2.0"},"peerDependencies":{"react":"^18 || ^19","react-dom":"^18 || ^19","@mosparo/api-client":"^1.2.0"},"peerDependenciesMeta":{"@mosparo/api-client":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/mosparo-hook_0.5.2_1775050304539_0.9018264206528832","host":"s3://npm-registry-packages-npm-production"}},"0.5.3":{"name":"@dreamind-tools/mosparo-hook","version":"0.5.3","keywords":["mosparo","spam","captcha","react","nextjs","form","spam-protection","anti-spam"],"license":"MIT","_id":"@dreamind-tools/mosparo-hook@0.5.3","maintainers":[{"name":"polimich","email":"michael.polivka1@gmail.com"}],"homepage":"https://github.com/dreamindsro/mosparo-hook#readme","bugs":{"url":"https://github.com/dreamindsro/mosparo-hook/issues"},"dist":{"shasum":"4ce6672acaa95177a19eef3179bd30b72457c874","tarball":"https://registry.npmjs.org/@dreamind-tools/mosparo-hook/-/mosparo-hook-0.5.3.tgz","fileCount":11,"integrity":"sha512-MerqIc5PZHqkLFe6rdSG7EJNmswaNLtZfoEJoUuV31h000dOZ2HrIPJ6oD+NZtFiPtfz1TPk07FCJ5j4KD/0Tg==","signatures":[{"sig":"MEUCIQD/emSWiwvg6puhPEwml/zXWvFfrbfCOAJ4sE4VOUUrhQIgSnCSvroGN1tDqGc9mATey9q4GIs5aAHLAzgk0AHYWPo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35165},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./server":{"import":{"types":"./dist/server.d.ts","default":"./dist/server.js"},"require":{"types":"./dist/server.d.cts","default":"./dist/server.cjs"}}},"gitHead":"ec8eaedf58be979c7a728dd41bc8dcc5ada6f865","scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"polimich","email":"michael.polivka1@gmail.com"},"repository":{"url":"git+https://github.com/dreamindsro/mosparo-hook.git","type":"git"},"_npmVersion":"10.9.0","description":"React/Next.js integration for mosparo spam protection","directories":{},"_nodeVersion":"22.11.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.15.1+sha1.8adba2d20330c02d3856e18c4eb3819d1d3ca6aa","devDependencies":{"tsup":"^8.0.0","react":"^19.0.0","react-dom":"^19.0.0","typescript":"^5.5.0","@types/node":"^25.5.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0","@mosparo/api-client":"^1.2.0"},"peerDependencies":{"react":"^18 || ^19","react-dom":"^18 || ^19","@mosparo/api-client":"^1.2.0"},"peerDependenciesMeta":{"@mosparo/api-client":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/mosparo-hook_0.5.3_1775050415449_0.7627400793570724","host":"s3://npm-registry-packages-npm-production"}},"0.5.4":{"name":"@dreamind-tools/mosparo-hook","version":"0.5.4","type":"module","description":"React/Next.js integration for mosparo spam protection","license":"MIT","keywords":["mosparo","spam","captcha","react","nextjs","form","spam-protection","anti-spam"],"homepage":"https://github.com/dreamindsro/mosparo-hook#readme","bugs":{"url":"https://github.com/dreamindsro/mosparo-hook/issues"},"repository":{"type":"git","url":"git+https://github.com/dreamindsro/mosparo-hook.git"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./server":{"import":{"types":"./dist/server.d.ts","default":"./dist/server.js"},"require":{"types":"./dist/server.d.cts","default":"./dist/server.cjs"}}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"peerDependencies":{"@mosparo/api-client":"^1.2.0","react":"^18 || ^19","react-dom":"^18 || ^19"},"peerDependenciesMeta":{"@mosparo/api-client":{"optional":true}},"devDependencies":{"@mosparo/api-client":"^1.2.0","@types/node":"^25.5.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0","react":"^19.0.0","react-dom":"^19.0.0","tsup":"^8.0.0","typescript":"^5.5.0"},"publishConfig":{"access":"public"},"packageManager":"pnpm@8.15.1+sha1.8adba2d20330c02d3856e18c4eb3819d1d3ca6aa","_id":"@dreamind-tools/mosparo-hook@0.5.4","gitHead":"15013e81af20824bbd6d80352b3c2a976ec96199","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-mZzCkLwI56fN/+ItiaBy1ZIyPrabF9UGNv7DjEE15FnG1/vm+V3qqkqNBFluDfkMawNE0NpYpL8LJOwK4mUm9A==","shasum":"37a4af3301658c46076aec602f8de5b8dbf1da67","tarball":"https://registry.npmjs.org/@dreamind-tools/mosparo-hook/-/mosparo-hook-0.5.4.tgz","fileCount":11,"unpackedSize":35165,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDKmfaZ/lAVf5FSAxdb7Wetfg9tqKjLSvUSWLsKJ/VOiQIhAMslrPQqQUjgsr0wKFC40jys/FmN5t9WEjMvvTAMJawf"}]},"_npmUser":{"name":"polimich","email":"michael.polivka1@gmail.com"},"directories":{},"maintainers":[{"name":"polimich","email":"michael.polivka1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mosparo-hook_0.5.4_1775050512132_0.060431949801277085"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-01T13:25:36.265Z","modified":"2026-04-01T13:35:12.406Z","0.5.0":"2026-04-01T13:25:36.475Z","0.5.2":"2026-04-01T13:31:44.699Z","0.5.3":"2026-04-01T13:33:35.593Z","0.5.4":"2026-04-01T13:35:12.271Z"},"bugs":{"url":"https://github.com/dreamindsro/mosparo-hook/issues"},"license":"MIT","homepage":"https://github.com/dreamindsro/mosparo-hook#readme","keywords":["mosparo","spam","captcha","react","nextjs","form","spam-protection","anti-spam"],"repository":{"type":"git","url":"git+https://github.com/dreamindsro/mosparo-hook.git"},"description":"React/Next.js integration for mosparo spam protection","maintainers":[{"name":"polimich","email":"michael.polivka1@gmail.com"}],"readme":"# @dreamind-tools/mosparo-hook\n\n[![npm version](https://img.shields.io/npm/v/@dreamind-tools/mosparo-hook)](https://www.npmjs.com/package/@dreamind-tools/mosparo-hook)\n[![license](https://img.shields.io/npm/l/@dreamind-tools/mosparo-hook)](https://github.com/dreamindsro/mosparo-hook/blob/main/LICENSE)\n\nReact/Next.js integration for [mosparo](https://mosparo.io) spam protection.\n\n## Installation\n\n```bash\nnpm install @dreamind-tools/mosparo-hook\n```\n\n### Peer dependencies\n\n- `react` ^18 or ^19\n- `@mosparo/api-client` ^1.2.0 (only needed for server-side verification)\n\n## Setup\n\n### Environment variables\n\nThe simplest way to configure the package is via environment variables. No props needed.\n\n```env\nNEXT_PUBLIC_MOSPARO_HOST=https://mosparo.example.com\nNEXT_PUBLIC_MOSPARO_UUID=your-project-uuid\nNEXT_PUBLIC_MOSPARO_PUBLIC_KEY=your-public-key\nMOSPARO_PRIVATE_KEY=your-private-key\n```\n\nThe first three are used by both the client component and server verification. The private key is server-only and never exposed to the browser. You can find these values in your mosparo project settings.\n\n## Usage\n\n### Client: `<MosparoField />`\n\nDrop the component into any form. It renders the mosparo captcha widget and automatically loads the mosparo frontend script.\n\n```tsx\nimport { MosparoField } from '@dreamind-tools/mosparo-hook';\n\nexport function ContactForm() {\n  return (\n    <form action=\"/api/contact\" method=\"POST\">\n      <input name=\"name\" placeholder=\"Name\" />\n      <input name=\"email\" placeholder=\"Email\" />\n      <textarea name=\"message\" placeholder=\"Message\" />\n\n      <MosparoField />\n\n      <button type=\"submit\">Send</button>\n    </form>\n  );\n}\n```\n\nIf you prefer passing config via props instead of environment variables:\n\n```tsx\n<MosparoField\n  host=\"https://mosparo.example.com\"\n  uuid=\"your-project-uuid\"\n  publicKey=\"your-public-key\"\n/>\n```\n\n#### Props\n\n| Prop | Type | Description |\n|------|------|-------------|\n| `host` | `string` | mosparo instance URL |\n| `uuid` | `string` | Project UUID |\n| `publicKey` | `string` | Project public key |\n| `options` | `MosparoOptions` | Widget options (language, design mode, etc.) |\n| `callbacks` | `MosparoCallbacks` | Lifecycle callbacks |\n| `invisibleCallbacks` | `MosparoInvisibleCallbacks` | Invisible mode callbacks |\n| `id` | `string` | Custom container element ID |\n| `className` | `string` | CSS class for the container |\n| `style` | `CSSProperties` | Inline styles for the container |\n| `onError` | `(error: Error) => void` | Called if widget initialization fails |\n\n### Server: `verifySubmission()`\n\nVerify form submissions on the server using `@mosparo/api-client` under the hood.\n\n```ts\nimport { verifySubmission } from '@dreamind-tools/mosparo-hook/server';\n```\n\n#### Next.js Server Action\n\n```ts\n'use server';\n\nimport { verifySubmission } from '@dreamind-tools/mosparo-hook/server';\n\nexport async function submitContact(formData: FormData) {\n  const result = await verifySubmission(formData);\n\n  if (!result.valid) {\n    return { error: result.error ?? 'Spam detected.' };\n  }\n\n  // Process the form...\n}\n```\n\n#### Next.js API Route\n\n```ts\nimport { verifySubmission } from '@dreamind-tools/mosparo-hook/server';\n\nexport async function POST(request: Request) {\n  const formData = await request.formData();\n  const result = await verifySubmission(formData);\n\n  if (!result.valid) {\n    return Response.json({ error: 'Verification failed.' }, { status: 422 });\n  }\n\n  // Process the form...\n  return Response.json({ success: true });\n}\n```\n\n#### With explicit config\n\n```ts\nconst result = await verifySubmission(formData, {\n  config: {\n    host: 'https://mosparo.example.com',\n    uuid: 'your-project-uuid',\n    publicKey: 'your-public-key',\n    privateKey: 'your-private-key',\n  },\n  excludeFields: ['honeypot'],\n});\n```\n\n#### Return type\n\n```ts\ninterface VerifySubmissionResult {\n  success: boolean;          // Whether the API call succeeded\n  valid: boolean;            // Whether the submission passed verification\n  verifiedFields: Record<string, string>;\n  issues: unknown[];\n  error?: string;            // Error message if success is false\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}