{"id":15083838,"url":"https://github.com/emrahcom/jwt","last_synced_at":"2026-01-29T05:46:32.746Z","repository":{"id":255702703,"uuid":"853427283","full_name":"emrahcom/jwt","owner":"emrahcom","description":"Create and verify JSON Web Token","archived":false,"fork":false,"pushed_at":"2025-02-01T10:16:42.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T11:22:35.661Z","etag":null,"topics":["deno","jsr","jwt","typescript"],"latest_commit_sha":null,"homepage":"https://jsr.io/@emrahcom/jwt","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/emrahcom.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}},"created_at":"2024-09-06T16:26:28.000Z","updated_at":"2025-02-01T10:16:45.000Z","dependencies_parsed_at":"2025-01-23T08:31:47.940Z","dependency_job_id":"b64f107d-221a-418f-b28a-bfbbb5c80652","html_url":"https://github.com/emrahcom/jwt","commit_stats":null,"previous_names":["emrahcom/jwt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emrahcom%2Fjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emrahcom%2Fjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emrahcom%2Fjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emrahcom%2Fjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emrahcom","download_url":"https://codeload.github.com/emrahcom/jwt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243941504,"owners_count":20372248,"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":["deno","jsr","jwt","typescript"],"created_at":"2024-09-25T06:33:48.393Z","updated_at":"2026-01-29T05:46:32.734Z","avatar_url":"https://github.com/emrahcom.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT\n\nCreate and verify JSON Web Tokens (JWT).\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\nOr to generate a **secure** `CryptoKey` using a secret.\n\n```typescript\nconst secret = \"MYSECRET\";\nconst encoder = new TextEncoder();\nconst keyData = encoder.encode(secret);\nconst key = await crypto.subtle.importKey(\n  \"raw\",\n  keyData,\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 \"jsr:@emrahcom/jwt\";\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 \"jsr:@emrahcom/jwt\";\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 \"jsr:@emrahcom/jwt\";\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\nimport { getNumericDate } from \"jsr:@emrahcom/jwt\";\n\n// A specific date:\nconst exp = getNumericDate(new Date(\"2025-07-01\"));\n// One hour from now:\nconst nbf = getNumericDate(60 * 60);\n```\n\nSee also [examples](examples).\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## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file\nfor details.\n\nThis project is a fork of [Zaubrik/djwt](https://github.com/Zaubrik/djwt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femrahcom%2Fjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femrahcom%2Fjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femrahcom%2Fjwt/lists"}