{"_id":"forgot-password","_rev":"1-adc22e3157dc1bf07856fc508250f72d","name":"forgot-password","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"forgot-password","version":"1.0.0","description":"A simple package for implementing the forgot-password feature in web-apps!","main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":{"name":"Md. Aman Khan"},"license":"MIT","dependencies":{"cryptr":"^6.0.2","mongoose":"^5.12.13","nodemailer":"^6.6.1"},"_id":"forgot-password@1.0.0","_nodeVersion":"16.3.0","_npmVersion":"7.15.1","dist":{"integrity":"sha512-/4Gqx/ZkWCN5nxzJidtxA8daPDvqFcuH3QXW6JRD8Sfb3zCwIT4lAcisdYQQmGDuzjtON9Pw0IUQE/CgUeWx0A==","shasum":"f922be2fecc46b5e7e3dc60d5268b3f5bd3e7d08","tarball":"https://registry.npmjs.org/forgot-password/-/forgot-password-1.0.0.tgz","fileCount":8,"unpackedSize":14866,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyaGDCRA9TVsSAnZWagAAIcsQAKSFF+IlqcXvNztcI7A4\nCIL2MGdGaOF5mllVNyBoShCQ5VHKMYtinZHnKRnJMeLyjaSHnDDG6HrDpvr/\nnGR0BAGXWsXiF9aIDuNUUZjL8O1NvOpNVS+7+yej294+G5QYCIOAZiTPNXOx\noN7B4XLzhrOVvvy9jpXnQa4I6eK5DQ7coccxu4bO4lvh8/1E0VyTW7bAyRAS\nsbx9QqWwvRu+XbA3NuLuBSLl0rMlEY9ajpfoiAFU187psqULkm51pbIG+qHO\nVc9OzxVqK63HHJA/NnYBVKxbK8omrIIdKIadeJo58CvH5/AP07JSEIskB0Tu\nBkimqGR2nN1OtwdOgKwEes0/tP+JFI8bBRQg9DQRzbNsBOdvIP6ati4PgdUN\nhr0lZ789cSKNNF+zb6SN7cdG4uZAgaMq4NOkItMR+KzP0WR35HHIPbMvi4Vz\nteYdHKl0ZawHZnjD5hFNSf6jFLrV8pGZuPPkDc77/Qsvn2zB+7iI9ttzaWeH\nj/leYZFGfjuoi98/HD9DmlJUM1XLQbA3BIn2z4ptyEniQYeeWdfe+BAHev/s\nGCDIQ0cC/ImNkJ/J/a3dRdtIuSEkrkzVPO6HqLuN6tlEiThIXrC/mV+AcA5+\nF8qX55ORxPNDJURFXOZlHfkBJgZwVqQcTJ050qohSpQMgcPvPFvYWSdMmC4D\nTsHe\r\n=D+8e\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGokdYDCqKcvwnXhHQkd5qmCVImXw1/9Y0t8Y7VqU62cAiEA1+TdTC3c4MbVHtTevtYOi7s17LE7OX1JsOrswuPW5dw="}]},"_npmUser":{"name":"amancodesinjs","email":"khanamankhan1973@gmail.com"},"directories":{},"maintainers":[{"name":"amancodesinjs","email":"khanamankhan1973@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/forgot-password_1.0.0_1623826818923_0.9269366227668738"},"_hasShrinkwrap":false}},"time":{"created":"2021-06-16T07:00:18.923Z","1.0.0":"2021-06-16T07:00:19.038Z","modified":"2022-05-02T18:55:02.641Z"},"maintainers":[{"name":"amancodesinjs","email":"khanamankhan1973@gmail.com"}],"description":"A simple package for implementing the forgot-password feature in web-apps!","keywords":[],"author":{"name":"Md. Aman Khan"},"license":"MIT","readme":"\n# Forgot-Password\n\nA simple package for implementing the forgot-password feature in web-apps!\n\n\n## Installation \n\nInstall forgot-password with npm\n\n```\nnpm install forgot-password\n```\n    \nor yarn\n\n```\nyarn add forgot-password \n```\n## Usage/Examples\n\nsimple initialization with express\n\n```\nimport { fpInitDB } from 'forgot-password'\nimport express from 'express'\n\nconst app = express()\n\nfpInitDB('your mongo uri')\n```\n\nsending an OTP to validate user requesting password reset\n\n```\nimport { sendOTP } from 'forgot-password'\n\napp.post('/', async (req, res) => {\n    const result = await sendOTP({\n        email: 'your email here', // better to use dotenv here\n        password: \"email's password\", // better to use dotenv here\n        emailToSend: 'recievers email address',\n        subject: 'subject of the email',\n        companyName: 'YOUR-COMPANY',\n        url: 'http://localhost:5000', // your app's base url\n        validationUrl: '/auth/forgot-password', // the url where you want the OTP validation to occur\n        email: '<b>{otp}</b>' // provide if you want to send a custom email, place {otp} where you want the otp to occur, we will replace it with the actual OTP and {token} to replace it with the token\n    })\n    // the result returns true or false based on, if the email was successfully sent\n    if(result === true){\n        res.send('SUCCESS')\n    }else{\n        res.send('FAILURE')\n    }\n})\n```\n\nvalidating the otp\n\nthe url is sent the email is something like: http://yourwebsiteurl.com/forgot-password?token=somegibberishandimportanttooken\n\nit is based on your app's base url and validation url you can send the token, otp and new password to the backend in whichever way you like\n\n```\napp.post('/auth/forgot-password', async (req, res) => {\n    const { token, otp, newPassword } = req.body\n    const result = await validateOtp({hash: token, otp})\n\n    // result returns true or false based on if the validation was successfull or not\n    \n    if(result === true){\n        saveNewPassword(password)\n        res.send('VALIDATED')\n    }else{\n        res.send('NOT VALIDATED')\n    }\n})\n```\n\nit is quite simple to use\n\n\n## Authors\n\n- [@aman2712](https://www.github.com/aman2712)\n\n  \nthis project is still under development\n\nPlease report any bugs you find at:\n\nkhanamankhan1973@gmail.com\n\n# Thanks :)","readmeFilename":"README.md"}