{"id":15569058,"url":"https://github.com/dan-online/jwtrust","last_synced_at":"2025-04-15T11:53:01.126Z","repository":{"id":64454913,"uuid":"572743880","full_name":"dan-online/jwtrust","owner":"dan-online","description":"A tiny library to sign and verify JWT tokens using Rust bindings for pure performance.","archived":false,"fork":false,"pushed_at":"2025-04-09T15:55:47.000Z","size":5273,"stargazers_count":16,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T16:51:36.742Z","etag":null,"topics":["jsonwebtoken","jwt","rust","speed"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/jwtrust","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dan-online.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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},"funding":{"github":["dan-online"]}},"created_at":"2022-11-30T23:53:12.000Z","updated_at":"2025-03-23T01:03:55.000Z","dependencies_parsed_at":"2024-03-07T06:29:49.367Z","dependency_job_id":"9766bdc3-609b-4c40-a164-ba2872770b8b","html_url":"https://github.com/dan-online/jwtrust","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":0.375,"last_synced_commit":"a1d8ad98185c970318fb461676863cd926347e46"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-online%2Fjwtrust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-online%2Fjwtrust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-online%2Fjwtrust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-online%2Fjwtrust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dan-online","download_url":"https://codeload.github.com/dan-online/jwtrust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249067759,"owners_count":21207395,"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":["jsonwebtoken","jwt","rust","speed"],"created_at":"2024-10-02T17:22:01.345Z","updated_at":"2025-04-15T11:53:01.104Z","avatar_url":"https://github.com/dan-online.png","language":"TypeScript","funding_links":["https://github.com/sponsors/dan-online"],"categories":[],"sub_categories":[],"readme":"![npm version](https://img.shields.io/npm/v/jwtrust)\n\n# JWTRust\n\nA tiny library to sign and verify JWT tokens using **Rust** bindings for pure performance.\n\n```ts\nJWTRust Benchmark commencing, runs set at 100000 and 16 payload length.\n\n✔ Benchmarking complete!\n┌──────────────┬──────────────┬───────────────────┬───────────┐\n│   (index)    │ Average (ms) │ Operations (op/s) │ Total (s) │\n├──────────────┼──────────────┼───────────────────┼───────────┤\n│   JWTRust    │   '0.010'    │     '104,020'     │  '0.96'   │\n│   fast-jwt   │   '0.018'    │     '55,056'      │  '1.82'   │\n│ jsonwebtoken │   '0.022'    │     '45,488'      │  '2.20'   │\n└──────────────┴──────────────┴───────────────────┴───────────┘\n```\n\n\u003e Benchmark run on Ryzen 3600X (6 cores, 12 threads) with 32GB RAM\n\n## Table of contents\n\n- [JWTRust](#jwtrust)\n  - [Table of contents](#table-of-contents)\n  - [Getting Started](#getting-started)\n  - [Installation](#installation)\n  - [API](#api)\n    - [construct](#construct)\n    - [sign](#sign)\n      - [Parameters](#parameters)\n    - [verify](#verify)\n      - [Parameters](#parameters-1)\n  - [Typescript](#typescript)\n  - [Development](#development)\n    - [Prerequisites](#prerequisites)\n    - [Building the entire package](#building-the-entire-package)\n    - [Running benchmarks](#running-benchmarks)\n  - [Contributing](#contributing)\n  - [Built With](#built-with)\n  - [Versioning](#versioning)\n  - [Authors](#authors)\n  - [License](#license)\n\n## Getting Started\n\n## Installation\n\nTo install and set up the library, run:\n\n```sh\n$ yarn add jwtrust\n```\n\nOr if you still for some reason prefer npm:\n\n```sh\n$ npm i jwtrust\n```\n\n## API\n\n### construct\n\n```js\nconst { JWTR } = require('jwtrust');\n\nconst jwtrust = new JWTR('secret');\n```\n\n### sign\n\n```js\nconst jwtrust = new JWTR('secret');\n\nconst token = jwtrust.sign({ hello: 'world' });\n```\n\nSupported options and result fields for the `sign` method are listed below.\n\n#### Parameters\n\n`payload`\n\n| Type    | Default value |\n| ------- | ------------- |\n| unknown | required      |\n\nThe payload to sign. This is JSON serialized before signing.\n\n`options`\n\n| Option | Default value       | Description                                                              |\n| ------ | ------------------- | ------------------------------------------------------------------------ |\n| exp    | 7 days              | Expiry date in UTC timestamp for example: Date.now() / 1000 + (60 \\* 60) |\n| iat    | (Date.now() / 1000) | Issued at time in UTC format                                             |\n\nTo aid expiry date, a helper is exported named `convertTime`:\n\n```js\nconst { convertTime } = require('jwtrust');\n\nconst exp = convertTime('1y');\nconst exp = convertTime('6h');\nconst exp = convertTime('2s');\n```\n\nExample:\n\n```js\nconst token = jwtrust.sign({ hello: 'world' }, { exp: convertTime('1y'), iat: Date.now() });\n```\n\n### verify\n\n```js\nconst jwtrust = new JWTR('secret');\n\nconst payload = jwtrust.verify(token);\n```\n\nSupported options and result fields for the `verify` method are listed below.\n\n#### Parameters\n\n`token`\n\n| Type   | Default value |\n| ------ | ------------- |\n| string | required      |\n\nThe token to verify and decode.\n\n## Typescript\n\nThis library is written in Typescript and includes type definitions. Here is an example that will be typed correctly:\n\n```ts\nimport { JWTR, convertTime } from 'jwtrust';\n\ntype Payload = { hello: string }\n\nconst jwtrust = new JWTR\u003cPayload\u003e('secret');\n\nconst token = jwtrust.sign({ hello: 'world' });\n\nconst decoded: Payload = jwtrust.verify(token);\n```\n\n## Development\n\n### Prerequisites\n\nThis project requires NodeJS (version 16 or later) and yarn.\n[Node](http://nodejs.dan-online/) and [NPM](https://yarnpkg.com/) are really easy to install.\nTo make sure you have them available on your machine,\ntry running the following command.\n\n```sh\n$ yarn -v \u0026\u0026 node -v \u0026\u0026 rustc --version\n3.3.0\nv16.18.0\nrustc 1.65.0\n```\n\n### Building the entire package\n\n_Requirement: Rust is installed on your machine._\n\n```sh\n$ yarn build\n```\n\nThis task will create a distribution version of the project\ninside your local `dist/` folder and output a binary in `native/`\n\n### Running benchmarks\n\n```sh\n$ yarn benchmark\n```\n\n## Contributing\n\n1.  Fork it!\n2.  Create your feature branch: `git checkout -b my-new-feature`\n3.  Add your changes: `git add .`\n4.  Commit your changes: `git commit -am 'Add some feature'`\n5.  Push to the branch: `git push origin my-new-feature`\n6.  Submit a pull request :sunglasses:\n\n## Built With\n\n- [Neon](https://neon-bindings.com/)\n- VSCode\n- TypeScript\n- Rust\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/dan-online/jwtrust/tags).\n\n## Authors\n\n- **DanCodes** - [@dan-online](https://github.com/dan-online) - \u003cdan@dancodes.online\u003e\n\n## License\n\n[MIT License](https://dan-online.mit-license.org/2022) © DanCodes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-online%2Fjwtrust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-online%2Fjwtrust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-online%2Fjwtrust/lists"}