{"id":30180616,"url":"https://github.com/timonson/djwt","last_synced_at":"2025-08-12T08:01:58.143Z","repository":{"id":37989679,"uuid":"208494002","full_name":"Zaubrik/djwt","owner":"Zaubrik","description":"Create and verify JSON Web Tokens (JWT) with Deno or the browser.","archived":false,"fork":false,"pushed_at":"2024-08-09T14:16:06.000Z","size":242,"stargazers_count":234,"open_issues_count":4,"forks_count":24,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-11T18:14:13.959Z","etag":null,"topics":["authentication","browser","deno","jsonwebtoken","jwt"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zaubrik.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":"2019-09-14T19:38:58.000Z","updated_at":"2025-08-07T05:49:44.000Z","dependencies_parsed_at":"2023-01-21T18:46:42.485Z","dependency_job_id":"b85adbb5-6837-4f3c-b5cb-eaa01a81a1b8","html_url":"https://github.com/Zaubrik/djwt","commit_stats":null,"previous_names":["timonson/djwt"],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/Zaubrik/djwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaubrik%2Fdjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaubrik%2Fdjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaubrik%2Fdjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaubrik%2Fdjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zaubrik","download_url":"https://codeload.github.com/Zaubrik/djwt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaubrik%2Fdjwt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270024697,"owners_count":24514054,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"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","browser","deno","jsonwebtoken","jwt"],"created_at":"2025-08-12T08:01:28.287Z","updated_at":"2025-08-12T08:01:58.128Z","avatar_url":"https://github.com/Zaubrik.png","language":"TypeScript","readme":"# djwt\n\nCreate and verify JSON Web Tokens with Deno or the browser.\n\n## API\n\nPlease use the native\n[Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey)\nto generate a **secure** `CryptoKey`.\n\n```typescript\nconst key = await crypto.subtle.generateKey(\n  { name: \"HMAC\", hash: \"SHA-512\" },\n  true,\n  [\"sign\", \"verify\"],\n);\n```\n\n### create\n\nTakes `Header`, `Payload` and `CryptoKey` and returns the url-safe encoded\n`jwt`.\n\n```typescript\nimport { create } from \"https://deno.land/x/djwt@$VERSION/mod.ts\";\n\nconst jwt = await create({ alg: \"HS512\", typ: \"JWT\" }, { foo: \"bar\" }, key);\n```\n\n### verify\n\nTakes `jwt`, `CryptoKey` and `VerifyOptions` and returns the `Payload` of the\n`jwt` if the `jwt` is valid. Otherwise it throws an `Error`.\n\n```typescript\nimport { verify } from \"https://deno.land/x/djwt@$VERSION/mod.ts\";\n\nconst payload = await verify(jwt, key); // { foo: \"bar\" }\n```\n\n### decode\n\nTakes a `jwt` and returns a 3-tuple\n`[header: unknown, payload: unknown, signature: Uint8Array]` if the `jwt` has a\nvalid _serialization_. Otherwise it throws an `Error`. This function does\n**not** verify the digital signature.\n\n```typescript\nimport { decode } from \"https://deno.land/x/djwt@$VERSION/mod.ts\";\n\nconst [header, payload, signature] = decode(jwt);\n```\n\n### getNumericDate\n\nThis helper function simplifies setting a\n[NumericDate](https://tools.ietf.org/html/rfc7519#page-6). It takes either a\n`Date` object or a `number` (in seconds) and returns the number of seconds from\n1970-01-01T00:00:00Z UTC until the specified UTC date/time.\n\n```typescript\n// A specific date:\nconst exp = getNumericDate(new Date(\"2025-07-01\"));\n// One hour from now:\nconst nbf = getNumericDate(60 * 60);\n```\n\n## Claims\n\n### Expiration Time (exp)\n\nThe optional `exp` (_expiration time_) claim in the payload identifies the\nexpiration time on or after which the JWT must not be accepted for processing.\nIts value must be a number containing a **NumericDate** value. This module\nchecks if the current date/time is before the expiration date/time listed in the\n`exp` claim.\n\n```typescript\nconst jwt = await create(header, { exp: getNumericDate(60 * 60) }, key);\n```\n\n### Not Before (nbf)\n\nThe optional `nbf` (_not before_) claim identifies the time before which the jwt\nmust not be accepted for processing. Its value must be a number containing a\n**NumericDate** value.\n\n### Audience (aud)\n\nThe optional `aud` (_audience_) claim identifies the recipients that the JWT is\nintended for. By passing the option `audience` with the type\n`string | string[] | RegExp` to `verify`, this application tries to identify the\nrecipient with a value in the `aud` claim. If the values don't match, an `Error`\nis thrown.\n\n## Algorithms\n\nThe following signature and MAC algorithms have been implemented:\n\n- HS256 (HMAC SHA-256)\n- HS384 (HMAC SHA-384)\n- HS512 (HMAC SHA-512)\n- RS256 (RSASSA-PKCS1-v1_5 SHA-256)\n- RS384 (RSASSA-PKCS1-v1_5 SHA-384)\n- RS512 (RSASSA-PKCS1-v1_5 SHA-512)\n- PS256 (RSASSA-PSS SHA-256)\n- PS384 (RSASSA-PSS SHA-384)\n- PS512 (RSASSA-PSS SHA-512)\n- ES256 (ECDSA using P-256 and SHA-256)\n- ES384 (ECDSA using P-384 and SHA-384)\n- ES512 (ECDSA using P-521 and SHA-512) (Not supported yet!)\n- none ([_Unsecured JWTs_](https://tools.ietf.org/html/rfc7519#section-6)).\n\n## Serialization\n\nThis application uses the JWS Compact Serialization only.\n\n## Specifications\n\n- [JSON Web Token](https://tools.ietf.org/html/rfc7519)\n- [JSON Web Signature](https://www.rfc-editor.org/rfc/rfc7515.html)\n- [JSON Web Algorithms](https://www.rfc-editor.org/rfc/rfc7518.html)\n\n## Applications\n\nThe following projects use djwt:\n\n- [Oak Middleware JWT](https://github.com/halvardssm/oak-middleware-jwt)\n- [deno_rest](https://github.com/Prolifode/deno_rest): A Boilerplate for deno\n  RESTful apis\n\n## Discord\n\nFeel free to ask questions and start discussions in our\n[discord server](https://discord.gg/6spYphKXAt).\n\n## Contribution\n\nWe welcome and appreciate all contributions to djwt.\n\nA big **Thank You** to [timreichen](https://github.com/timreichen) and all the\nother amazing contributors.\n","funding_links":[],"categories":["核心模块与框架（按需求挑）","Modules","Uncategorized","基础设施"],"sub_categories":["身份验证与安全（做登录/权限用）","Online Playgrounds","Assistants","Uncategorized","Web utils","JAM Stack/静态站点"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimonson%2Fdjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimonson%2Fdjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimonson%2Fdjwt/lists"}