@revealui/auth 0.0.1-pre.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/LICENSE +202 -0
- package/dist/better-auth/adapter/__tests__/transform.test.js +213 -0
- package/dist/better-auth/adapter/__tests__/transform.test.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/biome.d.js +2 -0
- package/dist/better-auth/adapter/generate-schema/biome.d.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +5 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +482 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +42 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts +4 -0
- package/dist/better-auth/adapter/generate-schema/index.js +19 -0
- package/dist/better-auth/adapter/generate-schema/index.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +2 -0
- package/dist/better-auth/adapter/generate-schema/utils.js +20 -0
- package/dist/better-auth/adapter/generate-schema/utils.js.map +1 -0
- package/dist/better-auth/adapter/index.d.ts +15 -0
- package/dist/better-auth/adapter/index.js +731 -0
- package/dist/better-auth/adapter/index.js.map +1 -0
- package/dist/better-auth/adapter/tests/adapter.test.js +174 -0
- package/dist/better-auth/adapter/tests/adapter.test.js.map +1 -0
- package/dist/better-auth/adapter/tests/base-collections-tests.js +575 -0
- package/dist/better-auth/adapter/tests/base-collections-tests.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/index.js +117 -0
- package/dist/better-auth/adapter/tests/dev/index.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/migrate.js +26 -0
- package/dist/better-auth/adapter/tests/dev/migrate.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js +218 -0
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/schema.js +160 -0
- package/dist/better-auth/adapter/tests/dev/schema.js.map +1 -0
- package/dist/better-auth/adapter/tests/plugins-tests.js +2 -0
- package/dist/better-auth/adapter/tests/plugins-tests.js.map +1 -0
- package/dist/better-auth/adapter/transform/index.d.ts +27 -0
- package/dist/better-auth/adapter/transform/index.js +664 -0
- package/dist/better-auth/adapter/transform/index.js.map +1 -0
- package/dist/better-auth/adapter/types.d.ts +10 -0
- package/dist/better-auth/adapter/types.js +3 -0
- package/dist/better-auth/adapter/types.js.map +1 -0
- package/dist/better-auth/generated-types.d.ts +285 -0
- package/dist/better-auth/index.d.ts +3 -0
- package/dist/better-auth/index.js +5 -0
- package/dist/better-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/__tests__/plugin.test.js +162 -0
- package/dist/better-auth/plugin/__tests__/plugin.test.js.map +1 -0
- package/dist/better-auth/plugin/constants.d.ts +220 -0
- package/dist/better-auth/plugin/constants.js +249 -0
- package/dist/better-auth/plugin/constants.js.map +1 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.d.ts +12 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js +14 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js.map +1 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +29 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +46 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.d.ts +7 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.js +22 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.d.ts +5 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.js +20 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.d.ts +18 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js +70 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.d.ts +5 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.js +20 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection.d.ts +15 -0
- package/dist/better-auth/plugin/helpers/get-collection.js +29 -0
- package/dist/better-auth/plugin/helpers/get-collection.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-ip.js +31 -0
- package/dist/better-auth/plugin/helpers/get-ip.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js +65 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js.map +1 -0
- package/dist/better-auth/plugin/helpers/index.d.ts +1 -0
- package/dist/better-auth/plugin/helpers/index.js +3 -0
- package/dist/better-auth/plugin/helpers/index.js.map +1 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts +59 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js +49 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js.map +1 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.d.ts +20 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js +67 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js.map +1 -0
- package/dist/better-auth/plugin/index.d.ts +11 -0
- package/dist/better-auth/plugin/index.js +125 -0
- package/dist/better-auth/plugin/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.d.ts +12 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js +87 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js +60 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js +154 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.d.ts +5 -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-after-read.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.d.ts +2 -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/hooks/get-url-before-change.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js +119 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js +177 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.js +50 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/index.d.ts +10 -0
- package/dist/better-auth/plugin/lib/build-collections/index.js +73 -0
- package/dist/better-auth/plugin/lib/build-collections/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.js +94 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.js +59 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/members.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/members.js +73 -0
- package/dist/better-auth/plugin/lib/build-collections/members.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js +107 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js +118 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js +89 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.js +70 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js +115 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.js +170 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js +81 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js +111 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.js +57 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.js +76 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js +53 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.d.ts +11 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js +75 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.d.ts +4 -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/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js +115 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js.map +1 -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.js +64 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js +80 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js +79 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js +82 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts +2 -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-delete.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.d.ts +6 -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/before-login.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.d.ts +6 -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/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.d.ts +2 -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/on-verified-change.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js +91 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.js +341 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.d.ts +15 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js +24 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.d.ts +10 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.d.ts +9 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js +94 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js +35 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js.map +1 -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.js +25 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.d.ts +14 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.d.ts +20 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js +98 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.js +87 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.js.map +1 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +5 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js +9 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +7 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js +46 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js.map +1 -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.js +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.d.ts +2 -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/device-authorization-plugin.js.map +1 -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.js +156 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js.map +1 -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.js +18 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js.map +1 -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.js +34 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js.map +1 -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.js +11 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js.map +1 -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.js +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.d.ts +2 -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/two-factor-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts +7 -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/ensure-password-set-before-create.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.d.ts +25 -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/password.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.d.ts +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js +47 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.d.ts +15 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js +42 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.d.ts +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js +63 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/set-login-methods.d.ts +4 -0
- package/dist/better-auth/plugin/lib/set-login-methods.js +14 -0
- package/dist/better-auth/plugin/lib/set-login-methods.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js +143 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js +219 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/logout-button.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/logout-button.js +24 -0
- package/dist/better-auth/plugin/payload/components/logout-button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js +117 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.js +66 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.js +52 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.js +57 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.d.ts +22 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.js +3 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.d.ts +6 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js +7 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.d.ts +15 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js +157 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/token-field.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/token-field.js +31 -0
- package/dist/better-auth/plugin/payload/components/token-field.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js +300 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts +6 -0
- package/dist/better-auth/plugin/payload/exports/client.js +8 -0
- package/dist/better-auth/plugin/payload/exports/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +8 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js +10 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js.map +1 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.d.ts +2 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js +9 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.d.ts +1 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js +22 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.d.ts +19 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.js +226 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.js +150 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.d.ts +16 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js +299 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js +104 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js.map +1 -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.js +119 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js +78 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.js +144 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.js +96 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.d.ts +6 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js +96 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js +56 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js.map +1 -0
- package/dist/better-auth/plugin/types.d.ts +429 -0
- package/dist/better-auth/plugin/types.js +3 -0
- package/dist/better-auth/plugin/types.js.map +1 -0
- package/dist/better-auth/plugin/utils/set.d.ts +39 -0
- package/dist/better-auth/plugin/utils/set.js +103 -0
- package/dist/better-auth/plugin/utils/set.js.map +1 -0
- package/dist/better-auth/scripts/generate-types.d.ts +1 -0
- package/dist/better-auth/scripts/generate-types.js +234 -0
- package/dist/better-auth/scripts/generate-types.js.map +1 -0
- package/dist/better-auth/types.d.ts +2 -0
- package/dist/better-auth/types.js +4 -0
- package/dist/better-auth/types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/components/icons.d.ts +7 -0
- package/dist/shared/components/icons.js +442 -0
- package/dist/shared/components/icons.js.map +1 -0
- package/dist/shared/components/logo.d.ts +3 -0
- package/dist/shared/components/logo.js +24 -0
- package/dist/shared/components/logo.js.map +1 -0
- package/dist/shared/form/components/submit.d.ts +7 -0
- package/dist/shared/form/components/submit.js +16 -0
- package/dist/shared/form/components/submit.js.map +1 -0
- package/dist/shared/form/fields/text-field.d.ts +8 -0
- package/dist/shared/form/fields/text-field.js +37 -0
- package/dist/shared/form/fields/text-field.js.map +1 -0
- package/dist/shared/form/index.d.ts +4 -0
- package/dist/shared/form/index.js +8 -0
- package/dist/shared/form/index.js.map +1 -0
- package/dist/shared/form/ui/header/index.d.ts +8 -0
- package/dist/shared/form/ui/header/index.js +24 -0
- package/dist/shared/form/ui/header/index.js.map +1 -0
- package/dist/shared/form/ui/index.d.ts +31 -0
- package/dist/shared/form/ui/index.js +57 -0
- package/dist/shared/form/ui/index.js.map +1 -0
- package/dist/shared/form/validation.d.ts +51 -0
- package/dist/shared/form/validation.js +127 -0
- package/dist/shared/form/validation.js.map +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/payload/fields/field-copy-button/index.d.ts +3 -0
- package/dist/shared/payload/fields/field-copy-button/index.js +38 -0
- package/dist/shared/payload/fields/field-copy-button/index.js.map +1 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.d.ts +3 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.js +26 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.js.map +1 -0
- package/dist/shared/payload/fields/index.d.ts +2 -0
- package/dist/shared/payload/fields/index.js +4 -0
- package/dist/shared/payload/fields/index.js.map +1 -0
- package/dist/shared/utils/regex.d.ts +2 -0
- package/dist/shared/utils/regex.js +4 -0
- package/dist/shared/utils/regex.js.map +1 -0
- package/dist/shared/utils/try-catch.d.ts +11 -0
- package/dist/shared/utils/try-catch.js +17 -0
- package/dist/shared/utils/try-catch.js.map +1 -0
- package/dist/shared/utils/value-or-default.d.ts +9 -0
- package/dist/shared/utils/value-or-default.js +12 -0
- package/dist/shared/utils/value-or-default.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { baModelKey } from "../../constants";
|
|
2
|
+
import { getAdminAccess } from "../../helpers/get-admin-access";
|
|
3
|
+
import { assertAllSchemaFields, getSchemaCollectionSlug, getSchemaFieldName } from "./utils/collection-schema";
|
|
4
|
+
import { filterDuplicateFields } from "./utils/filter-duplicate-fields";
|
|
5
|
+
import { getCollectionFields } from "./utils/transform-schema-fields-to-payload";
|
|
6
|
+
export function buildJwksCollection({ incomingCollections, pluginOptions, resolvedSchemas }) {
|
|
7
|
+
const jwksSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.jwks);
|
|
8
|
+
const jwksSchema = resolvedSchemas[baModelKey.jwks];
|
|
9
|
+
const existingJwksCollection = incomingCollections.find((collection)=>collection.slug === jwksSlug);
|
|
10
|
+
const fieldOverrides = {
|
|
11
|
+
publicKey: ()=>({
|
|
12
|
+
index: true,
|
|
13
|
+
admin: {
|
|
14
|
+
description: 'The public part of the web key'
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
privateKey: ()=>({
|
|
18
|
+
admin: {
|
|
19
|
+
description: 'The private part of the web key'
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
const collectionFields = getCollectionFields({
|
|
24
|
+
schema: jwksSchema,
|
|
25
|
+
additionalProperties: fieldOverrides
|
|
26
|
+
});
|
|
27
|
+
let jwksCollection = {
|
|
28
|
+
...existingJwksCollection,
|
|
29
|
+
slug: jwksSlug,
|
|
30
|
+
admin: {
|
|
31
|
+
hidden: pluginOptions.hidePluginCollections ?? false,
|
|
32
|
+
useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.jwks, 'publicKey'),
|
|
33
|
+
description: 'JWKS are used to verify the signature of the JWT token',
|
|
34
|
+
group: pluginOptions?.collectionAdminGroup ?? 'Auth',
|
|
35
|
+
...existingJwksCollection?.admin
|
|
36
|
+
},
|
|
37
|
+
access: {
|
|
38
|
+
...getAdminAccess(pluginOptions),
|
|
39
|
+
...existingJwksCollection?.access ?? {}
|
|
40
|
+
},
|
|
41
|
+
custom: {
|
|
42
|
+
...existingJwksCollection?.custom ?? {},
|
|
43
|
+
betterAuthModelKey: baModelKey.jwks
|
|
44
|
+
},
|
|
45
|
+
fields: [
|
|
46
|
+
...existingJwksCollection?.fields ?? [],
|
|
47
|
+
...filterDuplicateFields(existingJwksCollection?.fields, collectionFields)
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
if (typeof pluginOptions.pluginCollectionOverrides?.jwks === 'function') {
|
|
51
|
+
jwksCollection = pluginOptions.pluginCollectionOverrides.jwks({
|
|
52
|
+
collection: jwksCollection
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
assertAllSchemaFields(jwksCollection, jwksSchema);
|
|
56
|
+
return jwksCollection;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=jwks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/better-auth/plugin/lib/build-collections/jwks.ts"],"sourcesContent":["import { baModelKey } from '../../constants';\nimport { getAdminAccess } from '../../helpers/get-admin-access';\nimport {\n assertAllSchemaFields,\n getSchemaCollectionSlug,\n getSchemaFieldName,\n} from './utils/collection-schema';\nimport { filterDuplicateFields } from './utils/filter-duplicate-fields';\nimport { getCollectionFields } from './utils/transform-schema-fields-to-payload';\n\nimport type { Jwks } from '@/better-auth/generated-types';\nimport type { BuildCollectionProps, FieldOverrides } from '@/better-auth/plugin/types';\nimport type { CollectionConfig } from 'payload';\n\nexport function buildJwksCollection({\n incomingCollections,\n pluginOptions,\n resolvedSchemas,\n}: BuildCollectionProps): CollectionConfig {\n const jwksSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.jwks);\n const jwksSchema = resolvedSchemas[baModelKey.jwks];\n\n const existingJwksCollection = incomingCollections.find(\n collection => collection.slug === jwksSlug\n ) as CollectionConfig | undefined;\n\n const fieldOverrides: FieldOverrides<keyof Jwks> = {\n publicKey: () => ({\n index: true,\n admin: { description: 'The public part of the web key' },\n }),\n privateKey: () => ({\n admin: { description: 'The private part of the web key' },\n }),\n };\n\n const collectionFields = getCollectionFields({\n schema: jwksSchema,\n additionalProperties: fieldOverrides,\n });\n\n let jwksCollection: CollectionConfig = {\n ...existingJwksCollection,\n slug: jwksSlug,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.jwks, 'publicKey'),\n description: 'JWKS are used to verify the signature of the JWT token',\n group: pluginOptions?.collectionAdminGroup ?? 'Auth',\n ...existingJwksCollection?.admin,\n },\n access: {\n ...getAdminAccess(pluginOptions),\n ...(existingJwksCollection?.access ?? {}),\n },\n custom: {\n ...(existingJwksCollection?.custom ?? {}),\n betterAuthModelKey: baModelKey.jwks,\n },\n fields: [\n ...(existingJwksCollection?.fields ?? []),\n ...filterDuplicateFields(existingJwksCollection?.fields, collectionFields),\n ],\n };\n\n if (typeof pluginOptions.pluginCollectionOverrides?.jwks === 'function') {\n jwksCollection = pluginOptions.pluginCollectionOverrides.jwks({\n collection: jwksCollection,\n });\n }\n\n assertAllSchemaFields(jwksCollection, jwksSchema);\n\n return jwksCollection;\n}\n"],"names":["baModelKey","getAdminAccess","assertAllSchemaFields","getSchemaCollectionSlug","getSchemaFieldName","filterDuplicateFields","getCollectionFields","buildJwksCollection","incomingCollections","pluginOptions","resolvedSchemas","jwksSlug","jwks","jwksSchema","existingJwksCollection","find","collection","slug","fieldOverrides","publicKey","index","admin","description","privateKey","collectionFields","schema","additionalProperties","jwksCollection","hidden","hidePluginCollections","useAsTitle","group","collectionAdminGroup","access","custom","betterAuthModelKey","fields","pluginCollectionOverrides"],"mappings":"AAAA,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SACEC,qBAAqB,EACrBC,uBAAuB,EACvBC,kBAAkB,QACb,4BAA4B;AACnC,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mBAAmB,QAAQ,6CAA6C;AAMjF,OAAO,SAASC,oBAAoB,EAClCC,mBAAmB,EACnBC,aAAa,EACbC,eAAe,EACM;IACrB,MAAMC,WAAWR,wBAAwBO,iBAAiBV,WAAWY,IAAI;IACzE,MAAMC,aAAaH,eAAe,CAACV,WAAWY,IAAI,CAAC;IAEnD,MAAME,yBAAyBN,oBAAoBO,IAAI,CACrDC,CAAAA,aAAcA,WAAWC,IAAI,KAAKN;IAGpC,MAAMO,iBAA6C;QACjDC,WAAW,IAAO,CAAA;gBAChBC,OAAO;gBACPC,OAAO;oBAAEC,aAAa;gBAAiC;YACzD,CAAA;QACAC,YAAY,IAAO,CAAA;gBACjBF,OAAO;oBAAEC,aAAa;gBAAkC;YAC1D,CAAA;IACF;IAEA,MAAME,mBAAmBlB,oBAAoB;QAC3CmB,QAAQZ;QACRa,sBAAsBR;IACxB;IAEA,IAAIS,iBAAmC;QACrC,GAAGb,sBAAsB;QACzBG,MAAMN;QACNU,OAAO;YACLO,QAAQnB,cAAcoB,qBAAqB,IAAI;YAC/CC,YAAY1B,mBAAmBM,iBAAiBV,WAAWY,IAAI,EAAE;YACjEU,aAAa;YACbS,OAAOtB,eAAeuB,wBAAwB;YAC9C,GAAGlB,wBAAwBO,KAAK;QAClC;QACAY,QAAQ;YACN,GAAGhC,eAAeQ,cAAc;YAChC,GAAIK,wBAAwBmB,UAAU,CAAC,CAAC;QAC1C;QACAC,QAAQ;YACN,GAAIpB,wBAAwBoB,UAAU,CAAC,CAAC;YACxCC,oBAAoBnC,WAAWY,IAAI;QACrC;QACAwB,QAAQ;eACFtB,wBAAwBsB,UAAU,EAAE;eACrC/B,sBAAsBS,wBAAwBsB,QAAQZ;SAC1D;IACH;IAEA,IAAI,OAAOf,cAAc4B,yBAAyB,EAAEzB,SAAS,YAAY;QACvEe,iBAAiBlB,cAAc4B,yBAAyB,CAACzB,IAAI,CAAC;YAC5DI,YAAYW;QACd;IACF;IAEAzB,sBAAsByB,gBAAgBd;IAEtC,OAAOc;AACT"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { baModelKey } from "../../constants";
|
|
2
|
+
import { getAdminAccess } from "../../helpers/get-admin-access";
|
|
3
|
+
import { assertAllSchemaFields, getSchemaCollectionSlug, getSchemaFieldName } from "./utils/collection-schema";
|
|
4
|
+
import { filterDuplicateFields } from "./utils/filter-duplicate-fields";
|
|
5
|
+
import { getCollectionFields } from "./utils/transform-schema-fields-to-payload";
|
|
6
|
+
export function buildMembersCollection({ incomingCollections, pluginOptions, resolvedSchemas }) {
|
|
7
|
+
const memberSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.member);
|
|
8
|
+
const memberSchema = resolvedSchemas[baModelKey.member];
|
|
9
|
+
const existingMemberCollection = incomingCollections.find((collection)=>collection.slug === memberSlug);
|
|
10
|
+
const fieldOverrides = {
|
|
11
|
+
organizationId: ()=>({
|
|
12
|
+
index: true,
|
|
13
|
+
admin: {
|
|
14
|
+
readOnly: true,
|
|
15
|
+
description: 'The organization that the member belongs to.'
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
userId: ()=>({
|
|
19
|
+
index: true,
|
|
20
|
+
admin: {
|
|
21
|
+
readOnly: true,
|
|
22
|
+
description: 'The user that is a member of the organization.'
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
teamId: ()=>({
|
|
26
|
+
admin: {
|
|
27
|
+
description: 'The team that the member belongs to.'
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
role: ()=>({
|
|
31
|
+
defaultValue: 'member',
|
|
32
|
+
admin: {
|
|
33
|
+
description: 'The role of the member in the organization.'
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
const collectionFields = getCollectionFields({
|
|
38
|
+
schema: memberSchema,
|
|
39
|
+
additionalProperties: fieldOverrides
|
|
40
|
+
});
|
|
41
|
+
let memberCollection = {
|
|
42
|
+
...existingMemberCollection,
|
|
43
|
+
slug: memberSlug,
|
|
44
|
+
admin: {
|
|
45
|
+
hidden: pluginOptions.hidePluginCollections ?? false,
|
|
46
|
+
useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.member, 'organizationId'),
|
|
47
|
+
description: 'Members of an organization.',
|
|
48
|
+
group: pluginOptions?.collectionAdminGroup ?? 'Auth',
|
|
49
|
+
...existingMemberCollection?.admin
|
|
50
|
+
},
|
|
51
|
+
access: {
|
|
52
|
+
...getAdminAccess(pluginOptions),
|
|
53
|
+
...existingMemberCollection?.access ?? {}
|
|
54
|
+
},
|
|
55
|
+
custom: {
|
|
56
|
+
...existingMemberCollection?.custom ?? {},
|
|
57
|
+
betterAuthModelKey: baModelKey.member
|
|
58
|
+
},
|
|
59
|
+
fields: [
|
|
60
|
+
...existingMemberCollection?.fields ?? [],
|
|
61
|
+
...filterDuplicateFields(existingMemberCollection?.fields, collectionFields)
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
if (typeof pluginOptions.pluginCollectionOverrides?.members === 'function') {
|
|
65
|
+
memberCollection = pluginOptions.pluginCollectionOverrides.members({
|
|
66
|
+
collection: memberCollection
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
assertAllSchemaFields(memberCollection, memberSchema);
|
|
70
|
+
return memberCollection;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=members.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/better-auth/plugin/lib/build-collections/members.ts"],"sourcesContent":["import { baModelKey } from '../../constants';\nimport { getAdminAccess } from '../../helpers/get-admin-access';\nimport {\n assertAllSchemaFields,\n getSchemaCollectionSlug,\n getSchemaFieldName,\n} from './utils/collection-schema';\nimport { filterDuplicateFields } from './utils/filter-duplicate-fields';\nimport { getCollectionFields } from './utils/transform-schema-fields-to-payload';\n\nimport type { Member } from '@/better-auth/generated-types';\nimport type { BuildCollectionProps, FieldOverrides } from '@/better-auth/plugin/types';\nimport type { CollectionConfig } from 'payload';\n\nexport function buildMembersCollection({\n incomingCollections,\n pluginOptions,\n resolvedSchemas,\n}: BuildCollectionProps): CollectionConfig {\n const memberSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.member);\n const memberSchema = resolvedSchemas[baModelKey.member];\n\n const existingMemberCollection = incomingCollections.find(\n collection => collection.slug === memberSlug\n ) as CollectionConfig | undefined;\n\n const fieldOverrides: FieldOverrides<keyof Member> = {\n organizationId: () => ({\n index: true,\n admin: { readOnly: true, description: 'The organization that the member belongs to.' },\n }),\n userId: () => ({\n index: true,\n admin: { readOnly: true, description: 'The user that is a member of the organization.' },\n }),\n teamId: () => ({\n admin: { description: 'The team that the member belongs to.' },\n }),\n role: () => ({\n defaultValue: 'member',\n admin: { description: 'The role of the member in the organization.' },\n }),\n };\n\n const collectionFields = getCollectionFields({\n schema: memberSchema,\n additionalProperties: fieldOverrides,\n });\n\n let memberCollection: CollectionConfig = {\n ...existingMemberCollection,\n slug: memberSlug,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.member, 'organizationId'),\n description: 'Members of an organization.',\n group: pluginOptions?.collectionAdminGroup ?? 'Auth',\n ...existingMemberCollection?.admin,\n },\n access: {\n ...getAdminAccess(pluginOptions),\n ...(existingMemberCollection?.access ?? {}),\n },\n custom: {\n ...(existingMemberCollection?.custom ?? {}),\n betterAuthModelKey: baModelKey.member,\n },\n fields: [\n ...(existingMemberCollection?.fields ?? []),\n ...filterDuplicateFields(existingMemberCollection?.fields, collectionFields),\n ],\n };\n\n if (typeof pluginOptions.pluginCollectionOverrides?.members === 'function') {\n memberCollection = pluginOptions.pluginCollectionOverrides.members({\n collection: memberCollection,\n });\n }\n\n assertAllSchemaFields(memberCollection, memberSchema);\n\n return memberCollection;\n}\n"],"names":["baModelKey","getAdminAccess","assertAllSchemaFields","getSchemaCollectionSlug","getSchemaFieldName","filterDuplicateFields","getCollectionFields","buildMembersCollection","incomingCollections","pluginOptions","resolvedSchemas","memberSlug","member","memberSchema","existingMemberCollection","find","collection","slug","fieldOverrides","organizationId","index","admin","readOnly","description","userId","teamId","role","defaultValue","collectionFields","schema","additionalProperties","memberCollection","hidden","hidePluginCollections","useAsTitle","group","collectionAdminGroup","access","custom","betterAuth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YACN,GAAGpC,eAAeQ,cAAc;YAChC,GAAIK,0BAA0BuB,UAAU,CAAC,CAAC;QAC5C;QACAC,QAAQ;YACN,GAAIxB,0BAA0BwB,UAAU,CAAC,CAAC;YAC1CC,oBAAoBvC,WAAWY,MAAM;QACvC;QACA4B,QAAQ;eACF1B,0BAA0B0B,UAAU,EAAE;eACvCnC,sBAAsBS,0BAA0B0B,QAAQZ;SAC5D;IACH;IAEA,IAAI,OAAOnB,cAAcgC,yBAAyB,EAAEC,YAAY,YAAY;QAC1EX,mBAAmBtB,cAAcgC,yBAAyB,CAACC,OAAO,CAAC;YACjE1B,YAAYe;QACd;IACF;IAEA7B,sBAAsB6B,kBAAkBlB;IAExC,OAAOkB;AACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BuildCollectionProps } from '@/better-auth/plugin/types';
|
|
2
|
+
import type { CollectionConfig } from 'payload';
|
|
3
|
+
export declare function buildOauthAccessTokensCollection({ incomingCollections, pluginOptions, resolvedSchemas, }: BuildCollectionProps): CollectionConfig;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { baModelKey } from "../../constants";
|
|
2
|
+
import { getAdminAccess } from "../../helpers/get-admin-access";
|
|
3
|
+
import { assertAllSchemaFields, getSchemaCollectionSlug, getSchemaFieldName } from "./utils/collection-schema";
|
|
4
|
+
import { filterDuplicateFields } from "./utils/filter-duplicate-fields";
|
|
5
|
+
import { getCollectionFields } from "./utils/transform-schema-fields-to-payload";
|
|
6
|
+
export function buildOauthAccessTokensCollection({ incomingCollections, pluginOptions, resolvedSchemas }) {
|
|
7
|
+
const oauthAccessTokenSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.oauthAccessToken);
|
|
8
|
+
const oauthAccessTokenSchema = resolvedSchemas[baModelKey.oauthAccessToken];
|
|
9
|
+
const existingOauthAccessTokenCollection = incomingCollections.find((collection)=>collection.slug === oauthAccessTokenSlug);
|
|
10
|
+
const fieldOverrides = {
|
|
11
|
+
accessToken: ()=>({
|
|
12
|
+
index: true,
|
|
13
|
+
admin: {
|
|
14
|
+
readOnly: true,
|
|
15
|
+
description: 'Access token issued to the client'
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
refreshToken: ()=>({
|
|
19
|
+
admin: {
|
|
20
|
+
readOnly: true,
|
|
21
|
+
description: 'Refresh token issued to the client'
|
|
22
|
+
}
|
|
23
|
+
}),
|
|
24
|
+
accessTokenExpiresAt: ()=>({
|
|
25
|
+
admin: {
|
|
26
|
+
readOnly: true,
|
|
27
|
+
description: 'Expiration date of the access token'
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
refreshTokenExpiresAt: ()=>({
|
|
31
|
+
admin: {
|
|
32
|
+
readOnly: true,
|
|
33
|
+
description: 'Expiration date of the refresh token'
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
clientId: ()=>({
|
|
37
|
+
admin: {
|
|
38
|
+
readOnly: true,
|
|
39
|
+
description: 'OAuth application associated with the access token'
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
userId: ()=>({
|
|
43
|
+
admin: {
|
|
44
|
+
readOnly: true,
|
|
45
|
+
description: 'User associated with the access token'
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
scopes: ()=>({
|
|
49
|
+
admin: {
|
|
50
|
+
description: 'Comma-separated list of scopes granted'
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
const oauthAccessTokenFieldRules = [
|
|
55
|
+
{
|
|
56
|
+
condition: (field)=>field.type === 'date',
|
|
57
|
+
transform: (field)=>({
|
|
58
|
+
...field,
|
|
59
|
+
saveToJWT: false,
|
|
60
|
+
admin: {
|
|
61
|
+
disableBulkEdit: true,
|
|
62
|
+
hidden: true
|
|
63
|
+
},
|
|
64
|
+
index: true,
|
|
65
|
+
// Using any because PayloadCMS label function receives translation function with dynamic type
|
|
66
|
+
label: ({ t })=>t('general:updatedAt')
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
const collectionFields = getCollectionFields({
|
|
71
|
+
schema: oauthAccessTokenSchema,
|
|
72
|
+
fieldRules: oauthAccessTokenFieldRules,
|
|
73
|
+
additionalProperties: fieldOverrides
|
|
74
|
+
});
|
|
75
|
+
let oauthAccessTokenCollection = {
|
|
76
|
+
...existingOauthAccessTokenCollection,
|
|
77
|
+
slug: oauthAccessTokenSlug,
|
|
78
|
+
admin: {
|
|
79
|
+
hidden: pluginOptions.hidePluginCollections ?? false,
|
|
80
|
+
useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.oauthAccessToken, 'accessToken'),
|
|
81
|
+
description: 'OAuth access tokens for custom OAuth clients',
|
|
82
|
+
group: pluginOptions?.collectionAdminGroup ?? 'Auth',
|
|
83
|
+
...existingOauthAccessTokenCollection?.admin
|
|
84
|
+
},
|
|
85
|
+
access: {
|
|
86
|
+
...getAdminAccess(pluginOptions),
|
|
87
|
+
...existingOauthAccessTokenCollection?.access ?? {}
|
|
88
|
+
},
|
|
89
|
+
custom: {
|
|
90
|
+
...existingOauthAccessTokenCollection?.custom ?? {},
|
|
91
|
+
betterAuthModelKey: baModelKey.oauthAccessToken
|
|
92
|
+
},
|
|
93
|
+
fields: [
|
|
94
|
+
...existingOauthAccessTokenCollection?.fields ?? [],
|
|
95
|
+
...filterDuplicateFields(existingOauthAccessTokenCollection?.fields, collectionFields)
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
if (typeof pluginOptions.pluginCollectionOverrides?.oauthAccessTokens === 'function') {
|
|
99
|
+
oauthAccessTokenCollection = pluginOptions.pluginCollectionOverrides.oauthAccessTokens({
|
|
100
|
+
collection: oauthAccessTokenCollection
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
assertAllSchemaFields(oauthAccessTokenCollection, oauthAccessTokenSchema);
|
|
104
|
+
return oauthAccessTokenCollection;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=oauth-access-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/better-auth/plugin/lib/build-collections/oauth-access-tokens.ts"],"sourcesContent":["import { baModelKey } from '../../constants';\nimport { getAdminAccess } from '../../helpers/get-admin-access';\nimport {\n assertAllSchemaFields,\n getSchemaCollectionSlug,\n getSchemaFieldName,\n} from './utils/collection-schema';\nimport { filterDuplicateFields } from './utils/filter-duplicate-fields';\nimport { getCollectionFields } from './utils/transform-schema-fields-to-payload';\n\nimport type { OauthAccessToken } from '@/better-auth/generated-types';\nimport type { BuildCollectionProps, FieldOverrides, FieldRule } from '@/better-auth/plugin/types';\nimport type { CollectionConfig } from 'payload';\n\nexport function buildOauthAccessTokensCollection({\n incomingCollections,\n pluginOptions,\n resolvedSchemas,\n}: BuildCollectionProps): CollectionConfig {\n const oauthAccessTokenSlug = getSchemaCollectionSlug(\n resolvedSchemas,\n baModelKey.oauthAccessToken\n );\n const oauthAccessTokenSchema = resolvedSchemas[baModelKey.oauthAccessToken];\n\n const existingOauthAccessTokenCollection = incomingCollections.find(\n collection => collection.slug === oauthAccessTokenSlug\n ) as CollectionConfig | undefined;\n\n const fieldOverrides: FieldOverrides<keyof OauthAccessToken> = {\n accessToken: () => ({\n index: true,\n admin: { readOnly: true, description: 'Access token issued to the client' },\n }),\n refreshToken: () => ({\n admin: { readOnly: true, description: 'Refresh token issued to the client' },\n }),\n accessTokenExpiresAt: () => ({\n admin: { readOnly: true, description: 'Expiration date of the access token' },\n }),\n refreshTokenExpiresAt: () => ({\n admin: { readOnly: true, description: 'Expiration date of the refresh token' },\n }),\n clientId: () => ({\n admin: { readOnly: true, description: 'OAuth application associated with the access token' },\n }),\n userId: () => ({\n admin: { readOnly: true, description: 'User associated with the access token' },\n }),\n scopes: () => ({\n admin: { description: 'Comma-separated list of scopes granted' },\n }),\n };\n\n const oauthAccessTokenFieldRules: FieldRule[] = [\n {\n condition: field => field.type === 'date',\n transform: field => ({\n ...field,\n saveToJWT: false,\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n index: true,\n // Using any because PayloadCMS label function receives translation function with dynamic type\n label: ({ t }: any) => t('general:updatedAt'),\n }),\n },\n ];\n\n const collectionFields = getCollectionFields({\n schema: oauthAccessTokenSchema,\n fieldRules: oauthAccessTokenFieldRules,\n additionalProperties: fieldOverrides,\n });\n\n let oauthAccessTokenCollection: CollectionConfig = {\n ...existingOauthAccessTokenCollection,\n slug: oauthAccessTokenSlug,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.oauthAccessToken, 'accessToken'),\n description: 'OAuth access tokens for custom OAuth clients',\n group: pluginOptions?.collectionAdminGroup ?? 'Auth',\n ...existingOauthAccessTokenCollection?.admin,\n },\n access: {\n ...getAdminAccess(pluginOptions),\n ...(existingOauthAccessTokenCollection?.access ?? {}),\n },\n custom: {\n ...(existingOauthAccessTokenCollection?.custom ?? {}),\n betterAuthModelKey: baModelKey.oauthAccessToken,\n },\n fields: [\n ...(existingOauthAccessTokenCollection?.fields ?? []),\n ...filterDuplicateFields(existingOauthAccessTokenCollection?.fields, collectionFields),\n ],\n };\n\n if (typeof pluginOptions.pluginCollectionOverrides?.oauthAccessTokens === 'function') {\n oauthAccessTokenCollection = pluginOptions.pluginCollectionOverrides.oauthAccessTokens({\n collection: oauthAccessTokenCollection,\n });\n }\n\n assertAllSchemaFields(oauthAccessTokenCollection, oauthAccessTokenSchema);\n\n return oauthAccessTokenCollection;\n}\n"],"names":["baModelKey","getAdminAccess","assertAllSchemaFields","getSchemaCollectionSlug","getSchemaFieldName","filterDuplicateFields","getCollectionFields","buildOauthAccessTokensCollection","incomingCollections","pluginOptions","resolvedSchemas","oauthAccessTokenSlug","oauthAccessToken","oauthAccessTokenSchema","existingOauthAccessTokenCollection","find","collection","slug","fieldOverrides","accessToken","index","admin","readOnly","description","refreshToken","accessTokenExpiresAt","refreshTokenExpiresAt","clientId","userId","scopes","oauthAccessTokenFieldRules","condition","field","type","transform","saveToJWT","disableBulkEdit","hidden","label","t","collectionFields","schema","fieldRules","additionalProperties","oauthAccessTokenCollection","hidePluginCollections","useAsTitle","group","collectionAdminGroup","access","custom","betterAuthModelKey","fields","pluginCollectionOverrides","oauthAccessTokens"],"mappings":"AAAA,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SACEC,qBAAqB,EACrBC,uBAAuB,EACvBC,kBAAkB,QACb,4BAA4B;AACnC,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mBAAmB,QAAQ,6CAA6C;AAMjF,OAAO,SAASC,iCAAiC,EAC/CC,mBAAmB,EACnBC,aAAa,EACbC,eAAe,EACM;IACrB,MAAMC,uBAAuBR,wBAC3BO,iBACAV,WAAWY,gBAAgB;IAE7B,MAAMC,yBAAyBH,eAAe,CAACV,WAAWY,gBAAgB,CAAC;IAE3E,MAAME,qCAAqCN,oBAAoBO,IAAI,CACjEC,CAAAA,aAAcA,WAAWC,IAAI,KAAKN;IAGpC,MAAMO,iBAAyD;QAC7DC,aAAa,IAAO,CAAA;gBAClBC,OAAO;gBACPC,OAAO;oBAAEC,UAAU;oBAAMC,aAAa;gBAAoC;YAC5E,CAAA;QACAC,cAAc,IAAO,CAAA;gBACnBH,OAAO;oBAAEC,UAAU;oBAAMC,aAAa;gBAAqC;YAC7E,CAAA;QACAE,sBAAsB,IAAO,CAAA;gBAC3BJ,OAAO;oBAAEC,UAAU;oBAAMC,aAAa;gBAAsC;YAC9E,CAAA;QACAG,uBAAuB,IAAO,CAAA;gBAC5BL,OAAO;oBAAEC,UAAU;oBAAMC,aAAa;gBAAuC;YAC/E,CAAA;QACAI,UAAU,IAAO,CAAA;gBACfN,OAAO;oBAAEC,UAAU;oBAAMC,aAAa;gBAAqD;YAC7F,CAAA;QACAK,QAAQ,IAAO,CAAA;gBACbP,OAAO;oBAAEC,UAAU;oBAAMC,aAAa;gBAAwC;YAChF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1
|
+
import type { BuildCollectionProps } from '@/better-auth/plugin/types';
|
|
2
|
+
import type { CollectionConfig } from 'payload';
|
|
3
|
+
export declare function buildOauthApplicationsCollection({ incomingCollections, pluginOptions, resolvedSchemas, }: BuildCollectionProps): CollectionConfig;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { baModelKey } from "../../constants";
|
|
2
|
+
import { getAdminAccess } from "../../helpers/get-admin-access";
|
|
3
|
+
import { assertAllSchemaFields, getSchemaCollectionSlug } from "./utils/collection-schema";
|
|
4
|
+
import { filterDuplicateFields } from "./utils/filter-duplicate-fields";
|
|
5
|
+
import { getCollectionFields } from "./utils/transform-schema-fields-to-payload";
|
|
6
|
+
export function buildOauthApplicationsCollection({ incomingCollections, pluginOptions, resolvedSchemas }) {
|
|
7
|
+
const oauthApplicationSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.oauthApplication);
|
|
8
|
+
const oauthApplicationSchema = resolvedSchemas[baModelKey.oauthApplication];
|
|
9
|
+
const existingOauthApplicationCollection = incomingCollections.find((collection)=>collection.slug === oauthApplicationSlug);
|
|
10
|
+
const fieldOverrides = {
|
|
11
|
+
clientId: ()=>({
|
|
12
|
+
unique: true,
|
|
13
|
+
index: true,
|
|
14
|
+
admin: {
|
|
15
|
+
readOnly: true,
|
|
16
|
+
description: 'Unique identifier for each OAuth client'
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
clientSecret: ()=>({
|
|
20
|
+
admin: {
|
|
21
|
+
readOnly: true,
|
|
22
|
+
description: 'Secret key for the OAuth client'
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
name: ()=>({
|
|
26
|
+
index: true,
|
|
27
|
+
admin: {
|
|
28
|
+
description: 'Name of the OAuth application'
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
redirectURLs: ()=>({
|
|
32
|
+
admin: {
|
|
33
|
+
description: 'Comma-separated list of redirect URLs'
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
metadata: ()=>({
|
|
37
|
+
admin: {
|
|
38
|
+
readOnly: true,
|
|
39
|
+
description: 'Additional metadata for the OAuth application'
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
type: ()=>({
|
|
43
|
+
admin: {
|
|
44
|
+
readOnly: true,
|
|
45
|
+
description: 'Type of OAuth client (e.g., web, mobile)'
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
disabled: ()=>({
|
|
49
|
+
defaultValue: false,
|
|
50
|
+
admin: {
|
|
51
|
+
description: 'Indicates if the client is disabled'
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
icon: ()=>({
|
|
55
|
+
admin: {
|
|
56
|
+
description: 'Icon of the OAuth application'
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
userId: ()=>({
|
|
60
|
+
admin: {
|
|
61
|
+
readOnly: true,
|
|
62
|
+
description: 'ID of the user who owns the client. (optional)'
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
const oauthApplicationFieldRules = [
|
|
67
|
+
{
|
|
68
|
+
condition: (field)=>field.type === 'date',
|
|
69
|
+
transform: (field)=>({
|
|
70
|
+
...field,
|
|
71
|
+
saveToJWT: false,
|
|
72
|
+
admin: {
|
|
73
|
+
disableBulkEdit: true,
|
|
74
|
+
hidden: true
|
|
75
|
+
},
|
|
76
|
+
index: true,
|
|
77
|
+
label: ({ t })=>t('general:updatedAt')
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
const collectionFields = getCollectionFields({
|
|
82
|
+
schema: oauthApplicationSchema,
|
|
83
|
+
fieldRules: oauthApplicationFieldRules,
|
|
84
|
+
additionalProperties: fieldOverrides
|
|
85
|
+
});
|
|
86
|
+
let oauthApplicationCollection = {
|
|
87
|
+
...existingOauthApplicationCollection,
|
|
88
|
+
slug: oauthApplicationSlug,
|
|
89
|
+
admin: {
|
|
90
|
+
hidden: pluginOptions.hidePluginCollections ?? false,
|
|
91
|
+
useAsTitle: oauthApplicationSchema?.fields?.name?.fieldName ?? 'id',
|
|
92
|
+
description: 'OAuth applications are custom OAuth clients',
|
|
93
|
+
group: pluginOptions?.collectionAdminGroup ?? 'Auth',
|
|
94
|
+
...existingOauthApplicationCollection?.admin
|
|
95
|
+
},
|
|
96
|
+
access: {
|
|
97
|
+
...getAdminAccess(pluginOptions),
|
|
98
|
+
...existingOauthApplicationCollection?.access ?? {}
|
|
99
|
+
},
|
|
100
|
+
custom: {
|
|
101
|
+
...existingOauthApplicationCollection?.custom ?? {},
|
|
102
|
+
betterAuthModelKey: baModelKey.oauthApplication
|
|
103
|
+
},
|
|
104
|
+
fields: [
|
|
105
|
+
...existingOauthApplicationCollection?.fields ?? [],
|
|
106
|
+
...filterDuplicateFields(existingOauthApplicationCollection?.fields, collectionFields)
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
if (typeof pluginOptions.pluginCollectionOverrides?.oauthApplications === 'function') {
|
|
110
|
+
oauthApplicationCollection = pluginOptions.pluginCollectionOverrides.oauthApplications({
|
|
111
|
+
collection: oauthApplicationCollection
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
assertAllSchemaFields(oauthApplicationCollection, oauthApplicationSchema);
|
|
115
|
+
return oauthApplicationCollection;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=oauth-applications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/better-auth/plugin/lib/build-collections/oauth-applications.ts"],"sourcesContent":["import type { OauthApplication } from '@/better-auth/generated-types';\nimport type { BuildCollectionProps, FieldOverrides, FieldRule } from '@/better-auth/plugin/types';\nimport type { CollectionConfig } from 'payload';\nimport { baModelKey } from '../../constants';\nimport { getAdminAccess } from '../../helpers/get-admin-access';\nimport { assertAllSchemaFields, getSchemaCollectionSlug } from './utils/collection-schema';\nimport { filterDuplicateFields } from './utils/filter-duplicate-fields';\nimport { getCollectionFields } from './utils/transform-schema-fields-to-payload';\n\nexport function buildOauthApplicationsCollection({\n incomingCollections,\n pluginOptions,\n resolvedSchemas,\n}: BuildCollectionProps): CollectionConfig {\n const oauthApplicationSlug = getSchemaCollectionSlug(\n resolvedSchemas,\n baModelKey.oauthApplication\n );\n\n const oauthApplicationSchema = resolvedSchemas[baModelKey.oauthApplication];\n\n const existingOauthApplicationCollection = incomingCollections.find(\n collection => collection.slug === oauthApplicationSlug\n ) as CollectionConfig | undefined;\n\n const fieldOverrides: FieldOverrides<keyof OauthApplication> = {\n clientId: () => ({\n unique: true,\n index: true,\n admin: { readOnly: true, description: 'Unique identifier for each OAuth client' },\n }),\n clientSecret: () => ({\n admin: { readOnly: true, description: 'Secret key for the OAuth client' },\n }),\n name: () => ({\n index: true,\n admin: { description: 'Name of the OAuth application' },\n }),\n redirectURLs: () => ({\n admin: { description: 'Comma-separated list of redirect URLs' },\n }),\n metadata: () => ({\n admin: { readOnly: true, description: 'Additional metadata for the OAuth application' },\n }),\n type: () => ({\n admin: { readOnly: true, description: 'Type of OAuth client (e.g., web, mobile)' },\n }),\n disabled: () => ({\n defaultValue: false,\n admin: { description: 'Indicates if the client is disabled' },\n }),\n icon: () => ({\n admin: { description: 'Icon of the OAuth application' },\n }),\n userId: () => ({\n admin: { readOnly: true, description: 'ID of the user who owns the client. (optional)' },\n }),\n };\n\n const oauthApplicationFieldRules: FieldRule[] = [\n {\n condition: field => field.type === 'date',\n transform: field => ({\n ...field,\n saveToJWT: false,\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n index: true,\n label: ({ t }: any) => t('general:updatedAt'),\n }),\n },\n ];\n\n const collectionFields = getCollectionFields({\n schema: oauthApplicationSchema,\n fieldRules: oauthApplicationFieldRules,\n additionalProperties: fieldOverrides,\n });\n\n let oauthApplicationCollection: CollectionConfig = {\n ...existingOauthApplicationCollection,\n slug: oauthApplicationSlug,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: oauthApplicationSchema?.fields?.name?.fieldName ?? 'id',\n description: 'OAuth applications are custom OAuth clients',\n group: pluginOptions?.collectionAdminGroup ?? 'Auth',\n ...existingOauthApplicationCollection?.admin,\n },\n access: {\n ...getAdminAccess(pluginOptions),\n ...(existingOauthApplicationCollection?.access ?? {}),\n },\n custom: {\n ...(existingOauthApplicationCollection?.custom ?? {}),\n betterAuthModelKey: baModelKey.oauthApplication,\n },\n fields: [\n ...(existingOauthApplicationCollection?.fields ?? []),\n ...filterDuplicateFields(existingOauthApplicationCollection?.fields, collectionFields),\n ],\n };\n\n if (typeof pluginOptions.pluginCollectionOverrides?.oauthApplications === 'function') {\n oauthApplicationCollection = pluginOptions.pluginCollectionOverrides.oauthApplications({\n collection: oauthApplicationCollection,\n });\n }\n\n assertAllSchemaFields(oauthApplicationCollection, oauthApplicationSchema);\n\n return oauthApplicationCollection;\n}\n"],"names":["baModelKey","getAdminAccess","assertAllSchemaFields","getSchemaCollectionSlug","filterDuplicateFields","getCollectionFields","buildOauthApplicationsCollection","incomingCollections","pluginOptions","resolvedSchemas","oauthApplicationSlug","oauthApplication","oauthApplicationSchema","existingOauthApplicationCollection","find","collection","slug","fieldOverrides","clientId","unique","index","admin","readOnly","description","clientSecret","name","redirectURLs","metadata","type","disabled","defaultValue","icon","userId","oauthApplicationFieldRules","condition","field","transform","saveToJWT","disableBulkEdit","hidden","label","t","collectionFields","schema","fieldRules","additionalProperties","oauthApplicationCollection","hidePluginCollections","useAsTitle","fields","fieldName","group","collectionAdminGroup","access","custom","betterAuthModelKey","pluginCollectionOverrides","oauthApplications"],"mappings":"AAGA,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,qBAAqB,EAAEC,uBAAuB,QAAQ,4BAA4B;AAC3F,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mBAAmB,QAAQ,6CAA6C;AAEjF,OAAO,SAASC,iCAAiC,EAC/CC,mBAAmB,EACnBC,aA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OAAO;oBACPoB,OAAO,CAAC,EAAEC,CAAC,EAAO,GAAKA,EAAE;gBAC3B,CAAA;QACF;KACD;IAED,MAAMC,mBAAmBrC,oBAAoB;QAC3CsC,QAAQ/B;QACRgC,YAAYX;QACZY,sBAAsB5B;IACxB;IAEA,IAAI6B,6BAA+C;QACjD,GAAGjC,kCAAkC;QACrCG,MAAMN;QACNW,OAAO;YACLkB,QAAQ/B,cAAcuC,qBAAqB,IAAI;YAC/CC,YAAYpC,wBAAwBqC,QAAQxB,MAAMyB,aAAa;YAC/D3B,aAAa;YACb4B,OAAO3C,eAAe4C,wBAAwB;YAC9C,GAAGvC,oCAAoCQ,KAAK;QAC9C;QACAgC,QAAQ;YACN,GAAGpD,eAAeO,cAAc;YAChC,GAAIK,oCAAoCwC,UAAU,CAAC,CAAC;QACtD;QACAC,QAAQ;YACN,GAAIzC,oCAAoCyC,UAAU,CAAC,CAAC;YACpDC,oBAAoBvD,WAAWW,gBAAgB;QACjD;QACAsC,QAAQ;eACFpC,oCAAoCoC,UAAU,EAAE;eACjD7C,sBAAsBS,oCAAoCoC,QAAQP;SACtE;IACH;IAEA,IAAI,OAAOlC,cAAcgD,yBAAyB,EAAEC,sBAAsB,YAAY;QACpFX,6BAA6BtC,cAAcgD,yBAAyB,CAACC,iBAAiB,CAAC;YACrF1C,YAAY+B;QACd;IACF;IAEA5C,sBAAsB4C,4BAA4BlC;IAElD,OAAOkC;AACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BuildCollectionProps } from '@/better-auth/plugin/types';
|
|
2
|
+
import type { CollectionConfig } from 'payload';
|
|
3
|
+
export declare function buildOauthConsentsCollection({ incomingCollections, pluginOptions, resolvedSchemas, }: BuildCollectionProps): CollectionConfig;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { baModelKey } from "../../constants";
|
|
2
|
+
import { getAdminAccess } from "../../helpers/get-admin-access";
|
|
3
|
+
import { assertAllSchemaFields, getSchemaCollectionSlug } from "./utils/collection-schema";
|
|
4
|
+
import { filterDuplicateFields } from "./utils/filter-duplicate-fields";
|
|
5
|
+
import { getCollectionFields } from "./utils/transform-schema-fields-to-payload";
|
|
6
|
+
export function buildOauthConsentsCollection({ incomingCollections, pluginOptions, resolvedSchemas }) {
|
|
7
|
+
const oauthConsentSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.oauthConsent);
|
|
8
|
+
const oauthConsentSchema = resolvedSchemas[baModelKey.oauthConsent];
|
|
9
|
+
const existingOauthConsentCollection = incomingCollections.find((collection)=>collection.slug === oauthConsentSlug);
|
|
10
|
+
const fieldOverrides = {
|
|
11
|
+
clientId: ()=>({
|
|
12
|
+
admin: {
|
|
13
|
+
readOnly: true,
|
|
14
|
+
description: 'OAuth client associated with the consent'
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
userId: ()=>({
|
|
18
|
+
admin: {
|
|
19
|
+
readOnly: true,
|
|
20
|
+
description: 'User associated with the consent'
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
scopes: ()=>({
|
|
24
|
+
admin: {
|
|
25
|
+
readOnly: true,
|
|
26
|
+
description: 'Comma-separated list of scopes consented to'
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
consentGiven: ()=>({
|
|
30
|
+
defaultValue: false,
|
|
31
|
+
admin: {
|
|
32
|
+
readOnly: true,
|
|
33
|
+
description: 'Indicates if consent was given'
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
const oauthConsentFieldRules = [
|
|
38
|
+
{
|
|
39
|
+
condition: (field)=>field.type === 'date',
|
|
40
|
+
transform: (field)=>({
|
|
41
|
+
...field,
|
|
42
|
+
saveToJWT: false,
|
|
43
|
+
admin: {
|
|
44
|
+
disableBulkEdit: true,
|
|
45
|
+
hidden: true
|
|
46
|
+
},
|
|
47
|
+
index: true,
|
|
48
|
+
// Using any because PayloadCMS label function receives translation function with dynamic type
|
|
49
|
+
label: ({ t })=>t('general:updatedAt')
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
const collectionFields = getCollectionFields({
|
|
54
|
+
schema: oauthConsentSchema,
|
|
55
|
+
fieldRules: oauthConsentFieldRules,
|
|
56
|
+
additionalProperties: fieldOverrides
|
|
57
|
+
});
|
|
58
|
+
let oauthConsentCollection = {
|
|
59
|
+
...existingOauthConsentCollection,
|
|
60
|
+
slug: oauthConsentSlug,
|
|
61
|
+
admin: {
|
|
62
|
+
hidden: pluginOptions.hidePluginCollections ?? false,
|
|
63
|
+
description: 'OAuth consents are used to store user consents for OAuth clients',
|
|
64
|
+
group: pluginOptions?.collectionAdminGroup ?? 'Auth',
|
|
65
|
+
...existingOauthConsentCollection?.admin
|
|
66
|
+
},
|
|
67
|
+
access: {
|
|
68
|
+
...getAdminAccess(pluginOptions),
|
|
69
|
+
...existingOauthConsentCollection?.access ?? {}
|
|
70
|
+
},
|
|
71
|
+
custom: {
|
|
72
|
+
...existingOauthConsentCollection?.custom ?? {},
|
|
73
|
+
betterAuthModelKey: baModelKey.oauthConsent
|
|
74
|
+
},
|
|
75
|
+
fields: [
|
|
76
|
+
...existingOauthConsentCollection?.fields ?? [],
|
|
77
|
+
...filterDuplicateFields(existingOauthConsentCollection?.fields, collectionFields)
|
|
78
|
+
]
|
|
79
|
+
};
|
|
80
|
+
if (typeof pluginOptions.pluginCollectionOverrides?.oauthConsents === 'function') {
|
|
81
|
+
oauthConsentCollection = pluginOptions.pluginCollectionOverrides.oauthConsents({
|
|
82
|
+
collection: oauthConsentCollection
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
assertAllSchemaFields(oauthConsentCollection, oauthConsentSchema);
|
|
86
|
+
return oauthConsentCollection;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=oauth-consents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/better-auth/plugin/lib/build-collections/oauth-consents.ts"],"sourcesContent":["import type { OauthConsent } from '@/better-auth/generated-types';\nimport type { BuildCollectionProps, FieldOverrides, FieldRule } from '@/better-auth/plugin/types';\nimport type { CollectionConfig } from 'payload';\nimport { baModelKey } from '../../constants';\nimport { getAdminAccess } from '../../helpers/get-admin-access';\nimport { assertAllSchemaFields, getSchemaCollectionSlug } from './utils/collection-schema';\nimport { filterDuplicateFields } from './utils/filter-duplicate-fields';\nimport { getCollectionFields } from './utils/transform-schema-fields-to-payload';\n\nexport function buildOauthConsentsCollection({\n incomingCollections,\n pluginOptions,\n resolvedSchemas,\n}: BuildCollectionProps): CollectionConfig {\n const oauthConsentSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.oauthConsent);\n const oauthConsentSchema = resolvedSchemas[baModelKey.oauthConsent];\n\n const existingOauthConsentCollection = incomingCollections.find(\n collection => collection.slug === oauthConsentSlug\n ) as CollectionConfig | undefined;\n\n const fieldOverrides: FieldOverrides<keyof OauthConsent> = {\n clientId: () => ({\n admin: { readOnly: true, description: 'OAuth client associated with the consent' },\n }),\n userId: () => ({\n admin: { readOnly: true, description: 'User associated with the consent' },\n }),\n scopes: () => ({\n admin: { readOnly: true, description: 'Comma-separated list of scopes consented to' },\n }),\n consentGiven: () => ({\n defaultValue: false,\n admin: { readOnly: true, description: 'Indicates if consent was given' },\n }),\n };\n\n const oauthConsentFieldRules: FieldRule[] = [\n {\n condition: field => field.type === 'date',\n transform: field => ({\n ...field,\n saveToJWT: false,\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n index: true,\n // Using any because PayloadCMS label function receives translation function with dynamic type\n label: ({ t }: any) => t('general:updatedAt'),\n }),\n },\n ];\n\n const collectionFields = getCollectionFields({\n schema: oauthConsentSchema,\n fieldRules: oauthConsentFieldRules,\n additionalProperties: fieldOverrides,\n });\n\n let oauthConsentCollection: CollectionConfig = {\n ...existingOauthConsentCollection,\n slug: oauthConsentSlug,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n description: 'OAuth consents are used to store user consents for OAuth clients',\n group: pluginOptions?.collectionAdminGroup ?? 'Auth',\n ...existingOauthConsentCollection?.admin,\n },\n access: {\n ...getAdminAccess(pluginOptions),\n ...(existingOauthConsentCollection?.access ?? {}),\n },\n custom: {\n ...(existingOauthConsentCollection?.custom ?? {}),\n betterAuthModelKey: baModelKey.oauthConsent,\n },\n fields: [\n ...(existingOauthConsentCollection?.fields ?? []),\n ...filterDuplicateFields(existingOauthConsentCollection?.fields, collectionFields),\n ],\n };\n\n if (typeof pluginOptions.pluginCollectionOverrides?.oauthConsents === 'function') {\n oauthConsentCollection = pluginOptions.pluginCollectionOverrides.oauthConsents({\n collection: oauthConsentCollection,\n });\n }\n\n assertAllSchemaFields(oauthConsentCollection, oauthConsentSchema);\n\n return oauthConsentCollection;\n}\n"],"names":["baModelKey","getAdminAccess","assertAllSchemaFields","getSchemaCollectionSlug","filterDuplicateFields","getCollectionFields","buildOauthConsentsCollection","incomingCollections","pluginOptions","resolvedSchemas","oauthConsentSlug","oauthConsent","oauthConsentSchema","existingOauthConsentCollection","find","collection","slug","fieldOverrides","clientId","admin","readOnly","description","userId","scopes","consentGiven","defaultValue","oauthConsentFieldRules","condition","field","type","transform","saveToJWT","disableBulkEdit","hidden","index","label","t","collectionFields","schema","fieldRules","additionalProperties","oauthConsentCollection","hidePluginCollections","group","collectionAdminGroup","access","custom","betterAuthModelKey","fields","pluginCollectionOverrides","oauthConsents"],"mappings":"AAGA,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,qBAAqB,EAAEC,uBAAuB,QAAQ,4BAA4B;AAC3F,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mBAAmB,QAAQ,6CAA6C;AAEjF,OAAO,SAASC,6BAA6B,EAC3CC,mBAAmB,EACnBC,aAAa,EACbC,eAAe,EACM;IACrB,MAAMC,mBAAmBP,wBAAwBM,iBAAiBT,WAAWW,YAAY;IACzF,MAAMC,qBAAqBH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AAC;YAChDC,oBAAoB/C,WAAWW,YAAY;QAC7C;QACAqC,QAAQ;eACFnC,gCAAgCmC,UAAU,EAAE;eAC7C5C,sBAAsBS,gCAAgCmC,QAAQX;SAClE;IACH;IAEA,IAAI,OAAO7B,cAAcyC,yBAAyB,EAAEC,kBAAkB,YAAY;QAChFT,yBAAyBjC,cAAcyC,yBAAyB,CAACC,aAAa,CAAC;YAC7EnC,YAAY0B;QACd;IACF;IAEAvC,sBAAsBuC,wBAAwB7B;IAE9C,OAAO6B;AACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BuildCollectionProps } from '@/better-auth/plugin/types';
|
|
2
|
+
import type { CollectionConfig } from 'payload';
|
|
3
|
+
export declare function buildOrganizationsCollection({ incomingCollections, pluginOptions, resolvedSchemas, }: BuildCollectionProps): CollectionConfig;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { baModelKey } from "../../constants";
|
|
2
|
+
import { getAdminAccess } from "../../helpers/get-admin-access";
|
|
3
|
+
import { assertAllSchemaFields, getSchemaCollectionSlug, getSchemaFieldName } from "./utils/collection-schema";
|
|
4
|
+
import { filterDuplicateFields } from "./utils/filter-duplicate-fields";
|
|
5
|
+
import { getCollectionFields } from "./utils/transform-schema-fields-to-payload";
|
|
6
|
+
export function buildOrganizationsCollection({ incomingCollections, pluginOptions, resolvedSchemas }) {
|
|
7
|
+
const organizationSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.organization);
|
|
8
|
+
const organizationSchema = resolvedSchemas[baModelKey.organization];
|
|
9
|
+
const existingOrganizationCollection = incomingCollections.find((collection)=>collection.slug === organizationSlug);
|
|
10
|
+
const fieldOverrides = {
|
|
11
|
+
name: ()=>({
|
|
12
|
+
admin: {
|
|
13
|
+
description: 'The name of the organization.'
|
|
14
|
+
}
|
|
15
|
+
}),
|
|
16
|
+
slug: ()=>({
|
|
17
|
+
unique: true,
|
|
18
|
+
index: true,
|
|
19
|
+
admin: {
|
|
20
|
+
description: 'The slug of the organization.'
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
logo: ()=>({
|
|
24
|
+
admin: {
|
|
25
|
+
description: 'The logo of the organization.'
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
metadata: ()=>({
|
|
29
|
+
admin: {
|
|
30
|
+
description: 'Additional metadata for the organization.'
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
const collectionFields = getCollectionFields({
|
|
35
|
+
schema: organizationSchema,
|
|
36
|
+
additionalProperties: fieldOverrides
|
|
37
|
+
});
|
|
38
|
+
let organizationCollection = {
|
|
39
|
+
...existingOrganizationCollection,
|
|
40
|
+
slug: organizationSlug,
|
|
41
|
+
admin: {
|
|
42
|
+
hidden: pluginOptions.hidePluginCollections ?? false,
|
|
43
|
+
useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.organization, 'name'),
|
|
44
|
+
description: 'Organizations are groups of users that share access to certain resources.',
|
|
45
|
+
group: pluginOptions?.collectionAdminGroup ?? 'Auth',
|
|
46
|
+
...existingOrganizationCollection?.admin
|
|
47
|
+
},
|
|
48
|
+
access: {
|
|
49
|
+
...getAdminAccess(pluginOptions),
|
|
50
|
+
...existingOrganizationCollection?.access ?? {}
|
|
51
|
+
},
|
|
52
|
+
custom: {
|
|
53
|
+
...existingOrganizationCollection?.custom ?? {},
|
|
54
|
+
betterAuthModelKey: baModelKey.organization
|
|
55
|
+
},
|
|
56
|
+
fields: [
|
|
57
|
+
...existingOrganizationCollection?.fields ?? [],
|
|
58
|
+
...filterDuplicateFields(existingOrganizationCollection?.fields, collectionFields)
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
if (typeof pluginOptions.pluginCollectionOverrides?.organizations === 'function') {
|
|
62
|
+
organizationCollection = pluginOptions.pluginCollectionOverrides.organizations({
|
|
63
|
+
collection: organizationCollection
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
assertAllSchemaFields(organizationCollection, organizationSchema);
|
|
67
|
+
return organizationCollection;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=organizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/better-auth/plugin/lib/build-collections/organizations.ts"],"sourcesContent":["import { baModelKey } from '../../constants';\nimport { getAdminAccess } from '../../helpers/get-admin-access';\nimport {\n assertAllSchemaFields,\n getSchemaCollectionSlug,\n getSchemaFieldName,\n} from './utils/collection-schema';\nimport { filterDuplicateFields } from './utils/filter-duplicate-fields';\nimport { getCollectionFields } from './utils/transform-schema-fields-to-payload';\n\nimport type { Organization } from '@/better-auth/generated-types';\nimport type { BuildCollectionProps, FieldOverrides } from '@/better-auth/plugin/types';\nimport type { CollectionConfig } from 'payload';\n\nexport function buildOrganizationsCollection({\n incomingCollections,\n pluginOptions,\n resolvedSchemas,\n}: BuildCollectionProps): CollectionConfig {\n const organizationSlug = getSchemaCollectionSlug(resolvedSchemas, baModelKey.organization);\n const organizationSchema = resolvedSchemas[baModelKey.organization];\n\n const existingOrganizationCollection = incomingCollections.find(\n collection => collection.slug === organizationSlug\n ) as CollectionConfig | undefined;\n\n const fieldOverrides: FieldOverrides<keyof Organization> = {\n name: () => ({\n admin: { description: 'The name of the organization.' },\n }),\n slug: () => ({\n unique: true,\n index: true,\n admin: { description: 'The slug of the organization.' },\n }),\n logo: () => ({\n admin: { description: 'The logo of the organization.' },\n }),\n metadata: () => ({\n admin: { description: 'Additional metadata for the organization.' },\n }),\n };\n\n const collectionFields = getCollectionFields({\n schema: organizationSchema,\n additionalProperties: fieldOverrides,\n });\n\n let organizationCollection: CollectionConfig = {\n ...existingOrganizationCollection,\n slug: organizationSlug,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: getSchemaFieldName(resolvedSchemas, baModelKey.organization, 'name'),\n description: 'Organizations are groups of users that share access to certain resources.',\n group: pluginOptions?.collectionAdminGroup ?? 'Auth',\n ...existingOrganizationCollection?.admin,\n },\n access: {\n ...getAdminAccess(pluginOptions),\n ...(existingOrganizationCollection?.access ?? {}),\n },\n custom: {\n ...(existingOrganizationCollection?.custom ?? {}),\n betterAuthModelKey: baModelKey.organization,\n },\n fields: [\n ...(existingOrganizationCollection?.fields ?? []),\n ...filterDuplicateFields(existingOrganizationCollection?.fields, collectionFields),\n ],\n };\n\n if (typeof pluginOptions.pluginCollectionOverrides?.organizations === 'function') {\n organizationCollection = pluginOptions.pluginCollectionOverrides.organizations({\n collection: organizationCollection,\n });\n }\n\n assertAllSchemaFields(organizationCollection, organizationSchema);\n\n return organizationCollection;\n}\n"],"names":["baModelKey","getAdminAccess","assertAllSchemaFields","getSchemaCollectionSlug","getSchemaFieldName","filterDuplicateFields","getCollectionFields","buildOrganizationsCollection","incomingCollections","pluginOptions","resolvedSchemas","organizationSlug","organization","organizationSchema","existingOrganizationCollection","find","collection","slug","fieldOverrides","name","admin","description","unique","index","logo","metadata","collectionFields","schema","additionalProperties","organizationCollection","hidden","hidePluginCollections","useAsTitle","group","collectionAdminGroup","access","custom","betterAuthModelKey","fields","pluginCollectionOverrides","organizations"],"mappings":"AAAA,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SACEC,qBAAqB,EACrBC,uBAAuB,EACvBC,kBAAkB,QACb,4BAA4B;AACnC,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mBAAmB,QAAQ,6CAA6C;AAMjF,OAAO,SAASC,6BAA6B,EAC3CC,mBAAmB,EACnBC,aAAa,EACbC,eAAe,EACM;IACrB,MAAMC,mBAAmBR,wBAAwBO,iBAAiBV,WAAWY,YAAY;IACzF,MAAMC,qBAAqBH,eAAe,CAACV,WAAWY,YAAY,CAAC;IAEnE,MAAME,iCAAiCN,oBAAoBO,IAAI,CAC7DC,CAAAA,aAAcA,WAAWC,IAAI,KAAKN;IAGpC,MAAMO,iBAAqD;QACzDC,MAAM,IAAO,CAAA;gBACXC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