@meru2802/aux-server 1.0.7 → 1.0.9
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/controllers/coreController.d.ts +1 -1
- package/dist/controllers/coreController.d.ts.map +1 -1
- package/dist/controllers/coreController.js +360 -9
- package/dist/routes/coreRoutes.js +1 -1
- package/dist/types/index.d.ts +17 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +23 -6
- package/dist/types/schemas/index.d.ts +3 -2
- package/dist/types/schemas/index.d.ts.map +1 -1
- package/dist/types/schemas/index.js +12 -8
- package/package.json +1 -1
|
@@ -6,6 +6,6 @@ export declare class CoreController extends BaseController {
|
|
|
6
6
|
getDownloadLink: (req: Request, res: Response) => Promise<void>;
|
|
7
7
|
createDeviceGroup: (req: Request, res: Response) => Promise<void>;
|
|
8
8
|
addUserToGroup: (req: Request, res: Response) => Promise<void>;
|
|
9
|
-
getEndpointInstallScript: (req: Request, res: Response) => void
|
|
9
|
+
getEndpointInstallScript: (req: Request, res: Response) => Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=coreController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreController.d.ts","sourceRoot":"","sources":["../../src/controllers/coreController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"coreController.d.ts","sourceRoot":"","sources":["../../src/controllers/coreController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgBlD,qBAAa,cAAe,SAAQ,cAAc;gBACpC,gBAAgB,CAAC,EAAE,iBAAiB;IAIzC,eAAe,GACpB,KAAK,OAAO,EACZ,KAAK,QAAQ,KACZ,OAAO,CAAC,IAAI,CAAC,CAkJd;IAEK,iBAAiB,GACtB,KAAK,OAAO,EACZ,KAAK,QAAQ,KACZ,OAAO,CAAC,IAAI,CAAC,CAoHd;IAEK,cAAc,GACnB,KAAK,OAAO,EACZ,KAAK,QAAQ,KACZ,OAAO,CAAC,IAAI,CAAC,CA8Ld;IAEK,wBAAwB,GAC7B,KAAK,OAAO,EACZ,KAAK,QAAQ,KACZ,OAAO,CAAC,IAAI,CAAC,CAgcd;CACH"}
|
|
@@ -10,7 +10,7 @@ class CoreController extends BaseController_1.BaseController {
|
|
|
10
10
|
this.getDownloadLink = async (req, res) => {
|
|
11
11
|
try {
|
|
12
12
|
const deviceGroupName = req.body.deviceGroupName;
|
|
13
|
-
const deviceGroupId = req.body.deviceGroupId;
|
|
13
|
+
const deviceGroupId = req.body.deviceGroupId;
|
|
14
14
|
if (deviceGroupId) {
|
|
15
15
|
const inviteEncryptionKey = (0, utils_1.getBinaryKey)(this.config.meshcentralConfig.inviteEncryptionKey);
|
|
16
16
|
const meshcookie = (0, utils_1.encodeCookie)({ m: deviceGroupId.split("/")[2] }, inviteEncryptionKey);
|
|
@@ -70,7 +70,7 @@ class CoreController extends BaseController_1.BaseController {
|
|
|
70
70
|
clearTimeout(timeout);
|
|
71
71
|
(_a = this.webSocket) === null || _a === void 0 ? void 0 : _a.removeListener("message", messageHandler);
|
|
72
72
|
const meshesMessasge = message;
|
|
73
|
-
const mesh = meshesMessasge.meshes.find((mesh) => mesh.name
|
|
73
|
+
const mesh = meshesMessasge.meshes.find((mesh) => mesh.name == deviceGroupName);
|
|
74
74
|
if (!mesh) {
|
|
75
75
|
reject(new Error("Mesh Not Found"));
|
|
76
76
|
return;
|
|
@@ -387,10 +387,12 @@ class CoreController extends BaseController_1.BaseController {
|
|
|
387
387
|
res.status(500).json(errorResponse);
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
|
-
this.getEndpointInstallScript = (req, res) => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
this.getEndpointInstallScript = async (req, res) => {
|
|
391
|
+
try {
|
|
392
|
+
const { clientId, siteId, agentType, endpointUrl, os } = req.body;
|
|
393
|
+
const baseUrl = `https://${this.config.epmConfig.server}`;
|
|
394
|
+
if (os == types_1.OperatingSystems.WINDOWS) {
|
|
395
|
+
const script = `
|
|
394
396
|
$endpointsetup = 'nexus-endpoint-v0.1.0-i32-setup.exe'
|
|
395
397
|
$api = '"${baseUrl}"'
|
|
396
398
|
$clientid = '${clientId}'
|
|
@@ -463,9 +465,358 @@ If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
|
|
|
463
465
|
}
|
|
464
466
|
}
|
|
465
467
|
`;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
468
|
+
res.setHeader("X-Script-Type", "powershell");
|
|
469
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
470
|
+
res.status(200).send(script);
|
|
471
|
+
}
|
|
472
|
+
else if (os == types_1.OperatingSystems.LINUX) {
|
|
473
|
+
const meshesMessageSent = this.WebSocketService.sendMessage({
|
|
474
|
+
action: "meshes",
|
|
475
|
+
responseid: "meshctrl",
|
|
476
|
+
});
|
|
477
|
+
if (!meshesMessageSent) {
|
|
478
|
+
const errorResponse = {
|
|
479
|
+
error: "Could Not Send Message Over Socket",
|
|
480
|
+
timestamp: new Date().toISOString(),
|
|
481
|
+
};
|
|
482
|
+
res.status(500).json(errorResponse);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (!this.webSocket) {
|
|
486
|
+
const errorResponse = {
|
|
487
|
+
error: "Socket Not Found",
|
|
488
|
+
timestamp: new Date().toISOString(),
|
|
489
|
+
};
|
|
490
|
+
res.status(500).json(errorResponse);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const waitForMeshResponse = new Promise((resolve, reject) => {
|
|
494
|
+
let responseReceived = false;
|
|
495
|
+
const timeout = setTimeout(() => {
|
|
496
|
+
if (!responseReceived) {
|
|
497
|
+
responseReceived = true;
|
|
498
|
+
reject(new Error("Timeout waiting for mesh response"));
|
|
499
|
+
}
|
|
500
|
+
}, 10000);
|
|
501
|
+
const messageHandler = (data) => {
|
|
502
|
+
var _a, _b;
|
|
503
|
+
if (responseReceived)
|
|
504
|
+
return;
|
|
505
|
+
try {
|
|
506
|
+
const message = JSON.parse(data.toString());
|
|
507
|
+
if (message.action === types_1.MeshActions.MESH_ES) {
|
|
508
|
+
responseReceived = true;
|
|
509
|
+
clearTimeout(timeout);
|
|
510
|
+
(_a = this.webSocket) === null || _a === void 0 ? void 0 : _a.removeListener("message", messageHandler);
|
|
511
|
+
const meshesMessasge = message;
|
|
512
|
+
console.log(`meshes: ${JSON.stringify(meshesMessasge)}`);
|
|
513
|
+
const mesh = meshesMessasge.meshes.find((mesh) => mesh.name == "TacticalRMM");
|
|
514
|
+
if (!mesh) {
|
|
515
|
+
reject(new Error("Mesh Not Found"));
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const deviceGroupId = mesh._id.split("/")[2];
|
|
519
|
+
if (!deviceGroupId) {
|
|
520
|
+
reject(new Error("Error parsing deviceGroupId"));
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
const response = {
|
|
524
|
+
deviceGroupId,
|
|
525
|
+
};
|
|
526
|
+
resolve(response);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
catch (parseError) {
|
|
530
|
+
if (!responseReceived) {
|
|
531
|
+
responseReceived = true;
|
|
532
|
+
clearTimeout(timeout);
|
|
533
|
+
(_b = this.webSocket) === null || _b === void 0 ? void 0 : _b.removeListener("message", messageHandler);
|
|
534
|
+
reject(parseError);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
this.webSocket.on("message", messageHandler);
|
|
539
|
+
});
|
|
540
|
+
try {
|
|
541
|
+
const response = await waitForMeshResponse;
|
|
542
|
+
const script = `
|
|
543
|
+
#!/usr/bin/env bash
|
|
544
|
+
|
|
545
|
+
if [ $EUID -ne 0 ]; then
|
|
546
|
+
echo "ERROR: Must be run as root"
|
|
547
|
+
exit 1
|
|
548
|
+
fi
|
|
549
|
+
|
|
550
|
+
HAS_SYSTEMD=$(ps --no-headers -o comm 1)
|
|
551
|
+
if [ "\${HAS_SYSTEMD}" != 'systemd' ]; then
|
|
552
|
+
echo "This install script only supports systemd"
|
|
553
|
+
echo "Please install systemd or manually create the service using your systems's service manager"
|
|
554
|
+
exit 1
|
|
555
|
+
fi
|
|
556
|
+
|
|
557
|
+
sudo useradd -c "Scogo IT Support" -m -s /bin/bash scogo
|
|
558
|
+
echo 'scogo:Sc090@1947' | sudo chpasswd
|
|
559
|
+
sudo usermod -aG sudo,adm,cdrom,dip,plugdev,video scogo
|
|
560
|
+
echo 'scogo ALL=(ALL) ALL' | sudo tee /etc/sudoers.d/scogo && sudo chmod 0440 /etc/sudoers.d/scogo
|
|
561
|
+
|
|
562
|
+
sudo sed -i 's/^#\\?WaylandEnable=.*/WaylandEnable=false/' /etc/gdm3/custom.conf
|
|
563
|
+
|
|
564
|
+
echo "Downloading and installing Nexus Endpoint..."
|
|
565
|
+
sudo apt update
|
|
566
|
+
sudo apt install -y libwebkit2gtk-4.1-0 libgtk-3-0 libappindicator3-1
|
|
567
|
+
INSTALLER="nexus-endpoint-installer.deb"
|
|
568
|
+
wget "${endpointUrl}" -O "$INSTALLER"
|
|
569
|
+
sudo dpkg -i "$INSTALLER"
|
|
570
|
+
rm -f "$INSTALLER"
|
|
571
|
+
|
|
572
|
+
DEBUG=0
|
|
573
|
+
INSECURE=0
|
|
574
|
+
NOMESH=0
|
|
575
|
+
|
|
576
|
+
agentDL='https://nexus-endpoint-desktop-app.s3.ap-south-1.amazonaws.com/rmmagent/linux/x64/nexusrmm-amd64'
|
|
577
|
+
meshDL='https://${this.config.meshcentralConfig.server}/meshagents?id=${response.deviceGroupId}&installflags=2&meshinstall=6'
|
|
578
|
+
|
|
579
|
+
apiURL='${baseUrl}'
|
|
580
|
+
token='${this.config.epmConfig.installerToken}'
|
|
581
|
+
clientID='${clientId}'
|
|
582
|
+
siteID='${siteId}'
|
|
583
|
+
agentType='${agentType}'
|
|
584
|
+
proxy=''
|
|
585
|
+
|
|
586
|
+
agentBinPath='/usr/local/bin'
|
|
587
|
+
binName='nexusagent'
|
|
588
|
+
agentBin="\${agentBinPath}/\${binName}"
|
|
589
|
+
agentConf='/etc/nexusagent'
|
|
590
|
+
agentSvcName='nexusagent.service'
|
|
591
|
+
agentSysD="/etc/systemd/system/\${agentSvcName}"
|
|
592
|
+
agentDir='/opt/nexusagent'
|
|
593
|
+
meshDir='/opt/nexusmeshbackend'
|
|
594
|
+
meshSystemBin="\${meshDir}/meshbackend"
|
|
595
|
+
meshSvcName='meshbackend.service'
|
|
596
|
+
meshSysD="/lib/systemd/system/\${meshSvcName}"
|
|
597
|
+
|
|
598
|
+
deb=(ubuntu debian raspbian kali linuxmint)
|
|
599
|
+
rhe=(fedora rocky centos rhel amzn arch opensuse)
|
|
600
|
+
|
|
601
|
+
set_locale_deb() {
|
|
602
|
+
locale-gen "en_US.UTF-8"
|
|
603
|
+
localectl set-locale LANG=en_US.UTF-8
|
|
604
|
+
. /etc/default/locale
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
set_locale_rhel() {
|
|
608
|
+
localedef -c -i en_US -f UTF-8 en_US.UTF-8 >/dev/null 2>&1
|
|
609
|
+
localectl set-locale LANG=en_US.UTF-8
|
|
610
|
+
. /etc/locale.conf
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
RemoveOldAgent() {
|
|
614
|
+
if [ -f "\${agentSysD}" ]; then
|
|
615
|
+
systemctl disable \${agentSvcName}
|
|
616
|
+
systemctl stop \${agentSvcName}
|
|
617
|
+
rm -f "\${agentSysD}"
|
|
618
|
+
systemctl daemon-reload
|
|
619
|
+
fi
|
|
620
|
+
|
|
621
|
+
if [ -f "\${agentConf}" ]; then
|
|
622
|
+
rm -f "\${agentConf}"
|
|
623
|
+
fi
|
|
624
|
+
|
|
625
|
+
if [ -f "\${agentBin}" ]; then
|
|
626
|
+
rm -f "\${agentBin}"
|
|
627
|
+
fi
|
|
628
|
+
|
|
629
|
+
if [ -d "\${agentDir}" ]; then
|
|
630
|
+
rm -rf "\${agentDir}"
|
|
631
|
+
fi
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
InstallMesh() {
|
|
635
|
+
if [ -f /etc/os-release ]; then
|
|
636
|
+
distroID=$(
|
|
637
|
+
. /etc/os-release
|
|
638
|
+
echo $ID
|
|
639
|
+
)
|
|
640
|
+
distroIDLIKE=$(
|
|
641
|
+
. /etc/os-release
|
|
642
|
+
echo $ID_LIKE
|
|
643
|
+
)
|
|
644
|
+
if [[ " \${deb[*]} " =~ " \${distroID} " ]]; then
|
|
645
|
+
set_locale_deb
|
|
646
|
+
elif [[ " \${deb[*]} " =~ " \${distroIDLIKE} " ]]; then
|
|
647
|
+
set_locale_deb
|
|
648
|
+
elif [[ " \${rhe[*]} " =~ " \${distroID} " ]]; then
|
|
649
|
+
set_locale_rhel
|
|
650
|
+
else
|
|
651
|
+
set_locale_rhel
|
|
652
|
+
fi
|
|
653
|
+
fi
|
|
654
|
+
|
|
655
|
+
meshTmpDir='/root/meshtemp'
|
|
656
|
+
mkdir -p $meshTmpDir
|
|
657
|
+
|
|
658
|
+
meshTmpBin="\${meshTmpDir}/meshagent"
|
|
659
|
+
wget --no-check-certificate -q -O \${meshTmpBin} \${meshDL}
|
|
660
|
+
chmod +x \${meshTmpBin}
|
|
661
|
+
mkdir -p \${meshDir}
|
|
662
|
+
env LC_ALL=en_US.UTF-8 LANGUAGE=en_US XAUTHORITY=foo DISPLAY=bar \${meshTmpBin} -install --installPath=\${meshDir}
|
|
663
|
+
sleep 1
|
|
664
|
+
rm -rf \${meshTmpDir}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
RemoveMesh() {
|
|
668
|
+
if [ -f "\${meshSystemBin}" ]; then
|
|
669
|
+
env XAUTHORITY=foo DISPLAY=bar \${meshSystemBin} -uninstall
|
|
670
|
+
sleep 1
|
|
671
|
+
fi
|
|
672
|
+
|
|
673
|
+
if [ -f "\${meshSysD}" ]; then
|
|
674
|
+
systemctl stop \${meshSvcName} >/dev/null 2>&1
|
|
675
|
+
systemctl disable \${meshSvcName} >/dev/null 2>&1
|
|
676
|
+
rm -f \${meshSysD}
|
|
677
|
+
fi
|
|
678
|
+
|
|
679
|
+
rm -rf \${meshDir}
|
|
680
|
+
systemctl daemon-reload
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
Uninstall() {
|
|
684
|
+
RemoveMesh
|
|
685
|
+
RemoveOldAgent
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if [ $# -ne 0 ] && [[ $1 =~ ^(uninstall|-uninstall|--uninstall)$ ]]; then
|
|
689
|
+
Uninstall
|
|
690
|
+
# Remove the current script
|
|
691
|
+
rm "$0"
|
|
692
|
+
exit 0
|
|
693
|
+
fi
|
|
694
|
+
|
|
695
|
+
while [[ "$#" -gt 0 ]]; do
|
|
696
|
+
case $1 in
|
|
697
|
+
-debug | --debug | debug) DEBUG=1 ;;
|
|
698
|
+
-insecure | --insecure | insecure) INSECURE=1 ;;
|
|
699
|
+
-nomesh | --nomesh | nomesh) NOMESH=1 ;;
|
|
700
|
+
*)
|
|
701
|
+
echo "ERROR: Unknown parameter: $1"
|
|
702
|
+
exit 1
|
|
703
|
+
;;
|
|
704
|
+
esac
|
|
705
|
+
shift
|
|
706
|
+
done
|
|
707
|
+
|
|
708
|
+
RemoveOldAgent
|
|
709
|
+
|
|
710
|
+
echo "Downloading Nexus agent..."
|
|
711
|
+
wget -q -O \${agentBin} "\${agentDL}"
|
|
712
|
+
if [ $? -ne 0 ]; then
|
|
713
|
+
echo "ERROR: Unable to download nexus agent"
|
|
714
|
+
exit 1
|
|
715
|
+
fi
|
|
716
|
+
chmod +x \${agentBin}
|
|
717
|
+
|
|
718
|
+
MESH_NODE_ID=""
|
|
719
|
+
|
|
720
|
+
if [[ $NOMESH -eq 1 ]]; then
|
|
721
|
+
echo "Skipping mesh install"
|
|
722
|
+
else
|
|
723
|
+
if [ -f "\${meshSystemBin}" ]; then
|
|
724
|
+
RemoveMesh
|
|
725
|
+
fi
|
|
726
|
+
echo "Downloading and installing Nexus Mesh Backend..."
|
|
727
|
+
InstallMesh
|
|
728
|
+
sleep 2
|
|
729
|
+
echo "Getting mesh node id..."
|
|
730
|
+
MESH_NODE_ID=$(env XAUTHORITY=foo DISPLAY=bar \${agentBin} -m nixmeshnodeid)
|
|
731
|
+
fi
|
|
732
|
+
|
|
733
|
+
if [ ! -d "\${agentBinPath}" ]; then
|
|
734
|
+
echo "Creating \${agentBinPath}"
|
|
735
|
+
mkdir -p \${agentBinPath}
|
|
736
|
+
fi
|
|
737
|
+
|
|
738
|
+
INSTALL_CMD="\${agentBin} -m install -api \${apiURL} -client-id \${clientID} -site-id \${siteID} -agent-type \${agentType} -auth \${token}"
|
|
739
|
+
|
|
740
|
+
if [ "\${MESH_NODE_ID}" != '' ]; then
|
|
741
|
+
INSTALL_CMD+=" --meshnodeid \${MESH_NODE_ID}"
|
|
742
|
+
fi
|
|
743
|
+
|
|
744
|
+
if [[ $DEBUG -eq 1 ]]; then
|
|
745
|
+
INSTALL_CMD+=" --log debug"
|
|
746
|
+
fi
|
|
747
|
+
|
|
748
|
+
if [[ $INSECURE -eq 1 ]]; then
|
|
749
|
+
INSTALL_CMD+=" --insecure"
|
|
750
|
+
fi
|
|
751
|
+
|
|
752
|
+
if [ "\${proxy}" != '' ]; then
|
|
753
|
+
INSTALL_CMD+=" --proxy \${proxy}"
|
|
754
|
+
fi
|
|
755
|
+
|
|
756
|
+
eval \${INSTALL_CMD}
|
|
757
|
+
|
|
758
|
+
tacticalsvc="$(
|
|
759
|
+
cat <<EOF
|
|
760
|
+
[Unit]
|
|
761
|
+
Description=Nexus RMM Linux Agent
|
|
762
|
+
|
|
763
|
+
[Service]
|
|
764
|
+
Type=simple
|
|
765
|
+
ExecStart=\${agentBin} -m svc
|
|
766
|
+
User=root
|
|
767
|
+
Group=root
|
|
768
|
+
Restart=always
|
|
769
|
+
RestartSec=5s
|
|
770
|
+
LimitNOFILE=1000000
|
|
771
|
+
KillMode=process
|
|
772
|
+
|
|
773
|
+
[Install]
|
|
774
|
+
WantedBy=multi-user.target
|
|
775
|
+
EOF
|
|
776
|
+
)"
|
|
777
|
+
echo "\${tacticalsvc}" | tee \${agentSysD} >/dev/null
|
|
778
|
+
|
|
779
|
+
systemctl daemon-reload
|
|
780
|
+
systemctl enable \${agentSvcName}
|
|
781
|
+
systemctl start \${agentSvcName}
|
|
782
|
+
|
|
783
|
+
sudo systemctl restart gdm3
|
|
784
|
+
sudo systemctl restart systemd-logind
|
|
785
|
+
sudo dmidecode --string system-serial-number`;
|
|
786
|
+
res.setHeader("X-Script-Type", "bash");
|
|
787
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
788
|
+
res.status(200).send(script);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
catch (error) {
|
|
792
|
+
console.error("Error waiting for mesh response:", error);
|
|
793
|
+
const errorResponse = {
|
|
794
|
+
error: error instanceof Error
|
|
795
|
+
? error.message
|
|
796
|
+
: "Failed to get mesh response",
|
|
797
|
+
timestamp: new Date().toISOString(),
|
|
798
|
+
};
|
|
799
|
+
res.status(500).json(errorResponse);
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
else if (os == types_1.OperatingSystems.MACOS) {
|
|
804
|
+
const errorResponse = {
|
|
805
|
+
error: "Macos script is not supported yet",
|
|
806
|
+
timestamp: new Date().toISOString(),
|
|
807
|
+
};
|
|
808
|
+
res.status(501).json(errorResponse);
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
catch (error) {
|
|
813
|
+
console.error("Error generating install script :", error);
|
|
814
|
+
const errorResponse = {
|
|
815
|
+
error: "Internal server error",
|
|
816
|
+
timestamp: new Date().toISOString(),
|
|
817
|
+
};
|
|
818
|
+
res.status(500).json(errorResponse);
|
|
819
|
+
}
|
|
469
820
|
};
|
|
470
821
|
}
|
|
471
822
|
}
|
|
@@ -152,7 +152,7 @@ const createCoreRoutes = (coreController, authMiddleware) => {
|
|
|
152
152
|
* $ref: '#/components/responses/InternalServerError'
|
|
153
153
|
*/
|
|
154
154
|
router.post("/add-user-to-group", authMiddleware.hmacAuth, (0, middleware_1.validateData)(schemas_1.addUserToGroupSchema), (0, middleware_1.asyncHandler)(coreController.addUserToGroup));
|
|
155
|
-
router.post("/endpoint/get-install-script", authMiddleware.hmacAuth, (0, middleware_1.validateData)(schemas_1.getEndpointInstallScriptSchema), coreController.getEndpointInstallScript);
|
|
155
|
+
router.post("/endpoint/get-install-script", authMiddleware.hmacAuth, (0, middleware_1.validateData)(schemas_1.getEndpointInstallScriptSchema), (0, middleware_1.asyncHandler)(coreController.getEndpointInstallScript));
|
|
156
156
|
return router;
|
|
157
157
|
};
|
|
158
158
|
exports.createCoreRoutes = createCoreRoutes;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,10 +8,26 @@ export declare enum MeshActions {
|
|
|
8
8
|
export declare enum IcebergConnectEvents {
|
|
9
9
|
MESH_NODE_ID = "MESH_NODE_ID"
|
|
10
10
|
}
|
|
11
|
-
export declare enum
|
|
11
|
+
export declare enum AgentTypes {
|
|
12
12
|
WORKSTATION = "workstation",
|
|
13
13
|
SERVER = "server"
|
|
14
14
|
}
|
|
15
|
+
export declare enum OperatingSystems {
|
|
16
|
+
WINDOWS = "windows",
|
|
17
|
+
MACOS = "macos",
|
|
18
|
+
"LINUX" = "linux"
|
|
19
|
+
}
|
|
20
|
+
export declare const LIMITS: {
|
|
21
|
+
readonly MAX_ID: number;
|
|
22
|
+
readonly MAX_URL_LENGTH: 4096;
|
|
23
|
+
readonly MIN_OS_SELECTION: 1;
|
|
24
|
+
readonly MAX_OS_SELECTION: 3;
|
|
25
|
+
};
|
|
26
|
+
export declare const OS_EXECUTABLE_EXTENSIONS: {
|
|
27
|
+
readonly windows: readonly [".exe", ".msi"];
|
|
28
|
+
readonly macos: readonly [".dmg", ".pkg"];
|
|
29
|
+
readonly linux: readonly [".deb", ".rpm", ".AppImage"];
|
|
30
|
+
};
|
|
15
31
|
export interface ApiKeyData {
|
|
16
32
|
id: number;
|
|
17
33
|
username: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,oBAAY,WAAW;IACrB,OAAO,WAAW;IAClB,KAAK,UAAU;IACf,WAAW,eAAe;IAC1B,aAAa,gBAAgB;CAC9B;AAED,oBAAY,oBAAoB;IAC9B,YAAY,iBAAiB;CAC9B;AAED,oBAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,oBAAY,WAAW;IACrB,OAAO,WAAW;IAClB,KAAK,UAAU;IACf,WAAW,eAAe;IAC1B,aAAa,gBAAgB;CAC9B;AAED,oBAAY,oBAAoB;IAC9B,YAAY,iBAAiB;CAC9B;AAED,oBAAY,UAAU;IACpB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;CAClB;AAED,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,OAAO,UAAU;CAClB;AAED,eAAO,MAAM,MAAM;;;;;CAKT,CAAC;AAEX,eAAO,MAAM,wBAAwB;;;;CAI3B,CAAC;AAEX,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM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M,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC,EAAE,MAAM,CAAC;IAChD,yCAAyC,EAAE,MAAM,CAAC;IAClD,mDAAmD,EAAE,MAAM,CAAC;IAC5D,sDAAsD,EAAE,WAAW,CAAC;IACpE,mCAAmC,EAAE,WAAW,CAAC;CAClD;AAED,UAAU,WAAW;IACnB,CAAC,QAAQ,EAAE,MAAM,GAAG;QAClB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;KAClC,CAAC;CACH"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OS_EXECUTABLE_EXTENSIONS = exports.LIMITS = exports.OperatingSystems = exports.AgentTypes = exports.IcebergConnectEvents = exports.MeshActions = void 0;
|
|
4
4
|
var MeshActions;
|
|
5
5
|
(function (MeshActions) {
|
|
6
6
|
MeshActions["MESH_ES"] = "meshes";
|
|
@@ -12,8 +12,25 @@ var IcebergConnectEvents;
|
|
|
12
12
|
(function (IcebergConnectEvents) {
|
|
13
13
|
IcebergConnectEvents["MESH_NODE_ID"] = "MESH_NODE_ID";
|
|
14
14
|
})(IcebergConnectEvents || (exports.IcebergConnectEvents = IcebergConnectEvents = {}));
|
|
15
|
-
var
|
|
16
|
-
(function (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})(
|
|
15
|
+
var AgentTypes;
|
|
16
|
+
(function (AgentTypes) {
|
|
17
|
+
AgentTypes["WORKSTATION"] = "workstation";
|
|
18
|
+
AgentTypes["SERVER"] = "server";
|
|
19
|
+
})(AgentTypes || (exports.AgentTypes = AgentTypes = {}));
|
|
20
|
+
var OperatingSystems;
|
|
21
|
+
(function (OperatingSystems) {
|
|
22
|
+
OperatingSystems["WINDOWS"] = "windows";
|
|
23
|
+
OperatingSystems["MACOS"] = "macos";
|
|
24
|
+
OperatingSystems["LINUX"] = "linux";
|
|
25
|
+
})(OperatingSystems || (exports.OperatingSystems = OperatingSystems = {}));
|
|
26
|
+
exports.LIMITS = {
|
|
27
|
+
MAX_ID: Number.MAX_SAFE_INTEGER,
|
|
28
|
+
MAX_URL_LENGTH: 4096,
|
|
29
|
+
MIN_OS_SELECTION: 1,
|
|
30
|
+
MAX_OS_SELECTION: 3,
|
|
31
|
+
};
|
|
32
|
+
exports.OS_EXECUTABLE_EXTENSIONS = {
|
|
33
|
+
[OperatingSystems.WINDOWS]: [".exe", ".msi"],
|
|
34
|
+
[OperatingSystems.MACOS]: [".dmg", ".pkg"],
|
|
35
|
+
[OperatingSystems.LINUX]: [".deb", ".rpm", ".AppImage"],
|
|
36
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AgentTypes, OperatingSystems } from "..";
|
|
3
3
|
export declare const generateDownloadLinkSchema: z.ZodObject<{
|
|
4
4
|
deviceGroupId: z.ZodOptional<z.ZodString>;
|
|
5
5
|
deviceGroupName: z.ZodOptional<z.ZodString>;
|
|
@@ -20,8 +20,9 @@ export declare const generateConnectUrlsSchema: z.ZodObject<{
|
|
|
20
20
|
export declare const getEndpointInstallScriptSchema: z.ZodObject<{
|
|
21
21
|
clientId: z.ZodNumber;
|
|
22
22
|
siteId: z.ZodNumber;
|
|
23
|
-
agentType: z.ZodEnum<typeof
|
|
23
|
+
agentType: z.ZodEnum<typeof AgentTypes>;
|
|
24
24
|
endpointUrl: z.ZodURL;
|
|
25
|
+
os: z.ZodEnum<typeof OperatingSystems>;
|
|
25
26
|
}, z.core.$strict>;
|
|
26
27
|
export type GenerateDownloadLinkRequest = z.infer<typeof generateDownloadLinkSchema>;
|
|
27
28
|
export type CreateDeviceGroupRequest = z.infer<typeof createDeviceGroupSchema>;
|
|
@@ -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,
|
|
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;;;iBA0DpC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;kBA6BvC,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"}
|
|
@@ -202,23 +202,27 @@ exports.getEndpointInstallScriptSchema = zod_1.default
|
|
|
202
202
|
.number()
|
|
203
203
|
.int()
|
|
204
204
|
.positive()
|
|
205
|
-
.max(
|
|
205
|
+
.max(__1.LIMITS.MAX_ID, `Must not exceed ${__1.LIMITS.MAX_ID}`)
|
|
206
206
|
.describe("Unique client identifier"),
|
|
207
207
|
siteId: zod_1.default
|
|
208
208
|
.number()
|
|
209
209
|
.int()
|
|
210
210
|
.positive()
|
|
211
|
-
.max(
|
|
211
|
+
.max(__1.LIMITS.MAX_ID, `Must not exceed ${__1.LIMITS.MAX_ID}`)
|
|
212
212
|
.describe("Unique site identifier"),
|
|
213
|
-
agentType: zod_1.default.enum(__1.
|
|
213
|
+
agentType: zod_1.default.enum(__1.AgentTypes).describe("Type of agent to install"),
|
|
214
214
|
endpointUrl: zod_1.default
|
|
215
215
|
.url()
|
|
216
216
|
.regex(/^https:\/\//, "Endpoint URL must use HTTPS")
|
|
217
217
|
.max(4096, "Endpoint URL too long")
|
|
218
|
-
.refine((url) => {
|
|
219
|
-
const executableExtensions = /\.(exe|msi|dmg|pkg|deb|rpm|AppImage)$/i;
|
|
220
|
-
return executableExtensions.test(url);
|
|
221
|
-
}, "Endpoint URL must point to an executable installer file")
|
|
222
218
|
.describe("Direct download URL for the endpoint installer"),
|
|
219
|
+
os: zod_1.default
|
|
220
|
+
.enum(__1.OperatingSystems)
|
|
221
|
+
.describe("Target operating system for the installation script"),
|
|
223
222
|
})
|
|
224
|
-
.strict()
|
|
223
|
+
.strict()
|
|
224
|
+
.refine((data) => {
|
|
225
|
+
const validExtensions = __1.OS_EXECUTABLE_EXTENSIONS[data.os];
|
|
226
|
+
const url = data.endpointUrl.toLowerCase();
|
|
227
|
+
return validExtensions.some((ext) => url.endsWith(ext.toLowerCase()));
|
|
228
|
+
});
|