[object Object]

← back to Marketing Command Center

auto-save: 2026-06-30T12:40:24 (1 files) — scripts/cc-agent-discover.js

67b4c0ca635e955feeb7465f5cfe8bd97b1b65ed · 2026-06-30 12:40:29 -0700 · Steve Abrams

Files touched

Diff

commit 67b4c0ca635e955feeb7465f5cfe8bd97b1b65ed
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Jun 30 12:40:29 2026 -0700

    auto-save: 2026-06-30T12:40:24 (1 files) — scripts/cc-agent-discover.js
---
 scripts/cc-agent-discover.js | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/scripts/cc-agent-discover.js b/scripts/cc-agent-discover.js
new file mode 100644
index 0000000..000ac29
--- /dev/null
+++ b/scripts/cc-agent-discover.js
@@ -0,0 +1,43 @@
+// One-off discovery: enumerate the Connie cc-agent's API surface so we can
+// (1) find the China Seas campaign + its HTML and (2) learn the create-draft route.
+// Reuses the SAME config resolution as modules/constant-contact/index.js
+// (env-first, then gitignored .cc-agent.json). Read-only probes only.
+const fs = require('fs'); const path = require('path');
+const https = require('https'); const http = require('http'); const { URL } = require('url');
+
+function cfg() {
+  let c = { base: process.env.CC_AGENT_BASE, user: process.env.CC_AGENT_USER, pass: process.env.CC_AGENT_PASS };
+  if (!c.base || !c.user || !c.pass) {
+    try { const f = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '.cc-agent.json'), 'utf8'));
+      c.base = c.base || f.base; c.user = c.user || f.user; c.pass = c.pass || f.pass; } catch {}
+  }
+  c.base = c.base || 'https://100.107.67.67:9820'; c.user = c.user || 'admin'; c.pass = c.pass || 'DWSecure2024!';
+  return c;
+}
+function fetchJSON(pathname, { method = 'GET', body, timeoutMs = 9000 } = {}) {
+  return new Promise((resolve) => {
+    const c = cfg();
+    let u; try { u = new URL(pathname, c.base.endsWith('/') ? c.base : c.base + '/'); }
+    catch (e) { return resolve({ status: 0, err: 'bad url ' + e.message }); }
+    const isHttps = u.protocol === 'https:'; const lib = isHttps ? https : http;
+    const auth = 'Basic ' + Buffer.from(`${c.user}:${c.pass}`).toString('base64');
+    const opts = { method, hostname: u.hostname, port: u.port || (isHttps ? 443 : 80),
+      path: u.pathname + u.search, headers: { Authorization: auth, Accept: 'application/json, text/html' },
+      timeout: timeoutMs, ...(isHttps ? { rejectUnauthorized: false } : {}) };
+    if (body) opts.headers['Content-Type'] = 'application/json';
+    const req = lib.request(opts, (r) => { let t = ''; r.on('data', d => t += d); r.on('end', () => {
+      resolve({ status: r.statusCode, ct: r.headers['content-type'] || '', len: t.length, body: t.slice(0, 1200) }); }); });
+    req.on('error', e => resolve({ status: 0, err: e.message }));
+    req.on('timeout', () => { req.destroy(); resolve({ status: 0, err: 'timeout' }); });
+    if (body) req.write(JSON.stringify(body)); req.end();
+  });
+}
+(async () => {
+  const probes = ['', 'health', 'api', 'api/health', 'api/routes', 'routes', 'openapi.json',
+    'api/campaigns', 'api/campaigns?limit=100', 'api/drafts', 'api/lists', 'api/contacts'];
+  for (const p of probes) {
+    const r = await fetchJSON(p);
+    console.log(`\n### /${p}  ->  ${r.status} ${r.ct ? '('+r.ct+')' : ''} ${r.err ? 'ERR:'+r.err : 'len='+r.len}`);
+    if (r.body) console.log(r.body.replace(/("(?:pass|token|secret|access_token|refresh_token|authorization)"\s*:\s*")[^"]+/gi, '$1<redacted>'));
+  }
+})();

← fa747ed deploy.conf: fix MCC health URL to :9661 + guard gitignored  ·  back to Marketing Command Center  ·  chore: macstudio3 migration — reconcile from mac2 + repoint 897ebac →