{"_id":"@adriaragonn/node2fa","_rev":"3-5b0968489a62554247c0614ffa4c8fd7","name":"@adriaragonn/node2fa","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@adriaragonn/node2fa","version":"1.0.0","keywords":["2fa","totp","nodejs","nestjs","authentication","security"],"author":{"name":"adriaragonn"},"license":"MIT","_id":"@adriaragonn/node2fa@1.0.0","maintainers":[{"name":"adriaragonn","email":"adrianaragongarrote@gmail.com"}],"homepage":"https://github.com/adriaragonn/node2fa#readme","bugs":{"url":"https://github.com/adriaragonn/node2fa/issues"},"dist":{"shasum":"31ffedd68eb40a069f0d8cea8bec22a30470cf74","tarball":"https://registry.npmjs.org/@adriaragonn/node2fa/-/node2fa-1.0.0.tgz","fileCount":15,"integrity":"sha512-Aqg4N/+K4PABN4rRPUXMnqd93wA8wuGyELLvMM70E6L2NGETJ/eD8HxNStORG+7PoeK+GxD1P6zREyUs8Nld7g==","signatures":[{"sig":"MEQCIDojtUKuz4lzLokY0e++pCepnG/qD8CPbgZEKR67qE87AiAIjY2Xmc1WYPTkrPIzWICtpJxCeTljsBAiBsUnpcMLNA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10640},"main":"dist/index.js","type":"commonjs","types":"dist/index.d.ts","gitHead":"8cd06375ab26fbe6594d3b423bcb3b3caedc5412","scripts":{"test":"jest","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"adriaragonn","email":"adrianaragongarrote@gmail.com"},"repository":{"url":"git+https://github.com/adriaragonn/node2fa.git","type":"git"},"_npmVersion":"11.3.0","description":"A simple and robust Two-Factor Authentication (2FA) library for Node.js using TOTP.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"otplib":"^12.0.1","qrcode":"^1.5.4"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.0.5","ts-jest":"^29.4.1","typescript":"^5.9.2","@types/jest":"^30.0.0","@types/qrcode":"^1.5.5"},"_npmOperationalInternal":{"tmp":"tmp/node2fa_1.0.0_1755107463245_0.08791606251708872","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@adriaragonn/node2fa","version":"1.0.1","keywords":["2fa","totp","nodejs","nestjs","authentication","security"],"author":{"name":"adriaragonn"},"license":"MIT","_id":"@adriaragonn/node2fa@1.0.1","maintainers":[{"name":"adriaragonn","email":"adrianaragongarrote@gmail.com"}],"homepage":"https://github.com/adriaragonn/node2fa#readme","bugs":{"url":"https://github.com/adriaragonn/node2fa/issues"},"dist":{"shasum":"6d6e0559c389d0b547c416be03063040ec7533d7","tarball":"https://registry.npmjs.org/@adriaragonn/node2fa/-/node2fa-1.0.1.tgz","fileCount":15,"integrity":"sha512-KhPdUOBhkGYF2F0B1ZeDD0Cc5OrqSlLiMTN1fR4kYJ/jh7cH2V+OvxaVA5GtMLVL81T8Ljrevndg9R40WNsPbg==","signatures":[{"sig":"MEYCIQDhgN3oup8PPE+u+dhV5NcsO2XmzCV7PTBOwSC3wCrHHAIhANeIAvmFlEc/ozqrDbb/OYg7dnc0u61zXltbN+NElemh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10691},"main":"dist/index.js","type":"commonjs","types":"dist/index.d.ts","gitHead":"43f3eb5d6364e4ec5d5a08eca7198457e6163204","scripts":{"test":"jest","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"adriaragonn","email":"adrianaragongarrote@gmail.com"},"repository":{"url":"git+https://github.com/adriaragonn/node2fa.git","type":"git"},"_npmVersion":"11.3.0","description":"A simple and robust Two-Factor Authentication (2FA) library for Node.js using TOTP.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"otplib":"^12.0.1","qrcode":"^1.5.4"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.0.5","ts-jest":"^29.4.1","typescript":"^5.9.2","@types/jest":"^30.0.0","@types/qrcode":"^1.5.5"},"_npmOperationalInternal":{"tmp":"tmp/node2fa_1.0.1_1755108270736_0.9584115507145134","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@adriaragonn/node2fa","version":"1.0.2","description":"A simple and robust Two-Factor Authentication (2FA) library for Node.js using TOTP.","license":"MIT","author":{"name":"adriaragonn"},"type":"commonjs","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/adriaragonn/node2fa.git"},"keywords":["2fa","totp","nodejs","nestjs","authentication","security"],"scripts":{"build":"tsc","test":"jest","prepare":"npm run build"},"dependencies":{"otplib":"^12.0.1","qrcode":"^1.5.4"},"devDependencies":{"@types/jest":"^30.0.0","@types/qrcode":"^1.5.5","jest":"^30.0.5","ts-jest":"^29.4.1","typescript":"^5.9.2"},"_id":"@adriaragonn/node2fa@1.0.2","gitHead":"d0ff458205edb2942d691ee3e5c57ce351274091","bugs":{"url":"https://github.com/adriaragonn/node2fa/issues"},"homepage":"https://github.com/adriaragonn/node2fa#readme","_nodeVersion":"22.14.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-T+HD1XXEZEVkGRAl/KRTP7SyaoMRwUfwNH5v0ryBFKnNfD6WwSdmquNn2vIJ4uAF8EgHMKXAqIOMixvgLQ9fag==","shasum":"ce7176d079bc79739cdd4fb80518ae1e3ad535d9","tarball":"https://registry.npmjs.org/@adriaragonn/node2fa/-/node2fa-1.0.2.tgz","fileCount":15,"unpackedSize":10695,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIF/KL9CaT5jldSUxr4Cms0dpR76W04JxK60ENwqhx1XmAiEAn6T34G34DoqOShFPmXAIvI3S2kjqK1FYNsRcBDQt6fc="}]},"_npmUser":{"name":"adriaragonn","email":"adrianaragongarrote@gmail.com"},"directories":{},"maintainers":[{"name":"adriaragonn","email":"adrianaragongarrote@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/node2fa_1.0.2_1755202638476_0.9545136162229337"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-13T17:51:03.136Z","modified":"2025-08-14T20:17:18.829Z","1.0.0":"2025-08-13T17:51:03.457Z","1.0.1":"2025-08-13T18:04:30.956Z","1.0.2":"2025-08-14T20:17:18.668Z"},"bugs":{"url":"https://github.com/adriaragonn/node2fa/issues"},"author":{"name":"adriaragonn"},"license":"MIT","homepage":"https://github.com/adriaragonn/node2fa#readme","keywords":["2fa","totp","nodejs","nestjs","authentication","security"],"repository":{"type":"git","url":"git+https://github.com/adriaragonn/node2fa.git"},"description":"A simple and robust Two-Factor Authentication (2FA) library for Node.js using TOTP.","maintainers":[{"name":"adriaragonn","email":"adrianaragongarrote@gmail.com"}],"readme":"# node2fa\n\n[![npm version](https://img.shields.io/npm/v/node2fa.svg)](https://www.npmjs.com/package/@adriaragonn/node2fa)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)\n\nA simple and robust Two-Factor Authentication (2FA) library for Node.js and NestJS using TOTP.\n\n## Features\n\n- Generate TOTP secrets\n- Generate OTP Auth URLs compatible with Google Authenticator and similar apps\n- Generate QR codes for easy scanning\n- Verify TOTP tokens\n- Configurable time window\n\n## Installation\n\n```bash\nnpm install @adriaragonn/node2fa\n```\n\nor\n\n```bash\nyarn add @adriaragonn/node2fa\n```\n\n## Usage\n\n```ts\nimport { node2fa } from '@adriaragonn/node2fa';\n\nasync function main() {\n  const service = new node2fa.TotpService({ name: 'MyApp', window: 1 });\n\n  // Generate a secret\n  const secret = service.generateSecret();\n  console.log('Secret:', secret);\n\n  // Generate OTP Auth URL\n  const url = service.generateOtpAuthUrl('user@example.com', secret);\n  console.log('URL:', url);\n\n  // Generate QR code (base64)\n  const qrCodeBase64 = await service.generateQrCode(url);\n  console.log('QR Code (Base64):', qrCodeBase64);\n\n  // Verify a token\n  const token = '123456'; // token from Google Authenticator\n  const isValid = service.verifyToken(token, secret);\n  console.log('Is token valid?', isValid);\n}\n\nmain();\n```\n\n## API\n\n### `new TotpService(options?: TotpOptions)`\n\nCreates a new TOTP service instance.\n\n**Options:**\n- `name` (string): Name of your application (default: \"Node2fa\")\n- `window` (number): Verification window in steps (default: `1`)\n\n### `generateSecret(): string`\nGenerates a new TOTP secret.\n\n### `generateOtpAuthUrl(userEmail: string, secret: string): string`\nGenerates an OTP Auth URL compatible with Google Authenticator.\n\n### `generateQrCode(url: string): Promise<string>`\nGenerates a QR code in base64 format from the OTP Auth URL.\n\n### `verifyToken(token: string, secret: string): boolean`\nVerifies a TOTP token against a secret.\n\n## License\n\nThis project is licensed under the MIT License.\n\n","readmeFilename":"readme.md"}