@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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type ChangePasswordParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["changePassword"]>[0];
|
|
4
|
+
export type ChangePasswordOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof changePasswordOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for changing the authenticated user's password.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function changePasswordOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<Omit<{
|
|
11
|
+
token: string | null;
|
|
12
|
+
user: {
|
|
13
|
+
id: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
email: string;
|
|
17
|
+
emailVerified: boolean;
|
|
18
|
+
name: string;
|
|
19
|
+
image?: string | null | undefined;
|
|
20
|
+
} & Record<string, any> & {
|
|
21
|
+
id: string;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
email: string;
|
|
25
|
+
emailVerified: boolean;
|
|
26
|
+
name: string;
|
|
27
|
+
image?: string | null | undefined;
|
|
28
|
+
};
|
|
29
|
+
}, "user"> & {
|
|
30
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
31
|
+
id: string;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
updatedAt: Date;
|
|
34
|
+
email: string;
|
|
35
|
+
emailVerified: boolean;
|
|
36
|
+
name: string;
|
|
37
|
+
image?: string | null | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
}, BetterFetchError, ChangePasswordParams<TAuthClient>, unknown>, "mutationKey">;
|
|
40
|
+
/**
|
|
41
|
+
* Create a mutation for changing the authenticated user's password.
|
|
42
|
+
*
|
|
43
|
+
* Wraps `authClient.changePassword` and forwards React Query mutation
|
|
44
|
+
* options such as `onSuccess`, `onError`, and `retry`.
|
|
45
|
+
*
|
|
46
|
+
* @param authClient - The Better Auth client.
|
|
47
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useChangePassword<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: ChangePasswordOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<Omit<{
|
|
50
|
+
token: string | null;
|
|
51
|
+
user: {
|
|
52
|
+
id: string;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
email: string;
|
|
56
|
+
emailVerified: boolean;
|
|
57
|
+
name: string;
|
|
58
|
+
image?: string | null | undefined;
|
|
59
|
+
} & Record<string, any> & {
|
|
60
|
+
id: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
email: string;
|
|
64
|
+
emailVerified: boolean;
|
|
65
|
+
name: string;
|
|
66
|
+
image?: string | null | undefined;
|
|
67
|
+
};
|
|
68
|
+
}, "user"> & {
|
|
69
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
70
|
+
id: string;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
email: string;
|
|
74
|
+
emailVerified: boolean;
|
|
75
|
+
name: string;
|
|
76
|
+
image?: string | null | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
}, BetterFetchError, ChangePasswordParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { authMutationKeys as e } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
|
|
3
|
+
//#region src/mutations/settings/change-password-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.changePassword;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.changePassword({
|
|
9
|
+
...e,
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
...e?.fetchOptions,
|
|
12
|
+
throw: !0
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function i(e, t) {
|
|
18
|
+
return n({
|
|
19
|
+
...r(e),
|
|
20
|
+
...t
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as changePasswordOptions, i as useChangePassword };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type DeleteUserParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["deleteUser"]>[0];
|
|
4
|
+
export type DeleteUserOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof deleteUserOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for deleting the authenticated user's account.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deleteUserOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
message: string;
|
|
13
|
+
}, BetterFetchError, DeleteUserParams<TAuthClient>, unknown>, "mutationKey">;
|
|
14
|
+
/**
|
|
15
|
+
* Create a mutation for deleting the authenticated user's account.
|
|
16
|
+
*
|
|
17
|
+
* Wraps `authClient.deleteUser` and forwards React Query mutation options
|
|
18
|
+
* such as `onSuccess`, `onError`, and `retry`.
|
|
19
|
+
*
|
|
20
|
+
* @param authClient - The Better Auth client.
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useDeleteUser<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: DeleteUserOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
message: string;
|
|
26
|
+
}, BetterFetchError, DeleteUserParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { authMutationKeys as e } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
|
|
3
|
+
//#region src/mutations/settings/delete-user-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.deleteUser;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.deleteUser({
|
|
9
|
+
...e,
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
...e?.fetchOptions,
|
|
12
|
+
throw: !0
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function i(e, t) {
|
|
18
|
+
return n({
|
|
19
|
+
...r(e),
|
|
20
|
+
...t
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as deleteUserOptions, i as useDeleteUser };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type LinkSocialParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["linkSocial"]>[0];
|
|
4
|
+
export type LinkSocialOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof linkSocialOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for linking a social provider to the current user.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function linkSocialOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
url: string;
|
|
12
|
+
redirect: boolean;
|
|
13
|
+
}, BetterFetchError, LinkSocialParams<TAuthClient>, unknown>, "mutationKey">;
|
|
14
|
+
/**
|
|
15
|
+
* Create a mutation for linking a social provider to the current user.
|
|
16
|
+
*
|
|
17
|
+
* Wraps `authClient.linkSocial` to initiate a provider redirect and forwards
|
|
18
|
+
* React Query mutation options such as `onSuccess`, `onError`, and `retry`.
|
|
19
|
+
*
|
|
20
|
+
* @param authClient - The Better Auth client.
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useLinkSocial<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: LinkSocialOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
url: string;
|
|
25
|
+
redirect: boolean;
|
|
26
|
+
}, BetterFetchError, LinkSocialParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { authMutationKeys as e } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
|
|
3
|
+
//#region src/mutations/settings/link-social-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.linkSocial;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.linkSocial({
|
|
9
|
+
...e,
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
...e?.fetchOptions,
|
|
12
|
+
throw: !0
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function i(e, t) {
|
|
18
|
+
return n({
|
|
19
|
+
...r(e),
|
|
20
|
+
...t
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as linkSocialOptions, i as useLinkSocial };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type RevokeSessionParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["revokeSession"]>[0];
|
|
4
|
+
export type RevokeSessionOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof revokeSessionOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for revoking a user session.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function revokeSessionOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, RevokeSessionParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for revoking a user session.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.revokeSession`, refetches the sessions list on success,
|
|
17
|
+
* and forwards React Query mutation options such as `onSuccess`, `onError`,
|
|
18
|
+
* and `retry`.
|
|
19
|
+
*
|
|
20
|
+
* @param authClient - The Better Auth client.
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useRevokeSession<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: RevokeSessionOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
}, BetterFetchError, RevokeSessionParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useListSessions as e } from "../../queries/settings/list-sessions-query.js";
|
|
2
|
+
import { authMutationKeys as t } from "@better-auth-ui/core";
|
|
3
|
+
import { mutationOptions as n, useMutation as r } from "@tanstack/react-query";
|
|
4
|
+
//#region src/mutations/settings/revoke-session-mutation.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
let r = t.revokeSession;
|
|
7
|
+
return n({
|
|
8
|
+
mutationKey: r,
|
|
9
|
+
mutationFn: (t) => e.revokeSession({
|
|
10
|
+
...t,
|
|
11
|
+
fetchOptions: {
|
|
12
|
+
...t?.fetchOptions,
|
|
13
|
+
throw: !0
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function a(t, n) {
|
|
19
|
+
let { refetch: a } = e(t, { refetchOnMount: !1 });
|
|
20
|
+
return r({
|
|
21
|
+
...i(t),
|
|
22
|
+
...n,
|
|
23
|
+
onSuccess: async (...e) => {
|
|
24
|
+
await a(), await n?.onSuccess?.(...e);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i as revokeSessionOptions, a as useRevokeSession };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type UnlinkAccountParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["unlinkAccount"]>[0];
|
|
4
|
+
export type UnlinkAccountOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof unlinkAccountOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for unlinking a social provider from the current user.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function unlinkAccountOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, UnlinkAccountParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for unlinking a social provider from the current user.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.unlinkAccount`, refetches the linked accounts list on
|
|
17
|
+
* success, and forwards React Query mutation options such as `onSuccess`,
|
|
18
|
+
* `onError`, and `retry`.
|
|
19
|
+
*
|
|
20
|
+
* @param authClient - The Better Auth client.
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useUnlinkAccount<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UnlinkAccountOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
}, BetterFetchError, UnlinkAccountParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useListAccounts as e } from "../../queries/settings/list-accounts-query.js";
|
|
2
|
+
import { authMutationKeys as t } from "@better-auth-ui/core";
|
|
3
|
+
import { mutationOptions as n, useMutation as r } from "@tanstack/react-query";
|
|
4
|
+
//#region src/mutations/settings/unlink-account-mutation.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
let r = t.unlinkAccount;
|
|
7
|
+
return n({
|
|
8
|
+
mutationKey: r,
|
|
9
|
+
mutationFn: (t) => e.unlinkAccount({
|
|
10
|
+
...t,
|
|
11
|
+
fetchOptions: {
|
|
12
|
+
...t?.fetchOptions,
|
|
13
|
+
throw: !0
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function a(t, n) {
|
|
19
|
+
let { refetch: a } = e(t, { refetchOnMount: !1 });
|
|
20
|
+
return r({
|
|
21
|
+
...i(t),
|
|
22
|
+
...n,
|
|
23
|
+
onSuccess: async (...e) => {
|
|
24
|
+
await a(), await n?.onSuccess?.(...e);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i as unlinkAccountOptions, a as useUnlinkAccount };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type UpdateUserParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["updateUser"]>[0];
|
|
4
|
+
export type UpdateUserOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof updateUserOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for updating the authenticated user's profile.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateUserOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, UpdateUserParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for updating the authenticated user's profile.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.updateUser`, optimistically patches the cached session
|
|
17
|
+
* with the new fields, refetches the session, and forwards React Query
|
|
18
|
+
* mutation options such as `onSuccess`, `onError`, and `retry`.
|
|
19
|
+
*
|
|
20
|
+
* @param authClient - The Better Auth client.
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useUpdateUser<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UpdateUserOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
}, BetterFetchError, UpdateUserParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sessionOptions as e, useSession as t } from "../../queries/auth/session-query.js";
|
|
2
|
+
import { authMutationKeys as n } from "@better-auth-ui/core";
|
|
3
|
+
import { mutationOptions as r, useMutation as i, useQueryClient as a } from "@tanstack/react-query";
|
|
4
|
+
//#region src/mutations/settings/update-user-mutation.ts
|
|
5
|
+
function o(e) {
|
|
6
|
+
let t = n.updateUser;
|
|
7
|
+
return r({
|
|
8
|
+
mutationKey: t,
|
|
9
|
+
mutationFn: (t) => e.updateUser({
|
|
10
|
+
...t,
|
|
11
|
+
fetchOptions: {
|
|
12
|
+
...t?.fetchOptions,
|
|
13
|
+
throw: !0
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function s(n, r) {
|
|
19
|
+
let { data: s, refetch: c } = t(n, { refetchOnMount: !1 }), l = a();
|
|
20
|
+
return i({
|
|
21
|
+
...o(n),
|
|
22
|
+
...r,
|
|
23
|
+
onSuccess: async (t, i, ...a) => {
|
|
24
|
+
s && l.setQueryData(e(n).queryKey, {
|
|
25
|
+
...s,
|
|
26
|
+
user: {
|
|
27
|
+
...s.user,
|
|
28
|
+
...i
|
|
29
|
+
}
|
|
30
|
+
}), c(), await r?.onSuccess?.(t, i, ...a);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { o as updateUserOptions, s as useUpdateUser };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { UsernameAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type IsUsernameAvailableParams<TAuthClient extends UsernameAuthClient> = Parameters<TAuthClient["isUsernameAvailable"]>[0];
|
|
4
|
+
export type IsUsernameAvailableOptions<TAuthClient extends UsernameAuthClient> = Omit<ReturnType<typeof isUsernameAvailableOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for checking username availability.
|
|
7
|
+
*
|
|
8
|
+
* Modeled as a mutation because callers typically trigger the check on
|
|
9
|
+
* user action (debounced input, form submit) rather than on mount.
|
|
10
|
+
*
|
|
11
|
+
* @param authClient - The Better Auth client.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isUsernameAvailableOptions<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
14
|
+
available: boolean;
|
|
15
|
+
}, BetterFetchError, IsUsernameAvailableParams<TAuthClient>, unknown>, "mutationKey">;
|
|
16
|
+
/**
|
|
17
|
+
* Create a mutation for checking whether a username is available.
|
|
18
|
+
*
|
|
19
|
+
* Wraps `authClient.isUsernameAvailable` and forwards React Query mutation
|
|
20
|
+
* options such as `onSuccess`, `onError`, and `retry`.
|
|
21
|
+
*
|
|
22
|
+
* @param authClient - The Better Auth client with the username plugin.
|
|
23
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useIsUsernameAvailable<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient, options?: IsUsernameAvailableOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
26
|
+
available: boolean;
|
|
27
|
+
}, BetterFetchError, IsUsernameAvailableParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { authMutationKeys as e } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
|
|
3
|
+
//#region src/mutations/username/is-username-available-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.isUsernameAvailable;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.isUsernameAvailable({
|
|
9
|
+
...e,
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
...e?.fetchOptions,
|
|
12
|
+
throw: !0
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function i(e, t) {
|
|
18
|
+
return n({
|
|
19
|
+
...r(e),
|
|
20
|
+
...t
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as isUsernameAvailableOptions, i as useIsUsernameAvailable };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { UsernameAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SignInUsernameParams<TAuthClient extends UsernameAuthClient> = Parameters<TAuthClient["signIn"]["username"]>[0];
|
|
4
|
+
export type SignInUsernameOptions<TAuthClient extends UsernameAuthClient> = Omit<ReturnType<typeof signInUsernameOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for username/password sign-in.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function signInUsernameOptions<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<Omit<{
|
|
11
|
+
token: string;
|
|
12
|
+
user: {
|
|
13
|
+
id: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
email: string;
|
|
17
|
+
emailVerified: boolean;
|
|
18
|
+
name: string;
|
|
19
|
+
image?: string | null | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
username: string;
|
|
22
|
+
displayUsername: string;
|
|
23
|
+
};
|
|
24
|
+
}, "user"> & {
|
|
25
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
26
|
+
id: string;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
updatedAt: Date;
|
|
29
|
+
email: string;
|
|
30
|
+
emailVerified: boolean;
|
|
31
|
+
name: string;
|
|
32
|
+
image?: string | null | undefined;
|
|
33
|
+
} & {} & {
|
|
34
|
+
username?: string | null | undefined;
|
|
35
|
+
displayUsername?: string | null | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
}, BetterFetchError, SignInUsernameParams<TAuthClient>, unknown>, "mutationKey">;
|
|
38
|
+
/**
|
|
39
|
+
* Create a mutation for username/password sign-in.
|
|
40
|
+
*
|
|
41
|
+
* Wraps `authClient.signIn.username`, resets the session query on success so
|
|
42
|
+
* the new session is refetched, and forwards React Query mutation options
|
|
43
|
+
* such as `onSuccess`, `onError`, and `retry`.
|
|
44
|
+
*
|
|
45
|
+
* @param authClient - The Better Auth client with the username plugin.
|
|
46
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useSignInUsername<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient, options?: SignInUsernameOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<Omit<{
|
|
49
|
+
token: string;
|
|
50
|
+
user: {
|
|
51
|
+
id: string;
|
|
52
|
+
createdAt: Date;
|
|
53
|
+
updatedAt: Date;
|
|
54
|
+
email: string;
|
|
55
|
+
emailVerified: boolean;
|
|
56
|
+
name: string;
|
|
57
|
+
image?: string | null | undefined;
|
|
58
|
+
} & {
|
|
59
|
+
username: string;
|
|
60
|
+
displayUsername: string;
|
|
61
|
+
};
|
|
62
|
+
}, "user"> & {
|
|
63
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
64
|
+
id: string;
|
|
65
|
+
createdAt: Date;
|
|
66
|
+
updatedAt: Date;
|
|
67
|
+
email: string;
|
|
68
|
+
emailVerified: boolean;
|
|
69
|
+
name: string;
|
|
70
|
+
image?: string | null | undefined;
|
|
71
|
+
} & {} & {
|
|
72
|
+
username?: string | null | undefined;
|
|
73
|
+
displayUsername?: string | null | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
}, BetterFetchError, SignInUsernameParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { sessionOptions as e } from "../../queries/auth/session-query.js";
|
|
2
|
+
import { authMutationKeys as t } from "@better-auth-ui/core";
|
|
3
|
+
import { mutationOptions as n, useMutation as r, useQueryClient as i } from "@tanstack/react-query";
|
|
4
|
+
//#region src/mutations/username/sign-in-username-mutation.ts
|
|
5
|
+
function a(e) {
|
|
6
|
+
let r = t.signIn.username;
|
|
7
|
+
return n({
|
|
8
|
+
mutationKey: r,
|
|
9
|
+
mutationFn: (t) => e.signIn.username({
|
|
10
|
+
...t,
|
|
11
|
+
fetchOptions: {
|
|
12
|
+
...t?.fetchOptions,
|
|
13
|
+
throw: !0
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function o(t, n) {
|
|
19
|
+
let o = i();
|
|
20
|
+
return r({
|
|
21
|
+
...a(t),
|
|
22
|
+
...n,
|
|
23
|
+
onSuccess: async (...r) => {
|
|
24
|
+
o.resetQueries({ queryKey: e(t).queryKey }), await n?.onSuccess?.(...r);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { a as signInUsernameOptions, o as useSignInUsername };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
/** Props passed to the consumer's `render` component. */
|
|
3
|
+
export type CaptchaRenderProps = {
|
|
4
|
+
/** Call once the user solves the captcha. */
|
|
5
|
+
setToken: (token: string) => void;
|
|
6
|
+
/** Call on error/expire to clear the token. */
|
|
7
|
+
clearToken: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Register your widget's `reset()`. Forms call it after a failed
|
|
10
|
+
* submission since captcha tokens are single-use. Pass `null` on unmount.
|
|
11
|
+
*/
|
|
12
|
+
setReset: (reset: (() => void) | null) => void;
|
|
13
|
+
};
|
|
14
|
+
export type CaptchaPluginOptions = {
|
|
15
|
+
/** Renders the captcha widget. Wire `setToken`, `clearToken`, `setReset`. */
|
|
16
|
+
render: ComponentType<CaptchaRenderProps>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Provider-agnostic captcha plugin. Forwards the resolved token via the
|
|
20
|
+
* `x-captcha-response` header on Better Auth requests.
|
|
21
|
+
*/
|
|
22
|
+
export declare const captchaPlugin: ((args_0: CaptchaPluginOptions) => Omit<{
|
|
23
|
+
render: ComponentType<CaptchaRenderProps>;
|
|
24
|
+
captchaComponent: import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
}, "id"> & {
|
|
26
|
+
id: "captcha";
|
|
27
|
+
}) & {
|
|
28
|
+
id: "captcha";
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFetchOptions as e } from "../components/auth/fetch-options-provider.js";
|
|
3
|
+
import { useAuthPlugin as t } from "../hooks/use-auth-plugin.js";
|
|
4
|
+
import { createAuthPlugin as n } from "@better-auth-ui/core";
|
|
5
|
+
import { useCallback as r, useEffect as i } from "react";
|
|
6
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/plugins/captcha-plugin.tsx
|
|
8
|
+
function o() {
|
|
9
|
+
let { render: n } = t(s), { setFetchOptions: o, registerReset: c } = e(), l = r((e) => {
|
|
10
|
+
o({ headers: { "x-captcha-response": e } });
|
|
11
|
+
}, [o]), u = r(() => {
|
|
12
|
+
o(void 0);
|
|
13
|
+
}, [o]), d = r((e) => {
|
|
14
|
+
c(e);
|
|
15
|
+
}, [c]);
|
|
16
|
+
return i(() => () => {
|
|
17
|
+
o(void 0), c(null);
|
|
18
|
+
}, [o, c]), /* @__PURE__ */ a(n, {
|
|
19
|
+
setToken: l,
|
|
20
|
+
clearToken: u,
|
|
21
|
+
setReset: d
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
var s = n("captcha", ({ render: e }) => ({
|
|
25
|
+
render: e,
|
|
26
|
+
captchaComponent: /* @__PURE__ */ a(o, {})
|
|
27
|
+
}));
|
|
28
|
+
//#endregion
|
|
29
|
+
export { s as captchaPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugins/captcha-plugin';
|
package/dist/plugins.js
ADDED