@revealui/core 0.2.1 → 0.5.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/dist/api/compression.d.ts.map +1 -1
- package/dist/api/payload-optimization.d.ts.map +1 -1
- package/dist/api/rate-limit.d.ts +29 -28
- package/dist/api/rate-limit.d.ts.map +1 -1
- package/dist/api/rate-limit.js +63 -3
- package/dist/api/response-cache.d.ts.map +1 -1
- package/dist/api/response-cache.js +1 -1
- package/dist/api/rest.d.ts.map +1 -1
- package/dist/api/rest.js +3 -2
- package/dist/auth/access.d.ts.map +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/cache/query-cache.d.ts +12 -10
- package/dist/cache/query-cache.d.ts.map +1 -1
- package/dist/cache/query-cache.js +38 -42
- package/dist/caching/index.d.ts +6 -0
- package/dist/caching/index.d.ts.map +1 -0
- package/dist/caching/index.js +5 -0
- package/dist/client/admin/RichText.d.ts +1 -1
- package/dist/client/admin/RichText.d.ts.map +1 -1
- package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -1
- package/dist/client/admin/components/AdminDashboard.js +195 -205
- package/dist/client/admin/components/CollectionList.d.ts.map +1 -1
- package/dist/client/admin/components/DocumentForm.d.ts.map +1 -1
- package/dist/client/admin/components/DocumentForm.js +130 -6
- package/dist/client/admin/components/GlobalForm.d.ts.map +1 -1
- package/dist/client/admin/context/ServerFunctionContext.d.ts +8 -0
- package/dist/client/admin/context/ServerFunctionContext.d.ts.map +1 -0
- package/dist/client/admin/context/ServerFunctionContext.js +15 -0
- package/dist/client/admin/i18n/en.d.ts.map +1 -1
- package/dist/client/admin/index.d.ts +1 -0
- package/dist/client/admin/index.d.ts.map +1 -1
- package/dist/client/admin/index.js +1 -0
- package/dist/client/admin/layout.d.ts +1 -1
- package/dist/client/admin/layout.d.ts.map +1 -1
- package/dist/client/admin/layout.js +3 -2
- package/dist/client/admin/page.d.ts.map +1 -1
- package/dist/client/admin/utils/apiClient.d.ts.map +1 -1
- package/dist/client/admin/utils/apiClient.js +0 -4
- package/dist/client/admin/utils/index.d.ts +0 -1
- package/dist/client/admin/utils/index.d.ts.map +1 -1
- package/dist/client/admin/utils/index.js +0 -1
- package/dist/client/admin/utils/serializeConfig.d.ts.map +1 -1
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/richtext/RichTextEditor.d.ts.map +1 -1
- package/dist/client/richtext/components/ImageNodeComponent.d.ts.map +1 -1
- package/dist/client/richtext/components/ImageNodeComponent.js +0 -1
- package/dist/client/richtext/components/ImageUploadButton.d.ts +2 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts.map +1 -1
- package/dist/client/richtext/components/ImageUploadButton.js +30 -15
- package/dist/client/richtext/index.d.ts.map +1 -1
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts.map +1 -1
- package/dist/client/richtext/nodes/ImageNode.d.ts.map +1 -1
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
- package/dist/client/richtext/plugins/ImagePlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts.map +1 -1
- package/dist/client/ui/index.d.ts.map +1 -1
- package/dist/client/ui/index.js +1 -1
- package/dist/collections/CollectionOperations.d.ts +7 -7
- package/dist/collections/CollectionOperations.d.ts.map +1 -1
- package/dist/collections/CollectionOperations.js +15 -1
- package/dist/collections/hooks.d.ts.map +1 -1
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/collections/operations/create.d.ts +4 -5
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +35 -6
- package/dist/collections/operations/createMany.d.ts +12 -0
- package/dist/collections/operations/createMany.d.ts.map +1 -0
- package/dist/collections/operations/createMany.js +43 -0
- package/dist/collections/operations/delete.d.ts +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +31 -2
- package/dist/collections/operations/deleteMany.d.ts +11 -0
- package/dist/collections/operations/deleteMany.d.ts.map +1 -0
- package/dist/collections/operations/deleteMany.js +50 -0
- package/dist/collections/operations/fieldHooks.d.ts +2 -2
- package/dist/collections/operations/fieldHooks.d.ts.map +1 -1
- package/dist/collections/operations/fieldHooks.js +4 -4
- package/dist/collections/operations/find.d.ts +2 -4
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +115 -8
- package/dist/collections/operations/findById.d.ts +3 -4
- package/dist/collections/operations/findById.d.ts.map +1 -1
- package/dist/collections/operations/findById.js +53 -1
- package/dist/collections/operations/sqlAdapter.d.ts +23 -0
- package/dist/collections/operations/sqlAdapter.d.ts.map +1 -0
- package/dist/collections/operations/sqlAdapter.js +76 -0
- package/dist/collections/operations/update.d.ts +3 -5
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +103 -11
- package/dist/collections/operations/updateMany.d.ts +11 -0
- package/dist/collections/operations/updateMany.d.ts.map +1 -0
- package/dist/collections/operations/updateMany.js +52 -0
- package/dist/collections/registry.d.ts +12 -0
- package/dist/collections/registry.d.ts.map +1 -0
- package/dist/collections/registry.js +38 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/utils.d.ts +0 -10
- package/dist/config/utils.d.ts.map +1 -1
- package/dist/config/utils.js +0 -13
- package/dist/database/index.d.ts +3 -0
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +1 -5
- package/dist/database/safe-parse.d.ts.map +1 -1
- package/dist/database/ssl-config.d.ts.map +1 -1
- package/dist/database/type-adapter.d.ts.map +1 -1
- package/dist/database/universal-postgres.d.ts.map +1 -1
- package/dist/database/universal-postgres.js +6 -1
- package/dist/dataloader.d.ts.map +1 -1
- package/dist/error-handling/error-boundary.d.ts.map +1 -1
- package/dist/error-handling/error-reporter.d.ts +1 -1
- package/dist/error-handling/error-reporter.d.ts.map +1 -1
- package/dist/error-handling/error-reporter.js +19 -5
- package/dist/error-handling/fallback-components.d.ts.map +1 -1
- package/dist/error-handling/fallback-components.js +1 -1
- package/dist/error-handling/index.d.ts +2 -4
- package/dist/error-handling/index.d.ts.map +1 -1
- package/dist/error-handling/index.js +1 -4
- package/dist/factories/builders.d.ts.map +1 -1
- package/dist/factories/index.d.ts.map +1 -1
- package/dist/features.d.ts +7 -7
- package/dist/features.d.ts.map +1 -1
- package/dist/features.js +2 -2
- package/dist/fieldTraversal.d.ts.map +1 -1
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/getDefaultValue.d.ts.map +1 -1
- package/dist/fields/getFieldPaths.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/generated/types/cms.d.ts.map +1 -1
- package/dist/generated/types/cms.js +0 -1
- package/dist/generated/types/neon.d.ts.map +1 -1
- package/dist/generated/types/neon.js +4 -2
- package/dist/globals/GlobalOperations.d.ts.map +1 -1
- package/dist/globals/GlobalOperations.js +16 -4
- package/dist/globals/index.d.ts.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/instance/RevealUIInstance.d.ts.map +1 -1
- package/dist/instance/RevealUIInstance.js +6 -19
- package/dist/instance/index.d.ts.map +1 -1
- package/dist/instance/logger.d.ts.map +1 -1
- package/dist/instance/methods/create.d.ts.map +1 -1
- package/dist/instance/methods/create.js +0 -3
- package/dist/instance/methods/delete.d.ts.map +1 -1
- package/dist/instance/methods/delete.js +1 -4
- package/dist/instance/methods/find.d.ts.map +1 -1
- package/dist/instance/methods/find.js +0 -3
- package/dist/instance/methods/findById.d.ts.map +1 -1
- package/dist/instance/methods/findById.js +0 -3
- package/dist/instance/methods/hooks.d.ts.map +1 -1
- package/dist/instance/methods/update.d.ts.map +1 -1
- package/dist/instance/methods/update.js +0 -3
- package/dist/jobs/index.d.ts +16 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +14 -0
- package/dist/jobs/queue.d.ts +57 -0
- package/dist/jobs/queue.d.ts.map +1 -0
- package/dist/jobs/queue.js +134 -0
- package/dist/license-encryption.d.ts +21 -0
- package/dist/license-encryption.d.ts.map +1 -0
- package/dist/license-encryption.js +74 -0
- package/dist/license.d.ts +26 -3
- package/dist/license.d.ts.map +1 -1
- package/dist/license.js +87 -7
- package/dist/monitoring/alerts.d.ts +4 -4
- package/dist/monitoring/alerts.d.ts.map +1 -1
- package/dist/monitoring/cleanup-manager.d.ts.map +1 -1
- package/dist/monitoring/health-monitor.d.ts.map +1 -1
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/process-registry.d.ts.map +1 -1
- package/dist/monitoring/query-monitor.d.ts.map +1 -1
- package/dist/monitoring/types.d.ts.map +1 -1
- package/dist/monitoring/zombie-detector.d.ts.map +1 -1
- package/dist/monitoring/zombie-detector.js +5 -0
- package/dist/nextjs/index.d.ts.map +1 -1
- package/dist/nextjs/utilities.d.ts.map +1 -1
- package/dist/nextjs/withRevealUI.d.ts.map +1 -1
- package/dist/observability/alerts.d.ts.map +1 -1
- package/dist/observability/alerts.js +1 -2
- package/dist/observability/health-check.d.ts +0 -4
- package/dist/observability/health-check.d.ts.map +1 -1
- package/dist/observability/health-check.js +0 -36
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/logger.d.ts.map +1 -1
- package/dist/observability/logger.js +1 -1
- package/dist/observability/metrics.d.ts.map +1 -1
- package/dist/observability/tracing.d.ts.map +1 -1
- package/dist/observability/tracing.js +0 -1
- package/dist/plugins/form-builder.d.ts.map +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/nested-docs.d.ts +4 -0
- package/dist/plugins/nested-docs.d.ts.map +1 -1
- package/dist/plugins/nested-docs.js +50 -6
- package/dist/plugins/redirects.d.ts.map +1 -1
- package/dist/queries/index.d.ts.map +1 -1
- package/dist/queries/queryBuilder.d.ts.map +1 -1
- package/dist/queries/queryBuilder.js +13 -5
- package/dist/relationships/analyzer.d.ts.map +1 -1
- package/dist/relationships/analyzer.js +8 -0
- package/dist/relationships/index.d.ts.map +1 -1
- package/dist/relationships/populate-core.d.ts +57 -0
- package/dist/relationships/populate-core.d.ts.map +1 -0
- package/dist/relationships/populate-core.js +116 -0
- package/dist/relationships/populate-helpers.d.ts +5 -51
- package/dist/relationships/populate-helpers.d.ts.map +1 -1
- package/dist/relationships/populate-helpers.js +4 -109
- package/dist/relationships/population.d.ts +1 -9
- package/dist/relationships/population.d.ts.map +1 -1
- package/dist/relationships/population.js +8 -3
- package/dist/revealui.d.ts.map +1 -1
- package/dist/richtext/exports/client/rcc.d.ts.map +1 -1
- package/dist/richtext/exports/client/rcc.js +1 -1
- package/dist/richtext/exports/server/rsc.d.ts +17 -0
- package/dist/richtext/exports/server/rsc.d.ts.map +1 -1
- package/dist/richtext/exports/server/rsc.js +61 -5
- package/dist/richtext/index.d.ts.map +1 -1
- package/dist/richtext/lexical.d.ts.map +1 -1
- package/dist/security/index.d.ts +3 -16
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +3 -16
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/renderPage.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -4
- package/dist/storage/vercel-blob.d.ts.map +1 -1
- package/dist/storage/vercel-blob.js +3 -0
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/types/access.d.ts.map +1 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/cms.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/extensions.d.ts.map +1 -1
- package/dist/types/frontend.d.ts.map +1 -1
- package/dist/types/generated.d.ts.map +1 -1
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/app.d.ts.map +1 -1
- package/dist/types/jobs.d.ts.map +1 -1
- package/dist/types/legacy.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/query.d.ts.map +1 -1
- package/dist/types/request.d.ts.map +1 -1
- package/dist/types/richtext.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +60 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/user.d.ts.map +1 -1
- package/dist/utils/access-conversion.d.ts.map +1 -1
- package/dist/utils/api-wrapper.d.ts.map +1 -1
- package/dist/utils/api-wrapper.js +1 -1
- package/dist/utils/block-conversion.d.ts.map +1 -1
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/deep-clone.js +0 -1
- package/dist/utils/error-responses.d.ts.map +1 -1
- package/dist/utils/error-responses.js +2 -3
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +103 -0
- package/dist/utils/field-conversion.d.ts +1 -1
- package/dist/utils/field-conversion.d.ts.map +1 -1
- package/dist/utils/flattenResult.d.ts.map +1 -1
- package/dist/utils/flattenResult.js +0 -1
- package/dist/utils/getBlockSelect.d.ts.map +1 -1
- package/dist/utils/getSelectMode.d.ts.map +1 -1
- package/dist/utils/isValidID.d.ts.map +1 -1
- package/dist/utils/json-parsing.d.ts.map +1 -1
- package/dist/utils/logger-client.d.ts.map +1 -1
- package/dist/utils/logger-server.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/request-context.d.ts.map +1 -1
- package/dist/utils/stripUnselectedFields.d.ts.map +1 -1
- package/dist/utils/type-guards.d.ts.map +1 -1
- package/package.json +58 -26
- package/dist/caching/app-cache.d.ts +0 -237
- package/dist/caching/app-cache.d.ts.map +0 -1
- package/dist/caching/app-cache.js +0 -430
- package/dist/caching/cdn-config.d.ts +0 -155
- package/dist/caching/cdn-config.d.ts.map +0 -1
- package/dist/caching/cdn-config.js +0 -411
- package/dist/caching/edge-cache.d.ts +0 -177
- package/dist/caching/edge-cache.d.ts.map +0 -1
- package/dist/caching/edge-cache.js +0 -385
- package/dist/caching/service-worker.d.ts +0 -154
- package/dist/caching/service-worker.d.ts.map +0 -1
- package/dist/caching/service-worker.js +0 -437
- package/dist/client/admin/utils/auth.d.ts +0 -23
- package/dist/client/admin/utils/auth.d.ts.map +0 -1
- package/dist/client/admin/utils/auth.js +0 -52
- package/dist/client/http/client.d.ts +0 -15
- package/dist/client/http/client.d.ts.map +0 -1
- package/dist/client/http/client.js +0 -49
- package/dist/client/http/fetchBanner.d.ts +0 -18
- package/dist/client/http/fetchBanner.d.ts.map +0 -1
- package/dist/client/http/fetchBanner.js +0 -44
- package/dist/client/http/fetchCard.d.ts +0 -18
- package/dist/client/http/fetchCard.d.ts.map +0 -1
- package/dist/client/http/fetchCard.js +0 -46
- package/dist/client/http/fetchEvents.d.ts +0 -18
- package/dist/client/http/fetchEvents.d.ts.map +0 -1
- package/dist/client/http/fetchEvents.js +0 -44
- package/dist/client/http/fetchHero.d.ts +0 -17
- package/dist/client/http/fetchHero.d.ts.map +0 -1
- package/dist/client/http/fetchHero.js +0 -55
- package/dist/client/http/fetchMainInfos.d.ts +0 -17
- package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
- package/dist/client/http/fetchMainInfos.js +0 -44
- package/dist/client/http/fetchVideos.d.ts +0 -13
- package/dist/client/http/fetchVideos.d.ts.map +0 -1
- package/dist/client/http/fetchVideos.js +0 -36
- package/dist/client/http/index.d.ts +0 -19
- package/dist/client/http/index.d.ts.map +0 -1
- package/dist/client/http/index.js +0 -11
- package/dist/error-handling/circuit-breaker.d.ts +0 -262
- package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
- package/dist/error-handling/circuit-breaker.js +0 -542
- package/dist/error-handling/retry.d.ts +0 -194
- package/dist/error-handling/retry.d.ts.map +0 -1
- package/dist/error-handling/retry.js +0 -450
- package/dist/errors/index.d.ts +0 -23
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -40
- package/dist/generated/agents/index.d.ts +0 -8
- package/dist/generated/agents/index.d.ts.map +0 -1
- package/dist/generated/agents/index.js +0 -7
- package/dist/generated/components/index.d.ts +0 -8
- package/dist/generated/components/index.d.ts.map +0 -1
- package/dist/generated/components/index.js +0 -7
- package/dist/generated/functions/index.d.ts +0 -8
- package/dist/generated/functions/index.d.ts.map +0 -1
- package/dist/generated/functions/index.js +0 -7
- package/dist/generated/hooks/index.d.ts +0 -8
- package/dist/generated/hooks/index.d.ts.map +0 -1
- package/dist/generated/hooks/index.js +0 -7
- package/dist/generated/plans/index.d.ts +0 -8
- package/dist/generated/plans/index.d.ts.map +0 -1
- package/dist/generated/plans/index.js +0 -7
- package/dist/generated/prompts/index.d.ts +0 -8
- package/dist/generated/prompts/index.d.ts.map +0 -1
- package/dist/generated/prompts/index.js +0 -7
- package/dist/generated/tools/index.d.ts +0 -8
- package/dist/generated/tools/index.d.ts.map +0 -1
- package/dist/generated/tools/index.js +0 -7
- package/dist/generated/types/supabase.d.ts +0 -193
- package/dist/generated/types/supabase.d.ts.map +0 -1
- package/dist/generated/types/supabase.js +0 -5
- package/dist/optimization/asset-optimizer.d.ts +0 -202
- package/dist/optimization/asset-optimizer.d.ts.map +0 -1
- package/dist/optimization/asset-optimizer.js +0 -312
- package/dist/optimization/build-optimizer.d.ts +0 -202
- package/dist/optimization/build-optimizer.d.ts.map +0 -1
- package/dist/optimization/build-optimizer.js +0 -271
- package/dist/optimization/bundle-analyzer.d.ts +0 -98
- package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
- package/dist/optimization/bundle-analyzer.js +0 -322
- package/dist/optimization/code-splitting.d.ts +0 -131
- package/dist/optimization/code-splitting.d.ts.map +0 -1
- package/dist/optimization/code-splitting.js +0 -277
- package/dist/plugin/index.d.ts +0 -12
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -4
- package/dist/security/audit.d.ts +0 -188
- package/dist/security/audit.d.ts.map +0 -1
- package/dist/security/audit.js +0 -431
- package/dist/security/auth.d.ts +0 -241
- package/dist/security/auth.d.ts.map +0 -1
- package/dist/security/auth.js +0 -476
- package/dist/security/authorization.d.ts +0 -235
- package/dist/security/authorization.d.ts.map +0 -1
- package/dist/security/authorization.js +0 -434
- package/dist/security/encryption.d.ts +0 -214
- package/dist/security/encryption.d.ts.map +0 -1
- package/dist/security/encryption.js +0 -517
- package/dist/security/gdpr.d.ts +0 -300
- package/dist/security/gdpr.d.ts.map +0 -1
- package/dist/security/gdpr.js +0 -465
- package/dist/security/headers.d.ts +0 -182
- package/dist/security/headers.d.ts.map +0 -1
- package/dist/security/headers.js +0 -402
- package/dist/utils/jwt-validation.d.ts +0 -14
- package/dist/utils/jwt-validation.d.ts.map +0 -1
- package/dist/utils/jwt-validation.js +0 -36
- package/dist/utils/request-headers.d.ts +0 -15
- package/dist/utils/request-headers.d.ts.map +0 -1
- package/dist/utils/request-headers.js +0 -31
package/dist/security/headers.js
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JWT Validation Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for validating JWT tokens from RevealRequest objects.
|
|
5
|
-
*/
|
|
6
|
-
import type { RevealRequest } from '../types/index.js';
|
|
7
|
-
/**
|
|
8
|
-
* Validate JWT token from request authorization header
|
|
9
|
-
*
|
|
10
|
-
* @param req - RevealRequest object
|
|
11
|
-
* @throws Error if token is invalid or expired
|
|
12
|
-
*/
|
|
13
|
-
export declare function validateJWTFromRequest(req?: RevealRequest): Promise<void>;
|
|
14
|
-
//# sourceMappingURL=jwt-validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-validation.d.ts","sourceRoot":"","sources":["../../src/utils/jwt-validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGtD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B/E"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JWT Validation Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for validating JWT tokens from RevealRequest objects.
|
|
5
|
-
*/
|
|
6
|
-
import { jwtVerify } from 'jose';
|
|
7
|
-
import { extractAuthHeader } from './request-headers.js';
|
|
8
|
-
/**
|
|
9
|
-
* Validate JWT token from request authorization header
|
|
10
|
-
*
|
|
11
|
-
* @param req - RevealRequest object
|
|
12
|
-
* @throws Error if token is invalid or expired
|
|
13
|
-
*/
|
|
14
|
-
export async function validateJWTFromRequest(req) {
|
|
15
|
-
const authHeader = extractAuthHeader(req);
|
|
16
|
-
if (!authHeader || typeof authHeader !== 'string') {
|
|
17
|
-
return; // No auth header, skip validation
|
|
18
|
-
}
|
|
19
|
-
// Extract token from "JWT <token>" format
|
|
20
|
-
if (!authHeader.startsWith('JWT ')) {
|
|
21
|
-
return; // Not a JWT token, skip validation
|
|
22
|
-
}
|
|
23
|
-
const token = authHeader.substring(4);
|
|
24
|
-
const secret = process.env.REVEALUI_SECRET;
|
|
25
|
-
if (!secret || secret.length < 32) {
|
|
26
|
-
throw new Error('REVEALUI_SECRET must be set to a secure random value (minimum 32 characters). ' +
|
|
27
|
-
'Generate one with: openssl rand -base64 32');
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
await jwtVerify(token, new TextEncoder().encode(secret));
|
|
31
|
-
}
|
|
32
|
-
catch (_error) {
|
|
33
|
-
// Token is invalid, expired, or tampered
|
|
34
|
-
throw new Error('Invalid or expired token');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Request Header Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for extracting headers from RevealRequest objects.
|
|
5
|
-
* Handles various header types (Headers, Map, plain object).
|
|
6
|
-
*/
|
|
7
|
-
import type { RevealRequest } from '../types/index.js';
|
|
8
|
-
/**
|
|
9
|
-
* Extract authorization header from request
|
|
10
|
-
*
|
|
11
|
-
* @param req - RevealRequest object
|
|
12
|
-
* @returns Authorization header value or null if not found
|
|
13
|
-
*/
|
|
14
|
-
export declare function extractAuthHeader(req?: RevealRequest): string | null;
|
|
15
|
-
//# sourceMappingURL=request-headers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-headers.d.ts","sourceRoot":"","sources":["../../src/utils/request-headers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAqBpE"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Request Header Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for extracting headers from RevealRequest objects.
|
|
5
|
-
* Handles various header types (Headers, Map, plain object).
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Extract authorization header from request
|
|
9
|
-
*
|
|
10
|
-
* @param req - RevealRequest object
|
|
11
|
-
* @returns Authorization header value or null if not found
|
|
12
|
-
*/
|
|
13
|
-
export function extractAuthHeader(req) {
|
|
14
|
-
if (!req?.headers) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
let authHeader;
|
|
18
|
-
// Handle Headers object
|
|
19
|
-
if (req.headers instanceof Headers) {
|
|
20
|
-
authHeader = req.headers.get('authorization') || undefined;
|
|
21
|
-
}
|
|
22
|
-
// Handle Map object (used in tests) - type cast to avoid TS error
|
|
23
|
-
else if (req.headers instanceof Map) {
|
|
24
|
-
authHeader = req.headers.get('authorization') || undefined;
|
|
25
|
-
}
|
|
26
|
-
// Handle plain object with authorization property
|
|
27
|
-
else if (typeof req.headers === 'object' && 'authorization' in req.headers) {
|
|
28
|
-
authHeader = req.headers.authorization;
|
|
29
|
-
}
|
|
30
|
-
return authHeader || null;
|
|
31
|
-
}
|