@seed-ship/mcp-ui-solid 6.19.1 → 6.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +663 -0
- package/README.md +911 -4
- package/dist/adapters/connector.cjs +15 -4
- package/dist/adapters/connector.cjs.map +1 -1
- package/dist/adapters/connector.d.ts +38 -0
- package/dist/adapters/connector.d.ts.map +1 -1
- package/dist/adapters/connector.js +15 -4
- package/dist/adapters/connector.js.map +1 -1
- package/dist/adapters/index.d.ts +4 -3
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/macro-run.cjs +25 -13
- package/dist/adapters/macro-run.cjs.map +1 -1
- package/dist/adapters/macro-run.d.ts +37 -2
- package/dist/adapters/macro-run.d.ts.map +1 -1
- package/dist/adapters/macro-run.js +25 -13
- package/dist/adapters/macro-run.js.map +1 -1
- package/dist/adapters.cjs +2 -0
- package/dist/adapters.cjs.map +1 -1
- package/dist/adapters.js +4 -2
- package/dist/components/ActionGroupRenderer.cjs +3 -1
- package/dist/components/ActionGroupRenderer.cjs.map +1 -1
- package/dist/components/ActionGroupRenderer.d.ts.map +1 -1
- package/dist/components/ActionGroupRenderer.js +3 -1
- package/dist/components/ActionGroupRenderer.js.map +1 -1
- package/dist/components/AgentCard.cjs +11 -8
- package/dist/components/AgentCard.cjs.map +1 -1
- package/dist/components/AgentCard.d.ts.map +1 -1
- package/dist/components/AgentCard.js +11 -8
- package/dist/components/AgentCard.js.map +1 -1
- package/dist/components/AgentHandoff.cjs +6 -1
- package/dist/components/AgentHandoff.cjs.map +1 -1
- package/dist/components/AgentHandoff.d.ts.map +1 -1
- package/dist/components/AgentHandoff.js +6 -1
- package/dist/components/AgentHandoff.js.map +1 -1
- package/dist/components/ArtifactRenderer.cjs +25 -6
- package/dist/components/ArtifactRenderer.cjs.map +1 -1
- package/dist/components/ArtifactRenderer.d.ts.map +1 -1
- package/dist/components/ArtifactRenderer.js +25 -6
- package/dist/components/ArtifactRenderer.js.map +1 -1
- package/dist/components/AutocompleteDropdown.cjs +30 -24
- package/dist/components/AutocompleteDropdown.cjs.map +1 -1
- package/dist/components/AutocompleteDropdown.d.ts.map +1 -1
- package/dist/components/AutocompleteDropdown.js +30 -24
- package/dist/components/AutocompleteDropdown.js.map +1 -1
- package/dist/components/AutocompleteFormField.cjs +3 -1
- package/dist/components/AutocompleteFormField.cjs.map +1 -1
- package/dist/components/AutocompleteFormField.d.ts.map +1 -1
- package/dist/components/AutocompleteFormField.js +4 -2
- package/dist/components/AutocompleteFormField.js.map +1 -1
- package/dist/components/BriefingDiff.cjs +45 -39
- package/dist/components/BriefingDiff.cjs.map +1 -1
- package/dist/components/BriefingDiff.d.ts.map +1 -1
- package/dist/components/BriefingDiff.js +45 -39
- package/dist/components/BriefingDiff.js.map +1 -1
- package/dist/components/CarouselRenderer.cjs +8 -2
- package/dist/components/CarouselRenderer.cjs.map +1 -1
- package/dist/components/CarouselRenderer.d.ts.map +1 -1
- package/dist/components/CarouselRenderer.js +8 -2
- package/dist/components/CarouselRenderer.js.map +1 -1
- package/dist/components/ChartJSRenderer.cjs +60 -36
- package/dist/components/ChartJSRenderer.cjs.map +1 -1
- package/dist/components/ChartJSRenderer.d.ts.map +1 -1
- package/dist/components/ChartJSRenderer.js +61 -37
- package/dist/components/ChartJSRenderer.js.map +1 -1
- package/dist/components/ChatPrompt.cjs +15 -9
- package/dist/components/ChatPrompt.cjs.map +1 -1
- package/dist/components/ChatPrompt.d.ts.map +1 -1
- package/dist/components/ChatPrompt.js +15 -9
- package/dist/components/ChatPrompt.js.map +1 -1
- package/dist/components/CodeBlockRenderer.cjs +34 -16
- package/dist/components/CodeBlockRenderer.cjs.map +1 -1
- package/dist/components/CodeBlockRenderer.d.ts.map +1 -1
- package/dist/components/CodeBlockRenderer.js +34 -16
- package/dist/components/CodeBlockRenderer.js.map +1 -1
- package/dist/components/DataPreviewSection.cjs +91 -44
- package/dist/components/DataPreviewSection.cjs.map +1 -1
- package/dist/components/DataPreviewSection.d.ts.map +1 -1
- package/dist/components/DataPreviewSection.js +92 -45
- package/dist/components/DataPreviewSection.js.map +1 -1
- package/dist/components/DegradedFallback.cjs +20 -16
- package/dist/components/DegradedFallback.cjs.map +1 -1
- package/dist/components/DegradedFallback.d.ts.map +1 -1
- package/dist/components/DegradedFallback.js +20 -16
- package/dist/components/DegradedFallback.js.map +1 -1
- package/dist/components/FooterRenderer.cjs +21 -17
- package/dist/components/FooterRenderer.cjs.map +1 -1
- package/dist/components/FooterRenderer.d.ts.map +1 -1
- package/dist/components/FooterRenderer.js +21 -17
- package/dist/components/FooterRenderer.js.map +1 -1
- package/dist/components/FormFieldRenderer.cjs +116 -93
- package/dist/components/FormFieldRenderer.cjs.map +1 -1
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +116 -93
- package/dist/components/FormFieldRenderer.js.map +1 -1
- package/dist/components/FormRenderer.cjs +55 -31
- package/dist/components/FormRenderer.cjs.map +1 -1
- package/dist/components/FormRenderer.d.ts.map +1 -1
- package/dist/components/FormRenderer.js +55 -31
- package/dist/components/FormRenderer.js.map +1 -1
- package/dist/components/GenerativeUIErrorBoundary.cjs +20 -15
- package/dist/components/GenerativeUIErrorBoundary.cjs.map +1 -1
- package/dist/components/GenerativeUIErrorBoundary.d.ts.map +1 -1
- package/dist/components/GenerativeUIErrorBoundary.js +20 -15
- package/dist/components/GenerativeUIErrorBoundary.js.map +1 -1
- package/dist/components/GraphRenderer.cjs +56 -33
- package/dist/components/GraphRenderer.cjs.map +1 -1
- package/dist/components/GraphRenderer.d.ts.map +1 -1
- package/dist/components/GraphRenderer.js +56 -33
- package/dist/components/GraphRenderer.js.map +1 -1
- package/dist/components/IframeFallbackLink.cjs +37 -0
- package/dist/components/IframeFallbackLink.cjs.map +1 -0
- package/dist/components/IframeFallbackLink.d.ts +23 -0
- package/dist/components/IframeFallbackLink.d.ts.map +1 -0
- package/dist/components/IframeFallbackLink.js +37 -0
- package/dist/components/IframeFallbackLink.js.map +1 -0
- package/dist/components/ImageGalleryRenderer.cjs +13 -4
- package/dist/components/ImageGalleryRenderer.cjs.map +1 -1
- package/dist/components/ImageGalleryRenderer.d.ts.map +1 -1
- package/dist/components/ImageGalleryRenderer.js +13 -4
- package/dist/components/ImageGalleryRenderer.js.map +1 -1
- package/dist/components/LightboxOverlay.cjs +16 -8
- package/dist/components/LightboxOverlay.cjs.map +1 -1
- package/dist/components/LightboxOverlay.d.ts.map +1 -1
- package/dist/components/LightboxOverlay.js +17 -9
- package/dist/components/LightboxOverlay.js.map +1 -1
- package/dist/components/MapRenderer.cjs +59 -29
- package/dist/components/MapRenderer.cjs.map +1 -1
- package/dist/components/MapRenderer.d.ts +10 -2
- package/dist/components/MapRenderer.d.ts.map +1 -1
- package/dist/components/MapRenderer.js +60 -30
- package/dist/components/MapRenderer.js.map +1 -1
- package/dist/components/ModalRenderer.cjs +4 -1
- package/dist/components/ModalRenderer.cjs.map +1 -1
- package/dist/components/ModalRenderer.d.ts.map +1 -1
- package/dist/components/ModalRenderer.js +5 -2
- package/dist/components/ModalRenderer.js.map +1 -1
- package/dist/components/ScratchpadPanel.cjs +578 -535
- package/dist/components/ScratchpadPanel.cjs.map +1 -1
- package/dist/components/ScratchpadPanel.d.ts.map +1 -1
- package/dist/components/ScratchpadPanel.js +578 -535
- package/dist/components/ScratchpadPanel.js.map +1 -1
- package/dist/components/StreamingUIRenderer.cjs +92 -28
- package/dist/components/StreamingUIRenderer.cjs.map +1 -1
- package/dist/components/StreamingUIRenderer.d.ts.map +1 -1
- package/dist/components/StreamingUIRenderer.js +92 -28
- package/dist/components/StreamingUIRenderer.js.map +1 -1
- package/dist/components/UIResourceRenderer.cjs +481 -365
- package/dist/components/UIResourceRenderer.cjs.map +1 -1
- package/dist/components/UIResourceRenderer.d.ts +21 -0
- package/dist/components/UIResourceRenderer.d.ts.map +1 -1
- package/dist/components/UIResourceRenderer.js +484 -368
- package/dist/components/UIResourceRenderer.js.map +1 -1
- package/dist/components/VerifiedText.cjs +39 -20
- package/dist/components/VerifiedText.cjs.map +1 -1
- package/dist/components/VerifiedText.d.ts +2 -1
- package/dist/components/VerifiedText.d.ts.map +1 -1
- package/dist/components/VerifiedText.js +39 -20
- package/dist/components/VerifiedText.js.map +1 -1
- package/dist/components/VideoRenderer.cjs +51 -20
- package/dist/components/VideoRenderer.cjs.map +1 -1
- package/dist/components/VideoRenderer.d.ts.map +1 -1
- package/dist/components/VideoRenderer.js +51 -20
- package/dist/components/VideoRenderer.js.map +1 -1
- package/dist/components/chart-data-table.cjs +38 -17
- package/dist/components/chart-data-table.cjs.map +1 -1
- package/dist/components/chart-data-table.d.ts +30 -1
- package/dist/components/chart-data-table.d.ts.map +1 -1
- package/dist/components/chart-data-table.js +38 -17
- package/dist/components/chart-data-table.js.map +1 -1
- package/dist/context/MCPActionContext.cjs +3 -1
- package/dist/context/MCPActionContext.cjs.map +1 -1
- package/dist/context/MCPActionContext.d.ts.map +1 -1
- package/dist/context/MCPActionContext.js +3 -1
- package/dist/context/MCPActionContext.js.map +1 -1
- package/dist/context/MCPUIConfigContext.cjs +29 -0
- package/dist/context/MCPUIConfigContext.cjs.map +1 -0
- package/dist/context/MCPUIConfigContext.d.ts +124 -0
- package/dist/context/MCPUIConfigContext.d.ts.map +1 -0
- package/dist/context/MCPUIConfigContext.js +29 -0
- package/dist/context/MCPUIConfigContext.js.map +1 -0
- package/dist/context/MCPUIStringsContext.cjs +287 -2
- package/dist/context/MCPUIStringsContext.cjs.map +1 -1
- package/dist/context/MCPUIStringsContext.d.ts +607 -3
- package/dist/context/MCPUIStringsContext.d.ts.map +1 -1
- package/dist/context/MCPUIStringsContext.js +287 -2
- package/dist/context/MCPUIStringsContext.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useStreamingUI.cjs +28 -10
- package/dist/hooks/useStreamingUI.cjs.map +1 -1
- package/dist/hooks/useStreamingUI.d.ts +37 -0
- package/dist/hooks/useStreamingUI.d.ts.map +1 -1
- package/dist/hooks/useStreamingUI.js +28 -10
- package/dist/hooks/useStreamingUI.js.map +1 -1
- package/dist/hooks.cjs +1 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +2 -1
- package/dist/index.cjs +29 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/validation.cjs +52 -26
- package/dist/services/validation.cjs.map +1 -1
- package/dist/services/validation.d.ts +67 -2
- package/dist/services/validation.d.ts.map +1 -1
- package/dist/services/validation.js +52 -26
- package/dist/services/validation.js.map +1 -1
- package/dist/utils/degraded-projections.cjs +37 -12
- package/dist/utils/degraded-projections.cjs.map +1 -1
- package/dist/utils/degraded-projections.d.ts +39 -3
- package/dist/utils/degraded-projections.d.ts.map +1 -1
- package/dist/utils/degraded-projections.js +37 -12
- package/dist/utils/degraded-projections.js.map +1 -1
- package/dist/utils/format-string.cjs +10 -0
- package/dist/utils/format-string.cjs.map +1 -0
- package/dist/utils/format-string.d.ts +26 -0
- package/dist/utils/format-string.d.ts.map +1 -0
- package/dist/utils/format-string.js +10 -0
- package/dist/utils/format-string.js.map +1 -0
- package/dist/utils/iframe-coep.cjs +30 -0
- package/dist/utils/iframe-coep.cjs.map +1 -0
- package/dist/utils/iframe-coep.d.ts +46 -0
- package/dist/utils/iframe-coep.d.ts.map +1 -0
- package/dist/utils/iframe-coep.js +30 -0
- package/dist/utils/iframe-coep.js.map +1 -0
- package/dist/validation.cjs +5 -0
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.cts +2 -1
- package/dist/validation.d.ts +2 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +6 -1
- package/package.json +1 -1
- package/src/adapters/connector.ts +58 -4
- package/src/adapters/index.ts +12 -2
- package/src/adapters/macro-run.ts +71 -11
- package/src/components/ActionGroupRenderer.tsx +3 -1
- package/src/components/AgentCard.tsx +27 -9
- package/src/components/AgentHandoff.tsx +4 -1
- package/src/components/ArtifactRenderer.tsx +17 -5
- package/src/components/AutocompleteDropdown.tsx +8 -6
- package/src/components/AutocompleteFormField.tsx +5 -1
- package/src/components/BriefingDiff.tsx +11 -3
- package/src/components/CarouselRenderer.tsx +4 -2
- package/src/components/ChartJSRenderer.tsx +18 -9
- package/src/components/ChatPrompt.tsx +13 -8
- package/src/components/CodeBlockRenderer.tsx +12 -10
- package/src/components/DataPreviewSection.tsx +92 -26
- package/src/components/DegradedFallback.tsx +4 -2
- package/src/components/FooterRenderer.tsx +3 -1
- package/src/components/FormFieldRenderer.tsx +34 -19
- package/src/components/FormRenderer.tsx +38 -10
- package/src/components/GenerativeUIErrorBoundary.tsx +8 -3
- package/src/components/GraphRenderer.tsx +31 -16
- package/src/components/IframeFallbackLink.tsx +57 -0
- package/src/components/ImageGalleryRenderer.tsx +8 -4
- package/src/components/LightboxOverlay.tsx +6 -4
- package/src/components/MapRenderer.tsx +57 -20
- package/src/components/ModalRenderer.tsx +3 -1
- package/src/components/ScratchpadPanel.tsx +95 -44
- package/src/components/StreamingUIRenderer.tsx +41 -11
- package/src/components/UIResourceRenderer.tsx +176 -67
- package/src/components/VerifiedText.tsx +19 -9
- package/src/components/VideoRenderer.tsx +26 -4
- package/src/components/chart-data-table.ts +68 -14
- package/src/context/MCPActionContext.tsx +4 -1
- package/src/context/MCPUIConfigContext.tsx +151 -0
- package/src/context/MCPUIStringsContext.tsx +1014 -1
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useStreamingUI.ts +64 -10
- package/src/index.ts +38 -0
- package/src/services/index.ts +1 -0
- package/src/services/validation.ts +131 -32
- package/src/solid-jsx-attrs.d.ts +24 -0
- package/src/utils/degraded-projections.ts +75 -12
- package/src/utils/format-string.ts +33 -0
- package/src/utils/iframe-coep.ts +74 -0
- package/src/validation.ts +9 -0
package/dist/index.js
CHANGED
|
@@ -29,10 +29,11 @@ import { isDebugEnabled, setDebugMode } from "./utils/logger.js";
|
|
|
29
29
|
import { PERF_PREFIX, markRenderEnd, markRenderStart } from "./utils/perf.js";
|
|
30
30
|
import { getUiResourceStableKey } from "./utils/stable-key.js";
|
|
31
31
|
import { setDuplicateMountReporter } from "./utils/duplicate-mount-registry.js";
|
|
32
|
-
import { DEFAULT_MCPUI_STRINGS, MCPUIStringsContext, MCPUIStringsProvider, useMCPUIStrings } from "./context/MCPUIStringsContext.js";
|
|
32
|
+
import { DEFAULT_MCPUI_STRINGS, MCPUIStringsContext, MCPUIStringsProvider, resolveMCPUILocale, useMCPUIStrings } from "./context/MCPUIStringsContext.js";
|
|
33
|
+
import { DEFAULT_MCPUI_CONFIG, MCPUIConfigContext, MCPUIConfigProvider, useMCPUIConfig } from "./context/MCPUIConfigContext.js";
|
|
33
34
|
import { MCPUITelemetryContext, MCPUITelemetryProvider, useTelemetry } from "./context/MCPUITelemetryContext.js";
|
|
34
35
|
import { createTelemetryDispatcher } from "./services/telemetry.js";
|
|
35
|
-
import { useStreamingUI } from "./hooks/useStreamingUI.js";
|
|
36
|
+
import { DEFAULT_STREAMING_UI_MESSAGES, useStreamingUI } from "./hooks/useStreamingUI.js";
|
|
36
37
|
import { useAction, useToolAction } from "./hooks/useAction.js";
|
|
37
38
|
import { evaluateCondition, useConditionalField } from "./hooks/useConditionalField.js";
|
|
38
39
|
import { useConfirmModal, useModal } from "./hooks/useModal.js";
|
|
@@ -42,15 +43,18 @@ import { useResize } from "./hooks/useResize.js";
|
|
|
42
43
|
import { useAutocomplete } from "./hooks/useAutocomplete.js";
|
|
43
44
|
import { useDataValidator } from "./hooks/useDataValidator.js";
|
|
44
45
|
import { AutocompleteProvider, useAutocompleteContext, useAutocompleteContextSafe } from "./context/AutocompleteContext.js";
|
|
46
|
+
import { DEFAULT_IFRAME_DOMAINS, DEFAULT_RESOURCE_LIMITS, DEFAULT_VALIDATION_MESSAGES, TRUSTED_IFRAME_DOMAINS, getIframeSandbox, isTrustedIframeDomain, validateComponent, validateFieldValue, validateFormData, validateIframeDomain, validateLayout } from "./services/validation.js";
|
|
47
|
+
import { DEGRADED_PROJECTION_LABELS, chartToDegradedTable, graphToDegradedTable, mapToDegradedTable } from "./utils/degraded-projections.js";
|
|
48
|
+
import { CHART_DATA_TABLE_LABELS, chartToDataTable } from "./components/chart-data-table.js";
|
|
45
49
|
import { clarificationToPromptConfig, createChatBus, createCommandHandler, createEventEmitter, elicitationToPromptConfig, mergeScratchpadSections } from "./services/chat-bus.js";
|
|
46
50
|
import { PromptReplacedError, createChatPromptController } from "./services/chat-prompt-controller.js";
|
|
47
51
|
import { createMockChatBus } from "./testing/index.js";
|
|
48
52
|
import { ComponentRegistry } from "./services/component-registry.js";
|
|
49
|
-
import { DEFAULT_IFRAME_DOMAINS, DEFAULT_RESOURCE_LIMITS, TRUSTED_IFRAME_DOMAINS, getIframeSandbox, validateComponent, validateIframeDomain, validateLayout } from "./services/validation.js";
|
|
50
53
|
import { MCPActionContext, MCPActionProvider, useMCPAction, useMCPActionSafe } from "./context/MCPActionContext.js";
|
|
51
54
|
import { createGroqPlugin } from "./plugins/groq.js";
|
|
52
55
|
import { createRestPlugin } from "./plugins/rest.js";
|
|
53
56
|
import { createSupabasePlugin } from "./plugins/supabase.js";
|
|
57
|
+
import { formatMCPUIString } from "./utils/format-string.js";
|
|
54
58
|
import { validateAgainstSource } from "./services/data-validator.js";
|
|
55
59
|
export {
|
|
56
60
|
AgentCard,
|
|
@@ -60,14 +64,19 @@ export {
|
|
|
60
64
|
AutocompleteFormField,
|
|
61
65
|
AutocompleteProvider,
|
|
62
66
|
BriefingDiff,
|
|
67
|
+
CHART_DATA_TABLE_LABELS,
|
|
63
68
|
ChatBusProvider,
|
|
64
69
|
ChatPrompt,
|
|
65
70
|
ComponentRegistry,
|
|
66
71
|
ComponentToolbar,
|
|
67
72
|
DEFAULT_IFRAME_DOMAINS,
|
|
73
|
+
DEFAULT_MCPUI_CONFIG,
|
|
68
74
|
DEFAULT_MCPUI_STRINGS,
|
|
69
75
|
DEFAULT_PRESENTATION_FEEDBACK_LABELS,
|
|
70
76
|
DEFAULT_RESOURCE_LIMITS,
|
|
77
|
+
DEFAULT_STREAMING_UI_MESSAGES,
|
|
78
|
+
DEFAULT_VALIDATION_MESSAGES,
|
|
79
|
+
DEGRADED_PROJECTION_LABELS,
|
|
71
80
|
DataPreviewSection,
|
|
72
81
|
DraggableGridItem,
|
|
73
82
|
EditableUIResourceRenderer,
|
|
@@ -80,6 +89,8 @@ export {
|
|
|
80
89
|
GraphRenderer,
|
|
81
90
|
MCPActionContext,
|
|
82
91
|
MCPActionProvider,
|
|
92
|
+
MCPUIConfigContext,
|
|
93
|
+
MCPUIConfigProvider,
|
|
83
94
|
MCPUIStringsContext,
|
|
84
95
|
MCPUIStringsProvider,
|
|
85
96
|
MCPUITelemetryContext,
|
|
@@ -99,6 +110,8 @@ export {
|
|
|
99
110
|
TRUSTED_IFRAME_DOMAINS,
|
|
100
111
|
UIResourceRenderer,
|
|
101
112
|
VerifiedText,
|
|
113
|
+
chartToDataTable,
|
|
114
|
+
chartToDegradedTable,
|
|
102
115
|
clarificationToPromptConfig,
|
|
103
116
|
createChatBus,
|
|
104
117
|
createChatPromptController,
|
|
@@ -114,16 +127,21 @@ export {
|
|
|
114
127
|
dispatchScratchpad,
|
|
115
128
|
elicitationToPromptConfig,
|
|
116
129
|
evaluateCondition,
|
|
130
|
+
formatMCPUIString,
|
|
117
131
|
getIframeSandbox,
|
|
118
132
|
getUiResourceStableKey,
|
|
133
|
+
graphToDegradedTable,
|
|
119
134
|
graphToJSON,
|
|
120
135
|
graphToMermaid,
|
|
121
136
|
isDebugEnabled,
|
|
122
137
|
isG6Available,
|
|
138
|
+
isTrustedIframeDomain,
|
|
139
|
+
mapToDegradedTable,
|
|
123
140
|
markRenderEnd,
|
|
124
141
|
markRenderStart,
|
|
125
142
|
mergeScratchpadSections,
|
|
126
143
|
renderCellValue,
|
|
144
|
+
resolveMCPUILocale,
|
|
127
145
|
setDebugMode,
|
|
128
146
|
setDuplicateMountReporter,
|
|
129
147
|
setServerCapabilities,
|
|
@@ -140,6 +158,7 @@ export {
|
|
|
140
158
|
useFormPersistence,
|
|
141
159
|
useMCPAction,
|
|
142
160
|
useMCPActionSafe,
|
|
161
|
+
useMCPUIConfig,
|
|
143
162
|
useMCPUIStrings,
|
|
144
163
|
useModal,
|
|
145
164
|
useResize,
|
|
@@ -150,6 +169,8 @@ export {
|
|
|
150
169
|
useToolAction,
|
|
151
170
|
validateAgainstSource,
|
|
152
171
|
validateComponent,
|
|
172
|
+
validateFieldValue,
|
|
173
|
+
validateFormData,
|
|
153
174
|
validateIframeDomain,
|
|
154
175
|
validateLayout
|
|
155
176
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Business logic for component validation and registry management
|
|
5
5
|
*/
|
|
6
|
-
export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, } from './validation';
|
|
6
|
+
export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, } from './validation';
|
|
7
7
|
export { ComponentRegistry } from './component-registry';
|
|
8
8
|
export { createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections } from './chat-bus';
|
|
9
9
|
export { validateAgainstSource } from './data-validator';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAE7G,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAE7G,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const mcpUiSpec = require("@seed-ship/mcp-ui-spec");
|
|
4
|
+
const formatString = require("../utils/format-string.cjs");
|
|
4
5
|
const KNOWN_COMPONENT_TYPES = new Set(mcpUiSpec.ComponentTypeSchema.options);
|
|
5
6
|
const SPEC_VALIDATORS = {
|
|
6
7
|
metric: { schema: mcpUiSpec.MetricComponentParamsSchema, legacyCode: "INVALID_METRIC" },
|
|
@@ -456,21 +457,21 @@ function validateIframeDomain(url, options) {
|
|
|
456
457
|
};
|
|
457
458
|
}
|
|
458
459
|
}
|
|
459
|
-
function
|
|
460
|
-
const baseSandbox = "allow-scripts allow-popups";
|
|
460
|
+
function isTrustedIframeDomain(url, options) {
|
|
461
461
|
try {
|
|
462
462
|
const domain = new URL(url).hostname;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
trustedList = [...TRUSTED_IFRAME_DOMAINS, ...options.customTrustedDomains];
|
|
466
|
-
}
|
|
467
|
-
const isTrusted = trustedList.some(
|
|
463
|
+
const trustedList = (options == null ? void 0 : options.customTrustedDomains) ? [...TRUSTED_IFRAME_DOMAINS, ...options.customTrustedDomains] : TRUSTED_IFRAME_DOMAINS;
|
|
464
|
+
return trustedList.some(
|
|
468
465
|
(trusted) => domain === trusted || domain.endsWith(`.${trusted}`)
|
|
469
466
|
);
|
|
470
|
-
if (isTrusted) {
|
|
471
|
-
return `${baseSandbox} allow-same-origin allow-forms`;
|
|
472
|
-
}
|
|
473
467
|
} catch {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
function getIframeSandbox(url, options) {
|
|
472
|
+
const baseSandbox = "allow-scripts allow-popups";
|
|
473
|
+
if (isTrustedIframeDomain(url, options)) {
|
|
474
|
+
return `${baseSandbox} allow-same-origin allow-forms`;
|
|
474
475
|
}
|
|
475
476
|
return baseSandbox;
|
|
476
477
|
}
|
|
@@ -603,13 +604,30 @@ function validateLayout(layout, options) {
|
|
|
603
604
|
errors: errors.length > 0 ? errors : void 0
|
|
604
605
|
};
|
|
605
606
|
}
|
|
606
|
-
|
|
607
|
+
const DEFAULT_VALIDATION_MESSAGES = {
|
|
608
|
+
required: "{field} is required",
|
|
609
|
+
mustBeChecked: "{field} must be checked",
|
|
610
|
+
minLength: "Minimum {min} characters required",
|
|
611
|
+
maxLength: "Maximum {max} characters allowed",
|
|
612
|
+
invalidPattern: "Invalid format",
|
|
613
|
+
invalidEmail: "Invalid email address",
|
|
614
|
+
invalidNumber: "Must be a valid number",
|
|
615
|
+
minValue: "Minimum value is {min}",
|
|
616
|
+
maxValue: "Maximum value is {max}",
|
|
617
|
+
minDate: "Date must be after {min}",
|
|
618
|
+
maxDate: "Date must be before {max}",
|
|
619
|
+
invalidOption: "Please select a valid option",
|
|
620
|
+
invalidFormat: "Invalid format (expected: {format})"
|
|
621
|
+
};
|
|
622
|
+
function validateFieldValue(value, field, messages) {
|
|
623
|
+
const m = { ...DEFAULT_VALIDATION_MESSAGES, ...messages };
|
|
624
|
+
const fieldName = field.label || field.name;
|
|
607
625
|
if (field.required) {
|
|
608
626
|
if (value === void 0 || value === null || value === "") {
|
|
609
|
-
return { valid: false, error:
|
|
627
|
+
return { valid: false, error: formatString.formatMCPUIString(m.required, { field: fieldName }) };
|
|
610
628
|
}
|
|
611
629
|
if (field.type === "checkbox" && value !== true) {
|
|
612
|
-
return { valid: false, error:
|
|
630
|
+
return { valid: false, error: formatString.formatMCPUIString(m.mustBeChecked, { field: fieldName }) };
|
|
613
631
|
}
|
|
614
632
|
}
|
|
615
633
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -620,39 +638,45 @@ function validateFieldValue(value, field) {
|
|
|
620
638
|
case "textarea":
|
|
621
639
|
case "password":
|
|
622
640
|
if (field.minLength && String(value).length < field.minLength) {
|
|
623
|
-
return {
|
|
641
|
+
return {
|
|
642
|
+
valid: false,
|
|
643
|
+
error: formatString.formatMCPUIString(m.minLength, { min: field.minLength })
|
|
644
|
+
};
|
|
624
645
|
}
|
|
625
646
|
if (field.maxLength && String(value).length > field.maxLength) {
|
|
626
|
-
return {
|
|
647
|
+
return {
|
|
648
|
+
valid: false,
|
|
649
|
+
error: formatString.formatMCPUIString(m.maxLength, { max: field.maxLength })
|
|
650
|
+
};
|
|
627
651
|
}
|
|
628
652
|
if (field.pattern && !new RegExp(field.pattern).test(String(value))) {
|
|
629
|
-
return { valid: false, error:
|
|
653
|
+
return { valid: false, error: m.invalidPattern };
|
|
630
654
|
}
|
|
631
655
|
break;
|
|
632
656
|
case "email":
|
|
633
657
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(value))) {
|
|
634
|
-
return { valid: false, error:
|
|
658
|
+
return { valid: false, error: m.invalidEmail };
|
|
635
659
|
}
|
|
636
660
|
break;
|
|
637
661
|
case "number": {
|
|
638
662
|
const numValue = Number(value);
|
|
639
663
|
if (isNaN(numValue)) {
|
|
640
|
-
return { valid: false, error:
|
|
664
|
+
return { valid: false, error: m.invalidNumber };
|
|
641
665
|
}
|
|
642
666
|
if (field.min !== void 0 && numValue < field.min) {
|
|
643
|
-
return { valid: false, error:
|
|
667
|
+
return { valid: false, error: formatString.formatMCPUIString(m.minValue, { min: field.min }) };
|
|
644
668
|
}
|
|
645
669
|
if (field.max !== void 0 && numValue > field.max) {
|
|
646
|
-
return { valid: false, error:
|
|
670
|
+
return { valid: false, error: formatString.formatMCPUIString(m.maxValue, { max: field.max }) };
|
|
647
671
|
}
|
|
648
672
|
break;
|
|
649
673
|
}
|
|
650
674
|
case "date":
|
|
651
675
|
if (field.minDate && value < field.minDate) {
|
|
652
|
-
return { valid: false, error:
|
|
676
|
+
return { valid: false, error: formatString.formatMCPUIString(m.minDate, { min: field.minDate }) };
|
|
653
677
|
}
|
|
654
678
|
if (field.maxDate && value > field.maxDate) {
|
|
655
|
-
return { valid: false, error:
|
|
679
|
+
return { valid: false, error: formatString.formatMCPUIString(m.maxDate, { max: field.maxDate }) };
|
|
656
680
|
}
|
|
657
681
|
break;
|
|
658
682
|
case "select":
|
|
@@ -660,7 +684,7 @@ function validateFieldValue(value, field) {
|
|
|
660
684
|
if (field.options && field.options.length > 0) {
|
|
661
685
|
const validValues = field.options.map((opt) => opt.value);
|
|
662
686
|
if (!validValues.includes(String(value))) {
|
|
663
|
-
return { valid: false, error:
|
|
687
|
+
return { valid: false, error: m.invalidOption };
|
|
664
688
|
}
|
|
665
689
|
}
|
|
666
690
|
break;
|
|
@@ -671,17 +695,17 @@ function validateFieldValue(value, field) {
|
|
|
671
695
|
if (!new RegExp(field.valueFormat).test(v)) {
|
|
672
696
|
return {
|
|
673
697
|
valid: false,
|
|
674
|
-
error: field.valueFormatHint ||
|
|
698
|
+
error: field.valueFormatHint || formatString.formatMCPUIString(m.invalidFormat, { format: field.valueFormat })
|
|
675
699
|
};
|
|
676
700
|
}
|
|
677
701
|
}
|
|
678
702
|
}
|
|
679
703
|
return { valid: true };
|
|
680
704
|
}
|
|
681
|
-
function validateFormData(data, fields) {
|
|
705
|
+
function validateFormData(data, fields, messages) {
|
|
682
706
|
const errors = {};
|
|
683
707
|
for (const field of fields) {
|
|
684
|
-
const result = validateFieldValue(data[field.name], field);
|
|
708
|
+
const result = validateFieldValue(data[field.name], field, messages);
|
|
685
709
|
if (!result.valid && result.error) {
|
|
686
710
|
errors[field.name] = result.error;
|
|
687
711
|
}
|
|
@@ -693,8 +717,10 @@ function validateFormData(data, fields) {
|
|
|
693
717
|
}
|
|
694
718
|
exports.DEFAULT_IFRAME_DOMAINS = DEFAULT_IFRAME_DOMAINS;
|
|
695
719
|
exports.DEFAULT_RESOURCE_LIMITS = DEFAULT_RESOURCE_LIMITS;
|
|
720
|
+
exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES;
|
|
696
721
|
exports.TRUSTED_IFRAME_DOMAINS = TRUSTED_IFRAME_DOMAINS;
|
|
697
722
|
exports.getIframeSandbox = getIframeSandbox;
|
|
723
|
+
exports.isTrustedIframeDomain = isTrustedIframeDomain;
|
|
698
724
|
exports.sanitizeString = sanitizeString;
|
|
699
725
|
exports.validateChartComponent = validateChartComponent;
|
|
700
726
|
exports.validateComponent = validateComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.cjs","sources":["../../src/services/validation.ts"],"sourcesContent":["/**\n * Component Validation Service\n * Phase 0: Resource Limits & Schema Validation\n *\n * Validates LLM-generated components against:\n * - JSON schema\n * - Resource limits (data points, payload size, grid bounds)\n * - Security constraints (domain whitelist, XSS prevention)\n */\n\nimport type { ZodIssue, ZodSchema } from 'zod';\nimport {\n MetricComponentParamsSchema,\n TextComponentParamsSchema,\n IframeComponentParamsSchema,\n ImageComponentParamsSchema,\n LinkComponentParamsSchema,\n CarouselComponentParamsSchema,\n ArtifactComponentParamsSchema,\n ActionParamsSchema,\n VideoComponentParamsSchema,\n ImageGalleryParamsSchema,\n ActionGroupParamsSchema,\n CodeComponentParamsSchema,\n // v5.6.0 — added after spec@5.0.2 relaxations (deposium audit §M)\n MapComponentParamsSchema,\n FormComponentParamsSchema,\n // v6.0.0 — graph primitive (peer @antv/g6 ^5)\n GraphComponentParamsSchema,\n // Single source of truth for the component-type enum (kills spec↔solid drift).\n ComponentTypeSchema,\n} from '@seed-ship/mcp-ui-spec';\nimport type {\n UIComponent,\n UILayout,\n ValidationResult,\n ResourceLimits,\n ChartComponentParams,\n TableComponentParams,\n FormFieldParams,\n IframePolicy,\n ValidationOptions,\n ComponentType,\n} from '../types';\n\n/**\n * All known ComponentType values — used to distinguish known-but-unvalidated\n * types (pass through) from truly unknown strings (reject).\n *\n * Derived directly from the spec's `ComponentTypeSchema` (the single source of\n * truth) rather than hand-maintained, so a new enum member in the spec can\n * never silently drift out of solid's known-types set again. This is what\n * restored `composite`: it is in the spec enum but had been dropped from the\n * former hand-written list, contradicting the pass-through docstrings below.\n */\nconst KNOWN_COMPONENT_TYPES: Set<string> = new Set<string>(ComponentTypeSchema.options);\n\n/**\n * Spec-driven validation dispatch table (B.1 — v5.5.0, expanded in v5.6.0).\n *\n * For each ComponentType where we delegate shape validation to a Zod schema\n * from `@seed-ship/mcp-ui-spec`, this table maps:\n * - the schema to safeParse against\n * - the legacy error code to emit when shape parsing fails (preserves the\n * pre-v5.5.0 `errors[].code` API contract — see MCP-UI-AUDIT-2026-04-26.md\n * §I.3.a + §J.1)\n *\n * **v5.6.0** : `map` and `form` joined the dispatch after spec@5.0.2 relaxed\n * their schemas (LatLngPoint union for map.center, regex relax for\n * field.name) per deposium audit §L answers. As of v6.x this table\n * spec-validates 15 of the 21 component types; the remainder use imperative\n * validators (`chart`/`table`) or are pass-through (`grid`/`footer`/`composite`/`modal`).\n *\n * Types deliberately omitted (kept on the imperative path):\n * - `chart`, `table` — have rich imperative validators with their own\n * codes (MISSING_DATA, DATA_LENGTH_MISMATCH, RESOURCE_LIMIT_EXCEEDED, …)\n * - `modal` — all params are optional; nothing to enforce.\n * - `grid`, `footer`, `composite` — pass-through, validated elsewhere.\n */\nconst SPEC_VALIDATORS: Partial<Record<ComponentType, { schema: ZodSchema; legacyCode: string }>> = {\n metric: { schema: MetricComponentParamsSchema, legacyCode: 'INVALID_METRIC' },\n text: { schema: TextComponentParamsSchema, legacyCode: 'INVALID_TEXT' },\n iframe: { schema: IframeComponentParamsSchema, legacyCode: 'INVALID_IFRAME' },\n image: { schema: ImageComponentParamsSchema, legacyCode: 'INVALID_IMAGE' },\n link: { schema: LinkComponentParamsSchema, legacyCode: 'INVALID_LINK' },\n action: { schema: ActionParamsSchema, legacyCode: 'INVALID_ACTION' },\n video: { schema: VideoComponentParamsSchema, legacyCode: 'INVALID_VIDEO' },\n carousel: { schema: CarouselComponentParamsSchema, legacyCode: 'EMPTY_CAROUSEL' },\n 'image-gallery': { schema: ImageGalleryParamsSchema, legacyCode: 'EMPTY_GALLERY' },\n 'action-group': { schema: ActionGroupParamsSchema, legacyCode: 'EMPTY_ACTION_GROUP' },\n code: { schema: CodeComponentParamsSchema, legacyCode: 'INVALID_CODE' },\n artifact: { schema: ArtifactComponentParamsSchema, legacyCode: 'INVALID_ARTIFACT' },\n // v5.6.0 additions\n form: { schema: FormComponentParamsSchema, legacyCode: 'EMPTY_FORM' },\n map: { schema: MapComponentParamsSchema, legacyCode: 'INVALID_MAP' },\n // v6.0.0 — graph primitive (no chained post-check : Zod's\n // `nodes.min(1)` covers the only structural invariant ; edge\n // source/target ids reference nodes by convention, not enforced here\n // because LLM payloads sometimes ship edges to nodes added later.\n // Unresolved refs are gracefully ignored by G6 v5.)\n graph: { schema: GraphComponentParamsSchema, legacyCode: 'INVALID_GRAPH' },\n};\n\n/**\n * Map a Zod issue list to the legacy `ValidationError[]` shape.\n *\n * Preserves the pre-v5.5.0 contract: `path` always begins with `params`,\n * `code` is the per-type legacy code (so consumers that filtered by\n * `errors[].code === 'EMPTY_CAROUSEL'` keep working), `message` is Zod's\n * native human-readable message.\n */\nfunction mapZodIssuesToErrors(\n issues: readonly ZodIssue[],\n legacyCode: string\n): NonNullable<ValidationResult['errors']> {\n return issues.map((issue) => ({\n path: issue.path.length > 0 ? `params.${issue.path.join('.')}` : 'params',\n message: issue.message,\n code: legacyCode,\n }));\n}\n\n/**\n * Default resource limits (configurable via env)\n */\nexport const DEFAULT_RESOURCE_LIMITS: ResourceLimits = {\n maxDataPoints: 1000,\n maxTableRows: 100,\n // v6.8.0 — raised 50KB → 512KB. The single payload-size guard is shared by\n // every component type ; 50KB rejected otherwise-valid `map` components\n // carrying a realistic `params.geojson` FeatureCollection (a dense\n // multi-feature map — e.g. a département-wide choropleth — runs 300-500KB\n // even after reasonable geometry simplification). 512KB leaves real\n // headroom for that while still rejecting runaway payloads ; genuinely\n // large datasets belong in vector tiles (PMTiles), not inline GeoJSON.\n // The guard itself (`validatePayloadSize`) is unchanged — only the\n // default ceiling moved.\n maxPayloadSize: 512 * 1024, // 512KB\n renderTimeout: 5000, // 5 seconds\n};\n\n/**\n * Default allowed iframe domains (whitelist)\n * Must match CSP frame-src directive\n * Updated Sprint 7: Added code, design, docs, and map providers\n *\n * This list is exported for transparency and can be extended via ValidationOptions\n */\nexport const DEFAULT_IFRAME_DOMAINS = [\n // Charts\n 'quickchart.io',\n 'www.quickchart.io',\n\n // Deposium\n 'deposium.com',\n 'deposium.vip',\n 'deposium.ai',\n\n // Development\n 'localhost',\n\n // Video providers (Sprint 5)\n 'youtube.com',\n 'www.youtube.com',\n 'youtube-nocookie.com',\n 'www.youtube-nocookie.com',\n 'youtu.be',\n 'vimeo.com',\n 'player.vimeo.com',\n\n // Code playgrounds (Sprint 7)\n 'codepen.io',\n 'codesandbox.io',\n 'stackblitz.com',\n 'jsfiddle.net',\n\n // Design tools (Sprint 7)\n 'figma.com',\n 'www.figma.com',\n 'miro.com',\n\n // Google services (Sprint 7)\n 'docs.google.com',\n 'drive.google.com',\n 'sheets.google.com',\n 'slides.google.com',\n 'maps.google.com',\n 'www.google.com',\n 'datastudio.google.com',\n 'lookerstudio.google.com',\n\n // Productivity (Sprint 7)\n 'airtable.com',\n 'notion.so',\n 'www.notion.so',\n\n // Maps (Sprint 7)\n 'openstreetmap.org',\n 'www.openstreetmap.org',\n\n // Analytics/Dashboards (Sprint 7)\n 'public.tableau.com',\n 'app.powerbi.com',\n 'observablehq.com',\n\n // Diagrams & Whiteboards (v2.0.0)\n 'mermaid.live',\n 'excalidraw.com',\n 'lucidchart.com',\n 'lucid.app',\n\n // Video - Business (v2.0.0)\n 'loom.com',\n 'www.loom.com',\n 'cloudflarestream.com',\n 'streamable.com',\n\n // Code repositories (v2.0.0)\n 'github.com',\n 'gist.github.com',\n 'gitlab.com',\n 'replit.com',\n 'glitch.com',\n\n // Business tools (v2.0.0)\n 'calendly.com',\n 'typeform.com',\n 'cal.com',\n\n // Design (v2.0.0)\n 'canva.com',\n\n // Deploy previews (v2.0.0)\n 'vercel.app',\n 'netlify.app',\n\n // E-commerce (v2.0.0)\n 'amazon.com',\n 'amazon.fr',\n 'amazon.de',\n 'amazon.co.uk',\n 'amazon.es',\n 'amazon.it',\n 'amazon.ca',\n 'amazon.co.jp',\n 'images-amazon.com',\n 'media-amazon.com',\n 'ws-na.amazon-adsystem.com',\n\n // MCP Connectors — embed-capable services (v2.2.7)\n 'gamma.app',\n 'www.gamma.app',\n 'app.hubspot.com',\n 'share.hubspot.com',\n 'www.data.gouv.fr',\n 'data.gouv.fr',\n 'clinicaltrials.gov',\n 'www.clinicaltrials.gov',\n 'linear.app',\n 'www.linear.app',\n\n // Payment platforms (v2.2.12)\n 'polar.sh',\n 'www.polar.sh',\n 'checkout.stripe.com',\n 'js.stripe.com',\n 'billing.stripe.com',\n 'buy.stripe.com',\n 'connect.stripe.com',\n 'invoice.stripe.com',\n];\n\n/**\n * Trusted iframe domains that require allow-same-origin to function.\n * These domains need access to their own cookies/storage for auth.\n * All other whitelisted domains get a restrictive sandbox without allow-same-origin.\n */\nexport const TRUSTED_IFRAME_DOMAINS = [\n // Deposium (own domains)\n 'deposium.com',\n 'deposium.vip',\n 'deposium.ai',\n 'localhost',\n\n // Google services (need auth cookies)\n 'docs.google.com',\n 'drive.google.com',\n 'sheets.google.com',\n 'slides.google.com',\n 'maps.google.com',\n 'datastudio.google.com',\n 'lookerstudio.google.com',\n\n // Productivity (need auth)\n 'notion.so',\n 'www.notion.so',\n 'airtable.com',\n 'figma.com',\n 'www.figma.com',\n 'miro.com',\n\n // Payment (need auth + cookies for checkout)\n 'polar.sh',\n 'www.polar.sh',\n 'checkout.stripe.com',\n 'js.stripe.com',\n 'billing.stripe.com',\n 'buy.stripe.com',\n 'connect.stripe.com',\n 'invoice.stripe.com',\n\n // Business tools (need auth)\n 'app.hubspot.com',\n 'share.hubspot.com',\n 'app.powerbi.com',\n 'linear.app',\n 'www.linear.app',\n 'calendly.com',\n 'typeform.com',\n 'cal.com',\n 'canva.com',\n];\n\n/**\n * Validate grid position bounds (1-12 columns)\n */\nexport function validateGridPosition(position: UIComponent['position']): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n // ✅ PHASE 3 FIX: Defensive check for undefined position\n if (!position) {\n return {\n valid: false,\n errors: [\n {\n path: 'position',\n message: 'Position is required',\n code: 'MISSING_POSITION',\n },\n ],\n };\n }\n\n if (position.colStart < 1 || position.colStart > 12) {\n errors.push({\n path: 'position.colStart',\n message: 'Column start must be between 1 and 12',\n code: 'INVALID_GRID_COL_START',\n });\n }\n\n if (position.colSpan < 1 || position.colSpan > 12) {\n errors.push({\n path: 'position.colSpan',\n message: 'Column span must be between 1 and 12',\n code: 'INVALID_GRID_COL_SPAN',\n });\n }\n\n if (position.colStart + position.colSpan - 1 > 12) {\n errors.push({\n path: 'position',\n message: 'Column start + span exceeds grid width (12)',\n code: 'GRID_OVERFLOW',\n });\n }\n\n if (position.rowStart !== undefined && position.rowStart < 1) {\n errors.push({\n path: 'position.rowStart',\n message: 'Row start must be >= 1',\n code: 'INVALID_GRID_ROW_START',\n });\n }\n\n if (position.rowSpan !== undefined && position.rowSpan < 1) {\n errors.push({\n path: 'position.rowSpan',\n message: 'Row span must be >= 1',\n code: 'INVALID_GRID_ROW_SPAN',\n });\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate chart component against resource limits\n */\nexport function validateChartComponent(\n params: ChartComponentParams,\n limits: ResourceLimits = DEFAULT_RESOURCE_LIMITS\n): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n // Guard: params.data must exist with labels + datasets\n if (!params?.data) {\n return {\n valid: false,\n errors: [{ path: 'params.data', message: 'Missing chart data object', code: 'MISSING_DATA' }],\n };\n }\n if (!Array.isArray(params.data.datasets)) {\n return {\n valid: false,\n errors: [\n {\n path: 'params.data.datasets',\n message: 'Missing or invalid datasets array',\n code: 'MISSING_DATASETS',\n },\n ],\n };\n }\n // Detect point-based charts (scatter/bubble) or object data (time-series line)\n const chartType = params.type || 'bar';\n const usesPoints = (data: unknown[]) => data.some(value =>\n typeof value === 'object' && value !== null && 'x' in value\n );\n const hasObjectData = params.data.datasets.some(dataset =>\n Array.isArray(dataset.data) && usesPoints(dataset.data)\n );\n const isPointChart = chartType === 'scatter' || chartType === 'bubble' || hasObjectData;\n\n // Labels required only for categorical charts (not scatter/bubble/time-series)\n if (!isPointChart) {\n if (!Array.isArray(params.data.labels)) {\n return {\n valid: false,\n errors: [\n {\n path: 'params.data.labels',\n message: 'Missing or invalid labels array',\n code: 'MISSING_LABELS',\n },\n ],\n };\n }\n }\n\n // Validate data points count\n const totalDataPoints = params.data.datasets.reduce(\n (sum, dataset) => sum + (Array.isArray(dataset.data) ? dataset.data.length : 0),\n 0\n );\n\n if (totalDataPoints > limits.maxDataPoints) {\n errors.push({\n path: 'params.data',\n message: `Chart exceeds max data points: ${totalDataPoints} > ${limits.maxDataPoints}`,\n code: 'RESOURCE_LIMIT_EXCEEDED',\n });\n }\n\n // Length mismatch check — only for categorical charts, skip empty datasets\n if (chartType !== 'scatter' && chartType !== 'bubble' && Array.isArray(params.data.labels)) {\n const expectedLength = params.data.labels.length;\n for (const [index, dataset] of params.data.datasets.entries()) {\n if (\n Array.isArray(dataset.data) &&\n !usesPoints(dataset.data) &&\n dataset.data.length > 0 &&\n dataset.data.length !== expectedLength\n ) {\n errors.push({\n path: `params.data.datasets[${index}]`,\n message: `Dataset length mismatch: expected ${expectedLength}, got ${dataset.data.length}`,\n code: 'DATA_LENGTH_MISMATCH',\n });\n }\n }\n }\n\n // Data type validation — numbers for categorical, {x,y} objects for point charts\n for (const [index, dataset] of params.data.datasets.entries()) {\n if (!Array.isArray(dataset.data)) continue;\n const datasetIsPointChart = chartType === 'scatter' || chartType === 'bubble' || usesPoints(dataset.data);\n for (const [dataIndex, value] of dataset.data.entries()) {\n if (datasetIsPointChart) {\n const vObj = value as any;\n if (\n typeof value !== 'object' ||\n value === null ||\n vObj.x == null ||\n typeof vObj.y !== 'number' ||\n (vObj.r !== undefined && (typeof vObj.r !== 'number' || !Number.isFinite(vObj.r) || vObj.r < 0))\n ) {\n errors.push({\n path: `params.data.datasets[${index}].data[${dataIndex}]`,\n message: `Invalid point data: expected {x, y} object`,\n code: 'INVALID_POINT_DATA',\n });\n }\n } else {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n errors.push({\n path: `params.data.datasets[${index}].data[${dataIndex}]`,\n message: `Invalid data value: ${value} (must be finite number)`,\n code: 'INVALID_DATA_TYPE',\n });\n }\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate table component against resource limits\n */\nexport function validateTableComponent(\n params: TableComponentParams,\n limits: ResourceLimits = DEFAULT_RESOURCE_LIMITS\n): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n for (const key of ['pageSize', 'chatPageSize', 'initialPage'] as const) {\n const value = params[key];\n if (value !== undefined && (typeof value !== 'number' || !Number.isInteger(value) || value < 0)) {\n errors.push({\n path: `params.${key}`,\n message: `${key} must be a nonnegative integer`,\n code: 'INVALID_PAGINATION',\n });\n }\n }\n\n // Validate row count\n if (params.rows.length > limits.maxTableRows) {\n errors.push({\n path: 'params.rows',\n message: `Table exceeds max rows: ${params.rows.length} > ${limits.maxTableRows}`,\n code: 'RESOURCE_LIMIT_EXCEEDED',\n });\n }\n\n // Validate columns\n if (params.columns.length === 0) {\n errors.push({\n path: 'params.columns',\n message: 'Table must have at least one column',\n code: 'EMPTY_COLUMNS',\n });\n }\n\n // Validate column keys are unique\n const columnKeys = new Set<string>();\n for (const [index, column] of params.columns.entries()) {\n if (columnKeys.has(column.key)) {\n errors.push({\n path: `params.columns[${index}]`,\n message: `Duplicate column key: ${column.key}`,\n code: 'DUPLICATE_COLUMN_KEY',\n });\n }\n columnKeys.add(column.key);\n }\n\n // Validate rows have valid data for defined columns\n for (const [rowIndex, row] of params.rows.entries()) {\n for (const column of params.columns) {\n if (!(column.key in row)) {\n errors.push({\n path: `params.rows[${rowIndex}]`,\n message: `Missing column key: ${column.key}`,\n code: 'MISSING_COLUMN_DATA',\n });\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate payload size\n */\nexport function validatePayloadSize(\n component: UIComponent,\n limits: ResourceLimits = DEFAULT_RESOURCE_LIMITS\n): ValidationResult {\n const payloadSize = JSON.stringify(component).length;\n\n if (payloadSize > limits.maxPayloadSize) {\n return {\n valid: false,\n errors: [\n {\n path: 'component',\n message: `Payload size exceeds limit: ${payloadSize} > ${limits.maxPayloadSize} bytes`,\n code: 'PAYLOAD_TOO_LARGE',\n },\n ],\n };\n }\n\n return { valid: true };\n}\n\n/**\n * Sanitize string to prevent XSS\n * Basic implementation - DOMPurify used at render time\n */\nexport function sanitizeString(input: string): string {\n return input\n .replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, '')\n .replace(/on\\w+=\"[^\"]*\"/gi, '')\n .replace(/javascript:/gi, '');\n}\n\n/**\n * Validate iframe domain against whitelist\n *\n * @param url - The URL to validate\n * @param options - Optional validation options\n * @param options.policy - 'strict' (default), 'extend', or 'allow-all'\n * @param options.customDomains - Additional domains when policy is 'extend'\n */\nexport function validateIframeDomain(\n url: string,\n options?: { policy?: IframePolicy; customDomains?: string[] }\n): ValidationResult {\n // If allow-all, skip validation\n if (options?.policy === 'allow-all') {\n return { valid: true };\n }\n\n try {\n const parsedUrl = new URL(url);\n const domain = parsedUrl.hostname;\n\n // Build effective whitelist\n let effectiveWhitelist = DEFAULT_IFRAME_DOMAINS;\n if (options?.policy === 'extend' && options.customDomains) {\n effectiveWhitelist = [...DEFAULT_IFRAME_DOMAINS, ...options.customDomains];\n }\n\n // SECURITY (v5.5.1) — pre-fix bug: predicate was `allowed === 'localhost'`\n // which trivially returned true for every URL once the whitelist contained\n // 'localhost' (an entry from DEFAULT_IFRAME_DOMAINS), making the entire\n // domain whitelist inoperative. Fixed: only the URL's actual hostname\n // being 'localhost' (or a 127.0.0.x loopback) bypasses the whitelist.\n const isLoopback = domain === 'localhost' || /^127(\\.\\d{1,3}){3}$/.test(domain);\n const isAllowed =\n isLoopback ||\n effectiveWhitelist.some(\n (allowed) =>\n allowed !== 'localhost' && (domain === allowed || domain.endsWith(`.${allowed}`))\n );\n\n if (!isAllowed) {\n return {\n valid: false,\n errors: [\n {\n path: 'url',\n message: `Domain not whitelisted: ${domain}`,\n code: 'DOMAIN_NOT_WHITELISTED',\n },\n ],\n };\n }\n\n return { valid: true };\n } catch (error) {\n return {\n valid: false,\n errors: [\n {\n path: 'url',\n message: 'Invalid URL format',\n code: 'INVALID_URL',\n },\n ],\n };\n }\n}\n\n/**\n * Get the appropriate sandbox attribute for an iframe URL.\n *\n * Trusted domains (Google, Deposium, payment, auth-requiring services) get\n * `allow-same-origin` so they can access their own cookies/storage.\n * All other whitelisted domains get a restrictive sandbox without it,\n * preventing access to the parent page's localStorage/cookies.\n *\n * @param url - The iframe URL\n * @param options - Optional custom trusted domains\n * @returns sandbox attribute string\n */\nexport function getIframeSandbox(\n url: string,\n options?: { customTrustedDomains?: string[] }\n): string {\n const baseSandbox = 'allow-scripts allow-popups';\n\n try {\n const domain = new URL(url).hostname;\n let trustedList = TRUSTED_IFRAME_DOMAINS;\n if (options?.customTrustedDomains) {\n trustedList = [...TRUSTED_IFRAME_DOMAINS, ...options.customTrustedDomains];\n }\n\n const isTrusted = trustedList.some(\n (trusted) => domain === trusted || domain.endsWith(`.${trusted}`)\n );\n\n if (isTrusted) {\n return `${baseSandbox} allow-same-origin allow-forms`;\n }\n } catch {\n // Invalid URL — use restrictive sandbox\n }\n\n return baseSandbox;\n}\n\n/**\n * Validate entire component\n *\n * @param component - The component to validate\n * @param options - Optional validation options (limits, iframePolicy, customIframeDomains)\n */\nexport function validateComponent(\n component: UIComponent,\n options?: ValidationOptions\n): ValidationResult {\n const limits = options?.limits ?? DEFAULT_RESOURCE_LIMITS;\n const errors: ValidationResult['errors'] = [];\n\n // Guard: params must exist\n if (!component.params) {\n return {\n valid: false,\n errors: [{ path: 'params', message: 'Missing component params', code: 'MISSING_PARAMS' }],\n };\n }\n\n // Validate grid position\n const gridResult = validateGridPosition(component.position);\n if (!gridResult.valid) {\n errors.push(...(gridResult.errors || []));\n }\n\n // Validate payload size\n const sizeResult = validatePayloadSize(component, limits);\n if (!sizeResult.valid) {\n errors.push(...(sizeResult.errors || []));\n }\n\n // Type-specific validation (B.1 — v5.5.0, expanded v5.6.0).\n //\n // 14 types delegate shape validation to Zod schemas in `mcp-ui-spec` via\n // SPEC_VALIDATORS. The 3 remaining types stay imperative because they\n // need cross-field consistency, resource limits, or have nothing to validate\n // (see SPEC_VALIDATORS docstring).\n const specValidator = SPEC_VALIDATORS[component.type];\n if (specValidator) {\n const result = specValidator.schema.safeParse(component.params);\n if (!result.success) {\n errors.push(...mapZodIssuesToErrors(result.error.issues, specValidator.legacyCode));\n }\n // Post-spec chained checks. Skipped when the shape parse failed to avoid\n // cascading errors on already-broken payloads.\n if (result.success) {\n // Iframe + video: domain whitelist\n if (component.type === 'iframe' || component.type === 'video') {\n const url = (component.params as { url?: string })?.url;\n if (typeof url === 'string') {\n const domainResult = validateIframeDomain(url, {\n policy: options?.iframePolicy,\n customDomains: options?.customIframeDomains,\n });\n if (!domainResult.valid) {\n errors.push(...(domainResult.errors || []));\n }\n }\n }\n // Map (v5.6.0; widened v6.8.2): a map must carry at least one\n // visualizable thing. Originally only center/markers counted, but since\n // spec@5.2.0 a `type:'map'` may render purely from `geojson`, named\n // `layers`, or a `pmtiles` source (e.g. a Cadastre choropleth with no\n // markers and an auto-fit viewport). Rejecting those as INVALID_MAP\n // blocked valid maps the renderer draws. Accept ANY of:\n // center | markers | geojson | layers | pmtiles.\n if (component.type === 'map') {\n const mapParams = component.params as {\n center?: unknown;\n markers?: unknown[];\n geojson?: unknown;\n layers?: unknown[];\n pmtiles?: unknown;\n };\n const hasContent =\n mapParams.center != null ||\n (Array.isArray(mapParams.markers) && mapParams.markers.length > 0) ||\n mapParams.geojson != null ||\n (Array.isArray(mapParams.layers) && mapParams.layers.length > 0) ||\n mapParams.pmtiles != null;\n if (!hasContent) {\n errors.push({\n path: 'params',\n message: 'Map must have center, markers, geojson, layers, or pmtiles',\n code: 'INVALID_MAP',\n });\n }\n }\n }\n } else {\n // Imperative path for chart/table/modal/grid/footer/composite.\n switch (component.type) {\n case 'chart': {\n const chartResult = validateChartComponent(\n component.params as ChartComponentParams,\n limits\n );\n if (!chartResult.valid) {\n errors.push(...(chartResult.errors || []));\n }\n break;\n }\n\n case 'table': {\n const tableResult = validateTableComponent(\n component.params as TableComponentParams,\n limits\n );\n if (!tableResult.valid) {\n errors.push(...(tableResult.errors || []));\n }\n break;\n }\n\n case 'modal':\n // Modal is valid with minimal params (title optional, content can be children).\n break;\n\n default:\n // Known types without specific validation pass through — renderer handles errors.\n // Truly unknown types (e.g. typos in streamed JSON) are rejected.\n if (!KNOWN_COMPONENT_TYPES.has(component.type)) {\n errors.push({\n path: 'type',\n message: `Unknown component type: ${component.type}`,\n code: 'UNKNOWN_COMPONENT_TYPE',\n });\n }\n break;\n }\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate entire layout\n *\n * @param layout - The layout to validate\n * @param options - Optional validation options (limits, iframePolicy, customIframeDomains)\n */\nexport function validateLayout(layout: UILayout, options?: ValidationOptions): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n // Validate component count\n if (layout.components.length === 0) {\n errors.push({\n path: 'components',\n message: 'Layout must have at least one component',\n code: 'EMPTY_LAYOUT',\n });\n }\n\n if (layout.components.length > 12) {\n errors.push({\n path: 'components',\n message: `Layout exceeds max components: ${layout.components.length} > 12`,\n code: 'TOO_MANY_COMPONENTS',\n });\n }\n\n // Validate each component\n for (const [index, component] of layout.components.entries()) {\n const result = validateComponent(component, options);\n if (!result.valid) {\n errors.push(\n ...(result.errors?.map((error) => ({\n ...error,\n path: `components[${index}].${error.path}`,\n })) || [])\n );\n }\n }\n\n // Validate grid configuration\n if (layout.grid.columns !== 12) {\n errors.push({\n path: 'grid.columns',\n message: 'Grid must have 12 columns (Bootstrap-like)',\n code: 'INVALID_GRID_COLUMNS',\n });\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate a single form field value against field rules\n */\nexport function validateFieldValue(\n value: any,\n field: FormFieldParams\n): { valid: boolean; error?: string } {\n // Required check\n if (field.required) {\n if (value === undefined || value === null || value === '') {\n return { valid: false, error: `${field.label || field.name} is required` };\n }\n if (field.type === 'checkbox' && value !== true) {\n return { valid: false, error: `${field.label || field.name} must be checked` };\n }\n }\n\n // Skip further validation if value is empty and not required\n if (value === undefined || value === null || value === '') {\n return { valid: true };\n }\n\n // Type-specific validation\n switch (field.type) {\n case 'text':\n case 'textarea':\n case 'password':\n if (field.minLength && String(value).length < field.minLength) {\n return { valid: false, error: `Minimum ${field.minLength} characters required` };\n }\n if (field.maxLength && String(value).length > field.maxLength) {\n return { valid: false, error: `Maximum ${field.maxLength} characters allowed` };\n }\n if (field.pattern && !new RegExp(field.pattern).test(String(value))) {\n return { valid: false, error: 'Invalid format' };\n }\n break;\n\n case 'email':\n if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(String(value))) {\n return { valid: false, error: 'Invalid email address' };\n }\n break;\n\n case 'number': {\n const numValue = Number(value);\n if (isNaN(numValue)) {\n return { valid: false, error: 'Must be a valid number' };\n }\n if (field.min !== undefined && numValue < field.min) {\n return { valid: false, error: `Minimum value is ${field.min}` };\n }\n if (field.max !== undefined && numValue > field.max) {\n return { valid: false, error: `Maximum value is ${field.max}` };\n }\n break;\n }\n\n case 'date':\n if (field.minDate && value < field.minDate) {\n return { valid: false, error: `Date must be after ${field.minDate}` };\n }\n if (field.maxDate && value > field.maxDate) {\n return { valid: false, error: `Date must be before ${field.maxDate}` };\n }\n break;\n\n case 'select':\n case 'radio':\n // Validate that value is one of the options\n if (field.options && field.options.length > 0) {\n const validValues = field.options.map((opt) => opt.value);\n if (!validValues.includes(String(value))) {\n return { valid: false, error: 'Please select a valid option' };\n }\n }\n break;\n }\n\n // valueFormat validation (v4.3.0) — runs after type-specific checks\n if (field.valueFormat && value !== undefined && value !== null && value !== '') {\n const vals = Array.isArray(value) ? value : [String(value)];\n for (const v of vals) {\n if (!new RegExp(field.valueFormat).test(v)) {\n return {\n valid: false,\n error: field.valueFormatHint || `Invalid format (expected: ${field.valueFormat})`,\n };\n }\n }\n }\n\n return { valid: true };\n}\n\n/**\n * Validate entire form data against field definitions\n */\nexport function validateFormData(\n data: Record<string, any>,\n fields: FormFieldParams[]\n): { valid: boolean; errors: Record<string, string> } {\n const errors: Record<string, string> = {};\n\n for (const field of fields) {\n const result = validateFieldValue(data[field.name], field);\n if (!result.valid && result.error) {\n errors[field.name] = result.error;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors,\n };\n}\n"],"names":["ComponentTypeSchema","MetricComponentParamsSchema","TextComponentParamsSchema","IframeComponentParamsSchema","ImageComponentParamsSchema","LinkComponentParamsSchema","ActionParamsSchema","VideoComponentParamsSchema","CarouselComponentParamsSchema","ImageGalleryParamsSchema","ActionGroupParamsSchema","CodeComponentParamsSchema","ArtifactComponentParamsSchema","FormComponentParamsSchema","MapComponentParamsSchema","GraphComponentParamsSchema"],"mappings":";;;AAuDA,MAAM,wBAAqC,IAAI,IAAYA,UAAAA,oBAAoB,OAAO;AAwBtF,MAAM,kBAA6F;AAAA,EACjG,QAAQ,EAAE,QAAQC,uCAA6B,YAAY,iBAAA;AAAA,EAC3D,MAAM,EAAE,QAAQC,qCAA2B,YAAY,eAAA;AAAA,EACvD,QAAQ,EAAE,QAAQC,uCAA6B,YAAY,iBAAA;AAAA,EAC3D,OAAO,EAAE,QAAQC,sCAA4B,YAAY,gBAAA;AAAA,EACzD,MAAM,EAAE,QAAQC,qCAA2B,YAAY,eAAA;AAAA,EACvD,QAAQ,EAAE,QAAQC,8BAAoB,YAAY,iBAAA;AAAA,EAClD,OAAO,EAAE,QAAQC,sCAA4B,YAAY,gBAAA;AAAA,EACzD,UAAU,EAAE,QAAQC,yCAA+B,YAAY,iBAAA;AAAA,EAC/D,iBAAiB,EAAE,QAAQC,oCAA0B,YAAY,gBAAA;AAAA,EACjE,gBAAgB,EAAE,QAAQC,mCAAyB,YAAY,qBAAA;AAAA,EAC/D,MAAM,EAAE,QAAQC,qCAA2B,YAAY,eAAA;AAA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AM,IAAI,IAAI,OAAO;AAAA,IAC9B;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,OAAO,KAAK,MAAM,EAAE,WAAW;AAAA,IACtC;AAAA,EAAA;AAEJ;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"validation.cjs","sources":["../../src/services/validation.ts"],"sourcesContent":["/**\n * Component Validation Service\n * Phase 0: Resource Limits & Schema Validation\n *\n * Validates LLM-generated components against:\n * - JSON schema\n * - Resource limits (data points, payload size, grid bounds)\n * - Security constraints (domain whitelist, XSS prevention)\n */\n\nimport type { ZodIssue, ZodSchema } from 'zod';\nimport {\n MetricComponentParamsSchema,\n TextComponentParamsSchema,\n IframeComponentParamsSchema,\n ImageComponentParamsSchema,\n LinkComponentParamsSchema,\n CarouselComponentParamsSchema,\n ArtifactComponentParamsSchema,\n ActionParamsSchema,\n VideoComponentParamsSchema,\n ImageGalleryParamsSchema,\n ActionGroupParamsSchema,\n CodeComponentParamsSchema,\n // v5.6.0 — added after spec@5.0.2 relaxations (deposium audit §M)\n MapComponentParamsSchema,\n FormComponentParamsSchema,\n // v6.0.0 — graph primitive (peer @antv/g6 ^5)\n GraphComponentParamsSchema,\n // Single source of truth for the component-type enum (kills spec↔solid drift).\n ComponentTypeSchema,\n} from '@seed-ship/mcp-ui-spec';\nimport type {\n UIComponent,\n UILayout,\n ValidationResult,\n ResourceLimits,\n ChartComponentParams,\n TableComponentParams,\n FormFieldParams,\n IframePolicy,\n ValidationOptions,\n ComponentType,\n} from '../types';\n// Runtime-free template helper: `src/validation.ts` (the SSR-safe subpath)\n// re-exports this module, so it must stay free of any solid-js import.\nimport { formatMCPUIString } from '../utils/format-string';\n\n/**\n * All known ComponentType values — used to distinguish known-but-unvalidated\n * types (pass through) from truly unknown strings (reject).\n *\n * Derived directly from the spec's `ComponentTypeSchema` (the single source of\n * truth) rather than hand-maintained, so a new enum member in the spec can\n * never silently drift out of solid's known-types set again. This is what\n * restored `composite`: it is in the spec enum but had been dropped from the\n * former hand-written list, contradicting the pass-through docstrings below.\n */\nconst KNOWN_COMPONENT_TYPES: Set<string> = new Set<string>(ComponentTypeSchema.options);\n\n/**\n * Spec-driven validation dispatch table (B.1 — v5.5.0, expanded in v5.6.0).\n *\n * For each ComponentType where we delegate shape validation to a Zod schema\n * from `@seed-ship/mcp-ui-spec`, this table maps:\n * - the schema to safeParse against\n * - the legacy error code to emit when shape parsing fails (preserves the\n * pre-v5.5.0 `errors[].code` API contract — see MCP-UI-AUDIT-2026-04-26.md\n * §I.3.a + §J.1)\n *\n * **v5.6.0** : `map` and `form` joined the dispatch after spec@5.0.2 relaxed\n * their schemas (LatLngPoint union for map.center, regex relax for\n * field.name) per deposium audit §L answers. As of v6.x this table\n * spec-validates 15 of the 21 component types; the remainder use imperative\n * validators (`chart`/`table`) or are pass-through (`grid`/`footer`/`composite`/`modal`).\n *\n * Types deliberately omitted (kept on the imperative path):\n * - `chart`, `table` — have rich imperative validators with their own\n * codes (MISSING_DATA, DATA_LENGTH_MISMATCH, RESOURCE_LIMIT_EXCEEDED, …)\n * - `modal` — all params are optional; nothing to enforce.\n * - `grid`, `footer`, `composite` — pass-through, validated elsewhere.\n */\nconst SPEC_VALIDATORS: Partial<Record<ComponentType, { schema: ZodSchema; legacyCode: string }>> = {\n metric: { schema: MetricComponentParamsSchema, legacyCode: 'INVALID_METRIC' },\n text: { schema: TextComponentParamsSchema, legacyCode: 'INVALID_TEXT' },\n iframe: { schema: IframeComponentParamsSchema, legacyCode: 'INVALID_IFRAME' },\n image: { schema: ImageComponentParamsSchema, legacyCode: 'INVALID_IMAGE' },\n link: { schema: LinkComponentParamsSchema, legacyCode: 'INVALID_LINK' },\n action: { schema: ActionParamsSchema, legacyCode: 'INVALID_ACTION' },\n video: { schema: VideoComponentParamsSchema, legacyCode: 'INVALID_VIDEO' },\n carousel: { schema: CarouselComponentParamsSchema, legacyCode: 'EMPTY_CAROUSEL' },\n 'image-gallery': { schema: ImageGalleryParamsSchema, legacyCode: 'EMPTY_GALLERY' },\n 'action-group': { schema: ActionGroupParamsSchema, legacyCode: 'EMPTY_ACTION_GROUP' },\n code: { schema: CodeComponentParamsSchema, legacyCode: 'INVALID_CODE' },\n artifact: { schema: ArtifactComponentParamsSchema, legacyCode: 'INVALID_ARTIFACT' },\n // v5.6.0 additions\n form: { schema: FormComponentParamsSchema, legacyCode: 'EMPTY_FORM' },\n map: { schema: MapComponentParamsSchema, legacyCode: 'INVALID_MAP' },\n // v6.0.0 — graph primitive (no chained post-check : Zod's\n // `nodes.min(1)` covers the only structural invariant ; edge\n // source/target ids reference nodes by convention, not enforced here\n // because LLM payloads sometimes ship edges to nodes added later.\n // Unresolved refs are gracefully ignored by G6 v5.)\n graph: { schema: GraphComponentParamsSchema, legacyCode: 'INVALID_GRAPH' },\n};\n\n/**\n * Map a Zod issue list to the legacy `ValidationError[]` shape.\n *\n * Preserves the pre-v5.5.0 contract: `path` always begins with `params`,\n * `code` is the per-type legacy code (so consumers that filtered by\n * `errors[].code === 'EMPTY_CAROUSEL'` keep working), `message` is Zod's\n * native human-readable message.\n */\nfunction mapZodIssuesToErrors(\n issues: readonly ZodIssue[],\n legacyCode: string\n): NonNullable<ValidationResult['errors']> {\n return issues.map((issue) => ({\n path: issue.path.length > 0 ? `params.${issue.path.join('.')}` : 'params',\n message: issue.message,\n code: legacyCode,\n }));\n}\n\n/**\n * Default resource limits (configurable via env)\n */\nexport const DEFAULT_RESOURCE_LIMITS: ResourceLimits = {\n maxDataPoints: 1000,\n maxTableRows: 100,\n // v6.8.0 — raised 50KB → 512KB. The single payload-size guard is shared by\n // every component type ; 50KB rejected otherwise-valid `map` components\n // carrying a realistic `params.geojson` FeatureCollection (a dense\n // multi-feature map — e.g. a département-wide choropleth — runs 300-500KB\n // even after reasonable geometry simplification). 512KB leaves real\n // headroom for that while still rejecting runaway payloads ; genuinely\n // large datasets belong in vector tiles (PMTiles), not inline GeoJSON.\n // The guard itself (`validatePayloadSize`) is unchanged — only the\n // default ceiling moved.\n maxPayloadSize: 512 * 1024, // 512KB\n renderTimeout: 5000, // 5 seconds\n};\n\n/**\n * Default allowed iframe domains (whitelist)\n * Must match CSP frame-src directive\n * Updated Sprint 7: Added code, design, docs, and map providers\n *\n * This list is exported for transparency and can be extended via ValidationOptions\n */\nexport const DEFAULT_IFRAME_DOMAINS = [\n // Charts\n 'quickchart.io',\n 'www.quickchart.io',\n\n // Deposium\n 'deposium.com',\n 'deposium.vip',\n 'deposium.ai',\n\n // Development\n 'localhost',\n\n // Video providers (Sprint 5)\n 'youtube.com',\n 'www.youtube.com',\n 'youtube-nocookie.com',\n 'www.youtube-nocookie.com',\n 'youtu.be',\n 'vimeo.com',\n 'player.vimeo.com',\n\n // Code playgrounds (Sprint 7)\n 'codepen.io',\n 'codesandbox.io',\n 'stackblitz.com',\n 'jsfiddle.net',\n\n // Design tools (Sprint 7)\n 'figma.com',\n 'www.figma.com',\n 'miro.com',\n\n // Google services (Sprint 7)\n 'docs.google.com',\n 'drive.google.com',\n 'sheets.google.com',\n 'slides.google.com',\n 'maps.google.com',\n 'www.google.com',\n 'datastudio.google.com',\n 'lookerstudio.google.com',\n\n // Productivity (Sprint 7)\n 'airtable.com',\n 'notion.so',\n 'www.notion.so',\n\n // Maps (Sprint 7)\n 'openstreetmap.org',\n 'www.openstreetmap.org',\n\n // Analytics/Dashboards (Sprint 7)\n 'public.tableau.com',\n 'app.powerbi.com',\n 'observablehq.com',\n\n // Diagrams & Whiteboards (v2.0.0)\n 'mermaid.live',\n 'excalidraw.com',\n 'lucidchart.com',\n 'lucid.app',\n\n // Video - Business (v2.0.0)\n 'loom.com',\n 'www.loom.com',\n 'cloudflarestream.com',\n 'streamable.com',\n\n // Code repositories (v2.0.0)\n 'github.com',\n 'gist.github.com',\n 'gitlab.com',\n 'replit.com',\n 'glitch.com',\n\n // Business tools (v2.0.0)\n 'calendly.com',\n 'typeform.com',\n 'cal.com',\n\n // Design (v2.0.0)\n 'canva.com',\n\n // Deploy previews (v2.0.0)\n 'vercel.app',\n 'netlify.app',\n\n // E-commerce (v2.0.0)\n 'amazon.com',\n 'amazon.fr',\n 'amazon.de',\n 'amazon.co.uk',\n 'amazon.es',\n 'amazon.it',\n 'amazon.ca',\n 'amazon.co.jp',\n 'images-amazon.com',\n 'media-amazon.com',\n 'ws-na.amazon-adsystem.com',\n\n // MCP Connectors — embed-capable services (v2.2.7)\n 'gamma.app',\n 'www.gamma.app',\n 'app.hubspot.com',\n 'share.hubspot.com',\n 'www.data.gouv.fr',\n 'data.gouv.fr',\n 'clinicaltrials.gov',\n 'www.clinicaltrials.gov',\n 'linear.app',\n 'www.linear.app',\n\n // Payment platforms (v2.2.12)\n 'polar.sh',\n 'www.polar.sh',\n 'checkout.stripe.com',\n 'js.stripe.com',\n 'billing.stripe.com',\n 'buy.stripe.com',\n 'connect.stripe.com',\n 'invoice.stripe.com',\n];\n\n/**\n * Trusted iframe domains that require allow-same-origin to function.\n * These domains need access to their own cookies/storage for auth.\n * All other whitelisted domains get a restrictive sandbox without allow-same-origin.\n */\nexport const TRUSTED_IFRAME_DOMAINS = [\n // Deposium (own domains)\n 'deposium.com',\n 'deposium.vip',\n 'deposium.ai',\n 'localhost',\n\n // Google services (need auth cookies)\n 'docs.google.com',\n 'drive.google.com',\n 'sheets.google.com',\n 'slides.google.com',\n 'maps.google.com',\n 'datastudio.google.com',\n 'lookerstudio.google.com',\n\n // Productivity (need auth)\n 'notion.so',\n 'www.notion.so',\n 'airtable.com',\n 'figma.com',\n 'www.figma.com',\n 'miro.com',\n\n // Payment (need auth + cookies for checkout)\n 'polar.sh',\n 'www.polar.sh',\n 'checkout.stripe.com',\n 'js.stripe.com',\n 'billing.stripe.com',\n 'buy.stripe.com',\n 'connect.stripe.com',\n 'invoice.stripe.com',\n\n // Business tools (need auth)\n 'app.hubspot.com',\n 'share.hubspot.com',\n 'app.powerbi.com',\n 'linear.app',\n 'www.linear.app',\n 'calendly.com',\n 'typeform.com',\n 'cal.com',\n 'canva.com',\n];\n\n/**\n * Validate grid position bounds (1-12 columns)\n */\nexport function validateGridPosition(position: UIComponent['position']): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n // ✅ PHASE 3 FIX: Defensive check for undefined position\n if (!position) {\n return {\n valid: false,\n errors: [\n {\n path: 'position',\n message: 'Position is required',\n code: 'MISSING_POSITION',\n },\n ],\n };\n }\n\n if (position.colStart < 1 || position.colStart > 12) {\n errors.push({\n path: 'position.colStart',\n message: 'Column start must be between 1 and 12',\n code: 'INVALID_GRID_COL_START',\n });\n }\n\n if (position.colSpan < 1 || position.colSpan > 12) {\n errors.push({\n path: 'position.colSpan',\n message: 'Column span must be between 1 and 12',\n code: 'INVALID_GRID_COL_SPAN',\n });\n }\n\n if (position.colStart + position.colSpan - 1 > 12) {\n errors.push({\n path: 'position',\n message: 'Column start + span exceeds grid width (12)',\n code: 'GRID_OVERFLOW',\n });\n }\n\n if (position.rowStart !== undefined && position.rowStart < 1) {\n errors.push({\n path: 'position.rowStart',\n message: 'Row start must be >= 1',\n code: 'INVALID_GRID_ROW_START',\n });\n }\n\n if (position.rowSpan !== undefined && position.rowSpan < 1) {\n errors.push({\n path: 'position.rowSpan',\n message: 'Row span must be >= 1',\n code: 'INVALID_GRID_ROW_SPAN',\n });\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate chart component against resource limits\n */\nexport function validateChartComponent(\n params: ChartComponentParams,\n limits: ResourceLimits = DEFAULT_RESOURCE_LIMITS\n): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n // Guard: params.data must exist with labels + datasets\n if (!params?.data) {\n return {\n valid: false,\n errors: [{ path: 'params.data', message: 'Missing chart data object', code: 'MISSING_DATA' }],\n };\n }\n if (!Array.isArray(params.data.datasets)) {\n return {\n valid: false,\n errors: [\n {\n path: 'params.data.datasets',\n message: 'Missing or invalid datasets array',\n code: 'MISSING_DATASETS',\n },\n ],\n };\n }\n // Detect point-based charts (scatter/bubble) or object data (time-series line)\n const chartType = params.type || 'bar';\n const usesPoints = (data: unknown[]) => data.some(value =>\n typeof value === 'object' && value !== null && 'x' in value\n );\n const hasObjectData = params.data.datasets.some(dataset =>\n Array.isArray(dataset.data) && usesPoints(dataset.data)\n );\n const isPointChart = chartType === 'scatter' || chartType === 'bubble' || hasObjectData;\n\n // Labels required only for categorical charts (not scatter/bubble/time-series)\n if (!isPointChart) {\n if (!Array.isArray(params.data.labels)) {\n return {\n valid: false,\n errors: [\n {\n path: 'params.data.labels',\n message: 'Missing or invalid labels array',\n code: 'MISSING_LABELS',\n },\n ],\n };\n }\n }\n\n // Validate data points count\n const totalDataPoints = params.data.datasets.reduce(\n (sum, dataset) => sum + (Array.isArray(dataset.data) ? dataset.data.length : 0),\n 0\n );\n\n if (totalDataPoints > limits.maxDataPoints) {\n errors.push({\n path: 'params.data',\n message: `Chart exceeds max data points: ${totalDataPoints} > ${limits.maxDataPoints}`,\n code: 'RESOURCE_LIMIT_EXCEEDED',\n });\n }\n\n // Length mismatch check — only for categorical charts, skip empty datasets\n if (chartType !== 'scatter' && chartType !== 'bubble' && Array.isArray(params.data.labels)) {\n const expectedLength = params.data.labels.length;\n for (const [index, dataset] of params.data.datasets.entries()) {\n if (\n Array.isArray(dataset.data) &&\n !usesPoints(dataset.data) &&\n dataset.data.length > 0 &&\n dataset.data.length !== expectedLength\n ) {\n errors.push({\n path: `params.data.datasets[${index}]`,\n message: `Dataset length mismatch: expected ${expectedLength}, got ${dataset.data.length}`,\n code: 'DATA_LENGTH_MISMATCH',\n });\n }\n }\n }\n\n // Data type validation — numbers for categorical, {x,y} objects for point charts\n for (const [index, dataset] of params.data.datasets.entries()) {\n if (!Array.isArray(dataset.data)) continue;\n const datasetIsPointChart = chartType === 'scatter' || chartType === 'bubble' || usesPoints(dataset.data);\n for (const [dataIndex, value] of dataset.data.entries()) {\n if (datasetIsPointChart) {\n const vObj = value as any;\n if (\n typeof value !== 'object' ||\n value === null ||\n vObj.x == null ||\n typeof vObj.y !== 'number' ||\n (vObj.r !== undefined && (typeof vObj.r !== 'number' || !Number.isFinite(vObj.r) || vObj.r < 0))\n ) {\n errors.push({\n path: `params.data.datasets[${index}].data[${dataIndex}]`,\n message: `Invalid point data: expected {x, y} object`,\n code: 'INVALID_POINT_DATA',\n });\n }\n } else {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n errors.push({\n path: `params.data.datasets[${index}].data[${dataIndex}]`,\n message: `Invalid data value: ${value} (must be finite number)`,\n code: 'INVALID_DATA_TYPE',\n });\n }\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate table component against resource limits\n */\nexport function validateTableComponent(\n params: TableComponentParams,\n limits: ResourceLimits = DEFAULT_RESOURCE_LIMITS\n): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n for (const key of ['pageSize', 'chatPageSize', 'initialPage'] as const) {\n const value = params[key];\n if (value !== undefined && (typeof value !== 'number' || !Number.isInteger(value) || value < 0)) {\n errors.push({\n path: `params.${key}`,\n message: `${key} must be a nonnegative integer`,\n code: 'INVALID_PAGINATION',\n });\n }\n }\n\n // Validate row count\n if (params.rows.length > limits.maxTableRows) {\n errors.push({\n path: 'params.rows',\n message: `Table exceeds max rows: ${params.rows.length} > ${limits.maxTableRows}`,\n code: 'RESOURCE_LIMIT_EXCEEDED',\n });\n }\n\n // Validate columns\n if (params.columns.length === 0) {\n errors.push({\n path: 'params.columns',\n message: 'Table must have at least one column',\n code: 'EMPTY_COLUMNS',\n });\n }\n\n // Validate column keys are unique\n const columnKeys = new Set<string>();\n for (const [index, column] of params.columns.entries()) {\n if (columnKeys.has(column.key)) {\n errors.push({\n path: `params.columns[${index}]`,\n message: `Duplicate column key: ${column.key}`,\n code: 'DUPLICATE_COLUMN_KEY',\n });\n }\n columnKeys.add(column.key);\n }\n\n // Validate rows have valid data for defined columns\n for (const [rowIndex, row] of params.rows.entries()) {\n for (const column of params.columns) {\n if (!(column.key in row)) {\n errors.push({\n path: `params.rows[${rowIndex}]`,\n message: `Missing column key: ${column.key}`,\n code: 'MISSING_COLUMN_DATA',\n });\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate payload size\n */\nexport function validatePayloadSize(\n component: UIComponent,\n limits: ResourceLimits = DEFAULT_RESOURCE_LIMITS\n): ValidationResult {\n const payloadSize = JSON.stringify(component).length;\n\n if (payloadSize > limits.maxPayloadSize) {\n return {\n valid: false,\n errors: [\n {\n path: 'component',\n message: `Payload size exceeds limit: ${payloadSize} > ${limits.maxPayloadSize} bytes`,\n code: 'PAYLOAD_TOO_LARGE',\n },\n ],\n };\n }\n\n return { valid: true };\n}\n\n/**\n * Sanitize string to prevent XSS\n * Basic implementation - DOMPurify used at render time\n */\nexport function sanitizeString(input: string): string {\n return input\n .replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, '')\n .replace(/on\\w+=\"[^\"]*\"/gi, '')\n .replace(/javascript:/gi, '');\n}\n\n/**\n * Validate iframe domain against whitelist\n *\n * @param url - The URL to validate\n * @param options - Optional validation options\n * @param options.policy - 'strict' (default), 'extend', or 'allow-all'\n * @param options.customDomains - Additional domains when policy is 'extend'\n */\nexport function validateIframeDomain(\n url: string,\n options?: { policy?: IframePolicy; customDomains?: string[] }\n): ValidationResult {\n // If allow-all, skip validation\n if (options?.policy === 'allow-all') {\n return { valid: true };\n }\n\n try {\n const parsedUrl = new URL(url);\n const domain = parsedUrl.hostname;\n\n // Build effective whitelist\n let effectiveWhitelist = DEFAULT_IFRAME_DOMAINS;\n if (options?.policy === 'extend' && options.customDomains) {\n effectiveWhitelist = [...DEFAULT_IFRAME_DOMAINS, ...options.customDomains];\n }\n\n // SECURITY (v5.5.1) — pre-fix bug: predicate was `allowed === 'localhost'`\n // which trivially returned true for every URL once the whitelist contained\n // 'localhost' (an entry from DEFAULT_IFRAME_DOMAINS), making the entire\n // domain whitelist inoperative. Fixed: only the URL's actual hostname\n // being 'localhost' (or a 127.0.0.x loopback) bypasses the whitelist.\n const isLoopback = domain === 'localhost' || /^127(\\.\\d{1,3}){3}$/.test(domain);\n const isAllowed =\n isLoopback ||\n effectiveWhitelist.some(\n (allowed) =>\n allowed !== 'localhost' && (domain === allowed || domain.endsWith(`.${allowed}`))\n );\n\n if (!isAllowed) {\n return {\n valid: false,\n errors: [\n {\n path: 'url',\n message: `Domain not whitelisted: ${domain}`,\n code: 'DOMAIN_NOT_WHITELISTED',\n },\n ],\n };\n }\n\n return { valid: true };\n } catch (error) {\n return {\n valid: false,\n errors: [\n {\n path: 'url',\n message: 'Invalid URL format',\n code: 'INVALID_URL',\n },\n ],\n };\n }\n}\n\n/**\n * Is this URL's host a trusted iframe host?\n *\n * A host matches when it equals an entry of `TRUSTED_IFRAME_DOMAINS` (plus\n * `options.customTrustedDomains`) or is a subdomain of one. Trusted hosts\n * need their own cookies/storage to authenticate, which is why they receive\n * `allow-same-origin` in `getIframeSandbox` and deliberately do NOT receive\n * the `credentialless` iframe attribute (an authenticated embed loaded\n * without its cookies only shows a login screen).\n *\n * An unparsable URL is never trusted.\n *\n * @param url - The iframe URL\n * @param options - Optional custom trusted domains, merged over the defaults\n * @returns `true` when the URL's host is trusted\n * @since v6.21.0 — extracted from `getIframeSandbox`, identical matching.\n */\nexport function isTrustedIframeDomain(\n url: string,\n options?: { customTrustedDomains?: string[] }\n): boolean {\n try {\n const domain = new URL(url).hostname;\n const trustedList = options?.customTrustedDomains\n ? [...TRUSTED_IFRAME_DOMAINS, ...options.customTrustedDomains]\n : TRUSTED_IFRAME_DOMAINS;\n\n return trustedList.some(\n (trusted) => domain === trusted || domain.endsWith(`.${trusted}`)\n );\n } catch {\n // Invalid URL — never trusted.\n return false;\n }\n}\n\n/**\n * Get the appropriate sandbox attribute for an iframe URL.\n *\n * Trusted domains (Google, Deposium, payment, auth-requiring services) get\n * `allow-same-origin` so they can access their own cookies/storage.\n * All other whitelisted domains get a restrictive sandbox without it,\n * preventing access to the parent page's localStorage/cookies.\n *\n * @param url - The iframe URL\n * @param options - Optional custom trusted domains\n * @returns sandbox attribute string\n */\nexport function getIframeSandbox(\n url: string,\n options?: { customTrustedDomains?: string[] }\n): string {\n const baseSandbox = 'allow-scripts allow-popups';\n\n if (isTrustedIframeDomain(url, options)) {\n return `${baseSandbox} allow-same-origin allow-forms`;\n }\n\n return baseSandbox;\n}\n\n/**\n * Validate entire component\n *\n * @param component - The component to validate\n * @param options - Optional validation options (limits, iframePolicy, customIframeDomains)\n */\nexport function validateComponent(\n component: UIComponent,\n options?: ValidationOptions\n): ValidationResult {\n const limits = options?.limits ?? DEFAULT_RESOURCE_LIMITS;\n const errors: ValidationResult['errors'] = [];\n\n // Guard: params must exist\n if (!component.params) {\n return {\n valid: false,\n errors: [{ path: 'params', message: 'Missing component params', code: 'MISSING_PARAMS' }],\n };\n }\n\n // Validate grid position\n const gridResult = validateGridPosition(component.position);\n if (!gridResult.valid) {\n errors.push(...(gridResult.errors || []));\n }\n\n // Validate payload size\n const sizeResult = validatePayloadSize(component, limits);\n if (!sizeResult.valid) {\n errors.push(...(sizeResult.errors || []));\n }\n\n // Type-specific validation (B.1 — v5.5.0, expanded v5.6.0).\n //\n // 14 types delegate shape validation to Zod schemas in `mcp-ui-spec` via\n // SPEC_VALIDATORS. The 3 remaining types stay imperative because they\n // need cross-field consistency, resource limits, or have nothing to validate\n // (see SPEC_VALIDATORS docstring).\n const specValidator = SPEC_VALIDATORS[component.type];\n if (specValidator) {\n const result = specValidator.schema.safeParse(component.params);\n if (!result.success) {\n errors.push(...mapZodIssuesToErrors(result.error.issues, specValidator.legacyCode));\n }\n // Post-spec chained checks. Skipped when the shape parse failed to avoid\n // cascading errors on already-broken payloads.\n if (result.success) {\n // Iframe + video: domain whitelist\n if (component.type === 'iframe' || component.type === 'video') {\n const url = (component.params as { url?: string })?.url;\n if (typeof url === 'string') {\n const domainResult = validateIframeDomain(url, {\n policy: options?.iframePolicy,\n customDomains: options?.customIframeDomains,\n });\n if (!domainResult.valid) {\n errors.push(...(domainResult.errors || []));\n }\n }\n }\n // Map (v5.6.0; widened v6.8.2): a map must carry at least one\n // visualizable thing. Originally only center/markers counted, but since\n // spec@5.2.0 a `type:'map'` may render purely from `geojson`, named\n // `layers`, or a `pmtiles` source (e.g. a Cadastre choropleth with no\n // markers and an auto-fit viewport). Rejecting those as INVALID_MAP\n // blocked valid maps the renderer draws. Accept ANY of:\n // center | markers | geojson | layers | pmtiles.\n if (component.type === 'map') {\n const mapParams = component.params as {\n center?: unknown;\n markers?: unknown[];\n geojson?: unknown;\n layers?: unknown[];\n pmtiles?: unknown;\n };\n const hasContent =\n mapParams.center != null ||\n (Array.isArray(mapParams.markers) && mapParams.markers.length > 0) ||\n mapParams.geojson != null ||\n (Array.isArray(mapParams.layers) && mapParams.layers.length > 0) ||\n mapParams.pmtiles != null;\n if (!hasContent) {\n errors.push({\n path: 'params',\n message: 'Map must have center, markers, geojson, layers, or pmtiles',\n code: 'INVALID_MAP',\n });\n }\n }\n }\n } else {\n // Imperative path for chart/table/modal/grid/footer/composite.\n switch (component.type) {\n case 'chart': {\n const chartResult = validateChartComponent(\n component.params as ChartComponentParams,\n limits\n );\n if (!chartResult.valid) {\n errors.push(...(chartResult.errors || []));\n }\n break;\n }\n\n case 'table': {\n const tableResult = validateTableComponent(\n component.params as TableComponentParams,\n limits\n );\n if (!tableResult.valid) {\n errors.push(...(tableResult.errors || []));\n }\n break;\n }\n\n case 'modal':\n // Modal is valid with minimal params (title optional, content can be children).\n break;\n\n default:\n // Known types without specific validation pass through — renderer handles errors.\n // Truly unknown types (e.g. typos in streamed JSON) are rejected.\n if (!KNOWN_COMPONENT_TYPES.has(component.type)) {\n errors.push({\n path: 'type',\n message: `Unknown component type: ${component.type}`,\n code: 'UNKNOWN_COMPONENT_TYPE',\n });\n }\n break;\n }\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * Validate entire layout\n *\n * @param layout - The layout to validate\n * @param options - Optional validation options (limits, iframePolicy, customIframeDomains)\n */\nexport function validateLayout(layout: UILayout, options?: ValidationOptions): ValidationResult {\n const errors: ValidationResult['errors'] = [];\n\n // Validate component count\n if (layout.components.length === 0) {\n errors.push({\n path: 'components',\n message: 'Layout must have at least one component',\n code: 'EMPTY_LAYOUT',\n });\n }\n\n if (layout.components.length > 12) {\n errors.push({\n path: 'components',\n message: `Layout exceeds max components: ${layout.components.length} > 12`,\n code: 'TOO_MANY_COMPONENTS',\n });\n }\n\n // Validate each component\n for (const [index, component] of layout.components.entries()) {\n const result = validateComponent(component, options);\n if (!result.valid) {\n errors.push(\n ...(result.errors?.map((error) => ({\n ...error,\n path: `components[${index}].${error.path}`,\n })) || [])\n );\n }\n }\n\n // Validate grid configuration\n if (layout.grid.columns !== 12) {\n errors.push({\n path: 'grid.columns',\n message: 'Grid must have 12 columns (Bootstrap-like)',\n code: 'INVALID_GRID_COLUMNS',\n });\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n}\n\n/**\n * The end-user form-validation wording.\n *\n * `validateFieldValue` / `validateFormData` are pure and SSR-safe (they are\n * re-exported from the `@seed-ship/mcp-ui-solid/validation` subpath), so\n * they cannot read `MCPUIStrings`. The wording is injected instead: both\n * take an optional trailing `messages` partial, and `FormRenderer` feeds it\n * from `useMCPUIStrings()` (keys `fieldRequired`, `fieldMinLength`, …).\n *\n * The STRUCTURAL validators (`validateComponent`, `validateLayout`, …) keep\n * their English `ValidationError.message`: those are payload diagnostics\n * addressed to whoever produced the payload, not end-user chrome.\n *\n * @since v6.20.0\n */\nexport interface FormValidationMessages {\n /** Template \\u2014 `{field}`. */\n required: string;\n /** Template \\u2014 `{field}`. */\n mustBeChecked: string;\n /** Template \\u2014 `{min}`. */\n minLength: string;\n /** Template \\u2014 `{max}`. */\n maxLength: string;\n /** Value does not match `field.pattern`. */\n invalidPattern: string;\n /** Value is not a valid email address. */\n invalidEmail: string;\n /** Value is not a number. */\n invalidNumber: string;\n /** Template \\u2014 `{min}`. */\n minValue: string;\n /** Template \\u2014 `{max}`. */\n maxValue: string;\n /** Template \\u2014 `{min}`. */\n minDate: string;\n /** Template \\u2014 `{max}`. */\n maxDate: string;\n /** Value is not one of `field.options`. */\n invalidOption: string;\n /** Template \\u2014 `{format}`. `field.valueFormatHint` still wins. */\n invalidFormat: string;\n}\n\n/** English defaults for {@link FormValidationMessages}. */\nexport const DEFAULT_VALIDATION_MESSAGES: FormValidationMessages = {\n required: '{field} is required',\n mustBeChecked: '{field} must be checked',\n minLength: 'Minimum {min} characters required',\n maxLength: 'Maximum {max} characters allowed',\n invalidPattern: 'Invalid format',\n invalidEmail: 'Invalid email address',\n invalidNumber: 'Must be a valid number',\n minValue: 'Minimum value is {min}',\n maxValue: 'Maximum value is {max}',\n minDate: 'Date must be after {min}',\n maxDate: 'Date must be before {max}',\n invalidOption: 'Please select a valid option',\n invalidFormat: 'Invalid format (expected: {format})',\n};\n\n/**\n * Validate a single form field value against field rules\n */\nexport function validateFieldValue(\n value: any,\n field: FormFieldParams,\n messages?: Partial<FormValidationMessages>\n): { valid: boolean; error?: string } {\n const m: FormValidationMessages = { ...DEFAULT_VALIDATION_MESSAGES, ...messages };\n const fieldName = field.label || field.name;\n\n // Required check\n if (field.required) {\n if (value === undefined || value === null || value === '') {\n return { valid: false, error: formatMCPUIString(m.required, { field: fieldName }) };\n }\n if (field.type === 'checkbox' && value !== true) {\n return { valid: false, error: formatMCPUIString(m.mustBeChecked, { field: fieldName }) };\n }\n }\n\n // Skip further validation if value is empty and not required\n if (value === undefined || value === null || value === '') {\n return { valid: true };\n }\n\n // Type-specific validation\n switch (field.type) {\n case 'text':\n case 'textarea':\n case 'password':\n if (field.minLength && String(value).length < field.minLength) {\n return {\n valid: false,\n error: formatMCPUIString(m.minLength, { min: field.minLength }),\n };\n }\n if (field.maxLength && String(value).length > field.maxLength) {\n return {\n valid: false,\n error: formatMCPUIString(m.maxLength, { max: field.maxLength }),\n };\n }\n if (field.pattern && !new RegExp(field.pattern).test(String(value))) {\n return { valid: false, error: m.invalidPattern };\n }\n break;\n\n case 'email':\n if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(String(value))) {\n return { valid: false, error: m.invalidEmail };\n }\n break;\n\n case 'number': {\n const numValue = Number(value);\n if (isNaN(numValue)) {\n return { valid: false, error: m.invalidNumber };\n }\n if (field.min !== undefined && numValue < field.min) {\n return { valid: false, error: formatMCPUIString(m.minValue, { min: field.min }) };\n }\n if (field.max !== undefined && numValue > field.max) {\n return { valid: false, error: formatMCPUIString(m.maxValue, { max: field.max }) };\n }\n break;\n }\n\n case 'date':\n if (field.minDate && value < field.minDate) {\n return { valid: false, error: formatMCPUIString(m.minDate, { min: field.minDate }) };\n }\n if (field.maxDate && value > field.maxDate) {\n return { valid: false, error: formatMCPUIString(m.maxDate, { max: field.maxDate }) };\n }\n break;\n\n case 'select':\n case 'radio':\n // Validate that value is one of the options\n if (field.options && field.options.length > 0) {\n const validValues = field.options.map((opt) => opt.value);\n if (!validValues.includes(String(value))) {\n return { valid: false, error: m.invalidOption };\n }\n }\n break;\n }\n\n // valueFormat validation (v4.3.0) — runs after type-specific checks\n if (field.valueFormat && value !== undefined && value !== null && value !== '') {\n const vals = Array.isArray(value) ? value : [String(value)];\n for (const v of vals) {\n if (!new RegExp(field.valueFormat).test(v)) {\n return {\n valid: false,\n error:\n field.valueFormatHint ||\n formatMCPUIString(m.invalidFormat, { format: field.valueFormat }),\n };\n }\n }\n }\n\n return { valid: true };\n}\n\n/**\n * Validate entire form data against field definitions\n */\nexport function validateFormData(\n data: Record<string, any>,\n fields: FormFieldParams[],\n messages?: Partial<FormValidationMessages>\n): { valid: boolean; errors: Record<string, string> } {\n const errors: Record<string, string> = {};\n\n for (const field of fields) {\n const result = validateFieldValue(data[field.name], field, messages);\n if (!result.valid && result.error) {\n errors[field.name] = result.error;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors,\n };\n}\n"],"names":["ComponentTypeSchema","MetricComponentParamsSchema","TextComponentParamsSchema","IframeComponentParamsSchema","ImageComponentParamsSchema","LinkComponentParamsSchema","ActionParamsSchema","VideoComponentParamsSchema","CarouselComponentParamsSchema","ImageGalleryParamsSchema","ActionGroupParamsSchema","CodeComponentParamsSchema","ArtifactComponentParamsSchema","FormComponentParamsSchema","MapComponentParamsSchema","GraphComponentParamsSchema","formatMCPUIString"],"mappings":";;;;AA0DA,MAAM,wBAAqC,IAAI,IAAYA,UAAAA,oBAAoB,OAAO;AAwBtF,MAAM,kBAA6F;AAAA,EACjG,QAAQ,EAAE,QAAQC,uCAA6B,YAAY,iBAAA;AAAA,EAC3D,MAAM,EAAE,QAAQC,qCAA2B,YAAY,eAAA;AAAA,EACvD,QAAQ,EAAE,QAAQC,uCAA6B,YAAY,iBAAA;AAAA,EAC3D,OAAO,EAAE,QAAQC,sCAA4B,YAAY,gBAAA;AAAA,EACzD,MAAM,EAAE,QAAQC,qCAA2B,YAAY,eAAA;AAAA,EACvD,QAAQ,EAAE,QAAQC,8BAAoB,YAAY,iBAAA;AAAA,EAClD,OAAO,EAAE,QAAQC,sCAA4B,YAAY,gBAAA;AAAA,EACzD,UAAU,EAAE,QAAQC,yCAA+B,YAAY,iBAAA;AAAA,EAC/D,iBAAiB,EAAE,QAAQC,oCAA0B,YAAY,gBAAA;AAAA,EACjE,gBAAgB,EAAE,QAAQC,mCAAyB,YAAY,qBAAA;AAAA,EAC/D,MAAM,EAAE,QAAQC,qCAA2B,YAAY,eAAA;AAAA,EACvD,UAAU,EAAE,QAAQC,yCAA+B,YAAY,mBAAA;AAAA;AAAA,EAE/D,MAAM,EAAE,QAAQC,qCAA2B,YAAY,aAAA;AAAA,EACvD,KAAK,EAAE,QAAQC,oCAA0B,YAAY,cAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrD,OAAO,EAAE,QAAQC,UAAAA,4BAA4B,YAAY,gBAAA;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MAAM;AACpB,UAAI,CAAC,IAAI,OAAO,MAAM,WAAW,EAAE,KAAK,CAAC,GAAG;AAC1C,eAAO;AAAA,UACL,OAAO;AAAA,UACP,OACE,MAAM,mBACNA,+BAAkB,EAAE,eAAe,EAAE,QAAQ,MAAM,YAAA,CAAa;AAAA,QAAA;AAAA,MAEtE;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,OAAO,KAAA;AAClB;AAKO,SAAS,iBACd,MACA,QACA,UACoD;AACpD,QAAM,SAAiC,CAAA;AAEvC,aAAW,SAAS,QAAQ;AAC1B,UAAM,SAAS,mBAAmB,KAAK,MAAM,IAAI,GAAG,OAAO,QAAQ;AACnE,QAAI,CAAC,OAAO,SAAS,OAAO,OAAO;AACjC,aAAO,MAAM,IAAI,IAAI,OAAO;AAAA,IAC9B;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,OAAO,KAAK,MAAM,EAAE,WAAW;AAAA,IACtC;AAAA,EAAA;AAEJ;;;;;;;;;;;;;;;;;"}
|
|
@@ -59,6 +59,26 @@ export declare function validateIframeDomain(url: string, options?: {
|
|
|
59
59
|
policy?: IframePolicy;
|
|
60
60
|
customDomains?: string[];
|
|
61
61
|
}): ValidationResult;
|
|
62
|
+
/**
|
|
63
|
+
* Is this URL's host a trusted iframe host?
|
|
64
|
+
*
|
|
65
|
+
* A host matches when it equals an entry of `TRUSTED_IFRAME_DOMAINS` (plus
|
|
66
|
+
* `options.customTrustedDomains`) or is a subdomain of one. Trusted hosts
|
|
67
|
+
* need their own cookies/storage to authenticate, which is why they receive
|
|
68
|
+
* `allow-same-origin` in `getIframeSandbox` and deliberately do NOT receive
|
|
69
|
+
* the `credentialless` iframe attribute (an authenticated embed loaded
|
|
70
|
+
* without its cookies only shows a login screen).
|
|
71
|
+
*
|
|
72
|
+
* An unparsable URL is never trusted.
|
|
73
|
+
*
|
|
74
|
+
* @param url - The iframe URL
|
|
75
|
+
* @param options - Optional custom trusted domains, merged over the defaults
|
|
76
|
+
* @returns `true` when the URL's host is trusted
|
|
77
|
+
* @since v6.21.0 — extracted from `getIframeSandbox`, identical matching.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isTrustedIframeDomain(url: string, options?: {
|
|
80
|
+
customTrustedDomains?: string[];
|
|
81
|
+
}): boolean;
|
|
62
82
|
/**
|
|
63
83
|
* Get the appropriate sandbox attribute for an iframe URL.
|
|
64
84
|
*
|
|
@@ -88,17 +108,62 @@ export declare function validateComponent(component: UIComponent, options?: Vali
|
|
|
88
108
|
* @param options - Optional validation options (limits, iframePolicy, customIframeDomains)
|
|
89
109
|
*/
|
|
90
110
|
export declare function validateLayout(layout: UILayout, options?: ValidationOptions): ValidationResult;
|
|
111
|
+
/**
|
|
112
|
+
* The end-user form-validation wording.
|
|
113
|
+
*
|
|
114
|
+
* `validateFieldValue` / `validateFormData` are pure and SSR-safe (they are
|
|
115
|
+
* re-exported from the `@seed-ship/mcp-ui-solid/validation` subpath), so
|
|
116
|
+
* they cannot read `MCPUIStrings`. The wording is injected instead: both
|
|
117
|
+
* take an optional trailing `messages` partial, and `FormRenderer` feeds it
|
|
118
|
+
* from `useMCPUIStrings()` (keys `fieldRequired`, `fieldMinLength`, …).
|
|
119
|
+
*
|
|
120
|
+
* The STRUCTURAL validators (`validateComponent`, `validateLayout`, …) keep
|
|
121
|
+
* their English `ValidationError.message`: those are payload diagnostics
|
|
122
|
+
* addressed to whoever produced the payload, not end-user chrome.
|
|
123
|
+
*
|
|
124
|
+
* @since v6.20.0
|
|
125
|
+
*/
|
|
126
|
+
export interface FormValidationMessages {
|
|
127
|
+
/** Template \u2014 `{field}`. */
|
|
128
|
+
required: string;
|
|
129
|
+
/** Template \u2014 `{field}`. */
|
|
130
|
+
mustBeChecked: string;
|
|
131
|
+
/** Template \u2014 `{min}`. */
|
|
132
|
+
minLength: string;
|
|
133
|
+
/** Template \u2014 `{max}`. */
|
|
134
|
+
maxLength: string;
|
|
135
|
+
/** Value does not match `field.pattern`. */
|
|
136
|
+
invalidPattern: string;
|
|
137
|
+
/** Value is not a valid email address. */
|
|
138
|
+
invalidEmail: string;
|
|
139
|
+
/** Value is not a number. */
|
|
140
|
+
invalidNumber: string;
|
|
141
|
+
/** Template \u2014 `{min}`. */
|
|
142
|
+
minValue: string;
|
|
143
|
+
/** Template \u2014 `{max}`. */
|
|
144
|
+
maxValue: string;
|
|
145
|
+
/** Template \u2014 `{min}`. */
|
|
146
|
+
minDate: string;
|
|
147
|
+
/** Template \u2014 `{max}`. */
|
|
148
|
+
maxDate: string;
|
|
149
|
+
/** Value is not one of `field.options`. */
|
|
150
|
+
invalidOption: string;
|
|
151
|
+
/** Template \u2014 `{format}`. `field.valueFormatHint` still wins. */
|
|
152
|
+
invalidFormat: string;
|
|
153
|
+
}
|
|
154
|
+
/** English defaults for {@link FormValidationMessages}. */
|
|
155
|
+
export declare const DEFAULT_VALIDATION_MESSAGES: FormValidationMessages;
|
|
91
156
|
/**
|
|
92
157
|
* Validate a single form field value against field rules
|
|
93
158
|
*/
|
|
94
|
-
export declare function validateFieldValue(value: any, field: FormFieldParams): {
|
|
159
|
+
export declare function validateFieldValue(value: any, field: FormFieldParams, messages?: Partial<FormValidationMessages>): {
|
|
95
160
|
valid: boolean;
|
|
96
161
|
error?: string;
|
|
97
162
|
};
|
|
98
163
|
/**
|
|
99
164
|
* Validate entire form data against field definitions
|
|
100
165
|
*/
|
|
101
|
-
export declare function validateFormData(data: Record<string, any>, fields: FormFieldParams[]): {
|
|
166
|
+
export declare function validateFormData(data: Record<string, any>, fields: FormFieldParams[], messages?: Partial<FormValidationMessages>): {
|
|
102
167
|
valid: boolean;
|
|
103
168
|
errors: Record<string, string>;
|
|
104
169
|
};
|