This repository was archived by the owner on Dec 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathauthentication-service.d.ts
101 lines (88 loc) · 2.71 KB
/
authentication-service.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
interface IAuthenticationService {
/**
* Uses username and password for login and after successful login saves the user information.
* @param {string} username The username of the user.
* @param {string} password The password of the user.
* @returns {Promise<IUser>} Returns the user information after successful login.
*/
devLogin(username: string, password: string, instanceId?: string): Promise<IUser>;
/**
* Opens login page and after successful login saves the user information.
* If options.openAction is provided, it will be used to open the login url instead of the default opener.
* @param {ILoginOptions} options Optional settings for the login method.
* @returns {Promise<IUser>} Returns the user information after successful login.
*/
login(options?: ILoginOptions): Promise<IUser>;
/**
* Invalidates the current user authentication data.
* If options.openAction is provided, it will be used to open the logout url instead of the default opener.
* @param {IOpenActionOptions} options Optional settings for the logout method.
* @returns {void}
*/
logout(options?: IOpenActionOptions): void;
/**
* Uses the refresh token of the current user to issue new access token.
*/
refreshCurrentUserToken(): Promise<void>;
/**
* Checks if there is user info and the access token of the current user is valid. The method will try to issue new access token if the current is not valid.
* @returns {Promise<boolean>} Returns true if the user is logged in.
*/
isUserLoggedIn(): Promise<boolean>;
/**
* Stops the current login process and rejects the login promise with an error.
* @returns {void}
*/
cancelLogin(): void;
}
interface IOpenActionOptions {
/**
* Action which will receive url and decide how to open it.
*/
openAction?: (url: string) => void;
}
interface ILoginOptions extends IOpenActionOptions {
/**
* Sets the ammount of time which the login method will wait for login response in non-interactive terminal.
*/
timeout?: string;
}
interface IUserData extends ITokenData {
refreshToken: string;
userInfo: IUser;
instanceId?: string;
}
interface ITokenData {
accessToken: string;
}
interface IUser {
email: string;
firstName: string;
lastName: string;
}
interface IUserInfo {
avatar_type: number;
blogWebPageUrl: string;
companySize: number;
country: number;
developers: number;
externalAvatarUrl: string;
gravatar: string;
industry: number;
interests: string;
isProfilePublic: boolean;
twitterName: String;
}
interface IKinveyUserData {
email: string;
firstName: string;
lastName: string
instanceId: string
token: string;
lastLoginTime?: Date;
name?: string;
twoFactorAuth?: IKinveyTwoFactorAuth
}
interface IKinveyTwoFactorAuth {
enabled: boolean;
}