@flamingo-stack/openframe-frontend-core 0.0.568 → 0.0.569-snapshot.20260827034838
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.
- package/dist/{chunk-2LKVYI7H.js → chunk-3H6NH2AD.js} +6 -6
- package/dist/{chunk-KZ3PIUCH.cjs → chunk-3YO2ZIZL.cjs} +14 -14
- package/dist/{chunk-KZ3PIUCH.cjs.map → chunk-3YO2ZIZL.cjs.map} +1 -1
- package/dist/{chunk-L22CSZZU.cjs → chunk-4BJ4FQPG.cjs} +18 -18
- package/dist/{chunk-L22CSZZU.cjs.map → chunk-4BJ4FQPG.cjs.map} +1 -1
- package/dist/{chunk-EYXZF46V.js → chunk-5NVVVIHJ.js} +1038 -922
- package/dist/chunk-5NVVVIHJ.js.map +1 -0
- package/dist/{chunk-P7QGTNEW.cjs → chunk-6WXL6CIL.cjs} +101 -101
- package/dist/{chunk-P7QGTNEW.cjs.map → chunk-6WXL6CIL.cjs.map} +1 -1
- package/dist/{chunk-CEAAOVCV.cjs → chunk-AJPGQCZ2.cjs} +1 -1
- package/dist/chunk-AJPGQCZ2.cjs.map +1 -0
- package/dist/{chunk-NK3M6F5A.cjs → chunk-AQ6MIFNX.cjs} +148 -13
- package/dist/chunk-AQ6MIFNX.cjs.map +1 -0
- package/dist/{chunk-6PWUUWCO.cjs → chunk-CSCAOET4.cjs} +42 -42
- package/dist/{chunk-6PWUUWCO.cjs.map → chunk-CSCAOET4.cjs.map} +1 -1
- package/dist/{chunk-6I76UK2Z.cjs → chunk-CYY2PEYQ.cjs} +3 -3
- package/dist/{chunk-6I76UK2Z.cjs.map → chunk-CYY2PEYQ.cjs.map} +1 -1
- package/dist/{chunk-Y2BYHTEN.cjs → chunk-D463PBIY.cjs} +23 -23
- package/dist/{chunk-Y2BYHTEN.cjs.map → chunk-D463PBIY.cjs.map} +1 -1
- package/dist/{chunk-NKEOD2AD.cjs → chunk-DP2L7US5.cjs} +3 -3
- package/dist/{chunk-NKEOD2AD.cjs.map → chunk-DP2L7US5.cjs.map} +1 -1
- package/dist/{chunk-KZS2DFC2.cjs → chunk-GDPPFPLD.cjs} +42 -42
- package/dist/{chunk-KZS2DFC2.cjs.map → chunk-GDPPFPLD.cjs.map} +1 -1
- package/dist/{chunk-LNUXUOPN.cjs → chunk-HJCXSI7R.cjs} +4 -4
- package/dist/{chunk-LNUXUOPN.cjs.map → chunk-HJCXSI7R.cjs.map} +1 -1
- package/dist/{chunk-RBYMJF2V.cjs → chunk-I7CFA5DO.cjs} +35 -35
- package/dist/{chunk-RBYMJF2V.cjs.map → chunk-I7CFA5DO.cjs.map} +1 -1
- package/dist/{chunk-LXWQLUBR.cjs → chunk-IJA26YDA.cjs} +9 -7
- package/dist/chunk-IJA26YDA.cjs.map +1 -0
- package/dist/{chunk-O3JCKEVG.js → chunk-KYDVOX5J.js} +2 -2
- package/dist/{chunk-UWY722RH.js → chunk-MR6RRXSD.js} +1 -1
- package/dist/chunk-MR6RRXSD.js.map +1 -0
- package/dist/{chunk-HB3IG2MC.js → chunk-MT7IDGCM.js} +3 -3
- package/dist/{chunk-G2PAUMV6.js → chunk-MTORQ4LY.js} +4 -4
- package/dist/{chunk-HKG7BZON.cjs → chunk-PS2TV7WG.cjs} +14 -14
- package/dist/{chunk-HKG7BZON.cjs.map → chunk-PS2TV7WG.cjs.map} +1 -1
- package/dist/{chunk-QVQLNKFS.js → chunk-PTDRJCPW.js} +2 -2
- package/dist/{chunk-DZ2Z7HRF.js → chunk-QIU5B2ZD.js} +3 -3
- package/dist/{chunk-6RSKK4E7.cjs → chunk-RVCCJB6M.cjs} +1278 -1162
- package/dist/chunk-RVCCJB6M.cjs.map +1 -0
- package/dist/{chunk-T7AE7CKV.cjs → chunk-T4MB5TX6.cjs} +7 -7
- package/dist/{chunk-T7AE7CKV.cjs.map → chunk-T4MB5TX6.cjs.map} +1 -1
- package/dist/{chunk-ZARYIFCI.js → chunk-TQER4FVN.js} +5 -3
- package/dist/{chunk-ZARYIFCI.js.map → chunk-TQER4FVN.js.map} +1 -1
- package/dist/{chunk-BZ7B255K.js → chunk-U6NPZMNT.js} +9 -9
- package/dist/{chunk-MQQM4NCN.js → chunk-VZQKENQU.js} +3 -3
- package/dist/{chunk-VEXTUGUA.js → chunk-XWMEHLDK.js} +7 -7
- package/dist/{chunk-ZNEVGXMU.js → chunk-YFLKONLB.js} +139 -4
- package/dist/chunk-YFLKONLB.js.map +1 -0
- package/dist/{chunk-ZXASQL3E.js → chunk-YYESWAAQ.js} +4 -4
- package/dist/{chunk-6TDWCBQM.js → chunk-Z3MSD6ZE.js} +7 -7
- package/dist/{chunk-DHTT77AG.cjs → chunk-Z7DXVKVT.cjs} +78 -78
- package/dist/{chunk-DHTT77AG.cjs.map → chunk-Z7DXVKVT.cjs.map} +1 -1
- package/dist/{chunk-KL6ZDLDF.js → chunk-ZAYZ7JHF.js} +2 -2
- package/dist/{chunk-ZIZJDXUI.js → chunk-ZTGWMXJK.js} +2 -2
- package/dist/components/case-studies/index.cjs +10 -10
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/index.cjs +4 -17
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +3 -16
- package/dist/components/chat/utils/index.d.ts +0 -2
- package/dist/components/chat/utils/index.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/claude-embed.d.ts +15 -8
- package/dist/components/embeds/claude-embed.d.ts.map +1 -1
- package/dist/components/embeds/embed-viewer-frame.d.ts +17 -2
- package/dist/components/embeds/embed-viewer-frame.d.ts.map +1 -1
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +6 -6
- package/dist/components/faq/index.js +5 -5
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +25 -25
- package/dist/components/help-center-pages/index.js +16 -16
- package/dist/components/index.cjs +142 -154
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +14 -26
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +36 -36
- package/dist/components/meeting-scheduler/index.js +5 -5
- package/dist/components/navigation/index.cjs +4 -4
- package/dist/components/navigation/index.js +3 -3
- package/dist/components/onboarding-guides/index.cjs +8 -8
- package/dist/components/onboarding-guides/index.js +7 -7
- package/dist/components/related-content/index.cjs +6 -6
- package/dist/components/related-content/index.js +5 -5
- package/dist/components/tickets/index.cjs +8 -8
- package/dist/components/tickets/index.js +7 -7
- package/dist/components/ui/index.cjs +4 -16
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +3 -15
- package/dist/components/ui/markdown/sanitize.d.ts.map +1 -1
- package/dist/components/ui/table/table.d.ts +1 -1
- package/dist/components/ui/table/table.d.ts.map +1 -1
- package/dist/components/ui/table/types.d.ts +9 -0
- package/dist/components/ui/table/types.d.ts.map +1 -1
- package/dist/contexts/endpoints-runtime-context.d.ts +6 -0
- package/dist/contexts/endpoints-runtime-context.d.ts.map +1 -1
- package/dist/contexts/index.cjs +2 -2
- package/dist/contexts/index.js +1 -1
- package/dist/hooks/index.cjs +5 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -2
- package/dist/hooks/use-claude-mirror-src.d.ts +38 -0
- package/dist/hooks/use-claude-mirror-src.d.ts.map +1 -0
- package/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -13
- package/dist/utils/embed-proxy-auth-storage.d.ts.map +1 -1
- package/dist/utils/embed-url-converters.d.ts +20 -0
- package/dist/utils/embed-url-converters.d.ts.map +1 -1
- package/dist/utils/fullscreen-switch.d.ts +85 -0
- package/dist/utils/fullscreen-switch.d.ts.map +1 -0
- package/dist/utils/index.cjs +114 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +113 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/hooks/use-chat-attachments.ts +3 -3
- package/src/components/chat/hooks/use-chat-history-hydration.ts +2 -2
- package/src/components/chat/hooks/use-chat-identity.ts +5 -5
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +3 -3
- package/src/components/chat/utils/.index.md +1 -2
- package/src/components/chat/utils/chat-conversation-storage.ts +2 -2
- package/src/components/chat/utils/index.ts +3 -10
- package/src/components/embeds/claude-embed.tsx +50 -14
- package/src/components/embeds/embed-viewer-frame.tsx +103 -5
- package/src/components/ui/markdown/__tests__/sanitize-invariant.test.ts +30 -0
- package/src/components/ui/markdown/rich/__tests__/shortcodes.test.ts +8 -0
- package/src/components/ui/markdown/sanitize.ts +4 -0
- package/src/components/ui/table/table.tsx +7 -2
- package/src/components/ui/table/types.ts +9 -0
- package/src/contexts/endpoints-runtime-context.tsx +6 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/use-claude-mirror-src.ts +103 -0
- package/src/utils/.embed-proxy-auth-storage.md +2 -2
- package/src/utils/embed-proxy-auth-storage.ts +19 -14
- package/src/utils/embed-url-converters.ts +45 -0
- package/src/utils/fullscreen-switch.ts +180 -0
- package/src/utils/index.ts +8 -6
- package/dist/chunk-6RSKK4E7.cjs.map +0 -1
- package/dist/chunk-CEAAOVCV.cjs.map +0 -1
- package/dist/chunk-EYXZF46V.js.map +0 -1
- package/dist/chunk-LXWQLUBR.cjs.map +0 -1
- package/dist/chunk-NK3M6F5A.cjs.map +0 -1
- package/dist/chunk-UWY722RH.js.map +0 -1
- package/dist/chunk-ZNEVGXMU.js.map +0 -1
- package/dist/components/chat/utils/chat-authed-fetch.d.ts +0 -15
- package/dist/components/chat/utils/chat-authed-fetch.d.ts.map +0 -1
- package/dist/components/chat/utils/chat-proxy-auth-storage.d.ts +0 -16
- package/dist/components/chat/utils/chat-proxy-auth-storage.d.ts.map +0 -1
- package/src/components/chat/utils/.chat-authed-fetch.md +0 -25
- package/src/components/chat/utils/.chat-proxy-auth-storage.md +0 -38
- package/src/components/chat/utils/chat-authed-fetch.ts +0 -17
- package/src/components/chat/utils/chat-proxy-auth-storage.ts +0 -25
- /package/dist/{chunk-2LKVYI7H.js.map → chunk-3H6NH2AD.js.map} +0 -0
- /package/dist/{chunk-O3JCKEVG.js.map → chunk-KYDVOX5J.js.map} +0 -0
- /package/dist/{chunk-HB3IG2MC.js.map → chunk-MT7IDGCM.js.map} +0 -0
- /package/dist/{chunk-G2PAUMV6.js.map → chunk-MTORQ4LY.js.map} +0 -0
- /package/dist/{chunk-QVQLNKFS.js.map → chunk-PTDRJCPW.js.map} +0 -0
- /package/dist/{chunk-DZ2Z7HRF.js.map → chunk-QIU5B2ZD.js.map} +0 -0
- /package/dist/{chunk-BZ7B255K.js.map → chunk-U6NPZMNT.js.map} +0 -0
- /package/dist/{chunk-MQQM4NCN.js.map → chunk-VZQKENQU.js.map} +0 -0
- /package/dist/{chunk-VEXTUGUA.js.map → chunk-XWMEHLDK.js.map} +0 -0
- /package/dist/{chunk-ZXASQL3E.js.map → chunk-YYESWAAQ.js.map} +0 -0
- /package/dist/{chunk-6TDWCBQM.js.map → chunk-Z3MSD6ZE.js.map} +0 -0
- /package/dist/{chunk-KL6ZDLDF.js.map → chunk-ZAYZ7JHF.js.map} +0 -0
- /package/dist/{chunk-ZIZJDXUI.js.map → chunk-ZTGWMXJK.js.map} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react'
|
|
4
|
+
import { useEndpointsRuntime } from '../contexts/endpoints-runtime-context'
|
|
5
|
+
import { toClaudeMirrorPath } from '../utils/embed-url-converters'
|
|
6
|
+
|
|
7
|
+
export type ClaudeMirrorStatus =
|
|
8
|
+
/** No mirror candidate at all (no proxy configured, or a non-mirrorable url). */
|
|
9
|
+
| 'absent'
|
|
10
|
+
/** Probing the host for a self-hosted mirror (or minting one on first view). */
|
|
11
|
+
| 'probing'
|
|
12
|
+
/** A mirror exists and `src` points at it. */
|
|
13
|
+
| 'found'
|
|
14
|
+
|
|
15
|
+
export interface ClaudeMirrorState {
|
|
16
|
+
/** The mirror src when found (with a cache-bust once a re-publish is
|
|
17
|
+
* detected), else `null`. */
|
|
18
|
+
src: string | null
|
|
19
|
+
status: ClaudeMirrorStatus
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Ask the host's storage-view proxy whether the cached mirror is still the
|
|
24
|
+
* artifact's CURRENT version, re-minting it silently if a re-publish moved
|
|
25
|
+
* it. Returns a cache-bust token (the new version) when the mirror changed,
|
|
26
|
+
* else null. Best-effort: any failure just leaves the shown mirror in place.
|
|
27
|
+
*/
|
|
28
|
+
async function revalidateMirror(mirrorPath: string): Promise<string | null> {
|
|
29
|
+
try {
|
|
30
|
+
const res = await fetch(`${mirrorPath}?revalidate=1`)
|
|
31
|
+
if (!res.ok) return null
|
|
32
|
+
const body = (await res.json()) as { updated?: boolean; version?: string | null }
|
|
33
|
+
return body?.updated ? String(body.version ?? Date.now()) : null
|
|
34
|
+
} catch {
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The host's SELF-HOSTED MIRROR src for a claude artifact url, plus a
|
|
41
|
+
* `status` so the viewer can show a loading state while it resolves — THE
|
|
42
|
+
* hook behind `ClaudeEmbed`'s transparent mirror leg, extracted so the
|
|
43
|
+
* component stays presentational.
|
|
44
|
+
*
|
|
45
|
+
* Fully under the hood, three moves:
|
|
46
|
+
* 1. Derive the candidate mirror path from the url's artifact id under the
|
|
47
|
+
* host's configured storage-view proxy base
|
|
48
|
+
* (`EndpointsRuntime.storageViewBaseUrl`) and probe it with a 1-byte
|
|
49
|
+
* ranged GET. On a cold first view that probe IS the server-side
|
|
50
|
+
* self-heal (~1-2s), which is exactly why `status: 'probing'` exists —
|
|
51
|
+
* the viewer shows a spinner instead of the empty "no embeddable view"
|
|
52
|
+
* flash. Exists → `found`; missing / no proxy / blip → `absent`, and the
|
|
53
|
+
* caller's claude.ai fallback stands (the pre-mirror behavior).
|
|
54
|
+
* 2. Once found, fire ONE background revalidation. If the artifact was
|
|
55
|
+
* re-published since the mirror was cached, the server re-mints it and
|
|
56
|
+
* reports the new version; the hook bumps a cache-bust on `src` so the
|
|
57
|
+
* iframe silently reloads the fresh bytes. Unchanged → nothing happens.
|
|
58
|
+
*
|
|
59
|
+
* A host that mounts no EndpointsRuntime provider (or omits the entry) skips
|
|
60
|
+
* the mirror leg entirely (`absent`).
|
|
61
|
+
*/
|
|
62
|
+
export function useClaudeMirrorSrc(url: string): ClaudeMirrorState {
|
|
63
|
+
const endpoints = useEndpointsRuntime()
|
|
64
|
+
const mirrorPath = toClaudeMirrorPath(url, endpoints?.storageViewBaseUrl)
|
|
65
|
+
const [state, setState] = useState<ClaudeMirrorState>(() => ({
|
|
66
|
+
src: null,
|
|
67
|
+
status: mirrorPath ? 'probing' : 'absent',
|
|
68
|
+
}))
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!mirrorPath) {
|
|
72
|
+
setState({ src: null, status: 'absent' })
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
setState({ src: null, status: 'probing' })
|
|
76
|
+
let cancelled = false
|
|
77
|
+
fetch(mirrorPath, { headers: { Range: 'bytes=0-0' } })
|
|
78
|
+
.then((res) => {
|
|
79
|
+
if (cancelled) return
|
|
80
|
+
if (!(res.ok || res.status === 206)) {
|
|
81
|
+
setState({ src: null, status: 'absent' })
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
setState({ src: mirrorPath, status: 'found' })
|
|
85
|
+
// Background freshness check — reload in place only if it changed.
|
|
86
|
+
revalidateMirror(mirrorPath).then((bust) => {
|
|
87
|
+
if (!cancelled && bust) {
|
|
88
|
+
setState({ src: `${mirrorPath}?v=${encodeURIComponent(bust)}`, status: 'found' })
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
.catch(() => {
|
|
93
|
+
// No proxy on this host / network blip — the caller's claude.ai
|
|
94
|
+
// fallback stands, same as before mirrors existed.
|
|
95
|
+
if (!cancelled) setState({ src: null, status: 'absent' })
|
|
96
|
+
})
|
|
97
|
+
return () => {
|
|
98
|
+
cancelled = true
|
|
99
|
+
}
|
|
100
|
+
}, [mirrorPath])
|
|
101
|
+
|
|
102
|
+
return state
|
|
103
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- source-hash: 4f6996d4ad0ba284b64e13807891eb62 -->
|
|
2
|
-
Manages client-side persistence of embed-surface proxy credentials (
|
|
2
|
+
Manages client-side persistence of embed-surface proxy credentials (a platform API key + impersonation email) in `localStorage`, enabling embedded surfaces (chat widget, ticket center, etc.) to authenticate as a proxied customer across sessions.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
5
5
|
|
|
@@ -35,4 +35,4 @@ const response = await fetch(url, { method: 'POST', headers })
|
|
|
35
35
|
clearEmbedProxyAuth()
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
> **Security note:** Credentials persist in `localStorage` (survives tab close and browser restart). This is intentional — re-pasting on every tab was rejected as a dev-experience tradeoff. The `/debug` entry point is admin-gated, and all headers are server-validated against `
|
|
38
|
+
> **Security note:** Credentials persist in `localStorage` (survives tab close and browser restart). This is intentional — re-pasting on every tab was rejected as a dev-experience tradeoff. The `/debug` entry point is admin-gated, and all headers are server-validated against the hash-at-rest platform API key store (revocable in `/admin/api-keys`).
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Client-side persistence for embed-surface proxy credentials
|
|
5
|
-
*
|
|
4
|
+
* Client-side persistence for embed-surface proxy credentials (a
|
|
5
|
+
* PLATFORM API KEY + impersonation email). Used by every embedded
|
|
6
6
|
* surface — the chat widget AND the ticket center AND any future
|
|
7
7
|
* embedded React component that needs to identify itself as the
|
|
8
8
|
* impersonated customer.
|
|
9
9
|
*
|
|
10
10
|
* When set, the surface attaches the creds as
|
|
11
|
-
* `Authorization: Bearer <
|
|
11
|
+
* `Authorization: Bearer <platform API key>` + `X-Chat-Act-As: <email>`
|
|
12
12
|
* on every call to `/api/docs/chat`, `/api/chat/*`, and any other route
|
|
13
13
|
* gated by `requireChatAuth` — proving to the server that this session
|
|
14
|
-
* is acting on behalf of <email>.
|
|
14
|
+
* is acting on behalf of <email>. The key is minted in the hub's
|
|
15
|
+
* `/admin/api-keys` and is platform-bound (`fpk_<platform>_…`): a
|
|
16
|
+
* SERVICE key may act as any email; a PERSONAL key only as its owner.
|
|
15
17
|
*
|
|
16
|
-
* **Naming history:** the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* env
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* **Naming history:** the stored field is still named `secret` and the
|
|
19
|
+
* wire-side header names are `X-Chat-*`. Those are client/server
|
|
20
|
+
* contracts predating the per-platform key migration (the old shared
|
|
21
|
+
* `CHAT_PROXY_SECRET` env is removed hub-side); renaming them would
|
|
22
|
+
* break persisted state + the wire shape for zero behavior change. The
|
|
23
|
+
* CLIENT-side helpers were renamed `Embed*` so non-chat surfaces (e.g.
|
|
24
|
+
* ticket center) don't have to import a chat-prefixed symbol just to
|
|
25
|
+
* send the same headers.
|
|
22
26
|
*
|
|
23
27
|
* Persists to **`localStorage`** so the bearer token + act-as identity
|
|
24
28
|
* survive tab close, new-tab opens, and browser restarts — the
|
|
@@ -26,10 +30,11 @@
|
|
|
26
30
|
* cycle was rejected as a dev-experience tradeoff that wasn't worth
|
|
27
31
|
* the security gain. An XSS sink on this origin can read the value
|
|
28
32
|
* indefinitely (vs only-this-tab with sessionStorage), but `/debug`
|
|
29
|
-
* is admin-gated behind the platform's `askAI.enabled` flag
|
|
30
|
-
*
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
33
|
+
* is admin-gated behind the platform's `askAI.enabled` flag, the key
|
|
34
|
+
* is server-verified (hash-at-rest, platform-bound, revocable in
|
|
35
|
+
* `/admin/api-keys`), and the act-as reach is bounded by the key's
|
|
36
|
+
* tier. Explicit "Clear" button on the creds bar is the supported
|
|
37
|
+
* logout path; closing the tab is no longer.
|
|
33
38
|
*
|
|
34
39
|
* Namespaced under `<platform>.chat.proxy-auth.v1` (the storage key is
|
|
35
40
|
* unchanged from the old chat-prefixed helper — that's a storage
|
|
@@ -76,6 +76,51 @@ export function toFigmaOriginalUrl(url: string): string {
|
|
|
76
76
|
return url.replace(/\?.*$/, '')
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The self-hosted MIRROR url for a claude artifact url — the whole
|
|
81
|
+
* mirror mechanism is UNDER THE HOOD: the viewer detects a claude url,
|
|
82
|
+
* DERIVES the mirror location from the artifact's own id under the
|
|
83
|
+
* host's configured storage-view proxy base, and frames the downloaded
|
|
84
|
+
* copy from there. No per-link data, no props, no shortcode changes —
|
|
85
|
+
* 100% transparent to every consumer.
|
|
86
|
+
*
|
|
87
|
+
* `storageViewBaseUrl` comes from `EndpointsRuntime` — the SAME
|
|
88
|
+
* host-overridable proxy-path mechanism every other lib→API call uses
|
|
89
|
+
* (a reverse-proxied embedder remaps it; a host without the proxy omits
|
|
90
|
+
* it and gets `null` here, i.e. no mirror leg at all).
|
|
91
|
+
*
|
|
92
|
+
* `null` when the base is absent or the url carries no artifact id. The
|
|
93
|
+
* derived url is the configured base + a validated uuid — safe as a
|
|
94
|
+
* frame source without further checks. KEEP THE OBJECT NAMING IN SYNC
|
|
95
|
+
* with the hub's `lib/data/design-brief-mirror.cjs` (bucket +
|
|
96
|
+
* `<uuid>.html`) — that module owns the ingest/audit half.
|
|
97
|
+
*/
|
|
98
|
+
export function toClaudeMirrorPath(
|
|
99
|
+
url: string | null | undefined,
|
|
100
|
+
storageViewBaseUrl: string | null | undefined,
|
|
101
|
+
): string | null {
|
|
102
|
+
if (!url || !storageViewBaseUrl) return null
|
|
103
|
+
try {
|
|
104
|
+
const u = new URL(url)
|
|
105
|
+
const host = u.hostname.toLowerCase()
|
|
106
|
+
const id =
|
|
107
|
+
(host === 'claude.ai' &&
|
|
108
|
+
/^\/(?:code\/artifact|public\/artifacts)\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:[/?#]|$)/i.exec(
|
|
109
|
+
u.pathname,
|
|
110
|
+
)?.[1]) ||
|
|
111
|
+
(host === 'claude.site' &&
|
|
112
|
+
/^\/artifacts\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:[/?#]|$)/i.exec(
|
|
113
|
+
u.pathname,
|
|
114
|
+
)?.[1]) ||
|
|
115
|
+
null
|
|
116
|
+
return id
|
|
117
|
+
? `${storageViewBaseUrl.replace(/\/$/, '')}/design-briefs/${id.toLowerCase()}.html`
|
|
118
|
+
: null
|
|
119
|
+
} catch {
|
|
120
|
+
return null
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
79
124
|
/**
|
|
80
125
|
* The EMBED url for a published Claude artifact, or `null` when the link is not
|
|
81
126
|
* one we can frame — the Claude counterpart of `toFigmaEmbedUrl`.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FullscreenSwitchController — the ONE place fullscreen enter/exit lives.
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic (no React): the consumer passes callbacks (and, for
|
|
5
|
+
* page-level surfaces, the <html> mask classes); the controller owns the
|
|
6
|
+
* Fullscreen API calls, webkit fallbacks, and the flicker-free switch
|
|
7
|
+
* choreography. Originally extracted from the hub's company-hub deck (PR
|
|
8
|
+
* #737); moved into the lib so EVERY fullscreen surface — the deck, the
|
|
9
|
+
* embed viewers — shares one implementation instead of re-deriving the
|
|
10
|
+
* event-ordering lessons below. The hub's `lib/utils/fullscreen-switch.ts`
|
|
11
|
+
* re-exports from here (extractItems shim precedent).
|
|
12
|
+
*
|
|
13
|
+
* Two shapes of consumer:
|
|
14
|
+
* - PAGE-LEVEL (the deck): no `target` — fullscreens
|
|
15
|
+
* `document.documentElement`, uses the mask classes + geometry pulses.
|
|
16
|
+
* - ELEMENT-LEVEL (embed viewers): pass `target` — fullscreens one
|
|
17
|
+
* element; classes/pulses are optional and simply skipped when absent.
|
|
18
|
+
*
|
|
19
|
+
* Invariants (each guards a bug found while building the deck's fullscreen):
|
|
20
|
+
* - Fullscreen STATE follows the fullscreenchange event exclusively (never
|
|
21
|
+
* set optimistically): Esc, keyboard shortcuts, buttons and browser
|
|
22
|
+
* chrome all converge on one listener.
|
|
23
|
+
* - The switching mask (when configured) goes up PRE-EMPTIVELY:
|
|
24
|
+
* Chrome/Safari PAINT resized frames BEFORE fullscreenchange fires
|
|
25
|
+
* (whatwg/fullscreen#74), so masking inside the change event is already
|
|
26
|
+
* too late. `toggle()` masks before requesting; an Escape keydown
|
|
27
|
+
* listener (capture) masks the one exit path that skips toggle(); the
|
|
28
|
+
* change event remains the fallback for browser-chrome-initiated
|
|
29
|
+
* transitions.
|
|
30
|
+
* - The swap is a multi-frame viewport animation (macOS especially): one
|
|
31
|
+
* rAF re-anchor is NOT enough. While masked, every resize fires
|
|
32
|
+
* onGeometryPulse (re-measure + re-anchor under a constant scrollY);
|
|
33
|
+
* quiet resizes for `quietMs` (or the `capMs` hard cap — a rejected
|
|
34
|
+
* fullscreen request after a pre-emptive mask must never wedge the mask
|
|
35
|
+
* up) end the switch.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Webkit-prefixed Fullscreen API fallbacks (Safari < 16.4 desktop, older
|
|
39
|
+
* iPadOS; iOS 26+ ships the standard API — isSupported() gates elsewhere). */
|
|
40
|
+
type FsDocument = Document & {
|
|
41
|
+
webkitFullscreenElement?: Element | null
|
|
42
|
+
webkitFullscreenEnabled?: boolean
|
|
43
|
+
webkitExitFullscreen?: () => void
|
|
44
|
+
}
|
|
45
|
+
type FsElement = HTMLElement & { webkitRequestFullscreen?: () => void }
|
|
46
|
+
|
|
47
|
+
const fullscreenElementOf = (doc: FsDocument) => doc.fullscreenElement ?? doc.webkitFullscreenElement ?? null
|
|
48
|
+
|
|
49
|
+
export interface FullscreenSwitchOptions {
|
|
50
|
+
/** The element to fullscreen. Omit for page-level surfaces (the deck):
|
|
51
|
+
* `document.documentElement` — window scrolling survives, which
|
|
52
|
+
* element-level fullscreen would freeze. A callback so refs resolve at
|
|
53
|
+
* toggle time, not construction time. */
|
|
54
|
+
target?: () => HTMLElement | null
|
|
55
|
+
/** Held on <html> while fullscreen is ACTIVE (steady-state styling).
|
|
56
|
+
* Optional — element-level consumers style off their own state. */
|
|
57
|
+
activeClass?: string
|
|
58
|
+
/** Held on <html> for the DURATION of an enter/exit swap (the
|
|
59
|
+
* mask/curtain). Optional — see `activeClass`. */
|
|
60
|
+
switchingClass?: string
|
|
61
|
+
/** New fullscreen state, straight from the change event. For a `target`
|
|
62
|
+
* consumer this is "MY element is the fullscreen element". */
|
|
63
|
+
onFullscreenChange: (isFullscreen: boolean) => void
|
|
64
|
+
/** Geometry moved under a constant scrollY — re-measure + re-anchor.
|
|
65
|
+
* Optional; fired once per resize during the swap and once more when
|
|
66
|
+
* the switch ends. */
|
|
67
|
+
onGeometryPulse?: () => void
|
|
68
|
+
/** Switch ends after resizes have been quiet this long (default 200ms). */
|
|
69
|
+
quietMs?: number
|
|
70
|
+
/** Hard cap on a switch, mask-wedge failsafe (default 1000ms). */
|
|
71
|
+
capMs?: number
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const DEFAULT_QUIET_MS = 200
|
|
75
|
+
const DEFAULT_CAP_MS = 1000
|
|
76
|
+
|
|
77
|
+
export class FullscreenSwitchController {
|
|
78
|
+
private quietTimer = 0
|
|
79
|
+
private capTimer = 0
|
|
80
|
+
private attached = false
|
|
81
|
+
|
|
82
|
+
constructor(private readonly opts: FullscreenSwitchOptions) {}
|
|
83
|
+
|
|
84
|
+
/** SSR-safe feature detection — call post-mount to gate the affordance. */
|
|
85
|
+
static isSupported(): boolean {
|
|
86
|
+
if (typeof document === 'undefined') return false
|
|
87
|
+
const doc = document as FsDocument
|
|
88
|
+
const el = document.documentElement as FsElement
|
|
89
|
+
return (
|
|
90
|
+
Boolean(el.requestFullscreen || el.webkitRequestFullscreen) &&
|
|
91
|
+
(doc.fullscreenEnabled ?? doc.webkitFullscreenEnabled ?? true) !== false
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get isFullscreen(): boolean {
|
|
96
|
+
const fs = fullscreenElementOf(document as FsDocument)
|
|
97
|
+
const target = this.opts.target?.()
|
|
98
|
+
return target ? fs === target : Boolean(fs)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
attach(): void {
|
|
102
|
+
if (this.attached) return
|
|
103
|
+
this.attached = true
|
|
104
|
+
const doc = document as FsDocument
|
|
105
|
+
doc.addEventListener('fullscreenchange', this.onChange)
|
|
106
|
+
doc.addEventListener('webkitfullscreenchange', this.onChange)
|
|
107
|
+
window.addEventListener('keydown', this.onEscape, true)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
detach(): void {
|
|
111
|
+
if (!this.attached) return
|
|
112
|
+
this.attached = false
|
|
113
|
+
const doc = document as FsDocument
|
|
114
|
+
doc.removeEventListener('fullscreenchange', this.onChange)
|
|
115
|
+
doc.removeEventListener('webkitfullscreenchange', this.onChange)
|
|
116
|
+
window.removeEventListener('keydown', this.onEscape, true)
|
|
117
|
+
window.removeEventListener('resize', this.onResize)
|
|
118
|
+
window.clearTimeout(this.quietTimer)
|
|
119
|
+
window.clearTimeout(this.capTimer)
|
|
120
|
+
if (this.opts.activeClass) doc.documentElement.classList.remove(this.opts.activeClass)
|
|
121
|
+
if (this.opts.switchingClass) doc.documentElement.classList.remove(this.opts.switchingClass)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Mask first (pre-emptive — see header), then request/exit. */
|
|
125
|
+
toggle = (): void => {
|
|
126
|
+
const doc = document as FsDocument
|
|
127
|
+
this.beginSwitch()
|
|
128
|
+
if (fullscreenElementOf(doc)) {
|
|
129
|
+
if (doc.exitFullscreen) doc.exitFullscreen().catch(() => {})
|
|
130
|
+
else doc.webkitExitFullscreen?.()
|
|
131
|
+
} else {
|
|
132
|
+
const el = (this.opts.target?.() ?? document.documentElement) as FsElement
|
|
133
|
+
// navigationUI:'hide' = prefer screen space over browser nav chrome.
|
|
134
|
+
if (el.requestFullscreen) el.requestFullscreen({ navigationUI: 'hide' }).catch(() => {})
|
|
135
|
+
else el.webkitRequestFullscreen?.()
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Raise the mask + start tracking. Idempotent — safe from the pre-emptive
|
|
140
|
+
* paths (toggle, Escape) AND again from the change event. */
|
|
141
|
+
private beginSwitch = (): void => {
|
|
142
|
+
if (this.opts.switchingClass) document.documentElement.classList.add(this.opts.switchingClass)
|
|
143
|
+
window.addEventListener('resize', this.onResize)
|
|
144
|
+
window.clearTimeout(this.capTimer)
|
|
145
|
+
this.capTimer = window.setTimeout(this.endSwitch, this.opts.capMs ?? DEFAULT_CAP_MS)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private endSwitch = (): void => {
|
|
149
|
+
window.clearTimeout(this.quietTimer)
|
|
150
|
+
window.clearTimeout(this.capTimer)
|
|
151
|
+
window.removeEventListener('resize', this.onResize)
|
|
152
|
+
this.opts.onGeometryPulse?.()
|
|
153
|
+
if (this.opts.switchingClass) document.documentElement.classList.remove(this.opts.switchingClass)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private armQuiet = (): void => {
|
|
157
|
+
window.clearTimeout(this.quietTimer)
|
|
158
|
+
this.quietTimer = window.setTimeout(this.endSwitch, this.opts.quietMs ?? DEFAULT_QUIET_MS)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private onResize = (): void => {
|
|
162
|
+
this.opts.onGeometryPulse?.()
|
|
163
|
+
this.armQuiet()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Escape is the one exit path that skips toggle() — pre-mask on the
|
|
167
|
+
* keydown (capture phase), before the browser begins the swap. */
|
|
168
|
+
private onEscape = (e: KeyboardEvent): void => {
|
|
169
|
+
if (e.key === 'Escape' && this.isFullscreen) this.beginSwitch()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private onChange = (): void => {
|
|
173
|
+
const fs = this.isFullscreen
|
|
174
|
+
if (this.opts.activeClass) document.documentElement.classList.toggle(this.opts.activeClass, fs)
|
|
175
|
+
this.beginSwitch()
|
|
176
|
+
requestAnimationFrame(() => this.opts.onGeometryPulse?.())
|
|
177
|
+
this.armQuiet()
|
|
178
|
+
this.opts.onFullscreenChange(fs)
|
|
179
|
+
}
|
|
180
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -172,12 +172,13 @@ export {
|
|
|
172
172
|
|
|
173
173
|
// Embed-surface auth — generic across chat AND ticket center (and any
|
|
174
174
|
// future embedded React component that needs to identify as the proxied
|
|
175
|
-
// customer).
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
//
|
|
175
|
+
// customer). The bearer is a PLATFORM API KEY (minted in the hub's
|
|
176
|
+
// /admin/api-keys; the old shared CHAT_PROXY_SECRET env is removed
|
|
177
|
+
// hub-side). Wire headers / storage key are unchanged (`X-Chat-*`,
|
|
178
|
+
// `chat.proxy-auth.v1`) — those are server / deployment contracts. The
|
|
179
|
+
// CLIENT-side rename frees non-chat surfaces from importing a
|
|
180
|
+
// chat-prefixed symbol; the old chat-prefixed aliases are DELETED —
|
|
181
|
+
// these Embed* exports are the only names.
|
|
181
182
|
export {
|
|
182
183
|
embedAuthedFetch,
|
|
183
184
|
setEmbedAuthAdapter,
|
|
@@ -334,6 +335,7 @@ export {
|
|
|
334
335
|
type ContentRefGridSize,
|
|
335
336
|
} from './content-ref-groups'
|
|
336
337
|
export { extractItems, extractItemId } from './extract-items'
|
|
338
|
+
export { FullscreenSwitchController, type FullscreenSwitchOptions } from './fullscreen-switch'
|
|
337
339
|
export { buildSuggestionUrl, type SuggestionUrlOptions } from './suggestion-url'
|
|
338
340
|
|
|
339
341
|
// Embedder-configurable content-URL composer for the existing
|