Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 1.78 KB

README.md

File metadata and controls

75 lines (50 loc) · 1.78 KB

haxe-jwt

GitHub license

A JSON Web Token library for native Haxe.

API docs are available here: https://fuzzywuzzie.github.io/haxe-jwt/.

Features

  • 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

Usage

The library exposes two main functionalities: signing tokens and verifying tokens.

Signing Tokens

import jwt.JWT;

// ...

var token:String = JWT.sign({ adm: true }, "my super secret secret");

Verifying Tokens

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!';
}

Change Log

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.

1.1.0

Added

  • A replacer parameter to JWT.sign, allowing custom replacers for JSON encoding (through haxe.Json.encode).

Fixed

  • Actually fixed haxelib.json classpath 😅

1.0.1

Changed

  • Attempted to fix haxelib.json classpath so library can actually be used.

1.0.0

Added

  • HMACSHA256 token generation & signing
  • HMACSHA256 token verification & decoding