@stackfactor/client-api 1.1.11 → 1.1.12-9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +13 -0
- package/{exports.js → exports.ts} +14 -0
- package/index.ts +1 -0
- package/lib/{actionNotifications.js → actionNotifications.ts} +21 -11
- package/lib/{address.js → address.ts} +4 -5
- package/lib/aiAssistant.ts +197 -0
- package/lib/avatar.ts +41 -0
- package/lib/axiosClient.ts +92 -0
- package/lib/{config.js → config.ts} +20 -9
- package/lib/{constants.js → constants.ts} +11 -41
- package/lib/{dashboard.js → dashboard.ts} +19 -10
- package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +63 -32
- package/lib/{groups.js → groups.ts} +68 -29
- package/lib/{integration.js → integration.ts} +103 -47
- package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +27 -22
- package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
- package/lib/{learningContent.js → learningContent.ts} +218 -62
- package/lib/{learningPath.js → learningPath.ts} +57 -30
- package/lib/{logger.js → logger.ts} +18 -8
- package/lib/microSkillsQuizes.ts +70 -0
- package/lib/quotas.ts +59 -0
- package/lib/{role.js → role.ts} +117 -69
- package/lib/{roleTemplate.js → roleTemplate.ts} +65 -30
- package/lib/security.ts +99 -0
- package/lib/{skill.js → skill.ts} +125 -87
- package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +63 -16
- package/lib/skillAssessments.ts +192 -0
- package/lib/{skillTemplate.js → skillTemplate.ts} +73 -42
- package/lib/talentTransfromation.ts +126 -0
- package/lib/{teams.js → teams.ts} +73 -38
- package/lib/{tenants.js → tenants.ts} +17 -10
- package/lib/{trainingPlans.js → trainingPlans.ts} +159 -56
- package/lib/trainingPlansProficiencyLevels.ts +132 -0
- package/lib/{userInformation.js → userInformation.ts} +27 -26
- package/lib/{users.js → users.ts} +239 -140
- package/lib/utils.ts +64 -0
- package/package.json +12 -1
- package/index.js +0 -3
- package/lib/axiosClient.js +0 -85
- package/lib/skillAssessmentTestingSession.js +0 -148
- package/lib/utils.js +0 -48
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
1
2
|
import { client } from "./axiosClient.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Add a new API Token
|
|
6
|
+
* @param {string} name Name of the token
|
|
5
7
|
* @param {Date} expiration Expiration date of the token
|
|
6
|
-
* @param {
|
|
8
|
+
* @param {string} token Authorization token
|
|
9
|
+
* @returns {Promise<object>}
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
return new Promise(
|
|
11
|
+
const addAPIToken = (name: string, expiration: Date, token: string): Promise<object> => {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
10
13
|
const requestData = {
|
|
11
14
|
name: name,
|
|
12
15
|
expiration: expiration,
|
|
@@ -15,7 +18,7 @@ export const addAPIToken = (name, expiration, authToken) => {
|
|
|
15
18
|
`api/v1/users/addapitoken`,
|
|
16
19
|
requestData,
|
|
17
20
|
{
|
|
18
|
-
headers: { authorization:
|
|
21
|
+
headers: { authorization: token },
|
|
19
22
|
}
|
|
20
23
|
);
|
|
21
24
|
addTokenRequest
|
|
@@ -34,10 +37,11 @@ export const addAPIToken = (name, expiration, authToken) => {
|
|
|
34
37
|
|
|
35
38
|
/**
|
|
36
39
|
* Confirm email address
|
|
37
|
-
* @param {
|
|
40
|
+
* @param {string} validationCode The code was provided to the user in advance by email
|
|
41
|
+
* @returns {Promise<void>}
|
|
38
42
|
*/
|
|
39
|
-
|
|
40
|
-
return new Promise(
|
|
43
|
+
const confirmEmailAddress = (validationCode: string): Promise<void> => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
41
45
|
const requestData = {
|
|
42
46
|
validationCode: validationCode,
|
|
43
47
|
};
|
|
@@ -57,11 +61,12 @@ export const confirmEmailAddress = (validationCode) => {
|
|
|
57
61
|
|
|
58
62
|
/**
|
|
59
63
|
* Confirm phone number
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {
|
|
64
|
+
* @param {string} validationCode The code was provided to the user in advance by email
|
|
65
|
+
* @param {string} token Authorization token
|
|
66
|
+
* @returns {Promise<object>}
|
|
62
67
|
*/
|
|
63
|
-
|
|
64
|
-
return new Promise(
|
|
68
|
+
const confirmPhone = (validationCode: string, token: string): Promise<object> => {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
65
70
|
const requestData = {
|
|
66
71
|
validationCode: validationCode,
|
|
67
72
|
};
|
|
@@ -69,7 +74,7 @@ export const confirmPhone = (validationCode, authToken) => {
|
|
|
69
74
|
"api/v1/users/confirmPhone",
|
|
70
75
|
requestData,
|
|
71
76
|
{
|
|
72
|
-
headers: { authorization:
|
|
77
|
+
headers: { authorization: token },
|
|
73
78
|
}
|
|
74
79
|
);
|
|
75
80
|
confirmationRequest
|
|
@@ -84,11 +89,12 @@ export const confirmPhone = (validationCode, authToken) => {
|
|
|
84
89
|
|
|
85
90
|
/**
|
|
86
91
|
* Generate confirmation code
|
|
87
|
-
* @param {
|
|
88
|
-
* @param {
|
|
92
|
+
* @param {string} phoneNumber Send confirmation code to the phone number
|
|
93
|
+
* @param {string} token Authorization token
|
|
94
|
+
* @returns {Promise<object>}
|
|
89
95
|
*/
|
|
90
|
-
|
|
91
|
-
return new Promise(
|
|
96
|
+
const confirmPhoneGenerateCode = (phoneNumber: string, token: string): Promise<object> => {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
92
98
|
const requestData = {
|
|
93
99
|
phoneNumber: phoneNumber,
|
|
94
100
|
};
|
|
@@ -96,7 +102,7 @@ export const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
|
|
|
96
102
|
"api/v1/users/confirmPhoneGenerateCode",
|
|
97
103
|
requestData,
|
|
98
104
|
{
|
|
99
|
-
headers: { authorization:
|
|
105
|
+
headers: { authorization: token },
|
|
100
106
|
}
|
|
101
107
|
);
|
|
102
108
|
confirmationRequest
|
|
@@ -111,23 +117,23 @@ export const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
|
|
|
111
117
|
|
|
112
118
|
/**
|
|
113
119
|
* Create a new account (tenant). It returns a promise
|
|
114
|
-
* @param {
|
|
115
|
-
* @param {
|
|
116
|
-
* @param {
|
|
117
|
-
* @param {
|
|
118
|
-
* @param {
|
|
119
|
-
* @param {
|
|
120
|
-
* @
|
|
120
|
+
* @param {string} email User's email address
|
|
121
|
+
* @param {string} firstName User's first name
|
|
122
|
+
* @param {string} lastName User's last name
|
|
123
|
+
* @param {string} password User's password
|
|
124
|
+
* @param {string} subSite Subsite where the new account will be created
|
|
125
|
+
* @param {string} inviteCode Invitation code received in advance from one of the account owners
|
|
126
|
+
* @returns {Promise<object>}
|
|
121
127
|
*/
|
|
122
|
-
|
|
123
|
-
email,
|
|
124
|
-
firstName,
|
|
125
|
-
lastName,
|
|
126
|
-
password,
|
|
127
|
-
subSite,
|
|
128
|
-
inviteCode
|
|
129
|
-
) => {
|
|
130
|
-
return new Promise(
|
|
128
|
+
const createAccount = (
|
|
129
|
+
email: string,
|
|
130
|
+
firstName: string,
|
|
131
|
+
lastName: string,
|
|
132
|
+
password: string,
|
|
133
|
+
subSite: string,
|
|
134
|
+
inviteCode: string
|
|
135
|
+
): Promise<object> => {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
131
137
|
if (
|
|
132
138
|
email.trim() === "" ||
|
|
133
139
|
firstName.trim() === "" ||
|
|
@@ -160,20 +166,21 @@ export const createAccount = (
|
|
|
160
166
|
|
|
161
167
|
/**
|
|
162
168
|
* Create a new user account. It returns a promise
|
|
163
|
-
* @param {
|
|
164
|
-
* @param {
|
|
165
|
-
* @param {
|
|
166
|
-
* @param {
|
|
167
|
-
* @param {
|
|
169
|
+
* @param {string} email User's email address
|
|
170
|
+
* @param {string} firstName User's first name
|
|
171
|
+
* @param {string} lastName User's last name
|
|
172
|
+
* @param {string} password User's password
|
|
173
|
+
* @param {string} token Invitation token provided to the user
|
|
174
|
+
* @returns {Promise<object>}
|
|
168
175
|
*/
|
|
169
|
-
|
|
170
|
-
email,
|
|
171
|
-
firstName,
|
|
172
|
-
lastName,
|
|
173
|
-
password,
|
|
174
|
-
token
|
|
175
|
-
) => {
|
|
176
|
-
return new Promise(
|
|
176
|
+
const createUserAccount = (
|
|
177
|
+
email: string,
|
|
178
|
+
firstName: string,
|
|
179
|
+
lastName: string,
|
|
180
|
+
password: string,
|
|
181
|
+
token: string
|
|
182
|
+
): Promise<object> => {
|
|
183
|
+
return new Promise((resolve, reject) => {
|
|
177
184
|
if (
|
|
178
185
|
email.trim() === "" ||
|
|
179
186
|
firstName.trim() === "" ||
|
|
@@ -204,11 +211,12 @@ export const createUserAccount = (
|
|
|
204
211
|
|
|
205
212
|
/**
|
|
206
213
|
* Delete an existing API token
|
|
207
|
-
* @param {
|
|
208
|
-
* @param {
|
|
214
|
+
* @param {string} token Expiration date of the token
|
|
215
|
+
* @param {string} authToken Authorization token
|
|
216
|
+
* @returns {Promise<string>}
|
|
209
217
|
*/
|
|
210
|
-
|
|
211
|
-
return new Promise(
|
|
218
|
+
const deleteAPIToken = (token: string, authToken: string): Promise<string> => {
|
|
219
|
+
return new Promise((resolve, reject) => {
|
|
212
220
|
const deleteTokenRequest = client.delete(`api/v1/users/user/token`, {
|
|
213
221
|
headers: { authorization: authToken },
|
|
214
222
|
data: {
|
|
@@ -227,13 +235,14 @@ export const deleteAPIToken = (token, authToken) => {
|
|
|
227
235
|
|
|
228
236
|
/**
|
|
229
237
|
* Delete existing users
|
|
230
|
-
* @param {
|
|
231
|
-
* @param {
|
|
238
|
+
* @param {string[]} userIds The ID of the users to be deleted
|
|
239
|
+
* @param {string} token Authorization token
|
|
240
|
+
* @returns {Promise<object>}
|
|
232
241
|
*/
|
|
233
|
-
|
|
234
|
-
return new Promise(
|
|
242
|
+
const deleteUsers = (userIds: string[], token: string): Promise<object> => {
|
|
243
|
+
return new Promise((resolve, reject) => {
|
|
235
244
|
const deleteTokenRequest = client.delete(`api/v1/users/`, {
|
|
236
|
-
headers: { authorization:
|
|
245
|
+
headers: { authorization: token },
|
|
237
246
|
data: {
|
|
238
247
|
userIds: userIds,
|
|
239
248
|
},
|
|
@@ -250,12 +259,13 @@ export const deleteUsers = (userIds, authToken) => {
|
|
|
250
259
|
|
|
251
260
|
/**
|
|
252
261
|
* Get all the API tokens
|
|
253
|
-
* @param {
|
|
262
|
+
* @param {string} token Authorization token
|
|
263
|
+
* @returns {Promise<object>}
|
|
254
264
|
*/
|
|
255
|
-
|
|
256
|
-
return new Promise(
|
|
265
|
+
const getAPITokens = (token: string): Promise<object> => {
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
257
267
|
const getTokensRequest = client.get(`api/v1/users/getapitokens`, {
|
|
258
|
-
headers: { authorization:
|
|
268
|
+
headers: { authorization: token },
|
|
259
269
|
});
|
|
260
270
|
getTokensRequest
|
|
261
271
|
.then((result) => {
|
|
@@ -269,11 +279,15 @@ export const getAPITokens = (authToken) => {
|
|
|
269
279
|
|
|
270
280
|
/**
|
|
271
281
|
* Get the specified user account by Id. It returns a promise
|
|
272
|
-
* @param {
|
|
282
|
+
* @param {string} id Id of the user for which information is being requested
|
|
283
|
+
* @param {string} token Authorization token
|
|
284
|
+
* @returns {Promise<object>}
|
|
273
285
|
*/
|
|
274
|
-
|
|
275
|
-
return new Promise(
|
|
276
|
-
const getUserInformationRequest = client.get(`api/v1/users/user/${id}
|
|
286
|
+
const getUserById = (id: string, token: string): Promise<object> => {
|
|
287
|
+
return new Promise((resolve, reject) => {
|
|
288
|
+
const getUserInformationRequest = client.get(`api/v1/users/user/${id}`, {
|
|
289
|
+
headers: { authorization: token },
|
|
290
|
+
});
|
|
277
291
|
getUserInformationRequest
|
|
278
292
|
.then((result) => {
|
|
279
293
|
if (result != null) {
|
|
@@ -290,14 +304,15 @@ export const getUserById = (id) => {
|
|
|
290
304
|
|
|
291
305
|
/**
|
|
292
306
|
* Get user information
|
|
293
|
-
* @param {
|
|
294
|
-
* @param {
|
|
295
|
-
* @param {
|
|
307
|
+
* @param {string} userId User Id
|
|
308
|
+
* @param {string} category User information category
|
|
309
|
+
* @param {string} token Authorization token
|
|
310
|
+
* @returns {Promise<object>}
|
|
296
311
|
*/
|
|
297
|
-
|
|
298
|
-
return new Promise(
|
|
312
|
+
const getUserInformation = (userId: string, category: string, token: string): Promise<object> => {
|
|
313
|
+
return new Promise((resolve, reject) => {
|
|
299
314
|
let confirmationRequest = client.get(
|
|
300
|
-
`api/v1/users/user/${userId
|
|
315
|
+
`api/v1/users/user/${userId || 0}/${category || "*"}`,
|
|
301
316
|
{
|
|
302
317
|
headers: { authorization: token },
|
|
303
318
|
}
|
|
@@ -314,12 +329,13 @@ export const getUserInformation = (userId, category, token) => {
|
|
|
314
329
|
|
|
315
330
|
/**
|
|
316
331
|
* Get the list of users
|
|
317
|
-
* @param {
|
|
318
|
-
* @param {
|
|
319
|
-
* @param {
|
|
332
|
+
* @param {object} filter Filter to select the users. Ex: {firstName : "John"}
|
|
333
|
+
* @param {string[]} fields Fields to be loaded. Ex: ["firstName"]
|
|
334
|
+
* @param {string} token Authorization token
|
|
335
|
+
* @returns {Promise<object>}
|
|
320
336
|
*/
|
|
321
|
-
|
|
322
|
-
return new Promise(
|
|
337
|
+
const getUsers = (filter: object, fields: string[], token: string): Promise<object> => {
|
|
338
|
+
return new Promise((resolve, reject) => {
|
|
323
339
|
const requestData = {
|
|
324
340
|
filter: filter,
|
|
325
341
|
fields: fields,
|
|
@@ -339,13 +355,14 @@ export const getUsers = (filter, fields, token) => {
|
|
|
339
355
|
|
|
340
356
|
/**
|
|
341
357
|
* Invite other users to join the same account
|
|
342
|
-
* @param {
|
|
343
|
-
* @param {
|
|
344
|
-
* @param {
|
|
345
|
-
* @param {
|
|
358
|
+
* @param {string[]} invitees List of emails of the invitees
|
|
359
|
+
* @param {string} groupId The group the user should be added to
|
|
360
|
+
* @param {string} teamId The team the user should be added to
|
|
361
|
+
* @param {string} authToken Authorization token
|
|
362
|
+
* @returns {Promise<object>}
|
|
346
363
|
*/
|
|
347
|
-
|
|
348
|
-
return new Promise(
|
|
364
|
+
const inviteUsers = (invitees: string[], groupId: string, teamId: string, authToken: string): Promise<object> => {
|
|
365
|
+
return new Promise((resolve, reject) => {
|
|
349
366
|
const requestData = {
|
|
350
367
|
invitees: invitees,
|
|
351
368
|
groupId: groupId,
|
|
@@ -367,16 +384,15 @@ export const inviteUsers = (invitees, groupId, teamId, authToken) => {
|
|
|
367
384
|
|
|
368
385
|
/**
|
|
369
386
|
* Login using email and password. It returns a promise
|
|
370
|
-
* @param {
|
|
371
|
-
* @param {
|
|
372
|
-
* @
|
|
387
|
+
* @param {string} email User's email address
|
|
388
|
+
* @param {string} password User's password
|
|
389
|
+
* @returns {Promise<object>}
|
|
373
390
|
*/
|
|
374
|
-
|
|
375
|
-
return new Promise(
|
|
391
|
+
const login = (email: string, password: string): Promise<object> => {
|
|
392
|
+
return new Promise((resolve, reject) => {
|
|
376
393
|
const requestData = {
|
|
377
394
|
email: email,
|
|
378
395
|
password: password,
|
|
379
|
-
rememberMe: rememberMe,
|
|
380
396
|
};
|
|
381
397
|
let request = client.post("api/v1/auth/login", requestData);
|
|
382
398
|
request
|
|
@@ -390,15 +406,44 @@ export const login = (email, password, rememberMe) => {
|
|
|
390
406
|
};
|
|
391
407
|
|
|
392
408
|
/**
|
|
393
|
-
*
|
|
394
|
-
* @param {
|
|
409
|
+
* Login callback after authentication to exchange the code token for authentication and refresh tokens
|
|
410
|
+
* @param {string} code
|
|
411
|
+
* @param {string} codeVerifier
|
|
412
|
+
* @param {string} redirectUri
|
|
413
|
+
* @returns {Promise<object>}
|
|
395
414
|
*/
|
|
396
|
-
|
|
397
|
-
return new Promise(
|
|
398
|
-
const
|
|
399
|
-
|
|
415
|
+
const loginExchangeKeys = (code: string, codeVerifier: string, redirectUri: string): Promise<object> => {
|
|
416
|
+
return new Promise((resolve, reject) => {
|
|
417
|
+
const requestData = {
|
|
418
|
+
code: code,
|
|
419
|
+
codeVerifier: codeVerifier,
|
|
420
|
+
redirectUri: redirectUri,
|
|
400
421
|
};
|
|
401
|
-
let request = client.post("api/v1/auth/
|
|
422
|
+
let request = client.post("api/v1/auth/loginexchangekeys", requestData);
|
|
423
|
+
request
|
|
424
|
+
.then((response) => {
|
|
425
|
+
resolve(response.data);
|
|
426
|
+
})
|
|
427
|
+
.catch((error) => {
|
|
428
|
+
reject(error);
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Logout from the server. It returns a promise
|
|
435
|
+
* @param {string} token Authorization token
|
|
436
|
+
* @returns {Promise<object>}
|
|
437
|
+
*/
|
|
438
|
+
const logout = (token: string): Promise<object> => {
|
|
439
|
+
return new Promise((resolve, reject) => {
|
|
440
|
+
let request = client.post(
|
|
441
|
+
"api/v1/auth/logout",
|
|
442
|
+
{},
|
|
443
|
+
{
|
|
444
|
+
headers: { authorization: token },
|
|
445
|
+
}
|
|
446
|
+
);
|
|
402
447
|
request
|
|
403
448
|
.then((response) => {
|
|
404
449
|
resolve(response.data);
|
|
@@ -412,12 +457,14 @@ export const logout = (token) => {
|
|
|
412
457
|
/**
|
|
413
458
|
* Checks the current auth token and maintain it alive. It returns a promise. In case the token is invalid
|
|
414
459
|
* a new token can be restablished using login
|
|
415
|
-
* @param {
|
|
460
|
+
* @param {string} refreshToken User's auth token to be refreshed
|
|
461
|
+
* @returns {Promise<object>}
|
|
416
462
|
*/
|
|
417
|
-
|
|
418
|
-
return new Promise(
|
|
419
|
-
let
|
|
420
|
-
|
|
463
|
+
const refreshToken = (refreshToken: string): Promise<object> => {
|
|
464
|
+
return new Promise((resolve, reject) => {
|
|
465
|
+
let request = client.post("api/v1/auth/refreshToken", {
|
|
466
|
+
refreshToken: refreshToken,
|
|
467
|
+
});
|
|
421
468
|
request
|
|
422
469
|
.then((response) => {
|
|
423
470
|
resolve(response.data);
|
|
@@ -430,11 +477,12 @@ export const refreshToken = (token) => {
|
|
|
430
477
|
|
|
431
478
|
/**
|
|
432
479
|
* Remove an existing API token
|
|
433
|
-
* @param {
|
|
434
|
-
* @param {
|
|
480
|
+
* @param {string} id The ID of the token to be removed
|
|
481
|
+
* @param {string} authToken Authorization token
|
|
482
|
+
* @returns {Promise<string>}
|
|
435
483
|
*/
|
|
436
|
-
|
|
437
|
-
return new Promise(
|
|
484
|
+
const removeAPIToken = (id: string, authToken: string): Promise<string> => {
|
|
485
|
+
return new Promise((resolve, reject) => {
|
|
438
486
|
const requestData = {
|
|
439
487
|
id: id,
|
|
440
488
|
};
|
|
@@ -457,11 +505,12 @@ export const removeAPIToken = (id, authToken) => {
|
|
|
457
505
|
|
|
458
506
|
/**
|
|
459
507
|
* Resend invitation emails
|
|
460
|
-
* @param {
|
|
461
|
-
* @param {
|
|
508
|
+
* @param {string[]} invitees List of emails of the invitees
|
|
509
|
+
* @param {string} authToken Authorization token
|
|
510
|
+
* @returns {Promise<object>}
|
|
462
511
|
*/
|
|
463
|
-
|
|
464
|
-
return new Promise(
|
|
512
|
+
const resendInvitationEmails = (invitees: string[], authToken: string): Promise<object> => {
|
|
513
|
+
return new Promise((resolve, reject) => {
|
|
465
514
|
const requestData = {
|
|
466
515
|
invitees: invitees,
|
|
467
516
|
token: authToken,
|
|
@@ -481,12 +530,13 @@ export const resendInvitationEmails = (invitees, authToken) => {
|
|
|
481
530
|
|
|
482
531
|
/**
|
|
483
532
|
* Reset the password. It returns a promise
|
|
484
|
-
* @param {
|
|
485
|
-
* @param {
|
|
486
|
-
* @param {
|
|
533
|
+
* @param {string} code Code provided to the user by email
|
|
534
|
+
* @param {string} email User's email address
|
|
535
|
+
* @param {string} password User's new password
|
|
536
|
+
* @returns {Promise<object>}
|
|
487
537
|
*/
|
|
488
|
-
|
|
489
|
-
return new Promise(
|
|
538
|
+
const resetPassword = (email: string, code: string, password: string): Promise<object> => {
|
|
539
|
+
return new Promise((resolve, reject) => {
|
|
490
540
|
let postData = {
|
|
491
541
|
email: email,
|
|
492
542
|
code: code,
|
|
@@ -503,12 +553,41 @@ export const resetPassword = (email, code, password) => {
|
|
|
503
553
|
});
|
|
504
554
|
};
|
|
505
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Send email confirmation code
|
|
558
|
+
* @param {string} email
|
|
559
|
+
* @param {string} token
|
|
560
|
+
* @returns {Promise<object>}
|
|
561
|
+
*/
|
|
562
|
+
const sendEmailConfirmationCode = (email: string, token: string): Promise<object> => {
|
|
563
|
+
return new Promise((resolve, reject) => {
|
|
564
|
+
let postData = {
|
|
565
|
+
email: email,
|
|
566
|
+
};
|
|
567
|
+
let request = client.post(
|
|
568
|
+
"api/v1/users/sendemailconfirmationcode",
|
|
569
|
+
postData,
|
|
570
|
+
{
|
|
571
|
+
headers: { authorization: token },
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
request
|
|
575
|
+
.then((response) => {
|
|
576
|
+
resolve(response.data);
|
|
577
|
+
})
|
|
578
|
+
.catch((error) => {
|
|
579
|
+
reject(error);
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
};
|
|
583
|
+
|
|
506
584
|
/**
|
|
507
585
|
* Send an email to the user indicated by the email address to reset the password. It returns a promise
|
|
508
|
-
* @param {
|
|
586
|
+
* @param {string} email Email of the user who needs to reset the password
|
|
587
|
+
* @returns {Promise<object>}
|
|
509
588
|
*/
|
|
510
|
-
|
|
511
|
-
return new Promise(
|
|
589
|
+
const sendPasswordResetNotification = (email: string): Promise<object> => {
|
|
590
|
+
return new Promise((resolve, reject) => {
|
|
512
591
|
let postData = {
|
|
513
592
|
email: email,
|
|
514
593
|
};
|
|
@@ -528,13 +607,14 @@ export const sendPasswordResetNotification = (email) => {
|
|
|
528
607
|
|
|
529
608
|
/**
|
|
530
609
|
* Set user profile information
|
|
531
|
-
* @param {
|
|
532
|
-
* @param {
|
|
533
|
-
* @param {
|
|
534
|
-
* @param {
|
|
610
|
+
* @param {string} userId User Id
|
|
611
|
+
* @param {string} category User information category
|
|
612
|
+
* @param {object} data New or updated user data information
|
|
613
|
+
* @param {string} token Authorization token
|
|
614
|
+
* @returns {Promise<object>}
|
|
535
615
|
*/
|
|
536
|
-
|
|
537
|
-
return new Promise(
|
|
616
|
+
const setUserInformation = (userId: string, category: string, data: object, token: string): Promise<object> => {
|
|
617
|
+
return new Promise((resolve, reject) => {
|
|
538
618
|
const requestData = {
|
|
539
619
|
data: category ? { [category]: data } : data,
|
|
540
620
|
userId: userId,
|
|
@@ -554,14 +634,22 @@ export const setUserInformation = (userId, category, data, token) => {
|
|
|
554
634
|
|
|
555
635
|
/**
|
|
556
636
|
* Update user email
|
|
557
|
-
* @param {
|
|
558
|
-
* @param {
|
|
559
|
-
* @param {
|
|
637
|
+
* @param {string} email The new email address
|
|
638
|
+
* @param {string} verificationCode The verification code
|
|
639
|
+
* @param {string} password The current password
|
|
640
|
+
* @param {string} token Authorization token
|
|
641
|
+
* @returns {Promise<object>}
|
|
560
642
|
*/
|
|
561
|
-
|
|
562
|
-
|
|
643
|
+
const updateUserEmail = (
|
|
644
|
+
email: string,
|
|
645
|
+
verificationCode: string,
|
|
646
|
+
password: string,
|
|
647
|
+
token: string
|
|
648
|
+
): Promise<object> => {
|
|
649
|
+
return new Promise((resolve, reject) => {
|
|
563
650
|
const requestData = {
|
|
564
651
|
email: email,
|
|
652
|
+
verificationCode: verificationCode,
|
|
565
653
|
password: password,
|
|
566
654
|
};
|
|
567
655
|
let confirmationRequest = client.post(
|
|
@@ -583,12 +671,17 @@ export const updateUserEmail = (email, password, token) => {
|
|
|
583
671
|
|
|
584
672
|
/**
|
|
585
673
|
* Update user groups
|
|
586
|
-
* @param {String}
|
|
674
|
+
* @param {String} userId The id of the user
|
|
587
675
|
* @param {Array<String>} groups The id of the groups the user should belong to
|
|
588
676
|
* @param {String} token Authorization token
|
|
677
|
+
* @returns {Promise<Object>}
|
|
589
678
|
*/
|
|
590
|
-
|
|
591
|
-
|
|
679
|
+
const updateUserGroups = (
|
|
680
|
+
userId: string,
|
|
681
|
+
groups: string[],
|
|
682
|
+
token: string
|
|
683
|
+
): Promise<object> => {
|
|
684
|
+
return new Promise((resolve, reject) => {
|
|
592
685
|
const requestData = {
|
|
593
686
|
userId: userId,
|
|
594
687
|
groups: groups || [],
|
|
@@ -615,9 +708,14 @@ export const updateUserGroups = (userId, groups, token) => {
|
|
|
615
708
|
* @param {String} password The current password
|
|
616
709
|
* @param {String} newPassword The new password
|
|
617
710
|
* @param {String} token Authorization token
|
|
711
|
+
* @returns {Promise<Object>}
|
|
618
712
|
*/
|
|
619
|
-
|
|
620
|
-
|
|
713
|
+
const updateUserPassword = (
|
|
714
|
+
password: string,
|
|
715
|
+
newPassword: string,
|
|
716
|
+
token: string
|
|
717
|
+
): Promise<object> => {
|
|
718
|
+
return new Promise((resolve, reject) => {
|
|
621
719
|
const requestData = {
|
|
622
720
|
password: password,
|
|
623
721
|
newPassword: newPassword,
|
|
@@ -643,17 +741,18 @@ export const updateUserPassword = (password, newPassword, token) => {
|
|
|
643
741
|
* Validate reset password code. It returns a promise
|
|
644
742
|
* @param {String} email User's email address
|
|
645
743
|
* @param {String} code Provided reset code
|
|
744
|
+
* @returns {Promise<Object>}
|
|
646
745
|
*/
|
|
647
|
-
|
|
648
|
-
|
|
746
|
+
const validateResetPasswordCode = (
|
|
747
|
+
email: string,
|
|
748
|
+
code: string
|
|
749
|
+
): Promise<object> => {
|
|
750
|
+
return new Promise((resolve, reject) => {
|
|
649
751
|
let postData = {
|
|
650
752
|
email: email,
|
|
651
753
|
code: code,
|
|
652
754
|
};
|
|
653
|
-
let request = client.post(
|
|
654
|
-
"api/v1/users/validateresetpasswordcode",
|
|
655
|
-
postData
|
|
656
|
-
);
|
|
755
|
+
let request = client.post("api/v1/users/validateresetpasswordcode", postData);
|
|
657
756
|
request
|
|
658
757
|
.then((response) => {
|
|
659
758
|
resolve(response.data);
|
|
@@ -664,7 +763,7 @@ export const validateResetPasswordCode = (email, code) => {
|
|
|
664
763
|
});
|
|
665
764
|
};
|
|
666
765
|
|
|
667
|
-
|
|
766
|
+
export default {
|
|
668
767
|
addAPIToken,
|
|
669
768
|
confirmEmailAddress,
|
|
670
769
|
confirmPhone,
|
|
@@ -679,17 +778,17 @@ const users = {
|
|
|
679
778
|
getUsers,
|
|
680
779
|
inviteUsers,
|
|
681
780
|
login,
|
|
781
|
+
loginExchangeKeys,
|
|
682
782
|
logout,
|
|
683
783
|
refreshToken,
|
|
684
784
|
removeAPIToken,
|
|
685
785
|
resendInvitationEmails,
|
|
686
786
|
resetPassword,
|
|
787
|
+
sendEmailConfirmationCode,
|
|
687
788
|
sendPasswordResetNotification,
|
|
688
789
|
setUserInformation,
|
|
689
790
|
updateUserEmail,
|
|
690
791
|
updateUserGroups,
|
|
691
792
|
updateUserPassword,
|
|
692
793
|
validateResetPasswordCode,
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
export default users;
|
|
794
|
+
};
|