@erikey/react 0.4.26 → 0.4.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/__tests__/auth-client.test.ts +105 -0
- package/src/__tests__/security/localStorage-encryption.test.ts +171 -0
- package/src/auth-client.ts +158 -0
- package/src/dashboard-client.ts +60 -0
- package/src/index.ts +88 -0
- package/src/kv-client.ts +316 -0
- package/src/lib/cross-origin-auth.ts +99 -0
- package/src/stubs/captcha.ts +24 -0
- package/src/stubs/hashes.ts +16 -0
- package/src/stubs/index.ts +17 -0
- package/src/stubs/passkey.ts +12 -0
- package/src/stubs/qr-code.ts +10 -0
- package/src/stubs/query.ts +16 -0
- package/src/stubs/realtime.ts +17 -0
- package/src/stubs/use-sync-external-store.ts +12 -0
- package/src/styles.css +141 -0
- package/src/types.ts +14 -0
- package/src/ui/components/auth/auth-callback.tsx +36 -0
- package/src/ui/components/auth/auth-form.tsx +310 -0
- package/src/ui/components/auth/auth-view.tsx +435 -0
- package/src/ui/components/auth/email-otp-button.tsx +53 -0
- package/src/ui/components/auth/forms/email-otp-form.tsx +312 -0
- package/src/ui/components/auth/forms/email-verification-form.tsx +271 -0
- package/src/ui/components/auth/forms/forgot-password-form.tsx +173 -0
- package/src/ui/components/auth/forms/magic-link-form.tsx +196 -0
- package/src/ui/components/auth/forms/recover-account-form.tsx +143 -0
- package/src/ui/components/auth/forms/reset-password-form.tsx +220 -0
- package/src/ui/components/auth/forms/sign-in-form.tsx +323 -0
- package/src/ui/components/auth/forms/sign-up-form.tsx +820 -0
- package/src/ui/components/auth/forms/two-factor-form.tsx +381 -0
- package/src/ui/components/auth/magic-link-button.tsx +54 -0
- package/src/ui/components/auth/one-tap.tsx +53 -0
- package/src/ui/components/auth/otp-input-group.tsx +65 -0
- package/src/ui/components/auth/passkey-button.tsx +91 -0
- package/src/ui/components/auth/provider-button.tsx +155 -0
- package/src/ui/components/auth/sign-out.tsx +25 -0
- package/src/ui/components/auth/wallet-button.tsx +192 -0
- package/src/ui/components/auth-loading.tsx +21 -0
- package/src/ui/components/captcha/captcha.tsx +91 -0
- package/src/ui/components/captcha/recaptcha-badge.tsx +61 -0
- package/src/ui/components/captcha/recaptcha-v2.tsx +58 -0
- package/src/ui/components/captcha/recaptcha-v3.tsx +73 -0
- package/src/ui/components/email/email-template.tsx +216 -0
- package/src/ui/components/form-error.tsx +27 -0
- package/src/ui/components/password-input.tsx +56 -0
- package/src/ui/components/provider-icons.tsx +404 -0
- package/src/ui/components/redirect-to-sign-in.tsx +16 -0
- package/src/ui/components/redirect-to-sign-up.tsx +16 -0
- package/src/ui/components/signed-in.tsx +20 -0
- package/src/ui/components/signed-out.tsx +20 -0
- package/src/ui/components/ui/alert.tsx +66 -0
- package/src/ui/components/ui/button.tsx +70 -0
- package/src/ui/components/ui/card.tsx +92 -0
- package/src/ui/components/ui/checkbox.tsx +66 -0
- package/src/ui/components/ui/field.tsx +248 -0
- package/src/ui/components/ui/form.tsx +165 -0
- package/src/ui/components/ui/input-otp.tsx +77 -0
- package/src/ui/components/ui/input.tsx +21 -0
- package/src/ui/components/ui/label.tsx +23 -0
- package/src/ui/components/ui/separator.tsx +34 -0
- package/src/ui/components/ui/skeleton.tsx +13 -0
- package/src/ui/components/ui/textarea.tsx +18 -0
- package/src/ui/components/user-avatar.tsx +151 -0
- package/src/ui/hooks/use-auth-data.ts +193 -0
- package/src/ui/hooks/use-authenticate.ts +64 -0
- package/src/ui/hooks/use-captcha.tsx +151 -0
- package/src/ui/hooks/use-hydrated.ts +13 -0
- package/src/ui/hooks/use-lang.ts +32 -0
- package/src/ui/hooks/use-success-transition.ts +41 -0
- package/src/ui/hooks/use-theme.ts +39 -0
- package/src/ui/index.ts +46 -0
- package/src/ui/instantdb.ts +1 -0
- package/src/ui/lib/auth-data-cache.ts +90 -0
- package/src/ui/lib/auth-ui-provider.tsx +769 -0
- package/src/ui/lib/gravatar-utils.ts +58 -0
- package/src/ui/lib/image-utils.ts +55 -0
- package/src/ui/lib/instantdb/model-names.ts +24 -0
- package/src/ui/lib/instantdb/use-instant-options.ts +98 -0
- package/src/ui/lib/instantdb/use-list-accounts.ts +38 -0
- package/src/ui/lib/instantdb/use-list-sessions.ts +53 -0
- package/src/ui/lib/instantdb/use-session.ts +55 -0
- package/src/ui/lib/social-providers.ts +150 -0
- package/src/ui/lib/tanstack/auth-ui-provider-tanstack.tsx +49 -0
- package/src/ui/lib/tanstack/use-tanstack-options.ts +112 -0
- package/src/ui/lib/triplit/model-names.ts +24 -0
- package/src/ui/lib/triplit/use-conditional-query.ts +82 -0
- package/src/ui/lib/triplit/use-list-accounts.ts +31 -0
- package/src/ui/lib/triplit/use-list-sessions.ts +33 -0
- package/src/ui/lib/triplit/use-session.ts +42 -0
- package/src/ui/lib/triplit/use-triplit-hooks.ts +68 -0
- package/src/ui/lib/triplit/use-triplit-token.ts +44 -0
- package/src/ui/lib/utils.ts +119 -0
- package/src/ui/lib/view-paths.ts +61 -0
- package/src/ui/lib/wallet.ts +129 -0
- package/src/ui/localization/admin-error-codes.ts +20 -0
- package/src/ui/localization/anonymous-error-codes.ts +6 -0
- package/src/ui/localization/api-key-error-codes.ts +32 -0
- package/src/ui/localization/auth-localization.ts +865 -0
- package/src/ui/localization/base-error-codes.ts +27 -0
- package/src/ui/localization/captcha-error-codes.ts +17 -0
- package/src/ui/localization/email-otp-error-codes.ts +7 -0
- package/src/ui/localization/generic-oauth-error-codes.ts +3 -0
- package/src/ui/localization/haveibeenpwned-error-codes.ts +4 -0
- package/src/ui/localization/multi-session-error-codes.ts +3 -0
- package/src/ui/localization/organization-error-codes.ts +57 -0
- package/src/ui/localization/passkey-error-codes.ts +10 -0
- package/src/ui/localization/phone-number-error-codes.ts +10 -0
- package/src/ui/localization/stripe-localization.ts +12 -0
- package/src/ui/localization/team-error-codes.ts +12 -0
- package/src/ui/localization/two-factor-error-codes.ts +12 -0
- package/src/ui/localization/username-error-codes.ts +9 -0
- package/src/ui/server.ts +4 -0
- package/src/ui/style.css +146 -0
- package/src/ui/tanstack.ts +1 -0
- package/src/ui/triplit.ts +1 -0
- package/src/ui/types/account-options.ts +35 -0
- package/src/ui/types/additional-fields.ts +21 -0
- package/src/ui/types/any-auth-client.ts +6 -0
- package/src/ui/types/api-key.ts +9 -0
- package/src/ui/types/auth-client.ts +41 -0
- package/src/ui/types/auth-hooks.ts +81 -0
- package/src/ui/types/auth-mutators.ts +21 -0
- package/src/ui/types/avatar-options.ts +29 -0
- package/src/ui/types/captcha-options.ts +32 -0
- package/src/ui/types/captcha-provider.ts +7 -0
- package/src/ui/types/credentials-options.ts +38 -0
- package/src/ui/types/delete-user-options.ts +7 -0
- package/src/ui/types/email-verification-options.ts +7 -0
- package/src/ui/types/fetch-error.ts +6 -0
- package/src/ui/types/generic-oauth-options.ts +16 -0
- package/src/ui/types/gravatar-options.ts +21 -0
- package/src/ui/types/image.ts +7 -0
- package/src/ui/types/invitation.ts +10 -0
- package/src/ui/types/link.ts +7 -0
- package/src/ui/types/organization-options.ts +106 -0
- package/src/ui/types/password-validation.ts +16 -0
- package/src/ui/types/profile.ts +15 -0
- package/src/ui/types/refetch.ts +1 -0
- package/src/ui/types/render-toast.ts +9 -0
- package/src/ui/types/sign-up-options.ts +7 -0
- package/src/ui/types/social-options.ts +16 -0
- 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,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,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,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,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
|
+
}
|