payload-auth 1.0.1 → 1.1.0
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/authjs/index.d.ts +1 -0
- package/dist/authjs/index.d.ts.map +1 -0
- package/dist/authjs/index.js +1 -1
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts.map +1 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +1 -1
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts.map +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +1 -1
- package/dist/better-auth/adapter/generate-schema/index.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts.map +1 -0
- package/dist/better-auth/adapter/generate-schema/index.js +3 -3
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts.map +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.js +1 -1
- package/dist/better-auth/adapter/index.d.ts +3 -2
- package/dist/better-auth/adapter/index.d.ts.map +1 -0
- package/dist/better-auth/adapter/index.js +115 -69
- package/dist/better-auth/adapter/transform/index.d.ts +19 -6
- package/dist/better-auth/adapter/transform/index.d.ts.map +1 -0
- package/dist/better-auth/adapter/transform/index.js +387 -96
- package/dist/better-auth/adapter/types.d.ts +3 -1
- package/dist/better-auth/adapter/types.d.ts.map +1 -0
- package/dist/better-auth/adapter/types.js +1 -1
- package/dist/better-auth/index.d.ts +1 -0
- package/dist/better-auth/index.d.ts.map +1 -0
- package/dist/better-auth/index.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 +1 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts.map +1 -0
- 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 +2 -1
- package/dist/better-auth/plugin/helpers/get-ip.d.ts.map +1 -0
- 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 +2 -1
- package/dist/better-auth/plugin/helpers/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/index.js +2 -2
- package/dist/better-auth/plugin/{lib → helpers}/prepare-session-data.d.ts +3 -2
- 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 +3 -2
- package/dist/better-auth/plugin/helpers/serialize-cookie.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.js +34 -34
- package/dist/better-auth/plugin/index.d.ts +8 -7
- package/dist/better-auth/plugin/index.d.ts.map +1 -0
- 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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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} +2 -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} +14 -0
- 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 +3 -2
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js +2 -2
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts +5 -4
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.js +26 -43
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +5 -3
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js +6 -6
- 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} +2 -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/{password.d.ts → sanitize-better-auth-options/utils/password.d.ts} +1 -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 -5
- 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 +4 -1
- package/dist/better-auth/plugin/payload/components/logo.d.ts.map +1 -0
- 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 +7 -3
- package/dist/better-auth/plugin/payload/exports/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/exports/client.js +7 -4
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +10 -5
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts.map +1 -0
- 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 +11 -3
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.d.ts.map +1 -0
- 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 +11 -4
- package/dist/better-auth/plugin/payload/views/login/index.d.ts.map +1 -0
- 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 +171 -33
- package/dist/better-auth/plugin/types.d.ts.map +1 -0
- package/dist/better-auth/plugin/types.js +1 -1
- package/dist/better-auth/types.d.ts +1 -0
- package/dist/better-auth/types.d.ts.map +1 -0
- package/dist/better-auth/types.js +1 -1
- package/dist/clerk/admin-ui.d.ts +4 -0
- package/dist/clerk/admin-ui.d.ts.map +1 -0
- package/dist/clerk/admin-ui.js +5 -0
- package/dist/clerk/index.d.ts +7 -1
- package/dist/clerk/index.d.ts.map +1 -0
- package/dist/clerk/index.js +7 -2
- package/dist/clerk/plugin/auth-strategy.d.ts +11 -0
- package/dist/clerk/plugin/auth-strategy.d.ts.map +1 -0
- package/dist/clerk/plugin/auth-strategy.js +45 -0
- package/dist/clerk/plugin/collections/users/access.d.ts +14 -0
- package/dist/clerk/plugin/collections/users/access.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/access.js +36 -0
- package/dist/clerk/plugin/collections/users/endpoints/sync-from-clerk.d.ts +14 -0
- package/dist/clerk/plugin/collections/users/endpoints/sync-from-clerk.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/endpoints/sync-from-clerk.js +108 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/index.d.ts +4 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/index.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/index.js +5 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userCreated.d.ts +13 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userCreated.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userCreated.js +33 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userDeleted.d.ts +11 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userDeleted.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userDeleted.js +27 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userUpdated.d.ts +13 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userUpdated.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userUpdated.js +35 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/index.d.ts +12 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/index.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/endpoints/webhook/index.js +86 -0
- package/dist/clerk/plugin/collections/users/fields.d.ts +6 -0
- package/dist/clerk/plugin/collections/users/fields.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/fields.js +81 -0
- package/dist/clerk/plugin/collections/users/index.d.ts +10 -0
- package/dist/clerk/plugin/collections/users/index.d.ts.map +1 -0
- package/dist/clerk/plugin/collections/users/index.js +95 -0
- package/dist/clerk/plugin/components/after-login-form.d.ts +4 -0
- package/dist/clerk/plugin/components/after-login-form.d.ts.map +1 -0
- package/dist/clerk/plugin/components/after-login-form.js +65 -0
- package/dist/clerk/plugin/components/logout-button.d.ts +2 -0
- package/dist/clerk/plugin/components/logout-button.d.ts.map +1 -0
- package/dist/clerk/plugin/components/logout-button.js +49 -0
- package/dist/clerk/plugin/components/sync-clerk-users-button.d.ts +6 -0
- package/dist/clerk/plugin/components/sync-clerk-users-button.d.ts.map +1 -0
- package/dist/clerk/plugin/components/sync-clerk-users-button.js +75 -0
- package/dist/clerk/plugin.d.ts +6 -0
- package/dist/clerk/plugin.d.ts.map +1 -0
- package/dist/clerk/plugin.js +63 -0
- package/dist/clerk/types.d.ts +63 -0
- package/dist/clerk/types.d.ts.map +1 -0
- package/dist/clerk/types.js +3 -0
- package/dist/clerk/utils/clerk-user.d.ts +21 -0
- package/dist/clerk/utils/clerk-user.d.ts.map +1 -0
- package/dist/clerk/utils/clerk-user.js +45 -0
- package/dist/clerk/utils/index.d.ts +4 -0
- package/dist/clerk/utils/index.d.ts.map +1 -0
- package/dist/clerk/utils/index.js +5 -0
- package/dist/clerk/utils/load-clerk-instance.d.ts +8 -0
- package/dist/clerk/utils/load-clerk-instance.d.ts.map +1 -0
- package/dist/clerk/utils/load-clerk-instance.js +11 -0
- package/dist/clerk/utils/svix.d.ts +9 -0
- package/dist/clerk/utils/svix.d.ts.map +1 -0
- package/dist/clerk/utils/svix.js +40 -0
- package/dist/clerk/utils/user.d.ts +17 -0
- package/dist/clerk/utils/user.d.ts.map +1 -0
- package/dist/clerk/utils/user.js +46 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -5
- package/dist/kinde/index.d.ts +1 -0
- package/dist/kinde/index.d.ts.map +1 -0
- package/dist/kinde/index.js +1 -1
- package/package.json +44 -18
- package/LICENSE.md +0 -17
- package/dist/authjs/index.js.map +0 -1
- package/dist/better-auth/adapter/dev/bin/run.d.ts +0 -1
- package/dist/better-auth/adapter/dev/bin/run.js +0 -64
- package/dist/better-auth/adapter/dev/bin/run.js.map +0 -1
- package/dist/better-auth/adapter/dev/bin/schema.d.ts +0 -22
- package/dist/better-auth/adapter/dev/bin/schema.js +0 -160
- package/dist/better-auth/adapter/dev/bin/schema.js.map +0 -1
- package/dist/better-auth/adapter/dev/collections.d.ts +0 -3
- package/dist/better-auth/adapter/dev/collections.js +0 -212
- package/dist/better-auth/adapter/dev/collections.js.map +0 -1
- package/dist/better-auth/adapter/dev/index.d.ts +0 -3
- package/dist/better-auth/adapter/dev/index.js +0 -168
- package/dist/better-auth/adapter/dev/index.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/index.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/utils.js.map +0 -1
- package/dist/better-auth/adapter/index.js.map +0 -1
- package/dist/better-auth/adapter/test/adapter.test.d.ts +0 -1
- package/dist/better-auth/adapter/test/adapter.test.js +0 -181
- package/dist/better-auth/adapter/test/adapter.test.js.map +0 -1
- package/dist/better-auth/adapter/test/better-auth-adapter-test.d.ts +0 -7
- package/dist/better-auth/adapter/test/better-auth-adapter-test.js +0 -425
- package/dist/better-auth/adapter/test/better-auth-adapter-test.js.map +0 -1
- package/dist/better-auth/adapter/test/schema.test.d.ts +0 -1
- package/dist/better-auth/adapter/test/schema.test.js +0 -796
- package/dist/better-auth/adapter/test/schema.test.js.map +0 -1
- package/dist/better-auth/adapter/test/test_payload1/schema.d.ts +0 -23
- package/dist/better-auth/adapter/test/test_payload1/schema.js +0 -177
- package/dist/better-auth/adapter/test/test_payload1/schema.js.map +0 -1
- package/dist/better-auth/adapter/test/test_payload2/schema.d.ts +0 -23
- package/dist/better-auth/adapter/test/test_payload2/schema.js +0 -167
- package/dist/better-auth/adapter/test/test_payload2/schema.js.map +0 -1
- package/dist/better-auth/adapter/test/test_payload3/schema.d.ts +0 -23
- package/dist/better-auth/adapter/test/test_payload3/schema.js +0 -198
- package/dist/better-auth/adapter/test/test_payload3/schema.js.map +0 -1
- package/dist/better-auth/adapter/transform/index.js.map +0 -1
- package/dist/better-auth/adapter/types.js.map +0 -1
- package/dist/better-auth/index.js.map +0 -1
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js +0 -47
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js.map +0 -1
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.d.ts +0 -6
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js +0 -106
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js.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-login.js.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.js +0 -49
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.js.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/before-login.js +0 -18
- package/dist/better-auth/plugin/collections/users/hooks/before-login.js.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.d.ts +0 -5
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js +0 -33
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.d.ts +0 -2
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js +0 -14
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js.map +0 -1
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.js +0 -82
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.js.map +0 -1
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-ip.js.map +0 -1
- package/dist/better-auth/plugin/helpers/index.js.map +0 -1
- package/dist/better-auth/plugin/helpers/serialize-cookie.js.map +0 -1
- package/dist/better-auth/plugin/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/auth-strategy.d.ts +0 -8
- package/dist/better-auth/plugin/lib/auth-strategy.js +0 -48
- package/dist/better-auth/plugin/lib/auth-strategy.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collection-configs.d.ts +0 -11
- package/dist/better-auth/plugin/lib/build-collection-configs.js +0 -1558
- package/dist/better-auth/plugin/lib/build-collection-configs.js.map +0 -1
- package/dist/better-auth/plugin/lib/config.js +0 -43
- package/dist/better-auth/plugin/lib/config.js.map +0 -1
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js +0 -24
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js.map +0 -1
- package/dist/better-auth/plugin/lib/get-payload-auth.js.map +0 -1
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.js.map +0 -1
- package/dist/better-auth/plugin/lib/init-better-auth.js.map +0 -1
- package/dist/better-auth/plugin/lib/password.js +0 -63
- package/dist/better-auth/plugin/lib/password.js.map +0 -1
- package/dist/better-auth/plugin/lib/payload-access.js +0 -64
- package/dist/better-auth/plugin/lib/payload-access.js.map +0 -1
- package/dist/better-auth/plugin/lib/prepare-session-data.js +0 -42
- package/dist/better-auth/plugin/lib/prepare-session-data.js.map +0 -1
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js +0 -30
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-auth-options.d.ts +0 -5
- package/dist/better-auth/plugin/lib/sanitize-auth-options.js +0 -298
- package/dist/better-auth/plugin/lib/sanitize-auth-options.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/admin-buttons.d.ts +0 -5
- package/dist/better-auth/plugin/payload/components/admin-buttons.js +0 -222
- package/dist/better-auth/plugin/payload/components/admin-buttons.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/login-redirect.d.ts +0 -1
- package/dist/better-auth/plugin/payload/components/login-redirect.js +0 -6
- package/dist/better-auth/plugin/payload/components/login-redirect.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/logo.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/logout.d.ts +0 -1
- package/dist/better-auth/plugin/payload/components/logout.js +0 -61
- package/dist/better-auth/plugin/payload/components/logout.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/sign-in.d.ts +0 -3
- package/dist/better-auth/plugin/payload/components/sign-in.js +0 -384
- package/dist/better-auth/plugin/payload/components/sign-in.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/sign-up.d.ts +0 -6
- package/dist/better-auth/plugin/payload/components/sign-up.js +0 -502
- package/dist/better-auth/plugin/payload/components/sign-up.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/button.d.ts +0 -10
- package/dist/better-auth/plugin/payload/components/ui/button.js +0 -42
- package/dist/better-auth/plugin/payload/components/ui/button.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/card.d.ts +0 -9
- package/dist/better-auth/plugin/payload/components/ui/card.js +0 -55
- package/dist/better-auth/plugin/payload/components/ui/card.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/checkbox.d.ts +0 -4
- package/dist/better-auth/plugin/payload/components/ui/checkbox.js +0 -23
- package/dist/better-auth/plugin/payload/components/ui/checkbox.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/cn.d.ts +0 -2
- package/dist/better-auth/plugin/payload/components/ui/cn.js +0 -7
- package/dist/better-auth/plugin/payload/components/ui/cn.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/input.d.ts +0 -3
- package/dist/better-auth/plugin/payload/components/ui/input.js +0 -14
- package/dist/better-auth/plugin/payload/components/ui/input.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/label.d.ts +0 -4
- package/dist/better-auth/plugin/payload/components/ui/label.js +0 -15
- package/dist/better-auth/plugin/payload/components/ui/label.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/ui/password-input.d.ts +0 -2
- package/dist/better-auth/plugin/payload/components/ui/password-input.js +0 -55
- package/dist/better-auth/plugin/payload/components/ui/password-input.js.map +0 -1
- package/dist/better-auth/plugin/payload/exports/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/exports/rsc.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/login/index.js.map +0 -1
- package/dist/better-auth/plugin/types.js.map +0 -1
- package/dist/better-auth/types.js.map +0 -1
- package/dist/clerk/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kinde/index.js.map +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export const cleanUpUserAfterDelete = async ({ doc, req })=>{
|
|
2
|
-
try {
|
|
3
|
-
const { payload } = req;
|
|
4
|
-
const betterAuthContext = await payload.betterAuth.$context;
|
|
5
|
-
const userId = doc.id;
|
|
6
|
-
const beforeDelete = betterAuthContext.options.user?.deleteUser?.beforeDelete;
|
|
7
|
-
if (typeof beforeDelete === 'function') {
|
|
8
|
-
await beforeDelete(doc, req);
|
|
9
|
-
}
|
|
10
|
-
await betterAuthContext.internalAdapter.deleteSessions(userId);
|
|
11
|
-
await betterAuthContext.internalAdapter.deleteAccounts(userId);
|
|
12
|
-
if (payload.collections.verifications) {
|
|
13
|
-
await payload.delete({
|
|
14
|
-
collection: payload.collections.verifications.config.slug,
|
|
15
|
-
where: {
|
|
16
|
-
value: {
|
|
17
|
-
like: `"${userId}"`
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
const afterDelete = betterAuthContext.options.user?.deleteUser?.afterDelete;
|
|
23
|
-
if (typeof afterDelete === 'function') {
|
|
24
|
-
await afterDelete(doc, req);
|
|
25
|
-
}
|
|
26
|
-
return doc;
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('Error in user afterDelete hook:', error);
|
|
29
|
-
return doc;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=clean-up-user-after-delete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/clean-up-user-after-delete.ts"],"sourcesContent":["import type { CollectionAfterDeleteHook } from 'payload'\nimport type { CollectionHookWithBetterAuth } from '../../../types'\n\ntype CollectionAfterDeleteHookWithBetterAuth =\n CollectionHookWithBetterAuth<CollectionAfterDeleteHook>\n\nexport const cleanUpUserAfterDelete: CollectionAfterDeleteHookWithBetterAuth = async ({\n doc,\n req,\n}) => {\n try {\n const { payload } = req\n const betterAuthContext = await payload.betterAuth.$context\n const userId = doc.id\n const beforeDelete = betterAuthContext.options.user?.deleteUser?.beforeDelete\n if (typeof beforeDelete === 'function') {\n await beforeDelete(doc, req as Request)\n }\n await betterAuthContext.internalAdapter.deleteSessions(userId)\n await betterAuthContext.internalAdapter.deleteAccounts(userId)\n if (payload.collections.verifications) {\n await payload.delete({\n collection: payload.collections.verifications.config.slug,\n where: {\n value: {\n like: `\"${userId}\"`,\n },\n },\n })\n }\n const afterDelete = betterAuthContext.options.user?.deleteUser?.afterDelete\n if (typeof afterDelete === 'function') {\n await afterDelete(doc, req as Request)\n }\n return doc\n } catch (error) {\n console.error('Error in user afterDelete hook:', error)\n return doc\n }\n}\n"],"names":["cleanUpUserAfterDelete","doc","req","payload","betterAuthContext","betterAuth","$context","userId","id","beforeDelete","options","user","deleteUser","internalAdapter","deleteSessions","deleteAccounts","collections","verifications","delete","collection","config","slug","where","value","like","afterDelete","error","console"],"mappings":"AAMA,OAAO,MAAMA,yBAAkE,OAAO,EACpFC,GAAG,EACHC,GAAG,EACJ;IACC,IAAI;QACF,MAAM,EAAEC,OAAO,EAAE,GAAGD;QACpB,MAAME,oBAAoB,MAAMD,QAAQE,UAAU,CAACC,QAAQ;QAC3D,MAAMC,SAASN,IAAIO,EAAE;QACrB,MAAMC,eAAeL,kBAAkBM,OAAO,CAACC,IAAI,EAAEC,YAAYH;QACjE,IAAI,OAAOA,iBAAiB,YAAY;YACtC,MAAMA,aAAaR,KAAKC;QAC1B;QACA,MAAME,kBAAkBS,eAAe,CAACC,cAAc,CAACP;QACvD,MAAMH,kBAAkBS,eAAe,CAACE,cAAc,CAACR;QACvD,IAAIJ,QAAQa,WAAW,CAACC,aAAa,EAAE;YACrC,MAAMd,QAAQe,MAAM,CAAC;gBACnBC,YAAYhB,QAAQa,WAAW,CAACC,aAAa,CAACG,MAAM,CAACC,IAAI;gBACzDC,OAAO;oBACLC,OAAO;wBACLC,MAAM,CAAC,CAAC,EAAEjB,OAAO,CAAC,CAAC;oBACrB;gBACF;YACF;QACF;QACA,MAAMkB,cAAcrB,kBAAkBM,OAAO,CAACC,IAAI,EAAEC,YAAYa;QAChE,IAAI,OAAOA,gBAAgB,YAAY;YACrC,MAAMA,YAAYxB,KAAKC;QACzB;QACA,OAAOD;IACT,EAAE,OAAOyB,OAAO;QACdC,QAAQD,KAAK,CAAC,mCAAmCA;QACjD,OAAOzB;IACT;AACF,EAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const onVerifiedChange = async ({ data, originalDoc })=>{
|
|
2
|
-
const isVerifiedChangingToTrue = Boolean(data._verified) && !Boolean(originalDoc?._verified);
|
|
3
|
-
const isEmailVerifiedChangingToTrue = Boolean(data.emailVerified) && !Boolean(originalDoc?.emailVerified);
|
|
4
|
-
if (!isVerifiedChangingToTrue && !isEmailVerifiedChangingToTrue) {
|
|
5
|
-
return data;
|
|
6
|
-
}
|
|
7
|
-
return {
|
|
8
|
-
...data,
|
|
9
|
-
_verified: true,
|
|
10
|
-
emailVerified: true
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=on-verified-change.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/on-verified-change.ts"],"sourcesContent":["import { CollectionBeforeChangeHook } from 'payload'\n\nexport const onVerifiedChange: CollectionBeforeChangeHook = async ({ data, originalDoc }) => {\n const isVerifiedChangingToTrue = Boolean(data._verified) && !Boolean(originalDoc?._verified)\n const isEmailVerifiedChangingToTrue =\n Boolean(data.emailVerified) && !Boolean(originalDoc?.emailVerified)\n\n if (!isVerifiedChangingToTrue && !isEmailVerifiedChangingToTrue) {\n return data\n }\n\n return {\n ...data,\n _verified: true,\n emailVerified: true,\n }\n}\n"],"names":["onVerifiedChange","data","originalDoc","isVerifiedChangingToTrue","Boolean","_verified","isEmailVerifiedChangingToTrue","emailVerified"],"mappings":"AAEA,OAAO,MAAMA,mBAA+C,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAE;IACtF,MAAMC,2BAA2BC,QAAQH,KAAKI,SAAS,KAAK,CAACD,QAAQF,aAAaG;IAClF,MAAMC,gCACJF,QAAQH,KAAKM,aAAa,KAAK,CAACH,QAAQF,aAAaK;IAEvD,IAAI,CAACJ,4BAA4B,CAACG,+BAA+B;QAC/D,OAAOL;IACT;IAEA,OAAO;QACL,GAAGA,IAAI;QACPI,WAAW;QACXE,eAAe;IACjB;AACF,EAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { BETTER_AUTH_CONTEXT_KEY } from 'payload-auth/better-auth/adapter';
|
|
2
|
-
export const getSyncAccountHook = (options)=>{
|
|
3
|
-
const hook = async ({ doc, req, operation, context })=>{
|
|
4
|
-
if (context?.syncPasswordToUser) return doc;
|
|
5
|
-
if (operation !== 'create' && operation !== 'update') return doc;
|
|
6
|
-
const user = await req.payload.findByID({
|
|
7
|
-
collection: options.userSlug,
|
|
8
|
-
id: doc.id,
|
|
9
|
-
depth: 0,
|
|
10
|
-
req,
|
|
11
|
-
showHiddenFields: true
|
|
12
|
-
});
|
|
13
|
-
if (!user || !user.hash || !user.salt) return doc;
|
|
14
|
-
const passwordValue = `${user.salt}:${user.hash}`;
|
|
15
|
-
const userField = req.payload.betterAuth.options.account?.fields?.userId || 'userId';
|
|
16
|
-
if (operation === 'create' && !(BETTER_AUTH_CONTEXT_KEY in context)) {
|
|
17
|
-
try {
|
|
18
|
-
await req.payload.create({
|
|
19
|
-
collection: options.accountSlug,
|
|
20
|
-
data: {
|
|
21
|
-
[userField]: doc.id,
|
|
22
|
-
accountId: doc.id.toString(),
|
|
23
|
-
providerId: 'credential',
|
|
24
|
-
password: passwordValue,
|
|
25
|
-
context: {
|
|
26
|
-
syncAccountHook: true
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
req
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error('Failed to create account for user:', error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (operation === 'update') {
|
|
36
|
-
try {
|
|
37
|
-
const accounts = await req.payload.find({
|
|
38
|
-
collection: options.accountSlug,
|
|
39
|
-
where: {
|
|
40
|
-
and: [
|
|
41
|
-
{
|
|
42
|
-
[userField]: {
|
|
43
|
-
equals: doc.id
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
providerId: {
|
|
48
|
-
equals: 'credential'
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
req,
|
|
54
|
-
depth: 0,
|
|
55
|
-
context: {
|
|
56
|
-
syncAccountHook: true
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
const account = accounts.docs.at(0);
|
|
60
|
-
if (account) {
|
|
61
|
-
await req.payload.update({
|
|
62
|
-
collection: options.accountSlug,
|
|
63
|
-
id: account.id,
|
|
64
|
-
data: {
|
|
65
|
-
password: passwordValue
|
|
66
|
-
},
|
|
67
|
-
req,
|
|
68
|
-
context: {
|
|
69
|
-
syncAccountHook: true
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.error('Failed to sync hash/salt to account:', error);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return doc;
|
|
78
|
-
};
|
|
79
|
-
return hook;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=sync-account.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/sync-account.ts"],"sourcesContent":["import type { CollectionAfterChangeHook } from 'payload'\nimport type { CollectionHookWithBetterAuth } from '../../../types'\nimport { BETTER_AUTH_CONTEXT_KEY } from 'payload-auth/better-auth/adapter'\n\ntype CollectionAfterChangeHookWithBetterAuth =\n CollectionHookWithBetterAuth<CollectionAfterChangeHook>\n\ntype SyncAccountOptions = {\n userSlug: string\n accountSlug: string\n}\n\nexport const getSyncAccountHook = (options: SyncAccountOptions): CollectionAfterChangeHook => {\n const hook: CollectionAfterChangeHookWithBetterAuth = async ({\n doc,\n req,\n operation,\n context,\n }) => {\n if (context?.syncPasswordToUser) return doc\n\n if (operation !== 'create' && operation !== 'update') return doc\n\n const user = await req.payload.findByID({\n collection: options.userSlug,\n id: doc.id,\n depth: 0,\n req,\n showHiddenFields: true,\n })\n\n if (!user || !user.hash || !user.salt) return doc\n\n const passwordValue = `${user.salt}:${user.hash}`\n const userField = req.payload.betterAuth.options.account?.fields?.userId || 'userId'\n\n if (operation === 'create' && !(BETTER_AUTH_CONTEXT_KEY in context)) {\n try {\n await req.payload.create({\n collection: options.accountSlug,\n data: {\n [userField]: doc.id,\n accountId: doc.id.toString(),\n providerId: 'credential',\n password: passwordValue,\n context: { syncAccountHook: true },\n },\n req,\n })\n } catch (error) {\n console.error('Failed to create account for user:', error)\n }\n }\n\n if (operation === 'update') {\n try {\n const accounts = await req.payload.find({\n collection: options.accountSlug,\n where: {\n and: [{ [userField]: { equals: doc.id } }, { providerId: { equals: 'credential' } }],\n },\n req,\n depth: 0,\n context: { syncAccountHook: true },\n })\n\n const account = accounts.docs.at(0)\n if (account) {\n await req.payload.update({\n collection: options.accountSlug,\n id: account.id,\n data: {\n password: passwordValue,\n },\n req,\n context: { syncAccountHook: true },\n })\n }\n } catch (error) {\n console.error('Failed to sync hash/salt to account:', error)\n }\n }\n\n return doc\n }\n\n return hook as CollectionAfterChangeHook\n}\n"],"names":["BETTER_AUTH_CONTEXT_KEY","getSyncAccountHook","options","hook","doc","req","operation","context","syncPasswordToUser","user","payload","findByID","collection","userSlug","id","depth","showHiddenFields","hash","salt","passwordValue","userField","betterAuth","account","fields","userId","create","accountSlug","data","accountId","toString","providerId","password","syncAccountHook","error","console","accounts","find","where","and","equals","docs","at","update"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ,mCAAkC;AAU1E,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,OAAgD,OAAO,EAC3DC,GAAG,EACHC,GAAG,EACHC,SAAS,EACTC,OAAO,EACR;QACC,IAAIA,SAASC,oBAAoB,OAAOJ;QAExC,IAAIE,cAAc,YAAYA,cAAc,UAAU,OAAOF;QAE7D,MAAMK,OAAO,MAAMJ,IAAIK,OAAO,CAACC,QAAQ,CAAC;YACtCC,YAAYV,QAAQW,QAAQ;YAC5BC,IAAIV,IAAIU,EAAE;YACVC,OAAO;YACPV;YACAW,kBAAkB;QACpB;QAEA,IAAI,CAACP,QAAQ,CAACA,KAAKQ,IAAI,IAAI,CAACR,KAAKS,IAAI,EAAE,OAAOd;QAE9C,MAAMe,gBAAgB,GAAGV,KAAKS,IAAI,CAAC,CAAC,EAAET,KAAKQ,IAAI,EAAE;QACjD,MAAMG,YAAYf,IAAIK,OAAO,CAACW,UAAU,CAACnB,OAAO,CAACoB,OAAO,EAAEC,QAAQC,UAAU;QAE5E,IAAIlB,cAAc,YAAY,CAAEN,CAAAA,2BAA2BO,OAAM,GAAI;YACnE,IAAI;gBACF,MAAMF,IAAIK,OAAO,CAACe,MAAM,CAAC;oBACvBb,YAAYV,QAAQwB,WAAW;oBAC/BC,MAAM;wBACJ,CAACP,UAAU,EAAEhB,IAAIU,EAAE;wBACnBc,WAAWxB,IAAIU,EAAE,CAACe,QAAQ;wBAC1BC,YAAY;wBACZC,UAAUZ;wBACVZ,SAAS;4BAAEyB,iBAAiB;wBAAK;oBACnC;oBACA3B;gBACF;YACF,EAAE,OAAO4B,OAAO;gBACdC,QAAQD,KAAK,CAAC,sCAAsCA;YACtD;QACF;QAEA,IAAI3B,cAAc,UAAU;YAC1B,IAAI;gBACF,MAAM6B,WAAW,MAAM9B,IAAIK,OAAO,CAAC0B,IAAI,CAAC;oBACtCxB,YAAYV,QAAQwB,WAAW;oBAC/BW,OAAO;wBACLC,KAAK;4BAAC;gCAAE,CAAClB,UAAU,EAAE;oCAAEmB,QAAQnC,IAAIU,EAAE;gCAAC;4BAAE;4BAAG;gCAAEgB,YAAY;oCAAES,QAAQ;gCAAa;4BAAE;yBAAE;oBACtF;oBACAlC;oBACAU,OAAO;oBACPR,SAAS;wBAAEyB,iBAAiB;oBAAK;gBACnC;gBAEA,MAAMV,UAAUa,SAASK,IAAI,CAACC,EAAE,CAAC;gBACjC,IAAInB,SAAS;oBACX,MAAMjB,IAAIK,OAAO,CAACgC,MAAM,CAAC;wBACvB9B,YAAYV,QAAQwB,WAAW;wBAC/BZ,IAAIQ,QAAQR,EAAE;wBACda,MAAM;4BACJI,UAAUZ;wBACZ;wBACAd;wBACAE,SAAS;4BAAEyB,iBAAiB;wBAAK;oBACnC;gBACF;YACF,EAAE,OAAOC,OAAO;gBACdC,QAAQD,KAAK,CAAC,wCAAwCA;YACxD;QACF;QAEA,OAAO7B;IACT;IAEA,OAAOD;AACT,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugin/helpers/generate-verify-email-url.ts"],"sourcesContent":["import { SignJWT } from 'jose'\n\n/**\n * Generates a verification URL for email verification\n *\n * This utility function creates a JWT token containing the user's email and\n * expiration information, signs it with the provided secret, and constructs\n * a verification URL with the token as a query parameter.\n *\n * @param userEmail - The email address of the user to verify\n * @param secret - The secret used to sign the JWT\n * @param expiresIn - Duration in seconds for token expiration (default: 3600)\n * @param verifyRouteUrl - The base URL for the verification endpoint\n * @param callbackURL - Optional callback URL after verification (default: \"/\")\n * @returns The complete verification URL with token\n *\n * @example\n * const url = await generateVerifyEmailUrl({\n * userEmail: 'user@example.com',\n * secret: 'your-secret-key',\n * verifyRouteUrl: 'https://your-app.com/api/auth/verify-email',\n * callbackURL: '/profile'\n * });\n */\nexport const generateVerifyEmailUrl = async ({\n userEmail,\n secret,\n expiresIn = 3600,\n verifyRouteUrl,\n callbackURL = '/',\n}: {\n userEmail: string\n secret: string\n expiresIn?: number\n verifyRouteUrl: string\n callbackURL?: string\n}): Promise<string> => {\n if (!userEmail) {\n throw new Error('userEmail is required to generate a verification URL')\n }\n\n if (!secret) {\n throw new Error('secret is required to sign the JWT token')\n }\n\n if (!verifyRouteUrl) {\n throw new Error('verifyRouteUrl is required to generate a verification URL')\n }\n\n // Create and sign the JWT token\n const jwt = await new SignJWT({\n email: userEmail,\n iat: Math.floor(Date.now() / 1000),\n exp: Math.floor(Date.now() / 1000) + expiresIn,\n })\n .setProtectedHeader({ alg: 'HS256' })\n .sign(new TextEncoder().encode(secret))\n\n // Build the verification URL\n const verifyUrl = `${verifyRouteUrl}?token=${jwt}${callbackURL ? `&callbackURL=${encodeURIComponent(callbackURL)}` : ''}`\n\n return verifyUrl\n}\n"],"names":["SignJWT","generateVerifyEmailUrl","userEmail","secret","expiresIn","verifyRouteUrl","callbackURL","Error","jwt","email","iat","Math","floor","Date","now","exp","setProtectedHeader","alg","sign","TextEncoder","encode","verifyUrl","encodeURIComponent"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAM;AAE9B;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,MAAMC,yBAAyB,OAAO,EAC3CC,SAAS,EACTC,MAAM,EACNC,YAAY,IAAI,EAChBC,cAAc,EACdC,cAAc,GAAG,EAOlB;IACC,IAAI,CAACJ,WAAW;QACd,MAAM,IAAIK,MAAM;IAClB;IAEA,IAAI,CAACJ,QAAQ;QACX,MAAM,IAAII,MAAM;IAClB;IAEA,IAAI,CAACF,gBAAgB;QACnB,MAAM,IAAIE,MAAM;IAClB;IAEA,gCAAgC;IAChC,MAAMC,MAAM,MAAM,IAAIR,QAAQ;QAC5BS,OAAOP;QACPQ,KAAKC,KAAKC,KAAK,CAACC,KAAKC,GAAG,KAAK;QAC7BC,KAAKJ,KAAKC,KAAK,CAACC,KAAKC,GAAG,KAAK,QAAQV;IACvC,GACGY,kBAAkB,CAAC;QAAEC,KAAK;IAAQ,GAClCC,IAAI,CAAC,IAAIC,cAAcC,MAAM,CAACjB;IAEjC,6BAA6B;IAC7B,MAAMkB,YAAY,GAAGhB,eAAe,OAAO,EAAEG,MAAMF,cAAc,CAAC,aAAa,EAAEgB,mBAAmBhB,cAAc,GAAG,IAAI;IAEzH,OAAOe;AACT,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugin/helpers/get-ip.ts"],"sourcesContent":["import type { BetterAuthOptions } from 'better-auth'\n\nexport function getIp(headers: Headers, options: BetterAuthOptions): string | null {\n if (options.advanced?.ipAddress?.disableIpTracking) {\n return null\n }\n const testIP = '127.0.0.1'\n if ((process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development') ?? false) {\n return testIP\n }\n const ipHeaders = options.advanced?.ipAddress?.ipAddressHeaders\n const keys = ipHeaders || [\n 'x-client-ip',\n 'x-forwarded-for',\n 'cf-connecting-ip',\n 'fastly-client-ip',\n 'x-real-ip',\n 'x-cluster-client-ip',\n 'x-forwarded',\n 'forwarded-for',\n 'forwarded',\n ]\n for (const key of keys) {\n const value = headers.get(key)\n if (typeof value === 'string') {\n const ip = value.split(',')[0].trim()\n if (ip) return ip\n }\n }\n return null\n}\n"],"names":["getIp","headers","options","advanced","ipAddress","disableIpTracking","testIP","process","env","NODE_ENV","ipHeaders","ipAddressHeaders","keys","key","value","get","ip","split","trim"],"mappings":"AAEA,OAAO,SAASA,MAAMC,OAAgB,EAAEC,OAA0B;IAChE,IAAIA,QAAQC,QAAQ,EAAEC,WAAWC,mBAAmB;QAClD,OAAO;IACT;IACA,MAAMC,SAAS;IACf,IAAI,AAACC,CAAAA,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUF,QAAQC,GAAG,CAACC,QAAQ,KAAK,aAAY,KAAM,OAAO;QACxF,OAAOH;IACT;IACA,MAAMI,YAAYR,QAAQC,QAAQ,EAAEC,WAAWO;IAC/C,MAAMC,OAAOF,aAAa;QACxB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IACD,KAAK,MAAMG,OAAOD,KAAM;QACtB,MAAME,QAAQb,QAAQc,GAAG,CAACF;QAC1B,IAAI,OAAOC,UAAU,UAAU;YAC7B,MAAME,KAAKF,MAAMG,KAAK,CAAC,IAAI,CAAC,EAAE,CAACC,IAAI;YACnC,IAAIF,IAAI,OAAOA;QACjB;IACF;IACA,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugin/helpers/index.ts"],"sourcesContent":["export { generateVerifyEmailUrl } from './generate-verify-email-url'; "],"names":["generateVerifyEmailUrl"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,8BAA8B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugin/helpers/serialize-cookie.ts"],"sourcesContent":["import { subtle } from 'uncrypto'\n\ntype CookiePrefixOptions = 'host' | 'secure'\n\ntype CookieOptions = {\n /**\n * Domain of the cookie\n *\n * The Domain attribute specifies which server can receive a cookie. If specified, cookies are\n * available on the specified server and its subdomains. If the it is not\n * specified, the cookies are available on the server that sets it but not on\n * its subdomains.\n *\n * @example\n * `domain: \"example.com\"`\n */\n domain?: string\n /**\n * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the\n * Expires attribute:\n *\n * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and\n * takes precedence when both are set. The rationale behind this is that when you set an\n * Expires date and time, they're relative to the client the cookie is being set on. If the\n * server is set to a different time, this could cause errors\n */\n expires?: Date\n /**\n * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie\n * property. Note that a cookie that has been created with HttpOnly will still be sent with\n * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().\n * This mitigates attacks against cross-site scripting\n */\n httpOnly?: boolean\n /**\n * Indicates the number of seconds until the cookie expires. A zero or negative number will\n * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.\n *\n * @example 604800 - 7 days\n */\n maxAge?: number\n /**\n * Indicates the path that must exist in the requested URL for the browser to send the Cookie\n * header.\n *\n * @example\n * \"/docs\"\n * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.\n */\n path?: string\n /**\n * Indicates that the cookie is sent to the server only when a request is made with the https:\n * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.\n */\n secure?: boolean\n /**\n * Controls whether or not a cookie is sent with cross-site requests, providing some protection\n * against cross-site request forgery attacks (CSRF).\n *\n * Strict - Means that the browser sends the cookie only for same-site requests, that is,\n * requests originating from the same site that set the cookie. If a request originates from a\n * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict\n * attribute are sent.\n *\n * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load\n * images or frames, but is sent when a user is navigating to the origin site from an external\n * site (for example, when following a link). This is the default behavior if the SameSite\n * attribute is not specified.\n *\n * None - Means that the browser sends the cookie with both cross-site and same-site requests.\n * The Secure attribute must also be set when setting this value.\n */\n sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none'\n /**\n * Indicates that the cookie should be stored using partitioned storage. Note that if this is\n * set, the Secure directive must also be set.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies\n */\n partitioned?: boolean\n /**\n * Cooke Prefix\n *\n * - secure: `__Secure-` -> `__Secure-cookie-name`\n * - host: `__Host-` -> `__Host-cookie-name`\n *\n * `secure` must be set to true to use prefixes\n */\n prefix?: CookiePrefixOptions\n}\n\nexport const verifySignature = async (\n base64Signature: string,\n value: string,\n secret: CryptoKey,\n): Promise<boolean> => {\n try {\n const signatureBinStr = atob(base64Signature)\n const signature = new Uint8Array(signatureBinStr.length)\n for (let i = 0, len = signatureBinStr.length; i < len; i++) {\n signature[i] = signatureBinStr.charCodeAt(i)\n }\n return await subtle.verify(algorithm, secret, signature, new TextEncoder().encode(value))\n } catch (e) {\n return false\n }\n}\n\nconst _serialize = (key: string, value: string, opt: CookieOptions = {}) => {\n let cookie: string\n\n if (opt?.prefix === 'secure') {\n cookie = `${`__Secure-${key}`}=${value}`\n } else if (opt?.prefix === 'host') {\n cookie = `${`__Host-${key}`}=${value}`\n } else {\n cookie = `${key}=${value}`\n }\n\n if (key.startsWith('__Secure-') && !opt.secure) {\n opt.secure = true\n }\n\n if (key.startsWith('__Host-')) {\n if (!opt.secure) {\n opt.secure = true\n }\n\n if (opt.path !== '/') {\n opt.path = '/'\n }\n\n if (opt.domain) {\n opt.domain = undefined\n }\n }\n\n if (opt && typeof opt.maxAge === 'number' && opt.maxAge >= 0) {\n if (opt.maxAge > 34560000) {\n throw new Error(\n 'Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.',\n )\n }\n cookie += `; Max-Age=${Math.floor(opt.maxAge)}`\n }\n\n if (opt.domain && opt.prefix !== 'host') {\n cookie += `; Domain=${opt.domain}`\n }\n\n if (opt.path) {\n cookie += `; Path=${opt.path}`\n }\n\n if (opt.expires) {\n if (opt.expires.getTime() - Date.now() > 34560000_000) {\n throw new Error(\n 'Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.',\n )\n }\n cookie += `; Expires=${opt.expires.toUTCString()}`\n }\n\n if (opt.httpOnly) {\n cookie += '; HttpOnly'\n }\n\n if (opt.secure) {\n cookie += '; Secure'\n }\n\n if (opt.sameSite) {\n cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`\n }\n\n if (opt.partitioned) {\n if (!opt.secure) {\n opt.secure = true\n }\n cookie += '; Partitioned'\n }\n\n return cookie\n}\n\nconst algorithm = { name: 'HMAC', hash: 'SHA-256' }\n\nconst getCryptoKey = async (secret: string | BufferSource) => {\n const secretBuf = typeof secret === 'string' ? new TextEncoder().encode(secret) : secret\n return await subtle.importKey('raw', secretBuf, algorithm, false, ['sign', 'verify'])\n}\n\nconst makeSignature = async (value: string, secret: string | BufferSource): Promise<string> => {\n const key = await getCryptoKey(secret)\n const signature = await subtle.sign(algorithm.name, key, new TextEncoder().encode(value))\n // the returned base64 encoded signature will always be 44 characters long and end with one or two equal signs\n return btoa(String.fromCharCode(...new Uint8Array(signature)))\n}\n\nexport const signCookieValue = async (value: string, secret: string | BufferSource) => {\n const signature = await makeSignature(value, secret)\n value = `${value}.${signature}`\n value = encodeURIComponent(value)\n value = decodeURIComponent(value)\n return value\n}\n\nexport const serializeCookie = (key: string, value: string, opt?: CookieOptions) => {\n value = encodeURIComponent(value)\n return _serialize(key, value, opt)\n}\n\nexport const serializeSignedCookie = async (\n key: string,\n value: string,\n secret: string,\n opt?: CookieOptions,\n) => {\n value = await signCookieValue(value, secret)\n return _serialize(key, value, opt)\n}\n\nexport const getCookieKey = (key: string, prefix?: CookiePrefixOptions) => {\n let finalKey = key\n if (prefix) {\n if (prefix === 'secure') {\n finalKey = '__Secure-' + key\n } else if (prefix === 'host') {\n finalKey = '__Host-' + key\n } else {\n return undefined\n }\n }\n return finalKey\n}\n\nexport function tryDecode(str: string) {\n try {\n return str.includes('%') ? decodeURIComponent(str) : str\n } catch {\n return str\n }\n}\n\n/**\n * Parse an HTTP Cookie header string and returning an object of all cookie\n * name-value pairs.\n *\n * Inspired by https://github.com/unjs/cookie-es/blob/main/src/cookie/parse.ts\n *\n * @param str the string representing a `Cookie` header value\n */\nexport function parseCookies(str: string) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string')\n }\n\n const cookies: Map<string, string> = new Map()\n\n let index = 0\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index)\n\n if (eqIdx === -1) {\n break\n }\n\n let endIdx = str.indexOf(';', index)\n\n if (endIdx === -1) {\n endIdx = str.length\n } else if (endIdx < eqIdx) {\n index = str.lastIndexOf(';', eqIdx - 1) + 1\n continue\n }\n\n const key = str.slice(index, eqIdx).trim()\n if (!cookies.has(key)) {\n let val = str.slice(eqIdx + 1, endIdx).trim()\n if (val.codePointAt(0) === 0x22) {\n val = val.slice(1, -1)\n }\n cookies.set(key, tryDecode(val))\n }\n\n index = endIdx + 1\n }\n\n return cookies\n}\n\nexport const getSignedCookie = async (\n key: string,\n secret: string,\n headers: Headers,\n prefix?: CookiePrefixOptions,\n) => {\n const finalKey = getCookieKey(key, prefix)\n if (!finalKey) {\n return null\n }\n const cookieHeader = headers.get('cookie')\n const parsedCookies = cookieHeader ? parseCookies(cookieHeader) : undefined\n const value = parsedCookies?.get(finalKey)\n if (!value) {\n return null\n }\n const signatureStartPos = value.lastIndexOf('.')\n if (signatureStartPos < 1) {\n return null\n }\n const signedValue = value.substring(0, signatureStartPos)\n const signature = value.substring(signatureStartPos + 1)\n if (signature.length !== 44 || !signature.endsWith('=')) {\n return null\n }\n const secretKey = await getCryptoKey(secret)\n const isVerified = await verifySignature(signature, signedValue, secretKey)\n return isVerified ? signedValue : false\n}\n"],"names":["subtle","verifySignature","base64Signature","value","secret","signatureBinStr","atob","signature","Uint8Array","length","i","len","charCodeAt","verify","algorithm","TextEncoder","encode","e","_serialize","key","opt","cookie","prefix","startsWith","secure","path","domain","undefined","maxAge","Error","Math","floor","expires","getTime","Date","now","toUTCString","httpOnly","sameSite","charAt","toUpperCase","slice","partitioned","name","hash","getCryptoKey","secretBuf","importKey","makeSignature","sign","btoa","String","fromCharCode","signCookieValue","encodeURIComponent","decodeURIComponent","serializeCookie","serializeSignedCookie","getCookieKey","finalKey","tryDecode","str","includes","parseCookies","TypeError","cookies","Map","index","eqIdx","indexOf","endIdx","lastIndexOf","trim","has","val","codePointAt","set","getSignedCookie","headers","cookieHeader","get","parsedCookies","signatureStartPos","signedValue","substring","endsWith","secretKey","isVerified"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/index.ts"],"sourcesContent":["import type { BasePayload, Config } from 'payload'\nimport type { PayloadBetterAuthPluginOptions } from './types'\nimport { sanitizeBetterAuthOptions } from './lib/sanitize-auth-options'\nimport { getRequiredCollectionSlugs } from './lib/get-required-collection-slugs'\nimport { buildCollectionConfigs } from './lib/build-collection-configs'\nimport { respectSaveToJwtFieldsMiddleware } from './lib/respect-save-to-jwt-fields-middleware'\nimport { initBetterAuth } from './lib/init-better-auth'\n\nexport * from './types'\nexport * from './helpers'\nexport { sanitizeBetterAuthOptions } from './lib/sanitize-auth-options'\nexport { getPayloadAuth } from './lib/get-payload-auth'\n\nexport function betterAuthPlugin(pluginOptions: PayloadBetterAuthPluginOptions) {\n return (config: Config): Config => {\n if (pluginOptions.disabled) {\n return config\n }\n config.custom = {\n ...config.custom,\n hasBetterAuthPlugin: true,\n }\n\n if (!config.collections) {\n config.collections = []\n }\n\n let sanitzedBetterAuthOptions = sanitizeBetterAuthOptions(pluginOptions)\n\n // Determine which collections to add based on the options and plugins\n const requiredCollectionSlugs = getRequiredCollectionSlugs({\n logTables: pluginOptions.logTables ?? false,\n pluginOptions,\n sanitizedBAOptions: sanitzedBetterAuthOptions,\n })\n\n // Update with the required collections + existing collections\n config.collections = buildCollectionConfigs({\n incomingCollections: config.collections ?? [],\n requiredCollectionSlugs,\n pluginOptions,\n sanitizedBAOptions: sanitzedBetterAuthOptions,\n })\n\n respectSaveToJwtFieldsMiddleware({\n sanitizedOptions: sanitzedBetterAuthOptions,\n payloadConfig: config,\n pluginOptions,\n })\n\n const incomingOnInit = config.onInit\n\n config.onInit = async (payload) => {\n // Ensure we are executing any existing onInit functions before running our own.\n if (incomingOnInit) {\n await incomingOnInit(payload)\n }\n\n // Initialize and set the betterAuth instance\n const auth = initBetterAuth<NonNullable<typeof sanitzedBetterAuthOptions.plugins>>({\n payload,\n options: {\n ...sanitzedBetterAuthOptions,\n enableDebugLogs: pluginOptions.enableDebugLogs,\n plugins: [...(sanitzedBetterAuthOptions.plugins ?? [])],\n },\n })\n ;(payload as BasePayload & { betterAuth: typeof auth }).betterAuth = auth\n }\n return config\n }\n}\n"],"names":["sanitizeBetterAuthOptions","getRequiredCollectionSlugs","buildCollectionConfigs","respectSaveToJwtFieldsMiddleware","initBetterAuth","getPayloadAuth","betterAuthPlugin","pluginOptions","config","disabled","custom","hasBetterAuthPlugin","collections","sanitzedBetterAuthOptions","requiredCollectionSlugs","logTables","sanitizedBAOptions","incomingCollections","sanitizedOptions","payloadConfig","incomingOnInit","onInit","payload","auth","options","enableDebugLogs","plugins","betterAuth"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,8BAA6B;AACvE,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,gCAAgC,QAAQ,8CAA6C;AAC9F,SAASC,cAAc,QAAQ,yBAAwB;AAEvD,cAAc,UAAS;AACvB,cAAc,YAAW;AACzB,SAASJ,yBAAyB,QAAQ,8BAA6B;AACvE,SAASK,cAAc,QAAQ,yBAAwB;AAEvD,OAAO,SAASC,iBAAiBC,aAA6C;IAC5E,OAAO,CAACC;QACN,IAAID,cAAcE,QAAQ,EAAE;YAC1B,OAAOD;QACT;QACAA,OAAOE,MAAM,GAAG;YACd,GAAGF,OAAOE,MAAM;YAChBC,qBAAqB;QACvB;QAEA,IAAI,CAACH,OAAOI,WAAW,EAAE;YACvBJ,OAAOI,WAAW,GAAG,EAAE;QACzB;QAEA,IAAIC,4BAA4Bb,0BAA0BO;QAE1D,sEAAsE;QACtE,MAAMO,0BAA0Bb,2BAA2B;YACzDc,WAAWR,cAAcQ,SAAS,IAAI;YACtCR;YACAS,oBAAoBH;QACtB;QAEA,8DAA8D;QAC9DL,OAAOI,WAAW,GAAGV,uBAAuB;YAC1Ce,qBAAqBT,OAAOI,WAAW,IAAI,EAAE;YAC7CE;YACAP;YACAS,oBAAoBH;QACtB;QAEAV,iCAAiC;YAC/Be,kBAAkBL;YAClBM,eAAeX;YACfD;QACF;QAEA,MAAMa,iBAAiBZ,OAAOa,MAAM;QAEpCb,OAAOa,MAAM,GAAG,OAAOC;YACrB,gFAAgF;YAChF,IAAIF,gBAAgB;gBAClB,MAAMA,eAAeE;YACvB;YAEA,6CAA6C;YAC7C,MAAMC,OAAOnB,eAAsE;gBACjFkB;gBACAE,SAAS;oBACP,GAAGX,yBAAyB;oBAC5BY,iBAAiBlB,cAAckB,eAAe;oBAC9CC,SAAS;2BAAKb,0BAA0Ba,OAAO,IAAI,EAAE;qBAAE;gBACzD;YACF;YACEJ,QAAsDK,UAAU,GAAGJ;QACvE;QACA,OAAOf;IACT;AACF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AuthStrategy } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* Auth strategy for BetterAuth
|
|
4
|
-
* @param adminRoles - Admin roles
|
|
5
|
-
* @param userSlug - User collection slug
|
|
6
|
-
* @returns Auth strategy
|
|
7
|
-
*/
|
|
8
|
-
export declare function betterAuthStrategy(adminRoles?: string[], userSlug?: string): AuthStrategy;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { getPayloadAuth } from './get-payload-auth';
|
|
2
|
-
/**
|
|
3
|
-
* Auth strategy for BetterAuth
|
|
4
|
-
* @param adminRoles - Admin roles
|
|
5
|
-
* @param userSlug - User collection slug
|
|
6
|
-
* @returns Auth strategy
|
|
7
|
-
*/ export function betterAuthStrategy(adminRoles, userSlug) {
|
|
8
|
-
return {
|
|
9
|
-
name: 'better-auth',
|
|
10
|
-
authenticate: async ({ payload, headers })=>{
|
|
11
|
-
const payloadAuth = await getPayloadAuth(payload.config);
|
|
12
|
-
const session = await payloadAuth.betterAuth.api.getSession({
|
|
13
|
-
headers
|
|
14
|
-
});
|
|
15
|
-
const sessionUserIdField = payloadAuth.betterAuth.options.session?.fields?.userId ?? 'userId';
|
|
16
|
-
const userId = session?.session?.[sessionUserIdField] ?? session?.user?.id;
|
|
17
|
-
if (!session || !userId) {
|
|
18
|
-
return {
|
|
19
|
-
user: null
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const user = await payloadAuth.findByID({
|
|
24
|
-
collection: userSlug ?? 'users',
|
|
25
|
-
id: userId
|
|
26
|
-
});
|
|
27
|
-
if (!user) {
|
|
28
|
-
return {
|
|
29
|
-
user: null
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
user: {
|
|
34
|
-
...user,
|
|
35
|
-
collection: userSlug ?? 'users',
|
|
36
|
-
_strategy: 'better-auth'
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
} catch {
|
|
40
|
-
return {
|
|
41
|
-
user: null
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//# sourceMappingURL=auth-strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugin/lib/auth-strategy.ts"],"sourcesContent":["import type { AuthStrategy } from 'payload'\nimport { getPayloadAuth } from './get-payload-auth'\nimport type { TPlugins } from '..'\n\n/**\n * Auth strategy for BetterAuth\n * @param adminRoles - Admin roles\n * @param userSlug - User collection slug\n * @returns Auth strategy\n */\nexport function betterAuthStrategy(adminRoles?: string[], userSlug?: string): AuthStrategy {\n return {\n name: 'better-auth',\n authenticate: async ({ payload, headers }) => {\n const payloadAuth = await getPayloadAuth<NonNullable<TPlugins>>(payload.config)\n const session = await payloadAuth.betterAuth.api.getSession({ headers })\n const sessionUserIdField = payloadAuth.betterAuth.options.session?.fields?.userId ?? 'userId'\n const userId = (session?.session as any)?.[sessionUserIdField] ?? session?.user?.id\n\n if (!session || !userId) {\n return { user: null }\n }\n try {\n const user = await payloadAuth.findByID({\n collection: userSlug ?? 'users',\n id: userId,\n })\n\n if (!user) {\n return { user: null }\n }\n\n return {\n user: {\n ...user,\n collection: userSlug ?? 'users',\n _strategy: 'better-auth',\n },\n }\n } catch {\n return { user: null }\n }\n },\n }\n}\n"],"names":["getPayloadAuth","betterAuthStrategy","adminRoles","userSlug","name","authenticate","payload","headers","payloadAuth","config","session","betterAuth","api","getSession","sessionUserIdField","options","fields","userId","user","id","findByID","collection","_strategy"],"mappings":"AACA,SAASA,cAAc,QAAQ,qBAAoB;AAGnD;;;;;CAKC,GACD,OAAO,SAASC,mBAAmBC,UAAqB,EAAEC,QAAiB;IACzE,OAAO;QACLC,MAAM;QACNC,cAAc,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAE;YACvC,MAAMC,cAAc,MAAMR,eAAsCM,QAAQG,MAAM;YAC9E,MAAMC,UAAU,MAAMF,YAAYG,UAAU,CAACC,GAAG,CAACC,UAAU,CAAC;gBAAEN;YAAQ;YACtE,MAAMO,qBAAqBN,YAAYG,UAAU,CAACI,OAAO,CAACL,OAAO,EAAEM,QAAQC,UAAU;YACrF,MAAMA,SAAS,AAACP,SAASA,SAAiB,CAACI,mBAAmB,IAAIJ,SAASQ,MAAMC;YAEjF,IAAI,CAACT,WAAW,CAACO,QAAQ;gBACvB,OAAO;oBAAEC,MAAM;gBAAK;YACtB;YACA,IAAI;gBACF,MAAMA,OAAO,MAAMV,YAAYY,QAAQ,CAAC;oBACtCC,YAAYlB,YAAY;oBACxBgB,IAAIF;gBACN;gBAEA,IAAI,CAACC,MAAM;oBACT,OAAO;wBAAEA,MAAM;oBAAK;gBACtB;gBAEA,OAAO;oBACLA,MAAM;wBACJ,GAAGA,IAAI;wBACPG,YAAYlB,YAAY;wBACxBmB,WAAW;oBACb;gBACF;YACF,EAAE,OAAM;gBACN,OAAO;oBAAEJ,MAAM;gBAAK;YACtB;QACF;IACF;AACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PayloadBetterAuthPluginOptions, SanitizedBetterAuthOptions } from '..';
|
|
2
|
-
import { CollectionConfig } from 'payload';
|
|
3
|
-
/**
|
|
4
|
-
* Builds the required collections based on the BetterAuth options and plugins
|
|
5
|
-
*/
|
|
6
|
-
export declare function buildCollectionConfigs({ incomingCollections, requiredCollectionSlugs, pluginOptions, sanitizedBAOptions, }: {
|
|
7
|
-
incomingCollections: CollectionConfig[];
|
|
8
|
-
requiredCollectionSlugs: Set<string>;
|
|
9
|
-
pluginOptions: PayloadBetterAuthPluginOptions;
|
|
10
|
-
sanitizedBAOptions: SanitizedBetterAuthOptions;
|
|
11
|
-
}): CollectionConfig[];
|