@better-auth-ui/react 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth/auth-provider.d.ts +23 -8
- package/dist/components/auth/auth-provider.js +35 -19
- package/dist/components/{email → auth/email}/email-changed.js +2 -2
- package/dist/components/{email → auth/email}/email-localization.js +1 -1
- package/dist/components/{email → auth/email}/email-styles.js +1 -1
- package/dist/components/{email → auth/email}/email-verification.js +2 -2
- package/dist/components/{email → auth/email}/magic-link.js +2 -2
- package/dist/components/{email → auth/email}/new-device.js +2 -2
- package/dist/components/{email → auth/email}/otp-email.js +2 -2
- package/dist/components/{email → auth/email}/password-changed.js +2 -2
- package/dist/components/{email → auth/email}/reset-password.js +2 -2
- package/dist/components/auth/fetch-options-provider.d.ts +19 -0
- package/dist/components/auth/fetch-options-provider.js +30 -0
- package/dist/email.d.ts +1 -0
- package/dist/email.js +11 -0
- package/dist/hooks/auth/use-authenticate.d.ts +5 -28
- package/dist/hooks/auth/use-authenticate.js +12 -12
- package/dist/hooks/auth/use-user.d.ts +19 -314
- package/dist/hooks/auth/use-user.js +5 -5
- package/dist/hooks/use-auth-mutation.d.ts +12 -7
- package/dist/hooks/use-auth-plugin.d.ts +31 -0
- package/dist/hooks/use-auth-plugin.js +10 -0
- package/dist/hooks/use-auth-query.d.ts +3 -3
- package/dist/index.d.ts +34 -32
- package/dist/index.js +75 -83
- package/dist/lib/auth-client.d.ts +23 -3687
- package/dist/lib/auth-plugin.d.ts +61 -0
- package/dist/lib/auth-server.d.ts +16 -0
- package/dist/mutations/auth/request-password-reset-mutation.d.ts +26 -0
- package/dist/mutations/auth/request-password-reset-mutation.js +24 -0
- package/dist/mutations/auth/reset-password-mutation.d.ts +25 -0
- package/dist/mutations/auth/reset-password-mutation.js +24 -0
- package/dist/mutations/auth/send-verification-email-mutation.d.ts +24 -0
- package/dist/mutations/auth/send-verification-email-mutation.js +24 -0
- package/dist/mutations/auth/sign-in-email-mutation.d.ts +71 -0
- package/dist/mutations/auth/sign-in-email-mutation.js +29 -0
- package/dist/mutations/auth/sign-in-social-mutation.d.ts +77 -0
- package/dist/mutations/auth/sign-in-social-mutation.js +24 -0
- package/dist/mutations/auth/sign-out-mutation.d.ts +25 -0
- package/dist/mutations/auth/sign-out-mutation.js +28 -0
- package/dist/mutations/auth/sign-up-email-mutation.d.ts +105 -0
- package/dist/mutations/auth/sign-up-email-mutation.js +29 -0
- package/dist/mutations/auth-mutation-options.d.ts +37 -20
- package/dist/mutations/auth-mutation-options.js +2 -2
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.d.ts +24 -0
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.js +24 -0
- package/dist/mutations/multi-session/revoke-multi-session-mutation.d.ts +25 -0
- package/dist/mutations/multi-session/revoke-multi-session-mutation.js +29 -0
- package/dist/mutations/multi-session/set-active-session-mutation.d.ts +62 -0
- package/dist/mutations/multi-session/set-active-session-mutation.js +31 -0
- package/dist/mutations/passkey/add-passkey-mutation.d.ts +71 -0
- package/dist/mutations/passkey/add-passkey-mutation.js +29 -0
- package/dist/mutations/passkey/delete-passkey-mutation.d.ts +25 -0
- package/dist/mutations/passkey/delete-passkey-mutation.js +29 -0
- package/dist/mutations/passkey/sign-in-passkey-mutation.d.ts +105 -0
- package/dist/mutations/passkey/sign-in-passkey-mutation.js +29 -0
- package/dist/mutations/settings/change-email-mutation.d.ts +25 -0
- package/dist/mutations/settings/change-email-mutation.js +29 -0
- package/dist/mutations/settings/change-password-mutation.d.ts +78 -0
- package/dist/mutations/settings/change-password-mutation.js +24 -0
- package/dist/mutations/settings/delete-user-mutation.d.ts +26 -0
- package/dist/mutations/settings/delete-user-mutation.js +24 -0
- package/dist/mutations/settings/link-social-mutation.d.ts +26 -0
- package/dist/mutations/settings/link-social-mutation.js +24 -0
- package/dist/mutations/settings/revoke-session-mutation.d.ts +25 -0
- package/dist/mutations/settings/revoke-session-mutation.js +29 -0
- package/dist/mutations/settings/unlink-account-mutation.d.ts +25 -0
- package/dist/mutations/settings/unlink-account-mutation.js +29 -0
- package/dist/mutations/settings/update-user-mutation.d.ts +25 -0
- package/dist/mutations/settings/update-user-mutation.js +35 -0
- package/dist/mutations/username/is-username-available-mutation.d.ts +27 -0
- package/dist/mutations/username/is-username-available-mutation.js +24 -0
- package/dist/mutations/username/sign-in-username-mutation.d.ts +75 -0
- package/dist/mutations/username/sign-in-username-mutation.js +29 -0
- package/dist/plugins/captcha-plugin.d.ts +29 -0
- package/dist/plugins/captcha-plugin.js +29 -0
- package/dist/plugins.d.ts +1 -0
- package/dist/plugins.js +3 -0
- package/dist/queries/auth/session-query.d.ts +71 -0
- package/dist/queries/auth/session-query.js +30 -0
- package/dist/queries/auth-query-options.d.ts +26 -15
- package/dist/queries/multi-session/list-device-sessions-query.d.ts +76 -0
- package/dist/queries/multi-session/list-device-sessions-query.js +31 -0
- package/dist/queries/passkey/list-passkeys-query.d.ts +74 -0
- package/dist/queries/passkey/list-passkeys-query.js +31 -0
- package/dist/queries/settings/account-info-query.d.ts +85 -0
- package/dist/queries/settings/account-info-query.js +31 -0
- package/dist/queries/settings/list-accounts-query.d.ts +76 -0
- package/dist/queries/settings/list-accounts-query.js +31 -0
- package/dist/queries/settings/list-sessions-query.d.ts +74 -0
- package/dist/queries/settings/list-sessions-query.js +31 -0
- package/dist/server/queries/auth/session-query.d.ts +57 -0
- package/dist/server/queries/auth/session-query.js +13 -0
- package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +60 -0
- package/dist/server/queries/multi-session/list-device-sessions-query.js +12 -0
- package/dist/server/queries/passkey/list-passkeys-query.d.ts +60 -0
- package/dist/server/queries/passkey/list-passkeys-query.js +12 -0
- package/dist/server/queries/settings/account-info-query.d.ts +68 -0
- package/dist/server/queries/settings/account-info-query.js +12 -0
- package/dist/server/queries/settings/list-accounts-query.d.ts +60 -0
- package/dist/server/queries/settings/list-accounts-query.js +12 -0
- package/dist/server/queries/settings/list-sessions-query.d.ts +60 -0
- package/dist/server/queries/settings/list-sessions-query.js +12 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +7 -0
- package/package.json +28 -22
- package/src/components/auth/auth-provider.tsx +88 -25
- package/src/components/{email → auth/email}/email-changed.tsx +1 -1
- package/src/components/{email → auth/email}/email-verification.tsx +1 -1
- package/src/components/{email → auth/email}/magic-link.tsx +1 -1
- package/src/components/{email → auth/email}/new-device.tsx +1 -1
- package/src/components/{email → auth/email}/otp-email.tsx +1 -1
- package/src/components/{email → auth/email}/password-changed.tsx +1 -1
- package/src/components/{email → auth/email}/reset-password.tsx +1 -1
- package/src/components/auth/fetch-options-provider.tsx +77 -0
- package/src/email.ts +1 -0
- package/src/hooks/auth/use-authenticate.ts +12 -6
- package/src/hooks/auth/use-user.ts +14 -9
- package/src/hooks/use-auth-mutation.ts +30 -12
- package/src/hooks/use-auth-plugin.ts +50 -0
- package/src/hooks/use-auth-query.ts +11 -7
- package/src/index.ts +34 -32
- package/src/lib/auth-client.ts +33 -31
- package/src/lib/auth-plugin.ts +77 -0
- package/src/lib/auth-server.ts +30 -0
- package/src/mutations/auth/request-password-reset-mutation.ts +58 -0
- package/src/mutations/auth/reset-password-mutation.ts +60 -0
- package/src/mutations/auth/send-verification-email-mutation.ts +58 -0
- package/src/mutations/auth/sign-in-email-mutation.ts +78 -0
- package/src/mutations/auth/sign-in-social-mutation.ts +64 -0
- package/src/mutations/auth/sign-out-mutation.ts +71 -0
- package/src/mutations/auth/sign-up-email-mutation.ts +74 -0
- package/src/mutations/auth-mutation-options.ts +83 -38
- package/src/mutations/magic-link/sign-in-magic-link-mutation.ts +59 -0
- package/src/mutations/multi-session/revoke-multi-session-mutation.ts +70 -0
- package/src/mutations/multi-session/set-active-session-mutation.ts +98 -0
- package/src/mutations/passkey/add-passkey-mutation.ts +66 -0
- package/src/mutations/passkey/delete-passkey-mutation.ts +66 -0
- package/src/mutations/passkey/sign-in-passkey-mutation.ts +74 -0
- package/src/mutations/settings/change-email-mutation.ts +67 -0
- package/src/mutations/settings/change-password-mutation.ts +59 -0
- package/src/mutations/settings/delete-user-mutation.ts +59 -0
- package/src/mutations/settings/link-social-mutation.ts +59 -0
- package/src/mutations/settings/revoke-session-mutation.ts +69 -0
- package/src/mutations/settings/unlink-account-mutation.ts +67 -0
- package/src/mutations/settings/update-user-mutation.ts +82 -0
- package/src/mutations/username/is-username-available-mutation.ts +62 -0
- package/src/mutations/username/sign-in-username-mutation.ts +74 -0
- package/src/plugins/captcha-plugin.tsx +75 -0
- package/src/plugins.ts +3 -0
- package/src/queries/auth/session-query.ts +135 -0
- package/src/queries/auth-query-options.ts +61 -12
- package/src/queries/multi-session/list-device-sessions-query.ts +177 -0
- package/src/queries/passkey/list-passkeys-query.ts +154 -0
- package/src/queries/settings/account-info-query.ts +158 -0
- package/src/queries/settings/list-accounts-query.ts +156 -0
- package/src/queries/settings/list-sessions-query.ts +154 -0
- package/src/server/queries/auth/session-query.ts +94 -0
- package/src/server/queries/multi-session/list-device-sessions-query.ts +102 -0
- package/src/server/queries/passkey/list-passkeys-query.ts +100 -0
- package/src/server/queries/settings/account-info-query.ts +101 -0
- package/src/server/queries/settings/list-accounts-query.ts +101 -0
- package/src/server/queries/settings/list-sessions-query.ts +101 -0
- package/src/server.ts +7 -0
- package/dist/core.d.ts +0 -1
- package/dist/core.js +0 -1
- package/dist/hooks/auth/use-is-username-available.d.ts +0 -20
- package/dist/hooks/auth/use-is-username-available.js +0 -13
- package/dist/hooks/auth/use-request-password-reset.d.ts +0 -21
- package/dist/hooks/auth/use-request-password-reset.js +0 -13
- package/dist/hooks/auth/use-reset-password.d.ts +0 -23
- package/dist/hooks/auth/use-reset-password.js +0 -13
- package/dist/hooks/auth/use-send-verification-email.d.ts +0 -19
- package/dist/hooks/auth/use-send-verification-email.js +0 -13
- package/dist/hooks/auth/use-session.d.ts +0 -35
- package/dist/hooks/auth/use-session.js +0 -16
- package/dist/hooks/auth/use-sign-in-email.d.ts +0 -26
- package/dist/hooks/auth/use-sign-in-email.js +0 -17
- package/dist/hooks/auth/use-sign-in-magic-link.d.ts +0 -27
- package/dist/hooks/auth/use-sign-in-magic-link.js +0 -13
- package/dist/hooks/auth/use-sign-in-passkey.d.ts +0 -21
- package/dist/hooks/auth/use-sign-in-passkey.js +0 -17
- package/dist/hooks/auth/use-sign-in-social.d.ts +0 -63
- package/dist/hooks/auth/use-sign-in-social.js +0 -13
- package/dist/hooks/auth/use-sign-in-username.d.ts +0 -25
- package/dist/hooks/auth/use-sign-in-username.js +0 -17
- package/dist/hooks/auth/use-sign-out.d.ts +0 -18
- package/dist/hooks/auth/use-sign-out.js +0 -16
- package/dist/hooks/auth/use-sign-up-email.d.ts +0 -1186
- package/dist/hooks/auth/use-sign-up-email.js +0 -17
- package/dist/hooks/settings/use-account-info.d.ts +0 -17
- package/dist/hooks/settings/use-account-info.js +0 -18
- package/dist/hooks/settings/use-add-passkey.d.ts +0 -21
- package/dist/hooks/settings/use-add-passkey.js +0 -17
- package/dist/hooks/settings/use-change-email.d.ts +0 -21
- package/dist/hooks/settings/use-change-email.js +0 -17
- package/dist/hooks/settings/use-change-password.d.ts +0 -21
- package/dist/hooks/settings/use-change-password.js +0 -13
- package/dist/hooks/settings/use-delete-passkey.d.ts +0 -19
- package/dist/hooks/settings/use-delete-passkey.js +0 -17
- package/dist/hooks/settings/use-delete-user.d.ts +0 -24
- package/dist/hooks/settings/use-delete-user.js +0 -13
- package/dist/hooks/settings/use-link-social.d.ts +0 -43
- package/dist/hooks/settings/use-link-social.js +0 -13
- package/dist/hooks/settings/use-list-accounts.d.ts +0 -22
- package/dist/hooks/settings/use-list-accounts.js +0 -15
- package/dist/hooks/settings/use-list-device-sessions.d.ts +0 -34
- package/dist/hooks/settings/use-list-device-sessions.js +0 -15
- package/dist/hooks/settings/use-list-sessions.d.ts +0 -23
- package/dist/hooks/settings/use-list-sessions.js +0 -15
- package/dist/hooks/settings/use-list-user-passkeys.d.ts +0 -14
- package/dist/hooks/settings/use-list-user-passkeys.js +0 -15
- package/dist/hooks/settings/use-revoke-multi-session.d.ts +0 -19
- package/dist/hooks/settings/use-revoke-multi-session.js +0 -17
- package/dist/hooks/settings/use-revoke-session.d.ts +0 -19
- package/dist/hooks/settings/use-revoke-session.js +0 -17
- package/dist/hooks/settings/use-set-active-session.d.ts +0 -20
- package/dist/hooks/settings/use-set-active-session.js +0 -20
- package/dist/hooks/settings/use-unlink-account.d.ts +0 -21
- package/dist/hooks/settings/use-unlink-account.js +0 -17
- package/dist/hooks/settings/use-update-user.d.ts +0 -1185
- package/dist/hooks/settings/use-update-user.js +0 -24
- package/dist/lib/auth-client.js +0 -11
- package/dist/lib/auth-config.d.ts +0 -43
- package/dist/lib/auth-context.d.ts +0 -2
- package/dist/lib/auth-context.js +0 -6
- package/dist/mutations/auth/is-username-available-options.d.ts +0 -19
- package/dist/mutations/auth/is-username-available-options.js +0 -7
- package/dist/mutations/auth/request-password-reset-options.d.ts +0 -15
- package/dist/mutations/auth/request-password-reset-options.js +0 -7
- package/dist/mutations/auth/reset-password-options.d.ts +0 -17
- package/dist/mutations/auth/reset-password-options.js +0 -7
- package/dist/mutations/auth/send-verification-email-options.d.ts +0 -15
- package/dist/mutations/auth/send-verification-email-options.js +0 -7
- package/dist/mutations/auth/sign-in-email-options.d.ts +0 -23
- package/dist/mutations/auth/sign-in-email-options.js +0 -11
- package/dist/mutations/auth/sign-in-magic-link-options.d.ts +0 -23
- package/dist/mutations/auth/sign-in-magic-link-options.js +0 -11
- package/dist/mutations/auth/sign-in-passkey-options.d.ts +0 -15
- package/dist/mutations/auth/sign-in-passkey-options.js +0 -11
- package/dist/mutations/auth/sign-in-social-options.d.ts +0 -61
- package/dist/mutations/auth/sign-in-social-options.js +0 -11
- package/dist/mutations/auth/sign-in-username-options.d.ts +0 -19
- package/dist/mutations/auth/sign-in-username-options.js +0 -11
- package/dist/mutations/auth/sign-out-options.d.ts +0 -12
- package/dist/mutations/auth/sign-out-options.js +0 -7
- package/dist/mutations/auth/sign-up-email-options.d.ts +0 -1180
- package/dist/mutations/auth/sign-up-email-options.js +0 -11
- package/dist/mutations/settings/add-passkey-options.d.ts +0 -15
- package/dist/mutations/settings/add-passkey-options.js +0 -11
- package/dist/mutations/settings/change-email-options.d.ts +0 -15
- package/dist/mutations/settings/change-email-options.js +0 -7
- package/dist/mutations/settings/change-password-options.d.ts +0 -17
- package/dist/mutations/settings/change-password-options.js +0 -7
- package/dist/mutations/settings/delete-passkey-options.d.ts +0 -13
- package/dist/mutations/settings/delete-passkey-options.js +0 -11
- package/dist/mutations/settings/delete-user-options.d.ts +0 -20
- package/dist/mutations/settings/delete-user-options.js +0 -7
- package/dist/mutations/settings/link-social-options.d.ts +0 -39
- package/dist/mutations/settings/link-social-options.js +0 -7
- package/dist/mutations/settings/revoke-multi-session-options.d.ts +0 -13
- package/dist/mutations/settings/revoke-multi-session-options.js +0 -11
- package/dist/mutations/settings/revoke-session-options.d.ts +0 -13
- package/dist/mutations/settings/revoke-session-options.js +0 -7
- package/dist/mutations/settings/set-active-session-options.d.ts +0 -13
- package/dist/mutations/settings/set-active-session-options.js +0 -11
- package/dist/mutations/settings/unlink-account-options.d.ts +0 -15
- package/dist/mutations/settings/unlink-account-options.js +0 -7
- package/dist/mutations/settings/update-user-options.d.ts +0 -1182
- package/dist/mutations/settings/update-user-options.js +0 -7
- package/dist/queries/auth/session-options.d.ts +0 -110
- package/dist/queries/auth/session-options.js +0 -7
- package/dist/queries/settings/account-info-options.d.ts +0 -32
- package/dist/queries/settings/account-info-options.js +0 -12
- package/dist/queries/settings/list-accounts-options.d.ts +0 -53
- package/dist/queries/settings/list-accounts-options.js +0 -12
- package/dist/queries/settings/list-device-sessions-options.d.ts +0 -99
- package/dist/queries/settings/list-device-sessions-options.js +0 -12
- package/dist/queries/settings/list-sessions-options.d.ts +0 -54
- package/dist/queries/settings/list-sessions-options.js +0 -12
- package/dist/queries/settings/list-user-passkeys-options.d.ts +0 -18
- package/dist/queries/settings/list-user-passkeys-options.js +0 -12
- package/src/core.ts +0 -1
- package/src/hooks/auth/use-is-username-available.ts +0 -31
- package/src/hooks/auth/use-request-password-reset.ts +0 -33
- package/src/hooks/auth/use-reset-password.ts +0 -31
- package/src/hooks/auth/use-send-verification-email.ts +0 -31
- package/src/hooks/auth/use-session.ts +0 -31
- package/src/hooks/auth/use-sign-in-email.ts +0 -41
- package/src/hooks/auth/use-sign-in-magic-link.ts +0 -29
- package/src/hooks/auth/use-sign-in-passkey.ts +0 -40
- package/src/hooks/auth/use-sign-in-social.ts +0 -31
- package/src/hooks/auth/use-sign-in-username.ts +0 -40
- package/src/hooks/auth/use-sign-out.ts +0 -34
- package/src/hooks/auth/use-sign-up-email.ts +0 -40
- package/src/hooks/settings/use-account-info.ts +0 -40
- package/src/hooks/settings/use-add-passkey.ts +0 -37
- package/src/hooks/settings/use-change-email.ts +0 -37
- package/src/hooks/settings/use-change-password.ts +0 -29
- package/src/hooks/settings/use-delete-passkey.ts +0 -37
- package/src/hooks/settings/use-delete-user.ts +0 -29
- package/src/hooks/settings/use-link-social.ts +0 -29
- package/src/hooks/settings/use-list-accounts.ts +0 -39
- package/src/hooks/settings/use-list-device-sessions.ts +0 -39
- package/src/hooks/settings/use-list-sessions.ts +0 -39
- package/src/hooks/settings/use-list-user-passkeys.ts +0 -39
- package/src/hooks/settings/use-revoke-multi-session.ts +0 -39
- package/src/hooks/settings/use-revoke-session.ts +0 -39
- package/src/hooks/settings/use-set-active-session.ts +0 -58
- package/src/hooks/settings/use-unlink-account.ts +0 -37
- package/src/hooks/settings/use-update-user.ts +0 -50
- package/src/lib/auth-config.ts +0 -48
- package/src/lib/auth-context.ts +0 -6
- package/src/mutations/auth/is-username-available-options.ts +0 -18
- package/src/mutations/auth/request-password-reset-options.ts +0 -14
- package/src/mutations/auth/reset-password-options.ts +0 -14
- package/src/mutations/auth/send-verification-email-options.ts +0 -14
- package/src/mutations/auth/sign-in-email-options.ts +0 -19
- package/src/mutations/auth/sign-in-magic-link-options.ts +0 -15
- package/src/mutations/auth/sign-in-passkey-options.ts +0 -15
- package/src/mutations/auth/sign-in-social-options.ts +0 -19
- package/src/mutations/auth/sign-in-username-options.ts +0 -15
- package/src/mutations/auth/sign-out-options.ts +0 -11
- package/src/mutations/auth/sign-up-email-options.ts +0 -15
- package/src/mutations/settings/add-passkey-options.ts +0 -15
- package/src/mutations/settings/change-email-options.ts +0 -11
- package/src/mutations/settings/change-password-options.ts +0 -14
- package/src/mutations/settings/delete-passkey-options.ts +0 -15
- package/src/mutations/settings/delete-user-options.ts +0 -11
- package/src/mutations/settings/link-social-options.ts +0 -11
- package/src/mutations/settings/revoke-multi-session-options.ts +0 -15
- package/src/mutations/settings/revoke-session-options.ts +0 -14
- package/src/mutations/settings/set-active-session-options.ts +0 -15
- package/src/mutations/settings/unlink-account-options.ts +0 -14
- package/src/mutations/settings/update-user-options.ts +0 -15
- package/src/queries/auth/session-options.ts +0 -18
- package/src/queries/settings/account-info-options.ts +0 -25
- package/src/queries/settings/list-accounts-options.ts +0 -26
- package/src/queries/settings/list-device-sessions-options.ts +0 -24
- package/src/queries/settings/list-sessions-options.ts +0 -23
- package/src/queries/settings/list-user-passkeys-options.ts +0 -23
- /package/dist/components/{email → auth/email}/email-changed.d.ts +0 -0
- /package/dist/components/{email → auth/email}/email-localization.d.ts +0 -0
- /package/dist/components/{email → auth/email}/email-styles.d.ts +0 -0
- /package/dist/components/{email → auth/email}/email-verification.d.ts +0 -0
- /package/dist/components/{email → auth/email}/index.d.ts +0 -0
- /package/dist/components/{email → auth/email}/index.js +0 -0
- /package/dist/components/{email → auth/email}/magic-link.d.ts +0 -0
- /package/dist/components/{email → auth/email}/new-device.d.ts +0 -0
- /package/dist/components/{email → auth/email}/otp-email.d.ts +0 -0
- /package/dist/components/{email → auth/email}/password-changed.d.ts +0 -0
- /package/dist/components/{email → auth/email}/reset-password.d.ts +0 -0
- /package/src/components/{email → auth/email}/email-localization.tsx +0 -0
- /package/src/components/{email → auth/email}/email-styles.tsx +0 -0
- /package/src/components/{email → auth/email}/index.ts +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth-ui/react",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
7
|
-
"dev": "
|
|
8
|
-
"email": "email dev --dir src/components/email -p 9000",
|
|
7
|
+
"dev": "vite build --watch",
|
|
8
|
+
"email": "email dev --dir src/components/auth/email -p 9000",
|
|
9
9
|
"test": "vitest"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
@@ -19,46 +19,52 @@
|
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"import": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
-
"./
|
|
23
|
-
"types": "./dist/
|
|
24
|
-
"import": "./dist/
|
|
22
|
+
"./email": {
|
|
23
|
+
"types": "./dist/email.d.ts",
|
|
24
|
+
"import": "./dist/email.js"
|
|
25
|
+
},
|
|
26
|
+
"./server": {
|
|
27
|
+
"types": "./dist/server.d.ts",
|
|
28
|
+
"import": "./dist/server.js"
|
|
29
|
+
},
|
|
30
|
+
"./plugins": {
|
|
31
|
+
"types": "./dist/plugins.d.ts",
|
|
32
|
+
"import": "./dist/plugins.js"
|
|
25
33
|
}
|
|
26
34
|
},
|
|
27
35
|
"devDependencies": {
|
|
36
|
+
"@better-auth/passkey": "^1.6.9",
|
|
28
37
|
"@react-email/components": "^1.0.12",
|
|
29
38
|
"@react-email/preview-server": "^5.2.10",
|
|
30
|
-
"@tanstack/react-query": "^5.
|
|
39
|
+
"@tanstack/react-query": "^5.100.8",
|
|
31
40
|
"@testing-library/react": "^16.3.2",
|
|
32
41
|
"@testing-library/user-event": "^14.5.2",
|
|
33
42
|
"@types/react": "^19.2.14",
|
|
34
43
|
"@vitejs/plugin-react": "^6.0.1",
|
|
35
|
-
"@vitest/browser-playwright": "^4.1.
|
|
36
|
-
"
|
|
37
|
-
"better-auth": "^1.6.5",
|
|
44
|
+
"@vitest/browser-playwright": "^4.1.5",
|
|
45
|
+
"better-auth": "^1.6.9",
|
|
38
46
|
"clsx": "^2.1.1",
|
|
39
47
|
"playwright": "^1.59.1",
|
|
40
48
|
"react": "^19.2.5",
|
|
41
49
|
"react-dom": "^19.2.5",
|
|
42
|
-
"react-email": "^6.0.
|
|
50
|
+
"react-email": "^6.0.5",
|
|
43
51
|
"tailwind-merge": "^3.5.0",
|
|
44
|
-
"tailwindcss": "^4.2.
|
|
45
|
-
"vitest": "^4.1.
|
|
46
|
-
"zod": "^4.
|
|
47
|
-
},
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"@better-auth-ui/core": "*"
|
|
52
|
+
"tailwindcss": "^4.2.4",
|
|
53
|
+
"vitest": "^4.1.5",
|
|
54
|
+
"zod": "^4.4.2"
|
|
50
55
|
},
|
|
51
56
|
"peerDependencies": {
|
|
57
|
+
"@better-auth-ui/core": "*",
|
|
58
|
+
"@better-auth/passkey": ">=1.6.9",
|
|
52
59
|
"@react-email/components": ">=1.0.12",
|
|
53
|
-
"@tanstack/react-query": ">=5.
|
|
54
|
-
"
|
|
55
|
-
"better-auth": ">=1.6.5",
|
|
60
|
+
"@tanstack/react-query": ">=5.100.8",
|
|
61
|
+
"better-auth": ">=1.6.9",
|
|
56
62
|
"clsx": ">=2.0.0",
|
|
57
63
|
"react": ">=19.2.5",
|
|
58
64
|
"react-dom": ">=19.2.5",
|
|
59
65
|
"tailwind-merge": ">=3.5.0",
|
|
60
|
-
"tailwindcss": ">=4.2.
|
|
61
|
-
"zod": ">=4.
|
|
66
|
+
"tailwindcss": ">=4.2.4",
|
|
67
|
+
"zod": ">=4.4.2"
|
|
62
68
|
},
|
|
63
69
|
"repository": {
|
|
64
70
|
"type": "git",
|
|
@@ -1,30 +1,57 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type AdditionalField,
|
|
5
|
+
type AuthConfig,
|
|
6
|
+
type DeepPartial,
|
|
7
|
+
deepmerge,
|
|
8
|
+
defaultAuthConfig
|
|
9
|
+
} from "@better-auth-ui/core"
|
|
4
10
|
import {
|
|
5
11
|
QueryClient,
|
|
6
12
|
QueryClientContext,
|
|
7
13
|
QueryClientProvider
|
|
8
14
|
} from "@tanstack/react-query"
|
|
9
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
createContext,
|
|
17
|
+
type PropsWithChildren,
|
|
18
|
+
type ReactNode,
|
|
19
|
+
useContext
|
|
20
|
+
} from "react"
|
|
21
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
22
|
+
import { FetchOptionsProvider } from "./fetch-options-provider"
|
|
10
23
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
const AuthContext = createContext<AuthConfig | undefined>(undefined)
|
|
25
|
+
|
|
26
|
+
const fallbackQueryClient = new QueryClient({
|
|
27
|
+
defaultOptions: {
|
|
28
|
+
queries: {
|
|
29
|
+
staleTime: 5000
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
14
33
|
|
|
15
|
-
|
|
34
|
+
declare module "@better-auth-ui/core" {
|
|
35
|
+
interface AuthConfig {
|
|
36
|
+
/**
|
|
37
|
+
* The auth client to use for the authentication context.
|
|
38
|
+
* @remarks `AuthClient`
|
|
39
|
+
*/
|
|
40
|
+
authClient: AuthClient
|
|
41
|
+
}
|
|
16
42
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
43
|
+
/** Widen `AdditionalField.label` to `ReactNode` in the React package. */
|
|
44
|
+
interface AdditionalFieldRegister {
|
|
45
|
+
label: ReactNode
|
|
46
|
+
}
|
|
20
47
|
}
|
|
21
48
|
|
|
22
|
-
export type AuthProviderProps =
|
|
23
|
-
|
|
49
|
+
export type AuthProviderProps<TAuthClient = AuthClient> = PropsWithChildren<
|
|
50
|
+
DeepPartial<AuthConfig>
|
|
51
|
+
> & {
|
|
52
|
+
authClient: TAuthClient
|
|
24
53
|
navigate: (options: { to: string; replace?: boolean }) => void
|
|
25
|
-
/**
|
|
26
|
-
* TanStack QueryClient to use for your application's queries
|
|
27
|
-
*/
|
|
54
|
+
/** TanStack QueryClient to use for your application's queries */
|
|
28
55
|
queryClient?: QueryClient
|
|
29
56
|
}
|
|
30
57
|
|
|
@@ -43,33 +70,69 @@ export function AuthProvider({
|
|
|
43
70
|
queryClient,
|
|
44
71
|
...config
|
|
45
72
|
}: AuthProviderProps) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
73
|
+
const mergedConfig = deepmerge(defaultAuthConfig, {
|
|
74
|
+
...config,
|
|
75
|
+
viewPaths: {
|
|
76
|
+
auth: {
|
|
77
|
+
...defaultAuthConfig.viewPaths.auth,
|
|
78
|
+
...config.viewPaths?.auth
|
|
79
|
+
},
|
|
80
|
+
settings: {
|
|
81
|
+
...defaultAuthConfig.viewPaths.settings,
|
|
82
|
+
...config.viewPaths?.settings
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} as AuthConfig)
|
|
51
86
|
|
|
52
87
|
mergedConfig.redirectTo =
|
|
53
88
|
(typeof window !== "undefined" &&
|
|
54
89
|
new URLSearchParams(window.location.search).get("redirectTo")?.trim()) ||
|
|
55
90
|
mergedConfig.redirectTo
|
|
56
91
|
|
|
92
|
+
// Merge plugin-contributed `additionalFields` with user-supplied ones.
|
|
93
|
+
// Plugin order is preserved; user-supplied entries with the same `name`
|
|
94
|
+
// override the plugin contribution.
|
|
95
|
+
const fieldsByName = new Map<string, AdditionalField>()
|
|
96
|
+
for (const plugin of mergedConfig.plugins ?? []) {
|
|
97
|
+
for (const field of plugin.additionalFields ?? []) {
|
|
98
|
+
fieldsByName.set(field.name, field)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const field of mergedConfig.additionalFields ?? []) {
|
|
102
|
+
fieldsByName.set(field.name, field)
|
|
103
|
+
}
|
|
104
|
+
mergedConfig.additionalFields = Array.from(fieldsByName.values())
|
|
105
|
+
|
|
106
|
+
const contextQueryClient = useContext(QueryClientContext)
|
|
107
|
+
|
|
108
|
+
if (contextQueryClient) {
|
|
109
|
+
return (
|
|
110
|
+
<AuthContext.Provider value={mergedConfig}>
|
|
111
|
+
<FetchOptionsProvider>{children}</FetchOptionsProvider>
|
|
112
|
+
</AuthContext.Provider>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
57
116
|
return (
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
{children}
|
|
61
|
-
</
|
|
62
|
-
</
|
|
117
|
+
<QueryClientProvider client={queryClient || fallbackQueryClient}>
|
|
118
|
+
<AuthContext.Provider value={mergedConfig}>
|
|
119
|
+
<FetchOptionsProvider>{children}</FetchOptionsProvider>
|
|
120
|
+
</AuthContext.Provider>
|
|
121
|
+
</QueryClientProvider>
|
|
63
122
|
)
|
|
64
123
|
}
|
|
65
124
|
|
|
66
125
|
/**
|
|
67
126
|
* Accesses the current authentication configuration from AuthContext.
|
|
68
127
|
*
|
|
128
|
+
* UI packages widen the plugin type globally via the `Register` interface
|
|
129
|
+
* (see module augmentation in `@better-auth-ui/heroui`), so callers don't
|
|
130
|
+
* need to pass a generic.
|
|
131
|
+
*
|
|
69
132
|
* @returns The merged authentication configuration provided by AuthProvider.
|
|
70
133
|
* @throws If no AuthProvider is present in the component tree.
|
|
71
134
|
*/
|
|
72
|
-
export function useAuth() {
|
|
135
|
+
export function useAuth(): AuthConfig {
|
|
73
136
|
const context = useContext(AuthContext)
|
|
74
137
|
|
|
75
138
|
if (!context) {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
type PropsWithChildren,
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react"
|
|
11
|
+
|
|
12
|
+
/** Subset of BetterFetchOptions we expose. Add fields as use-cases arise. */
|
|
13
|
+
export type FetchOptions = {
|
|
14
|
+
headers?: Record<string, string>
|
|
15
|
+
body?: Record<string, unknown>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type FetchOptionsContextValue = {
|
|
19
|
+
/** Current fetchOptions, or `undefined` when none are set. */
|
|
20
|
+
fetchOptions: FetchOptions | undefined
|
|
21
|
+
/** OVERRIDES the entire fetchOptions object. Pass `undefined` to clear. */
|
|
22
|
+
setFetchOptions: (fetchOptions: FetchOptions | undefined) => void
|
|
23
|
+
/** Clears `fetchOptions` and runs the registered reset (e.g. captcha widget). Call from form `onError`. */
|
|
24
|
+
resetFetchOptions: () => void
|
|
25
|
+
/** Register a reset handler. Used by `captchaPlugin`. Pass `null` to clear. */
|
|
26
|
+
registerReset: (reset: (() => void) | null) => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const FetchOptionsContext = createContext<FetchOptionsContextValue | undefined>(
|
|
30
|
+
undefined
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export function FetchOptionsProvider({ children }: PropsWithChildren) {
|
|
34
|
+
const [current, setCurrent] = useState<FetchOptions | undefined>(undefined)
|
|
35
|
+
const resetRef = useRef<(() => void) | null>(null)
|
|
36
|
+
|
|
37
|
+
const setFetchOptions = useCallback(
|
|
38
|
+
(fetchOptions: FetchOptions | undefined) => {
|
|
39
|
+
setCurrent(fetchOptions)
|
|
40
|
+
},
|
|
41
|
+
[]
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const registerReset = useCallback((reset: (() => void) | null) => {
|
|
45
|
+
resetRef.current = reset
|
|
46
|
+
}, [])
|
|
47
|
+
|
|
48
|
+
const resetFetchOptions = useCallback(() => {
|
|
49
|
+
setCurrent(undefined)
|
|
50
|
+
resetRef.current?.()
|
|
51
|
+
}, [])
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<FetchOptionsContext.Provider
|
|
55
|
+
value={{
|
|
56
|
+
fetchOptions: current,
|
|
57
|
+
setFetchOptions,
|
|
58
|
+
resetFetchOptions,
|
|
59
|
+
registerReset
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</FetchOptionsContext.Provider>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function useFetchOptions(): FetchOptionsContextValue {
|
|
68
|
+
const ctx = useContext(FetchOptionsContext)
|
|
69
|
+
|
|
70
|
+
if (!ctx) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
"[Better Auth UI] useFetchOptions must be used within FetchOptionsProvider"
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return ctx
|
|
77
|
+
}
|
package/src/email.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./components/auth/email"
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { useEffect } from "react"
|
|
2
2
|
import { useAuth } from "../../components/auth/auth-provider"
|
|
3
|
-
import
|
|
3
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
4
|
+
import {
|
|
5
|
+
type UseSessionOptions,
|
|
6
|
+
useSession
|
|
7
|
+
} from "../../queries/auth/session-query"
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Calls `useSession` and redirects unauthenticated users to the sign-in page,
|
|
7
11
|
* preserving the current URL as a `redirectTo` query param.
|
|
8
12
|
*
|
|
9
|
-
* @param
|
|
10
|
-
*
|
|
11
|
-
* @returns React Query result for the session.
|
|
13
|
+
* @param authClient - The Better Auth client.
|
|
14
|
+
* @param options - `getSession` params & `useQuery` options.
|
|
12
15
|
*/
|
|
13
|
-
export function useAuthenticate
|
|
16
|
+
export function useAuthenticate<TAuthClient extends AuthClient>(
|
|
17
|
+
authClient: TAuthClient,
|
|
18
|
+
options?: UseSessionOptions<TAuthClient>
|
|
19
|
+
) {
|
|
14
20
|
const { basePaths, viewPaths, navigate } = useAuth()
|
|
15
|
-
const session = useSession(options)
|
|
21
|
+
const session = useSession(authClient, options)
|
|
16
22
|
|
|
17
23
|
useEffect(() => {
|
|
18
24
|
if (session.data || session.isPending) return
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import {
|
|
3
|
+
type UseSessionOptions,
|
|
4
|
+
useSession
|
|
5
|
+
} from "../../queries/auth/session-query"
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
|
-
* Retrieve the current authenticated user.
|
|
8
|
+
* Retrieve the current authenticated user. Thin wrapper over `useSession`
|
|
9
|
+
* that returns `session.user` as `data`.
|
|
5
10
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param options - Better Auth params (`query`, `fetchOptions`) and React
|
|
9
|
-
* Query options forwarded to `useQuery`.
|
|
10
|
-
* @returns React Query result with `data` narrowed to the user object.
|
|
11
|
+
* @param authClient - The Better Auth client.
|
|
12
|
+
* @param options - `getSession` params & `useQuery` options.
|
|
11
13
|
*/
|
|
12
|
-
export function useUser
|
|
13
|
-
|
|
14
|
+
export function useUser<TAuthClient extends AuthClient>(
|
|
15
|
+
authClient: TAuthClient,
|
|
16
|
+
options?: UseSessionOptions<TAuthClient>
|
|
17
|
+
) {
|
|
18
|
+
const { data, ...rest } = useSession(authClient, options)
|
|
14
19
|
|
|
15
20
|
return {
|
|
16
21
|
data: data?.user,
|
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type MutationKey,
|
|
3
|
+
type UseMutationOptions,
|
|
4
|
+
useMutation
|
|
5
|
+
} from "@tanstack/react-query"
|
|
6
|
+
import type { BetterFetchError } from "better-auth/client"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type AuthMutationFn,
|
|
10
|
+
type AuthMutationFnData,
|
|
11
|
+
type AuthMutationFnVariables,
|
|
12
|
+
authMutationOptions
|
|
13
|
+
} from "../mutations/auth-mutation-options"
|
|
14
|
+
|
|
15
|
+
type UseAuthMutationOptions<TFn extends AuthMutationFn> = Omit<
|
|
16
|
+
UseMutationOptions<
|
|
17
|
+
AuthMutationFnData<TFn>,
|
|
18
|
+
BetterFetchError,
|
|
19
|
+
AuthMutationFnVariables<TFn>
|
|
20
|
+
>,
|
|
21
|
+
"mutationKey" | "mutationFn"
|
|
22
|
+
>
|
|
3
23
|
|
|
4
24
|
/**
|
|
5
|
-
* Escape-hatch hook for Better Auth endpoints that don't have a
|
|
6
|
-
* mutation hook in this library yet. Thin wrapper over
|
|
7
|
-
* `authMutationOptions`.
|
|
25
|
+
* Escape-hatch hook for Better Auth write endpoints that don't have a
|
|
26
|
+
* purpose-built mutation hook in this library yet. Thin wrapper over
|
|
27
|
+
* `useMutation` and `authMutationOptions`.
|
|
8
28
|
*
|
|
9
29
|
* @param authFn - Better Auth client method (e.g. `authClient.emailOtp.sendVerificationOtp`).
|
|
10
|
-
* @param mutationKey -
|
|
30
|
+
* @param mutationKey - Stable key for the mutation. Prefer an entry from
|
|
31
|
+
* `authMutationKeys` over an inline tuple so `useIsMutating` and global
|
|
32
|
+
* `MutationCache` observers line up.
|
|
11
33
|
* @param options - React Query options forwarded to `useMutation`.
|
|
12
34
|
*/
|
|
13
35
|
export function useAuthMutation<
|
|
14
|
-
|
|
15
|
-
TFn extends (...args: any) => any,
|
|
36
|
+
TFn extends AuthMutationFn,
|
|
16
37
|
const TMutationKey extends MutationKey
|
|
17
38
|
>(
|
|
18
39
|
authFn: TFn,
|
|
19
40
|
mutationKey: TMutationKey,
|
|
20
|
-
options?:
|
|
21
|
-
ReturnType<typeof authMutationOptions<TFn, TMutationKey>>,
|
|
22
|
-
"mutationKey" | "mutationFn"
|
|
23
|
-
>
|
|
41
|
+
options?: UseAuthMutationOptions<TFn>
|
|
24
42
|
) {
|
|
25
43
|
return useMutation({
|
|
26
44
|
...authMutationOptions(authFn, mutationKey),
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useAuth } from "../components/auth/auth-provider"
|
|
4
|
+
import type { AuthPlugin } from "../lib/auth-plugin"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Plugin factory shape accepted by {@link useAuthPlugin}. The `id` is read as
|
|
8
|
+
* a static property — the factory is never invoked — so plugins with required
|
|
9
|
+
* options (e.g. `themePlugin`'s `setTheme`) can still be looked up.
|
|
10
|
+
*
|
|
11
|
+
* Always produced by `createAuthPlugin` from `@better-auth-ui/core`.
|
|
12
|
+
*/
|
|
13
|
+
export type AuthPluginFactory<T extends AuthPlugin = AuthPlugin> = {
|
|
14
|
+
id: string
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: factory args vary by plugin
|
|
16
|
+
(...args: any[]): T
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Access a registered plugin by passing its factory.
|
|
21
|
+
*
|
|
22
|
+
* Use inside plugin slot components to read plugin state (localization,
|
|
23
|
+
* config, etc.) without prop drilling.
|
|
24
|
+
*
|
|
25
|
+
* Throws if the plugin isn't registered on `AuthProvider` — this is an
|
|
26
|
+
* invariant: plugin slot components only render when their plugin is in
|
|
27
|
+
* `plugins`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* function PasskeyButton() {
|
|
32
|
+
* const { localization } = useAuthPlugin(passkeyPlugin)
|
|
33
|
+
* return <button>{localization.passkey}</button>
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function useAuthPlugin<T extends AuthPlugin>(
|
|
38
|
+
pluginFactory: AuthPluginFactory<T>
|
|
39
|
+
): T {
|
|
40
|
+
const { plugins } = useAuth()
|
|
41
|
+
const plugin = plugins?.find((p) => p.id === pluginFactory.id)
|
|
42
|
+
|
|
43
|
+
if (!plugin) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`[Better Auth UI] useAuthPlugin: plugin "${pluginFactory.id}" is not registered on AuthProvider.`
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return plugin as T
|
|
50
|
+
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { type QueryKey, useQuery } from "@tanstack/react-query"
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type AuthQueryFn,
|
|
4
|
+
type AuthQueryOptions,
|
|
5
|
+
authQueryOptions
|
|
6
|
+
} from "../queries/auth-query-options"
|
|
3
7
|
|
|
4
|
-
type UseAuthQueryOptions<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
> &
|
|
8
|
-
NonNullable<Parameters<TFn>[0]>
|
|
8
|
+
type UseAuthQueryOptions<
|
|
9
|
+
TFn extends AuthQueryFn,
|
|
10
|
+
TPrefix extends QueryKey
|
|
11
|
+
> = Omit<AuthQueryOptions<TFn, TPrefix>, "queryKey" | "queryFn"> &
|
|
12
|
+
Pick<NonNullable<Parameters<TFn>[0]>, "query" | "fetchOptions">
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* Escape-hatch hook for Better Auth endpoints that don't have a purpose-built
|
|
@@ -17,7 +21,7 @@ type UseAuthQueryOptions<TFn extends AuthFn, TQueryKey extends QueryKey> = Omit<
|
|
|
17
21
|
* Query options forwarded to `useQuery`.
|
|
18
22
|
*/
|
|
19
23
|
export function useAuthQuery<
|
|
20
|
-
TFn extends
|
|
24
|
+
TFn extends AuthQueryFn,
|
|
21
25
|
const TQueryKey extends QueryKey
|
|
22
26
|
>(
|
|
23
27
|
authFn: TFn,
|