From f46aa0bfb1e3e68e8a3420a60c3a45ebba22d509 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Thu, 18 Oct 2018 16:37:35 +0100 Subject: [PATCH] Add types for auth-header (#29779) * Add types for auth-header * Address Feedback --- types/auth-header/auth-header-tests.ts | 6 ++++++ types/auth-header/index.d.ts | 27 ++++++++++++++++++++++++++ types/auth-header/tsconfig.json | 23 ++++++++++++++++++++++ types/auth-header/tslint.json | 1 + 4 files changed, 57 insertions(+) create mode 100644 types/auth-header/auth-header-tests.ts create mode 100644 types/auth-header/index.d.ts create mode 100644 types/auth-header/tsconfig.json create mode 100644 types/auth-header/tslint.json diff --git a/types/auth-header/auth-header-tests.ts b/types/auth-header/auth-header-tests.ts new file mode 100644 index 0000000000..e8b510531c --- /dev/null +++ b/types/auth-header/auth-header-tests.ts @@ -0,0 +1,6 @@ +import * as auth from 'auth-header'; + +const basic: string = auth.format('Basic'); +const basic2: string = auth.format({scheme: 'Basic'}); + +const parsed: {scheme: string, token: null | string | string[]} = auth.parse(''); diff --git a/types/auth-header/index.d.ts b/types/auth-header/index.d.ts new file mode 100644 index 0000000000..fab462be9e --- /dev/null +++ b/types/auth-header/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for auth-header 1.0 +// Project: https://github.com/izaakschroeder/auth-header +// Definitions by: ForbesLindesay +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +type Params = + | Array<[string, string | ReadonlyArray]> + | {[key: string]: string | ReadonlyArray}; +export {Params}; + +export interface TokenOptions { + scheme: string; + token?: string; + params?: Params; +} + +export interface Token { + scheme: string; + params: {[key: string]: string | string[]}; + token: null | string | string[]; +} + +export function format(token: TokenOptions): string; +export function format(scheme: string, token?: string, params?: Params): string; + +export function parse(header: string): Token; diff --git a/types/auth-header/tsconfig.json b/types/auth-header/tsconfig.json new file mode 100644 index 0000000000..58c6fad6d7 --- /dev/null +++ b/types/auth-header/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "auth-header-tests.ts" + ] +} diff --git a/types/auth-header/tslint.json b/types/auth-header/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/auth-header/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }