forked from GluuFederation/SCIM-Node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
400 lines (339 loc) · 14 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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// Type definitions for scim-node 2.1
// Project: https://github.com/GluuFederation/scim-node#readme
// Definitions by: Thibaut SEVERAC <https://github.com/thib3113>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/*~ If this module has methods, declare them as functions like so.
*/
export default function ScimNode(config: ScimConfig): SCIMCombine
export interface umaConfigurations {
}
interface scimConfigurations {
}
interface gluuConfig {
}
// come from here : https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback (algorithm supported)
declare enum JWTAlgorithm {
HS256 = "HS256",
HS384 = "HS384",
}
interface ICallback {
(param: object | Error): void;
}
////////////////////////////////
// need to add details //
////////////////////////////////
interface rptDetails {
}
interface ticket {
}
interface AATDetails {
}
interface scimResponse {
}
interface userDetail {
}
interface groupDetail {
}
////////////////////////////////
// /need to add details //
////////////////////////////////
declare abstract class ScimCommon {
/**
* Gets configurations of UMA from domain URL
* @param {string} domain - Gluu server domain Url
* @returns {Promise.<umaConfigurations, error>} - A promise that returns a umaConfigurations if resolved, or an
* Error if rejected.
*/
private getUmaConfigurations(domain: string): Promise<umaConfigurations>
/**
* Gets configurations of SCIM 2.0 from domain URL.
* @param {string} domain - Gluu server domain Url
* @returns {Promise.<scimConfigurations, error>} - A promise that returns a scimConfigurations if resolved, or an
* Error if rejected.
*/
private getSCIMConfigurations(domain: string): Promise<scimConfigurations>
/**
* Authorizes RPT token by requesting PAT using ticket number.
* @param rpt
* @param {GUID} aat - Access token
* @param {json} scimResponse - json response of SCIM method call that contains ticket number.
* @param {string} authorizationEndpoint - Authorization Endpoint URL retrieved from uma configuration
* @returns {Promise<rptDetails, error>} - A promise that returns a rptDetails if resolved, or an Error if rejected.
*/
private authorizeRPT(rpt, aat, scimResponse: scimResponse, authorizationEndpoint): Promise<rptDetails>
/**
* To return users count.
* @returns {Promise<userDetail, error>} - callback or promise that returns users count if resolved,
* or an Error if rejected.
*/
getUsersCount(): Promise<userDetail>
/**
* To return users count.
* @param [callback] - The callback that handles the response and Error.
* callback or promise that returns users count if resolved,
* or an Error if rejected.
*/
getUsersCount(callback: ICallback): void
/**
* To return user list.
* @param {int} startIndex - page index starts with 1.
* @param {int} count - number of users to be returned.
* @returns {Promise<Array<userDetail>, error>} - callback or promise that returns users if resolved, or an Error if rejected.
*/
getUsers(startIndex: number, count: number): Promise<Array<userDetail>>
/**
* To return user list.
* @param {int} startIndex - page index starts with 1.
* @param {int} count - number of users to be returned.
* @param {ICallback} [callback] - The callback that handles the response and Error.
* @returns
*/
getUsers(startIndex: number, count: number, callback: ICallback): void
/**
* To remove user.
* @param {string} id - inum of user
* @returns {Promise<object, error>} - callback or promise that returns empty data if resolved, or an Error if rejected.
*/
removeUser(id: string): Promise<any>
/**
* To remove user.
* @param {string} id - inum of user
* @param {ICallback} [callback] - The callback that handles the response and Error.
*/
removeUser(id: string, callback: ICallback): void
/**
* Returns specific user detail.
* @param {string} id - inum of user
* @returns {Promise<userDetail, error>} - callback or promise that returns user detail if resolved, or an Error if rejected.
*/
getUser(id: string): Promise<userDetail>
/**
* Returns specific user detail.
* @param {string} id - inum of user
* @param {ICallback} [callback] - The callback that handles the response and Error.
*/
getUser(id: string, callback: ICallback): void
}
declare class Scim2 extends ScimCommon {
private getTicketAndConfig(resourceURL: string): Promise<any>
/**
* Gets AAT token detail.
* @param {gluuConfig} config - json of config values of Gluu client
* @param {string} tokenEndpoint - Token endpoint URL retrieve from UMA configuration.
* @param ticket
* @returns {Promise<AATDetails, error>} - A promise that returns a AATDetails if resolved, or an Error if rejected.
*/
private getToken(config: gluuConfig, tokenEndpoint: string, ticket: ticket): Promise<AATDetails>
/**
* @todo config ne semble pas être une string
*
* Gets RPT and SCIM details of Gluu client
* @param {string} config - json of config values of Gluu client
* @param resourceURL
* @returns {Promise<rptDetails, error>} - A promise that returns a rptDetails if resolved, or an Error if rejected.
*/
private getRPTToken(config: string, resourceURL: string): Promise<rptDetails>
/**
* Retrieves user list or total counts if count is zero or undefined.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {int} startIndex - page index starts with 1.
* @param {int} count - number of users to be returned.
* @returns {Promise<userDetail, error>} - A promise that returns a usersDetail if resolved, or an Error if
* rejected.
*/
private get(endpoint: string, rpt: string, startIndex: number, count: number): Promise<Array<userDetail>>
/**
* Retrieves specific user.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {string} id - Inum of user to be retrieve
* @returns {Promise<userDetail, error>} - A promise that returns a userDetail if resolved, or an Error if rejected.
*/
private getById(endpoint: string, rpt: string, id: string): Promise<userDetail>
/**
* Delete specific user.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {string} id - Inum of user to be retrieve
* @returns {Promise<userDetail, error>} - A promise that returns a userDetail if resolved, or an Error if rejected.
*/
private _delete(endpoint, rpt, id): Promise<userDetail>
/**
* To add new user.
* @param {object} userData - Object of user details
* @returns {Promise<object, error>} - callback or promise that returns user detail if resolved, or an Error if rejected.
*/
addUser(userData: userDetail): Promise<userDetail>
/**
* To add new user.
* @param {object} userData - Object of user details
* @param {ICallback} [callback] - The callback that handles the response and Error.
*/
addUser(userData: userDetail, callback: ICallback): void
/**
* Insert new user.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {object} data - User details to be inserted
* @param schema
* @returns {Promise<userDetail, error>} - A promise that returns a userDetail if resolved, or an Error if rejected.
*/
private insert(endpoint, rpt, data, schema): Promise<userDetail>
/**
* To return group count.
* @returns {Promise<object, error>} - callback or promise that returns groups count if resolved,
* or an Error if rejected.
*/
getGroupCount(): Promise<number>
/**
* To return group count.
* @param {ICallback} [callback] - The callback that handles the response and Error.
*/
getGroupCount(callback: ICallback): void
/**
* To return getGroups list.
* @param {int} startIndex - page index starts with 1.
* @param {int} count - number of getGroups to be returned.
* @returns {Promise<object, error>} - callback or promise that returns getGroups if resolved, or an Error if rejected.
*/
getGroups(startIndex: number, count: number): Promise<Array<groupDetail>>
/**
* To return getGroups list.
* @param {int} startIndex - page index starts with 1.
* @param {int} count - number of getGroups to be returned.
* @param {ICallback} [callback] - The callback that handles the response and Error.
* @returns {Promise<object, error>} - callback or promise that returns getGroups if resolved, or an Error if rejected.
*/
getGroups(startIndex: number, count: number, callback: ICallback): void
/**
* Returns specific user detail.
* @param {string} id - inum of user
* @returns {Promise<groupDetail, error>} - callback or promise that returns user detail if resolved, or an Error if rejected.
*/
getGroup(id: string): Promise<groupDetail>
/**
* Returns specific user detail.
* @param {string} id - inum of user
* @param {ICallback} [callback] - The callback that handles the response and Error.
*/
getGroup(id: string, callback: ICallback): void
/**
* To add new user.
* @param groupData
* @returns {Promise<object, error>} - callback or promise that returns user detail if resolved, or an Error if rejected.
*/
addGroup(groupData: groupDetail): Promise<any>
/**
* To add new user.
* @param groupData
* @param {ICallback} [callback] - The callback that handles the response and Error.
*/
addGroup(groupData: groupDetail, callback: ICallback): void
/**
* To remove user.
* @param {string} id - inum of user
* @returns {Promise<object, error>} - callback or promise that returns empty data if resolved, or an Error if rejected.
*/
removeGroup(id: string): Promise<any>
/**
* To remove user.
* @param {string} id - inum of user
* @param {ICallback} [callback] - The callback that handles the response and Error.
*/
removeGroup(id: string, callback: ICallback): void
}
declare class Scim1 extends ScimCommon {
/**
* Gets AAT token detail.
* @param {json} config - json of config values of Gluu client
* @param {string} tokenEndpoint - Token endpoint URL retrieve from UMA configuration.
* @returns {Promise<AATDetails, error>} - A promise that returns a AATDetails if resolved, or an Error if rejected.
*/
private getAAT(config: gluuConfig, tokenEndpoint: string): Promise<AATDetails>
/**
* Retrieves user list or total counts if count is zero or undefined.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {int} startIndex - page index starts with 1.
* @param {int} count - number of users to be returned.
* @returns {Promise<userDetail, error>} - A promise that returns a usersDetail if resolved, or an Error if
* rejected.
*/
private retrieveUsers(endpoint: string, rpt: string, startIndex: number, count: number): Promise<Array<userDetail>>
/**
* Gets RPT token detail.
* @param {string} accessToken - Access token value retrieve from getAAT
* @param {string} rptEndpoint - RPT endpoint URL retrieve from UMA configuration.
* @returns {Promise<rptDetails, error>} - A promise that returns a rptDetails if resolved, or an Error if rejected.
*/
getRPT(accessToken: string, rptEndpoint: string): Promise<rptDetails>
/**
* @todo config ne semble pas être une string
*
* Gets RPT and SCIM details of Gluu client
* @param {string} config - json of config values of Gluu client
* @returns {Promise<rptDetails, error>} - A promise that returns a rptDetails if resolved, or an Error if rejected.
*/
private getRPTToken(config: string): Promise<rptDetails>
/**
* Retrieves specific user.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {string} id - Inum of user to be retrieve
* @returns {Promise<userDetail, error>} - A promise that returns a userDetail if resolved, or an Error if rejected.
*/
private retrieveUsers(endpoint: string, rpt: string, id: string): Promise<userDetail>
/**
* Delete specific user.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {string} id - Inum of user to be retrieve
* @returns {Promise<userDetail, error>} - A promise that returns a userDetail if resolved, or an Error if rejected.
*/
private deleteUser(endpoint, rpt, id): Promise<userDetail>
/**
* Insert new user.
* @param {string} endpoint - User Endpoint URL of SCIM 2.0
* @param {string} rpt - RPT token received from getRPT
* @param {object} data - User details to be inserted
* @param schema
* @returns {Promise<userDetail, error>} - A promise that returns a userDetail if resolved, or an Error if rejected.
*/
private insertUser(endpoint, rpt, data, schema): Promise<userDetail>
}
interface ScimConfig {
/**
* Algorithm type.
*/
keyAlg: JWTAlgorithm | string,
/**
* Gluu server URL.
*/
domain: string,
/**
* Value can be buffer or path of private key.
*/
// @ts-ignore
privateKey: Buffer | string,
/**
* UMA client id
*/
clientId: string,
/**
* oxAuth JWKS key id.
*/
keyId: string,
}
interface SCIMCombine {
scim: Scim1;
scim2: Scim2
}
//
// interface ScimNode {
// (config: ScimConfig): SCIMCombine;
// }
//
// const ScimNode: ScimNode;
//
// export default ScimNode;