From 64515f0db6fdc8080a5962601c1e7b7f583df778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Nguyen?= Date: Sun, 5 Feb 2017 08:11:04 +0100 Subject: [PATCH] Adding type definitions for cookie-signature --- cookie-signature/cookie-signature-tests.ts | 7 +++++++ cookie-signature/index.d.ts | 21 +++++++++++++++++++++ cookie-signature/tsconfig.json | 22 ++++++++++++++++++++++ cookie-signature/tslint.json | 1 + 4 files changed, 51 insertions(+) create mode 100644 cookie-signature/cookie-signature-tests.ts create mode 100644 cookie-signature/index.d.ts create mode 100644 cookie-signature/tsconfig.json create mode 100644 cookie-signature/tslint.json diff --git a/cookie-signature/cookie-signature-tests.ts b/cookie-signature/cookie-signature-tests.ts new file mode 100644 index 0000000000..f76d6dcb59 --- /dev/null +++ b/cookie-signature/cookie-signature-tests.ts @@ -0,0 +1,7 @@ +import * as cookie from "cookie-signature"; + +let val = cookie.sign('hello', 'tobiiscool'); + +val = cookie.sign('hello', 'tobiiscool'); +cookie.unsign(val, 'tobiiscool'); +cookie.unsign(val, 'luna'); diff --git a/cookie-signature/index.d.ts b/cookie-signature/index.d.ts new file mode 100644 index 0000000000..b9b29911a6 --- /dev/null +++ b/cookie-signature/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for cookie-signature 1.0 +// Project: https://github.com/tj/node-cookie-signature +// Definitions by: François Nguyen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Sign the given `val` with `secret`. + * @param {string} val + * @param {string} secret + * @return {string} + */ +export function sign(value: string, secret: string): string; + +/** + * Unsign and decode the given `val` with `secret`, + * returning `false` if the signature is invalid. + * @param {string} val + * @param {string} secret + * @return {string|boolean} + */ +export function unsign(value: string, secret: string): string | boolean; diff --git a/cookie-signature/tsconfig.json b/cookie-signature/tsconfig.json new file mode 100644 index 0000000000..57344e816a --- /dev/null +++ b/cookie-signature/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cookie-signature-tests.ts" + ] +} diff --git a/cookie-signature/tslint.json b/cookie-signature/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/cookie-signature/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }