diff --git a/types/ghauth/ghauth-tests.ts b/types/ghauth/ghauth-tests.ts new file mode 100644 index 0000000000..56bc0cd1b0 --- /dev/null +++ b/types/ghauth/ghauth-tests.ts @@ -0,0 +1,29 @@ +/// +import ghauth = require("ghauth"); +import { AuthOptions, TokenData } from "ghauth"; + +// Full +const authOptions1: AuthOptions = { + configName: "awesome", + noSave: true, + authUrl: "https://api.github.com/authorizations", + promptName: "GitHub", + scopes: ["user"], + note: "This token is for my awesome app", + userAgent: "My Awesome App", +}; + +ghauth(authOptions1, (err: Error, authData: TokenData) => { + authData.user; + authData.token; +}); + +// Required +const authOptions2: AuthOptions = { + configName: "awesome", +}; + +ghauth(authOptions2, (err: Error, authData: TokenData) => { + authData.user; + authData.token; +}); diff --git a/types/ghauth/index.d.ts b/types/ghauth/index.d.ts new file mode 100644 index 0000000000..3d91ab8ef5 --- /dev/null +++ b/types/ghauth/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for ghauth 3.2 +// Project: https://github.com/rvagg/ghauth +// Definitions by: Leko +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function ghauth(authOptions: ghauth.AuthOptions, callback: (err: Error, tokenData: ghauth.TokenData) => void): void; + +declare namespace ghauth { + interface AuthOptions { + configName: string; + + /** + * @default false + */ + noSave?: boolean; + + /** + * @default "https://api.github.com/authorizations" + */ + authUrl?: string; + + /** + * @default "GitHub" + */ + promptName?: string; + + /** + * @default [] + */ + scopes?: ReadonlyArray; + + /** + * @default "Node.js command-line app with ghauth" + */ + note?: string; + + /** + * @default "Magic Node.js application that does magic things with ghauth" + */ + userAgent?: string; + } + + interface TokenData { + user: string; + token: string; + } +} + +export = ghauth; diff --git a/types/ghauth/tsconfig.json b/types/ghauth/tsconfig.json new file mode 100644 index 0000000000..0b946b4ae8 --- /dev/null +++ b/types/ghauth/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ghauth-tests.ts" + ] +} diff --git a/types/ghauth/tslint.json b/types/ghauth/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ghauth/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }