{"_id":"auth.js","_rev":"13-70b5d01af2d5b208d150f7c454ef2560","name":"auth.js","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"auth.js","version":"0.1.0","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mongoose":"^4.13.2","scmp":"^2.0.0"},"_id":"auth.js@0.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-iciTtTub+1PVQEfAWKDAAdFceQ/wP5tm8kfETdonX50q+aqi+dv8soru70i+CzJ+U/ftGX/JKE3HrhDWGFPNCw==","shasum":"aa5b94c3338fe755727372836f8478a082cdade3","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxofpdGut3yUKIUNi6BBenu2xCbTe2Mdq6/KQ1Io2qwwIgH2/Sb48ojfx1Sn+72l1v7vzCu2N3pfBmc9RzABUR4iI="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.0.tgz_1510952888645_0.16513639176264405"}},"0.1.1":{"name":"auth.js","version":"0.1.1","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mongoose":"^4.13.2","scmp":"^2.0.0"},"_id":"auth.js@0.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-l34HsB03MVMs+7LxgdqwTqCMEZKBHdDpiAH4UufB3Axx+sptXXQOZ+XUrVBBWJqAIrxA2RJsjbR1vcThNVWeiw==","shasum":"12f603e6f0cf715bc435d0e9ee71d6c352384518","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD2pY3QKjYGRWL0R0N3/TGlAJRhmd+JhNNKbckkkdgx/gIgUbmyr/X/Hs4EjVFD5iKci85bz9I7D/M4fVDNMGsiOVE="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.1.tgz_1510952952580_0.7889684338588268"}},"0.1.2":{"name":"auth.js","version":"0.1.2","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mongoose":"^4.13.2","scmp":"^2.0.0"},"gitHead":"8b3b7fa2e7402cb2a2801ff9c7cce2ac6b8811d7","_id":"auth.js@0.1.2","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-8rjX71s9Tw86nxpcsFye/txgzZug+0gz0+sZWsNS3tFCjvyPiOePVBNvW4LdgGaASOfwVdPOKUCzjSCVSzpNtA==","shasum":"74b087f9b52c8ae72bcc86805f89ccf1fb3f19f9","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeGLrF/UUFllcNZQycQmnjfwgLT4wFPfLkwxpFF9UeXAIgH8ry/WthBibnNRPJQtaJ64bMrfyhbVAApeRno20rM5U="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.2.tgz_1511026815005_0.9312208963092417"}},"0.1.3":{"name":"auth.js","version":"0.1.3","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"cross-env NODE_ENV=test nyc mocha"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","chai":"^4.1.2","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mocha":"^4.0.1","mongoose":"^4.13.2","nyc":"^11.3.0","scmp":"^2.0.0"},"gitHead":"2632f10f3909f708bf11d2b295f3e34433c06d9f","_id":"auth.js@0.1.3","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-PUESZGhS7wK3jOIs8Xts62/FOIzrBi5PWJiYDY9e6v8VJQ1yJZiJ3DPRFfAei/99a3kMrlQVSzffdNPC6tstTA==","shasum":"9800ec7c3fbb666de1ae3ae9ef6acefa898293bc","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.3.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFKbFd8gfTYF4cWVM8zb5rEbZ/cwGA12AUkdwZ/wnWAZAiEAgoH3IQj15YIDfya6+zszuf5K0s4c23Pu6h9p2lkMZxE="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.3.tgz_1511143910726_0.47722355532459915"}},"0.1.4":{"name":"auth.js","version":"0.1.4","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"cross-env NODE_ENV=test nyc mocha"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","chai":"^4.1.2","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mocha":"^4.0.1","mongoose":"^4.13.2","nyc":"^11.3.0","scmp":"^2.0.0"},"gitHead":"c6226cff8fadff55378ee59c10533bc262cf4b8b","_id":"auth.js@0.1.4","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-KTWeGJGhIL0Fb2CunNGjt29ivKMemt3vevB6cILxgIDWxmihRVCldr7vFTCl4OMrGZuQAGe8WzWxo8lWhoK+5Q==","shasum":"46d85a4c117ffbe7080d80e4c7293325bac8163d","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.4.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyIiLv5ybvOY7I4EkUYXEdqFGrJS4TMrFTczCskaF/wwIhAMQT5Cdskvc/48qRUO9hU/fF+/MvmaGrj6IScccMQXuA"}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.4.tgz_1511145566121_0.3666485284920782"}},"0.1.5":{"name":"auth.js","version":"0.1.5","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"cross-env NODE_ENV=test nyc mocha"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","chai":"^4.1.2","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mocha":"^4.0.1","mongoose":"^4.13.2","nyc":"^11.3.0","scmp":"^2.0.0"},"gitHead":"65d76e8228a192fa7a5e46cef84a9902638181d8","_id":"auth.js@0.1.5","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-UZ/abd8gTojC1sjGJISk5GkyPNn0Ktd79jVFfgCXy404ldEHJBSeiZwt/15Ru1KCnSlVL4ImMFAt13JWG2233g==","shasum":"358c6b5473fb87c793ab77c0bc2b8dd57a9c2233","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.5.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCySMR8NcLwYIMpd/YS4DHohUNkvMtfqXTbpo0qDZ2U/AIhAIFcrryWQFcEz9FTa2YgoNh6wEvCBV61nq4kEKT65qUs"}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.5.tgz_1511145874251_0.016816871240735054"}},"0.1.6":{"name":"auth.js","version":"0.1.6","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"cross-env NODE_ENV=test nyc mocha"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","chai":"^4.1.2","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mocha":"^4.0.1","mongoose":"^4.13.2","nyc":"^11.3.0","scmp":"^2.0.0"},"gitHead":"95bbeccbaf7ea254e3b3df65ec2fa461f1558dca","_id":"auth.js@0.1.6","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-LCNZUKpWueQ7be5AjiSrQpBJHie8pHVXZmCinbamb3yFmcIjqbQeU0edjy3o4/h1F03m7E8g8H0m6Tn438QE6g==","shasum":"5f5dad8f060ece0b1cdd11850c6ba4974b785ad0","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.6.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH6sb15kMivdi0Lvo1iRzHkY2pto4UhCudhEoI/7HV+zAiEA/deiPrcdAtAA87iwfqdvB+z5j/hbkSZ9AIqvwGU65so="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.6.tgz_1511146124200_0.5745741089340299"}},"0.1.7":{"name":"auth.js","version":"0.1.7","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"cross-env NODE_ENV=test nyc mocha"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","chai":"^4.1.2","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mocha":"^4.0.1","mongoose":"^4.13.2","nyc":"^11.3.0","scmp":"^2.0.0"},"gitHead":"1432c729caa274835c9973d95da0702ae48dbedb","_id":"auth.js@0.1.7","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-PgE+5vdDtk7N6gI9TgbOEuSwfQUvagGQA7IFIqnBQ5pQNA0uvnGgn2CkPfke0xCwJe9oQ3Rbuf8EIIZAofV/xw==","shasum":"8b5595422d78f94c8580646bd22a31dc62a22761","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.7.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB6O9BsYdt5yBX2hE8WGyzQqwFp6RTr7cHibI+q2tmYTAiEA0ot1mO92SqL9PlTilq0lPbjiIoXe1vUK53oC4lTizJA="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.7.tgz_1511279407106_0.33323754579760134"}},"0.1.8":{"name":"auth.js","version":"0.1.8","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"cross-env NODE_ENV=test nyc mocha"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","chai":"^4.1.2","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mocha":"^4.0.1","mongoose":"^4.13.2","nodemailer":"^4.4.0","nyc":"^11.3.0","scmp":"^2.0.0"},"gitHead":"1432c729caa274835c9973d95da0702ae48dbedb","_id":"auth.js@0.1.8","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-hI/VKhNIqymYCYGXnOohOJyMCO4pefg/PNQGZa3oLAQQ5Qo5R27DOJb4UpZrnfIaP705nnzmfvDSeD9IxOspoA==","shasum":"8387b99c217dd62cac6419001893a3844f3babf0","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.8.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIADaVv5x+cs/fpJ7+FrmxBKP5DBDLNoZdZEKEKuT20DSAiEA41slCODLFVP3S4tbC4WVuBwjM+o61Thau2Dt8npB6bg="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.8.tgz_1511541884058_0.17524064728058875"}},"0.1.9":{"name":"auth.js","version":"0.1.9","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"cross-env NODE_ENV=test nyc mocha"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","chai":"^4.1.2","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mocha":"^4.0.1","mongoose":"^4.13.2","nodemailer":"^4.4.0","nyc":"^11.3.0","scmp":"^2.0.0"},"gitHead":"1432c729caa274835c9973d95da0702ae48dbedb","_id":"auth.js@0.1.9","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-L4wZCBKhtccWKUhQr1RirKHpfNBYkYwU/Ibi98u2Gb2SyFopp44a31BbPsOACoVaANMaJD+WUnoS5kIp4UlTOQ==","shasum":"16afc6d036a60c3408044bd4029f8cae6e965633","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.1.9.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDZrrfyn6UecuPy/cEOhqL0xABoDCUa5Ipr2il2/uE8YAiA4SsqsHiNpHNCD4LM/xMDxHgMog8Es5A1RymtiDcY38g=="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.1.9.tgz_1511542059958_0.05483788950368762"}},"0.2.0":{"name":"auth.js","version":"0.2.0","description":"A simple authentication and authorization module for building APIs when using front-end frameworks","main":"index.js","scripts":{"test":"mocha tests/index.js -w"},"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"keywords":["node.js","api","angular","react","vue","authentication","authorization"],"author":{"name":"Matthew McSparran"},"license":"MIT","bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","dependencies":{"bcrypt":"^1.0.3","cross-env":"^5.1.1","jsonwebtoken":"^8.1.0","lodash":"^4.17.4","mongoose":"^4.13.2","nodemailer":"^4.4.0","nyc":"^11.3.0","scmp":"^2.0.0"},"devDependencies":{"chai":"^4.1.2","mocha":"^4.0.1"},"gitHead":"4fbce1cbae0ea31a152c4dec7ae5f8a64b0ba95a","_id":"auth.js@0.2.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"},"dist":{"integrity":"sha512-AD9JZvZ+dUOj5+Xi4sBykalOsehowamHbO3OFZ8nIVcdmaIvTJR8Yd9svNhOEGEouqEztKdqiTzMGbI3Xj7Pmw==","shasum":"a44a10240db3e8d73b79910a733b30ec8ece44c6","tarball":"https://registry.npmjs.org/auth.js/-/auth.js-0.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHj+WnIVFeUnb0PdDrSbm6PdqOYb4MGfJUnpRbwkCIfhAiEArMTKdMhltslwEWFwNyskrsFfsxAm8hkEcDNaG2PvwLk="}]},"maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/auth.js-0.2.0.tgz_1511924144334_0.7886401482392102"}}},"readme":"[![npm version](https://img.shields.io/npm/v/auth.js.svg)](https://www.npmjs.com/package/auth.js)\r\n[![npm](https://img.shields.io/npm/dt/auth.js.svg)](https://www.npmjs.com/package/auth.js)\r\n\r\n# auth.js\r\nA simple authentication and authorization module for building APIs when using front-end frameworks\r\n## Getting Started\r\n\r\nInstalling via npm:\r\n```\r\nnpm i --save auth.js\r\n```\r\n\r\nAdding the module to your project:\r\n\r\n```\r\nconst auth = require('auth.js');\r\nconst authConfig = require('auth.js/lib/config');\r\n```\r\n\r\n## Configuring the variables\r\nThe configuration function is as follows\r\n```\r\ndotenv.load({ path: '.env' });\r\nauthConfig.conf(secret, saltRounds, expire);\r\n```\r\nThere only two options that have defaults are ```saltRounds``` and ```expire```, which are ```16``` and ```{ expiresIn: '1h' }``` respectively.\r\n\r\nThe recommended configuration is to use ```dotenv``` to place the JWT secret and salt rounds in the ```.env``` file as seen in the example below.\r\n\r\n\r\n```\r\nauthConfig.conf(process.env.SECRET_JWT, process.env.SALTROUNDS, { expiresIn: '4h' });\r\n```\r\nAuth.js uses [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) for tokens and follows auth0's formatting.\r\n\r\nNOTE: Please make sure to configure ```dotenv``` before you configure auth.js, or your application will fail.\r\n\r\n## Configuring auth.js with mongoose\r\nRequire it in your user schema like so:\r\n\r\n```\r\nconst mongoose = require(\"mongoose\");\r\nconst auth = require('auth.js');\r\n\r\nconst UserSchema = new mongoose.Schema({\r\n    username: String,\r\n    password: String\r\n});\r\n\r\nUserSchema.plugin(auth)\r\nmodule.exports = mongoose.model(\"User\", UserSchema);\r\n```\r\n\r\n## Configuring user models/schemas and permissions\r\n\r\nAuth.js has middleware capabilities that authorize and authenticate. For these to be done properly, some extra configuration has to be done.\r\n\r\nFirst, we need to include the user model/schema in the application root.\r\n\r\nFor example, in ```app.js```, we can include the following:\r\n\r\n```\r\nconst User = require('./models/user');\r\n```\r\nNext, we will need to set up a local variable in the application, in order for the middleware to use the model.\r\n\r\n```\r\napp.use((req, res, next) => {\r\n  res.locals.User = User;\r\n  next();\r\n});\r\n```\r\n\r\n## Using auth.js in your routes\r\nRequire it in your route.\r\n\r\nHere is a example of the registration method:\r\n\r\n```\r\nservice.register = (req, res) => {\r\n  const newUser = new User({username: req.body.username, email: req.body.email});\r\n  User.register(newUser, req.body.password, (err, user, msg) => {\r\n    if (err) {\r\n      console.log('error recieved: ' + err.body + ' ' + err.code);\r\n      res.status(err.code).send(err.body)\r\n    }\r\n    console.log(msg.type + ' recieved!' + ' ' + msg.body);\r\n    res.status(msg.code).json({user, message: msg });\r\n  });\r\n}\r\n  ```\r\n\r\n  And an example of the login method:\r\n\r\n  ```\r\nservice.login = (req, res) => {\r\n  User.findOne({username: req.body.username}, (err, user) => {\r\n    if (!user) {\r\n      return res.sendStatus(403);\r\n    }\r\n    if (err) {\r\n      return res.status(err.code).send(err.body);\r\n    }\r\n    User.login(req.body.username, req.body.password, (err, token, msg) => {\r\n      if (err) {\r\n        return res.status(err.code).send(err.body);\r\n      }\r\n      console.log(msg.type + ' recieved!' + ' ' + msg.body);\r\n      res.status(msg.code).json({ token: token, message: msg });\r\n    });\r\n  });\r\n}\r\n  ```\r\nNote: console.log()'s are being used for tracking purposes until a better logging system is implemented.\r\n\r\n\r\n## Middleware serivce\r\nAuth.js features a middleware to authenticate, authorize, and validate users, their permissions, and their tokens.\r\n\r\nCurrently, the middleware functions are ```verify``` and ```isAdmin```.\r\n\r\nIn the routes you want to authenticate and authorize, require the middleware.\r\n\r\n```\r\nconst authMiddleware = require('auth.js/middleware');\r\n```\r\n\r\nAfter requiring it, place it in the routes as you would do for any other middleware.\r\n\r\n```\r\nrouter.post('/', [authMiddleware.verify, authMiddleware.isAdmin], userService.insert);\r\n```\r\n\r\nIn the above example, the middleware is being used in a route that inserts users into a database. This is different from the typical registering users route.\r\n### Verify Token\r\n```\r\nmiddleware.verify = (req, res, next) => {\r\n  if (!req.headers.authorization) {\r\n      return res.sendStatus(401);\r\n      }\r\n    j.verifyToken(req.headers.authorization, secretToken(), (err, verified) => {\r\n      if (err) {\r\n        return res.send(err).status(400);\r\n      }\r\n      req.user = verified.user;\r\n      return next();\r\n    });\r\n}\r\n```\r\n\r\nThe verify middleware uses the jwt verify function and takes the following parameters:\r\n\r\n```\r\nj.verifyToken(jwtToken, jwtSecret, callback)\r\n```\r\nThe token should be placed in the headers in an authorization field, the jwt secret will be taken from your environment variables, and the callback sets the ```req.user``` field to an object with a value of verified user. You can choose to query your database to retrieve the most current information regarding a specific user in the route.\r\n\r\n### isAdmin\r\n```\r\nmiddleware.isAdmin = (req, res, next) => {\r\n  if (req.user) {\r\n    res.locals.User.findById({_id: req.user._id}, (err, user) => {\r\n      if (err) { return res.status(404).send(err); }\r\n      if (user.role === 'admin') {\r\n      return next();\r\n      }\r\n      return res.status(401).send('User not authorized');\r\n    });\r\n  }\r\n}\r\n```\r\n\r\nThe isAdmin middleware verifies whether the user making the request has administrative privileges. Since the example route inserts a new user into the database, it needs to be secured so only users with admin privileges can insert users. The reason for this, is the example route has more options that can be used when making a request.\r\n\r\nThe middleware checks to see if a req.user field is present, and if it is, it uses the User model to find the user making the request in the database, in order to verify that the role that is shown in the token, is the role they currently have.\r\n\r\n\r\n## Error handling\r\nIn the example above, you can see that auth.js handles its own errors and other messages. Messages are stored in a message object:\r\n\r\n  ```\r\nmessages = {\r\n  body: '',\r\n  type: '',\r\n  code: ''\r\n}\r\n```\r\nThe module will use pre determined error messages and HTTP codes. It will also send what type of message it is (currently: success or error) which will also allow you to utilize alerts on your front end.\r\n","maintainers":[{"name":"mattmcsparran","email":"mattmcsparran@gmail.com"}],"time":{"modified":"2022-04-11T15:56:03.162Z","created":"2017-11-17T21:08:09.670Z","0.1.0":"2017-11-17T21:08:09.670Z","0.1.1":"2017-11-17T21:09:14.064Z","0.1.2":"2017-11-18T17:40:16.628Z","0.1.3":"2017-11-20T02:11:51.640Z","0.1.4":"2017-11-20T02:39:27.033Z","0.1.5":"2017-11-20T02:44:35.149Z","0.1.6":"2017-11-20T02:48:45.136Z","0.1.7":"2017-11-21T15:50:07.175Z","0.1.8":"2017-11-24T16:44:44.125Z","0.1.9":"2017-11-24T16:47:40.015Z","0.2.0":"2017-11-29T02:55:46.321Z"},"homepage":"https://github.com/mattmcsparran/auth.js#readme","keywords":["node.js","api","angular","react","vue","authentication","authorization"],"repository":{"type":"git","url":"git+https://github.com/mattmcsparran/auth.js.git"},"author":{"name":"Matthew McSparran"},"bugs":{"url":"https://github.com/mattmcsparran/auth.js/issues"},"license":"MIT","readmeFilename":"README.md"}