Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions public/css/domain-check.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,12 @@ html[data-style] body.landing .hero .dmc-linkbox{background:rgba(255,255,255,.06
.dk .dk-fr-saved{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px;margin-top:12px;font-size:13px;color:var(--dk-tx2,#56544f)}
.dk-fr-saved b{color:var(--dk-tx,#1d1c1a);font-weight:600}
.dk-fr-saved .dk-tibtn{height:32px}
/* "Watch this domain" after a check: the Free plan's one-domain watch */
.dk .dk-fr-watch{display:flex;flex-wrap:wrap;align-items:center;gap:10px 16px;margin-top:12px;padding-top:12px;border-top:1px solid var(--dk-line2,#efeee9);font-size:13px;line-height:1.5;color:var(--dk-tx2,#56544f)}
.dk .dk-fr-watch[hidden]{display:none}
.dk-fr-watch .dk-fr-wtx{flex:1 1 320px;min-width:0}
.dk-fr-watch b{color:var(--dk-tx,#1d1c1a);font-weight:600}
.dk-fr-watch .dk-fr-wbtns{display:flex;flex-wrap:wrap;gap:8px}
.dk-fr-watch .dk-tibtn{height:32px}
.dk-fr-watch.err .dk-fr-wtx{color:#b3261e}
@media (max-width:720px){.dk-fr .dk-actform input{flex:1 1 100%;width:auto}}
6 changes: 3 additions & 3 deletions public/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3003,7 +3003,7 @@ onAuthStateChanged(auth, async (user) => {
const udoc = await getDoc(doc(db, "users", user.uid)).catch(() => null);
// Terms are versioned: bumping TOS_VERSION asks every account to accept the new text,
// including accounts that accepted an earlier version (they also see what changed).
const TOS_VERSION = "2026-11-07";
const TOS_VERSION = "2026-11-25";
const ud = udoc && udoc.exists() ? udoc.data() : {};
const tosAccepted = !!ud.tosAccepted && ud.tosVersion === TOS_VERSION;
const tosReturning = !!ud.tosAccepted && !tosAccepted;
Expand All @@ -3014,9 +3014,9 @@ onAuthStateChanged(auth, async (user) => {
<h1>${tosReturning ? "We updated our Terms of Service" : "Terms of Service"}</h1>
<p class="tos-sub">${tosReturning ? "Please review the changes and accept to keep using Darknode." : "Please read and accept before continuing."}</p>
${tosReturning ? `<div class="tos-update">
<strong>What changed (November 7, 2026)</strong>
<strong>What changed (November 25, 2026)</strong>
<ul>
<li>When you are signed in to the Nexus terminal agent or the desktop app, it now tells us about every 6 hours that your account uses it, with the app version and operating system. The desktop app also reports how many virtual machines it holds and when one last started, never their names, disks or contents. Turn it off with /shareusage off in Nexus or Settings &gt; Share app usage in the app (Section 14).</li>
<li>The Free plan can now watch one domain. If you set up a monitor or the domain watch, we store the domains it watches and its latest results, and send email alerts only to your verified account email through our email provider, Resend. Turn it off under Monitors or with the stop link in any alert email (Section 14).</li>
</ul></div>` : ""}
<div class="tos-box" id="tosBox" tabindex="0">
${TOS_HTML}
Expand Down
78 changes: 75 additions & 3 deletions public/js/check/first-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
// Deck" (localStorage dn_first_domain, cleared once it has run), or the user. The sign-up
// email's domain is only offered as a one-click chip, never typed into the field, and
// never for a free-mail provider or a Test Mode / guest identity.
//
// Once a check has run, "Watch this domain" sets up the Free plan's one-domain watch: a
// certificate-expiry and an email/DNS monitor on that domain, checked once a day, alerting by
// email to the account's own verified address (the Worker takes the address from the sign-in
// token and enforces the one-domain limit, worker/free-watch.js).

import { runDomainCheck, normalizeDomain, workDomainFromEmail, domainCheckFindings, domainCheckHeld, runLevel } from "/js/check/domain-check.js?v=1";
import { renderResult, renderPending, escapeHtml as esc } from "/js/check/check-view.js?v=1";
Expand All @@ -28,7 +33,7 @@ const isTestIdentity = (u) => !!(u && (u.isAnonymous || u.email === "test@darkno
|| (u.providerData || []).some((p) => p && p.providerId === "test")));

// Survives overview re-renders for this page load: the block is redrawn into each new slot.
const S = { domain: "", res: null, running: false, saved: null, error: "", seq: 0, slot: null, ctx: null };
const S = { domain: "", res: null, running: false, saved: null, error: "", seq: 0, slot: null, ctx: null, watch: null };

function toolLabel(id) {
const c = S.ctx;
Expand All @@ -50,6 +55,71 @@ function paint() {
} else { out.hidden = true; out.innerHTML = ""; }
saved.hidden = !S.saved;
if (S.saved) saved.innerHTML = savedHtml(S.saved);
const watch = slot.querySelector(".dk-fr-watch");
const showWatch = !!(S.res && S.res.checks && S.res.checks.length && !S.running);
watch.hidden = !showWatch;
watch.classList.toggle("err", !!(showWatch && S.watch && S.watch.domain === S.res.domain && S.watch.state === "error"));
if (showWatch) watch.innerHTML = watchHtml();
}

// ---- "Watch this domain" -------------------------------------------------------------------
const WATCH_TYPES = ["cert-expiry", "email-posture"];
const DAY = 86400000;
const isFree = () => { const t = S.ctx && S.ctx.tier; return !t || t === "free"; };
const hostsOf = (m) => ((m && m.config && m.config.domains) || []).map((d) => normalizeDomain(d)).filter(Boolean);
const goBtn = (act, label) => `<button type="button" class="dk-tibtn" data-fr-go="${act}">${label}</button>`;

function watchHtml() {
const d = S.res.domain, w = S.watch && S.watch.domain === d ? S.watch : null;
if (!w || w.state === "busy") {
const busy = !!w;
return `<div class="dk-fr-wtx"><b>Watch ${esc(d)}</b><br>Get an email when its certificate is close to expiry, or when an email or DNS record (SPF, DMARC, MX, CAA) is removed or weakened. Checked once a day${isFree() ? ". The Free plan watches one domain" : ""}.</div>
<div class="dk-fr-wbtns"><button type="button" class="dk-tibtn on" data-fr-watch="1"${busy ? " disabled" : ""}>${busy ? "Setting up…" : "Watch this domain"}</button></div>`;
}
if (w.state === "on") {
const where = w.to ? `Alerts go by email to <b>${esc(w.to)}</b>, at most 5 emails a day.` : w.emailAll ? "Alerts go by email to your account address, at most 5 emails a day." : "Alerts go to the channels set on each monitor.";
const head = w.paused ? `The watch on ${esc(d)} is turned off.` : (w.already ? "Already watching " : "Watching ") + esc(d) + ".";
const body = w.paused ? "Turn it back on under Monitors to check its certificate and email/DNS records once a day."
: `Its certificate (expiry within 21 days) and its email/DNS records (SPF, DMARC, MX, CAA) are checked once a day. ${where} Turn the watch off any time under Monitors.`;
return `<div class="dk-fr-wtx"><b>${head}</b> ${body}</div><div class="dk-fr-wbtns">${goBtn("monitors", "Open Monitors")}</div>`;
}
if (w.state === "conflict") {
return `<div class="dk-fr-wtx"><b>Your Free plan already watches ${esc(w.other)}.</b> The Free plan watches one domain. To watch ${esc(d)} instead, delete the watch on ${esc(w.other)} under Monitors, or request an upgrade under Plans.</div>
<div class="dk-fr-wbtns">${goBtn("monitors", "Open Monitors")}${goBtn("plans", "See Plans")}</div>`;
}
return `<div class="dk-fr-wtx">${esc(w.msg)}</div><div class="dk-fr-wbtns">${w.plan ? goBtn("plans", "See Plans") : '<button type="button" class="dk-tibtn" data-fr-watch="1">Try again</button>'}</div>`;
}

async function watchDomain() {
const domain = S.res && S.res.domain;
if (!domain || S.running || (S.watch && S.watch.domain === domain && S.watch.state === "busy")) return;
const free = isFree();
const set = (w) => { if (S.res && S.res.domain === domain) { S.watch = { domain, ...w }; paint(); } };
set({ state: "busy" });
try {
const { monitorApi } = await import("/js/deck/monitor-client.js?v=1");
// the Free watch lives in the caller's own workspace, whichever one is active
const opts = { personal: free };
const mons = ((await monitorApi({ op: "list" }, opts)) || {}).monitors || [];
if (free) {
const other = [...new Set(mons.flatMap(hostsOf))].filter((h) => h !== domain);
if (other.length) return set({ state: "conflict", other: other[0] });
}
const mine = mons.filter((m) => WATCH_TYPES.includes(m.type) && hostsOf(m).includes(domain));
const made = [];
for (const type of WATCH_TYPES) {
if (mine.some((m) => m.type === type)) continue;
const monitor = { name: (type === "cert-expiry" ? "Certificate: " : "Email and DNS: ") + domain, type, config: type === "cert-expiry" ? { domains: [domain], warnDays: 21 } : { domains: [domain] }, intervalMs: DAY, channels: [{ type: "email" }] };
const r = await monitorApi({ op: "upsert", monitor }, opts);
if (r && r.monitor) made.push(r.monitor);
}
const all = mine.concat(made);
const mail = all.flatMap((m) => m.channels || []).find((c) => c.type === "email" && c.mine && c.to);
set({ state: "on", already: !made.length, paused: all.some((m) => m.paused), to: mail ? mail.to : "", emailAll: all.every((m) => (m.channels || []).some((c) => c.type === "email")) });
} catch (e) {
const msg = (e && e.message) || "The watch could not be set up. Try again.";
set({ state: "error", plan: !!(e && e.plan), msg: !(e && e.status) && /^Sign in/.test(msg) ? "Sign in with your own account to watch a domain. Alerts go to its verified email address." : msg });
}
}

function savedHtml(sv) {
Expand Down Expand Up @@ -103,7 +173,7 @@ async function run(raw) {

/**
* Draw the block into `slot` (an empty element at the top of the overview).
* ctx = { user, pending, isLocked(key), toolName(id), openTool(id), go(scene), onSaved() }
* ctx = { user, tier, pending, isLocked(key), toolName(id), openTool(id), go(scene), onSaved() }
*/
export function mountFirstRun(slot, ctx) {
S.slot = slot; S.ctx = ctx;
Expand All @@ -116,6 +186,7 @@ export function mountFirstRun(slot, ctx) {
<p class="dk-fr-msg" role="alert" hidden></p>
<div class="dk-fr-out" aria-live="polite" hidden></div>
<div class="dk-fr-saved" hidden></div>
<div class="dk-fr-watch" aria-live="polite" hidden></div>
</div>`;
const form = slot.querySelector(".dk-fr-form"), input = form.querySelector("input");
form.addEventListener("submit", (e) => { e.preventDefault(); if (!S.running) { run(input.value); input.value = ""; } });
Expand All @@ -124,8 +195,9 @@ export function mountFirstRun(slot, ctx) {
if (!t || !slot.contains(t)) return;
if (t.dataset.frDomain && !S.running) run(t.dataset.frDomain);
else if (t.dataset.dmcTool && S.ctx.openTool) S.ctx.openTool(t.dataset.dmcTool);
else if (t.dataset.frGo === "findings" && S.ctx.go) S.ctx.go("findings");
else if (t.dataset.frWatch) watchDomain();
else if (t.dataset.frGo === "secgraph" && S.ctx.openTool) S.ctx.openTool("secgraph");
else if (t.dataset.frGo && S.ctx.go) S.ctx.go(t.dataset.frGo);
});
paint();
// a /check/<domain> link or the landing's hand-off runs at once; the hand-off key is
Expand Down
10 changes: 8 additions & 2 deletions public/js/core/entitlements.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const FEATURES = {
cloudSync: "pro", // findings/reports synced across devices
unlimitedReports: "pro", // unlimited saved findings & reports
priorityAI: "pro", // premium AI models (worker/plan.js enforces them)
monitors: "pro", // monitors beyond the Free one-domain watch: more domains, KEV/EPSS, chat and webhook alerts
teamWorkspaces: "team", // shared workspaces & roles
vaultServerEnforced: "team", // server-enforced VAULT approvals & audit
integrations: "team", // SIEM / ticketing / chat connectors
Expand All @@ -30,6 +31,9 @@ export const FEATURES = {
export const LIMITS = {
seats: { free: 1, pro: 1, team: 25, enterprise: -1 },
workspaces: { free: 1, pro: 1, team: 5, enterprise: -1 },
// domains a Free account may watch for certificate expiry and email/DNS changes, with
// alerts by email (worker/free-watch.js enforces it); Pro and above have no domain cap
watchDomains: { free: 1, pro: -1, team: -1, enterprise: -1 },
};

// Normalise any input into a known tier string.
Expand Down Expand Up @@ -85,9 +89,11 @@ export function limit(tier, key) {
// entries. Shared by the Deck sidebar and the AI tool catalog (js/api/catalog.js), so a
// tool an AI can run through the MCP server needs the same plan it needs in the Deck.
export const PLAN_GROUP = { exposure: "pro", code: "pro", identity: "team", detect: "team", finsec: "team", risk: "enterprise", compliance: "enterprise" };
export const PLAN_ITEM = { enterprise: "team", findings: "pro", inventory: "pro", reports: "pro", activity: "pro", monitors: "pro", phishtriage: "pro", dlp: "pro", leakprobe: "pro", team: "team",
export const PLAN_ITEM = { enterprise: "team", findings: "pro", inventory: "pro", reports: "pro", activity: "pro", phishtriage: "pro", dlp: "pro", leakprobe: "pro", team: "team",
// Free on every plan: the public vulnerability feed and the local-only graph and case files.
threat: "free", secgraph: "free", investigation: "free" };
threat: "free", secgraph: "free", investigation: "free",
// Free: the one-domain watch (Pro adds more monitors; the server enforces both)
monitors: "free" };
export const tierFor = (id, group) => (own(PLAN_ITEM, id) && PLAN_ITEM[id]) || (own(PLAN_GROUP, group) && PLAN_GROUP[group]) || "free";

export const planLabel = (tier) => PLAN_LABEL[normTier(tier)] || "Free";
8 changes: 4 additions & 4 deletions public/js/deck-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,7 @@ export function renderDeck(host, opts) {
if (!frSlot.isConnected) return;
frMod = m;
const pending = frPending; frPending = "";
m.mountFirstRun(frSlot, { user, pending, isLocked, toolName: (id) => secLabel[id] || "", openTool: (id) => openTool(id, secLabel[id] || id), go, onSaved: refreshGraphScene });
m.mountFirstRun(frSlot, { user, tier: planTier, pending, isLocked, toolName: (id) => secLabel[id] || "", openTool: (id) => openTool(id, secLabel[id] || id), go, onSaved: refreshGraphScene });
};
if (frMod) mountFr(frMod);
else import("/js/check/first-run.js?v=1").then(mountFr).catch(() => frSlot.remove());
Expand Down Expand Up @@ -4102,7 +4102,7 @@ export function renderDeck(host, opts) {
function repaintCorrelations(g){ corrMod().then((m) => m.repaintCorrelations(g), () => {}); }
function renderInventory(){ lazyScene(sceneEls.inventory, invMod, (m) => m.mountInventory(sceneEls.inventory, { withGraph, esc, IC, IC_SEARCH, openEntityDrawer, openTool, agoISO: agoISO, toast })); }
function renderCorrelations(){ lazyScene(sceneEls.correlations, corrMod, (m) => m.mountCorrelations(sceneEls.correlations, { withGraph, esc, IC, IC_SEARCH, openEntityDrawer, openTool, toast })); }
function renderMonitors(){ lazyScene(sceneEls.monitors, monMod, (m) => m.mountMonitors(sceneEls.monitors, { esc, IC, toast })); }
function renderMonitors(){ lazyScene(sceneEls.monitors, monMod, (m) => m.mountMonitors(sceneEls.monitors, { esc, IC, toast, tier: planTier, go })); }
function renderApiKeys(){ lazyScene(sceneEls.apikeys, keysMod, (m) => m.mountApiKeys(sceneEls.apikeys, { esc, IC, toast })); }
function renderAudit(){ lazyScene(sceneEls.audit, auditMod, (m) => m.mountAudit(sceneEls.audit, { esc, IC, toast })); }
function renderDevice(){ lazyScene(sceneEls.device, deviceMod, (m) => m.mountDevice(sceneEls.device, { esc, IC, toast, askAI })); }
Expand Down Expand Up @@ -4209,11 +4209,11 @@ export function renderDeck(host, opts) {
const PLANS = [
{ id: "free", name: "Free", price: "$0", unit: "forever", tag: "", a: "#2552c6",
blurb: "Quick checks, the live feed and the assistant, for individuals and evaluation.",
feats: ["Free browser tools in the Tool Library", "Quick Checks: email security, headers, certificates, DNS, breaches, CVEs", "Personal space: domain, link, secret and data checks", "Live vulnerability feed (CVE and known-exploited)", "Local-only security graph & case files", "Darknode AI assistant: 50 messages a day", "1 workspace, 1 seat"],
feats: ["Free browser tools in the Tool Library", "Quick Checks: email security, headers, certificates, DNS, breaches, CVEs", "Personal space: domain, link, secret and data checks", "Live vulnerability feed (CVE and known-exploited)", "Local-only security graph & case files", "Watch 1 domain: certificate expiry and email/DNS changes, alerts by email", "Darknode AI assistant: 50 messages a day", "1 workspace, 1 seat"],
cta: "Current plan", cur: true },
{ id: "pro", name: "Pro", price: "$29", unit: "per user / month", tag: "Recommended", a: "#2552c6",
blurb: "For professionals who need history, exports and the strongest AI models.",
feats: ["Everything in Free", "Exposure and Application Security tools, findings and reports", "Unlimited saved findings & reports", "Premium AI models: Claude Fable 5.1, Claude Opus 5.5, Darknode Max", "500 AI messages a day (150 on Claude)", "Cloud sync across devices", "Email support"],
feats: ["Everything in Free", "Exposure and Application Security tools, findings and reports", "Unlimited saved findings & reports", "Premium AI models: Claude Fable 5.1, Claude Opus 5.5, Darknode Max", "500 AI messages a day (150 on Claude)", "Cloud sync across devices", "Monitors for more domains and known-exploited CVEs, with Slack, Teams and webhook alerts", "Email support"],
cta: "Upgrade to Pro" },
{ id: "team", name: "Team", price: "$79", unit: "per user / month", tag: "", a: "#2552c6",
blurb: "Shared workspaces, roles and one audit trail for the whole team.",
Expand Down
13 changes: 8 additions & 5 deletions public/js/deck/monitor-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ const proxyBase = () => { try { return String(window.DARKNODE_PROXY_URL || "").r

export function monitoringAvailable() { return !!proxyBase(); }

// monitorApi(body) -> parsed JSON. Throws a readable Error on any non-2xx (the scene
// shows 503 "not configured on this deployment" verbatim, so a pre-deploy Deck is honest).
export async function monitorApi(body) {
// monitorApi(body, { personal }) -> parsed JSON. Throws a readable Error on any non-2xx (the
// scene shows 503 "not configured on this deployment" verbatim, so a pre-deploy Deck is honest);
// the Error carries .status, and .plan when the plan does not include the request (402).
// personal: send to the caller's own workspace (where the Free plan's one-domain watch lives)
// whatever workspace is active.
export async function monitorApi(body, opts = {}) {
const base = proxyBase();
if (!base) throw new Error("Monitoring needs the cloud proxy, which this build has not configured.");
const { auth } = await import("/js/firebase.js?v=20261021a");
const user = (auth && auth.currentUser) || null;
if (!user) throw new Error("Sign in to use monitors.");
const wid = activeWorkspaceId() || user.uid;
const wid = (opts.personal ? "" : activeWorkspaceId()) || user.uid;
const r = await fetch(base + "/api/monitor/" + encodeURIComponent(wid), {
method: "POST",
headers: { Authorization: "Bearer " + (await user.getIdToken()), "Content-Type": "application/json" },
body: JSON.stringify(body || { op: "list" }),
});
let j = {}; try { j = await r.json(); } catch (_) {}
if (!r.ok) throw new Error(j.error || ("Monitor request failed (" + r.status + ")"));
if (!r.ok) throw Object.assign(new Error(j.error || ("Monitor request failed (" + r.status + ")")), { status: r.status, plan: j.plan === true });
return j;
}
Loading
Loading