{"id":28076687,"url":"https://github.com/jaredhanson/passport-hotp","last_synced_at":"2025-09-16T12:52:08.158Z","repository":{"id":8420563,"uuid":"10007249","full_name":"jaredhanson/passport-hotp","owner":"jaredhanson","description":"HOTP authentication strategy for Passport and Node.js.","archived":false,"fork":false,"pushed_at":"2018-01-04T16:37:03.000Z","size":12,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T01:15:48.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jpartogi/django-wmd-editor","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredhanson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-12T00:36:11.000Z","updated_at":"2022-03-25T15:37:25.000Z","dependencies_parsed_at":"2022-09-11T12:22:36.431Z","dependency_job_id":null,"html_url":"https://github.com/jaredhanson/passport-hotp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jaredhanson/passport-hotp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-hotp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-hotp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-hotp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-hotp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredhanson","download_url":"https://codeload.github.com/jaredhanson/passport-hotp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-hotp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264888074,"owners_count":23678792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-13T01:45:53.542Z","updated_at":"2025-09-16T12:52:03.088Z","avatar_url":"https://github.com/jaredhanson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Passport-HOTP\n\n[Passport](http://passportjs.org/) strategy for two-factor authentication using\na [HOTP](http://tools.ietf.org/html/rfc4226) value.\n\nThis module lets you authenticate using a HOTP value in your Node.js\napplications.  By plugging into Passport, HOTP two-factor authentication can be\neasily and unobtrusively integrated into any application or framework that\nsupports [Connect](http://www.senchalabs.org/connect/)-style middleware,\nincluding [Express](http://expressjs.com/).  HOTP values can be generated by\nhardware devices or software applications, including [Google Authenticator](https://code.google.com/p/google-authenticator/).\n\nNote that in contrast to most Passport strategies, HOTP authentication requires\nthat a user already be authenticated using an initial factor.  Requirements\nregarding when to require a second factor are a matter of application-level\npolicy, and outside the scope of both Passport and this strategy.\n\n## Install\n\n    $ npm install passport-hotp\n\n## Usage\n\n#### Configure Strategy\n\nThe HOTP authentication strategy authenticates a user using a HOTP value\ngenerated by a hardware device or software application (known as a token).  The\nstrategy requires a `setup` callback and a `resync` callback.\n\nThe `setup` callback accepts a previously authenticated `user` and calls `done`\nproviding a `key` and `counter` used to verify the HOTP value.  Authentication\nfails if the value is not verified.\n\nAfter successful authentication, the `resync` callback is invoked to synchronize\nthe counter values on the server and on the token.\n\n    passport.use(new HotpStrategy(\n      function(user, done) {\n        HotpKey.findOne({ userId: user.id }, function (err, key) {\n          if (err) { return done(err); }\n          return done(null, key.key, key.counter);\n        });\n      },\n      function(user, key, counter, delta, done) {\n        HotpKey.update(user.id, { key: key, counter: counter }, function (err, key) {\n          if (err) { return done(err); }\n          return done();\n        });\n      }\n    ));\n\n#### Authenticate Requests\n\nUse `passport.authenticate()`, specifying the `'hotp'` strategy, to authenticate\nrequests.\n\nFor example, as route middleware in an [Express](http://expressjs.com/)\napplication:\n\n    app.post('/verify-otp', \n      passport.authenticate('hotp', { failureRedirect: '/verify-otp' }),\n      function(req, res) {\n        req.session.authFactors = [ 'hotp' ];\n        res.redirect('/');\n      });\n\n## Examples\n\nFor a complete, working example, refer to the [two-factor example](https://github.com/jaredhanson/passport-hotp/tree/master/examples/two-factor).\n\n## Tests\n\n    $ npm install\n    $ make test\n\n[![Build Status](https://secure.travis-ci.org/jaredhanson/passport-hotp.png)](http://travis-ci.org/jaredhanson/passport-hotp)\n\n## Credits\n\n  - [Jared Hanson](http://github.com/jaredhanson)\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2013 Jared Hanson \u003c[http://jaredhanson.net/](http://jaredhanson.net/)\u003e\n\n\u003ca target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/passport-hotp'\u003e  \u003cimg alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/passport-hotp.svg' /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-hotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredhanson%2Fpassport-hotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-hotp/lists"}