{"id":16430304,"url":"https://github.com/neutron92/types-passport-jwt.socketio","last_synced_at":"2026-05-18T03:35:23.515Z","repository":{"id":57320189,"uuid":"221780972","full_name":"neutron92/types-passport-jwt.socketio","owner":"neutron92","description":"A typescript passport-jwt middleware for socket.io","archived":false,"fork":false,"pushed_at":"2023-01-09T20:21:54.000Z","size":4496,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-22T14:27:37.780Z","etag":null,"topics":["authentication","node","nodejs","socketio","ts","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neutron92.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":"2019-11-14T20:27:23.000Z","updated_at":"2020-04-16T16:51:48.000Z","dependencies_parsed_at":"2023-02-08T14:01:37.854Z","dependency_job_id":null,"html_url":"https://github.com/neutron92/types-passport-jwt.socketio","commit_stats":null,"previous_names":["neutron92/-types-passport-jwt.socketio"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/neutron92/types-passport-jwt.socketio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutron92%2Ftypes-passport-jwt.socketio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutron92%2Ftypes-passport-jwt.socketio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutron92%2Ftypes-passport-jwt.socketio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutron92%2Ftypes-passport-jwt.socketio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neutron92","download_url":"https://codeload.github.com/neutron92/types-passport-jwt.socketio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neutron92%2Ftypes-passport-jwt.socketio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["authentication","node","nodejs","socketio","ts","typescript"],"created_at":"2024-10-11T08:26:28.130Z","updated_at":"2026-05-18T03:35:23.500Z","avatar_url":"https://github.com/neutron92.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"A [Socket.IO](https://socket.io/) middleware for authenticating with a [JSON Web Token](http://jwt.io) based on [passport-jwt](https://github.com/themikenicholson/passport-jwt) and [typeScript](https://github.com/microsoft/TypeScript) .\r\n\r\nThis module lets you authenticate socket.io endpoints using a JSON web token. It is\r\nintended to be used to secure endpoints without sessions.\r\n\r\n## Example usage\r\n\r\n### Server\r\n```TypeScript\r\n// Initialize our modules\r\nimport socketIO from 'socket.io';\r\nimport passportSocketIoTs from \"passport-jwt.socketio.ts\";\r\n\r\nconst server = http.createServer(router);\r\n\r\nexport const ioSocket : socketIO.Server = socketIO(server);\r\n\r\n// set the passport-jwt options\r\nconst options = {\r\n  jwtFromRequest: ExtractJwt.fromUrlQueryParameter('token'),\r\n  secretOrKey: secret\r\n}\r\n\r\nlet passSocketIo: passportSocketIoTs = new passportSocketIoTs();\r\n\r\nlet verify=(jwtPayload : any, done : any)=\u003e{\r\n    // token is valid we still can verify the token\r\n    console.log('jwtPayload', jwtPayload)\r\n    // the user passed is set to socket.request.user\r\n    done(null, jwtPayload)\r\n}\r\n\r\n// set the authorization middleware\r\n ioSocket.use(passSocketIo.authorize(options,verify,(err: any) =\u003e {\r\n    // calllback to log errors\r\n }));\r\n\r\nioSocket.on('connection', function (socket) {\r\n    // Connection now authenticated to receive further events\r\n    socket.on('ping', function (message) {\r\n        socket.emit('pong', message);\r\n    });\r\n});\r\n\r\n```\r\n\r\n### Client\r\n```html\r\n\u003chtml lang=\"en\"\u003e\r\n\r\n\u003chead\u003e\r\n    \u003cmeta charset=\"UTF-8\" /\u003e\r\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\r\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" /\u003e\r\n    \u003ctitle\u003eDocument\u003c/title\u003e\r\n\u003c/head\u003e\r\n\r\n\u003cbody\u003e\r\n    \u003cbutton onClick=\"sendMsg()\"\u003eHit Me\u003c/button\u003e\r\n\r\n    \u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js\"\u003e\u003c/script\u003e\r\n    \u003cscript\u003e\r\n        const jwt = 'eyJhbGciOiJIU...';\r\n\r\n        const socket = io.connect('http://localhost:3001', {\r\n            query: {\r\n                token: jwt // your token\r\n            }\r\n        });\r\n\r\n        function sendMsg() {\r\n            socket.emit('messages', 'hello!');\r\n            socket.on('messages', (data) =\u003e {\r\n                console.log('authenticate', data)\r\n            });\r\n        }\r\n    \u003c/script\u003e\r\n\u003c/body\u003e\r\n\r\n\u003c/html\u003e\r\n\r\n```\r\n\r\n## Tests\r\n\r\n    npm install\r\n\r\n## Inspiration\r\n\r\n* [passport-jwt.socketio](https://github.com/erreina/passport-jwt.socketio)\r\n\r\n## Contribute\r\n\r\nYou are always welcome to open an issue or provide a pull-request!\r\n\r\n## License\r\n\r\nThe [GPL-3.0-or-later](https://www.gnu.org/licenses/gpl-3.0.fr.html)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneutron92%2Ftypes-passport-jwt.socketio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneutron92%2Ftypes-passport-jwt.socketio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneutron92%2Ftypes-passport-jwt.socketio/lists"}