@meru2802/aux-server 1.0.19 → 1.0.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"apiController.d.ts","sourceRoot":"","sources":["../../src/controllers/apiController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOjE,qBAAa,aAAc,SAAQ,cAAc;gBACnC,gBAAgB,CAAC,EAAE,iBAAiB;IAIzC,YAAY,GAAU,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CAwGtE;IAEK,cAAc,GACnB,KAAK,OAAO,EACZ,KAAK,QAAQ,KACZ,OAAO,CAAC,IAAI,CAAC,CA2Rd;CACH"}
1
+ {"version":3,"file":"apiController.d.ts","sourceRoot":"","sources":["../../src/controllers/apiController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOjE,qBAAa,aAAc,SAAQ,cAAc;gBACnC,gBAAgB,CAAC,EAAE,iBAAiB;IAIzC,YAAY,GAAU,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CA0GtE;IAEK,cAAc,GACnB,KAAK,OAAO,EACZ,KAAK,QAAQ,KACZ,OAAO,CAAC,IAAI,CAAC,CAkUd;CACH"}
@@ -44,6 +44,7 @@ class ApiController extends BaseController_1.BaseController {
44
44
  userEpmId,
45
45
  expiration: expiration.toISOString(),
46
46
  });
47
+ const agent = (0, utils_1.getNoProxyHttpAgent)();
47
48
  const epmResponse = await axios_1.default.post(epmUrl, {
48
49
  name: keyName,
49
50
  expiration: expiration.toISOString(),
@@ -54,7 +55,7 @@ class ApiController extends BaseController_1.BaseController {
54
55
  "Content-Type": "application/json",
55
56
  "X-API-KEY": this.config.epmConfig.masterApiKey,
56
57
  },
57
- httpsAgent: this.httpsAgent,
58
+ httpsAgent: agent,
58
59
  validateStatus: () => true,
59
60
  });
60
61
  console.log("EPM API Response:", {
@@ -100,14 +101,44 @@ class ApiController extends BaseController_1.BaseController {
100
101
  }
101
102
  };
102
103
  this.getConnectUrls = async (req, res) => {
103
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
104
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
104
105
  try {
105
- const meshNodeId = req.body.meshNodeId;
106
106
  const userId = req.body.userId;
107
+ let meshNodeId = req.body.meshNodeId;
108
+ const agentId = req.body.agentId;
107
109
  const isApplet = req.body.isApplet;
108
- if (!meshNodeId || !userId) {
110
+ if (!meshNodeId && !agentId) {
109
111
  const errorResponse = {
110
- error: "'meshNodeId' or 'userId' are missing in body params",
112
+ error: "Either 'meshNodeId' or 'agentId' must be present in body",
113
+ timestamp: new Date().toISOString(),
114
+ };
115
+ res.status(400).json(errorResponse);
116
+ return;
117
+ }
118
+ if (!userId) {
119
+ const errorResponse = {
120
+ error: "'userId' is missing in body params",
121
+ timestamp: new Date().toISOString(),
122
+ };
123
+ res.status(400).json(errorResponse);
124
+ return;
125
+ }
126
+ if (!meshNodeId && agentId) {
127
+ const nexus_epm_mesh_node_id_query = "SELECT mesh_node_id FROM agents_agent where agent_id = $1";
128
+ const nexus_epm_mesh_node_id = await this.dbPool.query(nexus_epm_mesh_node_id_query, [agentId]);
129
+ if (nexus_epm_mesh_node_id.rows.length === 0) {
130
+ const errorResponse = {
131
+ error: `Mesh Node Id corresponding to Agent ID: '${agentId}' Not Found`,
132
+ timestamp: new Date().toISOString(),
133
+ };
134
+ res.status(400).json(errorResponse);
135
+ return;
136
+ }
137
+ meshNodeId = (_a = nexus_epm_mesh_node_id.rows[0]) === null || _a === void 0 ? void 0 : _a.mesh_node_id;
138
+ }
139
+ if (!meshNodeId) {
140
+ const errorResponse = {
141
+ error: `'meshNodeId' for agent id: ${agentId} not found. This endpoint needs reinstallation`,
111
142
  timestamp: new Date().toISOString(),
112
143
  };
113
144
  res.status(400).json(errorResponse);
@@ -126,7 +157,7 @@ class ApiController extends BaseController_1.BaseController {
126
157
  if (!isApplet) {
127
158
  const nexus_epm_agent_id_query = "SELECT agent_id, site_id FROM agents_agent where mesh_node_id= $1";
128
159
  const nexus_epm_agent_id = await this.dbPool.query(nexus_epm_agent_id_query, [meshNodeId]);
129
- if (!((_a = nexus_epm_user_id.rows[0]) === null || _a === void 0 ? void 0 : _a.role_id)) {
160
+ if (!((_b = nexus_epm_user_id.rows[0]) === null || _b === void 0 ? void 0 : _b.role_id)) {
130
161
  const errorResponse = {
131
162
  error: `'Role id corresponding to user ${userId}' Not Found`,
132
163
  timestamp: new Date().toISOString(),
@@ -144,11 +175,11 @@ class ApiController extends BaseController_1.BaseController {
144
175
  }
145
176
  const nexus_epm_agent_client_id_query = "SELECT client_id FROM clients_site WHERE id= $1";
146
177
  const nexus_epm_agent_client_id = await this.dbPool.query(nexus_epm_agent_client_id_query, [
147
- (_b = nexus_epm_agent_id.rows[0]) === null || _b === void 0 ? void 0 : _b.site_id,
178
+ (_c = nexus_epm_agent_id.rows[0]) === null || _c === void 0 ? void 0 : _c.site_id,
148
179
  ]);
149
180
  if (nexus_epm_agent_client_id.rows.length === 0) {
150
181
  const errorResponse = {
151
- error: `'Client ID corresponding to site id ${(_c = nexus_epm_agent_id.rows[0]) === null || _c === void 0 ? void 0 : _c.site_id}' Not Found`,
182
+ error: `'Client ID corresponding to site id ${(_d = nexus_epm_agent_id.rows[0]) === null || _d === void 0 ? void 0 : _d.site_id}' Not Found`,
152
183
  timestamp: new Date().toISOString(),
153
184
  };
154
185
  res.status(400).json(errorResponse);
@@ -158,10 +189,10 @@ class ApiController extends BaseController_1.BaseController {
158
189
  const nexus_epm_role_site_ids_query = "SELECT site_id FROM accounts_role_can_view_sites WHERE role_id= $1";
159
190
  const [nexus_epm_role_client_ids, nexus_epm_role_site_ids] = await Promise.all([
160
191
  this.dbPool.query(nexus_epm_role_client_ids_query, [
161
- (_d = nexus_epm_user_id.rows[0]) === null || _d === void 0 ? void 0 : _d.role_id,
192
+ (_e = nexus_epm_user_id.rows[0]) === null || _e === void 0 ? void 0 : _e.role_id,
162
193
  ]),
163
194
  this.dbPool.query(nexus_epm_role_site_ids_query, [
164
- (_e = nexus_epm_user_id.rows[0]) === null || _e === void 0 ? void 0 : _e.role_id,
195
+ (_f = nexus_epm_user_id.rows[0]) === null || _f === void 0 ? void 0 : _f.role_id,
165
196
  ]),
166
197
  ]);
167
198
  const roleHasPermissionForAgentClient = () => {
@@ -194,20 +225,20 @@ class ApiController extends BaseController_1.BaseController {
194
225
  return;
195
226
  }
196
227
  }
197
- const meshUser = `user//${userId}___${(_f = nexus_epm_user_id.rows[0]) === null || _f === void 0 ? void 0 : _f.id}`.toLowerCase();
198
- const meshUserWithoutDomain = `${userId}___${(_g = nexus_epm_user_id.rows[0]) === null || _g === void 0 ? void 0 : _g.id}`.toLowerCase();
228
+ const meshUser = `user//${userId}___${(_g = nexus_epm_user_id.rows[0]) === null || _g === void 0 ? void 0 : _g.id}`.toLowerCase();
229
+ const meshUserWithoutDomain = `${userId}___${(_h = nexus_epm_user_id.rows[0]) === null || _h === void 0 ? void 0 : _h.id}`.toLowerCase();
199
230
  const meshUsers = [
200
231
  {
201
232
  meshId: meshUser,
202
233
  meshUserName: meshUserWithoutDomain,
203
- fullName: `${(_h = nexus_epm_user_id.rows[0]) === null || _h === void 0 ? void 0 : _h.first_name} ${(_j = nexus_epm_user_id.rows[0]) === null || _j === void 0 ? void 0 : _j.last_name}`,
204
- email: ((_k = nexus_epm_user_id.rows[0]) === null || _k === void 0 ? void 0 : _k.email) || "",
234
+ fullName: `${(_j = nexus_epm_user_id.rows[0]) === null || _j === void 0 ? void 0 : _j.first_name} ${(_k = nexus_epm_user_id.rows[0]) === null || _k === void 0 ? void 0 : _k.last_name}`,
235
+ email: ((_l = nexus_epm_user_id.rows[0]) === null || _l === void 0 ? void 0 : _l.email) || "",
205
236
  },
206
237
  ];
207
238
  const { createdUsers, existingUsers, failedToCreate } = await this.createMeshUsers(meshUsers);
208
239
  if (failedToCreate.length == 1) {
209
240
  const errorResponse = {
210
- error: `User with id ${(_l = nexus_epm_user_id.rows[0]) === null || _l === void 0 ? void 0 : _l.id} Could not be created in Nexus Mesh!`,
241
+ error: `User with id ${(_m = nexus_epm_user_id.rows[0]) === null || _m === void 0 ? void 0 : _m.id} Could not be created in Nexus Mesh!`,
211
242
  timestamp: new Date().toISOString(),
212
243
  };
213
244
  res.status(500).json(errorResponse);
@@ -18,7 +18,7 @@ class HealthController extends BaseController_1.BaseController {
18
18
  this.status = (req, res) => {
19
19
  const response = {
20
20
  service: "aux-server",
21
- version: "1.0.19",
21
+ version: "1.0.21",
22
22
  meshCentral: {
23
23
  connected: this.isWebSocketConnected,
24
24
  server: this.meshServer,
@@ -14,7 +14,8 @@ export declare const addUserToGroupSchema: z.ZodObject<{
14
14
  users: z.ZodArray<z.ZodString>;
15
15
  }, z.core.$strip>;
16
16
  export declare const generateConnectUrlsSchema: z.ZodObject<{
17
- meshNodeId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
17
+ meshNodeId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
18
+ agentId: z.ZodOptional<z.ZodString>;
18
19
  userId: z.ZodString;
19
20
  isApplet: z.ZodPipe<z.ZodOptional<z.ZodBoolean>, z.ZodTransform<boolean | undefined, boolean | undefined>>;
20
21
  }, z.core.$strip>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/schemas/index.ts"],"names":[],"mappings":"AAA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CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC/E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACzE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,yBAAyB,CACjC,CAAC;AACF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,8BAA8B,CACtC,CAAC"}
@@ -155,7 +155,8 @@ exports.addUserToGroupSchema = zod_1.default
155
155
  message: "Both deviceGroupName and deviceGroupId must be provided",
156
156
  path: ["deviceGroupName", "deviceGroupId"],
157
157
  });
158
- exports.generateConnectUrlsSchema = zod_1.default.object({
158
+ exports.generateConnectUrlsSchema = zod_1.default
159
+ .object({
159
160
  meshNodeId: zod_1.default
160
161
  .string()
161
162
  .min(1, "Hex identifier cannot be empty")
@@ -171,7 +172,9 @@ exports.generateConnectUrlsSchema = zod_1.default.object({
171
172
  }, {
172
173
  message: "Hex identifier too short. Must have at least 8 characters",
173
174
  })
174
- .transform((value) => value.toUpperCase()),
175
+ .transform((value) => value.toUpperCase())
176
+ .optional(),
177
+ agentId: zod_1.default.string().min(1, "Agent ID cannot be empty").optional(),
175
178
  userId: zod_1.default
176
179
  .string()
177
180
  .min(1, "User ID cannot be empty")
@@ -203,6 +206,13 @@ exports.generateConnectUrlsSchema = zod_1.default.object({
203
206
  message: "isApplet must be a boolean value",
204
207
  })
205
208
  .transform((value) => (value === undefined ? undefined : Boolean(value))),
209
+ })
210
+ .refine((data) => {
211
+ // At least one of meshNodeId or agentId must be provided
212
+ return data.meshNodeId !== undefined || data.agentId !== undefined;
213
+ }, {
214
+ message: "Either meshNodeId or agentId must be provided",
215
+ path: ["meshNodeId"],
206
216
  });
207
217
  exports.getEndpointInstallScriptSchema = zod_1.default
208
218
  .object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meru2802/aux-server",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Nexus EPM auxillary server to facilitate additional functionality required by Scogo Iceberg",
5
5
  "main": "index.js",
6
6
  "files": [