@stackfactor/client-api 1.1.152 → 1.1.153
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/dist/cjs/actionNotifications.js.map +1 -1
- package/dist/cjs/address.js.map +1 -1
- package/dist/cjs/aiAssistant.js.map +1 -1
- package/dist/cjs/avatar.js.map +1 -1
- package/dist/cjs/axiosClient.js.map +1 -1
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/dashboard.js.map +1 -1
- package/dist/cjs/departmentTrainingPlans.d.ts +4 -4
- package/dist/cjs/departmentTrainingPlans.js +2 -2
- package/dist/cjs/departmentTrainingPlans.js.map +1 -1
- package/dist/cjs/groups.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/integration.d.ts +2 -2
- package/dist/cjs/integration.d.ts.map +1 -1
- package/dist/cjs/integration.js +1 -1
- package/dist/cjs/integration.js.map +1 -1
- package/dist/cjs/integrationConfiguration.d.ts +2 -2
- package/dist/cjs/integrationConfiguration.js +1 -1
- package/dist/cjs/integrationConfiguration.js.map +1 -1
- package/dist/cjs/integrations/contentGenerator.js.map +1 -1
- package/dist/cjs/learningContent.js.map +1 -1
- package/dist/cjs/learningPath.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/cjs/microSkillsQuizes.js.map +1 -1
- package/dist/cjs/quotas.js.map +1 -1
- package/dist/cjs/role.js.map +1 -1
- package/dist/cjs/roleTemplate.js.map +1 -1
- package/dist/cjs/security.js.map +1 -1
- package/dist/cjs/skill.js.map +1 -1
- package/dist/cjs/skillAssessmentTestingSession.d.ts +2 -2
- package/dist/cjs/skillAssessmentTestingSession.d.ts.map +1 -1
- package/dist/cjs/skillAssessmentTestingSession.js +1 -1
- package/dist/cjs/skillAssessmentTestingSession.js.map +1 -1
- package/dist/cjs/skillAssessments.d.ts +2 -2
- package/dist/cjs/skillAssessments.js +1 -1
- package/dist/cjs/skillAssessments.js.map +1 -1
- package/dist/cjs/skillTemplate.js.map +1 -1
- package/dist/cjs/talentTransfromation.js.map +1 -1
- package/dist/cjs/teams.js.map +1 -1
- package/dist/cjs/tenants.d.ts +2 -2
- package/dist/cjs/tenants.d.ts.map +1 -1
- package/dist/cjs/tenants.js +1 -1
- package/dist/cjs/tenants.js.map +1 -1
- package/dist/cjs/trainingPlans.js.map +1 -1
- package/dist/cjs/trainingPlansProficiencyLevels.js.map +1 -1
- package/dist/cjs/userInformation.js.map +1 -1
- package/dist/cjs/users.d.ts +1 -1
- package/dist/cjs/users.d.ts.map +1 -1
- package/dist/cjs/users.js.map +1 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/actionNotifications.js.map +1 -1
- package/dist/esm/address.js.map +1 -1
- package/dist/esm/aiAssistant.js.map +1 -1
- package/dist/esm/avatar.js.map +1 -1
- package/dist/esm/axiosClient.js.map +1 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/dashboard.js.map +1 -1
- package/dist/esm/departmentTrainingPlans.d.ts +4 -4
- package/dist/esm/departmentTrainingPlans.js +2 -2
- package/dist/esm/departmentTrainingPlans.js.map +1 -1
- package/dist/esm/groups.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integration.d.ts +2 -2
- package/dist/esm/integration.d.ts.map +1 -1
- package/dist/esm/integration.js +1 -1
- package/dist/esm/integration.js.map +1 -1
- package/dist/esm/integrationConfiguration.d.ts +2 -2
- package/dist/esm/integrationConfiguration.js +1 -1
- package/dist/esm/integrationConfiguration.js.map +1 -1
- package/dist/esm/integrations/contentGenerator.js.map +1 -1
- package/dist/esm/learningContent.js.map +1 -1
- package/dist/esm/learningPath.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/microSkillsQuizes.js.map +1 -1
- package/dist/esm/quotas.js.map +1 -1
- package/dist/esm/role.js.map +1 -1
- package/dist/esm/roleTemplate.js.map +1 -1
- package/dist/esm/security.js.map +1 -1
- package/dist/esm/skill.js.map +1 -1
- package/dist/esm/skillAssessmentTestingSession.d.ts +2 -2
- package/dist/esm/skillAssessmentTestingSession.d.ts.map +1 -1
- package/dist/esm/skillAssessmentTestingSession.js +1 -1
- package/dist/esm/skillAssessmentTestingSession.js.map +1 -1
- package/dist/esm/skillAssessments.d.ts +2 -2
- package/dist/esm/skillAssessments.js +1 -1
- package/dist/esm/skillAssessments.js.map +1 -1
- package/dist/esm/skillTemplate.js.map +1 -1
- package/dist/esm/talentTransfromation.js.map +1 -1
- package/dist/esm/teams.js.map +1 -1
- package/dist/esm/tenants.d.ts +2 -2
- package/dist/esm/tenants.d.ts.map +1 -1
- package/dist/esm/tenants.js +1 -1
- package/dist/esm/tenants.js.map +1 -1
- package/dist/esm/trainingPlans.js.map +1 -1
- package/dist/esm/trainingPlansProficiencyLevels.js.map +1 -1
- package/dist/esm/userInformation.js.map +1 -1
- package/dist/esm/users.d.ts +1 -1
- package/dist/esm/users.d.ts.map +1 -1
- package/dist/esm/users.js.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/actionNotifications.js +0 -73
- package/dist/address.js +0 -22
- package/dist/aiAssistant.js +0 -134
- package/dist/avatar.js +0 -32
- package/dist/axiosClient.js +0 -89
- package/dist/config.js +0 -63
- package/dist/constants.js +0 -94
- package/dist/dashboard.js +0 -74
- package/dist/departmentTrainingPlans.js +0 -154
- package/dist/exports.js +0 -77
- package/dist/groups.js +0 -273
- package/dist/index.js +0 -77
- package/dist/integration.js +0 -319
- package/dist/integrationConfiguration.js +0 -86
- package/dist/integrations/contentGenerator.js +0 -70
- package/dist/learningContent.js +0 -394
- package/dist/learningPath.js +0 -205
- package/dist/logger.js +0 -57
- package/dist/microSkillsQuizes.js +0 -53
- package/dist/quotas.js +0 -50
- package/dist/role.js +0 -363
- package/dist/roleTemplate.js +0 -236
- package/dist/security.js +0 -79
- package/dist/skill.js +0 -439
- package/dist/skillAssessmentTestingSession.js +0 -156
- package/dist/skillAssessments.js +0 -156
- package/dist/skillTemplate.js +0 -281
- package/dist/talentTransfromation.js +0 -100
- package/dist/teams.js +0 -252
- package/dist/tenants.js +0 -52
- package/dist/trainingPlans.js +0 -308
- package/dist/trainingPlansProficiencyLevels.js +0 -98
- package/dist/userInformation.js +0 -81
- package/dist/users.js +0 -694
- package/dist/utils.js +0 -65
package/dist/users.js
DELETED
|
@@ -1,694 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable no-undef */
|
|
4
|
-
const axiosClient_1 = require("./axiosClient");
|
|
5
|
-
/**
|
|
6
|
-
* Add a new API Token
|
|
7
|
-
* @param {string} name Name of the token
|
|
8
|
-
* @param {Date} expiration Expiration date of the token
|
|
9
|
-
* @param {string} token Authorization token
|
|
10
|
-
* @returns {Promise<object>}
|
|
11
|
-
*/
|
|
12
|
-
const addAPIToken = (name, expiration, token) => {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
const requestData = {
|
|
15
|
-
name: name,
|
|
16
|
-
expiration: expiration,
|
|
17
|
-
};
|
|
18
|
-
const addTokenRequest = axiosClient_1.client.post(`api/v1/users/addapitoken`, requestData, {
|
|
19
|
-
headers: { authorization: token },
|
|
20
|
-
});
|
|
21
|
-
addTokenRequest
|
|
22
|
-
.then((result) => {
|
|
23
|
-
if (result != null) {
|
|
24
|
-
resolve(result.data);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
reject(process.env.ERROR_INVALID_INFORMATION);
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
.catch((error) => {
|
|
31
|
-
reject(error);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Confirm email address
|
|
37
|
-
* @param {string} validationCode The code was provided to the user in advance by email
|
|
38
|
-
* @returns {Promise<void>}
|
|
39
|
-
*/
|
|
40
|
-
const confirmEmailAddress = (validationCode) => {
|
|
41
|
-
return new Promise((resolve, reject) => {
|
|
42
|
-
const requestData = {
|
|
43
|
-
validationCode: validationCode,
|
|
44
|
-
};
|
|
45
|
-
const confirmationRequest = axiosClient_1.client.post("api/v1/users/confirmEmail", requestData);
|
|
46
|
-
confirmationRequest
|
|
47
|
-
.then(() => {
|
|
48
|
-
resolve();
|
|
49
|
-
})
|
|
50
|
-
.catch((error) => {
|
|
51
|
-
reject(error);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Confirm phone number
|
|
57
|
-
* @param {string} validationCode The code was provided to the user in advance by email
|
|
58
|
-
* @param {string} token Authorization token
|
|
59
|
-
* @returns {Promise<object>}
|
|
60
|
-
*/
|
|
61
|
-
const confirmPhone = (validationCode, token) => {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
const requestData = {
|
|
64
|
-
validationCode: validationCode,
|
|
65
|
-
};
|
|
66
|
-
const confirmationRequest = axiosClient_1.client.post("api/v1/users/confirmPhone", requestData, {
|
|
67
|
-
headers: { authorization: token },
|
|
68
|
-
});
|
|
69
|
-
confirmationRequest
|
|
70
|
-
.then((response) => {
|
|
71
|
-
resolve(response.data);
|
|
72
|
-
})
|
|
73
|
-
.catch((error) => {
|
|
74
|
-
reject(error);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Generate confirmation code
|
|
80
|
-
* @param {string} phoneNumber Send confirmation code to the phone number
|
|
81
|
-
* @param {string} token Authorization token
|
|
82
|
-
* @returns {Promise<object>}
|
|
83
|
-
*/
|
|
84
|
-
const confirmPhoneGenerateCode = (phoneNumber, token) => {
|
|
85
|
-
return new Promise((resolve, reject) => {
|
|
86
|
-
const requestData = {
|
|
87
|
-
phoneNumber: phoneNumber,
|
|
88
|
-
};
|
|
89
|
-
const confirmationRequest = axiosClient_1.client.post("api/v1/users/confirmPhoneGenerateCode", requestData, {
|
|
90
|
-
headers: { authorization: token },
|
|
91
|
-
});
|
|
92
|
-
confirmationRequest
|
|
93
|
-
.then((response) => {
|
|
94
|
-
resolve(response.data);
|
|
95
|
-
})
|
|
96
|
-
.catch((error) => {
|
|
97
|
-
reject(error);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Create a new account (tenant). It returns a promise
|
|
103
|
-
* @param {string} email User's email address
|
|
104
|
-
* @param {string} firstName User's first name
|
|
105
|
-
* @param {string} lastName User's last name
|
|
106
|
-
* @param {string} password User's password
|
|
107
|
-
* @param {string} subSite Subsite where the new account will be created
|
|
108
|
-
* @param {string} inviteCode Invitation code received in advance from one of the account owners
|
|
109
|
-
* @returns {Promise<object>}
|
|
110
|
-
*/
|
|
111
|
-
const createAccount = (email, firstName, lastName, password, subSite, inviteCode) => {
|
|
112
|
-
return new Promise((resolve, reject) => {
|
|
113
|
-
if (email.trim() === "" ||
|
|
114
|
-
firstName.trim() === "" ||
|
|
115
|
-
lastName.trim() === "" ||
|
|
116
|
-
password.trim() === "" ||
|
|
117
|
-
subSite.trim() === "" ||
|
|
118
|
-
inviteCode.trim() === "") {
|
|
119
|
-
reject(process.env.ERROR_EMPTY_FIELDS);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const signupData = {
|
|
123
|
-
email: email,
|
|
124
|
-
firstName: firstName,
|
|
125
|
-
inviteCode: inviteCode,
|
|
126
|
-
lastName: lastName,
|
|
127
|
-
password: password,
|
|
128
|
-
subSite: subSite,
|
|
129
|
-
};
|
|
130
|
-
let request = axiosClient_1.client.post("api/v1/users/createAccount", signupData);
|
|
131
|
-
request
|
|
132
|
-
.then((result) => {
|
|
133
|
-
resolve(result.data.user);
|
|
134
|
-
})
|
|
135
|
-
.catch((error) => {
|
|
136
|
-
reject(error);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Create a new user account. It returns a promise
|
|
143
|
-
* @param {string} email User's email address
|
|
144
|
-
* @param {string} firstName User's first name
|
|
145
|
-
* @param {string} lastName User's last name
|
|
146
|
-
* @param {string} password User's password
|
|
147
|
-
* @param {string} token Invitation token provided to the user
|
|
148
|
-
* @returns {Promise<object>}
|
|
149
|
-
*/
|
|
150
|
-
const createUserAccount = (email, firstName, lastName, password, token) => {
|
|
151
|
-
return new Promise((resolve, reject) => {
|
|
152
|
-
if (email.trim() === "" ||
|
|
153
|
-
firstName.trim() === "" ||
|
|
154
|
-
lastName.trim() === "" ||
|
|
155
|
-
password.trim() === "" ||
|
|
156
|
-
token.trim() === "") {
|
|
157
|
-
reject(process.env.ERROR_EMPTY_FIELDS);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
const signupData = {
|
|
161
|
-
email: email,
|
|
162
|
-
firstName: firstName,
|
|
163
|
-
lastName: lastName,
|
|
164
|
-
password: password,
|
|
165
|
-
token: token,
|
|
166
|
-
};
|
|
167
|
-
let request = axiosClient_1.client.post("api/v1/users/createUser", signupData);
|
|
168
|
-
request
|
|
169
|
-
.then((result) => {
|
|
170
|
-
resolve(result.data.user);
|
|
171
|
-
})
|
|
172
|
-
.catch((error) => {
|
|
173
|
-
reject(error);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Delete an existing API token
|
|
180
|
-
* @param {string} token Expiration date of the token
|
|
181
|
-
* @param {string} authToken Authorization token
|
|
182
|
-
* @returns {Promise<string>}
|
|
183
|
-
*/
|
|
184
|
-
const deleteAPIToken = (token, authToken) => {
|
|
185
|
-
return new Promise((resolve, reject) => {
|
|
186
|
-
const deleteTokenRequest = axiosClient_1.client.delete(`api/v1/users/user/token`, {
|
|
187
|
-
headers: { authorization: authToken },
|
|
188
|
-
data: {
|
|
189
|
-
token: token,
|
|
190
|
-
},
|
|
191
|
-
});
|
|
192
|
-
deleteTokenRequest
|
|
193
|
-
.then(() => {
|
|
194
|
-
resolve(token);
|
|
195
|
-
})
|
|
196
|
-
.catch((error) => {
|
|
197
|
-
reject(error);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* Delete existing users
|
|
203
|
-
* @param {string[]} userIds The ID of the users to be deleted
|
|
204
|
-
* @param {string} token Authorization token
|
|
205
|
-
* @returns {Promise<object>}
|
|
206
|
-
*/
|
|
207
|
-
const deleteUsers = (userIds, token) => {
|
|
208
|
-
return new Promise((resolve, reject) => {
|
|
209
|
-
const deleteTokenRequest = axiosClient_1.client.delete(`api/v1/users/`, {
|
|
210
|
-
headers: { authorization: token },
|
|
211
|
-
data: {
|
|
212
|
-
userIds: userIds,
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
deleteTokenRequest
|
|
216
|
-
.then((response) => {
|
|
217
|
-
resolve(response.data);
|
|
218
|
-
})
|
|
219
|
-
.catch((error) => {
|
|
220
|
-
reject(error);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Get all the API tokens
|
|
226
|
-
* @param {string} token Authorization token
|
|
227
|
-
* @returns {Promise<object>}
|
|
228
|
-
*/
|
|
229
|
-
const getAPITokens = (token) => {
|
|
230
|
-
return new Promise((resolve, reject) => {
|
|
231
|
-
const getTokensRequest = axiosClient_1.client.get(`api/v1/users/getapitokens`, {
|
|
232
|
-
headers: { authorization: token },
|
|
233
|
-
});
|
|
234
|
-
getTokensRequest
|
|
235
|
-
.then((result) => {
|
|
236
|
-
resolve(result.data);
|
|
237
|
-
})
|
|
238
|
-
.catch((error) => {
|
|
239
|
-
reject(error);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
/**
|
|
244
|
-
* Get the specified user account by Id. It returns a promise
|
|
245
|
-
* @param {string} id Id of the user for which information is being requested
|
|
246
|
-
* @param {string} token Authorization token
|
|
247
|
-
* @returns {Promise<object>}
|
|
248
|
-
*/
|
|
249
|
-
const getUserById = (id, token) => {
|
|
250
|
-
return new Promise((resolve, reject) => {
|
|
251
|
-
const getUserInformationRequest = axiosClient_1.client.get(`api/v1/users/user/${id}`, {
|
|
252
|
-
headers: { authorization: token },
|
|
253
|
-
});
|
|
254
|
-
getUserInformationRequest
|
|
255
|
-
.then((result) => {
|
|
256
|
-
if (result != null) {
|
|
257
|
-
resolve(result.data.user);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
reject(process.env.ERROR_INVALID_INFORMATION);
|
|
261
|
-
}
|
|
262
|
-
})
|
|
263
|
-
.catch((error) => {
|
|
264
|
-
reject(error);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* Get user information
|
|
270
|
-
* @param {string} userId User Id
|
|
271
|
-
* @param {string} category User information category
|
|
272
|
-
* @param {string} token Authorization token
|
|
273
|
-
* @returns {Promise<object>}
|
|
274
|
-
*/
|
|
275
|
-
const getUserInformation = (userId, category, token) => {
|
|
276
|
-
return new Promise((resolve, reject) => {
|
|
277
|
-
let confirmationRequest = axiosClient_1.client.get(`api/v1/users/user/${userId || 0}/${category || "*"}`, {
|
|
278
|
-
headers: { authorization: token },
|
|
279
|
-
});
|
|
280
|
-
confirmationRequest
|
|
281
|
-
.then((response) => {
|
|
282
|
-
resolve(response.data);
|
|
283
|
-
})
|
|
284
|
-
.catch((error) => {
|
|
285
|
-
reject(error);
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Get the list of users
|
|
291
|
-
* @param {object} filter Filter to select the users. Ex: {firstName : "John"}
|
|
292
|
-
* @param {string[]} fields Fields to be loaded. Ex: ["firstName"]
|
|
293
|
-
* @param {string} token Authorization token
|
|
294
|
-
* @returns {Promise<object>}
|
|
295
|
-
*/
|
|
296
|
-
const getUsers = (filter, fields, token) => {
|
|
297
|
-
return new Promise((resolve, reject) => {
|
|
298
|
-
const requestData = {
|
|
299
|
-
filter: filter,
|
|
300
|
-
fields: fields,
|
|
301
|
-
};
|
|
302
|
-
let confirmationRequest = axiosClient_1.client.post(`api/v1/users/`, requestData, {
|
|
303
|
-
headers: { authorization: token },
|
|
304
|
-
});
|
|
305
|
-
confirmationRequest
|
|
306
|
-
.then((response) => {
|
|
307
|
-
resolve(response.data);
|
|
308
|
-
})
|
|
309
|
-
.catch((error) => {
|
|
310
|
-
reject(error);
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Invite other users to join the same account
|
|
316
|
-
* @param {string[]} invitees List of emails of the invitees
|
|
317
|
-
* @param {string} groupId The group the user should be added to
|
|
318
|
-
* @param {string} teamId The team the user should be added to
|
|
319
|
-
* @param {string} authToken Authorization token
|
|
320
|
-
* @returns {Promise<object>}
|
|
321
|
-
*/
|
|
322
|
-
const inviteUsers = (invitees, groupId, teamId, authToken) => {
|
|
323
|
-
return new Promise((resolve, reject) => {
|
|
324
|
-
const requestData = {
|
|
325
|
-
invitees: invitees,
|
|
326
|
-
groupId: groupId,
|
|
327
|
-
teamId: teamId,
|
|
328
|
-
token: authToken,
|
|
329
|
-
};
|
|
330
|
-
let request = axiosClient_1.client.post("api/v1/users/invite", requestData, {
|
|
331
|
-
headers: { authorization: authToken },
|
|
332
|
-
});
|
|
333
|
-
request
|
|
334
|
-
.then((response) => {
|
|
335
|
-
resolve(response.data);
|
|
336
|
-
})
|
|
337
|
-
.catch((error) => {
|
|
338
|
-
reject(error);
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
};
|
|
342
|
-
/**
|
|
343
|
-
* Login using email and password. It returns a promise
|
|
344
|
-
* @param {string} email User's email address
|
|
345
|
-
* @param {string} password User's password
|
|
346
|
-
* @returns {Promise<object>}
|
|
347
|
-
*/
|
|
348
|
-
const login = (email, password) => {
|
|
349
|
-
return new Promise((resolve, reject) => {
|
|
350
|
-
const requestData = {
|
|
351
|
-
email: email,
|
|
352
|
-
password: password,
|
|
353
|
-
};
|
|
354
|
-
let request = axiosClient_1.client.post("api/v1/auth/login", requestData);
|
|
355
|
-
request
|
|
356
|
-
.then((response) => {
|
|
357
|
-
resolve(response.data);
|
|
358
|
-
})
|
|
359
|
-
.catch((error) => {
|
|
360
|
-
reject(error);
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
};
|
|
364
|
-
/**
|
|
365
|
-
* Login callback after authentication to exchange the code token for authentication and refresh tokens
|
|
366
|
-
* @param {string} code
|
|
367
|
-
* @param {string} codeVerifier
|
|
368
|
-
* @param {string} redirectUri
|
|
369
|
-
* @returns {Promise<object>}
|
|
370
|
-
*/
|
|
371
|
-
const loginExchangeKeys = (code, codeVerifier, redirectUri) => {
|
|
372
|
-
return new Promise((resolve, reject) => {
|
|
373
|
-
const requestData = {
|
|
374
|
-
code: code,
|
|
375
|
-
codeVerifier: codeVerifier,
|
|
376
|
-
redirectUri: redirectUri,
|
|
377
|
-
};
|
|
378
|
-
let request = axiosClient_1.client.post("api/v1/auth/loginexchangekeys", requestData);
|
|
379
|
-
request
|
|
380
|
-
.then((response) => {
|
|
381
|
-
resolve(response.data);
|
|
382
|
-
})
|
|
383
|
-
.catch((error) => {
|
|
384
|
-
reject(error);
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
};
|
|
388
|
-
/**
|
|
389
|
-
* Logout from the server. It returns a promise
|
|
390
|
-
* @param {string} token Authorization token
|
|
391
|
-
* @returns {Promise<object>}
|
|
392
|
-
*/
|
|
393
|
-
const logout = (token) => {
|
|
394
|
-
return new Promise((resolve, reject) => {
|
|
395
|
-
let request = axiosClient_1.client.post("api/v1/auth/logout", {}, {
|
|
396
|
-
headers: { authorization: token },
|
|
397
|
-
});
|
|
398
|
-
request
|
|
399
|
-
.then((response) => {
|
|
400
|
-
resolve(response.data);
|
|
401
|
-
})
|
|
402
|
-
.catch((error) => {
|
|
403
|
-
reject(error);
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
|
-
/**
|
|
408
|
-
* Checks the current auth token and maintain it alive. It returns a promise. In case the token is invalid
|
|
409
|
-
* a new token can be restablished using login
|
|
410
|
-
* @param {string} refreshToken User's auth token to be refreshed
|
|
411
|
-
* @returns {Promise<object>}
|
|
412
|
-
*/
|
|
413
|
-
const refreshToken = (refreshToken) => {
|
|
414
|
-
return new Promise((resolve, reject) => {
|
|
415
|
-
let request = axiosClient_1.client.post("api/v1/auth/refreshToken", {
|
|
416
|
-
refreshToken: refreshToken,
|
|
417
|
-
});
|
|
418
|
-
request
|
|
419
|
-
.then((response) => {
|
|
420
|
-
resolve(response.data);
|
|
421
|
-
})
|
|
422
|
-
.catch((error) => {
|
|
423
|
-
reject(error);
|
|
424
|
-
});
|
|
425
|
-
});
|
|
426
|
-
};
|
|
427
|
-
/**
|
|
428
|
-
* Remove an existing API token
|
|
429
|
-
* @param {string} id The ID of the token to be removed
|
|
430
|
-
* @param {string} authToken Authorization token
|
|
431
|
-
* @returns {Promise<string>}
|
|
432
|
-
*/
|
|
433
|
-
const removeAPIToken = (id, authToken) => {
|
|
434
|
-
return new Promise((resolve, reject) => {
|
|
435
|
-
const requestData = {
|
|
436
|
-
id: id,
|
|
437
|
-
};
|
|
438
|
-
const removeTokenRequest = axiosClient_1.client.post(`api/v1/users/removeapitoken`, requestData, {
|
|
439
|
-
headers: { authorization: authToken },
|
|
440
|
-
});
|
|
441
|
-
removeTokenRequest
|
|
442
|
-
.then(() => {
|
|
443
|
-
resolve(id);
|
|
444
|
-
})
|
|
445
|
-
.catch((error) => {
|
|
446
|
-
reject(error);
|
|
447
|
-
});
|
|
448
|
-
});
|
|
449
|
-
};
|
|
450
|
-
/**
|
|
451
|
-
* Resend invitation emails
|
|
452
|
-
* @param {string[]} invitees List of emails of the invitees
|
|
453
|
-
* @param {string} authToken Authorization token
|
|
454
|
-
* @returns {Promise<object>}
|
|
455
|
-
*/
|
|
456
|
-
const resendInvitationEmails = (invitees, authToken) => {
|
|
457
|
-
return new Promise((resolve, reject) => {
|
|
458
|
-
const requestData = {
|
|
459
|
-
invitees: invitees,
|
|
460
|
-
token: authToken,
|
|
461
|
-
};
|
|
462
|
-
let request = axiosClient_1.client.post("api/v1/users/resendinvite", requestData, {
|
|
463
|
-
headers: { authorization: authToken },
|
|
464
|
-
});
|
|
465
|
-
request
|
|
466
|
-
.then((response) => {
|
|
467
|
-
resolve(response.data);
|
|
468
|
-
})
|
|
469
|
-
.catch((error) => {
|
|
470
|
-
reject(error);
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
/**
|
|
475
|
-
* Reset the password. It returns a promise
|
|
476
|
-
* @param {string} code Code provided to the user by email
|
|
477
|
-
* @param {string} email User's email address
|
|
478
|
-
* @param {string} password User's new password
|
|
479
|
-
* @returns {Promise<object>}
|
|
480
|
-
*/
|
|
481
|
-
const resetPassword = (email, code, password) => {
|
|
482
|
-
return new Promise((resolve, reject) => {
|
|
483
|
-
let postData = {
|
|
484
|
-
email: email,
|
|
485
|
-
code: code,
|
|
486
|
-
password: password,
|
|
487
|
-
};
|
|
488
|
-
let request = axiosClient_1.client.post("api/v1/users/resetpassword", postData);
|
|
489
|
-
request
|
|
490
|
-
.then((response) => {
|
|
491
|
-
resolve(response.data);
|
|
492
|
-
})
|
|
493
|
-
.catch((error) => {
|
|
494
|
-
reject(error);
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
};
|
|
498
|
-
/**
|
|
499
|
-
* Send email confirmation code
|
|
500
|
-
* @param {string} email
|
|
501
|
-
* @param {string} token
|
|
502
|
-
* @returns {Promise<object>}
|
|
503
|
-
*/
|
|
504
|
-
const sendEmailConfirmationCode = (email, token) => {
|
|
505
|
-
return new Promise((resolve, reject) => {
|
|
506
|
-
let postData = {
|
|
507
|
-
email: email,
|
|
508
|
-
};
|
|
509
|
-
let request = axiosClient_1.client.post("api/v1/users/sendemailconfirmationcode", postData, {
|
|
510
|
-
headers: { authorization: token },
|
|
511
|
-
});
|
|
512
|
-
request
|
|
513
|
-
.then((response) => {
|
|
514
|
-
resolve(response.data);
|
|
515
|
-
})
|
|
516
|
-
.catch((error) => {
|
|
517
|
-
reject(error);
|
|
518
|
-
});
|
|
519
|
-
});
|
|
520
|
-
};
|
|
521
|
-
/**
|
|
522
|
-
* Send an email to the user indicated by the email address to reset the password. It returns a promise
|
|
523
|
-
* @param {string} email Email of the user who needs to reset the password
|
|
524
|
-
* @returns {Promise<object>}
|
|
525
|
-
*/
|
|
526
|
-
const sendPasswordResetNotification = (email) => {
|
|
527
|
-
return new Promise((resolve, reject) => {
|
|
528
|
-
let postData = {
|
|
529
|
-
email: email,
|
|
530
|
-
};
|
|
531
|
-
let request = axiosClient_1.client.post("api/v1/users/sendpasswordresetnotification", postData);
|
|
532
|
-
request
|
|
533
|
-
.then((response) => {
|
|
534
|
-
resolve(response.data);
|
|
535
|
-
})
|
|
536
|
-
.catch((error) => {
|
|
537
|
-
reject(error);
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
/**
|
|
542
|
-
* Set user profile information
|
|
543
|
-
* @param {string} userId User Id
|
|
544
|
-
* @param {string} category User information category
|
|
545
|
-
* @param {object} data New or updated user data information
|
|
546
|
-
* @param {string} token Authorization token
|
|
547
|
-
* @returns {Promise<object>}
|
|
548
|
-
*/
|
|
549
|
-
const setUserInformation = (userId, category, data, token) => {
|
|
550
|
-
return new Promise((resolve, reject) => {
|
|
551
|
-
const requestData = {
|
|
552
|
-
data: category ? { [category]: data } : data,
|
|
553
|
-
userId: userId,
|
|
554
|
-
};
|
|
555
|
-
let confirmationRequest = axiosClient_1.client.post("api/v1/users/user", requestData, {
|
|
556
|
-
headers: { authorization: token },
|
|
557
|
-
});
|
|
558
|
-
confirmationRequest
|
|
559
|
-
.then((response) => {
|
|
560
|
-
resolve(response.data);
|
|
561
|
-
})
|
|
562
|
-
.catch((error) => {
|
|
563
|
-
reject(error);
|
|
564
|
-
});
|
|
565
|
-
});
|
|
566
|
-
};
|
|
567
|
-
/**
|
|
568
|
-
* Update user email
|
|
569
|
-
* @param {string} email The new email address
|
|
570
|
-
* @param {string} verificationCode The verification code
|
|
571
|
-
* @param {string} password The current password
|
|
572
|
-
* @param {string} token Authorization token
|
|
573
|
-
* @returns {Promise<object>}
|
|
574
|
-
*/
|
|
575
|
-
const updateUserEmail = (email, verificationCode, password, token) => {
|
|
576
|
-
return new Promise((resolve, reject) => {
|
|
577
|
-
const requestData = {
|
|
578
|
-
email: email,
|
|
579
|
-
verificationCode: verificationCode,
|
|
580
|
-
password: password,
|
|
581
|
-
};
|
|
582
|
-
let confirmationRequest = axiosClient_1.client.post("api/v1/users/updateemail", requestData, {
|
|
583
|
-
headers: { authorization: token },
|
|
584
|
-
});
|
|
585
|
-
confirmationRequest
|
|
586
|
-
.then((response) => {
|
|
587
|
-
resolve(response.data);
|
|
588
|
-
})
|
|
589
|
-
.catch((error) => {
|
|
590
|
-
reject(error);
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
};
|
|
594
|
-
/**
|
|
595
|
-
* Update user groups
|
|
596
|
-
* @param {String} userId The id of the user
|
|
597
|
-
* @param {Array<String>} groups The id of the groups the user should belong to
|
|
598
|
-
* @param {String} token Authorization token
|
|
599
|
-
* @returns {Promise<Object>}
|
|
600
|
-
*/
|
|
601
|
-
const updateUserGroups = (userId, groups, token) => {
|
|
602
|
-
return new Promise((resolve, reject) => {
|
|
603
|
-
const requestData = {
|
|
604
|
-
userId: userId,
|
|
605
|
-
groups: groups || [],
|
|
606
|
-
};
|
|
607
|
-
let confirmationRequest = axiosClient_1.client.post("api/v1/users/user/updategroups", requestData, {
|
|
608
|
-
headers: { authorization: token },
|
|
609
|
-
});
|
|
610
|
-
confirmationRequest
|
|
611
|
-
.then(() => {
|
|
612
|
-
resolve(requestData);
|
|
613
|
-
})
|
|
614
|
-
.catch((error) => {
|
|
615
|
-
reject(error);
|
|
616
|
-
});
|
|
617
|
-
});
|
|
618
|
-
};
|
|
619
|
-
/**
|
|
620
|
-
* Update user password
|
|
621
|
-
* @param {String} password The current password
|
|
622
|
-
* @param {String} newPassword The new password
|
|
623
|
-
* @param {String} token Authorization token
|
|
624
|
-
* @returns {Promise<Object>}
|
|
625
|
-
*/
|
|
626
|
-
const updateUserPassword = (password, newPassword, token) => {
|
|
627
|
-
return new Promise((resolve, reject) => {
|
|
628
|
-
const requestData = {
|
|
629
|
-
password: password,
|
|
630
|
-
newPassword: newPassword,
|
|
631
|
-
};
|
|
632
|
-
let confirmationRequest = axiosClient_1.client.post("api/v1/users/updatepassword", requestData, {
|
|
633
|
-
headers: { authorization: token },
|
|
634
|
-
});
|
|
635
|
-
confirmationRequest
|
|
636
|
-
.then((response) => {
|
|
637
|
-
resolve(response.data);
|
|
638
|
-
})
|
|
639
|
-
.catch((error) => {
|
|
640
|
-
reject(error);
|
|
641
|
-
});
|
|
642
|
-
});
|
|
643
|
-
};
|
|
644
|
-
/**
|
|
645
|
-
* Validate reset password code. It returns a promise
|
|
646
|
-
* @param {String} email User's email address
|
|
647
|
-
* @param {String} code Provided reset code
|
|
648
|
-
* @returns {Promise<Object>}
|
|
649
|
-
*/
|
|
650
|
-
const validateResetPasswordCode = (email, code) => {
|
|
651
|
-
return new Promise((resolve, reject) => {
|
|
652
|
-
let postData = {
|
|
653
|
-
email: email,
|
|
654
|
-
code: code,
|
|
655
|
-
};
|
|
656
|
-
let request = axiosClient_1.client.post("api/v1/users/validateresetpasswordcode", postData);
|
|
657
|
-
request
|
|
658
|
-
.then((response) => {
|
|
659
|
-
resolve(response.data);
|
|
660
|
-
})
|
|
661
|
-
.catch((error) => {
|
|
662
|
-
reject(error);
|
|
663
|
-
});
|
|
664
|
-
});
|
|
665
|
-
};
|
|
666
|
-
exports.default = {
|
|
667
|
-
addAPIToken,
|
|
668
|
-
confirmEmailAddress,
|
|
669
|
-
confirmPhone,
|
|
670
|
-
confirmPhoneGenerateCode,
|
|
671
|
-
createAccount,
|
|
672
|
-
createUserAccount,
|
|
673
|
-
deleteAPIToken,
|
|
674
|
-
deleteUsers,
|
|
675
|
-
getAPITokens,
|
|
676
|
-
getUserById,
|
|
677
|
-
getUserInformation,
|
|
678
|
-
getUsers,
|
|
679
|
-
inviteUsers,
|
|
680
|
-
login,
|
|
681
|
-
loginExchangeKeys,
|
|
682
|
-
logout,
|
|
683
|
-
refreshToken,
|
|
684
|
-
removeAPIToken,
|
|
685
|
-
resendInvitationEmails,
|
|
686
|
-
resetPassword,
|
|
687
|
-
sendEmailConfirmationCode,
|
|
688
|
-
sendPasswordResetNotification,
|
|
689
|
-
setUserInformation,
|
|
690
|
-
updateUserEmail,
|
|
691
|
-
updateUserGroups,
|
|
692
|
-
updateUserPassword,
|
|
693
|
-
validateResetPasswordCode,
|
|
694
|
-
};
|