{"id":21743946,"url":"https://github.com/telefonica/node-jwt-utils","last_synced_at":"2025-06-12T14:36:34.893Z","repository":{"id":34137855,"uuid":"37972327","full_name":"Telefonica/node-jwt-utils","owner":"Telefonica","description":"JSON Web Tokens (JWT) utils.","archived":false,"fork":false,"pushed_at":"2020-05-13T14:13:26.000Z","size":66,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-13T05:06:30.473Z","etag":null,"topics":["cdco"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Telefonica.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-24T08:30:24.000Z","updated_at":"2022-12-19T12:39:02.000Z","dependencies_parsed_at":"2022-08-18T00:35:47.254Z","dependency_job_id":null,"html_url":"https://github.com/Telefonica/node-jwt-utils","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-jwt-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-jwt-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-jwt-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-jwt-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Telefonica","download_url":"https://codeload.github.com/Telefonica/node-jwt-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665748,"owners_count":21142123,"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":["cdco"],"created_at":"2024-11-26T07:09:29.683Z","updated_at":"2025-04-13T05:06:39.568Z","avatar_url":"https://github.com/Telefonica.png","language":"JavaScript","readme":"jwt-utils\n=========\n\nJSON Web Tokens (JWT) utils.\n\n[![npm version](https://badge.fury.io/js/jwt-utils.svg)](http://badge.fury.io/js/jwt-utils)\n[![Build Status](https://travis-ci.org/telefonica/node-jwt-utils.svg)](https://travis-ci.org/telefonica/node-jwt-utils)\n[![Coverage Status](https://img.shields.io/coveralls/telefonica/node-jwt-utils.svg)](https://coveralls.io/r/telefonica/node-jwt-utils)\n\nThis module is able to parse and generate both encrypted and unencrypted JWT tokens.\n\n- A **hash key** (```hashKey```) is needed to generate a JWT signature.\n- An **encryption key** (```encryptKey```) is needed only if you need to deal with encrypted JWT tokens.\n\nThis module only allows hexadecimal strings as hash and encryption keys. The encryption key must be\na 32-length hexadecimal value (16 bytes) if the encryption algorithm is ```A128CBC```.\n\nThe ```kid``` (key identifier) goes in the JWT header, and serves as a client identifier, in case you need\nto use different keys for different clients.\n\n## Installation\n\n```bash\nnpm install jwt-utils\n```\n\n## Examples\n\n```javascript\nvar config = { expiration: 600};\nvar jwt = require('jwt-utils')(config);\n\n// Encode JWT token\njwt.buildJWT(payload, header, hashKey, function(err, token) {\n    if (!err) {\n        console.log(token); // something in the format \"aaa.bbb.ccc\"\n    }\n});\n\n// Decode JWT token\njwt.readJWT(token, hashKey, function(err, token) {\n    if (!err) {\n        console.log(token.payload);\n        console.log(token.header);\n    }\n});\n\n// Encrypt JWT token\njwt.buildJWTEncrypted(payload, header, encryptKey, hashKey, function(err, token) {\n    if (!err) {\n        console.log(token); // something in the format \"aaa.bbb.ccc.ddd.eee\"\n    }\n});\n\n// Decrypt JWT token\njwt.readJWTEncrypted(token, encryptKey, hashKey, function(err, token) {\n    if (!err) {\n        console.log(token.payload);\n        console.log(token.header);\n    }\n});\n\n// Read JWT header\njwt.readJWTHeader(token, function(err, header) {\n    if (!err) {\n        console.log(header);\n    }\n});\n```\n\n## Configuration\n\n* expiration: Expiration time in seconds to generate exp field in token (this functionality can be disabled by setting the value to 0).\n* futureTolerance: Tolerance seconds to find out if a jwt comes from the future or not.\n\n## Development information\n\n```\nnpm test\n```\n\n## Errors:\nThe following file has registered the error of this library:\n[errors.json](errors.json)\n\n## License\n\nCopyright 2015 [Telefónica Investigación y Desarrollo, S.A.U](http://www.tid.es)\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelefonica%2Fnode-jwt-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelefonica%2Fnode-jwt-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelefonica%2Fnode-jwt-utils/lists"}