@erikey/react 0.4.26 → 0.4.27

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.
Files changed (143) hide show
  1. package/package.json +2 -1
  2. package/src/__tests__/auth-client.test.ts +105 -0
  3. package/src/__tests__/security/localStorage-encryption.test.ts +171 -0
  4. package/src/auth-client.ts +158 -0
  5. package/src/dashboard-client.ts +60 -0
  6. package/src/index.ts +88 -0
  7. package/src/kv-client.ts +316 -0
  8. package/src/lib/cross-origin-auth.ts +99 -0
  9. package/src/stubs/captcha.ts +24 -0
  10. package/src/stubs/hashes.ts +16 -0
  11. package/src/stubs/index.ts +17 -0
  12. package/src/stubs/passkey.ts +12 -0
  13. package/src/stubs/qr-code.ts +10 -0
  14. package/src/stubs/query.ts +16 -0
  15. package/src/stubs/realtime.ts +17 -0
  16. package/src/stubs/use-sync-external-store.ts +12 -0
  17. package/src/styles.css +141 -0
  18. package/src/types.ts +14 -0
  19. package/src/ui/components/auth/auth-callback.tsx +36 -0
  20. package/src/ui/components/auth/auth-form.tsx +310 -0
  21. package/src/ui/components/auth/auth-view.tsx +435 -0
  22. package/src/ui/components/auth/email-otp-button.tsx +53 -0
  23. package/src/ui/components/auth/forms/email-otp-form.tsx +312 -0
  24. package/src/ui/components/auth/forms/email-verification-form.tsx +271 -0
  25. package/src/ui/components/auth/forms/forgot-password-form.tsx +173 -0
  26. package/src/ui/components/auth/forms/magic-link-form.tsx +196 -0
  27. package/src/ui/components/auth/forms/recover-account-form.tsx +143 -0
  28. package/src/ui/components/auth/forms/reset-password-form.tsx +220 -0
  29. package/src/ui/components/auth/forms/sign-in-form.tsx +323 -0
  30. package/src/ui/components/auth/forms/sign-up-form.tsx +820 -0
  31. package/src/ui/components/auth/forms/two-factor-form.tsx +381 -0
  32. package/src/ui/components/auth/magic-link-button.tsx +54 -0
  33. package/src/ui/components/auth/one-tap.tsx +53 -0
  34. package/src/ui/components/auth/otp-input-group.tsx +65 -0
  35. package/src/ui/components/auth/passkey-button.tsx +91 -0
  36. package/src/ui/components/auth/provider-button.tsx +155 -0
  37. package/src/ui/components/auth/sign-out.tsx +25 -0
  38. package/src/ui/components/auth/wallet-button.tsx +192 -0
  39. package/src/ui/components/auth-loading.tsx +21 -0
  40. package/src/ui/components/captcha/captcha.tsx +91 -0
  41. package/src/ui/components/captcha/recaptcha-badge.tsx +61 -0
  42. package/src/ui/components/captcha/recaptcha-v2.tsx +58 -0
  43. package/src/ui/components/captcha/recaptcha-v3.tsx +73 -0
  44. package/src/ui/components/email/email-template.tsx +216 -0
  45. package/src/ui/components/form-error.tsx +27 -0
  46. package/src/ui/components/password-input.tsx +56 -0
  47. package/src/ui/components/provider-icons.tsx +404 -0
  48. package/src/ui/components/redirect-to-sign-in.tsx +16 -0
  49. package/src/ui/components/redirect-to-sign-up.tsx +16 -0
  50. package/src/ui/components/signed-in.tsx +20 -0
  51. package/src/ui/components/signed-out.tsx +20 -0
  52. package/src/ui/components/ui/alert.tsx +66 -0
  53. package/src/ui/components/ui/button.tsx +70 -0
  54. package/src/ui/components/ui/card.tsx +92 -0
  55. package/src/ui/components/ui/checkbox.tsx +66 -0
  56. package/src/ui/components/ui/field.tsx +248 -0
  57. package/src/ui/components/ui/form.tsx +165 -0
  58. package/src/ui/components/ui/input-otp.tsx +77 -0
  59. package/src/ui/components/ui/input.tsx +21 -0
  60. package/src/ui/components/ui/label.tsx +23 -0
  61. package/src/ui/components/ui/separator.tsx +34 -0
  62. package/src/ui/components/ui/skeleton.tsx +13 -0
  63. package/src/ui/components/ui/textarea.tsx +18 -0
  64. package/src/ui/components/user-avatar.tsx +151 -0
  65. package/src/ui/hooks/use-auth-data.ts +193 -0
  66. package/src/ui/hooks/use-authenticate.ts +64 -0
  67. package/src/ui/hooks/use-captcha.tsx +151 -0
  68. package/src/ui/hooks/use-hydrated.ts +13 -0
  69. package/src/ui/hooks/use-lang.ts +32 -0
  70. package/src/ui/hooks/use-success-transition.ts +41 -0
  71. package/src/ui/hooks/use-theme.ts +39 -0
  72. package/src/ui/index.ts +46 -0
  73. package/src/ui/instantdb.ts +1 -0
  74. package/src/ui/lib/auth-data-cache.ts +90 -0
  75. package/src/ui/lib/auth-ui-provider.tsx +769 -0
  76. package/src/ui/lib/gravatar-utils.ts +58 -0
  77. package/src/ui/lib/image-utils.ts +55 -0
  78. package/src/ui/lib/instantdb/model-names.ts +24 -0
  79. package/src/ui/lib/instantdb/use-instant-options.ts +98 -0
  80. package/src/ui/lib/instantdb/use-list-accounts.ts +38 -0
  81. package/src/ui/lib/instantdb/use-list-sessions.ts +53 -0
  82. package/src/ui/lib/instantdb/use-session.ts +55 -0
  83. package/src/ui/lib/social-providers.ts +150 -0
  84. package/src/ui/lib/tanstack/auth-ui-provider-tanstack.tsx +49 -0
  85. package/src/ui/lib/tanstack/use-tanstack-options.ts +112 -0
  86. package/src/ui/lib/triplit/model-names.ts +24 -0
  87. package/src/ui/lib/triplit/use-conditional-query.ts +82 -0
  88. package/src/ui/lib/triplit/use-list-accounts.ts +31 -0
  89. package/src/ui/lib/triplit/use-list-sessions.ts +33 -0
  90. package/src/ui/lib/triplit/use-session.ts +42 -0
  91. package/src/ui/lib/triplit/use-triplit-hooks.ts +68 -0
  92. package/src/ui/lib/triplit/use-triplit-token.ts +44 -0
  93. package/src/ui/lib/utils.ts +119 -0
  94. package/src/ui/lib/view-paths.ts +61 -0
  95. package/src/ui/lib/wallet.ts +129 -0
  96. package/src/ui/localization/admin-error-codes.ts +20 -0
  97. package/src/ui/localization/anonymous-error-codes.ts +6 -0
  98. package/src/ui/localization/api-key-error-codes.ts +32 -0
  99. package/src/ui/localization/auth-localization.ts +865 -0
  100. package/src/ui/localization/base-error-codes.ts +27 -0
  101. package/src/ui/localization/captcha-error-codes.ts +17 -0
  102. package/src/ui/localization/email-otp-error-codes.ts +7 -0
  103. package/src/ui/localization/generic-oauth-error-codes.ts +3 -0
  104. package/src/ui/localization/haveibeenpwned-error-codes.ts +4 -0
  105. package/src/ui/localization/multi-session-error-codes.ts +3 -0
  106. package/src/ui/localization/organization-error-codes.ts +57 -0
  107. package/src/ui/localization/passkey-error-codes.ts +10 -0
  108. package/src/ui/localization/phone-number-error-codes.ts +10 -0
  109. package/src/ui/localization/stripe-localization.ts +12 -0
  110. package/src/ui/localization/team-error-codes.ts +12 -0
  111. package/src/ui/localization/two-factor-error-codes.ts +12 -0
  112. package/src/ui/localization/username-error-codes.ts +9 -0
  113. package/src/ui/server.ts +4 -0
  114. package/src/ui/style.css +146 -0
  115. package/src/ui/tanstack.ts +1 -0
  116. package/src/ui/triplit.ts +1 -0
  117. package/src/ui/types/account-options.ts +35 -0
  118. package/src/ui/types/additional-fields.ts +21 -0
  119. package/src/ui/types/any-auth-client.ts +6 -0
  120. package/src/ui/types/api-key.ts +9 -0
  121. package/src/ui/types/auth-client.ts +41 -0
  122. package/src/ui/types/auth-hooks.ts +81 -0
  123. package/src/ui/types/auth-mutators.ts +21 -0
  124. package/src/ui/types/avatar-options.ts +29 -0
  125. package/src/ui/types/captcha-options.ts +32 -0
  126. package/src/ui/types/captcha-provider.ts +7 -0
  127. package/src/ui/types/credentials-options.ts +38 -0
  128. package/src/ui/types/delete-user-options.ts +7 -0
  129. package/src/ui/types/email-verification-options.ts +7 -0
  130. package/src/ui/types/fetch-error.ts +6 -0
  131. package/src/ui/types/generic-oauth-options.ts +16 -0
  132. package/src/ui/types/gravatar-options.ts +21 -0
  133. package/src/ui/types/image.ts +7 -0
  134. package/src/ui/types/invitation.ts +10 -0
  135. package/src/ui/types/link.ts +7 -0
  136. package/src/ui/types/organization-options.ts +106 -0
  137. package/src/ui/types/password-validation.ts +16 -0
  138. package/src/ui/types/profile.ts +15 -0
  139. package/src/ui/types/refetch.ts +1 -0
  140. package/src/ui/types/render-toast.ts +9 -0
  141. package/src/ui/types/sign-up-options.ts +7 -0
  142. package/src/ui/types/social-options.ts +16 -0
  143. package/src/ui/types/team-options.ts +47 -0
@@ -0,0 +1,38 @@
1
+ import type { PasswordValidation } from "./password-validation"
2
+
3
+ export type CredentialsOptions = {
4
+ /**
5
+ * Enable or disable the Confirm Password input
6
+ * @default false
7
+ */
8
+ confirmPassword?: boolean
9
+
10
+ /**
11
+ * Enable or disable Forgot Password flow
12
+ * @default true
13
+ */
14
+ forgotPassword?: boolean
15
+
16
+ /**
17
+ * Customize the password validation
18
+ */
19
+ passwordValidation?: PasswordValidation
20
+
21
+ /**
22
+ * Enable or disable Remember Me checkbox
23
+ * @default false
24
+ */
25
+ rememberMe?: boolean
26
+
27
+ /**
28
+ * Enable or disable Username support
29
+ * @default false
30
+ */
31
+ username?: boolean
32
+
33
+ /**
34
+ * Make username required when username is enabled
35
+ * @default true
36
+ */
37
+ usernameRequired?: boolean
38
+ }
@@ -0,0 +1,7 @@
1
+ export type DeleteUserOptions = {
2
+ /**
3
+ * Enable or disable email verification for account deletion
4
+ * @default undefined
5
+ */
6
+ verification?: boolean
7
+ }
@@ -0,0 +1,7 @@
1
+ export type EmailVerificationOptions = {
2
+ /**
3
+ * Enable OTP verification for email verification
4
+ * @default false
5
+ */
6
+ otp?: boolean
7
+ }
@@ -0,0 +1,6 @@
1
+ export type FetchError = {
2
+ code?: string | undefined
3
+ message?: string | undefined
4
+ status?: number
5
+ statusText?: string
6
+ }
@@ -0,0 +1,16 @@
1
+ import type { Provider } from "../lib/social-providers"
2
+ import type { AuthClient } from "./auth-client"
3
+
4
+ export type GenericOAuthOptions = {
5
+ /**
6
+ * Custom OAuth Providers
7
+ * @default []
8
+ */
9
+ providers: Provider[]
10
+ /**
11
+ * Custom generic OAuth sign in function
12
+ */
13
+ signIn?: (
14
+ params: Parameters<AuthClient["signIn"]["oauth2"]>[0]
15
+ ) => Promise<unknown>
16
+ }
@@ -0,0 +1,21 @@
1
+ export type GravatarOptions = {
2
+ /**
3
+ * Default image type or URL
4
+ * Options: '404', 'mp', 'identicon', 'monsterid', 'wavatar', 'retro', 'robohash', 'blank', or custom URL
5
+ */
6
+ d?: string
7
+ /**
8
+ * Image size in pixels (1-2048)
9
+ */
10
+ size?: number
11
+ /**
12
+ * Whether to append .jpg extension to the hash
13
+ * @default false
14
+ */
15
+ jpg?: boolean
16
+ /**
17
+ * Force default image even if user has Gravatar
18
+ * @default false
19
+ */
20
+ forceDefault?: boolean
21
+ }
@@ -0,0 +1,7 @@
1
+ import type { ComponentType } from "react"
2
+
3
+ export type Image = ComponentType<{
4
+ src: string
5
+ alt: string
6
+ className?: string
7
+ }>
@@ -0,0 +1,10 @@
1
+ export type Invitation = {
2
+ id: string
3
+ organizationId: string
4
+ email: string
5
+ role: string
6
+ status: string
7
+ inviterId: string
8
+ expiresAt: Date
9
+ teamId?: string | undefined
10
+ }
@@ -0,0 +1,7 @@
1
+ import type { ComponentType, ReactNode } from "react"
2
+
3
+ export type Link = ComponentType<{
4
+ href: string
5
+ className?: string
6
+ children: ReactNode
7
+ }>
@@ -0,0 +1,106 @@
1
+ export type OrganizationLogoOptions = {
2
+ /**
3
+ * Upload a logo image and return the URL string
4
+ * @remarks `(file: File) => Promise<string>`
5
+ */
6
+ upload?: (file: File) => Promise<string | undefined | null>
7
+ /**
8
+ * Delete a previously uploaded logo image from your storage/CDN
9
+ * @remarks `(url: string) => Promise<void>`
10
+ */
11
+ delete?: (url: string) => Promise<void>
12
+ /**
13
+ * Logo size for resizing
14
+ * @default 256 if upload is provided, 128 otherwise
15
+ */
16
+ size: number
17
+ /**
18
+ * File extension for logo uploads
19
+ * @default "png"
20
+ */
21
+ extension: string
22
+ }
23
+
24
+ import type { OrganizationViewPaths } from "../lib/view-paths"
25
+
26
+ export type OrganizationOptions = {
27
+ /**
28
+ * Logo configuration
29
+ * @default undefined
30
+ */
31
+ logo?: boolean | Partial<OrganizationLogoOptions>
32
+ /**
33
+ * Custom roles to add to the built-in roles (owner, admin, member)
34
+ * @default []
35
+ */
36
+ customRoles?: Array<{ role: string; label: string }>
37
+ /**
38
+ * Enable or disable API key support for organizations
39
+ * @default false
40
+ */
41
+ apiKey?: boolean
42
+ /**
43
+ * Base path for organization-scoped views (supports slugged or static base)
44
+ * When using slug paths, set this to the common prefix (e.g. "/organization")
45
+ */
46
+ basePath?: string
47
+ /**
48
+ * Organization path mode
49
+ * - "default": use active-organization based routes
50
+ * - "slug": use slug-based URLs where slug becomes the first path segment
51
+ * e.g. "/[slug]/members" (or `${basePath}/[slug]/members` if basePath provided)
52
+ * @default "default"
53
+ */
54
+ pathMode?: "default" | "slug"
55
+ /**
56
+ * The current organization slug
57
+ */
58
+ slug?: string
59
+ /**
60
+ * The path to redirect to when Personal Account is selected
61
+ */
62
+ personalPath?: string
63
+ /**
64
+ * Customize organization view paths
65
+ */
66
+ viewPaths?: Partial<OrganizationViewPaths>
67
+ }
68
+
69
+ export type OrganizationOptionsContext = {
70
+ /**
71
+ * Logo configuration
72
+ * @default undefined
73
+ */
74
+ logo?: OrganizationLogoOptions
75
+ /**
76
+ * Custom roles to add to the built-in roles (owner, admin, member)
77
+ * @default []
78
+ */
79
+ customRoles: Array<{ role: string; label: string }>
80
+ /**
81
+ * Enable or disable API key support for organizations
82
+ * @default false
83
+ */
84
+ apiKey?: boolean
85
+ /**
86
+ * Base path for organization-scoped views
87
+ */
88
+ basePath: string
89
+ /**
90
+ * Organization path mode
91
+ * @default "default"
92
+ */
93
+ pathMode?: "default" | "slug"
94
+ /**
95
+ * The current organization slug
96
+ */
97
+ slug?: string
98
+ /**
99
+ * The path to redirect to when Personal Account is selected
100
+ */
101
+ personalPath?: string
102
+ /**
103
+ * Customize organization view paths
104
+ */
105
+ viewPaths: OrganizationViewPaths
106
+ }
@@ -0,0 +1,16 @@
1
+ export type PasswordValidation = {
2
+ /**
3
+ * Maximum password length
4
+ */
5
+ maxLength?: number
6
+
7
+ /**
8
+ * Minimum password length
9
+ */
10
+ minLength?: number
11
+
12
+ /**
13
+ * Password validation regex
14
+ */
15
+ regex?: RegExp
16
+ }
@@ -0,0 +1,15 @@
1
+ export type Profile = {
2
+ id?: string | number
3
+ email?: string | null
4
+ name?: string | null
5
+ displayUsername?: string | null
6
+ username?: string | null
7
+ displayName?: string | null
8
+ firstName?: string | null
9
+ fullName?: string | null
10
+ isAnonymous?: boolean | null
11
+ emailVerified?: boolean | null
12
+ image?: string | null
13
+ avatar?: string | null
14
+ avatarUrl?: string | null
15
+ }
@@ -0,0 +1 @@
1
+ export type Refetch = () => Promise<unknown> | unknown
@@ -0,0 +1,9 @@
1
+ type ToastVariant = "default" | "success" | "error" | "info" | "warning"
2
+
3
+ export type RenderToast = ({
4
+ variant,
5
+ message
6
+ }: {
7
+ variant?: ToastVariant
8
+ message?: string
9
+ }) => void
@@ -0,0 +1,7 @@
1
+ export type SignUpOptions = {
2
+ /**
3
+ * Array of fields to show in Sign Up form
4
+ * @default ["name"]
5
+ */
6
+ fields?: string[]
7
+ }
@@ -0,0 +1,16 @@
1
+ import type { SocialProvider } from "better-auth/social-providers"
2
+ import type { AuthClient } from "./auth-client"
3
+
4
+ export type SocialOptions = {
5
+ /**
6
+ * Array of Social Providers to enable
7
+ * @remarks `SocialProvider[]`
8
+ */
9
+ providers: SocialProvider[]
10
+ /**
11
+ * Custom social sign in function
12
+ */
13
+ signIn?: (
14
+ params: Parameters<AuthClient["signIn"]["social"]>[0]
15
+ ) => Promise<unknown>
16
+ }
@@ -0,0 +1,47 @@
1
+ export type TeamOptions = {
2
+ /**
3
+ * Enable teams feature
4
+ * @default false
5
+ */
6
+ enabled?: boolean
7
+ /**
8
+ * Custom roles to add to the built-in team roles (admin, member)
9
+ * @default []
10
+ */
11
+ customRoles?: Array<{ role: string; label: string }>
12
+ /**
13
+ * Team color configuration
14
+ * Define custom CSS variables for team colors
15
+ * @default Uses --team-1 through --team-5
16
+ */
17
+ colors?: {
18
+ /**
19
+ * Number of predefined team colors
20
+ * @default 5
21
+ */
22
+ count?: number
23
+ /**
24
+ * CSS variable prefix
25
+ * @default "team"
26
+ */
27
+ prefix?: string
28
+ }
29
+ }
30
+
31
+ export type TeamOptionsContext = {
32
+ /**
33
+ * Enable teams feature
34
+ */
35
+ enabled: boolean
36
+ /**
37
+ * Custom roles to add to the built-in team roles (admin, member)
38
+ */
39
+ customRoles: Array<{ role: string; label: string }>
40
+ /**
41
+ * Team color configuration
42
+ */
43
+ colors: {
44
+ count: number
45
+ prefix: string
46
+ }
47
+ }