{"id":16196309,"url":"https://github.com/mattroberts297/jsonwebtokencli","last_synced_at":"2025-03-19T05:30:26.678Z","repository":{"id":49597187,"uuid":"87273987","full_name":"mattroberts297/jsonwebtokencli","owner":"mattroberts297","description":"A simple command line interface (CLI) for the jsonwebtoken (JWT) library","archived":false,"fork":false,"pushed_at":"2022-12-22T10:37:03.000Z","size":87,"stargazers_count":28,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-16T05:31:57.130Z","etag":null,"topics":["cli","jwt"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/mattroberts297.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":"2017-04-05T06:25:52.000Z","updated_at":"2024-08-30T09:46:09.000Z","dependencies_parsed_at":"2023-01-30T07:15:41.776Z","dependency_job_id":null,"html_url":"https://github.com/mattroberts297/jsonwebtokencli","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattroberts297%2Fjsonwebtokencli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattroberts297%2Fjsonwebtokencli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattroberts297%2Fjsonwebtokencli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattroberts297%2Fjsonwebtokencli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattroberts297","download_url":"https://codeload.github.com/mattroberts297/jsonwebtokencli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243971156,"owners_count":20376784,"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":["cli","jwt"],"created_at":"2024-10-10T08:47:11.464Z","updated_at":"2025-03-19T05:30:24.726Z","avatar_url":"https://github.com/mattroberts297.png","language":"JavaScript","readme":"# JSON Web Token CLI\n\n[![Build status](https://travis-ci.org/mattroberts297/jsonwebtokencli.svg?branch=master)](https://travis-ci.org/mattroberts297/jsonwebtokencli)\n[![npm version](https://badge.fury.io/js/jsonwebtokencli.svg)](https://badge.fury.io/js/jsonwebtokencli)\n\nA simple command line interface (CLI) for the `jsonwebtoken` (JWT) library that can encode and decode both HS256 and RS256 tokens.\n\n## Installation\n\n```bash\nnpm install --global jsonwebtokencli\n```\n\n## Show help\n\n```bash\njwt\n```\n\nReturns:\n```bash\njsonwebtokencli\n\n  A json web token command line interface\n\nOptions\n\n  -h, --help                  Display this help\n  -d, --decode                Decode an encoded jwt token\n  -e, --encode                Encode a decoded jwt token - requires secret or private key\n  -s, --secret string         Used with decode and encode - when used with decode the jwt token is verified\n  --private-key-file string   Used with encode - the key to sign a decoded jwt token with\n  --public-key-file string    When used with decode the encoded jwt token is verified\n  -t, --timestamp             Used with encode - whether or not to include iat\n  --algorithm string          Used with encode - supported values include HS256, HS384 and RS256\n  --algorithms string[]       Used with decode - requires secret or private key\n  --jwt string                The jwt to decode or encode - falls back to stdin\n```\n\n## HS256 Examples\n\n### Decode a HS256 token\n\n```bash\njwt --decode eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ\n```\n\n```json\n{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}\n```\n\n### Verify a HS256 token using secret\n\n```bash\njwt --decode --secret secret eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ\n```\n\n```json\n{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}\n```\n\n### Encode a HS256 token using secret\n\n```bash\njwt --encode --secret secret '{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}'\n```\n\n```\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ\n```\n\n## RS256 Examples\n\n### Decode a RS256 token\n\n```bash\njwt --decode 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.EkN-DOsnsuRjRO6BxXemmJDm3HbxrbRzXglbN2S4sOkopdU4IsDxTI8jO19W_A4K8ZPJijNLis4EZsHeY559a4DFOd50_OqgHGuERTqYZyuhtF39yxJPAjUESwxk2J5k_4zM3O-vtd1Ghyo4IbqKKSy6J9mTniYJPenn5-HIirE'\n```\n\n```json\n{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}\n```\n\n### Verify a RS256 token using public key\n\n```bash\ncat \u003e public.key \u003c\u003cEOF\n-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugdUWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQsHUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5Do2kQ+X5xK9cipRgEKwIDAQAB\n-----END PUBLIC KEY-----\nEOF\n```\n\n```bash\njwt --decode --algorithms 'RS256' --public-key-file './public.key' 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.EkN-DOsnsuRjRO6BxXemmJDm3HbxrbRzXglbN2S4sOkopdU4IsDxTI8jO19W_A4K8ZPJijNLis4EZsHeY559a4DFOd50_OqgHGuERTqYZyuhtF39yxJPAjUESwxk2J5k_4zM3O-vtd1Ghyo4IbqKKSy6J9mTniYJPenn5-HIirE'\n```\n\n```json\n{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}\n```\n\n### Encode a RS256 token using private key\n\n```bash\ncat \u003e private.key \u003c\u003cEOF\n-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgQDdlatRjRjogo3WojgGHFHYLugdUWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQsHUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5Do2kQ+X5xK9cipRgEKwIDAQABAoGAD+onAtVye4ic7VR7V50DF9bOnwRwNXrARcDhq9LWNRrRGElESYYTQ6EbatXS3MCyjjX2eMhu/aF5YhXBwkppwxg+EOmXeh+MzL7Zh284OuPbkglAaGhV9bb6/5CpuGb1esyPbYW+Ty2PC0GSZfIXkXs76jXAu9TOBvD0ybc2YlkCQQDywg2R/7t3Q2OE2+yo382CLJdrlSLVROWKwb4tb2PjhY4XAwV8d1vy0RenxTB+K5Mu57uVSTHtrMK0GAtFr833AkEA6avx20OHo61Yela/4k5kQDtjEf1N0LfI+BcWZtxsS3jDM3i1Hp0KSu5rsCPb8acJo5RO26gGVrfAsDcIXKC+bQJAZZ2XIpsitLyPpuiMOvBbzPavd4gY6Z8KWrfYzJoI/Q9FuBo6rKwl4BFoToD7WIUS+hpkagwWiz+6zLoX1dbOZwJACmH5fSSjAkLRi54PKJ8TFUeOP15h9sQzydI8zJU+upvDEKZsZc/UhT/SySDOxQ4G/523Y0sz/OZtSWcol/UMgQJALesy++GdvoIDLfJX5GBQpuFgFenRiRDabxrE9MNUZ2aPFaFp+DyAe+b4nDwuJaW2LURbr8AEZga7oQj0uYxcYw==\n-----END RSA PRIVATE KEY-----\nEOF\n```\n\n```bash\njwt --encode --algorithm 'RS256' --private-key-file './private.key' '{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}'\n```\n\n```\neyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.EkN-DOsnsuRjRO6BxXemmJDm3HbxrbRzXglbN2S4sOkopdU4IsDxTI8jO19W_A4K8ZPJijNLis4EZsHeY559a4DFOd50_OqgHGuERTqYZyuhtF39yxJPAjUESwxk2J5k_4zM3O-vtd1Ghyo4IbqKKSy6J9mTniYJPenn5-HIirE\n```\n\n## `stdin` Examples\n\n### Decode `stdin`\n\n```bash\necho eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ | jwt --decode\n```\n\n```json\n{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}\n```\n\n### Encode `stdin`\n\n```bash\necho '{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"admin\":true}' | jwt --encode --secret secret\n```\n\n```\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ\n```\n\n## Development\n\nCheck jwt is not installed globally:\n\n```bash\n$ which jwt\njwt not found\n```\n\nMaybe uninstall it:\n\n```bash\nnpm --global uninstall jsonwebtokencli\n```\n\nIn the project directory, use `npm link`:\n\n```bash\n$ npm link\n/usr/local/bin/jwt -\u003e /usr/local/lib/node_modules/jsonwebtokencli/main.js\n```\n\nCheck it worked:\n\n```bash\n$ which jwt\n/usr/local/bin/jwt\n```\n\nUnlink when finished:\n\n```bash\n$ npm unlink\n```\n\n## Known Issues\n\n- There is little to no validation performed, so error messages leave a lot to be desired.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattroberts297%2Fjsonwebtokencli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattroberts297%2Fjsonwebtokencli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattroberts297%2Fjsonwebtokencli/lists"}