@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,474 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication System
|
|
3
|
+
*
|
|
4
|
+
* JWT-based authentication with session management, token refresh, and OAuth support
|
|
5
|
+
*/
|
|
6
|
+
import { createHmac, randomBytes } from 'node:crypto';
|
|
7
|
+
import { jwtVerify, SignJWT } from 'jose';
|
|
8
|
+
const DEFAULT_CONFIG = {
|
|
9
|
+
jwtAlgorithm: 'HS256',
|
|
10
|
+
accessTokenExpiry: 3600, // 1 hour
|
|
11
|
+
refreshTokenExpiry: 604800, // 7 days
|
|
12
|
+
issuer: 'revealui',
|
|
13
|
+
audience: 'revealui-app',
|
|
14
|
+
sessionTimeout: 1800, // 30 minutes
|
|
15
|
+
refreshThreshold: 300, // 5 minutes before expiry
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Authentication system
|
|
19
|
+
*/
|
|
20
|
+
export class AuthSystem {
|
|
21
|
+
static MAX_SESSIONS = 10_000;
|
|
22
|
+
config;
|
|
23
|
+
sessions = new Map();
|
|
24
|
+
refreshTokens = new Map(); // refreshToken -> userId
|
|
25
|
+
sessionCleanupInterval;
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
28
|
+
this.startSessionCleanup();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Authenticate user with credentials
|
|
32
|
+
*/
|
|
33
|
+
async authenticate(_email, _password, _deviceInfo) {
|
|
34
|
+
// This would integrate with your authentication backend
|
|
35
|
+
// For now, this is a placeholder implementation
|
|
36
|
+
throw new Error('Implement authenticate() with your auth backend');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create JWT token
|
|
40
|
+
*/
|
|
41
|
+
async createToken(user, expiresIn = this.config.accessTokenExpiry) {
|
|
42
|
+
const now = Math.floor(Date.now() / 1000);
|
|
43
|
+
const expiresAt = now + expiresIn;
|
|
44
|
+
const payload = {
|
|
45
|
+
sub: user.id,
|
|
46
|
+
email: user.email,
|
|
47
|
+
roles: user.roles,
|
|
48
|
+
permissions: user.permissions,
|
|
49
|
+
iat: now,
|
|
50
|
+
exp: expiresAt,
|
|
51
|
+
iss: this.config.issuer,
|
|
52
|
+
aud: this.config.audience,
|
|
53
|
+
};
|
|
54
|
+
const accessToken = await this.encodeJWT(payload);
|
|
55
|
+
// Create refresh token
|
|
56
|
+
const refreshToken = this.generateRefreshToken(user.id);
|
|
57
|
+
return {
|
|
58
|
+
accessToken,
|
|
59
|
+
refreshToken,
|
|
60
|
+
expiresAt: expiresAt * 1000, // Convert to ms
|
|
61
|
+
tokenType: 'Bearer',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Verify and decode JWT token
|
|
66
|
+
*/
|
|
67
|
+
async verifyToken(token) {
|
|
68
|
+
try {
|
|
69
|
+
const payload = await this.decodeJWT(token);
|
|
70
|
+
// Check expiration
|
|
71
|
+
const now = Math.floor(Date.now() / 1000);
|
|
72
|
+
if (payload.exp && payload.exp < now) {
|
|
73
|
+
throw new Error('Token expired');
|
|
74
|
+
}
|
|
75
|
+
// Check issuer
|
|
76
|
+
if (payload.iss !== this.config.issuer) {
|
|
77
|
+
throw new Error('Invalid token issuer');
|
|
78
|
+
}
|
|
79
|
+
// Check audience
|
|
80
|
+
if (payload.aud !== this.config.audience) {
|
|
81
|
+
throw new Error('Invalid token audience');
|
|
82
|
+
}
|
|
83
|
+
return payload;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new Error(`Token verification failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Refresh access token
|
|
91
|
+
*/
|
|
92
|
+
async refreshAccessToken(refreshToken) {
|
|
93
|
+
const userId = this.refreshTokens.get(refreshToken);
|
|
94
|
+
if (!userId) {
|
|
95
|
+
throw new Error('Invalid refresh token');
|
|
96
|
+
}
|
|
97
|
+
// Get user session
|
|
98
|
+
const session = Array.from(this.sessions.values()).find((s) => s.user.id === userId);
|
|
99
|
+
if (!session) {
|
|
100
|
+
throw new Error('Session not found');
|
|
101
|
+
}
|
|
102
|
+
// Create new access token
|
|
103
|
+
return await this.createToken(session.user);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create session
|
|
107
|
+
*/
|
|
108
|
+
createSession(user, token, deviceInfo) {
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
// Evict oldest session if at capacity
|
|
111
|
+
if (this.sessions.size >= AuthSystem.MAX_SESSIONS) {
|
|
112
|
+
let oldestKey;
|
|
113
|
+
let oldestTime = Number.POSITIVE_INFINITY;
|
|
114
|
+
for (const [key, session] of this.sessions.entries()) {
|
|
115
|
+
if (session.lastActivity < oldestTime) {
|
|
116
|
+
oldestTime = session.lastActivity;
|
|
117
|
+
oldestKey = key;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (oldestKey) {
|
|
121
|
+
this.destroySession(oldestKey);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const session = {
|
|
125
|
+
user,
|
|
126
|
+
token,
|
|
127
|
+
createdAt: now,
|
|
128
|
+
lastActivity: now,
|
|
129
|
+
expiresAt: now + this.config.sessionTimeout * 1000,
|
|
130
|
+
deviceInfo,
|
|
131
|
+
};
|
|
132
|
+
this.sessions.set(user.id, session);
|
|
133
|
+
if (token.refreshToken) {
|
|
134
|
+
this.refreshTokens.set(token.refreshToken, user.id);
|
|
135
|
+
}
|
|
136
|
+
return session;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get session
|
|
140
|
+
*/
|
|
141
|
+
getSession(userId) {
|
|
142
|
+
const session = this.sessions.get(userId);
|
|
143
|
+
if (!session) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
// Check if session expired
|
|
147
|
+
if (Date.now() > session.expiresAt) {
|
|
148
|
+
this.destroySession(userId);
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
return session;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Update session activity
|
|
155
|
+
*/
|
|
156
|
+
updateSessionActivity(userId) {
|
|
157
|
+
const session = this.sessions.get(userId);
|
|
158
|
+
if (session) {
|
|
159
|
+
session.lastActivity = Date.now();
|
|
160
|
+
session.expiresAt = Date.now() + this.config.sessionTimeout * 1000;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Destroy session
|
|
165
|
+
*/
|
|
166
|
+
destroySession(userId) {
|
|
167
|
+
const session = this.sessions.get(userId);
|
|
168
|
+
if (session?.token.refreshToken) {
|
|
169
|
+
this.refreshTokens.delete(session.token.refreshToken);
|
|
170
|
+
}
|
|
171
|
+
this.sessions.delete(userId);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Destroy all sessions for user
|
|
175
|
+
*/
|
|
176
|
+
destroyAllSessions(userId) {
|
|
177
|
+
this.destroySession(userId);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Check if token needs refresh
|
|
181
|
+
*/
|
|
182
|
+
shouldRefreshToken(token) {
|
|
183
|
+
const timeUntilExpiry = token.expiresAt - Date.now();
|
|
184
|
+
return timeUntilExpiry < this.config.refreshThreshold * 1000;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get user from token
|
|
188
|
+
*/
|
|
189
|
+
async getUserFromToken(token) {
|
|
190
|
+
try {
|
|
191
|
+
const payload = await this.verifyToken(token);
|
|
192
|
+
return {
|
|
193
|
+
id: payload.sub,
|
|
194
|
+
email: payload.email,
|
|
195
|
+
roles: payload.roles,
|
|
196
|
+
permissions: payload.permissions,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Encode JWT using jose library (Web Crypto API)
|
|
205
|
+
*/
|
|
206
|
+
async encodeJWT(payload) {
|
|
207
|
+
const secret = new TextEncoder().encode(this.config.jwtSecret);
|
|
208
|
+
const alg = this.config.jwtAlgorithm === 'RS256' ? 'RS256' : this.config.jwtAlgorithm;
|
|
209
|
+
const builder = new SignJWT({
|
|
210
|
+
email: payload.email,
|
|
211
|
+
roles: payload.roles,
|
|
212
|
+
permissions: payload.permissions,
|
|
213
|
+
})
|
|
214
|
+
.setProtectedHeader({ alg })
|
|
215
|
+
.setSubject(payload.sub)
|
|
216
|
+
.setIssuedAt(payload.iat)
|
|
217
|
+
.setExpirationTime(payload.exp);
|
|
218
|
+
if (payload.iss)
|
|
219
|
+
builder.setIssuer(payload.iss);
|
|
220
|
+
if (payload.aud)
|
|
221
|
+
builder.setAudience(payload.aud);
|
|
222
|
+
return builder.sign(secret);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Decode and verify JWT using jose library (Web Crypto API)
|
|
226
|
+
*/
|
|
227
|
+
async decodeJWT(token) {
|
|
228
|
+
const secret = new TextEncoder().encode(this.config.jwtSecret);
|
|
229
|
+
const { payload } = await jwtVerify(token, secret);
|
|
230
|
+
return payload;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Generate cryptographically secure refresh token
|
|
234
|
+
*/
|
|
235
|
+
generateRefreshToken(userId) {
|
|
236
|
+
const token = randomBytes(32).toString('hex');
|
|
237
|
+
return `${userId}.${token}`;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Start session cleanup interval
|
|
241
|
+
*/
|
|
242
|
+
startSessionCleanup() {
|
|
243
|
+
this.sessionCleanupInterval = setInterval(() => {
|
|
244
|
+
const now = Date.now();
|
|
245
|
+
for (const [userId, session] of this.sessions.entries()) {
|
|
246
|
+
if (now > session.expiresAt) {
|
|
247
|
+
this.destroySession(userId);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}, 60000); // Every minute
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Stop session cleanup
|
|
254
|
+
*/
|
|
255
|
+
destroy() {
|
|
256
|
+
if (this.sessionCleanupInterval) {
|
|
257
|
+
clearInterval(this.sessionCleanupInterval);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* OAuth provider configurations
|
|
263
|
+
*/
|
|
264
|
+
export const OAuthProviders = {
|
|
265
|
+
google: {
|
|
266
|
+
authorizationUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
267
|
+
tokenUrl: 'https://oauth2.googleapis.com/token',
|
|
268
|
+
userInfoUrl: 'https://www.googleapis.com/oauth2/v2/userinfo',
|
|
269
|
+
scope: ['openid', 'email', 'profile'],
|
|
270
|
+
},
|
|
271
|
+
github: {
|
|
272
|
+
authorizationUrl: 'https://github.com/login/oauth/authorize',
|
|
273
|
+
tokenUrl: 'https://github.com/login/oauth/access_token',
|
|
274
|
+
userInfoUrl: 'https://api.github.com/user',
|
|
275
|
+
scope: ['user:email'],
|
|
276
|
+
},
|
|
277
|
+
microsoft: {
|
|
278
|
+
authorizationUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
|
279
|
+
tokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
|
280
|
+
userInfoUrl: 'https://graph.microsoft.com/v1.0/me',
|
|
281
|
+
scope: ['openid', 'email', 'profile'],
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* OAuth client
|
|
286
|
+
*/
|
|
287
|
+
export class OAuthClient {
|
|
288
|
+
config;
|
|
289
|
+
constructor(config) {
|
|
290
|
+
this.config = {
|
|
291
|
+
...config,
|
|
292
|
+
...OAuthProviders[config.provider],
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Get authorization URL
|
|
297
|
+
*/
|
|
298
|
+
getAuthorizationUrl(state) {
|
|
299
|
+
const params = new URLSearchParams({
|
|
300
|
+
client_id: this.config.clientId,
|
|
301
|
+
redirect_uri: this.config.redirectUri,
|
|
302
|
+
response_type: 'code',
|
|
303
|
+
scope: (this.config.scope || []).join(' '),
|
|
304
|
+
});
|
|
305
|
+
if (state) {
|
|
306
|
+
params.append('state', state);
|
|
307
|
+
}
|
|
308
|
+
return `${this.config.authorizationUrl}?${params.toString()}`;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Exchange code for token
|
|
312
|
+
*/
|
|
313
|
+
async exchangeCodeForToken(code) {
|
|
314
|
+
const response = await fetch(this.config.tokenUrl, {
|
|
315
|
+
method: 'POST',
|
|
316
|
+
headers: {
|
|
317
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
318
|
+
},
|
|
319
|
+
body: new URLSearchParams({
|
|
320
|
+
client_id: this.config.clientId,
|
|
321
|
+
client_secret: this.config.clientSecret,
|
|
322
|
+
code,
|
|
323
|
+
grant_type: 'authorization_code',
|
|
324
|
+
redirect_uri: this.config.redirectUri,
|
|
325
|
+
}),
|
|
326
|
+
});
|
|
327
|
+
if (!response.ok) {
|
|
328
|
+
throw new Error('Failed to exchange code for token');
|
|
329
|
+
}
|
|
330
|
+
return response.json();
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Get user info
|
|
334
|
+
*/
|
|
335
|
+
async getUserInfo(accessToken) {
|
|
336
|
+
const response = await fetch(this.config.userInfoUrl, {
|
|
337
|
+
headers: {
|
|
338
|
+
Authorization: `Bearer ${accessToken}`,
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
if (!response.ok) {
|
|
342
|
+
throw new Error('Failed to fetch user info');
|
|
343
|
+
}
|
|
344
|
+
return response.json();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Password hashing utilities
|
|
349
|
+
*
|
|
350
|
+
* Uses PBKDF2 with a random salt for secure password hashing.
|
|
351
|
+
* For even stronger hashing, use bcryptjs (available in @revealui/auth).
|
|
352
|
+
*/
|
|
353
|
+
export class PasswordHasher {
|
|
354
|
+
static ITERATIONS = 100000;
|
|
355
|
+
static KEY_LENGTH = 64;
|
|
356
|
+
static DIGEST = 'sha512';
|
|
357
|
+
/**
|
|
358
|
+
* Hash password with PBKDF2 and random salt
|
|
359
|
+
*/
|
|
360
|
+
static async hash(password) {
|
|
361
|
+
const { pbkdf2, randomBytes: rb } = await import('node:crypto');
|
|
362
|
+
const salt = rb(16).toString('hex');
|
|
363
|
+
return new Promise((resolve, reject) => {
|
|
364
|
+
pbkdf2(password, salt, PasswordHasher.ITERATIONS, PasswordHasher.KEY_LENGTH, PasswordHasher.DIGEST, (err, derivedKey) => {
|
|
365
|
+
if (err)
|
|
366
|
+
reject(err);
|
|
367
|
+
else
|
|
368
|
+
resolve(`${salt}:${derivedKey.toString('hex')}`);
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Verify password against stored hash
|
|
374
|
+
*/
|
|
375
|
+
static async verify(password, storedHash) {
|
|
376
|
+
const { pbkdf2, timingSafeEqual } = await import('node:crypto');
|
|
377
|
+
const [salt, hash] = storedHash.split(':');
|
|
378
|
+
if (!(salt && hash)) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
return new Promise((resolve, reject) => {
|
|
382
|
+
pbkdf2(password, salt, PasswordHasher.ITERATIONS, PasswordHasher.KEY_LENGTH, PasswordHasher.DIGEST, (err, derivedKey) => {
|
|
383
|
+
if (err)
|
|
384
|
+
reject(err);
|
|
385
|
+
else {
|
|
386
|
+
const derived = Buffer.from(derivedKey.toString('hex'), 'utf-8');
|
|
387
|
+
const expected = Buffer.from(hash, 'utf-8');
|
|
388
|
+
if (derived.length !== expected.length) {
|
|
389
|
+
resolve(false);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
resolve(timingSafeEqual(derived, expected));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Two-factor authentication
|
|
401
|
+
*/
|
|
402
|
+
export class TwoFactorAuth {
|
|
403
|
+
/**
|
|
404
|
+
* Generate TOTP secret
|
|
405
|
+
*/
|
|
406
|
+
static generateSecret() {
|
|
407
|
+
const crypto = globalThis.crypto;
|
|
408
|
+
if (!crypto) {
|
|
409
|
+
throw new Error('Crypto API not available');
|
|
410
|
+
}
|
|
411
|
+
const buffer = new Uint8Array(20);
|
|
412
|
+
crypto.getRandomValues(buffer);
|
|
413
|
+
return TwoFactorAuth.base32Encode(buffer);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Generate TOTP code
|
|
417
|
+
*/
|
|
418
|
+
static generateCode(secret, timestamp) {
|
|
419
|
+
const time = Math.floor((timestamp || Date.now()) / 30000);
|
|
420
|
+
const hmacDigest = TwoFactorAuth.hmac(secret, time.toString());
|
|
421
|
+
const offset = hmacDigest[hmacDigest.length - 1] & 0x0f;
|
|
422
|
+
const code = (((hmacDigest[offset] & 0x7f) << 24) |
|
|
423
|
+
((hmacDigest[offset + 1] & 0xff) << 16) |
|
|
424
|
+
((hmacDigest[offset + 2] & 0xff) << 8) |
|
|
425
|
+
(hmacDigest[offset + 3] & 0xff)) %
|
|
426
|
+
1000000;
|
|
427
|
+
return code.toString().padStart(6, '0');
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Verify TOTP code
|
|
431
|
+
*/
|
|
432
|
+
static verifyCode(secret, code, window = 1) {
|
|
433
|
+
const timestamp = Date.now();
|
|
434
|
+
// Check current and adjacent time windows
|
|
435
|
+
for (let i = -window; i <= window; i++) {
|
|
436
|
+
const testTime = timestamp + i * 30000;
|
|
437
|
+
const testCode = TwoFactorAuth.generateCode(secret, testTime);
|
|
438
|
+
if (testCode === code) {
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Base32 encode
|
|
446
|
+
*/
|
|
447
|
+
static base32Encode(buffer) {
|
|
448
|
+
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
449
|
+
let result = '';
|
|
450
|
+
let bits = 0;
|
|
451
|
+
let value = 0;
|
|
452
|
+
for (const byte of buffer) {
|
|
453
|
+
if (byte === undefined)
|
|
454
|
+
continue;
|
|
455
|
+
value = (value << 8) | byte;
|
|
456
|
+
bits += 8;
|
|
457
|
+
while (bits >= 5) {
|
|
458
|
+
result += alphabet[(value >>> (bits - 5)) & 31];
|
|
459
|
+
bits -= 5;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (bits > 0) {
|
|
463
|
+
result += alphabet[(value << (5 - bits)) & 31];
|
|
464
|
+
}
|
|
465
|
+
return result;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* HMAC-SHA1 implementation for TOTP
|
|
469
|
+
*/
|
|
470
|
+
static hmac(key, message) {
|
|
471
|
+
const hmacDigest = createHmac('sha1', key).update(message).digest();
|
|
472
|
+
return new Uint8Array(hmacDigest);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authorization System
|
|
3
|
+
*
|
|
4
|
+
* Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC)
|
|
5
|
+
*/
|
|
6
|
+
export interface Permission {
|
|
7
|
+
resource: string;
|
|
8
|
+
action: string;
|
|
9
|
+
conditions?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export interface Role {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
permissions: Permission[];
|
|
16
|
+
inherits?: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface Policy {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
effect: 'allow' | 'deny';
|
|
22
|
+
resources: string[];
|
|
23
|
+
actions: string[];
|
|
24
|
+
conditions?: PolicyCondition[];
|
|
25
|
+
priority?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface PolicyCondition {
|
|
28
|
+
field: string;
|
|
29
|
+
operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains';
|
|
30
|
+
value: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface AuthorizationContext {
|
|
33
|
+
user: {
|
|
34
|
+
id: string;
|
|
35
|
+
roles: string[];
|
|
36
|
+
attributes?: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
resource?: {
|
|
39
|
+
type: string;
|
|
40
|
+
id?: string;
|
|
41
|
+
owner?: string;
|
|
42
|
+
attributes?: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
environment?: {
|
|
45
|
+
time?: Date;
|
|
46
|
+
ip?: string;
|
|
47
|
+
userAgent?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Authorization system
|
|
52
|
+
*/
|
|
53
|
+
export declare class AuthorizationSystem {
|
|
54
|
+
private roles;
|
|
55
|
+
private policies;
|
|
56
|
+
/**
|
|
57
|
+
* Register role
|
|
58
|
+
*/
|
|
59
|
+
registerRole(role: Role): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get role
|
|
62
|
+
*/
|
|
63
|
+
getRole(roleId: string): Role | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Register policy
|
|
66
|
+
*/
|
|
67
|
+
registerPolicy(policy: Policy): void;
|
|
68
|
+
/**
|
|
69
|
+
* Check if user has permission (RBAC)
|
|
70
|
+
*/
|
|
71
|
+
hasPermission(userRoles: string[], resource: string, action: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Check access with policies (ABAC)
|
|
74
|
+
*/
|
|
75
|
+
checkAccess(context: AuthorizationContext, resource: string, action: string): {
|
|
76
|
+
allowed: boolean;
|
|
77
|
+
reason?: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Get all permissions for roles
|
|
81
|
+
*/
|
|
82
|
+
private getUserPermissions;
|
|
83
|
+
/**
|
|
84
|
+
* Get applicable policies
|
|
85
|
+
*/
|
|
86
|
+
private getApplicablePolicies;
|
|
87
|
+
/**
|
|
88
|
+
* Match resource pattern
|
|
89
|
+
*/
|
|
90
|
+
private matchesResource;
|
|
91
|
+
/**
|
|
92
|
+
* Match action pattern
|
|
93
|
+
*/
|
|
94
|
+
private matchesAction;
|
|
95
|
+
/**
|
|
96
|
+
* Evaluate policy conditions
|
|
97
|
+
*/
|
|
98
|
+
private evaluateConditions;
|
|
99
|
+
/**
|
|
100
|
+
* Get value from context
|
|
101
|
+
*/
|
|
102
|
+
private getContextValue;
|
|
103
|
+
/**
|
|
104
|
+
* Evaluate single condition
|
|
105
|
+
*/
|
|
106
|
+
private evaluateCondition;
|
|
107
|
+
/**
|
|
108
|
+
* Check if user owns resource
|
|
109
|
+
*/
|
|
110
|
+
ownsResource(userId: string, resource: {
|
|
111
|
+
owner?: string;
|
|
112
|
+
}): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Clear all roles and policies
|
|
115
|
+
*/
|
|
116
|
+
clear(): void;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Global authorization instance
|
|
120
|
+
*/
|
|
121
|
+
export declare const authorization: AuthorizationSystem;
|
|
122
|
+
/**
|
|
123
|
+
* Common roles
|
|
124
|
+
*/
|
|
125
|
+
export declare const CommonRoles: {
|
|
126
|
+
admin: {
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
description: string;
|
|
130
|
+
permissions: {
|
|
131
|
+
resource: string;
|
|
132
|
+
action: string;
|
|
133
|
+
}[];
|
|
134
|
+
};
|
|
135
|
+
user: {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
description: string;
|
|
139
|
+
permissions: {
|
|
140
|
+
resource: string;
|
|
141
|
+
action: string;
|
|
142
|
+
}[];
|
|
143
|
+
};
|
|
144
|
+
guest: {
|
|
145
|
+
id: string;
|
|
146
|
+
name: string;
|
|
147
|
+
description: string;
|
|
148
|
+
permissions: {
|
|
149
|
+
resource: string;
|
|
150
|
+
action: string;
|
|
151
|
+
}[];
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Permission builder
|
|
156
|
+
*/
|
|
157
|
+
export declare class PermissionBuilder {
|
|
158
|
+
private permission;
|
|
159
|
+
resource(resource: string): this;
|
|
160
|
+
action(action: string): this;
|
|
161
|
+
conditions(conditions: Record<string, unknown>): this;
|
|
162
|
+
build(): Permission;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Policy builder
|
|
166
|
+
*/
|
|
167
|
+
export declare class PolicyBuilder {
|
|
168
|
+
private policy;
|
|
169
|
+
id(id: string): this;
|
|
170
|
+
name(name: string): this;
|
|
171
|
+
allow(): this;
|
|
172
|
+
deny(): this;
|
|
173
|
+
resources(...resources: string[]): this;
|
|
174
|
+
actions(...actions: string[]): this;
|
|
175
|
+
condition(field: string, operator: PolicyCondition['operator'], value: unknown): this;
|
|
176
|
+
priority(priority: number): this;
|
|
177
|
+
build(): Policy;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Authorization decorators
|
|
181
|
+
*/
|
|
182
|
+
export declare function RequirePermission(resource: string, action: string): (_target: object, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
183
|
+
export declare function RequireRole(requiredRole: string): (_target: object, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
184
|
+
/**
|
|
185
|
+
* Authorization middleware
|
|
186
|
+
*/
|
|
187
|
+
export declare function createAuthorizationMiddleware<TRequest = unknown>(getUser: (request: TRequest) => {
|
|
188
|
+
id: string;
|
|
189
|
+
roles: string[];
|
|
190
|
+
}, resource: string, action: string): (request: TRequest, next: () => Promise<unknown>) => Promise<unknown>;
|
|
191
|
+
/**
|
|
192
|
+
* Resource ownership check
|
|
193
|
+
*/
|
|
194
|
+
export declare function canAccessResource(userId: string, userRoles: string[], resource: {
|
|
195
|
+
type: string;
|
|
196
|
+
id?: string;
|
|
197
|
+
owner?: string;
|
|
198
|
+
}, action: string): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Attribute-based access control helper
|
|
201
|
+
*/
|
|
202
|
+
export declare function checkAttributeAccess(context: AuthorizationContext, resource: string, action: string, requiredAttributes?: Record<string, unknown>): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Permission cache for performance
|
|
205
|
+
*/
|
|
206
|
+
export declare class PermissionCache {
|
|
207
|
+
private cache;
|
|
208
|
+
private ttl;
|
|
209
|
+
constructor(ttl?: number);
|
|
210
|
+
/**
|
|
211
|
+
* Get cached permission
|
|
212
|
+
*/
|
|
213
|
+
get(userId: string, resource: string, action: string): boolean | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Set cached permission
|
|
216
|
+
*/
|
|
217
|
+
set(userId: string, resource: string, action: string, allowed: boolean): void;
|
|
218
|
+
/**
|
|
219
|
+
* Clear cache for user
|
|
220
|
+
*/
|
|
221
|
+
clearUser(userId: string): void;
|
|
222
|
+
/**
|
|
223
|
+
* Clear all cache
|
|
224
|
+
*/
|
|
225
|
+
clear(): void;
|
|
226
|
+
/**
|
|
227
|
+
* Get cache key
|
|
228
|
+
*/
|
|
229
|
+
private getCacheKey;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Global permission cache
|
|
233
|
+
*/
|
|
234
|
+
export declare const permissionCache: PermissionCache;
|
|
235
|
+
//# sourceMappingURL=authorization.d.ts.map
|