{"id":16185731,"url":"https://github.com/forbeslindesay/jwt-cache","last_synced_at":"2025-07-08T07:36:34.687Z","repository":{"id":57287718,"uuid":"418495923","full_name":"ForbesLindesay/jwt-cache","owner":"ForbesLindesay","description":"Cache an async function for generating a JSON Web Token","archived":false,"fork":false,"pushed_at":"2023-03-16T16:47:23.000Z","size":38,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-12T12:50:28.134Z","etag":null,"topics":["javascript","jsonwebtoken","jwt","nodejs"],"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/ForbesLindesay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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":["ForbesLindesay"],"patreon":"ForbesLindesay","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-10-18T12:41:44.000Z","updated_at":"2021-10-22T12:29:47.000Z","dependencies_parsed_at":"2024-10-20T00:06:21.280Z","dependency_job_id":"50dafdce-e6b1-4ed4-93ee-eaa420ba2386","html_url":"https://github.com/ForbesLindesay/jwt-cache","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"ForbesLindesay/npm-package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForbesLindesay%2Fjwt-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForbesLindesay%2Fjwt-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForbesLindesay%2Fjwt-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForbesLindesay%2Fjwt-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForbesLindesay","download_url":"https://codeload.github.com/ForbesLindesay/jwt-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234139242,"owners_count":18785537,"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":["javascript","jsonwebtoken","jwt","nodejs"],"created_at":"2024-10-10T07:15:06.501Z","updated_at":"2025-01-16T02:24:00.672Z","avatar_url":"https://github.com/ForbesLindesay.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ForbesLindesay","https://patreon.com/ForbesLindesay"],"categories":[],"sub_categories":[],"readme":"# jwt-cache\n\nCache an async function for generating a JSON Web Token\n\n[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen)](https://rollingversions.com/ForbesLindesay/jwt-cache)\n\n## Installation\n\n```\nyarn add jwt-cache\n```\n\n## Usage\n\n```ts\nimport jwtCache from 'jwt-cache';\n\nconst cache = jwtCache({\n  getToken: async () =\u003e {\n    // this could be slow code for generating a JSON Web Token\n    // with an expiry represented via the standard \"exp\" value\n    return sign({hello: 'world'}, `my_secret`, {expiresIn: 3});\n  },\n  // If the token will not be valid for this many ms, get\n  // a new token rather than returning the cached token\n  // Defaults to 1 second\n  minimumValidityMilliseconds: 100,\n  // Optionally eagerly fetch a token before it is needed.\n  // This will trigger fetching a new token this many ms\n  // before it would reach the minimum validity threshold\n  eagerRefreshMilliseconds: 100,\n});\n\n// When you need a token:\ncache.getToken().then((token) =\u003e {\n  // use the token here\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforbeslindesay%2Fjwt-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforbeslindesay%2Fjwt-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforbeslindesay%2Fjwt-cache/lists"}