{"id":18282664,"url":"https://github.com/gaku-sei/purescript-node-jwt","last_synced_at":"2025-04-09T05:26:12.787Z","repository":{"id":37652161,"uuid":"274285290","full_name":"gaku-sei/purescript-node-jwt","owner":"gaku-sei","description":"Safe bindings for the Node JWT module","archived":false,"fork":false,"pushed_at":"2022-12-22T17:03:11.000Z","size":54,"stargazers_count":6,"open_issues_count":8,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T23:48:17.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PureScript","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/gaku-sei.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}},"created_at":"2020-06-23T02:02:10.000Z","updated_at":"2022-11-15T09:43:48.000Z","dependencies_parsed_at":"2023-01-30T14:31:13.648Z","dependency_job_id":null,"html_url":"https://github.com/gaku-sei/purescript-node-jwt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaku-sei%2Fpurescript-node-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaku-sei%2Fpurescript-node-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaku-sei%2Fpurescript-node-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaku-sei%2Fpurescript-node-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaku-sei","download_url":"https://codeload.github.com/gaku-sei/purescript-node-jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247983112,"owners_count":21028247,"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-05T13:05:57.956Z","updated_at":"2025-04-09T05:26:12.765Z","avatar_url":"https://github.com/gaku-sei.png","language":"PureScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# purescript-node-jwt\n\nSafe bindings for the Node [JWT](https://github.com/auth0/node-jsonwebtoken) module.\nAllows to sign, decode, and verify tokens.\n\n## Installation\n\n```\nspago install node-jwt\n```\n\n## Example\n\nThis library adheres to the [JWT RFC](https://tools.ietf.org/html/rfc7519), so in the below examples, headers is JOSE Header, and claims is, well, Claims.\n\n### Sign\n\nTo sign a project, you'll need to provide a secret key, some headers, and some claims. The `sign` function will return an [`Aff String`](https://pursuit.purescript.org/packages/purescript-aff/5.1.2/docs/Effect.Aff#t:Aff).\n\n```purs\nsign\n  (Secret \"my-super-secret-key\")\n  defaultHeaders\n  defaultClaims\n```\n\nBy default, some values will be set for you: `alg` will be `HS256`, `typ` equals `JWT`, and the `iat` field will be set to the creation timestamp. You _can_ override any for the above by providing the value explicitely.\n\nYou can also provide an `unregisteredClaims` record, each values of that record must be [encodable](https://pursuit.purescript.org/packages/purescript-foreign-generic/10.0.0/docs/Foreign.Generic.Class#t:Encode):\n\n```purs\nsign\n  (Secret \"my-super-secret-key\")\n  defaultHeaders\n  (defaultClaims { unregisteredClaims = Just { foo: \"bar\" } )\n```\n\n### Decode\n\nIf decode succeeds, it will return a `Token r Unverified` where `r` is the row type of the `unregisteredClaims` record. You can read the headers and claims as follow:\n\n```purs\ndecodedHeaders :: String -\u003e Maybe JOSEHeaders\ndecodedHeaders token = hush $ decode' token \u003c#\u003e _.headers\n\ndecodedClaims :: String -\u003e Maybe (Claims ())\ndecodedClaims token = hush $ decode' token \u003c#\u003e _.claims\n\ndecodedClaims' :: String -\u003e Maybe (Claims ( foo :: String ))\ndecodedClaims' token = hush $ decode token \u003c#\u003e _.claims\n```\n\nNotice that when decoding claims with some explicit unregistered claims, said claims must be of the expected type at runtime.\n\n### Verify\n\nIf verify succeeds, it will return a `Token Verified` you can read the headers and claims this way:\n\n```purs\nverifiedHeaders :: String -\u003e Maybe JOSEHeaders\nverifiedHeaders token = hush $ verify' (Secret \"my-super-secret-key\") token \u003c#\u003e _.headers\n\nverifiedClaims :: String -\u003e Maybe (Claims ())\nverifiedClaims token = hush $ verify' (Secret \"my-super-secret-key\") token \u003c#\u003e _.claims\n\nverifiedClaims' :: String -\u003e Maybe (Claims ( foo :: String ))\nverifiedClaims' token = hush $ verify (Secret \"my-super-secret-key\") token \u003c#\u003e _.claims\n```\n\n## Documentation\n\nModule documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-node-jwt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaku-sei%2Fpurescript-node-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaku-sei%2Fpurescript-node-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaku-sei%2Fpurescript-node-jwt/lists"}