jsonwebtoken 2.0.2

JsonWebToken for Haxe

Released 2017-05-23.

To install, run:

haxelib install jsonwebtoken 2.0.2

See using Haxelib in Haxelib documentation for more information.

Maintainerkevinresol
Websitehttps://github.com/kevinresol/jsonwebtoken
Current version2.0.2
StatisticsInstalled 129 times
LicenseMIT
Tags cross, jsonwebtoken

README.md

jsonwebtoken Build Status

Use JsonWebToken in Haxe

Supported Algorithms
TargetHS256HS384HS512RS256RS384RS512Remarks
all sys targetsUsing openssl cli
NodeUsing Node std lib
PHPUsing PHP std lib
JavaUsing Java std lib
C#Using C# std lib
PythonUsing Python std lib
InterpUsing Haxe std lib
NekoUsing Haxe std lib
JSUsing Haxe std lib
C++Using Haxe std lib
Supported Verifications
  • Issuer
  • Audience
  • Expiry

Install

haxelib install jsonwebtoken

Usage

Signing

var crypto = new NodeCrypto(); // pick a crypto from the jsonwebtoken.crypto package
var signer = new BasicSigner(HS256('secret'), crypto);
var payload:Claims = {iss: 'issuer'}
signer.sign(payload).handle(function(o) switch o {
	case Success(token): trace(token);
	case Failure(e)): trace('Failed to sign: $e');
});

Verifying

var crypto = new NodeCrypto(); // pick a crypto from the jsonwebtoken.crypto package
var verifier = new BasicVerifier(HS256('secret'), crypto, {iss: 'issuer'});
var token = ...;
verifier.verify(token).handle(function(o) switch o {
	case Success(_): trace('verified');
	case Failure(e)): trace('Invalid token: $e');
});