{"id":28629762,"url":"https://github.com/fibjs/fib-jws","last_synced_at":"2025-06-12T12:13:31.221Z","repository":{"id":57235124,"uuid":"100013971","full_name":"fibjs/fib-jws","owner":"fibjs","description":"JSON Web Signatures for fibjs.","archived":false,"fork":false,"pushed_at":"2024-07-23T15:40:16.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-06T08:10:40.163Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/fibjs.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.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}},"created_at":"2017-08-11T09:09:43.000Z","updated_at":"2024-07-23T15:40:19.000Z","dependencies_parsed_at":"2024-03-19T18:02:20.776Z","dependency_job_id":"49212328-31a6-44e7-bda6-df6d7060485b","html_url":"https://github.com/fibjs/fib-jws","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":"0.21052631578947367","last_synced_commit":"fa2775622c30cf9be91077ed5c7feb0c3e594dee"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-jws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-jws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-jws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-jws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibjs","download_url":"https://codeload.github.com/fibjs/fib-jws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-jws/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259178211,"owners_count":22817373,"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":"2025-06-12T12:13:30.509Z","updated_at":"2025-06-12T12:13:31.193Z","avatar_url":"https://github.com/fibjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fib-jws\n\n\u003c!-- [![Build Status](https://travis-ci.org/fibjs/fib-jws.svg)](https://travis-ci.org/fibjs/fib-jws) --\u003e\n[![NPM version](https://img.shields.io/npm/v/fib-jws.svg)](https://www.npmjs.org/package/fib-jws)\n\nAn implementation of [JSON Web Signatures](https://www.rfc-editor.org/rfc/rfc7515.txt).\n\n# Install\n\n```bash\n$ npm install fib-jws\n```\n\n# Usage\n\n## jws.ALGORITHMS\nArray of supported algorithms. The following algorithms are currently supported.\n\nalg Parameter Value | Digital Signature or MAC Algorithm\n----------------|----------------------------\nHS256 | HMAC using SHA-256 hash algorithm\nHS384 | HMAC using SHA-384 hash algorithm\nHS512 | HMAC using SHA-512 hash algorithm\nHSM3 | HMAC using SM3 hash algorithm\nRS256 | RSASSA using SHA-256 hash algorithm\nRS384 | RSASSA using SHA-384 hash algorithm\nRS512 | RSASSA using SHA-512 hash algorithm\nES256 | ECDSA using P-256 curve and SHA-256 hash algorithm\nES384 | ECDSA using P-384 curve and SHA-384 hash algorithm\nES512 | ECDSA using P-521 curve and SHA-512 hash algorithm\nES256K | ECDSA using secp256k1 curve and SHA-256 hash algorithm\nSM2SM3 | using SM2 curve and SM3 hash algorithm\nEdDSA | EdDSA using Ed25519 curve\nnone | No digital signature or MAC value included\n\n## jws.sign(header, payload, key)\n\nReturn a JSON Web Signature for a header and a payload.\n\nArguments:\n\n* `header`\n* `payload`\n* `key`\n\n`header` must be an object with an `alg` property. `header.alg` must be\none a value found in `jws.ALGORITHMS`. See above for a table of\nsupported algorithms.\n\nIf `payload` will be coerced into a string using `JSON.stringify`.\n\n`key` is a buffer containing either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA, or the json format private key, or a PKey object.\n\nExample\n\n```js\nconst signature = jws.sign(\n  // header\n  { alg: 'HS256' },\n  // payload\n  { id: 12345, name: \"Frank\" },\n  // secret\n  '98DE76B1',\n);\n```\n\n## jws.verify(signature, key, acceptAlgs)\n\nReturns`true` or `false` for whether a signature matches a secret or key.\n\n`signature` is a JWS Signature. `header.alg` must be a value found in `jws.ALGORITHMS`.\nSee above for a table of supported algorithms. `key` is a buffer containing either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA, or the json format public key, or a PKey object.\n\n`acceptAlgs` is a list of what algorithms are accepted.\n\n## jws.decode(signature)\n\nReturns the decoded header, decoded payload, and signature parts of the JWS Signature.\n\nReturns an object with three properties, e.g.\n```js\n{\n  header: { alg: 'HS256' },\n  payload: { id: 12345, name: \"Frank\" }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-jws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibjs%2Ffib-jws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-jws/lists"}