A JSON Web Token library for native Haxe.
- Signing (generating) tokens
- Limited to HS256 algorithm for now
- Verifying (& decoding) tokens
- Limited to HS256 algorithm for now
- Does not check any public claims (exp, iss, sub, etc) yet
The library exposes two main functionalities: signing tokens and verifying tokens.
import jwt.JWT;
// ...
var token:String = JWT.sign({ adm: true }, "my super secret secret");
import jwt.JWT;
typedef TPayload = {
> jwt.JWTPayloadBase,
var adm:Bool;
}
// ...
var result:JWTResult<TPayload> = JWT.verify(token, "my super secret secret");
switch(result) {
case Valid(payload): {
trace(payload);
}
case Invalid: throw 'The token was invalid, you dummy!';
}
import jwt.JWT;
// ...
typedef HeaderStruct = {};
typedef PayloadStruct = {};
var header:HeaderStruct = JWT.extract(token, JWTPart.Header);
var payload:PayloadStruct = JWT.extract(token, JWTPart.Payload);
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- A
replacer
parameter toJWT.sign
, allowing custom replacers for JSON encoding (throughhaxe.Json.encode
).
- Actually fixed
haxelib.json
classpath
😅
- Attempted to fix
haxelib.json
classpath
so library can actually be used.
- HMACSHA256 token generation & signing
- HMACSHA256 token verification & decoding