{"id":24752572,"url":"https://github.com/inoles/kotjwt","last_synced_at":"2025-03-23T04:26:37.748Z","repository":{"id":271973858,"uuid":"915150328","full_name":"iNoles/KotJWT","owner":"iNoles","description":"Kotlin Multiplatform library for generating and verifying JWTs ","archived":false,"fork":false,"pushed_at":"2025-03-04T23:42:57.000Z","size":188,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T00:27:38.182Z","etag":null,"topics":["api","authentication","cyrptography","jwt","jwt-authentication","jwt-library","jwt-token","kotlin","kotlin-library","kotlin-multiplatform","security","token"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/iNoles.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}},"created_at":"2025-01-11T05:13:27.000Z","updated_at":"2025-03-04T23:42:55.000Z","dependencies_parsed_at":"2025-01-11T06:20:03.066Z","dependency_job_id":"60249526-36fd-47d2-9dcb-b85bdd8ea40b","html_url":"https://github.com/iNoles/KotJWT","commit_stats":null,"previous_names":["inoles/kotjwt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iNoles%2FKotJWT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iNoles%2FKotJWT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iNoles%2FKotJWT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iNoles%2FKotJWT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iNoles","download_url":"https://codeload.github.com/iNoles/KotJWT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245055447,"owners_count":20553682,"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":["api","authentication","cyrptography","jwt","jwt-authentication","jwt-library","jwt-token","kotlin","kotlin-library","kotlin-multiplatform","security","token"],"created_at":"2025-01-28T10:50:24.169Z","updated_at":"2025-03-23T04:26:37.726Z","avatar_url":"https://github.com/iNoles.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KotJWT\n\nKotJWT is a lightweight Kotlin Multiplatform library designed for encoding, decoding, and managing JSON Web Tokens (JWT) and refresh tokens. It supports a variety of cryptographic algorithms, including HMAC SHA-256, ECDSA, and RSA, while providing essential features like token expiration validation, blacklist management, and secure token handling.\n\n## ✨ Features\n\n- **JWT Support** – Encode and decode JWTs with HMAC SHA-256, ECDSA, and RSA signing.\n- **Refresh Token Support** – Securely generate and validate refresh tokens.\n- **Expiration Handling** – Automatically checks if a token is expired.\n- **Token Blacklist** – Prevent the use of revoked tokens.\n- **base64 URL-Safe Encoding** – Secure encoding and decoding for JWTs and refresh tokens.\n- **Multiple Signing Algorithms** – Supports HMAC, ECDSA, and RSA for signing JWTs.\n- **Kotlin Multiplatform Support** – Now available for JVM, iOS, macOS, and other platforms.\n\n## 🚀 Usage\n\n### Encoding a JWT\n\nTo encode a JWT, you need to create a `JwtPayload` and use the `encodeJwt` function:\n\n```kotlin\nimport com.jonathansteele.kojwt.*\n\nval payload = JwtPayload(\n    sub = \"user123\",\n    exp = System.currentTimeMillis() / 1000 + 3600  // Expire in 1 hour\n)\nval secret = \"your-secret-key\"\n\nval jwt = encodeJwt(payload, secret)\nprintln(\"Encoded JWT: $jwt\")\n```\n\n### Decoding a JWT\n\nTo decode a JWT, use the `decodeJwt` function:\n\n```kotlin\nval decodedPayload = decodeJwt(jwt, secret)\nprintln(\"Decoded Payload: $decodedPayload\")\n```\n\n### Encoding a Refresh Token\n\nYou can encode a refresh token using the `encodeRefreshToken` function:\n\n```kotlin\nval refreshTokenPayload = RefreshTokenPayload(\n    sub = \"user123\",\n    exp = System.currentTimeMillis() / 1000 + 86400  // Expire in 24 hours\n)\nval refreshToken = encodeRefreshToken(refreshTokenPayload, secret)\nprintln(\"Encoded Refresh Token: $refreshToken\")\n```\n\n### Decoding a Refresh Token\n\nTo decode a refresh token, use the decodeRefreshToken function:\n\n```kotlin\nval decodedRefreshToken = decodeRefreshToken(refreshToken, secret)\nprintln(\"Decoded Refresh Token: $decodedRefreshToken\")\n```\n\n### Blacklisting Tokens\n\nYou can add tokens to the blacklist to prevent further use:\n\n```kotlin\nTokenBlacklist.revoke(jwt)\nTokenBlacklist.revoke(refreshToken)\n```\n\n## 🛣 Roadmap\n\n- Kotlin Multiplatform support for additional targets\n\n## Contributions 🤝\n\nThis project is a work in progress, and contributions are welcome! Feel free to:\n\n- Submit issues for bugs or feature suggestions\n- Open pull requests to contribute directly\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finoles%2Fkotjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finoles%2Fkotjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finoles%2Fkotjwt/lists"}