@revealui/auth 0.0.1-pre.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -202
- package/README.md +101 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -4
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +10 -0
- package/dist/react/useSession.d.ts +32 -0
- package/dist/react/useSession.d.ts.map +1 -0
- package/dist/react/useSession.js +98 -0
- package/dist/react/useSignIn.d.ts +41 -0
- package/dist/react/useSignIn.d.ts.map +1 -0
- package/dist/react/useSignIn.js +99 -0
- package/dist/react/useSignOut.d.ts +30 -0
- package/dist/react/useSignOut.d.ts.map +1 -0
- package/dist/react/useSignOut.js +57 -0
- package/dist/react/useSignUp.d.ts +43 -0
- package/dist/react/useSignUp.d.ts.map +1 -0
- package/dist/react/useSignUp.js +90 -0
- package/dist/server/auth.d.ts +46 -0
- package/dist/server/auth.d.ts.map +1 -0
- package/dist/server/auth.js +314 -0
- package/dist/server/brute-force.d.ts +44 -0
- package/dist/server/brute-force.d.ts.map +1 -0
- package/dist/server/brute-force.js +149 -0
- package/dist/server/errors.d.ts +28 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/errors.js +51 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +14 -0
- package/dist/server/oauth.d.ts +49 -0
- package/dist/server/oauth.d.ts.map +1 -0
- package/dist/server/oauth.js +223 -0
- package/dist/server/password-reset.d.ts +55 -0
- package/dist/server/password-reset.d.ts.map +1 -0
- package/dist/server/password-reset.js +232 -0
- package/dist/server/password-validation.d.ts +25 -0
- package/dist/server/password-validation.d.ts.map +1 -0
- package/dist/server/password-validation.js +47 -0
- package/dist/server/providers/github.d.ts +14 -0
- package/dist/server/providers/github.d.ts.map +1 -0
- package/dist/server/providers/github.js +73 -0
- package/dist/server/providers/google.d.ts +11 -0
- package/dist/server/providers/google.d.ts.map +1 -0
- package/dist/server/providers/google.js +53 -0
- package/dist/server/providers/vercel.d.ts +11 -0
- package/dist/server/providers/vercel.d.ts.map +1 -0
- package/dist/server/providers/vercel.js +47 -0
- package/dist/server/rate-limit.d.ts +45 -0
- package/dist/server/rate-limit.d.ts.map +1 -0
- package/dist/server/rate-limit.js +130 -0
- package/dist/server/session.d.ts +47 -0
- package/dist/server/session.d.ts.map +1 -0
- package/dist/server/session.js +248 -0
- package/dist/server/storage/database.d.ts +26 -0
- package/dist/server/storage/database.d.ts.map +1 -0
- package/dist/server/storage/database.js +102 -0
- package/dist/server/storage/in-memory.d.ts +28 -0
- package/dist/server/storage/in-memory.d.ts.map +1 -0
- package/dist/server/storage/in-memory.js +80 -0
- package/dist/server/storage/index.d.ts +26 -0
- package/dist/server/storage/index.d.ts.map +1 -0
- package/dist/server/storage/index.js +80 -0
- package/dist/server/storage/interface.d.ts +46 -0
- package/dist/server/storage/interface.d.ts.map +1 -0
- package/dist/server/storage/interface.js +6 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/utils/database.d.ts +53 -0
- package/dist/utils/database.d.ts.map +1 -0
- package/dist/utils/database.js +144 -0
- package/dist/utils/token.d.ts +30 -0
- package/dist/utils/token.d.ts.map +1 -0
- package/dist/utils/token.js +39 -0
- package/package.json +50 -106
- package/dist/better-auth/adapter/__tests__/transform.test.js +0 -213
- package/dist/better-auth/adapter/__tests__/transform.test.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/biome.d.js +0 -2
- package/dist/better-auth/adapter/generate-schema/biome.d.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +0 -5
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +0 -482
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +0 -1
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +0 -42
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/index.d.ts +0 -4
- package/dist/better-auth/adapter/generate-schema/index.js +0 -19
- package/dist/better-auth/adapter/generate-schema/index.js.map +0 -1
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +0 -2
- package/dist/better-auth/adapter/generate-schema/utils.js +0 -20
- package/dist/better-auth/adapter/generate-schema/utils.js.map +0 -1
- package/dist/better-auth/adapter/index.d.ts +0 -15
- package/dist/better-auth/adapter/index.js +0 -731
- package/dist/better-auth/adapter/index.js.map +0 -1
- package/dist/better-auth/adapter/tests/adapter.test.js +0 -174
- package/dist/better-auth/adapter/tests/adapter.test.js.map +0 -1
- package/dist/better-auth/adapter/tests/base-collections-tests.js +0 -575
- package/dist/better-auth/adapter/tests/base-collections-tests.js.map +0 -1
- package/dist/better-auth/adapter/tests/dev/index.js +0 -117
- package/dist/better-auth/adapter/tests/dev/index.js.map +0 -1
- package/dist/better-auth/adapter/tests/dev/migrate.js +0 -26
- package/dist/better-auth/adapter/tests/dev/migrate.js.map +0 -1
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js +0 -218
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js.map +0 -1
- package/dist/better-auth/adapter/tests/dev/schema.js +0 -160
- package/dist/better-auth/adapter/tests/dev/schema.js.map +0 -1
- package/dist/better-auth/adapter/tests/plugins-tests.js +0 -2
- package/dist/better-auth/adapter/tests/plugins-tests.js.map +0 -1
- package/dist/better-auth/adapter/transform/index.d.ts +0 -27
- package/dist/better-auth/adapter/transform/index.js +0 -664
- package/dist/better-auth/adapter/transform/index.js.map +0 -1
- package/dist/better-auth/adapter/types.d.ts +0 -10
- package/dist/better-auth/adapter/types.js +0 -3
- package/dist/better-auth/adapter/types.js.map +0 -1
- package/dist/better-auth/generated-types.d.ts +0 -285
- package/dist/better-auth/index.d.ts +0 -3
- package/dist/better-auth/index.js +0 -5
- package/dist/better-auth/index.js.map +0 -1
- package/dist/better-auth/plugin/__tests__/plugin.test.js +0 -162
- package/dist/better-auth/plugin/__tests__/plugin.test.js.map +0 -1
- package/dist/better-auth/plugin/constants.d.ts +0 -220
- package/dist/better-auth/plugin/constants.js +0 -249
- package/dist/better-auth/plugin/constants.js.map +0 -1
- package/dist/better-auth/plugin/helpers/check-plugin-exists.d.ts +0 -12
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js +0 -14
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js.map +0 -1
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +0 -29
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +0 -46
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-admin-access.d.ts +0 -7
- package/dist/better-auth/plugin/helpers/get-admin-access.js +0 -22
- package/dist/better-auth/plugin/helpers/get-admin-access.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-all-roles.d.ts +0 -5
- package/dist/better-auth/plugin/helpers/get-all-roles.js +0 -20
- package/dist/better-auth/plugin/helpers/get-all-roles.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.d.ts +0 -18
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js +0 -70
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-collection-slug.d.ts +0 -5
- package/dist/better-auth/plugin/helpers/get-collection-slug.js +0 -20
- package/dist/better-auth/plugin/helpers/get-collection-slug.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-collection.d.ts +0 -15
- package/dist/better-auth/plugin/helpers/get-collection.js +0 -29
- package/dist/better-auth/plugin/helpers/get-collection.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +0 -2
- package/dist/better-auth/plugin/helpers/get-ip.js +0 -31
- package/dist/better-auth/plugin/helpers/get-ip.js.map +0 -1
- package/dist/better-auth/plugin/helpers/get-signed-cookie.d.ts +0 -2
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js +0 -65
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js.map +0 -1
- package/dist/better-auth/plugin/helpers/index.d.ts +0 -1
- package/dist/better-auth/plugin/helpers/index.js +0 -3
- package/dist/better-auth/plugin/helpers/index.js.map +0 -1
- package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts +0 -59
- package/dist/better-auth/plugin/helpers/prepare-session-data.js +0 -49
- package/dist/better-auth/plugin/helpers/prepare-session-data.js.map +0 -1
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.d.ts +0 -20
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js +0 -67
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js.map +0 -1
- package/dist/better-auth/plugin/index.d.ts +0 -11
- package/dist/better-auth/plugin/index.js +0 -125
- package/dist/better-auth/plugin/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.d.ts +0 -12
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js +0 -87
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js +0 -60
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js +0 -154
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.d.ts +0 -5
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js +0 -11
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.d.ts +0 -2
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js +0 -8
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.d.ts +0 -6
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js +0 -119
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js +0 -177
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/device-code.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/device-code.js +0 -50
- package/dist/better-auth/plugin/lib/build-collections/device-code.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/index.d.ts +0 -10
- package/dist/better-auth/plugin/lib/build-collections/index.js +0 -73
- package/dist/better-auth/plugin/lib/build-collections/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/invitations.js +0 -94
- package/dist/better-auth/plugin/lib/build-collections/invitations.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/jwks.js +0 -59
- package/dist/better-auth/plugin/lib/build-collections/jwks.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/members.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/members.js +0 -73
- package/dist/better-auth/plugin/lib/build-collections/members.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js +0 -107
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js +0 -118
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js +0 -89
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/organizations.js +0 -70
- package/dist/better-auth/plugin/lib/build-collections/organizations.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js +0 -115
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/sessions.js +0 -170
- package/dist/better-auth/plugin/lib/build-collections/sessions.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js +0 -81
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js +0 -111
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/team-members.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/team-members.js +0 -57
- package/dist/better-auth/plugin/lib/build-collections/team-members.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/teams.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/teams.js +0 -76
- package/dist/better-auth/plugin/lib/build-collections/teams.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js +0 -67
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.d.ts +0 -7
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js +0 -53
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.d.ts +0 -11
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js +0 -75
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.d.ts +0 -4
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js +0 -6
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.d.ts +0 -2
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js +0 -115
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js +0 -64
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js +0 -80
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.d.ts +0 -6
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js +0 -79
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.d.ts +0 -2
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js +0 -82
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts +0 -2
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js +0 -54
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.d.ts +0 -6
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js +0 -15
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.d.ts +0 -6
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js +0 -8
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.d.ts +0 -2
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js +0 -17
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.d.ts +0 -2
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js +0 -91
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/users/index.js +0 -341
- package/dist/better-auth/plugin/lib/build-collections/users/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.d.ts +0 -15
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js +0 -24
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.d.ts +0 -10
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js +0 -67
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.d.ts +0 -9
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js +0 -94
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.d.ts +0 -7
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js +0 -35
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.d.ts +0 -12
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js +0 -25
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.d.ts +0 -14
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js +0 -67
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.d.ts +0 -20
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js +0 -98
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js.map +0 -1
- package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts +0 -3
- package/dist/better-auth/plugin/lib/build-collections/verifications.js +0 -87
- package/dist/better-auth/plugin/lib/build-collections/verifications.js.map +0 -1
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +0 -5
- package/dist/better-auth/plugin/lib/get-payload-auth.js +0 -9
- package/dist/better-auth/plugin/lib/get-payload-auth.js.map +0 -1
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +0 -7
- package/dist/better-auth/plugin/lib/init-better-auth.js +0 -46
- package/dist/better-auth/plugin/lib/init-better-auth.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js +0 -9
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js +0 -10
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js +0 -8
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.d.ts +0 -10
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js +0 -156
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js +0 -18
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js +0 -34
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js +0 -11
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js +0 -10
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.d.ts +0 -2
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js +0 -11
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts +0 -7
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js +0 -23
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.d.ts +0 -25
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js +0 -62
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.d.ts +0 -9
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js +0 -47
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.d.ts +0 -15
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js +0 -42
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js.map +0 -1
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.d.ts +0 -9
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js +0 -63
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js.map +0 -1
- package/dist/better-auth/plugin/lib/set-login-methods.d.ts +0 -4
- package/dist/better-auth/plugin/lib/set-login-methods.js +0 -14
- package/dist/better-auth/plugin/lib/set-login-methods.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts +0 -9
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js +0 -143
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.d.ts +0 -10
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js +0 -219
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/logout-button.d.ts +0 -4
- package/dist/better-auth/plugin/payload/components/logout-button.js +0 -24
- package/dist/better-auth/plugin/payload/components/logout-button.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.d.ts +0 -8
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js +0 -117
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/passkeys/client.d.ts +0 -3
- package/dist/better-auth/plugin/payload/components/passkeys/client.js +0 -66
- package/dist/better-auth/plugin/payload/components/passkeys/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/passkeys/index.d.ts +0 -4
- package/dist/better-auth/plugin/payload/components/passkeys/index.js +0 -52
- package/dist/better-auth/plugin/payload/components/passkeys/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/passkeys/list.d.ts +0 -8
- package/dist/better-auth/plugin/payload/components/passkeys/list.js +0 -57
- package/dist/better-auth/plugin/payload/components/passkeys/list.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/passkeys/types.d.ts +0 -22
- package/dist/better-auth/plugin/payload/components/passkeys/types.js +0 -3
- package/dist/better-auth/plugin/payload/components/passkeys/types.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/rsc-redirect.d.ts +0 -6
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js +0 -7
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.d.ts +0 -15
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js +0 -157
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/token-field.d.ts +0 -4
- package/dist/better-auth/plugin/payload/components/token-field.js +0 -31
- package/dist/better-auth/plugin/payload/components/token-field.js.map +0 -1
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.d.ts +0 -8
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js +0 -300
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/exports/client.d.ts +0 -6
- package/dist/better-auth/plugin/payload/exports/client.js +0 -8
- package/dist/better-auth/plugin/payload/exports/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +0 -8
- package/dist/better-auth/plugin/payload/exports/rsc.js +0 -10
- package/dist/better-auth/plugin/payload/exports/rsc.js.map +0 -1
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.d.ts +0 -2
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js +0 -9
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js.map +0 -1
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.d.ts +0 -1
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js +0 -22
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/admin-login/client.d.ts +0 -19
- package/dist/better-auth/plugin/payload/views/admin-login/client.js +0 -226
- package/dist/better-auth/plugin/payload/views/admin-login/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/admin-login/index.d.ts +0 -10
- package/dist/better-auth/plugin/payload/views/admin-login/index.js +0 -150
- package/dist/better-auth/plugin/payload/views/admin-login/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/admin-signup/client.d.ts +0 -16
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js +0 -299
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/admin-signup/index.d.ts +0 -9
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js +0 -104
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/forgot-password/client.d.ts +0 -7
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js +0 -119
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/forgot-password/index.d.ts +0 -8
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js +0 -78
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts +0 -10
- package/dist/better-auth/plugin/payload/views/reset-password/client.js +0 -144
- package/dist/better-auth/plugin/payload/views/reset-password/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts +0 -8
- package/dist/better-auth/plugin/payload/views/reset-password/index.js +0 -96
- package/dist/better-auth/plugin/payload/views/reset-password/index.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.d.ts +0 -6
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js +0 -96
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js.map +0 -1
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.d.ts +0 -9
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js +0 -56
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js.map +0 -1
- package/dist/better-auth/plugin/types.d.ts +0 -429
- package/dist/better-auth/plugin/types.js +0 -3
- package/dist/better-auth/plugin/types.js.map +0 -1
- package/dist/better-auth/plugin/utils/set.d.ts +0 -39
- package/dist/better-auth/plugin/utils/set.js +0 -103
- package/dist/better-auth/plugin/utils/set.js.map +0 -1
- package/dist/better-auth/scripts/generate-types.d.ts +0 -1
- package/dist/better-auth/scripts/generate-types.js +0 -234
- package/dist/better-auth/scripts/generate-types.js.map +0 -1
- package/dist/better-auth/types.d.ts +0 -2
- package/dist/better-auth/types.js +0 -4
- package/dist/better-auth/types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shared/components/icons.d.ts +0 -7
- package/dist/shared/components/icons.js +0 -442
- package/dist/shared/components/icons.js.map +0 -1
- package/dist/shared/components/logo.d.ts +0 -3
- package/dist/shared/components/logo.js +0 -24
- package/dist/shared/components/logo.js.map +0 -1
- package/dist/shared/form/components/submit.d.ts +0 -7
- package/dist/shared/form/components/submit.js +0 -16
- package/dist/shared/form/components/submit.js.map +0 -1
- package/dist/shared/form/fields/text-field.d.ts +0 -8
- package/dist/shared/form/fields/text-field.js +0 -37
- package/dist/shared/form/fields/text-field.js.map +0 -1
- package/dist/shared/form/index.d.ts +0 -4
- package/dist/shared/form/index.js +0 -8
- package/dist/shared/form/index.js.map +0 -1
- package/dist/shared/form/ui/header/index.d.ts +0 -8
- package/dist/shared/form/ui/header/index.js +0 -24
- package/dist/shared/form/ui/header/index.js.map +0 -1
- package/dist/shared/form/ui/index.d.ts +0 -31
- package/dist/shared/form/ui/index.js +0 -57
- package/dist/shared/form/ui/index.js.map +0 -1
- package/dist/shared/form/validation.d.ts +0 -51
- package/dist/shared/form/validation.js +0 -127
- package/dist/shared/form/validation.js.map +0 -1
- package/dist/shared/index.d.ts +0 -2
- package/dist/shared/index.js +0 -4
- package/dist/shared/index.js.map +0 -1
- package/dist/shared/payload/fields/field-copy-button/index.d.ts +0 -3
- package/dist/shared/payload/fields/field-copy-button/index.js +0 -38
- package/dist/shared/payload/fields/field-copy-button/index.js.map +0 -1
- package/dist/shared/payload/fields/generate-uuid-button/index.d.ts +0 -3
- package/dist/shared/payload/fields/generate-uuid-button/index.js +0 -26
- package/dist/shared/payload/fields/generate-uuid-button/index.js.map +0 -1
- package/dist/shared/payload/fields/index.d.ts +0 -2
- package/dist/shared/payload/fields/index.js +0 -4
- package/dist/shared/payload/fields/index.js.map +0 -1
- package/dist/shared/utils/regex.d.ts +0 -2
- package/dist/shared/utils/regex.js +0 -4
- package/dist/shared/utils/regex.js.map +0 -1
- package/dist/shared/utils/try-catch.d.ts +0 -11
- package/dist/shared/utils/try-catch.js +0 -17
- package/dist/shared/utils/try-catch.js.map +0 -1
- package/dist/shared/utils/value-or-default.d.ts +0 -9
- package/dist/shared/utils/value-or-default.js +0 -12
- package/dist/shared/utils/value-or-default.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,202 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(which shall not include Communications that are clearly marked or
|
|
39
|
-
otherwise designated in writing by the copyright owner as "Not a Work").
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is clearly marked or otherwise designated
|
|
61
|
-
in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "page" as the copyright notice for easier identification within
|
|
188
|
-
third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright 2025 RevealUI Team
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
201
|
-
implied. See the License for the specific language governing
|
|
202
|
-
permissions and limitations under the License.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 RevealUI Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @revealui/auth
|
|
2
|
+
|
|
3
|
+
Session-based authentication for RevealUI — database-backed sessions, rate limiting, brute force protection, and password reset.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Database Sessions** — PostgreSQL/NeonDB-backed sessions with SHA-256 token hashing
|
|
8
|
+
- **Secure Cookies** — HTTP-only, SameSite, secure flag, cross-subdomain support
|
|
9
|
+
- **Rate Limiting** — Configurable per-endpoint rate limits stored in database
|
|
10
|
+
- **Brute Force Protection** — Progressive lockout on failed sign-in attempts
|
|
11
|
+
- **Password Reset** — Token-based password reset flow with email integration
|
|
12
|
+
- **Password Validation** — Strength requirements and common password checks
|
|
13
|
+
- **React Hooks** — Client-side session management (`useSession`, `useSignIn`, `useSignOut`)
|
|
14
|
+
- **Framework Agnostic** — Works with Next.js, Hono, and other Node.js frameworks
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @revealui/auth
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Server-Side
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { getSession, signIn, signOut, createSession } from '@revealui/auth/server'
|
|
28
|
+
|
|
29
|
+
// Validate session from request headers
|
|
30
|
+
const session = await getSession(request.headers)
|
|
31
|
+
|
|
32
|
+
// Sign in with email/password
|
|
33
|
+
const result = await signIn({ email, password })
|
|
34
|
+
|
|
35
|
+
// Sign out (invalidate session)
|
|
36
|
+
await signOut(sessionToken)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Client-Side (React)
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
'use client'
|
|
43
|
+
import { useSession, useSignIn, useSignOut } from '@revealui/auth/react'
|
|
44
|
+
|
|
45
|
+
function AuthComponent() {
|
|
46
|
+
const { data: session, isLoading } = useSession()
|
|
47
|
+
const { signIn } = useSignIn()
|
|
48
|
+
const { signOut } = useSignOut()
|
|
49
|
+
|
|
50
|
+
if (isLoading) return <div>Loading...</div>
|
|
51
|
+
if (!session) return <button onClick={() => signIn({ email, password })}>Sign In</button>
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<p>Hello, {session.user.name}</p>
|
|
56
|
+
<button onClick={() => signOut()}>Sign Out</button>
|
|
57
|
+
</div>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Exports
|
|
63
|
+
|
|
64
|
+
| Subpath | Contents |
|
|
65
|
+
|---------|----------|
|
|
66
|
+
| `@revealui/auth/server` | Server-side auth (session CRUD, sign in/out, rate limiting, brute force) |
|
|
67
|
+
| `@revealui/auth/client` | Client-side utilities |
|
|
68
|
+
| `@revealui/auth/react` | React hooks (`useSession`, `useSignIn`, `useSignOut`) |
|
|
69
|
+
|
|
70
|
+
## Security
|
|
71
|
+
|
|
72
|
+
- Passwords hashed with bcrypt
|
|
73
|
+
- Session tokens hashed with SHA-256 before storage
|
|
74
|
+
- HTTP-only cookies prevent XSS token theft
|
|
75
|
+
- SameSite cookie attribute prevents CSRF
|
|
76
|
+
- Rate limiting prevents abuse (configurable per endpoint)
|
|
77
|
+
- Brute force protection with progressive lockout
|
|
78
|
+
- Cookie domain supports cross-subdomain auth (e.g. `.revealui.com`)
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Build
|
|
84
|
+
pnpm build
|
|
85
|
+
|
|
86
|
+
# Type check
|
|
87
|
+
pnpm typecheck
|
|
88
|
+
|
|
89
|
+
# Run tests
|
|
90
|
+
pnpm test
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Related
|
|
94
|
+
|
|
95
|
+
- [Core Package](../core/README.md) — CMS engine (uses auth for access control)
|
|
96
|
+
- [DB Package](../db/README.md) — Database schema (sessions, users, rate_limits tables)
|
|
97
|
+
- [Auth Guide](../../docs/AUTH.md) — Architecture, usage patterns, and security design
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @revealui/auth
|
|
3
|
+
*
|
|
4
|
+
* Authentication system for RevealUI.
|
|
5
|
+
* Database-backed sessions with Better Auth patterns.
|
|
6
|
+
*/
|
|
7
|
+
export * from './react/index.js';
|
|
8
|
+
export * from './server/index.js';
|
|
9
|
+
export type { AuthSession, Session, SignInResult, SignUpResult, User, } from './types.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,kBAAkB,CAAA;AAEhC,cAAc,mBAAmB,CAAA;AAGjC,YAAY,EACV,WAAW,EACX,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,IAAI,GACL,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @revealui/auth
|
|
3
|
+
*
|
|
4
|
+
* Authentication system for RevealUI.
|
|
5
|
+
* Database-backed sessions with Better Auth patterns.
|
|
6
|
+
*/
|
|
7
|
+
// Client exports (React hooks)
|
|
8
|
+
export * from './react/index.js';
|
|
9
|
+
// Server exports
|
|
10
|
+
export * from './server/index.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Hooks for Authentication
|
|
3
|
+
*
|
|
4
|
+
* Client-side React hooks for authentication.
|
|
5
|
+
* Inspired by Better Auth and TanStack Start patterns.
|
|
6
|
+
*/
|
|
7
|
+
export type { UseSessionResult } from './useSession.js';
|
|
8
|
+
export { useSession } from './useSession.js';
|
|
9
|
+
export type { SignInInput, UseSignInResult } from './useSignIn.js';
|
|
10
|
+
export { useSignIn } from './useSignIn.js';
|
|
11
|
+
export type { UseSignOutResult } from './useSignOut.js';
|
|
12
|
+
export { useSignOut } from './useSignOut.js';
|
|
13
|
+
export type { SignUpInput, UseSignUpResult } from './useSignUp.js';
|
|
14
|
+
export { useSignUp } from './useSignUp.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Hooks for Authentication
|
|
3
|
+
*
|
|
4
|
+
* Client-side React hooks for authentication.
|
|
5
|
+
* Inspired by Better Auth and TanStack Start patterns.
|
|
6
|
+
*/
|
|
7
|
+
export { useSession } from './useSession.js';
|
|
8
|
+
export { useSignIn } from './useSignIn.js';
|
|
9
|
+
export { useSignOut } from './useSignOut.js';
|
|
10
|
+
export { useSignUp } from './useSignUp.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSession Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for accessing the current session.
|
|
5
|
+
* Inspired by Better Auth and TanStack Start patterns.
|
|
6
|
+
*/
|
|
7
|
+
import type { AuthSession } from '../types.js';
|
|
8
|
+
export interface UseSessionResult {
|
|
9
|
+
data: AuthSession | null;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
refetch: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Hook to get the current session
|
|
16
|
+
*
|
|
17
|
+
* @returns Session data, loading state, error, and refetch function
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* function MyComponent() {
|
|
22
|
+
* const { data: session, isLoading } = useSession()
|
|
23
|
+
*
|
|
24
|
+
* if (isLoading) return <div>Loading...</div>
|
|
25
|
+
* if (!session) return <div>Not signed in</div>
|
|
26
|
+
*
|
|
27
|
+
* return <div>Hello, {session.user.name}</div>
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function useSession(): UseSessionResult;
|
|
32
|
+
//# sourceMappingURL=useSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSession.d.ts","sourceRoot":"","sources":["../../src/react/useSession.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAmB9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,IAAI,gBAAgB,CA6D7C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSession Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for accessing the current session.
|
|
5
|
+
* Inspired by Better Auth and TanStack Start patterns.
|
|
6
|
+
*/
|
|
7
|
+
'use client';
|
|
8
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { z } from 'zod/v4';
|
|
10
|
+
// Validation schema for session response - uses passthrough to allow all User properties
|
|
11
|
+
const AuthSessionSchema = z.object({
|
|
12
|
+
session: z
|
|
13
|
+
.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
expiresAt: z.string(),
|
|
16
|
+
})
|
|
17
|
+
.passthrough(),
|
|
18
|
+
user: z
|
|
19
|
+
.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
email: z.string(),
|
|
22
|
+
name: z.string().nullable().optional(),
|
|
23
|
+
})
|
|
24
|
+
.passthrough(), // Allow all other User properties
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Hook to get the current session
|
|
28
|
+
*
|
|
29
|
+
* @returns Session data, loading state, error, and refetch function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* function MyComponent() {
|
|
34
|
+
* const { data: session, isLoading } = useSession()
|
|
35
|
+
*
|
|
36
|
+
* if (isLoading) return <div>Loading...</div>
|
|
37
|
+
* if (!session) return <div>Not signed in</div>
|
|
38
|
+
*
|
|
39
|
+
* return <div>Hello, {session.user.name}</div>
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function useSession() {
|
|
44
|
+
const [data, setData] = useState(null);
|
|
45
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
46
|
+
const [error, setError] = useState(null);
|
|
47
|
+
const abortControllerRef = useRef(null);
|
|
48
|
+
const fetchSession = useCallback(async () => {
|
|
49
|
+
// Abort any in-flight request
|
|
50
|
+
abortControllerRef.current?.abort();
|
|
51
|
+
const controller = new AbortController();
|
|
52
|
+
abortControllerRef.current = controller;
|
|
53
|
+
try {
|
|
54
|
+
setIsLoading(true);
|
|
55
|
+
setError(null);
|
|
56
|
+
const response = await fetch('/api/auth/session', {
|
|
57
|
+
credentials: 'include',
|
|
58
|
+
signal: controller.signal,
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
if (response.status === 401) {
|
|
62
|
+
setData(null);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Failed to fetch session: ${response.statusText}`);
|
|
66
|
+
}
|
|
67
|
+
const json = await response.json();
|
|
68
|
+
const validated = AuthSessionSchema.parse(json);
|
|
69
|
+
// Type assertion through unknown is safe because Zod validation ensures the shape is correct
|
|
70
|
+
// The API returns serialized data (Dates as strings), so we cast to expected type
|
|
71
|
+
setData(validated);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
78
|
+
setError(error);
|
|
79
|
+
setData(null);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
setIsLoading(false);
|
|
83
|
+
}
|
|
84
|
+
}, []);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
void fetchSession();
|
|
87
|
+
return () => {
|
|
88
|
+
// Clean up: abort in-flight request on unmount
|
|
89
|
+
abortControllerRef.current?.abort();
|
|
90
|
+
};
|
|
91
|
+
}, [fetchSession]);
|
|
92
|
+
return {
|
|
93
|
+
data,
|
|
94
|
+
isLoading,
|
|
95
|
+
error,
|
|
96
|
+
refetch: fetchSession,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSignIn Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for signing in a user.
|
|
5
|
+
*/
|
|
6
|
+
import type { User } from '../types.js';
|
|
7
|
+
export interface SignInInput {
|
|
8
|
+
email: string;
|
|
9
|
+
password: string;
|
|
10
|
+
}
|
|
11
|
+
export interface UseSignInResult {
|
|
12
|
+
signIn: (input: SignInInput) => Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
user?: User;
|
|
15
|
+
error?: string;
|
|
16
|
+
}>;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hook to sign in a user
|
|
22
|
+
*
|
|
23
|
+
* @returns Sign in function, loading state, and error
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* function SignInForm() {
|
|
28
|
+
* const { signIn, isLoading } = useSignIn()
|
|
29
|
+
*
|
|
30
|
+
* const handleSubmit = async (e: FormEvent) => {
|
|
31
|
+
* e.preventDefault()
|
|
32
|
+
* const result = await signIn({ email, password })
|
|
33
|
+
* if (result.success) {
|
|
34
|
+
* router.push('/dashboard')
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useSignIn(): UseSignInResult;
|
|
41
|
+
//# sourceMappingURL=useSignIn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignIn.d.ts","sourceRoot":"","sources":["../../src/react/useSignIn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAiBvC,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC1F,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,IAAI,eAAe,CA8D3C"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSignIn Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for signing in a user.
|
|
5
|
+
*/
|
|
6
|
+
'use client';
|
|
7
|
+
import { useCallback, useRef, useState } from 'react';
|
|
8
|
+
import { z } from 'zod/v4';
|
|
9
|
+
// Validation schemas for sign-in response
|
|
10
|
+
const SignInErrorResponseSchema = z.object({
|
|
11
|
+
error: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
const SignInSuccessResponseSchema = z.object({
|
|
14
|
+
user: z
|
|
15
|
+
.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
email: z.string(),
|
|
18
|
+
name: z.string().nullable().optional(),
|
|
19
|
+
})
|
|
20
|
+
.passthrough(), // Allow all other User properties
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Hook to sign in a user
|
|
24
|
+
*
|
|
25
|
+
* @returns Sign in function, loading state, and error
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* function SignInForm() {
|
|
30
|
+
* const { signIn, isLoading } = useSignIn()
|
|
31
|
+
*
|
|
32
|
+
* const handleSubmit = async (e: FormEvent) => {
|
|
33
|
+
* e.preventDefault()
|
|
34
|
+
* const result = await signIn({ email, password })
|
|
35
|
+
* if (result.success) {
|
|
36
|
+
* router.push('/dashboard')
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function useSignIn() {
|
|
43
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
44
|
+
const [error, setError] = useState(null);
|
|
45
|
+
const abortControllerRef = useRef(null);
|
|
46
|
+
const signIn = useCallback(async (input) => {
|
|
47
|
+
// Abort any in-flight request
|
|
48
|
+
abortControllerRef.current?.abort();
|
|
49
|
+
const controller = new AbortController();
|
|
50
|
+
abortControllerRef.current = controller;
|
|
51
|
+
try {
|
|
52
|
+
setIsLoading(true);
|
|
53
|
+
setError(null);
|
|
54
|
+
const response = await fetch('/api/auth/sign-in', {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: {
|
|
57
|
+
'Content-Type': 'application/json',
|
|
58
|
+
},
|
|
59
|
+
credentials: 'include',
|
|
60
|
+
body: JSON.stringify(input),
|
|
61
|
+
signal: controller.signal,
|
|
62
|
+
});
|
|
63
|
+
const json = await response.json();
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
const errorData = SignInErrorResponseSchema.parse(json);
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: errorData.error || 'Failed to sign in',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const successData = SignInSuccessResponseSchema.parse(json);
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
// Type assertion through unknown is safe because Zod validation ensures the shape is correct
|
|
75
|
+
// The API returns serialized data, so we cast to expected type
|
|
76
|
+
user: successData.user,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
81
|
+
return { success: false, error: 'Request was cancelled' };
|
|
82
|
+
}
|
|
83
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
84
|
+
setError(error);
|
|
85
|
+
return {
|
|
86
|
+
success: false,
|
|
87
|
+
error: error.message,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
setIsLoading(false);
|
|
92
|
+
}
|
|
93
|
+
}, []);
|
|
94
|
+
return {
|
|
95
|
+
signIn,
|
|
96
|
+
isLoading,
|
|
97
|
+
error,
|
|
98
|
+
};
|
|
99
|
+
}
|