-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
83 lines (70 loc) · 1.82 KB
/
index.d.ts
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
73
74
75
76
77
78
79
80
81
82
83
import 'egg';
import { Context } from 'egg';
export type oauthPageConfig = {
title: string,
logo: string,
slogan: string,
}
export interface PassportDingtalkConfig {
key: string,
secret: string,
callbackURL: string,
loginURL: string,
passReqToCallback: boolean,
customLoginURL?: string,
oauthPageConfig?: oauthPageConfig,
}
export type AuthenticateReq = {
url: string,
ctx: Context,
query: {
code: string,
},
}
export type DingtalkResponse = {
nick: string,
unionid: string,
dingId: string,
openid: string,
}
export type PassportDingtalkResponseUser = {
provider: string,
id: string,
name: string,
raw: DingtalkResponse,
}
export type DingTalkVerifyType = (
req: AuthenticateReq,
user: PassportDingtalkResponseUser,
done: (err: Error | null | undefined, user: PassportDingtalkResponseUser) => void,
) => void;
export interface DingtalkVerify {
verifyDingtalk: DingTalkVerifyType,
}
export type errorCb = (err: Error) => void;
export type successCb = (user: PassportDingtalkResponseUser) => void;
export interface PassportStrategy {
authenticate: (req: AuthenticateReq, options: PassportDingtalkConfig) => void,
}
export interface Passport extends PassportStrategy {
fail: errorCb,
success: successCb,
mount: (type: string, options: PassportDingtalkConfig) => void,
verify: (verifyUser: (ctx: Context, user: PassportDingtalkResponseUser) => Promise<any>) => any,
doVerify: DingTalkVerifyType,
use: (type: string, strategy: PassportStrategy) => void,
}
declare module 'egg' {
interface Application {
passport: Passport,
}
interface EggAppConfig {
passportDingtalk: PassportDingtalkConfig,
}
interface Context {
user: any,
login: (user: any, options: any) => Promise<any>,
logout: (...args: any[]) => void,
isAuthenticated: () => boolean,
}
}