jwt-simple definition file

This commit is contained in:
Ken Fukuyama
2014-12-11 23:40:29 +09:00
parent 1fb0d8c3e3
commit 84716eb575
2 changed files with 38 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
/// <reference path='jwt-simple.d.ts' />
import jwt = require('jwt-simple');
var payload = { foo: 'bar' };
var secret:string = 'xxx';
// encode
var token = jwt.encode(payload, secret);
// decode
var decoded = jwt.decode(token, secret);
console.log(decoded); //=> { foo: 'bar' }
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for jwt-simple v0.2.0
// Project: https://github.com/hokaccha/node-jwt-simple
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "jwt-simple" {
module jwtSimple {
/**
* Decode jwt
* @param token
* @param key
* @param noVerify
* @api public
*/
export function decode(token:any, key:string, noVerify?:boolean):any;
/**
* Encode jwt
* @param payload
* @param key
* @param algorithm default is HS256
* @api public
*/
export function encode(payload:any, key:string, algorithm?:string):string;
}
export = jwtSimple;
}