From 84716eb575a63ca6766668602d02d29b5d26353a Mon Sep 17 00:00:00 2001 From: Ken Fukuyama Date: Thu, 11 Dec 2014 23:40:29 +0900 Subject: [PATCH 1/2] 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 0000000000..8a0cc59c52 --- /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 0000000000..74e5d487d8 --- /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 From d1291bfc3aaa4929bad30b881efb61621ba3aa79 Mon Sep 17 00:00:00 2001 From: vvakame Date: Thu, 11 Dec 2014 23:53:13 +0900 Subject: [PATCH 2/2] simplify jwt-simple/jwt-simple.d.ts --- jwt-simple/jwt-simple.d.ts | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/jwt-simple/jwt-simple.d.ts b/jwt-simple/jwt-simple.d.ts index 74e5d487d8..0ee3cc6799 100644 --- a/jwt-simple/jwt-simple.d.ts +++ b/jwt-simple/jwt-simple.d.ts @@ -3,24 +3,20 @@ // 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 + /** + * 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; +}