-
Notifications
You must be signed in to change notification settings - Fork 104
/
adal-angular.d.ts
248 lines (208 loc) · 6.28 KB
/
adal-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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Typings needed for using ADAL with Angular 4
declare module 'adal-angular' {
export function inject(config: adal.Config): adal.AuthenticationContext;
export class adal{
}
}
declare var AuthenticationContext: adal.AuthenticationContextStatic;
declare var Logging: adal.Logging;
declare namespace adal {
/**
*
*
* @interface Config
*/
interface Config {
tenant?: string;
clientId: string;
redirectUri?: string;
instance?: string;
endpoints?: any; // If you need to send CORS api requests.
popUp?: boolean;
localLoginUrl?: string;
displayCall?: (urlNavigate: string) => any;
postLogoutRedirectUri?: string; // redirect url after succesful logout operation
cacheLocation?: string;
anonymousEndpoints?: string[];
expireOffsetSeconds?: number;
correlationId?: string;
loginResource?: string;
resource?: string;
extraQueryParameter?: string;
navigateToLoginRequestUrl?: boolean;
logOutUri?: string;
loadFrameTimeout?: number;
}
/**
*
*
* @interface User
*/
interface User {
userName: string;
profile: any;
authenticated: any;
error: any;
token: any;
loginCached: boolean;
}
/**
*
*
* @interface RequestInfo
*/
interface RequestInfo {
valid: boolean;
parameters: any;
stateMatch: boolean;
stateResponse: string;
requestType: string;
}
/**
*
*
* @interface Logging
*/
interface Logging {
log: (message: string) => void;
level: LoggingLevel;
}
/**
*
*
* @enum {number}
*/
enum LoggingLevel {
ERROR = 0,
WARNING = 1,
INFO = 2,
VERBOSE = 3
}
/**
*
*
* @interface AuthenticationContextStatic
*/
interface AuthenticationContextStatic {
new (config: Config): AuthenticationContext;
}
/**
*
*
* @interface AuthenticationContext
*/
interface AuthenticationContext {
// Additional items for Angular 4
CONSTANTS: any;
REQUEST_TYPE: {
LOGIN: string,
RENEW_TOKEN: string,
UNKNOWN: string
};
// Methods
callback: any;
_getItem: any;
_renewFailed: any;
_openedWindows: any;
_callBackMappedToRenewStates: any;
// Original ADAL Types
instance: string;
config: Config;
/**
* Gets initial Idtoken for the app backend
* Saves the resulting Idtoken in localStorage.
*/
login(): void;
/**
* Indicates whether login is in progress now or not.
*/
loginInProgress(): boolean;
/**
* Gets token for the specified resource from local storage cache
* @param {string} resource A URI that identifies the resource for which the token is valid.
* @returns {string} token if exists and not expired or null
*/
getCachedToken(resource: string): string;
/**
* Retrieves and parse idToken from localstorage
* @returns {User} user object
*/
getCachedUser(): User;
registerCallback(expectedState: string, resource: string, callback: (message: string, token: string) => any): void;
/**
* Acquire token from cache if not expired and available. Acquires token from iframe if expired.
* @param {string} resource ResourceUri identifying the target resource
* @param {requestCallback} callback
*/
acquireToken(resource: string, callback: (message: string, token: string) => any): void;
/**
* Redirect the Browser to Azure AD Authorization endpoint
* @param {string} urlNavigate The authorization request url
*/
promptUser(urlNavigate: string): void;
/**
* Clear cache items.
*/
clearCache(): void;
/**
* Clear cache items for a resource.
*/
clearCacheForResource(resource: string): void;
/**
* Logout user will redirect page to logout endpoint.
* After logout, it will redirect to post_logout page if provided.
*/
logOut(): void;
/**
* Gets a user profile
* @param {requestCallback} callback - The callback that handles the response.
*/
getUser(callback: (message: string, user?: User) => any): void;
/**
* Checks if hash contains access token or id token or error_description
* @param {string} hash - Hash passed from redirect page
* @returns {Boolean}
*/
isCallback(hash: string): boolean;
/**
* Gets login error
* @returns {string} error message related to login
*/
getLoginError(): string;
/**
* Gets requestInfo from given hash.
* @returns {RequestInfo} for appropriate hash.
*/
getRequestInfo(hash: string): RequestInfo;
/**
* Saves token from hash that is received from redirect.
*/
saveTokenFromHash(requestInfo: RequestInfo): void;
/**
* Gets resource for given endpoint if mapping is provided with config.
* @param {string} endpoint - API endpoint
* @returns {string} resource for this API endpoint
*/
getResourceForEndpoint(endpoint: string): string;
/**
* Handles redirection after login operation.
* Gets access token from url and saves token to the (local/session) storage
* or saves error in case unsuccessful login.
* @param {boolean} removeHash - Set to false if you use HashLocationStrategy to retain URL after refresh
*/
handleWindowCallback(removeHash: boolean): void;
log(level: number, message: string, error: any): void;
error(message: string, error: any): void;
warn(message: string): void;
info(message: string): void;
verbose(message: string): void;
}
}
/**
*
*
* @interface Window
*/
interface Window {
_adalInstance: adal.AuthenticationContext;
}