svelte-firekit 0.0.15 → 0.0.16
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 +34 -87
- package/dist/{firebase/auth → auth}/auth.js +1 -2
- package/dist/auth/user.svelte.d.ts +94 -0
- package/dist/auth/user.svelte.js +134 -0
- package/dist/config.d.ts +2 -2
- package/dist/config.js +44 -28
- package/dist/{firebase/firebase.d.ts → firebase.d.ts} +1 -2
- package/dist/{firebase/firebase.js → firebase.js} +1 -4
- package/dist/{firebase/firestore → firestore}/awaitable-doc.svelte.js +1 -1
- package/dist/{firebase/firestore → firestore}/collection.svelte.js +1 -1
- package/dist/{firebase/firestore → firestore}/doc.svelte.js +1 -1
- package/dist/{firebase/firestore → firestore}/document-mutations.svelte.js +11 -11
- package/dist/index.d.ts +10 -23
- package/dist/index.js +10 -28
- package/package.json +10 -26
- package/dist/auth/auth.svelte +0 -65
- package/dist/auth/auth.svelte.d.ts +0 -2
- package/dist/auth/require-auth.svelte +0 -52
- package/dist/auth/require-auth.svelte.d.ts +0 -11
- package/dist/auth/require-no-auth.svelte +0 -42
- package/dist/auth/require-no-auth.svelte.d.ts +0 -6
- package/dist/auth/reset-password.svelte +0 -33
- package/dist/auth/reset-password.svelte.d.ts +0 -8
- package/dist/auth/sign-in.svelte +0 -61
- package/dist/auth/sign-in.svelte.d.ts +0 -15
- package/dist/auth/sign-up.svelte +0 -72
- package/dist/auth/sign-up.svelte.d.ts +0 -18
- package/dist/components/app/nav/app-sidebar.svelte +0 -35
- package/dist/components/app/nav/app-sidebar.svelte.d.ts +0 -8
- package/dist/components/app/nav/breadcrumb.svelte +0 -42
- package/dist/components/app/nav/breadcrumb.svelte.d.ts +0 -19
- package/dist/components/auth/google-sign-in.svelte +0 -62
- package/dist/components/auth/google-sign-in.svelte.d.ts +0 -4
- package/dist/components/auth/reset-password-form.svelte +0 -59
- package/dist/components/auth/reset-password-form.svelte.d.ts +0 -4
- package/dist/components/auth/sign-in-form.svelte +0 -92
- package/dist/components/auth/sign-in-form.svelte.d.ts +0 -9
- package/dist/components/auth/sign-up-form.svelte +0 -138
- package/dist/components/auth/sign-up-form.svelte.d.ts +0 -12
- package/dist/components/auth/user-button/profile-section/avatar-user.svelte +0 -107
- package/dist/components/auth/user-button/profile-section/avatar-user.svelte.d.ts +0 -2
- package/dist/components/auth/user-button/profile-section/connect-user.svelte +0 -45
- package/dist/components/auth/user-button/profile-section/connect-user.svelte.d.ts +0 -18
- package/dist/components/auth/user-button/profile-section/email-user.svelte +0 -81
- package/dist/components/auth/user-button/profile-section/email-user.svelte.d.ts +0 -2
- package/dist/components/auth/user-button/profile-section/phone-user.svelte +0 -122
- package/dist/components/auth/user-button/profile-section/phone-user.svelte.d.ts +0 -2
- package/dist/components/auth/user-button/profile-section/profile-section.svelte +0 -17
- package/dist/components/auth/user-button/profile-section/profile-section.svelte.d.ts +0 -18
- package/dist/components/auth/user-button/settings-dialog.svelte +0 -88
- package/dist/components/auth/user-button/settings-dialog.svelte.d.ts +0 -2
- package/dist/components/auth/user-button/type-account.svelte +0 -35
- package/dist/components/auth/user-button/type-account.svelte.d.ts +0 -4
- package/dist/components/auth/user-button/user-button.svelte +0 -131
- package/dist/components/auth/user-button/user-button.svelte.d.ts +0 -6
- package/dist/components/firestore/collection.svelte +0 -45
- package/dist/components/firestore/collection.svelte.d.ts +0 -25
- package/dist/components/firestore/doc.svelte +0 -39
- package/dist/components/firestore/doc.svelte.d.ts +0 -25
- package/dist/components/nav/app-sidebar.svelte +0 -46
- package/dist/components/nav/app-sidebar.svelte.d.ts +0 -8
- package/dist/components/nav/breadcrumb.svelte +0 -42
- package/dist/components/nav/breadcrumb.svelte.d.ts +0 -19
- package/dist/components/nav/dark-mode-toggle.svelte +0 -16
- package/dist/components/nav/dark-mode-toggle.svelte.d.ts +0 -18
- package/dist/components/nav/nav-main.svelte +0 -70
- package/dist/components/nav/nav-main.svelte.d.ts +0 -18
- package/dist/components/nav/nav.d.ts +0 -11
- package/dist/components/nav/nav.js +0 -157
- package/dist/components/nav/search-form.svelte +0 -21
- package/dist/components/nav/search-form.svelte.d.ts +0 -4
- package/dist/components/nav/version-switcher.svelte +0 -48
- package/dist/components/nav/version-switcher.svelte.d.ts +0 -5
- package/dist/components/public/footer-main.svelte +0 -0
- package/dist/components/public/footer-main.svelte.d.ts +0 -26
- package/dist/components/public/nav-main.svelte +0 -136
- package/dist/components/public/nav-main.svelte.d.ts +0 -18
- package/dist/components/storage/upload.svelte +0 -134
- package/dist/components/storage/upload.svelte.d.ts +0 -11
- package/dist/components/ui/alert-dialog/alert-dialog-action.svelte +0 -13
- package/dist/components/ui/alert-dialog/alert-dialog-action.svelte.d.ts +0 -3
- package/dist/components/ui/alert-dialog/alert-dialog-cancel.svelte +0 -17
- package/dist/components/ui/alert-dialog/alert-dialog-cancel.svelte.d.ts +0 -3
- package/dist/components/ui/alert-dialog/alert-dialog-content.svelte +0 -23
- package/dist/components/ui/alert-dialog/alert-dialog-content.svelte.d.ts +0 -2
- package/dist/components/ui/alert-dialog/alert-dialog-description.svelte +0 -16
- package/dist/components/ui/alert-dialog/alert-dialog-description.svelte.d.ts +0 -3
- package/dist/components/ui/alert-dialog/alert-dialog-footer.svelte +0 -20
- package/dist/components/ui/alert-dialog/alert-dialog-footer.svelte.d.ts +0 -4
- package/dist/components/ui/alert-dialog/alert-dialog-header.svelte +0 -20
- package/dist/components/ui/alert-dialog/alert-dialog-header.svelte.d.ts +0 -4
- package/dist/components/ui/alert-dialog/alert-dialog-overlay.svelte +0 -19
- package/dist/components/ui/alert-dialog/alert-dialog-overlay.svelte.d.ts +0 -3
- package/dist/components/ui/alert-dialog/alert-dialog-title.svelte +0 -18
- package/dist/components/ui/alert-dialog/alert-dialog-title.svelte.d.ts +0 -3
- package/dist/components/ui/alert-dialog/index.js +0 -15
- package/dist/components/ui/avatar/avatar-fallback.svelte +0 -16
- package/dist/components/ui/avatar/avatar-fallback.svelte.d.ts +0 -3
- package/dist/components/ui/avatar/avatar-image.svelte +0 -20
- package/dist/components/ui/avatar/avatar-image.svelte.d.ts +0 -3
- package/dist/components/ui/avatar/avatar.svelte +0 -18
- package/dist/components/ui/avatar/avatar.svelte.d.ts +0 -3
- package/dist/components/ui/avatar/index.d.ts +0 -4
- package/dist/components/ui/avatar/index.js +0 -6
- package/dist/components/ui/badge/badge.svelte +0 -49
- package/dist/components/ui/badge/badge.svelte.d.ts +0 -59
- package/dist/components/ui/badge/index.d.ts +0 -2
- package/dist/components/ui/badge/index.js +0 -2
- package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte +0 -23
- package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte.d.ts +0 -4
- package/dist/components/ui/breadcrumb/breadcrumb-item.svelte +0 -16
- package/dist/components/ui/breadcrumb/breadcrumb-item.svelte.d.ts +0 -4
- package/dist/components/ui/breadcrumb/breadcrumb-link.svelte +0 -31
- package/dist/components/ui/breadcrumb/breadcrumb-link.svelte.d.ts +0 -10
- package/dist/components/ui/breadcrumb/breadcrumb-list.svelte +0 -23
- package/dist/components/ui/breadcrumb/breadcrumb-list.svelte.d.ts +0 -4
- package/dist/components/ui/breadcrumb/breadcrumb-page.svelte +0 -23
- package/dist/components/ui/breadcrumb/breadcrumb-page.svelte.d.ts +0 -4
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte +0 -27
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte.d.ts +0 -4
- package/dist/components/ui/breadcrumb/breadcrumb.svelte +0 -15
- package/dist/components/ui/breadcrumb/breadcrumb.svelte.d.ts +0 -4
- package/dist/components/ui/breadcrumb/index.d.ts +0 -8
- package/dist/components/ui/breadcrumb/index.js +0 -10
- package/dist/components/ui/button/button.svelte +0 -75
- package/dist/components/ui/button/button.svelte.d.ts +0 -117
- package/dist/components/ui/button/index.d.ts +0 -2
- package/dist/components/ui/button/index.js +0 -4
- package/dist/components/ui/card/card-content.svelte +0 -16
- package/dist/components/ui/card/card-content.svelte.d.ts +0 -4
- package/dist/components/ui/card/card-description.svelte +0 -16
- package/dist/components/ui/card/card-description.svelte.d.ts +0 -4
- package/dist/components/ui/card/card-footer.svelte +0 -16
- package/dist/components/ui/card/card-footer.svelte.d.ts +0 -4
- package/dist/components/ui/card/card-header.svelte +0 -16
- package/dist/components/ui/card/card-header.svelte.d.ts +0 -4
- package/dist/components/ui/card/card-title.svelte +0 -25
- package/dist/components/ui/card/card-title.svelte.d.ts +0 -7
- package/dist/components/ui/card/card.svelte +0 -20
- package/dist/components/ui/card/card.svelte.d.ts +0 -4
- package/dist/components/ui/card/index.d.ts +0 -7
- package/dist/components/ui/card/index.js +0 -9
- package/dist/components/ui/checkbox/checkbox.svelte +0 -33
- package/dist/components/ui/checkbox/checkbox.svelte.d.ts +0 -3
- package/dist/components/ui/checkbox/index.d.ts +0 -2
- package/dist/components/ui/checkbox/index.js +0 -4
- package/dist/components/ui/collapsible/index.d.ts +0 -5
- package/dist/components/ui/collapsible/index.js +0 -7
- package/dist/components/ui/dialog/dialog-content.svelte +0 -36
- package/dist/components/ui/dialog/dialog-content.svelte.d.ts +0 -6
- package/dist/components/ui/dialog/dialog-description.svelte +0 -16
- package/dist/components/ui/dialog/dialog-description.svelte.d.ts +0 -3
- package/dist/components/ui/dialog/dialog-footer.svelte +0 -20
- package/dist/components/ui/dialog/dialog-footer.svelte.d.ts +0 -4
- package/dist/components/ui/dialog/dialog-header.svelte +0 -20
- package/dist/components/ui/dialog/dialog-header.svelte.d.ts +0 -4
- package/dist/components/ui/dialog/dialog-overlay.svelte +0 -19
- package/dist/components/ui/dialog/dialog-overlay.svelte.d.ts +0 -3
- package/dist/components/ui/dialog/dialog-title.svelte +0 -16
- package/dist/components/ui/dialog/dialog-title.svelte.d.ts +0 -3
- package/dist/components/ui/dialog/index.d.ts +0 -12
- package/dist/components/ui/dialog/index.js +0 -14
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +0 -40
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +0 -6
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +0 -22
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +0 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +0 -19
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte.d.ts +0 -11
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +0 -23
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +0 -18
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte +0 -23
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte.d.ts +0 -7
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +0 -30
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte.d.ts +0 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte +0 -16
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte.d.ts +0 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +0 -20
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte.d.ts +0 -4
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +0 -19
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +0 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +0 -28
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +0 -5
- package/dist/components/ui/dropdown-menu/index.js +0 -17
- package/dist/components/ui/form/form-button.svelte +0 -7
- package/dist/components/ui/form/form-button.svelte.d.ts +0 -3
- package/dist/components/ui/form/form-description.svelte +0 -17
- package/dist/components/ui/form/form-description.svelte.d.ts +0 -3
- package/dist/components/ui/form/form-element-field.svelte +0 -30
- package/dist/components/ui/form/form-element-field.svelte.d.ts +0 -22
- package/dist/components/ui/form/form-field-errors.svelte +0 -30
- package/dist/components/ui/form/form-field-errors.svelte.d.ts +0 -5
- package/dist/components/ui/form/form-field.svelte +0 -30
- package/dist/components/ui/form/form-field.svelte.d.ts +0 -21
- package/dist/components/ui/form/form-fieldset.svelte +0 -21
- package/dist/components/ui/form/form-fieldset.svelte.d.ts +0 -19
- package/dist/components/ui/form/form-label.svelte +0 -21
- package/dist/components/ui/form/form-label.svelte.d.ts +0 -3
- package/dist/components/ui/form/form-legend.svelte +0 -17
- package/dist/components/ui/form/form-legend.svelte.d.ts +0 -3
- package/dist/components/ui/form/index.d.ts +0 -11
- package/dist/components/ui/form/index.js +0 -13
- package/dist/components/ui/input/index.d.ts +0 -2
- package/dist/components/ui/input/index.js +0 -4
- package/dist/components/ui/input/input.svelte +0 -22
- package/dist/components/ui/input/input.svelte.d.ts +0 -4
- package/dist/components/ui/label/index.d.ts +0 -2
- package/dist/components/ui/label/index.js +0 -4
- package/dist/components/ui/label/label.svelte +0 -19
- package/dist/components/ui/label/label.svelte.d.ts +0 -3
- package/dist/components/ui/select/index.js +0 -13
- package/dist/components/ui/select/select-content.svelte +0 -38
- package/dist/components/ui/select/select-content.svelte.d.ts +0 -5
- package/dist/components/ui/select/select-group-heading.svelte +0 -16
- package/dist/components/ui/select/select-group-heading.svelte.d.ts +0 -3
- package/dist/components/ui/select/select-item.svelte +0 -37
- package/dist/components/ui/select/select-item.svelte.d.ts +0 -3
- package/dist/components/ui/select/select-scroll-down-button.svelte +0 -19
- package/dist/components/ui/select/select-scroll-down-button.svelte.d.ts +0 -3
- package/dist/components/ui/select/select-scroll-up-button.svelte +0 -19
- package/dist/components/ui/select/select-scroll-up-button.svelte.d.ts +0 -3
- package/dist/components/ui/select/select-separator.svelte +0 -13
- package/dist/components/ui/select/select-separator.svelte.d.ts +0 -3
- package/dist/components/ui/select/select-trigger.svelte +0 -24
- package/dist/components/ui/select/select-trigger.svelte.d.ts +0 -3
- package/dist/components/ui/separator/index.d.ts +0 -2
- package/dist/components/ui/separator/index.js +0 -4
- package/dist/components/ui/separator/separator.svelte +0 -22
- package/dist/components/ui/separator/separator.svelte.d.ts +0 -3
- package/dist/components/ui/sheet/index.js +0 -14
- package/dist/components/ui/sheet/sheet-content.svelte +0 -52
- package/dist/components/ui/sheet/sheet-content.svelte.d.ts +0 -59
- package/dist/components/ui/sheet/sheet-description.svelte +0 -16
- package/dist/components/ui/sheet/sheet-description.svelte.d.ts +0 -3
- package/dist/components/ui/sheet/sheet-footer.svelte +0 -20
- package/dist/components/ui/sheet/sheet-footer.svelte.d.ts +0 -4
- package/dist/components/ui/sheet/sheet-header.svelte +0 -20
- package/dist/components/ui/sheet/sheet-header.svelte.d.ts +0 -4
- package/dist/components/ui/sheet/sheet-overlay.svelte +0 -19
- package/dist/components/ui/sheet/sheet-overlay.svelte.d.ts +0 -3
- package/dist/components/ui/sheet/sheet-title.svelte +0 -16
- package/dist/components/ui/sheet/sheet-title.svelte.d.ts +0 -3
- package/dist/components/ui/sidebar/constants.d.ts +0 -6
- package/dist/components/ui/sidebar/constants.js +0 -6
- package/dist/components/ui/sidebar/context.svelte.d.ts +0 -42
- package/dist/components/ui/sidebar/context.svelte.js +0 -54
- package/dist/components/ui/sidebar/index.d.ts +0 -25
- package/dist/components/ui/sidebar/index.js +0 -27
- package/dist/components/ui/sidebar/sidebar-content.svelte +0 -24
- package/dist/components/ui/sidebar/sidebar-content.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-footer.svelte +0 -21
- package/dist/components/ui/sidebar/sidebar-footer.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-group-action.svelte +0 -36
- package/dist/components/ui/sidebar/sidebar-group-action.svelte.d.ts +0 -10
- package/dist/components/ui/sidebar/sidebar-group-content.svelte +0 -21
- package/dist/components/ui/sidebar/sidebar-group-content.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-group-label.svelte +0 -34
- package/dist/components/ui/sidebar/sidebar-group-label.svelte.d.ts +0 -10
- package/dist/components/ui/sidebar/sidebar-group.svelte +0 -21
- package/dist/components/ui/sidebar/sidebar-group.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-header.svelte +0 -21
- package/dist/components/ui/sidebar/sidebar-header.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-input.svelte +0 -23
- package/dist/components/ui/sidebar/sidebar-input.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-inset.svelte +0 -24
- package/dist/components/ui/sidebar/sidebar-inset.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-menu-action.svelte +0 -43
- package/dist/components/ui/sidebar/sidebar-menu-action.svelte.d.ts +0 -11
- package/dist/components/ui/sidebar/sidebar-menu-badge.svelte +0 -29
- package/dist/components/ui/sidebar/sidebar-menu-badge.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-menu-button.svelte +0 -97
- package/dist/components/ui/sidebar/sidebar-menu-button.svelte.d.ts +0 -91
- package/dist/components/ui/sidebar/sidebar-menu-item.svelte +0 -21
- package/dist/components/ui/sidebar/sidebar-menu-item.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte +0 -36
- package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte.d.ts +0 -7
- package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte +0 -43
- package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte.d.ts +0 -12
- package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte +0 -14
- package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-menu-sub.svelte +0 -25
- package/dist/components/ui/sidebar/sidebar-menu-sub.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-menu.svelte +0 -21
- package/dist/components/ui/sidebar/sidebar-menu.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-provider.svelte +0 -59
- package/dist/components/ui/sidebar/sidebar-provider.svelte.d.ts +0 -9
- package/dist/components/ui/sidebar/sidebar-rail.svelte +0 -36
- package/dist/components/ui/sidebar/sidebar-rail.svelte.d.ts +0 -4
- package/dist/components/ui/sidebar/sidebar-separator.svelte +0 -18
- package/dist/components/ui/sidebar/sidebar-separator.svelte.d.ts +0 -12
- package/dist/components/ui/sidebar/sidebar-trigger.svelte +0 -34
- package/dist/components/ui/sidebar/sidebar-trigger.svelte.d.ts +0 -9
- package/dist/components/ui/sidebar/sidebar.svelte +0 -98
- package/dist/components/ui/sidebar/sidebar.svelte.d.ts +0 -9
- package/dist/components/ui/skeleton/index.d.ts +0 -2
- package/dist/components/ui/skeleton/index.js +0 -4
- package/dist/components/ui/skeleton/skeleton.svelte +0 -17
- package/dist/components/ui/skeleton/skeleton.svelte.d.ts +0 -4
- package/dist/components/ui/sonner/index.d.ts +0 -1
- package/dist/components/ui/sonner/index.js +0 -1
- package/dist/components/ui/sonner/sonner.svelte +0 -20
- package/dist/components/ui/sonner/sonner.svelte.d.ts +0 -3
- package/dist/components/ui/tooltip/index.js +0 -8
- package/dist/components/ui/tooltip/tooltip-content.svelte +0 -21
- package/dist/components/ui/tooltip/tooltip-content.svelte.d.ts +0 -3
- package/dist/firebase/auth/auth-manager.svelte.d.ts +0 -85
- package/dist/firebase/auth/auth-manager.svelte.js +0 -386
- package/dist/firebase/config.d.ts +0 -2
- package/dist/firebase/config.js +0 -44
- package/dist/hooks/is-mobile.svelte.d.ts +0 -5
- package/dist/hooks/is-mobile.svelte.js +0 -23
- package/dist/schemas/reset-password.d.ts +0 -4
- package/dist/schemas/reset-password.js +0 -4
- package/dist/schemas/sign-in.d.ts +0 -5
- package/dist/schemas/sign-in.js +0 -5
- package/dist/schemas/sign-up.d.ts +0 -8
- package/dist/schemas/sign-up.js +0 -8
- package/dist/types/docs.d.ts +0 -50
- package/dist/types/docs.js +0 -1
- package/dist/types/nav.d.ts +0 -13
- package/dist/types/nav.js +0 -1
- package/dist/utils.d.ts +0 -29
- package/dist/utils.js +0 -92
- /package/dist/{firebase/auth → auth}/auth.d.ts +0 -0
- /package/dist/{firebase/firestore → firestore}/awaitable-doc.svelte.d.ts +0 -0
- /package/dist/{firebase/firestore → firestore}/collection.svelte.d.ts +0 -0
- /package/dist/{firebase/firestore → firestore}/doc.svelte.d.ts +0 -0
- /package/dist/{firebase/firestore → firestore}/document-mutations.svelte.d.ts +0 -0
- /package/dist/{firebase/storage → storage}/download-url.svelte.d.ts +0 -0
- /package/dist/{firebase/storage → storage}/download-url.svelte.js +0 -0
- /package/dist/{firebase/storage → storage}/storage-list.svelte.d.ts +0 -0
- /package/dist/{firebase/storage → storage}/storage-list.svelte.js +0 -0
- /package/dist/{firebase/storage → storage}/upload-task.svelte.d.ts +0 -0
- /package/dist/{firebase/storage → storage}/upload-task.svelte.js +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import * as Sheet from "../sheet/index.js";
|
|
3
|
-
import { cn } from "../../../utils.js";
|
|
4
|
-
import type { WithElementRef } from "bits-ui";
|
|
5
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
6
|
-
import { SIDEBAR_WIDTH_MOBILE } from "./constants.js";
|
|
7
|
-
import { useSidebar } from "./context.svelte.js";
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
ref = $bindable(null),
|
|
11
|
-
side = "left",
|
|
12
|
-
variant = "sidebar",
|
|
13
|
-
collapsible = "offcanvas",
|
|
14
|
-
class: className,
|
|
15
|
-
children,
|
|
16
|
-
...restProps
|
|
17
|
-
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
18
|
-
side?: "left" | "right";
|
|
19
|
-
variant?: "sidebar" | "floating" | "inset";
|
|
20
|
-
collapsible?: "offcanvas" | "icon" | "none";
|
|
21
|
-
} = $props();
|
|
22
|
-
|
|
23
|
-
const sidebar = useSidebar();
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
{#if collapsible === "none"}
|
|
27
|
-
<div
|
|
28
|
-
class={cn(
|
|
29
|
-
"bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",
|
|
30
|
-
className
|
|
31
|
-
)}
|
|
32
|
-
bind:this={ref}
|
|
33
|
-
{...restProps}
|
|
34
|
-
>
|
|
35
|
-
{@render children?.()}
|
|
36
|
-
</div>
|
|
37
|
-
{:else if sidebar.isMobile}
|
|
38
|
-
<Sheet.Root
|
|
39
|
-
controlledOpen
|
|
40
|
-
open={sidebar.openMobile}
|
|
41
|
-
onOpenChange={sidebar.setOpenMobile}
|
|
42
|
-
{...restProps}
|
|
43
|
-
>
|
|
44
|
-
<Sheet.Content
|
|
45
|
-
data-sidebar="sidebar"
|
|
46
|
-
data-mobile="true"
|
|
47
|
-
class="bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden"
|
|
48
|
-
style="--sidebar-width: {SIDEBAR_WIDTH_MOBILE};"
|
|
49
|
-
{side}
|
|
50
|
-
>
|
|
51
|
-
<div class="flex h-full w-full flex-col">
|
|
52
|
-
{@render children?.()}
|
|
53
|
-
</div>
|
|
54
|
-
</Sheet.Content>
|
|
55
|
-
</Sheet.Root>
|
|
56
|
-
{:else}
|
|
57
|
-
<div
|
|
58
|
-
bind:this={ref}
|
|
59
|
-
class="text-sidebar-foreground group peer hidden md:block"
|
|
60
|
-
data-state={sidebar.state}
|
|
61
|
-
data-collapsible={sidebar.state === "collapsed" ? collapsible : ""}
|
|
62
|
-
data-variant={variant}
|
|
63
|
-
data-side={side}
|
|
64
|
-
>
|
|
65
|
-
<!-- This is what handles the sidebar gap on desktop -->
|
|
66
|
-
<div
|
|
67
|
-
class={cn(
|
|
68
|
-
"relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
|
|
69
|
-
"group-data-[collapsible=offcanvas]:w-0",
|
|
70
|
-
"group-data-[side=right]:rotate-180",
|
|
71
|
-
variant === "floating" || variant === "inset"
|
|
72
|
-
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
|
|
73
|
-
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"
|
|
74
|
-
)}
|
|
75
|
-
></div>
|
|
76
|
-
<div
|
|
77
|
-
class={cn(
|
|
78
|
-
"fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
|
|
79
|
-
side === "left"
|
|
80
|
-
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
|
81
|
-
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
82
|
-
// Adjust the padding for floating and inset variants.
|
|
83
|
-
variant === "floating" || variant === "inset"
|
|
84
|
-
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
|
|
85
|
-
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
86
|
-
className
|
|
87
|
-
)}
|
|
88
|
-
{...restProps}
|
|
89
|
-
>
|
|
90
|
-
<div
|
|
91
|
-
data-sidebar="sidebar"
|
|
92
|
-
class="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow"
|
|
93
|
-
>
|
|
94
|
-
{@render children?.()}
|
|
95
|
-
</div>
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
{/if}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
-
declare const Sidebar: import("svelte").Component<HTMLAttributes<HTMLDivElement> & {
|
|
3
|
-
ref?: HTMLElement | null | undefined;
|
|
4
|
-
} & {
|
|
5
|
-
side?: "left" | "right";
|
|
6
|
-
variant?: "sidebar" | "floating" | "inset";
|
|
7
|
-
collapsible?: "offcanvas" | "icon" | "none";
|
|
8
|
-
}, {}, "ref">;
|
|
9
|
-
export default Sidebar;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { WithElementRef, WithoutChildren } from "bits-ui";
|
|
3
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
-
import { cn } from "../../../utils.js";
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
ref = $bindable(null),
|
|
8
|
-
class: className,
|
|
9
|
-
...restProps
|
|
10
|
-
}: WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> = $props();
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<div
|
|
14
|
-
bind:this={ref}
|
|
15
|
-
class={cn("bg-primary/10 animate-pulse rounded-md", className)}
|
|
16
|
-
{...restProps}
|
|
17
|
-
></div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Toaster } from "./sonner.svelte";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Toaster } from "./sonner.svelte";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Toaster as Sonner, type ToasterProps as SonnerProps } from "svelte-sonner";
|
|
3
|
-
import { mode } from "mode-watcher";
|
|
4
|
-
|
|
5
|
-
let restProps: SonnerProps = $props();
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<Sonner
|
|
9
|
-
theme={$mode}
|
|
10
|
-
class="toaster group"
|
|
11
|
-
toastOptions={{
|
|
12
|
-
classes: {
|
|
13
|
-
toast: "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
|
14
|
-
description: "group-[.toast]:text-muted-foreground",
|
|
15
|
-
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
|
16
|
-
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
{...restProps}
|
|
20
|
-
/>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Tooltip as TooltipPrimitive } from "bits-ui";
|
|
2
|
-
import Content from "./tooltip-content.svelte";
|
|
3
|
-
const Root = TooltipPrimitive.Root;
|
|
4
|
-
const Trigger = TooltipPrimitive.Trigger;
|
|
5
|
-
const Provider = TooltipPrimitive.Provider;
|
|
6
|
-
export { Root, Trigger, Content, Provider,
|
|
7
|
-
//
|
|
8
|
-
Root as Tooltip, Content as TooltipContent, Trigger as TooltipTrigger, Provider as TooltipProvider, };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Tooltip as TooltipPrimitive } from "bits-ui";
|
|
3
|
-
import { cn } from "../../../utils.js";
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
ref = $bindable(null),
|
|
7
|
-
class: className,
|
|
8
|
-
sideOffset = 4,
|
|
9
|
-
...restProps
|
|
10
|
-
}: TooltipPrimitive.ContentProps = $props();
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<TooltipPrimitive.Content
|
|
14
|
-
bind:ref
|
|
15
|
-
{sideOffset}
|
|
16
|
-
class={cn(
|
|
17
|
-
"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md px-3 py-1.5 text-xs",
|
|
18
|
-
className
|
|
19
|
-
)}
|
|
20
|
-
{...restProps}
|
|
21
|
-
/>
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { type DocumentData } from "firebase/firestore";
|
|
2
|
-
type UserClaims = Record<string, any>;
|
|
3
|
-
interface UserData extends DocumentData {
|
|
4
|
-
displayName?: string;
|
|
5
|
-
email?: string;
|
|
6
|
-
photoURL?: string;
|
|
7
|
-
createdAt?: Date;
|
|
8
|
-
updatedAt?: Date;
|
|
9
|
-
isProfileComplete?: boolean;
|
|
10
|
-
role?: string;
|
|
11
|
-
settings?: Record<string, any>;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}
|
|
14
|
-
interface GuardConfig {
|
|
15
|
-
authRequired?: boolean;
|
|
16
|
-
redirectTo?: string;
|
|
17
|
-
requiredClaims?: string[];
|
|
18
|
-
requiredData?: (data: DocumentData | null) => boolean;
|
|
19
|
-
allowIf?: (manager: FirekitAuthManager) => boolean;
|
|
20
|
-
redirectParams?: Record<string, string>;
|
|
21
|
-
}
|
|
22
|
-
export declare class FirekitAuthManager {
|
|
23
|
-
private static instance;
|
|
24
|
-
private readonly SESSION_TIMEOUT;
|
|
25
|
-
private activityInterval;
|
|
26
|
-
private _initPromise;
|
|
27
|
-
private _user;
|
|
28
|
-
private _userData;
|
|
29
|
-
private _claims;
|
|
30
|
-
private _initialized;
|
|
31
|
-
private _loading;
|
|
32
|
-
private _error;
|
|
33
|
-
private _currentSession;
|
|
34
|
-
private _lastValidationTime;
|
|
35
|
-
readonly isLoggedIn: boolean;
|
|
36
|
-
readonly uid: string | undefined;
|
|
37
|
-
readonly email: string | null | undefined;
|
|
38
|
-
readonly displayName: string | null | undefined;
|
|
39
|
-
readonly photoURL: string | null | undefined;
|
|
40
|
-
readonly emailVerified: boolean | undefined;
|
|
41
|
-
readonly claims: UserClaims;
|
|
42
|
-
readonly data: UserData | null;
|
|
43
|
-
readonly initialized: boolean;
|
|
44
|
-
readonly loading: boolean;
|
|
45
|
-
readonly error: Error | null;
|
|
46
|
-
readonly sessionActive: boolean;
|
|
47
|
-
private constructor();
|
|
48
|
-
static getInstance(): FirekitAuthManager;
|
|
49
|
-
private initialize;
|
|
50
|
-
waitForInit(): Promise<void>;
|
|
51
|
-
private handleAuthStateChange;
|
|
52
|
-
private loadUserData;
|
|
53
|
-
private loadUserClaims;
|
|
54
|
-
private setupActivityTracking;
|
|
55
|
-
private initializeSession;
|
|
56
|
-
private updateLastActivity;
|
|
57
|
-
private checkSession;
|
|
58
|
-
private handleSessionTimeout;
|
|
59
|
-
private clearSession;
|
|
60
|
-
private handleError;
|
|
61
|
-
private generateDeviceId;
|
|
62
|
-
private getPlatformInfo;
|
|
63
|
-
private validateClaims;
|
|
64
|
-
handleRedirect(redirectTo: string, params?: Record<string, string>): Promise<void>;
|
|
65
|
-
validateAuth({ authRequired, redirectTo, requiredClaims, requiredData, allowIf, redirectParams, }?: GuardConfig): Promise<boolean>;
|
|
66
|
-
updateEmailUser(email: string): Promise<void>;
|
|
67
|
-
updatePassword(password: string): Promise<void>;
|
|
68
|
-
updateProfileInfo({ displayName, photoURL, }: {
|
|
69
|
-
displayName?: string;
|
|
70
|
-
photoURL?: string;
|
|
71
|
-
}): Promise<void>;
|
|
72
|
-
updateUserData(data: Partial<UserData>): Promise<void>;
|
|
73
|
-
saveUserData(data: UserData): Promise<void>;
|
|
74
|
-
sendVerificationEmail(): Promise<void>;
|
|
75
|
-
refreshUserData(): Promise<void>;
|
|
76
|
-
hasRequiredClaims(requiredClaims: string[]): boolean;
|
|
77
|
-
isAdmin(): boolean;
|
|
78
|
-
isPremium(): boolean;
|
|
79
|
-
requireClaims(claims: string[], redirectTo?: string, redirectParams?: Record<string, string>): Promise<boolean>;
|
|
80
|
-
requireData(validator: (data: DocumentData | null) => boolean, redirectTo?: string, redirectParams?: Record<string, string>): Promise<boolean>;
|
|
81
|
-
logOut(): Promise<void>;
|
|
82
|
-
destroy(): void;
|
|
83
|
-
}
|
|
84
|
-
export declare const firekitAuthManager: FirekitAuthManager;
|
|
85
|
-
export {};
|
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import { browser } from "$app/environment";
|
|
2
|
-
import { goto } from "$app/navigation";
|
|
3
|
-
import { firebaseService } from "../firebase.js";
|
|
4
|
-
import { toast } from "svelte-sonner";
|
|
5
|
-
import { onAuthStateChanged, updateEmail, updatePassword, updateProfile, sendEmailVerification, } from "firebase/auth";
|
|
6
|
-
import { doc, getDoc, setDoc, updateDoc, } from "firebase/firestore";
|
|
7
|
-
class AuthError extends Error {
|
|
8
|
-
code;
|
|
9
|
-
originalError;
|
|
10
|
-
constructor(message, code = 'unknown', originalError) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.code = code;
|
|
13
|
-
this.originalError = originalError;
|
|
14
|
-
this.name = 'AuthError';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export class FirekitAuthManager {
|
|
18
|
-
static instance;
|
|
19
|
-
SESSION_TIMEOUT = 30 * 60 * 1000; // 30 minutes
|
|
20
|
-
activityInterval = null;
|
|
21
|
-
_initPromise = null;
|
|
22
|
-
// State using Svelte 5 runes
|
|
23
|
-
_user = $state();
|
|
24
|
-
_userData = $state(null);
|
|
25
|
-
_claims = $state({});
|
|
26
|
-
_initialized = $state(false);
|
|
27
|
-
_loading = $state(true);
|
|
28
|
-
_error = $state(null);
|
|
29
|
-
_currentSession = $state(null);
|
|
30
|
-
_lastValidationTime = $state(0);
|
|
31
|
-
// Derived state
|
|
32
|
-
isLoggedIn = $derived(Boolean(this._user));
|
|
33
|
-
uid = $derived(this._user?.uid);
|
|
34
|
-
email = $derived(this._user?.email);
|
|
35
|
-
displayName = $derived(this._user?.displayName);
|
|
36
|
-
photoURL = $derived(this._user?.photoURL);
|
|
37
|
-
emailVerified = $derived(this._user?.emailVerified);
|
|
38
|
-
claims = $derived(this._claims);
|
|
39
|
-
data = $derived(this._userData);
|
|
40
|
-
initialized = $derived(this._initialized);
|
|
41
|
-
loading = $derived(this._loading);
|
|
42
|
-
error = $derived(this._error);
|
|
43
|
-
sessionActive = $derived(Boolean(this._currentSession));
|
|
44
|
-
constructor() {
|
|
45
|
-
if (browser) {
|
|
46
|
-
this.initialize();
|
|
47
|
-
this.setupActivityTracking();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
static getInstance() {
|
|
51
|
-
if (!FirekitAuthManager.instance) {
|
|
52
|
-
FirekitAuthManager.instance = new FirekitAuthManager();
|
|
53
|
-
}
|
|
54
|
-
return FirekitAuthManager.instance;
|
|
55
|
-
}
|
|
56
|
-
async initialize() {
|
|
57
|
-
if (this._initialized)
|
|
58
|
-
return;
|
|
59
|
-
this._initPromise = new Promise((resolve) => {
|
|
60
|
-
const auth = firebaseService.getAuthInstance();
|
|
61
|
-
if (!auth)
|
|
62
|
-
throw new AuthError('Firebase Auth not initialized', 'init_failed');
|
|
63
|
-
onAuthStateChanged(auth, async (user) => {
|
|
64
|
-
await this.handleAuthStateChange(user);
|
|
65
|
-
resolve();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
async waitForInit() {
|
|
70
|
-
if (this._initialized)
|
|
71
|
-
return;
|
|
72
|
-
return this._initPromise || Promise.resolve();
|
|
73
|
-
}
|
|
74
|
-
async handleAuthStateChange(user) {
|
|
75
|
-
this._loading = true;
|
|
76
|
-
try {
|
|
77
|
-
if (user) {
|
|
78
|
-
this._user = user;
|
|
79
|
-
await Promise.all([
|
|
80
|
-
this.loadUserData(user.uid),
|
|
81
|
-
this.loadUserClaims(user)
|
|
82
|
-
]);
|
|
83
|
-
this.initializeSession();
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
this._user = null;
|
|
87
|
-
this._userData = null;
|
|
88
|
-
this._claims = {};
|
|
89
|
-
this.clearSession();
|
|
90
|
-
}
|
|
91
|
-
this._initialized = true;
|
|
92
|
-
this._error = null;
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
this.handleError(error);
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
this._loading = false;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async loadUserData(uid) {
|
|
102
|
-
const docRef = doc(firebaseService.getDb(), "users", uid);
|
|
103
|
-
const docSnap = await getDoc(docRef);
|
|
104
|
-
if (docSnap.exists()) {
|
|
105
|
-
this._userData = docSnap.data();
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
const initialData = {
|
|
109
|
-
displayName: this._user?.displayName || "",
|
|
110
|
-
email: this._user?.email || "",
|
|
111
|
-
photoURL: this._user?.photoURL || "",
|
|
112
|
-
createdAt: new Date(),
|
|
113
|
-
updatedAt: new Date(),
|
|
114
|
-
isProfileComplete: false,
|
|
115
|
-
};
|
|
116
|
-
await this.saveUserData(initialData);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async loadUserClaims(user) {
|
|
120
|
-
const tokenResult = await user.getIdTokenResult();
|
|
121
|
-
this._claims = tokenResult.claims;
|
|
122
|
-
}
|
|
123
|
-
setupActivityTracking() {
|
|
124
|
-
if (browser) {
|
|
125
|
-
['mousedown', 'keydown', 'scroll', 'touchstart'].forEach(eventName => {
|
|
126
|
-
window.addEventListener(eventName, () => this.updateLastActivity());
|
|
127
|
-
});
|
|
128
|
-
this.activityInterval = setInterval(() => this.checkSession(), 60000);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
initializeSession() {
|
|
132
|
-
this._currentSession = {
|
|
133
|
-
lastActivity: Date.now(),
|
|
134
|
-
deviceId: this.generateDeviceId(),
|
|
135
|
-
platform: this.getPlatformInfo()
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
updateLastActivity() {
|
|
139
|
-
if (this._currentSession) {
|
|
140
|
-
this._currentSession.lastActivity = Date.now();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async checkSession() {
|
|
144
|
-
if (!this._currentSession)
|
|
145
|
-
return;
|
|
146
|
-
const inactiveTime = Date.now() - this._currentSession.lastActivity;
|
|
147
|
-
if (inactiveTime > this.SESSION_TIMEOUT) {
|
|
148
|
-
await this.handleSessionTimeout();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
async handleSessionTimeout() {
|
|
152
|
-
toast.warning('Session expired due to inactivity', {
|
|
153
|
-
description: 'Please log in again to continue.',
|
|
154
|
-
duration: 5000
|
|
155
|
-
});
|
|
156
|
-
await this.logOut();
|
|
157
|
-
}
|
|
158
|
-
clearSession() {
|
|
159
|
-
this._currentSession = null;
|
|
160
|
-
if (this.activityInterval) {
|
|
161
|
-
clearInterval(this.activityInterval);
|
|
162
|
-
this.activityInterval = null;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
handleError(error) {
|
|
166
|
-
const authError = error instanceof AuthError
|
|
167
|
-
? error
|
|
168
|
-
: new AuthError(error instanceof Error ? error.message : 'An unknown error occurred', 'unknown', error instanceof Error ? error : undefined);
|
|
169
|
-
this._error = authError;
|
|
170
|
-
this._loading = false;
|
|
171
|
-
console.error('[FirekitAuthManager]', authError);
|
|
172
|
-
}
|
|
173
|
-
generateDeviceId() {
|
|
174
|
-
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
175
|
-
}
|
|
176
|
-
getPlatformInfo() {
|
|
177
|
-
if (!browser)
|
|
178
|
-
return 'server';
|
|
179
|
-
return `${navigator.platform} - ${navigator.userAgent}`;
|
|
180
|
-
}
|
|
181
|
-
validateClaims(requiredClaims, userClaims) {
|
|
182
|
-
return requiredClaims.every(claim => userClaims[claim]);
|
|
183
|
-
}
|
|
184
|
-
async handleRedirect(redirectTo, params) {
|
|
185
|
-
const url = new URL(redirectTo, window.location.origin);
|
|
186
|
-
if (params) {
|
|
187
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
188
|
-
url.searchParams.append(key, value);
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
await goto(url.toString());
|
|
192
|
-
}
|
|
193
|
-
// Public Methods
|
|
194
|
-
async validateAuth({ authRequired = true, redirectTo = "/login", requiredClaims = [], requiredData, allowIf, redirectParams, } = {}) {
|
|
195
|
-
if (!browser)
|
|
196
|
-
return true;
|
|
197
|
-
const now = Date.now();
|
|
198
|
-
if (now - this._lastValidationTime < 1000)
|
|
199
|
-
return false;
|
|
200
|
-
this._lastValidationTime = now;
|
|
201
|
-
try {
|
|
202
|
-
this._loading = true;
|
|
203
|
-
this._error = null;
|
|
204
|
-
await this.waitForInit();
|
|
205
|
-
// Basic auth validation
|
|
206
|
-
if (authRequired && !this._user) {
|
|
207
|
-
await this.handleRedirect(redirectTo, {
|
|
208
|
-
...redirectParams,
|
|
209
|
-
returnTo: window.location.pathname,
|
|
210
|
-
});
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
if (!authRequired && this._user) {
|
|
214
|
-
await this.handleRedirect(redirectTo, redirectParams);
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
// Custom conditions
|
|
218
|
-
if (allowIf && !allowIf(this)) {
|
|
219
|
-
await this.handleRedirect(redirectTo, redirectParams);
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
// Claims validation
|
|
223
|
-
if (requiredClaims.length > 0 && !this.validateClaims(requiredClaims, this._claims)) {
|
|
224
|
-
await this.handleRedirect(redirectTo, redirectParams);
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
// Data validation
|
|
228
|
-
if (requiredData && !requiredData(this._userData)) {
|
|
229
|
-
await this.handleRedirect(redirectTo, redirectParams);
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
this.handleError(error);
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
finally {
|
|
239
|
-
this._loading = false;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
async updateEmailUser(email) {
|
|
243
|
-
if (!this._user)
|
|
244
|
-
throw new AuthError("No authenticated user", "no_user");
|
|
245
|
-
try {
|
|
246
|
-
await updateEmail(this._user, email);
|
|
247
|
-
await this.updateUserData({ email });
|
|
248
|
-
toast.success("Email updated successfully!", {
|
|
249
|
-
description: "Please note that you will be logged out, and you will need to log in again using your new email address.",
|
|
250
|
-
});
|
|
251
|
-
setTimeout(async () => {
|
|
252
|
-
await this.logOut();
|
|
253
|
-
}, 4500);
|
|
254
|
-
}
|
|
255
|
-
catch (error) {
|
|
256
|
-
this.handleError(error);
|
|
257
|
-
throw error;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
async updatePassword(password) {
|
|
261
|
-
if (!this._user)
|
|
262
|
-
throw new AuthError("No authenticated user", "no_user");
|
|
263
|
-
try {
|
|
264
|
-
await updatePassword(this._user, password);
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
this.handleError(error);
|
|
268
|
-
throw error;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
async updateProfileInfo({ displayName, photoURL, }) {
|
|
272
|
-
if (!this._user)
|
|
273
|
-
throw new AuthError("No authenticated user", "no_user");
|
|
274
|
-
if (!displayName && !photoURL)
|
|
275
|
-
return;
|
|
276
|
-
try {
|
|
277
|
-
if (displayName)
|
|
278
|
-
await updateProfile(this._user, { displayName });
|
|
279
|
-
if (photoURL)
|
|
280
|
-
await updateProfile(this._user, { photoURL });
|
|
281
|
-
await this.updateUserData({ displayName, photoURL });
|
|
282
|
-
}
|
|
283
|
-
catch (error) {
|
|
284
|
-
this.handleError(error);
|
|
285
|
-
throw error;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
async updateUserData(data) {
|
|
289
|
-
if (!this._user?.uid)
|
|
290
|
-
throw new AuthError("No authenticated user", "no_user");
|
|
291
|
-
try {
|
|
292
|
-
const docRef = doc(firebaseService.getDb(), "users", this._user.uid);
|
|
293
|
-
const updateData = { ...data, updatedAt: new Date() };
|
|
294
|
-
await updateDoc(docRef, updateData);
|
|
295
|
-
await this.loadUserData(this._user.uid);
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
this.handleError(error);
|
|
299
|
-
throw error;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
async saveUserData(data) {
|
|
303
|
-
if (!this._user?.uid)
|
|
304
|
-
throw new AuthError("No authenticated user", "no_user");
|
|
305
|
-
try {
|
|
306
|
-
const docRef = doc(firebaseService.getDb(), "users", this._user.uid);
|
|
307
|
-
const saveData = {
|
|
308
|
-
...data,
|
|
309
|
-
createdAt: data.createdAt || new Date(),
|
|
310
|
-
updatedAt: new Date(),
|
|
311
|
-
};
|
|
312
|
-
await setDoc(docRef, saveData);
|
|
313
|
-
await this.loadUserData(this._user.uid);
|
|
314
|
-
}
|
|
315
|
-
catch (error) {
|
|
316
|
-
this.handleError(error);
|
|
317
|
-
throw error;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
async sendVerificationEmail() {
|
|
321
|
-
if (!this._user)
|
|
322
|
-
throw new AuthError('No authenticated user', 'no_user');
|
|
323
|
-
try {
|
|
324
|
-
await sendEmailVerification(this._user);
|
|
325
|
-
toast.success('Verification email sent!');
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
this.handleError(error);
|
|
329
|
-
throw error;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
async refreshUserData() {
|
|
333
|
-
if (!this._user)
|
|
334
|
-
return;
|
|
335
|
-
try {
|
|
336
|
-
await Promise.all([
|
|
337
|
-
this.loadUserData(this._user.uid),
|
|
338
|
-
this.loadUserClaims(this._user)
|
|
339
|
-
]);
|
|
340
|
-
}
|
|
341
|
-
catch (error) {
|
|
342
|
-
this.handleError(error);
|
|
343
|
-
throw error;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
// Helper methods
|
|
347
|
-
hasRequiredClaims(requiredClaims) {
|
|
348
|
-
return requiredClaims.every((claim) => this._claims[claim]);
|
|
349
|
-
}
|
|
350
|
-
isAdmin() {
|
|
351
|
-
return Boolean(this._claims.admin);
|
|
352
|
-
}
|
|
353
|
-
isPremium() {
|
|
354
|
-
return Boolean(this._claims.premium);
|
|
355
|
-
}
|
|
356
|
-
async requireClaims(claims, redirectTo = "/login", redirectParams) {
|
|
357
|
-
return this.validateAuth({
|
|
358
|
-
requiredClaims: claims,
|
|
359
|
-
redirectTo,
|
|
360
|
-
redirectParams,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
async requireData(validator, redirectTo = "/login", redirectParams) {
|
|
364
|
-
return this.validateAuth({
|
|
365
|
-
requiredData: validator,
|
|
366
|
-
redirectTo,
|
|
367
|
-
redirectParams,
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
async logOut() {
|
|
371
|
-
try {
|
|
372
|
-
await firebaseService.getAuthInstance().signOut();
|
|
373
|
-
this.clearSession();
|
|
374
|
-
}
|
|
375
|
-
catch (error) {
|
|
376
|
-
this.handleError(error);
|
|
377
|
-
throw error;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
// Cleanup
|
|
381
|
-
destroy() {
|
|
382
|
-
this.clearSession();
|
|
383
|
-
// Additional cleanup if needed
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
export const firekitAuthManager = FirekitAuthManager.getInstance();
|