{"_id":"2fa","_rev":"15-9c531b4ff225ec8d57f49d06db722baa","name":"2fa","description":"TOTP + HOTP library, with nice utilities for handing 2FA","dist-tags":{"latest":"0.1.2"},"versions":{"0.0.1":{"name":"2fa","version":"0.0.1","description":"TOTP + HOTP library, with nice utilities for handing 2FA","main":"lib/2FA.js","repository":{"type":"git","url":"git://github.com/simontabor/2fa.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["auth","two-factor","2fa"],"author":{"name":"Simon Tabor"},"license":"MIT","dependencies":{"async":"^0.9.0","qrcode":"^0.2.12","thirty-two":"0.0.2"},"bugs":{"url":"https://github.com/simontabor/2fa/issues"},"homepage":"https://github.com/simontabor/2fa","_id":"2fa@0.0.1","_shasum":"5dc2dc5d8e12b98d8baa786f07faaad1cecb173f","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"simontabor","email":"me@simontabor.com"},"maintainers":[{"name":"simontabor","email":"me@simontabor.com"}],"dist":{"shasum":"5dc2dc5d8e12b98d8baa786f07faaad1cecb173f","tarball":"https://registry.npmjs.org/2fa/-/2fa-0.0.1.tgz","integrity":"sha512-mmfcRsjTuhrbJr/vKsx6vRow5HU/N8G8EinwEtHB43Bb4whx1qvUJOroEdmdaLG/cJWqwxdrl45JrY7Xarc8aQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICCvjFAtSXUS5jlJgkJx+waRfzipvTrIk8NfGPz+lKslAiEAvBes3OPsgx3cu6koKkXWQBFwNlkjMuf0g+CKUx2BESc="}]},"directories":{}},"0.1.0":{"name":"2fa","version":"0.1.0","description":"TOTP + HOTP library, with nice utilities for handing 2FA","main":"lib/2FA.js","repository":{"type":"git","url":"git://github.com/simontabor/2fa.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["auth","two-factor","2fa"],"author":{"name":"Simon Tabor"},"license":"MIT","dependencies":{"qr-image":"^3.1.0","thirty-two":"0.0.2"},"gitHead":"bc927eb447e2e6ef8c59d8ba363220c2e7e33602","bugs":{"url":"https://github.com/simontabor/2fa/issues"},"homepage":"https://github.com/simontabor/2fa","_id":"2fa@0.1.0","_shasum":"bf5757655c1560a8a2207f64c9b3d6c43618c110","_from":".","_npmVersion":"2.1.11","_nodeVersion":"0.10.32","_npmUser":{"name":"simontabor","email":"me@simontabor.com"},"maintainers":[{"name":"simontabor","email":"me@simontabor.com"}],"dist":{"shasum":"bf5757655c1560a8a2207f64c9b3d6c43618c110","tarball":"https://registry.npmjs.org/2fa/-/2fa-0.1.0.tgz","integrity":"sha512-kHBmFqB4/x78V3xakmVWOEWPE9YW6WahStFdZzjqCKviVxaypl0r/8rcmWfxNVoJYdcqkgSdYyPYsIqb/w1eDw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDSyqd8xEZ1eHERovE56SzIoFJqOYJVGR+fkcYdwXnsqwIgTtLzwnPEMWBmtce+qvbk5NoSd3ZpQJm5AQTNIfB8Y/4="}]},"directories":{}},"0.1.1":{"name":"2fa","version":"0.1.1","description":"TOTP + HOTP library, with nice utilities for handing 2FA","main":"lib/2FA.js","repository":{"type":"git","url":"git://github.com/simontabor/2fa.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["auth","two-factor","2fa"],"author":{"name":"Simon Tabor"},"license":"MIT","dependencies":{"qr-image":"^3.1.0","thirty-two":"0.0.2"},"gitHead":"ae4ec4d64f5313bbf6d1b5cbd52511a05da12742","bugs":{"url":"https://github.com/simontabor/2fa/issues"},"homepage":"https://github.com/simontabor/2fa","_id":"2fa@0.1.1","_shasum":"2579a71edc3ee43954e24e9f32d1923b56b55814","_from":".","_npmVersion":"2.1.11","_nodeVersion":"0.10.32","_npmUser":{"name":"simontabor","email":"me@simontabor.com"},"maintainers":[{"name":"simontabor","email":"me@simontabor.com"}],"dist":{"shasum":"2579a71edc3ee43954e24e9f32d1923b56b55814","tarball":"https://registry.npmjs.org/2fa/-/2fa-0.1.1.tgz","integrity":"sha512-JDc4uVkn+7O4PO6nNNw0XA74lO0wocynBte3Xu5TKy3a71bBZ+3YRMSt+xPODOiNX6fFvs2qsDIYZSxr5bw5ng==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDu6zptPg+KQTPNBmLMU0ZAaQpXE69Im3FtZ5Pjm+LaBgIgCgQHCRoCKvdKAAraowCdz8DuAR/jpFXv8zzqfAmyBQ0="}]},"directories":{}},"0.1.2":{"name":"2fa","version":"0.1.2","description":"TOTP + HOTP library, with nice utilities for handing 2FA","main":"lib/2FA.js","repository":{"type":"git","url":"git://github.com/simontabor/2fa.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["auth","two-factor","2fa"],"author":{"name":"Simon Tabor"},"license":"MIT","dependencies":{"qr-image":"^3.1.0","thirty-two":"0.0.2"},"gitHead":"ad80083a85229e4fe6b740fc85133f9e0b584d0c","bugs":{"url":"https://github.com/simontabor/2fa/issues"},"homepage":"https://github.com/simontabor/2fa","_id":"2fa@0.1.2","_shasum":"8fcac92a63ad35949b23f00a3e1fd3eabc8b61d9","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.32","_npmUser":{"name":"simontabor","email":"me@simontabor.com"},"maintainers":[{"name":"simontabor","email":"me@simontabor.com"}],"dist":{"shasum":"8fcac92a63ad35949b23f00a3e1fd3eabc8b61d9","tarball":"https://registry.npmjs.org/2fa/-/2fa-0.1.2.tgz","integrity":"sha512-PbQttc6USc2TmZwOPE/zlNWTJTySLt50rWhUbZgPkZ5LAOLpgShT3yclbxwHPfHGUXEjfLrTo3Lunyx8onGnXw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFLMCmGxqcPj7UeCS7xvSW+USwQAxKankg7jnqcDsarIAiEA1StpM+LXqMCWfDIOK1T0M6XRDRb0RRZ+nPpf8njvWHk="}]},"directories":{}}},"readme":"# 2FA\n\nModule for generating and verifying 2FA codes (specifically TOTP and HOTP).\n\nAlso contains utilities for handing 2FA logic, such as generating Google Authenticator compatible QR codes (without going via Google Charts) and generating backup codes.\n\n## Install\n```\nnpm install --save 2fa\n```\n\n## Usage\n\n```js\nvar tfa = require('2fa');\n\n// lets generate a new key for a user\n// tfa.generateKey(length (optional), cb)\ntfa.generateKey(32, function(err, key) {\n  // crypto secure hex key with 32 characters\n\n  // generate crypto-secure backups codes in a user-friendly pattern\n  // tfa.generateBackupCodes(num, pattern (optional), cb)\n  tfa.generateBackupCodes(8, 'xxxx-xxxx-xxxx', function(err, codes) {\n    // [ '7818-b7b8-c928', '3526-dc04-d3f2', 'be3c-5d9f-cb68', ... ]\n\n    // these should be sent to the user, stored and checked when we get a 2fa code\n  });\n\n  // generate a google QR code so the user can save their new key\n  // tfa.generateGoogleQR(name, accountname, secretkey, cb)\n  tfa.generateGoogleQR('Company', 'email@gmail.com', key, function(err, qr) {\n    // data URL png image for google authenticator\n  });\n\n  var opts = {\n    // the number of counters to check before what we're given\n    // default: 0\n    beforeDrift: 2,\n    // and the number to check after\n    // default: 0\n    afterDrift: 2,\n    // if before and after drift aren't specified,\n    // before + after drift are set to drift / 2\n    // default: 0\n    drift: 4,\n    // the step for the TOTP counter in seconds\n    // default: 30\n    step: 30\n  };\n\n  // calculate the counter for the HOTP (pretending it's actually TOTP)\n  var counter = Math.floor(Date.now() / 1000 / opts.step);\n\n  // generate a valid code (in real-life this will be user-input)\n  var code = tfa.generateCode(key, counter);\n\n  // verify it as a HOTP\n  var validHOTP = tfa.verifyHOTP(key, code, counter, opts);\n  // true\n\n  // for TOTP, the counter is calculated internally using Date.now();\n  var validTOTP = tfa.verifyTOTP(key, code, opts);\n  // true\n\n});\n```\n","maintainers":[{"name":"simontabor","email":"me@simontabor.com"}],"time":{"modified":"2022-06-12T14:06:55.958Z","created":"2014-09-21T20:55:34.615Z","0.0.1":"2014-09-21T20:55:34.615Z","0.1.0":"2015-03-05T18:20:35.279Z","0.1.1":"2015-03-13T12:25:54.790Z","0.1.2":"2015-04-21T11:04:03.575Z"},"homepage":"https://github.com/simontabor/2fa","keywords":["auth","two-factor","2fa"],"repository":{"type":"git","url":"git://github.com/simontabor/2fa.git"},"author":{"name":"Simon Tabor"},"bugs":{"url":"https://github.com/simontabor/2fa/issues"},"license":"MIT","readmeFilename":"README.md","users":{"jnk":true,"zewish":true}}