{"id":19163262,"url":"https://github.com/oada/node-jwks-utils","last_synced_at":"2025-07-13T23:33:40.965Z","repository":{"id":27340779,"uuid":"30815652","full_name":"OADA/node-jwks-utils","owner":"OADA","description":"Utility methods for working with a JSON Web Key (JWK) and/or JSON Web Key Set (JWKs)","archived":false,"fork":false,"pushed_at":"2024-07-30T16:25:18.000Z","size":41,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-07T11:39:44.102Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/OADA.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,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-02-15T02:33:50.000Z","updated_at":"2022-08-26T15:25:06.000Z","dependencies_parsed_at":"2025-04-20T15:15:23.564Z","dependency_job_id":null,"html_url":"https://github.com/OADA/node-jwks-utils","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/OADA/node-jwks-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OADA%2Fnode-jwks-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OADA%2Fnode-jwks-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OADA%2Fnode-jwks-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OADA%2Fnode-jwks-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OADA","download_url":"https://codeload.github.com/OADA/node-jwks-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OADA%2Fnode-jwks-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265220829,"owners_count":23729893,"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-09T09:14:40.608Z","updated_at":"2025-07-13T23:33:40.921Z","avatar_url":"https://github.com/OADA.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/OADA/node-jwks-utils.svg?branch=master)](https://travis-ci.org/OADA/node-jwks-utils)\n[![Coverage Status](https://coveralls.io/repos/OADA/node-jwks-utils/badge.svg?branch=master)](https://coveralls.io/r/OADA/node-jwks-utils?branch=master)\n[![Dependency Status](https://david-dm.org/oada/node-jwks-utils.svg)](https://david-dm.org/oada/node-jwks-utils)\n[![License](http://img.shields.io/:license-Apache%202.0-green.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)\n\nnode-jwks-utils\n===============\n\n*THIS LIBRARY IS DEPRECATED. WE USE OADA-CERTS NOW INSTEAD.*\n\nA set of useful tools when working with [JSON Web Key (JWK)][JWK] and [JSON Web\nKey Set (JWKs)][JWKs].\n\nInstall\n-------\n```shell\n$ npm install jwks-utils\n```\n\nExample\n-------\n```javascript\nvar jwksUtils = require('jwks-utils');\n\nvar jwk = { kid: '1234', kty: 'RSA', n: '12345...XYZ=', e: 'AQAB' };\nvar jwks = { keys: [ jwk ] }\n\n// Detect a JWK object\nif(jwksUtils.isJWK(jwk)) {\n    // Do stuff with the JWk\n}\n\n// Detect a JWKs object\nif(jwksUtils.isJWKset(jwks)) {\n    // Do stuff with the JWKs\n}\n\n// Find a particilar JWK within a JWKs\nvar jwk1 = jwkUtils.findJWK('1234', jwks);\n\n// Find the JWK corsponding to a particular JWS (or JWT)\nvar signature = getJWSFromSomwhere();\njwkUtils.jwkForSignature(signature, false, {timeout: 100}, function(err, jwk2) {\n    if (!err) {\n        // jwk2 is the corresponding JWK\n    }\n};\n\n```\n\n## Caching of JSON Web Key Sets (`jwks`) from a JSON Web Key URI (`jku`) ##\nThis library makes requests to outside web URI's if it determines that a `jku` is needed\nto get the public key (`jwk`) to verify a signature.  It expects that URL to have a JSON\nWeb Key Set (`jwks` according to the standard).  Because this process can sometimes be \nslow, and because in production sometimes networks go down, we have added a small in-memory\ncache to this library.  \n\nWhen the library decides it needs a `jwks` from a `jku`, it will immediately return the \ncached value if the given signature's key is in the cached keyset.  It will also fire off\na request in the background that will update the cache to the latest copy of the jwk set.\nIt will consider the cache entry stale after 1 hour and then wait for the request to update\nthe cache.\n\nIf the key in the signature was not in a cached `jwks` (or it was not yet cached at all),\nthe function will wait for the request to finish.  Once it finishes, if there was an error\nin the request, it will check the cache to see if we have a stale cached copy.  If so, then\nit will use that stale cached copy for up to 24 hours before removing it from the cache.\n\nIf it does not have an error in the request, even if we've already returned the cached copy\nfor the signature, it will go ahead and put the new response's `jwks` into the cache and then\nreturn it.\n\nIn this way, whenever you publish a new `kid` in your `jwks`, any clients will immediately be\nable to use it.  However, if you revoke a `kid`, the client will still allow for 1 valid\nsignature in the first hour, and then any request after the first one, or after an hour, will\nbe invalid.\n\nReferences\n----------\n1. [JSON Web Key (JWK) Draft 40](https://tools.ietf.org/html/draft-ietf-jose-json-web-key-40)\n\n[JWK]: https://tools.ietf.org/html/draft-ietf-jose-json-web-key-40#section-4 \"JSON Web Key\"\n[JWKs]: https://tools.ietf.org/html/draft-ietf-jose-json-web-key-40#section-5 \"JSON Web Key Set\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foada%2Fnode-jwks-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foada%2Fnode-jwks-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foada%2Fnode-jwks-utils/lists"}