@edge-base/auth-ui-react 0.1.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.
Files changed (52) hide show
  1. package/README.md +180 -0
  2. package/dist/components/AuthForm.d.ts +11 -0
  3. package/dist/components/AuthForm.d.ts.map +1 -0
  4. package/dist/components/AuthForm.js +71 -0
  5. package/dist/components/AuthForm.js.map +1 -0
  6. package/dist/components/EmailOTP.d.ts +11 -0
  7. package/dist/components/EmailOTP.d.ts.map +1 -0
  8. package/dist/components/EmailOTP.js +56 -0
  9. package/dist/components/EmailOTP.js.map +1 -0
  10. package/dist/components/ForgotPassword.d.ts +9 -0
  11. package/dist/components/ForgotPassword.d.ts.map +1 -0
  12. package/dist/components/ForgotPassword.js +36 -0
  13. package/dist/components/ForgotPassword.js.map +1 -0
  14. package/dist/components/MFAChallenge.d.ts +17 -0
  15. package/dist/components/MFAChallenge.d.ts.map +1 -0
  16. package/dist/components/MFAChallenge.js +44 -0
  17. package/dist/components/MFAChallenge.js.map +1 -0
  18. package/dist/components/MagicLink.d.ts +9 -0
  19. package/dist/components/MagicLink.d.ts.map +1 -0
  20. package/dist/components/MagicLink.js +39 -0
  21. package/dist/components/MagicLink.js.map +1 -0
  22. package/dist/components/PhoneOTP.d.ts +11 -0
  23. package/dist/components/PhoneOTP.d.ts.map +1 -0
  24. package/dist/components/PhoneOTP.js +56 -0
  25. package/dist/components/PhoneOTP.js.map +1 -0
  26. package/dist/components/SignIn.d.ts +16 -0
  27. package/dist/components/SignIn.d.ts.map +1 -0
  28. package/dist/components/SignIn.js +39 -0
  29. package/dist/components/SignIn.js.map +1 -0
  30. package/dist/components/SignUp.d.ts +11 -0
  31. package/dist/components/SignUp.d.ts.map +1 -0
  32. package/dist/components/SignUp.js +43 -0
  33. package/dist/components/SignUp.js.map +1 -0
  34. package/dist/components/SocialButtons.d.ts +6 -0
  35. package/dist/components/SocialButtons.d.ts.map +1 -0
  36. package/dist/components/SocialButtons.js +39 -0
  37. package/dist/components/SocialButtons.js.map +1 -0
  38. package/dist/context.d.ts +80 -0
  39. package/dist/context.d.ts.map +1 -0
  40. package/dist/context.js +69 -0
  41. package/dist/context.js.map +1 -0
  42. package/dist/hooks/useAuth.d.ts +11 -0
  43. package/dist/hooks/useAuth.d.ts.map +1 -0
  44. package/dist/hooks/useAuth.js +34 -0
  45. package/dist/hooks/useAuth.js.map +1 -0
  46. package/dist/index.d.ts +49 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +41 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/styles.css +344 -0
  51. package/llms.txt +106 -0
  52. package/package.json +65 -0
@@ -0,0 +1,344 @@
1
+ /**
2
+ * @edge-base/auth-ui-react — Default theme
3
+ *
4
+ * CSS-class-based styling with `eb-auth` prefix.
5
+ * Override by targeting these classes or change classPrefix in config.
6
+ */
7
+
8
+ /* ─── Container ─── */
9
+
10
+ .eb-auth-container {
11
+ max-width: 400px;
12
+ margin: 0 auto;
13
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
14
+ Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
15
+ color: #1a1a1a;
16
+ }
17
+
18
+ /* ─── Form ─── */
19
+
20
+ .eb-auth-form {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: 16px;
24
+ }
25
+
26
+ .eb-auth-title {
27
+ font-size: 24px;
28
+ font-weight: 600;
29
+ margin: 0 0 4px 0;
30
+ text-align: center;
31
+ }
32
+
33
+ .eb-auth-description {
34
+ font-size: 14px;
35
+ color: #666;
36
+ margin: 0;
37
+ text-align: center;
38
+ }
39
+
40
+ /* ─── Fields ─── */
41
+
42
+ .eb-auth-field {
43
+ display: flex;
44
+ flex-direction: column;
45
+ gap: 6px;
46
+ }
47
+
48
+ .eb-auth-label {
49
+ font-size: 14px;
50
+ font-weight: 500;
51
+ color: #333;
52
+ }
53
+
54
+ .eb-auth-input {
55
+ padding: 10px 12px;
56
+ font-size: 14px;
57
+ border: 1px solid #d1d5db;
58
+ border-radius: 6px;
59
+ background: #fff;
60
+ color: #1a1a1a;
61
+ outline: none;
62
+ transition: border-color 0.15s ease;
63
+ }
64
+
65
+ .eb-auth-input:focus {
66
+ border-color: #3b82f6;
67
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
68
+ }
69
+
70
+ .eb-auth-input:disabled {
71
+ background: #f3f4f6;
72
+ cursor: not-allowed;
73
+ }
74
+
75
+ .eb-auth-input-code {
76
+ font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
77
+ font-size: 18px;
78
+ letter-spacing: 4px;
79
+ text-align: center;
80
+ }
81
+
82
+ /* ─── Buttons ─── */
83
+
84
+ .eb-auth-button {
85
+ padding: 10px 16px;
86
+ font-size: 14px;
87
+ font-weight: 500;
88
+ border: none;
89
+ border-radius: 6px;
90
+ cursor: pointer;
91
+ transition: background-color 0.15s ease, opacity 0.15s ease;
92
+ }
93
+
94
+ .eb-auth-button:disabled {
95
+ opacity: 0.6;
96
+ cursor: not-allowed;
97
+ }
98
+
99
+ .eb-auth-button-primary {
100
+ background: #3b82f6;
101
+ color: #fff;
102
+ }
103
+
104
+ .eb-auth-button-primary:hover:not(:disabled) {
105
+ background: #2563eb;
106
+ }
107
+
108
+ .eb-auth-button-social {
109
+ background: #f3f4f6;
110
+ color: #374151;
111
+ border: 1px solid #d1d5db;
112
+ width: 100%;
113
+ }
114
+
115
+ .eb-auth-button-social:hover:not(:disabled) {
116
+ background: #e5e7eb;
117
+ }
118
+
119
+ /* Provider-specific colors */
120
+ .eb-auth-button-google {
121
+ background: #fff;
122
+ border: 1px solid #d1d5db;
123
+ }
124
+
125
+ .eb-auth-button-github {
126
+ background: #24292e;
127
+ color: #fff;
128
+ border: none;
129
+ }
130
+
131
+ .eb-auth-button-github:hover:not(:disabled) {
132
+ background: #1b1f23;
133
+ }
134
+
135
+ .eb-auth-button-apple {
136
+ background: #000;
137
+ color: #fff;
138
+ border: none;
139
+ }
140
+
141
+ .eb-auth-button-apple:hover:not(:disabled) {
142
+ background: #1a1a1a;
143
+ }
144
+
145
+ .eb-auth-button-discord {
146
+ background: #5865f2;
147
+ color: #fff;
148
+ border: none;
149
+ }
150
+
151
+ .eb-auth-button-discord:hover:not(:disabled) {
152
+ background: #4752c4;
153
+ }
154
+
155
+ .eb-auth-button-twitter {
156
+ background: #1da1f2;
157
+ color: #fff;
158
+ border: none;
159
+ }
160
+
161
+ .eb-auth-button-twitter:hover:not(:disabled) {
162
+ background: #1a91da;
163
+ }
164
+
165
+ /* ─── Links ─── */
166
+
167
+ .eb-auth-link {
168
+ background: none;
169
+ border: none;
170
+ color: #3b82f6;
171
+ cursor: pointer;
172
+ font-size: 14px;
173
+ padding: 0;
174
+ text-decoration: none;
175
+ }
176
+
177
+ .eb-auth-link:hover {
178
+ color: #2563eb;
179
+ text-decoration: underline;
180
+ }
181
+
182
+ .eb-auth-forgot-link {
183
+ align-self: flex-end;
184
+ margin-top: -8px;
185
+ }
186
+
187
+ /* ─── Toggle (sign-in ↔ sign-up) ─── */
188
+
189
+ .eb-auth-toggle {
190
+ font-size: 14px;
191
+ color: #666;
192
+ text-align: center;
193
+ margin: 0;
194
+ }
195
+
196
+ /* ─── Error ─── */
197
+
198
+ .eb-auth-error {
199
+ padding: 10px 12px;
200
+ font-size: 14px;
201
+ color: #dc2626;
202
+ background: #fef2f2;
203
+ border: 1px solid #fecaca;
204
+ border-radius: 6px;
205
+ }
206
+
207
+ /* ─── Success ─── */
208
+
209
+ .eb-auth-success .eb-auth-description {
210
+ color: #16a34a;
211
+ }
212
+
213
+ /* ─── Divider ─── */
214
+
215
+ .eb-auth-divider {
216
+ display: flex;
217
+ align-items: center;
218
+ gap: 12px;
219
+ margin: 8px 0;
220
+ font-size: 13px;
221
+ color: #9ca3af;
222
+ }
223
+
224
+ .eb-auth-divider::before,
225
+ .eb-auth-divider::after {
226
+ content: '';
227
+ flex: 1;
228
+ height: 1px;
229
+ background: #e5e7eb;
230
+ }
231
+
232
+ /* ─── Social Buttons Layout ─── */
233
+
234
+ .eb-auth-social {
235
+ margin-top: 8px;
236
+ }
237
+
238
+ .eb-auth-social-buttons {
239
+ display: flex;
240
+ flex-direction: column;
241
+ gap: 8px;
242
+ }
243
+
244
+ /* ─── Alternative Methods ─── */
245
+
246
+ .eb-auth-alt-methods {
247
+ display: flex;
248
+ flex-direction: column;
249
+ align-items: center;
250
+ gap: 8px;
251
+ margin-top: 12px;
252
+ padding-top: 12px;
253
+ border-top: 1px solid #e5e7eb;
254
+ }
255
+
256
+ /* ─── MFA Actions ─── */
257
+
258
+ .eb-auth-mfa-actions {
259
+ display: flex;
260
+ justify-content: space-between;
261
+ gap: 12px;
262
+ }
263
+
264
+ /* ─── Loading ─── */
265
+
266
+ .eb-auth-loading {
267
+ text-align: center;
268
+ padding: 32px;
269
+ color: #666;
270
+ }
271
+
272
+ /* ─── Dark Mode ─── */
273
+
274
+ @media (prefers-color-scheme: dark) {
275
+ .eb-auth-container {
276
+ color: #f3f4f6;
277
+ }
278
+
279
+ .eb-auth-description {
280
+ color: #9ca3af;
281
+ }
282
+
283
+ .eb-auth-label {
284
+ color: #d1d5db;
285
+ }
286
+
287
+ .eb-auth-input {
288
+ background: #1f2937;
289
+ border-color: #374151;
290
+ color: #f3f4f6;
291
+ }
292
+
293
+ .eb-auth-input:focus {
294
+ border-color: #60a5fa;
295
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
296
+ }
297
+
298
+ .eb-auth-input:disabled {
299
+ background: #111827;
300
+ }
301
+
302
+ .eb-auth-button-social {
303
+ background: #1f2937;
304
+ color: #d1d5db;
305
+ border-color: #374151;
306
+ }
307
+
308
+ .eb-auth-button-social:hover:not(:disabled) {
309
+ background: #374151;
310
+ }
311
+
312
+ .eb-auth-button-google {
313
+ background: #1f2937;
314
+ border-color: #374151;
315
+ color: #d1d5db;
316
+ }
317
+
318
+ .eb-auth-error {
319
+ color: #f87171;
320
+ background: #450a0a;
321
+ border-color: #7f1d1d;
322
+ }
323
+
324
+ .eb-auth-toggle {
325
+ color: #9ca3af;
326
+ }
327
+
328
+ .eb-auth-divider {
329
+ color: #6b7280;
330
+ }
331
+
332
+ .eb-auth-divider::before,
333
+ .eb-auth-divider::after {
334
+ background: #374151;
335
+ }
336
+
337
+ .eb-auth-alt-methods {
338
+ border-top-color: #374151;
339
+ }
340
+
341
+ .eb-auth-loading {
342
+ color: #9ca3af;
343
+ }
344
+ }
package/llms.txt ADDED
@@ -0,0 +1,106 @@
1
+ # EdgeBase React Auth UI
2
+
3
+ Use this file as a quick-reference contract for AI coding assistants working with `@edge-base/auth-ui-react`.
4
+
5
+ ## Package Boundary
6
+
7
+ Use `@edge-base/auth-ui-react` for React auth components in browser-oriented apps.
8
+
9
+ It must be paired with `@edge-base/web`. Do not pass an admin or SSR client to `AuthProvider`. Do not use this package for React Native.
10
+
11
+ ## Source Of Truth
12
+
13
+ - Package README: https://github.com/edge-base/edgebase/blob/main/packages/sdk/js/packages/auth-ui-react/README.md
14
+ - Authentication overview: https://edgebase.fun/docs/authentication
15
+ - Email/password: https://edgebase.fun/docs/authentication/email-password
16
+ - Magic link: https://edgebase.fun/docs/authentication/magic-link
17
+ - Email OTP: https://edgebase.fun/docs/authentication/email-otp
18
+ - MFA: https://edgebase.fun/docs/authentication/mfa
19
+ - Next.js guide: https://edgebase.fun/docs/sdks/nextjs
20
+
21
+ ## Canonical Examples
22
+
23
+ ### Basic provider setup
24
+
25
+ ```tsx
26
+ import { createClient } from '@edge-base/web';
27
+ import { AuthProvider, AuthForm } from '@edge-base/auth-ui-react';
28
+ import '@edge-base/auth-ui-react/styles.css';
29
+
30
+ const client = createClient('https://your-project.edgebase.fun');
31
+
32
+ export function LoginScreen() {
33
+ return (
34
+ <AuthProvider client={client}>
35
+ <AuthForm />
36
+ </AuthProvider>
37
+ );
38
+ }
39
+ ```
40
+
41
+ ### Provider with config
42
+
43
+ ```tsx
44
+ <AuthProvider
45
+ client={client}
46
+ config={{
47
+ providers: ['google', 'github'],
48
+ defaultView: 'sign_in',
49
+ magicLinkEnabled: true,
50
+ emailOtpEnabled: true,
51
+ }}
52
+ >
53
+ <AuthForm onSuccess={() => navigate('/dashboard')} />
54
+ </AuthProvider>
55
+ ```
56
+
57
+ ### Read auth state
58
+
59
+ ```tsx
60
+ import { useAuth } from '@edge-base/auth-ui-react';
61
+
62
+ function HeaderActions() {
63
+ const { user, loading, signOut } = useAuth();
64
+
65
+ if (loading) return <span>Loading...</span>;
66
+ if (!user) return <a href="/login">Sign in</a>;
67
+
68
+ return <button onClick={() => void signOut()}>Sign out</button>;
69
+ }
70
+ ```
71
+
72
+ ## Hard Rules
73
+
74
+ - `AuthProvider` requires a `client` created with `@edge-base/web`
75
+ - `useAuthContext()` must be used inside `<AuthProvider>`
76
+ - `useAuth()` returns `{ user, loading, signOut }`
77
+ - importing `@edge-base/auth-ui-react/styles.css` is optional, but available
78
+ - default `classPrefix` is `eb-auth`
79
+ - supported `defaultView` values are:
80
+ - `sign_in`
81
+ - `sign_up`
82
+ - `magic_link`
83
+ - `email_otp`
84
+ - `phone_otp`
85
+ - `forgot_password`
86
+ - `reset_password`
87
+ - `mfa_challenge`
88
+ - `verify_email`
89
+
90
+ ## Common Mistakes
91
+
92
+ - do not create a new EdgeBase client inside every render; create it once and pass it to `AuthProvider`
93
+ - do not pass `@edge-base/admin` or `@edge-base/ssr` clients to `AuthProvider`
94
+ - `AuthForm` returns `null` when a user is already signed in
95
+ - `useAuthContext()` throws if used outside the provider
96
+ - `onSuccess` is a UI callback; routing and redirect behavior are still your job
97
+ - OAuth provider buttons are configured through `config.providers`
98
+
99
+ ## Quick Reference
100
+
101
+ ```text
102
+ AuthProvider({ client, config?, children }) -> context provider
103
+ AuthForm({ onSuccess?, defaultView?, className? }) -> complete auth flow UI
104
+ useAuth() -> { user, loading, signOut }
105
+ useAuthContext() -> raw context, throws outside provider
106
+ ```
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@edge-base/auth-ui-react",
3
+ "version": "0.1.1",
4
+ "description": "EdgeBase Auth UI for React — pre-built authentication components",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/edge-base/edgebase.git",
9
+ "directory": "packages/sdk/js/packages/auth-ui-react"
10
+ },
11
+ "homepage": "https://edgebase.fun",
12
+ "bugs": "https://github.com/edge-base/edgebase/issues",
13
+ "keywords": [
14
+ "edgebase",
15
+ "auth",
16
+ "react",
17
+ "ui",
18
+ "authentication"
19
+ ],
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js"
27
+ },
28
+ "./styles.css": "./dist/styles.css"
29
+ },
30
+ "sideEffects": [
31
+ "*.css"
32
+ ],
33
+ "files": [
34
+ "dist",
35
+ "llms.txt"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "scripts": {
41
+ "build": "tsc && cp src/styles.css dist/styles.css",
42
+ "dev": "tsc --watch",
43
+ "test": "vitest run",
44
+ "test:watch": "vitest",
45
+ "prepack": "pnpm run build"
46
+ },
47
+ "peerDependencies": {
48
+ "react": ">=18.0.0",
49
+ "react-dom": ">=18.0.0"
50
+ },
51
+ "dependencies": {
52
+ "@edge-base/web": "workspace:*"
53
+ },
54
+ "devDependencies": {
55
+ "@types/react": "^18.0.0",
56
+ "@types/react-dom": "^18.0.0",
57
+ "@testing-library/jest-dom": "^6.0.0",
58
+ "@testing-library/react": "^14.0.0",
59
+ "jsdom": "^24.0.0",
60
+ "react": "^18.0.0",
61
+ "react-dom": "^18.0.0",
62
+ "typescript": "^5.7.0",
63
+ "vitest": "^2.0.0"
64
+ }
65
+ }