{"id":20987412,"url":"https://github.com/stacks-network/jsontokens-js","last_synced_at":"2025-03-24T15:05:29.945Z","repository":{"id":39140911,"uuid":"42963977","full_name":"stacks-network/jsontokens-js","owner":"stacks-network","description":"Library for encoding, decoding, and verifying JSON Web Tokens (JWTs) in node.js","archived":false,"fork":false,"pushed_at":"2023-09-11T17:22:25.000Z","size":5110,"stargazers_count":45,"open_issues_count":9,"forks_count":26,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-11T14:08:51.434Z","etag":null,"topics":[],"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/stacks-network.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-09-22T22:13:10.000Z","updated_at":"2024-08-08T15:17:13.000Z","dependencies_parsed_at":"2024-06-18T13:39:27.767Z","dependency_job_id":"29e77a10-f643-4168-a4b6-aa2f3db00996","html_url":"https://github.com/stacks-network/jsontokens-js","commit_stats":{"total_commits":125,"total_committers":11,"mean_commits":"11.363636363636363","dds":0.5760000000000001,"last_synced_commit":"76ecc0c7289c7573c190e91d51b66d1e215bf9d9"},"previous_names":["blockstack/blockstack-tokens-js","blockstack/jsonwebtoken-js","blockstack/jsontokens-js"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fjsontokens-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fjsontokens-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fjsontokens-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fjsontokens-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacks-network","download_url":"https://codeload.github.com/stacks-network/jsontokens-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244924996,"owners_count":20532898,"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":[],"created_at":"2024-11-19T06:16:52.702Z","updated_at":"2025-03-24T15:05:29.917Z","avatar_url":"https://github.com/stacks-network.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Tokens JS\n\n[![CircleCI](https://img.shields.io/circleci/project/blockstack/jsontokens-js/master.svg)](https://circleci.com/gh/blockstack/jsontokens-js/tree/master)\n[![npm](https://img.shields.io/npm/l/jsontokens.svg)](https://www.npmjs.com/package/jsontokens)\n[![npm](https://img.shields.io/npm/v/jsontokens.svg)](https://www.npmjs.com/package/jsontokens)\n[![npm](https://img.shields.io/npm/dm/jsontokens.svg)](https://www.npmjs.com/package/jsontokens)\n[![Slack](https://img.shields.io/badge/join-slack-e32072.svg?style=flat)](http://slack.blockstack.org/)\n\nnode.js library for signing, decoding, and verifying JSON Web Tokens (JWTs) with the ES256K signature scheme (which uses the secp256k elliptic curve). This is currently the only supported signing and verification scheme for this library.\n\n### Installation\n\n```\nnpm install jsontokens\n```\n\n### Signing Tokens\n\n```js\nimport { TokenSigner } from 'jsontokens'\n\nconst rawPrivateKey = '278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f'\nconst tokenPayload = {\"iat\": 1440713414.85}\nconst token = new TokenSigner('ES256K', rawPrivateKey).sign(tokenPayload)\n```\n\n### Creating Unsecured Tokens\n\n```js\nimport { createUnsecuredToken } from 'jsontokens'\n\nconst unsecuredToken = createUnsecuredToken(tokenPayload)\n```\n\n### Decoding Tokens\n\n```js\nimport { decodeToken } = from 'jsontokens'\nconst tokenData = decodeToken(token)\n```\n\n### Verifying Tokens\n\nThe TokenVerifier class will validate that a token is correctly signed. It does not perform checks on the claims in the payload (e.g., the `exp` field)--- checking the expiration field, etc., is left as a requirement for callers.\n\n```js\nimport { TokenVerifier } from 'jsontokens'\nconst rawPublicKey = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'\nconst verified = new TokenVerifier('ES256K', rawPublicKey).verify(token)\n```\n\n### Example Tokens\n\n```text\neyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacks-network%2Fjsontokens-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacks-network%2Fjsontokens-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacks-network%2Fjsontokens-js/lists"}