Merge pull request #31115 from Leko/add-ghauth

Add type definitions for ghauth 3.2
This commit is contained in:
Andrew Casey
2018-12-07 10:07:50 -08:00
committed by GitHub
4 changed files with 102 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
/// <reference types="node" />
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;
});
+49
View File
@@ -0,0 +1,49 @@
// Type definitions for ghauth 3.2
// Project: https://github.com/rvagg/ghauth
// Definitions by: Leko <https://github.com/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<string>;
/**
* @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;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }