Add types for auth-header (#29779)

* Add types for auth-header

* Address Feedback
This commit is contained in:
Forbes Lindesay
2018-10-18 08:37:35 -07:00
committed by Sheetal Nandi
parent da78ffb13c
commit f46aa0bfb1
4 changed files with 57 additions and 0 deletions
+6
View File
@@ -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('');
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for auth-header 1.0
// Project: https://github.com/izaakschroeder/auth-header
// Definitions by: ForbesLindesay <https://github.com/ForbesLindesay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
type Params =
| Array<[string, string | ReadonlyArray<string>]>
| {[key: string]: string | ReadonlyArray<string>};
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;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }