@xemahq/ui-kernel 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -21
- package/dist/index.js.map +1 -1
- package/dist/lib/biome-host/agent-validation.js +5 -9
- package/dist/lib/biome-host/agent-validation.js.map +1 -1
- package/dist/lib/biome-host/biome-builders.js +5 -9
- package/dist/lib/biome-host/biome-builders.js.map +1 -1
- package/dist/lib/biome-host/biome-mode.js +1 -2
- package/dist/lib/biome-host/biome-navigation.js +6 -10
- package/dist/lib/biome-host/biome-navigation.js.map +1 -1
- package/dist/lib/biome-host/biome-registry.d.ts.map +1 -1
- package/dist/lib/biome-host/biome-registry.js +27 -29
- package/dist/lib/biome-host/biome-registry.js.map +1 -1
- package/dist/lib/biome-host/biome-scope.js +9 -14
- package/dist/lib/biome-host/biome-scope.js.map +1 -1
- package/dist/lib/biome-host/biome-scoped-query.js +8 -13
- package/dist/lib/biome-host/biome-scoped-query.js.map +1 -1
- package/dist/lib/biome-host/create-biome-orval-config.js +1 -4
- package/dist/lib/biome-host/create-biome-orval-config.js.map +1 -1
- package/dist/lib/biome-host/define-web-biome.js +3 -6
- package/dist/lib/biome-host/define-web-biome.js.map +1 -1
- package/dist/lib/biome-host/errors.js +1 -4
- package/dist/lib/biome-host/errors.js.map +1 -1
- package/dist/lib/biome-host/frontend-biome.js +3 -6
- package/dist/lib/biome-host/frontend-biome.js.map +1 -1
- package/dist/lib/biome-host/host-bridge.js +5 -9
- package/dist/lib/biome-host/host-bridge.js.map +1 -1
- package/dist/lib/biome-host/host-sources.js +1 -2
- package/dist/lib/biome-host/i18n-hooks.js +5 -9
- package/dist/lib/biome-host/i18n-hooks.js.map +1 -1
- package/dist/lib/biome-host/i18n-port.js +1 -4
- package/dist/lib/biome-host/i18n-port.js.map +1 -1
- package/dist/lib/biome-host/index.js +22 -38
- package/dist/lib/biome-host/index.js.map +1 -1
- package/dist/lib/biome-host/realtime-hooks.js +7 -12
- package/dist/lib/biome-host/realtime-hooks.js.map +1 -1
- package/dist/lib/biome-host/realtime-port.js +1 -2
- package/dist/lib/biome-host/response-envelope.js +2 -6
- package/dist/lib/biome-host/response-envelope.js.map +1 -1
- package/dist/lib/biome-host/session-contributions.js +1 -2
- package/dist/lib/biome-host/session-profiles.js +7 -11
- package/dist/lib/biome-host/session-profiles.js.map +1 -1
- package/dist/lib/biome-host/use-mutation-with-error-toast.js +7 -10
- package/dist/lib/biome-host/use-mutation-with-error-toast.js.map +1 -1
- package/dist/lib/biome-host/use-page-state.js +16 -21
- package/dist/lib/biome-host/use-page-state.js.map +1 -1
- package/dist/lib/capabilities/capability-provider.js +11 -15
- package/dist/lib/capabilities/capability-provider.js.map +1 -1
- package/dist/lib/capabilities/index.js +3 -19
- package/dist/lib/capabilities/index.js.map +1 -1
- package/dist/lib/capabilities/types.js +1 -2
- package/dist/lib/capabilities/use-capability.js +5 -9
- package/dist/lib/capabilities/use-capability.js.map +1 -1
- package/dist/lib/contribution-registry/contribution-registry.d.ts +24 -0
- package/dist/lib/contribution-registry/contribution-registry.d.ts.map +1 -0
- package/dist/lib/contribution-registry/contribution-registry.js +67 -0
- package/dist/lib/contribution-registry/contribution-registry.js.map +1 -0
- package/dist/lib/contribution-registry/index.d.ts +3 -0
- package/dist/lib/contribution-registry/index.d.ts.map +1 -0
- package/dist/lib/contribution-registry/index.js +3 -0
- package/dist/lib/contribution-registry/index.js.map +1 -0
- package/dist/lib/contribution-registry/renderable-registry.d.ts +33 -0
- package/dist/lib/contribution-registry/renderable-registry.d.ts.map +1 -0
- package/dist/lib/contribution-registry/renderable-registry.js +51 -0
- package/dist/lib/contribution-registry/renderable-registry.js.map +1 -0
- package/dist/lib/system-bus/capability-invoke.js +1 -2
- package/dist/lib/system-bus/deeplink.js +12 -17
- package/dist/lib/system-bus/deeplink.js.map +1 -1
- package/dist/lib/system-bus/enums.js +10 -13
- package/dist/lib/system-bus/enums.js.map +1 -1
- package/dist/lib/system-bus/host-ports.js +1 -2
- package/dist/lib/system-bus/index.js +10 -26
- package/dist/lib/system-bus/index.js.map +1 -1
- package/dist/lib/system-bus/intent-registry.js +6 -10
- package/dist/lib/system-bus/intent-registry.js.map +1 -1
- package/dist/lib/system-bus/intents.js +1 -2
- package/dist/lib/system-bus/palette.js +1 -2
- package/dist/lib/system-bus/system-bus-builder.js +10 -13
- package/dist/lib/system-bus/system-bus-builder.js.map +1 -1
- package/dist/lib/system-bus/system-bus.js +1 -2
- package/dist/lib/system-bus/windows.js +1 -2
- package/dist/offline/id.js +1 -4
- package/dist/offline/id.js.map +1 -1
- package/dist/offline/index.js +8 -25
- package/dist/offline/index.js.map +1 -1
- package/dist/offline/mutation.js +5 -8
- package/dist/offline/mutation.js.map +1 -1
- package/dist/offline/offline-status-badge.js +7 -10
- package/dist/offline/offline-status-badge.js.map +1 -1
- package/dist/offline/online-controller.js +2 -7
- package/dist/offline/online-controller.js.map +1 -1
- package/dist/offline/outbox.js +22 -26
- package/dist/offline/outbox.js.map +1 -1
- package/dist/offline/react.js +15 -21
- package/dist/offline/react.js.map +1 -1
- package/dist/offline/storage.js +3 -9
- package/dist/offline/storage.js.map +1 -1
- package/dist/offline/types.js +2 -5
- package/dist/offline/types.js.map +1 -1
- package/dist/org-db/components/DbResultTable.js +7 -10
- package/dist/org-db/components/DbResultTable.js.map +1 -1
- package/dist/org-db/index.js +1 -5
- package/dist/org-db/index.js.map +1 -1
- package/dist/pdf/index.d.ts +2 -0
- package/dist/pdf/index.d.ts.map +1 -0
- package/dist/pdf/index.js +2 -0
- package/dist/pdf/index.js.map +1 -0
- package/dist/registry/index.js +8 -24
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/lib/agent-validation-host.js +5 -8
- package/dist/registry/lib/agent-validation-host.js.map +1 -1
- package/dist/registry/lib/biome-slot.js +9 -12
- package/dist/registry/lib/biome-slot.js.map +1 -1
- package/dist/registry/lib/biomes-enabled-context.js +5 -9
- package/dist/registry/lib/biomes-enabled-context.js.map +1 -1
- package/dist/registry/lib/extension-points.js +1 -4
- package/dist/registry/lib/extension-points.js.map +1 -1
- package/dist/registry/lib/primitives/SessionEventCard.js +7 -10
- package/dist/registry/lib/primitives/SessionEventCard.js.map +1 -1
- package/dist/registry/lib/primitives/SessionEventTimeline.js +9 -12
- package/dist/registry/lib/primitives/SessionEventTimeline.js.map +1 -1
- package/dist/registry/lib/primitives/SessionMutationBar.js +3 -6
- package/dist/registry/lib/primitives/SessionMutationBar.js.map +1 -1
- package/dist/registry/lib/primitives/SessionTabbedDrawer.js +11 -14
- package/dist/registry/lib/primitives/SessionTabbedDrawer.js.map +1 -1
- package/dist/registry/lib/primitives/index.js +4 -20
- package/dist/registry/lib/primitives/index.js.map +1 -1
- package/dist/registry/lib/session-context-builder.js +6 -10
- package/dist/registry/lib/session-context-builder.js.map +1 -1
- package/dist/registry/lib/session-context-provider.js +9 -14
- package/dist/registry/lib/session-context-provider.js.map +1 -1
- package/dist/registry/lib/session-selectors.js +30 -39
- package/dist/registry/lib/session-selectors.js.map +1 -1
- package/dist/session/comments/CommentRail.js +6 -9
- package/dist/session/comments/CommentRail.js.map +1 -1
- package/dist/session/index.js +3 -9
- package/dist/session/index.js.map +1 -1
- package/dist/session/lib/cn.js +4 -7
- package/dist/session/lib/cn.js.map +1 -1
- package/dist/session/shell/SessionWorkspaceShell.js +5 -8
- package/dist/session/shell/SessionWorkspaceShell.js.map +1 -1
- package/dist/session-kit/approvals/ApprovalButton.js +3 -6
- package/dist/session-kit/approvals/ApprovalButton.js.map +1 -1
- package/dist/session-kit/approvals/ApprovalCard.js +30 -33
- package/dist/session-kit/approvals/ApprovalCard.js.map +1 -1
- package/dist/session-kit/approvals/ApprovalsCenter.js +29 -32
- package/dist/session-kit/approvals/ApprovalsCenter.js.map +1 -1
- package/dist/session-kit/approvals/CapabilityApprovalStickyBar.js +12 -15
- package/dist/session-kit/approvals/CapabilityApprovalStickyBar.js.map +1 -1
- package/dist/session-kit/approvals/Obligation.js +12 -16
- package/dist/session-kit/approvals/Obligation.js.map +1 -1
- package/dist/session-kit/approvals/ScopedBody.js +34 -37
- package/dist/session-kit/approvals/ScopedBody.js.map +1 -1
- package/dist/session-kit/approvals/approval-icons.js +1 -2
- package/dist/session-kit/approvals/approval-model.js +6 -11
- package/dist/session-kit/approvals/approval-model.js.map +1 -1
- package/dist/session-kit/approvals/index.js +11 -27
- package/dist/session-kit/approvals/index.js.map +1 -1
- package/dist/session-kit/approvals/obligation-display.js +13 -16
- package/dist/session-kit/approvals/obligation-display.js.map +1 -1
- package/dist/session-kit/approvals/risk-accent.js +6 -9
- package/dist/session-kit/approvals/risk-accent.js.map +1 -1
- package/dist/session-kit/approvals/scope-icons.js +2 -5
- package/dist/session-kit/approvals/scope-icons.js.map +1 -1
- package/dist/session-kit/combobox/Combobox.js +19 -22
- package/dist/session-kit/combobox/Combobox.js.map +1 -1
- package/dist/session-kit/combobox/use-click-outside.js +4 -7
- package/dist/session-kit/combobox/use-click-outside.js.map +1 -1
- package/dist/session-kit/display/ContextHeader.js +10 -13
- package/dist/session-kit/display/ContextHeader.js.map +1 -1
- package/dist/session-kit/display/FileDiffCard.js +11 -14
- package/dist/session-kit/display/FileDiffCard.js.map +1 -1
- package/dist/session-kit/display/MD.js +14 -17
- package/dist/session-kit/display/MD.js.map +1 -1
- package/dist/session-kit/display/MessageTurn.js +20 -23
- package/dist/session-kit/display/MessageTurn.js.map +1 -1
- package/dist/session-kit/display/ThinkingPanel.js +7 -10
- package/dist/session-kit/display/ThinkingPanel.js.map +1 -1
- package/dist/session-kit/display/TodoChecklist.js +13 -16
- package/dist/session-kit/display/TodoChecklist.js.map +1 -1
- package/dist/session-kit/display/TokenMeter.js +8 -11
- package/dist/session-kit/display/TokenMeter.js.map +1 -1
- package/dist/session-kit/display/ToolStrip.js +26 -30
- package/dist/session-kit/display/ToolStrip.js.map +1 -1
- package/dist/session-kit/display/TypingDots.js +3 -6
- package/dist/session-kit/display/TypingDots.js.map +1 -1
- package/dist/session-kit/index.js +20 -36
- package/dist/session-kit/index.js.map +1 -1
- package/dist/session-kit/lib/enums.js +14 -17
- package/dist/session-kit/lib/enums.js.map +1 -1
- package/dist/session-kit/lib/portal-accent.js +1 -4
- package/dist/session-kit/lib/portal-accent.js.map +1 -1
- package/dist/session-kit/lib/status-dot.js +19 -24
- package/dist/session-kit/lib/status-dot.js.map +1 -1
- package/dist/session-kit/primitives/Avatar.js +3 -6
- package/dist/session-kit/primitives/Avatar.js.map +1 -1
- package/dist/session-kit/primitives/PortalGlyph.js +8 -11
- package/dist/session-kit/primitives/PortalGlyph.js.map +1 -1
- package/dist/session-kit/primitives/RiskPill.js +10 -14
- package/dist/session-kit/primitives/RiskPill.js.map +1 -1
- package/dist/session-kit/primitives/ScopeDot.js +7 -10
- package/dist/session-kit/primitives/ScopeDot.js.map +1 -1
- package/dist/session-kit/primitives/Segmented.js +4 -7
- package/dist/session-kit/primitives/Segmented.js.map +1 -1
- package/dist/ui/branding/app-branding-provider.js +13 -51
- package/dist/ui/branding/app-branding-provider.js.map +1 -1
- package/dist/ui/branding/sanitize.js +3 -8
- package/dist/ui/branding/sanitize.js.map +1 -1
- package/dist/ui/breakpoints.js +1 -4
- package/dist/ui/breakpoints.js.map +1 -1
- package/dist/ui/capture/document-preview.js +16 -19
- package/dist/ui/capture/document-preview.js.map +1 -1
- package/dist/ui/capture/field-spec-to-zod.d.ts +1 -0
- package/dist/ui/capture/field-spec-to-zod.d.ts.map +1 -1
- package/dist/ui/capture/field-spec-to-zod.js +51 -36
- package/dist/ui/capture/field-spec-to-zod.js.map +1 -1
- package/dist/ui/capture/field-spec-validate.d.ts +4 -0
- package/dist/ui/capture/field-spec-validate.d.ts.map +1 -0
- package/dist/ui/capture/field-spec-validate.js +129 -0
- package/dist/ui/capture/field-spec-validate.js.map +1 -0
- package/dist/ui/capture/field-spec.d.ts +13 -1
- package/dist/ui/capture/field-spec.d.ts.map +1 -1
- package/dist/ui/capture/field-spec.js +31 -13
- package/dist/ui/capture/field-spec.js.map +1 -1
- package/dist/ui/capture/index.d.ts +4 -2
- package/dist/ui/capture/index.d.ts.map +1 -1
- package/dist/ui/capture/index.js +12 -30
- package/dist/ui/capture/index.js.map +1 -1
- package/dist/ui/capture/schema-field-input.d.ts.map +1 -1
- package/dist/ui/capture/schema-field-input.js +82 -58
- package/dist/ui/capture/schema-field-input.js.map +1 -1
- package/dist/ui/capture/schema-form.js +11 -14
- package/dist/ui/capture/schema-form.js.map +1 -1
- package/dist/ui/capture/submit-values.d.ts +6 -0
- package/dist/ui/capture/submit-values.d.ts.map +1 -0
- package/dist/ui/capture/submit-values.js +28 -0
- package/dist/ui/capture/submit-values.js.map +1 -0
- package/dist/ui/capture/use-prefill.js +13 -16
- package/dist/ui/capture/use-prefill.js.map +1 -1
- package/dist/ui/capture/use-schema-validation.js +13 -16
- package/dist/ui/capture/use-schema-validation.js.map +1 -1
- package/dist/ui/capture/use-wizard.js +15 -18
- package/dist/ui/capture/use-wizard.js.map +1 -1
- package/dist/ui/capture/value-format.js +4 -8
- package/dist/ui/capture/value-format.js.map +1 -1
- package/dist/ui/capture/wizard.js +10 -14
- package/dist/ui/capture/wizard.js.map +1 -1
- package/dist/ui/charts/bar-chart.js +14 -17
- package/dist/ui/charts/bar-chart.js.map +1 -1
- package/dist/ui/charts/chart-frame.js +11 -16
- package/dist/ui/charts/chart-frame.js.map +1 -1
- package/dist/ui/charts/chart-types.js +1 -2
- package/dist/ui/charts/chart-utils.js +7 -15
- package/dist/ui/charts/chart-utils.js.map +1 -1
- package/dist/ui/charts/donut-chart.js +11 -14
- package/dist/ui/charts/donut-chart.js.map +1 -1
- package/dist/ui/charts/index.js +6 -20
- package/dist/ui/charts/index.js.map +1 -1
- package/dist/ui/charts/line-chart.js +15 -18
- package/dist/ui/charts/line-chart.js.map +1 -1
- package/dist/ui/charts/sparkline.js +9 -12
- package/dist/ui/charts/sparkline.js.map +1 -1
- package/dist/ui/chrome/AsyncBoundary.js +9 -15
- package/dist/ui/chrome/AsyncBoundary.js.map +1 -1
- package/dist/ui/chrome/EmptyState.js +9 -12
- package/dist/ui/chrome/EmptyState.js.map +1 -1
- package/dist/ui/chrome/ErrorCard.js +8 -11
- package/dist/ui/chrome/ErrorCard.js.map +1 -1
- package/dist/ui/chrome/LoadingState.js +8 -11
- package/dist/ui/chrome/LoadingState.js.map +1 -1
- package/dist/ui/chrome/PageHeader.js +10 -14
- package/dist/ui/chrome/PageHeader.js.map +1 -1
- package/dist/ui/chrome/StateCard.js +7 -11
- package/dist/ui/chrome/StateCard.js.map +1 -1
- package/dist/ui/chrome/confirm-delete-dialog.js +5 -8
- package/dist/ui/chrome/confirm-delete-dialog.js.map +1 -1
- package/dist/ui/chrome/page-shell.js +9 -15
- package/dist/ui/chrome/page-shell.js.map +1 -1
- package/dist/ui/chrome/scope-badge.js +5 -8
- package/dist/ui/chrome/scope-badge.js.map +1 -1
- package/dist/ui/chrome/status-badge.js +7 -10
- package/dist/ui/chrome/status-badge.js.map +1 -1
- package/dist/ui/cn.js +5 -8
- package/dist/ui/cn.js.map +1 -1
- package/dist/ui/design-tokens.js +21 -28
- package/dist/ui/design-tokens.js.map +1 -1
- package/dist/ui/hooks/use-debounced-value.js +4 -7
- package/dist/ui/hooks/use-debounced-value.js.map +1 -1
- package/dist/ui/hooks/use-is-mobile.js +8 -11
- package/dist/ui/hooks/use-is-mobile.js.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +47 -87
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/pdf/pdf-preview.js +17 -20
- package/dist/ui/pdf/pdf-preview.js.map +1 -1
- package/dist/ui/primitives/alert-dialog.js +14 -60
- package/dist/ui/primitives/alert-dialog.js.map +1 -1
- package/dist/ui/primitives/async-combobox.js +18 -21
- package/dist/ui/primitives/async-combobox.js.map +1 -1
- package/dist/ui/primitives/badge.js +7 -44
- package/dist/ui/primitives/badge.js.map +1 -1
- package/dist/ui/primitives/button.js +9 -46
- package/dist/ui/primitives/button.js.map +1 -1
- package/dist/ui/primitives/card.js +10 -51
- package/dist/ui/primitives/card.js.map +1 -1
- package/dist/ui/primitives/checkbox.js +7 -43
- package/dist/ui/primitives/checkbox.js.map +1 -1
- package/dist/ui/primitives/collapsible.js +2 -40
- package/dist/ui/primitives/collapsible.js.map +1 -1
- package/dist/ui/primitives/dialog.js +12 -57
- package/dist/ui/primitives/dialog.js.map +1 -1
- package/dist/ui/primitives/dropdown-menu.js +15 -65
- package/dist/ui/primitives/dropdown-menu.js.map +1 -1
- package/dist/ui/primitives/form-stepper.js +8 -12
- package/dist/ui/primitives/form-stepper.js.map +1 -1
- package/dist/ui/primitives/input.js +5 -41
- package/dist/ui/primitives/input.js.map +1 -1
- package/dist/ui/primitives/label.js +8 -44
- package/dist/ui/primitives/label.js.map +1 -1
- package/dist/ui/primitives/overflow-tabs.d.ts +5 -0
- package/dist/ui/primitives/overflow-tabs.d.ts.map +1 -1
- package/dist/ui/primitives/overflow-tabs.js +19 -22
- package/dist/ui/primitives/overflow-tabs.js.map +1 -1
- package/dist/ui/primitives/popover.js +6 -44
- package/dist/ui/primitives/popover.js.map +1 -1
- package/dist/ui/primitives/preview-device-frame.js +16 -19
- package/dist/ui/primitives/preview-device-frame.js.map +1 -1
- package/dist/ui/primitives/radio-group.js +8 -45
- package/dist/ui/primitives/radio-group.js.map +1 -1
- package/dist/ui/primitives/resizable.js +11 -16
- package/dist/ui/primitives/resizable.js.map +1 -1
- package/dist/ui/primitives/scroll-area.js +7 -44
- package/dist/ui/primitives/scroll-area.js.map +1 -1
- package/dist/ui/primitives/select.js +15 -60
- package/dist/ui/primitives/select.js.map +1 -1
- package/dist/ui/primitives/separator.js +6 -42
- package/dist/ui/primitives/separator.js.map +1 -1
- package/dist/ui/primitives/sheet.js +14 -59
- package/dist/ui/primitives/sheet.js.map +1 -1
- package/dist/ui/primitives/skeleton.js +5 -7
- package/dist/ui/primitives/skeleton.js.map +1 -1
- package/dist/ui/primitives/switch.js +6 -42
- package/dist/ui/primitives/switch.js.map +1 -1
- package/dist/ui/primitives/table.js +12 -55
- package/dist/ui/primitives/table.js.map +1 -1
- package/dist/ui/primitives/tabs.js +8 -47
- package/dist/ui/primitives/tabs.js.map +1 -1
- package/dist/ui/primitives/tag-multi-select.js +24 -27
- package/dist/ui/primitives/tag-multi-select.js.map +1 -1
- package/dist/ui/primitives/textarea.js +5 -41
- package/dist/ui/primitives/textarea.js.map +1 -1
- package/dist/ui/primitives/tooltip.js +6 -45
- package/dist/ui/primitives/tooltip.js.map +1 -1
- package/dist/ui/primitives/url-preview-chrome.d.ts +8 -0
- package/dist/ui/primitives/url-preview-chrome.d.ts.map +1 -0
- package/dist/ui/primitives/url-preview-chrome.js +40 -0
- package/dist/ui/primitives/url-preview-chrome.js.map +1 -0
- package/dist/vista/GenericCatalogueSurface.d.ts +10 -0
- package/dist/vista/GenericCatalogueSurface.d.ts.map +1 -0
- package/dist/vista/GenericCatalogueSurface.js +80 -0
- package/dist/vista/GenericCatalogueSurface.js.map +1 -0
- package/dist/vista/SurfaceFallbackCard.d.ts +9 -0
- package/dist/vista/SurfaceFallbackCard.d.ts.map +1 -0
- package/dist/vista/SurfaceFallbackCard.js +44 -0
- package/dist/vista/SurfaceFallbackCard.js.map +1 -0
- package/dist/vista/VistaPanel.d.ts +21 -0
- package/dist/vista/VistaPanel.d.ts.map +1 -0
- package/dist/vista/VistaPanel.js +31 -0
- package/dist/vista/VistaPanel.js.map +1 -0
- package/dist/vista/html/CustomUiFrame.d.ts +20 -0
- package/dist/vista/html/CustomUiFrame.d.ts.map +1 -0
- package/dist/vista/html/CustomUiFrame.js +69 -0
- package/dist/vista/html/CustomUiFrame.js.map +1 -0
- package/dist/vista/html/custom-ui-frame-bridge.d.ts +13 -0
- package/dist/vista/html/custom-ui-frame-bridge.d.ts.map +1 -0
- package/dist/vista/html/custom-ui-frame-bridge.js +30 -0
- package/dist/vista/html/custom-ui-frame-bridge.js.map +1 -0
- package/dist/vista/html/custom-ui-frame-contract.d.ts +29 -0
- package/dist/vista/html/custom-ui-frame-contract.d.ts.map +1 -0
- package/dist/vista/html/custom-ui-frame-contract.js +16 -0
- package/dist/vista/html/custom-ui-frame-contract.js.map +1 -0
- package/dist/vista/html/custom-ui-intents.d.ts +20 -0
- package/dist/vista/html/custom-ui-intents.d.ts.map +1 -0
- package/dist/vista/html/custom-ui-intents.js +57 -0
- package/dist/vista/html/custom-ui-intents.js.map +1 -0
- package/dist/vista/html/custom-ui-srcdoc.d.ts +17 -0
- package/dist/vista/html/custom-ui-srcdoc.d.ts.map +1 -0
- package/dist/vista/html/custom-ui-srcdoc.js +70 -0
- package/dist/vista/html/custom-ui-srcdoc.js.map +1 -0
- package/dist/vista/html/index.d.ts +6 -0
- package/dist/vista/html/index.d.ts.map +1 -0
- package/dist/vista/html/index.js +6 -0
- package/dist/vista/html/index.js.map +1 -0
- package/dist/vista/index.d.ts +18 -0
- package/dist/vista/index.d.ts.map +1 -0
- package/dist/vista/index.js +18 -0
- package/dist/vista/index.js.map +1 -0
- package/dist/vista/surface-catalogue.d.ts +5 -0
- package/dist/vista/surface-catalogue.d.ts.map +1 -0
- package/dist/vista/surface-catalogue.js +30 -0
- package/dist/vista/surface-catalogue.js.map +1 -0
- package/dist/vista/surface-icons.d.ts +7 -0
- package/dist/vista/surface-icons.d.ts.map +1 -0
- package/dist/vista/surface-icons.js +26 -0
- package/dist/vista/surface-icons.js.map +1 -0
- package/dist/vista/surface-registry.d.ts +7 -0
- package/dist/vista/surface-registry.d.ts.map +1 -0
- package/dist/vista/surface-registry.js +7 -0
- package/dist/vista/surface-registry.js.map +1 -0
- package/dist/vista/surfaces/ChartSurface.d.ts +4 -0
- package/dist/vista/surfaces/ChartSurface.d.ts.map +1 -0
- package/dist/vista/surfaces/ChartSurface.js +17 -0
- package/dist/vista/surfaces/ChartSurface.js.map +1 -0
- package/dist/vista/surfaces/FilesSurface.d.ts +15 -0
- package/dist/vista/surfaces/FilesSurface.d.ts.map +1 -0
- package/dist/vista/surfaces/FilesSurface.js +121 -0
- package/dist/vista/surfaces/FilesSurface.js.map +1 -0
- package/dist/vista/surfaces/FormSurface.d.ts +4 -0
- package/dist/vista/surfaces/FormSurface.d.ts.map +1 -0
- package/dist/vista/surfaces/FormSurface.js +97 -0
- package/dist/vista/surfaces/FormSurface.js.map +1 -0
- package/dist/vista/surfaces/HtmlSurface.d.ts +4 -0
- package/dist/vista/surfaces/HtmlSurface.d.ts.map +1 -0
- package/dist/vista/surfaces/HtmlSurface.js +11 -0
- package/dist/vista/surfaces/HtmlSurface.js.map +1 -0
- package/dist/vista/surfaces/TableSurface.d.ts +4 -0
- package/dist/vista/surfaces/TableSurface.d.ts.map +1 -0
- package/dist/vista/surfaces/TableSurface.js +42 -0
- package/dist/vista/surfaces/TableSurface.js.map +1 -0
- package/dist/vista/surfaces/UrlSurface.d.ts +4 -0
- package/dist/vista/surfaces/UrlSurface.d.ts.map +1 -0
- package/dist/vista/surfaces/UrlSurface.js +7 -0
- package/dist/vista/surfaces/UrlSurface.js.map +1 -0
- package/dist/vista/surfaces/blob-surfaces.d.ts +6 -0
- package/dist/vista/surfaces/blob-surfaces.d.ts.map +1 -0
- package/dist/vista/surfaces/blob-surfaces.js +38 -0
- package/dist/vista/surfaces/blob-surfaces.js.map +1 -0
- package/dist/vista/surfaces/elicitation-transport.d.ts +18 -0
- package/dist/vista/surfaces/elicitation-transport.d.ts.map +1 -0
- package/dist/vista/surfaces/elicitation-transport.js +100 -0
- package/dist/vista/surfaces/elicitation-transport.js.map +1 -0
- package/dist/vista/surfaces/index.d.ts +11 -0
- package/dist/vista/surfaces/index.d.ts.map +1 -0
- package/dist/vista/surfaces/index.js +89 -0
- package/dist/vista/surfaces/index.js.map +1 -0
- package/dist/vista/surfaces/text-surfaces.d.ts +8 -0
- package/dist/vista/surfaces/text-surfaces.d.ts.map +1 -0
- package/dist/vista/surfaces/text-surfaces.js +54 -0
- package/dist/vista/surfaces/text-surfaces.js.map +1 -0
- package/dist/vista/use-vista-tabs.d.ts +30 -0
- package/dist/vista/use-vista-tabs.d.ts.map +1 -0
- package/dist/vista/use-vista-tabs.js +77 -0
- package/dist/vista/use-vista-tabs.js.map +1 -0
- package/dist/vista/vista-code-renderer.d.ts +12 -0
- package/dist/vista/vista-code-renderer.d.ts.map +1 -0
- package/dist/vista/vista-code-renderer.js +10 -0
- package/dist/vista/vista-code-renderer.js.map +1 -0
- package/dist/vista/vista-file-source.d.ts +20 -0
- package/dist/vista/vista-file-source.d.ts.map +1 -0
- package/dist/vista/vista-file-source.js +69 -0
- package/dist/vista/vista-file-source.js.map +1 -0
- package/dist/vista/vista-form-host.d.ts +16 -0
- package/dist/vista/vista-form-host.d.ts.map +1 -0
- package/dist/vista/vista-form-host.js +10 -0
- package/dist/vista/vista-form-host.js.map +1 -0
- package/dist/vista/vista-model.d.ts +12 -0
- package/dist/vista/vista-model.d.ts.map +1 -0
- package/dist/vista/vista-model.js +72 -0
- package/dist/vista/vista-model.js.map +1 -0
- package/dist/vista/vista-open-context.d.ts +9 -0
- package/dist/vista/vista-open-context.d.ts.map +1 -0
- package/dist/vista/vista-open-context.js +10 -0
- package/dist/vista/vista-open-context.js.map +1 -0
- package/dist/vista/vista-payloads.d.ts +107 -0
- package/dist/vista/vista-payloads.d.ts.map +1 -0
- package/dist/vista/vista-payloads.js +305 -0
- package/dist/vista/vista-payloads.js.map +1 -0
- package/dist/vista/vista-tabs-manifest.d.ts +17 -0
- package/dist/vista/vista-tabs-manifest.d.ts.map +1 -0
- package/dist/vista/vista-tabs-manifest.js +60 -0
- package/dist/vista/vista-tabs-manifest.js.map +1 -0
- package/dist/vista/vista-tools.d.ts +41 -0
- package/dist/vista/vista-tools.d.ts.map +1 -0
- package/dist/vista/vista-tools.js +113 -0
- package/dist/vista/vista-tools.js.map +1 -0
- package/package.json +10 -3
- package/src/index.ts +5 -0
- package/src/lib/biome-host/biome-registry.ts +31 -11
- package/src/lib/contribution-registry/contribution-registry.spec.ts +141 -0
- package/src/lib/contribution-registry/contribution-registry.ts +202 -0
- package/src/lib/contribution-registry/index.ts +9 -0
- package/src/lib/contribution-registry/renderable-registry.ts +142 -0
- package/src/pdf/index.ts +11 -0
- package/src/ui/capture/field-spec-to-zod.ts +22 -0
- package/src/ui/capture/field-spec-validate.ts +147 -0
- package/src/ui/capture/field-spec.ts +62 -0
- package/src/ui/capture/index.ts +9 -1
- package/src/ui/capture/schema-field-input.tsx +134 -14
- package/src/ui/capture/submit-values.test.ts +70 -0
- package/src/ui/capture/submit-values.ts +63 -0
- package/src/ui/index.ts +8 -1
- package/src/ui/primitives/overflow-tabs.tsx +24 -4
- package/src/ui/primitives/url-preview-chrome.tsx +102 -0
- package/src/vista/GenericCatalogueSurface.tsx +177 -0
- package/src/vista/SurfaceFallbackCard.tsx +109 -0
- package/src/vista/VistaPanel.tsx +155 -0
- package/src/vista/form-payload.spec.ts +93 -0
- package/src/vista/html/CustomUiFrame.spec.tsx +125 -0
- package/src/vista/html/CustomUiFrame.tsx +204 -0
- package/src/vista/html/custom-ui-frame-bridge.spec.ts +191 -0
- package/src/vista/html/custom-ui-frame-bridge.ts +92 -0
- package/src/vista/html/custom-ui-frame-contract.ts +88 -0
- package/src/vista/html/custom-ui-intents.spec.ts +133 -0
- package/src/vista/html/custom-ui-intents.ts +151 -0
- package/src/vista/html/custom-ui-srcdoc.spec.ts +151 -0
- package/src/vista/html/custom-ui-srcdoc.ts +193 -0
- package/src/vista/html/index.ts +13 -0
- package/src/vista/index.ts +48 -0
- package/src/vista/surface-catalogue.spec.ts +140 -0
- package/src/vista/surface-catalogue.ts +84 -0
- package/src/vista/surface-icons.ts +57 -0
- package/src/vista/surface-registry.ts +56 -0
- package/src/vista/surfaces/ChartSurface.tsx +34 -0
- package/src/vista/surfaces/FilesSurface.tsx +268 -0
- package/src/vista/surfaces/FormSurface.tsx +264 -0
- package/src/vista/surfaces/HtmlSurface.tsx +43 -0
- package/src/vista/surfaces/TableSurface.tsx +99 -0
- package/src/vista/surfaces/UrlSurface.tsx +40 -0
- package/src/vista/surfaces/blob-surfaces.tsx +129 -0
- package/src/vista/surfaces/elicitation-transport.spec.ts +187 -0
- package/src/vista/surfaces/elicitation-transport.ts +175 -0
- package/src/vista/surfaces/index.tsx +157 -0
- package/src/vista/surfaces/text-surfaces.tsx +119 -0
- package/src/vista/use-vista-tabs.ts +188 -0
- package/src/vista/vista-code-renderer.tsx +46 -0
- package/src/vista/vista-file-source.tsx +163 -0
- package/src/vista/vista-form-host.tsx +78 -0
- package/src/vista/vista-model.ts +130 -0
- package/src/vista/vista-open-context.tsx +42 -0
- package/src/vista/vista-payloads.ts +514 -0
- package/src/vista/vista-tabs-manifest.ts +123 -0
- package/src/vista/vista-tools.ts +220 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guards `validateFormPayload` — the structural half of "the value never
|
|
3
|
+
* reaches the agent".
|
|
4
|
+
*
|
|
5
|
+
* The validator is what makes the submit target un-aimable at the host's own
|
|
6
|
+
* origin (where the BFF / chat transport lives): only an ABSOLUTE `http(s)`
|
|
7
|
+
* URL is accepted, and a rejected payload draws the typed fallback card rather
|
|
8
|
+
* than a form.
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, it } from 'vitest';
|
|
11
|
+
|
|
12
|
+
import { CaptureFieldType } from '../ui/capture/field-spec';
|
|
13
|
+
|
|
14
|
+
import { validateFormPayload } from './vista-payloads';
|
|
15
|
+
|
|
16
|
+
const BASE = {
|
|
17
|
+
ref: 'ref-1',
|
|
18
|
+
purpose: 'Connect Acme so I can read your tickets.',
|
|
19
|
+
submitUrl: 'https://connector-gateway.example.test/credential-elicitations/ref-1/submit',
|
|
20
|
+
statusUrl: 'https://connector-gateway.example.test/credential-elicitations/ref-1',
|
|
21
|
+
fields: [
|
|
22
|
+
{
|
|
23
|
+
key: 'apiKey',
|
|
24
|
+
label: 'API key',
|
|
25
|
+
type: CaptureFieldType.String,
|
|
26
|
+
required: true,
|
|
27
|
+
isSecret: true,
|
|
28
|
+
transform: 'trim',
|
|
29
|
+
},
|
|
30
|
+
{ key: 'baseUrl', label: 'Base URL', type: CaptureFieldType.Url, required: true, isSecret: false },
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
describe('validateFormPayload', () => {
|
|
35
|
+
it('accepts a well-formed field-mode payload and preserves declared secrecy', () => {
|
|
36
|
+
const payload = validateFormPayload(BASE);
|
|
37
|
+
expect(payload).not.toBeNull();
|
|
38
|
+
expect(payload?.fields).toHaveLength(2);
|
|
39
|
+
expect(payload?.fields[0]?.isSecret).toBe(true);
|
|
40
|
+
expect(payload?.fields[1]?.isSecret).toBe(false);
|
|
41
|
+
expect(payload?.fields[0]?.transform).toBe('trim');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('REJECTS a host-relative submit URL — it could only hit the app itself', () => {
|
|
45
|
+
expect(validateFormPayload({ ...BASE, submitUrl: '/credential-elicitations/ref-1/submit' })).toBeNull();
|
|
46
|
+
expect(validateFormPayload({ ...BASE, submitUrl: '//evil.example/x' })).toBeNull();
|
|
47
|
+
expect(validateFormPayload({ ...BASE, submitUrl: 'javascript:alert(1)' })).toBeNull();
|
|
48
|
+
expect(validateFormPayload({ ...BASE, statusUrl: '/credential-elicitations/ref-1' })).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('accepts an EMPTY field schema — the service is the authority, not the client', () => {
|
|
52
|
+
const payload = validateFormPayload({ ...BASE, fields: [] });
|
|
53
|
+
expect(payload).not.toBeNull();
|
|
54
|
+
expect(payload?.fields).toEqual([]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('rejects a malformed field spec rather than half-rendering it', () => {
|
|
58
|
+
expect(validateFormPayload({ ...BASE, fields: [{ key: 'a', label: 'A', type: 'nope' }] })).toBeNull();
|
|
59
|
+
expect(validateFormPayload({ ...BASE, fields: [{ key: 'a', label: 'A' }] })).toBeNull();
|
|
60
|
+
expect(
|
|
61
|
+
validateFormPayload({
|
|
62
|
+
...BASE,
|
|
63
|
+
fields: [{ key: 'a', label: 'A', type: CaptureFieldType.String, isSecret: 'yes' }],
|
|
64
|
+
}),
|
|
65
|
+
).toBeNull();
|
|
66
|
+
expect(validateFormPayload({ ...BASE, fields: {} })).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('accepts a launch (oauth2 / app_install) payload with an absolute URL', () => {
|
|
70
|
+
const payload = validateFormPayload({
|
|
71
|
+
...BASE,
|
|
72
|
+
fields: [],
|
|
73
|
+
launch: { url: 'https://acme.example.test/oauth/authorize?x=1', label: 'Continue to Acme', hint: 'h' },
|
|
74
|
+
});
|
|
75
|
+
expect(payload?.launch).toEqual({
|
|
76
|
+
url: 'https://acme.example.test/oauth/authorize?x=1',
|
|
77
|
+
label: 'Continue to Acme',
|
|
78
|
+
hint: 'h',
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('rejects a launch with a relative URL or no label', () => {
|
|
83
|
+
expect(validateFormPayload({ ...BASE, launch: { url: '/authorize', label: 'Go' } })).toBeNull();
|
|
84
|
+
expect(
|
|
85
|
+
validateFormPayload({ ...BASE, launch: { url: 'https://acme.example.test/a', label: '' } }),
|
|
86
|
+
).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('rejects a missing ref', () => {
|
|
90
|
+
expect(validateFormPayload({ ...BASE, ref: '' })).toBeNull();
|
|
91
|
+
expect(validateFormPayload({ ...BASE, ref: undefined })).toBeNull();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CustomUiFrame — the executes-author-code security surface.
|
|
3
|
+
*
|
|
4
|
+
* Asserts the opaque-origin posture on the rendered iframe: sandbox is
|
|
5
|
+
* `allow-scripts` with NO `allow-same-origin`, the srcdoc pins the server SRI
|
|
6
|
+
* hash as the CSP script-src, and the chunk bytes are the inline module script.
|
|
7
|
+
* The static-document form is asserted too: same containment, `script-src
|
|
8
|
+
* 'none'`, so an authored `<script>` can never run.
|
|
9
|
+
*
|
|
10
|
+
* The final block MUTATION-tests the sandbox invariant IN ISOLATION: it proves
|
|
11
|
+
* the suite goes RED if `allow-same-origin` is ever added to the sandbox token
|
|
12
|
+
* (which would dissolve the origin boundary), independent of the CSP-hash
|
|
13
|
+
* mutation proof in `custom-ui-srcdoc.spec.ts`.
|
|
14
|
+
*
|
|
15
|
+
* Migrated from `app-forge-web` when the frame was promoted into the UI kernel;
|
|
16
|
+
* runs under the host-web vitest mirror (this package carries no vitest dep).
|
|
17
|
+
*/
|
|
18
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
19
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
createNavigateIntentSet,
|
|
23
|
+
CustomUiIntentKind,
|
|
24
|
+
NO_CUSTOM_UI_INTENTS,
|
|
25
|
+
} from './custom-ui-intents';
|
|
26
|
+
import { CustomUiFrame } from './CustomUiFrame';
|
|
27
|
+
|
|
28
|
+
const INTEGRITY = 'sha384-AbC123def456Ghi789jklMnoPqr';
|
|
29
|
+
const COMPILED = 'export default function C(){return null}';
|
|
30
|
+
// The style import is a HOST concern (the kernel defaults to its own reset) —
|
|
31
|
+
// this test is about the security surface, so it pins a trivial stylesheet.
|
|
32
|
+
const STYLE_CSS = ':root{--x:1}';
|
|
33
|
+
|
|
34
|
+
function parseIframe(markup: string): Element {
|
|
35
|
+
const doc = new DOMParser().parseFromString(markup, 'text/html');
|
|
36
|
+
const iframe = doc.querySelector('iframe');
|
|
37
|
+
if (!iframe) throw new Error('no iframe rendered');
|
|
38
|
+
return iframe;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function renderFrame() {
|
|
42
|
+
return parseIframe(
|
|
43
|
+
renderToStaticMarkup(
|
|
44
|
+
<CustomUiFrame
|
|
45
|
+
content={{ compiledOutput: COMPILED, integrity: INTEGRITY }}
|
|
46
|
+
componentProps={{ records: [] }}
|
|
47
|
+
intents={createNavigateIntentSet({
|
|
48
|
+
[CustomUiIntentKind.Navigate]: vi.fn(),
|
|
49
|
+
})}
|
|
50
|
+
styleCss={STYLE_CSS}
|
|
51
|
+
title="Test custom view"
|
|
52
|
+
/>,
|
|
53
|
+
),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function renderDocumentFrame(document: string) {
|
|
58
|
+
return parseIframe(
|
|
59
|
+
renderToStaticMarkup(
|
|
60
|
+
<CustomUiFrame
|
|
61
|
+
content={{ document }}
|
|
62
|
+
intents={NO_CUSTOM_UI_INTENTS}
|
|
63
|
+
styleCss={STYLE_CSS}
|
|
64
|
+
title="Test static document"
|
|
65
|
+
/>,
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
describe('CustomUiFrame security posture', () => {
|
|
71
|
+
it('renders an opaque-origin sandbox: allow-scripts, NO allow-same-origin', () => {
|
|
72
|
+
const iframe = renderFrame();
|
|
73
|
+
expect(iframe.getAttribute('sandbox')).toBe('allow-scripts');
|
|
74
|
+
expect(iframe.getAttribute('sandbox')).not.toContain('allow-same-origin');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('pins the server integrity as the CSP script-src in the srcdoc', () => {
|
|
78
|
+
const srcdoc = renderFrame().getAttribute('srcdoc') ?? '';
|
|
79
|
+
expect(srcdoc).toContain(`script-src '${INTEGRITY}'`);
|
|
80
|
+
expect(srcdoc).toContain(`default-src 'none'`);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('inlines the chunk bytes as the one module script', () => {
|
|
84
|
+
const srcdoc = renderFrame().getAttribute('srcdoc') ?? '';
|
|
85
|
+
expect(srcdoc).toContain(`<script type="module">${COMPILED}</script>`);
|
|
86
|
+
expect(srcdoc).toContain('<div id="root"></div>');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// ── MUTATION TEST (sandbox invariant, isolated) ────────────────────────────
|
|
90
|
+
// Prove the assertion is load-bearing: if the component were changed to
|
|
91
|
+
// `sandbox="allow-scripts allow-same-origin"`, THIS exact assertion fails.
|
|
92
|
+
it('MUTATION: adding allow-same-origin to the sandbox token is caught', () => {
|
|
93
|
+
const sandbox = renderFrame().getAttribute('sandbox') ?? '';
|
|
94
|
+
// Exact-match pin: any extra token (e.g. allow-same-origin) breaks equality.
|
|
95
|
+
expect(sandbox).toBe('allow-scripts');
|
|
96
|
+
// And the explicit negative guard the mutation would trip.
|
|
97
|
+
const mutated = 'allow-scripts allow-same-origin';
|
|
98
|
+
expect(sandbox).not.toBe(mutated);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('CustomUiFrame static-document form', () => {
|
|
103
|
+
it("renders an untrusted document with script-src 'none' in the same sandbox", () => {
|
|
104
|
+
const iframe = renderDocumentFrame('<h1>Report</h1>');
|
|
105
|
+
expect(iframe.getAttribute('sandbox')).toBe('allow-scripts');
|
|
106
|
+
const srcdoc = iframe.getAttribute('srcdoc') ?? '';
|
|
107
|
+
expect(srcdoc).toContain(`script-src 'none'`);
|
|
108
|
+
expect(srcdoc).toContain(`default-src 'none'`);
|
|
109
|
+
expect(srcdoc).toContain('<h1>Report</h1>');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('renders a visible notice (no iframe) when the document cannot be built safely', () => {
|
|
113
|
+
const markup = renderToStaticMarkup(
|
|
114
|
+
<CustomUiFrame
|
|
115
|
+
content={{ document: '<p>x</p></script><script>alert(1)</script>' }}
|
|
116
|
+
intents={NO_CUSTOM_UI_INTENTS}
|
|
117
|
+
styleCss={STYLE_CSS}
|
|
118
|
+
title="Unsafe document"
|
|
119
|
+
/>,
|
|
120
|
+
);
|
|
121
|
+
expect(markup).toContain('role="alert"');
|
|
122
|
+
expect(markup).toContain('could not be prepared safely');
|
|
123
|
+
expect(markup).not.toContain('<iframe');
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `CustomUiFrame` — the reusable, security-hardened renderer for untrusted UI.
|
|
3
|
+
* It runs author-/agent-authored content inside an OPAQUE-ORIGIN sandbox iframe
|
|
4
|
+
* and bridges it to the host over the frozen `postMessage` contract.
|
|
5
|
+
*
|
|
6
|
+
* Promoted from `app-forge-web` into the UI kernel (Canopy §8.3) so App Forge's
|
|
7
|
+
* runtime views and the Vista `html` surface share ONE hardened frame. The
|
|
8
|
+
* intent set is now supplied by the mounting surface
|
|
9
|
+
* ({@link CustomUiIntentSet}); everything below is carried over verbatim.
|
|
10
|
+
*
|
|
11
|
+
* Security posture (NON-NEGOTIABLE — this renders untrusted content):
|
|
12
|
+
* • sandbox="allow-scripts" and NO allow-same-origin → the frame runs in a
|
|
13
|
+
* unique opaque origin and cannot reach host DOM, cookies, localStorage or
|
|
14
|
+
* tokens.
|
|
15
|
+
* • srcdoc with a `<meta>` CSP that pins the chunk's server SRI hash as the
|
|
16
|
+
* sole script-src (or `'none'` for a static document) and sets default-src
|
|
17
|
+
* 'none' → no network, only the exact pinned bytes execute. See
|
|
18
|
+
* {@link buildCustomUiSrcDoc} / {@link buildUntrustedHtmlSrcDoc}.
|
|
19
|
+
* • Every inbound message is validated by {@link classifyFrameMessage}
|
|
20
|
+
* (source-window identity + protocol + closed type set) before the host
|
|
21
|
+
* acts. Intents are validated against a closed set and performed by the
|
|
22
|
+
* host — the frame never acts with the user's authority.
|
|
23
|
+
*
|
|
24
|
+
* The host pushes read-only props on `frameReady` (and re-pushes when they
|
|
25
|
+
* change), performs validated intents, and surfaces a render error the frame
|
|
26
|
+
* reports — never a blank frame.
|
|
27
|
+
*/
|
|
28
|
+
import { AlertTriangle } from 'lucide-react';
|
|
29
|
+
import { useEffect, useMemo, useRef, useState, type ReactElement } from 'react';
|
|
30
|
+
|
|
31
|
+
import { classifyFrameMessage } from './custom-ui-frame-bridge';
|
|
32
|
+
import {
|
|
33
|
+
hostPropsMessage,
|
|
34
|
+
type CustomUiComponentProps,
|
|
35
|
+
} from './custom-ui-frame-contract';
|
|
36
|
+
import { type CustomUiIntentSet } from './custom-ui-intents';
|
|
37
|
+
import {
|
|
38
|
+
CUSTOM_UI_FRAME_RESET_CSS,
|
|
39
|
+
buildCustomUiSrcDoc,
|
|
40
|
+
buildUntrustedHtmlSrcDoc,
|
|
41
|
+
} from './custom-ui-srcdoc';
|
|
42
|
+
import { cn } from '../../ui/cn';
|
|
43
|
+
|
|
44
|
+
/** What the frame renders. Exactly one of the two forms. */
|
|
45
|
+
export type CustomUiFrameContent =
|
|
46
|
+
| {
|
|
47
|
+
/** A server-compiled, SRI-pinned, self-mounting ESM chunk. */
|
|
48
|
+
readonly compiledOutput: string;
|
|
49
|
+
/** Server SRI/CSP token (`sha384-<base64>`) pinning the chunk bytes. */
|
|
50
|
+
readonly integrity: string;
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
/** An untrusted HTML document. Rendered with `script-src 'none'`. */
|
|
54
|
+
readonly document: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export interface CustomUiFrameProps<TIntent> {
|
|
58
|
+
/** The content to render. */
|
|
59
|
+
readonly content: CustomUiFrameContent;
|
|
60
|
+
/** Read-only, serializable props handed to a compiled component. */
|
|
61
|
+
readonly componentProps?: CustomUiComponentProps;
|
|
62
|
+
/** The CLOSED intent set this frame may exercise against the host. */
|
|
63
|
+
readonly intents: CustomUiIntentSet<TIntent>;
|
|
64
|
+
/**
|
|
65
|
+
* CSS inlined into the frame (the frame cannot fetch a stylesheet — its CSP
|
|
66
|
+
* is `default-src 'none'`). Defaults to {@link CUSTOM_UI_FRAME_RESET_CSS};
|
|
67
|
+
* hosts prepend it to their own design-token CSS.
|
|
68
|
+
*/
|
|
69
|
+
readonly styleCss?: string;
|
|
70
|
+
/** Accessible title for the iframe. */
|
|
71
|
+
readonly title: string;
|
|
72
|
+
readonly className?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const EMPTY_PROPS: CustomUiComponentProps = {};
|
|
76
|
+
|
|
77
|
+
export function CustomUiFrame<TIntent>({
|
|
78
|
+
content,
|
|
79
|
+
componentProps = EMPTY_PROPS,
|
|
80
|
+
intents,
|
|
81
|
+
styleCss = CUSTOM_UI_FRAME_RESET_CSS,
|
|
82
|
+
title,
|
|
83
|
+
className,
|
|
84
|
+
}: CustomUiFrameProps<TIntent>): ReactElement {
|
|
85
|
+
const iframeRef = useRef<HTMLIFrameElement | null>(null);
|
|
86
|
+
const [frameError, setFrameError] = useState<string | null>(null);
|
|
87
|
+
|
|
88
|
+
// Latest props/intent set, read by the message listener without
|
|
89
|
+
// re-subscribing (the listener is attached once; a props re-render is handled
|
|
90
|
+
// by a dedicated effect below).
|
|
91
|
+
const propsRef = useRef(componentProps);
|
|
92
|
+
propsRef.current = componentProps;
|
|
93
|
+
const intentsRef = useRef(intents);
|
|
94
|
+
intentsRef.current = intents;
|
|
95
|
+
const readyRef = useRef(false);
|
|
96
|
+
|
|
97
|
+
// The srcdoc is a pure function of the content identity + inlined styles — it
|
|
98
|
+
// does NOT depend on props (props flow over postMessage, not by re-mounting
|
|
99
|
+
// the frame). Recomputing only on content change avoids reloading the frame
|
|
100
|
+
// on every prop update.
|
|
101
|
+
// The builders throw on content that would truncate the inline module (a
|
|
102
|
+
// `</script`-bearing body) — surface it as a visible error rather than
|
|
103
|
+
// white-screening. `null` srcDoc ⇒ render the notice, no iframe.
|
|
104
|
+
const isCompiled = 'compiledOutput' in content;
|
|
105
|
+
const compiledOutput = isCompiled ? content.compiledOutput : null;
|
|
106
|
+
const integrity = isCompiled ? content.integrity : null;
|
|
107
|
+
const document = isCompiled ? null : content.document;
|
|
108
|
+
const srcDoc = useMemo<string | null>(() => {
|
|
109
|
+
try {
|
|
110
|
+
return compiledOutput !== null && integrity !== null
|
|
111
|
+
? buildCustomUiSrcDoc({ compiledOutput, integrity, styleCss })
|
|
112
|
+
: buildUntrustedHtmlSrcDoc({ document: document ?? '', styleCss });
|
|
113
|
+
} catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}, [compiledOutput, integrity, document, styleCss]);
|
|
117
|
+
|
|
118
|
+
// Fresh content is a fresh frame lifecycle — reset ready + error state.
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
readyRef.current = false;
|
|
121
|
+
setFrameError(null);
|
|
122
|
+
}, [srcDoc]);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
function onMessage(event: MessageEvent): void {
|
|
126
|
+
const frameWindow = iframeRef.current?.contentWindow ?? null;
|
|
127
|
+
const classified = classifyFrameMessage(
|
|
128
|
+
event,
|
|
129
|
+
frameWindow,
|
|
130
|
+
intentsRef.current.parse,
|
|
131
|
+
);
|
|
132
|
+
switch (classified.kind) {
|
|
133
|
+
case 'ready':
|
|
134
|
+
readyRef.current = true;
|
|
135
|
+
setFrameError(null);
|
|
136
|
+
frameWindow?.postMessage(hostPropsMessage(propsRef.current), '*');
|
|
137
|
+
return;
|
|
138
|
+
case 'intent':
|
|
139
|
+
intentsRef.current.perform(classified.intent);
|
|
140
|
+
return;
|
|
141
|
+
case 'error':
|
|
142
|
+
setFrameError(classified.message);
|
|
143
|
+
return;
|
|
144
|
+
case 'ignored':
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
window.addEventListener('message', onMessage);
|
|
149
|
+
return () => window.removeEventListener('message', onMessage);
|
|
150
|
+
}, []);
|
|
151
|
+
|
|
152
|
+
// Re-push props to an already-ready frame when they change (repeatable
|
|
153
|
+
// re-render, per the HostProps contract). Before ready, the frameReady
|
|
154
|
+
// handler above pushes the current props — so no update is lost.
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (!readyRef.current) return;
|
|
157
|
+
iframeRef.current?.contentWindow?.postMessage(
|
|
158
|
+
hostPropsMessage(componentProps),
|
|
159
|
+
'*',
|
|
160
|
+
);
|
|
161
|
+
}, [componentProps]);
|
|
162
|
+
|
|
163
|
+
if (srcDoc === null) {
|
|
164
|
+
return (
|
|
165
|
+
<div className={className}>
|
|
166
|
+
<div
|
|
167
|
+
role="alert"
|
|
168
|
+
className="flex items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive"
|
|
169
|
+
>
|
|
170
|
+
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0" />
|
|
171
|
+
<span>
|
|
172
|
+
This custom view could not be prepared safely and was not rendered.
|
|
173
|
+
</span>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<div className={cn('flex h-full min-h-0 flex-col', className)}>
|
|
181
|
+
{frameError !== null ? (
|
|
182
|
+
<div
|
|
183
|
+
role="alert"
|
|
184
|
+
className="mb-2 flex items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive"
|
|
185
|
+
>
|
|
186
|
+
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0" />
|
|
187
|
+
<span>This custom view failed to render: {frameError}</span>
|
|
188
|
+
</div>
|
|
189
|
+
) : null}
|
|
190
|
+
<iframe
|
|
191
|
+
ref={iframeRef}
|
|
192
|
+
title={title}
|
|
193
|
+
// OPAQUE ORIGIN: allow-scripts ONLY. Adding allow-same-origin would
|
|
194
|
+
// dissolve the origin boundary and give author code access to host
|
|
195
|
+
// cookies/DOM/tokens — never add it.
|
|
196
|
+
sandbox="allow-scripts"
|
|
197
|
+
srcDoc={srcDoc}
|
|
198
|
+
className="min-h-[24rem] w-full flex-1 rounded border border-rule bg-paper"
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export default CustomUiFrame;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host-side inbound-message classifier — the security gate for every
|
|
3
|
+
* message the host acts on. Proves it REJECTS a wrong-source message, a
|
|
4
|
+
* wrong-protocol message, an unknown type, and a well-formed envelope carrying
|
|
5
|
+
* an unknown intent; and that it correctly classifies frameReady / a valid
|
|
6
|
+
* intent / a render error. Also proves frameReady is answered with a hostProps
|
|
7
|
+
* message (via the paired builder), and that a frame mounted with the EMPTY
|
|
8
|
+
* intent set can never get an intent performed.
|
|
9
|
+
*
|
|
10
|
+
* Migrated from `app-forge-web` when the frame was promoted into the UI kernel
|
|
11
|
+
* (the intent parser is now an argument instead of a hard-wired import — every
|
|
12
|
+
* gate is otherwise unchanged); runs under the host-web vitest mirror.
|
|
13
|
+
*/
|
|
14
|
+
import { describe, expect, it } from 'vitest';
|
|
15
|
+
|
|
16
|
+
import { classifyFrameMessage } from './custom-ui-frame-bridge';
|
|
17
|
+
import {
|
|
18
|
+
CUSTOM_UI_FRAME_PROTOCOL,
|
|
19
|
+
CustomUiFrameMessageType,
|
|
20
|
+
hostPropsMessage,
|
|
21
|
+
} from './custom-ui-frame-contract';
|
|
22
|
+
import {
|
|
23
|
+
CustomUiIntentKind,
|
|
24
|
+
NO_CUSTOM_UI_INTENTS,
|
|
25
|
+
parseCustomUiIntent,
|
|
26
|
+
} from './custom-ui-intents';
|
|
27
|
+
|
|
28
|
+
// A stand-in for the iframe's contentWindow — identity is all the gate checks.
|
|
29
|
+
const FRAME_WINDOW = { name: 'frame' } as unknown as Window;
|
|
30
|
+
const OTHER_WINDOW = { name: 'other' } as unknown as Window;
|
|
31
|
+
|
|
32
|
+
function evt(
|
|
33
|
+
data: unknown,
|
|
34
|
+
source: Window | null,
|
|
35
|
+
): Pick<MessageEvent, 'source' | 'data'> {
|
|
36
|
+
return { data, source };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('classifyFrameMessage', () => {
|
|
40
|
+
it('classifies a valid frameReady', () => {
|
|
41
|
+
const result = classifyFrameMessage(
|
|
42
|
+
evt(
|
|
43
|
+
{
|
|
44
|
+
type: CustomUiFrameMessageType.FrameReady,
|
|
45
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
46
|
+
},
|
|
47
|
+
FRAME_WINDOW,
|
|
48
|
+
),
|
|
49
|
+
FRAME_WINDOW,
|
|
50
|
+
parseCustomUiIntent,
|
|
51
|
+
);
|
|
52
|
+
expect(result).toEqual({ kind: 'ready' });
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('classifies a valid frameIntent into a typed intent', () => {
|
|
56
|
+
const result = classifyFrameMessage(
|
|
57
|
+
evt(
|
|
58
|
+
{
|
|
59
|
+
type: CustomUiFrameMessageType.FrameIntent,
|
|
60
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
61
|
+
intent: { kind: 'navigate', href: '/apps/x/page' },
|
|
62
|
+
},
|
|
63
|
+
FRAME_WINDOW,
|
|
64
|
+
),
|
|
65
|
+
FRAME_WINDOW,
|
|
66
|
+
parseCustomUiIntent,
|
|
67
|
+
);
|
|
68
|
+
expect(result).toEqual({
|
|
69
|
+
kind: 'intent',
|
|
70
|
+
intent: { kind: CustomUiIntentKind.Navigate, href: '/apps/x/page' },
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('classifies a frameError, surfacing the message', () => {
|
|
75
|
+
const result = classifyFrameMessage(
|
|
76
|
+
evt(
|
|
77
|
+
{
|
|
78
|
+
type: CustomUiFrameMessageType.FrameError,
|
|
79
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
80
|
+
message: 'boom',
|
|
81
|
+
},
|
|
82
|
+
FRAME_WINDOW,
|
|
83
|
+
),
|
|
84
|
+
FRAME_WINDOW,
|
|
85
|
+
parseCustomUiIntent,
|
|
86
|
+
);
|
|
87
|
+
expect(result).toEqual({ kind: 'error', message: 'boom' });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('REJECTS a message from the wrong source window', () => {
|
|
91
|
+
const result = classifyFrameMessage(
|
|
92
|
+
evt(
|
|
93
|
+
{
|
|
94
|
+
type: CustomUiFrameMessageType.FrameReady,
|
|
95
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
96
|
+
},
|
|
97
|
+
OTHER_WINDOW,
|
|
98
|
+
),
|
|
99
|
+
FRAME_WINDOW,
|
|
100
|
+
parseCustomUiIntent,
|
|
101
|
+
);
|
|
102
|
+
expect(result).toEqual({ kind: 'ignored' });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('REJECTS a message with the wrong protocol', () => {
|
|
106
|
+
const result = classifyFrameMessage(
|
|
107
|
+
evt(
|
|
108
|
+
{ type: CustomUiFrameMessageType.FrameReady, protocol: 999 },
|
|
109
|
+
FRAME_WINDOW,
|
|
110
|
+
),
|
|
111
|
+
FRAME_WINDOW,
|
|
112
|
+
parseCustomUiIntent,
|
|
113
|
+
);
|
|
114
|
+
expect(result).toEqual({ kind: 'ignored' });
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('REJECTS an unknown message type', () => {
|
|
118
|
+
const result = classifyFrameMessage(
|
|
119
|
+
evt(
|
|
120
|
+
{
|
|
121
|
+
type: 'xema.customui.somethingElse',
|
|
122
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
123
|
+
},
|
|
124
|
+
FRAME_WINDOW,
|
|
125
|
+
),
|
|
126
|
+
FRAME_WINDOW,
|
|
127
|
+
parseCustomUiIntent,
|
|
128
|
+
);
|
|
129
|
+
expect(result).toEqual({ kind: 'ignored' });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('REJECTS a well-formed envelope carrying an unknown intent', () => {
|
|
133
|
+
const result = classifyFrameMessage(
|
|
134
|
+
evt(
|
|
135
|
+
{
|
|
136
|
+
type: CustomUiFrameMessageType.FrameIntent,
|
|
137
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
138
|
+
intent: { kind: 'wipe-db' },
|
|
139
|
+
},
|
|
140
|
+
FRAME_WINDOW,
|
|
141
|
+
),
|
|
142
|
+
FRAME_WINDOW,
|
|
143
|
+
parseCustomUiIntent,
|
|
144
|
+
);
|
|
145
|
+
expect(result).toEqual({ kind: 'ignored' });
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('REJECTS when no frame window is mounted yet', () => {
|
|
149
|
+
const result = classifyFrameMessage(
|
|
150
|
+
evt(
|
|
151
|
+
{
|
|
152
|
+
type: CustomUiFrameMessageType.FrameReady,
|
|
153
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
154
|
+
},
|
|
155
|
+
FRAME_WINDOW,
|
|
156
|
+
),
|
|
157
|
+
null,
|
|
158
|
+
parseCustomUiIntent,
|
|
159
|
+
);
|
|
160
|
+
expect(result).toEqual({ kind: 'ignored' });
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// The intent set is now supplied by the mounting surface — a frame mounted
|
|
164
|
+
// with the EMPTY set has no authority, so even a perfectly-formed navigate
|
|
165
|
+
// envelope is ignored.
|
|
166
|
+
it('REJECTS every intent when mounted with the EMPTY intent set', () => {
|
|
167
|
+
const result = classifyFrameMessage(
|
|
168
|
+
evt(
|
|
169
|
+
{
|
|
170
|
+
type: CustomUiFrameMessageType.FrameIntent,
|
|
171
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
172
|
+
intent: { kind: 'navigate', href: '/apps/x/page' },
|
|
173
|
+
},
|
|
174
|
+
FRAME_WINDOW,
|
|
175
|
+
),
|
|
176
|
+
FRAME_WINDOW,
|
|
177
|
+
NO_CUSTOM_UI_INTENTS.parse,
|
|
178
|
+
);
|
|
179
|
+
expect(result).toEqual({ kind: 'ignored' });
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('answers frameReady with a hostProps message (paired builder)', () => {
|
|
183
|
+
const props = { records: [{ id: 'r1' }] };
|
|
184
|
+
const message = hostPropsMessage(props);
|
|
185
|
+
expect(message).toEqual({
|
|
186
|
+
type: CustomUiFrameMessageType.HostProps,
|
|
187
|
+
protocol: CUSTOM_UI_FRAME_PROTOCOL,
|
|
188
|
+
props,
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|