@meru2802/aux-server 1.0.19 → 1.0.20

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,CAwGtE;IAEK,cAAc,GACnB,KAAK,OAAO,EACZ,KAAK,QAAQ,KACZ,OAAO,CAAC,IAAI,CAAC,CAkUd;CACH"}
@@ -100,14 +100,44 @@ class ApiController extends BaseController_1.BaseController {
100
100
  }
101
101
  };
102
102
  this.getConnectUrls = async (req, res) => {
103
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
103
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
104
104
  try {
105
- const meshNodeId = req.body.meshNodeId;
106
105
  const userId = req.body.userId;
106
+ let meshNodeId = req.body.meshNodeId;
107
+ const agentId = req.body.agentId;
107
108
  const isApplet = req.body.isApplet;
108
- if (!meshNodeId || !userId) {
109
+ if (!meshNodeId && !agentId) {
109
110
  const errorResponse = {
110
- error: "'meshNodeId' or 'userId' are missing in body params",
111
+ error: "Either 'meshNodeId' or 'agentId' must be present in body",
112
+ timestamp: new Date().toISOString(),
113
+ };
114
+ res.status(400).json(errorResponse);
115
+ return;
116
+ }
117
+ if (!userId) {
118
+ const errorResponse = {
119
+ error: "'userId' is missing in body params",
120
+ timestamp: new Date().toISOString(),
121
+ };
122
+ res.status(400).json(errorResponse);
123
+ return;
124
+ }
125
+ if (!meshNodeId && agentId) {
126
+ const nexus_epm_mesh_node_id_query = "SELECT mesh_node_id FROM agents_agent where agent_id = $1";
127
+ const nexus_epm_mesh_node_id = await this.dbPool.query(nexus_epm_mesh_node_id_query, [agentId]);
128
+ if (nexus_epm_mesh_node_id.rows.length === 0) {
129
+ const errorResponse = {
130
+ error: `Mesh Node Id corresponding to Agent ID: '${agentId}' Not Found`,
131
+ timestamp: new Date().toISOString(),
132
+ };
133
+ res.status(400).json(errorResponse);
134
+ return;
135
+ }
136
+ meshNodeId = (_a = nexus_epm_mesh_node_id.rows[0]) === null || _a === void 0 ? void 0 : _a.mesh_node_id;
137
+ }
138
+ if (!meshNodeId) {
139
+ const errorResponse = {
140
+ error: "'meshNodeId' is missing",
111
141
  timestamp: new Date().toISOString(),
112
142
  };
113
143
  res.status(400).json(errorResponse);
@@ -126,7 +156,7 @@ class ApiController extends BaseController_1.BaseController {
126
156
  if (!isApplet) {
127
157
  const nexus_epm_agent_id_query = "SELECT agent_id, site_id FROM agents_agent where mesh_node_id= $1";
128
158
  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)) {
159
+ if (!((_b = nexus_epm_user_id.rows[0]) === null || _b === void 0 ? void 0 : _b.role_id)) {
130
160
  const errorResponse = {
131
161
  error: `'Role id corresponding to user ${userId}' Not Found`,
132
162
  timestamp: new Date().toISOString(),
@@ -144,11 +174,11 @@ class ApiController extends BaseController_1.BaseController {
144
174
  }
145
175
  const nexus_epm_agent_client_id_query = "SELECT client_id FROM clients_site WHERE id= $1";
146
176
  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,
177
+ (_c = nexus_epm_agent_id.rows[0]) === null || _c === void 0 ? void 0 : _c.site_id,
148
178
  ]);
149
179
  if (nexus_epm_agent_client_id.rows.length === 0) {
150
180
  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`,
181
+ 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
182
  timestamp: new Date().toISOString(),
153
183
  };
154
184
  res.status(400).json(errorResponse);
@@ -158,10 +188,10 @@ class ApiController extends BaseController_1.BaseController {
158
188
  const nexus_epm_role_site_ids_query = "SELECT site_id FROM accounts_role_can_view_sites WHERE role_id= $1";
159
189
  const [nexus_epm_role_client_ids, nexus_epm_role_site_ids] = await Promise.all([
160
190
  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,
191
+ (_e = nexus_epm_user_id.rows[0]) === null || _e === void 0 ? void 0 : _e.role_id,
162
192
  ]),
163
193
  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,
194
+ (_f = nexus_epm_user_id.rows[0]) === null || _f === void 0 ? void 0 : _f.role_id,
165
195
  ]),
166
196
  ]);
167
197
  const roleHasPermissionForAgentClient = () => {
@@ -194,20 +224,20 @@ class ApiController extends BaseController_1.BaseController {
194
224
  return;
195
225
  }
196
226
  }
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();
227
+ const meshUser = `user//${userId}___${(_g = nexus_epm_user_id.rows[0]) === null || _g === void 0 ? void 0 : _g.id}`.toLowerCase();
228
+ const meshUserWithoutDomain = `${userId}___${(_h = nexus_epm_user_id.rows[0]) === null || _h === void 0 ? void 0 : _h.id}`.toLowerCase();
199
229
  const meshUsers = [
200
230
  {
201
231
  meshId: meshUser,
202
232
  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) || "",
233
+ 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}`,
234
+ email: ((_l = nexus_epm_user_id.rows[0]) === null || _l === void 0 ? void 0 : _l.email) || "",
205
235
  },
206
236
  ];
207
237
  const { createdUsers, existingUsers, failedToCreate } = await this.createMeshUsers(meshUsers);
208
238
  if (failedToCreate.length == 1) {
209
239
  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!`,
240
+ 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
241
  timestamp: new Date().toISOString(),
212
242
  };
213
243
  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.20",
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":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EACL,UAAU,EACV,gBAAgB,EAGjB,MAAM,IAAI,CAAC;AAEZ,eAAO,MAAM,0BAA0B;;;iBAkEpC,CAAC;AAEJ,eAAO,MAAM,uBAAuB;;;iBA+BlC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;iBAkH9B,CAAC;AAEJ,eAAO,MAAM,yBAAyB;;;;iBAmEpC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;kBA8BvC,CAAC;AAEL,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,0BAA0B,CAClC,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EACL,UAAU,EACV,gBAAgB,EAGjB,MAAM,IAAI,CAAC;AAEZ,eAAO,MAAM,0BAA0B;;;iBAkEpC,CAAC;AAEJ,eAAO,MAAM,uBAAuB;;;iBA+BlC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;iBAkH9B,CAAC;AAEJ,eAAO,MAAM,yBAAyB;;;;;iBAgFnC,CAAC;AAEJ,eAAO,MAAM,8BAA8B;;;;;;;kBA8BvC,CAAC;AAEL,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,0BAA0B,CAClC,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.20",
4
4
  "description": "Nexus EPM auxillary server to facilitate additional functionality required by Scogo Iceberg",
5
5
  "main": "index.js",
6
6
  "files": [