diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..3a5d219 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,28 @@ +declare module 'discord-auth' { + export default class Strategy { + /** + * `Strategy` constructor. + * + * The Discord authentication strategy authenticates requests by delegating to + * Discord via the OAuth2.0 protocol + * + * Applications must supply a `verify` callback which accepts an `accessToken`, + * `refreshToken` and service-specific `profile`, and then calls the `cb` + * callback supplying a `user`, which should be set to `false` if the + * credentials are not valid. If an exception occured, `err` should be set. + * + * Options: + * - `clientID` OAuth ID to discord + * - `clientSecret` OAuth Secret to verify client to discord + * - `callbackURL` URL that discord will redirect to after auth + * - `scope` Array of permission scopes to request + * Check the official documentation for valid scopes to pass as an array. + */ + constructor(options: { + clientID: string, + clientSecret: string, + callbackURL: string, + scope?: string | string[]; + }, verify: (accessToken: string, refreshToken: string, profile: string, cb: (err: Error, user?: object) => void) => void) + } +} diff --git a/package.json b/package.json index 394d27b..0fa5ad1 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,31 @@ { - "name": "discord-auth", - "version": "1.0.0", - "description": "Simple Discord OAuth client for making dashboard and website linked with discord.", - "main": "lib/index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/IamTheRealSami/discord-auth.git" - }, - "keywords": [ - "passport", - "discord", - "auth", - "authentication", - "authn", - "identity", - "discord-auth", - "discord-oauth", - "discordapp" - ], - "author": "IamTheRealSami", - "license": "ISC", - "bugs": { - "url": "https://github.com/IamTheRealSami/discord-auth/issues" - }, - "homepage": "https://github.com/IamTheRealSami/discord-auth#readme", - "dependencies": { - "passport-oauth2": "^1.5.0" - } - } \ No newline at end of file + "name": "discord-auth", + "version": "1.0.0", + "description": "Simple Discord OAuth client for making dashboard and website linked with discord.", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/IamTheRealSami/discord-auth.git" + }, + "keywords": [ + "passport", + "discord", + "auth", + "authentication", + "authn", + "identity", + "discord-auth", + "discord-oauth", + "discordapp" + ], + "author": "IamTheRealSami", + "license": "ISC", + "bugs": { + "url": "https://github.com/IamTheRealSami/discord-auth/issues" + }, + "homepage": "https://github.com/IamTheRealSami/discord-auth#readme", + "dependencies": { + "passport-oauth2": "^1.5.0" + } +}