@ultimat3/core 31.55.0 → 31.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/safe-url.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/core",
3
- "version": "31.55.0",
3
+ "version": "31.56.0",
4
4
  "description": "Ultimate's foundation: errors, context, env, config, clock, ids, logging, telemetry, lifecycle",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -57,6 +57,6 @@
57
57
  "test": "bun test"
58
58
  },
59
59
  "dependencies": {
60
- "@ultimat3/schema": "31.55.0"
60
+ "@ultimat3/schema": "31.56.0"
61
61
  }
62
62
  }
package/src/safe-url.ts CHANGED
@@ -15,6 +15,13 @@ export const URL_ATTRIBUTES: readonly string[] = ['href', 'src', 'action', 'form
15
15
  */
16
16
  const SAFE_SCHEMES: readonly string[] = ['http:', 'https:', 'mailto:', 'tel:', 'sms:'];
17
17
 
18
+ /**
19
+ * An authenticator setup link, as `enrolTotp` (`@ultimat3/auth`) answers it: following one opens
20
+ * an authenticator app with the account filled in, the one-tap setup on a phone. Nothing runs, and
21
+ * it is a link, so `href` only — never a `src` or a form target.
22
+ */
23
+ const LINK_ONLY_SCHEMES: readonly string[] = ['otpauth:'];
24
+
18
25
  const SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
19
26
 
20
27
  /** The prefix the `src` exemption is written against — see `safeUrl`'s last branch. */
@@ -47,6 +54,7 @@ export function safeUrl(value: string, attribute: string): string | null {
47
54
  if (matched === null) return value;
48
55
  const scheme = matched[0].toLowerCase();
49
56
  if (SAFE_SCHEMES.includes(scheme)) return value;
57
+ if (attribute === 'href' && LINK_ONLY_SCHEMES.includes(scheme)) return value;
50
58
  // The one data URL kept, and only where the bytes are RENDERED rather than navigated to: the
51
59
  // framework's own blur placeholder is a `data:image/webp`. In an `href` a data URL is a document
52
60
  // that runs on nothing but is still a phishing surface, so it is refused there.