jwt

A JSON Web Token library for native Haxe.
https://github.com/FuzzyWuzzie/haxe-jwt

To install, run:

haxelib install jwt 1.3.0 

See using Haxelib in Haxelib documentation for more information.

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
Contributors
FuzzyWuzzie
Version
1.3.0
Published
8 months ago
License
Apache

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github