moonhead 1.0.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/README.md +32 -0
- package/dist/components/layout/app-header.d.ts +1 -0
- package/dist/components/layout/app-header.js +1 -0
- package/dist/components/layout/app-sidebar.d.ts +9 -0
- package/dist/components/layout/app-sidebar.js +1 -0
- package/dist/components/layout/brand-logo.d.ts +2 -0
- package/dist/components/layout/brand-logo.js +1 -0
- package/dist/components/layout/user-menu.d.ts +6 -0
- package/dist/components/layout/user-menu.js +1 -0
- package/dist/components/ui/action-form.d.ts +10 -0
- package/dist/components/ui/action-form.js +1 -0
- package/dist/components/ui/alert-dialog.d.ts +14 -0
- package/dist/components/ui/alert-dialog.js +1 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +1 -0
- package/dist/components/ui/avatar.d.ts +12 -0
- package/dist/components/ui/avatar.js +1 -0
- package/dist/components/ui/badge.d.ts +2 -0
- package/dist/components/ui/badge.js +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.js +1 -0
- package/dist/components/ui/card.d.ts +2 -0
- package/dist/components/ui/card.js +1 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.js +1 -0
- package/dist/components/ui/combobox.d.ts +18 -0
- package/dist/components/ui/combobox.js +1 -0
- package/dist/components/ui/copy-button.d.ts +8 -0
- package/dist/components/ui/copy-button.js +1 -0
- package/dist/components/ui/country-select.d.ts +12 -0
- package/dist/components/ui/country-select.js +1 -0
- package/dist/components/ui/data-table.d.ts +11 -0
- package/dist/components/ui/data-table.js +1 -0
- package/dist/components/ui/date-range-picker.d.ts +25 -0
- package/dist/components/ui/date-range-picker.js +1 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dialog.js +1 -0
- package/dist/components/ui/drawer.d.ts +24 -0
- package/dist/components/ui/drawer.js +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +17 -0
- package/dist/components/ui/dropdown-menu.js +1 -0
- package/dist/components/ui/field.d.ts +7 -0
- package/dist/components/ui/field.js +1 -0
- package/dist/components/ui/fieldset.d.ts +4 -0
- package/dist/components/ui/fieldset.js +1 -0
- package/dist/components/ui/form-field.d.ts +17 -0
- package/dist/components/ui/form-field.js +1 -0
- package/dist/components/ui/form.d.ts +3 -0
- package/dist/components/ui/form.js +1 -0
- package/dist/components/ui/icon-tile.d.ts +5 -0
- package/dist/components/ui/icon-tile.js +1 -0
- package/dist/components/ui/identity.d.ts +6 -0
- package/dist/components/ui/identity.js +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.js +1 -0
- package/dist/components/ui/number-input.d.ts +19 -0
- package/dist/components/ui/number-input.js +1 -0
- package/dist/components/ui/otp-field.d.ts +6 -0
- package/dist/components/ui/otp-field.js +1 -0
- package/dist/components/ui/page-toolbar.d.ts +9 -0
- package/dist/components/ui/page-toolbar.js +1 -0
- package/dist/components/ui/password-input.d.ts +7 -0
- package/dist/components/ui/password-input.js +1 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +1 -0
- package/dist/components/ui/search-input.d.ts +4 -0
- package/dist/components/ui/search-input.js +1 -0
- package/dist/components/ui/section-card.d.ts +7 -0
- package/dist/components/ui/section-card.js +1 -0
- package/dist/components/ui/select-field.d.ts +19 -0
- package/dist/components/ui/select-field.js +1 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +1 -0
- package/dist/components/ui/sidebar.d.ts +27 -0
- package/dist/components/ui/sidebar.js +1 -0
- package/dist/components/ui/slider.d.ts +10 -0
- package/dist/components/ui/slider.js +1 -0
- package/dist/components/ui/sort-button.d.ts +5 -0
- package/dist/components/ui/sort-button.js +1 -0
- package/dist/components/ui/spinner.d.ts +4 -0
- package/dist/components/ui/spinner.js +1 -0
- package/dist/components/ui/status-badge.d.ts +11 -0
- package/dist/components/ui/status-badge.js +1 -0
- package/dist/components/ui/switch-field.d.ts +18 -0
- package/dist/components/ui/switch-field.js +1 -0
- package/dist/components/ui/switch.d.ts +3 -0
- package/dist/components/ui/switch.js +1 -0
- package/dist/components/ui/table-pagination.d.ts +9 -0
- package/dist/components/ui/table-pagination.js +1 -0
- package/dist/components/ui/table.d.ts +18 -0
- package/dist/components/ui/table.js +1 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.js +1 -0
- package/dist/components/ui/tag-input.d.ts +9 -0
- package/dist/components/ui/tag-input.js +1 -0
- package/dist/components/ui/text-link.d.ts +10 -0
- package/dist/components/ui/text-link.js +1 -0
- package/dist/components/ui/textarea.d.ts +2 -0
- package/dist/components/ui/textarea.js +1 -0
- package/dist/components/ui/toast.d.ts +1 -0
- package/dist/components/ui/toast.js +1 -0
- package/dist/components/ui/tree.d.ts +32 -0
- package/dist/components/ui/tree.js +1 -0
- package/dist/db/client.d.ts +8 -0
- package/dist/db/client.js +1 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.js +1 -0
- package/dist/db/logger.d.ts +2 -0
- package/dist/db/logger.js +1 -0
- package/dist/db/migrations/20260628182304_wonderful_groot/migration.sql +289 -0
- package/dist/db/migrations/20260628182304_wonderful_groot/snapshot.json +3750 -0
- package/dist/db/migrations/20260630082829_wet_robin_chapel/migration.sql +2 -0
- package/dist/db/migrations/20260630082829_wet_robin_chapel/snapshot.json +3791 -0
- package/dist/db/migrations/20260702132335_wooden_iron_monger/migration.sql +48 -0
- package/dist/db/migrations/20260702132335_wooden_iron_monger/snapshot.json +4407 -0
- package/dist/db/migrations/20260702142948_vengeful_rhino/migration.sql +1 -0
- package/dist/db/migrations/20260702142948_vengeful_rhino/snapshot.json +4420 -0
- package/dist/db/migrations/20260702185813_curved_pyro/migration.sql +16 -0
- package/dist/db/migrations/20260702185813_curved_pyro/snapshot.json +4646 -0
- package/dist/db/migrations/20260702192041_shiny_franklin_storm/migration.sql +16 -0
- package/dist/db/migrations/20260702192041_shiny_franklin_storm/snapshot.json +4872 -0
- package/dist/db/migrations/20260704101548_bizarre_namorita/migration.sql +1 -0
- package/dist/db/migrations/20260704101548_bizarre_namorita/snapshot.json +4885 -0
- package/dist/db/migrations/20260704105911_sleepy_juggernaut/migration.sql +1 -0
- package/dist/db/migrations/20260704105911_sleepy_juggernaut/snapshot.json +4898 -0
- package/dist/db/migrations/20260704115959_lean_sandman/migration.sql +1 -0
- package/dist/db/migrations/20260704115959_lean_sandman/snapshot.json +4885 -0
- package/dist/db/migrations/20260707231532_daffy_captain_stacy/migration.sql +10 -0
- package/dist/db/migrations/20260707231532_daffy_captain_stacy/snapshot.json +4919 -0
- package/dist/db/migrations/20260708190355_spooky_jimmy_woo/migration.sql +3 -0
- package/dist/db/migrations/20260708190355_spooky_jimmy_woo/snapshot.json +4970 -0
- package/dist/db/migrations/20260711145212_drop_legacy_earning_status/migration.sql +7 -0
- package/dist/db/migrations/20260711145212_drop_legacy_earning_status/snapshot.json +4968 -0
- package/dist/db/migrations/20260712161249_dashboard_stat_indexes/migration.sql +3 -0
- package/dist/db/migrations/20260712161249_dashboard_stat_indexes/snapshot.json +5038 -0
- package/dist/db/migrations/20260713013911_add_payout_paid_at/migration.sql +2 -0
- package/dist/db/migrations/20260713013911_add_payout_paid_at/snapshot.json +5072 -0
- package/dist/db/schema/analytics-outbox.d.ts +145 -0
- package/dist/db/schema/analytics-outbox.js +1 -0
- package/dist/db/schema/audit-logs.d.ts +204 -0
- package/dist/db/schema/audit-logs.js +1 -0
- package/dist/db/schema/campaigns.d.ts +180 -0
- package/dist/db/schema/campaigns.js +1 -0
- package/dist/db/schema/casinos.d.ts +129 -0
- package/dist/db/schema/casinos.js +1 -0
- package/dist/db/schema/commission-rule-groups.d.ts +84 -0
- package/dist/db/schema/commission-rule-groups.js +1 -0
- package/dist/db/schema/commission-rules.d.ts +145 -0
- package/dist/db/schema/commission-rules.js +1 -0
- package/dist/db/schema/commissions.d.ts +242 -0
- package/dist/db/schema/commissions.js +1 -0
- package/dist/db/schema/conversions.d.ts +302 -0
- package/dist/db/schema/conversions.js +1 -0
- package/dist/db/schema/deals.d.ts +180 -0
- package/dist/db/schema/deals.js +1 -0
- package/dist/db/schema/earnings.d.ts +262 -0
- package/dist/db/schema/earnings.js +1 -0
- package/dist/db/schema/groups.d.ts +214 -0
- package/dist/db/schema/groups.js +1 -0
- package/dist/db/schema/index.d.ts +18 -0
- package/dist/db/schema/index.js +1 -0
- package/dist/db/schema/payouts.d.ts +182 -0
- package/dist/db/schema/payouts.js +1 -0
- package/dist/db/schema/platform-settings.d.ts +84 -0
- package/dist/db/schema/platform-settings.js +1 -0
- package/dist/db/schema/player-activity.d.ts +159 -0
- package/dist/db/schema/player-activity.js +1 -0
- package/dist/db/schema/revshare-carryover.d.ts +129 -0
- package/dist/db/schema/revshare-carryover.js +1 -0
- package/dist/db/schema/sessions.d.ts +213 -0
- package/dist/db/schema/sessions.js +1 -0
- package/dist/db/schema/table.d.ts +1 -0
- package/dist/db/schema/table.js +1 -0
- package/dist/db/schema/users.d.ts +609 -0
- package/dist/db/schema/users.js +1 -0
- package/dist/db/schema/verification-tokens.d.ts +106 -0
- package/dist/db/schema/verification-tokens.js +1 -0
- package/dist/db/types/branded.d.ts +3 -0
- package/dist/db/types/branded.js +0 -0
- package/dist/db/types/commission-rules.d.ts +70 -0
- package/dist/db/types/commission-rules.js +1 -0
- package/dist/db/types/index.d.ts +2 -0
- package/dist/db/types/index.js +1 -0
- package/dist/emails/admin/support-message.d.ts +39 -0
- package/dist/emails/admin/support-message.js +5 -0
- package/dist/emails/affiliate/activated.d.ts +33 -0
- package/dist/emails/affiliate/activated.js +1 -0
- package/dist/emails/affiliate/deal-notice.d.ts +35 -0
- package/dist/emails/affiliate/deal-notice.js +1 -0
- package/dist/emails/affiliate/invite.d.ts +35 -0
- package/dist/emails/affiliate/invite.js +1 -0
- package/dist/emails/affiliate/signup-verify.d.ts +35 -0
- package/dist/emails/affiliate/signup-verify.js +1 -0
- package/dist/emails/auth/password-reset.d.ts +37 -0
- package/dist/emails/auth/password-reset.js +1 -0
- package/dist/emails/layout.d.ts +10 -0
- package/dist/emails/layout.js +1 -0
- package/dist/emails/manager/affiliate-activated.d.ts +33 -0
- package/dist/emails/manager/affiliate-activated.js +1 -0
- package/dist/emails/manager/bulk-affiliates-activated.d.ts +33 -0
- package/dist/emails/manager/bulk-affiliates-activated.js +1 -0
- package/dist/emails/manager/invite.d.ts +35 -0
- package/dist/emails/manager/invite.js +1 -0
- package/dist/emails/manager/pending-approval.d.ts +33 -0
- package/dist/emails/manager/pending-approval.js +1 -0
- package/dist/emails/preview-env.d.ts +2 -0
- package/dist/emails/preview-env.js +1 -0
- package/dist/features/affiliates/actions.d.ts +60 -0
- package/dist/features/affiliates/actions.js +1 -0
- package/dist/features/affiliates/activation-email.d.ts +8 -0
- package/dist/features/affiliates/activation-email.js +1 -0
- package/dist/features/affiliates/bulk-approve.d.ts +2 -0
- package/dist/features/affiliates/bulk-approve.js +1 -0
- package/dist/features/affiliates/components/affiliate-actions-menu.d.ts +6 -0
- package/dist/features/affiliates/components/affiliate-actions-menu.js +1 -0
- package/dist/features/affiliates/components/affiliate-create-button.d.ts +1 -0
- package/dist/features/affiliates/components/affiliate-create-button.js +1 -0
- package/dist/features/affiliates/components/affiliate-detail-tabs.d.ts +6 -0
- package/dist/features/affiliates/components/affiliate-detail-tabs.js +1 -0
- package/dist/features/affiliates/components/affiliate-dialog.d.ts +11 -0
- package/dist/features/affiliates/components/affiliate-dialog.js +1 -0
- package/dist/features/affiliates/components/affiliate-profile-fields.d.ts +6 -0
- package/dist/features/affiliates/components/affiliate-profile-fields.js +1 -0
- package/dist/features/affiliates/components/affiliate-status-badge.d.ts +4 -0
- package/dist/features/affiliates/components/affiliate-status-badge.js +1 -0
- package/dist/features/affiliates/components/affiliate-status-tabs.d.ts +4 -0
- package/dist/features/affiliates/components/affiliate-status-tabs.js +1 -0
- package/dist/features/affiliates/components/affiliates-table.d.ts +10 -0
- package/dist/features/affiliates/components/affiliates-table.js +1 -0
- package/dist/features/affiliates/components/assign-parent-dialog.d.ts +5 -0
- package/dist/features/affiliates/components/assign-parent-dialog.js +1 -0
- package/dist/features/affiliates/components/detach-affiliate-confirm.d.ts +5 -0
- package/dist/features/affiliates/components/detach-affiliate-confirm.js +1 -0
- package/dist/features/affiliates/components/reject-affiliate-confirm.d.ts +5 -0
- package/dist/features/affiliates/components/reject-affiliate-confirm.js +1 -0
- package/dist/features/affiliates/components/sub-affiliate-invite-button.d.ts +3 -0
- package/dist/features/affiliates/components/sub-affiliate-invite-button.js +1 -0
- package/dist/features/affiliates/invite.d.ts +6 -0
- package/dist/features/affiliates/invite.js +1 -0
- package/dist/features/affiliates/list-params.d.ts +27 -0
- package/dist/features/affiliates/list-params.js +1 -0
- package/dist/features/affiliates/pending-notification.d.ts +18 -0
- package/dist/features/affiliates/pending-notification.js +1 -0
- package/dist/features/affiliates/sub-invite.d.ts +7 -0
- package/dist/features/affiliates/sub-invite.js +1 -0
- package/dist/features/audit/action-labels.d.ts +15 -0
- package/dist/features/audit/action-labels.js +1 -0
- package/dist/features/audit/components/audit-log-table.d.ts +5 -0
- package/dist/features/audit/components/audit-log-table.js +1 -0
- package/dist/features/audit/list-params.d.ts +2 -0
- package/dist/features/audit/list-params.js +1 -0
- package/dist/features/audit/read.d.ts +27 -0
- package/dist/features/audit/read.js +1 -0
- package/dist/features/auth/actions.d.ts +33 -0
- package/dist/features/auth/actions.js +1 -0
- package/dist/features/auth/authorization.d.ts +14 -0
- package/dist/features/auth/authorization.js +1 -0
- package/dist/features/auth/components/accept-invite-form.d.ts +3 -0
- package/dist/features/auth/components/accept-invite-form.js +1 -0
- package/dist/features/auth/components/forgot-password-form.d.ts +1 -0
- package/dist/features/auth/components/forgot-password-form.js +1 -0
- package/dist/features/auth/components/permissions-form.d.ts +5 -0
- package/dist/features/auth/components/permissions-form.js +1 -0
- package/dist/features/auth/components/reset-password-form.d.ts +3 -0
- package/dist/features/auth/components/reset-password-form.js +1 -0
- package/dist/features/auth/components/signin-form.d.ts +5 -0
- package/dist/features/auth/components/signin-form.js +1 -0
- package/dist/features/auth/components/signup-form.d.ts +1 -0
- package/dist/features/auth/components/signup-form.js +1 -0
- package/dist/features/auth/components/verify-email-form.d.ts +3 -0
- package/dist/features/auth/components/verify-email-form.js +1 -0
- package/dist/features/auth/password-reset.d.ts +6 -0
- package/dist/features/auth/password-reset.js +1 -0
- package/dist/features/auth/permissions.d.ts +49 -0
- package/dist/features/auth/permissions.js +1 -0
- package/dist/features/auth/require.d.ts +3 -0
- package/dist/features/auth/require.js +1 -0
- package/dist/features/auth/signup-email.d.ts +6 -0
- package/dist/features/auth/signup-email.js +1 -0
- package/dist/features/campaigns/actions.d.ts +53 -0
- package/dist/features/campaigns/actions.js +1 -0
- package/dist/features/campaigns/components/campaign-dialog.d.ts +7 -0
- package/dist/features/campaigns/components/campaign-dialog.js +1 -0
- package/dist/features/campaigns/components/campaign-row-actions.d.ts +8 -0
- package/dist/features/campaigns/components/campaign-row-actions.js +1 -0
- package/dist/features/campaigns/components/campaign-status-badge.d.ts +6 -0
- package/dist/features/campaigns/components/campaign-status-badge.js +1 -0
- package/dist/features/campaigns/components/campaign-status-tabs.d.ts +1 -0
- package/dist/features/campaigns/components/campaign-status-tabs.js +1 -0
- package/dist/features/campaigns/components/campaigns-table.d.ts +7 -0
- package/dist/features/campaigns/components/campaigns-table.js +1 -0
- package/dist/features/campaigns/components/create-campaign-button.d.ts +5 -0
- package/dist/features/campaigns/components/create-campaign-button.js +1 -0
- package/dist/features/campaigns/components/sub-id-builder.d.ts +4 -0
- package/dist/features/campaigns/components/sub-id-builder.js +1 -0
- package/dist/features/campaigns/components/tracking-link-box.d.ts +3 -0
- package/dist/features/campaigns/components/tracking-link-box.js +1 -0
- package/dist/features/campaigns/components/tracking-link-cell.d.ts +4 -0
- package/dist/features/campaigns/components/tracking-link-cell.js +1 -0
- package/dist/features/campaigns/components/tracking-link-dialog.d.ts +6 -0
- package/dist/features/campaigns/components/tracking-link-dialog.js +1 -0
- package/dist/features/campaigns/list-params.d.ts +14 -0
- package/dist/features/campaigns/list-params.js +1 -0
- package/dist/features/campaigns/tracking-url.d.ts +8 -0
- package/dist/features/campaigns/tracking-url.js +1 -0
- package/dist/features/casinos/actions.d.ts +39 -0
- package/dist/features/casinos/actions.js +1 -0
- package/dist/features/casinos/components/casino-create-button.d.ts +1 -0
- package/dist/features/casinos/components/casino-create-button.js +1 -0
- package/dist/features/casinos/components/casino-dialog.d.ts +11 -0
- package/dist/features/casinos/components/casino-dialog.js +1 -0
- package/dist/features/casinos/components/casino-form-fields.d.ts +7 -0
- package/dist/features/casinos/components/casino-form-fields.js +1 -0
- package/dist/features/casinos/components/casino-status-tabs.d.ts +1 -0
- package/dist/features/casinos/components/casino-status-tabs.js +1 -0
- package/dist/features/casinos/components/casinos-table.d.ts +6 -0
- package/dist/features/casinos/components/casinos-table.js +1 -0
- package/dist/features/casinos/components/delete-casino-confirm.d.ts +5 -0
- package/dist/features/casinos/components/delete-casino-confirm.js +1 -0
- package/dist/features/casinos/list-params.d.ts +14 -0
- package/dist/features/casinos/list-params.js +1 -0
- package/dist/features/commissions/actions.d.ts +76 -0
- package/dist/features/commissions/actions.js +1 -0
- package/dist/features/commissions/components/casino-bindings-field.d.ts +10 -0
- package/dist/features/commissions/components/casino-bindings-field.js +1 -0
- package/dist/features/commissions/components/commission-create-button.d.ts +1 -0
- package/dist/features/commissions/components/commission-create-button.js +1 -0
- package/dist/features/commissions/components/commission-detail-dialog.d.ts +5 -0
- package/dist/features/commissions/components/commission-detail-dialog.js +1 -0
- package/dist/features/commissions/components/commission-editor.d.ts +8 -0
- package/dist/features/commissions/components/commission-editor.js +1 -0
- package/dist/features/commissions/components/commission-read-view.d.ts +5 -0
- package/dist/features/commissions/components/commission-read-view.js +1 -0
- package/dist/features/commissions/components/commission-status-badge.d.ts +4 -0
- package/dist/features/commissions/components/commission-status-badge.js +1 -0
- package/dist/features/commissions/components/commission-status-tabs.d.ts +1 -0
- package/dist/features/commissions/components/commission-status-tabs.js +1 -0
- package/dist/features/commissions/components/commissions-table.d.ts +14 -0
- package/dist/features/commissions/components/commissions-table.js +1 -0
- package/dist/features/commissions/components/delete-commission-confirm.d.ts +5 -0
- package/dist/features/commissions/components/delete-commission-confirm.js +1 -0
- package/dist/features/commissions/components/duplicate-commission-dialog.d.ts +6 -0
- package/dist/features/commissions/components/duplicate-commission-dialog.js +1 -0
- package/dist/features/commissions/components/rule-editor/conditions-block.d.ts +9 -0
- package/dist/features/commissions/components/rule-editor/conditions-block.js +1 -0
- package/dist/features/commissions/components/rule-editor/modifiers-block.d.ts +9 -0
- package/dist/features/commissions/components/rule-editor/modifiers-block.js +1 -0
- package/dist/features/commissions/components/rule-editor/qualifiers-block.d.ts +9 -0
- package/dist/features/commissions/components/rule-editor/qualifiers-block.js +1 -0
- package/dist/features/commissions/components/rule-editor/reducer.d.ts +102 -0
- package/dist/features/commissions/components/rule-editor/reducer.js +1 -0
- package/dist/features/commissions/components/rule-editor/rewards-block.d.ts +9 -0
- package/dist/features/commissions/components/rule-editor/rewards-block.js +1 -0
- package/dist/features/commissions/components/rule-editor/rule-card.d.ts +10 -0
- package/dist/features/commissions/components/rule-editor/rule-card.js +1 -0
- package/dist/features/commissions/components/rule-editor/rule-editor.d.ts +7 -0
- package/dist/features/commissions/components/rule-editor/rule-editor.js +1 -0
- package/dist/features/commissions/components/rule-editor/rule-group-card.d.ts +9 -0
- package/dist/features/commissions/components/rule-editor/rule-group-card.js +1 -0
- package/dist/features/commissions/components/rule-editor/state.d.ts +21 -0
- package/dist/features/commissions/components/rule-editor/state.js +1 -0
- package/dist/features/commissions/components/rule-groups-read-view.d.ts +4 -0
- package/dist/features/commissions/components/rule-groups-read-view.js +1 -0
- package/dist/features/commissions/list-params.d.ts +14 -0
- package/dist/features/commissions/list-params.js +1 -0
- package/dist/features/commissions/rule-validation.d.ts +173 -0
- package/dist/features/commissions/rule-validation.js +1 -0
- package/dist/features/dashboard/affiliate-queries.d.ts +14 -0
- package/dist/features/dashboard/affiliate-queries.js +1 -0
- package/dist/features/dashboard/clickhouse.d.ts +3 -0
- package/dist/features/dashboard/clickhouse.js +2 -0
- package/dist/features/dashboard/components/affiliate-charts.d.ts +5 -0
- package/dist/features/dashboard/components/affiliate-charts.js +1 -0
- package/dist/features/dashboard/components/affiliate-stats.d.ts +5 -0
- package/dist/features/dashboard/components/affiliate-stats.js +1 -0
- package/dist/features/dashboard/components/charts/funnel-chart.d.ts +11 -0
- package/dist/features/dashboard/components/charts/funnel-chart.js +1 -0
- package/dist/features/dashboard/components/charts/rank-bar-chart.d.ts +10 -0
- package/dist/features/dashboard/components/charts/rank-bar-chart.js +1 -0
- package/dist/features/dashboard/components/charts/time-series-chart.d.ts +12 -0
- package/dist/features/dashboard/components/charts/time-series-chart.js +1 -0
- package/dist/features/dashboard/components/charts-grid.d.ts +8 -0
- package/dist/features/dashboard/components/charts-grid.js +1 -0
- package/dist/features/dashboard/components/dashboard-charts.d.ts +4 -0
- package/dist/features/dashboard/components/dashboard-charts.js +1 -0
- package/dist/features/dashboard/components/dashboard-period-tabs.d.ts +1 -0
- package/dist/features/dashboard/components/dashboard-period-tabs.js +1 -0
- package/dist/features/dashboard/components/money-stat-card.d.ts +6 -0
- package/dist/features/dashboard/components/money-stat-card.js +1 -0
- package/dist/features/dashboard/components/stat-card.d.ts +6 -0
- package/dist/features/dashboard/components/stat-card.js +1 -0
- package/dist/features/dashboard/components/top-affiliates.d.ts +4 -0
- package/dist/features/dashboard/components/top-affiliates.js +1 -0
- package/dist/features/dashboard/list-params.d.ts +24 -0
- package/dist/features/dashboard/list-params.js +1 -0
- package/dist/features/dashboard/queries.d.ts +63 -0
- package/dist/features/dashboard/queries.js +1 -0
- package/dist/features/dashboard/series.d.ts +32 -0
- package/dist/features/dashboard/series.js +1 -0
- package/dist/features/deals/actions.d.ts +60 -0
- package/dist/features/deals/actions.js +1 -0
- package/dist/features/deals/components/affiliate-deals.d.ts +10 -0
- package/dist/features/deals/components/affiliate-deals.js +1 -0
- package/dist/features/deals/components/assign-deal-button.d.ts +9 -0
- package/dist/features/deals/components/assign-deal-button.js +1 -0
- package/dist/features/deals/components/deal-dialog.d.ts +19 -0
- package/dist/features/deals/components/deal-dialog.js +1 -0
- package/dist/features/deals/components/deal-row-actions.d.ts +6 -0
- package/dist/features/deals/components/deal-row-actions.js +1 -0
- package/dist/features/deals/components/deal-status-badge.d.ts +10 -0
- package/dist/features/deals/components/deal-status-badge.js +1 -0
- package/dist/features/deals/components/deal-status-tabs.d.ts +1 -0
- package/dist/features/deals/components/deal-status-tabs.js +1 -0
- package/dist/features/deals/components/delegate-deal-button.d.ts +8 -0
- package/dist/features/deals/components/delegate-deal-button.js +1 -0
- package/dist/features/deals/deal-assigned-email.d.ts +11 -0
- package/dist/features/deals/deal-assigned-email.js +1 -0
- package/dist/features/deals/deal-delegated-email.d.ts +13 -0
- package/dist/features/deals/deal-delegated-email.js +1 -0
- package/dist/features/deals/list-params.d.ts +14 -0
- package/dist/features/deals/list-params.js +1 -0
- package/dist/features/earnings/components/earnings-balances.d.ts +4 -0
- package/dist/features/earnings/components/earnings-balances.js +1 -0
- package/dist/features/earnings/components/earnings-ledger.d.ts +5 -0
- package/dist/features/earnings/components/earnings-ledger.js +1 -0
- package/dist/features/earnings/components/earnings-status-badge.d.ts +4 -0
- package/dist/features/earnings/components/earnings-status-badge.js +1 -0
- package/dist/features/earnings/components/earnings-status-tabs.d.ts +1 -0
- package/dist/features/earnings/components/earnings-status-tabs.js +1 -0
- package/dist/features/earnings/components/sub-affiliate-earnings.d.ts +4 -0
- package/dist/features/earnings/components/sub-affiliate-earnings.js +1 -0
- package/dist/features/earnings/list-params.d.ts +14 -0
- package/dist/features/earnings/list-params.js +1 -0
- package/dist/features/earnings/queries.d.ts +30 -0
- package/dist/features/earnings/queries.js +1 -0
- package/dist/features/groups/actions.d.ts +36 -0
- package/dist/features/groups/actions.js +1 -0
- package/dist/features/groups/components/delete-group-confirm.d.ts +5 -0
- package/dist/features/groups/components/delete-group-confirm.js +1 -0
- package/dist/features/groups/components/group-create-button.d.ts +1 -0
- package/dist/features/groups/components/group-create-button.js +1 -0
- package/dist/features/groups/components/group-dialog.d.ts +11 -0
- package/dist/features/groups/components/group-dialog.js +1 -0
- package/dist/features/groups/components/group-form-fields.d.ts +10 -0
- package/dist/features/groups/components/group-form-fields.js +1 -0
- package/dist/features/groups/components/group-status-tabs.d.ts +1 -0
- package/dist/features/groups/components/group-status-tabs.js +1 -0
- package/dist/features/groups/components/groups-table.d.ts +9 -0
- package/dist/features/groups/components/groups-table.js +1 -0
- package/dist/features/groups/list-params.d.ts +14 -0
- package/dist/features/groups/list-params.js +1 -0
- package/dist/features/managers/actions.d.ts +43 -0
- package/dist/features/managers/actions.js +1 -0
- package/dist/features/managers/components/manager-create-button.d.ts +1 -0
- package/dist/features/managers/components/manager-create-button.js +1 -0
- package/dist/features/managers/components/manager-dialog.d.ts +11 -0
- package/dist/features/managers/components/manager-dialog.js +1 -0
- package/dist/features/managers/components/manager-permissions-dialog.d.ts +7 -0
- package/dist/features/managers/components/manager-permissions-dialog.js +1 -0
- package/dist/features/managers/components/manager-profile-fields.d.ts +7 -0
- package/dist/features/managers/components/manager-profile-fields.js +1 -0
- package/dist/features/managers/components/manager-status-tabs.d.ts +1 -0
- package/dist/features/managers/components/manager-status-tabs.js +1 -0
- package/dist/features/managers/components/managers-table.d.ts +8 -0
- package/dist/features/managers/components/managers-table.js +1 -0
- package/dist/features/managers/invite.d.ts +6 -0
- package/dist/features/managers/invite.js +1 -0
- package/dist/features/managers/list-params.d.ts +14 -0
- package/dist/features/managers/list-params.js +1 -0
- package/dist/features/payouts/actions.d.ts +12 -0
- package/dist/features/payouts/actions.js +1 -0
- package/dist/features/payouts/balance.d.ts +2 -0
- package/dist/features/payouts/balance.js +1 -0
- package/dist/features/payouts/components/my-payouts-table.d.ts +5 -0
- package/dist/features/payouts/components/my-payouts-table.js +1 -0
- package/dist/features/payouts/components/payout-row-actions.d.ts +5 -0
- package/dist/features/payouts/components/payout-row-actions.js +1 -0
- package/dist/features/payouts/components/payout-status-badge.d.ts +4 -0
- package/dist/features/payouts/components/payout-status-badge.js +1 -0
- package/dist/features/payouts/components/payout-status-tabs.d.ts +1 -0
- package/dist/features/payouts/components/payout-status-tabs.js +1 -0
- package/dist/features/payouts/components/payouts-table.d.ts +6 -0
- package/dist/features/payouts/components/payouts-table.js +1 -0
- package/dist/features/payouts/components/request-payout-dialog.d.ts +4 -0
- package/dist/features/payouts/components/request-payout-dialog.js +1 -0
- package/dist/features/payouts/constants.d.ts +2 -0
- package/dist/features/payouts/constants.js +1 -0
- package/dist/features/payouts/list-params.d.ts +14 -0
- package/dist/features/payouts/list-params.js +1 -0
- package/dist/features/payouts/my-queries.d.ts +14 -0
- package/dist/features/payouts/my-queries.js +1 -0
- package/dist/features/payouts/queries.d.ts +14 -0
- package/dist/features/payouts/queries.js +1 -0
- package/dist/features/postbacks/actions.d.ts +27 -0
- package/dist/features/postbacks/actions.js +1 -0
- package/dist/features/postbacks/components/integration-dialog.d.ts +6 -0
- package/dist/features/postbacks/components/integration-dialog.js +1 -0
- package/dist/features/postbacks/components/postback-editor.d.ts +5 -0
- package/dist/features/postbacks/components/postback-editor.js +1 -0
- package/dist/features/postbacks/components/postbacks-table.d.ts +4 -0
- package/dist/features/postbacks/components/postbacks-table.js +1 -0
- package/dist/features/settings/actions.d.ts +2 -0
- package/dist/features/settings/actions.js +1 -0
- package/dist/features/settings/components/affiliate-approval-setting.d.ts +3 -0
- package/dist/features/settings/components/affiliate-approval-setting.js +1 -0
- package/dist/features/settings/components/manager-totp-setting.d.ts +3 -0
- package/dist/features/settings/components/manager-totp-setting.js +1 -0
- package/dist/features/support/actions.d.ts +12 -0
- package/dist/features/support/actions.js +1 -0
- package/dist/features/support/components/support-page.d.ts +4 -0
- package/dist/features/support/components/support-page.js +1 -0
- package/dist/features/support/email.d.ts +13 -0
- package/dist/features/support/email.js +1 -0
- package/dist/features/users/actions.d.ts +4 -0
- package/dist/features/users/actions.js +1 -0
- package/dist/features/users/components/password-section.d.ts +1 -0
- package/dist/features/users/components/password-section.js +1 -0
- package/dist/features/users/components/preferences-section.d.ts +4 -0
- package/dist/features/users/components/preferences-section.js +1 -0
- package/dist/features/users/components/settings-tabs.d.ts +1 -0
- package/dist/features/users/components/settings-tabs.js +1 -0
- package/dist/features/users/components/totp-section.d.ts +4 -0
- package/dist/features/users/components/totp-section.js +1 -0
- package/dist/features/users/list-params.d.ts +12 -0
- package/dist/features/users/list-params.js +1 -0
- package/dist/features/users/totp.d.ts +7 -0
- package/dist/features/users/totp.js +1 -0
- package/dist/i18n/config.d.ts +5 -0
- package/dist/i18n/config.js +1 -0
- package/dist/i18n/get-locale.d.ts +3 -0
- package/dist/i18n/get-locale.js +1 -0
- package/dist/i18n/locale.d.ts +2 -0
- package/dist/i18n/locale.js +1 -0
- package/dist/lib/actions/parse-form.d.ts +3 -0
- package/dist/lib/actions/parse-form.js +1 -0
- package/dist/lib/actions/state.d.ts +22 -0
- package/dist/lib/actions/state.js +0 -0
- package/dist/lib/audit/actions.d.ts +9 -0
- package/dist/lib/audit/actions.js +1 -0
- package/dist/lib/audit/record.d.ts +4 -0
- package/dist/lib/audit/record.js +1 -0
- package/dist/lib/auth/action.d.ts +45 -0
- package/dist/lib/auth/action.js +1 -0
- package/dist/lib/auth/config.d.ts +24 -0
- package/dist/lib/auth/config.js +1 -0
- package/dist/lib/auth/jwt.d.ts +17 -0
- package/dist/lib/auth/jwt.js +1 -0
- package/dist/lib/auth/password-options.d.ts +6 -0
- package/dist/lib/auth/password-options.js +1 -0
- package/dist/lib/auth/password.d.ts +3 -0
- package/dist/lib/auth/password.js +1 -0
- package/dist/lib/auth/session.d.ts +26 -0
- package/dist/lib/auth/session.js +1 -0
- package/dist/lib/auth/tokens.d.ts +43 -0
- package/dist/lib/auth/tokens.js +1 -0
- package/dist/lib/auth/totp-challenge.d.ts +4 -0
- package/dist/lib/auth/totp-challenge.js +1 -0
- package/dist/lib/auth/totp.d.ts +7 -0
- package/dist/lib/auth/totp.js +1 -0
- package/dist/lib/auth/verification-tokens.d.ts +19 -0
- package/dist/lib/auth/verification-tokens.js +1 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +1 -0
- package/dist/lib/countries.d.ts +18 -0
- package/dist/lib/countries.js +1 -0
- package/dist/lib/currencies.d.ts +6 -0
- package/dist/lib/currencies.js +1 -0
- package/dist/lib/data/countries-by-continent.json +257 -0
- package/dist/lib/db/errors.d.ts +4 -0
- package/dist/lib/db/errors.js +1 -0
- package/dist/lib/email/client.d.ts +6 -0
- package/dist/lib/email/client.js +1 -0
- package/dist/lib/email/env.d.ts +12 -0
- package/dist/lib/email/env.js +1 -0
- package/dist/lib/email/format.d.ts +5 -0
- package/dist/lib/email/format.js +1 -0
- package/dist/lib/email/locale.d.ts +3 -0
- package/dist/lib/email/locale.js +1 -0
- package/dist/lib/email/send.d.ts +12 -0
- package/dist/lib/email/send.js +1 -0
- package/dist/lib/env.d.ts +20 -0
- package/dist/lib/env.js +1 -0
- package/dist/lib/errors/codes.d.ts +72 -0
- package/dist/lib/errors/codes.js +1 -0
- package/dist/lib/errors/server.d.ts +10 -0
- package/dist/lib/errors/server.js +1 -0
- package/dist/lib/format.d.ts +3 -0
- package/dist/lib/format.js +1 -0
- package/dist/lib/hooks/use-deferred-dialog.d.ts +11 -0
- package/dist/lib/hooks/use-deferred-dialog.js +1 -0
- package/dist/lib/hooks/use-form-reset.d.ts +2 -0
- package/dist/lib/hooks/use-form-reset.js +1 -0
- package/dist/lib/hooks/use-form-toast.d.ts +2 -0
- package/dist/lib/hooks/use-form-toast.js +1 -0
- package/dist/lib/i18n/format-datetime.d.ts +1 -0
- package/dist/lib/i18n/format-datetime.js +1 -0
- package/dist/lib/i18n/relative-time.d.ts +1 -0
- package/dist/lib/i18n/relative-time.js +1 -0
- package/dist/lib/list-params.d.ts +51 -0
- package/dist/lib/list-params.js +1 -0
- package/dist/lib/money.d.ts +2 -0
- package/dist/lib/money.js +1 -0
- package/dist/lib/platform-settings.d.ts +5 -0
- package/dist/lib/platform-settings.js +1 -0
- package/dist/lib/preferences/actions.d.ts +1 -0
- package/dist/lib/preferences/actions.js +1 -0
- package/dist/lib/preferences/index.d.ts +15 -0
- package/dist/lib/preferences/index.js +1 -0
- package/dist/lib/preferences/read.d.ts +2 -0
- package/dist/lib/preferences/read.js +1 -0
- package/dist/lib/slug.d.ts +1 -0
- package/dist/lib/slug.js +1 -0
- package/dist/lib/toast.d.ts +13 -0
- package/dist/lib/toast.js +1 -0
- package/dist/lib/tracking-cache.d.ts +2 -0
- package/dist/lib/tracking-cache.js +1 -0
- package/dist/lib/users.d.ts +12 -0
- package/dist/lib/users.js +1 -0
- package/dist/lib/validation/zod.d.ts +30 -0
- package/dist/lib/validation/zod.js +1 -0
- package/dist/messages/de/emails.json +136 -0
- package/dist/messages/de/index.json +1104 -0
- package/dist/messages/en/emails.json +136 -0
- package/dist/messages/en/index.json +1104 -0
- package/dist/theme/config.d.ts +8 -0
- package/dist/theme/config.js +1 -0
- package/dist/theme/get-theme.d.ts +3 -0
- package/dist/theme/get-theme.js +1 -0
- package/dist/theme/theme.d.ts +2 -0
- package/dist/theme/theme.js +1 -0
- package/package.json +131 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type SuccessMessage = {
|
|
2
|
+
message?: string;
|
|
3
|
+
};
|
|
4
|
+
type FormSuccess<T> = T extends void ? {
|
|
5
|
+
ok: true;
|
|
6
|
+
} & SuccessMessage : {
|
|
7
|
+
ok: true;
|
|
8
|
+
} & SuccessMessage & T;
|
|
9
|
+
export type FieldErrors = Record<string, string[]>;
|
|
10
|
+
type Failure = {
|
|
11
|
+
ok: false;
|
|
12
|
+
error: string;
|
|
13
|
+
fieldErrors?: FieldErrors;
|
|
14
|
+
toast?: true;
|
|
15
|
+
};
|
|
16
|
+
export type FormState<T = void> = undefined | FormSuccess<T> | Failure;
|
|
17
|
+
export type ActionResult<T> = {
|
|
18
|
+
ok: true;
|
|
19
|
+
data: T;
|
|
20
|
+
message?: string;
|
|
21
|
+
} | Failure;
|
|
22
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for every audit action key. Keys follow the
|
|
3
|
+
* `entity.action` convention. `ctx.audit({ action })` is typed to this union,
|
|
4
|
+
* so a typo or an unregistered key fails at compile time. Add new actions here
|
|
5
|
+
* (and give them an i18n label under `AuditLog.actions` — enforced by
|
|
6
|
+
* `features/audit/action-labels.ts`).
|
|
7
|
+
*/
|
|
8
|
+
export declare const AUDIT_ACTIONS: readonly ["user.status.update", "user.password.change", "user.totp.enable", "user.totp.disable", "affiliate.create", "affiliate.sub_invite", "affiliate.update", "affiliate.delete", "affiliate.approve", "affiliate.reject", "affiliate.unreject", "affiliate.attach", "affiliate.detach", "manager.create", "manager.update", "manager.permissions.update", "manager.delete", "group.create", "group.update", "group.delete", "casino.create", "casino.update", "casino.activate", "casino.deactivate", "casino.delete", "casino.postback_update", "casino.postback_secret_regenerate", "campaign.create", "campaign.deactivate", "campaign.reactivate", "deal.create", "deal.update", "deal.deactivate", "deal.reactivate", "deal.delegate", "commission.create", "commission.update", "commission.publish", "commission.deactivate", "commission.reactivate", "commission.duplicate", "commission.delete", "payout.request", "payout.approve", "payout.reject", "payout.paid", "settings.update"];
|
|
9
|
+
export type AuditAction = (typeof AUDIT_ACTIONS)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=["user.status.update","user.password.change","user.totp.enable","user.totp.disable","affiliate.create","affiliate.sub_invite","affiliate.update","affiliate.delete","affiliate.approve","affiliate.reject","affiliate.unreject","affiliate.attach","affiliate.detach","manager.create","manager.update","manager.permissions.update","manager.delete","group.create","group.update","group.delete","casino.create","casino.update","casino.activate","casino.deactivate","casino.delete","casino.postback_update","casino.postback_secret_regenerate","campaign.create","campaign.deactivate","campaign.reactivate","deal.create","deal.update","deal.deactivate","deal.reactivate","deal.delegate","commission.create","commission.update","commission.publish","commission.deactivate","commission.reactivate","commission.duplicate","commission.delete","payout.request","payout.approve","payout.reject","payout.paid","settings.update"];export{e as AUDIT_ACTIONS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{db as i}from"../../db/index.js";import{auditLogs as r}from"../../db/schema/index.js";async function m(o,t=i){await t.insert(r).values(o)}export{m as recordAuditLog};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { Executor } from "../../db/index.js";
|
|
3
|
+
import type { PublicUser, UserRole } from "../../db/schema/index.js";
|
|
4
|
+
import type { Permission, PermissionCarrier } from "../../features/auth/permissions.js";
|
|
5
|
+
import type { ActionResult, FormState } from "../actions/state.js";
|
|
6
|
+
import type { AuditAction } from "../audit/actions.js";
|
|
7
|
+
export type AuditInput = {
|
|
8
|
+
action: AuditAction;
|
|
9
|
+
subjectId?: string;
|
|
10
|
+
target?: {
|
|
11
|
+
type: string;
|
|
12
|
+
id: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
};
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
export type AuditFn = (input: AuditInput, tx?: Executor) => Promise<void>;
|
|
18
|
+
export type AuthCtx = {
|
|
19
|
+
user: PublicUser;
|
|
20
|
+
carrier: PermissionCarrier;
|
|
21
|
+
audit: AuditFn;
|
|
22
|
+
};
|
|
23
|
+
type Resolver<Args extends unknown[], R extends object> = (ctx: AuthCtx, ...args: Args) => Promise<R>;
|
|
24
|
+
type AuthOptions<Args extends unknown[], R extends object> = {
|
|
25
|
+
permission?: Permission;
|
|
26
|
+
role?: UserRole;
|
|
27
|
+
requireAdmin?: boolean;
|
|
28
|
+
resolve?: Resolver<Args, R>;
|
|
29
|
+
revalidate?: readonly string[];
|
|
30
|
+
};
|
|
31
|
+
type FormOptions = {
|
|
32
|
+
revalidate?: readonly string[];
|
|
33
|
+
};
|
|
34
|
+
type WithOptionalMessage<T> = T extends void ? {
|
|
35
|
+
message: string;
|
|
36
|
+
} | undefined : T | (T & {
|
|
37
|
+
message: string;
|
|
38
|
+
});
|
|
39
|
+
export declare function authAction<Args extends unknown[], T = void, R extends object = object>(options: AuthOptions<Args, R>, fn: (ctx: AuthCtx & R, ...args: Args) => Promise<WithOptionalMessage<T>>): (...args: Args) => Promise<ActionResult<T>>;
|
|
40
|
+
export declare function authFormAction<P extends unknown[] = [], T = void, R extends object = object>(options: AuthOptions<[...P, FormData], R>, fn: (ctx: AuthCtx & R, ...args: [...P, FormData]) => Promise<WithOptionalMessage<T>>): (...args: [...P, FormState<T>, FormData]) => Promise<FormState<T>>;
|
|
41
|
+
export declare function formAction<P extends unknown[] = [], T = void>(options: FormOptions, fn: (...args: [...P, FormData]) => Promise<WithOptionalMessage<T>>): (...args: [...P, FormState<T>, FormData]) => Promise<FormState<T>>;
|
|
42
|
+
export declare function authQuery<Args extends unknown[], R>(permission: Permission, fn: (ctx: AuthCtx, ...args: Args) => Promise<R>): (...args: Args) => Promise<R>;
|
|
43
|
+
export declare function adminQuery<Args extends unknown[], R>(fn: (ctx: AuthCtx, ...args: Args) => Promise<R>): (...args: Args) => Promise<R>;
|
|
44
|
+
export declare function roleQuery<Args extends unknown[], R>(role: UserRole, fn: (ctx: AuthCtx, ...args: Args) => Promise<R>): (...args: Args) => Promise<R>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{revalidatePath as x}from"next/cache";import{headers as y}from"next/headers";import{getTranslations as h}from"next-intl/server";import{requirePermission as m,requirePlatformAdmin as l,requireRole as g,requireSession as i}from"../../features/auth/authorization.js";import{recordAuditLog as f}from"../audit/record.js";import{isDbUnavailable as P}from"../db/errors.js";import{errorI18nKey as w,isAppError as R}from"../errors/codes.js";function b(r){return async(t,e)=>{const s=await y(),a={actorId:r.id,actorRole:r.role,actorEmail:r.email,action:t.action,subjectId:t.subjectId??null,targetType:t.target?.type??null,targetId:t.target?.id??null,targetLabel:t.target?.label??null,metadata:t.metadata??null,ipAddress:s.get("x-forwarded-for")?.split(",")[0]?.trim()??null,userAgent:s.get("user-agent")??null};if(e){await f(a,e);return}try{await f(a)}catch(o){console.error("[audit] record failed:",t.action,o)}}}function u(r){return{...r,audit:b(r.user)}}async function A(r,t){const e=await i();r.permission&&m(e.carrier,r.permission),r.role&&g(e.user,r.role),r.requireAdmin&&l(e.user);const s=u(e),a=r.resolve?await r.resolve(s,...t):{};return{...s,...a}}function d(r){for(const t of r??[])x(t)}async function p(r,t){const s=(await h())(w(r)),a=t?.fieldErrors?t.fieldErrors:t?.field?{[t.field]:[s]}:t?.toast?void 0:{_form:[s]};return{ok:!1,error:s,...a?{fieldErrors:a}:{},...t?.toast?{toast:!0}:{}}}async function c(r){if(R(r))return await p(r.code,{field:r.field,fieldErrors:r.fieldErrors,toast:r.toast});if(P(r))return await p("service_unavailable",{toast:!0})}function F(r){if(r!==null&&typeof r=="object"&&"message"in r&&typeof r.message=="string"){const{message:t,...e}=r;return{data:e,message:t}}return{data:r}}function S(r,t){return async(...e)=>{try{const s=await A(r,e),a=await t(s,...e);return d(r.revalidate),{ok:!0,...F(a)}}catch(s){const a=await c(s);if(a)return a;throw s}}}function I(r,t){return async(...e)=>{const s=e[e.length-1],a=[...e.slice(0,-2),s];try{const o=await A(r,a),n=await t(o,...a);return d(r.revalidate),{ok:!0,...n??{}}}catch(o){const n=await c(o);if(n)return n;throw o}}}function U(r,t){return async(...e)=>{const s=e[e.length-1],a=[...e.slice(0,-2),s];try{const o=await t(...a);return d(r.revalidate),{ok:!0,...o??{}}}catch(o){const n=await c(o);if(n)return n;throw o}}}function q(r,t){return async(...e)=>{const s=await i();return m(s.carrier,r),t(u(s),...e)}}function M(r){return async(...t)=>{const e=await i();return l(e.user),r(u(e),...t)}}function W(r,t){return async(...e)=>{const s=await i();return g(s.user,r),t(u(s),...e)}}export{M as adminQuery,S as authAction,I as authFormAction,q as authQuery,U as formAction,W as roleQuery};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const ACCESS_COOKIE: string;
|
|
2
|
+
export declare const REFRESH_COOKIE: string;
|
|
3
|
+
export declare const TOTP_CHALLENGE_COOKIE: string;
|
|
4
|
+
export declare const JWT_TTL_SECONDS: number;
|
|
5
|
+
export declare const REFRESH_TTL_SECONDS: number;
|
|
6
|
+
export declare const TOTP_CHALLENGE_TTL_SECONDS: number;
|
|
7
|
+
export type CookieOptions = {
|
|
8
|
+
path: "/";
|
|
9
|
+
maxAge: number;
|
|
10
|
+
httpOnly: true;
|
|
11
|
+
sameSite: "lax";
|
|
12
|
+
secure: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type ClearCookieOptions = {
|
|
15
|
+
name: string;
|
|
16
|
+
path: "/";
|
|
17
|
+
httpOnly: true;
|
|
18
|
+
sameSite: "lax";
|
|
19
|
+
secure: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function clearCookieOptions(name: string): ClearCookieOptions;
|
|
22
|
+
export declare function accessCookieOptions(): CookieOptions;
|
|
23
|
+
export declare function refreshCookieOptions(): CookieOptions;
|
|
24
|
+
export declare function totpChallengeCookieOptions(): CookieOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=process.env.NODE_ENV==="production",s=e?"__Host-access":"access",p=e?"__Host-refresh":"refresh",a=e?"__Host-totp-challenge":"totp-challenge",o=600,r=3600*24*30,n=300;function i(t){return{name:t,path:"/",httpOnly:!0,sameSite:"lax",secure:e}}function c(){return{path:"/",maxAge:o,httpOnly:!0,sameSite:"lax",secure:e}}function O(){return{path:"/",maxAge:r,httpOnly:!0,sameSite:"lax",secure:e}}function l(){return{path:"/",maxAge:n,httpOnly:!0,sameSite:"lax",secure:e}}export{s as ACCESS_COOKIE,o as JWT_TTL_SECONDS,p as REFRESH_COOKIE,r as REFRESH_TTL_SECONDS,a as TOTP_CHALLENGE_COOKIE,n as TOTP_CHALLENGE_TTL_SECONDS,c as accessCookieOptions,i as clearCookieOptions,O as refreshCookieOptions,l as totpChallengeCookieOptions};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
export type SessionClaims = {
|
|
3
|
+
userId: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
};
|
|
6
|
+
export type VerifiedSessionClaims = SessionClaims & {
|
|
7
|
+
expiresAt: number;
|
|
8
|
+
};
|
|
9
|
+
export type VerifyAccessResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
claims: VerifiedSessionClaims;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
reason: "missing" | "expired" | "invalid";
|
|
15
|
+
};
|
|
16
|
+
export declare function createSessionJwt(claims: SessionClaims, ttlSeconds?: number): Promise<string>;
|
|
17
|
+
export declare function verifySessionJwt(token: string | undefined | null): Promise<VerifyAccessResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{errors as d,jwtVerify as p,SignJWT as f}from"jose";import{JWT_TTL_SECONDS as l}from"./config.js";import{env as t}from"../env.js";const o="HS256",a=t.BRAND_NAME.toLowerCase(),u="session",c=new TextEncoder().encode(t.JWT_SECRET);async function T(e,s=l){return new f({sid:e.sessionId}).setProtectedHeader({alg:o,typ:"JWT"}).setSubject(e.userId).setIssuer(a).setAudience(u).setIssuedAt().setExpirationTime(`${s}s`).sign(c)}async function g(e){if(!e)return{ok:!1,reason:"missing"};try{const{payload:s}=await p(e,c,{algorithms:[o],issuer:a,audience:u,clockTolerance:5,requiredClaims:["sub","sid","exp"]}),{sub:r,sid:i,exp:n}=s;return typeof r!="string"||typeof i!="string"||typeof n!="number"?{ok:!1,reason:"invalid"}:{ok:!0,claims:{userId:r,sessionId:i,expiresAt:n}}}catch(s){return s instanceof d.JWTExpired?{ok:!1,reason:"expired"}:{ok:!1,reason:"invalid"}}}export{T as createSessionJwt,g as verifySessionJwt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o={algorithm:2,memoryCost:19456,timeCost:2,parallelism:1};export{o as ARGON2_OPTIONS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{hash as s,verify as i}from"@node-rs/argon2";import{ARGON2_OPTIONS as t}from"./password-options.js";async function f(r){return s(r,t)}async function m(r,o){try{return await i(r,o,t)}catch{return!1}}export{f as hashPassword,m as verifyPassword};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type PublicUser } from "../../db/schema/index.js";
|
|
3
|
+
import { type SessionContext } from "./tokens.js";
|
|
4
|
+
export type Session = {
|
|
5
|
+
user: PublicUser;
|
|
6
|
+
permissions: ReadonlyArray<string>;
|
|
7
|
+
};
|
|
8
|
+
export declare const loadSession: () => Promise<Session | null>;
|
|
9
|
+
export declare function getCurrentUser(): Promise<PublicUser | null>;
|
|
10
|
+
export declare function signIn(userId: string): Promise<void>;
|
|
11
|
+
export declare function signOut(): Promise<void>;
|
|
12
|
+
type RotateOk = {
|
|
13
|
+
ok: true;
|
|
14
|
+
userId: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
context: SessionContext;
|
|
17
|
+
accessToken: string;
|
|
18
|
+
refreshToken: string;
|
|
19
|
+
};
|
|
20
|
+
type RotateFail = {
|
|
21
|
+
ok: false;
|
|
22
|
+
reason: "missing" | "invalid" | "reuse";
|
|
23
|
+
};
|
|
24
|
+
export type RotateResult = RotateOk | RotateFail;
|
|
25
|
+
export declare function rotateSession(rawRt: string | undefined): Promise<RotateResult>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{db as l}from"../../db/index.js";import{canSignIn as y,groupPermissions as c,publicUserColumns as S,userGroups as n,userPermissions as a,users as m}from"../../db/schema/index.js";import{eq as t}from"drizzle-orm";import{cookies as d,headers as C}from"next/headers";import{cache as p}from"react";import{ACCESS_COOKIE as u,accessCookieOptions as v,clearCookieOptions as k,REFRESH_COOKIE as f,refreshCookieOptions as h}from"./config.js";import{createSessionJwt as w,verifySessionJwt as I}from"./jwt.js";import{consumeAndRotate as A,createSession as x,revokeAllSessionsForUser as R,revokeSession as P,revokeSessionByRawToken as O}from"./tokens.js";import{isDbUnavailable as b}from"../db/errors.js";import{appError as T}from"../errors/codes.js";const U=p(async()=>{const e=await d();return I(e.get(u)?.value)}),E=p(async()=>{const e=await U();return e.ok?e.claims:null}),F=p(async()=>{const e=await E();if(!e)return null;try{const s=l.select({userId:n.userId,permission:c.permission}).from(n).innerJoin(c,t(n.groupId,c.groupId)).where(t(n.userId,e.userId)).unionAll(l.select({userId:a.userId,permission:a.permission}).from(a).where(t(a.userId,e.userId))).as("perms"),r=await l.select({user:S,permission:s.permission}).from(m).leftJoin(s,t(s.userId,m.id)).where(t(m.id,e.userId));if(r.length===0)return null;const o=r[0].user;if(!y(o.status))return await R(o.id),null;const i=Array.from(new Set(r.flatMap(g=>g.permission===null?[]:[g.permission])));return{user:o,permissions:i}}catch(s){throw b(s)?T("service_unavailable",{toast:!0}):s}});async function L(){return(await F())?.user??null}async function J(){const e=await C(),s=e.get("user-agent"),r=e.get("x-forwarded-for"),o=(r?r.split(",")[0]?.trim():null)||e.get("x-real-ip")||null;return{userAgent:s??null,ipAddress:o}}async function N(e){const s=await J(),r=await x({userId:e,...s}),o=await w({userId:e,sessionId:r.sessionId}),i=await d();i.set(u,o,v()),i.set(f,r.refreshToken.raw,h())}async function Q(){const e=await d(),s=e.get(u)?.value,r=e.get(f)?.value,o=s?await I(s):{ok:!1,reason:"missing"};o.ok?await P(o.claims.sessionId):r&&await O(r),e.delete(k(u)),e.delete(k(f))}async function W(e){if(!e)return{ok:!1,reason:"missing"};const s=await A(e);if(s.kind==="invalid")return{ok:!1,reason:"invalid"};if(s.kind==="reuse")return{ok:!1,reason:"reuse"};const r=await w({userId:s.userId,sessionId:s.sessionId});return{ok:!0,userId:s.userId,sessionId:s.sessionId,context:{role:s.role,totpConfirmedAt:s.totpConfirmedAt},accessToken:r,refreshToken:s.raw}}export{L as getCurrentUser,F as loadSession,W as rotateSession,N as signIn,Q as signOut};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type Tx } from "../../db/index.js";
|
|
3
|
+
import { type UserRole } from "../../db/schema/index.js";
|
|
4
|
+
export type IssuedRefreshToken = {
|
|
5
|
+
id: string;
|
|
6
|
+
raw: string;
|
|
7
|
+
expiresAt: Date;
|
|
8
|
+
};
|
|
9
|
+
export type CreatedSession = {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
refreshToken: IssuedRefreshToken;
|
|
12
|
+
};
|
|
13
|
+
export type SessionContext = {
|
|
14
|
+
role: UserRole;
|
|
15
|
+
totpConfirmedAt: Date | null;
|
|
16
|
+
};
|
|
17
|
+
export type ConsumeResult = ({
|
|
18
|
+
kind: "ok";
|
|
19
|
+
userId: string;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
raw: string;
|
|
22
|
+
expiresAt: Date;
|
|
23
|
+
} & SessionContext) | {
|
|
24
|
+
kind: "invalid";
|
|
25
|
+
} | {
|
|
26
|
+
kind: "reuse";
|
|
27
|
+
sessionId: string;
|
|
28
|
+
userId: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function createSession(args: {
|
|
31
|
+
userId: string;
|
|
32
|
+
userAgent?: string | null;
|
|
33
|
+
ipAddress?: string | null;
|
|
34
|
+
}): Promise<CreatedSession>;
|
|
35
|
+
export declare function issueRefreshToken(args: {
|
|
36
|
+
sessionId: string;
|
|
37
|
+
tx?: Tx;
|
|
38
|
+
}): Promise<IssuedRefreshToken>;
|
|
39
|
+
export declare function consumeAndRotate(rawToken: string): Promise<ConsumeResult>;
|
|
40
|
+
export declare function loadSessionContext(sessionId: string): Promise<SessionContext | null>;
|
|
41
|
+
export declare function revokeSession(sessionId: string): Promise<void>;
|
|
42
|
+
export declare function revokeSessionByRawToken(rawToken: string): Promise<void>;
|
|
43
|
+
export declare function revokeAllSessionsForUser(userId: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{createHash as m,randomBytes as I}from"node:crypto";import{db as u}from"../../db/index.js";import{refreshTokens as r,sessions as s,users as d}from"../../db/schema/index.js";import{and as k,eq as i,gt as x,lt as g}from"drizzle-orm";import{REFRESH_TTL_SECONDS as h}from"./config.js";const A=32,v=1e4;function p(t){return m("sha256").update(t).digest("hex")}function l(){return new Date(Date.now()+h*1e3)}async function H(t){const o=I(A).toString("base64url"),n=l();return await u.transaction(async e=>{const[a]=await e.insert(s).values({userId:t.userId,userAgent:t.userAgent??null,ipAddress:t.ipAddress??null,expiresAt:n}).returning({id:s.id}),[c]=await e.insert(r).values({sessionId:a.id,tokenHash:p(o),expiresAt:n}).returning({id:r.id});return{sessionId:a.id,refreshToken:{id:c.id,raw:o,expiresAt:n}}})}async function f(t){const o=I(A).toString("base64url"),n=l(),e=t.tx??u,[a]=await e.insert(r).values({sessionId:t.sessionId,tokenHash:p(o),expiresAt:n}).returning({id:r.id});return{id:a.id,raw:o,expiresAt:n}}async function P(t){const o=p(t);return await u.transaction(async n=>{await n.delete(s).where(g(s.expiresAt,new Date));const[e]=await n.select({rtId:r.id,rtRevokedAt:r.revokedAt,rtExpiresAt:r.expiresAt,sessionId:r.sessionId,userId:s.userId,sessionExpiresAt:s.expiresAt,role:d.role,totpConfirmedAt:d.totpConfirmedAt}).from(r).innerJoin(s,i(s.id,r.sessionId)).innerJoin(d,i(d.id,s.userId)).where(i(r.tokenHash,o)).for("update").limit(1);if(!e)return{kind:"invalid"};if(e.rtExpiresAt<new Date)return{kind:"invalid"};if(e.sessionExpiresAt<new Date)return{kind:"invalid"};if(e.rtRevokedAt){if(Date.now()-e.rtRevokedAt.getTime()<v){const w=await f({sessionId:e.sessionId,tx:n});return await n.update(s).set({lastSeenAt:new Date,expiresAt:l()}).where(i(s.id,e.sessionId)),{kind:"ok",userId:e.userId,sessionId:e.sessionId,role:e.role,totpConfirmedAt:e.totpConfirmedAt,raw:w.raw,expiresAt:w.expiresAt}}return await n.delete(s).where(i(s.id,e.sessionId)),{kind:"reuse",sessionId:e.sessionId,userId:e.userId}}const a=await f({sessionId:e.sessionId,tx:n});return await n.update(r).set({revokedAt:new Date}).where(i(r.id,e.rtId)),await n.update(s).set({lastSeenAt:new Date,expiresAt:l()}).where(i(s.id,e.sessionId)),{kind:"ok",userId:e.userId,sessionId:e.sessionId,role:e.role,totpConfirmedAt:e.totpConfirmedAt,raw:a.raw,expiresAt:a.expiresAt}})}async function _(t){const[o]=await u.select({role:d.role,totpConfirmedAt:d.totpConfirmedAt}).from(s).innerJoin(d,i(d.id,s.userId)).where(k(i(s.id,t),x(s.expiresAt,new Date))).limit(1);return o??null}async function C(t){await u.delete(s).where(i(s.id,t))}async function O(t){const o=p(t),[n]=await u.select({sessionId:r.sessionId}).from(r).where(i(r.tokenHash,o)).limit(1);n&&await C(n.sessionId)}async function b(t){await u.delete(s).where(i(s.userId,t))}export{P as consumeAndRotate,H as createSession,f as issueRefreshToken,_ as loadSessionContext,b as revokeAllSessionsForUser,C as revokeSession,O as revokeSessionByRawToken};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{jwtVerify as u,SignJWT as E}from"jose";import{cookies as s}from"next/headers";import{clearCookieOptions as p,TOTP_CHALLENGE_COOKIE as n,TOTP_CHALLENGE_TTL_SECONDS as C,totpChallengeCookieOptions as T}from"./config.js";import{env as r}from"../env.js";const i="HS256",a=r.BRAND_NAME.toLowerCase(),c="totp-challenge",l=new TextEncoder().encode(r.JWT_SECRET);async function f(t){const e=await new E({}).setProtectedHeader({alg:i,typ:"JWT"}).setSubject(t).setIssuer(a).setAudience(c).setIssuedAt().setExpirationTime(`${C}s`).sign(l);(await s()).set(n,e,T())}async function _(){const e=(await s()).get(n)?.value;if(!e)return null;try{const{payload:o}=await u(e,l,{algorithms:[i],issuer:a,audience:c,clockTolerance:5,requiredClaims:["sub","exp"]});return typeof o.sub=="string"?o.sub:null}catch{return null}}async function w(){(await s()).delete(p(n))}export{w as clearTotpChallenge,f as issueTotpChallenge,_ as readTotpChallenge};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
export declare function encryptSecret(plain: string): string;
|
|
3
|
+
export declare function decryptSecret(encoded: string): string;
|
|
4
|
+
export declare function generateSecret(): string;
|
|
5
|
+
export declare function buildOtpAuthUri(secretBase32: string, accountLabel: string): string;
|
|
6
|
+
export declare function renderQrDataUrl(otpAuthUri: string): Promise<string>;
|
|
7
|
+
export declare function verifyCode(secretBase32: string, code: string, accountLabel: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import u from"node:crypto";import{Secret as a,TOTP as d}from"otpauth";import m from"qrcode";import{env as f}from"../env.js";const _=f.BRAND_NAME,O="SHA1",P=6,E=30,b=20,T="aes-256-gcm",n=12,g=16;let i=null;function p(){if(i)return i;const t=Buffer.from(f.TOTP_ENCRYPTION_KEY,"base64url");if(t.length!==32)throw new Error("TOTP_ENCRYPTION_KEY must decode to exactly 32 bytes (AES-256)");return i=t,i}function x(t){const r=u.randomBytes(n),e=u.createCipheriv(T,p(),r),o=Buffer.concat([e.update(t,"utf8"),e.final()]),s=e.getAuthTag();return Buffer.concat([r,s,o]).toString("base64url")}function N(t){const r=Buffer.from(t,"base64url"),e=r.subarray(0,n),o=r.subarray(n,n+g),s=r.subarray(n+g),c=u.createDecipheriv(T,p(),e);return c.setAuthTag(o),Buffer.concat([c.update(s),c.final()]).toString("utf8")}function v(){return new a({size:b}).base32}function l(t,r){return new d({issuer:_,label:r,algorithm:O,digits:P,period:E,secret:a.fromBase32(t)})}function C(t,r){return l(t,r).toString()}async function R(t){return m.toDataURL(t,{margin:1,width:240,errorCorrectionLevel:"M"})}function w(t,r,e){return/^\d{6}$/.test(r)?l(t,e).validate({token:r,window:1})!==null:!1}export{C as buildOtpAuthUri,N as decryptSecret,x as encryptSecret,v as generateSecret,R as renderQrDataUrl,w as verifyCode};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type VerificationTokenPurpose } from "../../db/schema/index.js";
|
|
3
|
+
export type IssuedVerificationToken = {
|
|
4
|
+
id: string;
|
|
5
|
+
raw: string;
|
|
6
|
+
expiresAt: Date;
|
|
7
|
+
};
|
|
8
|
+
export type ConsumeVerificationResult = {
|
|
9
|
+
kind: "ok";
|
|
10
|
+
userId: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "invalid";
|
|
13
|
+
};
|
|
14
|
+
export declare function issueVerificationToken(args: {
|
|
15
|
+
userId: string;
|
|
16
|
+
purpose: VerificationTokenPurpose;
|
|
17
|
+
}): Promise<IssuedVerificationToken>;
|
|
18
|
+
export declare function consumeVerificationToken(rawToken: string, purpose: VerificationTokenPurpose): Promise<ConsumeVerificationResult>;
|
|
19
|
+
export declare function inspectVerificationToken(rawToken: string, purpose: VerificationTokenPurpose): Promise<ConsumeVerificationResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{createHash as p,randomBytes as c}from"node:crypto";import{db as s}from"../../db/index.js";import{verificationTokens as e}from"../../db/schema/index.js";import{and as u,eq as o}from"drizzle-orm";const f=32,k={invite:4320*60,password_reset:3600,email_verify:1440*60};function a(r){return p("sha256").update(r).digest("hex")}async function x(r){const t=c(f).toString("base64url"),n=a(t),i=new Date(Date.now()+k[r.purpose]*1e3),[d]=await s.insert(e).values({userId:r.userId,purpose:r.purpose,tokenHash:n,expiresAt:i}).onConflictDoUpdate({target:[e.userId,e.purpose],set:{tokenHash:n,expiresAt:i,createdAt:new Date}}).returning({id:e.id});return{id:d.id,raw:t,expiresAt:i}}async function V(r,t){const n=a(r),[i]=await s.delete(e).where(u(o(e.tokenHash,n),o(e.purpose,t))).returning({userId:e.userId,expiresAt:e.expiresAt});return i?i.expiresAt<new Date?{kind:"invalid"}:{kind:"ok",userId:i.userId}:{kind:"invalid"}}async function h(r,t){const n=a(r),[i]=await s.select({userId:e.userId,expiresAt:e.expiresAt}).from(e).where(u(o(e.tokenHash,n),o(e.purpose,t))).limit(1);return i?i.expiresAt<new Date?{kind:"invalid"}:{kind:"ok",userId:i.userId}:{kind:"invalid"}}export{V as consumeVerificationToken,h as inspectVerificationToken,x as issueVerificationToken};
|
package/dist/lib/cn.d.ts
ADDED
package/dist/lib/cn.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{clsx as e}from"clsx";import{twMerge as t}from"tailwind-merge";function s(...r){return t(e(r))}export{s as cn};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const CONTINENT_KEYS: readonly ["europe", "americas", "asia", "africa", "oceania", "antarctica"];
|
|
2
|
+
export type ContinentKey = (typeof CONTINENT_KEYS)[number];
|
|
3
|
+
export declare const COUNTRIES_BY_CONTINENT: {
|
|
4
|
+
europe: string[];
|
|
5
|
+
americas: string[];
|
|
6
|
+
asia: string[];
|
|
7
|
+
africa: string[];
|
|
8
|
+
oceania: string[];
|
|
9
|
+
antarctica: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare function getCountryName(code: string, locale: string): string;
|
|
12
|
+
export declare function countriesByContinent(locale: string): {
|
|
13
|
+
continent: ContinentKey;
|
|
14
|
+
countries: {
|
|
15
|
+
code: string;
|
|
16
|
+
name: string;
|
|
17
|
+
}[];
|
|
18
|
+
}[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import a from"./data/countries-by-continent.json";const s=["europe","americas","asia","africa","oceania","antarctica"],o=a,r=new Map;function c(n){const e=r.get(n);if(e!==void 0)return e;let t;try{t=new Intl.DisplayNames([n],{type:"region"})}catch{t=null}return r.set(n,t),t}function u(n,e){try{return c(e)?.of(n)??n}catch{return n}}function m(n){return s.map(e=>({continent:e,countries:o[e].map(t=>({code:t,name:u(t,n)})).sort((t,i)=>t.name.localeCompare(i.name,n))}))}export{s as CONTINENT_KEYS,o as COUNTRIES_BY_CONTINENT,m as countriesByContinent,u as getCountryName};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const FIAT_CURRENCIES: readonly ["EUR", "USD", "GBP"];
|
|
2
|
+
export declare const CRYPTO_CURRENCIES: readonly ["BTC", "ETH", "USDT", "USDC"];
|
|
3
|
+
export declare const SUPPORTED_CURRENCIES: readonly ["EUR", "USD", "GBP", "BTC", "ETH", "USDT", "USDC"];
|
|
4
|
+
export type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
|
|
5
|
+
export declare const DEFAULT_CURRENCY: SupportedCurrency;
|
|
6
|
+
export declare function isSupportedCurrency(code: string): code is SupportedCurrency;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=["EUR","USD","GBP"],r=["BTC","ETH","USDT","USDC"],o=[...e,...r],C="EUR",n=new Set(o);function E(t){return n.has(t)}export{r as CRYPTO_CURRENCIES,C as DEFAULT_CURRENCY,e as FIAT_CURRENCIES,o as SUPPORTED_CURRENCIES,E as isSupportedCurrency};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
{
|
|
2
|
+
"europe": [
|
|
3
|
+
"AD",
|
|
4
|
+
"AL",
|
|
5
|
+
"AT",
|
|
6
|
+
"AX",
|
|
7
|
+
"BA",
|
|
8
|
+
"BE",
|
|
9
|
+
"BG",
|
|
10
|
+
"BY",
|
|
11
|
+
"CH",
|
|
12
|
+
"CZ",
|
|
13
|
+
"DE",
|
|
14
|
+
"DK",
|
|
15
|
+
"EE",
|
|
16
|
+
"ES",
|
|
17
|
+
"FI",
|
|
18
|
+
"FO",
|
|
19
|
+
"FR",
|
|
20
|
+
"GB",
|
|
21
|
+
"GG",
|
|
22
|
+
"GI",
|
|
23
|
+
"GR",
|
|
24
|
+
"HR",
|
|
25
|
+
"HU",
|
|
26
|
+
"IE",
|
|
27
|
+
"IM",
|
|
28
|
+
"IS",
|
|
29
|
+
"IT",
|
|
30
|
+
"JE",
|
|
31
|
+
"LI",
|
|
32
|
+
"LT",
|
|
33
|
+
"LU",
|
|
34
|
+
"LV",
|
|
35
|
+
"MC",
|
|
36
|
+
"MD",
|
|
37
|
+
"ME",
|
|
38
|
+
"MK",
|
|
39
|
+
"MT",
|
|
40
|
+
"NL",
|
|
41
|
+
"NO",
|
|
42
|
+
"PL",
|
|
43
|
+
"PT",
|
|
44
|
+
"RO",
|
|
45
|
+
"RS",
|
|
46
|
+
"RU",
|
|
47
|
+
"SE",
|
|
48
|
+
"SI",
|
|
49
|
+
"SJ",
|
|
50
|
+
"SK",
|
|
51
|
+
"SM",
|
|
52
|
+
"UA",
|
|
53
|
+
"VA"
|
|
54
|
+
],
|
|
55
|
+
"americas": [
|
|
56
|
+
"AG",
|
|
57
|
+
"AI",
|
|
58
|
+
"AR",
|
|
59
|
+
"AW",
|
|
60
|
+
"BB",
|
|
61
|
+
"BL",
|
|
62
|
+
"BM",
|
|
63
|
+
"BO",
|
|
64
|
+
"BQ",
|
|
65
|
+
"BR",
|
|
66
|
+
"BS",
|
|
67
|
+
"BZ",
|
|
68
|
+
"CA",
|
|
69
|
+
"CL",
|
|
70
|
+
"CO",
|
|
71
|
+
"CR",
|
|
72
|
+
"CU",
|
|
73
|
+
"CW",
|
|
74
|
+
"DM",
|
|
75
|
+
"DO",
|
|
76
|
+
"EC",
|
|
77
|
+
"FK",
|
|
78
|
+
"GD",
|
|
79
|
+
"GF",
|
|
80
|
+
"GL",
|
|
81
|
+
"GP",
|
|
82
|
+
"GT",
|
|
83
|
+
"GY",
|
|
84
|
+
"HN",
|
|
85
|
+
"HT",
|
|
86
|
+
"JM",
|
|
87
|
+
"KN",
|
|
88
|
+
"KY",
|
|
89
|
+
"LC",
|
|
90
|
+
"MF",
|
|
91
|
+
"MQ",
|
|
92
|
+
"MS",
|
|
93
|
+
"MX",
|
|
94
|
+
"NI",
|
|
95
|
+
"PA",
|
|
96
|
+
"PE",
|
|
97
|
+
"PM",
|
|
98
|
+
"PR",
|
|
99
|
+
"PY",
|
|
100
|
+
"SR",
|
|
101
|
+
"SV",
|
|
102
|
+
"SX",
|
|
103
|
+
"TC",
|
|
104
|
+
"TT",
|
|
105
|
+
"US",
|
|
106
|
+
"UY",
|
|
107
|
+
"VC",
|
|
108
|
+
"VE",
|
|
109
|
+
"VG",
|
|
110
|
+
"VI"
|
|
111
|
+
],
|
|
112
|
+
"asia": [
|
|
113
|
+
"AE",
|
|
114
|
+
"AF",
|
|
115
|
+
"AM",
|
|
116
|
+
"AZ",
|
|
117
|
+
"BD",
|
|
118
|
+
"BH",
|
|
119
|
+
"BN",
|
|
120
|
+
"BT",
|
|
121
|
+
"CN",
|
|
122
|
+
"CY",
|
|
123
|
+
"GE",
|
|
124
|
+
"HK",
|
|
125
|
+
"ID",
|
|
126
|
+
"IL",
|
|
127
|
+
"IN",
|
|
128
|
+
"IO",
|
|
129
|
+
"IQ",
|
|
130
|
+
"IR",
|
|
131
|
+
"JO",
|
|
132
|
+
"JP",
|
|
133
|
+
"KG",
|
|
134
|
+
"KH",
|
|
135
|
+
"KP",
|
|
136
|
+
"KR",
|
|
137
|
+
"KW",
|
|
138
|
+
"KZ",
|
|
139
|
+
"LA",
|
|
140
|
+
"LB",
|
|
141
|
+
"LK",
|
|
142
|
+
"MM",
|
|
143
|
+
"MN",
|
|
144
|
+
"MO",
|
|
145
|
+
"MV",
|
|
146
|
+
"MY",
|
|
147
|
+
"NP",
|
|
148
|
+
"OM",
|
|
149
|
+
"PH",
|
|
150
|
+
"PK",
|
|
151
|
+
"PS",
|
|
152
|
+
"QA",
|
|
153
|
+
"SA",
|
|
154
|
+
"SG",
|
|
155
|
+
"SY",
|
|
156
|
+
"TH",
|
|
157
|
+
"TJ",
|
|
158
|
+
"TL",
|
|
159
|
+
"TM",
|
|
160
|
+
"TR",
|
|
161
|
+
"TW",
|
|
162
|
+
"UZ",
|
|
163
|
+
"VN",
|
|
164
|
+
"YE"
|
|
165
|
+
],
|
|
166
|
+
"africa": [
|
|
167
|
+
"AO",
|
|
168
|
+
"BF",
|
|
169
|
+
"BI",
|
|
170
|
+
"BJ",
|
|
171
|
+
"BW",
|
|
172
|
+
"CD",
|
|
173
|
+
"CF",
|
|
174
|
+
"CG",
|
|
175
|
+
"CI",
|
|
176
|
+
"CM",
|
|
177
|
+
"CV",
|
|
178
|
+
"DJ",
|
|
179
|
+
"DZ",
|
|
180
|
+
"EG",
|
|
181
|
+
"EH",
|
|
182
|
+
"ER",
|
|
183
|
+
"ET",
|
|
184
|
+
"GA",
|
|
185
|
+
"GH",
|
|
186
|
+
"GM",
|
|
187
|
+
"GN",
|
|
188
|
+
"GQ",
|
|
189
|
+
"GW",
|
|
190
|
+
"KE",
|
|
191
|
+
"KM",
|
|
192
|
+
"LR",
|
|
193
|
+
"LS",
|
|
194
|
+
"LY",
|
|
195
|
+
"MA",
|
|
196
|
+
"MG",
|
|
197
|
+
"ML",
|
|
198
|
+
"MR",
|
|
199
|
+
"MU",
|
|
200
|
+
"MW",
|
|
201
|
+
"MZ",
|
|
202
|
+
"NA",
|
|
203
|
+
"NE",
|
|
204
|
+
"NG",
|
|
205
|
+
"RE",
|
|
206
|
+
"RW",
|
|
207
|
+
"SC",
|
|
208
|
+
"SD",
|
|
209
|
+
"SH",
|
|
210
|
+
"SL",
|
|
211
|
+
"SN",
|
|
212
|
+
"SO",
|
|
213
|
+
"SS",
|
|
214
|
+
"ST",
|
|
215
|
+
"SZ",
|
|
216
|
+
"TD",
|
|
217
|
+
"TG",
|
|
218
|
+
"TN",
|
|
219
|
+
"TZ",
|
|
220
|
+
"UG",
|
|
221
|
+
"YT",
|
|
222
|
+
"ZA",
|
|
223
|
+
"ZM",
|
|
224
|
+
"ZW"
|
|
225
|
+
],
|
|
226
|
+
"oceania": [
|
|
227
|
+
"AS",
|
|
228
|
+
"AU",
|
|
229
|
+
"CC",
|
|
230
|
+
"CK",
|
|
231
|
+
"CX",
|
|
232
|
+
"FJ",
|
|
233
|
+
"FM",
|
|
234
|
+
"GU",
|
|
235
|
+
"KI",
|
|
236
|
+
"MH",
|
|
237
|
+
"MP",
|
|
238
|
+
"NC",
|
|
239
|
+
"NF",
|
|
240
|
+
"NR",
|
|
241
|
+
"NU",
|
|
242
|
+
"NZ",
|
|
243
|
+
"PF",
|
|
244
|
+
"PG",
|
|
245
|
+
"PN",
|
|
246
|
+
"PW",
|
|
247
|
+
"SB",
|
|
248
|
+
"TK",
|
|
249
|
+
"TO",
|
|
250
|
+
"TV",
|
|
251
|
+
"UM",
|
|
252
|
+
"VU",
|
|
253
|
+
"WF",
|
|
254
|
+
"WS"
|
|
255
|
+
],
|
|
256
|
+
"antarctica": ["AQ", "BV", "GS", "HM", "TF"]
|
|
257
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import{isAppError as i}from"../errors/codes.js";const r=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","EPIPE","EAI_AGAIN","CONNECT_TIMEOUT","CONNECTION_CLOSED","57P01","57P02","57P03","08000","08001","08003","08004","08006","3D000","3D001","28000","28P01"]);function e(n,o=5){if(o<=0||n==null||typeof n!="object")return null;const t=n.code;if(typeof t=="string")return t;const u=n.cause??n.errors?.[0];return e(u,o-1)}function a(n){if(i(n,"service_unavailable"))return!0;const o=e(n);return o!=null&&r.has(o)}function l(n){return e(n)==="23505"}function c(n){return e(n)==="23503"}export{a as isDbUnavailable,c as isForeignKeyViolation,l as isUniqueViolation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"server-only";import e from"nodemailer";import{env as s}from"../env.js";import{emailEnv as a}from"./env.js";const n=globalThis;function c(){const r=a(),o=r.SMTP_PORT===465,t=n.transporter??e.createTransport({host:r.SMTP_HOST,port:r.SMTP_PORT,secure:o,requireTLS:!o,auth:{user:r.SMTP_USER,pass:r.SMTP_PASSWORD}});return s.NODE_ENV!=="production"&&(n.transporter=t),{transporter:t,from:r.EMAIL_FROM}}export{c as getTransporter};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const EmailEnvSchema: z.ZodObject<{
|
|
4
|
+
SMTP_HOST: z.ZodString;
|
|
5
|
+
SMTP_PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
6
|
+
SMTP_USER: z.ZodString;
|
|
7
|
+
SMTP_PASSWORD: z.ZodString;
|
|
8
|
+
EMAIL_FROM: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type EmailEnv = z.infer<typeof EmailEnvSchema>;
|
|
11
|
+
export declare function emailEnv(): EmailEnv;
|
|
12
|
+
export {};
|