@stackfactor/client-api 1.1.83 → 1.1.84

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} token The authentication token
5
+ * @param {String} authToken The authentication token
6
6
  */
7
- const getAllUserNotifications = (token) => {
7
+ const getAllUserNotifications = (authToken) => {
8
8
  return new Promise(function (resolve, reject) {
9
9
  const request = client.get(`api/v1/actionnotifications`, {
10
- headers: { authorization: token },
10
+ headers: { authorization: authToken },
11
11
  });
12
12
  request
13
13
  .then((response) => {
@@ -1,12 +1,15 @@
1
1
  import axios from "axios";
2
2
  import { RESPONSE_TYPE } from "./constants.js";
3
+ import https from "https";
3
4
  import utils from "./utils.js";
4
5
 
5
6
  const baseUrl = utils.getBaseUrl();
6
7
 
7
8
  const client = axios.create({
8
9
  baseURL: baseUrl,
9
- withCredentials: true,
10
+ httpsAgent: new https.Agent({
11
+ rejectUnauthorized: false,
12
+ }),
10
13
  });
11
14
 
12
15
  /**
package/lib/constants.js CHANGED
@@ -98,6 +98,7 @@ 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",
101
102
  };
102
103
 
103
104
  const PERMISSION_DESCRIPTIONS = {
@@ -121,6 +122,8 @@ const PERMISSION_DESCRIPTIONS = {
121
122
  "5dd61314afc2455a89b1a37b": "Manage teams",
122
123
  "5dd612e40f0bc559c41a2b29": "Manage users",
123
124
  "5fac2126427ce31f8a92c0cb": "Promote content",
125
+ "66de32d41b5a76fbba015702":
126
+ "Allows users to view the skill assessments of their peers",
124
127
  };
125
128
 
126
129
  export {
package/lib/dashboard.js CHANGED
@@ -56,7 +56,6 @@ 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
-
60
59
  data: {
61
60
  id: id,
62
61
  },
@@ -47,7 +47,6 @@ 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
-
51
50
  data: {
52
51
  id: id,
53
52
  },
@@ -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,8 +193,7 @@ export const getContentInformationByUrlFromBrowser = (url) => {
193
193
 
194
194
  let document = htmlParser.parse(response.responseText);
195
195
  let duration = getReadingTime(htmlToText(response.responseText));
196
- let titleTag = document.querySelector("title");
197
- let title = titleTag ? titleTag.rawText : "";
196
+ let title = document.querySelector("title")?.rawText;
198
197
  let description = "";
199
198
  const descriptionEl = document.querySelector("meta");
200
199
  try {
@@ -43,7 +43,6 @@ 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
-
47
46
  data: data,
48
47
  });
49
48
  request
@@ -67,7 +66,6 @@ const discardLearningContentChanges = (id, token) => {
67
66
  const data = {};
68
67
  const request = client.get(`api/v1/learningcontent/discard/${id}`, {
69
68
  headers: { authorization: token },
70
-
71
69
  data: data,
72
70
  });
73
71
  request
@@ -38,7 +38,6 @@ 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
-
42
41
  data: data,
43
42
  });
44
43
  request
@@ -61,7 +60,6 @@ const discardLearningPathChanges = (id, token) => {
61
60
  const data = {};
62
61
  const request = client.get(`api/v1/learningpaths/discard/${id}`, {
63
62
  headers: { authorization: token },
64
-
65
63
  data: data,
66
64
  });
67
65
  request
package/lib/role.js CHANGED
@@ -70,7 +70,6 @@ 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
-
74
73
  data: data,
75
74
  });
76
75
  request
@@ -94,7 +93,6 @@ const discardRoleChanges = (id, token) => {
94
93
  const data = {};
95
94
  const request = client.get(`api/v1/roles/discard/${id}`, {
96
95
  headers: { authorization: token },
97
-
98
96
  data: data,
99
97
  });
100
98
  request
@@ -37,7 +37,6 @@ 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
-
41
40
  data: data,
42
41
  });
43
42
  request
@@ -60,7 +59,6 @@ const discardRoleTemplateChanges = (id, token) => {
60
59
  const data = {};
61
60
  const request = client.get(`api/v1/roletemplates/discard/${id}`, {
62
61
  headers: { authorization: token },
63
-
64
62
  data: data,
65
63
  });
66
64
  request
package/lib/skill.js CHANGED
@@ -68,7 +68,6 @@ 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
-
72
71
  data: data,
73
72
  });
74
73
  request
@@ -92,7 +91,6 @@ const discardSkillChanges = (id, token) => {
92
91
  const data = {};
93
92
  const request = client.get(`api/v1/skills/discard/${id}`, {
94
93
  headers: { authorization: token },
95
-
96
94
  data: data,
97
95
  });
98
96
  request
@@ -76,7 +76,6 @@ 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
-
80
79
  data: data,
81
80
  });
82
81
  request
@@ -37,7 +37,6 @@ 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
-
41
40
  data: data,
42
41
  });
43
42
  request
@@ -60,7 +59,6 @@ const discardSkillTemplateChanges = (id, token) => {
60
59
  const data = {};
61
60
  const request = client.get(`api/v1/skilltemplates/discard/${id}`, {
62
61
  headers: { authorization: token },
63
-
64
62
  data: data,
65
63
  });
66
64
  request
package/lib/teams.js CHANGED
@@ -64,7 +64,6 @@ 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
-
68
67
  data: {
69
68
  id: teamId,
70
69
  defaultTeamId: defaultTeamId,
@@ -63,7 +63,6 @@ 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
-
67
66
  data: data,
68
67
  });
69
68
  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} token Authorization token
7
+ * @param {String} authToken Authorization token
8
8
  */
9
- const addAPIToken = (name, expiration, token) => {
9
+ const addAPIToken = (name, expiration, authToken) => {
10
10
  return new Promise(function (resolve, reject) {
11
11
  const requestData = {
12
12
  name: name,
@@ -16,7 +16,7 @@ const addAPIToken = (name, expiration, token) => {
16
16
  `api/v1/users/addapitoken`,
17
17
  requestData,
18
18
  {
19
- headers: { authorization: token },
19
+ headers: { authorization: authToken },
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} token Authorization token
62
+ * @param {String} authToken Authorization token
63
63
  */
64
- const confirmPhone = (validationCode, token) => {
64
+ const confirmPhone = (validationCode, authToken) => {
65
65
  return new Promise(function (resolve, reject) {
66
66
  const requestData = {
67
67
  validationCode: validationCode,
@@ -70,7 +70,7 @@ const confirmPhone = (validationCode, token) => {
70
70
  "api/v1/users/confirmPhone",
71
71
  requestData,
72
72
  {
73
- headers: { authorization: token },
73
+ headers: { authorization: authToken },
74
74
  }
75
75
  );
76
76
  confirmationRequest
@@ -86,9 +86,9 @@ const confirmPhone = (validationCode, token) => {
86
86
  /**
87
87
  * Generate confirmation code
88
88
  * @param {String} phoneNumber Send confirmation code to the phone number
89
- * @param {String} token Authorization token
89
+ * @param {String} authToken Authorization token
90
90
  */
91
- const confirmPhoneGenerateCode = (phoneNumber, token) => {
91
+ const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
92
92
  return new Promise(function (resolve, reject) {
93
93
  const requestData = {
94
94
  phoneNumber: phoneNumber,
@@ -97,7 +97,7 @@ const confirmPhoneGenerateCode = (phoneNumber, token) => {
97
97
  "api/v1/users/confirmPhoneGenerateCode",
98
98
  requestData,
99
99
  {
100
- headers: { authorization: token },
100
+ headers: { authorization: authToken },
101
101
  }
102
102
  );
103
103
  confirmationRequest
@@ -206,7 +206,6 @@ 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
-
210
209
  data: {
211
210
  token: token,
212
211
  },
@@ -224,13 +223,12 @@ const deleteAPIToken = (token, authToken) => {
224
223
  /**
225
224
  * Delete existing users
226
225
  * @param {Array<String>} userIds The ID of the users to be deleted
227
- * @param {String} token Authorization token
226
+ * @param {String} authToken Authorization token
228
227
  */
229
- const deleteUsers = (userIds, token) => {
228
+ const deleteUsers = (userIds, authToken) => {
230
229
  return new Promise(function (resolve, reject) {
231
230
  const deleteTokenRequest = client.delete(`api/v1/users/`, {
232
- headers: { authorization: token },
233
-
231
+ headers: { authorization: authToken },
234
232
  data: {
235
233
  userIds: userIds,
236
234
  },
@@ -247,12 +245,12 @@ const deleteUsers = (userIds, token) => {
247
245
 
248
246
  /**
249
247
  * Get all the API tokens
250
- * @param {String} token Authorization token
248
+ * @param {String} authToken Authorization token
251
249
  */
252
- const getAPITokens = (token) => {
250
+ const getAPITokens = (authToken) => {
253
251
  return new Promise(function (resolve, reject) {
254
252
  const getTokensRequest = client.get(`api/v1/users/getapitokens`, {
255
- headers: { authorization: token },
253
+ headers: { authorization: authToken },
256
254
  });
257
255
  getTokensRequest
258
256
  .then((result) => {
@@ -267,13 +265,10 @@ const getAPITokens = (token) => {
267
265
  /**
268
266
  * Get the specified user account by Id. It returns a promise
269
267
  * @param {String} id Id of the user for which information is being requested
270
- * @param {String} token Authorization token
271
268
  */
272
- const getUserById = (id, token) => {
269
+ const getUserById = (id) => {
273
270
  return new Promise(function (resolve, reject) {
274
- const getUserInformationRequest = client.get(`api/v1/users/user/${id}`, {
275
- headers: { authorization: token },
276
- });
271
+ const getUserInformationRequest = client.get(`api/v1/users/user/${id}`);
277
272
  getUserInformationRequest
278
273
  .then((result) => {
279
274
  if (result != null) {
@@ -391,13 +386,14 @@ const login = (email, password, rememberMe) => {
391
386
 
392
387
  /**
393
388
  * Logout from the server. It returns a promise
394
- * @param {String} refreshToken Authorization token
389
+ * @param {String} token Authorization token
395
390
  */
396
- const logout = (refreshToken) => {
391
+ const logout = (token) => {
397
392
  return new Promise(function (resolve, reject) {
398
- let request = client.post("api/v1/auth/logout", {
399
- refreshToken,
400
- });
393
+ const options = {
394
+ headers: { authorization: token },
395
+ };
396
+ let request = client.post("api/v1/auth/logout", {}, options);
401
397
  request
402
398
  .then((response) => {
403
399
  resolve(response.data);
@@ -413,9 +409,10 @@ const logout = (refreshToken) => {
413
409
  * a new token can be restablished using login
414
410
  * @param {String} token User's auth token to be refreshed
415
411
  */
416
- const refreshToken = (refreshToken) => {
412
+ const refreshToken = (token) => {
417
413
  return new Promise(function (resolve, reject) {
418
- let request = client.post("api/v1/auth/refreshToken", { refreshToken });
414
+ let options = { headers: { Authorization: token } };
415
+ let request = client.post("api/v1/auth/refreshToken", {}, options);
419
416
  request
420
417
  .then((response) => {
421
418
  resolve(response.data);
package/lib/utils.js CHANGED
@@ -23,13 +23,11 @@ const getBaseUrl = () => {
23
23
  case "development":
24
24
  case null:
25
25
  case undefined:
26
- return "https://localhost/";
26
+ return "http://localhost:3100/";
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/";
33
31
  default:
34
32
  throw new Error("Invalid environment");
35
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.1.83",
3
+ "version": "1.1.84",
4
4
  "description": "Node.js library for the StackFactor API",
5
5
  "main": "index.js",
6
6
  "exports": {