@better-auth-ui/react 1.6.3 → 1.6.4
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 +32 -17
- 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/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 +33 -32
- package/dist/index.js +74 -83
- package/dist/lib/auth-client.d.ts +23 -3687
- package/dist/lib/auth-plugin.d.ts +59 -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/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 +24 -22
- package/src/components/auth/auth-provider.tsx +87 -24
- 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/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 +33 -32
- package/src/lib/auth-client.ts +33 -31
- package/src/lib/auth-plugin.ts +75 -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/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,59 @@
|
|
|
1
|
+
import { AuthPluginBase, AuthView } from '@better-auth-ui/core';
|
|
2
|
+
import { ComponentType, ReactNode } from 'react';
|
|
3
|
+
export type { AuthPluginViewPaths } from '@better-auth-ui/core';
|
|
4
|
+
/** Props for plugin-contributed auth buttons (e.g. passkey, magic link). */
|
|
5
|
+
export type AuthButtonProps = {
|
|
6
|
+
className?: string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/** Current auth view — lets buttons context-switch (e.g. show "back to sign-in"). */
|
|
9
|
+
view?: AuthView;
|
|
10
|
+
};
|
|
11
|
+
/** Props for plugin-contributed cards under `/settings/security`. */
|
|
12
|
+
export type SecurityCardProps = {
|
|
13
|
+
className?: string;
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
/** Props for plugin-contributed cards under `/settings/account`. */
|
|
17
|
+
export type AccountCardProps = {
|
|
18
|
+
className?: string;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
/** Props for plugin-contributed items in the `UserButton` dropdown. */
|
|
22
|
+
export type UserMenuItemProps = {
|
|
23
|
+
className?: string;
|
|
24
|
+
};
|
|
25
|
+
/** Framework-agnostic slot component shapes. UI packages narrow these via `TComponents`. */
|
|
26
|
+
export type AuthPluginComponents = {
|
|
27
|
+
/** Rendered below the submit button in auth forms. */
|
|
28
|
+
authButtons?: ComponentType<AuthButtonProps>[];
|
|
29
|
+
/** Rendered as cards inside security settings. */
|
|
30
|
+
securityCards?: ComponentType<SecurityCardProps>[];
|
|
31
|
+
/** Rendered as cards inside account settings. */
|
|
32
|
+
accountCards?: ComponentType<AccountCardProps>[];
|
|
33
|
+
/** Rendered as items inside the `UserButton` dropdown. */
|
|
34
|
+
userMenuItems?: ComponentType<UserMenuItemProps>[];
|
|
35
|
+
};
|
|
36
|
+
/** Plugin view overrides keyed by `AuthPluginViewPaths`. Always replaces the built-in view. */
|
|
37
|
+
export type AuthPluginViews<TAuthViewProps, TSettingsViewProps> = {
|
|
38
|
+
auth?: Record<string, ComponentType<TAuthViewProps>>;
|
|
39
|
+
settings?: Record<string, ComponentType<TSettingsViewProps>>;
|
|
40
|
+
};
|
|
41
|
+
/** Conditional view replacements — only used when the built-in flow isn't viable. */
|
|
42
|
+
export type AuthPluginFallbackViews<TAuthViewProps> = {
|
|
43
|
+
auth?: {
|
|
44
|
+
/** Rendered at `/auth/sign-in` when `emailAndPassword.enabled === false`. */
|
|
45
|
+
signIn?: ComponentType<TAuthViewProps>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* UI-aware plugin definition. UI packages bind the generics in their own
|
|
50
|
+
* `AuthPlugin` re-export so plugin authors don't have to.
|
|
51
|
+
*
|
|
52
|
+
* @typeParam TComponents - Slot component shapes (e.g. heroui variant unions).
|
|
53
|
+
* @typeParam TAuthViewProps - Props the `<Auth>` router spreads onto plugin auth views.
|
|
54
|
+
* @typeParam TSettingsViewProps - Props the `<Settings>` router spreads onto plugin settings views.
|
|
55
|
+
*/
|
|
56
|
+
export type AuthPlugin<TComponents = AuthPluginComponents, TAuthViewProps = any, TSettingsViewProps = any> = AuthPluginBase & TComponents & {
|
|
57
|
+
views?: AuthPluginViews<TAuthViewProps, TSettingsViewProps>;
|
|
58
|
+
fallbackViews?: AuthPluginFallbackViews<TAuthViewProps>;
|
|
59
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { passkey } from '@better-auth/passkey';
|
|
2
|
+
import { Auth } from 'better-auth';
|
|
3
|
+
import { magicLink, multiSession, username } from 'better-auth/plugins';
|
|
4
|
+
export type AuthServer = Pick<Auth, "api">;
|
|
5
|
+
export type MagicLinkAuthServer = Pick<Auth<{
|
|
6
|
+
plugins: [ReturnType<typeof magicLink>];
|
|
7
|
+
}>, "api">;
|
|
8
|
+
export type MultiSessionAuthServer = Pick<Auth<{
|
|
9
|
+
plugins: [ReturnType<typeof multiSession>];
|
|
10
|
+
}>, "api">;
|
|
11
|
+
export type PasskeyAuthServer = Pick<Auth<{
|
|
12
|
+
plugins: [ReturnType<typeof passkey>];
|
|
13
|
+
}>, "api">;
|
|
14
|
+
export type UsernameAuthServer = Pick<Auth<{
|
|
15
|
+
plugins: [ReturnType<typeof username>];
|
|
16
|
+
}>, "api">;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type RequestPasswordResetParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["requestPasswordReset"]>[0];
|
|
4
|
+
export type RequestPasswordResetOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof requestPasswordResetOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for requesting a password reset email.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function requestPasswordResetOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
message: string;
|
|
13
|
+
}, BetterFetchError, RequestPasswordResetParams<TAuthClient>, unknown>, "mutationKey">;
|
|
14
|
+
/**
|
|
15
|
+
* Create a mutation for requesting a password reset email.
|
|
16
|
+
*
|
|
17
|
+
* Wraps `authClient.requestPasswordReset` and forwards React Query mutation
|
|
18
|
+
* 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 useRequestPasswordReset<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: RequestPasswordResetOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
message: string;
|
|
26
|
+
}, BetterFetchError, RequestPasswordResetParams<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/auth/request-password-reset-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.requestPasswordReset;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.requestPasswordReset({
|
|
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 requestPasswordResetOptions, i as useRequestPasswordReset };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type ResetPasswordParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["resetPassword"]>[0];
|
|
4
|
+
export type ResetPasswordOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof resetPasswordOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for completing a password reset.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resetPasswordOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, ResetPasswordParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for completing a password reset.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.resetPassword` (using the token from the reset email)
|
|
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 useResetPassword<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: ResetPasswordOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
}, BetterFetchError, ResetPasswordParams<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/auth/reset-password-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.resetPassword;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.resetPassword({
|
|
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 resetPasswordOptions, i as useResetPassword };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SendVerificationEmailParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["sendVerificationEmail"]>[0];
|
|
4
|
+
export type SendVerificationEmailOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof sendVerificationEmailOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for sending a verification email.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sendVerificationEmailOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, SendVerificationEmailParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for sending an email-verification link.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.sendVerificationEmail` and forwards React Query mutation
|
|
17
|
+
* options such as `onSuccess`, `onError`, and `retry`.
|
|
18
|
+
*
|
|
19
|
+
* @param authClient - The Better Auth client.
|
|
20
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useSendVerificationEmail<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SendVerificationEmailOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
23
|
+
status: boolean;
|
|
24
|
+
}, BetterFetchError, SendVerificationEmailParams<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/auth/send-verification-email-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.sendVerificationEmail;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.sendVerificationEmail({
|
|
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 sendVerificationEmailOptions, i as useSendVerificationEmail };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SignInEmailParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signIn"]["email"]>[0];
|
|
4
|
+
export type SignInEmailOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signInEmailOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for email/password sign-in.
|
|
7
|
+
*
|
|
8
|
+
* The returned `mutationKey` (`authMutationKeys.signIn.email`) is stable and
|
|
9
|
+
* can be passed to `useIsMutating` or matched inside a global
|
|
10
|
+
* `MutationCache` observer for toast handling.
|
|
11
|
+
*
|
|
12
|
+
* @param authClient - The Better Auth client.
|
|
13
|
+
*/
|
|
14
|
+
export declare function signInEmailOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<Omit<{
|
|
15
|
+
redirect: boolean;
|
|
16
|
+
token: string;
|
|
17
|
+
url?: string | undefined;
|
|
18
|
+
user: {
|
|
19
|
+
id: string;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
email: string;
|
|
23
|
+
emailVerified: boolean;
|
|
24
|
+
name: string;
|
|
25
|
+
image?: string | null | undefined | undefined;
|
|
26
|
+
};
|
|
27
|
+
}, "user"> & {
|
|
28
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
29
|
+
id: string;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
email: string;
|
|
33
|
+
emailVerified: boolean;
|
|
34
|
+
name: string;
|
|
35
|
+
image?: string | null | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
}, BetterFetchError, SignInEmailParams<TAuthClient>, unknown>, "mutationKey">;
|
|
38
|
+
/**
|
|
39
|
+
* Create a mutation for email/password sign-in.
|
|
40
|
+
*
|
|
41
|
+
* Wraps `authClient.signIn.email`, 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.
|
|
46
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useSignInEmail<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignInEmailOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<Omit<{
|
|
49
|
+
redirect: boolean;
|
|
50
|
+
token: string;
|
|
51
|
+
url?: string | undefined;
|
|
52
|
+
user: {
|
|
53
|
+
id: string;
|
|
54
|
+
createdAt: Date;
|
|
55
|
+
updatedAt: Date;
|
|
56
|
+
email: string;
|
|
57
|
+
emailVerified: boolean;
|
|
58
|
+
name: string;
|
|
59
|
+
image?: string | null | undefined | undefined;
|
|
60
|
+
};
|
|
61
|
+
}, "user"> & {
|
|
62
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
63
|
+
id: string;
|
|
64
|
+
createdAt: Date;
|
|
65
|
+
updatedAt: Date;
|
|
66
|
+
email: string;
|
|
67
|
+
emailVerified: boolean;
|
|
68
|
+
name: string;
|
|
69
|
+
image?: string | null | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
}, BetterFetchError, SignInEmailParams<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/auth/sign-in-email-mutation.ts
|
|
5
|
+
function a(e) {
|
|
6
|
+
let r = t.signIn.email;
|
|
7
|
+
return n({
|
|
8
|
+
mutationKey: r,
|
|
9
|
+
mutationFn: (t) => e.signIn.email({
|
|
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 signInEmailOptions, o as useSignInEmail };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SignInSocialParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signIn"]["social"]>[0];
|
|
4
|
+
export type SignInSocialOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signInSocialOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for social sign-in.
|
|
7
|
+
*
|
|
8
|
+
* The returned `mutationKey` (`["auth", "signIn", "social"]`) is stable and
|
|
9
|
+
* can be passed to `useIsMutating` or matched inside a global
|
|
10
|
+
* `MutationCache` observer for toast handling.
|
|
11
|
+
*
|
|
12
|
+
* @param authClient - The Better Auth client.
|
|
13
|
+
*/
|
|
14
|
+
export declare function signInSocialOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
15
|
+
redirect: boolean;
|
|
16
|
+
url: string;
|
|
17
|
+
} | (Omit<{
|
|
18
|
+
redirect: boolean;
|
|
19
|
+
token: string;
|
|
20
|
+
url: undefined;
|
|
21
|
+
user: {
|
|
22
|
+
id: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
email: string;
|
|
26
|
+
emailVerified: boolean;
|
|
27
|
+
name: string;
|
|
28
|
+
image?: string | null | undefined | undefined;
|
|
29
|
+
};
|
|
30
|
+
}, "user"> & {
|
|
31
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
32
|
+
id: string;
|
|
33
|
+
createdAt: Date;
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
email: string;
|
|
36
|
+
emailVerified: boolean;
|
|
37
|
+
name: string;
|
|
38
|
+
image?: string | null | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
}), BetterFetchError, SignInSocialParams<TAuthClient>, unknown>, "mutationKey">;
|
|
41
|
+
/**
|
|
42
|
+
* Create a mutation for social sign-in.
|
|
43
|
+
*
|
|
44
|
+
* Wraps `authClient.signIn.social` to initiate a provider redirect and
|
|
45
|
+
* forwards React Query mutation options such as `onSuccess`, `onError`,
|
|
46
|
+
* and `retry`.
|
|
47
|
+
*
|
|
48
|
+
* @param authClient - The Better Auth client.
|
|
49
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function useSignInSocial<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignInSocialOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
52
|
+
redirect: boolean;
|
|
53
|
+
url: string;
|
|
54
|
+
} | (Omit<{
|
|
55
|
+
redirect: boolean;
|
|
56
|
+
token: string;
|
|
57
|
+
url: undefined;
|
|
58
|
+
user: {
|
|
59
|
+
id: string;
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
updatedAt: Date;
|
|
62
|
+
email: string;
|
|
63
|
+
emailVerified: boolean;
|
|
64
|
+
name: string;
|
|
65
|
+
image?: string | null | undefined | undefined;
|
|
66
|
+
};
|
|
67
|
+
}, "user"> & {
|
|
68
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
69
|
+
id: string;
|
|
70
|
+
createdAt: Date;
|
|
71
|
+
updatedAt: Date;
|
|
72
|
+
email: string;
|
|
73
|
+
emailVerified: boolean;
|
|
74
|
+
name: string;
|
|
75
|
+
image?: string | null | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
}), BetterFetchError, SignInSocialParams<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/auth/sign-in-social-mutation.ts
|
|
4
|
+
function r(n) {
|
|
5
|
+
let r = e.signIn.social;
|
|
6
|
+
return t({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => n.signIn.social({
|
|
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 signInSocialOptions, i as useSignInSocial };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SignOutParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signOut"]>[0];
|
|
4
|
+
export type SignOutOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signOutOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for signing out.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function signOutOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
}, BetterFetchError, void | SignOutParams<TAuthClient> | undefined, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for signing the current user out.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.signOut`, removes all cached auth queries 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 useSignOut<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignOutOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
}, BetterFetchError, void | SignOutParams<TAuthClient> | undefined, unknown>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { authMutationKeys as e, authQueryKeys as t } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions as n, useMutation as r, useQueryClient as i } from "@tanstack/react-query";
|
|
3
|
+
//#region src/mutations/auth/sign-out-mutation.ts
|
|
4
|
+
function a(t) {
|
|
5
|
+
let r = e.signOut;
|
|
6
|
+
return n({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => t.signOut({
|
|
9
|
+
...e ?? {},
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
...e?.fetchOptions,
|
|
12
|
+
throw: !0
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function o(e, n) {
|
|
18
|
+
let o = i();
|
|
19
|
+
return r({
|
|
20
|
+
...a(e),
|
|
21
|
+
...n,
|
|
22
|
+
onSuccess: async (...e) => {
|
|
23
|
+
o.removeQueries({ queryKey: t.all }), await n?.onSuccess?.(...e);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { a as signOutOptions, o as useSignOut };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SignUpEmailParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signUp"]["email"]>[0];
|
|
4
|
+
export type SignUpEmailOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signUpEmailOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for email/password sign-up.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function signUpEmailOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<(Omit<{
|
|
11
|
+
token: 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 | undefined;
|
|
20
|
+
};
|
|
21
|
+
}, "user"> & {
|
|
22
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
23
|
+
id: string;
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
updatedAt: Date;
|
|
26
|
+
email: string;
|
|
27
|
+
emailVerified: boolean;
|
|
28
|
+
name: string;
|
|
29
|
+
image?: string | null | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
}) | (Omit<{
|
|
32
|
+
token: string;
|
|
33
|
+
user: {
|
|
34
|
+
id: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
email: string;
|
|
38
|
+
emailVerified: boolean;
|
|
39
|
+
name: string;
|
|
40
|
+
image?: string | null | undefined | undefined;
|
|
41
|
+
};
|
|
42
|
+
}, "user"> & {
|
|
43
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
email: string;
|
|
48
|
+
emailVerified: boolean;
|
|
49
|
+
name: string;
|
|
50
|
+
image?: string | null | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
}), BetterFetchError, SignUpEmailParams<TAuthClient>, unknown>, "mutationKey">;
|
|
53
|
+
/**
|
|
54
|
+
* Create a mutation for email/password sign-up.
|
|
55
|
+
*
|
|
56
|
+
* Wraps `authClient.signUp.email`, resets the session query on success so
|
|
57
|
+
* the new session is refetched, and forwards React Query mutation options
|
|
58
|
+
* such as `onSuccess`, `onError`, and `retry`.
|
|
59
|
+
*
|
|
60
|
+
* @param authClient - The Better Auth client.
|
|
61
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useSignUpEmail<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignUpEmailOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<(Omit<{
|
|
64
|
+
token: null;
|
|
65
|
+
user: {
|
|
66
|
+
id: string;
|
|
67
|
+
createdAt: Date;
|
|
68
|
+
updatedAt: Date;
|
|
69
|
+
email: string;
|
|
70
|
+
emailVerified: boolean;
|
|
71
|
+
name: string;
|
|
72
|
+
image?: string | null | undefined | undefined;
|
|
73
|
+
};
|
|
74
|
+
}, "user"> & {
|
|
75
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
76
|
+
id: string;
|
|
77
|
+
createdAt: Date;
|
|
78
|
+
updatedAt: Date;
|
|
79
|
+
email: string;
|
|
80
|
+
emailVerified: boolean;
|
|
81
|
+
name: string;
|
|
82
|
+
image?: string | null | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
}) | (Omit<{
|
|
85
|
+
token: string;
|
|
86
|
+
user: {
|
|
87
|
+
id: string;
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
updatedAt: Date;
|
|
90
|
+
email: string;
|
|
91
|
+
emailVerified: boolean;
|
|
92
|
+
name: string;
|
|
93
|
+
image?: string | null | undefined | undefined;
|
|
94
|
+
};
|
|
95
|
+
}, "user"> & {
|
|
96
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
97
|
+
id: string;
|
|
98
|
+
createdAt: Date;
|
|
99
|
+
updatedAt: Date;
|
|
100
|
+
email: string;
|
|
101
|
+
emailVerified: boolean;
|
|
102
|
+
name: string;
|
|
103
|
+
image?: string | null | undefined;
|
|
104
|
+
}>;
|
|
105
|
+
}), BetterFetchError, SignUpEmailParams<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/auth/sign-up-email-mutation.ts
|
|
5
|
+
function a(e) {
|
|
6
|
+
let r = t.signUp.email;
|
|
7
|
+
return n({
|
|
8
|
+
mutationKey: r,
|
|
9
|
+
mutationFn: (t) => e.signUp.email({
|
|
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 signUpEmailOptions, o as useSignUpEmail };
|