@nextsparkjs/core 0.1.0-beta.185 → 0.1.0-beta.187
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/components/app/guards/DeveloperGuard.d.ts.map +1 -1
- package/dist/components/app/guards/DeveloperGuard.js +8 -4
- package/dist/components/app/guards/SuperAdminGuard.d.ts.map +1 -1
- package/dist/components/app/guards/SuperAdminGuard.js +8 -4
- package/dist/components/app/layouts/PublicFooter.d.ts.map +1 -1
- package/dist/components/app/layouts/PublicFooter.js +2 -2
- package/dist/components/app/layouts/PublicNavbar.d.ts.map +1 -1
- package/dist/components/app/layouts/PublicNavbar.js +2 -2
- package/dist/components/app/misc/ThemeToggle.d.ts.map +1 -1
- package/dist/components/app/misc/ThemeToggle.js +4 -1
- package/dist/components/auth/DevKeyring.d.ts.map +1 -1
- package/dist/components/auth/DevKeyring.js +10 -2
- package/dist/components/auth/SessionCookieRefresher.d.ts +21 -0
- package/dist/components/auth/SessionCookieRefresher.d.ts.map +1 -0
- package/dist/components/auth/SessionCookieRefresher.js +11 -0
- package/dist/components/auth/forms/LoginForm.d.ts.map +1 -1
- package/dist/components/auth/forms/LoginForm.js +300 -6
- package/dist/components/auth/index.d.ts +1 -0
- package/dist/components/auth/index.d.ts.map +1 -1
- package/dist/components/auth/index.js +2 -0
- package/dist/components/billing/InvoicesTable.d.ts.map +1 -1
- package/dist/components/billing/InvoicesTable.js +4 -3
- package/dist/components/dashboard/block-editor/dynamic-form.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/AuthGuard.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/AuthGuard.js +2 -2
- package/dist/components/dashboard/layouts/DashboardAuthLayout.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/DashboardAuthLayout.js +2 -2
- package/dist/components/dashboard/layouts/DashboardAuthSkeleton.d.ts +17 -0
- package/dist/components/dashboard/layouts/DashboardAuthSkeleton.d.ts.map +1 -0
- package/dist/components/dashboard/layouts/DashboardAuthSkeleton.js +52 -0
- package/dist/components/dashboard/layouts/Sidebar.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/Sidebar.js +2 -3
- package/dist/components/dashboard/layouts/TopNavbar.js +2 -2
- package/dist/components/dashboard/layouts/index.d.ts +1 -0
- package/dist/components/dashboard/layouts/index.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/index.js +2 -0
- package/dist/components/devtools/api-explorer/ApiExplorer.js +4 -4
- package/dist/components/entities/EntityFieldRenderer.d.ts.map +1 -1
- package/dist/components/entities/EntityFieldRenderer.js +3 -0
- package/dist/components/entities/EntityTable.d.ts.map +1 -1
- package/dist/components/entities/EntityTable.js +2 -1
- package/dist/components/entities/wrappers/EntityFormWrapper.d.ts.map +1 -1
- package/dist/components/entities/wrappers/EntityFormWrapper.js +7 -2
- package/dist/components/patterns/pages/PatternEditPage.d.ts +5 -1
- package/dist/components/patterns/pages/PatternEditPage.d.ts.map +1 -1
- package/dist/components/patterns/pages/PatternEditPage.js +16 -5
- package/dist/components/patterns/pages/PatternsCreatePage.d.ts +2 -1
- package/dist/components/patterns/pages/PatternsCreatePage.d.ts.map +1 -1
- package/dist/components/patterns/pages/PatternsCreatePage.js +17 -5
- package/dist/components/ui/combobox.d.ts +8 -1
- package/dist/components/ui/combobox.d.ts.map +1 -1
- package/dist/components/ui/combobox.js +37 -44
- package/dist/components/ui/country-select.d.ts +3 -1
- package/dist/components/ui/country-select.d.ts.map +1 -1
- package/dist/components/ui/country-select.js +3 -1
- package/dist/components/ui/currency-select.d.ts +3 -1
- package/dist/components/ui/currency-select.d.ts.map +1 -1
- package/dist/components/ui/currency-select.js +3 -1
- package/dist/components/ui/sheet.d.ts +5 -0
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js +46 -26
- package/dist/components/ui/timezone-select.d.ts +3 -1
- package/dist/components/ui/timezone-select.d.ts.map +1 -1
- package/dist/components/ui/timezone-select.js +3 -1
- package/dist/contexts/TeamContext.d.ts +6 -0
- package/dist/contexts/TeamContext.d.ts.map +1 -1
- package/dist/contexts/TeamContext.js +8 -1
- package/dist/emails/otp-verification.d.ts.map +1 -1
- package/dist/emails/reset-password.d.ts.map +1 -1
- package/dist/emails/team-invitation.d.ts.map +1 -1
- package/dist/emails/team-invitation.js +3 -2
- package/dist/emails/verify-email.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useAuth.d.ts +29 -0
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +24 -0
- package/dist/hooks/useEnsureUserMetadata.d.ts +22 -0
- package/dist/hooks/useEnsureUserMetadata.d.ts.map +1 -1
- package/dist/hooks/useEnsureUserMetadata.js +18 -5
- package/dist/hooks/useSessionCookieRefresh.d.ts +35 -0
- package/dist/hooks/useSessionCookieRefresh.d.ts.map +1 -0
- package/dist/hooks/useSessionCookieRefresh.js +49 -0
- package/dist/lib/api/api-error.d.ts +3 -1
- package/dist/lib/api/api-error.d.ts.map +1 -1
- package/dist/lib/api/api-error.js +4 -2
- package/dist/lib/api/auth/dual-auth.d.ts +38 -3
- package/dist/lib/api/auth/dual-auth.d.ts.map +1 -1
- package/dist/lib/api/auth/dual-auth.js +42 -7
- package/dist/lib/api/auth/permissions.d.ts +7 -2
- package/dist/lib/api/auth/permissions.d.ts.map +1 -1
- package/dist/lib/api/auth/permissions.js +2 -2
- package/dist/lib/api/auth/scope-policy.d.ts +71 -0
- package/dist/lib/api/auth/scope-policy.d.ts.map +1 -0
- package/dist/lib/api/auth/scope-policy.js +53 -0
- package/dist/lib/api/auth.d.ts +15 -0
- package/dist/lib/api/auth.d.ts.map +1 -1
- package/dist/lib/api/auth.js +17 -4
- package/dist/lib/api/entities.js +2 -1
- package/dist/lib/api/entity/audit-log.d.ts +35 -0
- package/dist/lib/api/entity/audit-log.d.ts.map +1 -0
- package/dist/lib/api/entity/audit-log.js +35 -0
- package/dist/lib/api/entity/generic-handler.d.ts.map +1 -1
- package/dist/lib/api/entity/generic-handler.js +333 -138
- package/dist/lib/api/entity-handler.js +2 -2
- package/dist/lib/api/helpers.d.ts +29 -4
- package/dist/lib/api/helpers.d.ts.map +1 -1
- package/dist/lib/api/helpers.js +30 -6
- package/dist/lib/api/keys.d.ts +16 -0
- package/dist/lib/api/keys.d.ts.map +1 -1
- package/dist/lib/api/keys.js +19 -1
- package/dist/lib/api/routes/patterns-usages.d.ts.map +1 -1
- package/dist/lib/api/routes/patterns-usages.js +3 -11
- package/dist/lib/auth/auth-methods.d.ts +52 -0
- package/dist/lib/auth/auth-methods.d.ts.map +1 -0
- package/dist/lib/auth/auth-methods.js +63 -0
- package/dist/lib/auth/registration-guard-plugin.d.ts.map +1 -1
- package/dist/lib/auth/registration-helpers.d.ts +9 -0
- package/dist/lib/auth/registration-helpers.d.ts.map +1 -1
- package/dist/lib/auth/registration-helpers.js +8 -2
- package/dist/lib/auth/security-notifications/device-fingerprint.d.ts +52 -0
- package/dist/lib/auth/security-notifications/device-fingerprint.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/device-fingerprint.js +42 -0
- package/dist/lib/auth/security-notifications/dispatcher.d.ts +37 -0
- package/dist/lib/auth/security-notifications/dispatcher.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/dispatcher.js +157 -0
- package/dist/lib/auth/security-notifications/index.d.ts +20 -0
- package/dist/lib/auth/security-notifications/index.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/index.js +22 -0
- package/dist/lib/auth/security-notifications/registry.d.ts +36 -0
- package/dist/lib/auth/security-notifications/registry.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/registry.js +26 -0
- package/dist/lib/auth/security-notifications/templates/email-changed.d.ts +12 -0
- package/dist/lib/auth/security-notifications/templates/email-changed.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/templates/email-changed.js +43 -0
- package/dist/lib/auth/security-notifications/templates/new-device-login.d.ts +7 -0
- package/dist/lib/auth/security-notifications/templates/new-device-login.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/templates/new-device-login.js +46 -0
- package/dist/lib/auth/security-notifications/templates/password-changed.d.ts +7 -0
- package/dist/lib/auth/security-notifications/templates/password-changed.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/templates/password-changed.js +35 -0
- package/dist/lib/auth/security-notifications/templates/shared.d.ts +36 -0
- package/dist/lib/auth/security-notifications/templates/shared.d.ts.map +1 -0
- package/dist/lib/auth/security-notifications/templates/shared.js +68 -0
- package/dist/lib/auth/security-notifications/types.d.ts +74 -0
- package/dist/lib/auth/security-notifications/types.d.ts.map +1 -0
- package/dist/lib/auth/session-config.d.ts +37 -0
- package/dist/lib/auth/session-config.d.ts.map +1 -0
- package/dist/lib/auth/session-config.js +59 -0
- package/dist/lib/auth/session-refresh.d.ts +46 -0
- package/dist/lib/auth/session-refresh.d.ts.map +1 -0
- package/dist/lib/auth/session-refresh.js +11 -0
- package/dist/lib/auth-client.d.ts +1639 -0
- package/dist/lib/auth-client.d.ts.map +1 -0
- package/dist/lib/auth-client.js +13 -1
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +45 -11
- package/dist/lib/billing/gateways/factory.d.ts +8 -3
- package/dist/lib/billing/gateways/factory.d.ts.map +1 -1
- package/dist/lib/billing/gateways/factory.js +37 -23
- package/dist/lib/billing/stripe-webhook.d.ts.map +1 -1
- package/dist/lib/billing/stripe-webhook.js +2 -1
- package/dist/lib/config/app.config.d.ts.map +1 -1
- package/dist/lib/config/app.config.js +71 -0
- package/dist/lib/config/config-sync.d.ts +1 -4
- package/dist/lib/config/config-sync.d.ts.map +1 -1
- package/dist/lib/config/config-sync.js +6 -2
- package/dist/lib/config/types.d.ts +130 -0
- package/dist/lib/config/types.d.ts.map +1 -1
- package/dist/lib/email/templates.d.ts +3 -3
- package/dist/lib/email/templates.d.ts.map +1 -1
- package/dist/lib/entities/api-generator.js +5 -5
- package/dist/lib/entities/entity-hooks.d.ts +9 -1
- package/dist/lib/entities/entity-hooks.d.ts.map +1 -1
- package/dist/lib/entities/entity-hooks.js +77 -4
- package/dist/lib/entities/schema-generator.d.ts.map +1 -1
- package/dist/lib/entities/schema-generator.js +20 -4
- package/dist/lib/entities/serialization.d.ts +2 -2
- package/dist/lib/entities/serialization.d.ts.map +1 -1
- package/dist/lib/entities/serialization.js +3 -2
- package/dist/lib/entities/types.d.ts +20 -0
- package/dist/lib/entities/types.d.ts.map +1 -1
- package/dist/lib/locale.d.ts.map +1 -1
- package/dist/lib/locale.js +4 -1
- package/dist/lib/mcp/audit.d.ts +8 -4
- package/dist/lib/mcp/audit.d.ts.map +1 -1
- package/dist/lib/plugins/hook-system.d.ts +13 -0
- package/dist/lib/plugins/hook-system.d.ts.map +1 -1
- package/dist/lib/plugins/hook-system.js +32 -2
- package/dist/lib/scheduled-actions/handlers/index.d.ts +1 -0
- package/dist/lib/scheduled-actions/handlers/index.d.ts.map +1 -1
- package/dist/lib/scheduled-actions/handlers/index.js +3 -1
- package/dist/lib/scheduled-actions/handlers/security-notification.d.ts +26 -0
- package/dist/lib/scheduled-actions/handlers/security-notification.d.ts.map +1 -0
- package/dist/lib/scheduled-actions/handlers/security-notification.js +54 -0
- package/dist/lib/selectors/core-selectors.d.ts +12 -0
- package/dist/lib/selectors/core-selectors.d.ts.map +1 -1
- package/dist/lib/selectors/domains/auth.selectors.d.ts +12 -0
- package/dist/lib/selectors/domains/auth.selectors.d.ts.map +1 -1
- package/dist/lib/selectors/domains/auth.selectors.js +14 -1
- package/dist/lib/selectors/selectors.d.ts +24 -0
- package/dist/lib/selectors/selectors.d.ts.map +1 -1
- package/dist/lib/services/api-docs.service.d.ts +5 -1
- package/dist/lib/services/api-docs.service.d.ts.map +1 -1
- package/dist/lib/services/api-presets.service.d.ts +6 -1
- package/dist/lib/services/api-presets.service.d.ts.map +1 -1
- package/dist/lib/services/feature.service.d.ts +58 -4
- package/dist/lib/services/feature.service.d.ts.map +1 -1
- package/dist/lib/services/generic-entity.service.d.ts.map +1 -1
- package/dist/lib/services/generic-entity.service.js +16 -32
- package/dist/lib/services/membership.service.d.ts +10 -2
- package/dist/lib/services/membership.service.d.ts.map +1 -1
- package/dist/lib/services/membership.service.js +37 -16
- package/dist/lib/services/permission.service.d.ts +10 -4
- package/dist/lib/services/permission.service.d.ts.map +1 -1
- package/dist/lib/services/plugin.service.d.ts +1 -1
- package/dist/lib/services/plugin.service.d.ts.map +1 -1
- package/dist/lib/services/subscription.service.d.ts.map +1 -1
- package/dist/lib/services/subscription.service.js +2 -1
- package/dist/lib/services/team-member.service.d.ts +15 -3
- package/dist/lib/services/team-member.service.d.ts.map +1 -1
- package/dist/lib/services/team-member.service.js +27 -6
- package/dist/lib/services/team.service.d.ts.map +1 -1
- package/dist/lib/teams/permissions.d.ts +3 -1
- package/dist/lib/teams/permissions.d.ts.map +1 -1
- package/dist/lib/teams/permissions.js +6 -0
- package/dist/lib/teams/schema.d.ts.map +1 -1
- package/dist/lib/teams/schema.js +3 -0
- package/dist/lib/template-resolver.d.ts +3 -3
- package/dist/lib/theme/forced-theme.d.ts +34 -0
- package/dist/lib/theme/forced-theme.d.ts.map +1 -0
- package/dist/lib/theme/forced-theme.js +27 -0
- package/dist/lib/theme/get-default-theme-mode.d.ts +3 -0
- package/dist/lib/theme/get-default-theme-mode.d.ts.map +1 -1
- package/dist/lib/theme/get-default-theme-mode.js +5 -3
- package/dist/lib/utils/cors.d.ts +13 -0
- package/dist/lib/utils/cors.d.ts.map +1 -1
- package/dist/lib/utils/cors.js +20 -0
- package/dist/messages/de/auth.json +25 -2
- package/dist/messages/de/index.d.ts +83 -0
- package/dist/messages/de/index.d.ts.map +1 -1
- package/dist/messages/de/index.js +2 -0
- package/dist/messages/de/index.ts +2 -0
- package/dist/messages/de/navigation.json +3 -1
- package/dist/messages/en/auth.json +25 -2
- package/dist/messages/en/index.d.ts +83 -0
- package/dist/messages/en/index.d.ts.map +1 -1
- package/dist/messages/en/index.js +2 -0
- package/dist/messages/en/index.ts +2 -0
- package/dist/messages/en/navigation.json +3 -1
- package/dist/messages/es/auth.json +25 -2
- package/dist/messages/es/index.d.ts +83 -0
- package/dist/messages/es/index.d.ts.map +1 -1
- package/dist/messages/es/index.js +2 -0
- package/dist/messages/es/index.ts +2 -0
- package/dist/messages/es/navigation.json +3 -1
- package/dist/messages/fr/auth.json +25 -2
- package/dist/messages/fr/index.d.ts +83 -0
- package/dist/messages/fr/index.d.ts.map +1 -1
- package/dist/messages/fr/index.js +2 -0
- package/dist/messages/fr/index.ts +2 -0
- package/dist/messages/fr/navigation.json +3 -1
- package/dist/messages/it/auth.json +25 -2
- package/dist/messages/it/index.d.ts +83 -0
- package/dist/messages/it/index.d.ts.map +1 -1
- package/dist/messages/it/index.js +2 -0
- package/dist/messages/it/index.ts +2 -0
- package/dist/messages/it/navigation.json +3 -1
- package/dist/messages/pt/auth.json +25 -2
- package/dist/messages/pt/index.d.ts +83 -0
- package/dist/messages/pt/index.d.ts.map +1 -1
- package/dist/messages/pt/index.js +2 -0
- package/dist/messages/pt/index.ts +2 -0
- package/dist/messages/pt/navigation.json +3 -1
- package/dist/migrations/005_api_audit_log.sql +2 -1
- package/dist/migrations/025_api_audit_log_nullable_api_key.sql +12 -0
- package/dist/migrations/026_login_events.sql +91 -0
- package/dist/migrations/027_rls_bypass_developer_and_system_admin_team.sql +197 -0
- package/dist/nextspark-registries.d.ts +580 -236
- package/dist/providers/DashboardProviders.d.ts +12 -3
- package/dist/providers/DashboardProviders.d.ts.map +1 -1
- package/dist/providers/DashboardProviders.js +6 -2
- package/dist/providers/theme-provider.d.ts +19 -2
- package/dist/providers/theme-provider.d.ts.map +1 -1
- package/dist/providers/theme-provider.js +6 -2
- package/dist/templates/app/(auth)/signup/page.tsx +8 -0
- package/dist/templates/app/(public)/[...slug]/page.tsx +9 -14
- package/dist/templates/app/api/auth/[...all]/route.ts +23 -1
- package/dist/templates/app/api/health/route.ts +4 -2
- package/dist/templates/app/api/internal/user-metadata/route.ts +5 -3
- package/dist/templates/app/api/mcp/route.ts +4 -1
- package/dist/templates/app/api/superadmin/subscriptions/route.ts +2 -1
- package/dist/templates/app/api/superadmin/teams/[teamId]/route.ts +4 -3
- package/dist/templates/app/api/superadmin/users/[userId]/route.ts +10 -3
- package/dist/templates/app/api/v1/api-keys/[id]/route.ts +50 -71
- package/dist/templates/app/api/v1/api-keys/route.ts +21 -43
- package/dist/templates/app/api/v1/auth/signup-with-invite/route.ts +14 -14
- package/dist/templates/app/api/v1/billing/cancel/route.ts +7 -6
- package/dist/templates/app/api/v1/billing/change-plan/route.ts +5 -4
- package/dist/templates/app/api/v1/billing/check-action/route.ts +6 -4
- package/dist/templates/app/api/v1/billing/checkout/route.ts +7 -5
- package/dist/templates/app/api/v1/billing/plans/route.ts +8 -12
- package/dist/templates/app/api/v1/billing/portal/route.ts +7 -5
- package/dist/templates/app/api/v1/billing/webhooks/polar/route.ts +1 -1
- package/dist/templates/app/api/v1/devtools/blocks/route.ts +5 -4
- package/dist/templates/app/api/v1/devtools/features/route.ts +5 -4
- package/dist/templates/app/api/v1/devtools/flows/route.ts +5 -4
- package/dist/templates/app/api/v1/devtools/scheduled-actions/route.ts +9 -7
- package/dist/templates/app/api/v1/devtools/scheduled-actions/run/route.ts +5 -4
- package/dist/templates/app/api/v1/devtools/testing/route.ts +5 -4
- package/dist/templates/app/api/v1/media/[id]/route.ts +13 -25
- package/dist/templates/app/api/v1/media/[id]/tags/route.ts +17 -25
- package/dist/templates/app/api/v1/media/check-duplicates/route.ts +5 -7
- package/dist/templates/app/api/v1/media/route.ts +5 -9
- package/dist/templates/app/api/v1/media/upload/route.ts +9 -21
- package/dist/templates/app/api/v1/media-tags/route.ts +9 -13
- package/dist/templates/app/api/v1/patterns/[id]/usages/route.ts +11 -19
- package/dist/templates/app/api/v1/post-categories/[id]/route.ts +9 -7
- package/dist/templates/app/api/v1/post-categories/route.ts +5 -4
- package/dist/templates/app/api/v1/team-invitations/[token]/accept/route.ts +16 -18
- package/dist/templates/app/api/v1/team-invitations/[token]/decline/route.ts +15 -17
- package/dist/templates/app/api/v1/team-invitations/[token]/route.ts +8 -8
- package/dist/templates/app/api/v1/team-invitations/route.ts +9 -11
- package/dist/templates/app/api/v1/teams/[teamId]/invitations/route.ts +41 -32
- package/dist/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +15 -16
- package/dist/templates/app/api/v1/teams/[teamId]/invoices/route.ts +14 -15
- package/dist/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +32 -36
- package/dist/templates/app/api/v1/teams/[teamId]/members/route.ts +33 -33
- package/dist/templates/app/api/v1/teams/[teamId]/route.ts +35 -41
- package/dist/templates/app/api/v1/teams/[teamId]/subscription/route.ts +5 -3
- package/dist/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +10 -6
- package/dist/templates/app/api/v1/teams/route.ts +33 -27
- package/dist/templates/app/api/v1/teams/switch/route.ts +11 -13
- package/dist/templates/app/api/v1/theme/[...path]/route.ts +23 -2
- package/dist/templates/app/api/v1/users/[id]/meta/[key]/route.ts +32 -77
- package/dist/templates/app/api/v1/users/[id]/route.ts +35 -68
- package/dist/templates/app/api/v1/users/route.ts +21 -25
- package/dist/templates/app/dashboard/layout.tsx +2 -6
- package/dist/templates/app/layout.ppr.tsx +15 -15
- package/dist/templates/app/layout.tsx +46 -20
- package/dist/templates/contents/themes/starter/config/app.config.ts +19 -0
- package/dist/templates/contents/themes/starter/config/theme.config.ts +6 -0
- package/dist/templates/contents/themes/starter/styles/globals.css +6 -2
- package/dist/templates/proxy.ts +46 -10
- package/dist/templates/tsconfig.json +4 -0
- package/dist/types/theme.d.ts +9 -0
- package/dist/types/theme.d.ts.map +1 -1
- package/migrations/005_api_audit_log.sql +2 -1
- package/migrations/025_api_audit_log_nullable_api_key.sql +12 -0
- package/migrations/026_login_events.sql +91 -0
- package/migrations/027_rls_bypass_developer_and_system_admin_team.sql +197 -0
- package/package.json +14 -11
- package/scripts/build/registry/__tests__/scope-registry.test.mjs +18 -0
- package/scripts/build/registry/generators/scope-registry.mjs +9 -2
- package/templates/app/(auth)/signup/page.tsx +8 -0
- package/templates/app/(public)/[...slug]/page.tsx +9 -14
- package/templates/app/api/auth/[...all]/route.ts +23 -1
- package/templates/app/api/health/route.ts +4 -2
- package/templates/app/api/internal/user-metadata/route.ts +5 -3
- package/templates/app/api/mcp/route.ts +4 -1
- package/templates/app/api/superadmin/subscriptions/route.ts +2 -1
- package/templates/app/api/superadmin/teams/[teamId]/route.ts +4 -3
- package/templates/app/api/superadmin/users/[userId]/route.ts +10 -3
- package/templates/app/api/v1/api-keys/[id]/route.ts +50 -71
- package/templates/app/api/v1/api-keys/route.ts +21 -43
- package/templates/app/api/v1/auth/signup-with-invite/route.ts +14 -14
- package/templates/app/api/v1/billing/cancel/route.ts +7 -6
- package/templates/app/api/v1/billing/change-plan/route.ts +5 -4
- package/templates/app/api/v1/billing/check-action/route.ts +6 -4
- package/templates/app/api/v1/billing/checkout/route.ts +7 -5
- package/templates/app/api/v1/billing/plans/route.ts +8 -12
- package/templates/app/api/v1/billing/portal/route.ts +7 -5
- package/templates/app/api/v1/billing/webhooks/polar/route.ts +1 -1
- package/templates/app/api/v1/devtools/blocks/route.ts +5 -4
- package/templates/app/api/v1/devtools/features/route.ts +5 -4
- package/templates/app/api/v1/devtools/flows/route.ts +5 -4
- package/templates/app/api/v1/devtools/scheduled-actions/route.ts +9 -7
- package/templates/app/api/v1/devtools/scheduled-actions/run/route.ts +5 -4
- package/templates/app/api/v1/devtools/testing/route.ts +5 -4
- package/templates/app/api/v1/media/[id]/route.ts +13 -25
- package/templates/app/api/v1/media/[id]/tags/route.ts +17 -25
- package/templates/app/api/v1/media/check-duplicates/route.ts +5 -7
- package/templates/app/api/v1/media/route.ts +5 -9
- package/templates/app/api/v1/media/upload/route.ts +9 -21
- package/templates/app/api/v1/media-tags/route.ts +9 -13
- package/templates/app/api/v1/patterns/[id]/usages/route.ts +11 -19
- package/templates/app/api/v1/post-categories/[id]/route.ts +9 -7
- package/templates/app/api/v1/post-categories/route.ts +5 -4
- package/templates/app/api/v1/team-invitations/[token]/accept/route.ts +16 -18
- package/templates/app/api/v1/team-invitations/[token]/decline/route.ts +15 -17
- package/templates/app/api/v1/team-invitations/[token]/route.ts +8 -8
- package/templates/app/api/v1/team-invitations/route.ts +9 -11
- package/templates/app/api/v1/teams/[teamId]/invitations/route.ts +41 -32
- package/templates/app/api/v1/teams/[teamId]/invoices/[invoiceNumber]/route.ts +15 -16
- package/templates/app/api/v1/teams/[teamId]/invoices/route.ts +14 -15
- package/templates/app/api/v1/teams/[teamId]/members/[memberId]/route.ts +32 -36
- package/templates/app/api/v1/teams/[teamId]/members/route.ts +33 -33
- package/templates/app/api/v1/teams/[teamId]/route.ts +35 -41
- package/templates/app/api/v1/teams/[teamId]/subscription/route.ts +5 -3
- package/templates/app/api/v1/teams/[teamId]/usage/[limitSlug]/route.ts +10 -6
- package/templates/app/api/v1/teams/route.ts +33 -27
- package/templates/app/api/v1/teams/switch/route.ts +11 -13
- package/templates/app/api/v1/theme/[...path]/route.ts +23 -2
- package/templates/app/api/v1/users/[id]/meta/[key]/route.ts +32 -77
- package/templates/app/api/v1/users/[id]/route.ts +35 -68
- package/templates/app/api/v1/users/route.ts +21 -25
- package/templates/app/dashboard/layout.tsx +2 -6
- package/templates/app/layout.ppr.tsx +15 -15
- package/templates/app/layout.tsx +46 -20
- package/templates/contents/themes/starter/config/app.config.ts +19 -0
- package/templates/contents/themes/starter/config/theme.config.ts +6 -0
- package/templates/contents/themes/starter/styles/globals.css +6 -2
- package/templates/proxy.ts +46 -10
- package/templates/tsconfig.json +4 -0
- package/tests/jest/__mocks__/@nextsparkjs/registries/permissions-registry.ts +23 -0
- package/tests/jest/__mocks__/next-server.js +24 -0
- package/dist/components/teams/TeamSwitchModal.d.js +0 -0
- package/dist/components/ui/accordion.d.js +0 -0
- package/dist/components/ui/avatar.d.js +0 -0
- package/dist/components/ui/badge.d.js +0 -0
- package/dist/components/ui/button.d.js +0 -0
- package/dist/components/ui/card.d.js +0 -0
- package/dist/components/ui/dialog.d.js +0 -0
- package/dist/components/ui/dropdown-menu.d.js +0 -0
- package/dist/components/ui/input.d.js +0 -0
- package/dist/components/ui/progress.d.js +0 -0
- package/dist/components/ui/scroll-area.d.js +0 -0
- package/dist/components/ui/select.d.js +0 -0
- package/dist/components/ui/separator.d.js +0 -0
- package/dist/components/ui/table.d.js +0 -0
- package/dist/components/ui/textarea.d.js +0 -0
- package/dist/contexts/TeamContext.d.js +0 -0
- package/dist/hooks/useAuth.d.js +0 -0
- package/dist/hooks/useLastAuthMethod.d.js +0 -0
- package/dist/hooks/useOrigin.d.js +0 -0
- package/dist/lib/api/auth/dual-auth.d.js +0 -0
- package/dist/lib/api/auth.d.js +0 -0
- package/dist/lib/api/cache.d.js +0 -0
- package/dist/lib/api/keys.d.js +0 -0
- package/dist/lib/auth-client.d.js +0 -0
- package/dist/lib/auth-context.d.js +0 -0
- package/dist/lib/auth.d.js +0 -0
- package/dist/lib/billing/config-types.d.js +0 -0
- package/dist/lib/billing/enforcement.d.js +0 -0
- package/dist/lib/billing/helpers.d.js +0 -0
- package/dist/lib/billing/jobs.d.js +0 -0
- package/dist/lib/billing/types.d.js +0 -0
- package/dist/lib/blocks/loader.d.js +0 -0
- package/dist/lib/config/app.config.d.js +0 -0
- package/dist/lib/config/config-loader.d.js +0 -0
- package/dist/lib/config/config-sync.d.js +0 -0
- package/dist/lib/config/config-types.d.js +0 -0
- package/dist/lib/config/config-utils.d.js +0 -0
- package/dist/lib/config/dashboard-types.d.js +0 -0
- package/dist/lib/config/dashboard.config.d.js +0 -0
- package/dist/lib/config/icon-map.d.js +0 -0
- package/dist/lib/config/index.d.js +0 -7
- package/dist/lib/config/nextspark-types.d.js +0 -0
- package/dist/lib/config/roles-merge.d.js +0 -0
- package/dist/lib/config/types.d.js +0 -0
- package/dist/lib/db.d.js +0 -0
- package/dist/lib/email/factory.d.js +0 -0
- package/dist/lib/email/index.d.js +0 -3
- package/dist/lib/email/providers/console.d.js +0 -0
- package/dist/lib/email/providers/resend.d.js +0 -0
- package/dist/lib/email/templates.d.js +0 -0
- package/dist/lib/email/types.d.js +0 -0
- package/dist/lib/entities/types.d.js +0 -0
- package/dist/lib/permissions/system.d.js +0 -0
- package/dist/lib/permissions/types.d.js +0 -0
- package/dist/lib/plugins/hook-system.d.js +0 -0
- package/dist/lib/scheduled-actions/cleanup.d.js +0 -0
- package/dist/lib/scheduled-actions/index.d.js +0 -19
- package/dist/lib/scheduled-actions/initializer.d.js +0 -1
- package/dist/lib/scheduled-actions/processor.d.js +0 -0
- package/dist/lib/scheduled-actions/registry.d.js +0 -0
- package/dist/lib/scheduled-actions/scheduler.d.js +0 -0
- package/dist/lib/scheduled-actions/types.d.js +0 -0
- package/dist/lib/services/api-routes.service.d.js +0 -0
- package/dist/lib/services/entity-type.service.d.js +0 -0
- package/dist/lib/services/index.d.js +0 -40
- package/dist/lib/services/invoice.service.d.js +0 -0
- package/dist/lib/services/membership.service.d.js +0 -0
- package/dist/lib/services/meta.service.d.js +0 -0
- package/dist/lib/services/middleware.service.d.js +0 -0
- package/dist/lib/services/namespace.service.d.js +0 -0
- package/dist/lib/services/permission.service.d.js +0 -0
- package/dist/lib/services/plan.service.d.js +0 -0
- package/dist/lib/services/plugin.service.d.js +0 -0
- package/dist/lib/services/route-handler.service.d.js +0 -0
- package/dist/lib/services/scope.service.d.js +0 -0
- package/dist/lib/services/subscription.service.d.js +0 -0
- package/dist/lib/services/team-member.service.d.js +0 -0
- package/dist/lib/services/team.service.d.js +0 -0
- package/dist/lib/services/theme.service.d.js +0 -0
- package/dist/lib/services/usage.service.d.js +0 -0
- package/dist/lib/services/user-flags.service.d.js +0 -0
- package/dist/lib/services/user.service.d.js +0 -0
- package/dist/lib/teams/helpers.d.js +0 -0
- package/dist/lib/teams/permissions.d.js +0 -0
- package/dist/lib/teams/types.d.js +0 -0
- package/dist/lib/utils/config-merge.d.js +0 -0
- package/dist/lib/utils/file-logger.d.js +0 -0
- package/dist/lib/utils.d.js +0 -0
- package/dist/styles/classes.json +0 -1093
- package/dist/styles/ui.css +0 -2
- package/dist/types/auth.d.js +0 -0
- package/dist/types/blocks.d.js +0 -0
- package/dist/types/meta.types.d.js +0 -0
- package/dist/types/plugin.d.js +0 -0
- package/dist/types/testing.types.d.js +0 -0
- package/dist/types/theme.d.js +0 -0
- package/dist/types/user.types.d.js +0 -0
- package/scripts/build/build-ui-css.mjs +0 -351
- /package/dist/{components/app/layouts/PublicFooter.d.js → lib/auth/security-notifications/types.js} +0 -0
- /package/dist/{components/app/layouts/PublicNavbar.d.js → nextspark-registries.d.js} +0 -0
- /package/dist/{components/app/misc/ThemeToggle.d.js → types/use-intl-react-shim.d.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server'
|
|
2
|
-
import { authenticateRequest,
|
|
2
|
+
import { authenticateRequest, createAuthFailureResponse, resolveTeamContext } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
3
|
import { createApiResponse, createApiError } from '@nextsparkjs/core/lib/api/helpers'
|
|
4
4
|
import { API_ERROR_CODES } from '@nextsparkjs/core/lib/api/api-error'
|
|
5
5
|
import { checkPermission } from '@nextsparkjs/core/lib/permissions/check'
|
|
@@ -20,15 +20,11 @@ export const GET = withRateLimitTier(async (
|
|
|
20
20
|
{ params }: { params: Promise<{ id: string }> }
|
|
21
21
|
) => {
|
|
22
22
|
try {
|
|
23
|
-
// 1. Authenticate
|
|
24
|
-
|
|
23
|
+
// 1. Authenticate; the API-key scope is declared at the entry point,
|
|
24
|
+
// which fails closed for keys that lack it (#93).
|
|
25
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:read' })
|
|
25
26
|
if (!authResult.success) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 2. Check permissions
|
|
30
|
-
if (!hasRequiredScope(authResult, 'media:read')) {
|
|
31
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
27
|
+
return createAuthFailureResponse(authResult)
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
// 3. Resolve and validate team context
|
|
@@ -76,15 +72,11 @@ export const PATCH = withRateLimitTier(async (
|
|
|
76
72
|
{ params }: { params: Promise<{ id: string }> }
|
|
77
73
|
) => {
|
|
78
74
|
try {
|
|
79
|
-
// 1. Authenticate
|
|
80
|
-
|
|
75
|
+
// 1. Authenticate; the API-key scope is declared at the entry point,
|
|
76
|
+
// which fails closed for keys that lack it (#93).
|
|
77
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:write' })
|
|
81
78
|
if (!authResult.success) {
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// 2. Check permissions
|
|
86
|
-
if (!hasRequiredScope(authResult, 'media:write')) {
|
|
87
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
79
|
+
return createAuthFailureResponse(authResult)
|
|
88
80
|
}
|
|
89
81
|
|
|
90
82
|
// 3. Resolve and validate team context
|
|
@@ -141,15 +133,11 @@ export const DELETE = withRateLimitTier(async (
|
|
|
141
133
|
{ params }: { params: Promise<{ id: string }> }
|
|
142
134
|
) => {
|
|
143
135
|
try {
|
|
144
|
-
// 1. Authenticate
|
|
145
|
-
|
|
136
|
+
// 1. Authenticate; the API-key scope is declared at the entry point,
|
|
137
|
+
// which fails closed for keys that lack it (#93).
|
|
138
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:delete' })
|
|
146
139
|
if (!authResult.success) {
|
|
147
|
-
return
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// 2. Check permissions
|
|
151
|
-
if (!hasRequiredScope(authResult, 'media:delete')) {
|
|
152
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
140
|
+
return createAuthFailureResponse(authResult)
|
|
153
141
|
}
|
|
154
142
|
|
|
155
143
|
// 3. Resolve and validate team context
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server'
|
|
2
|
-
import { authenticateRequest,
|
|
2
|
+
import { authenticateRequest, createAuthFailureResponse, resolveTeamContext } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
3
|
import { createApiResponse, createApiError } from '@nextsparkjs/core/lib/api/helpers'
|
|
4
4
|
import { API_ERROR_CODES } from '@nextsparkjs/core/lib/api/api-error'
|
|
5
5
|
import { checkPermission } from '@nextsparkjs/core/lib/permissions/check'
|
|
@@ -25,13 +25,11 @@ export const GET = withRateLimitTier(async (
|
|
|
25
25
|
{ params }: { params: Promise<{ id: string }> }
|
|
26
26
|
) => {
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
// Authenticate; the API-key scope is declared at the entry point, which
|
|
29
|
+
// fails closed for keys that lack it (#93).
|
|
30
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:read' })
|
|
29
31
|
if (!authResult.success) {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!hasRequiredScope(authResult, 'media:read')) {
|
|
34
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
32
|
+
return createAuthFailureResponse(authResult)
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
const teamResult = await resolveTeamContext(request, authResult)
|
|
@@ -70,13 +68,11 @@ export const POST = withRateLimitTier(async (
|
|
|
70
68
|
{ params }: { params: Promise<{ id: string }> }
|
|
71
69
|
) => {
|
|
72
70
|
try {
|
|
73
|
-
|
|
71
|
+
// Authenticate; the API-key scope is declared at the entry point, which
|
|
72
|
+
// fails closed for keys that lack it (#93).
|
|
73
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:write' })
|
|
74
74
|
if (!authResult.success) {
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (!hasRequiredScope(authResult, 'media:write')) {
|
|
79
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
75
|
+
return createAuthFailureResponse(authResult)
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
const teamResult = await resolveTeamContext(request, authResult)
|
|
@@ -124,13 +120,11 @@ export const PUT = withRateLimitTier(async (
|
|
|
124
120
|
{ params }: { params: Promise<{ id: string }> }
|
|
125
121
|
) => {
|
|
126
122
|
try {
|
|
127
|
-
|
|
123
|
+
// Authenticate; the API-key scope is declared at the entry point, which
|
|
124
|
+
// fails closed for keys that lack it (#93).
|
|
125
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:write' })
|
|
128
126
|
if (!authResult.success) {
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (!hasRequiredScope(authResult, 'media:write')) {
|
|
133
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
127
|
+
return createAuthFailureResponse(authResult)
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
const teamResult = await resolveTeamContext(request, authResult)
|
|
@@ -178,13 +172,11 @@ export const DELETE = withRateLimitTier(async (
|
|
|
178
172
|
{ params }: { params: Promise<{ id: string }> }
|
|
179
173
|
) => {
|
|
180
174
|
try {
|
|
181
|
-
|
|
175
|
+
// Authenticate; the API-key scope is declared at the entry point, which
|
|
176
|
+
// fails closed for keys that lack it (#93).
|
|
177
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:write' })
|
|
182
178
|
if (!authResult.success) {
|
|
183
|
-
return
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (!hasRequiredScope(authResult, 'media:write')) {
|
|
187
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
179
|
+
return createAuthFailureResponse(authResult)
|
|
188
180
|
}
|
|
189
181
|
|
|
190
182
|
const teamResult = await resolveTeamContext(request, authResult)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server'
|
|
2
|
-
import { authenticateRequest,
|
|
2
|
+
import { authenticateRequest, createAuthFailureResponse, resolveTeamContext } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
3
|
import { createApiResponse, createApiError } from '@nextsparkjs/core/lib/api/helpers'
|
|
4
4
|
import { API_ERROR_CODES } from '@nextsparkjs/core/lib/api/api-error'
|
|
5
5
|
import { checkPermission } from '@nextsparkjs/core/lib/permissions/check'
|
|
@@ -17,13 +17,11 @@ import { MediaService } from '@nextsparkjs/core/lib/services/media.service'
|
|
|
17
17
|
*/
|
|
18
18
|
export const POST = withRateLimitTier(async (request: NextRequest) => {
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
// Authenticate; the API-key scope is declared at the entry point, which
|
|
21
|
+
// fails closed for keys that lack it (#93).
|
|
22
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:read' })
|
|
21
23
|
if (!authResult.success) {
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!hasRequiredScope(authResult, 'media:read')) {
|
|
26
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
24
|
+
return createAuthFailureResponse(authResult)
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
const teamResult = await resolveTeamContext(request, authResult)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server'
|
|
2
|
-
import { authenticateRequest,
|
|
2
|
+
import { authenticateRequest, createAuthFailureResponse, resolveTeamContext } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
3
|
import { createApiResponse, createApiError } from '@nextsparkjs/core/lib/api/helpers'
|
|
4
4
|
import { API_ERROR_CODES } from '@nextsparkjs/core/lib/api/api-error'
|
|
5
5
|
import { checkPermission } from '@nextsparkjs/core/lib/permissions/check'
|
|
@@ -26,15 +26,11 @@ import { mediaListQuerySchema } from '@nextsparkjs/core/lib/media/schemas'
|
|
|
26
26
|
*/
|
|
27
27
|
export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
28
28
|
try {
|
|
29
|
-
// 1. Authenticate
|
|
30
|
-
|
|
29
|
+
// 1. Authenticate; the API-key scope is declared at the entry point,
|
|
30
|
+
// which fails closed for keys that lack it (#93).
|
|
31
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:read' })
|
|
31
32
|
if (!authResult.success) {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 2. Check permissions
|
|
36
|
-
if (!hasRequiredScope(authResult, 'media:read')) {
|
|
37
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
33
|
+
return createAuthFailureResponse(authResult)
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
// 3. Resolve and validate team context
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server'
|
|
2
2
|
import { put } from '@vercel/blob'
|
|
3
|
-
import { authenticateRequest,
|
|
3
|
+
import { authenticateRequest, createAuthFailureResponse, resolveTeamContext } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
4
4
|
import { createApiResponse, createApiError } from '@nextsparkjs/core/lib/api/helpers'
|
|
5
5
|
import { API_ERROR_CODES } from '@nextsparkjs/core/lib/api/api-error'
|
|
6
6
|
import { checkPermission } from '@nextsparkjs/core/lib/permissions/check'
|
|
@@ -55,18 +55,12 @@ async function uploadToLocalStorageBuffer(buffer: Buffer, fileName: string): Pro
|
|
|
55
55
|
*/
|
|
56
56
|
export const POST = withRateLimitTier(async (request: NextRequest) => {
|
|
57
57
|
try {
|
|
58
|
-
// 1. Dual Authentication (API Key OR Session)
|
|
59
|
-
|
|
58
|
+
// 1. Dual Authentication (API Key OR Session); the API-key scope is
|
|
59
|
+
// declared at the entry point, which fails closed for keys that lack it (#93).
|
|
60
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:write' })
|
|
60
61
|
|
|
61
62
|
if (!authResult.success) {
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 2. Check permissions for media upload
|
|
66
|
-
const hasPermission = hasRequiredScope(authResult, 'media:write')
|
|
67
|
-
|
|
68
|
-
if (!hasPermission) {
|
|
69
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
63
|
+
return createAuthFailureResponse(authResult)
|
|
70
64
|
}
|
|
71
65
|
|
|
72
66
|
// 3. Resolve and validate team context
|
|
@@ -237,18 +231,12 @@ export const POST = withRateLimitTier(async (request: NextRequest) => {
|
|
|
237
231
|
*/
|
|
238
232
|
export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
239
233
|
try {
|
|
240
|
-
// 1. Dual Authentication (API Key OR Session)
|
|
241
|
-
|
|
234
|
+
// 1. Dual Authentication (API Key OR Session); the API-key scope is
|
|
235
|
+
// declared at the entry point, which fails closed for keys that lack it (#93).
|
|
236
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:read' })
|
|
242
237
|
|
|
243
238
|
if (!authResult.success) {
|
|
244
|
-
return
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// 2. Check permissions for media read
|
|
248
|
-
const hasPermission = hasRequiredScope(authResult, 'media:read')
|
|
249
|
-
|
|
250
|
-
if (!hasPermission) {
|
|
251
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
239
|
+
return createAuthFailureResponse(authResult)
|
|
252
240
|
}
|
|
253
241
|
|
|
254
242
|
// 3. Resolve and validate team context
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server'
|
|
2
|
-
import { authenticateRequest,
|
|
2
|
+
import { authenticateRequest, createAuthFailureResponse, resolveTeamContext } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
3
|
import { createApiResponse, createApiError } from '@nextsparkjs/core/lib/api/helpers'
|
|
4
4
|
import { API_ERROR_CODES } from '@nextsparkjs/core/lib/api/api-error'
|
|
5
5
|
import { checkPermission } from '@nextsparkjs/core/lib/permissions/check'
|
|
@@ -15,13 +15,11 @@ import { MediaService } from '@nextsparkjs/core/lib/services/media.service'
|
|
|
15
15
|
*/
|
|
16
16
|
export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
// Authenticate; the API-key scope is declared at the entry point, which
|
|
19
|
+
// fails closed for keys that lack it (#93).
|
|
20
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:read' })
|
|
19
21
|
if (!authResult.success) {
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!hasRequiredScope(authResult, 'media:read')) {
|
|
24
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
22
|
+
return createAuthFailureResponse(authResult)
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
const teamResult = await resolveTeamContext(request, authResult)
|
|
@@ -51,13 +49,11 @@ export const GET = withRateLimitTier(async (request: NextRequest) => {
|
|
|
51
49
|
*/
|
|
52
50
|
export const POST = withRateLimitTier(async (request: NextRequest) => {
|
|
53
51
|
try {
|
|
54
|
-
|
|
52
|
+
// Authenticate; the API-key scope is declared at the entry point, which
|
|
53
|
+
// fails closed for keys that lack it (#93).
|
|
54
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'media:write' })
|
|
55
55
|
if (!authResult.success) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!hasRequiredScope(authResult, 'media:write')) {
|
|
60
|
-
return createApiError('Insufficient permissions', 403, undefined, API_ERROR_CODES.INSUFFICIENT_SCOPE)
|
|
56
|
+
return createAuthFailureResponse(authResult)
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
const teamResult = await resolveTeamContext(request, authResult)
|
|
@@ -23,46 +23,38 @@ import {
|
|
|
23
23
|
handleCorsPreflightRequest,
|
|
24
24
|
addCorsHeaders,
|
|
25
25
|
} from '@nextsparkjs/core/lib/api/helpers'
|
|
26
|
-
import { authenticateRequest,
|
|
26
|
+
import { authenticateRequest, createAuthFailureResponse } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
27
27
|
import { PatternUsageService } from '@nextsparkjs/core/lib/services'
|
|
28
28
|
import { queryOneWithRLS } from '@nextsparkjs/core/lib/db'
|
|
29
29
|
|
|
30
30
|
// Handle CORS preflight
|
|
31
|
-
export async function OPTIONS() {
|
|
32
|
-
return handleCorsPreflightRequest()
|
|
31
|
+
export async function OPTIONS(request: NextRequest) {
|
|
32
|
+
return handleCorsPreflightRequest(request)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// GET /api/v1/patterns/:id/usages - Get pattern usages
|
|
36
36
|
export const GET = withApiLogging(
|
|
37
37
|
async (req: NextRequest, { params }: { params: Promise<{ id: string }> }): Promise<NextResponse> => {
|
|
38
38
|
try {
|
|
39
|
-
// Authenticate using dual auth
|
|
40
|
-
|
|
39
|
+
// Authenticate using dual auth; the required API-key scope is declared
|
|
40
|
+
// at the entry point (fail closed, #93).
|
|
41
|
+
const authResult = await authenticateRequest(req, { requiredScope: 'patterns:read' })
|
|
41
42
|
|
|
42
43
|
if (!authResult.success) {
|
|
43
|
-
return
|
|
44
|
-
{ success: false, error: 'Authentication required', code: 'AUTHENTICATION_FAILED' },
|
|
45
|
-
{ status: 401 }
|
|
46
|
-
)
|
|
44
|
+
return createAuthFailureResponse(authResult)
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
if (authResult.rateLimitResponse) {
|
|
50
48
|
return authResult.rateLimitResponse as NextResponse
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
// Check required permissions
|
|
54
|
-
if (!hasRequiredScope(authResult, 'patterns:read')) {
|
|
55
|
-
const response = createApiError('Insufficient permissions', 403)
|
|
56
|
-
return addCorsHeaders(response)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
51
|
const { id: patternId } = await params
|
|
60
52
|
const userId = authResult.user!.id
|
|
61
53
|
|
|
62
54
|
// Validate that patternId is not empty
|
|
63
55
|
if (!patternId || patternId.trim() === '') {
|
|
64
56
|
const response = createApiError('Pattern ID is required', 400, null, 'MISSING_PATTERN_ID')
|
|
65
|
-
return addCorsHeaders(response)
|
|
57
|
+
return addCorsHeaders(response, req)
|
|
66
58
|
}
|
|
67
59
|
|
|
68
60
|
// Verify pattern exists and user has access
|
|
@@ -74,7 +66,7 @@ export const GET = withApiLogging(
|
|
|
74
66
|
|
|
75
67
|
if (!pattern) {
|
|
76
68
|
const response = createApiError('Pattern not found', 404, null, 'PATTERN_NOT_FOUND')
|
|
77
|
-
return addCorsHeaders(response)
|
|
69
|
+
return addCorsHeaders(response, req)
|
|
78
70
|
}
|
|
79
71
|
|
|
80
72
|
// Parse query parameters
|
|
@@ -106,11 +98,11 @@ export const GET = withApiLogging(
|
|
|
106
98
|
entityType: entityType || 'all',
|
|
107
99
|
})
|
|
108
100
|
|
|
109
|
-
return addCorsHeaders(response)
|
|
101
|
+
return addCorsHeaders(response, req)
|
|
110
102
|
} catch (error) {
|
|
111
103
|
console.error('Error fetching pattern usages:', error)
|
|
112
104
|
const response = createApiError('Internal server error', 500)
|
|
113
|
-
return addCorsHeaders(response)
|
|
105
|
+
return addCorsHeaders(response, req)
|
|
114
106
|
}
|
|
115
107
|
}
|
|
116
108
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server'
|
|
2
|
-
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
2
|
+
import { authenticateRequest, createAuthFailureResponse } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
3
|
import { query as dbQuery } from '@nextsparkjs/core/lib/db'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
@@ -52,10 +52,11 @@ export const PUT = withRateLimitTier(async (
|
|
|
52
52
|
{ params }: { params: Promise<{ id: string }> }
|
|
53
53
|
): Promise<NextResponse> => {
|
|
54
54
|
try {
|
|
55
|
-
// Dual authentication: API key or session
|
|
56
|
-
|
|
55
|
+
// Dual authentication: API key or session; the API-key scope is declared
|
|
56
|
+
// at the entry point, which fails closed for keys that lack it (#93).
|
|
57
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'posts:write' })
|
|
57
58
|
if (!authResult.success || !authResult.user) {
|
|
58
|
-
return
|
|
59
|
+
return createAuthFailureResponse(authResult)
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
const body = await request.json()
|
|
@@ -192,10 +193,11 @@ export const DELETE = withRateLimitTier(async (
|
|
|
192
193
|
{ params }: { params: Promise<{ id: string }> }
|
|
193
194
|
): Promise<NextResponse> => {
|
|
194
195
|
try {
|
|
195
|
-
// Dual authentication: API key or session
|
|
196
|
-
|
|
196
|
+
// Dual authentication: API key or session; the API-key scope is declared
|
|
197
|
+
// at the entry point, which fails closed for keys that lack it (#93).
|
|
198
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'posts:delete' })
|
|
197
199
|
if (!authResult.success || !authResult.user) {
|
|
198
|
-
return
|
|
200
|
+
return createAuthFailureResponse(authResult)
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
const { id } = await params
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server'
|
|
2
|
-
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
2
|
+
import { authenticateRequest, createAuthFailureResponse } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
3
3
|
import { query as dbQuery } from '@nextsparkjs/core/lib/db'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
@@ -50,10 +50,11 @@ export const GET = withRateLimitTier(async () => {
|
|
|
50
50
|
// POST /api/v1/post-categories - Create category
|
|
51
51
|
export const POST = withRateLimitTier(async (request: NextRequest) => {
|
|
52
52
|
try {
|
|
53
|
-
// Dual authentication: API key or session
|
|
54
|
-
|
|
53
|
+
// Dual authentication: API key or session; the API-key scope is declared
|
|
54
|
+
// at the entry point, which fails closed for keys that lack it (#93).
|
|
55
|
+
const authResult = await authenticateRequest(request, { requiredScope: 'posts:write' })
|
|
55
56
|
if (!authResult.success || !authResult.user) {
|
|
56
|
-
return
|
|
57
|
+
return createAuthFailureResponse(authResult)
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
const body = await request.json()
|
|
@@ -7,28 +7,26 @@ import {
|
|
|
7
7
|
handleCorsPreflightRequest,
|
|
8
8
|
addCorsHeaders,
|
|
9
9
|
} from '@nextsparkjs/core/lib/api/helpers'
|
|
10
|
-
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
10
|
+
import { authenticateRequest, createAuthFailureResponse } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
11
11
|
import { checkRateLimit, withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
12
12
|
import { RATE_LIMITS } from '@nextsparkjs/core/lib/api/keys'
|
|
13
13
|
import type { TeamInvitation, TeamMember } from '@nextsparkjs/core/lib/teams/types'
|
|
14
14
|
|
|
15
15
|
// Handle CORS preflight
|
|
16
|
-
export async function OPTIONS() {
|
|
17
|
-
return handleCorsPreflightRequest()
|
|
16
|
+
export async function OPTIONS(request: NextRequest) {
|
|
17
|
+
return handleCorsPreflightRequest(request)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// POST /api/v1/team-invitations/:token/accept - Accept invitation and become member
|
|
21
21
|
export const POST = withRateLimitTier(withApiLogging(
|
|
22
22
|
async (req: NextRequest, { params }: { params: Promise<{ token: string }> }): Promise<NextResponse> => {
|
|
23
23
|
try {
|
|
24
|
-
// Authenticate using dual auth
|
|
25
|
-
|
|
24
|
+
// Authenticate using dual auth; the API-key scope is declared at the entry
|
|
25
|
+
// point, which fails closed for keys that lack it (#93).
|
|
26
|
+
const authResult = await authenticateRequest(req, { requiredScope: 'teams:write' })
|
|
26
27
|
|
|
27
28
|
if (!authResult.success) {
|
|
28
|
-
return
|
|
29
|
-
{ success: false, error: 'Authentication required', code: 'AUTHENTICATION_FAILED' },
|
|
30
|
-
{ status: 401 }
|
|
31
|
-
)
|
|
29
|
+
return createAuthFailureResponse(authResult)
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
if (authResult.rateLimitResponse) {
|
|
@@ -47,7 +45,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
47
45
|
{ retryAfter: Math.ceil((rateLimit.resetTime - Date.now()) / 1000) },
|
|
48
46
|
'RATE_LIMIT_EXCEEDED'
|
|
49
47
|
)
|
|
50
|
-
return addCorsHeaders(response)
|
|
48
|
+
return addCorsHeaders(response, req)
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
const { token } = await params
|
|
@@ -55,7 +53,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
55
53
|
// Validate that token is not empty
|
|
56
54
|
if (!token || token.trim() === '') {
|
|
57
55
|
const response = createApiError('Invitation token is required', 400, null, 'MISSING_TOKEN')
|
|
58
|
-
return addCorsHeaders(response)
|
|
56
|
+
return addCorsHeaders(response, req)
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
// Get invitation by token
|
|
@@ -67,7 +65,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
67
65
|
|
|
68
66
|
if (!invitation) {
|
|
69
67
|
const response = createApiError('Invitation not found', 404, null, 'INVITATION_NOT_FOUND')
|
|
70
|
-
return addCorsHeaders(response)
|
|
68
|
+
return addCorsHeaders(response, req)
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
// Verify invitation is for the current user's email
|
|
@@ -78,7 +76,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
78
76
|
null,
|
|
79
77
|
'EMAIL_MISMATCH'
|
|
80
78
|
)
|
|
81
|
-
return addCorsHeaders(response)
|
|
79
|
+
return addCorsHeaders(response, req)
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
// Check if invitation is pending
|
|
@@ -89,7 +87,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
89
87
|
null,
|
|
90
88
|
'INVITATION_NOT_PENDING'
|
|
91
89
|
)
|
|
92
|
-
return addCorsHeaders(response)
|
|
90
|
+
return addCorsHeaders(response, req)
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
// Check if invitation has expired
|
|
@@ -103,7 +101,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
103
101
|
)
|
|
104
102
|
|
|
105
103
|
const response = createApiError('Invitation has expired', 410, null, 'INVITATION_EXPIRED')
|
|
106
|
-
return addCorsHeaders(response)
|
|
104
|
+
return addCorsHeaders(response, req)
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
// Check if user is already a member
|
|
@@ -115,7 +113,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
115
113
|
|
|
116
114
|
if (existingMember) {
|
|
117
115
|
const response = createApiError('You are already a member of this team', 409, null, 'ALREADY_MEMBER')
|
|
118
|
-
return addCorsHeaders(response)
|
|
116
|
+
return addCorsHeaders(response, req)
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
// Use transaction to ensure atomicity
|
|
@@ -165,7 +163,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
165
163
|
)
|
|
166
164
|
|
|
167
165
|
const response = createApiResponse(memberWithUser, { created: true }, 201)
|
|
168
|
-
return addCorsHeaders(response)
|
|
166
|
+
return addCorsHeaders(response, req)
|
|
169
167
|
} catch (error) {
|
|
170
168
|
await tx.rollback()
|
|
171
169
|
throw error
|
|
@@ -173,7 +171,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
173
171
|
} catch (error) {
|
|
174
172
|
console.error('Error accepting invitation:', error)
|
|
175
173
|
const response = createApiError('Internal server error', 500)
|
|
176
|
-
return addCorsHeaders(response)
|
|
174
|
+
return addCorsHeaders(response, req)
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
), 'write');
|
|
@@ -7,28 +7,26 @@ import {
|
|
|
7
7
|
handleCorsPreflightRequest,
|
|
8
8
|
addCorsHeaders,
|
|
9
9
|
} from '@nextsparkjs/core/lib/api/helpers'
|
|
10
|
-
import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
10
|
+
import { authenticateRequest, createAuthFailureResponse } from '@nextsparkjs/core/lib/api/auth/dual-auth'
|
|
11
11
|
import { checkRateLimit, withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
|
|
12
12
|
import { RATE_LIMITS } from '@nextsparkjs/core/lib/api/keys'
|
|
13
13
|
import type { TeamInvitation } from '@nextsparkjs/core/lib/teams/types'
|
|
14
14
|
|
|
15
15
|
// Handle CORS preflight
|
|
16
|
-
export async function OPTIONS() {
|
|
17
|
-
return handleCorsPreflightRequest()
|
|
16
|
+
export async function OPTIONS(request: NextRequest) {
|
|
17
|
+
return handleCorsPreflightRequest(request)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// POST /api/v1/team-invitations/:token/decline - Decline invitation
|
|
21
21
|
export const POST = withRateLimitTier(withApiLogging(
|
|
22
22
|
async (req: NextRequest, { params }: { params: Promise<{ token: string }> }): Promise<NextResponse> => {
|
|
23
23
|
try {
|
|
24
|
-
// Authenticate using dual auth
|
|
25
|
-
|
|
24
|
+
// Authenticate using dual auth; the API-key scope is declared at the entry
|
|
25
|
+
// point, which fails closed for keys that lack it (#93).
|
|
26
|
+
const authResult = await authenticateRequest(req, { requiredScope: 'teams:write' })
|
|
26
27
|
|
|
27
28
|
if (!authResult.success) {
|
|
28
|
-
return
|
|
29
|
-
{ success: false, error: 'Authentication required', code: 'AUTHENTICATION_FAILED' },
|
|
30
|
-
{ status: 401 }
|
|
31
|
-
)
|
|
29
|
+
return createAuthFailureResponse(authResult)
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
if (authResult.rateLimitResponse) {
|
|
@@ -47,7 +45,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
47
45
|
{ retryAfter: Math.ceil((rateLimit.resetTime - Date.now()) / 1000) },
|
|
48
46
|
'RATE_LIMIT_EXCEEDED'
|
|
49
47
|
)
|
|
50
|
-
return addCorsHeaders(response)
|
|
48
|
+
return addCorsHeaders(response, req)
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
const { token } = await params
|
|
@@ -55,7 +53,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
55
53
|
// Validate that token is not empty
|
|
56
54
|
if (!token || token.trim() === '') {
|
|
57
55
|
const response = createApiError('Invitation token is required', 400, null, 'MISSING_TOKEN')
|
|
58
|
-
return addCorsHeaders(response)
|
|
56
|
+
return addCorsHeaders(response, req)
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
// Get invitation by token
|
|
@@ -67,7 +65,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
67
65
|
|
|
68
66
|
if (!invitation) {
|
|
69
67
|
const response = createApiError('Invitation not found', 404, null, 'INVITATION_NOT_FOUND')
|
|
70
|
-
return addCorsHeaders(response)
|
|
68
|
+
return addCorsHeaders(response, req)
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
// Verify invitation is for the current user's email
|
|
@@ -78,7 +76,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
78
76
|
null,
|
|
79
77
|
'EMAIL_MISMATCH'
|
|
80
78
|
)
|
|
81
|
-
return addCorsHeaders(response)
|
|
79
|
+
return addCorsHeaders(response, req)
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
// Check if invitation is pending
|
|
@@ -89,7 +87,7 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
89
87
|
null,
|
|
90
88
|
'INVITATION_NOT_PENDING'
|
|
91
89
|
)
|
|
92
|
-
return addCorsHeaders(response)
|
|
90
|
+
return addCorsHeaders(response, req)
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
// Update invitation status to declined
|
|
@@ -104,17 +102,17 @@ export const POST = withRateLimitTier(withApiLogging(
|
|
|
104
102
|
|
|
105
103
|
if (result.rows.length === 0) {
|
|
106
104
|
const response = createApiError('Invitation not found', 404, null, 'INVITATION_NOT_FOUND')
|
|
107
|
-
return addCorsHeaders(response)
|
|
105
|
+
return addCorsHeaders(response, req)
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
const declinedInvitation = result.rows[0]
|
|
111
109
|
|
|
112
110
|
const response = createApiResponse(declinedInvitation)
|
|
113
|
-
return addCorsHeaders(response)
|
|
111
|
+
return addCorsHeaders(response, req)
|
|
114
112
|
} catch (error) {
|
|
115
113
|
console.error('Error declining invitation:', error)
|
|
116
114
|
const response = createApiError('Internal server error', 500)
|
|
117
|
-
return addCorsHeaders(response)
|
|
115
|
+
return addCorsHeaders(response, req)
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
118
|
), 'write');
|