@digilogiclabs/saas-factory-auth 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +396 -384
- package/dist/index.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +295 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -138
- package/dist/index.mjs.map +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -1,384 +1,396 @@
|
|
|
1
|
-
# @digilogiclabs/saas-factory-auth
|
|
2
|
-
|
|
3
|
-
A universal authentication package supporting both Next.js web applications and React Native mobile apps. Provides a unified API for multiple authentication providers with zero-configuration setup.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🔐 **Multi-Provider Support**
|
|
8
|
-
- Supabase Authentication
|
|
9
|
-
- Firebase Authentication
|
|
10
|
-
- Auto-detection based on environment variables
|
|
11
|
-
- 📱 **Cross-Platform**
|
|
12
|
-
- Next.js 15+ (App Router)
|
|
13
|
-
- React Native with Expo
|
|
14
|
-
- React 19+ compatible
|
|
15
|
-
- 🚀 **Complete Auth Flows**
|
|
16
|
-
- Email/Password authentication
|
|
17
|
-
- OAuth providers (Google, GitHub, Facebook, Twitter, Discord, Apple, Microsoft, LinkedIn, Spotify, Twitch, Slack, Notion)
|
|
18
|
-
- Magic link (passwordless) authentication
|
|
19
|
-
- Password reset
|
|
20
|
-
- 🎯 **Modern Architecture**
|
|
21
|
-
- TypeScript-first
|
|
22
|
-
- Zustand state management
|
|
23
|
-
- Provider factory pattern
|
|
24
|
-
- Proper error handling with typed errors
|
|
25
|
-
- 💾 **Session Management**
|
|
26
|
-
- Automatic token refresh
|
|
27
|
-
- Persistent sessions
|
|
28
|
-
- Custom storage adapters
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
npm install @digilogiclabs/saas-factory-auth
|
|
34
|
-
# or
|
|
35
|
-
yarn add @digilogiclabs/saas-factory-auth
|
|
36
|
-
# or
|
|
37
|
-
pnpm add @digilogiclabs/saas-factory-auth
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Requirements
|
|
41
|
-
|
|
42
|
-
- Next.js 15+ or React Native with Expo
|
|
43
|
-
- React 19+
|
|
44
|
-
- Either Supabase or Firebase project credentials
|
|
45
|
-
|
|
46
|
-
## Quick Start
|
|
47
|
-
|
|
48
|
-
### 1. Configure Environment Variables
|
|
49
|
-
|
|
50
|
-
#### For Supabase:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
|
214
|
-
|
|
|
215
|
-
|
|
|
216
|
-
|
|
|
217
|
-
|
|
|
218
|
-
|
|
|
219
|
-
|
|
|
220
|
-
|
|
|
221
|
-
|
|
|
222
|
-
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
-
|
|
300
|
-
|
|
301
|
-
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
### v1.0.
|
|
363
|
-
|
|
364
|
-
-
|
|
365
|
-
-
|
|
366
|
-
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
- React
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
-
|
|
383
|
-
|
|
384
|
-
|
|
1
|
+
# @digilogiclabs/saas-factory-auth
|
|
2
|
+
|
|
3
|
+
A universal authentication package supporting both Next.js web applications and React Native mobile apps. Provides a unified API for multiple authentication providers with zero-configuration setup.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔐 **Multi-Provider Support**
|
|
8
|
+
- Supabase Authentication
|
|
9
|
+
- Firebase Authentication
|
|
10
|
+
- Auto-detection based on environment variables
|
|
11
|
+
- 📱 **Cross-Platform**
|
|
12
|
+
- Next.js 15+ (App Router)
|
|
13
|
+
- React Native with Expo
|
|
14
|
+
- React 19+ compatible
|
|
15
|
+
- 🚀 **Complete Auth Flows**
|
|
16
|
+
- Email/Password authentication
|
|
17
|
+
- OAuth providers (Google, GitHub, Facebook, Twitter, Discord, Apple, Microsoft, LinkedIn, Spotify, Twitch, Slack, Notion)
|
|
18
|
+
- Magic link (passwordless) authentication
|
|
19
|
+
- Password reset
|
|
20
|
+
- 🎯 **Modern Architecture**
|
|
21
|
+
- TypeScript-first
|
|
22
|
+
- Zustand state management
|
|
23
|
+
- Provider factory pattern
|
|
24
|
+
- Proper error handling with typed errors
|
|
25
|
+
- 💾 **Session Management**
|
|
26
|
+
- Automatic token refresh
|
|
27
|
+
- Persistent sessions
|
|
28
|
+
- Custom storage adapters
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @digilogiclabs/saas-factory-auth
|
|
34
|
+
# or
|
|
35
|
+
yarn add @digilogiclabs/saas-factory-auth
|
|
36
|
+
# or
|
|
37
|
+
pnpm add @digilogiclabs/saas-factory-auth
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Next.js 15+ or React Native with Expo
|
|
43
|
+
- React 19+
|
|
44
|
+
- Either Supabase or Firebase project credentials
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### 1. Configure Environment Variables
|
|
49
|
+
|
|
50
|
+
#### For Supabase:
|
|
51
|
+
|
|
52
|
+
```env
|
|
53
|
+
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
|
|
54
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### For Firebase:
|
|
58
|
+
|
|
59
|
+
```env
|
|
60
|
+
NEXT_PUBLIC_FIREBASE_API_KEY=your-api-key
|
|
61
|
+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-auth-domain
|
|
62
|
+
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Optional - Explicit Provider Selection:
|
|
66
|
+
|
|
67
|
+
```env
|
|
68
|
+
NEXT_PUBLIC_AUTH_PROVIDER=supabase # or 'firebase'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 2. Wrap Your App with AuthProvider
|
|
72
|
+
|
|
73
|
+
#### Next.js App Router:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
// app/layout.tsx
|
|
77
|
+
import { AuthProvider } from "@digilogiclabs/saas-factory-auth";
|
|
78
|
+
|
|
79
|
+
export default function RootLayout({
|
|
80
|
+
children,
|
|
81
|
+
}: {
|
|
82
|
+
children: React.ReactNode;
|
|
83
|
+
}) {
|
|
84
|
+
return (
|
|
85
|
+
<html lang="en">
|
|
86
|
+
<body>
|
|
87
|
+
<AuthProvider>{children}</AuthProvider>
|
|
88
|
+
</body>
|
|
89
|
+
</html>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### React Native:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// App.tsx
|
|
98
|
+
import { AuthProvider } from "@digilogiclabs/saas-factory-auth";
|
|
99
|
+
|
|
100
|
+
export default function App() {
|
|
101
|
+
return <AuthProvider>{/* Your app components */}</AuthProvider>;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 3. Use the Auth Hook
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
"use client"; // For Next.js App Router
|
|
109
|
+
|
|
110
|
+
import { useAuth } from "@digilogiclabs/saas-factory-auth";
|
|
111
|
+
|
|
112
|
+
export default function AuthExample() {
|
|
113
|
+
const {
|
|
114
|
+
user,
|
|
115
|
+
loading,
|
|
116
|
+
error,
|
|
117
|
+
signIn,
|
|
118
|
+
signUp,
|
|
119
|
+
signOut,
|
|
120
|
+
signInWithOAuth,
|
|
121
|
+
signInWithMagicLink,
|
|
122
|
+
resetPassword,
|
|
123
|
+
} = useAuth();
|
|
124
|
+
|
|
125
|
+
if (loading) return <div>Loading...</div>;
|
|
126
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
127
|
+
|
|
128
|
+
if (user) {
|
|
129
|
+
return (
|
|
130
|
+
<div>
|
|
131
|
+
<p>Welcome, {user.email}!</p>
|
|
132
|
+
<button onClick={() => signOut()}>Sign Out</button>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<div>
|
|
139
|
+
<button onClick={() => signIn("user@example.com", "password")}>
|
|
140
|
+
Sign In
|
|
141
|
+
</button>
|
|
142
|
+
<button onClick={() => signInWithOAuth("google")}>
|
|
143
|
+
Sign In with Google
|
|
144
|
+
</button>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## API Reference
|
|
151
|
+
|
|
152
|
+
### `<AuthProvider>`
|
|
153
|
+
|
|
154
|
+
The main provider component that initializes authentication.
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
interface AuthProviderProps {
|
|
158
|
+
children: React.ReactNode;
|
|
159
|
+
onAuthChange?: (event: AuthEvent) => void;
|
|
160
|
+
autoSignIn?: boolean; // Default: true
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `useAuth()` Hook
|
|
165
|
+
|
|
166
|
+
Returns the complete authentication state and methods:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
interface AuthStore {
|
|
170
|
+
// State
|
|
171
|
+
user: User | null;
|
|
172
|
+
session: AuthSession | null;
|
|
173
|
+
loading: boolean;
|
|
174
|
+
error: Error | null;
|
|
175
|
+
|
|
176
|
+
// Methods
|
|
177
|
+
signIn: (email: string, password: string) => Promise<void>;
|
|
178
|
+
signUp: (email: string, password: string) => Promise<void>;
|
|
179
|
+
signOut: () => Promise<void>;
|
|
180
|
+
signInWithOAuth: (
|
|
181
|
+
provider: OAuthProvider,
|
|
182
|
+
redirectTo?: string,
|
|
183
|
+
) => Promise<void>;
|
|
184
|
+
signInWithMagicLink: (email: string, redirectTo?: string) => Promise<void>;
|
|
185
|
+
resetPassword: (email: string) => Promise<void>;
|
|
186
|
+
getUser: () => Promise<User | null>;
|
|
187
|
+
getSession: () => Promise<AuthSession | null>;
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Types
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
// User object
|
|
195
|
+
interface User {
|
|
196
|
+
id: string;
|
|
197
|
+
email?: string;
|
|
198
|
+
name?: string | null;
|
|
199
|
+
avatar?: string | null;
|
|
200
|
+
[key: string]: any; // Additional metadata
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Session object
|
|
204
|
+
interface AuthSession {
|
|
205
|
+
user: User;
|
|
206
|
+
access_token: string;
|
|
207
|
+
refresh_token?: string;
|
|
208
|
+
expires_at?: number;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// OAuth providers
|
|
212
|
+
type OAuthProvider =
|
|
213
|
+
| "google"
|
|
214
|
+
| "github"
|
|
215
|
+
| "facebook"
|
|
216
|
+
| "twitter"
|
|
217
|
+
| "discord"
|
|
218
|
+
| "apple"
|
|
219
|
+
| "microsoft"
|
|
220
|
+
| "linkedin"
|
|
221
|
+
| "spotify"
|
|
222
|
+
| "twitch"
|
|
223
|
+
| "slack"
|
|
224
|
+
| "notion";
|
|
225
|
+
|
|
226
|
+
// Auth events
|
|
227
|
+
enum AuthEvent {
|
|
228
|
+
SIGNED_IN = "SIGNED_IN",
|
|
229
|
+
SIGNED_OUT = "SIGNED_OUT",
|
|
230
|
+
TOKEN_REFRESHED = "TOKEN_REFRESHED",
|
|
231
|
+
USER_UPDATED = "USER_UPDATED",
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Error Handling
|
|
236
|
+
|
|
237
|
+
The package provides typed errors for better error handling:
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
enum AuthErrorType {
|
|
241
|
+
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
|
|
242
|
+
USER_NOT_FOUND = "USER_NOT_FOUND",
|
|
243
|
+
EMAIL_ALREADY_EXISTS = "EMAIL_ALREADY_EXISTS",
|
|
244
|
+
WEAK_PASSWORD = "WEAK_PASSWORD",
|
|
245
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
246
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
247
|
+
CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
|
|
248
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Usage
|
|
252
|
+
const { error } = useAuth();
|
|
253
|
+
if (error?.type === AuthErrorType.INVALID_CREDENTIALS) {
|
|
254
|
+
// Handle invalid credentials
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Advanced Usage
|
|
259
|
+
|
|
260
|
+
### Custom Storage (React Native)
|
|
261
|
+
|
|
262
|
+
For React Native, you can provide a custom storage implementation:
|
|
263
|
+
|
|
264
|
+
```tsx
|
|
265
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
266
|
+
import { AuthProvider } from "@digilogiclabs/saas-factory-auth";
|
|
267
|
+
|
|
268
|
+
const customStorage = {
|
|
269
|
+
getItem: async (key: string) => AsyncStorage.getItem(key),
|
|
270
|
+
setItem: async (key: string, value: string) =>
|
|
271
|
+
AsyncStorage.setItem(key, value),
|
|
272
|
+
removeItem: async (key: string) => AsyncStorage.removeItem(key),
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// Pass to provider factory if using advanced configuration
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Listen to Auth State Changes
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
<AuthProvider
|
|
282
|
+
onAuthChange={(event) => {
|
|
283
|
+
console.log("Auth event:", event);
|
|
284
|
+
// Handle auth state changes
|
|
285
|
+
}}
|
|
286
|
+
>
|
|
287
|
+
{children}
|
|
288
|
+
</AuthProvider>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Disable Auto Sign-In
|
|
292
|
+
|
|
293
|
+
```tsx
|
|
294
|
+
<AuthProvider autoSignIn={false}>{children}</AuthProvider>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Provider-Specific Features
|
|
298
|
+
|
|
299
|
+
### Supabase-Specific
|
|
300
|
+
|
|
301
|
+
- Row Level Security (RLS) support
|
|
302
|
+
- Realtime subscriptions compatibility
|
|
303
|
+
- Built-in email verification flows
|
|
304
|
+
|
|
305
|
+
### Firebase-Specific
|
|
306
|
+
|
|
307
|
+
- Firebase Auth UI compatibility
|
|
308
|
+
- Firestore rules integration
|
|
309
|
+
- Firebase Admin SDK support
|
|
310
|
+
|
|
311
|
+
## Migration Guide
|
|
312
|
+
|
|
313
|
+
### From v0.3.x to v0.4.x
|
|
314
|
+
|
|
315
|
+
1. **Update imports**: Components like `SignIn`, `SignUp`, `OAuthButtons` are no longer provided. Use the `useAuth` hook directly.
|
|
316
|
+
|
|
317
|
+
2. **Update AuthProvider usage**: Remove any configuration props, configuration is now handled via environment variables.
|
|
318
|
+
|
|
319
|
+
3. **Update auth method calls**: All methods now return promises and handle errors internally:
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
// Old
|
|
323
|
+
const { data, error } = await signIn(email, password);
|
|
324
|
+
|
|
325
|
+
// New
|
|
326
|
+
try {
|
|
327
|
+
await signIn(email, password);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
// Handle error
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Troubleshooting
|
|
334
|
+
|
|
335
|
+
### "Auth provider not initialized"
|
|
336
|
+
|
|
337
|
+
Ensure you've wrapped your app with `<AuthProvider>` at the root level.
|
|
338
|
+
|
|
339
|
+
### "Invalid Supabase URL"
|
|
340
|
+
|
|
341
|
+
Check that your `NEXT_PUBLIC_SUPABASE_URL` includes the full URL with `https://`.
|
|
342
|
+
|
|
343
|
+
### Network/DNS Errors
|
|
344
|
+
|
|
345
|
+
Verify your project credentials and ensure the project is not paused (for Supabase).
|
|
346
|
+
|
|
347
|
+
## Contributing
|
|
348
|
+
|
|
349
|
+
We welcome contributions! Please see our [contributing guide](CONTRIBUTING.md) for details.
|
|
350
|
+
|
|
351
|
+
## Support
|
|
352
|
+
|
|
353
|
+
- [GitHub Issues](https://github.com/DigiLogicLabs/saas-factory-auth/issues)
|
|
354
|
+
- [Documentation](https://github.com/DigiLogicLabs/saas-factory-auth/wiki)
|
|
355
|
+
|
|
356
|
+
## License
|
|
357
|
+
|
|
358
|
+
MIT © [DigiLogic Labs](https://github.com/DigiLogicLabs)
|
|
359
|
+
|
|
360
|
+
## Changelog
|
|
361
|
+
|
|
362
|
+
### v1.0.1 (Latest)
|
|
363
|
+
|
|
364
|
+
- **🎉 Enhanced OAuth Provider Support**: Added Microsoft, LinkedIn, Spotify, Twitch, Slack, and Notion OAuth providers
|
|
365
|
+
- **🔧 Improved TypeScript Types**: Complete rewrite of User interface with detailed profile fields, metadata support, and extended authentication state tracking
|
|
366
|
+
- **✨ Enhanced User Experience**: Better OAuth provider UI with proper branding, icons, and colors for all supported providers
|
|
367
|
+
- **📚 Comprehensive Role Support**: Extended UserRole type with additional built-in roles (owner, editor, viewer, contributor, manager, developer, analyst, support)
|
|
368
|
+
- **💪 Backward Compatibility**: All changes are non-destructive and maintain full backward compatibility
|
|
369
|
+
|
|
370
|
+
### v1.0.0
|
|
371
|
+
|
|
372
|
+
- **Major Release**: Production-ready authentication package
|
|
373
|
+
- Complete feature parity between Supabase and Firebase providers
|
|
374
|
+
- Enhanced error handling and user feedback
|
|
375
|
+
- Comprehensive testing and documentation
|
|
376
|
+
|
|
377
|
+
### v0.4.3
|
|
378
|
+
|
|
379
|
+
- Fixed React hooks usage in auth callbacks
|
|
380
|
+
- Improved error handling and network error detection
|
|
381
|
+
- Added proper auth provider initialization in store
|
|
382
|
+
- Enhanced TypeScript types
|
|
383
|
+
|
|
384
|
+
### v0.4.0
|
|
385
|
+
|
|
386
|
+
- Complete architecture rewrite
|
|
387
|
+
- Added Firebase support alongside Supabase
|
|
388
|
+
- Implemented provider factory pattern
|
|
389
|
+
- Migrated to Zustand for state management
|
|
390
|
+
- React 19 and Next.js 15 compatibility
|
|
391
|
+
|
|
392
|
+
### v0.3.x
|
|
393
|
+
|
|
394
|
+
- Initial Supabase-only implementation
|
|
395
|
+
- Basic authentication flows
|
|
396
|
+
- Component-based architecture
|