devicely 2.2.0 → 2.2.1

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 (35) hide show
  1. package/lib/scriptLoader.js +75 -0
  2. package/lib/server.js.bak +3524 -0
  3. package/package.json +1 -1
  4. package/lib/frontend/static/js/main.96600727.js +0 -3
  5. package/lib/frontend/static/js/main.96600727.js.LICENSE.txt +0 -48
  6. package/scripts/shell/android_device_control +0 -0
  7. package/scripts/shell/connect_android_usb +0 -0
  8. package/scripts/shell/connect_android_usb_multi_final +0 -0
  9. package/scripts/shell/connect_android_wireless +0 -0
  10. package/scripts/shell/connect_android_wireless_multi_final +0 -0
  11. package/scripts/shell/connect_ios_usb +0 -0
  12. package/scripts/shell/connect_ios_usb_multi_final +0 -0
  13. package/scripts/shell/connect_ios_wireless_multi_final +0 -0
  14. package/scripts/shell/create_production_scripts +0 -0
  15. package/scripts/shell/diagnose_wireless_ios +0 -0
  16. package/scripts/shell/find_element_coordinates +0 -0
  17. package/scripts/shell/find_wda +0 -0
  18. package/scripts/shell/install_uiautomator2 +0 -0
  19. package/scripts/shell/ios_device_control +0 -0
  20. package/scripts/shell/organize_project +0 -0
  21. package/scripts/shell/pre-publish-check +0 -0
  22. package/scripts/shell/publish +0 -0
  23. package/scripts/shell/publish-to-npm +0 -0
  24. package/scripts/shell/setup +0 -0
  25. package/scripts/shell/setup_android +0 -0
  26. package/scripts/shell/start +0 -0
  27. package/scripts/shell/sync-to-npm-package-final +0 -0
  28. package/scripts/shell/test_android_locators +0 -0
  29. package/scripts/shell/test_connect +0 -0
  30. package/scripts/shell/test_device_detection +0 -0
  31. package/scripts/shell/test_fixes +0 -0
  32. package/scripts/shell/test_getlocators_fix +0 -0
  33. package/scripts/shell/test_recording_feature +0 -0
  34. package/scripts/shell/verify-shell-protection +0 -0
  35. package/scripts/shell/verify_distribution +0 -0
@@ -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
+ // Use fixed key for cross-version compatibility
8
+ return crypto.createHash('sha256').update('devicely' + 'devicely-encryption-key-v1').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 };