@flamingo-stack/openframe-frontend-core 0.0.810 → 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 (115) 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-MAQFG62O.cjs → chunk-66J7ZSI5.cjs} +34 -34
  5. package/dist/{chunk-RKNCNL6K.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-3FBXQSSC.cjs → chunk-CB77J5L7.cjs} +858 -664
  10. package/dist/{chunk-VHX4A4SA.cjs → chunk-CC3Q3MQG.cjs} +2 -2
  11. package/dist/{chunk-TOTR2WMH.cjs → chunk-CJ7W2SY4.cjs} +8 -8
  12. package/dist/{chunk-CZWQCYKV.cjs → chunk-CLU2KJFB.cjs} +3 -3
  13. package/dist/{chunk-OJZBZH56.cjs → chunk-CNTBGJA7.cjs} +3 -3
  14. package/dist/{chunk-F26COFTW.cjs → chunk-CPP2APON.cjs} +89 -89
  15. package/dist/{chunk-TT64NRFU.cjs → chunk-ERLMCSGF.cjs} +3 -3
  16. package/dist/{chunk-RPBOWCME.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-EKDLVUEA.cjs → chunk-GU3GJ5DH.cjs} +48 -48
  20. package/dist/{chunk-X2JSCOOR.cjs → chunk-IQLXO6EI.cjs} +97 -97
  21. package/dist/{chunk-J4QORJMC.cjs → chunk-J6C7F63P.cjs} +113 -113
  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-FCFYZIOY.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-B6DIM5JG.cjs → chunk-O32RLIN4.cjs} +6 -6
  29. package/dist/{chunk-2C63MX75.cjs → chunk-O4MEG2ZS.cjs} +21 -21
  30. package/dist/{chunk-4W77VLQV.cjs → chunk-OQDPZOGC.cjs} +6 -6
  31. package/dist/{chunk-ZXBRPQND.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-ETI7OMPU.cjs → chunk-R55KNVPR.cjs} +71 -71
  35. package/dist/{chunk-NG3RKTQU.cjs → chunk-SFUNXMY3.cjs} +8 -8
  36. package/dist/{chunk-GG36TCKP.cjs → chunk-TKK66KHU.cjs} +6 -6
  37. package/dist/{chunk-TGOJHOQR.cjs → chunk-U2MHQBL4.cjs} +3 -3
  38. package/dist/{chunk-I3RJLXEL.cjs → chunk-UP3TLY2V.cjs} +131 -131
  39. package/dist/{chunk-CLMUD56S.cjs → chunk-VXMPVDOS.cjs} +26 -26
  40. package/dist/{chunk-MSAXZRXZ.cjs → chunk-WX5WDSKV.cjs} +583 -582
  41. package/dist/{chunk-R2ABQG2T.cjs → chunk-XLEWM5X5.cjs} +53 -53
  42. package/dist/{chunk-SZHDXXMK.cjs → chunk-YSDB6HGQ.cjs} +3 -3
  43. package/dist/{chunk-JLKGLPDC.cjs → chunk-ZW25QUJK.cjs} +16 -16
  44. package/dist/{chunk-FLW2VL5W.cjs → chunk-ZZO3FGPM.cjs} +24 -24
  45. package/dist/{cloud-tenants-QTASS5KP.cjs → cloud-tenants-XGGQG7SO.cjs} +24 -24
  46. package/dist/components/case-studies/index.cjs +40 -40
  47. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  48. package/dist/components/chat/entity-cards/dispatch.js +4 -1
  49. package/dist/components/chat/index.cjs +18 -18
  50. package/dist/components/contact/index.cjs +25 -25
  51. package/dist/components/docs/index.cjs +28 -28
  52. package/dist/components/embeds/index.cjs +25 -25
  53. package/dist/components/faq/index.cjs +26 -26
  54. package/dist/components/features/index.cjs +24 -24
  55. package/dist/components/help-center-pages/index.cjs +129 -129
  56. package/dist/components/index.cjs +89 -89
  57. package/dist/components/meeting-scheduler/index.cjs +93 -93
  58. package/dist/components/navigation/index.cjs +27 -27
  59. package/dist/components/onboarding-guides/index.cjs +27 -27
  60. package/dist/components/product-demo/index.cjs +35 -35
  61. package/dist/components/related-content/index.cjs +14 -14
  62. package/dist/components/tickets/index.cjs +31 -31
  63. package/dist/components/ui/index.cjs +24 -24
  64. package/dist/components/ui/markdown/base-components.d.ts.map +1 -1
  65. package/dist/components/ui/markdown/base-components.js +6 -7
  66. package/dist/components/ui/markdown/engine.d.ts +7 -0
  67. package/dist/components/ui/markdown/engine.d.ts.map +1 -1
  68. package/dist/components/ui/markdown/engine.js +12 -3
  69. package/dist/components/ui/markdown/external-media-notice.d.ts +33 -0
  70. package/dist/components/ui/markdown/external-media-notice.d.ts.map +1 -0
  71. package/dist/components/ui/markdown/external-media-notice.js +56 -0
  72. package/dist/components/ui/markdown/mermaid-diagram.d.ts +24 -2
  73. package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -1
  74. package/dist/components/ui/markdown/mermaid-diagram.js +66 -6
  75. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts +4 -4
  76. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts.map +1 -1
  77. package/dist/components/ui/markdown/rich/rich-markdown-renderer.js +2 -1
  78. package/dist/components/ui/markdown/sanitize.d.ts +28 -3
  79. package/dist/components/ui/markdown/sanitize.d.ts.map +1 -1
  80. package/dist/components/ui/markdown/sanitize.js +84 -12
  81. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts +3 -2
  82. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts.map +1 -1
  83. package/dist/{devices-KPMQI57Y.cjs → devices-H5Y4DBVC.cjs} +25 -25
  84. package/dist/{embeddable-chat-LB7NDFVQ.cjs → embeddable-chat-77ZOLCCK.cjs} +88 -88
  85. package/dist/hooks/index.cjs +10 -10
  86. package/dist/index.cjs +29 -29
  87. package/dist/{knowledge-JWGBY3ZJ.cjs → knowledge-MGH65HXM.cjs} +25 -25
  88. package/dist/{logs-QENTXKWY.cjs → logs-OL7ETVK6.cjs} +32 -32
  89. package/dist/{policies-2HXFZ2EL.cjs → policies-BCECWQ3F.cjs} +28 -28
  90. package/dist/{remote-session-LMUFV2RZ.cjs → remote-session-HML4UF7W.cjs} +11 -11
  91. package/dist/{scripts-TMXULK6L.cjs → scripts-XCD6V2JB.cjs} +31 -31
  92. package/dist/{software-update-H2LAEWDN.cjs → software-update-U5ESXRG5.cjs} +28 -28
  93. package/dist/{tickets-board-QF5JNSH2.cjs → tickets-board-EICQ5VLE.cjs} +14 -14
  94. package/dist/utils/app-origins.d.ts +41 -0
  95. package/dist/utils/app-origins.d.ts.map +1 -0
  96. package/dist/utils/app-origins.js +51 -0
  97. package/dist/utils/embed-auth-adapter-registry.d.ts +7 -0
  98. package/dist/utils/embed-auth-adapter-registry.d.ts.map +1 -0
  99. package/dist/utils/embed-auth-adapter-registry.js +34 -0
  100. package/dist/utils/embed-authed-fetch.d.ts.map +1 -1
  101. package/dist/utils/embed-authed-fetch.js +6 -19
  102. package/dist/utils/index.cjs +28 -12
  103. package/dist/{video-file-player-2FMFCGXE.cjs → video-file-player-4QMVTOBE.cjs} +3 -3
  104. package/package.json +1 -1
  105. package/src/components/chat/entity-cards/dispatch.tsx +12 -1
  106. package/src/components/ui/markdown/base-components.tsx +6 -7
  107. package/src/components/ui/markdown/engine.tsx +29 -5
  108. package/src/components/ui/markdown/external-media-notice.tsx +84 -0
  109. package/src/components/ui/markdown/mermaid-diagram.tsx +107 -5
  110. package/src/components/ui/markdown/rich/rich-markdown-renderer.tsx +11 -5
  111. package/src/components/ui/markdown/sanitize.ts +162 -15
  112. package/src/components/ui/markdown/simple-markdown-renderer.tsx +6 -2
  113. package/src/utils/app-origins.ts +95 -0
  114. package/src/utils/embed-auth-adapter-registry.ts +49 -0
  115. package/src/utils/embed-authed-fetch.ts +7 -35
@@ -0,0 +1,95 @@
1
+ import { readRegisteredAdapter, subscribeRegisteredAdapter } from './embed-auth-adapter-registry';
2
+
3
+ /**
4
+ * Where the app loads from: the page, and the origins the host sanctions in
5
+ * `EmbedAuthAdapter.allowedOrigins` (the gateway of a native shell, whose page
6
+ * origin is `capacitor://` / `tauri://`). Untrusted markdown may load media
7
+ * only from here; `embedAuthedFetch` sends the bearer only here.
8
+ */
9
+ export interface AppOrigins {
10
+ /** The page's root URL (`https://host/`, `capacitor://localhost/`); `null` on the server, where there is no page. */
11
+ readonly pageUrl: string | null;
12
+ readonly allowedOrigins: readonly string[];
13
+ }
14
+
15
+ /** The server's answer, and the first one a hydrating client gives: only relative URLs belong to the app. */
16
+ export const SERVER_APP_ORIGINS: AppOrigins = Object.freeze({ pageUrl: null, allowedOrigins: Object.freeze([]) });
17
+
18
+ /** Base relative URLs resolve against without a page: only a relative URL lands on it. */
19
+ const SERVER_PAGE_URL = 'http://app.invalid/';
20
+
21
+ let snapshot: AppOrigins = SERVER_APP_ORIGINS;
22
+
23
+ /**
24
+ * The app's origins now. Same object until they change, so it can be a
25
+ * `useSyncExternalStore` snapshot (`subscribeAppOrigins` reports the change).
26
+ */
27
+ export function readAppOrigins(): AppOrigins {
28
+ if (typeof window === 'undefined') return SERVER_APP_ORIGINS;
29
+ // The page's root, not its full URL: only the origin decides, and a snapshot
30
+ // that changed with every `?tab=` would re-parse every markdown body on the
31
+ // page. Parsed from `href` rather than read from `window.location.origin`:
32
+ // tests mock `window.location` as a plain object without an `origin` field.
33
+ let pageUrl: string;
34
+ try {
35
+ pageUrl = new URL('/', window.location.href).href;
36
+ } catch {
37
+ return SERVER_APP_ORIGINS;
38
+ }
39
+ const allowedOrigins = readRegisteredAdapter<{ allowedOrigins?: readonly string[] }>()?.allowedOrigins ?? [];
40
+ if (
41
+ snapshot.pageUrl !== pageUrl ||
42
+ snapshot.allowedOrigins.length !== allowedOrigins.length ||
43
+ snapshot.allowedOrigins.some((origin, i) => origin !== allowedOrigins[i])
44
+ ) {
45
+ snapshot = { pageUrl, allowedOrigins: [...allowedOrigins] };
46
+ }
47
+ return snapshot;
48
+ }
49
+
50
+ /** Called when a host registers, replaces or clears its auth adapter, which can change `allowedOrigins`. */
51
+ export const subscribeAppOrigins: (listener: () => void) => () => void = subscribeRegisteredAdapter;
52
+
53
+ /**
54
+ * `url` resolved against the page when it belongs to the app, otherwise `null`.
55
+ *
56
+ * The page match compares scheme and host instead of `URL.origin`, which is
57
+ * `"null"` for a `capacitor://` page.
58
+ */
59
+ export function resolveAppOriginUrl(url: string, origins: AppOrigins = readAppOrigins()): URL | null {
60
+ let page: URL;
61
+ let target: URL;
62
+ try {
63
+ page = new URL(origins.pageUrl ?? SERVER_PAGE_URL);
64
+ target = new URL(url, page);
65
+ } catch {
66
+ return null;
67
+ }
68
+ if (target.protocol === page.protocol && target.host === page.host) return target;
69
+ if (target.protocol !== 'http:' && target.protocol !== 'https:') return null;
70
+ return origins.allowedOrigins.includes(target.origin) ? target : null;
71
+ }
72
+
73
+ /**
74
+ * Whether `url` loads from the app itself rather than from a third party.
75
+ * Untrusted markdown may only load media from here: a third-party `<img src>`
76
+ * is a request the content's author receives, with whatever the URL carries.
77
+ * Pass `origins` to decide against a snapshot (a render that must give the
78
+ * server's answer while it hydrates); it defaults to the app's origins now.
79
+ */
80
+ export function isAppOriginUrl(url: string, origins?: AppOrigins): boolean {
81
+ return resolveAppOriginUrl(url, origins) !== null;
82
+ }
83
+
84
+ /**
85
+ * `url` as an absolute http(s) URL against `origins`' page, for a notice to
86
+ * name its host; `null` when it is not http(s).
87
+ */
88
+ export function absoluteHttpUrl(url: string, origins: AppOrigins = readAppOrigins()): string | null {
89
+ try {
90
+ const resolved = new URL(url.trim(), origins.pageUrl ?? SERVER_PAGE_URL);
91
+ return resolved.protocol === 'http:' || resolved.protocol === 'https:' ? resolved.href : null;
92
+ } catch {
93
+ return null;
94
+ }
95
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The slot the host's auth adapter (`setEmbedAuthAdapter`) is registered in, and the listeners told when it changes.
3
+ *
4
+ * Both are parked on `globalThis`, NOT in module-private `let`s. Reason: this lib ships multiple entry points
5
+ * (`/utils`, `/components/chat`, …) and a consumer's bundler can inline a file into more than one chunk, giving each
6
+ * chunk its OWN module scope. If the host calls `setEmbedAuthAdapter` from the `/utils` copy while the chat's
7
+ * `embedAuthedFetch` runs from the `/components/chat` copy, a module-local `let` would be set on one copy and read as
8
+ * `null` on the other (the exact "credentials: same-origin, no Bearer, no refresh" symptom). The listeners follow the
9
+ * slot for the same reason: one registered in another copy must still hear about the change.
10
+ *
11
+ * No imports, so the readers (`embed-authed-fetch`, `app-origins`) do not depend on each other through it.
12
+ */
13
+ const ADAPTER_GLOBAL_KEY = '__embedAuthedFetchAdapter__';
14
+ const LISTENERS_GLOBAL_KEY = '__embedAuthedFetchAdapterListeners__';
15
+
16
+ type Slots = Record<string, unknown>;
17
+
18
+ function listeners(): Set<() => void> {
19
+ const slots = globalThis as Slots;
20
+ let set = slots[LISTENERS_GLOBAL_KEY] as Set<() => void> | undefined;
21
+ if (!set) {
22
+ set = new Set();
23
+ slots[LISTENERS_GLOBAL_KEY] = set;
24
+ }
25
+ return set;
26
+ }
27
+
28
+ /** The registered adapter, typed by the caller (the slot itself does not know the adapter's shape). */
29
+ export function readRegisteredAdapter<T>(): T | null {
30
+ if (typeof globalThis === 'undefined') return null;
31
+ return ((globalThis as Slots)[ADAPTER_GLOBAL_KEY] as T | null | undefined) ?? null;
32
+ }
33
+
34
+ /** Store the adapter (or `null`) and tell every listener, in every copy of this module. */
35
+ export function writeRegisteredAdapter(adapter: unknown): void {
36
+ if (typeof globalThis === 'undefined') return;
37
+ (globalThis as Slots)[ADAPTER_GLOBAL_KEY] = adapter;
38
+ for (const listener of [...listeners()]) listener();
39
+ }
40
+
41
+ /** Called after every registration, replacement or clear. */
42
+ export function subscribeRegisteredAdapter(listener: () => void): () => void {
43
+ if (typeof globalThis === 'undefined') return () => {};
44
+ const set = listeners();
45
+ set.add(listener);
46
+ return () => {
47
+ set.delete(listener);
48
+ };
49
+ }
@@ -20,6 +20,8 @@
20
20
  * (e.g. `/api/profile/me`) keep using vanilla `fetch`.
21
21
  */
22
22
 
23
+ import { resolveAppOriginUrl } from './app-origins';
24
+ import { readRegisteredAdapter, writeRegisteredAdapter } from './embed-auth-adapter-registry';
23
25
  import { applyProxyAuth } from './embed-proxy-auth-storage';
24
26
 
25
27
  // =============================================================================
@@ -139,28 +141,9 @@ export interface EmbedAuthAdapter {
139
141
  subscribe?: (listener: () => void) => () => void;
140
142
  }
141
143
 
142
- /**
143
- * The registered adapter is parked on `globalThis`, NOT in a module-private
144
- * `let`. Reason: this lib ships multiple entry points (`/utils`,
145
- * `/components/chat`, …) and a consumer's bundler can inline this file into
146
- * more than one chunk — giving each chunk its OWN module scope. If the host
147
- * calls `setEmbedAuthAdapter` from the `/utils` copy while the chat's
148
- * `embedAuthedFetch` runs from the `/components/chat` copy, a module-local
149
- * `let` would be set on one copy and read as `null` on the other (the exact
150
- * "credentials: same-origin, no Bearer, no refresh" symptom). A single
151
- * `globalThis` slot is shared across every copy, so registration always
152
- * reaches the fetch path.
153
- */
154
- const ADAPTER_GLOBAL_KEY = '__embedAuthedFetchAdapter__';
155
-
144
+ /** The registered adapter: a `globalThis` slot shared by every copy of this module (see the registry). */
156
145
  function getRegisteredAuthAdapter(): EmbedAuthAdapter | null {
157
- if (typeof globalThis === 'undefined') return null;
158
- return ((globalThis as Record<string, unknown>)[ADAPTER_GLOBAL_KEY] as EmbedAuthAdapter | null) ?? null;
159
- }
160
-
161
- function storeRegisteredAuthAdapter(adapter: EmbedAuthAdapter | null): void {
162
- if (typeof globalThis === 'undefined') return;
163
- (globalThis as Record<string, unknown>)[ADAPTER_GLOBAL_KEY] = adapter;
146
+ return readRegisteredAdapter<EmbedAuthAdapter>();
164
147
  }
165
148
 
166
149
  /**
@@ -181,7 +164,7 @@ export function setEmbedAuthAdapter(adapter: EmbedAuthAdapter | null): void {
181
164
  'mount order and pass `null` from the unmounting provider.',
182
165
  );
183
166
  }
184
- storeRegisteredAuthAdapter(adapter);
167
+ writeRegisteredAdapter(adapter);
185
168
  }
186
169
 
187
170
  /**
@@ -237,19 +220,8 @@ export function needsBearerAssetFetch(url: string): boolean {
237
220
  if (typeof window === 'undefined') return false;
238
221
  const adapter = getRegisteredAuthAdapter();
239
222
  if (!adapter || adapter.getHeaders?.().Authorization === undefined) return false;
240
- let target: URL;
241
- let pageOrigin: string;
242
- try {
243
- target = new URL(url, window.location.href);
244
- // Same reason `assertSameOrigin` derives it this way: test environments
245
- // mock `window.location` as a plain object with no `origin` field.
246
- pageOrigin = new URL(window.location.href).origin;
247
- } catch {
248
- return false;
249
- }
250
- if (target.protocol !== 'http:' && target.protocol !== 'https:') return false;
251
- if (target.origin === pageOrigin) return true;
252
- return adapter.allowedOrigins?.includes(target.origin) ?? false;
223
+ const target = resolveAppOriginUrl(url);
224
+ return target !== null && (target.protocol === 'http:' || target.protocol === 'https:');
253
225
  }
254
226
 
255
227
  /**