From 84716eb575a63ca6766668602d02d29b5d26353a Mon Sep 17 00:00:00 2001 From: Ken Fukuyama Date: Thu, 11 Dec 2014 23:40:29 +0900 Subject: [PATCH] jwt-simple definition file --- jwt-simple/jwt-simple-tests.ts | 12 ++++++++++++ jwt-simple/jwt-simple.d.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 jwt-simple/jwt-simple-tests.ts create mode 100644 jwt-simple/jwt-simple.d.ts diff --git a/jwt-simple/jwt-simple-tests.ts b/jwt-simple/jwt-simple-tests.ts new file mode 100644 index 000000000..8a0cc59c5 --- /dev/null +++ b/jwt-simple/jwt-simple-tests.ts @@ -0,0 +1,12 @@ +/// + +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' } \ No newline at end of file diff --git a/jwt-simple/jwt-simple.d.ts b/jwt-simple/jwt-simple.d.ts new file mode 100644 index 000000000..74e5d487d --- /dev/null +++ b/jwt-simple/jwt-simple.d.ts @@ -0,0 +1,26 @@ +// Type definitions for jwt-simple v0.2.0 +// Project: https://github.com/hokaccha/node-jwt-simple +// Definitions by: Ken Fukuyama +// 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; +} \ No newline at end of file