@revealui/core 0.0.1-pre.3 → 0.2.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/LICENSE +22 -202
- package/README.md +29 -180
- package/dist/api/compression.d.ts +83 -0
- package/dist/api/compression.d.ts.map +1 -0
- package/dist/api/compression.js +233 -0
- package/dist/api/payload-optimization.d.ts +138 -0
- package/dist/api/payload-optimization.d.ts.map +1 -0
- package/dist/api/payload-optimization.js +320 -0
- package/dist/api/rate-limit.d.ts +113 -0
- package/dist/api/rate-limit.d.ts.map +1 -0
- package/dist/api/rate-limit.js +301 -0
- package/dist/api/response-cache.d.ts +125 -0
- package/dist/api/response-cache.d.ts.map +1 -0
- package/dist/api/response-cache.js +335 -0
- package/dist/api/rest.d.ts +54 -0
- package/dist/api/rest.d.ts.map +1 -0
- package/dist/api/rest.js +464 -0
- package/dist/auth/access.d.ts +25 -0
- package/dist/auth/access.d.ts.map +1 -0
- package/dist/auth/access.js +20 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/cache/query-cache.d.ts +98 -0
- package/dist/cache/query-cache.d.ts.map +1 -0
- package/dist/cache/query-cache.js +260 -0
- package/dist/caching/app-cache.d.ts +237 -0
- package/dist/caching/app-cache.d.ts.map +1 -0
- package/dist/caching/app-cache.js +430 -0
- package/dist/caching/cdn-config.d.ts +155 -0
- package/dist/caching/cdn-config.d.ts.map +1 -0
- package/dist/caching/cdn-config.js +425 -0
- package/dist/caching/edge-cache.d.ts +177 -0
- package/dist/caching/edge-cache.d.ts.map +1 -0
- package/dist/caching/edge-cache.js +381 -0
- package/dist/caching/service-worker.d.ts +165 -0
- package/dist/caching/service-worker.d.ts.map +1 -0
- package/dist/caching/service-worker.js +437 -0
- package/dist/client/admin/RichText.d.ts +12 -0
- package/dist/client/admin/RichText.d.ts.map +1 -0
- package/dist/client/admin/RichText.js +5 -0
- package/dist/client/admin/components/AdminDashboard.d.ts +7 -0
- package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -0
- package/dist/client/admin/components/AdminDashboard.js +318 -0
- package/dist/client/admin/components/CollectionList.d.ts +16 -0
- package/dist/client/admin/components/CollectionList.d.ts.map +1 -0
- package/dist/client/admin/components/CollectionList.js +67 -0
- package/dist/client/admin/components/DocumentForm.d.ts +11 -0
- package/dist/client/admin/components/DocumentForm.d.ts.map +1 -0
- package/dist/client/admin/components/DocumentForm.js +99 -0
- package/dist/client/admin/components/GlobalForm.d.ts +11 -0
- package/dist/client/admin/components/GlobalForm.d.ts.map +1 -0
- package/dist/client/admin/components/GlobalForm.js +74 -0
- package/dist/client/admin/i18n/en.d.ts +25 -0
- package/dist/client/admin/i18n/en.d.ts.map +1 -0
- package/dist/client/admin/i18n/en.js +25 -0
- package/dist/client/admin/index.d.ts +10 -0
- package/dist/client/admin/index.d.ts.map +1 -0
- package/dist/client/admin/index.js +10 -0
- package/dist/client/admin/layout.d.ts +10 -0
- package/dist/client/admin/layout.d.ts.map +1 -0
- package/dist/client/admin/layout.js +6 -0
- package/dist/client/admin/page.d.ts +38 -0
- package/dist/client/admin/page.d.ts.map +1 -0
- package/dist/client/admin/page.js +15 -0
- package/dist/client/admin/utils/apiClient.d.ts +110 -0
- package/dist/client/admin/utils/apiClient.d.ts.map +1 -0
- package/dist/client/admin/utils/apiClient.js +220 -0
- package/dist/client/admin/utils/auth.d.ts +27 -0
- package/dist/client/admin/utils/auth.d.ts.map +1 -0
- package/dist/client/admin/utils/auth.js +58 -0
- package/dist/client/admin/utils/index.d.ts +6 -0
- package/dist/client/admin/utils/index.d.ts.map +1 -0
- package/dist/client/admin/utils/index.js +5 -0
- package/dist/client/admin/utils/serializeConfig.d.ts +7 -0
- package/dist/client/admin/utils/serializeConfig.d.ts.map +1 -0
- package/dist/client/admin/utils/serializeConfig.js +35 -0
- package/dist/client/hooks.d.ts +18 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +29 -0
- package/dist/client/http/client.d.ts +15 -0
- package/dist/client/http/client.d.ts.map +1 -0
- package/dist/client/http/client.js +49 -0
- package/dist/client/http/fetchBanner.d.ts +18 -0
- package/dist/client/http/fetchBanner.d.ts.map +1 -0
- package/dist/client/http/fetchBanner.js +44 -0
- package/dist/client/http/fetchCard.d.ts +18 -0
- package/dist/client/http/fetchCard.d.ts.map +1 -0
- package/dist/client/http/fetchCard.js +46 -0
- package/dist/client/http/fetchEvents.d.ts +18 -0
- package/dist/client/http/fetchEvents.d.ts.map +1 -0
- package/dist/client/http/fetchEvents.js +44 -0
- package/dist/client/http/fetchHero.d.ts +17 -0
- package/dist/client/http/fetchHero.d.ts.map +1 -0
- package/dist/client/http/fetchHero.js +55 -0
- package/dist/client/http/fetchMainInfos.d.ts +17 -0
- package/dist/client/http/fetchMainInfos.d.ts.map +1 -0
- package/dist/client/http/fetchMainInfos.js +44 -0
- package/dist/client/http/fetchVideos.d.ts +13 -0
- package/dist/client/http/fetchVideos.d.ts.map +1 -0
- package/dist/client/http/fetchVideos.js +36 -0
- package/dist/client/http/index.d.ts +19 -0
- package/dist/client/http/index.d.ts.map +1 -0
- package/dist/client/http/index.js +11 -0
- package/dist/client/index.d.ts +12 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +15 -0
- package/dist/client/richtext/RichTextEditor.d.ts +48 -0
- package/dist/client/richtext/RichTextEditor.d.ts.map +1 -0
- package/dist/client/richtext/RichTextEditor.js +360 -0
- package/dist/client/richtext/components/ImageNodeComponent.d.ts +9 -0
- package/dist/client/richtext/components/ImageNodeComponent.d.ts.map +1 -0
- package/dist/client/richtext/components/ImageNodeComponent.js +99 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts +11 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts.map +1 -0
- package/dist/client/richtext/components/ImageUploadButton.js +103 -0
- package/dist/client/richtext/index.d.ts +92 -0
- package/dist/client/richtext/index.d.ts.map +1 -0
- package/dist/client/richtext/index.js +74 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts +20 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts.map +1 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.js +29 -0
- package/dist/client/richtext/nodes/ImageNode.d.ts +51 -0
- package/dist/client/richtext/nodes/ImageNode.d.ts.map +1 -0
- package/dist/client/richtext/nodes/ImageNode.js +95 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts +13 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.js +8 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts +4 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.js +50 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts +7 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +248 -0
- package/dist/client/richtext/plugins/ImagePlugin.d.ts +3 -0
- package/dist/client/richtext/plugins/ImagePlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/ImagePlugin.js +73 -0
- package/dist/client/richtext/plugins/PastePlugin.d.ts +2 -0
- package/dist/client/richtext/plugins/PastePlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/PastePlugin.js +36 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts +8 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.js +204 -0
- package/dist/client/ui/index.d.ts +111 -0
- package/dist/client/ui/index.d.ts.map +1 -0
- package/dist/client/ui/index.js +130 -0
- package/dist/collections/CollectionOperations.d.ts +27 -0
- package/dist/collections/CollectionOperations.d.ts.map +1 -0
- package/dist/collections/CollectionOperations.js +34 -0
- package/dist/collections/hooks.d.ts +11 -0
- package/dist/collections/hooks.d.ts.map +1 -0
- package/dist/collections/hooks.js +35 -0
- package/dist/collections/index.d.ts +2 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js +1 -0
- package/dist/collections/operations/create.d.ts +10 -0
- package/dist/collections/operations/create.d.ts.map +1 -0
- package/dist/collections/operations/create.js +101 -0
- package/dist/collections/operations/delete.d.ts +10 -0
- package/dist/collections/operations/delete.d.ts.map +1 -0
- package/dist/collections/operations/delete.js +16 -0
- package/dist/collections/operations/fieldHooks.d.ts +21 -0
- package/dist/collections/operations/fieldHooks.d.ts.map +1 -0
- package/dist/collections/operations/fieldHooks.js +51 -0
- package/dist/collections/operations/find.d.ts +10 -0
- package/dist/collections/operations/find.d.ts.map +1 -0
- package/dist/collections/operations/find.js +124 -0
- package/dist/collections/operations/findById.d.ts +15 -0
- package/dist/collections/operations/findById.d.ts.map +1 -0
- package/dist/collections/operations/findById.js +59 -0
- package/dist/collections/operations/update.d.ts +10 -0
- package/dist/collections/operations/update.d.ts.map +1 -0
- package/dist/collections/operations/update.js +134 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +61 -0
- package/dist/config/runtime.d.ts +22 -0
- package/dist/config/runtime.d.ts.map +1 -0
- package/dist/config/runtime.js +32 -0
- package/dist/config/utils.d.ts +12 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +20 -0
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +6 -0
- package/dist/database/ssl-config.d.ts +9 -0
- package/dist/database/ssl-config.d.ts.map +1 -0
- package/dist/database/ssl-config.js +7 -0
- package/dist/database/type-adapter.d.ts +113 -0
- package/dist/database/type-adapter.d.ts.map +1 -0
- package/dist/database/type-adapter.js +97 -0
- package/dist/database/universal-postgres.d.ts +45 -0
- package/dist/database/universal-postgres.d.ts.map +1 -0
- package/dist/database/universal-postgres.js +526 -0
- package/dist/dataloader.d.ts +26 -0
- package/dist/dataloader.d.ts.map +1 -0
- package/dist/dataloader.js +162 -0
- package/dist/error-handling/circuit-breaker.d.ts +262 -0
- package/dist/error-handling/circuit-breaker.d.ts.map +1 -0
- package/dist/error-handling/circuit-breaker.js +542 -0
- package/dist/error-handling/error-boundary.d.ts +94 -0
- package/dist/error-handling/error-boundary.d.ts.map +1 -0
- package/dist/error-handling/error-boundary.js +285 -0
- package/dist/error-handling/error-reporter.d.ts +213 -0
- package/dist/error-handling/error-reporter.d.ts.map +1 -0
- package/dist/error-handling/error-reporter.js +506 -0
- package/dist/error-handling/fallback-components.d.ts +131 -0
- package/dist/error-handling/fallback-components.d.ts.map +1 -0
- package/dist/error-handling/fallback-components.js +371 -0
- package/dist/error-handling/index.d.ts +16 -0
- package/dist/error-handling/index.d.ts.map +1 -0
- package/dist/error-handling/index.js +15 -0
- package/dist/error-handling/retry.d.ts +194 -0
- package/dist/error-handling/retry.d.ts.map +1 -0
- package/dist/error-handling/retry.js +450 -0
- package/dist/errors/index.d.ts +23 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +40 -0
- package/dist/factories/builders.d.ts +50 -0
- package/dist/factories/builders.d.ts.map +1 -0
- package/dist/factories/builders.js +77 -0
- package/dist/factories/index.d.ts +2 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +1 -0
- package/dist/features.d.ts +82 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +89 -0
- package/dist/fieldTraversal.d.ts +26 -0
- package/dist/fieldTraversal.d.ts.map +1 -0
- package/dist/fieldTraversal.js +132 -0
- package/dist/fields/config/types.d.ts +48 -0
- package/dist/fields/config/types.d.ts.map +1 -0
- package/dist/fields/config/types.js +20 -0
- package/dist/fields/getDefaultValue.d.ts +16 -0
- package/dist/fields/getDefaultValue.d.ts.map +1 -0
- package/dist/fields/getDefaultValue.js +20 -0
- package/dist/fields/getFieldPaths.d.ts +25 -0
- package/dist/fields/getFieldPaths.d.ts.map +1 -0
- package/dist/fields/getFieldPaths.js +23 -0
- package/dist/fields/hooks/afterRead/index.d.ts +36 -0
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/index.js +70 -0
- package/dist/fields/hooks/afterRead/promise.d.ts +46 -0
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/promise.js +178 -0
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +44 -0
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/traverseFields.js +37 -0
- package/dist/generated/agents/index.d.ts +8 -0
- package/dist/generated/agents/index.d.ts.map +1 -0
- package/dist/generated/agents/index.js +7 -0
- package/dist/generated/components/index.d.ts +8 -0
- package/dist/generated/components/index.d.ts.map +1 -0
- package/dist/generated/components/index.js +7 -0
- package/dist/generated/functions/index.d.ts +8 -0
- package/dist/generated/functions/index.d.ts.map +1 -0
- package/dist/generated/functions/index.js +7 -0
- package/dist/generated/hooks/index.d.ts +8 -0
- package/dist/generated/hooks/index.d.ts.map +1 -0
- package/dist/generated/hooks/index.js +7 -0
- package/dist/generated/index.d.ts +10 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +9 -0
- package/dist/generated/plans/index.d.ts +8 -0
- package/dist/generated/plans/index.d.ts.map +1 -0
- package/dist/generated/plans/index.js +7 -0
- package/dist/generated/prompts/index.d.ts +8 -0
- package/dist/generated/prompts/index.d.ts.map +1 -0
- package/dist/generated/prompts/index.js +7 -0
- package/dist/generated/tools/index.d.ts +8 -0
- package/dist/generated/tools/index.d.ts.map +1 -0
- package/dist/generated/tools/index.js +7 -0
- package/dist/generated/types/cms.d.ts +1766 -0
- package/dist/generated/types/cms.d.ts.map +1 -0
- package/dist/generated/types/cms.js +12 -0
- package/dist/generated/types/index.d.ts +19 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/index.js +28 -0
- package/dist/generated/types/neon.d.ts +11 -0
- package/dist/generated/types/neon.d.ts.map +1 -0
- package/dist/generated/types/neon.js +11 -0
- package/dist/generated/types/supabase.d.ts +193 -0
- package/dist/generated/types/supabase.d.ts.map +1 -0
- package/dist/generated/types/supabase.js +5 -0
- package/dist/globals/GlobalOperations.d.ts +24 -0
- package/dist/globals/GlobalOperations.d.ts.map +1 -0
- package/dist/globals/GlobalOperations.js +149 -0
- package/dist/globals/index.d.ts +2 -0
- package/dist/globals/index.d.ts.map +1 -0
- package/dist/globals/index.js +1 -0
- package/dist/index.d.ts +64 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -33
- package/dist/instance/RevealUIInstance.d.ts +6 -0
- package/dist/instance/RevealUIInstance.d.ts.map +1 -0
- package/dist/instance/RevealUIInstance.js +312 -0
- package/dist/instance/index.d.ts +3 -0
- package/dist/instance/index.d.ts.map +1 -0
- package/dist/instance/index.js +2 -0
- package/dist/instance/logger.d.ts +31 -0
- package/dist/instance/logger.d.ts.map +1 -0
- package/dist/instance/logger.js +42 -0
- package/dist/instance/methods/create.d.ts +10 -0
- package/dist/instance/methods/create.d.ts.map +1 -0
- package/dist/instance/methods/create.js +38 -0
- package/dist/instance/methods/delete.d.ts +10 -0
- package/dist/instance/methods/delete.d.ts.map +1 -0
- package/dist/instance/methods/delete.js +24 -0
- package/dist/instance/methods/find.d.ts +10 -0
- package/dist/instance/methods/find.d.ts.map +1 -0
- package/dist/instance/methods/find.js +23 -0
- package/dist/instance/methods/findById.d.ts +13 -0
- package/dist/instance/methods/findById.d.ts.map +1 -0
- package/dist/instance/methods/findById.js +23 -0
- package/dist/instance/methods/hooks.d.ts +14 -0
- package/dist/instance/methods/hooks.d.ts.map +1 -0
- package/dist/instance/methods/hooks.js +32 -0
- package/dist/instance/methods/update.d.ts +10 -0
- package/dist/instance/methods/update.d.ts.map +1 -0
- package/dist/instance/methods/update.js +42 -0
- package/dist/license.d.ts +73 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +157 -0
- package/dist/monitoring/alerts.d.ts +118 -0
- package/dist/monitoring/alerts.d.ts.map +1 -0
- package/dist/monitoring/alerts.js +324 -0
- package/dist/monitoring/cleanup-manager.d.ts +71 -0
- package/dist/monitoring/cleanup-manager.d.ts.map +1 -0
- package/dist/monitoring/cleanup-manager.js +226 -0
- package/dist/monitoring/health-monitor.d.ts +22 -0
- package/dist/monitoring/health-monitor.d.ts.map +1 -0
- package/dist/monitoring/health-monitor.js +142 -0
- package/dist/monitoring/index.d.ts +14 -0
- package/dist/monitoring/index.d.ts.map +1 -0
- package/dist/monitoring/index.js +17 -0
- package/dist/monitoring/process-registry.d.ts +97 -0
- package/dist/monitoring/process-registry.d.ts.map +1 -0
- package/dist/monitoring/process-registry.js +222 -0
- package/dist/monitoring/query-monitor.d.ts +153 -0
- package/dist/monitoring/query-monitor.d.ts.map +1 -0
- package/dist/monitoring/query-monitor.js +209 -0
- package/dist/monitoring/types.d.ts +231 -0
- package/dist/monitoring/types.d.ts.map +1 -0
- package/dist/monitoring/types.js +42 -0
- package/dist/monitoring/zombie-detector.d.ts +81 -0
- package/dist/monitoring/zombie-detector.d.ts.map +1 -0
- package/dist/monitoring/zombie-detector.js +231 -0
- package/dist/nextjs/index.d.ts +4 -0
- package/dist/nextjs/index.d.ts.map +1 -0
- package/dist/nextjs/index.js +3 -0
- package/dist/nextjs/utilities.d.ts +5 -0
- package/dist/nextjs/utilities.d.ts.map +1 -0
- package/dist/nextjs/utilities.js +16 -0
- package/dist/nextjs/withRevealUI.d.ts +20 -0
- package/dist/nextjs/withRevealUI.d.ts.map +1 -0
- package/dist/nextjs/withRevealUI.js +181 -0
- package/dist/observability/alerts.d.ts +138 -0
- package/dist/observability/alerts.d.ts.map +1 -0
- package/dist/observability/alerts.js +390 -0
- package/dist/observability/health-check.d.ts +95 -0
- package/dist/observability/health-check.d.ts.map +1 -0
- package/dist/observability/health-check.js +345 -0
- package/dist/observability/index.d.ts +12 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +11 -0
- package/dist/observability/logger.d.ts +47 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +140 -0
- package/dist/observability/metrics.d.ts +205 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +429 -0
- package/dist/observability/tracing.d.ts +149 -0
- package/dist/observability/tracing.d.ts.map +1 -0
- package/dist/observability/tracing.js +381 -0
- package/dist/optimization/asset-optimizer.d.ts +202 -0
- package/dist/optimization/asset-optimizer.d.ts.map +1 -0
- package/dist/optimization/asset-optimizer.js +312 -0
- package/dist/optimization/build-optimizer.d.ts +202 -0
- package/dist/optimization/build-optimizer.d.ts.map +1 -0
- package/dist/optimization/build-optimizer.js +271 -0
- package/dist/optimization/bundle-analyzer.d.ts +98 -0
- package/dist/optimization/bundle-analyzer.d.ts.map +1 -0
- package/dist/optimization/bundle-analyzer.js +322 -0
- package/dist/optimization/code-splitting.d.ts +144 -0
- package/dist/optimization/code-splitting.d.ts.map +1 -0
- package/dist/optimization/code-splitting.js +290 -0
- package/dist/plugin/index.d.ts +12 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +4 -0
- package/dist/plugins/form-builder.d.ts +115 -0
- package/dist/plugins/form-builder.d.ts.map +1 -0
- package/dist/plugins/form-builder.js +239 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/nested-docs.d.ts +8 -0
- package/dist/plugins/nested-docs.d.ts.map +1 -0
- package/dist/plugins/nested-docs.js +67 -0
- package/dist/plugins/redirects.d.ts +17 -0
- package/dist/plugins/redirects.d.ts.map +1 -0
- package/dist/plugins/redirects.js +62 -0
- package/dist/queries/index.d.ts +2 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +1 -0
- package/dist/queries/queryBuilder.d.ts +47 -0
- package/dist/queries/queryBuilder.d.ts.map +1 -0
- package/dist/queries/queryBuilder.js +252 -0
- package/dist/relationships/analyzer.d.ts +39 -0
- package/dist/relationships/analyzer.d.ts.map +1 -0
- package/dist/relationships/analyzer.js +127 -0
- package/dist/relationships/index.d.ts +3 -0
- package/dist/relationships/index.d.ts.map +1 -0
- package/dist/relationships/index.js +2 -0
- package/dist/relationships/populate-helpers.d.ts +104 -0
- package/dist/relationships/populate-helpers.d.ts.map +1 -0
- package/dist/relationships/populate-helpers.js +187 -0
- package/dist/relationships/population.d.ts +42 -0
- package/dist/relationships/population.d.ts.map +1 -0
- package/dist/relationships/population.js +188 -0
- package/dist/revealui.d.ts +46 -0
- package/dist/revealui.d.ts.map +1 -0
- package/dist/revealui.js +92 -0
- package/dist/richtext/exports/client/rcc.d.ts +37 -0
- package/dist/richtext/exports/client/rcc.d.ts.map +1 -0
- package/dist/richtext/exports/client/rcc.js +182 -0
- package/dist/richtext/exports/server/rsc.d.ts +117 -0
- package/dist/richtext/exports/server/rsc.d.ts.map +1 -0
- package/dist/richtext/exports/server/rsc.js +288 -0
- package/dist/richtext/index.d.ts +161 -0
- package/dist/richtext/index.d.ts.map +1 -0
- package/dist/richtext/index.js +243 -0
- package/dist/richtext/lexical.d.ts +23 -0
- package/dist/richtext/lexical.d.ts.map +1 -0
- package/dist/richtext/lexical.js +35 -0
- package/dist/security/audit.d.ts +188 -0
- package/dist/security/audit.d.ts.map +1 -0
- package/dist/security/audit.js +431 -0
- package/dist/security/auth.d.ts +241 -0
- package/dist/security/auth.d.ts.map +1 -0
- package/dist/security/auth.js +474 -0
- package/dist/security/authorization.d.ts +235 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/authorization.js +434 -0
- package/dist/security/encryption.d.ts +214 -0
- package/dist/security/encryption.d.ts.map +1 -0
- package/dist/security/encryption.js +506 -0
- package/dist/security/gdpr.d.ts +300 -0
- package/dist/security/gdpr.d.ts.map +1 -0
- package/dist/security/gdpr.js +470 -0
- package/dist/security/headers.d.ts +182 -0
- package/dist/security/headers.d.ts.map +1 -0
- package/dist/security/headers.js +402 -0
- package/dist/security/index.d.ts +19 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +18 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +28 -0
- package/dist/server/renderPage.d.ts +69 -0
- package/dist/server/renderPage.d.ts.map +1 -0
- package/dist/server/renderPage.js +109 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +4 -0
- package/dist/storage/vercel-blob.d.ts +17 -0
- package/dist/storage/vercel-blob.d.ts.map +1 -0
- package/dist/storage/vercel-blob.js +83 -0
- package/dist/translations/index.d.ts +17 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +1 -0
- package/dist/types/access.d.ts +67 -0
- package/dist/types/access.d.ts.map +1 -0
- package/dist/types/access.js +8 -0
- package/dist/types/api.d.ts +57 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +8 -0
- package/dist/types/cms.d.ts +8 -0
- package/dist/types/cms.d.ts.map +1 -0
- package/dist/types/cms.js +6 -0
- package/dist/types/config.d.ts +152 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +9 -0
- package/dist/types/core.d.ts +11 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +9 -0
- package/dist/types/extensions.d.ts +116 -0
- package/dist/types/extensions.d.ts.map +1 -0
- package/dist/types/extensions.js +8 -0
- package/dist/types/frontend.d.ts +53 -0
- package/dist/types/frontend.d.ts.map +1 -0
- package/dist/types/frontend.js +7 -0
- package/dist/types/generated.d.ts +14 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/generated.js +11 -0
- package/dist/types/hooks.d.ts +53 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/hooks.js +8 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +61 -0
- package/dist/types/interfaces/app.d.ts +50 -0
- package/dist/types/interfaces/app.d.ts.map +1 -0
- package/dist/types/interfaces/app.js +5 -0
- package/dist/types/jobs.d.ts +112 -0
- package/dist/types/jobs.d.ts.map +1 -0
- package/dist/types/jobs.js +7 -0
- package/dist/types/legacy.d.ts +147 -0
- package/dist/types/legacy.d.ts.map +1 -0
- package/dist/types/legacy.js +8 -0
- package/dist/types/plugins.d.ts +17 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/plugins.js +8 -0
- package/dist/types/query.d.ts +99 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +24 -0
- package/dist/types/request.d.ts +40 -0
- package/dist/types/request.d.ts.map +1 -0
- package/dist/types/request.js +8 -0
- package/dist/types/richtext.d.ts +23 -0
- package/dist/types/richtext.d.ts.map +1 -0
- package/dist/types/richtext.js +8 -0
- package/dist/types/runtime.d.ts +216 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/runtime.js +9 -0
- package/dist/types/schema.d.ts +9 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +7 -0
- package/dist/types/user.d.ts +48 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +8 -0
- package/dist/utils/access-conversion.d.ts +17 -0
- package/dist/utils/access-conversion.d.ts.map +1 -0
- package/dist/utils/access-conversion.js +96 -0
- package/dist/utils/api-wrapper.d.ts +63 -0
- package/dist/utils/api-wrapper.d.ts.map +1 -0
- package/dist/utils/api-wrapper.js +151 -0
- package/dist/utils/block-conversion.d.ts +21 -0
- package/dist/utils/block-conversion.d.ts.map +1 -0
- package/dist/utils/block-conversion.js +109 -0
- package/dist/utils/cache.d.ts +86 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +154 -0
- package/dist/utils/deep-clone.d.ts +25 -0
- package/dist/utils/deep-clone.d.ts.map +1 -0
- package/dist/utils/deep-clone.js +115 -0
- package/dist/utils/error-responses.d.ts +57 -0
- package/dist/utils/error-responses.d.ts.map +1 -0
- package/dist/utils/error-responses.js +96 -0
- package/dist/utils/errors.d.ts +97 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +397 -0
- package/dist/utils/field-conversion.d.ts +40 -0
- package/dist/utils/field-conversion.d.ts.map +1 -0
- package/dist/utils/field-conversion.js +275 -0
- package/dist/utils/flattenResult.d.ts +7 -0
- package/dist/utils/flattenResult.d.ts.map +1 -0
- package/dist/utils/flattenResult.js +23 -0
- package/dist/utils/getBlockSelect.d.ts +12 -0
- package/dist/utils/getBlockSelect.d.ts.map +1 -0
- package/dist/utils/getBlockSelect.js +12 -0
- package/dist/utils/getSelectMode.d.ts +8 -0
- package/dist/utils/getSelectMode.d.ts.map +1 -0
- package/dist/utils/getSelectMode.js +21 -0
- package/dist/utils/isValidID.d.ts +5 -0
- package/dist/utils/isValidID.d.ts.map +1 -0
- package/dist/utils/isValidID.js +13 -0
- package/dist/utils/json-parsing.d.ts +48 -0
- package/dist/utils/json-parsing.d.ts.map +1 -0
- package/dist/utils/json-parsing.js +130 -0
- package/dist/utils/jwt-validation.d.ts +14 -0
- package/dist/utils/jwt-validation.d.ts.map +1 -0
- package/dist/utils/jwt-validation.js +36 -0
- package/dist/utils/logger-client.d.ts +32 -0
- package/dist/utils/logger-client.d.ts.map +1 -0
- package/dist/utils/logger-client.js +55 -0
- package/dist/utils/logger-server.d.ts +32 -0
- package/dist/utils/logger-server.d.ts.map +1 -0
- package/dist/utils/logger-server.js +68 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +12 -0
- package/dist/utils/request-context.d.ts +143 -0
- package/dist/utils/request-context.d.ts.map +1 -0
- package/dist/utils/request-context.js +168 -0
- package/dist/utils/request-headers.d.ts +15 -0
- package/dist/utils/request-headers.d.ts.map +1 -0
- package/dist/utils/request-headers.js +31 -0
- package/dist/utils/stripUnselectedFields.d.ts +10 -0
- package/dist/utils/stripUnselectedFields.d.ts.map +1 -0
- package/dist/utils/stripUnselectedFields.js +20 -0
- package/dist/utils/type-guards.d.ts +33 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +63 -0
- package/dist/utils/user.d.ts +14 -0
- package/dist/utils/user.d.ts.map +1 -0
- package/dist/utils/user.js +15 -0
- package/package.json +250 -697
- package/LICENSE_SUMMARY.md +0 -55
- package/NOTICE +0 -34
- package/dist/core/gaurds/logger/log404/index.spec.snapshot-1 +0 -8
- package/dist/core/gaurds/logger/log404/index.spec.snapshot-2 +0 -9
- package/dist/exports/RenderErrorPage.js +0 -3
- package/dist/exports/__internal.js +0 -3
- package/dist/exports/abort.js +0 -3
- package/dist/exports/bin-entry.js +0 -17
- package/dist/exports/cli.js +0 -3
- package/dist/exports/client.js +0 -3
- package/dist/exports/config.js +0 -1
- package/dist/exports/helpers.js +0 -1
- package/dist/exports/index.js +0 -33
- package/dist/exports/plugin.js +0 -3
- package/dist/exports/prerender.js +0 -3
- package/dist/exports/router.js +0 -3
- package/dist/exports/routing.js +0 -3
- package/dist/exports/server.js +0 -3
- package/dist/exports/setup.js +0 -3
- package/dist/exports/types.js +0 -1
- package/dist/integration/styles.css +0 -141
- package/dist/node/cli/index.js +0 -18
- package/dist/shared/RenderErrorPage.d.ts +0 -3
- package/dist/shared/RenderErrorPage.js +0 -3
- package/dist/shared/abort.js +0 -3
- package/dist/shared/route/routing.js +0 -3
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Headers and CORS Configuration
|
|
3
|
+
*
|
|
4
|
+
* HTTP security headers and CORS policy management
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Security headers manager
|
|
8
|
+
*/
|
|
9
|
+
export class SecurityHeaders {
|
|
10
|
+
config;
|
|
11
|
+
constructor(config = {}) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get all security headers
|
|
16
|
+
*/
|
|
17
|
+
getHeaders() {
|
|
18
|
+
const headers = {};
|
|
19
|
+
// Content Security Policy
|
|
20
|
+
if (this.config.contentSecurityPolicy) {
|
|
21
|
+
headers['Content-Security-Policy'] = this.buildCSP(this.config.contentSecurityPolicy);
|
|
22
|
+
}
|
|
23
|
+
// Strict Transport Security
|
|
24
|
+
if (this.config.strictTransportSecurity) {
|
|
25
|
+
headers['Strict-Transport-Security'] = this.buildHSTS(this.config.strictTransportSecurity);
|
|
26
|
+
}
|
|
27
|
+
// X-Frame-Options
|
|
28
|
+
if (this.config.xFrameOptions) {
|
|
29
|
+
headers['X-Frame-Options'] = this.config.xFrameOptions;
|
|
30
|
+
}
|
|
31
|
+
// X-Content-Type-Options
|
|
32
|
+
if (this.config.xContentTypeOptions !== false) {
|
|
33
|
+
headers['X-Content-Type-Options'] = 'nosniff';
|
|
34
|
+
}
|
|
35
|
+
// Referrer-Policy
|
|
36
|
+
if (this.config.referrerPolicy) {
|
|
37
|
+
headers['Referrer-Policy'] = this.config.referrerPolicy;
|
|
38
|
+
}
|
|
39
|
+
// Permissions-Policy
|
|
40
|
+
if (this.config.permissionsPolicy) {
|
|
41
|
+
headers['Permissions-Policy'] = this.buildPermissionsPolicy(this.config.permissionsPolicy);
|
|
42
|
+
}
|
|
43
|
+
// Cross-Origin headers
|
|
44
|
+
if (this.config.crossOriginEmbedderPolicy) {
|
|
45
|
+
headers['Cross-Origin-Embedder-Policy'] = this.config.crossOriginEmbedderPolicy;
|
|
46
|
+
}
|
|
47
|
+
if (this.config.crossOriginOpenerPolicy) {
|
|
48
|
+
headers['Cross-Origin-Opener-Policy'] = this.config.crossOriginOpenerPolicy;
|
|
49
|
+
}
|
|
50
|
+
if (this.config.crossOriginResourcePolicy) {
|
|
51
|
+
headers['Cross-Origin-Resource-Policy'] = this.config.crossOriginResourcePolicy;
|
|
52
|
+
}
|
|
53
|
+
return headers;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build Content Security Policy header
|
|
57
|
+
*/
|
|
58
|
+
buildCSP(config) {
|
|
59
|
+
if (typeof config === 'string') {
|
|
60
|
+
return config;
|
|
61
|
+
}
|
|
62
|
+
const directives = [];
|
|
63
|
+
const addDirective = (name, values) => {
|
|
64
|
+
if (values && values.length > 0) {
|
|
65
|
+
directives.push(`${name} ${values.join(' ')}`);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
addDirective('default-src', config.defaultSrc);
|
|
69
|
+
addDirective('script-src', config.scriptSrc);
|
|
70
|
+
addDirective('style-src', config.styleSrc);
|
|
71
|
+
addDirective('img-src', config.imgSrc);
|
|
72
|
+
addDirective('font-src', config.fontSrc);
|
|
73
|
+
addDirective('connect-src', config.connectSrc);
|
|
74
|
+
addDirective('frame-src', config.frameSrc);
|
|
75
|
+
addDirective('object-src', config.objectSrc);
|
|
76
|
+
addDirective('media-src', config.mediaSrc);
|
|
77
|
+
addDirective('worker-src', config.workerSrc);
|
|
78
|
+
addDirective('child-src', config.childSrc);
|
|
79
|
+
addDirective('form-action', config.formAction);
|
|
80
|
+
addDirective('frame-ancestors', config.frameAncestors);
|
|
81
|
+
addDirective('base-uri', config.baseUri);
|
|
82
|
+
addDirective('manifest-src', config.manifestSrc);
|
|
83
|
+
if (config.upgradeInsecureRequests) {
|
|
84
|
+
directives.push('upgrade-insecure-requests');
|
|
85
|
+
}
|
|
86
|
+
if (config.blockAllMixedContent) {
|
|
87
|
+
directives.push('block-all-mixed-content');
|
|
88
|
+
}
|
|
89
|
+
if (config.reportUri) {
|
|
90
|
+
directives.push(`report-uri ${config.reportUri}`);
|
|
91
|
+
}
|
|
92
|
+
if (config.reportTo) {
|
|
93
|
+
directives.push(`report-to ${config.reportTo}`);
|
|
94
|
+
}
|
|
95
|
+
return directives.join('; ');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build HSTS header
|
|
99
|
+
*/
|
|
100
|
+
buildHSTS(config) {
|
|
101
|
+
if (config === true) {
|
|
102
|
+
return 'max-age=31536000; includeSubDomains';
|
|
103
|
+
}
|
|
104
|
+
if (config === false) {
|
|
105
|
+
return '';
|
|
106
|
+
}
|
|
107
|
+
// config is now HSTSConfig
|
|
108
|
+
const parts = [`max-age=${config.maxAge}`];
|
|
109
|
+
if (config.includeSubDomains) {
|
|
110
|
+
parts.push('includeSubDomains');
|
|
111
|
+
}
|
|
112
|
+
if (config.preload) {
|
|
113
|
+
parts.push('preload');
|
|
114
|
+
}
|
|
115
|
+
return parts.join('; ');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Build Permissions-Policy header
|
|
119
|
+
*/
|
|
120
|
+
buildPermissionsPolicy(config) {
|
|
121
|
+
if (typeof config === 'string') {
|
|
122
|
+
return config;
|
|
123
|
+
}
|
|
124
|
+
const policies = [];
|
|
125
|
+
Object.entries(config).forEach(([feature, origins]) => {
|
|
126
|
+
if (!origins || origins.length === 0) {
|
|
127
|
+
policies.push(`${feature}=()`);
|
|
128
|
+
}
|
|
129
|
+
else if (origins.includes('*')) {
|
|
130
|
+
policies.push(`${feature}=*`);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const originsList = origins.map((o) => `"${o}"`).join(' ');
|
|
134
|
+
policies.push(`${feature}=(${originsList})`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return policies.join(', ');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Apply headers to response
|
|
141
|
+
*/
|
|
142
|
+
applyHeaders(response) {
|
|
143
|
+
const headers = this.getHeaders();
|
|
144
|
+
Object.entries(headers).forEach(([name, value]) => {
|
|
145
|
+
response.headers.set(name, value);
|
|
146
|
+
});
|
|
147
|
+
return response;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* CORS manager
|
|
152
|
+
*/
|
|
153
|
+
export class CORSManager {
|
|
154
|
+
config;
|
|
155
|
+
constructor(config = {}) {
|
|
156
|
+
this.config = {
|
|
157
|
+
origin: config.origin ?? [],
|
|
158
|
+
methods: config.methods || ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
|
159
|
+
allowedHeaders: config.allowedHeaders || ['Content-Type', 'Authorization'],
|
|
160
|
+
exposedHeaders: config.exposedHeaders || [],
|
|
161
|
+
credentials: config.credentials ?? false,
|
|
162
|
+
maxAge: config.maxAge || 86400,
|
|
163
|
+
preflightContinue: config.preflightContinue ?? false,
|
|
164
|
+
optionsSuccessStatus: config.optionsSuccessStatus || 204,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Check if origin is allowed
|
|
169
|
+
*/
|
|
170
|
+
isOriginAllowed(origin) {
|
|
171
|
+
const { origin: allowedOrigin } = this.config;
|
|
172
|
+
if (allowedOrigin === '*') {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (typeof allowedOrigin === 'function') {
|
|
176
|
+
return allowedOrigin(origin);
|
|
177
|
+
}
|
|
178
|
+
if (typeof allowedOrigin === 'string') {
|
|
179
|
+
return origin === allowedOrigin;
|
|
180
|
+
}
|
|
181
|
+
if (Array.isArray(allowedOrigin)) {
|
|
182
|
+
return allowedOrigin.includes(origin);
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get CORS headers
|
|
188
|
+
*/
|
|
189
|
+
getCORSHeaders(origin) {
|
|
190
|
+
const headers = {};
|
|
191
|
+
// Access-Control-Allow-Origin
|
|
192
|
+
if (this.isOriginAllowed(origin)) {
|
|
193
|
+
headers['Access-Control-Allow-Origin'] = this.config.origin === '*' ? '*' : origin;
|
|
194
|
+
}
|
|
195
|
+
// Access-Control-Allow-Credentials — incompatible with origin: '*' per Fetch spec
|
|
196
|
+
if (this.config.credentials && this.config.origin !== '*') {
|
|
197
|
+
headers['Access-Control-Allow-Credentials'] = 'true';
|
|
198
|
+
}
|
|
199
|
+
// Access-Control-Expose-Headers
|
|
200
|
+
if (this.config.exposedHeaders.length > 0) {
|
|
201
|
+
headers['Access-Control-Expose-Headers'] = this.config.exposedHeaders.join(', ');
|
|
202
|
+
}
|
|
203
|
+
return headers;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get preflight headers
|
|
207
|
+
*/
|
|
208
|
+
getPreflightHeaders(origin) {
|
|
209
|
+
const headers = this.getCORSHeaders(origin);
|
|
210
|
+
// Access-Control-Allow-Methods
|
|
211
|
+
headers['Access-Control-Allow-Methods'] = this.config.methods.join(', ');
|
|
212
|
+
// Access-Control-Allow-Headers
|
|
213
|
+
headers['Access-Control-Allow-Headers'] = this.config.allowedHeaders.join(', ');
|
|
214
|
+
// Access-Control-Max-Age
|
|
215
|
+
headers['Access-Control-Max-Age'] = this.config.maxAge.toString();
|
|
216
|
+
return headers;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Handle CORS request
|
|
220
|
+
*/
|
|
221
|
+
handleRequest(request) {
|
|
222
|
+
const origin = request.headers.get('Origin');
|
|
223
|
+
if (!origin) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
// Handle preflight
|
|
227
|
+
if (request.method === 'OPTIONS') {
|
|
228
|
+
return this.handlePreflight(request, origin);
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Handle preflight request
|
|
234
|
+
*/
|
|
235
|
+
handlePreflight(_request, origin) {
|
|
236
|
+
if (!this.isOriginAllowed(origin)) {
|
|
237
|
+
return new Response(null, { status: 403 });
|
|
238
|
+
}
|
|
239
|
+
const headers = this.getPreflightHeaders(origin);
|
|
240
|
+
return new Response(null, {
|
|
241
|
+
status: this.config.optionsSuccessStatus,
|
|
242
|
+
headers,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Apply CORS headers to response
|
|
247
|
+
*/
|
|
248
|
+
applyHeaders(response, origin) {
|
|
249
|
+
if (!this.isOriginAllowed(origin)) {
|
|
250
|
+
return response;
|
|
251
|
+
}
|
|
252
|
+
const headers = this.getCORSHeaders(origin);
|
|
253
|
+
Object.entries(headers).forEach(([name, value]) => {
|
|
254
|
+
response.headers.set(name, value);
|
|
255
|
+
});
|
|
256
|
+
return response;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Common security header presets
|
|
261
|
+
*/
|
|
262
|
+
export const SecurityPresets = {
|
|
263
|
+
/**
|
|
264
|
+
* Strict security (recommended for production)
|
|
265
|
+
*/
|
|
266
|
+
strict: () => ({
|
|
267
|
+
contentSecurityPolicy: {
|
|
268
|
+
defaultSrc: ["'self'"],
|
|
269
|
+
scriptSrc: ["'self'"],
|
|
270
|
+
styleSrc: ["'self'", "'unsafe-inline'"],
|
|
271
|
+
imgSrc: ["'self'", 'data:', 'https:'],
|
|
272
|
+
fontSrc: ["'self'", 'data:'],
|
|
273
|
+
connectSrc: ["'self'"],
|
|
274
|
+
frameSrc: ["'none'"],
|
|
275
|
+
objectSrc: ["'none'"],
|
|
276
|
+
baseUri: ["'self'"],
|
|
277
|
+
formAction: ["'self'"],
|
|
278
|
+
frameAncestors: ["'none'"],
|
|
279
|
+
upgradeInsecureRequests: true,
|
|
280
|
+
},
|
|
281
|
+
strictTransportSecurity: {
|
|
282
|
+
maxAge: 31536000,
|
|
283
|
+
includeSubDomains: true,
|
|
284
|
+
preload: true,
|
|
285
|
+
},
|
|
286
|
+
xFrameOptions: 'DENY',
|
|
287
|
+
xContentTypeOptions: true,
|
|
288
|
+
referrerPolicy: 'strict-origin-when-cross-origin',
|
|
289
|
+
crossOriginEmbedderPolicy: 'require-corp',
|
|
290
|
+
crossOriginOpenerPolicy: 'same-origin',
|
|
291
|
+
crossOriginResourcePolicy: 'same-origin',
|
|
292
|
+
}),
|
|
293
|
+
/**
|
|
294
|
+
* Moderate security (balanced)
|
|
295
|
+
*/
|
|
296
|
+
moderate: () => ({
|
|
297
|
+
contentSecurityPolicy: {
|
|
298
|
+
defaultSrc: ["'self'"],
|
|
299
|
+
scriptSrc: ["'self'", "'unsafe-inline'"],
|
|
300
|
+
styleSrc: ["'self'", "'unsafe-inline'"],
|
|
301
|
+
imgSrc: ["'self'", 'data:', 'https:'],
|
|
302
|
+
fontSrc: ["'self'", 'data:', 'https:'],
|
|
303
|
+
connectSrc: ["'self'", 'https:'],
|
|
304
|
+
frameAncestors: ["'self'"],
|
|
305
|
+
},
|
|
306
|
+
strictTransportSecurity: {
|
|
307
|
+
maxAge: 31536000,
|
|
308
|
+
includeSubDomains: true,
|
|
309
|
+
},
|
|
310
|
+
xFrameOptions: 'SAMEORIGIN',
|
|
311
|
+
xContentTypeOptions: true,
|
|
312
|
+
referrerPolicy: 'origin-when-cross-origin',
|
|
313
|
+
}),
|
|
314
|
+
/**
|
|
315
|
+
* Development (permissive)
|
|
316
|
+
*/
|
|
317
|
+
development: () => ({
|
|
318
|
+
xContentTypeOptions: true,
|
|
319
|
+
referrerPolicy: 'no-referrer-when-downgrade',
|
|
320
|
+
}),
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Common CORS presets
|
|
324
|
+
*/
|
|
325
|
+
export const CORSPresets = {
|
|
326
|
+
/**
|
|
327
|
+
* Strict CORS (same origin only)
|
|
328
|
+
*/
|
|
329
|
+
strict: () => ({
|
|
330
|
+
origin: [],
|
|
331
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
332
|
+
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
333
|
+
credentials: true,
|
|
334
|
+
maxAge: 86400,
|
|
335
|
+
}),
|
|
336
|
+
/**
|
|
337
|
+
* Moderate CORS (specific origins)
|
|
338
|
+
*/
|
|
339
|
+
moderate: (allowedOrigins) => ({
|
|
340
|
+
origin: allowedOrigins,
|
|
341
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
|
342
|
+
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'],
|
|
343
|
+
exposedHeaders: ['X-Total-Count'],
|
|
344
|
+
credentials: true,
|
|
345
|
+
maxAge: 86400,
|
|
346
|
+
}),
|
|
347
|
+
/**
|
|
348
|
+
* Permissive CORS (all origins)
|
|
349
|
+
*/
|
|
350
|
+
permissive: () => ({
|
|
351
|
+
origin: '*',
|
|
352
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
|
353
|
+
allowedHeaders: ['*'],
|
|
354
|
+
credentials: false,
|
|
355
|
+
maxAge: 86400,
|
|
356
|
+
}),
|
|
357
|
+
/**
|
|
358
|
+
* API CORS (for public APIs)
|
|
359
|
+
*/
|
|
360
|
+
api: () => ({
|
|
361
|
+
origin: '*',
|
|
362
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
|
363
|
+
allowedHeaders: ['Content-Type', 'Authorization', 'X-API-Key'],
|
|
364
|
+
exposedHeaders: ['X-RateLimit-Limit', 'X-RateLimit-Remaining', 'X-RateLimit-Reset'],
|
|
365
|
+
credentials: false,
|
|
366
|
+
maxAge: 86400,
|
|
367
|
+
}),
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Security middleware creator
|
|
371
|
+
*/
|
|
372
|
+
export function createSecurityMiddleware(securityConfig, corsConfig) {
|
|
373
|
+
const security = new SecurityHeaders(securityConfig);
|
|
374
|
+
const cors = new CORSManager(corsConfig);
|
|
375
|
+
return async (request, next) => {
|
|
376
|
+
const origin = request.headers.get('Origin');
|
|
377
|
+
// Handle CORS preflight
|
|
378
|
+
if (origin && request.method === 'OPTIONS') {
|
|
379
|
+
const preflightResponse = cors.handleRequest(request);
|
|
380
|
+
if (preflightResponse) {
|
|
381
|
+
return preflightResponse;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// Process request
|
|
385
|
+
const response = await next();
|
|
386
|
+
// Apply security headers
|
|
387
|
+
security.applyHeaders(response);
|
|
388
|
+
// Apply CORS headers
|
|
389
|
+
if (origin) {
|
|
390
|
+
cors.applyHeaders(response, origin);
|
|
391
|
+
}
|
|
392
|
+
return response;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Rate limiting headers
|
|
397
|
+
*/
|
|
398
|
+
export function setRateLimitHeaders(response, limit, remaining, reset) {
|
|
399
|
+
response.headers.set('X-RateLimit-Limit', limit.toString());
|
|
400
|
+
response.headers.set('X-RateLimit-Remaining', remaining.toString());
|
|
401
|
+
response.headers.set('X-RateLimit-Reset', reset.toString());
|
|
402
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security & Compliance
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive security infrastructure for authentication, authorization,
|
|
5
|
+
* encryption, audit logging, GDPR compliance, and secure headers
|
|
6
|
+
*/
|
|
7
|
+
export type { AuditEvent, AuditEventType, AuditQuery, AuditSeverity, AuditStorage, } from './audit';
|
|
8
|
+
export { AuditReportGenerator, AuditSystem, AuditTrail, audit, createAuditMiddleware, InMemoryAuditStorage, } from './audit';
|
|
9
|
+
export type { AuthConfig, AuthSession, AuthToken, JWTPayload, OAuthConfig, User, } from './auth';
|
|
10
|
+
export { AuthSystem, OAuthClient, OAuthProviders, PasswordHasher, TwoFactorAuth, } from './auth';
|
|
11
|
+
export type { AuthorizationContext, Permission, Policy, PolicyCondition, Role, } from './authorization';
|
|
12
|
+
export { AuthorizationSystem, authorization, CommonRoles, canAccessResource, checkAttributeAccess, createAuthorizationMiddleware, PermissionBuilder, PermissionCache, PolicyBuilder, permissionCache, RequirePermission, RequireRole, } from './authorization';
|
|
13
|
+
export type { EncryptedData, EncryptionConfig, } from './encryption';
|
|
14
|
+
export { DataMasking, EncryptionSystem, EnvelopeEncryption, encryption, FieldEncryption, KeyRotationManager, TokenGenerator, } from './encryption';
|
|
15
|
+
export type { ConsentRecord, ConsentType, CookieConsentConfig, DataBreach, DataCategory, DataDeletionRequest, DataProcessingPurpose, PersonalDataExport, } from './gdpr';
|
|
16
|
+
export { ConsentManager, CookieConsentManager, consentManager, cookieConsentManager, DataAnonymization, DataBreachManager, DataDeletionSystem, DataExportSystem, dataBreachManager, dataDeletionSystem, dataExportSystem, PrivacyPolicyManager, privacyPolicyManager, } from './gdpr';
|
|
17
|
+
export type { CORSConfig, ContentSecurityPolicyConfig, HSTSConfig, PermissionsPolicyConfig, ReferrerPolicyValue, SecurityHeadersConfig, } from './headers';
|
|
18
|
+
export { CORSManager, CORSPresets, createSecurityMiddleware, SecurityHeaders, SecurityPresets, setRateLimitHeaders, } from './headers';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,SAAS,CAAA;AAEhB,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,KAAK,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,SAAS,CAAA;AAChB,YAAY,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,WAAW,EACX,IAAI,GACL,MAAM,QAAQ,CAAA;AAEf,OAAO,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,GACd,MAAM,QAAQ,CAAA;AACf,YAAY,EACV,oBAAoB,EACpB,UAAU,EACV,MAAM,EACN,eAAe,EACf,IAAI,GACL,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,6BAA6B,EAC7B,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,WAAW,GACZ,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACV,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,QAAQ,CAAA;AAEf,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,QAAQ,CAAA;AACf,YAAY,EACV,UAAU,EACV,2BAA2B,EAC3B,UAAU,EACV,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,WAAW,EACX,WAAW,EACX,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security & Compliance
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive security infrastructure for authentication, authorization,
|
|
5
|
+
* encryption, audit logging, GDPR compliance, and secure headers
|
|
6
|
+
*/
|
|
7
|
+
// Audit logging
|
|
8
|
+
export { AuditReportGenerator, AuditSystem, AuditTrail, audit, createAuditMiddleware, InMemoryAuditStorage, } from './audit';
|
|
9
|
+
// Authentication
|
|
10
|
+
export { AuthSystem, OAuthClient, OAuthProviders, PasswordHasher, TwoFactorAuth, } from './auth';
|
|
11
|
+
// Authorization
|
|
12
|
+
export { AuthorizationSystem, authorization, CommonRoles, canAccessResource, checkAttributeAccess, createAuthorizationMiddleware, PermissionBuilder, PermissionCache, PolicyBuilder, permissionCache, RequirePermission, RequireRole, } from './authorization';
|
|
13
|
+
// Encryption
|
|
14
|
+
export { DataMasking, EncryptionSystem, EnvelopeEncryption, encryption, FieldEncryption, KeyRotationManager, TokenGenerator, } from './encryption';
|
|
15
|
+
// GDPR compliance
|
|
16
|
+
export { ConsentManager, CookieConsentManager, consentManager, cookieConsentManager, DataAnonymization, DataBreachManager, DataDeletionSystem, DataExportSystem, dataBreachManager, dataDeletionSystem, dataExportSystem, PrivacyPolicyManager, privacyPolicyManager, } from './gdpr';
|
|
17
|
+
// Security headers
|
|
18
|
+
export { CORSManager, CORSPresets, createSecurityMiddleware, SecurityHeaders, SecurityPresets, setRateLimitHeaders, } from './headers';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RevealUI Core - Server Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Server-only exports for RevealUI framework.
|
|
5
|
+
* This module includes Node.js-specific utilities and should only be imported
|
|
6
|
+
* in server-side code (API routes, server components, middleware with nodejs runtime).
|
|
7
|
+
*
|
|
8
|
+
* WARNING: Do NOT import from this module in client components or edge runtime.
|
|
9
|
+
* Use '@revealui/core' or '@revealui/core/client' for client-safe exports.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This file does NOT use 'use server' directive as that's for Server Actions in Next.js,
|
|
12
|
+
* not for server-only modules. The separation is enforced through package.json exports.
|
|
13
|
+
*/
|
|
14
|
+
export { createRESTHandlers, handleRESTRequest } from '../api/rest.js';
|
|
15
|
+
export { universalPostgresAdapter } from '../database/universal-postgres.js';
|
|
16
|
+
export { vercelBlobStorage } from '../storage/vercel-blob.js';
|
|
17
|
+
export type { LogContext, Logger, LogLevel } from '../utils/logger-server.js';
|
|
18
|
+
export { createLogger, logger } from '../utils/logger-server.js';
|
|
19
|
+
export * from '../utils/request-context.js';
|
|
20
|
+
export { renderPage } from './renderPage.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEhE,cAAc,6BAA6B,CAAA;AAQ3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RevealUI Core - Server Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Server-only exports for RevealUI framework.
|
|
5
|
+
* This module includes Node.js-specific utilities and should only be imported
|
|
6
|
+
* in server-side code (API routes, server components, middleware with nodejs runtime).
|
|
7
|
+
*
|
|
8
|
+
* WARNING: Do NOT import from this module in client components or edge runtime.
|
|
9
|
+
* Use '@revealui/core' or '@revealui/core/client' for client-safe exports.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This file does NOT use 'use server' directive as that's for Server Actions in Next.js,
|
|
12
|
+
* not for server-only modules. The separation is enforced through package.json exports.
|
|
13
|
+
*/
|
|
14
|
+
// Server-only API handlers
|
|
15
|
+
export { createRESTHandlers, handleRESTRequest } from '../api/rest.js';
|
|
16
|
+
// Server-only database/storage
|
|
17
|
+
export { universalPostgresAdapter } from '../database/universal-postgres.js';
|
|
18
|
+
export { vercelBlobStorage } from '../storage/vercel-blob.js';
|
|
19
|
+
// Server-only logger with request context
|
|
20
|
+
export { createLogger, logger } from '../utils/logger-server.js';
|
|
21
|
+
// Request context utilities (server-only - uses async_hooks)
|
|
22
|
+
export * from '../utils/request-context.js';
|
|
23
|
+
// Monitoring (server-only due to request-context dependency)
|
|
24
|
+
// NOTE: Monitoring exports are commented out due to Sentry build-time import issues
|
|
25
|
+
// Import directly from '@revealui/core/monitoring' if needed
|
|
26
|
+
// export * from '../monitoring/index.js'
|
|
27
|
+
// Existing server functionality
|
|
28
|
+
export { renderPage } from './renderPage.js';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { PageContext } from '../types/frontend.js';
|
|
2
|
+
export type { PageContext, PageContextInit } from '../types/frontend.js';
|
|
3
|
+
/**
|
|
4
|
+
* Escape HTML entities to prevent XSS attacks.
|
|
5
|
+
*
|
|
6
|
+
* @param str - String to escape
|
|
7
|
+
* @returns Escaped string safe for HTML content
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* escapeHtml('<script>alert("xss")</script>')
|
|
12
|
+
* // Returns: '<script>alert("xss")</script>'
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function escapeHtml(str: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Options for rendering an HTML shell
|
|
18
|
+
*/
|
|
19
|
+
export interface HTMLShellOptions {
|
|
20
|
+
title?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
lang?: string;
|
|
23
|
+
charset?: string;
|
|
24
|
+
viewport?: string;
|
|
25
|
+
styles?: string[];
|
|
26
|
+
scripts?: string[];
|
|
27
|
+
headContent?: string;
|
|
28
|
+
bodyContent?: string;
|
|
29
|
+
bodyAttributes?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Render a basic HTML shell for SSR.
|
|
33
|
+
*
|
|
34
|
+
* @param options - Options for the HTML shell
|
|
35
|
+
* @returns Complete HTML document string
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const html = renderHTMLShell({
|
|
40
|
+
* title: 'My Page',
|
|
41
|
+
* description: 'A sample page',
|
|
42
|
+
* bodyContent: '<div id="root">Loading...</div>',
|
|
43
|
+
* styles: ['/styles/main.css'],
|
|
44
|
+
* scripts: ['/js/app.js'],
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function renderHTMLShell(options?: HTMLShellOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* Render a page to HTML string for server-side rendering.
|
|
51
|
+
*
|
|
52
|
+
* This is a framework-agnostic utility for basic SSR. For React Server Components
|
|
53
|
+
* and advanced features like Lexical rich text serialization, use the full
|
|
54
|
+
* SSR handler at apps/mainframe/src/server/revealui-handler.tsx.
|
|
55
|
+
*
|
|
56
|
+
* @param pageData - The page data to render
|
|
57
|
+
* @param context - Page context information
|
|
58
|
+
* @returns HTML string
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const html = renderPage(
|
|
63
|
+
* { title: 'Welcome', content: '<p>Hello world</p>' },
|
|
64
|
+
* { url: '/welcome', locale: 'en' }
|
|
65
|
+
* )
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function renderPage(pageData: unknown, context: PageContext): string;
|
|
69
|
+
//# sourceMappingURL=renderPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderPage.d.ts","sourceRoot":"","sources":["../../src/server/renderPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGvD,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAcxE;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CA6CtE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAoB1E"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML entity escaping map for preventing XSS
|
|
3
|
+
*/
|
|
4
|
+
const HTML_ESCAPE_MAP = {
|
|
5
|
+
'&': '&',
|
|
6
|
+
'<': '<',
|
|
7
|
+
'>': '>',
|
|
8
|
+
'"': '"',
|
|
9
|
+
"'": ''',
|
|
10
|
+
'/': '/',
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Escape HTML entities to prevent XSS attacks.
|
|
14
|
+
*
|
|
15
|
+
* @param str - String to escape
|
|
16
|
+
* @returns Escaped string safe for HTML content
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* escapeHtml('<script>alert("xss")</script>')
|
|
21
|
+
* // Returns: '<script>alert("xss")</script>'
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function escapeHtml(str) {
|
|
25
|
+
return str.replace(/[&<>"'/]/g, (char) => HTML_ESCAPE_MAP[char] || char);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Render a basic HTML shell for SSR.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Options for the HTML shell
|
|
31
|
+
* @returns Complete HTML document string
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const html = renderHTMLShell({
|
|
36
|
+
* title: 'My Page',
|
|
37
|
+
* description: 'A sample page',
|
|
38
|
+
* bodyContent: '<div id="root">Loading...</div>',
|
|
39
|
+
* styles: ['/styles/main.css'],
|
|
40
|
+
* scripts: ['/js/app.js'],
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function renderHTMLShell(options = {}) {
|
|
45
|
+
const { title = 'Page', description = '', lang = 'en', charset = 'UTF-8', viewport = 'width=device-width, initial-scale=1.0', styles = [], scripts = [], headContent = '', bodyContent = '', bodyAttributes = {}, } = options;
|
|
46
|
+
const escapedTitle = escapeHtml(title);
|
|
47
|
+
const escapedDescription = escapeHtml(description);
|
|
48
|
+
const styleLinks = styles
|
|
49
|
+
.map((href) => ` <link rel="stylesheet" href="${escapeHtml(href)}">`)
|
|
50
|
+
.join('\n');
|
|
51
|
+
const scriptTags = scripts
|
|
52
|
+
.map((src) => ` <script src="${escapeHtml(src)}" defer></script>`)
|
|
53
|
+
.join('\n');
|
|
54
|
+
const bodyAttrs = Object.entries(bodyAttributes)
|
|
55
|
+
.map(([key, value]) => `${escapeHtml(key)}="${escapeHtml(value)}"`)
|
|
56
|
+
.join(' ');
|
|
57
|
+
const bodyTag = bodyAttrs ? `<body ${bodyAttrs}>` : '<body>';
|
|
58
|
+
return `<!DOCTYPE html>
|
|
59
|
+
<html lang="${lang}">
|
|
60
|
+
<head>
|
|
61
|
+
<meta charset="${charset}">
|
|
62
|
+
<meta name="viewport" content="${viewport}">
|
|
63
|
+
<title>${escapedTitle}</title>
|
|
64
|
+
${escapedDescription ? `<meta name="description" content="${escapedDescription}">` : ''}
|
|
65
|
+
${styleLinks}
|
|
66
|
+
${headContent}
|
|
67
|
+
</head>
|
|
68
|
+
${bodyTag}
|
|
69
|
+
${bodyContent}
|
|
70
|
+
${scriptTags}
|
|
71
|
+
</body>
|
|
72
|
+
</html>`.trim();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Render a page to HTML string for server-side rendering.
|
|
76
|
+
*
|
|
77
|
+
* This is a framework-agnostic utility for basic SSR. For React Server Components
|
|
78
|
+
* and advanced features like Lexical rich text serialization, use the full
|
|
79
|
+
* SSR handler at apps/mainframe/src/server/revealui-handler.tsx.
|
|
80
|
+
*
|
|
81
|
+
* @param pageData - The page data to render
|
|
82
|
+
* @param context - Page context information
|
|
83
|
+
* @returns HTML string
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const html = renderPage(
|
|
88
|
+
* { title: 'Welcome', content: '<p>Hello world</p>' },
|
|
89
|
+
* { url: '/welcome', locale: 'en' }
|
|
90
|
+
* )
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export function renderPage(pageData, context) {
|
|
94
|
+
void context;
|
|
95
|
+
const data = pageData && typeof pageData === 'object' ? pageData : {};
|
|
96
|
+
const title = typeof data.title === 'string' ? data.title : 'Page';
|
|
97
|
+
const content = typeof data.content === 'string' ? data.content : '';
|
|
98
|
+
const description = typeof data.description === 'string' ? data.description : 'Generated by RevealUI CMS';
|
|
99
|
+
// Escape title and description, but allow content to contain safe HTML
|
|
100
|
+
const escapedTitle = escapeHtml(title);
|
|
101
|
+
return renderHTMLShell({
|
|
102
|
+
title,
|
|
103
|
+
description,
|
|
104
|
+
bodyContent: ` <div id="root">
|
|
105
|
+
<h1>${escapedTitle}</h1>
|
|
106
|
+
<div>${content}</div>
|
|
107
|
+
</div>`,
|
|
108
|
+
});
|
|
109
|
+
}
|