@credal/actions 0.2.198 → 0.2.200
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/actions/actionMapper.js +8 -1
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +65 -0
- package/dist/actions/autogen/types.d.ts +39 -0
- package/dist/actions/autogen/types.js +17 -0
- package/dist/actions/providers/googlemail/replyToGmail.d.ts +3 -0
- package/dist/actions/providers/googlemail/replyToGmail.js +89 -0
- package/package.json +1 -1
- package/dist/actions/groups.d.ts +0 -6
- package/dist/actions/groups.js +0 -251
- package/dist/actions/providers/ashby/addCandidateToProject.d.ts +0 -3
- package/dist/actions/providers/ashby/addCandidateToProject.js +0 -31
- package/dist/actions/providers/ashby/createCandidate.d.ts +0 -3
- package/dist/actions/providers/ashby/createCandidate.js +0 -38
- package/dist/actions/providers/ashby/createNote.d.ts +0 -3
- package/dist/actions/providers/ashby/createNote.js +0 -31
- package/dist/actions/providers/ashby/getCandidateInfo.d.ts +0 -3
- package/dist/actions/providers/ashby/getCandidateInfo.js +0 -33
- package/dist/actions/providers/ashby/listCandidateNotes.d.ts +0 -3
- package/dist/actions/providers/ashby/listCandidateNotes.js +0 -33
- package/dist/actions/providers/ashby/listCandidates.d.ts +0 -3
- package/dist/actions/providers/ashby/listCandidates.js +0 -30
- package/dist/actions/providers/ashby/searchCandidates.d.ts +0 -3
- package/dist/actions/providers/ashby/searchCandidates.js +0 -34
- package/dist/actions/providers/ashby/updateCandidate.d.ts +0 -3
- package/dist/actions/providers/ashby/updateCandidate.js +0 -56
- package/dist/actions/providers/github/fetchFile.d.ts +0 -3
- package/dist/actions/providers/github/fetchFile.js +0 -131
- package/dist/actions/providers/github/getContents.d.ts +0 -3
- package/dist/actions/providers/github/getContents.js +0 -41
- package/dist/actions/providers/gong/getGongTranscripts.d.ts +0 -3
- package/dist/actions/providers/gong/getGongTranscripts.js +0 -315
- package/dist/actions/providers/jamf/getJamfComputerInventory.d.ts +0 -3
- package/dist/actions/providers/jamf/getJamfComputerInventory.js +0 -37
- package/dist/actions/providers/jamf/getJamfFileVaultRecoveryKey.d.ts +0 -3
- package/dist/actions/providers/jamf/getJamfFileVaultRecoveryKey.js +0 -39
- package/dist/actions/providers/jamf/getJamfUserComputerId.d.ts +0 -3
- package/dist/actions/providers/jamf/getJamfUserComputerId.js +0 -45
- package/dist/actions/providers/jamf/lockJamfComputerById.d.ts +0 -3
- package/dist/actions/providers/jamf/lockJamfComputerById.js +0 -39
- package/dist/actions/providers/kandji/getFVRecoveryKeyForDevice.d.ts +0 -3
- package/dist/actions/providers/kandji/getFVRecoveryKeyForDevice.js +0 -85
- package/dist/actions/providers/okta/addUserToGroup.d.ts +0 -3
- package/dist/actions/providers/okta/addUserToGroup.js +0 -56
- package/dist/actions/providers/okta/getOktaGroup.d.ts +0 -3
- package/dist/actions/providers/okta/getOktaGroup.js +0 -73
- package/dist/actions/providers/okta/getOktaUser.d.ts +0 -3
- package/dist/actions/providers/okta/getOktaUser.js +0 -40
- package/dist/actions/providers/okta/listMFA.d.ts +0 -3
- package/dist/actions/providers/okta/listMFA.js +0 -52
- package/dist/actions/providers/okta/listOktaGroupMembers.d.ts +0 -3
- package/dist/actions/providers/okta/listOktaGroupMembers.js +0 -99
- package/dist/actions/providers/okta/listOktaGroups.d.ts +0 -3
- package/dist/actions/providers/okta/listOktaGroups.js +0 -92
- package/dist/actions/providers/okta/listOktaUserGroups.d.ts +0 -3
- package/dist/actions/providers/okta/listOktaUserGroups.js +0 -83
- package/dist/actions/providers/okta/listOktaUsers.d.ts +0 -3
- package/dist/actions/providers/okta/listOktaUsers.js +0 -100
- package/dist/actions/providers/okta/removeUserFromGroup.d.ts +0 -3
- package/dist/actions/providers/okta/removeUserFromGroup.js +0 -56
- package/dist/actions/providers/okta/resetMFA.d.ts +0 -3
- package/dist/actions/providers/okta/resetMFA.js +0 -62
- package/dist/actions/providers/okta/resetPassword.d.ts +0 -3
- package/dist/actions/providers/okta/resetPassword.js +0 -57
- package/dist/actions/providers/okta/triggerOktaWorkflow.d.ts +0 -3
- package/dist/actions/providers/okta/triggerOktaWorkflow.js +0 -44
- package/dist/actions/providers/salesforce/fetchSalesforceSchema.d.ts +0 -3
- package/dist/actions/providers/salesforce/fetchSalesforceSchema.js +0 -40
- package/dist/actions/providers/slack/archiveChannel.d.ts +0 -3
- package/dist/actions/providers/slack/archiveChannel.js +0 -42
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
import axios, { AxiosError } from "axios";
|
|
22
|
-
import { z } from "zod";
|
|
23
|
-
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
24
|
-
const UserSchema = z
|
|
25
|
-
.object({
|
|
26
|
-
id: z.string(),
|
|
27
|
-
firstName: z.string(),
|
|
28
|
-
lastName: z.string(),
|
|
29
|
-
title: z.string().nullable(),
|
|
30
|
-
emailAddress: z.string(),
|
|
31
|
-
})
|
|
32
|
-
.partial()
|
|
33
|
-
.passthrough();
|
|
34
|
-
const CallSchema = z
|
|
35
|
-
.object({
|
|
36
|
-
metaData: z.object({
|
|
37
|
-
id: z.string(),
|
|
38
|
-
primaryUserId: z.string(),
|
|
39
|
-
started: z.string(),
|
|
40
|
-
isPrivate: z.boolean(),
|
|
41
|
-
title: z.string(),
|
|
42
|
-
}),
|
|
43
|
-
parties: z.array(z
|
|
44
|
-
.object({
|
|
45
|
-
id: z.string(),
|
|
46
|
-
name: z.string(),
|
|
47
|
-
userId: z.string(),
|
|
48
|
-
emailAddress: z.string(),
|
|
49
|
-
speakerId: z.string().nullable(),
|
|
50
|
-
})
|
|
51
|
-
.partial()
|
|
52
|
-
.passthrough()),
|
|
53
|
-
content: z.object({
|
|
54
|
-
trackers: z.array(z.object({
|
|
55
|
-
id: z.string(),
|
|
56
|
-
name: z.string(),
|
|
57
|
-
})),
|
|
58
|
-
}),
|
|
59
|
-
})
|
|
60
|
-
.partial()
|
|
61
|
-
.passthrough();
|
|
62
|
-
const SentenceSchema = z
|
|
63
|
-
.object({
|
|
64
|
-
start: z.number(),
|
|
65
|
-
end: z.number(),
|
|
66
|
-
text: z.string(),
|
|
67
|
-
})
|
|
68
|
-
.partial()
|
|
69
|
-
.passthrough();
|
|
70
|
-
const TranscriptSchema = z
|
|
71
|
-
.object({
|
|
72
|
-
callId: z.string(),
|
|
73
|
-
transcript: z.array(z
|
|
74
|
-
.object({
|
|
75
|
-
speakerId: z.string(),
|
|
76
|
-
topic: z.string().nullable(),
|
|
77
|
-
sentences: z.array(SentenceSchema),
|
|
78
|
-
})
|
|
79
|
-
.partial()
|
|
80
|
-
.passthrough()),
|
|
81
|
-
})
|
|
82
|
-
.partial()
|
|
83
|
-
.passthrough();
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
85
|
-
const GongResponseSchema = z.object({
|
|
86
|
-
users: z.array(UserSchema).optional(),
|
|
87
|
-
calls: z.array(CallSchema).optional(),
|
|
88
|
-
callTranscripts: z.array(TranscriptSchema).optional(),
|
|
89
|
-
cursor: z.string().optional(),
|
|
90
|
-
});
|
|
91
|
-
function getUsers(authToken) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
var _a;
|
|
94
|
-
const results = [];
|
|
95
|
-
let cursor = undefined;
|
|
96
|
-
do {
|
|
97
|
-
const response = yield axios.get(`https://api.gong.io/v2/users` + (cursor ? `?cursor=${cursor}` : ""), {
|
|
98
|
-
headers: {
|
|
99
|
-
Authorization: `Bearer ${authToken}`,
|
|
100
|
-
"Content-Type": "application/json",
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
if (!response) {
|
|
104
|
-
return results;
|
|
105
|
-
}
|
|
106
|
-
for (const user of (_a = response.data.users) !== null && _a !== void 0 ? _a : []) {
|
|
107
|
-
const parsedUser = UserSchema.safeParse(user);
|
|
108
|
-
if (parsedUser.success) {
|
|
109
|
-
results.push(parsedUser.data);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
cursor = response.data.cursor;
|
|
113
|
-
} while (cursor);
|
|
114
|
-
return results;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function getCalls(authToken_1) {
|
|
118
|
-
return __awaiter(this, arguments, void 0, function* (authToken, params = {}) {
|
|
119
|
-
let results = [];
|
|
120
|
-
let cursor = undefined;
|
|
121
|
-
do {
|
|
122
|
-
const response = yield axios.post(`https://api.gong.io/v2/calls/extensive` + (cursor ? `?cursor=${cursor}` : ""), {
|
|
123
|
-
filter: Object.assign({}, params),
|
|
124
|
-
contentSelector: {
|
|
125
|
-
exposedFields: {
|
|
126
|
-
parties: true,
|
|
127
|
-
content: {
|
|
128
|
-
trackers: true,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
}, {
|
|
133
|
-
headers: {
|
|
134
|
-
Authorization: `Bearer ${authToken}`,
|
|
135
|
-
"Content-Type": "application/json",
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
if (!response) {
|
|
139
|
-
return results;
|
|
140
|
-
}
|
|
141
|
-
const parsedItems = z.array(CallSchema).safeParse(response.data.calls);
|
|
142
|
-
if (parsedItems.success) {
|
|
143
|
-
results = [...results, ...parsedItems.data];
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
return results;
|
|
147
|
-
}
|
|
148
|
-
cursor = response.data.cursor;
|
|
149
|
-
} while (cursor);
|
|
150
|
-
return results;
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function getTranscripts(authToken_1) {
|
|
154
|
-
return __awaiter(this, arguments, void 0, function* (authToken, params = {}) {
|
|
155
|
-
let results = [];
|
|
156
|
-
let cursor = undefined;
|
|
157
|
-
do {
|
|
158
|
-
const response = yield axios.post(`https://api.gong.io/v2/calls/transcript` + (cursor ? `?cursor=${cursor}` : ""), {
|
|
159
|
-
filter: Object.assign({}, params),
|
|
160
|
-
}, {
|
|
161
|
-
headers: {
|
|
162
|
-
Authorization: `Bearer ${authToken}`,
|
|
163
|
-
"Content-Type": "application/json",
|
|
164
|
-
},
|
|
165
|
-
});
|
|
166
|
-
if (!response) {
|
|
167
|
-
return results;
|
|
168
|
-
}
|
|
169
|
-
const parsedItems = z.array(TranscriptSchema).safeParse(response.data.callTranscripts);
|
|
170
|
-
if (parsedItems.success) {
|
|
171
|
-
results = [...results, ...parsedItems.data];
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
return results;
|
|
175
|
-
}
|
|
176
|
-
cursor = response.data.cursor;
|
|
177
|
-
} while (cursor);
|
|
178
|
-
return results;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
// Retrieves transcripts from Gong based on the provided parameters
|
|
182
|
-
const getGongTranscripts = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
183
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
184
|
-
if (!authParams.authToken) {
|
|
185
|
-
return {
|
|
186
|
-
success: false,
|
|
187
|
-
error: MISSING_AUTH_TOKEN,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
if (!authParams.username) {
|
|
191
|
-
return {
|
|
192
|
-
success: false,
|
|
193
|
-
error: "Missing user email",
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
const gongUsers = yield getUsers(authParams.authToken);
|
|
198
|
-
const userEmails = gongUsers.map(user => user.emailAddress);
|
|
199
|
-
if (!userEmails.includes(authParams.username)) {
|
|
200
|
-
return {
|
|
201
|
-
success: false,
|
|
202
|
-
error: "User email not found in Gong users",
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
const filteredGongUsers = gongUsers.filter(user => user.title === params.userRole);
|
|
206
|
-
const filteredPrimaryIds = filteredGongUsers.map(user => user.id).filter((id) => id !== undefined);
|
|
207
|
-
if (filteredPrimaryIds.length === 0) {
|
|
208
|
-
return {
|
|
209
|
-
success: false,
|
|
210
|
-
error: "No Gong users found with the specified role",
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
const calls = yield getCalls(authParams.authToken, {
|
|
214
|
-
fromDateTime: (_b = params.startDate) !== null && _b !== void 0 ? _b : "",
|
|
215
|
-
toDateTime: (_c = params.endDate) !== null && _c !== void 0 ? _c : "",
|
|
216
|
-
primaryUserIds: filteredPrimaryIds,
|
|
217
|
-
});
|
|
218
|
-
const callsWithTrackers = calls.filter(call => {
|
|
219
|
-
// If the user didn't provide any trackers to filter on, return all calls
|
|
220
|
-
if (!params.trackers || params.trackers.length === 0) {
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
// Filter out calls that don't have trackers if the user specified trackers
|
|
224
|
-
if (!call.content || !call.content.trackers) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
const trackerNames = call.content.trackers.map(tracker => tracker.name);
|
|
228
|
-
// Check if any of the trackers in the call match the ones provided by the user
|
|
229
|
-
return params.trackers.some(tr => trackerNames.includes(tr));
|
|
230
|
-
});
|
|
231
|
-
const publicCalls = callsWithTrackers.filter(call => {
|
|
232
|
-
if (!call.metaData) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
return !call.metaData.isPrivate;
|
|
236
|
-
});
|
|
237
|
-
if (publicCalls.length === 0) {
|
|
238
|
-
return {
|
|
239
|
-
success: true,
|
|
240
|
-
callTranscripts: [],
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
// Get transcripts for the calls we found
|
|
244
|
-
const callTranscripts = yield getTranscripts(authParams.authToken, {
|
|
245
|
-
fromDateTime: (_d = params.startDate) !== null && _d !== void 0 ? _d : "",
|
|
246
|
-
toDateTime: (_e = params.endDate) !== null && _e !== void 0 ? _e : "",
|
|
247
|
-
callIds: publicCalls.map(call => { var _a; return (_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id; }).filter((id) => id !== undefined),
|
|
248
|
-
});
|
|
249
|
-
// Map speaker IDs to names in the transcripts
|
|
250
|
-
const userIdToNameMap = {};
|
|
251
|
-
const userIdToEmailMap = {};
|
|
252
|
-
const callIdToEmails = {};
|
|
253
|
-
publicCalls.forEach(call => {
|
|
254
|
-
var _a;
|
|
255
|
-
// Check if call has parties array
|
|
256
|
-
if (call.parties && Array.isArray(call.parties)) {
|
|
257
|
-
// Iterate through each party in the call
|
|
258
|
-
if ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) {
|
|
259
|
-
callIdToEmails[call.metaData.id] = [];
|
|
260
|
-
call.parties.forEach(party => {
|
|
261
|
-
var _a;
|
|
262
|
-
// Add the mapping of speakerId to name
|
|
263
|
-
if (party.speakerId) {
|
|
264
|
-
if (party.name) {
|
|
265
|
-
userIdToNameMap[party.speakerId] = party.name;
|
|
266
|
-
}
|
|
267
|
-
if (party.emailAddress) {
|
|
268
|
-
userIdToEmailMap[party.speakerId] = party.emailAddress;
|
|
269
|
-
if ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) {
|
|
270
|
-
callIdToEmails[call.metaData.id].push(party.emailAddress);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
const callTranscriptsWithNames = callTranscripts
|
|
279
|
-
.map(callTranscript => {
|
|
280
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
281
|
-
const currTranscript = Object.assign({}, callTranscript);
|
|
282
|
-
const callId = callTranscript.callId;
|
|
283
|
-
currTranscript.transcript = (_a = callTranscript.transcript) === null || _a === void 0 ? void 0 : _a.map(transcript => {
|
|
284
|
-
var _a, _b;
|
|
285
|
-
const { speakerId } = transcript, rest = __rest(transcript, ["speakerId"]);
|
|
286
|
-
return Object.assign(Object.assign({}, rest), { speakerName: (_a = userIdToNameMap[speakerId !== null && speakerId !== void 0 ? speakerId : ""]) !== null && _a !== void 0 ? _a : "Unknown", speakerEmail: (_b = userIdToEmailMap[speakerId !== null && speakerId !== void 0 ? speakerId : ""]) !== null && _b !== void 0 ? _b : "Unknown" });
|
|
287
|
-
});
|
|
288
|
-
return Object.assign({ callName: (_d = (_c = (_b = publicCalls.find(call => { var _a; return ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) === callTranscript.callId; })) === null || _b === void 0 ? void 0 : _b.metaData) === null || _c === void 0 ? void 0 : _c.title) !== null && _d !== void 0 ? _d : "", userEmails: (_e = callIdToEmails[callId]) !== null && _e !== void 0 ? _e : [], startTime: (_h = (_g = (_f = publicCalls.find(call => { var _a; return ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) === callTranscript.callId; })) === null || _f === void 0 ? void 0 : _f.metaData) === null || _g === void 0 ? void 0 : _g.started) !== null && _h !== void 0 ? _h : "" }, currTranscript);
|
|
289
|
-
})
|
|
290
|
-
.filter(callTranscript => {
|
|
291
|
-
var _a;
|
|
292
|
-
if (!params.company || params.company === "") {
|
|
293
|
-
return true; // If no company filter is provided, include all transcripts
|
|
294
|
-
}
|
|
295
|
-
for (const email of callIdToEmails[callTranscript.callId]) {
|
|
296
|
-
const companyName = (_a = params.company) === null || _a === void 0 ? void 0 : _a.toLowerCase().replace(/ /g, "");
|
|
297
|
-
if (email.includes(companyName)) {
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return false;
|
|
302
|
-
});
|
|
303
|
-
return {
|
|
304
|
-
success: true,
|
|
305
|
-
callTranscripts: callTranscriptsWithNames,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
catch (error) {
|
|
309
|
-
return {
|
|
310
|
-
success: false,
|
|
311
|
-
error: error instanceof AxiosError ? ((_h = (_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.errors) !== null && _h !== void 0 ? _h : error.message) : error,
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
export default getGongTranscripts;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const getJamfComputerInventory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
|
|
12
|
-
const { authToken, subdomain } = authParams;
|
|
13
|
-
if (!subdomain || !authToken) {
|
|
14
|
-
throw new Error("Instance and authToken are required to fetch Jamf computer inventory");
|
|
15
|
-
}
|
|
16
|
-
const url = `https://${subdomain}.jamfcloud.com`;
|
|
17
|
-
try {
|
|
18
|
-
const computers = yield axiosClient.get(`${url}/api/v1/computers-inventory`, {
|
|
19
|
-
headers: {
|
|
20
|
-
Authorization: `Bearer ${authToken}`,
|
|
21
|
-
Accept: "application/json",
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
success: true,
|
|
26
|
-
data: computers.data,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.error("Error retrieving Jamf computer inventory: ", error);
|
|
31
|
-
return {
|
|
32
|
-
success: false,
|
|
33
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
export default getJamfComputerInventory;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const getJamfFileVaultRecoveryKey = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
-
const { authToken, subdomain } = authParams;
|
|
13
|
-
const { computerId } = params;
|
|
14
|
-
if (!subdomain || !authToken) {
|
|
15
|
-
throw new Error("Instance and authToken are required to fetch FileVault2 recovery key");
|
|
16
|
-
}
|
|
17
|
-
// const apiUrl = `${baseUrl}/api/v1/computers-inventory/${computerId}/filevault`;
|
|
18
|
-
const url = `https://${subdomain}.jamfcloud.com`;
|
|
19
|
-
try {
|
|
20
|
-
const fileVaultResponse = yield axiosClient.get(`${url}/api/v1/computers-inventory/${computerId}/filevault`, {
|
|
21
|
-
headers: {
|
|
22
|
-
Authorization: `Bearer ${authToken}`,
|
|
23
|
-
Accept: "application/json",
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
success: true,
|
|
28
|
-
data: fileVaultResponse.data,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error("Error retrieving FileVault2 recovery key: ", error);
|
|
33
|
-
return {
|
|
34
|
-
success: false,
|
|
35
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
export default getJamfFileVaultRecoveryKey;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const getJamfUserComputerId = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
-
const { authToken, subdomain } = authParams;
|
|
13
|
-
const { userEmail } = params;
|
|
14
|
-
if (!subdomain || !authToken) {
|
|
15
|
-
throw new Error("Instance and authToken are required to fetch Jamf user computer ID");
|
|
16
|
-
}
|
|
17
|
-
const url = `https://${subdomain}.jamfcloud.com`;
|
|
18
|
-
try {
|
|
19
|
-
const computers = yield axiosClient.get(`${url}/api/v1/computers-inventory`, {
|
|
20
|
-
headers: {
|
|
21
|
-
Authorization: `Bearer ${authToken}`,
|
|
22
|
-
Accept: "application/json",
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
const filteredComputers = computers.data.results.filter(computer => { var _a; return ((_a = computer.userAndLocation) === null || _a === void 0 ? void 0 : _a.email) === userEmail; });
|
|
26
|
-
if (filteredComputers.length === 0) {
|
|
27
|
-
return {
|
|
28
|
-
success: false,
|
|
29
|
-
error: `No computers found for user with email: ${userEmail}`,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
success: true,
|
|
34
|
-
computerId: filteredComputers[0].id,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error("Error retrieving Jamf user computer ID: ", error);
|
|
39
|
-
return {
|
|
40
|
-
success: false,
|
|
41
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
export default getJamfUserComputerId;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const lockJamfComputerById = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
-
const { authToken, subdomain } = authParams;
|
|
13
|
-
const { computerId, passcode } = params;
|
|
14
|
-
if (!subdomain || !authToken) {
|
|
15
|
-
throw new Error("Instance and authToken are required to fetch Jamf user computer ID");
|
|
16
|
-
}
|
|
17
|
-
const url = `https://${subdomain}.jamfcloud.com`;
|
|
18
|
-
try {
|
|
19
|
-
yield axiosClient.post(`${url}/JSSResource/computercommands/command/DeviceLock/id/${computerId}`, {
|
|
20
|
-
passcode,
|
|
21
|
-
}, {
|
|
22
|
-
headers: {
|
|
23
|
-
Authorization: `Bearer ${authToken}`,
|
|
24
|
-
Accept: "application/json",
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
success: true,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error("Error locking Jamf computer: ", error);
|
|
33
|
-
return {
|
|
34
|
-
success: false,
|
|
35
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
export default lockJamfComputerById;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const getFVRecoveryKeyForDevice = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
-
const { userEmail, subdomain } = params;
|
|
13
|
-
const { apiKey } = authParams;
|
|
14
|
-
if (!apiKey) {
|
|
15
|
-
throw new Error("Missing API key in auth parameters");
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
// First list all devices to get the device for the specific device
|
|
19
|
-
const device = yield getDeviceByEmail({
|
|
20
|
-
apiKey,
|
|
21
|
-
userEmail,
|
|
22
|
-
subdomain,
|
|
23
|
-
});
|
|
24
|
-
if (!device) {
|
|
25
|
-
return {
|
|
26
|
-
success: false,
|
|
27
|
-
error: "Device not found for the given serial number",
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
// Then get the FV recovery key for that device
|
|
31
|
-
const fvRecoveryKey = yield axiosClient.get(`https://${subdomain}.api.kandji.io/api/v1/devices/${device.device_id}/secrets/filevaultkey`, {
|
|
32
|
-
headers: {
|
|
33
|
-
"Content-Type": "application/json",
|
|
34
|
-
Authorization: `Bearer ${apiKey}`,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
if (!fvRecoveryKey || !fvRecoveryKey.data || !fvRecoveryKey.data.key) {
|
|
38
|
-
return {
|
|
39
|
-
success: false,
|
|
40
|
-
error: "FireVault recovery key not found",
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
success: true,
|
|
45
|
-
recoveryKey: fvRecoveryKey.data.key,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
return {
|
|
50
|
-
success: false,
|
|
51
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
function getDeviceByEmail(input) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const limit = 300;
|
|
58
|
-
let offset = 0;
|
|
59
|
-
const { apiKey, userEmail, subdomain } = input;
|
|
60
|
-
while (true) {
|
|
61
|
-
// Update params
|
|
62
|
-
const params = { limit, offset };
|
|
63
|
-
const endpoint = `https://${subdomain}.api.kandji.io/api/v1/devices`;
|
|
64
|
-
const response = yield axiosClient.get(endpoint, {
|
|
65
|
-
params: Object.assign({}, params),
|
|
66
|
-
headers: {
|
|
67
|
-
"Content-Type": "application/json",
|
|
68
|
-
Authorization: `Bearer ${apiKey}`,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
for (const device of response.data) {
|
|
72
|
-
if (device.user && device.user.email === userEmail) {
|
|
73
|
-
// If the device user email matches, return the device
|
|
74
|
-
return device;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
offset += limit;
|
|
78
|
-
if (response.data.length === 0) {
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
export default getFVRecoveryKeyForDevice;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { AxiosError } from "axios";
|
|
11
|
-
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
|
-
const addUserToGroup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, params, }) {
|
|
13
|
-
var _b, _c;
|
|
14
|
-
const { authToken, baseUrl } = authParams;
|
|
15
|
-
if (!authToken || !baseUrl) {
|
|
16
|
-
return {
|
|
17
|
-
success: false,
|
|
18
|
-
error: "Missing Okta OAuth token (authToken) or base URL (baseUrl) in authParams.",
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const requestConfig = {
|
|
23
|
-
headers: {
|
|
24
|
-
Authorization: `Bearer ${authToken}`,
|
|
25
|
-
Accept: "application/json",
|
|
26
|
-
"Content-Type": "application/json",
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
const endpointUrl = new URL(`/api/v1/groups/${params.groupId}/users/${params.userId}`, baseUrl).toString();
|
|
30
|
-
const response = yield axiosClient.put(endpointUrl, {}, requestConfig);
|
|
31
|
-
if (response.status === 204) {
|
|
32
|
-
return { success: true };
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const errorDetail = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.errorSummary) || ((_c = response.data) === null || _c === void 0 ? void 0 : _c.message) || `Okta API responded with status ${response.status}`;
|
|
36
|
-
return { success: false, error: `Failed to add user to group: ${errorDetail}` };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
console.error("Error adding user to group:", error);
|
|
41
|
-
let errorMessage = "Unknown error while adding user to group";
|
|
42
|
-
if (error instanceof AxiosError && error.response) {
|
|
43
|
-
const oktaError = error.response.data;
|
|
44
|
-
errorMessage =
|
|
45
|
-
(oktaError === null || oktaError === void 0 ? void 0 : oktaError.errorSummary) || (oktaError === null || oktaError === void 0 ? void 0 : oktaError.message) || `Okta API request failed with status ${error.response.status}`;
|
|
46
|
-
}
|
|
47
|
-
else if (error instanceof Error) {
|
|
48
|
-
errorMessage = error.message;
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
success: false,
|
|
52
|
-
error: errorMessage,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
export default addUserToGroup;
|