{"_id":"2fauth","_rev":"3-3105f1af3cdc5a82c63d68b172639477","name":"2fauth","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"2fauth","version":"1.0.0","keywords":["authentication","jwt","2fa","express","oauth"],"author":{"name":"hemant1234"},"license":"MIT","_id":"2fauth@1.0.0","maintainers":[{"name":"hemant1234","email":"bhatiahemant128@gmail.com"}],"homepage":"https://github.com/Hemantbhatiahb/npm-2fa","bugs":{"url":"https://github.com/Hemantbhatiahb/npm-2fa/issues"},"dist":{"shasum":"ca233d7b53c2178278f5707aeaa81a3aceb99647","tarball":"https://registry.npmjs.org/2fauth/-/2fauth-1.0.0.tgz","fileCount":7,"integrity":"sha512-d6EArc9VYYPpFYKxqnhCJG5Fr4qDe6wveqmJqqfI4Hzal9Md+BbIgRkE61GvAyvB9+7j0CYlCa+w+NFso6l8fA==","signatures":[{"sig":"MEUCIQCdBFwewzFkP2npAChQI01O97LFrkdKSqAiXFrZ3jtHSQIgIpMY2thKQekBpW7ROURGaZIXRw3G2hUoKmnTO8q5zUA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11698},"main":"index.js","gitHead":"0736e9313a5ebcadb50b1eccf382b6da7f4b74ff","scripts":{"test":"node test.js"},"_npmUser":{"name":"hemant1234","email":"bhatiahemant128@gmail.com"},"repository":{"url":"git+https://github.com/Hemantbhatiahb/npm-2fa.git","type":"git"},"_npmVersion":"9.8.1","description":"A plug-and-play authentication system with JWT, 2FA, and OAuth.","directories":{},"_nodeVersion":"18.18.0","dependencies":{"cors":"^2.8.5","dotenv":"^16.4.7","qrcode":"^1.5.4","express":"^4.18.2","bcryptjs":"^2.4.3","mongoose":"^7.5.0","speakeasy":"^2.0.0","nodemailer":"^6.9.7","jsonwebtoken":"^9.0.0","cookie-parser":"^1.4.7"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/2fauth_1.0.0_1740036983794_0.48834248276048253","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"2fauth","version":"1.0.1","keywords":["authentication","jwt","2fa","express","oauth"],"author":{"name":"hemant1234"},"license":"MIT","_id":"2fauth@1.0.1","maintainers":[{"name":"hemant1234","email":"bhatiahemant128@gmail.com"}],"homepage":"https://github.com/Hemantbhatiahb/npm-2fa","bugs":{"url":"https://github.com/Hemantbhatiahb/npm-2fa/issues"},"dist":{"shasum":"7bdc5c9a4c636eb2d856008d98787907612bc84b","tarball":"https://registry.npmjs.org/2fauth/-/2fauth-1.0.1.tgz","fileCount":8,"integrity":"sha512-ZPhzEalSVfTjrJjOxP3jQzplzjC4JBG7vmy/jHqcaF/lsqZ2LbqEeeafNBAoK53A8hNEAasL24jpMyYV7wrj2w==","signatures":[{"sig":"MEYCIQC3Scx+kuzspY5rG/yOP8sGS3B+ZvUlgaCzjXcJrKYtUwIhALqFZoagL1/E9HonlFG6l/pM4xzZ8PlyRIiM+qJO2mxr","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14545},"main":"index.js","gitHead":"6c496a0eac0f0335aa2d6044d8e67433a8c1572e","scripts":{"test":"node test.js"},"_npmUser":{"name":"hemant1234","email":"bhatiahemant128@gmail.com"},"repository":{"url":"git+https://github.com/Hemantbhatiahb/npm-2fa.git","type":"git"},"_npmVersion":"9.8.1","description":"A plug-and-play authentication system with JWT, 2FA, and OAuth.","directories":{},"_nodeVersion":"18.18.0","dependencies":{"cors":"^2.8.5","dotenv":"^16.4.7","qrcode":"^1.5.4","express":"^4.18.2","bcryptjs":"^2.4.3","mongoose":"^7.5.0","speakeasy":"^2.0.0","nodemailer":"^6.9.7","jsonwebtoken":"^9.0.0","cookie-parser":"^1.4.7"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/2fauth_1.0.1_1740039872421_0.9027452318318696","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"2fauth","version":"1.0.2","keywords":["authentication","jwt","2fa","express","oauth"],"author":{"name":"hemant1234"},"license":"MIT","_id":"2fauth@1.0.2","maintainers":[{"name":"hemant1234","email":"bhatiahemant128@gmail.com"}],"homepage":"https://github.com/Hemantbhatiahb/npm-2fa","bugs":{"url":"https://github.com/Hemantbhatiahb/npm-2fa/issues"},"dist":{"shasum":"c73aae60888b9bc5bf56316099684193010b3520","tarball":"https://registry.npmjs.org/2fauth/-/2fauth-1.0.2.tgz","fileCount":9,"integrity":"sha512-InWGeIaySsGvUrCu1KSR6hbyRZTZgRlK5G9jsnQj1UmETsgjjltVaCIUVUbDlYhbYTPbWr+AEljk4HR2XqRkwA==","signatures":[{"sig":"MEQCIHQwbJJ4NASCFICjOhs2i7X5H/B8ZpDvTLeIzhRbjeoPAiA2qg1NL6b8Qew17kMygNnKQED9glFUo4bkIXOHcGsRgw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19564},"main":"index.js","gitHead":"a1ba87c3d37dde07fcdfc98570d9a3f960644b0e","scripts":{"test":"node test.js"},"_npmUser":{"name":"hemant1234","email":"bhatiahemant128@gmail.com"},"repository":{"url":"git+https://github.com/Hemantbhatiahb/npm-2fa.git","type":"git"},"_npmVersion":"9.8.1","description":"A plug-and-play authentication system with JWT, 2FA, and OAuth.","directories":{},"_nodeVersion":"18.18.0","dependencies":{"cors":"^2.8.5","dotenv":"^16.4.7","qrcode":"^1.5.4","express":"^4.18.2","bcryptjs":"^2.4.3","mongoose":"^7.5.0","speakeasy":"^2.0.0","nodemailer":"^6.9.7","jsonwebtoken":"^9.0.0","cookie-parser":"^1.4.7"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/2fauth_1.0.2_1740111899926_0.30678885785640864","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"2fauth","version":"1.0.3","description":"A plug-and-play authentication system with JWT, 2FA, and OAuth.","main":"index.js","scripts":{"test":"node test.js"},"keywords":["authentication","jwt","2fa","express","oauth"],"repository":{"type":"git","url":"git+https://github.com/Hemantbhatiahb/npm-2fa.git"},"bugs":{"url":"https://github.com/Hemantbhatiahb/npm-2fa/issues"},"homepage":"https://github.com/Hemantbhatiahb/npm-2fa","dependencies":{"express":"^4.18.2","jsonwebtoken":"^9.0.0","mongoose":"^7.5.0","bcryptjs":"^2.4.3","nodemailer":"^6.9.7","cookie-parser":"^1.4.7","cors":"^2.8.5","dotenv":"^16.4.7","qrcode":"^1.5.4","speakeasy":"^2.0.0"},"author":{"name":"hemant1234"},"license":"MIT","_id":"2fauth@1.0.3","gitHead":"3531a7de62a08547a3a9be6665f378f4b761b54c","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-Swpyrj3RqsbqOke9zmo25Q5ai9rd2tI9JtVQgXRX3Su+fuSgAZB61+akbVc24gmFm9GWihdh04IJh3J3PAWl3Q==","shasum":"6646e1615f22f31279ac4f9785de530dad62de1a","tarball":"https://registry.npmjs.org/2fauth/-/2fauth-1.0.3.tgz","fileCount":9,"unpackedSize":19985,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD1OPOaQAsgwWdOzShB7PXiCoJB2EM72WiDG/2adBpUzgIgfhyM9n4xcX9c7W91850lm4pP65xCyTTK3DuVspu7sQY="}]},"_npmUser":{"name":"hemant1234","email":"bhatiahemant128@gmail.com"},"directories":{},"maintainers":[{"name":"hemant1234","email":"bhatiahemant128@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/2fauth_1.0.3_1740112501571_0.8950145701715806"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-20T07:36:23.697Z","modified":"2025-02-21T04:35:01.973Z","1.0.0":"2025-02-20T07:36:24.025Z","1.0.1":"2025-02-20T08:24:32.647Z","1.0.2":"2025-02-21T04:25:00.127Z","1.0.3":"2025-02-21T04:35:01.763Z"},"bugs":{"url":"https://github.com/Hemantbhatiahb/npm-2fa/issues"},"author":{"name":"hemant1234"},"license":"MIT","homepage":"https://github.com/Hemantbhatiahb/npm-2fa","keywords":["authentication","jwt","2fa","express","oauth"],"repository":{"type":"git","url":"git+https://github.com/Hemantbhatiahb/npm-2fa.git"},"description":"A plug-and-play authentication system with JWT, 2FA, and OAuth.","maintainers":[{"name":"hemant1234","email":"bhatiahemant128@gmail.com"}],"readme":"# 2FAuth - Secure Authentication with JWT & 2FA  \n\n![npm](https://img.shields.io/npm/v/2fauth) ![license](https://img.shields.io/npm/l/2fauth) ![downloads](https://img.shields.io/npm/dt/2fauth)  \n\n🚀 **2FAuth** is a plug-and-play authentication system for Node.js/Express apps, featuring:  \n✅ **User Registration & Login**  \n✅ **JWT Authentication**  \n✅ **Email Verification**  \n✅ **Two-Factor Authentication (2FA)**  \n✅ **Password Reset**  \n\n---\n\n## 🏗️ Installation  \n\nInstall 2FAuth via NPM:  \n\n```sh\nnpm install 2fauth\n```\n\n## 🚀 Usage\nImport and initialize authentication in your Express app:\n\n```js\nconst express = require(\"express\");\nconst { initAuth } = require(\"2fauth\");\n\nconst app = express();\n\napp.use(\n  initAuth({\n    mongoUrl: \"mongodb+srv://your-mongo-db\",\n    jwtSecretKey: \"your-secret-key\",\n    emailConfig: {\n      fromEmail: \"noreply@example.com\",\n      transportOptions: {\n        service: \"gmail\",\n        auth: {\n          user: process.env.EMAIL_USER,\n          pass: process.env.EMAIL_PASSWORD,\n        },\n      },\n    },\n  })\n);\n\napp.listen(5000, () => console.log(\"Auth system running!\"));\n```\n\n## 📡 API Endpoints  \n\n| Method   | Endpoint                    | Description                    |\n|----------|-----------------------------|--------------------------------|\n| **POST** | `/auth/register`            | Register a new user            |\n| **GET**  | `/auth/verify-email`        | Verify user email              |\n| **GET**  | `/auth/resend-verification` | Verify user email              |\n| **POST** | `/auth/login`               | User Login                     |\n| **POST** | `/auth/enable-2fa`          | Enable 2FA (Generates QR code) |\n| **POST** | `/auth/disable-2fa`         | Disable 2FA                    |\n| **POST** | `/auth/verify-2fa`          | Verify OTP for 2FA             |\n| **POST** | `/auth/logout`              | Logout the user                |\n| **POST** | `/auth/forgot-password`     | Initiate password reset        |\n| **POST** | `/auth/reset-password`      | Reset password                 |\n| **PUT**  | `/auth/change-password`     | Change the current password    |\n| **GET**  | `/auth/current-user`        | Fetch Current User             |\n| **PUT**  | `/auth/update-user/:userId` | Update the current user        |\n\n\n## 🚀 Usage Examples\n\n### **🔹 Register a New User**\n```bash\ncurl -X POST http://localhost:8000/auth/register \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\n           \"name\": \"John Doe\",\n           \"email\": \"johndoe@example.com\",\n           \"password\": \"securepassword\"\n         }'\n```\n### 📌 Response (Success)\n```json\n{\n  \"success\": true,\n  \"message\": \"User registered successfully. Please verify your email\"\n}\n```\n\n### **🔹 Login a User**\n```bash\ncurl -X POST http://localhost:8000/auth/login \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\n           \"email\": \"johndoe@example.com\",\n           \"password\": \"securepassword\"\n         }'\n```\n\n### 📌 Response (Success)\n```json\n{\n  \"success\": true,\n  \"message\": \"Login Successful\"\n}\n```\n\n## 🤝 Contributing\nContributions are welcome! If you find a bug or want to add a feature, feel free to open an issue or submit a PR.\n\n## ⚖️ License\nMIT License - Free to use and modify!\n\n\n","readmeFilename":"README.md"}