@terreno/rtk 0.1.0 → 0.3.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/dist/betterAuthClient.d.ts +734 -0
- package/dist/betterAuthClient.d.ts.map +1 -0
- package/dist/betterAuthClient.js +79 -0
- package/dist/betterAuthClient.js.map +1 -0
- package/dist/betterAuthSlice.d.ts +338 -0
- package/dist/betterAuthSlice.d.ts.map +1 -0
- package/dist/betterAuthSlice.js +220 -0
- package/dist/betterAuthSlice.js.map +1 -0
- package/dist/betterAuthSlice.test.d.ts +2 -0
- package/dist/betterAuthSlice.test.d.ts.map +1 -0
- package/dist/betterAuthSlice.test.js +258 -0
- package/dist/betterAuthSlice.test.js.map +1 -0
- package/dist/betterAuthTypes.d.ts +74 -0
- package/dist/betterAuthTypes.d.ts.map +1 -0
- package/dist/betterAuthTypes.js +8 -0
- package/dist/betterAuthTypes.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/src/betterAuthClient.ts +107 -0
- package/src/betterAuthSlice.test.ts +329 -0
- package/src/betterAuthSlice.ts +307 -0
- package/src/betterAuthTypes.ts +81 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"betterAuthClient.d.ts","sourceRoot":"","sources":["../src/betterAuthClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AAI9D,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACf,MAAM,mBAAmB,CAAC;AA+C3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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F;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Better Auth client factory for React Native/Expo applications.
|
|
3
|
+
*
|
|
4
|
+
* Provides a configured Better Auth client with Expo-specific storage
|
|
5
|
+
* and deep linking support.
|
|
6
|
+
*/
|
|
7
|
+
import { expoClient } from "@better-auth/expo/client";
|
|
8
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
9
|
+
import { createAuthClient } from "better-auth/react";
|
|
10
|
+
import * as SecureStore from "expo-secure-store";
|
|
11
|
+
import { IsWeb } from "./platform";
|
|
12
|
+
/**
|
|
13
|
+
* Async storage adapter for Better Auth that works on both web and native.
|
|
14
|
+
* Uses SecureStore on native platforms and AsyncStorage on web.
|
|
15
|
+
*/
|
|
16
|
+
const createStorageAdapter = () => {
|
|
17
|
+
if (IsWeb) {
|
|
18
|
+
return {
|
|
19
|
+
getItem: (key) => {
|
|
20
|
+
if (typeof window !== "undefined") {
|
|
21
|
+
return AsyncStorage.getItem(key);
|
|
22
|
+
}
|
|
23
|
+
return Promise.resolve(null);
|
|
24
|
+
},
|
|
25
|
+
removeItem: (key) => {
|
|
26
|
+
if (typeof window !== "undefined") {
|
|
27
|
+
return AsyncStorage.removeItem(key);
|
|
28
|
+
}
|
|
29
|
+
return Promise.resolve();
|
|
30
|
+
},
|
|
31
|
+
setItem: (key, value) => {
|
|
32
|
+
if (typeof window !== "undefined") {
|
|
33
|
+
return AsyncStorage.setItem(key, value);
|
|
34
|
+
}
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Native platform - use SecureStore
|
|
40
|
+
return {
|
|
41
|
+
getItem: (key) => SecureStore.getItemAsync(key),
|
|
42
|
+
removeItem: (key) => SecureStore.deleteItemAsync(key),
|
|
43
|
+
setItem: (key, value) => SecureStore.setItemAsync(key, value),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Better Auth client configured for Expo/React Native.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const authClient = createBetterAuthClient({
|
|
52
|
+
* baseURL: "http://localhost:3000",
|
|
53
|
+
* scheme: "terreno",
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Use for social login
|
|
57
|
+
* await authClient.signIn.social({
|
|
58
|
+
* provider: "google",
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // Get current session
|
|
62
|
+
* const session = await authClient.getSession();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export const createBetterAuthClient = (config) => {
|
|
66
|
+
const storage = createStorageAdapter();
|
|
67
|
+
return createAuthClient({
|
|
68
|
+
baseURL: config.baseURL,
|
|
69
|
+
plugins: [
|
|
70
|
+
expoClient({
|
|
71
|
+
scheme: config.scheme,
|
|
72
|
+
// biome-ignore lint/suspicious/noExplicitAny: Better Auth storage type is flexible
|
|
73
|
+
storage: storage,
|
|
74
|
+
storagePrefix: config.storagePrefix ?? "terreno",
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=betterAuthClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"betterAuthClient.js","sourceRoot":"","sources":["../src/betterAuthClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,YAAY,MAAM,2CAA2C,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAoBjC;;;GAGG;AACH,MAAM,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AAoB,EAAE,CAAC;IAEvC,OAAO,gBAAgB,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE;YACP,UAAU,CAAC;gBACT,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,mFAAmF;gBACnF,OAAO,EAAE,OAAc;gBACvB,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,SAAS;aACjD,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Better Auth Redux slice for session state management.
|
|
3
|
+
*
|
|
4
|
+
* Provides Redux integration for Better Auth, including session synchronization,
|
|
5
|
+
* login/logout actions, and selectors for auth state.
|
|
6
|
+
*/
|
|
7
|
+
import { type PayloadAction } from "@reduxjs/toolkit";
|
|
8
|
+
import type { BetterAuthClientInterface, BetterAuthUser } from "./betterAuthTypes";
|
|
9
|
+
/**
|
|
10
|
+
* Root state type - loosely typed to avoid circular dependencies.
|
|
11
|
+
*/
|
|
12
|
+
type RootState = any;
|
|
13
|
+
/**
|
|
14
|
+
* Better Auth Redux state interface.
|
|
15
|
+
*/
|
|
16
|
+
export interface BetterAuthState {
|
|
17
|
+
/**
|
|
18
|
+
* Whether the user is authenticated.
|
|
19
|
+
*/
|
|
20
|
+
isAuthenticated: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The authenticated user's ID, or null if not authenticated.
|
|
23
|
+
*/
|
|
24
|
+
userId: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* The authenticated user data, or null if not authenticated.
|
|
27
|
+
*/
|
|
28
|
+
user: BetterAuthUser | null;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the auth state is currently loading.
|
|
31
|
+
*/
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Last error message, if any.
|
|
35
|
+
*/
|
|
36
|
+
error: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Timestamp of the last session sync.
|
|
39
|
+
*/
|
|
40
|
+
lastSyncTimestamp: number | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Configuration for generating the Better Auth slice.
|
|
44
|
+
*/
|
|
45
|
+
export interface GenerateBetterAuthSliceConfig {
|
|
46
|
+
/**
|
|
47
|
+
* The Better Auth client instance.
|
|
48
|
+
*/
|
|
49
|
+
authClient: BetterAuthClientInterface;
|
|
50
|
+
/**
|
|
51
|
+
* How often to sync the session state (in milliseconds).
|
|
52
|
+
* @default 60000 (1 minute)
|
|
53
|
+
*/
|
|
54
|
+
syncInterval?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generates a Better Auth Redux slice with session management.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const authClient = createBetterAuthClient({
|
|
62
|
+
* baseURL: "http://localhost:3000",
|
|
63
|
+
* scheme: "terreno",
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* const betterAuthSlice = generateBetterAuthSlice({ authClient });
|
|
67
|
+
*
|
|
68
|
+
* // Add to your store
|
|
69
|
+
* const store = configureStore({
|
|
70
|
+
* reducer: {
|
|
71
|
+
* betterAuth: betterAuthSlice.reducer,
|
|
72
|
+
* },
|
|
73
|
+
* middleware: (getDefaultMiddleware) =>
|
|
74
|
+
* getDefaultMiddleware().concat(betterAuthSlice.middleware),
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* // Use in components
|
|
78
|
+
* const isAuthenticated = useSelector(selectBetterAuthIsAuthenticated);
|
|
79
|
+
* const user = useSelector(selectBetterAuthUser);
|
|
80
|
+
*
|
|
81
|
+
* // Trigger logout
|
|
82
|
+
* dispatch(betterAuthSlice.actions.logout());
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const generateBetterAuthSlice: (config: GenerateBetterAuthSliceConfig) => {
|
|
86
|
+
/**
|
|
87
|
+
* Actions for the Better Auth slice.
|
|
88
|
+
*/
|
|
89
|
+
actions: import("@reduxjs/toolkit").CaseReducerActions<{
|
|
90
|
+
/**
|
|
91
|
+
* Clear the session data on logout.
|
|
92
|
+
*/
|
|
93
|
+
clearSession: (state: {
|
|
94
|
+
isAuthenticated: boolean;
|
|
95
|
+
userId: string | null;
|
|
96
|
+
user: {
|
|
97
|
+
id: string;
|
|
98
|
+
email: string;
|
|
99
|
+
name: string | null;
|
|
100
|
+
image: string | null;
|
|
101
|
+
emailVerified: boolean;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
updatedAt: Date;
|
|
104
|
+
} | null;
|
|
105
|
+
isLoading: boolean;
|
|
106
|
+
error: string | null;
|
|
107
|
+
lastSyncTimestamp: number | null;
|
|
108
|
+
}) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Trigger logout action.
|
|
111
|
+
*/
|
|
112
|
+
logout: (state: {
|
|
113
|
+
isAuthenticated: boolean;
|
|
114
|
+
userId: string | null;
|
|
115
|
+
user: {
|
|
116
|
+
id: string;
|
|
117
|
+
email: string;
|
|
118
|
+
name: string | null;
|
|
119
|
+
image: string | null;
|
|
120
|
+
emailVerified: boolean;
|
|
121
|
+
createdAt: Date;
|
|
122
|
+
updatedAt: Date;
|
|
123
|
+
} | null;
|
|
124
|
+
isLoading: boolean;
|
|
125
|
+
error: string | null;
|
|
126
|
+
lastSyncTimestamp: number | null;
|
|
127
|
+
}) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Set error state.
|
|
130
|
+
*/
|
|
131
|
+
setError: (state: {
|
|
132
|
+
isAuthenticated: boolean;
|
|
133
|
+
userId: string | null;
|
|
134
|
+
user: {
|
|
135
|
+
id: string;
|
|
136
|
+
email: string;
|
|
137
|
+
name: string | null;
|
|
138
|
+
image: string | null;
|
|
139
|
+
emailVerified: boolean;
|
|
140
|
+
createdAt: Date;
|
|
141
|
+
updatedAt: Date;
|
|
142
|
+
} | null;
|
|
143
|
+
isLoading: boolean;
|
|
144
|
+
error: string | null;
|
|
145
|
+
lastSyncTimestamp: number | null;
|
|
146
|
+
}, action: PayloadAction<string | null>) => void;
|
|
147
|
+
/**
|
|
148
|
+
* Set loading state.
|
|
149
|
+
*/
|
|
150
|
+
setLoading: (state: {
|
|
151
|
+
isAuthenticated: boolean;
|
|
152
|
+
userId: string | null;
|
|
153
|
+
user: {
|
|
154
|
+
id: string;
|
|
155
|
+
email: string;
|
|
156
|
+
name: string | null;
|
|
157
|
+
image: string | null;
|
|
158
|
+
emailVerified: boolean;
|
|
159
|
+
createdAt: Date;
|
|
160
|
+
updatedAt: Date;
|
|
161
|
+
} | null;
|
|
162
|
+
isLoading: boolean;
|
|
163
|
+
error: string | null;
|
|
164
|
+
lastSyncTimestamp: number | null;
|
|
165
|
+
}, action: PayloadAction<boolean>) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Set the session data after successful authentication or session refresh.
|
|
168
|
+
*/
|
|
169
|
+
setSession: (state: {
|
|
170
|
+
isAuthenticated: boolean;
|
|
171
|
+
userId: string | null;
|
|
172
|
+
user: {
|
|
173
|
+
id: string;
|
|
174
|
+
email: string;
|
|
175
|
+
name: string | null;
|
|
176
|
+
image: string | null;
|
|
177
|
+
emailVerified: boolean;
|
|
178
|
+
createdAt: Date;
|
|
179
|
+
updatedAt: Date;
|
|
180
|
+
} | null;
|
|
181
|
+
isLoading: boolean;
|
|
182
|
+
error: string | null;
|
|
183
|
+
lastSyncTimestamp: number | null;
|
|
184
|
+
}, action: PayloadAction<{
|
|
185
|
+
user: BetterAuthUser;
|
|
186
|
+
userId: string;
|
|
187
|
+
}>) => void;
|
|
188
|
+
}, "betterAuth">;
|
|
189
|
+
/**
|
|
190
|
+
* The Better Auth client instance.
|
|
191
|
+
*/
|
|
192
|
+
authClient: BetterAuthClientInterface;
|
|
193
|
+
/**
|
|
194
|
+
* Middleware for handling Better Auth side effects.
|
|
195
|
+
*/
|
|
196
|
+
middleware: import("@reduxjs/toolkit").ListenerMiddleware<unknown, import("@reduxjs/toolkit").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction>, unknown>[];
|
|
197
|
+
/**
|
|
198
|
+
* The reducer for the Better Auth slice.
|
|
199
|
+
*/
|
|
200
|
+
reducer: import("@reduxjs/toolkit").Reducer<BetterAuthState>;
|
|
201
|
+
/**
|
|
202
|
+
* The Better Auth Redux slice.
|
|
203
|
+
*/
|
|
204
|
+
slice: import("@reduxjs/toolkit").Slice<BetterAuthState, {
|
|
205
|
+
/**
|
|
206
|
+
* Clear the session data on logout.
|
|
207
|
+
*/
|
|
208
|
+
clearSession: (state: {
|
|
209
|
+
isAuthenticated: boolean;
|
|
210
|
+
userId: string | null;
|
|
211
|
+
user: {
|
|
212
|
+
id: string;
|
|
213
|
+
email: string;
|
|
214
|
+
name: string | null;
|
|
215
|
+
image: string | null;
|
|
216
|
+
emailVerified: boolean;
|
|
217
|
+
createdAt: Date;
|
|
218
|
+
updatedAt: Date;
|
|
219
|
+
} | null;
|
|
220
|
+
isLoading: boolean;
|
|
221
|
+
error: string | null;
|
|
222
|
+
lastSyncTimestamp: number | null;
|
|
223
|
+
}) => void;
|
|
224
|
+
/**
|
|
225
|
+
* Trigger logout action.
|
|
226
|
+
*/
|
|
227
|
+
logout: (state: {
|
|
228
|
+
isAuthenticated: boolean;
|
|
229
|
+
userId: string | null;
|
|
230
|
+
user: {
|
|
231
|
+
id: string;
|
|
232
|
+
email: string;
|
|
233
|
+
name: string | null;
|
|
234
|
+
image: string | null;
|
|
235
|
+
emailVerified: boolean;
|
|
236
|
+
createdAt: Date;
|
|
237
|
+
updatedAt: Date;
|
|
238
|
+
} | null;
|
|
239
|
+
isLoading: boolean;
|
|
240
|
+
error: string | null;
|
|
241
|
+
lastSyncTimestamp: number | null;
|
|
242
|
+
}) => void;
|
|
243
|
+
/**
|
|
244
|
+
* Set error state.
|
|
245
|
+
*/
|
|
246
|
+
setError: (state: {
|
|
247
|
+
isAuthenticated: boolean;
|
|
248
|
+
userId: string | null;
|
|
249
|
+
user: {
|
|
250
|
+
id: string;
|
|
251
|
+
email: string;
|
|
252
|
+
name: string | null;
|
|
253
|
+
image: string | null;
|
|
254
|
+
emailVerified: boolean;
|
|
255
|
+
createdAt: Date;
|
|
256
|
+
updatedAt: Date;
|
|
257
|
+
} | null;
|
|
258
|
+
isLoading: boolean;
|
|
259
|
+
error: string | null;
|
|
260
|
+
lastSyncTimestamp: number | null;
|
|
261
|
+
}, action: PayloadAction<string | null>) => void;
|
|
262
|
+
/**
|
|
263
|
+
* Set loading state.
|
|
264
|
+
*/
|
|
265
|
+
setLoading: (state: {
|
|
266
|
+
isAuthenticated: boolean;
|
|
267
|
+
userId: string | null;
|
|
268
|
+
user: {
|
|
269
|
+
id: string;
|
|
270
|
+
email: string;
|
|
271
|
+
name: string | null;
|
|
272
|
+
image: string | null;
|
|
273
|
+
emailVerified: boolean;
|
|
274
|
+
createdAt: Date;
|
|
275
|
+
updatedAt: Date;
|
|
276
|
+
} | null;
|
|
277
|
+
isLoading: boolean;
|
|
278
|
+
error: string | null;
|
|
279
|
+
lastSyncTimestamp: number | null;
|
|
280
|
+
}, action: PayloadAction<boolean>) => void;
|
|
281
|
+
/**
|
|
282
|
+
* Set the session data after successful authentication or session refresh.
|
|
283
|
+
*/
|
|
284
|
+
setSession: (state: {
|
|
285
|
+
isAuthenticated: boolean;
|
|
286
|
+
userId: string | null;
|
|
287
|
+
user: {
|
|
288
|
+
id: string;
|
|
289
|
+
email: string;
|
|
290
|
+
name: string | null;
|
|
291
|
+
image: string | null;
|
|
292
|
+
emailVerified: boolean;
|
|
293
|
+
createdAt: Date;
|
|
294
|
+
updatedAt: Date;
|
|
295
|
+
} | null;
|
|
296
|
+
isLoading: boolean;
|
|
297
|
+
error: string | null;
|
|
298
|
+
lastSyncTimestamp: number | null;
|
|
299
|
+
}, action: PayloadAction<{
|
|
300
|
+
user: BetterAuthUser;
|
|
301
|
+
userId: string;
|
|
302
|
+
}>) => void;
|
|
303
|
+
}, "betterAuth", "betterAuth", import("@reduxjs/toolkit").SliceSelectors<BetterAuthState>>;
|
|
304
|
+
/**
|
|
305
|
+
* Function to sync session state from Better Auth to Redux.
|
|
306
|
+
*/
|
|
307
|
+
syncSession: (dispatch: any) => Promise<void>;
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Type for the return value of generateBetterAuthSlice.
|
|
311
|
+
*/
|
|
312
|
+
export type BetterAuthSlice = ReturnType<typeof generateBetterAuthSlice>;
|
|
313
|
+
/**
|
|
314
|
+
* Selects the entire Better Auth state.
|
|
315
|
+
*/
|
|
316
|
+
export declare const selectBetterAuthState: (state: RootState) => BetterAuthState | undefined;
|
|
317
|
+
/**
|
|
318
|
+
* Selects whether the user is authenticated.
|
|
319
|
+
*/
|
|
320
|
+
export declare const selectBetterAuthIsAuthenticated: (state: RootState) => boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Selects the current user ID.
|
|
323
|
+
*/
|
|
324
|
+
export declare const selectBetterAuthUserId: (state: RootState) => string | null;
|
|
325
|
+
/**
|
|
326
|
+
* Selects the current user data.
|
|
327
|
+
*/
|
|
328
|
+
export declare const selectBetterAuthUser: (state: RootState) => BetterAuthUser | null;
|
|
329
|
+
/**
|
|
330
|
+
* Selects whether the auth state is loading.
|
|
331
|
+
*/
|
|
332
|
+
export declare const selectBetterAuthIsLoading: (state: RootState) => boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Selects the last error message.
|
|
335
|
+
*/
|
|
336
|
+
export declare const selectBetterAuthError: (state: RootState) => string | null;
|
|
337
|
+
export {};
|
|
338
|
+
//# sourceMappingURL=betterAuthSlice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"betterAuthSlice.d.ts","sourceRoot":"","sources":["../src/betterAuthSlice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAwC,KAAK,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE3F,OAAO,KAAK,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,mBAAmB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AEG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAIzE;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,SAAS,KAAG,eAAe,GAAG,SAEhD,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,+BAA+B,GAAI,OAAO,SAAS,KAAG,OAEd,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,SAAS,KAAG,MAAM,GAAG,IAExB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,SAAS,KAAG,cAAc,GAAG,IAEhC,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,SAAS,KAAG,OAEd,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,SAAS,KAAG,MAAM,GAAG,IAExB,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Better Auth Redux slice for session state management.
|
|
3
|
+
*
|
|
4
|
+
* Provides Redux integration for Better Auth, including session synchronization,
|
|
5
|
+
* login/logout actions, and selectors for auth state.
|
|
6
|
+
*/
|
|
7
|
+
import { createListenerMiddleware, createSlice } from "@reduxjs/toolkit";
|
|
8
|
+
/**
|
|
9
|
+
* Global logout action type for compatibility with other auth systems.
|
|
10
|
+
*/
|
|
11
|
+
const LOGOUT_ACTION_TYPE = "auth/logout";
|
|
12
|
+
const initialState = {
|
|
13
|
+
error: null,
|
|
14
|
+
isAuthenticated: false,
|
|
15
|
+
isLoading: true,
|
|
16
|
+
lastSyncTimestamp: null,
|
|
17
|
+
user: null,
|
|
18
|
+
userId: null,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Generates a Better Auth Redux slice with session management.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const authClient = createBetterAuthClient({
|
|
26
|
+
* baseURL: "http://localhost:3000",
|
|
27
|
+
* scheme: "terreno",
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const betterAuthSlice = generateBetterAuthSlice({ authClient });
|
|
31
|
+
*
|
|
32
|
+
* // Add to your store
|
|
33
|
+
* const store = configureStore({
|
|
34
|
+
* reducer: {
|
|
35
|
+
* betterAuth: betterAuthSlice.reducer,
|
|
36
|
+
* },
|
|
37
|
+
* middleware: (getDefaultMiddleware) =>
|
|
38
|
+
* getDefaultMiddleware().concat(betterAuthSlice.middleware),
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Use in components
|
|
42
|
+
* const isAuthenticated = useSelector(selectBetterAuthIsAuthenticated);
|
|
43
|
+
* const user = useSelector(selectBetterAuthUser);
|
|
44
|
+
*
|
|
45
|
+
* // Trigger logout
|
|
46
|
+
* dispatch(betterAuthSlice.actions.logout());
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export const generateBetterAuthSlice = (config) => {
|
|
50
|
+
const { authClient } = config;
|
|
51
|
+
const betterAuthSlice = createSlice({
|
|
52
|
+
initialState,
|
|
53
|
+
name: "betterAuth",
|
|
54
|
+
reducers: {
|
|
55
|
+
/**
|
|
56
|
+
* Clear the session data on logout.
|
|
57
|
+
*/
|
|
58
|
+
clearSession: (state) => {
|
|
59
|
+
state.isAuthenticated = false;
|
|
60
|
+
state.userId = null;
|
|
61
|
+
state.user = null;
|
|
62
|
+
state.isLoading = false;
|
|
63
|
+
state.error = null;
|
|
64
|
+
state.lastSyncTimestamp = Date.now();
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Trigger logout action.
|
|
68
|
+
*/
|
|
69
|
+
logout: (state) => {
|
|
70
|
+
state.isAuthenticated = false;
|
|
71
|
+
state.userId = null;
|
|
72
|
+
state.user = null;
|
|
73
|
+
state.isLoading = false;
|
|
74
|
+
state.error = null;
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Set error state.
|
|
78
|
+
*/
|
|
79
|
+
setError: (state, action) => {
|
|
80
|
+
state.error = action.payload;
|
|
81
|
+
state.isLoading = false;
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Set loading state.
|
|
85
|
+
*/
|
|
86
|
+
setLoading: (state, action) => {
|
|
87
|
+
state.isLoading = action.payload;
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Set the session data after successful authentication or session refresh.
|
|
91
|
+
*/
|
|
92
|
+
setSession: (state, action) => {
|
|
93
|
+
state.isAuthenticated = true;
|
|
94
|
+
state.userId = action.payload.userId;
|
|
95
|
+
state.user = action.payload.user;
|
|
96
|
+
state.isLoading = false;
|
|
97
|
+
state.error = null;
|
|
98
|
+
state.lastSyncTimestamp = Date.now();
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
// Listener middleware for handling logout side effects
|
|
103
|
+
const logoutListenerMiddleware = createListenerMiddleware();
|
|
104
|
+
// Handle logout action - sign out from Better Auth
|
|
105
|
+
logoutListenerMiddleware.startListening({
|
|
106
|
+
actionCreator: betterAuthSlice.actions.logout,
|
|
107
|
+
effect: async (_action, _listenerApi) => {
|
|
108
|
+
try {
|
|
109
|
+
await authClient.signOut();
|
|
110
|
+
console.debug("Better Auth: Signed out successfully");
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error("Better Auth: Error signing out:", error);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
// Also listen for the global logout action type for compatibility
|
|
118
|
+
logoutListenerMiddleware.startListening({
|
|
119
|
+
effect: async (_action, listenerApi) => {
|
|
120
|
+
try {
|
|
121
|
+
await authClient.signOut();
|
|
122
|
+
listenerApi.dispatch(betterAuthSlice.actions.clearSession());
|
|
123
|
+
console.debug("Better Auth: Signed out via global logout action");
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.error("Better Auth: Error signing out:", error);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
type: LOGOUT_ACTION_TYPE,
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Syncs the session state from Better Auth to Redux.
|
|
133
|
+
* Call this on app startup and periodically to keep state in sync.
|
|
134
|
+
*/
|
|
135
|
+
// biome-ignore lint/suspicious/noExplicitAny: Redux dispatch type varies by store configuration
|
|
136
|
+
const syncSession = async (dispatch) => {
|
|
137
|
+
dispatch(betterAuthSlice.actions.setLoading(true));
|
|
138
|
+
try {
|
|
139
|
+
const sessionData = await authClient.getSession();
|
|
140
|
+
if (sessionData?.data?.user && sessionData?.data?.session) {
|
|
141
|
+
dispatch(betterAuthSlice.actions.setSession({
|
|
142
|
+
user: sessionData.data.user,
|
|
143
|
+
userId: sessionData.data.user.id,
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
dispatch(betterAuthSlice.actions.clearSession());
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
console.error("Better Auth: Error syncing session:", error);
|
|
152
|
+
dispatch(betterAuthSlice.actions.setError("Failed to sync session"));
|
|
153
|
+
dispatch(betterAuthSlice.actions.clearSession());
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
return {
|
|
157
|
+
/**
|
|
158
|
+
* Actions for the Better Auth slice.
|
|
159
|
+
*/
|
|
160
|
+
actions: betterAuthSlice.actions,
|
|
161
|
+
/**
|
|
162
|
+
* The Better Auth client instance.
|
|
163
|
+
*/
|
|
164
|
+
authClient,
|
|
165
|
+
/**
|
|
166
|
+
* Middleware for handling Better Auth side effects.
|
|
167
|
+
*/
|
|
168
|
+
middleware: [logoutListenerMiddleware.middleware],
|
|
169
|
+
/**
|
|
170
|
+
* The reducer for the Better Auth slice.
|
|
171
|
+
*/
|
|
172
|
+
reducer: betterAuthSlice.reducer,
|
|
173
|
+
/**
|
|
174
|
+
* The Better Auth Redux slice.
|
|
175
|
+
*/
|
|
176
|
+
slice: betterAuthSlice,
|
|
177
|
+
/**
|
|
178
|
+
* Function to sync session state from Better Auth to Redux.
|
|
179
|
+
*/
|
|
180
|
+
syncSession,
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
// Selectors
|
|
184
|
+
/**
|
|
185
|
+
* Selects the entire Better Auth state.
|
|
186
|
+
*/
|
|
187
|
+
export const selectBetterAuthState = (state) =>
|
|
188
|
+
// biome-ignore lint/suspicious/noExplicitAny: RootState is loosely typed
|
|
189
|
+
state.betterAuth;
|
|
190
|
+
/**
|
|
191
|
+
* Selects whether the user is authenticated.
|
|
192
|
+
*/
|
|
193
|
+
export const selectBetterAuthIsAuthenticated = (state) =>
|
|
194
|
+
// biome-ignore lint/suspicious/noExplicitAny: RootState is loosely typed
|
|
195
|
+
state.betterAuth?.isAuthenticated ?? false;
|
|
196
|
+
/**
|
|
197
|
+
* Selects the current user ID.
|
|
198
|
+
*/
|
|
199
|
+
export const selectBetterAuthUserId = (state) =>
|
|
200
|
+
// biome-ignore lint/suspicious/noExplicitAny: RootState is loosely typed
|
|
201
|
+
state.betterAuth?.userId ?? null;
|
|
202
|
+
/**
|
|
203
|
+
* Selects the current user data.
|
|
204
|
+
*/
|
|
205
|
+
export const selectBetterAuthUser = (state) =>
|
|
206
|
+
// biome-ignore lint/suspicious/noExplicitAny: RootState is loosely typed
|
|
207
|
+
state.betterAuth?.user ?? null;
|
|
208
|
+
/**
|
|
209
|
+
* Selects whether the auth state is loading.
|
|
210
|
+
*/
|
|
211
|
+
export const selectBetterAuthIsLoading = (state) =>
|
|
212
|
+
// biome-ignore lint/suspicious/noExplicitAny: RootState is loosely typed
|
|
213
|
+
state.betterAuth?.isLoading ?? false;
|
|
214
|
+
/**
|
|
215
|
+
* Selects the last error message.
|
|
216
|
+
*/
|
|
217
|
+
export const selectBetterAuthError = (state) =>
|
|
218
|
+
// biome-ignore lint/suspicious/noExplicitAny: RootState is loosely typed
|
|
219
|
+
state.betterAuth?.error ?? null;
|
|
220
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