jwt 1.3.0

A JSON Web Token library for native Haxe.

Released 2017-09-20.

To install, run:

haxelib install jwt 1.3.0

See using Haxelib in Haxelib documentation for more information.

MaintainerFuzzyWuzzie
Websitehttps://github.com/FuzzyWuzzie/haxe-jwt
Current version1.3.0
StatisticsInstalled 24 times
LicenseApache
Tags cross, utility, web

README.md

haxe-jwt

GitHub license

A JSON Web Token library for native Haxe.

API docs are available here: [https://fuzzywuzzie.github.io/haxe-jwt/](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 :sweat_smile:

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