@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
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
import { MutationKey } from '@tanstack/react-query';
|
|
2
|
-
import { BetterFetchError
|
|
3
|
-
export type AuthMutationFn<TData = unknown, TVariables = unknown> = (params: TVariables & {
|
|
4
|
-
fetchOptions?: BetterFetchOption;
|
|
5
|
-
}) => Promise<{
|
|
6
|
-
data: TData;
|
|
7
|
-
}>;
|
|
8
|
-
type AuthMutationFnData<TFn> = TFn extends AuthMutationFn<infer TData> ? TData : never;
|
|
9
|
-
type AuthMutationFnVariables<TFn extends (...args: any) => any> = undefined extends Parameters<TFn>[0] ? // biome-ignore lint/suspicious/noConfusingVoidType: void lets `mutate()` be called with no arg
|
|
10
|
-
void | NonNullable<Parameters<TFn>[0]> : Parameters<TFn>[0];
|
|
1
|
+
import { MutationKey, UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
import { BetterFetchError } from 'better-auth/client';
|
|
11
3
|
/**
|
|
12
|
-
*
|
|
4
|
+
* Write-style Better Auth client method. Variables are a single object that
|
|
5
|
+
* may carry top-level params plus `fetchOptions` (e.g. `signIn.email` takes
|
|
6
|
+
* `{ email, password, rememberMe?, fetchOptions? }`).
|
|
13
7
|
*
|
|
14
|
-
*
|
|
15
|
-
|
|
8
|
+
* Read-style endpoints use `AuthQueryFn` / `useAuthQuery` instead.
|
|
9
|
+
*/
|
|
10
|
+
export type AuthMutationFn = (variables: any) => Promise<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Resolved data type returned by an {@link AuthMutationFn}.
|
|
13
|
+
*/
|
|
14
|
+
export type AuthMutationFnData<TFn extends AuthMutationFn> = Awaited<ReturnType<TFn>>;
|
|
15
|
+
/**
|
|
16
|
+
* Variables type accepted by `mutate` / `mutateAsync` for a given
|
|
17
|
+
* {@link AuthMutationFn}.
|
|
18
|
+
*
|
|
19
|
+
* If the method's params are entirely optional (e.g. `authClient.signOut`),
|
|
20
|
+
* this resolves to `Variables | void` so `mutate()` is callable without
|
|
21
|
+
* arguments. Otherwise it resolves to the exact required shape so the type
|
|
22
|
+
* checker rejects `mutate()` when the underlying call needs params.
|
|
23
|
+
*/
|
|
24
|
+
export type AuthMutationFnVariables<TFn extends AuthMutationFn> = Parameters<TFn>[0] extends infer P ? undefined extends P ? // biome-ignore lint/suspicious/noConfusingVoidType: void allows no-arg mutate
|
|
25
|
+
NonNullable<P> | void : P : never;
|
|
26
|
+
/**
|
|
27
|
+
* Return type of {@link authMutationOptions}, matching the shape produced by
|
|
28
|
+
* TanStack Query's own `mutationOptions` helper.
|
|
29
|
+
*/
|
|
30
|
+
export type AuthMutationOptions<TFn extends AuthMutationFn, TMutationKey extends MutationKey = MutationKey> = Omit<UseMutationOptions<AuthMutationFnData<TFn>, BetterFetchError, AuthMutationFnVariables<TFn>>, "mutationKey"> & {
|
|
31
|
+
mutationKey: TMutationKey;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Build `mutationOptions` for a write-style Better Auth endpoint.
|
|
16
35
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `TData` explicitly (e.g. `authMutationOptions<_, _, { available: boolean }>`).
|
|
36
|
+
* Injects `throw: true` into `fetchOptions` so the promise rejects with a
|
|
37
|
+
* `BetterFetchError` on failure instead of resolving to `{ data, error }`.
|
|
20
38
|
*
|
|
21
|
-
* @param authFn - Better Auth client method (e.g. `authClient.
|
|
22
|
-
* @param mutationKey -
|
|
39
|
+
* @param authFn - Better Auth client method (e.g. `authClient.emailOtp.sendVerificationOtp`).
|
|
40
|
+
* @param mutationKey - Stable key for the mutation (used by `useIsMutating`, `MutationCache`, …).
|
|
23
41
|
*/
|
|
24
|
-
export declare function authMutationOptions<TFn extends
|
|
25
|
-
export {};
|
|
42
|
+
export declare function authMutationOptions<TFn extends AuthMutationFn, const TMutationKey extends MutationKey>(authFn: TFn, mutationKey: TMutationKey): AuthMutationOptions<TFn, TMutationKey>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { MagicLinkAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SignInMagicLinkParams<TAuthClient extends MagicLinkAuthClient> = Parameters<TAuthClient["signIn"]["magicLink"]>[0];
|
|
4
|
+
export type SignInMagicLinkOptions<TAuthClient extends MagicLinkAuthClient> = Omit<ReturnType<typeof signInMagicLinkOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for magic-link sign-in.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function signInMagicLinkOptions<TAuthClient extends MagicLinkAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, SignInMagicLinkParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for requesting a magic-link sign-in email.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.signIn.magicLink` and forwards React Query mutation
|
|
17
|
+
* options such as `onSuccess`, `onError`, and `retry`.
|
|
18
|
+
*
|
|
19
|
+
* @param authClient - The Better Auth client with the magic-link plugin.
|
|
20
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useSignInMagicLink<TAuthClient extends MagicLinkAuthClient>(authClient: TAuthClient, options?: SignInMagicLinkOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
23
|
+
status: boolean;
|
|
24
|
+
}, BetterFetchError, SignInMagicLinkParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mutationOptions as e, useMutation as t } from "@tanstack/react-query";
|
|
2
|
+
import { magicLinkMutationKeys as n } from "@better-auth-ui/core/plugins";
|
|
3
|
+
//#region src/mutations/magic-link/sign-in-magic-link-mutation.ts
|
|
4
|
+
function r(t) {
|
|
5
|
+
let r = n.signIn;
|
|
6
|
+
return e({
|
|
7
|
+
mutationKey: r,
|
|
8
|
+
mutationFn: (e) => t.signIn.magicLink({
|
|
9
|
+
...e,
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
...e?.fetchOptions,
|
|
12
|
+
throw: !0
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function i(e, n) {
|
|
18
|
+
return t({
|
|
19
|
+
...r(e),
|
|
20
|
+
...n
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as signInMagicLinkOptions, i as useSignInMagicLink };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { MultiSessionAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type RevokeMultiSessionParams<TAuthClient extends MultiSessionAuthClient> = Parameters<TAuthClient["multiSession"]["revoke"]>[0];
|
|
4
|
+
export type RevokeMultiSessionOptions<TAuthClient extends MultiSessionAuthClient> = Omit<ReturnType<typeof revokeMultiSessionOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for revoking a device session in multi-session mode.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
9
|
+
*/
|
|
10
|
+
export declare function revokeMultiSessionOptions<TAuthClient extends MultiSessionAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, RevokeMultiSessionParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for revoking a device session in multi-session mode.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.multiSession.revoke`, refetches the device sessions list
|
|
17
|
+
* on success, and forwards React Query mutation options such as `onSuccess`,
|
|
18
|
+
* `onError`, and `retry`.
|
|
19
|
+
*
|
|
20
|
+
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useRevokeMultiSession<TAuthClient extends MultiSessionAuthClient>(authClient: TAuthClient, options?: RevokeMultiSessionOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
}, BetterFetchError, RevokeMultiSessionParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useListDeviceSessions as e } from "../../queries/multi-session/list-device-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/multi-session/revoke-multi-session-mutation.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
let r = t.multiSession.revoke;
|
|
7
|
+
return n({
|
|
8
|
+
mutationKey: r,
|
|
9
|
+
mutationFn: (t) => e.multiSession.revoke({
|
|
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 revokeMultiSessionOptions, a as useRevokeMultiSession };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { MultiSessionAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SetActiveSessionParams<TAuthClient extends MultiSessionAuthClient> = Parameters<TAuthClient["multiSession"]["setActive"]>[0];
|
|
4
|
+
export type SetActiveSessionOptions<TAuthClient extends MultiSessionAuthClient> = Omit<ReturnType<typeof setActiveSessionOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for switching the active device session.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
9
|
+
*/
|
|
10
|
+
export declare function setActiveSessionOptions<TAuthClient extends MultiSessionAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
session: {
|
|
12
|
+
id: string;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
userId: string;
|
|
16
|
+
expiresAt: Date;
|
|
17
|
+
token: string;
|
|
18
|
+
ipAddress?: string | null | undefined;
|
|
19
|
+
userAgent?: string | null | undefined;
|
|
20
|
+
} & Record<string, any>;
|
|
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;
|
|
29
|
+
} & Record<string, any>;
|
|
30
|
+
}, BetterFetchError, SetActiveSessionParams<TAuthClient>, unknown>, "mutationKey">;
|
|
31
|
+
/**
|
|
32
|
+
* Create a mutation for switching the active device session.
|
|
33
|
+
*
|
|
34
|
+
* Wraps `authClient.multiSession.setActive`, optimistically swaps the cached
|
|
35
|
+
* session to the matching device session, refetches both the session and
|
|
36
|
+
* device-session queries, and forwards React Query mutation options such as
|
|
37
|
+
* `onSuccess`, `onError`, and `retry`.
|
|
38
|
+
*
|
|
39
|
+
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
40
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useSetActiveSession<TAuthClient extends MultiSessionAuthClient>(authClient: TAuthClient, options?: SetActiveSessionOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
43
|
+
session: {
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
userId: string;
|
|
48
|
+
expiresAt: Date;
|
|
49
|
+
token: string;
|
|
50
|
+
ipAddress?: string | null | undefined;
|
|
51
|
+
userAgent?: string | null | undefined;
|
|
52
|
+
} & Record<string, any>;
|
|
53
|
+
user: {
|
|
54
|
+
id: string;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
updatedAt: Date;
|
|
57
|
+
email: string;
|
|
58
|
+
emailVerified: boolean;
|
|
59
|
+
name: string;
|
|
60
|
+
image?: string | null | undefined;
|
|
61
|
+
} & Record<string, any>;
|
|
62
|
+
}, BetterFetchError, SetActiveSessionParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { sessionOptions as e, useSession as t } from "../../queries/auth/session-query.js";
|
|
2
|
+
import { useListDeviceSessions as n } from "../../queries/multi-session/list-device-sessions-query.js";
|
|
3
|
+
import { authMutationKeys as r } from "@better-auth-ui/core";
|
|
4
|
+
import { mutationOptions as i, useMutation as a, useQueryClient as o } from "@tanstack/react-query";
|
|
5
|
+
//#region src/mutations/multi-session/set-active-session-mutation.ts
|
|
6
|
+
function s(e) {
|
|
7
|
+
let t = r.multiSession.setActive;
|
|
8
|
+
return i({
|
|
9
|
+
mutationKey: t,
|
|
10
|
+
mutationFn: (t) => e.multiSession.setActive({
|
|
11
|
+
...t,
|
|
12
|
+
fetchOptions: {
|
|
13
|
+
...t?.fetchOptions,
|
|
14
|
+
throw: !0
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function c(r, i) {
|
|
20
|
+
let c = o(), { refetch: l } = t(r, { refetchOnMount: !1 }), { data: u, refetch: d } = n(r, { refetchOnMount: !1 });
|
|
21
|
+
return a({
|
|
22
|
+
...s(r),
|
|
23
|
+
...i,
|
|
24
|
+
onSuccess: async (t, n, ...a) => {
|
|
25
|
+
let o = n?.sessionToken, s = u?.find(({ session: { token: e } }) => e === o);
|
|
26
|
+
s && c.setQueryData(e(r).queryKey, s), await l(), await d(), await i?.onSuccess?.(t, n, ...a);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { s as setActiveSessionOptions, c as useSetActiveSession };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { PasskeyAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type AddPasskeyParams<TAuthClient extends PasskeyAuthClient> = Parameters<TAuthClient["passkey"]["addPasskey"]>[0];
|
|
4
|
+
export type AddPasskeyOptions<TAuthClient extends PasskeyAuthClient> = Omit<ReturnType<typeof addPasskeyOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for registering a new passkey.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client with the passkey plugin.
|
|
9
|
+
*/
|
|
10
|
+
export declare function addPasskeyOptions<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
data: null;
|
|
12
|
+
error: {
|
|
13
|
+
message?: string | undefined;
|
|
14
|
+
status: number;
|
|
15
|
+
statusText: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
data: import('@better-auth/passkey').Passkey;
|
|
19
|
+
error: null;
|
|
20
|
+
} | {
|
|
21
|
+
webauthn: {
|
|
22
|
+
response: import('@better-auth/passkey/client').RegistrationResponseJSON;
|
|
23
|
+
clientExtensionResults: import('@better-auth/passkey/client').AuthenticationExtensionsClientOutputs;
|
|
24
|
+
};
|
|
25
|
+
data: import('@better-auth/passkey').Passkey;
|
|
26
|
+
error: null;
|
|
27
|
+
} | {
|
|
28
|
+
data: null;
|
|
29
|
+
error: {
|
|
30
|
+
code: string;
|
|
31
|
+
message: string;
|
|
32
|
+
status: number;
|
|
33
|
+
statusText: string;
|
|
34
|
+
};
|
|
35
|
+
}, BetterFetchError, void | AddPasskeyParams<TAuthClient> | undefined, unknown>, "mutationKey">;
|
|
36
|
+
/**
|
|
37
|
+
* Create a mutation for registering a new passkey.
|
|
38
|
+
*
|
|
39
|
+
* Wraps `authClient.passkey.addPasskey`, refetches the user's passkey list
|
|
40
|
+
* on success, and forwards React Query mutation options such as
|
|
41
|
+
* `onSuccess`, `onError`, and `retry`.
|
|
42
|
+
*
|
|
43
|
+
* @param authClient - The Better Auth client with the passkey plugin.
|
|
44
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useAddPasskey<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient, options?: AddPasskeyOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
47
|
+
data: null;
|
|
48
|
+
error: {
|
|
49
|
+
message?: string | undefined;
|
|
50
|
+
status: number;
|
|
51
|
+
statusText: string;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
data: import('@better-auth/passkey').Passkey;
|
|
55
|
+
error: null;
|
|
56
|
+
} | {
|
|
57
|
+
webauthn: {
|
|
58
|
+
response: import('@better-auth/passkey/client').RegistrationResponseJSON;
|
|
59
|
+
clientExtensionResults: import('@better-auth/passkey/client').AuthenticationExtensionsClientOutputs;
|
|
60
|
+
};
|
|
61
|
+
data: import('@better-auth/passkey').Passkey;
|
|
62
|
+
error: null;
|
|
63
|
+
} | {
|
|
64
|
+
data: null;
|
|
65
|
+
error: {
|
|
66
|
+
code: string;
|
|
67
|
+
message: string;
|
|
68
|
+
status: number;
|
|
69
|
+
statusText: string;
|
|
70
|
+
};
|
|
71
|
+
}, BetterFetchError, void | AddPasskeyParams<TAuthClient> | undefined, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useListPasskeys as e } from "../../queries/passkey/list-passkeys-query.js";
|
|
2
|
+
import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
|
|
3
|
+
import { passkeyMutationKeys as r } from "@better-auth-ui/core/plugins";
|
|
4
|
+
//#region src/mutations/passkey/add-passkey-mutation.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
let n = r.addPasskey;
|
|
7
|
+
return t({
|
|
8
|
+
mutationKey: n,
|
|
9
|
+
mutationFn: (t) => e.passkey.addPasskey({
|
|
10
|
+
...t ?? {},
|
|
11
|
+
fetchOptions: {
|
|
12
|
+
...t?.fetchOptions,
|
|
13
|
+
throw: !0
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function a(t, r) {
|
|
19
|
+
let { refetch: a } = e(t, { refetchOnMount: !1 });
|
|
20
|
+
return n({
|
|
21
|
+
...i(t),
|
|
22
|
+
...r,
|
|
23
|
+
onSuccess: async (...e) => {
|
|
24
|
+
await a(), await r?.onSuccess?.(...e);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i as addPasskeyOptions, a as useAddPasskey };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { PasskeyAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type DeletePasskeyParams<TAuthClient extends PasskeyAuthClient> = Parameters<TAuthClient["passkey"]["deletePasskey"]>[0];
|
|
4
|
+
export type DeletePasskeyOptions<TAuthClient extends PasskeyAuthClient> = Omit<ReturnType<typeof deletePasskeyOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for deleting a passkey.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deletePasskeyOptions<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, DeletePasskeyParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for deleting a passkey.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.passkey.deletePasskey`, refetches the user's passkey
|
|
17
|
+
* list on success, and forwards React Query mutation options such as
|
|
18
|
+
* `onSuccess`, `onError`, and `retry`.
|
|
19
|
+
*
|
|
20
|
+
* @param authClient - The Better Auth client with the passkey plugin.
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useDeletePasskey<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient, options?: DeletePasskeyOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
}, BetterFetchError, DeletePasskeyParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useListPasskeys as e } from "../../queries/passkey/list-passkeys-query.js";
|
|
2
|
+
import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
|
|
3
|
+
import { passkeyMutationKeys as r } from "@better-auth-ui/core/plugins";
|
|
4
|
+
//#region src/mutations/passkey/delete-passkey-mutation.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
let n = r.deletePasskey;
|
|
7
|
+
return t({
|
|
8
|
+
mutationKey: n,
|
|
9
|
+
mutationFn: (t) => e.passkey.deletePasskey({
|
|
10
|
+
...t,
|
|
11
|
+
fetchOptions: {
|
|
12
|
+
...t?.fetchOptions,
|
|
13
|
+
throw: !0
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function a(t, r) {
|
|
19
|
+
let { refetch: a } = e(t, { refetchOnMount: !1 });
|
|
20
|
+
return n({
|
|
21
|
+
...i(t),
|
|
22
|
+
...r,
|
|
23
|
+
onSuccess: async (...e) => {
|
|
24
|
+
await a(), await r?.onSuccess?.(...e);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i as deletePasskeyOptions, a as useDeletePasskey };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { PasskeyAuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type SignInPasskeyParams<TAuthClient extends PasskeyAuthClient> = Parameters<TAuthClient["signIn"]["passkey"]>[0];
|
|
4
|
+
export type SignInPasskeyOptions<TAuthClient extends PasskeyAuthClient> = Omit<ReturnType<typeof signInPasskeyOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for passkey sign-in.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client with the passkey plugin.
|
|
9
|
+
*/
|
|
10
|
+
export declare function signInPasskeyOptions<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
data: null;
|
|
12
|
+
error: {
|
|
13
|
+
message?: string | undefined;
|
|
14
|
+
status: number;
|
|
15
|
+
statusText: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
data: {
|
|
19
|
+
session: import('better-auth').Session;
|
|
20
|
+
user: import('better-auth').User;
|
|
21
|
+
};
|
|
22
|
+
error: null;
|
|
23
|
+
} | {
|
|
24
|
+
webauthn: {
|
|
25
|
+
response: import('@better-auth/passkey/client').AuthenticationResponseJSON;
|
|
26
|
+
clientExtensionResults: import('@better-auth/passkey/client').AuthenticationExtensionsClientOutputs;
|
|
27
|
+
};
|
|
28
|
+
data: null;
|
|
29
|
+
error: {
|
|
30
|
+
message?: string | undefined;
|
|
31
|
+
status: number;
|
|
32
|
+
statusText: string;
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
webauthn: {
|
|
36
|
+
response: import('@better-auth/passkey/client').AuthenticationResponseJSON;
|
|
37
|
+
clientExtensionResults: import('@better-auth/passkey/client').AuthenticationExtensionsClientOutputs;
|
|
38
|
+
};
|
|
39
|
+
data: {
|
|
40
|
+
session: import('better-auth').Session;
|
|
41
|
+
user: import('better-auth').User;
|
|
42
|
+
};
|
|
43
|
+
error: null;
|
|
44
|
+
} | {
|
|
45
|
+
data: null;
|
|
46
|
+
error: {
|
|
47
|
+
code: string;
|
|
48
|
+
message: string;
|
|
49
|
+
status: number;
|
|
50
|
+
statusText: string;
|
|
51
|
+
};
|
|
52
|
+
}, BetterFetchError, void | SignInPasskeyParams<TAuthClient> | undefined, unknown>, "mutationKey">;
|
|
53
|
+
/**
|
|
54
|
+
* Create a mutation for passkey sign-in.
|
|
55
|
+
*
|
|
56
|
+
* Wraps `authClient.signIn.passkey`, 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 with the passkey plugin.
|
|
61
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useSignInPasskey<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient, options?: SignInPasskeyOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
64
|
+
data: null;
|
|
65
|
+
error: {
|
|
66
|
+
message?: string | undefined;
|
|
67
|
+
status: number;
|
|
68
|
+
statusText: string;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
data: {
|
|
72
|
+
session: import('better-auth').Session;
|
|
73
|
+
user: import('better-auth').User;
|
|
74
|
+
};
|
|
75
|
+
error: null;
|
|
76
|
+
} | {
|
|
77
|
+
webauthn: {
|
|
78
|
+
response: import('@better-auth/passkey/client').AuthenticationResponseJSON;
|
|
79
|
+
clientExtensionResults: import('@better-auth/passkey/client').AuthenticationExtensionsClientOutputs;
|
|
80
|
+
};
|
|
81
|
+
data: null;
|
|
82
|
+
error: {
|
|
83
|
+
message?: string | undefined;
|
|
84
|
+
status: number;
|
|
85
|
+
statusText: string;
|
|
86
|
+
};
|
|
87
|
+
} | {
|
|
88
|
+
webauthn: {
|
|
89
|
+
response: import('@better-auth/passkey/client').AuthenticationResponseJSON;
|
|
90
|
+
clientExtensionResults: import('@better-auth/passkey/client').AuthenticationExtensionsClientOutputs;
|
|
91
|
+
};
|
|
92
|
+
data: {
|
|
93
|
+
session: import('better-auth').Session;
|
|
94
|
+
user: import('better-auth').User;
|
|
95
|
+
};
|
|
96
|
+
error: null;
|
|
97
|
+
} | {
|
|
98
|
+
data: null;
|
|
99
|
+
error: {
|
|
100
|
+
code: string;
|
|
101
|
+
message: string;
|
|
102
|
+
status: number;
|
|
103
|
+
statusText: string;
|
|
104
|
+
};
|
|
105
|
+
}, BetterFetchError, void | SignInPasskeyParams<TAuthClient> | undefined, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { sessionOptions as e } from "../../queries/auth/session-query.js";
|
|
2
|
+
import { mutationOptions as t, useMutation as n, useQueryClient as r } from "@tanstack/react-query";
|
|
3
|
+
import { passkeyMutationKeys as i } from "@better-auth-ui/core/plugins";
|
|
4
|
+
//#region src/mutations/passkey/sign-in-passkey-mutation.ts
|
|
5
|
+
function a(e) {
|
|
6
|
+
let n = i.signIn;
|
|
7
|
+
return t({
|
|
8
|
+
mutationKey: n,
|
|
9
|
+
mutationFn: (t) => e.signIn.passkey({
|
|
10
|
+
...t ?? {},
|
|
11
|
+
fetchOptions: {
|
|
12
|
+
...t?.fetchOptions,
|
|
13
|
+
throw: !0
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function o(t, i) {
|
|
19
|
+
let o = r();
|
|
20
|
+
return n({
|
|
21
|
+
...a(t),
|
|
22
|
+
...i,
|
|
23
|
+
onSuccess: async (...n) => {
|
|
24
|
+
o.resetQueries({ queryKey: e(t).queryKey }), await i?.onSuccess?.(...n);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { a as signInPasskeyOptions, o as useSignInPasskey };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BetterFetchError } from 'better-auth/react';
|
|
2
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
3
|
+
export type ChangeEmailParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["changeEmail"]>[0];
|
|
4
|
+
export type ChangeEmailOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof changeEmailOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
/**
|
|
6
|
+
* Mutation options factory for changing the current user's email address.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function changeEmailOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
|
|
11
|
+
status: boolean;
|
|
12
|
+
}, BetterFetchError, ChangeEmailParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
|
+
/**
|
|
14
|
+
* Create a mutation for changing the current user's email address.
|
|
15
|
+
*
|
|
16
|
+
* Wraps `authClient.changeEmail`, refetches the session on success to
|
|
17
|
+
* surface the new email, and forwards React Query mutation options such
|
|
18
|
+
* 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 useChangeEmail<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: ChangeEmailOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
|
|
24
|
+
status: boolean;
|
|
25
|
+
}, BetterFetchError, ChangeEmailParams<TAuthClient>, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useSession 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 } from "@tanstack/react-query";
|
|
4
|
+
//#region src/mutations/settings/change-email-mutation.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
let r = t.changeEmail;
|
|
7
|
+
return n({
|
|
8
|
+
mutationKey: r,
|
|
9
|
+
mutationFn: (t) => e.changeEmail({
|
|
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 changeEmailOptions, a as useChangeEmail };
|