This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
KJWT is a Kotlin Multiplatform library for creating, signing, encrypting, parsing, and validating JWT (RFC 7519), JWS ( RFC 7515), and JWE (RFC 7516) tokens across JVM, JavaScript, WebAssembly, and Native platforms.
# Build
./gradlew build
# Run all tests (aggregated report)
./gradlew allTests
# Run tests for specific platforms
./gradlew jvmTest
./gradlew jsTest
./gradlew macosArm64Test
./gradlew linuxX64Test
# Run all checks
./gradlew checkTests live in lib/src/commonTest/kotlin/ and run on all platforms.
Jwt.builder()— create and sign/encrypt tokensJwt.parser()— parse and verify tokens
| Package | Purpose |
|---|---|
algorithm/ |
JWS (HMAC, RSA, ECDSA) and JWE algorithm definitions |
builder/ |
JwtBuilder — fluent API for creating tokens |
parser/ |
JwtParser / JwtParserBuilder — parsing, verification, claim validation |
model/ |
Claims, JwtPayload, JwtHeader, JwtInstance (sealed Jws/Jwe) |
cryptography/ |
Key wrapper types for each algorithm |
ext/ |
Extension functions for builder (JwtBuilderExt) and parser (JwtParserExt) |
serializers/ |
kotlinx.serialization adapters (audience, instant, headers) |
internal/ |
Base64URL and JSON utilities |
dsl/ |
DSL helpers for claim blocks |
exception/ |
JwtException hierarchy |
- JVM:
cryptography-provider-jdk - JS/WASM:
cryptography-provider-web - Apple:
cryptography-provider-apple - Linux/MinGW:
cryptography-provider-openssl3
Providers are registered per-platform; all crypto is delegated to the cryptography-kotlin library.
- All signing and encryption operations are
suspendfunctions - Custom payload types must implement
JwtPayloadand be@Serializable - JWE tokens have 5 parts; JWS tokens have 3 parts
alg=none(unsecured tokens) must be explicitly opted into viaallowUnsecured(true)on the parser
- JWS: HS256/384/512, RS256/384/512, PS256/384/512, ES256/384/512
- JWE Key: RSA-OAEP, RSA-OAEP-256, dir
- JWE Content: A128GCM, A192GCM, A256GCM, A128CbcHs256, A192CbcHs384, A256CbcHs512
- Kotlin 2.x with Kotlin Multiplatform
- kotlinx-serialization
- kotlinx-coroutines
- cryptography-kotlin 0.5.0
- For an overview of the API, use the official webpage https://whyoleg.github.io/cryptography-kotlin/api/