{"_id":"@assamlabs/payload-2fa","_rev":"2-db5bad8cef196076cadd00cdb9c5be74","name":"@assamlabs/payload-2fa","dist-tags":{"latest":"1.4.1"},"versions":{"1.4.0":{"name":"@assamlabs/payload-2fa","version":"1.4.0","author":{"name":"AssamLabs"},"license":"GPL-3.0-only","_id":"@assamlabs/payload-2fa@1.4.0","maintainers":[{"name":"natork97","email":"nat.ork97@gmail.com"}],"homepage":"https://docs.assamlabs.com/payload-2fa","dist":{"shasum":"96481a8c3bc8d574067ee32b65d2928f86ff3830","tarball":"https://registry.npmjs.org/@assamlabs/payload-2fa/-/payload-2fa-1.4.0.tgz","fileCount":27,"integrity":"sha512-er/Xo3fVcGb7wgxnT8TS42THHzlsDAvRrbGqgoK/7khcQ8qBBVsyFaK9IG4yic/WUTCjCekFoNutRIOLUC0XQw==","signatures":[{"sig":"MEUCIDRmCYKkQj4afPOdGmaa9rSejRlhZR5mAyytdW20V4x4AiEAtY/NR+c1n7muM5fM+C8VYaehH4qjYWdmLphD+eiByzM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":75617},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./dist/*":"./dist/*"},"gitHead":"9ac03e278190c85c22abd08c5e1a40a028bc8eea","scripts":{"test":"echo \"No tests yet\"","build":"tsc && node scripts/copy-assets.mjs"},"_npmUser":{"name":"natork97","email":"nat.ork97@gmail.com"},"_npmVersion":"11.3.0","description":"Two-factor authentication plugin for Payload CMS","directories":{},"_nodeVersion":"24.1.0","dependencies":{"qrcode":"^1.5.4","speakeasy":"^2.0.0"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.17.1","devDependencies":{"typescript":"^7.0.2","@types/node":"^26.2.0","@types/react":"^19.2.18","@types/qrcode":"^1.5.6","@payloadcms/ui":"^3.80.0","@types/react-dom":"^19.2.4","@types/speakeasy":"^2.0.10"},"peerDependencies":{"payload":"^3.80.0","@payloadcms/ui":"^3.80.0"},"_npmOperationalInternal":{"tmp":"tmp/payload-2fa_1.4.0_1787674529559_0.3851486922210394","host":"s3://npm-registry-packages-npm-production"}},"1.4.1":{"name":"@assamlabs/payload-2fa","version":"1.4.1","description":"Two-factor authentication plugin for Payload CMS","license":"GPL-3.0-only","author":{"name":"AssamLabs"},"homepage":"https://docs.assamlabs.com/payload-2fa","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./dist/*":"./dist/*"},"scripts":{"build":"tsc && node scripts/copy-assets.mjs","test":"echo \"No tests yet\""},"peerDependencies":{"@payloadcms/ui":"^3.80.0","payload":"^3.80.0"},"dependencies":{"qrcode":"^1.5.4","speakeasy":"^2.0.0"},"devDependencies":{"@payloadcms/ui":"^3.80.0","@types/node":"^26.2.0","@types/qrcode":"^1.5.6","@types/react":"^19.2.18","@types/react-dom":"^19.2.4","@types/speakeasy":"^2.0.10","typescript":"^7.0.2"},"packageManager":"pnpm@10.17.1","_id":"@assamlabs/payload-2fa@1.4.1","gitHead":"fe959ec79085275f92af3c79ab240a1519dba878","_nodeVersion":"24.1.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-cPHgYz4AVwpvSfZI+Pe2IbIx3sOM+DniA6tVqLwWXyE1jcnRQDt/33B4kK2z1lp1/iF0YYSCC4NMPan4UdornQ==","shasum":"d1cd02a893c915d74d25cfb986b3b2f9ebf1abca","tarball":"https://registry.npmjs.org/@assamlabs/payload-2fa/-/payload-2fa-1.4.1.tgz","fileCount":27,"unpackedSize":75280,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD6puDzGfkW7rHQCMgNmH9njEPWPEmiEU9587SlPtU7vwIhANo07dpRcpMFQ12j1mFi2WPqhl8MLFjy3RS5UzJuSsMl"}]},"_npmUser":{"name":"natork97","email":"nat.ork97@gmail.com"},"directories":{},"maintainers":[{"name":"natork97","email":"nat.ork97@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/payload-2fa_1.4.1_1787676364595_0.7433850411068341"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-25T16:15:29.370Z","modified":"2026-08-25T16:46:05.017Z","1.4.0":"2026-08-25T16:15:29.740Z","1.4.1":"2026-08-25T16:46:04.728Z"},"author":{"name":"AssamLabs"},"license":"GPL-3.0-only","homepage":"https://docs.assamlabs.com/payload-2fa","description":"Two-factor authentication plugin for Payload CMS","maintainers":[{"name":"natork97","email":"nat.ork97@gmail.com"}],"readme":"# Payload CMS 2FA\r\n\r\nA lightweight two-factor authentication plugin for [Payload CMS](https://payloadcms.com/).\r\n\r\nBuilt and maintained by **[AssamLabs](https://www.assamlabs.com/)**.\r\n\r\n> **📖 Read the complete documentation:** [AssamLabs Docs](https://docs.assamlabs.com/payload-2fa)\r\n\r\n> **🔐 Built on Payload CMS security:** Payload 2FA integrates with Payload CMS's native authentication and security system, giving you a straightforward way to add two-factor authentication without replacing your existing authentication setup.\r\n\r\n> **⚡ One of the easiest ways to add 2FA to Payload CMS:** Install the plugin, configure your authentication collection, and you're ready to enable two-factor authentication.\r\n\r\n## Features\r\n\r\n- TOTP-based two-factor authentication\r\n- QR code setup with authenticator apps\r\n- Backup codes for account recovery\r\n- Enable and disable 2FA from the Payload Admin Panel\r\n- Protected authentication flow\r\n- Custom login interface\r\n- Admin UI for managing 2FA\r\n- Support for custom authentication collections\r\n- Automatic login protection through Payload hooks\r\n- Configurable TOTP issuer\r\n\r\n## Installation\r\n\r\n### 1. Create a User for a New Payload App\r\n\r\nIf you are installing Payload CMS 2FA in a completely new Payload CMS application, make sure at least one user already exists and can log in normally **before installing the plugin**.\r\n\r\nThis is only required for a fresh Payload CMS setup.\r\n\r\n### 2. Install the Package\r\n\r\nInstall the package using your preferred package manager:\r\n\r\n```bash\r\npnpm add @assamlabs/payload-2fa\r\n```\r\n\r\n### 3. Add the Plugin\r\n\r\nAdd the plugin to your Payload configuration:\r\n\r\n```ts\r\nimport { twoFactorAuth } from \"@assamlabs/payload-2fa\";\r\n\r\nexport default buildConfig({\r\n  // ...\r\n\r\n  plugins: [twoFactorAuth()],\r\n});\r\n```\r\n\r\nPayload 2FA uses the `users` collection by default.\r\n\r\n### Required Environment Variable\r\n\r\nThe plugin requires an internal authentication secret:\r\n\r\n```bash\r\nPAYLOAD_2FA_INTERNAL_SECRET=your-secure-random-secret\r\n```\r\n\r\nKeep this value private and do not expose it to the client.\r\n\r\n### Custom Authentication Collection\r\n\r\nYou can use a different authentication-enabled collection:\r\n\r\n```ts\r\ntwoFactorAuth({\r\n  collectionSlug: \"members\",\r\n});\r\n```\r\n\r\n### 4. Generate the Import Map\r\n\r\nAfter completing your Payload configuration, generate the Payload Admin import map:\r\n\r\n```bash\r\npnpm payload generate:importmap\r\n```\r\n\r\n> **Note:** If your development server is already running, stop it before generating the import map and start it again afterward.\r\n\r\n### 5. Start Your Payload Application\r\n\r\nOnce the configuration and import map are complete, start your Payload application:\r\n\r\n```bash\r\npnpm dev\r\n```\r\n\r\n## Quick Start\r\n\r\nAfter installation:\r\n\r\n1. Open the user document in the Payload Admin Panel.\r\n2. Enable **Two-Factor Authentication**.\r\n3. Scan the generated QR code with your authenticator app.\r\n4. Verify the generated code.\r\n5. Save your backup codes.\r\n6. Log out and test the 2FA login flow.\r\n\r\n## Requirements\r\n\r\n- Payload CMS 3.x\r\n- Node.js `18.20.2+` or `20.9+`\r\n- React 19\r\n\r\n## Documentation\r\n\r\nFull documentation is available at [AssamLabs Docs](https://docs.assamlabs.com/payload-2fa).\r\n\r\n## License\r\n\r\nGPL-3.0-only\r\n","readmeFilename":"README.md"}