@stackfactor/client-api 1.1.12-9.2 → 1.1.12
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.ts → exports.js} +0 -14
- package/index.js +3 -0
- package/lib/{actionNotifications.ts → actionNotifications.js} +11 -21
- package/lib/{address.ts → address.js} +5 -4
- package/lib/axiosClient.js +85 -0
- package/lib/{config.ts → config.js} +9 -20
- package/lib/{constants.ts → constants.js} +41 -11
- package/lib/{dashboard.ts → dashboard.js} +10 -19
- package/lib/{departmentTrainingPlans.ts → departmentTrainingPlans.js} +32 -63
- package/lib/{groups.ts → groups.js} +29 -68
- package/lib/{integration.ts → integration.js} +47 -103
- package/lib/{integrationConfiguration.ts → integrationConfiguration.js} +22 -27
- package/lib/integrations/{contentGenerator.ts → contentGenerator.js} +18 -38
- package/lib/{learningContent.ts → learningContent.js} +62 -218
- package/lib/{learningPath.ts → learningPath.js} +30 -57
- package/lib/{logger.ts → logger.js} +8 -18
- package/lib/{role.ts → role.js} +69 -117
- package/lib/{roleTemplate.ts → roleTemplate.js} +30 -65
- package/lib/{skill.ts → skill.js} +87 -125
- package/lib/skillAssessmentTestingSession.js +148 -0
- package/lib/{skillAssessments.ts → skillAssessments.js} +16 -63
- package/lib/{skillTemplate.ts → skillTemplate.js} +42 -73
- package/lib/{teams.ts → teams.js} +38 -73
- package/lib/{tenants.ts → tenants.js} +10 -17
- package/lib/{trainingPlans.ts → trainingPlans.js} +56 -159
- package/lib/{userInformation.ts → userInformation.js} +26 -27
- package/lib/{users.ts → users.js} +140 -239
- package/lib/utils.js +48 -0
- package/package.json +1 -12
- package/.eslintrc.json +0 -13
- package/index.ts +0 -1
- package/lib/aiAssistant.ts +0 -197
- package/lib/avatar.ts +0 -41
- package/lib/axiosClient.ts +0 -92
- package/lib/microSkillsQuizes.ts +0 -70
- package/lib/quotas.ts +0 -59
- package/lib/security.ts +0 -99
- package/lib/skillAssessmentTestingSession.ts +0 -192
- package/lib/talentTransfromation.ts +0 -126
- package/lib/trainingPlansProficiencyLevels.ts +0 -132
- package/lib/utils.ts +0 -64
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackfactor/client-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Node.js library for the StackFactor API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -12,11 +12,6 @@
|
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "npm run build:esm && npm run build:cjs",
|
|
16
|
-
"build:esm": "tsc --project tsconfig.esm.json",
|
|
17
|
-
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
18
|
-
"build:watch": "tsc --watch",
|
|
19
|
-
"lint": "eslint lib/**/*.js",
|
|
20
15
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
21
16
|
},
|
|
22
17
|
"repository": {
|
|
@@ -35,11 +30,5 @@
|
|
|
35
30
|
"html2plaintext": "^2.1.4",
|
|
36
31
|
"https": "^1.0.0",
|
|
37
32
|
"node-html-parser": "^6.1.5"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/axios": "^0.14.4",
|
|
41
|
-
"@types/node": "^22.13.5",
|
|
42
|
-
"eslint": "^8.57.0",
|
|
43
|
-
"eslint-plugin-react": "^7.34.0"
|
|
44
33
|
}
|
|
45
34
|
}
|
package/.eslintrc.json
DELETED
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./exports.js";
|
package/lib/aiAssistant.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { client } from "./axiosClient.js";
|
|
2
|
-
|
|
3
|
-
interface AskQuestionData {
|
|
4
|
-
conversationId: string;
|
|
5
|
-
question: string;
|
|
6
|
-
updatedContext: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface EndConversationData {
|
|
10
|
-
conversationId: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface StartConversationData {
|
|
14
|
-
autoContextRefresh: boolean;
|
|
15
|
-
context: string;
|
|
16
|
-
question: string;
|
|
17
|
-
elementId: string;
|
|
18
|
-
elementType: string;
|
|
19
|
-
conversationId?: string | null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Ask Question to the AI
|
|
24
|
-
* @param {String} conversationId
|
|
25
|
-
* @param {String} question
|
|
26
|
-
* @param {String} updatedContext
|
|
27
|
-
* @param {String} token Authorization token
|
|
28
|
-
* @returns {Promise<Object>}
|
|
29
|
-
*/
|
|
30
|
-
const askQuestion = (
|
|
31
|
-
conversationId: string,
|
|
32
|
-
question: string,
|
|
33
|
-
updatedContext: string,
|
|
34
|
-
token: string
|
|
35
|
-
): Promise<object> => {
|
|
36
|
-
return new Promise((resolve, reject) => {
|
|
37
|
-
let data: AskQuestionData = {
|
|
38
|
-
conversationId: conversationId,
|
|
39
|
-
question: question,
|
|
40
|
-
updatedContext: updatedContext,
|
|
41
|
-
};
|
|
42
|
-
let confirmationRequest = client.post(
|
|
43
|
-
"/api/v1/aiassistant/askquestion",
|
|
44
|
-
data,
|
|
45
|
-
{
|
|
46
|
-
headers: { authorization: token },
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
confirmationRequest
|
|
50
|
-
.then((response) => {
|
|
51
|
-
resolve(response.data);
|
|
52
|
-
})
|
|
53
|
-
.catch((error) => {
|
|
54
|
-
reject(error);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* End conversation with the AI
|
|
61
|
-
* @param {String} conversationId
|
|
62
|
-
* @param {String} token Authorization token
|
|
63
|
-
* @returns {Promise<Object>}
|
|
64
|
-
*/
|
|
65
|
-
const endConversation = (
|
|
66
|
-
conversationId: string,
|
|
67
|
-
token: string
|
|
68
|
-
): Promise<object> => {
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
let data: EndConversationData = {
|
|
71
|
-
conversationId: conversationId,
|
|
72
|
-
};
|
|
73
|
-
let confirmationRequest = client.post(
|
|
74
|
-
"/api/v1/aiassistant/endconversation",
|
|
75
|
-
data,
|
|
76
|
-
{
|
|
77
|
-
headers: { authorization: token },
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
confirmationRequest
|
|
81
|
-
.then((response) => {
|
|
82
|
-
resolve(response.data);
|
|
83
|
-
})
|
|
84
|
-
.catch((error) => {
|
|
85
|
-
reject(error);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Get conversation by elementId
|
|
92
|
-
* @param {String} elementId
|
|
93
|
-
* @param {String} token
|
|
94
|
-
* @returns {Promise<Object>}
|
|
95
|
-
*/
|
|
96
|
-
const getConversationByElementId = (
|
|
97
|
-
elementId: string,
|
|
98
|
-
token: string
|
|
99
|
-
): Promise<object> => {
|
|
100
|
-
return new Promise((resolve, reject) => {
|
|
101
|
-
let confirmationRequest = client.get(
|
|
102
|
-
`/api/v1/aiassistant/getconversation/${elementId}`,
|
|
103
|
-
{
|
|
104
|
-
headers: { authorization: token },
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
confirmationRequest
|
|
108
|
-
.then((response) => {
|
|
109
|
-
resolve(response.data);
|
|
110
|
-
})
|
|
111
|
-
.catch((error) => {
|
|
112
|
-
reject(error);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Get the voice assistant URL
|
|
119
|
-
* @param {String} language
|
|
120
|
-
* @param {String} token
|
|
121
|
-
* @returns {Promise<Object>}
|
|
122
|
-
*/
|
|
123
|
-
const getVoiceAssistantUrl = (
|
|
124
|
-
language: string,
|
|
125
|
-
token: string
|
|
126
|
-
): Promise<object> => {
|
|
127
|
-
return new Promise((resolve, reject) => {
|
|
128
|
-
let confirmationRequest = client.get(
|
|
129
|
-
`/api/v1/aiassistant/getvoiceassistanturl/${language}`,
|
|
130
|
-
{
|
|
131
|
-
headers: { authorization: token },
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
confirmationRequest
|
|
135
|
-
.then((response) => {
|
|
136
|
-
resolve(response.data);
|
|
137
|
-
})
|
|
138
|
-
.catch((error) => {
|
|
139
|
-
reject(error);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Start conversation with the AI
|
|
146
|
-
* @param {String} elementId
|
|
147
|
-
* @param {String} elementType
|
|
148
|
-
* @param {String} context
|
|
149
|
-
* @param {Boolean} autoContextRefresh
|
|
150
|
-
* @param {String} token
|
|
151
|
-
* @param {String} conversationId Optional
|
|
152
|
-
* @returns {Promise<Object>}
|
|
153
|
-
*/
|
|
154
|
-
const startConversation = (
|
|
155
|
-
elementId: string,
|
|
156
|
-
elementType: string,
|
|
157
|
-
question: string,
|
|
158
|
-
context: string,
|
|
159
|
-
autoContextRefresh: boolean,
|
|
160
|
-
token: string,
|
|
161
|
-
conversationId: string | null = null
|
|
162
|
-
): Promise<object> => {
|
|
163
|
-
return new Promise((resolve, reject) => {
|
|
164
|
-
let data: StartConversationData = {
|
|
165
|
-
autoContextRefresh: autoContextRefresh,
|
|
166
|
-
context: context,
|
|
167
|
-
question: question,
|
|
168
|
-
elementId: elementId,
|
|
169
|
-
elementType: elementType,
|
|
170
|
-
};
|
|
171
|
-
if (conversationId) {
|
|
172
|
-
data.conversationId = conversationId;
|
|
173
|
-
}
|
|
174
|
-
let confirmationRequest = client.post(
|
|
175
|
-
"/api/v1/aiassistant/startconversation",
|
|
176
|
-
data,
|
|
177
|
-
{
|
|
178
|
-
headers: { authorization: token },
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
confirmationRequest
|
|
182
|
-
.then((response) => {
|
|
183
|
-
resolve(response.data);
|
|
184
|
-
})
|
|
185
|
-
.catch((error) => {
|
|
186
|
-
reject(error);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export default {
|
|
192
|
-
askQuestion,
|
|
193
|
-
endConversation,
|
|
194
|
-
getConversationByElementId,
|
|
195
|
-
getVoiceAssistantUrl,
|
|
196
|
-
startConversation,
|
|
197
|
-
};
|
package/lib/avatar.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { client } from "./axiosClient.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get avatar for an elementId
|
|
5
|
-
* @param {String} elementId
|
|
6
|
-
* @param {String} type
|
|
7
|
-
* @param {Number} width
|
|
8
|
-
* @param {Number} height
|
|
9
|
-
* @param {String} token
|
|
10
|
-
* @returns {Promise<Blob>}
|
|
11
|
-
*/
|
|
12
|
-
const getAvatar = (
|
|
13
|
-
elementId: string,
|
|
14
|
-
type: string,
|
|
15
|
-
width: number,
|
|
16
|
-
height: number,
|
|
17
|
-
token: string
|
|
18
|
-
): Promise<Blob> => {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
let confirmationRequest = client.get(
|
|
21
|
-
`/api/v1/avatar/getavatar/${elementId}/${type}/${width}/${height}`,
|
|
22
|
-
{
|
|
23
|
-
headers: {
|
|
24
|
-
authorization: token,
|
|
25
|
-
},
|
|
26
|
-
responseType: "blob",
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
confirmationRequest
|
|
30
|
-
.then((response) => {
|
|
31
|
-
resolve(response.data);
|
|
32
|
-
})
|
|
33
|
-
.catch(() => {
|
|
34
|
-
reject("Error getting avatar");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default {
|
|
40
|
-
getAvatar,
|
|
41
|
-
};
|
package/lib/axiosClient.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosError } from "axios";
|
|
2
|
-
import { RESPONSE_TYPE } from "./constants.js";
|
|
3
|
-
import utils from "./utils.js";
|
|
4
|
-
|
|
5
|
-
const baseUrl = utils.getBaseUrl();
|
|
6
|
-
|
|
7
|
-
const client = axios.create({
|
|
8
|
-
baseURL: baseUrl,
|
|
9
|
-
withCredentials: true,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the error as a string
|
|
14
|
-
* @param {AxiosError} error
|
|
15
|
-
* @returns {string}
|
|
16
|
-
*/
|
|
17
|
-
const errorToString = (error: AxiosError): string => {
|
|
18
|
-
if (error != null) {
|
|
19
|
-
if (error.response?.data) {
|
|
20
|
-
let asString = "";
|
|
21
|
-
if (Array.isArray((error.response.data as any).errors)) {
|
|
22
|
-
(error.response.data as any).errors.forEach(
|
|
23
|
-
(item: any, index: number) => {
|
|
24
|
-
asString += `${index > 0 ? ", " : ""} ${item.msg} param ${
|
|
25
|
-
item.param
|
|
26
|
-
} ${item.value ? `value ${item.value.toString()}` : ""}`;
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
return asString;
|
|
30
|
-
} else if ((error.response.data as any).error) {
|
|
31
|
-
return (error.response.data as any).error.toString();
|
|
32
|
-
} else if (error.response.statusText) {
|
|
33
|
-
return error.response.statusText.toString();
|
|
34
|
-
} else {
|
|
35
|
-
return (error.response.data as any).toString();
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
return error.message ? error.message : "Unknown error";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return "Unknown error";
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Returns the code of the error as a number
|
|
46
|
-
* @param {AxiosError} error
|
|
47
|
-
* @returns {number} The error code
|
|
48
|
-
*/
|
|
49
|
-
const getErrorType = (error: AxiosError): number => {
|
|
50
|
-
if (error.response?.status) {
|
|
51
|
-
return error.response.status;
|
|
52
|
-
} else return RESPONSE_TYPE.SERVICE_UNAVAILABLE;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Return the error information to include just the status and the message
|
|
57
|
-
* @param {AxiosError} error
|
|
58
|
-
* @returns {Object}
|
|
59
|
-
*/
|
|
60
|
-
const getErrorInformation = (
|
|
61
|
-
error: AxiosError
|
|
62
|
-
): { status: number; message: string } => {
|
|
63
|
-
return {
|
|
64
|
-
status: getErrorType(error),
|
|
65
|
-
message: errorToString(error),
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Returns true if an exception should be handled to the business and presentation layer
|
|
71
|
-
* @param {boolean} returnAllExceptions - If set true all exceptions will be passed
|
|
72
|
-
* @param {AxiosError} error - The error returned by the server
|
|
73
|
-
* @returns {boolean}
|
|
74
|
-
*/
|
|
75
|
-
const shouldReturnError = (
|
|
76
|
-
returnAllExceptions: boolean,
|
|
77
|
-
error: AxiosError
|
|
78
|
-
): boolean => {
|
|
79
|
-
if (getErrorType(error) === RESPONSE_TYPE.UNAUTHORIZED) {
|
|
80
|
-
return returnAllExceptions;
|
|
81
|
-
} else {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export {
|
|
87
|
-
client,
|
|
88
|
-
errorToString,
|
|
89
|
-
getErrorType,
|
|
90
|
-
getErrorInformation,
|
|
91
|
-
shouldReturnError,
|
|
92
|
-
};
|
package/lib/microSkillsQuizes.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { client } from "./axiosClient.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get responses for a microskill quiz
|
|
5
|
-
* @param {String} learningContentId
|
|
6
|
-
* @param {String} microSkillId
|
|
7
|
-
* @param {String} token
|
|
8
|
-
* @returns {Promise<Object>}
|
|
9
|
-
*/
|
|
10
|
-
const getResponses = (
|
|
11
|
-
learningContentId: string,
|
|
12
|
-
microSkillId: string,
|
|
13
|
-
token: string
|
|
14
|
-
): Promise<object> => {
|
|
15
|
-
return new Promise((resolve, reject) => {
|
|
16
|
-
let confirmationRequest = client.get(
|
|
17
|
-
`api/v1/microskillsresponses/${learningContentId}/${microSkillId}`,
|
|
18
|
-
{
|
|
19
|
-
headers: { authorization: token },
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
confirmationRequest
|
|
23
|
-
.then((response) => {
|
|
24
|
-
resolve(response.data);
|
|
25
|
-
})
|
|
26
|
-
.catch((error) => {
|
|
27
|
-
reject(error);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Save responses for a microskill quiz
|
|
34
|
-
* @param {String} learningContentId
|
|
35
|
-
* @param {String} microSkillId
|
|
36
|
-
* @param {Array<Object>} responses
|
|
37
|
-
* @param {String} token Authorization token
|
|
38
|
-
* @returns {Promise<Object>}
|
|
39
|
-
*/
|
|
40
|
-
const saveResponses = (
|
|
41
|
-
learningContentId: string,
|
|
42
|
-
microSkillId: string,
|
|
43
|
-
responses: object[],
|
|
44
|
-
token: string
|
|
45
|
-
): Promise<object> => {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
let data = {
|
|
48
|
-
responses: responses,
|
|
49
|
-
};
|
|
50
|
-
let confirmationRequest = client.post(
|
|
51
|
-
`api/v1/microskillsresponses/${learningContentId}/${microSkillId}`,
|
|
52
|
-
data,
|
|
53
|
-
{
|
|
54
|
-
headers: { authorization: token },
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
confirmationRequest
|
|
58
|
-
.then((response) => {
|
|
59
|
-
resolve(response.data);
|
|
60
|
-
})
|
|
61
|
-
.catch((error) => {
|
|
62
|
-
reject(error);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default {
|
|
68
|
-
getResponses,
|
|
69
|
-
saveResponses,
|
|
70
|
-
};
|
package/lib/quotas.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { client } from "./axiosClient.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get the current quota for the user and tenant
|
|
5
|
-
* @param {String} token
|
|
6
|
-
* @returns {Promise<Object>}
|
|
7
|
-
*/
|
|
8
|
-
const getAllQuota = (token: string): Promise<object> => {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
let confirmationRequest = client.get(`/api/v1/quotas/getallquota`, {
|
|
11
|
-
headers: { authorization: token },
|
|
12
|
-
});
|
|
13
|
-
confirmationRequest
|
|
14
|
-
.then((response) => {
|
|
15
|
-
resolve(response.data);
|
|
16
|
-
})
|
|
17
|
-
.catch((error) => {
|
|
18
|
-
reject(error);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Increase quota utilization
|
|
25
|
-
* @param {String} quotaId
|
|
26
|
-
* @param {Number} value
|
|
27
|
-
* @param {String} token
|
|
28
|
-
* @returns {Promise<Object>}
|
|
29
|
-
*/
|
|
30
|
-
const increaseQuotaUtilization = (
|
|
31
|
-
quotaId: string,
|
|
32
|
-
value: number,
|
|
33
|
-
token: string
|
|
34
|
-
): Promise<object> => {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
let confirmationRequest = client.post(
|
|
37
|
-
`/api/v1/quotas/increaseutilization`,
|
|
38
|
-
{
|
|
39
|
-
id: quotaId,
|
|
40
|
-
value: value,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
headers: { authorization: token },
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
confirmationRequest
|
|
47
|
-
.then((response) => {
|
|
48
|
-
resolve(response.data);
|
|
49
|
-
})
|
|
50
|
-
.catch((error) => {
|
|
51
|
-
reject(error);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export default {
|
|
57
|
-
getAllQuota,
|
|
58
|
-
increaseQuotaUtilization,
|
|
59
|
-
};
|
package/lib/security.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
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 getAuthConnections = (authToken: string): Promise<object> => {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
const getConfigInformationRequest = client.get(
|
|
11
|
-
`api/v1/security/authconnections`,
|
|
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
|
-
* @returns {Promise<Object>}
|
|
29
|
-
*/
|
|
30
|
-
const setAuthConnections = (
|
|
31
|
-
data: object,
|
|
32
|
-
authToken: string
|
|
33
|
-
): Promise<object> => {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
const setConfigInformationRequest = client.post(
|
|
36
|
-
`api/v1/security/authconnections`,
|
|
37
|
-
{ data: data },
|
|
38
|
-
{ headers: { authorization: authToken } }
|
|
39
|
-
);
|
|
40
|
-
setConfigInformationRequest
|
|
41
|
-
.then((response) => {
|
|
42
|
-
resolve(response.data);
|
|
43
|
-
})
|
|
44
|
-
.catch((error) => {
|
|
45
|
-
reject(error);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Reset the MFA for the user.
|
|
52
|
-
* @param {String} userId
|
|
53
|
-
* @param {String} authToken
|
|
54
|
-
* @returns {Promise<Object>}
|
|
55
|
-
*/
|
|
56
|
-
const resetMFA = (userId: string, authToken: string): Promise<object> => {
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
const resetMFARequest = client.post(
|
|
59
|
-
`api/v1/security/resetmfa`,
|
|
60
|
-
userId ? {} : { userId: userId },
|
|
61
|
-
{ headers: { authorization: authToken } }
|
|
62
|
-
);
|
|
63
|
-
resetMFARequest
|
|
64
|
-
.then((response) => {
|
|
65
|
-
resolve(response.data);
|
|
66
|
-
})
|
|
67
|
-
.catch((error) => {
|
|
68
|
-
reject(error);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Synchronize the authentication connections with Auth0.
|
|
75
|
-
* @param {String} authToken
|
|
76
|
-
* @returns {Promise<Object>}
|
|
77
|
-
*/
|
|
78
|
-
const synchronizeWithAuth0 = (authToken: string): Promise<object> => {
|
|
79
|
-
return new Promise((resolve, reject) => {
|
|
80
|
-
const synchronizeRequest = client.get(
|
|
81
|
-
`api/v1/security/synchronizewithauth0`,
|
|
82
|
-
{ headers: { authorization: authToken } }
|
|
83
|
-
);
|
|
84
|
-
synchronizeRequest
|
|
85
|
-
.then((response) => {
|
|
86
|
-
resolve(response.data);
|
|
87
|
-
})
|
|
88
|
-
.catch((error) => {
|
|
89
|
-
reject(error);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export default {
|
|
95
|
-
getAuthConnections,
|
|
96
|
-
resetMFA,
|
|
97
|
-
setAuthConnections,
|
|
98
|
-
synchronizeWithAuth0,
|
|
99
|
-
};
|