Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: bring isSafeHref/isHttpUrl under the mirror-coverage guard (#6303)
[._.]/ Adam Eivy3fde165cd784
diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 1260ca7a61..e4f9f42a2a 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -59,6 +59,7 @@ grep -i "what you want to do" client/src/lib/README.md| `loraTriggers.js` | Mirror of the trigger-word predicates in `server/lib/loraTriggers.js` (#4665): `firstTriggerWord` (the canonical activation token of a Civitai `trainedWords` list) and `promptHasTriggerWord` (whole-token, case-insensitive presence — `aria_tok` does not match inside `aria_token`). Plus `appendTriggerWords(prompt, words, effectivePrompt?)` — the "+ trigger" button's append, which adds ALL of a LoRA's words (the server only ever weaves the first) and judges presence against the composed prompt the page will actually submit. Lets the LoRA picker warn that the server is about to append a token, with the button and the hint sharing one presence rule. || `runnerFamilies.js` | Mirror of `server/lib/runners.js`, including the shared LTX + MiniMax H3 Ref2VA audio-to-video runtime predicate. || `slashdoCatalog.js` | Mirror of `server/lib/slashdoCatalog.js` — the launchable slashdo workflows (`SLASHDO_WORKFLOWS`, `slashdoWorkflowsForApp(isSwiftApp)`, `SLASHDO_APP_TYPES`) driving the app-overview Agent Operations buttons. Adds only the per-button Tailwind classes; pinned by `server/lib/slashdoCatalog.test.js`. |+| `isSafeHref.js` | Pure http(s)-only scheme check (`isSafeHref`) for user-supplied URL fields rendered as a clickable `<a href>` — rejects `javascript:`/`data:`/etc. stored-XSS payloads. Mirror of `server/lib/isSafeHref.js`. Re-exported as `isHttpUrl` from `client/src/utils/urlNormalize.js` for existing importers. || `issueLength.js` | Mirror of `server/lib/issueLength.js`. || `musicDuration.js` | Lyric-aware MiniMax Music 3 duration analysis: section/word detection, ending-cushioned auto-duration recommendations, and cap warnings. Mirrors `server/lib/musicDuration.js`. |diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex 240ffe905f..286d13348a 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -47,6 +47,7 @@ export * from './imageTo3dRenderOptions.js';export * from './importerDeepLink.js';export * from './installFailureTask.js';export * from './letteringDensity.js';+export * from './isSafeHref.js';export * from './issueLength.js';export * from './musicDuration.js';export * from './muscriptorModels.js';diff --git a/client/src/lib/isSafeHref.js b/client/src/lib/isSafeHref.jsnew file mode 100644index 0000000000..cceb97172a--- /dev/null+++ b/client/src/lib/isSafeHref.js@@ -0,0 +1,25 @@+/**+ * Pure http(s)-only scheme check for user-supplied URL fields that get+ * rendered as a clickable `<a href>` (privacy-org website/portal links,+ * broker opt-out/search URLs, song reference links, notification links, …).+ *+ * A stored `javascript:`/`data:`/`vbscript:` URL turns into a stored-XSS+ * payload the moment it's rendered as an href — validating the scheme at+ * write time (server, Zod `.refine`) and re-checking at render time+ * (client) closes both the write and the read side. Mirrors+ * `server/lib/isSafeHref.js` (kept as two small copies — server and client+ * don't share a build step — so keep both in sync if this changes; pinned+ * by `isSafeHref.mirror.test.js`).+ *+ * @param {string} url+ * @returns {boolean}+ */+export function isSafeHref(url) {+ if (typeof url !== 'string' || url.length === 0) return false;+ try {+ const parsed = new URL(url);+ return parsed.protocol === 'http:' || parsed.protocol === 'https:';+ } catch {+ return false;+ }+}diff --git a/client/src/lib/isSafeHref.mirror.test.js b/client/src/lib/isSafeHref.mirror.test.jsnew file mode 100644index 0000000000..0480f83f1e--- /dev/null+++ b/client/src/lib/isSafeHref.mirror.test.js@@ -0,0 +1,26 @@+import { describe, expect, it } from 'vitest';+import { isSafeHref as clientIsSafeHref } from './isSafeHref.js';+import { isSafeHref as serverIsSafeHref } from '../../../server/lib/isSafeHref.js';++// Shared input matrix so the client and server copies must agree on every+// case, not merely both exist (server/lib/mirrorCoverage.test.js's parity+// guard only proves a test reads both files).+const CASES = [+ 'https://host/path',+ 'http://host/path',+ 'https:foo',+ 'https:/host',+ 'https:///host',+ '//host',+ 'javascript:alert(1)',+ 'data:text/html,<script>alert(1)</script>',+ '',+ null,+ undefined,+];++describe('isSafeHref client/server parity', () => {+ it.each(CASES)('agrees on %p', (input) => {+ expect(clientIsSafeHref(input)).toBe(serverIsSafeHref(input));+ });+});diff --git a/client/src/utils/urlNormalize.js b/client/src/utils/urlNormalize.jsindex 6ddf065ad0..f77ae4b619 100644--- a/client/src/utils/urlNormalize.js+++ b/client/src/utils/urlNormalize.js@@ -11,18 +11,22 @@// (LinksTab's quick-add guard). FeedsTab/QuickBrainCapture// prepend unconditionally for non-scheme input.+import { isSafeHref } from '../lib/isSafeHref.js';+const URL_SCHEME_PATTERN = /^(https?:\/\/|git@)/i;const DOMAIN_PATTERN = /^\S+\.\S+$/;/*** True when a stored/user value is an explicit http(s) URL — the only scheme* safe to render as a clickable link (rejects javascript:/data: so a stored- * URL can't smuggle a script into an href).+ * URL can't smuggle a script into an href). Alias of `isSafeHref` from+ * `client/src/lib/isSafeHref.js` (which mirrors `server/lib/isSafeHref.js`) —+ * kept here so existing importers of `isHttpUrl` don't need to change.** @param {string} url* @returns {boolean}*/-export const isHttpUrl = (url) => /^https?:\/\//i.test(url || '');+export const isHttpUrl = isSafeHref;/*** True only for a syntactically valid HTTPS URL. Use this for provider-issueddiff --git a/server/lib/README.md b/server/lib/README.mdindex a640a1a0b2..58b28e2f68 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -345,7 +345,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and| `tailscale.js` | Locate the Tailscale CLI binary, flag the sandboxed macOS App-bundle build, and return a normalized backend/MagicDNS/peer snapshot (`getTailscaleStatus` / `isTailscaleUp`). || `httpsState.js` | Captures whether PortOS booted with HTTPS active. || `bareUrl.js` | `parseBareUrl(text)` — returns the normalized URL when a captured string is nothing *but* a URL (bare host gets `https://`), else null. Drives the brain-capture short-circuit that files a pasted URL straight to Links instead of running the classifier. Stricter than the client's `urlNormalize.js` `isUrl` (needs a plausible TLD; http/https/`git@` only) because it picks a storage destination rather than a hint. |-| `isSafeHref.js` | Pure http(s)-only scheme check (`isSafeHref`) for user-supplied URL fields that get rendered as a clickable `<a href>` — rejects `javascript:`/`data:`/etc. stored-XSS payloads. Mirrors client `urlNormalize.js`'s `isHttpUrl`. |+| `isSafeHref.js` | Pure http(s)-only scheme check (`isSafeHref`) for user-supplied URL fields that get rendered as a clickable `<a href>` — rejects `javascript:`/`data:`/etc. stored-XSS payloads. Mirror of `client/src/lib/isSafeHref.js`, which `client/src/utils/urlNormalize.js` re-exports as `isHttpUrl`. || `networkExposure.js` | Runtime scheme/bind/cert snapshot plus the shared ordered Tailscale, MagicDNS, certificate, and trusted-launch setup guide used by CLI and UI; `localApiBaseUrl()` resolves the plain-HTTP loopback origin (mirror port under HTTPS, API port otherwise) for local scripts and agent-facing curl snippets. |## Search & indexing