forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth0-angular.d.ts
167 lines (138 loc) · 4.94 KB
/
auth0-angular.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Type definitions for auth0-angular
// Project: https://github.com/auth0/auth0-angular
// Definitions by: Matt Emory <https://github.com/homesar>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare namespace auth0.angular {
interface IAuth0ClientOptions {
/**
* Login url if you're using ngRoute
*/
loginUrl?: string;
/**
* Login state if you're using ui-router
*/
loginState?: string;
/**
* Client identifier of your Auth0 application
*/
clientID: string;
/**
* Domain of your Auth0 account
*/
domain: string;
/**
* Use single signon
*/
sso?: boolean;
}
interface ITokenOptions {
targetClientId?: string;
api?: string;
}
interface IAuth0Options {
/**
* Connection name
*/
connection?: string;
/**
* Username
*/
username?: string;
/**
* Email address
*/
email?: string;
}
interface ISuccessCallback {
(profile?: string, idToken?: string, accessToken?: string, state?: string, refreshToken?: string): void;
}
interface IErrorCallback {
(error: any): void;
}
interface IAuth0Service {
/**
* Hooks to internal Angular events so that a user will be redirected to the login page if trying to visit a restricted resource
*/
hookEvents(): void;
/**
* Performs a token delegation request exchanging th ecurrent token for another one.
* @param options Token options
*/
getToken(options?: ITokenOptions): ng.IPromise<any>;
/**
* Refreshes the Id token
* @param refreshToken Refresh token to use when renewing
*/
refreshIdToken(refreshToken: string): ng.IPromise<any>;
/**
* Renews the Id Token with the same scopes as the original token
* @param id_token Id Token
*/
renewIdToken(id_token: string): ng.IPromise<any>;
/**
* Logs in a user, returning tokens and profile information
* @param options Options to bypass displaying the Lock UI
* @param successCallback Callback on successful login
* @param errorCallback Callback on failed login
*/
signin(options?: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void;
/**
* Displays Lock in signup mode, and logs the user in immediately after a successful signup.
* @param options Options to bypass displaying the Lock UI
* @param successCallback Callback on successful signup
* @param errorCallback Callback on failed signup
*/
signup(options?: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void;
/**
* Performs the "forgot your password" flow.
* @param options Options to bypass displaying the Lock UI
* @param successCallback Callback on successful reset
* @param errorCallback Callback on failed reset
*/
reset(options?: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void;
/**
* Validates the user
* @param options Options to bypass displaying the Lock UI
* @param successCallback Callback on successful validation
* @param errorCallback Callback on failed validation
*/
validateUser(options: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void;
/**
* Logs the user out locally by deleting their token from local storage.
*/
signout(): void;
/**
* Reauthenticates the user by using a stored profile and token without going through the login flow.
* @param profile Profile of the user
* @param idToken Id token
* @param accessToken Access token
* @param state State
* @param refreshToken Flag to indicate refreshing the token
*/
authenticate(profile?: any, idToken?: string, accessToken?: string, state?: any, refreshToken?: boolean): ng.IPromise<any>;
/**
* Gets the user's profile
* @param idToken Id token
*/
getProfile(idToken?: string): ng.IPromise<any>;
// Properties
accessToken: string;
idToken: string;
profile: any;
isAuthenticated: boolean;
config: any;
}
interface IAuth0ServiceProvider {
/**
* Configures the auth service
* @param options Client options passed into Auth0
*/
init(options: IAuth0ClientOptions): void;
/**
* @param event Name of the event to handle.
* @param handler Event handler
*/
on(event: string, handler: (...args: any[]) => any): void;
}
}