@stackfactor/client-api 1.1.84 → 1.1.86

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.
@@ -2,12 +2,12 @@ import { client } from "./axiosClient.js";
2
2
 
3
3
  /**
4
4
  * Get all permissions
5
- * @param {String} authToken The authentication token
5
+ * @param {String} token The authentication token
6
6
  */
7
- const getAllUserNotifications = (authToken) => {
7
+ const getAllUserNotifications = (token) => {
8
8
  return new Promise(function (resolve, reject) {
9
9
  const request = client.get(`api/v1/actionnotifications`, {
10
- headers: { authorization: authToken },
10
+ headers: { authorization: token },
11
11
  });
12
12
  request
13
13
  .then((response) => {
@@ -1,15 +1,12 @@
1
1
  import axios from "axios";
2
2
  import { RESPONSE_TYPE } from "./constants.js";
3
- import https from "https";
4
3
  import utils from "./utils.js";
5
4
 
6
5
  const baseUrl = utils.getBaseUrl();
7
6
 
8
7
  const client = axios.create({
9
8
  baseURL: baseUrl,
10
- httpsAgent: new https.Agent({
11
- rejectUnauthorized: false,
12
- }),
9
+ withCredentials: true,
13
10
  });
14
11
 
15
12
  /**
package/lib/constants.js CHANGED
@@ -98,7 +98,6 @@ const PERMISSIONS = {
98
98
  PROMOTE_CONTENT: "5fac2126427ce31f8a92c0cb",
99
99
  TALENT_TRANSFORMATION_CHAMPION: "5fac210f7e6539d37a897c95",
100
100
  TALENT_TRANSFORMATION_CHAMPION_ADMIN: "5fac2112b7e49e10c779b4a6",
101
- VIEW_PEERS_SKILL_ASSESSMENTS: "66de32d41b5a76fbba015702",
102
101
  };
103
102
 
104
103
  const PERMISSION_DESCRIPTIONS = {
@@ -122,8 +121,6 @@ const PERMISSION_DESCRIPTIONS = {
122
121
  "5dd61314afc2455a89b1a37b": "Manage teams",
123
122
  "5dd612e40f0bc559c41a2b29": "Manage users",
124
123
  "5fac2126427ce31f8a92c0cb": "Promote content",
125
- "66de32d41b5a76fbba015702":
126
- "Allows users to view the skill assessments of their peers",
127
124
  };
128
125
 
129
126
  export {
package/lib/dashboard.js CHANGED
@@ -56,6 +56,7 @@ const removeCardFromDashboard = (id, authToken) => {
56
56
  return new Promise(function (resolve, reject) {
57
57
  const request = client.delete(`/api/v1/dashboard/card`, {
58
58
  headers: { authorization: authToken },
59
+
59
60
  data: {
60
61
  id: id,
61
62
  },
@@ -47,6 +47,7 @@ const deleteDepartmentTrainingPlan = (id, token) => {
47
47
  return new Promise(function (resolve, reject) {
48
48
  const request = client.delete(`api/v1/departmenttrainingplans/`, {
49
49
  headers: { authorization: token },
50
+
50
51
  data: {
51
52
  id: id,
52
53
  },
@@ -175,7 +175,7 @@ export const getContentInformationByUrlFromBrowser = (url) => {
175
175
  "Access-Control-Allow-Origin": "*",
176
176
  "Access-Control-Allow-Headers":
177
177
  "Authorization, Origin, X-Requested-With, Content-Type, Accept",
178
- Accept:
178
+ "Accept":
179
179
  "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
180
180
  "Accept-Encoding": "gzip, deflate, br",
181
181
  "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
@@ -193,7 +193,8 @@ export const getContentInformationByUrlFromBrowser = (url) => {
193
193
 
194
194
  let document = htmlParser.parse(response.responseText);
195
195
  let duration = getReadingTime(htmlToText(response.responseText));
196
- let title = document.querySelector("title")?.rawText;
196
+ let titleTag = document.querySelector("title");
197
+ let title = titleTag ? titleTag.rawText : "";
197
198
  let description = "";
198
199
  const descriptionEl = document.querySelector("meta");
199
200
  try {
@@ -43,6 +43,7 @@ const deleteLearningContent = (id, comments, token) => {
43
43
  return new Promise(function (resolve, reject) {
44
44
  const request = client.delete(`api/v1/learningcontent/`, {
45
45
  headers: { authorization: token },
46
+
46
47
  data: data,
47
48
  });
48
49
  request
@@ -66,6 +67,7 @@ const discardLearningContentChanges = (id, token) => {
66
67
  const data = {};
67
68
  const request = client.get(`api/v1/learningcontent/discard/${id}`, {
68
69
  headers: { authorization: token },
70
+
69
71
  data: data,
70
72
  });
71
73
  request
@@ -38,6 +38,7 @@ const deleteLearningPath = (id, comments, token) => {
38
38
  if (comments) data.comments = comments;
39
39
  const request = client.delete(`api/v1/learningpaths/`, {
40
40
  headers: { authorization: token },
41
+
41
42
  data: data,
42
43
  });
43
44
  request
@@ -60,6 +61,7 @@ const discardLearningPathChanges = (id, token) => {
60
61
  const data = {};
61
62
  const request = client.get(`api/v1/learningpaths/discard/${id}`, {
62
63
  headers: { authorization: token },
64
+
63
65
  data: data,
64
66
  });
65
67
  request
package/lib/role.js CHANGED
@@ -70,6 +70,7 @@ const deleteRole = (id, comments, token) => {
70
70
  if (comments) data.comments = comments;
71
71
  const request = client.delete(`api/v1/roles/`, {
72
72
  headers: { authorization: token },
73
+
73
74
  data: data,
74
75
  });
75
76
  request
@@ -93,6 +94,7 @@ const discardRoleChanges = (id, token) => {
93
94
  const data = {};
94
95
  const request = client.get(`api/v1/roles/discard/${id}`, {
95
96
  headers: { authorization: token },
97
+
96
98
  data: data,
97
99
  });
98
100
  request
@@ -37,6 +37,7 @@ const deleteRoleTemplate = (id, comments, token) => {
37
37
  if (comments) data.comments = comments;
38
38
  const request = client.delete(`api/v1/roletemplates/`, {
39
39
  headers: { authorization: token },
40
+
40
41
  data: data,
41
42
  });
42
43
  request
@@ -59,6 +60,7 @@ const discardRoleTemplateChanges = (id, token) => {
59
60
  const data = {};
60
61
  const request = client.get(`api/v1/roletemplates/discard/${id}`, {
61
62
  headers: { authorization: token },
63
+
62
64
  data: data,
63
65
  });
64
66
  request
package/lib/skill.js CHANGED
@@ -68,6 +68,7 @@ const deleteSkill = (id, comments, token) => {
68
68
  if (comments) data.comments = comments;
69
69
  const request = client.delete(`api/v1/skills/`, {
70
70
  headers: { authorization: token },
71
+
71
72
  data: data,
72
73
  });
73
74
  request
@@ -91,6 +92,7 @@ const discardSkillChanges = (id, token) => {
91
92
  const data = {};
92
93
  const request = client.get(`api/v1/skills/discard/${id}`, {
93
94
  headers: { authorization: token },
95
+
94
96
  data: data,
95
97
  });
96
98
  request
@@ -76,6 +76,7 @@ const deleteSkillAssessment = (id, comments, token) => {
76
76
  if (comments) data.comments = comments;
77
77
  const request = client.delete(`api/v1/skillassessments`, {
78
78
  headers: { authorization: token },
79
+
79
80
  data: data,
80
81
  });
81
82
  request
@@ -37,6 +37,7 @@ const deleteSkillTemplate = (id, comments, token) => {
37
37
  return new Promise(function (resolve, reject) {
38
38
  const request = client.delete(`api/v1/skilltemplates/`, {
39
39
  headers: { authorization: token },
40
+
40
41
  data: data,
41
42
  });
42
43
  request
@@ -59,6 +60,7 @@ const discardSkillTemplateChanges = (id, token) => {
59
60
  const data = {};
60
61
  const request = client.get(`api/v1/skilltemplates/discard/${id}`, {
61
62
  headers: { authorization: token },
63
+
62
64
  data: data,
63
65
  });
64
66
  request
package/lib/teams.js CHANGED
@@ -64,6 +64,7 @@ const deleteTeam = (teamId, defaultTeamId, authToken) => {
64
64
  return new Promise(function (resolve, reject) {
65
65
  const request = client.delete(`api/v1/teams/delete`, {
66
66
  headers: { authorization: authToken },
67
+
67
68
  data: {
68
69
  id: teamId,
69
70
  defaultTeamId: defaultTeamId,
@@ -63,6 +63,7 @@ const deleteTrainingPlan = (id, comments, token) => {
63
63
  if (comments) data.comments = comments;
64
64
  const request = client.delete(`api/v1/trainingplans/`, {
65
65
  headers: { authorization: token },
66
+
66
67
  data: data,
67
68
  });
68
69
  request
package/lib/users.js CHANGED
@@ -4,9 +4,9 @@ import { client } from "./axiosClient.js";
4
4
  /**
5
5
  * Add a new API Token
6
6
  * @param {Date} expiration Expiration date of the token
7
- * @param {String} authToken Authorization token
7
+ * @param {String} token Authorization token
8
8
  */
9
- const addAPIToken = (name, expiration, authToken) => {
9
+ const addAPIToken = (name, expiration, token) => {
10
10
  return new Promise(function (resolve, reject) {
11
11
  const requestData = {
12
12
  name: name,
@@ -16,7 +16,7 @@ const addAPIToken = (name, expiration, authToken) => {
16
16
  `api/v1/users/addapitoken`,
17
17
  requestData,
18
18
  {
19
- headers: { authorization: authToken },
19
+ headers: { authorization: token },
20
20
  }
21
21
  );
22
22
  addTokenRequest
@@ -59,9 +59,9 @@ const confirmEmailAddress = (validationCode) => {
59
59
  /**
60
60
  * Confirm phone number
61
61
  * @param {String} validationCode The code was provided to the user in advance by email
62
- * @param {String} authToken Authorization token
62
+ * @param {String} token Authorization token
63
63
  */
64
- const confirmPhone = (validationCode, authToken) => {
64
+ const confirmPhone = (validationCode, token) => {
65
65
  return new Promise(function (resolve, reject) {
66
66
  const requestData = {
67
67
  validationCode: validationCode,
@@ -70,7 +70,7 @@ const confirmPhone = (validationCode, authToken) => {
70
70
  "api/v1/users/confirmPhone",
71
71
  requestData,
72
72
  {
73
- headers: { authorization: authToken },
73
+ headers: { authorization: token },
74
74
  }
75
75
  );
76
76
  confirmationRequest
@@ -86,9 +86,9 @@ const confirmPhone = (validationCode, authToken) => {
86
86
  /**
87
87
  * Generate confirmation code
88
88
  * @param {String} phoneNumber Send confirmation code to the phone number
89
- * @param {String} authToken Authorization token
89
+ * @param {String} token Authorization token
90
90
  */
91
- const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
91
+ const confirmPhoneGenerateCode = (phoneNumber, token) => {
92
92
  return new Promise(function (resolve, reject) {
93
93
  const requestData = {
94
94
  phoneNumber: phoneNumber,
@@ -97,7 +97,7 @@ const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
97
97
  "api/v1/users/confirmPhoneGenerateCode",
98
98
  requestData,
99
99
  {
100
- headers: { authorization: authToken },
100
+ headers: { authorization: token },
101
101
  }
102
102
  );
103
103
  confirmationRequest
@@ -206,6 +206,7 @@ const deleteAPIToken = (token, authToken) => {
206
206
  return new Promise(function (resolve, reject) {
207
207
  const deleteTokenRequest = client.delete(`api/v1/users/user/token`, {
208
208
  headers: { authorization: authToken },
209
+
209
210
  data: {
210
211
  token: token,
211
212
  },
@@ -223,12 +224,13 @@ const deleteAPIToken = (token, authToken) => {
223
224
  /**
224
225
  * Delete existing users
225
226
  * @param {Array<String>} userIds The ID of the users to be deleted
226
- * @param {String} authToken Authorization token
227
+ * @param {String} token Authorization token
227
228
  */
228
- const deleteUsers = (userIds, authToken) => {
229
+ const deleteUsers = (userIds, token) => {
229
230
  return new Promise(function (resolve, reject) {
230
231
  const deleteTokenRequest = client.delete(`api/v1/users/`, {
231
- headers: { authorization: authToken },
232
+ headers: { authorization: token },
233
+
232
234
  data: {
233
235
  userIds: userIds,
234
236
  },
@@ -245,12 +247,12 @@ const deleteUsers = (userIds, authToken) => {
245
247
 
246
248
  /**
247
249
  * Get all the API tokens
248
- * @param {String} authToken Authorization token
250
+ * @param {String} token Authorization token
249
251
  */
250
- const getAPITokens = (authToken) => {
252
+ const getAPITokens = (token) => {
251
253
  return new Promise(function (resolve, reject) {
252
254
  const getTokensRequest = client.get(`api/v1/users/getapitokens`, {
253
- headers: { authorization: authToken },
255
+ headers: { authorization: token },
254
256
  });
255
257
  getTokensRequest
256
258
  .then((result) => {
@@ -265,10 +267,13 @@ const getAPITokens = (authToken) => {
265
267
  /**
266
268
  * Get the specified user account by Id. It returns a promise
267
269
  * @param {String} id Id of the user for which information is being requested
270
+ * @param {String} token Authorization token
268
271
  */
269
- const getUserById = (id) => {
272
+ const getUserById = (id, token) => {
270
273
  return new Promise(function (resolve, reject) {
271
- const getUserInformationRequest = client.get(`api/v1/users/user/${id}`);
274
+ const getUserInformationRequest = client.get(`api/v1/users/user/${id}`, {
275
+ headers: { authorization: token },
276
+ });
272
277
  getUserInformationRequest
273
278
  .then((result) => {
274
279
  if (result != null) {
@@ -364,14 +369,12 @@ const inviteUsers = (invitees, groupId, teamId, authToken) => {
364
369
  * Login using email and password. It returns a promise
365
370
  * @param {String} email User's email address
366
371
  * @param {String} password User's password
367
- * @param {boolean} rememberMe Set to true if the user wants his account to be saved on the current machine
368
372
  */
369
- const login = (email, password, rememberMe) => {
373
+ const login = (email, password) => {
370
374
  return new Promise(function (resolve, reject) {
371
375
  const requestData = {
372
376
  email: email,
373
377
  password: password,
374
- rememberMe: rememberMe,
375
378
  };
376
379
  let request = client.post("api/v1/auth/login", requestData);
377
380
  request
@@ -386,14 +389,13 @@ const login = (email, password, rememberMe) => {
386
389
 
387
390
  /**
388
391
  * Logout from the server. It returns a promise
389
- * @param {String} token Authorization token
392
+ * @param {String} refreshToken Authorization token
390
393
  */
391
- const logout = (token) => {
394
+ const logout = (refreshToken) => {
392
395
  return new Promise(function (resolve, reject) {
393
- const options = {
394
- headers: { authorization: token },
395
- };
396
- let request = client.post("api/v1/auth/logout", {}, options);
396
+ let request = client.post("api/v1/auth/logout", {
397
+ refreshToken,
398
+ });
397
399
  request
398
400
  .then((response) => {
399
401
  resolve(response.data);
@@ -409,10 +411,11 @@ const logout = (token) => {
409
411
  * a new token can be restablished using login
410
412
  * @param {String} token User's auth token to be refreshed
411
413
  */
412
- const refreshToken = (token) => {
414
+ const refreshToken = (refreshToken) => {
413
415
  return new Promise(function (resolve, reject) {
414
- let options = { headers: { Authorization: token } };
415
- let request = client.post("api/v1/auth/refreshToken", {}, options);
416
+ let request = client.post("api/v1/auth/refreshToken", {
417
+ refreshToken: refreshToken,
418
+ });
416
419
  request
417
420
  .then((response) => {
418
421
  resolve(response.data);
package/lib/utils.js CHANGED
@@ -23,11 +23,13 @@ const getBaseUrl = () => {
23
23
  case "development":
24
24
  case null:
25
25
  case undefined:
26
- return "http://localhost:3100/";
26
+ return "https://localhost/";
27
27
  case "testing":
28
28
  return "https://qaapi.stackfactor.ai/";
29
29
  case "production":
30
30
  return "https://api.stackfactor.ai/";
31
+ case "security":
32
+ return "https://csapi.stackfactor.ai/";
31
33
  default:
32
34
  throw new Error("Invalid environment");
33
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.1.84",
3
+ "version": "1.1.86",
4
4
  "description": "Node.js library for the StackFactor API",
5
5
  "main": "index.js",
6
6
  "exports": {