devicely 2.1.3 → 2.1.5

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.
Files changed (89) hide show
  1. package/bin/devicely.js +105 -1
  2. package/lib/androidDeviceDetection.js +276 -1
  3. package/lib/appMappings.js +337 -1
  4. package/lib/deviceDetection.js +394 -1
  5. package/lib/devices.js +54 -1
  6. package/lib/doctor.js +94 -1
  7. package/lib/executor.js +104 -1
  8. package/lib/logger.js +35 -1
  9. package/lib/scriptLoader.js +75 -0
  10. package/lib/server.js +3483 -1
  11. package/package.json +3 -12
  12. package/scripts/compile-shell-scripts.js +208 -0
  13. package/scripts/encrypt-shell-simple.js +75 -0
  14. package/scripts/obfuscate-shell.js +160 -0
  15. package/scripts/shell/android_device_control +0 -0
  16. package/scripts/shell/android_device_control.sh +848 -0
  17. package/scripts/shell/apps_presets.conf +271 -0
  18. package/scripts/shell/connect_android_usb +0 -0
  19. package/scripts/shell/connect_android_usb_multi_final +0 -0
  20. package/scripts/shell/connect_android_usb_multi_final.sh +289 -0
  21. package/scripts/shell/connect_android_wireless +0 -0
  22. package/scripts/shell/connect_android_wireless.sh +58 -0
  23. package/scripts/shell/connect_android_wireless_multi_final +0 -0
  24. package/scripts/shell/connect_android_wireless_multi_final.sh +476 -0
  25. package/scripts/shell/connect_ios_usb +0 -0
  26. package/scripts/shell/connect_ios_usb_multi_final +0 -0
  27. package/scripts/shell/connect_ios_usb_multi_final.sh +4225 -0
  28. package/scripts/shell/connect_ios_wireless_multi_final +0 -0
  29. package/scripts/shell/connect_ios_wireless_multi_final.sh +4167 -0
  30. package/scripts/shell/create_production_scripts +0 -0
  31. package/scripts/shell/create_production_scripts.sh +38 -0
  32. package/scripts/shell/devices.conf +24 -0
  33. package/scripts/shell/diagnose_wireless_ios +0 -0
  34. package/scripts/shell/find_element_coordinates +0 -0
  35. package/scripts/shell/find_wda +0 -0
  36. package/scripts/shell/install_uiautomator2 +0 -0
  37. package/scripts/shell/install_uiautomator2.sh +93 -0
  38. package/scripts/shell/ios_device_control +0 -0
  39. package/scripts/shell/ios_device_control.sh +220 -0
  40. package/scripts/shell/organize_project +0 -0
  41. package/scripts/shell/organize_project.sh +59 -0
  42. package/scripts/shell/pre-publish-check +0 -0
  43. package/scripts/shell/pre-publish-check.sh +238 -0
  44. package/scripts/shell/publish +0 -0
  45. package/scripts/shell/publish-to-npm +0 -0
  46. package/scripts/shell/publish-to-npm.sh +366 -0
  47. package/scripts/shell/publish.sh +100 -0
  48. package/scripts/shell/setup +0 -0
  49. package/scripts/shell/setup.sh +121 -0
  50. package/scripts/shell/setup_android +0 -0
  51. package/scripts/shell/start +0 -0
  52. package/scripts/shell/start.sh +59 -0
  53. package/scripts/shell/sync-to-npm-package-final +0 -0
  54. package/scripts/shell/sync-to-npm-package-final.sh +60 -0
  55. package/scripts/shell/test-local-package.sh +95 -0
  56. package/scripts/shell/test_android_locators +0 -0
  57. package/scripts/shell/test_connect +0 -0
  58. package/scripts/shell/test_device_detection +0 -0
  59. package/scripts/shell/test_fixes +0 -0
  60. package/scripts/shell/test_getlocators_fix +0 -0
  61. package/scripts/shell/test_recording_feature +0 -0
  62. package/scripts/shell/verify-shell-protection +0 -0
  63. package/scripts/shell/verify-shell-protection.sh +73 -0
  64. package/scripts/shell/verify_distribution +0 -0
  65. package/lib/package-lock.json +0 -1678
  66. package/lib/package.json +0 -30
  67. package/lib/screenshots/screenshot_ios_iPhone17_20260205_225900.png +0 -0
  68. package/lib/screenshots/screenshot_ios_iPhone17_20260205_225942.png +0 -0
  69. package/lib/screenshots/screenshot_ios_iPhone17_20260205_231101.png +0 -0
  70. package/lib/screenshots/screenshot_ios_iPhone17_20260205_232911.png +0 -0
  71. package/lib/screenshots/screenshot_ios_iPhone17_20260208_095103.png +0 -0
  72. package/lib/screenshots/screenshot_ios_iPhone17_20260208_095720.png +0 -0
  73. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115040.png +0 -0
  74. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115047.png +0 -0
  75. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115118.png +0 -0
  76. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115125.png +0 -0
  77. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115143.png +0 -0
  78. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120107.png +0 -0
  79. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120118.png +0 -0
  80. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120137.png +0 -0
  81. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120201.png +0 -0
  82. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_134529.png +0 -0
  83. package/scripts/shell/android_device_control.enc +0 -1
  84. package/scripts/shell/connect_android_usb_multi_final.enc +0 -1
  85. package/scripts/shell/connect_android_wireless.enc +0 -1
  86. package/scripts/shell/connect_android_wireless_multi_final.enc +0 -1
  87. package/scripts/shell/connect_ios_usb_multi_final.enc +0 -1
  88. package/scripts/shell/connect_ios_wireless_multi_final.enc +0 -1
  89. package/scripts/shell/ios_device_control.enc +0 -1
package/lib/executor.js CHANGED
@@ -1 +1,104 @@
1
- function _0x3a6d(_0x3a946b,_0x2c6405){_0x3a946b=_0x3a946b-0x1f1;const _0x1e1e43=_0x1e1e();let _0x3a6d92=_0x1e1e43[_0x3a946b];if(_0x3a6d['zCPjxb']===undefined){var _0x5f56b9=function(_0x4f6a63){const _0x4f8250='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4747dd='',_0x3d0ae0='';for(let _0x45e9ef=0x0,_0x26ade6,_0x543151,_0x5700b0=0x0;_0x543151=_0x4f6a63['charAt'](_0x5700b0++);~_0x543151&&(_0x26ade6=_0x45e9ef%0x4?_0x26ade6*0x40+_0x543151:_0x543151,_0x45e9ef++%0x4)?_0x4747dd+=String['fromCharCode'](0xff&_0x26ade6>>(-0x2*_0x45e9ef&0x6)):0x0){_0x543151=_0x4f8250['indexOf'](_0x543151);}for(let _0x19d03c=0x0,_0xd5c341=_0x4747dd['length'];_0x19d03c<_0xd5c341;_0x19d03c++){_0x3d0ae0+='%'+('00'+_0x4747dd['charCodeAt'](_0x19d03c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3d0ae0);};_0x3a6d['iNgwvx']=_0x5f56b9,_0x3a6d['hArWDq']={},_0x3a6d['zCPjxb']=!![];}const _0x2a1d2e=_0x1e1e43[0x0],_0x4d74e4=_0x3a946b+_0x2a1d2e,_0x146366=_0x3a6d['hArWDq'][_0x4d74e4];return!_0x146366?(_0x3a6d92=_0x3a6d['iNgwvx'](_0x3a6d92),_0x3a6d['hArWDq'][_0x4d74e4]=_0x3a6d92):_0x3a6d92=_0x146366,_0x3a6d92;}const _0xb0355e=_0x3a6d;(function(_0x3c281b,_0x3e15bd){const _0x48bdb7=_0x3a6d,_0x34e50a=_0x3c281b();while(!![]){try{const _0x1adcb0=-parseInt(_0x48bdb7(0x1f6))/0x1+-parseInt(_0x48bdb7(0x21b))/0x2+parseInt(_0x48bdb7(0x20e))/0x3+parseInt(_0x48bdb7(0x201))/0x4*(parseInt(_0x48bdb7(0x236))/0x5)+parseInt(_0x48bdb7(0x202))/0x6+-parseInt(_0x48bdb7(0x233))/0x7+-parseInt(_0x48bdb7(0x1f7))/0x8;if(_0x1adcb0===_0x3e15bd)break;else _0x34e50a['push'](_0x34e50a['shift']());}catch(_0x3e7796){_0x34e50a['push'](_0x34e50a['shift']());}}}(_0x1e1e,0x4c715));const {spawn}=require('child_process'),path=require(_0xb0355e(0x21f)),chalk=require(_0xb0355e(0x1f5));let discoverAllDevices;try{({discoverAllDevices}=require('./deviceDetection'));}catch(_0x47fa2c){({discoverAllDevices}=require(_0xb0355e(0x208)));}function _0x1e1e(){const _0x3214ad=['zxHLy3v0zunVBw1HBMq','rxvYyMW','B25SAw5L','y29UBMvJDf9HBMrYB2LKx3DPCMvSzxnZx211BhrPx2zPBMfSlNnO','EenjCvK','C3rKzxjY','r3zLEuu','cKv4zwn1DgLUzYbVBIa','cUkDJcboBYbKzxzPy2vZigzVDw5K','zMLSDgvY','Aw9Z','mtG4mZi3m3joq2DrCq','t090vge','Bg9N','mZG1CgjSEgrZ','yLP6Che','Du9Hr2C','DNLzrgm','zM9YrwfJAa','CMvK','v0jOB08','DhjPBq','4PQG77IpicbvBNn1ChbVCNrLzcbKzxzPy2uGDhLWztOG','z0rdwxm','ANnVD3a','BMfTzq','tuPvtMW','C3bSAxq','rg1KrLC','ELPVq0C','zhjHz3q','C2rQzgy','y2HHBgS','mZaZmdaWBxnIruXP','otmYmdu2q3DbD2fl','C3rHDhvZ','y3LHBG','z3jHEq','qxrpBw8','rMP3Bve','xsdINiuGu3vJy2vZCWO','cUkDJcbezxzPy2uGiG','sw5vDhO','C3rKAw8','mteXmJbOAK1Vuwu','mJu1nZyYmeXQvNzuwa','icdIGkiG','qvr1wvm','AM9PBG','rLbvq2C','z3jLzw4','lI4VlI4Vzgv2AwnLrgv0zwn0Aw9U','uhLPs3K','yw5KCM9Pza','sNn5B0m','C3rKB3v0','D2LYzwXLC3m','mtC2mJK4oxPkt1bMsG','vLnguwC','tMfNC0u','Dg9tDhjPBMC','zgf0yq','cUkAOo+4JYaGtM8GB25SAw5LigrLDMLJzxmGzM91BMq','wgLwuwi','DhLWzq','zgv2AwnL','zuP6CK8','DeDvC3m','igrLDMLJzsHZktO','wvf5Eu8','nduYnJC2D2DrwvHH','iIbUB3qGzM91BMqGB3iGB2zMBgLUzq','xsdINyWGrMfPBgvKicHLEgL0ignVzgu6ia','vLHytfy','Cgf0Aa','y29UBMvJDf9PB3nFDxnIx211BhrPx2zPBMfSlNnO','BgvUz3rO','tgXMtMG','C0LHt0e','vLPOuxe','EwvSBg93','yNnpA0q','y29UBMvJDf9PB3nFD2LYzwXLC3nFBxvSDgLFzMLUywWUC2G'];_0x1e1e=function(){return _0x3214ad;};return _0x1e1e();}async function executeCommand(_0x29339d,_0xa358ca={}){const _0x236b37=_0xb0355e,_0x544520={'xCIqY':function(_0x50eaec,_0x190781){return _0x50eaec===_0x190781;},'VZhQq':_0x236b37(0x220),'ZUfAI':_0x236b37(0x230),'XiVQb':function(_0x2193a3,_0x3a1bec){return _0x2193a3!==_0x3a1bec;},'WBhoO':_0x236b37(0x1ff),'bZzpq':_0x236b37(0x210),'PyiKy':_0x236b37(0x21e),'gDCYs':function(_0x25444d){return _0x25444d();},'YQyyO':'close','AtOmo':function(_0xc1aa04){return _0xc1aa04();},'MJUNl':_0x236b37(0x20b),'ATuYS':_0x236b37(0x222),'QTesi':function(_0x389c06,_0x36c734){return _0x389c06===_0x36c734;},'GveyE':_0x236b37(0x213),'bsOkD':'../../scripts/shell','nnXNq':_0x236b37(0x229),'eJzrO':_0x236b37(0x239),'DmdFW':function(_0x17324f,_0x114b80){return _0x17324f===_0x114b80;},'ltMAT':_0x236b37(0x232),'sdjdf':'usb','jsowp':_0x236b37(0x20d),'RbngR':_0x236b37(0x234),'FjwmQ':_0x236b37(0x227),'tGUss':_0x236b37(0x20a),'FPUCg':'connect_android_usb_multi_final.sh','Ojjtr':function(_0x14af49,_0x335ada){return _0x14af49===_0x335ada;},'xUHzm':function(_0x531671,_0x2c9183){return _0x531671===_0x2c9183;},'dragt':_0x236b37(0x22b),'ualhi':_0x236b37(0x238),'sIaOA':'pipe','VSFQg':_0x236b37(0x212)},_0x36a6ad=await _0x544520[_0x236b37(0x1fb)](discoverAllDevices);if(!_0x36a6ad||_0x36a6ad[_0x236b37(0x221)]===0x0){if(_0x544520[_0x236b37(0x242)]!==_0x544520['MJUNl']){_0x4ccc64=_0x460a8d[_0x236b37(0x231)](_0x5f298e=>_0x5f298e[_0x236b37(0x241)]===_0xe4e45f[_0x236b37(0x216)]&&_0x5f298e[_0x236b37(0x1f8)]===_0x236b37(0x22a));if(_0x544520[_0x236b37(0x22c)](_0x5962ef[_0x236b37(0x221)],0x0)){_0x31ff44[_0x236b37(0x235)](_0x250480[_0x236b37(0x23b)](_0x236b37(0x1fe)+_0x361823[_0x236b37(0x216)]+_0x236b37(0x21c)));return;}}else{console[_0x236b37(0x235)](chalk[_0x236b37(0x23b)](_0x544520['ZUfAI']));return;}}let _0x39c04a=_0x36a6ad['filter'](_0x5b6ce7=>_0x5b6ce7[_0x236b37(0x1f8)]===_0x236b37(0x22a));if(_0xa358ca[_0x236b37(0x216)]){if(_0x544520[_0x236b37(0x214)](_0x544520['ATuYS'],_0x544520[_0x236b37(0x204)])){_0x1ec783[_0x236b37(0x235)](_0x5168d6[_0x236b37(0x225)](_0x236b37(0x213)));return;}else{_0x39c04a=_0x36a6ad[_0x236b37(0x231)](_0x327174=>_0x327174[_0x236b37(0x241)]===_0xa358ca[_0x236b37(0x216)]&&_0x327174[_0x236b37(0x1f8)]===_0x236b37(0x22a));if(_0x544520['QTesi'](_0x39c04a[_0x236b37(0x221)],0x0)){console[_0x236b37(0x235)](chalk['red'](_0x236b37(0x1fe)+_0xa358ca['device']+_0x236b37(0x21c)));return;}}}if(_0x39c04a[_0x236b37(0x221)]===0x0){console['log'](chalk[_0x236b37(0x225)](_0x544520[_0x236b37(0x22e)]));return;}console['log'](chalk[_0x236b37(0x1f9)](_0x236b37(0x22f)+_0x39c04a[_0x236b37(0x221)]+_0x236b37(0x219))),_0x39c04a[_0x236b37(0x23a)](_0x515637=>console[_0x236b37(0x235)](_0x236b37(0x203)+_0x515637['name'])),console[_0x236b37(0x235)]('');const _0x3ec585=path[_0x236b37(0x205)](__dirname,_0x544520[_0x236b37(0x226)]);for(const _0x40cb48 of _0x39c04a){if(_0x544520['nnXNq']===_0x544520[_0x236b37(0x217)])_0x5452c5=_0x544520[_0x236b37(0x224)];else{const _0x4548ef=_0x40cb48['platform'],_0x3148f5=_0x40cb48[_0x236b37(0x215)];let _0x2df1ad;if(_0x544520[_0x236b37(0x1f1)](_0x4548ef,_0x544520['ltMAT'])&&_0x544520[_0x236b37(0x1f1)](_0x3148f5,_0x544520[_0x236b37(0x1f4)]))_0x2df1ad=_0x544520[_0x236b37(0x224)];else{if(_0x4548ef===_0x236b37(0x232)&&_0x3148f5===_0x544520[_0x236b37(0x240)])_0x544520['xCIqY'](_0x544520['RbngR'],_0x236b37(0x1f2))?_0x3ed911[_0x236b37(0x235)](_0x2a4f01[_0x236b37(0x1fa)]('\x20\x20'+_0x2c2a23)):_0x2df1ad=_0x544520[_0x236b37(0x1fc)];else{if(_0x4548ef===_0x544520[_0x236b37(0x218)]&&_0x3148f5===_0x544520[_0x236b37(0x1f4)])_0x2df1ad=_0x544520[_0x236b37(0x206)];else{if(_0x544520['Ojjtr'](_0x4548ef,_0x544520[_0x236b37(0x218)])&&_0x544520['xUHzm'](_0x3148f5,_0x544520['jsowp']))_0x2df1ad=_0x544520[_0x236b37(0x1f3)];else{if(_0x544520['ualhi']==='LVPHn')_0x5ad1e6='connect_android_wireless_multi_final.sh';else{console[_0x236b37(0x235)](chalk[_0x236b37(0x225)](_0x236b37(0x23e)+_0x4548ef+'-'+_0x3148f5));continue;}}}}}const _0x1258f9=path[_0x236b37(0x205)](_0x3ec585,_0x2df1ad);console['log'](chalk['blue']('['+_0x40cb48['name']+']\x20Running\x20command...'));const _0xb1e432={};_0xb1e432[_0x236b37(0x200)]=_0x544520[_0x236b37(0x223)];const _0x6fc7f4=spawn(_0x1258f9,['-d',_0x40cb48[_0x236b37(0x241)],..._0x29339d[_0x236b37(0x243)]('\x20')],_0xb1e432);_0x6fc7f4[_0x236b37(0x20c)]['on'](_0x544520[_0x236b37(0x20f)],_0x5db2df=>{const _0x3e1c2f=_0x236b37;if(_0x544520['XiVQb'](_0x544520[_0x3e1c2f(0x23c)],'YVQnF')){const _0x4224dd=_0x5db2df[_0x3e1c2f(0x211)]()[_0x3e1c2f(0x243)]('\x0a')[_0x3e1c2f(0x231)](_0x1096ba=>_0x1096ba[_0x3e1c2f(0x23d)]());_0x4224dd[_0x3e1c2f(0x23a)](_0xf957bb=>{const _0x23001c=_0x3e1c2f;console[_0x23001c(0x235)](chalk[_0x23001c(0x1fa)]('\x20\x20'+_0xf957bb));});}else{_0x4503db[_0x3e1c2f(0x235)](_0x121e62[_0x3e1c2f(0x23b)](_0x544520['ZUfAI']));return;}}),_0x6fc7f4[_0x236b37(0x22d)]['on'](_0x544520[_0x236b37(0x20f)],_0x599cbb=>{const _0x6e483f=_0x236b37;if(_0x544520[_0x6e483f(0x22c)](_0x544520[_0x6e483f(0x237)],_0x544520[_0x6e483f(0x209)])){const _0x363770=_0x1e3365[_0x6e483f(0x211)]()['split']('\x0a')[_0x6e483f(0x231)](_0x2458b8=>_0x2458b8[_0x6e483f(0x23d)]());_0x363770['forEach'](_0x2c3bbd=>{const _0x1b4197=_0x6e483f;_0x2aad06[_0x1b4197(0x235)](_0x14f7f5[_0x1b4197(0x1fa)]('\x20\x20'+_0x2c3bbd));});}else{const _0x3e3008=_0x599cbb[_0x6e483f(0x211)]()[_0x6e483f(0x243)]('\x0a')[_0x6e483f(0x231)](_0x1eb27a=>_0x1eb27a[_0x6e483f(0x23d)]());_0x3e3008[_0x6e483f(0x23a)](_0x2174c1=>{const _0xed0a63=_0x6e483f;console[_0xed0a63(0x235)](chalk['red']('\x20\x20'+_0x2174c1));});}}),await new Promise(_0x39c6b2=>{const _0x183768=_0x236b37;_0x6fc7f4['on'](_0x544520[_0x183768(0x21a)],_0x53cb49=>{const _0x300186=_0x183768;_0x544520[_0x300186(0x22c)](_0x53cb49,0x0)?console[_0x300186(0x235)](chalk[_0x300186(0x207)]('['+_0x40cb48[_0x300186(0x241)]+_0x300186(0x1fd))):console[_0x300186(0x235)](chalk[_0x300186(0x23b)]('['+_0x40cb48['name']+_0x300186(0x21d)+_0x53cb49+')\x0a')),_0x544520[_0x300186(0x23f)](_0x39c6b2);});});}}}const _0x15faa0={};_0x15faa0[_0xb0355e(0x228)]=executeCommand,module['exports']=_0x15faa0;
1
+ /**
2
+ * Command executor for Devicely CLI
3
+ */
4
+
5
+ const { spawn } = require('child_process');
6
+ const path = require('path');
7
+ const chalk = require('chalk');
8
+
9
+ // Import deviceDetection from appropriate location
10
+ let discoverAllDevices;
11
+ try {
12
+ ({ discoverAllDevices } = require('./deviceDetection'));
13
+ } catch (err) {
14
+ ({ discoverAllDevices } = require('../../deviceDetection'));
15
+ }
16
+
17
+ async function executeCommand(command, options = {}) {
18
+ const devices = await discoverAllDevices();
19
+
20
+ if (!devices || devices.length === 0) {
21
+ console.log(chalk.red('\n❌ No devices found'));
22
+ return;
23
+ }
24
+
25
+ let targetDevices = devices.filter(d => d.status === 'online');
26
+
27
+ if (options.device) {
28
+ targetDevices = devices.filter(d =>
29
+ d.name === options.device && d.status === 'online'
30
+ );
31
+
32
+ if (targetDevices.length === 0) {
33
+ console.log(chalk.red(`\n❌ Device "${options.device}" not found or offline`));
34
+ return;
35
+ }
36
+ }
37
+
38
+ if (targetDevices.length === 0) {
39
+ console.log(chalk.yellow('\n⚠️ No online devices found'));
40
+ return;
41
+ }
42
+
43
+ console.log(chalk.cyan(`\nExecuting on ${targetDevices.length} device(s):`));
44
+ targetDevices.forEach(d => console.log(` • ${d.name}`));
45
+ console.log('');
46
+
47
+ const scriptDir = path.join(__dirname, '../../scripts/shell');
48
+
49
+ for (const device of targetDevices) {
50
+ const platform = device.platform;
51
+ const type = device.type;
52
+
53
+ let scriptName;
54
+ if (platform === 'ios' && type === 'usb') {
55
+ scriptName = 'connect_ios_usb_multi_final.sh';
56
+ } else if (platform === 'ios' && type === 'wireless') {
57
+ scriptName = 'connect_ios_wireless_multi_final.sh';
58
+ } else if (platform === 'android' && type === 'usb') {
59
+ scriptName = 'connect_android_usb_multi_final.sh';
60
+ } else if (platform === 'android' && type === 'wireless') {
61
+ scriptName = 'connect_android_wireless_multi_final.sh';
62
+ } else {
63
+ console.log(chalk.yellow(`⚠️ Unsupported device type: ${platform}-${type}`));
64
+ continue;
65
+ }
66
+
67
+ const scriptPath = path.join(scriptDir, scriptName);
68
+
69
+ console.log(chalk.blue(`[${device.name}] Running command...`));
70
+
71
+ const child = spawn(scriptPath, ['-d', device.name, ...command.split(' ')], {
72
+ stdio: 'pipe'
73
+ });
74
+
75
+ child.stdout.on('data', (data) => {
76
+ const lines = data.toString().split('\n').filter(l => l.trim());
77
+ lines.forEach(line => {
78
+ console.log(chalk.gray(` ${line}`));
79
+ });
80
+ });
81
+
82
+ child.stderr.on('data', (data) => {
83
+ const lines = data.toString().split('\n').filter(l => l.trim());
84
+ lines.forEach(line => {
85
+ console.log(chalk.red(` ${line}`));
86
+ });
87
+ });
88
+
89
+ await new Promise((resolve) => {
90
+ child.on('close', (code) => {
91
+ if (code === 0) {
92
+ console.log(chalk.green(`[${device.name}] ✅ Success\n`));
93
+ } else {
94
+ console.log(chalk.red(`[${device.name}] ❌ Failed (exit code: ${code})\n`));
95
+ }
96
+ resolve();
97
+ });
98
+ });
99
+ }
100
+ }
101
+
102
+ module.exports = {
103
+ executeCommand
104
+ };
package/lib/logger.js CHANGED
@@ -1 +1,35 @@
1
- const _0xddba86=_0x3297;(function(_0x56107f,_0x423af3){const _0x33e269=_0x3297,_0x16f251=_0x56107f();while(!![]){try{const _0x228bce=parseInt(_0x33e269(0x123))/0x1*(parseInt(_0x33e269(0x12c))/0x2)+-parseInt(_0x33e269(0x129))/0x3+-parseInt(_0x33e269(0x12d))/0x4*(-parseInt(_0x33e269(0x128))/0x5)+parseInt(_0x33e269(0x131))/0x6*(-parseInt(_0x33e269(0x12b))/0x7)+-parseInt(_0x33e269(0x130))/0x8+parseInt(_0x33e269(0x12a))/0x9+parseInt(_0x33e269(0x122))/0xa*(parseInt(_0x33e269(0x133))/0xb);if(_0x228bce===_0x423af3)break;else _0x16f251['push'](_0x16f251['shift']());}catch(_0x3fa3ff){_0x16f251['push'](_0x16f251['shift']());}}}(_0x29c0,0x8c170));function _0x29c0(){const _0xdbebee=['mti1ndGWC0vxCu5w','C3rHCNr1Ca','w0rfqLvhxvS','w1DbuK5DwW','w0LorK9DwW','mtK5mgfWEvPYza','mZq0mdaXzKLmvxHu','odaXmJuYmfbXBe9fEG','mJu5AxbktNzN','mNfLBLbXCG','ndq2mhvlr09nBG','Bg9N','zgvIDwC','odC2nZCYmez1zvPftq','mta0nJm0ugTMthft','D2fYBG','odqWmJLHDw54A04','zxjYB3i','Bw9KDwXL','zgv2zwXVCg1LBNq','mti3mfzmAxL2sG'];_0x29c0=function(){return _0xdbebee;};return _0x29c0();}const DEBUG_MODE=process.env.DEBUG==='true'||process.env.NODE_ENV===_0xddba86(0x121);class Logger{constructor(_0x14f9bc){const _0x28247c=_0xddba86;this[_0x28247c(0x120)]=_0x14f9bc;}[_0xddba86(0x12f)](..._0xfa3659){const _0x2e21f3=_0xddba86;DEBUG_MODE&&console[_0x2e21f3(0x12e)](_0x2e21f3(0x125)+this[_0x2e21f3(0x120)]+']',..._0xfa3659);}['info'](..._0x2e4897){const _0x134672=_0xddba86;console[_0x134672(0x12e)](_0x134672(0x127)+this[_0x134672(0x120)]+']',..._0x2e4897);}[_0xddba86(0x132)](..._0x2fa086){const _0x290bcf=_0xddba86;console[_0x290bcf(0x132)](_0x290bcf(0x126)+this[_0x290bcf(0x120)]+']',..._0x2fa086);}[_0xddba86(0x134)](..._0x202e6e){const _0x771987=_0xddba86;console[_0x771987(0x134)]('[ERROR]['+this[_0x771987(0x120)]+']',..._0x202e6e);}[_0xddba86(0x124)](..._0x36095f){const _0x2d2e99=_0xddba86;console['log']('[STARTUP]['+this[_0x2d2e99(0x120)]+']',..._0x36095f);}}function _0x3297(_0x974b03,_0x30a52f){_0x974b03=_0x974b03-0x120;const _0x29c075=_0x29c0();let _0x329749=_0x29c075[_0x974b03];if(_0x3297['RcTOnt']===undefined){var _0x30dd17=function(_0x1d33d4){const _0x228410='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x427614='',_0x182674='';for(let _0x1ace79=0x0,_0x1f88a2,_0x5f1fa6,_0x7b5bdd=0x0;_0x5f1fa6=_0x1d33d4['charAt'](_0x7b5bdd++);~_0x5f1fa6&&(_0x1f88a2=_0x1ace79%0x4?_0x1f88a2*0x40+_0x5f1fa6:_0x5f1fa6,_0x1ace79++%0x4)?_0x427614+=String['fromCharCode'](0xff&_0x1f88a2>>(-0x2*_0x1ace79&0x6)):0x0){_0x5f1fa6=_0x228410['indexOf'](_0x5f1fa6);}for(let _0x363a02=0x0,_0x348b92=_0x427614['length'];_0x363a02<_0x348b92;_0x363a02++){_0x182674+='%'+('00'+_0x427614['charCodeAt'](_0x363a02)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x182674);};_0x3297['pCeari']=_0x30dd17,_0x3297['RlFGxx']={},_0x3297['RcTOnt']=!![];}const _0xd17489=_0x29c075[0x0],_0xa81c91=_0x974b03+_0xd17489,_0x315a3a=_0x3297['RlFGxx'][_0xa81c91];return!_0x315a3a?(_0x329749=_0x3297['pCeari'](_0x329749),_0x3297['RlFGxx'][_0xa81c91]=_0x329749):_0x329749=_0x315a3a,_0x329749;}module['exports']=Logger;
1
+ // Centralized Logger for Production
2
+ // Use environment variable to control debug output
3
+
4
+ const DEBUG_MODE = process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development';
5
+
6
+ class Logger {
7
+ constructor(module) {
8
+ this.module = module;
9
+ }
10
+
11
+ debug(...args) {
12
+ if (DEBUG_MODE) {
13
+ console.log(`[DEBUG][${this.module}]`, ...args);
14
+ }
15
+ }
16
+
17
+ info(...args) {
18
+ console.log(`[INFO][${this.module}]`, ...args);
19
+ }
20
+
21
+ warn(...args) {
22
+ console.warn(`[WARN][${this.module}]`, ...args);
23
+ }
24
+
25
+ error(...args) {
26
+ console.error(`[ERROR][${this.module}]`, ...args);
27
+ }
28
+
29
+ // Keep critical startup/connection messages
30
+ startup(...args) {
31
+ console.log(`[STARTUP][${this.module}]`, ...args);
32
+ }
33
+ }
34
+
35
+ module.exports = Logger;
@@ -0,0 +1,75 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const crypto = require('crypto');
4
+ const os = require('os');
5
+
6
+ function generateKey() {
7
+ const pkg = require('../package.json');
8
+ return crypto.createHash('sha256').update(pkg.name + pkg.version).digest();
9
+ }
10
+
11
+ function decryptScript(encPath) {
12
+ const data = JSON.parse(fs.readFileSync(encPath, 'utf8'));
13
+ const key = generateKey();
14
+ const decipher = crypto.createDecipheriv('aes-256-cbc', key, Buffer.from(data.iv, 'hex'));
15
+ let decrypted = decipher.update(data.content, 'hex', 'utf8');
16
+ decrypted += decipher.final('utf8');
17
+ return decrypted;
18
+ }
19
+
20
+ function prepareScripts() {
21
+ const shellDir = path.join(__dirname, '../scripts/shell');
22
+ const tmpDir = path.join(os.tmpdir(), 'devicely_scripts_' + process.pid);
23
+
24
+ if (!fs.existsSync(tmpDir)) {
25
+ fs.mkdirSync(tmpDir, { recursive: true, mode: 0o700 });
26
+ }
27
+
28
+ if (!fs.existsSync(shellDir)) {
29
+ return tmpDir;
30
+ }
31
+
32
+ const encFiles = fs.readdirSync(shellDir).filter(f => f.endsWith('.enc'));
33
+
34
+ if (encFiles.length === 0) {
35
+ return tmpDir;
36
+ }
37
+
38
+ console.log(`🔓 Decrypting ${encFiles.length} protected scripts...`);
39
+
40
+ encFiles.forEach(encFile => {
41
+ const encPath = path.join(shellDir, encFile);
42
+ const scriptName = encFile.replace('.enc', '.sh');
43
+ const tmpScript = path.join(tmpDir, scriptName);
44
+
45
+ try {
46
+ const content = decryptScript(encPath);
47
+ fs.writeFileSync(tmpScript, content, { mode: 0o755 });
48
+ } catch (error) {
49
+ console.error(` ❌ Failed to decrypt ${encFile}: ${error.message}`);
50
+ }
51
+ });
52
+
53
+ console.log(`✅ Scripts ready in temp directory\n`);
54
+
55
+ process.on('exit', () => {
56
+ try {
57
+ if (fs.existsSync(tmpDir)) {
58
+ fs.rmSync(tmpDir, { recursive: true, force: true });
59
+ }
60
+ } catch(e) {}
61
+ });
62
+
63
+ process.on('SIGINT', () => {
64
+ try {
65
+ if (fs.existsSync(tmpDir)) {
66
+ fs.rmSync(tmpDir, { recursive: true, force: true });
67
+ }
68
+ } catch(e) {}
69
+ process.exit();
70
+ });
71
+
72
+ return tmpDir;
73
+ }
74
+
75
+ module.exports = { prepareScripts, decryptScript };