diff --git a/public/js/auth.js b/public/js/auth.js index 72d77d26..9bfb4abf 100644 --- a/public/js/auth.js +++ b/public/js/auth.js @@ -2969,6 +2969,9 @@ onAuthStateChanged(auth, async (user) => { // The desktop app has no marketing landing: straight to sign-in (which keeps the // no-account Test Mode entry for local tools). if (isDesktop()) { dismissBoot(); renderAuth("signin"); return; } + // "Create a free account" in the guest Deck links /?signup=1: open the sign-up form. + let signup = false; try { signup = new URLSearchParams(location.search).get("signup") === "1"; } catch (_) {} + if (signup) { try { history.replaceState(history.state, "", "/"); } catch (_) {} dismissBoot(); renderAuth("signup"); return; } showLanding(); return; } // An embedded tool (/?embed=1 inside the Deck) shares this tab's sessionStorage with diff --git a/public/js/deck-ui.js b/public/js/deck-ui.js index badfa9b3..5e2a9d0f 100644 --- a/public/js/deck-ui.js +++ b/public/js/deck-ui.js @@ -1637,6 +1637,11 @@ textarea.dk-kitio{min-height:120px} .dk[data-ui=deck] .dk-kpis6>.dk-start:not([hidden]) .dk-actform input{flex:1 1 140px;min-width:0} @media(max-width:720px){.dk[data-ui=deck] .dk-ov .dk-kpis.dk-kpis6:has(>.dk-start:not([hidden])){grid-template-columns:repeat(2,minmax(0,1fr))!important}.dk[data-ui=deck] .dk-kpis6>.dk-start:not([hidden]){grid-row:auto}} @media(max-width:520px){.dk[data-ui=deck] .dk-ov .dk-kpis.dk-kpis6:has(>.dk-start:not([hidden])){grid-template-columns:1fr!important}} +/* no findings yet and the first-run check showing: the two exposure tiles are hidden, so the four left fill the row */ +.dk[data-ui=deck] .dk-ov .dk-kpis.dk-kpis6:has(>.dk-kpi[data-k="exposure"][hidden]):not(:has(>.dk-start:not([hidden]))){grid-template-columns:repeat(4,minmax(0,1fr))!important} +@media(max-width:720px){.dk[data-ui=deck] .dk-ov .dk-kpis.dk-kpis6:has(>.dk-kpi[data-k="exposure"][hidden]):not(:has(>.dk-start:not([hidden]))){grid-template-columns:repeat(2,minmax(0,1fr))!important}} +@media(max-width:520px){.dk[data-ui=deck] .dk-ov .dk-kpis.dk-kpis6:has(>.dk-kpi[data-k="exposure"][hidden]):not(:has(>.dk-start:not([hidden]))){grid-template-columns:1fr!important}} +.dk .dk-sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0} .dk[data-ui=deck] .dk-start b{font-size:15px;font-weight:600} .dk[data-ui=deck] .dk-start p{font-size:13px;color:var(--dk-tx2);line-height:1.5;margin:0 0 6px} @media(max-width:520px){.dk[data-ui=deck] .dk-start{grid-column:auto}.dk[data-ui=deck] .dk-start .dk-actform input{flex:1 1 100%;width:100%}} @@ -1996,7 +2001,7 @@ export function renderDeck(host, opts) {
- +
@@ -2080,6 +2085,16 @@ export function renderDeck(host, opts) { `; (host || document.body).appendChild(root); const $ = (s) => root.querySelector(s); + // When the Deck is the page, the signed-out shell behind it (#app: its header and the empty + // #view, plus the scroll-to-top button) stays in the DOM. Keep it out of the tab order and + // the accessibility tree, make the page that is showing the main landmark, and point + // "Skip to content" at it. Undone by teardown. + const behind = primary ? [document.getElementById("app"), document.querySelector("body > .stt")].filter((e) => e && !e.inert) : []; + behind.forEach((e) => { e.inert = true; }); + if (primary) root.querySelectorAll(".dk-scene").forEach((sc) => { sc.setAttribute("role", "main"); sc.setAttribute("tabindex", "-1"); }); + const skipLink = primary ? document.querySelector(".skip-link") : null; + const onSkip = (e) => { const sc = [...root.querySelectorAll(".dk-scene")].find((x) => !x.hidden); if (!sc) return; e.preventDefault(); sc.focus(); }; + if (skipLink) skipLink.addEventListener("click", onSkip); // clock const clock = $("#dkClock"); @@ -2090,6 +2105,10 @@ export function renderDeck(host, opts) { // Decorative animated starfield removed — a flat dark surface reads as an ops // console, not an AI landing page. Kept as no-ops so resize/teardown stay valid. let rafId = 0; + // Pages and tools opened since this Deck mounted. The boot route below waits for a frame, + // and a background tab gets no frames until it is shown: a page the user (or a script) + // opened before then must not be replaced by the restored one. + let navSeq = 0; function sizeStars(){} function drawStars(){} @@ -2155,6 +2174,7 @@ export function renderDeck(host, opts) { }); } function go(scene, arg){ + navSeq++; if (!SCENES[scene] || isLocked(scene === "section" ? "section:" + (isSect(arg) ? arg : curSect) : "scene:" + scene)) scene = "overview"; curScene = scene; if (scene === "section") { if (isSect(arg)) curSect = arg; try { localStorage.setItem("dn_deck_sect", curSect); } catch (_) {} } @@ -2643,6 +2663,7 @@ export function renderDeck(host, opts) { function openTool(sec, label, accent){ if (!sec) return; if (isLocked("tool:" + sec)) return; + navSeq++; label = label || sec; curSec = sec; try { closeDrawer(); } catch (_) {} syncUrl("/" + sec); pushRecentTool(sec); @@ -2798,6 +2819,11 @@ export function renderDeck(host, opts) { // ---------- command-center chrome: status, quick-create, notifications, account ---------- const popNew = $("#dkNewPop"), popBell = $("#dkBellPop"), popAcct = $("#dkAcctPop"), badge = $("#dkBadge"), health = $("#dkHealth"); const user = opts.user || {}; + // Guest (/?app=1) and Test Mode run without an account (auth.js gives them a per-session + // "app-guest-" / "test-" uid). What needs one (monitors, deadlines, the digest, upgrade + // requests) says so and offers sign-up instead of failing after the click. + const noAccount = /^(test|app-guest)-/.test(user.uid || ""); + function toSignup(){ try { sessionStorage.removeItem("dn_guest"); } catch (_) {} location.assign("/?signup=1"); } let notifs = readRecentActivity().map((a) => ({ text: a.text, ts: a.ts, sim: !!a.sim })); let notifSeen = 0, busOffs = []; try { notifSeen = parseInt(localStorage.getItem(LS_NOTIF_SEEN) || "0", 10) || 0; } catch (_) {} @@ -2857,8 +2883,9 @@ export function renderDeck(host, opts) { }; } function buildAcctMenu(){ - const nm = user.displayName || user.email || "Account", em = user.email || "Signed in to Darknode"; + const nm = user.displayName || user.email || "Account", em = noAccount ? "Not signed in. Your work stays in this browser." : user.email || "Signed in to Darknode"; popAcct.innerHTML = `
${esc(nm)}${esc(em)}
+ ${noAccount ? `` : ""} @@ -2870,7 +2897,8 @@ export function renderDeck(host, opts) { ${primary ? (opts.isOwner ? `` : "") + (typeof opts.onClassic === "function" ? `` : "") : ``}
- `; + `; + const su = popAcct.querySelector("#dkMiSignup"); if (su) su.onclick = () => { closeAllMenus(); toSignup(); }; popAcct.querySelector("[data-go]").onclick = () => { closeAllMenus(); go("overview"); }; popAcct.querySelector("[data-tool]").onclick = () => { closeAllMenus(); go("settings"); }; popAcct.querySelector("#dkMiPlans").onclick = () => { closeAllMenus(); go("plans"); }; @@ -2901,9 +2929,14 @@ export function renderDeck(host, opts) { + `${esc(w.name)}${sub}` + (active ? `${IC.check}` : "") + ``; }).join(""); + // Team workspaces are a Team-plan feature (worker/plan.js teamSync; the Team page is hidden + // below it), so below Team the menu points at Plans instead of creating one that cannot sync or add members. + const canTeam = !isLocked("scene:team"); popWs.innerHTML = `
Workspace
${rows}
` - + `` + + (canTeam ? `` + : ``) + `
Each workspace has its own security graph. A team's graph is shared with its members and always syncs; your personal graph syncs only when you turn it on in Settings.
`; + const wp = popWs.querySelector("#dkWsPlans"); if (wp) wp.onclick = () => { closeAllMenus(); go("plans"); }; popWs.querySelectorAll(".dk-wsrow[data-wid]").forEach((b) => b.onclick = () => { const wid = b.dataset.wid || null; if ((wid || null) === (cur || null)) { closeAllMenus(); return; } @@ -3297,7 +3330,7 @@ export function renderDeck(host, opts) { } // Deadlines: the soonest open ones, or nothing at all when none are open const dlSlot = el.querySelector("#dkDeadlines0"); - if (dlSlot && !isLocked("scene:deadlines")) dlMod().then((m) => m.mountDeadlineBlock(dlSlot, { tier: planTier, go }), () => {}); + if (dlSlot && !noAccount && !isLocked("scene:deadlines")) dlMod().then((m) => m.mountDeadlineBlock(dlSlot, { tier: planTier, go }), () => {}); // quick AI ask bar -> prefill + open the assistant const askForm = el.querySelector("#dkAsk"), askIn = el.querySelector("#dkAskIn"); if (askForm) askForm.onsubmit = (e) => { e.preventDefault(); askAI(askIn.value); }; @@ -4111,8 +4144,8 @@ 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, tier: planTier, go })); } - function renderDeadlines(){ lazyScene(sceneEls.deadlines, dlMod, (m) => m.mountDeadlines(sceneEls.deadlines, { toast, tier: planTier, go })); } + function renderMonitors(){ lazyScene(sceneEls.monitors, monMod, (m) => m.mountMonitors(sceneEls.monitors, { esc, IC, toast, tier: planTier, go, noAccount, signup: toSignup })); } + function renderDeadlines(){ lazyScene(sceneEls.deadlines, dlMod, (m) => m.mountDeadlines(sceneEls.deadlines, { toast, tier: planTier, go, noAccount, signup: toSignup })); } 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 })); } @@ -4193,7 +4226,7 @@ export function renderDeck(host, opts) { const feedNote = iv.status === "rejected" && kv.status === "rejected" ? `
Live CVE feeds are unavailable right now, so this list uses your security graph only.
` : ""; const SRC = { finding: "Your findings", cve: "Global feed", connect: "Setup" }; box.innerHTML = (acts.length - ? `
${acts.map((a) => ``).join("")}
SeverityItemSource
${esc(a.sev.charAt(0).toUpperCase() + a.sev.slice(1))}${esc(a.title)}${esc(a.detail)}${esc(SRC[a.kind] || "")}${go1(a)}
` + ? `
${acts.map((a) => ``).join("")}
SeverityItemSourceAction
${esc(a.sev.charAt(0).toUpperCase() + a.sev.slice(1))}${esc(a.title)}${esc(a.detail)}${esc(SRC[a.kind] || "")}${go1(a)}
` : `
Nothing urgent: no open critical or high findings and no known-exploited CVEs in this week's feed.
`) + feedNote; const f = box.querySelector(".dk-actform"); if (f) { @@ -4249,7 +4282,7 @@ export function renderDeck(host, opts) {

Plans & billing

${opts.isOwner ? `
Owner account: pick any plan to use the Deck exactly as a customer on it does. You're using ${esc(planLabel(planTier))}${planTier !== realTier ? `; your account plan is ${esc(planLabel(realTier))}` : ""}. Your account keeps full access on the server either way.
` - : `
Preview pricing — checkout isn't live yet. You're on the ${esc(planLabel(planTier))} plan${lentTier ? ` in this workspace, shared by its owner; your own plan is ${esc(planLabel(realTier))}` : ""}. Upgrades are requested here and granted manually; no payment is taken.
`} + : `
Preview pricing — checkout isn't live yet. You're on the ${esc(planLabel(planTier))} plan${lentTier ? ` in this workspace, shared by its owner; your own plan is ${esc(planLabel(realTier))}` : ""}. Upgrades are requested here and granted manually; no payment is taken.${noAccount ? " You're not signed in: create a free account to request one." : ""}
`}
${PLANS.map((p) => { const c = ctaFor(p.id); return `
${p.id === planTier ? `Current` : p.tag ? `${esc(p.tag)}` : ""} @@ -4267,6 +4300,11 @@ export function renderDeck(host, opts) { const plan = b.dataset.plan; if (b.dataset.owner) { setPreviewTier(plan === realTier ? "" : plan, "plans"); toast("Using the " + planLabel(plan) + " plan"); return; } if (plan === "enterprise") { try { window.open("mailto:sales@darknode.ai?subject=" + encodeURIComponent("Darknode Enterprise enquiry"), "_blank", "noopener"); } catch (_) {} return; } + if (noAccount) { + const ok = window.dnConfirm ? await window.dnConfirm("Upgrades need an account", "Create a free Darknode account first, then request " + planLabel(plan) + " from this page.", { submitText: "Create a free account" }) : false; + if (ok) toSignup(); + return; + } if (typeof opts.onUpgradeRequest !== "function") { toast("Upgrade requests aren't available in this context."); return; } const note = window.dnPrompt ? await window.dnPrompt("Request " + planLabel(plan), { desc: "We'll review and get back to you. Add anything about your team or needs (optional).", placeholder: "e.g. 6 analysts, needs SSO", textarea: true, submitText: "Send request" }) : ""; if (note === null) return; // cancelled @@ -4404,6 +4442,7 @@ export function renderDeck(host, opts) { function wireDigest(el){ const on = el.querySelector("#dkDigOn"), tb = el.querySelector("#dkDigTest"), st = el.querySelector("#dkDigSt"); if (!on) return; + if (noAccount) { on.textContent = "Off"; st.textContent = "The digest is emailed to an account, so it needs a free account."; return; } const watchLine = (m, d) => { const w = m.localWatch(), n = (w.certs || []).length; return n ? "Watching " + n + " certificate" + (n === 1 ? "" : "s") + (w.certsAt ? ", last checked " + new Date(w.certsAt).toLocaleDateString() : "") + "." + (d && d.lastSent ? " Last digest sent " + new Date(d.lastSent).toLocaleDateString() + "." : "") @@ -4450,10 +4489,13 @@ export function renderDeck(host, opts) {
Accent colour
A hex colour for workspace accents. Optional.
-
+ ${noAccount ? `
+
Not signed in
Without an account, your checks, notes and keys stay in this browser, and monitors, deadlines and the weekly digest are off. A free account watches one domain and emails you its alerts.
+ +
` : `
Signed in as
${esc(user.email || "—")}
${esc(user.displayName || "")} -
+
`}
@@ -4483,7 +4525,7 @@ export function renderDeck(host, opts) {

${IC.note} Weekly email digest

-
Monday digest
Each Monday: vulnerabilities CISA confirmed as exploited that week, and any certificate you watch that has expired or expires within 30 days. Sent to ${esc(user.email || "your account email")}.
+
Monday digest
Each Monday: vulnerabilities CISA confirmed as exploited that week, and any certificate you watch that has expired or expires within 30 days. Sent to ${noAccount ? "your account email" : esc(user.email || "your account email")}.
@@ -4551,6 +4593,7 @@ export function renderDeck(host, opts) { const coolBtn = el.querySelector("#dkSetCool"); if (coolBtn) coolBtn.onclick = (e) => { const on = !coolOn(); try { localStorage.setItem("dn_cool_ui", on ? "1" : "0"); } catch (_) {} reloadToolsForCool(); e.target.classList.toggle("on", on); e.target.textContent = on ? "On" : "Off"; }; el.querySelector("#dkSetPlans").onclick = () => go("plans"); + const setSu = el.querySelector("#dkSetSignup"); if (setSu) setSu.onclick = toSignup; el.querySelector("#dkSetExport").onclick = () => exportDeckState(); el.querySelector("#dkSetImport").onclick = () => importDeckState(); const syncPlanBtn = el.querySelector("#dkSetSyncPlan"); @@ -5250,6 +5293,7 @@ export function renderDeck(host, opts) { : opts.startSec && !route0 ? "tool:" + opts.startSec : null; const lockedLink = lockedKey && isLocked(lockedKey) && !isLocked("scene:plans") ? lockedKey : null; rafId = requestAnimationFrame(() => { + if (navSeq) { routing = false; return; } // something was opened already (see navSeq) if (lockedLink) { go("plans"); const name = navName[lockedLink] || lockedLink.split(":")[1]; @@ -5284,6 +5328,8 @@ export function renderDeck(host, opts) { cancelAnimationFrame(rafId); clearInterval(clockId); clearTimeout(gTimer); busOffs.forEach((off) => { try { off(); } catch (_) {} }); busOffs = []; document.removeEventListener("keydown", onKey); window.removeEventListener("resize", onResize); + behind.forEach((e) => { e.inert = false; }); + if (skipLink) skipLink.removeEventListener("click", onSkip); root.remove(); } return () => (swapped ? swapped() : teardown()); diff --git a/public/js/deck/deadlines.js b/public/js/deck/deadlines.js index f896d3d1..269dda59 100644 --- a/public/js/deck/deadlines.js +++ b/public/js/deck/deadlines.js @@ -113,6 +113,12 @@ async function load() { const box = S.el && S.el.querySelector("#dlBody"); if (!box) return; const my = ++S.seq; if (!monitoringAvailable()) { box.innerHTML = `
Deadlines need the cloud proxy, which this build has not configured.
`; return; } + // guest / Test Mode: the clocks come from server-side monitors, which need an account + if (S.ctx && S.ctx.noAccount) { + box.innerHTML = `
Deadlines come from monitors, which run on Darknode's servers for an account. Create a free account and watch a domain, and its certificate expiry is tracked here.
`; + box.querySelector("#dlSignup").onclick = () => S.ctx.signup && S.ctx.signup(); + return; + } try { const [data, mons] = await Promise.all([call({ op: "deadlines" }), call({ op: "list" }).catch(() => null)]); if (my !== S.seq) return; diff --git a/public/js/deck/monitors.js b/public/js/deck/monitors.js index c59aae3a..d8c87d7a 100644 --- a/public/js/deck/monitors.js +++ b/public/js/deck/monitors.js @@ -89,6 +89,13 @@ async function load() { const box = S.el && S.el.querySelector("#monBody"); if (!box) return; const my = ++S.seq; if (!monitoringAvailable()) { box.innerHTML = `
Monitoring is not available on this build — it needs the cloud proxy. Nothing to configure yet.
`; return; } + // guest / Test Mode: monitors run on the server for an account and email it, so offer sign-up + if (S.ctx && S.ctx.noAccount) { + box.innerHTML = `
Monitors need a free account
They run on Darknode's servers and email the account that set them up. A free account watches one domain for certificate expiry and email/DNS changes, checked once a day.
+
`; + box.querySelector("#monSignup").onclick = () => S.ctx.signup && S.ctx.signup(); + return; + } try { const data = await monitorApi({ op: "list" }); if (my !== S.seq) return;