@stackfactor/client-api 1.1.97 → 1.1.100

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/exports.js CHANGED
@@ -28,6 +28,7 @@ import logger from "./lib/logger.js";
28
28
  import microSkillsQuizes from "./lib/microSkillsQuizes.js";
29
29
  import role from "./lib/role.js";
30
30
  import roleTemplate from "./lib/roleTemplate.js";
31
+ import security from "./lib/security.js";
31
32
  import skill from "./lib/skill.js";
32
33
  import skillAssessment from "./lib/skillAssessments.js";
33
34
  import skillAssessmentTestingSession from "./lib/skillAssessmentTestingSession.js";
@@ -66,6 +67,7 @@ export {
66
67
  RESPONSE_TYPE,
67
68
  role,
68
69
  roleTemplate,
70
+ security,
69
71
  shouldReturnError,
70
72
  skill,
71
73
  skillAssessment,
@@ -0,0 +1,49 @@
1
+ import { client } from "./axiosClient.js";
2
+
3
+ /**
4
+ * Get the enabled authentication connections for current organization.
5
+ * @param {String} authToken - Authorization token
6
+ * @returns {Promise<Object>}
7
+ */
8
+ const getAuthConnection = (authToken) => {
9
+ return new Promise(function (resolve, reject) {
10
+ const getConfigInformationRequest = client.get(
11
+ `api/v1/security/getauthconnection`,
12
+ { headers: { authorization: authToken } }
13
+ );
14
+ getConfigInformationRequest
15
+ .then((response) => {
16
+ resolve(response.data);
17
+ })
18
+ .catch((error) => {
19
+ reject(error);
20
+ });
21
+ });
22
+ };
23
+
24
+ /**
25
+ * Set the enabled authentication connections for current organization.
26
+ * @param {Object} data - the object containing the updated configuration
27
+ * @param {String} authToken - Authorization token
28
+ */
29
+ const setAuthConnection = (data, authToken) => {
30
+ return new Promise(function (resolve, reject) {
31
+ const setConfigInformationRequest = client.post(
32
+ `api/v1/security/setauthconnection`,
33
+ { data: data },
34
+ { headers: { authorization: authToken } }
35
+ );
36
+ setConfigInformationRequest
37
+ .then((response) => {
38
+ resolve(response.data);
39
+ })
40
+ .catch((error) => {
41
+ reject(error);
42
+ });
43
+ });
44
+ };
45
+
46
+ export default {
47
+ getAuthConnection,
48
+ setAuthConnection,
49
+ };
package/lib/utils.js CHANGED
@@ -19,21 +19,25 @@ const objectToArray = (data) => {
19
19
  * @returns {String}
20
20
  */
21
21
  const getBaseUrl = () => {
22
- switch (process.env.REACT_APP_NODE_ENV) {
23
- case "development":
24
- case null:
25
- case undefined:
26
- return "https://localhost/";
27
- case "testing":
28
- return "https://qaapi.stackfactor.ai/";
29
- case "nonprod":
30
- return "https://apiqa.stackfactor.ai/";
31
- case "production":
32
- return "https://api.stackfactor.ai/";
33
- case "security":
34
- return "https://csapi.stackfactor.ai/";
35
- default:
36
- throw new Error("Invalid environment");
22
+ if (process.env.REACT_APP_BACKEND_URL) {
23
+ return process.env.REACT_APP_BACKEND_URL;
24
+ } else {
25
+ switch (process.env.REACT_APP_NODE_ENV) {
26
+ case "development":
27
+ case null:
28
+ case undefined:
29
+ return "https://localhost/";
30
+ case "testing":
31
+ return "https://qaapi.stackfactor.ai/";
32
+ case "nonprod":
33
+ return "https://apiqa.stackfactor.ai/";
34
+ case "production":
35
+ return "https://api.stackfactor.ai/";
36
+ case "security":
37
+ return "https://csapi.stackfactor.ai/";
38
+ default:
39
+ throw new Error("Invalid environment");
40
+ }
37
41
  }
38
42
  };
39
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.1.97",
3
+ "version": "1.1.100",
4
4
  "description": "Node.js library for the StackFactor API",
5
5
  "main": "index.js",
6
6
  "exports": {