@luochuanyuewu/payload-auth 1.8.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/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +24 -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 +317 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +2 -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 +23 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts +5 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts.map +1 -0
- package/dist/better-auth/adapter/generate-schema/index.js +19 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +3 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts.map +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.js +20 -0
- package/dist/better-auth/adapter/index.d.ts +16 -0
- package/dist/better-auth/adapter/index.d.ts.map +1 -0
- package/dist/better-auth/adapter/index.js +717 -0
- package/dist/better-auth/adapter/transform/index.d.ts +31 -0
- package/dist/better-auth/adapter/transform/index.d.ts.map +1 -0
- package/dist/better-auth/adapter/transform/index.js +729 -0
- package/dist/better-auth/adapter/types.d.ts +11 -0
- package/dist/better-auth/adapter/types.d.ts.map +1 -0
- package/dist/better-auth/adapter/types.js +3 -0
- package/dist/better-auth/generated-types.d.ts +329 -0
- package/dist/better-auth/generated-types.d.ts.map +1 -0
- package/dist/better-auth/generated-types.js +4 -0
- package/dist/better-auth/index.d.ts +4 -0
- package/dist/better-auth/index.d.ts.map +1 -0
- package/dist/better-auth/index.js +5 -0
- package/dist/better-auth/plugin/constants.d.ts +231 -0
- package/dist/better-auth/plugin/constants.d.ts.map +1 -0
- package/dist/better-auth/plugin/constants.js +259 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.d.ts +13 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js +14 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +30 -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 +46 -0
- 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-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-better-auth-schema.d.ts +19 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js +75 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.d.ts +6 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.js +20 -0
- package/dist/better-auth/plugin/helpers/get-collection.d.ts +28 -0
- package/dist/better-auth/plugin/helpers/get-collection.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection.js +49 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +3 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-ip.js +31 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.d.ts +3 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js +63 -0
- package/dist/better-auth/plugin/helpers/index.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/index.js +3 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts +60 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js +49 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.d.ts +21 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.d.ts.map +1 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js +63 -0
- package/dist/better-auth/plugin/index.d.ts +8 -0
- package/dist/better-auth/plugin/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/index.js +103 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.d.ts +13 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js +87 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.d.ts +4 -0
- 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 +51 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts +4 -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 +150 -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 +117 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts +4 -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 +174 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.js +49 -0
- package/dist/better-auth/plugin/lib/build-collections/index.d.ts +11 -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 +79 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts +4 -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 +93 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts +4 -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 +58 -0
- package/dist/better-auth/plugin/lib/build-collections/members.d.ts +4 -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 +72 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts +4 -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 +105 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts +4 -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 +117 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts +4 -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 +87 -0
- package/dist/better-auth/plugin/lib/build-collections/organization-roles.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/organization-roles.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/organization-roles.js +65 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts +4 -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 +106 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts +4 -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 +115 -0
- package/dist/better-auth/plugin/lib/build-collections/rate-limit.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/rate-limit.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/rate-limit.js +54 -0
- package/dist/better-auth/plugin/lib/build-collections/scim-provider.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/scim-provider.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/scim-provider.js +65 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts +4 -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 +140 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts +4 -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 +80 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js +110 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.js +63 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.d.ts +4 -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 +74 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts +4 -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 +66 -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/generate-invite-url.d.ts +12 -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 +68 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.d.ts +5 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js +6 -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 +114 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.d.ts +4 -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 +64 -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 +90 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.d.ts +7 -0
- 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 +80 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.d.ts +3 -0
- 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 +79 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts +3 -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 +54 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.d.ts +7 -0
- 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 +15 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js +8 -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 +17 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.d.ts +3 -0
- 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 +90 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts +4 -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 +333 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.d.ts +16 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js +24 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.d.ts +11 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js +112 -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/build-collections/utils/model-field-transformations.d.ts +12 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js +26 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.d.ts +18 -0
- 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 +84 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.d.ts +21 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js +95 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts +4 -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 +82 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +6 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js +9 -0
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +8 -0
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js +16 -0
- 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 +12 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.d.ts +3 -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 +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.d.ts +3 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js +8 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.d.ts +12 -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 +146 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.d.ts +3 -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 +18 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.d.ts +3 -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 +34 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.d.ts +3 -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 +11 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.d.ts +3 -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 +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.d.ts +3 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js +11 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/admin-after-role-middleware.d.ts +8 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/admin-after-role-middleware.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/admin-after-role-middleware.js +20 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/admin-before-role-middleware.d.ts +8 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/admin-before-role-middleware.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/admin-before-role-middleware.js +20 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/apply-save-to-jwt-returned.d.ts +14 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/apply-save-to-jwt-returned.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/apply-save-to-jwt-returned.js +38 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts +8 -0
- 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 +26 -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/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.d.ts +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js +42 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.d.ts +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js +62 -0
- package/dist/better-auth/plugin/lib/set-login-methods.d.ts +5 -0
- package/dist/better-auth/plugin/lib/set-login-methods.d.ts.map +1 -0
- package/dist/better-auth/plugin/lib/set-login-methods.js +14 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts +10 -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 +116 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.scss +36 -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 +213 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.scss +136 -0
- package/dist/better-auth/plugin/payload/components/login-form/alternative-methods.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/login-form/alternative-methods.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/login-form/alternative-methods.js +197 -0
- package/dist/better-auth/plugin/payload/components/login-form/context.d.ts +49 -0
- package/dist/better-auth/plugin/payload/components/login-form/context.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/login-form/context.js +94 -0
- package/dist/better-auth/plugin/payload/components/login-form/credentials-form.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/login-form/credentials-form.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/login-form/credentials-form.js +167 -0
- package/dist/better-auth/plugin/payload/components/login-form/index.d.ts +5 -0
- package/dist/better-auth/plugin/payload/components/login-form/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/login-form/index.js +6 -0
- package/dist/better-auth/plugin/payload/components/login-form/index.scss +58 -0
- package/dist/better-auth/plugin/payload/components/logout-button.d.ts +5 -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 +24 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js +122 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.js +61 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.d.ts +5 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.js +42 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.scss +98 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.js +57 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.d.ts +23 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.js +3 -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 +13 -0
- package/dist/better-auth/plugin/payload/components/token-field.d.ts +4 -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 +29 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js +347 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.scss +116 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts +7 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/exports/client.js +8 -0
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +9 -0
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js +10 -0
- 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 +9 -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 +22 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.d.ts +23 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.js +24 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.d.ts +11 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.js +143 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.d.ts +23 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js +185 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js +92 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.d.ts +7 -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 +104 -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 +61 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts +11 -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 +111 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts +9 -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 +78 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js +79 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.d.ts.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js +49 -0
- package/dist/better-auth/plugin/types.d.ts +448 -0
- package/dist/better-auth/plugin/types.d.ts.map +1 -0
- package/dist/better-auth/plugin/types.js +3 -0
- package/dist/better-auth/plugin/utils/set.d.ts +40 -0
- package/dist/better-auth/plugin/utils/set.d.ts.map +1 -0
- package/dist/better-auth/plugin/utils/set.js +84 -0
- package/dist/better-auth/scripts/generate-types.d.ts +2 -0
- package/dist/better-auth/scripts/generate-types.d.ts.map +1 -0
- package/dist/better-auth/scripts/generate-types.js +225 -0
- package/dist/better-auth/types.d.ts +3 -0
- package/dist/better-auth/types.d.ts.map +1 -0
- package/dist/better-auth/types.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/shared/components/icons.d.ts +8 -0
- package/dist/shared/components/icons.d.ts.map +1 -0
- package/dist/shared/components/icons.js +436 -0
- package/dist/shared/components/logo.d.ts +3 -0
- package/dist/shared/components/logo.d.ts.map +1 -0
- package/dist/shared/components/logo.js +24 -0
- package/dist/shared/form/components/submit.d.ts +8 -0
- package/dist/shared/form/components/submit.d.ts.map +1 -0
- package/dist/shared/form/components/submit.js +23 -0
- package/dist/shared/form/fields/text-field.d.ts +9 -0
- package/dist/shared/form/fields/text-field.d.ts.map +1 -0
- package/dist/shared/form/fields/text-field.js +44 -0
- package/dist/shared/form/index.d.ts +28 -0
- package/dist/shared/form/index.d.ts.map +1 -0
- package/dist/shared/form/index.js +17 -0
- package/dist/shared/form/ui/header/index.d.ts +9 -0
- package/dist/shared/form/ui/header/index.d.ts.map +1 -0
- package/dist/shared/form/ui/header/index.js +23 -0
- package/dist/shared/form/ui/header/index.scss +8 -0
- package/dist/shared/form/ui/index.d.ts +34 -0
- package/dist/shared/form/ui/index.d.ts.map +1 -0
- package/dist/shared/form/ui/index.js +70 -0
- package/dist/shared/form/ui/index.scss +27 -0
- package/dist/shared/form/validation.d.ts +65 -0
- package/dist/shared/form/validation.d.ts.map +1 -0
- package/dist/shared/form/validation.js +108 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/payload/fields/field-copy-button/index.css +47 -0
- package/dist/shared/payload/fields/field-copy-button/index.d.ts +4 -0
- package/dist/shared/payload/fields/field-copy-button/index.d.ts.map +1 -0
- package/dist/shared/payload/fields/field-copy-button/index.js +38 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.css +14 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.d.ts +4 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.d.ts.map +1 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.js +26 -0
- package/dist/shared/payload/fields/index.d.ts +3 -0
- package/dist/shared/payload/fields/index.d.ts.map +1 -0
- package/dist/shared/payload/fields/index.js +4 -0
- package/dist/shared/utils/regex.d.ts +3 -0
- package/dist/shared/utils/regex.d.ts.map +1 -0
- package/dist/shared/utils/regex.js +4 -0
- package/dist/shared/utils/try-catch.d.ts +12 -0
- package/dist/shared/utils/try-catch.d.ts.map +1 -0
- package/dist/shared/utils/try-catch.js +17 -0
- package/dist/shared/utils/value-or-default.d.ts +10 -0
- package/dist/shared/utils/value-or-default.d.ts.map +1 -0
- package/dist/shared/utils/value-or-default.js +12 -0
- package/package.json +124 -0
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
[saltValue, storedHash] = parts;
|
|
53
|
+
}
|
|
54
|
+
if (!saltValue || !storedHash) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const hashRaw = await pbkdf2Promisified(password, saltValue);
|
|
58
|
+
const computedHash = hashRaw.toString("hex");
|
|
59
|
+
return storedHash === computedHash;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL3Nhbml0aXplLWJldHRlci1hdXRoLW9wdGlvbnMvdXRpbHMvcGFzc3dvcmQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGNyeXB0byBmcm9tIFwiY3J5cHRvXCI7XG5cbi8qKlxuICogTWltaWNzIFBheWxvYWQncyBpbnRlcm5hbCBwYXNzd29yZCBoYXNoaW5nIHVzaW5nIHBia2RmMlxuICpcbiAqIFRoaXMgZ2VuZXJhdGVzIGEgaGFzaCBjb21wYXRpYmxlIHdpdGggUGF5bG9hZCdzIGludGVybmFsIGF1dGggc3lzdGVtXG4gKiBzbyB0aGF0IHBhc3N3b3JkcyBzZXQgdmlhIGJldHRlci1hdXRoIGNhbiBiZSB1c2VkIHdpdGggUGF5bG9hZCBhZG1pbiBwYW5lbFxuICovXG5mdW5jdGlvbiBwYmtkZjJQcm9taXNpZmllZChwYXNzd29yZDogc3RyaW5nLCBzYWx0OiBzdHJpbmcpOiBQcm9taXNlPEJ1ZmZlcj4ge1xuICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT5cbiAgICBjcnlwdG8ucGJrZGYyKHBhc3N3b3JkLCBzYWx0LCAyNTAwMCwgNTEyLCBcInNoYTI1NlwiLCAoZXJyLCBoYXNoUmF3KSA9PlxuICAgICAgZXJyID8gcmVqZWN0KGVycikgOiByZXNvbHZlKGhhc2hSYXcpXG4gICAgKVxuICApO1xuf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BTztJQUNUO0lBRUEsTUFBTVIsVUFBVSxNQUFNUixrQkFBa0JDLFVBQVVjO0lBQ2xELE1BQU1LLGVBQWVaLFFBQVFJLFFBQVEsQ0FBQztJQUV0QyxPQUFPSSxlQUFlSTtBQUN4QixFQUFFIn0=
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SanitizedBetterAuthOptions } from "@/better-auth/plugin/types";
|
|
2
|
+
import { PayloadAuthOptions } from "@/better-auth/types";
|
|
3
|
+
/**
|
|
4
|
+
* Mofies options object and adds a middleware to check for admin invite for sign up
|
|
5
|
+
*/
|
|
6
|
+
export declare const requireAdminInviteForSignUpMiddleware: ({ options, pluginOptions }: {
|
|
7
|
+
options: SanitizedBetterAuthOptions;
|
|
8
|
+
pluginOptions: PayloadAuthOptions;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
//# sourceMappingURL=require-admin-invite-for-sign-up-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-admin-invite-for-sign-up-middleware.d.ts","sourceRoot":"","sources":["../../../../../../src/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAQzD;;GAEG;AACH,eAAO,MAAM,qCAAqC,GAAU,4BAGzD;IACD,OAAO,EAAE,0BAA0B,CAAC;IACpC,aAAa,EAAE,kBAAkB,CAAC;CACnC,kBAiCA,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { APIError, createAuthMiddleware } from "better-auth/api";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { baseSlugs } from "../../../constants";
|
|
4
|
+
const throwUnauthorizedError = ()=>{
|
|
5
|
+
throw new APIError("UNAUTHORIZED", {
|
|
6
|
+
message: "signup disabled" // mimic: https://github.com/better-auth/better-auth/blob/171fab5273cf38f46cf207b0d99c8ccdda64c2fb/packages/better-auth/src/oauth2/link-account.ts#L108
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Mofies options object and adds a middleware to check for admin invite for sign up
|
|
11
|
+
*/ export const requireAdminInviteForSignUpMiddleware = async ({ options, pluginOptions })=>{
|
|
12
|
+
options.hooks = options.hooks || {};
|
|
13
|
+
const originalBefore = options.hooks.before;
|
|
14
|
+
options.hooks.before = createAuthMiddleware(async (ctx)=>{
|
|
15
|
+
if (ctx.path !== "/sign-up/email" && // not an email sign-up request
|
|
16
|
+
!(ctx.path === "/sign-in/social" && ctx.body?.requestSignUp // not a social sign-in request with sign-up intent
|
|
17
|
+
)) return;
|
|
18
|
+
const adminInviteToken = ctx?.query?.adminInviteToken ?? ctx.body.adminInviteToken;
|
|
19
|
+
if (!!pluginOptions.requireAdminInviteForSignUp && !z.string().uuid().safeParse(adminInviteToken).success) {
|
|
20
|
+
throwUnauthorizedError();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const query = {
|
|
24
|
+
field: "token",
|
|
25
|
+
value: adminInviteToken,
|
|
26
|
+
operator: "eq"
|
|
27
|
+
};
|
|
28
|
+
const isValidAdminInvitation = await ctx.context.adapter.count({
|
|
29
|
+
model: pluginOptions.adminInvitations?.slug ?? baseSlugs.adminInvitations,
|
|
30
|
+
where: [
|
|
31
|
+
query
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
if (isValidAdminInvitation) {
|
|
35
|
+
if (originalBefore) return originalBefore(ctx);
|
|
36
|
+
return ctx;
|
|
37
|
+
}
|
|
38
|
+
throwUnauthorizedError();
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wb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UFDM0MsQ0FBQ2hCLEVBQUVpQixNQUFNLEdBQUdDLElBQUksR0FBR0MsU0FBUyxDQUFDTCxrQkFBa0JNLE9BQU8sRUFDdEQ7WUFDQWxCO1lBQ0E7UUFDRjtRQUNBLE1BQU1hLFFBQWU7WUFDbkJNLE9BQU87WUFDUEMsT0FBT1I7WUFDUFMsVUFBVTtRQUNaO1FBQ0EsTUFBTUMseUJBQXlCLE1BQU1kLElBQUllLE9BQU8sQ0FBQ0MsT0FBTyxDQUFDQyxLQUFLLENBQUM7WUFDN0RDLE9BQU90QixjQUFjdUIsZ0JBQWdCLEVBQUVDLFFBQVE3QixVQUFVNEIsZ0JBQWdCO1lBQ3pFRSxPQUFPO2dCQUFDaEI7YUFBTTtRQUNoQjtRQUNBLElBQUlTLHdCQUF3QjtZQUMxQixJQUFJaEIsZ0JBQWdCLE9BQU9BLGVBQWVFO1lBQzFDLE9BQU9BO1FBQ1Q7UUFDQVI7SUFDRjtBQUNGLEVBQUUifQ==
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SanitizedBetterAuthOptions } from "@/better-auth/plugin/types";
|
|
2
|
+
/**
|
|
3
|
+
* Modifies options object and adds a middleware to check for admin invite for sign up
|
|
4
|
+
*/
|
|
5
|
+
export declare const useAdminInviteAfterEmailSignUpMiddleware: ({ options, adminInvitationCollectionSlug, userCollectionSlug }: {
|
|
6
|
+
options: SanitizedBetterAuthOptions;
|
|
7
|
+
adminInvitationCollectionSlug: string;
|
|
8
|
+
userCollectionSlug: string;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
//# sourceMappingURL=use-admin-invite-after-email-sign-up-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-admin-invite-after-email-sign-up-middleware.d.ts","sourceRoot":"","sources":["../../../../../../src/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,wCAAwC,GAAU,gEAI5D;IACD,OAAO,EAAE,0BAA0B,CAAC;IACpC,6BAA6B,EAAE,MAAM,CAAC;IACtC,kBAAkB,EAAE,MAAM,CAAC;CAC5B,kBA8DA,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "better-auth/api";
|
|
2
|
+
/**
|
|
3
|
+
* Modifies options object and adds a middleware to check for admin invite for sign up
|
|
4
|
+
*/ export const useAdminInviteAfterEmailSignUpMiddleware = async ({ options, adminInvitationCollectionSlug, userCollectionSlug })=>{
|
|
5
|
+
options.hooks = options.hooks || {};
|
|
6
|
+
const originalAfter = options.hooks.after;
|
|
7
|
+
options.hooks.after = createAuthMiddleware(async (ctx)=>{
|
|
8
|
+
const adapter = ctx.context.adapter;
|
|
9
|
+
const internalAdapter = ctx.context.internalAdapter;
|
|
10
|
+
if (ctx.path !== "/sign-up/email") {
|
|
11
|
+
if (typeof originalAfter === "function") originalAfter(ctx);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const email = ctx.body.email;
|
|
15
|
+
const adminInviteToken = ctx?.query?.adminInviteToken ?? ctx.body.adminInviteToken;
|
|
16
|
+
const adminInvitation = await adapter.findOne({
|
|
17
|
+
model: adminInvitationCollectionSlug,
|
|
18
|
+
where: [
|
|
19
|
+
{
|
|
20
|
+
field: "token",
|
|
21
|
+
value: adminInviteToken,
|
|
22
|
+
operator: "eq"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
if (!adminInvitation || !adminInvitation?.role || !email) {
|
|
27
|
+
if (typeof originalAfter === "function") originalAfter(ctx);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const newlyCreatedUser = await internalAdapter.findUserByEmail(email);
|
|
31
|
+
if (!newlyCreatedUser) {
|
|
32
|
+
if (typeof originalAfter === "function") originalAfter(ctx);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
await adapter.update({
|
|
36
|
+
model: userCollectionSlug,
|
|
37
|
+
where: [
|
|
38
|
+
{
|
|
39
|
+
field: "id",
|
|
40
|
+
value: newlyCreatedUser.user.id,
|
|
41
|
+
operator: "eq"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
update: {
|
|
45
|
+
role: adminInvitation?.role
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
await adapter.delete({
|
|
49
|
+
model: adminInvitationCollectionSlug,
|
|
50
|
+
where: [
|
|
51
|
+
{
|
|
52
|
+
field: "id",
|
|
53
|
+
value: adminInvitation.id,
|
|
54
|
+
operator: "eq"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
if (typeof originalAfter === "function") originalAfter(ctx);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL3Nhbml0aXplLWJldHRlci1hdXRoLW9wdGlvbnMvdXRpbHMvdXNlLWFkbWluLWludml0ZS1hZnRlci1lbWFpbC1zaWduLXVwLW1pZGRsZXdhcmUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3JlYXRlQXV0aE1pZGRsZXdhcmUgfSBmcm9tIFwiYmV0dGVyLWF1dGgvYXBpXCI7XG5pbXBvcnQgdHlwZSB7IFNhbml0aXplZEJldHRlckF1dGhPcHRpb25zIH0gZnJvbSBcIkAvYmV0dGVyLWF1dGgvcGx1Z2luL3R5cGVzXCI7XG5cbi8qKlxuICogTW9kaWZpZXMgb3B0aW9ucyBvYmplY3QgYW5kIGFkZHMgYSBtaWRkbGV3YXJlIHRvIGNoZWNrIGZvciBhZG1pbiBpbnZpdGUgZm9yIHNpZ24g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0FBY0U7WUFDdkQ7UUFDRjtRQUVBLE1BQU1DLFFBQVFrQixNQUFNLENBQUM7WUFDbkJSLE9BQU9mO1lBQ1BnQixPQUFPO2dCQUNMO29CQUNFQyxPQUFPO29CQUNQQyxPQUFPRyxpQkFBaUJHLElBQUksQ0FBQ0MsRUFBRTtvQkFDL0JOLFVBQVU7Z0JBQ1o7YUFDRDtZQUNESSxRQUFRO2dCQUNOSCxNQUFNUCxpQkFBaUJPO1lBQ3pCO1FBQ0Y7UUFFQSxNQUFNZixRQUFRcUIsTUFBTSxDQUFDO1lBQ25CWCxPQUFPaEI7WUFDUGlCLE9BQU87Z0JBQ0w7b0JBQ0VDLE9BQU87b0JBQ1BDLE9BQU9MLGdCQUFnQlksRUFBRTtvQkFDekJOLFVBQVU7Z0JBQ1o7YUFDRDtRQUNIO1FBRUEsSUFBSSxPQUFPakIsa0JBQWtCLFlBQVlBLGNBQWNFO0lBQ3pEO0FBQ0YsRUFBRSJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-login-methods.d.ts","sourceRoot":"","sources":["../../../../src/better-auth/plugin/lib/set-login-methods.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3D,wBAAgB,eAAe,CAAC,EAC9B,aAAa,EACd,EAAE;IACD,aAAa,EAAE,kBAAkB,CAAC;CACnC,sBAcA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { supportedBAPluginIds } from "../constants";
|
|
2
|
+
import { checkPluginExists } from "../helpers/check-plugin-exists";
|
|
3
|
+
export function setLoginMethods({ pluginOptions }) {
|
|
4
|
+
const betterAuthOptions = pluginOptions.betterAuthOptions ?? {};
|
|
5
|
+
if (pluginOptions?.admin?.loginMethods) return pluginOptions; // If user defined, exit early
|
|
6
|
+
const loginMethods = Object.keys(betterAuthOptions?.socialProviders ?? {});
|
|
7
|
+
if (!!betterAuthOptions?.emailAndPassword || betterAuthOptions?.emailAndPassword?.enabled) loginMethods.push("emailPassword");
|
|
8
|
+
if (checkPluginExists(betterAuthOptions, supportedBAPluginIds.passkey)) loginMethods.push("passkey");
|
|
9
|
+
pluginOptions.admin = pluginOptions.admin ?? {};
|
|
10
|
+
pluginOptions.admin.loginMethods = loginMethods;
|
|
11
|
+
return pluginOptions;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vbGliL3NldC1sb2dpbi1tZXRob2RzLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHN1cHBvcnRlZEJBUGx1Z2luSWRzIH0gZnJvbSBcIi4uL2NvbnN0YW50c1wiO1xuaW1wb3J0IHsgY2hlY2tQbHVnaW5FeGlzdHMgfSBmcm9tIFwiLi4vaGVscGVycy9jaGVjay1wbHVnaW4tZXhpc3RzXCI7XG5pbXBvcnQgeyBMb2dpbk1ldGhvZCwgUGF5bG9hZEF1dGhPcHRpb25zIH0gZnJvbSBcIi4uL3R5cGVzXCI7XG5cbmV4cG9ydCBmdW5jdGlvbiBzZXRMb2dpbk1ldGhvZHMoe1xuICBwbHVnaW5PcHRpb25zXG59OiB7XG4gIHBsdWdpbk9wdGlvbnM6IFBheWxvYWRBdXRoT3B0aW9ucztcbn0pIHtcbiAgY29uc3QgYmV0dGVyQXV0aE9wdGlvbnMgPSBwbHVnaW5PcHRpb25zLmJldHRlckF1dGhPcHRpb25zID8/IHt9O1xuICBpZiAocGx1Z2luT3B0aW9ucz8uYWRtaW4/LmxvZ2luTWV0aG9kcykgcmV0dXJuIHBsdWdpbk9wdGlvbnM7IC8vIElmIHVzZXIgZGVmaW5lZCwgZXhpdCBlYXJseVxuICBjb25zdCBsb2dpbk1ldGhvZHMgPSBPYmplY3Qua2V5cyhiZXR0ZXJBdXRoT3B0aW9ucz8uc29jaW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O0lBQzlELElBQUlELGVBQWVFLE9BQU9DLGNBQWMsT0FBT0gsZUFBZSw4QkFBOEI7SUFDNUYsTUFBTUcsZUFBZUMsT0FBT0MsSUFBSSxDQUFDSixtQkFBbUJLLG1CQUFtQixDQUFDO0lBQ3hFLElBQ0UsQ0FBQyxDQUFDTCxtQkFBbUJNLG9CQUNyQk4sbUJBQW1CTSxrQkFBa0JDLFNBRXJDTCxhQUFhTSxJQUFJLENBQUM7SUFDcEIsSUFBSVgsa0JBQWtCRyxtQkFBbUJKLHFCQUFxQmEsT0FBTyxHQUNuRVAsYUFBYU0sSUFBSSxDQUFDO0lBQ3BCVCxjQUFjRSxLQUFLLEdBQUdGLGNBQWNFLEtBQUssSUFBSSxDQUFDO0lBQzlDRixjQUFjRSxLQUFLLENBQUNDLFlBQVksR0FBR0E7SUFDbkMsT0FBT0g7QUFDVCJ9
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./index.scss";
|
|
3
|
+
interface AdminButtonsProps {
|
|
4
|
+
userSlug: string;
|
|
5
|
+
baseURL?: string;
|
|
6
|
+
basePath?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function AdminButtons({ baseURL, basePath }: AdminButtonsProps): React.JSX.Element | null;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/better-auth/plugin/payload/components/admin-buttons/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,cAAc,CAAC;AAEtB,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,iBAAiB,4BA0HpE"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, toast, useDocumentInfo, useFormFields } from "@payloadcms/ui";
|
|
4
|
+
import { adminClient } from "better-auth/client/plugins";
|
|
5
|
+
import { createAuthClient } from "better-auth/react";
|
|
6
|
+
import { useRouter } from "next/navigation";
|
|
7
|
+
import React, { Fragment, useMemo } from "react";
|
|
8
|
+
import "./index.scss";
|
|
9
|
+
export function AdminButtons({ baseURL, basePath }) {
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const { id } = useDocumentInfo();
|
|
12
|
+
const isBanned = useFormFields(([fields])=>fields.banned);
|
|
13
|
+
if (!id) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const authClient = useMemo(()=>createAuthClient({
|
|
17
|
+
baseURL,
|
|
18
|
+
basePath,
|
|
19
|
+
plugins: [
|
|
20
|
+
adminClient()
|
|
21
|
+
]
|
|
22
|
+
}), []);
|
|
23
|
+
const handleImpersonate = async ()=>{
|
|
24
|
+
await authClient.admin.impersonateUser({
|
|
25
|
+
userId: String(id),
|
|
26
|
+
fetchOptions: {
|
|
27
|
+
onSuccess () {
|
|
28
|
+
router.push("/");
|
|
29
|
+
},
|
|
30
|
+
onError (error) {
|
|
31
|
+
console.error("Error impersonating user:", error);
|
|
32
|
+
toast.error("Failed to impersonate user");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const handleBan = async ()=>{
|
|
38
|
+
await authClient.admin.banUser({
|
|
39
|
+
userId: String(id),
|
|
40
|
+
fetchOptions: {
|
|
41
|
+
onSuccess () {
|
|
42
|
+
toast.success("User banned successfully");
|
|
43
|
+
router.refresh();
|
|
44
|
+
},
|
|
45
|
+
onError (error) {
|
|
46
|
+
console.error("Error banning user:", error);
|
|
47
|
+
toast.error("Failed to ban user");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const handleUnban = async ()=>{
|
|
53
|
+
await authClient.admin.unbanUser({
|
|
54
|
+
userId: String(id),
|
|
55
|
+
fetchOptions: {
|
|
56
|
+
onSuccess () {
|
|
57
|
+
toast.success("User unbanned successfully");
|
|
58
|
+
router.refresh();
|
|
59
|
+
},
|
|
60
|
+
onError (error) {
|
|
61
|
+
console.error("Error unbanning user:", error);
|
|
62
|
+
toast.error("Failed to unban user");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const handleRevokeAllSessions = async ()=>{
|
|
68
|
+
await authClient.admin.revokeUserSessions({
|
|
69
|
+
userId: String(id),
|
|
70
|
+
fetchOptions: {
|
|
71
|
+
onSuccess () {
|
|
72
|
+
toast.success("All sessions revoked successfully");
|
|
73
|
+
router.refresh();
|
|
74
|
+
},
|
|
75
|
+
onError (error) {
|
|
76
|
+
console.error("Error revoking all sessions:", error);
|
|
77
|
+
toast.error("Failed to revoke all sessions");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
85
|
+
onClick: handleImpersonate,
|
|
86
|
+
buttonStyle: "pill",
|
|
87
|
+
className: "impersonate-button",
|
|
88
|
+
size: "medium",
|
|
89
|
+
children: "Impersonate"
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
92
|
+
onClick: handleRevokeAllSessions,
|
|
93
|
+
buttonStyle: "secondary",
|
|
94
|
+
className: "revoke-sessions-button",
|
|
95
|
+
size: "medium",
|
|
96
|
+
children: "Revoke All Sessions"
|
|
97
|
+
}),
|
|
98
|
+
!isBanned ? /*#__PURE__*/ _jsx(Button, {
|
|
99
|
+
onClick: handleBan,
|
|
100
|
+
buttonStyle: "error",
|
|
101
|
+
className: "ban-button",
|
|
102
|
+
size: "medium",
|
|
103
|
+
children: "Ban"
|
|
104
|
+
}) : null,
|
|
105
|
+
isBanned ? /*#__PURE__*/ _jsx(Button, {
|
|
106
|
+
onClick: handleUnban,
|
|
107
|
+
buttonStyle: "primary",
|
|
108
|
+
className: "unban-button",
|
|
109
|
+
size: "medium",
|
|
110
|
+
children: "Unban"
|
|
111
|
+
}) : null
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9iZXR0ZXItYXV0aC9wbHVnaW4vcGF5bG9hZC9jb21wb25lbnRzL2FkbWluLWJ1dHRvbnMvaW5kZXgudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIGNsaWVudFwiO1xuXG5pbXBvcnQgeyBCdXR0b24sIHRvYXN0LCB1c2VEb2N1bWVudEluZm8sIHVzZUZvcm1GaWVsZHMgfSBmcm9tIFwiQHBheWxvYWRjbXMvdWlcIjtcbmltcG9ydCB7IGFkbWluQ2xpZW50IH0gZnJvbSBcImJldHRlci1hdXRoL2NsaWVudC9wbHVnaW5zXCI7XG5pbXBvcnQgeyBjcmVhdGVBdXRoQ2xpZW50IH0gZnJvbSBcImJldHRlci1hdXRoL3JlYWN0XCI7XG5pbXBvcnQgeyB1c2VSb3V0ZXIgfSBmcm9tIFwibmV4dC9uYXZpZ2F0aW9uXCI7XG5pbXBvcnQgUmVhY3QsIHsgRnJhZ21lbnQsIHVzZU1lbW8gfSBmcm9tIFwicmVhY3RcIjtcblxuaW1wb3J0IFwiLi9pbmRleC5zY3NzXCI7XG5cbmludGVyZmFjZSBBZG1pbkJ1dHRvbnNQcm9wcyB7XG4gIHVzZXJTbHVnOiBzdHJpbmc7XG4gIGJhc2VVUkw/OiBzdHJpbmc7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QVFDLE9BQU9WO1lBQ2ZXLGNBQWM7Z0JBQ1pDO29CQUNFekIsTUFBTWdDLE9BQU8sQ0FBQztvQkFDZHBCLE9BQU9xQixPQUFPO2dCQUNoQjtnQkFDQU4sU0FBUUMsS0FBVTtvQkFDaEJDLFFBQVFELEtBQUssQ0FBQyxnQ0FBZ0NBO29CQUM5QzVCLE1BQU00QixLQUFLLENBQUM7Z0JBQ2Q7WUFDRjtRQUNGO0lBQ0Y7SUFFQSxxQkFDRSxNQUFDckI7OzBCQUNDLEtBQUNSO2dCQUNDdUMsU0FBU25CO2dCQUNUb0IsYUFBWTtnQkFDWkMsV0FBVTtnQkFDVkMsTUFBSzswQkFDTjs7MEJBR0QsS0FBQzFDO2dCQUNDdUMsU0FBU0Y7Z0JBQ1RHLGFBQVk7Z0JBQ1pDLFdBQVU7Z0JBQ1ZDLE1BQUs7MEJBQ047O1lBR0EsQ0FBQzNCLHlCQUNBLEtBQUNmO2dCQUNDdUMsU0FBU1I7Z0JBQ1RTLGFBQVk7Z0JBQ1pDLFdBQVU7Z0JBQ1ZDLE1BQUs7MEJBQ047aUJBR0M7WUFDSDNCLHlCQUNDLEtBQUNmO2dCQUNDdUMsU0FBU0o7Z0JBQ1RLLGFBQVk7Z0JBQ1pDLFdBQVU7Z0JBQ1ZDLE1BQUs7MEJBQ047aUJBR0M7OztBQUdWIn0=
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.doc-tabs__tabs:has(.impersonate-button) .doc-tab {
|
|
2
|
+
order: 10;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.impersonate-button,
|
|
6
|
+
.revoke-sessions-button,
|
|
7
|
+
.ban-button,
|
|
8
|
+
.unban-button {
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
margin-block: 0;
|
|
12
|
+
padding-block: 0.23rem;
|
|
13
|
+
text-wrap: nowrap;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ban-button {
|
|
17
|
+
background-color: oklch(0.258 0.092 26.042);
|
|
18
|
+
color: oklch(0.577 0.245 27.325);
|
|
19
|
+
border: 1px solid oklch(0.396 0.141 25.723);
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
color: #fff;
|
|
23
|
+
background-color: oklch(0.505 0.213 27.518);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.revoke-sessions-button {
|
|
28
|
+
--theme-elevation-800: oklch(0.396 0.141 25.723);
|
|
29
|
+
color: oklch(0.637 0.237 25.331);
|
|
30
|
+
|
|
31
|
+
&:hover {
|
|
32
|
+
--theme-elevation-400: oklch(0.396 0.141 25.723);
|
|
33
|
+
color: #fff;
|
|
34
|
+
background-color: oklch(0.396 0.141 25.723);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./index.scss";
|
|
3
|
+
interface AdminInviteButtonProps {
|
|
4
|
+
roles: {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[];
|
|
8
|
+
}
|
|
9
|
+
export declare function AdminInviteButton({ roles }: AdminInviteButtonProps): React.JSX.Element | null;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/better-auth/plugin/payload/components/admin-invite-button/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,cAAc,CAAC;AAItB,UAAU,sBAAsB;IAC9B,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C;AAED,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE,sBAAsB,4BA0MlE"}
|