{"id":15838735,"url":"https://github.com/gamemaker1/jwt","last_synced_at":"2026-01-31T04:01:46.871Z","repository":{"id":115225928,"uuid":"357910680","full_name":"gamemaker1/jwt","owner":"gamemaker1","description":"An implementations of JWT (JSON Web Token) in V","archived":false,"fork":false,"pushed_at":"2021-04-17T03:37:11.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T07:53:57.810Z","etag":null,"topics":["json-web-token","jwt","v","vlang"],"latest_commit_sha":null,"homepage":"","language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gamemaker1.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2021-04-14T13:13:38.000Z","updated_at":"2021-11-14T17:20:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae6f3ff8-18b6-4336-abc9-fd182fc5d0a4","html_url":"https://github.com/gamemaker1/jwt","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"39169a25b3d8f71fd9bb11df7909602bffe88e43"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gamemaker1/jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamemaker1","download_url":"https://codeload.github.com/gamemaker1/jwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fjwt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28928641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T02:59:34.861Z","status":"ssl_error","status_checked_at":"2026-01-31T02:59:05.369Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["json-web-token","jwt","v","vlang"],"created_at":"2024-10-05T16:01:39.772Z","updated_at":"2026-01-31T04:01:46.858Z","avatar_url":"https://github.com/gamemaker1.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://jwt.io/img/logo-asset.svg\" /\u003e\n\u003c/p\u003e\n\n## JSON Web Token Implementation\n\nThis is a barebones implementation of [JWT (JSON Web Token)](https://jwt.io) in V (or vlang, for search engine friendliness). It currently supports only the HMAC-SHA algorithm, support for other algorithms (like RSA and ED25519) is a work in progress. Please feel free to open a issue/pull request if you find any problem or want to add a feature. Take a look at the todos.md file if you just want to contribute, but don't know what to help with.\n\n## Installation\n\nTo install JWT, just type in the following (uploading to vpm, vpkg is in progress):\n\n```\ngit clone https://github.com/gamemaker1/jwt ~/.vmodules/gamemaker1/jwt/\n```\n\nOn Windows (command prompt), replace the `~` above with `%USERPROFILE%`.\n\n## Usage\n\nFirst import the library:\n\n```v\nimport gamemaker1.jwt\n```\n\nThen create a header object and specify the algorithm you want to use (default is HMAC with SHA384):\n\n```v\n// Create headers with the default algorithm (HMAC with SHA384). Possible\n// values include .hs224 (HMAC with SHA224), .hs256 (HMAC with SHA256), .hs384\n// (HMAC with SHA384) and .hs512 (HMAC with SHA512)\nmut headers := jwt.headers(.default)\n```\n\nThen declare a struct that contains all the claims you want to put in the token:\n\n```v\n// A struct declaring custom claims to be encoded in the JWT (these are\n// all example values, replace them with your own. You might want to look\n// at https://en.wikipedia.org/wiki/JSON_Web_Token#Standard_fields for a\n// list of standard fields used in a JWT)\nstruct CustomClaims {\n\t// The user name\n\tuser_name string\n\t// The user ID\n\tuser_id string\n\t// The `iat`, or Issued At Time as an epoch timestamp\n\tiat u64\n\t// The `exp` or Expires At Time (Here we set it to expire after one \n\t// hour) as an epoch timestamp\n\texp u64\n}\n```\n\nCreate an instance of the struct with the values you want to put in:\n\n```v\n// The current time (this requires the `time` module to be imported,\n// i.e., add `import time` at the top where you import the `jwt` module)\ncurrent_time := time.utc()\n// Create the claims to put in the JWT\nclaims := CustomClaims {\n\t// The user name\n\t'exampleusername',\n\t// The user ID\n\t'sISDkdmeIEpwS9W',\n\t// The `iat`, or Issued At Time as an epoch timestamp\n\tcurrent_time.unix,\n\t// The `exp` or Expires At Time (Here we set it to expire after one \n\t// hour) as an epoch timestamp\n\tcurrent_time.add_seconds(3600).unix\n}\n```\n\nThen define the secret used to sign the token's headers and claims. If you are using HMAC, you can use a secret_key with sufficient entropy according to the algorithm you use. If you are using RSA, use a private key:\n\n```v\n// The secret key used to sign the algorithm (for HMAC). In case you are \n// using RSA, use the private key here instead. It is recommended to read\n// this secret from a file. The secret should be known only to the entity\n// issuing the JWTs, i.e., an auth server\nsecret_key := 'YOUR_SUPER_SECRET_KEY'\n```\n\nNow create the JWT (remember to specify the struct name in \u003c\u003e while calling `create()`):\n```v\n// Generate a token. Add the type of custom claim in \u003c\u003e as well to allow json \n// serialization.\ntoken := jwt.create\u003cCustomClaims\u003e(headers, claims, secret_key) or {\n\t// Handle errors in the `or` block. To let the program panic on an error, \n\t// or to return the error to the calling function, replace this entire `or` \n\t// block with a `?`\n\tprintln('An error occurred - $err')\n\treturn\n}\n```\n\nTo decode and verify the signature of the token, use the `decode()` method - it will return the headers and the claims of the token if the signature is valid:\n\n```v\n// Verify the signature of the generated token and decode it.\nretrieved_headers, retrieved_claims := jwt.decode\u003cCustomClaims\u003e(\n\t// The JWT\n\ttoken,\n\t// The algorithm that was used to generate the JWT\n\t.default,\n\t// The secret key (in case of HMAC) or private key (in case of RSA) used to \n\t// sign the JWT\n\tsecret_key\n) or {\n\t// Handle errors in the `or` block. To let the program panic on an error, \n\t// or to return the error to the calling function, replace this entire `or` \n\t// block with a `?`\n\tprintln('An error occurred - $err')\n\treturn\n}\n```\n\n## Example\n\nFor an example program that uses `jwt`, take a look at [`jwt_example.v`](./examples/jwt_example.v).\n\n## Todos\n\nRefer to [the todos file](./todos.md).\n\n## Legal stuff\n\n### License: ISC\n\nCopyright (c) 2021, Vedant K (gamemaker1) \\\u003cgamemaker0042@gmail.com\\\u003e\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemaker1%2Fjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamemaker1%2Fjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemaker1%2Fjwt/lists"}