jwt
JSON Web Token (JWT) signing and validation. Create HS256-signed tokens, verify signatures, decode claims and check expiry.
Install
ppm install jwt
Usage Example
uses jwt;
// Sign a token
var claims: TJWTClaims;
claims.Sub := 'user_123';
claims.Iss := 'myapp';
claims.Exp := UnixTime(Now) + 3600;
var token := Sign(claims, 'my-secret-key');
// Verify and decode
if Verify(token, 'my-secret-key') then
begin
var decoded := Decode(token);
WriteLn('User: ' + decoded.Sub);
if IsExpired(decoded) then
WriteLn('Token expired!');
end;
Features
HS256 HMAC-SHA256 signing
Signature verification
Claims decoding (sub, iss, exp, iat)
Expiry checking with IsExpired()
Custom claims via dictionary