-
-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy pathpassport-oauth2.d.ts
More file actions
72 lines (59 loc) · 2.61 KB
/
Copy pathpassport-oauth2.d.ts
File metadata and controls
72 lines (59 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Type definitions for passport-oauth2 1.4
// Project: https://github.com/jaredhanson/passport-oauth2#readme
// Definitions by: Pasi Eronen <https://github.com/pasieronen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Request } from 'express';
import { Strategy } from 'passport';
declare class OAuth2Strategy implements Strategy {
name: string;
constructor(options: OAuth2Strategy.StrategyOptions, verify: OAuth2Strategy.VerifyFunction);
constructor(options: OAuth2Strategy.StrategyOptionsWithRequest, verify: OAuth2Strategy.VerifyFunctionWithRequest);
authenticate(req: Request, options?: any): void;
userProfile(accessToken: string, done: (err?: Error | null, profile?: any) => void): void;
authorizationParams(options: any): object;
tokenParams(options: any): object;
parseErrorResponse(body: any, status: number): Error | null;
}
declare namespace OAuth2Strategy {
type VerifyCallback = (err?: Error | null, user?: object, info?: object) => void;
type VerifyFunction =
((accessToken: string, refreshToken: string, profile: any, verified: VerifyCallback) => void) |
((accessToken: string, refreshToken: string, results: any, profile: any, verified: VerifyCallback) => void);
type VerifyFunctionWithRequest =
((req: Request, accessToken: string, refreshToken: string, profile: any, verified: VerifyCallback) => void) |
((req: Request, accessToken: string, refreshToken: string, results: any, profile: any, verified: VerifyCallback) => void);
interface _StrategyOptionsBase {
authorizationURL: string;
tokenURL: string;
clientID: string;
clientSecret: string;
callbackURL: string;
useExactURLs?: boolean;
}
interface StrategyOptions extends _StrategyOptionsBase {
passReqToCallback?: false;
}
interface StrategyOptionsWithRequest extends _StrategyOptionsBase {
passReqToCallback: true;
}
type Strategy = OAuth2Strategy;
const Strategy: typeof OAuth2Strategy;
class TokenError extends Error {
constructor(message: string | undefined, code: string, uri?: string, status?: number);
code: string;
uri?: string;
status: number;
}
class AuthorizationError extends Error {
constructor(message: string | undefined, code: string, uri?: string, status?: number);
code: string;
uri?: string;
status: number;
}
class InternalOAuthError extends Error {
constructor(message: string, err: any);
oauthError: any;
}
}
export = OAuth2Strategy;