{"id":18535291,"url":"https://github.com/tinyhttp/jwt","last_synced_at":"2025-10-05T08:57:01.354Z","repository":{"id":57166687,"uuid":"382919742","full_name":"tinyhttp/jwt","owner":"tinyhttp","description":"🔐 tiny JWT middleware for Node.js","archived":false,"fork":false,"pushed_at":"2023-10-27T18:10:34.000Z","size":99,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:47:25.004Z","etag":null,"topics":["jwt","jwt-middleware","middleware","nodejs","tinyhttp"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinyhttp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"issuehunt":"talentlessguy","github":["tinyhttp","talentlessguy"]}},"created_at":"2021-07-04T18:15:55.000Z","updated_at":"2023-10-27T18:11:01.000Z","dependencies_parsed_at":"2023-01-21T20:19:12.164Z","dependency_job_id":"c2ad79ae-c20f-40a1-a5bc-64147ab987cb","html_url":"https://github.com/tinyhttp/jwt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyhttp","download_url":"https://codeload.github.com/tinyhttp/jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248058069,"owners_count":21040688,"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":["jwt","jwt-middleware","middleware","nodejs","tinyhttp"],"created_at":"2024-11-06T19:21:54.920Z","updated_at":"2025-10-05T08:56:56.308Z","avatar_url":"https://github.com/tinyhttp.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n\n# @tinyhttp/jwt\n\n[![NPM][npm-badge]][npm-url] [![NPM][dl-badge]][npm-url] [![GitHub Workflow Status][actions-img]][github-actions] [![Coverage][cov-img]][cov-url]\n\nJWT middleware for HTTP servers.\n\n\u003c/div\u003e\n\n## Install\n\n```sh\nbun i @tinyhttp/jwt\n```\n\n## API\n\n```ts\nimport { jwt } from '@tinyhttp/jwt'\n```\n\n### Options\n\n#### `jwt(options)`\n\n- `secret`: can be an array of strings (in case you are using private / public key encryption), or just a string if you are using basic HMAC signing (see the examples below)\n- `algorithm? (\"HS256\")`: the algorithm used to sign and verify the token\n- `audience?`: the expected \"audience\" of the jwt token\n- `issuer?`: who issued this token\n- `expiresIn?`: expiration time of the token (ex: `1d` for 1 day)\n- `notBefore?`: not before date of the token (ex: `20m` for 20 minutes)\n- `requestHeaderName? (\"Authorization\")`: the name of the header contaning the Bearer token\n- `responseHeaderName? (\"X-Token\")`: the name of the response header containing the new signed token that will be used later on\n- `getToken(string)?: string`: the method used for ex\n\n## Example\n\n### Basic secret\n\n```ts\nimport { App } from '@tinyhttp/app'\nimport { jwt } from '@tinyhttp/jwt'\n\nnew App()\n  .use(jwt({ secret: 'secret', algorithm: 'HS256' }))\n  .get('/', (req, res) =\u003e res.send(`Data inside the payload: ${req['user']}`))\n  .listen(8080)\n```\n\n### Private / Public key\n\n```ts\nimport { App } from '@tinyhttp/app'\nimport { jwt } from '@tinyhttp/jwt'\n\nnew App()\n  .use(jwt({ secret: ['PRIVATE KEY', 'PUBLIC KEY'], algorithm: 'RS256' }))\n  .get('/', (req, res) =\u003e res.send(`Data inside the payload: ${req['user']}`))\n  .listen(8080)\n```\n\n[npm-badge]: https://img.shields.io/npm/v/@tinyhttp/jwt?style=for-the-badge\u0026color=hotpink\u0026label=\u0026logo=npm\n[npm-url]: https://npmjs.com/package/@tinyhttp/jwt\n[dl-badge]: https://img.shields.io/npm/dt/@tinyhttp/jwt?style=for-the-badge\u0026color=hotpink\n[actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/jwt/main.yml?style=for-the-badge\u0026logo=github\u0026label=\u0026color=hotpink\n[github-actions]: https://github.com/tinyhttp/jwt/actions\n[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/jwt?style=for-the-badge\u0026color=hotpink\u0026a\n[cov-url]: https://coveralls.io/github/tinyhttp/jwt\n","funding_links":["https://issuehunt.io/r/talentlessguy","https://github.com/sponsors/tinyhttp","https://github.com/sponsors/talentlessguy"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Fjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinyhttp%2Fjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Fjwt/lists"}