payload-auth 1.0.2 → 1.1.1
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/better-auth/adapter/index.d.ts +2 -2
- package/dist/better-auth/adapter/index.d.ts.map +1 -1
- package/dist/better-auth/adapter/index.js +115 -69
- package/dist/better-auth/adapter/transform/index.d.ts +22 -10
- package/dist/better-auth/adapter/transform/index.d.ts.map +1 -1
- package/dist/better-auth/adapter/transform/index.js +387 -96
- package/dist/better-auth/adapter/types.d.ts +2 -1
- package/dist/better-auth/adapter/types.d.ts.map +1 -1
- package/dist/better-auth/adapter/types.js +1 -1
- package/dist/better-auth/plugin/helpers/check-passkey-plugin.d.ts +3 -0
- package/dist/better-auth/plugin/helpers/check-passkey-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/check-passkey-plugin.js +5 -0
- package/dist/better-auth/plugin/helpers/check-username-plugin.d.ts +3 -0
- package/dist/better-auth/plugin/helpers/check-username-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/check-username-plugin.js +5 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts.map +1 -1
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +8 -8
- package/dist/better-auth/plugin/helpers/get-admin-access.d.ts +8 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.js +22 -0
- package/dist/better-auth/plugin/helpers/get-admin-routes.d.ts +14 -0
- package/dist/better-auth/plugin/helpers/get-admin-routes.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-admin-routes.js +6 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.d.ts +6 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.js +20 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +1 -1
- package/dist/better-auth/plugin/helpers/get-ip.d.ts.map +1 -1
- package/dist/better-auth/plugin/helpers/get-ip.js +14 -14
- package/dist/better-auth/plugin/helpers/get-requst-collection.d.ts +3 -0
- package/dist/better-auth/plugin/helpers/get-requst-collection.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-requst-collection.js +14 -0
- package/dist/better-auth/plugin/helpers/index.d.ts +1 -1
- package/dist/better-auth/plugin/helpers/index.js +2 -2
- package/dist/better-auth/plugin/{lib → helpers}/prepare-session-data.d.ts +3 -3
- package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js +42 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.d.ts +4 -4
- package/dist/better-auth/plugin/helpers/serialize-cookie.d.ts.map +1 -1
- package/dist/better-auth/plugin/helpers/serialize-cookie.js +34 -34
- package/dist/better-auth/plugin/index.d.ts +7 -7
- package/dist/better-auth/plugin/index.d.ts.map +1 -1
- package/dist/better-auth/plugin/index.js +145 -37
- package/dist/better-auth/plugin/{collections → lib/build-collections}/accounts/hooks/sync-password-to-user.d.ts +1 -1
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js +47 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js +159 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js +11 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js +8 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js +107 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js +196 -0
- package/dist/better-auth/plugin/lib/build-collections/index.d.ts +12 -0
- package/dist/better-auth/plugin/lib/build-collections/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/index.js +96 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.js +91 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.js +43 -0
- package/dist/better-auth/plugin/lib/build-collections/members.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/members.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/members.js +71 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js +98 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js +113 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.js +59 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js +108 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts +8 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.js +123 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js +83 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.js +45 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js +56 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.d.ts +8 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js +52 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/forgot-password.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/forgot-password.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/forgot-password.js +96 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.d.ts +13 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/login.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/login.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/login.js +115 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js +110 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/reset-password.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/reset-password.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/reset-password.js +62 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js +42 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js +79 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/signup.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/signup.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/signup.js +153 -0
- package/dist/better-auth/plugin/{collections → lib/build-collections}/users/hooks/after-login.d.ts +1 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js +75 -0
- package/dist/better-auth/plugin/{collections → lib/build-collections}/users/hooks/after-logout.d.ts +1 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js +74 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js +45 -0
- package/dist/better-auth/plugin/{collections → lib/build-collections}/users/hooks/before-login.d.ts +1 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js +18 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js +14 -0
- package/dist/better-auth/plugin/{collections → lib/build-collections}/users/hooks/sync-account.d.ts +1 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js +82 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts +8 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.js +345 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.d.ts +8 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js +31 -0
- package/dist/better-auth/plugin/lib/{payload-access.d.ts → build-collections/utils/payload-access.d.ts} +1 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js +64 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.js +63 -0
- package/dist/better-auth/plugin/lib/{config.d.ts → constants.d.ts} +13 -1
- package/dist/better-auth/plugin/lib/constants.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/constants.js +56 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +2 -2
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts.map +1 -1
- package/dist/better-auth/plugin/lib/get-payload-auth.js +2 -2
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts +4 -4
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts.map +1 -1
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.js +26 -43
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +4 -3
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts.map +1 -1
- package/dist/better-auth/plugin/lib/init-better-auth.js +7 -7
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.d.ts +3 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js +8 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js +17 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.d.ts +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js +118 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js +58 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js +86 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js +17 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js +17 -0
- package/dist/better-auth/plugin/lib/{ensure-password-set-before-create.d.ts → sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts} +1 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js +23 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js +62 -0
- package/dist/better-auth/plugin/lib/{respect-save-to-jwt-fields-middleware.d.ts → sanitize-better-auth-options/utils/save-to-jwt-middleware.d.ts} +6 -6
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js +30 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js +115 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.scss +31 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.d.ts +11 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js +196 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.scss +131 -0
- package/dist/better-auth/plugin/payload/components/admin-social-provider-buttons/index.d.ts +14 -0
- package/dist/better-auth/plugin/payload/components/admin-social-provider-buttons/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-social-provider-buttons/index.js +111 -0
- package/dist/better-auth/plugin/payload/components/admin-social-provider-buttons/index.scss +51 -0
- package/dist/better-auth/plugin/payload/components/form-header/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/form-header/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/form-header/index.js +23 -0
- package/dist/better-auth/plugin/payload/components/form-header/index.scss +8 -0
- package/dist/better-auth/plugin/payload/components/icons.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/icons.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/icons.js +437 -0
- package/dist/better-auth/plugin/payload/components/logo.d.ts +3 -2
- package/dist/better-auth/plugin/payload/components/logo.d.ts.map +1 -1
- package/dist/better-auth/plugin/payload/components/logo.js +22 -34
- package/dist/better-auth/plugin/payload/components/logout-button.d.ts +6 -0
- package/dist/better-auth/plugin/payload/components/logout-button.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/logout-button.js +27 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.d.ts +7 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js +8 -0
- package/dist/better-auth/plugin/payload/components/styles.css +2 -2
- package/dist/better-auth/plugin/payload/components/token-field.d.ts +5 -0
- package/dist/better-auth/plugin/payload/components/token-field.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/token-field.js +30 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts +6 -3
- package/dist/better-auth/plugin/payload/exports/client.d.ts.map +1 -1
- package/dist/better-auth/plugin/payload/exports/client.js +7 -4
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +9 -5
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts.map +1 -1
- package/dist/better-auth/plugin/payload/exports/rsc.js +10 -6
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.d.ts +3 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js +8 -0
- package/dist/better-auth/plugin/payload/utils/generate-metadata.d.ts +15 -0
- package/dist/better-auth/plugin/payload/utils/generate-metadata.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/utils/generate-metadata.js +74 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.d.ts +2 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js +23 -0
- package/dist/better-auth/plugin/payload/views/admin-invite/client.d.ts +12 -0
- package/dist/better-auth/plugin/payload/views/admin-invite/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-invite/client.js +92 -0
- package/dist/better-auth/plugin/payload/views/admin-invite/index.d.ts +11 -0
- package/dist/better-auth/plugin/payload/views/admin-invite/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-invite/index.js +84 -0
- package/dist/better-auth/plugin/payload/views/admin-invite/index.scss +25 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/client.d.ts +14 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/client.js +95 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.d.ts +10 -4
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.d.ts.map +1 -1
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.js +124 -92
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.scss +29 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js +119 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js +69 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.scss +0 -0
- package/dist/better-auth/plugin/payload/views/inactivity/index.d.ts +5 -0
- package/dist/better-auth/plugin/payload/views/inactivity/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/inactivity/index.js +12 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/login-field.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/login-field.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/login-field.js +54 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/password/index.d.ts +1 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/password/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/password/index.js +121 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/password/index.scss +31 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/password/types.d.ts +56 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/password/types.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/login/form/fields/password/types.js +3 -0
- package/dist/better-auth/plugin/payload/views/login/form/index.d.ts +17 -0
- package/dist/better-auth/plugin/payload/views/login/form/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/login/form/index.js +137 -0
- package/dist/better-auth/plugin/payload/views/login/form/index.scss +23 -0
- package/dist/better-auth/plugin/payload/views/login/index.d.ts +10 -5
- package/dist/better-auth/plugin/payload/views/login/index.d.ts.map +1 -1
- package/dist/better-auth/plugin/payload/views/login/index.js +81 -61
- package/dist/better-auth/plugin/payload/views/login/index.scss +10 -0
- package/dist/better-auth/plugin/payload/views/logout/client.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/logout/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/logout/client.js +76 -0
- package/dist/better-auth/plugin/payload/views/logout/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/logout/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/logout/index.js +14 -0
- package/dist/better-auth/plugin/payload/views/logout/index.scss +0 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts +7 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.js +72 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts +5 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.js +81 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.scss +9 -0
- package/dist/better-auth/plugin/payload/views/reset-password/metadata.d.ts +3 -0
- package/dist/better-auth/plugin/payload/views/reset-password/metadata.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/metadata.js +11 -0
- package/dist/better-auth/plugin/types.d.ts +170 -33
- package/dist/better-auth/plugin/types.d.ts.map +1 -1
- package/dist/better-auth/plugin/types.js +1 -1
- package/dist/clerk/plugin/components/sync-clerk-users-button.d.ts +1 -1
- package/dist/clerk/plugin/components/sync-clerk-users-button.d.ts.map +1 -1
- package/dist/clerk/utils/clerk-user.d.ts +0 -3
- package/dist/clerk/utils/clerk-user.d.ts.map +1 -1
- package/dist/clerk/utils/clerk-user.js +1 -3
- package/dist/clerk/utils/load-clerk-instance.d.ts +1 -1
- package/dist/clerk/utils/load-clerk-instance.d.ts.map +1 -1
- package/package.json +14 -14
- package/LICENSE.md +0 -17
- package/dist/better-auth/adapter/dev/bin/run.d.ts +0 -2
- package/dist/better-auth/adapter/dev/bin/run.d.ts.map +0 -1
- package/dist/better-auth/adapter/dev/bin/run.js +0 -64
- package/dist/better-auth/adapter/dev/bin/schema.d.ts +0 -23
- package/dist/better-auth/adapter/dev/bin/schema.d.ts.map +0 -1
- package/dist/better-auth/adapter/dev/bin/schema.js +0 -160
- package/dist/better-auth/adapter/dev/collections.d.ts +0 -4
- package/dist/better-auth/adapter/dev/collections.d.ts.map +0 -1
- package/dist/better-auth/adapter/dev/collections.js +0 -212
- package/dist/better-auth/adapter/dev/index.d.ts +0 -4
- package/dist/better-auth/adapter/dev/index.d.ts.map +0 -1
- package/dist/better-auth/adapter/dev/index.js +0 -168
- package/dist/better-auth/adapter/test/adapter.test.d.ts +0 -2
- package/dist/better-auth/adapter/test/adapter.test.d.ts.map +0 -1
- package/dist/better-auth/adapter/test/adapter.test.js +0 -181
- package/dist/better-auth/adapter/test/better-auth-adapter-test.d.ts +0 -8
- package/dist/better-auth/adapter/test/better-auth-adapter-test.d.ts.map +0 -1
- package/dist/better-auth/adapter/test/better-auth-adapter-test.js +0 -425
- package/dist/better-auth/adapter/test/schema.test.d.ts +0 -2
- package/dist/better-auth/adapter/test/schema.test.d.ts.map +0 -1
- package/dist/better-auth/adapter/test/schema.test.js +0 -796
- package/dist/better-auth/adapter/test/test_payload1/schema.d.ts +0 -24
- package/dist/better-auth/adapter/test/test_payload1/schema.d.ts.map +0 -1
- package/dist/better-auth/adapter/test/test_payload1/schema.js +0 -177
- package/dist/better-auth/adapter/test/test_payload2/schema.d.ts +0 -24
- package/dist/better-auth/adapter/test/test_payload2/schema.d.ts.map +0 -1
- package/dist/better-auth/adapter/test/test_payload2/schema.js +0 -167
- package/dist/better-auth/adapter/test/test_payload3/schema.d.ts +0 -24
- package/dist/better-auth/adapter/test/test_payload3/schema.d.ts.map +0 -1
- package/dist/better-auth/adapter/test/test_payload3/schema.js +0 -198
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js +0 -47
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.d.ts +0 -7
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js +0 -106
- package/dist/better-auth/plugin/collections/users/hooks/after-login.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/after-login.js +0 -71
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.js +0 -49
- package/dist/better-auth/plugin/collections/users/hooks/before-login.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/before-login.js +0 -18
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.d.ts +0 -6
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js +0 -33
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.d.ts +0 -3
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js +0 -14
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.d.ts.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.js +0 -82
- package/dist/better-auth/plugin/lib/auth-strategy.d.ts +0 -9
- package/dist/better-auth/plugin/lib/auth-strategy.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/auth-strategy.js +0 -48
- package/dist/better-auth/plugin/lib/build-collection-configs.d.ts +0 -12
- package/dist/better-auth/plugin/lib/build-collection-configs.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/build-collection-configs.js +0 -1558
- package/dist/better-auth/plugin/lib/config.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/config.js +0 -44
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js +0 -24
- package/dist/better-auth/plugin/lib/password.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/password.js +0 -63
- package/dist/better-auth/plugin/lib/payload-access.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/payload-access.js +0 -64
- package/dist/better-auth/plugin/lib/prepare-session-data.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/prepare-session-data.js +0 -42
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js +0 -30
- package/dist/better-auth/plugin/lib/sanitize-auth-options.d.ts +0 -6
- package/dist/better-auth/plugin/lib/sanitize-auth-options.d.ts.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-auth-options.js +0 -298
- package/dist/better-auth/plugin/payload/components/admin-buttons.d.ts +0 -7
- package/dist/better-auth/plugin/payload/components/admin-buttons.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/admin-buttons.js +0 -219
- package/dist/better-auth/plugin/payload/components/login-redirect.d.ts +0 -2
- package/dist/better-auth/plugin/payload/components/login-redirect.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/login-redirect.js +0 -6
- package/dist/better-auth/plugin/payload/components/logout.d.ts +0 -3
- package/dist/better-auth/plugin/payload/components/logout.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/logout.js +0 -61
- package/dist/better-auth/plugin/payload/components/sign-in.d.ts +0 -4
- package/dist/better-auth/plugin/payload/components/sign-in.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/sign-in.js +0 -384
- package/dist/better-auth/plugin/payload/components/sign-up.d.ts +0 -7
- package/dist/better-auth/plugin/payload/components/sign-up.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/sign-up.js +0 -503
- package/dist/better-auth/plugin/payload/components/ui/button.d.ts +0 -11
- package/dist/better-auth/plugin/payload/components/ui/button.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/button.js +0 -42
- package/dist/better-auth/plugin/payload/components/ui/card.d.ts +0 -10
- package/dist/better-auth/plugin/payload/components/ui/card.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/card.js +0 -55
- package/dist/better-auth/plugin/payload/components/ui/checkbox.d.ts +0 -5
- package/dist/better-auth/plugin/payload/components/ui/checkbox.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/checkbox.js +0 -23
- package/dist/better-auth/plugin/payload/components/ui/cn.d.ts +0 -3
- package/dist/better-auth/plugin/payload/components/ui/cn.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/cn.js +0 -7
- package/dist/better-auth/plugin/payload/components/ui/input.d.ts +0 -4
- package/dist/better-auth/plugin/payload/components/ui/input.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/input.js +0 -14
- package/dist/better-auth/plugin/payload/components/ui/label.d.ts +0 -5
- package/dist/better-auth/plugin/payload/components/ui/label.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/label.js +0 -15
- package/dist/better-auth/plugin/payload/components/ui/password-input.d.ts +0 -3
- package/dist/better-auth/plugin/payload/components/ui/password-input.d.ts.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/password-input.js +0 -55
- /package/dist/better-auth/plugin/lib/{password.d.ts → sanitize-better-auth-options/utils/password.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/better-auth/plugin/lib/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;CAqB/B,CAAA;AAEV,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAA;AAEV,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;CAaxB,CAAA"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export const supportedBetterAuthPluginIds = {
|
|
2
|
-
harmonyEmail: 'harmony-email',
|
|
3
|
-
harmonyPhoneNumber: 'harmony-phone-number',
|
|
4
|
-
twoFactor: 'two-factor',
|
|
5
|
-
username: 'username',
|
|
6
|
-
anonymous: 'anonymous',
|
|
7
|
-
phoneNumber: 'phone-number',
|
|
8
|
-
magicLink: 'magic-link',
|
|
9
|
-
emailOtp: 'email-otp',
|
|
10
|
-
passkey: 'passkey',
|
|
11
|
-
oneTap: 'one-tap',
|
|
12
|
-
admin: 'admin',
|
|
13
|
-
apiKey: 'api-key',
|
|
14
|
-
organization: 'organization',
|
|
15
|
-
multiSession: 'multi-session',
|
|
16
|
-
openApi: 'open-api',
|
|
17
|
-
jwt: 'jwt',
|
|
18
|
-
nextCookies: 'next-cookies',
|
|
19
|
-
sso: 'sso',
|
|
20
|
-
oidc: 'oidc',
|
|
21
|
-
expo: 'expo'
|
|
22
|
-
};
|
|
23
|
-
export const baseCollectionSlugs = {
|
|
24
|
-
users: 'users',
|
|
25
|
-
sessions: 'sessions',
|
|
26
|
-
accounts: 'accounts',
|
|
27
|
-
verifications: 'verifications'
|
|
28
|
-
};
|
|
29
|
-
export const betterAuthPluginSlugs = {
|
|
30
|
-
apiKeys: 'apiKeys',
|
|
31
|
-
jwks: 'jwks',
|
|
32
|
-
twoFactors: 'twoFactors',
|
|
33
|
-
passkeys: 'passkeys',
|
|
34
|
-
oauthApplications: 'oauthApplications',
|
|
35
|
-
oauthAccessTokens: 'oauthAccessTokens',
|
|
36
|
-
oauthConsents: 'oauthConsents',
|
|
37
|
-
ssoProviders: 'ssoProviders',
|
|
38
|
-
organizations: 'organizations',
|
|
39
|
-
invitations: 'invitations',
|
|
40
|
-
members: 'members',
|
|
41
|
-
teams: 'teams'
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL2NvbmZpZy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3Qgc3VwcG9ydGVkQmV0dGVyQXV0aFBsdWdpbklkcyA9IHtcbiAgaGFybW9ueUVtYWlsOiAnaGFybW9ueS1lbWFpbCcsXG4gIGhhcm1vbnlQaG9uZU51bWJlcjogJ2hhcm1vbnktcGhvbmUtbnVtYmVyJyxcbiAgdHdvRmFjdG9yOiAndHdvLWZhY3RvcicsXG4gIHVzZXJuYW1lOiAndXNlcm5hbWUnLFxuICBhbm9ueW1vdXM6ICdhbm9ueW1vdXMnLFxuICBwaG9uZU51bWJlcjogJ3Bob25lLW51bWJlcicsXG4gIG1hZ2ljTGluazogJ21hZ2ljLWxpbmsnLFxuICBlbWFpbE90cDogJ2VtYWlsLW90cCcsXG4gIHBhc3NrZXk6ICdwYXNza2V5JyxcbiAgb25lVGFwOiAnb25lLXRhcCcsXG4gIGFkbWluOiAnYWRtaW4nLFxuICBhcGlLZXk6ICdhcGkta2V5JyxcbiAgb3JnYW5pemF0aW9uOiAnb3JnYW5pemF0aW9uJyxcbiAgbXVsdGlTZXNzaW9uOiAnbXVsdGktc2Vzc2lvbicsXG4gIG9wZW5BcGk6ICdvcGVuLWFwaScsXG4gIGp3dDogJ2p3dCcsXG4gIG5leHRDb29raWVzOiAnbmV4dC1jb29raWVzJyxcbiAgc3NvOiAnc3NvJyxcbiAgb2lkYzogJ29pZGMnLFxuICBleHBvOiAnZXhwbycsXG59IGFzIGNvbnN0XG5cbmV4cG9ydCBjb25zdCBiYXNlQ29sbGVjdGlvblNs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|
-
{"version":3,"file":"ensure-password-set-before-create.d.ts","sourceRoot":"","sources":["../../../../src/better-auth/plugin/lib/ensure-password-set-before-create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,IAAI,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,0BAA0B,QAoBpF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adds a before hook to the user create operation to ensure the password is set.
|
|
3
|
-
* This is necessary because the password is not set in the user create operation
|
|
4
|
-
* and is instead set in the sync password accounts hook.
|
|
5
|
-
*/ export function ensurePasswordSetBeforeUserCreate(options) {
|
|
6
|
-
if (typeof options.databaseHooks !== 'object') options.databaseHooks = {};
|
|
7
|
-
if (typeof options.databaseHooks.user !== 'object') options.databaseHooks.user = {};
|
|
8
|
-
if (typeof options.databaseHooks.user.create !== 'object') options.databaseHooks.user.create = {};
|
|
9
|
-
const initialBeforeUserCreateHook = options.databaseHooks.user.create.before ?? null;
|
|
10
|
-
options.databaseHooks.user.create.before = async (user, ctx)=>{
|
|
11
|
-
if (!user.password) {
|
|
12
|
-
;
|
|
13
|
-
user.password = ctx?.body?.password ?? Array(3).fill(0).map(()=>Math.random().toString(36).slice(2)).join('');
|
|
14
|
-
}
|
|
15
|
-
if (typeof initialBeforeUserCreateHook === 'function') {
|
|
16
|
-
return initialBeforeUserCreateHook(user, ctx);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
data: user
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL2Vuc3VyZS1wYXNzd29yZC1zZXQtYmVmb3JlLWNyZWF0ZS50cyJdLCJzb3VyY2VzQ29udGVudCI6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A"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
/**
|
|
3
|
-
* Mimics Payload's internal password hashing using pbkdf2
|
|
4
|
-
*
|
|
5
|
-
* This generates a hash compatible with Payload's internal auth system
|
|
6
|
-
* so that passwords set via better-auth can be used with Payload admin panel
|
|
7
|
-
*/ function pbkdf2Promisified(password, salt) {
|
|
8
|
-
return new Promise((resolve, reject)=>crypto.pbkdf2(password, salt, 25000, 512, 'sha256', (err, hashRaw)=>err ? reject(err) : resolve(hashRaw)));
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Generates random bytes for the salt
|
|
12
|
-
*/ function randomBytes() {
|
|
13
|
-
return new Promise((resolve, reject)=>crypto.randomBytes(32, (err, saltBuffer)=>err ? reject(err) : resolve(saltBuffer)));
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Custom implementation of password hashing that matches Payload's format
|
|
17
|
-
*
|
|
18
|
-
* Instead of using better-auth's scrypt, this uses pbkdf2 with the same
|
|
19
|
-
* parameters as Payload CMS
|
|
20
|
-
*
|
|
21
|
-
* @param password The password to hash
|
|
22
|
-
* @returns A string in the format {salt}:{hash}
|
|
23
|
-
*/ export const hashPassword = async (password)=>{
|
|
24
|
-
const saltBuffer = await randomBytes();
|
|
25
|
-
const salt = saltBuffer.toString('hex');
|
|
26
|
-
const hashRaw = await pbkdf2Promisified(password, salt);
|
|
27
|
-
const hash = hashRaw.toString('hex');
|
|
28
|
-
return `${salt}:${hash}`;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Verifies a password against a stored hash
|
|
32
|
-
*
|
|
33
|
-
* This function is flexible and can handle:
|
|
34
|
-
* 1. A combined string in format {salt}:{hash} (for account passwords)
|
|
35
|
-
* 2. When salt and hash need to be combined from user records
|
|
36
|
-
*
|
|
37
|
-
* @param params Object containing the hash and password
|
|
38
|
-
* @returns Boolean indicating if the password matches
|
|
39
|
-
*/ export const verifyPassword = async ({ hash, password, salt })=>{
|
|
40
|
-
let saltValue;
|
|
41
|
-
let storedHash;
|
|
42
|
-
// If salt is provided separately (from user record), use it with the hash
|
|
43
|
-
if (salt) {
|
|
44
|
-
saltValue = salt;
|
|
45
|
-
storedHash = hash;
|
|
46
|
-
} else {
|
|
47
|
-
// Otherwise, split the combined format (from account.password)
|
|
48
|
-
const parts = hash.split(':');
|
|
49
|
-
if (parts.length !== 2) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
;
|
|
53
|
-
[saltValue, storedHash] = parts;
|
|
54
|
-
}
|
|
55
|
-
if (!saltValue || !storedHash) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
const hashRaw = await pbkdf2Promisified(password, saltValue);
|
|
59
|
-
const computedHash = hashRaw.toString('hex');
|
|
60
|
-
return storedHash === computedHash;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL3Bhc3N3b3JkLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBjcnlwdG8gZnJvbSAnY3J5cHRvJ1xuXG4vKipcbiAqIE1pbWljcyBQYXlsb2FkJ3MgaW50ZXJuYWwgcGFzc3dvcmQgaGFzaGluZyB1c2luZyBwYmtkZjJcbiAqXG4gKiBUaGlzIGdlbmVyYXRlcyBhIGhhc2ggY29tcGF0aWJsZSB3aXRoIFBheWxvYWQncyBpbnRlcm5hbCBhdXRoIHN5c3RlbVxuICogc28gdGhhdCBwYXNzd29yZHMgc2V0IHZpYSBiZXR0ZXItYXV0aCBjYW4gYmUgdXNlZCB3aXRoIFBheWxvYWQgYWRtaW4gcGFuZWxcbiAqL1xuZnVuY3Rpb24gcGJrZGYyUHJvbWlzaWZpZWQocGFzc3dvcmQ6IHN0cmluZywgc2FsdDogc3RyaW5n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0QsTUFBTUksUUFBUUosS0FBS0ssS0FBSyxDQUFDO1FBQ3pCLElBQUlELE1BQU1FLE1BQU0sS0FBSyxHQUFHO1lBQ3RCLE9BQU87UUFDVDs7UUFDQyxDQUFDSixXQUFXQyxXQUFXLEdBQUdDO0lBQzdCO0lBRUEsSUFBSSxDQUFDRixhQUFhLENBQUNDLFlBQVk7UUFDN0IsT0FBTztJQUNUO0lBRUEsTUFBTVIsVUFBVSxNQUFNUixrQkFBa0JDLFVBQVVjO0lBQ2xELE1BQU1LLGVBQWVaLFFBQVFJLFFBQVEsQ0FBQztJQUV0QyxPQUFPSSxlQUFlSTtBQUN4QixFQUFDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payload-access.d.ts","sourceRoot":"","sources":["../../../../src/better-auth/plugin/lib/payload-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IACxD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG,wBAAwB,GAAG;IACtE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC1B,SAAQ,gBAAqB,KAAG,WAKhC,CAAA;AAEH,eAAO,MAAM,6BAA6B,GACvC,SAAQ,wBAA6B,KAAG,MAUxC,CAAA;AAEH,eAAO,MAAM,2CAA2C,GACtD,QAAQ,8BAA8B,KACrC,MA2CF,CAAA"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export const isAdminWithRoles = (config = {})=>({ req })=>{
|
|
2
|
-
const { adminRoles = [
|
|
3
|
-
'admin'
|
|
4
|
-
] } = config;
|
|
5
|
-
if (!req?.user || !req.user.role || !adminRoles.includes(req.user.role)) return false;
|
|
6
|
-
return true;
|
|
7
|
-
};
|
|
8
|
-
export const isAdminOrCurrentUserWithRoles = (config = {})=>({ req })=>{
|
|
9
|
-
const { adminRoles = [
|
|
10
|
-
'admin'
|
|
11
|
-
], idField = 'id' } = config;
|
|
12
|
-
if (isAdminWithRoles({
|
|
13
|
-
adminRoles
|
|
14
|
-
})({
|
|
15
|
-
req
|
|
16
|
-
})) return true;
|
|
17
|
-
if (!req?.user) return false;
|
|
18
|
-
return {
|
|
19
|
-
[idField]: {
|
|
20
|
-
equals: req?.user?.id
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export const isAdminOrCurrentUserUpdateWithAllowedFields = (config)=>{
|
|
25
|
-
return async ({ req, id, data })=>{
|
|
26
|
-
const { adminRoles = [
|
|
27
|
-
'admin'
|
|
28
|
-
], allowedFields = [], userSlug, idField = 'id' } = config;
|
|
29
|
-
const user = req.user;
|
|
30
|
-
if (isAdminWithRoles({
|
|
31
|
-
adminRoles
|
|
32
|
-
})({
|
|
33
|
-
req
|
|
34
|
-
})) return true;
|
|
35
|
-
if (!user) return false;
|
|
36
|
-
if (user[idField] === id && data) {
|
|
37
|
-
const dataKeys = Object.keys(data);
|
|
38
|
-
const hasCurrentPassword = dataKeys.includes('currentPassword');
|
|
39
|
-
const hasPassword = dataKeys.includes('password');
|
|
40
|
-
if (hasPassword || hasCurrentPassword) {
|
|
41
|
-
if (!(hasCurrentPassword && hasPassword)) return false;
|
|
42
|
-
try {
|
|
43
|
-
if (!user.email) return false;
|
|
44
|
-
const result = await req.payload.login({
|
|
45
|
-
collection: userSlug,
|
|
46
|
-
data: {
|
|
47
|
-
email: user.email,
|
|
48
|
-
password: data.currentPassword
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (!result) return false;
|
|
52
|
-
allowedFields.push('password', 'currentPassword');
|
|
53
|
-
} catch (error) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const hasDisallowedField = dataKeys.some((key)=>!allowedFields.includes(key));
|
|
58
|
-
return !hasDisallowedField;
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL3BheWxvYWQtYWNjZXNzLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgQWNjZXNzLCBGaWVsZEFjY2VzcyB9IGZyb20gJ3BheWxvYWQnXG5cbmV4cG9ydCB0eXBlIEFkbWluUm9sZXNDb25maWcgPSB7XG4gIGFkbWluUm9sZXM/OiBzdHJpbmdbXVxufVxuXG5leHBvcnQgdHlwZSBBZG1pbk9yQ3VycmVudFVzZXJDb25maWcgPSBBZG1pblJvbGVzQ29uZmlnICYge1xuICBpZEZpZWxkPzogc3RyaW5nXG59XG5cbmV4cG9ydCB0eXBlIEFkbWluT3JDdXJyZW50VXNlclVwZGF0ZUNvbmZpZyA9IEFkbWluT3JDdXJyZW50VXNlckNvbmZpZyAmIHtcbiAgYWxsb3dlZEZpZWxkcz86IHN0cmluZ1tdXG4gIHVzZXJTbHVnOiBzdHJpbmdcbn1cblxuZXhwb3J0IGNvbnN0IGlzQWRtaW5XaXRoUm9sZXMgPVxuICAoY29uZmlnOiBBZG1pblJvbGVzQ29uZmlnID0ge30pOiBGaWVsZEFjY2VzcyA9PlxuICAoeyByZXEgfSkgPT4ge1xuICAgIGNvbnN0IHsgYWRtaW5Sb2xlcyA9IFsnYWRtaW4nXSB9ID0gY29uZmlnXG4gICAgaWYgKCFyZXE/LnVzZXIgfHwgIXJlcS51c2VyLnJvbGUgfHwgIWFkbWluUm9sZXMuaW5jbHVkZXMoc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UFDZixLQUFLZ0IsS0FBSyxFQUFFLE9BQU87b0JBRXhCLE1BQU1DLFNBQVMsTUFBTW5CLElBQUlvQixPQUFPLENBQUNDLEtBQUssQ0FBQzt3QkFDckNDLFlBQVlWO3dCQUNaRixNQUFNOzRCQUNKUSxPQUFPaEIsS0FBS2dCLEtBQUs7NEJBQ2pCSyxVQUFVYixLQUFLYyxlQUFlO3dCQUNoQztvQkFDRjtvQkFFQSxJQUFJLENBQUNMLFFBQVEsT0FBTztvQkFFcEJSLGNBQWNjLElBQUksQ0FBQyxZQUFZO2dCQUNqQyxFQUFFLE9BQU9DLE9BQU87b0JBQ2QsT0FBTztnQkFDVDtZQUNGO1lBRUEsTUFBTUMscUJBQXFCZCxTQUFTZSxJQUFJLENBQUMsQ0FBQ0MsTUFBUSxDQUFDbEIsY0FBY1AsUUFBUSxDQUFDeUI7WUFFMUUsT0FBTyxDQUFDRjtRQUNWO1FBRUEsT0FBTztJQUNUO0FBQ0YsRUFBQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-session-data.d.ts","sourceRoot":"","sources":["../../../../src/better-auth/plugin/lib/prepare-session-data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,UAAU,EACV,aAAa,EACb,eAAe,GAChB,EAAE;IACD,UAAU,EAAE;QACV,IAAI,EAAE,GAAG,CAAA;QACT,OAAO,EAAE,GAAG,CAAA;KACb,CAAA;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAA;IACzC,eAAe,EAAE,eAAe,CAAA;CACjC;;;GA6CA"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { getFieldsToSign } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* Prepares session data for cookie cache by filtering user and session objects
|
|
4
|
-
* based on the payload configuration's 'saveToJwt' property
|
|
5
|
-
*/ export async function prepareSessionData({ newSession, payloadConfig, collectionSlugs }) {
|
|
6
|
-
if (!newSession || !newSession.user) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const { userCollectionSlug, sessionCollectionSlug } = collectionSlugs;
|
|
10
|
-
const userCollection = payloadConfig?.collections?.find((c)=>c.slug === userCollectionSlug);
|
|
11
|
-
const sessionCollection = payloadConfig?.collections?.find((c)=>c.slug === sessionCollectionSlug);
|
|
12
|
-
if (!userCollection) {
|
|
13
|
-
throw new Error(`User collection with slug '${userCollectionSlug}' not found`);
|
|
14
|
-
}
|
|
15
|
-
const filteredUser = getFieldsToSign({
|
|
16
|
-
collectionConfig: userCollection,
|
|
17
|
-
email: newSession.user.email,
|
|
18
|
-
user: newSession.user
|
|
19
|
-
});
|
|
20
|
-
let filteredSession = newSession.session;
|
|
21
|
-
const isImpersonated = newSession.session.impersonatedBy;
|
|
22
|
-
if (sessionCollection && newSession.session) {
|
|
23
|
-
filteredSession = getFieldsToSign({
|
|
24
|
-
collectionConfig: sessionCollection,
|
|
25
|
-
email: newSession.user.email,
|
|
26
|
-
user: newSession.session
|
|
27
|
-
});
|
|
28
|
-
// getFieldsToSign is meant for auth collections so we remove the email and collection fields
|
|
29
|
-
delete filteredSession.email;
|
|
30
|
-
delete filteredSession.collection;
|
|
31
|
-
}
|
|
32
|
-
if (isImpersonated) {
|
|
33
|
-
filteredSession.impersonatedBy = newSession.session.impersonatedBy;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
...newSession,
|
|
37
|
-
user: filteredUser,
|
|
38
|
-
session: filteredSession
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjp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SSxVQUFVO0lBQ25DO0lBRUEsSUFBSUYsZ0JBQWdCO1FBQ2xCRixnQkFBZ0JHLGNBQWMsR0FBR25CLFdBQVdpQixPQUFPLENBQUNFLGNBQWM7SUFDcEU7SUFFQSxPQUFPO1FBQ0wsR0FBR25CLFVBQVU7UUFDYkcsTUFBTVU7UUFDTkksU0FBU0Q7SUFDWDtBQUNGIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"respect-save-to-jwt-fields-middleware.d.ts","sourceRoot":"","sources":["../../../../src/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,8BAA8B,EAAE,MAAM,IAAI,CAAA;AACpF,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAG9C;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAAC,EAC/C,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,EAAE;IACD,gBAAgB,EAAE,0BAA0B,CAAA;IAC5C,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAA;IACzC,aAAa,EAAE,8BAA8B,CAAA;CAC9C,QAoBA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { setCookieCache } from 'better-auth/cookies';
|
|
2
|
-
import { createAuthMiddleware } from 'better-auth/api';
|
|
3
|
-
import { prepareSessionData } from './prepare-session-data';
|
|
4
|
-
/**
|
|
5
|
-
* Sets up a middleware that enforces the saveToJwt configuration when setting session data.
|
|
6
|
-
* This ensures that only fields specified in saveToJwt are included in the cookie cache
|
|
7
|
-
* for both user and session objects.
|
|
8
|
-
*
|
|
9
|
-
* The middleware runs after authentication and filters the session data based on
|
|
10
|
-
* the collection configurations before storing it in the cookie cache.
|
|
11
|
-
*/ export function respectSaveToJwtFieldsMiddleware({ sanitizedOptions, payloadConfig, pluginOptions }) {
|
|
12
|
-
if (typeof sanitizedOptions.hooks !== 'object') sanitizedOptions.hooks = {};
|
|
13
|
-
sanitizedOptions.hooks.after = createAuthMiddleware(async (ctx)=>{
|
|
14
|
-
const newSession = ctx.context?.newSession;
|
|
15
|
-
if (!newSession) return;
|
|
16
|
-
const filteredSessionData = await prepareSessionData({
|
|
17
|
-
newSession,
|
|
18
|
-
payloadConfig,
|
|
19
|
-
collectionSlugs: {
|
|
20
|
-
userCollectionSlug: pluginOptions.users?.slug ?? 'users',
|
|
21
|
-
sessionCollectionSlug: pluginOptions.sessions?.slug ?? 'sessions'
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
if (filteredSessionData) {
|
|
25
|
-
await setCookieCache(ctx, filteredSessionData);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL3Jlc3BlY3Qtc2F2ZS10by1qd3QtZmllbGRzLW1pZGRsZXdhcmUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgc2V0Q29va2llQ2FjaGUgfSBmcm9tICdiZXR0ZXItYXV0aC9jb29raWVzJ1xuaW1wb3J0IHsgY3JlYXRlQXV0aE1pZGRsZXdhcmUgfSBmcm9tICdiZXR0ZXItYXV0aC9hcGknXG5pbXBvcnQgdHlwZSB7IFNhbml0aXplZEJldHRlckF1dGhPcHRpb25zLCBQYXlsb2FkQmV0dGVyQXV0aFBsdWdpbk9wdGlvbnMgfSBmcm9tICcuLidcbmltcG9ydCB0eXBlIHsgQ29uZmlnLCBQYXlsb2FkIH0gZnJvbSAncGF5bG9hZCdcbmltcG9ydCB7IHByZXBhcmVTZXNzaW9uRGF0YSB9IGZyb20gJy4vcHJlcGFyZS1zZXNzaW9uLWRhdGEnXG5cbi8qKlxuICogU2V0cyB1cCBhIG1pZG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UFBUSxzQkFBcUI7QUFDcEQsU0FBU0Msb0JBQW9CLFFBQVEsa0JBQWlCO0FBR3RELFNBQVNDLGtCQUFrQixRQUFRLHlCQUF3QjtBQUUzRDs7Ozs7OztDQU9DLEdBQ0QsT0FBTyxTQUFTQyxpQ0FBaUMsRUFDL0NDLGdCQUFnQixFQUNoQkMsYUFBYSxFQUNiQyxhQUFhLEVBS2Q7SUFDQyxJQUFJLE9BQU9GLGlCQUFpQkcsS0FBSyxLQUFLLFVBQVVILGlCQUFpQkcsS0FBSyxHQUFHLENBQUM7SUFFMUVILGlCQUFpQkcsS0FBSyxDQUFDQyxLQUFLLEdBQUdQLHFCQUFxQixPQUFPUTtRQUN6RCxNQUFNQyxhQUFhRCxJQUFJRSxPQUFPLEVBQUVEO1FBQ2hDLElBQUksQ0FBQ0EsWUFBWTtRQUVqQixNQUFNRSxzQkFBc0IsTUFBTVYsbUJBQW1CO1lBQ25EUTtZQUNBTDtZQUNBUSxpQkFBaUI7Z0JBQ2ZDLG9CQUFvQlIsY0FBY1MsS0FBSyxFQUFFQyxRQUFRO2dCQUNqREMsdUJBQXVCWCxjQUFjWSxRQUFRLEVBQUVGLFFBQVE7WUFDekQ7UUFDRjtRQUVBLElBQUlKLHFCQUFxQjtZQUN2QixNQUFNWixlQUFlUyxLQUFLRztRQUM1QjtJQUNGO0FBQ0YifQ==
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { PayloadBetterAuthPluginOptions, SanitizedBetterAuthOptions } from '..';
|
|
2
|
-
/**
|
|
3
|
-
* Sanitizes the BetterAuth options
|
|
4
|
-
*/
|
|
5
|
-
export declare function sanitizeBetterAuthOptions(options: PayloadBetterAuthPluginOptions): SanitizedBetterAuthOptions;
|
|
6
|
-
//# sourceMappingURL=sanitize-auth-options.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize-auth-options.d.ts","sourceRoot":"","sources":["../../../../src/better-auth/plugin/lib/sanitize-auth-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,MAAM,IAAI,CAAA;AAKpF;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,8BAA8B,GACtC,0BAA0B,CAwT5B"}
|