{"id":30683199,"url":"https://github.com/ysdragon/ring-jwt","last_synced_at":"2026-02-18T18:01:11.959Z","repository":{"id":310881357,"uuid":"1041613357","full_name":"ysdragon/ring-jwt","owner":"ysdragon","description":"JWT library for the Ring programming language","archived":false,"fork":false,"pushed_at":"2025-08-28T07:51:49.000Z","size":56,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-10T09:46:44.435Z","etag":null,"topics":["jwt","ring-programming-language"],"latest_commit_sha":null,"homepage":"","language":"Ring","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/ysdragon.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":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-20T18:43:55.000Z","updated_at":"2025-08-28T07:51:53.000Z","dependencies_parsed_at":"2025-08-20T20:51:58.965Z","dependency_job_id":"06d746f3-7054-4584-bd99-f1d6a82138fd","html_url":"https://github.com/ysdragon/ring-jwt","commit_stats":null,"previous_names":["ysdragon/ring-jwt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ysdragon/ring-jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysdragon%2Fring-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysdragon%2Fring-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysdragon%2Fring-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysdragon%2Fring-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ysdragon","download_url":"https://codeload.github.com/ysdragon/ring-jwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysdragon%2Fring-jwt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29588776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T16:55:40.614Z","status":"ssl_error","status_checked_at":"2026-02-18T16:55:37.558Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["jwt","ring-programming-language"],"created_at":"2025-09-01T19:08:28.509Z","updated_at":"2026-02-18T18:01:11.952Z","avatar_url":"https://github.com/ysdragon.png","language":"Ring","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ring JWT\n\n[license]: https://img.shields.io/github/license/ysdragon/ring-jwt?style=for-the-badge\u0026logo=opensourcehardware\u0026label=License\u0026logoColor=C0CAF5\u0026labelColor=414868\u0026color=8c73cc\n[![][license]](https://github.com/ysdragon/ring-jwt/blob/main/LICENSE)\n\n[ring]: https://img.shields.io/badge/Made_with_❤️_for-Ring-2D54CB?style=for-the-badge\n[![][ring]](https://ring-lang.net/)\n\n**JWT authentication and authorization library for the Ring programming language.**\n\n## Features\n\n- **JWT Encoding:** Create JSON Web Tokens with a given payload and secret.\n- **JWT Decoding \u0026 Verification:** Decode JWTs and verify their signature and expiration.\n- **Multiple Algorithm Support:** Supports HMAC, RSA PKCS#1 v1.5, and RSA-PSS algorithms.\n- **Flexible Signing:** Choose from 9 different signing algorithms for various security needs.\n\n## Supported Algorithms\n\nRing JWT supports the following JWT signing algorithms:\n\n### HMAC Algorithms (Symmetric)\n- **HS256** - HMAC with SHA-256\n- **HS384** - HMAC with SHA-384\n- **HS512** - HMAC with SHA-512\n\n### RSA Algorithms (Asymmetric - PKCS#1 v1.5)\n- **RS256** - RSA with SHA-256\n- **RS384** - RSA with SHA-384\n- **RS512** - RSA with SHA-512\n\n### RSA-PSS Algorithms (Asymmetric - Probabilistic Signature Scheme)\n- **PS256** - RSA-PSS with SHA-256\n- **PS384** - RSA-PSS with SHA-384\n- **PS512** - RSA-PSS with SHA-512\n\n### Currently Unsupported Algorithms\n\nThe following algorithms are **not yet supported**:\n- **ES256/ES384/ES512** - ECDSA (Elliptic Curve Digital Signature Algorithm)\n- **EdDSA** - Edwards-curve Digital Signature Algorithm\n- **none** - Unsigned tokens (intentionally not supported for security reasons)\n\n## Installation\n\nThis library can be installed using the Ring Package Manager (RingPM).\n\n```bash\nringpm install ring-jwt from ysdragon\n```\n\n## Usage\n\n### Basic JWT Operations (HMAC)\n\nThe core functionality is provided by the `JWT` class. By default, it uses **HS256**.\n\n```ring\nload \"jwt.ring\"\n\noJWT = new JWT\ncSecret = \"your_super_secret_key_here\"\n\n# Example Payload\npayload = [\n    :sub = \"user123\",\n    :iat = unixtime(),\n    :exp = unixtime() + 3600, # Expires in 1 hour\n    :role = \"member\"\n]\n\n# Encode the token\ncToken = oJWT.Encode(payload, cSecret)\n? \"Encoded JWT: \" + cToken\n\n# Decode and verify the token\ntry\n    aDecodedPayload = oJWT.Decode(cToken, cSecret)\n    ? \"Decoded Payload: \" + list2code(aDecodedPayload)\ncatch\n    ? \"Error decoding token: \" + cCatchError\ndone\n```\n\n### Using Different HMAC Algorithms\n\n```ring\nload \"jwt.ring\"\n\n# Use HS384\noJWT = new JWT {\n    algorithm = \"HS384\"\n}\n\ncSecret = \"your_super_secret_key_here\"\npayload = [:sub = \"user123\", :iat = unixtime()]\n\ncToken = oJWT.Encode(payload, cSecret)\naDecodedPayload = oJWT.Decode(cToken, cSecret)\n```\n\n### Using RSA Algorithms (Asymmetric)\n\nRSA algorithms require a private key for signing and a public key for verification.\n\n```ring\nload \"jwt.ring\"\n\n# Use RS256 (RSA with SHA-256)\noJWT = new JWT {\n    algorithm = \"RS256\"\n}\n\n# Read RSA keys\nprivateKey = read(\"private_key.pem\")\npublicKey = read(\"public_key.pem\")\n\npayload = [:sub = \"user123\", :iat = unixtime()]\n\n# Sign with private key\ncToken = oJWT.Encode(payload, privateKey)\n\n# Verify with public key\naDecodedPayload = oJWT.Decode(cToken, publicKey)\n```\n\n### Using RSA-PSS Algorithms\n\nRSA-PSS provides enhanced security with probabilistic padding.\n\n```ring\nload \"jwt.ring\"\n\n# Use PS256 (RSA-PSS with SHA-256)\noJWT = new JWT {\n    algorithm = \"PS256\"\n}\n\nprivateKey = read(\"private_key.pem\")\npublicKey = read(\"public_key.pem\")\n\npayload = [:sub = \"user123\", :iat = unixtime()]\n\ncToken = oJWT.Encode(payload, privateKey)\naDecodedPayload = oJWT.Decode(cToken, publicKey)\n```\n\n### 2. API Reference\n\n#### `JWT` Class\n\nThe `JWT` class provides methods for encoding and decoding JSON Web Tokens.\n\n##### `new JWT()`\n\nCreates a new instance of the `JWT` class.\n\n**Properties:**\n- `algorithm` (String): The signing algorithm to use. Default is `\"HS256\"`. \n  - Supported values: `\"HS256\"`, `\"HS384\"`, `\"HS512\"`, `\"RS256\"`, `\"RS384\"`, `\"RS512\"`, `\"PS256\"`, `\"PS384\"`, `\"PS512\"`\n\n**Example:**\n```ring\n# Create JWT with default algorithm (HS256)\noJWT = new JWT\n\n# Create JWT with specific algorithm\noJWT = new JWT {\n    algorithm = \"RS256\"\n}\n```\n\n##### `Encode(payload, secret)`\n\nEncodes a given payload into a JWT string.\n\n**Parameters:**\n- `payload` (List): The data to be encoded into the JWT. This should be a Ring list.\n- `secret` (String): The secret key or private key used for signing the JWT.\n  - For HMAC algorithms (HS256/HS384/HS512): Use a shared secret string\n  - For RSA algorithms (RS*/PS*): Use a PEM-formatted private key string\n\n**Returns:** (String) The encoded JWT string.\n\n**Example:**\n```ring\n# HMAC\npayload = [:sub = \"user123\", :iat = unixtime()]\ntoken = oJWT.Encode(payload, \"my-secret-key\")\n\n# RSA\nprivateKey = read(\"private_key.pem\")\ntoken = oJWT.Encode(payload, privateKey)\n```\n\n##### `Decode(token, secret)`\n\nDecodes a JWT string, verifies its signature, and returns the payload.\n\n**Parameters:**\n- `token` (String): The JWT string to decode.\n- `secret` (String): The secret key or public key used for verifying the JWT's signature.\n  - For HMAC algorithms (HS256/HS384/HS512): Use the same shared secret string used for encoding\n  - For RSA algorithms (RS*/PS*): Use a PEM-formatted public key string\n\n**Returns:** (List) The decoded payload as a Ring list.\n\n**Raises/Throws:**\n- `Invalid token format` if the token does not have three parts.\n- `Token has expired` if the `exp` claim in the payload indicates the token is expired.\n- `Invalid signature` if the token's signature is invalid.\n\n**Example:**\n```ring\n# HMAC\ndecoded = oJWT.Decode(token, \"my-secret-key\")\n\n# RSA\npublicKey = read(\"public_key.pem\")\ndecoded = oJWT.Decode(token, publicKey)\n```\n\n\n## Examples\n\nYou can find various usage examples in the [`examples`](examples).\n\n## Contributing\n\nContributions are welcome! Please feel free to open issues or submit pull requests.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysdragon%2Fring-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fysdragon%2Fring-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysdragon%2Fring-jwt/lists"}