{"id":30040371,"url":"https://github.com/ap-1/elysia-oauth2-resource-server","last_synced_at":"2026-02-25T19:33:48.683Z","repository":{"id":290288038,"uuid":"973931098","full_name":"ap-1/elysia-oauth2-resource-server","owner":"ap-1","description":"OAuth2 Resource Server middleware for Elysia","archived":false,"fork":false,"pushed_at":"2025-12-26T17:25:05.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T20:36:36.963Z","etag":null,"topics":["authorization","elysia","jwks","jwt","oauth2","resource-server"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/elysia-oauth2-resource-server","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ap-1.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-28T02:18:14.000Z","updated_at":"2025-08-08T11:04:59.000Z","dependencies_parsed_at":"2025-04-28T03:36:13.682Z","dependency_job_id":null,"html_url":"https://github.com/ap-1/elysia-oauth2-resource-server","commit_stats":null,"previous_names":["ap-1/elysia-oauth2-resource-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ap-1/elysia-oauth2-resource-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-1%2Felysia-oauth2-resource-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-1%2Felysia-oauth2-resource-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-1%2Felysia-oauth2-resource-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-1%2Felysia-oauth2-resource-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ap-1","download_url":"https://codeload.github.com/ap-1/elysia-oauth2-resource-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-1%2Felysia-oauth2-resource-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29836310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T19:08:47.527Z","status":"ssl_error","status_checked_at":"2026-02-25T18:59:04.705Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["authorization","elysia","jwks","jwt","oauth2","resource-server"],"created_at":"2025-08-07T01:58:49.413Z","updated_at":"2026-02-25T19:33:48.655Z","avatar_url":"https://github.com/ap-1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elysia-oauth2-resource-server\n\nOAuth2 Resource Server middleware for Elysia, providing local JWT validation against JWKS endpoints. Inspired by the [`tower-oauth2-resource-server`](https://crates.io/crates/tower-oauth2-resource-server) crate for Rust.\n\n[![NPM Version](https://img.shields.io/npm/v/elysia-oauth2-resource-server)](https://www.npmjs.com/package/elysia-oauth2-resource-server)\n[![License](https://img.shields.io/npm/l/elysia-oauth2-resource-server)](https://github.com/ap-1/elysia-oauth2-resource-server/blob/main/LICENSE)\n\n## Features\n\n- Validates JWT tokens from OAuth2/OIDC providers\n- JWKS-based signature validation\n- Verifies issuer and audience claims\n- Validates token scopes for authorization\n\n## Installation\n\n```bash\nbun add elysia-oauth2-resource-server\n```\n\n## Quick Start\n\n```ts\nimport { Elysia } from \"elysia\";\nimport { oauth2ResourceServer } from \"elysia-oauth2-resource-server\"\n\nconst app = new Elysia()\n\t.use(oauth2ResourceServer({\n\t\tjwksUri: 'https://auth.example.com/.well-known/jwks.json',\n\t\tissuer: 'https://auth.example.com',\n\t\taudience: 'my-api',\n\t\trequiredScopes: ['read:users']\n\t}))\n\t.get('/users', ({ auth }) =\u003e {\n\t\t// auth contains the validated JWT payload\n\t\treturn { userId: auth.sub }\n\t})\n\t.listen(3000);\n\nconsole.log(\"Server is listening at http://localhost:3000\");\n```\n\n## API Reference\n\n### `oauth2ResourceServer(options)`\n\nCreates an OAuth2 Resource Server middleware that validates JWTs against a JWKS endpoint.\n\n#### Options\n\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `jwksUri` | `string` | Yes | The URL to the JWKS endpoint (typically ends with `/.well-known/jwks.json`) |\n| `issuer` | `string` | Yes | The expected issuer claim value (must match the JWT's `iss` claim) |\n| `audience` | `string \\| string[]` | No | Expected audience(s) (must be included in the JWT's `aud` claim) |\n| `requiredScopes` | `string[]` | No | List of scopes that must be present in the token |\n| `jwksOptions` | `object` | No | Options for JWKS retrieval and caching |\n| `jwksOptions.cacheMaxAge` | `number` | No | Max age of cached JWKS in milliseconds |\n| `jwksOptions.timeoutDuration` | `number` | No | Timeout for JWKS request in milliseconds |\n\n#### Returns\n\nAdds an `auth` property to the request context, which contains the validated JWT payload.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fap-1%2Felysia-oauth2-resource-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fap-1%2Felysia-oauth2-resource-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fap-1%2Felysia-oauth2-resource-server/lists"}