@payez/next-mvp 3.8.2 → 3.9.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.
@@ -0,0 +1,1020 @@
1
+ /**
2
+ * Better Auth Client (Phase 3)
3
+ *
4
+ * Drop-in replacement for next-auth/react hooks and functions.
5
+ * Import from '@payez/next-mvp/client/better-auth-client'.
6
+ *
7
+ * Includes useSessionCompat() — returns NextAuth-shaped { data, status }
8
+ * so existing components don't need destructure pattern changes.
9
+ */
10
+ export declare const authClient: {
11
+ signIn: {
12
+ social: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
13
+ provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
14
+ callbackURL?: string | undefined;
15
+ newUserCallbackURL?: string | undefined;
16
+ errorCallbackURL?: string | undefined;
17
+ disableRedirect?: boolean | undefined;
18
+ idToken?: {
19
+ token: string;
20
+ nonce?: string | undefined;
21
+ accessToken?: string | undefined;
22
+ refreshToken?: string | undefined;
23
+ expiresAt?: number | undefined;
24
+ user?: {
25
+ name?: {
26
+ firstName?: string | undefined;
27
+ lastName?: string | undefined;
28
+ } | undefined;
29
+ email?: string | undefined;
30
+ } | undefined;
31
+ } | undefined;
32
+ scopes?: string[] | undefined;
33
+ requestSignUp?: boolean | undefined;
34
+ loginHint?: string | undefined;
35
+ additionalData?: Record<string, any> | undefined;
36
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
37
+ provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
38
+ callbackURL?: string | undefined;
39
+ newUserCallbackURL?: string | undefined;
40
+ errorCallbackURL?: string | undefined;
41
+ disableRedirect?: boolean | undefined;
42
+ idToken?: {
43
+ token: string;
44
+ nonce?: string | undefined;
45
+ accessToken?: string | undefined;
46
+ refreshToken?: string | undefined;
47
+ expiresAt?: number | undefined;
48
+ user?: {
49
+ name?: {
50
+ firstName?: string | undefined;
51
+ lastName?: string | undefined;
52
+ } | undefined;
53
+ email?: string | undefined;
54
+ } | undefined;
55
+ } | undefined;
56
+ scopes?: string[] | undefined;
57
+ requestSignUp?: boolean | undefined;
58
+ loginHint?: string | undefined;
59
+ additionalData?: Record<string, any> | undefined;
60
+ } & {
61
+ fetchOptions?: FetchOptions | undefined;
62
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
63
+ redirect: boolean;
64
+ url: string;
65
+ } | (Omit<{
66
+ redirect: boolean;
67
+ token: string;
68
+ url: undefined;
69
+ user: {
70
+ id: string;
71
+ createdAt: Date;
72
+ updatedAt: Date;
73
+ email: string;
74
+ emailVerified: boolean;
75
+ name: string;
76
+ image?: string | null | undefined | undefined;
77
+ };
78
+ }, "user"> & {
79
+ user: import("better-auth/react").StripEmptyObjects<{
80
+ id: string;
81
+ createdAt: Date;
82
+ updatedAt: Date;
83
+ email: string;
84
+ emailVerified: boolean;
85
+ name: string;
86
+ image?: string | null | undefined;
87
+ }>;
88
+ }), {
89
+ code?: string | undefined;
90
+ message?: string | undefined;
91
+ }, FetchOptions["throw"] extends true ? true : false>>;
92
+ };
93
+ } & {
94
+ signOut: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
95
+ query?: Record<string, any> | undefined;
96
+ fetchOptions?: FetchOptions | undefined;
97
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
98
+ success: boolean;
99
+ }, {
100
+ code?: string | undefined;
101
+ message?: string | undefined;
102
+ }, FetchOptions["throw"] extends true ? true : false>>;
103
+ } & {
104
+ signUp: {
105
+ email: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
106
+ name: string;
107
+ email: string;
108
+ password: string;
109
+ image?: string | undefined;
110
+ callbackURL?: string | undefined;
111
+ rememberMe?: boolean | undefined;
112
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
113
+ email: string;
114
+ name: string;
115
+ password: string;
116
+ image?: string | undefined;
117
+ callbackURL?: string | undefined;
118
+ fetchOptions?: FetchOptions | undefined;
119
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<(Omit<{
120
+ token: null;
121
+ user: {
122
+ id: string;
123
+ createdAt: Date;
124
+ updatedAt: Date;
125
+ email: string;
126
+ emailVerified: boolean;
127
+ name: string;
128
+ image?: string | null | undefined | undefined;
129
+ };
130
+ }, "user"> & {
131
+ user: import("better-auth/react").StripEmptyObjects<{
132
+ id: string;
133
+ createdAt: Date;
134
+ updatedAt: Date;
135
+ email: string;
136
+ emailVerified: boolean;
137
+ name: string;
138
+ image?: string | null | undefined;
139
+ }>;
140
+ }) | (Omit<{
141
+ token: string;
142
+ user: {
143
+ id: string;
144
+ createdAt: Date;
145
+ updatedAt: Date;
146
+ email: string;
147
+ emailVerified: boolean;
148
+ name: string;
149
+ image?: string | null | undefined | undefined;
150
+ };
151
+ }, "user"> & {
152
+ user: import("better-auth/react").StripEmptyObjects<{
153
+ id: string;
154
+ createdAt: Date;
155
+ updatedAt: Date;
156
+ email: string;
157
+ emailVerified: boolean;
158
+ name: string;
159
+ image?: string | null | undefined;
160
+ }>;
161
+ }), {
162
+ code?: string | undefined;
163
+ message?: string | undefined;
164
+ }, FetchOptions["throw"] extends true ? true : false>>;
165
+ };
166
+ } & {
167
+ signIn: {
168
+ email: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
169
+ email: string;
170
+ password: string;
171
+ callbackURL?: string | undefined;
172
+ rememberMe?: boolean | undefined;
173
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
174
+ email: string;
175
+ password: string;
176
+ callbackURL?: string | undefined;
177
+ rememberMe?: boolean | undefined;
178
+ } & {
179
+ fetchOptions?: FetchOptions | undefined;
180
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<Omit<{
181
+ redirect: boolean;
182
+ token: string;
183
+ url?: string | undefined;
184
+ user: {
185
+ id: string;
186
+ createdAt: Date;
187
+ updatedAt: Date;
188
+ email: string;
189
+ emailVerified: boolean;
190
+ name: string;
191
+ image?: string | null | undefined | undefined;
192
+ };
193
+ }, "user"> & {
194
+ user: import("better-auth/react").StripEmptyObjects<{
195
+ id: string;
196
+ createdAt: Date;
197
+ updatedAt: Date;
198
+ email: string;
199
+ emailVerified: boolean;
200
+ name: string;
201
+ image?: string | null | undefined;
202
+ }>;
203
+ }, {
204
+ code?: string | undefined;
205
+ message?: string | undefined;
206
+ }, FetchOptions["throw"] extends true ? true : false>>;
207
+ };
208
+ } & {
209
+ resetPassword: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
210
+ newPassword: string;
211
+ token?: string | undefined;
212
+ }> & Record<string, any>, Partial<{
213
+ token?: string | undefined;
214
+ }> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
215
+ newPassword: string;
216
+ token?: string | undefined;
217
+ } & {
218
+ fetchOptions?: FetchOptions | undefined;
219
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
220
+ status: boolean;
221
+ }, {
222
+ code?: string | undefined;
223
+ message?: string | undefined;
224
+ }, FetchOptions["throw"] extends true ? true : false>>;
225
+ } & {
226
+ verifyEmail: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<{
227
+ token: string;
228
+ callbackURL?: string | undefined;
229
+ }> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
230
+ query: {
231
+ token: string;
232
+ callbackURL?: string | undefined;
233
+ };
234
+ fetchOptions?: FetchOptions | undefined;
235
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<NonNullable<void | {
236
+ status: boolean;
237
+ }>, {
238
+ code?: string | undefined;
239
+ message?: string | undefined;
240
+ }, FetchOptions["throw"] extends true ? true : false>>;
241
+ } & {
242
+ sendVerificationEmail: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
243
+ email: string;
244
+ callbackURL?: string | undefined;
245
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
246
+ email: string;
247
+ callbackURL?: string | undefined;
248
+ } & {
249
+ fetchOptions?: FetchOptions | undefined;
250
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
251
+ status: boolean;
252
+ }, {
253
+ code?: string | undefined;
254
+ message?: string | undefined;
255
+ }, FetchOptions["throw"] extends true ? true : false>>;
256
+ } & {
257
+ changeEmail: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
258
+ newEmail: string;
259
+ callbackURL?: string | undefined;
260
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
261
+ newEmail: string;
262
+ callbackURL?: string | undefined;
263
+ } & {
264
+ fetchOptions?: FetchOptions | undefined;
265
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
266
+ status: boolean;
267
+ }, {
268
+ code?: string | undefined;
269
+ message?: string | undefined;
270
+ }, FetchOptions["throw"] extends true ? true : false>>;
271
+ } & {
272
+ changePassword: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
273
+ newPassword: string;
274
+ currentPassword: string;
275
+ revokeOtherSessions?: boolean | undefined;
276
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
277
+ newPassword: string;
278
+ currentPassword: string;
279
+ revokeOtherSessions?: boolean | undefined;
280
+ } & {
281
+ fetchOptions?: FetchOptions | undefined;
282
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<Omit<{
283
+ token: string | null;
284
+ user: {
285
+ id: string;
286
+ createdAt: Date;
287
+ updatedAt: Date;
288
+ email: string;
289
+ emailVerified: boolean;
290
+ name: string;
291
+ image?: string | null | undefined;
292
+ } & Record<string, any> & {
293
+ id: string;
294
+ createdAt: Date;
295
+ updatedAt: Date;
296
+ email: string;
297
+ emailVerified: boolean;
298
+ name: string;
299
+ image?: string | null | undefined;
300
+ };
301
+ }, "user"> & {
302
+ user: import("better-auth/react").StripEmptyObjects<{
303
+ id: string;
304
+ createdAt: Date;
305
+ updatedAt: Date;
306
+ email: string;
307
+ emailVerified: boolean;
308
+ name: string;
309
+ image?: string | null | undefined;
310
+ }>;
311
+ }, {
312
+ code?: string | undefined;
313
+ message?: string | undefined;
314
+ }, FetchOptions["throw"] extends true ? true : false>>;
315
+ } & {
316
+ updateSession: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<Partial<{}>> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<Partial<{}> & {
317
+ fetchOptions?: FetchOptions | undefined;
318
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
319
+ session: {
320
+ id: string;
321
+ createdAt: Date;
322
+ updatedAt: Date;
323
+ userId: string;
324
+ expiresAt: Date;
325
+ token: string;
326
+ ipAddress?: string | null | undefined;
327
+ userAgent?: string | null | undefined;
328
+ };
329
+ }, {
330
+ code?: string | undefined;
331
+ message?: string | undefined;
332
+ }, FetchOptions["throw"] extends true ? true : false>>;
333
+ } & {
334
+ updateUser: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<Partial<{}> & {
335
+ name?: string | undefined;
336
+ image?: string | undefined | null;
337
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<import("better-auth/dist/client/path-to-object.mjs").InferUserUpdateCtx<{}, FetchOptions>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
338
+ status: boolean;
339
+ }, {
340
+ code?: string | undefined;
341
+ message?: string | undefined;
342
+ }, FetchOptions["throw"] extends true ? true : false>>;
343
+ } & {
344
+ deleteUser: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
345
+ callbackURL?: string | undefined;
346
+ password?: string | undefined;
347
+ token?: string | undefined;
348
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
349
+ callbackURL?: string | undefined;
350
+ password?: string | undefined;
351
+ token?: string | undefined;
352
+ } & {
353
+ fetchOptions?: FetchOptions | undefined;
354
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
355
+ success: boolean;
356
+ message: string;
357
+ }, {
358
+ code?: string | undefined;
359
+ message?: string | undefined;
360
+ }, FetchOptions["throw"] extends true ? true : false>>;
361
+ } & {
362
+ requestPasswordReset: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
363
+ email: string;
364
+ redirectTo?: string | undefined;
365
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
366
+ email: string;
367
+ redirectTo?: string | undefined;
368
+ } & {
369
+ fetchOptions?: FetchOptions | undefined;
370
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
371
+ status: boolean;
372
+ message: string;
373
+ }, {
374
+ code?: string | undefined;
375
+ message?: string | undefined;
376
+ }, FetchOptions["throw"] extends true ? true : false>>;
377
+ } & {
378
+ resetPassword: {
379
+ ":token": <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<{
380
+ callbackURL: string;
381
+ }> & Record<string, any>, {
382
+ token: string;
383
+ }>>(data_0: import("better-auth/react").Prettify<{
384
+ query: {
385
+ callbackURL: string;
386
+ };
387
+ fetchOptions?: FetchOptions | undefined;
388
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<never, {
389
+ code?: string | undefined;
390
+ message?: string | undefined;
391
+ }, FetchOptions["throw"] extends true ? true : false>>;
392
+ };
393
+ } & {
394
+ listSessions: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
395
+ query?: Record<string, any> | undefined;
396
+ fetchOptions?: FetchOptions | undefined;
397
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<import("better-auth/react").Prettify<{
398
+ id: string;
399
+ createdAt: Date;
400
+ updatedAt: Date;
401
+ userId: string;
402
+ expiresAt: Date;
403
+ token: string;
404
+ ipAddress?: string | null | undefined | undefined;
405
+ userAgent?: string | null | undefined | undefined;
406
+ }>[], {
407
+ code?: string | undefined;
408
+ message?: string | undefined;
409
+ }, FetchOptions["throw"] extends true ? true : false>>;
410
+ } & {
411
+ revokeSession: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
412
+ token: string;
413
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
414
+ token: string;
415
+ } & {
416
+ fetchOptions?: FetchOptions | undefined;
417
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
418
+ status: boolean;
419
+ }, {
420
+ code?: string | undefined;
421
+ message?: string | undefined;
422
+ }, FetchOptions["throw"] extends true ? true : false>>;
423
+ } & {
424
+ revokeSessions: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
425
+ query?: Record<string, any> | undefined;
426
+ fetchOptions?: FetchOptions | undefined;
427
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
428
+ status: boolean;
429
+ }, {
430
+ code?: string | undefined;
431
+ message?: string | undefined;
432
+ }, FetchOptions["throw"] extends true ? true : false>>;
433
+ } & {
434
+ revokeOtherSessions: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
435
+ query?: Record<string, any> | undefined;
436
+ fetchOptions?: FetchOptions | undefined;
437
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
438
+ status: boolean;
439
+ }, {
440
+ code?: string | undefined;
441
+ message?: string | undefined;
442
+ }, FetchOptions["throw"] extends true ? true : false>>;
443
+ } & {
444
+ linkSocial: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
445
+ provider: unknown;
446
+ callbackURL?: string | undefined;
447
+ idToken?: {
448
+ token: string;
449
+ nonce?: string | undefined;
450
+ accessToken?: string | undefined;
451
+ refreshToken?: string | undefined;
452
+ scopes?: string[] | undefined;
453
+ } | undefined;
454
+ requestSignUp?: boolean | undefined;
455
+ scopes?: string[] | undefined;
456
+ errorCallbackURL?: string | undefined;
457
+ disableRedirect?: boolean | undefined;
458
+ additionalData?: Record<string, any> | undefined;
459
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
460
+ provider: unknown;
461
+ callbackURL?: string | undefined;
462
+ idToken?: {
463
+ token: string;
464
+ nonce?: string | undefined;
465
+ accessToken?: string | undefined;
466
+ refreshToken?: string | undefined;
467
+ scopes?: string[] | undefined;
468
+ } | undefined;
469
+ requestSignUp?: boolean | undefined;
470
+ scopes?: string[] | undefined;
471
+ errorCallbackURL?: string | undefined;
472
+ disableRedirect?: boolean | undefined;
473
+ additionalData?: Record<string, any> | undefined;
474
+ } & {
475
+ fetchOptions?: FetchOptions | undefined;
476
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
477
+ url: string;
478
+ redirect: boolean;
479
+ }, {
480
+ code?: string | undefined;
481
+ message?: string | undefined;
482
+ }, FetchOptions["throw"] extends true ? true : false>>;
483
+ } & {
484
+ listAccounts: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
485
+ query?: Record<string, any> | undefined;
486
+ fetchOptions?: FetchOptions | undefined;
487
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
488
+ scopes: string[];
489
+ id: string;
490
+ createdAt: Date;
491
+ updatedAt: Date;
492
+ userId: string;
493
+ providerId: string;
494
+ accountId: string;
495
+ }[], {
496
+ code?: string | undefined;
497
+ message?: string | undefined;
498
+ }, FetchOptions["throw"] extends true ? true : false>>;
499
+ } & {
500
+ deleteUser: {
501
+ callback: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<{
502
+ token: string;
503
+ callbackURL?: string | undefined;
504
+ }> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
505
+ query: {
506
+ token: string;
507
+ callbackURL?: string | undefined;
508
+ };
509
+ fetchOptions?: FetchOptions | undefined;
510
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
511
+ success: boolean;
512
+ message: string;
513
+ }, {
514
+ code?: string | undefined;
515
+ message?: string | undefined;
516
+ }, FetchOptions["throw"] extends true ? true : false>>;
517
+ };
518
+ } & {
519
+ unlinkAccount: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
520
+ providerId: string;
521
+ accountId?: string | undefined;
522
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
523
+ providerId: string;
524
+ accountId?: string | undefined;
525
+ } & {
526
+ fetchOptions?: FetchOptions | undefined;
527
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
528
+ status: boolean;
529
+ }, {
530
+ code?: string | undefined;
531
+ message?: string | undefined;
532
+ }, FetchOptions["throw"] extends true ? true : false>>;
533
+ } & {
534
+ refreshToken: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
535
+ providerId: string;
536
+ accountId?: string | undefined;
537
+ userId?: string | undefined;
538
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
539
+ providerId: string;
540
+ accountId?: string | undefined;
541
+ userId?: string | undefined;
542
+ } & {
543
+ fetchOptions?: FetchOptions | undefined;
544
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
545
+ accessToken: string | undefined;
546
+ refreshToken: string;
547
+ accessTokenExpiresAt: Date | undefined;
548
+ refreshTokenExpiresAt: Date | null | undefined;
549
+ scope: string | null | undefined;
550
+ idToken: string | null | undefined;
551
+ providerId: string;
552
+ accountId: string;
553
+ }, {
554
+ code?: string | undefined;
555
+ message?: string | undefined;
556
+ }, FetchOptions["throw"] extends true ? true : false>>;
557
+ } & {
558
+ getAccessToken: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
559
+ providerId: string;
560
+ accountId?: string | undefined;
561
+ userId?: string | undefined;
562
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
563
+ providerId: string;
564
+ accountId?: string | undefined;
565
+ userId?: string | undefined;
566
+ } & {
567
+ fetchOptions?: FetchOptions | undefined;
568
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
569
+ accessToken: string;
570
+ accessTokenExpiresAt: Date | undefined;
571
+ scopes: string[];
572
+ idToken: string | undefined;
573
+ }, {
574
+ code?: string | undefined;
575
+ message?: string | undefined;
576
+ }, FetchOptions["throw"] extends true ? true : false>>;
577
+ } & {
578
+ accountInfo: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<{
579
+ accountId?: string | undefined;
580
+ }> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
581
+ query?: {
582
+ accountId?: string | undefined;
583
+ } | undefined;
584
+ fetchOptions?: FetchOptions | undefined;
585
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
586
+ user: import("better-auth/*").OAuth2UserInfo;
587
+ data: Record<string, any>;
588
+ }, {
589
+ code?: string | undefined;
590
+ message?: string | undefined;
591
+ }, FetchOptions["throw"] extends true ? true : false>>;
592
+ } & {
593
+ getSession: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<{
594
+ disableCookieCache?: unknown;
595
+ disableRefresh?: unknown;
596
+ }> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
597
+ query?: {
598
+ disableCookieCache?: unknown;
599
+ disableRefresh?: unknown;
600
+ } | undefined;
601
+ fetchOptions?: FetchOptions | undefined;
602
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
603
+ user: import("better-auth/react").StripEmptyObjects<{
604
+ id: string;
605
+ createdAt: Date;
606
+ updatedAt: Date;
607
+ email: string;
608
+ emailVerified: boolean;
609
+ name: string;
610
+ image?: string | null | undefined;
611
+ }>;
612
+ session: import("better-auth/react").StripEmptyObjects<{
613
+ id: string;
614
+ createdAt: Date;
615
+ updatedAt: Date;
616
+ userId: string;
617
+ expiresAt: Date;
618
+ token: string;
619
+ ipAddress?: string | null | undefined;
620
+ userAgent?: string | null | undefined;
621
+ }>;
622
+ } | null, {
623
+ code?: string | undefined;
624
+ message?: string | undefined;
625
+ }, FetchOptions["throw"] extends true ? true : false>>;
626
+ } & {
627
+ useSession: () => {
628
+ data: {
629
+ user: import("better-auth/react").StripEmptyObjects<{
630
+ id: string;
631
+ createdAt: Date;
632
+ updatedAt: Date;
633
+ email: string;
634
+ emailVerified: boolean;
635
+ name: string;
636
+ image?: string | null | undefined;
637
+ }>;
638
+ session: import("better-auth/react").StripEmptyObjects<{
639
+ id: string;
640
+ createdAt: Date;
641
+ updatedAt: Date;
642
+ userId: string;
643
+ expiresAt: Date;
644
+ token: string;
645
+ ipAddress?: string | null | undefined;
646
+ userAgent?: string | null | undefined;
647
+ }>;
648
+ } | null;
649
+ isPending: boolean;
650
+ isRefetching: boolean;
651
+ error: import("@better-fetch/fetch").BetterFetchError | null;
652
+ refetch: (queryParams?: {
653
+ query?: import("better-auth/types").SessionQueryParams;
654
+ } | undefined) => Promise<void>;
655
+ };
656
+ $Infer: {
657
+ Session: {
658
+ user: import("better-auth/react").StripEmptyObjects<{
659
+ id: string;
660
+ createdAt: Date;
661
+ updatedAt: Date;
662
+ email: string;
663
+ emailVerified: boolean;
664
+ name: string;
665
+ image?: string | null | undefined;
666
+ }>;
667
+ session: import("better-auth/react").StripEmptyObjects<{
668
+ id: string;
669
+ createdAt: Date;
670
+ updatedAt: Date;
671
+ userId: string;
672
+ expiresAt: Date;
673
+ token: string;
674
+ ipAddress?: string | null | undefined;
675
+ userAgent?: string | null | undefined;
676
+ }>;
677
+ };
678
+ };
679
+ $fetch: import("@better-fetch/fetch").BetterFetch<{
680
+ plugins: (import("@better-fetch/fetch").BetterFetchPlugin<Record<string, any>> | {
681
+ id: string;
682
+ name: string;
683
+ hooks: {
684
+ onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): void;
685
+ };
686
+ } | {
687
+ id: string;
688
+ name: string;
689
+ hooks: {
690
+ onSuccess: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
691
+ onError: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
692
+ onRequest: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
693
+ onResponse: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
694
+ };
695
+ })[];
696
+ cache?: RequestCache | undefined;
697
+ priority?: RequestPriority | undefined;
698
+ credentials?: RequestCredentials;
699
+ headers?: (HeadersInit & (HeadersInit | {
700
+ accept: "application/json" | "text/plain" | "application/octet-stream";
701
+ "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
702
+ authorization: "Bearer" | "Basic";
703
+ })) | undefined;
704
+ integrity?: string | undefined;
705
+ keepalive?: boolean | undefined;
706
+ method: string;
707
+ mode?: RequestMode | undefined;
708
+ redirect?: RequestRedirect | undefined;
709
+ referrer?: string | undefined;
710
+ referrerPolicy?: ReferrerPolicy | undefined;
711
+ signal?: (AbortSignal | null) | undefined;
712
+ window?: null | undefined;
713
+ onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
714
+ hookOptions?: {
715
+ cloneResponse?: boolean;
716
+ } | undefined;
717
+ timeout?: number | undefined;
718
+ customFetchImpl: import("@better-fetch/fetch").FetchEsque;
719
+ baseURL: string;
720
+ throw?: boolean | undefined;
721
+ auth?: ({
722
+ type: "Bearer";
723
+ token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
724
+ } | {
725
+ type: "Basic";
726
+ username: string | (() => string | undefined) | undefined;
727
+ password: string | (() => string | undefined) | undefined;
728
+ } | {
729
+ type: "Custom";
730
+ prefix: string | (() => string | undefined) | undefined;
731
+ value: string | (() => string | undefined) | undefined;
732
+ }) | undefined;
733
+ body?: any;
734
+ query?: any;
735
+ params?: any;
736
+ duplex?: "full" | "half" | undefined;
737
+ jsonParser: (text: string) => Promise<any> | any;
738
+ retry?: import("@better-fetch/fetch").RetryOptions | undefined;
739
+ retryAttempt?: number | undefined;
740
+ output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
741
+ errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
742
+ disableValidation?: boolean | undefined;
743
+ disableSignal?: boolean | undefined;
744
+ }, unknown, unknown, {}>;
745
+ $store: {
746
+ notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
747
+ listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
748
+ atoms: Record<string, import("nanostores/atom").WritableAtom<any>>;
749
+ };
750
+ $ERROR_CODES: {
751
+ USER_NOT_FOUND: import("better-auth/*").RawError<"USER_NOT_FOUND">;
752
+ FAILED_TO_CREATE_USER: import("better-auth/*").RawError<"FAILED_TO_CREATE_USER">;
753
+ FAILED_TO_CREATE_SESSION: import("better-auth/*").RawError<"FAILED_TO_CREATE_SESSION">;
754
+ FAILED_TO_UPDATE_USER: import("better-auth/*").RawError<"FAILED_TO_UPDATE_USER">;
755
+ FAILED_TO_GET_SESSION: import("better-auth/*").RawError<"FAILED_TO_GET_SESSION">;
756
+ INVALID_PASSWORD: import("better-auth/*").RawError<"INVALID_PASSWORD">;
757
+ INVALID_EMAIL: import("better-auth/*").RawError<"INVALID_EMAIL">;
758
+ INVALID_EMAIL_OR_PASSWORD: import("better-auth/*").RawError<"INVALID_EMAIL_OR_PASSWORD">;
759
+ INVALID_USER: import("better-auth/*").RawError<"INVALID_USER">;
760
+ SOCIAL_ACCOUNT_ALREADY_LINKED: import("better-auth/*").RawError<"SOCIAL_ACCOUNT_ALREADY_LINKED">;
761
+ PROVIDER_NOT_FOUND: import("better-auth/*").RawError<"PROVIDER_NOT_FOUND">;
762
+ INVALID_TOKEN: import("better-auth/*").RawError<"INVALID_TOKEN">;
763
+ TOKEN_EXPIRED: import("better-auth/*").RawError<"TOKEN_EXPIRED">;
764
+ ID_TOKEN_NOT_SUPPORTED: import("better-auth/*").RawError<"ID_TOKEN_NOT_SUPPORTED">;
765
+ FAILED_TO_GET_USER_INFO: import("better-auth/*").RawError<"FAILED_TO_GET_USER_INFO">;
766
+ USER_EMAIL_NOT_FOUND: import("better-auth/*").RawError<"USER_EMAIL_NOT_FOUND">;
767
+ EMAIL_NOT_VERIFIED: import("better-auth/*").RawError<"EMAIL_NOT_VERIFIED">;
768
+ PASSWORD_TOO_SHORT: import("better-auth/*").RawError<"PASSWORD_TOO_SHORT">;
769
+ PASSWORD_TOO_LONG: import("better-auth/*").RawError<"PASSWORD_TOO_LONG">;
770
+ USER_ALREADY_EXISTS: import("better-auth/*").RawError<"USER_ALREADY_EXISTS">;
771
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("better-auth/*").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
772
+ EMAIL_CAN_NOT_BE_UPDATED: import("better-auth/*").RawError<"EMAIL_CAN_NOT_BE_UPDATED">;
773
+ CREDENTIAL_ACCOUNT_NOT_FOUND: import("better-auth/*").RawError<"CREDENTIAL_ACCOUNT_NOT_FOUND">;
774
+ ACCOUNT_NOT_FOUND: import("better-auth/*").RawError<"ACCOUNT_NOT_FOUND">;
775
+ SESSION_EXPIRED: import("better-auth/*").RawError<"SESSION_EXPIRED">;
776
+ FAILED_TO_UNLINK_LAST_ACCOUNT: import("better-auth/*").RawError<"FAILED_TO_UNLINK_LAST_ACCOUNT">;
777
+ USER_ALREADY_HAS_PASSWORD: import("better-auth/*").RawError<"USER_ALREADY_HAS_PASSWORD">;
778
+ CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: import("better-auth/*").RawError<"CROSS_SITE_NAVIGATION_LOGIN_BLOCKED">;
779
+ VERIFICATION_EMAIL_NOT_ENABLED: import("better-auth/*").RawError<"VERIFICATION_EMAIL_NOT_ENABLED">;
780
+ EMAIL_ALREADY_VERIFIED: import("better-auth/*").RawError<"EMAIL_ALREADY_VERIFIED">;
781
+ EMAIL_MISMATCH: import("better-auth/*").RawError<"EMAIL_MISMATCH">;
782
+ SESSION_NOT_FRESH: import("better-auth/*").RawError<"SESSION_NOT_FRESH">;
783
+ LINKED_ACCOUNT_ALREADY_EXISTS: import("better-auth/*").RawError<"LINKED_ACCOUNT_ALREADY_EXISTS">;
784
+ INVALID_ORIGIN: import("better-auth/*").RawError<"INVALID_ORIGIN">;
785
+ INVALID_CALLBACK_URL: import("better-auth/*").RawError<"INVALID_CALLBACK_URL">;
786
+ INVALID_REDIRECT_URL: import("better-auth/*").RawError<"INVALID_REDIRECT_URL">;
787
+ INVALID_ERROR_CALLBACK_URL: import("better-auth/*").RawError<"INVALID_ERROR_CALLBACK_URL">;
788
+ INVALID_NEW_USER_CALLBACK_URL: import("better-auth/*").RawError<"INVALID_NEW_USER_CALLBACK_URL">;
789
+ MISSING_OR_NULL_ORIGIN: import("better-auth/*").RawError<"MISSING_OR_NULL_ORIGIN">;
790
+ CALLBACK_URL_REQUIRED: import("better-auth/*").RawError<"CALLBACK_URL_REQUIRED">;
791
+ FAILED_TO_CREATE_VERIFICATION: import("better-auth/*").RawError<"FAILED_TO_CREATE_VERIFICATION">;
792
+ FIELD_NOT_ALLOWED: import("better-auth/*").RawError<"FIELD_NOT_ALLOWED">;
793
+ ASYNC_VALIDATION_NOT_SUPPORTED: import("better-auth/*").RawError<"ASYNC_VALIDATION_NOT_SUPPORTED">;
794
+ VALIDATION_ERROR: import("better-auth/*").RawError<"VALIDATION_ERROR">;
795
+ MISSING_FIELD: import("better-auth/*").RawError<"MISSING_FIELD">;
796
+ METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED: import("better-auth/*").RawError<"METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED">;
797
+ BODY_MUST_BE_AN_OBJECT: import("better-auth/*").RawError<"BODY_MUST_BE_AN_OBJECT">;
798
+ PASSWORD_ALREADY_SET: import("better-auth/*").RawError<"PASSWORD_ALREADY_SET">;
799
+ };
800
+ };
801
+ export declare const useSession: () => {
802
+ data: {
803
+ user: import("better-auth/react").StripEmptyObjects<{
804
+ id: string;
805
+ createdAt: Date;
806
+ updatedAt: Date;
807
+ email: string;
808
+ emailVerified: boolean;
809
+ name: string;
810
+ image?: string | null | undefined;
811
+ }>;
812
+ session: import("better-auth/react").StripEmptyObjects<{
813
+ id: string;
814
+ createdAt: Date;
815
+ updatedAt: Date;
816
+ userId: string;
817
+ expiresAt: Date;
818
+ token: string;
819
+ ipAddress?: string | null | undefined;
820
+ userAgent?: string | null | undefined;
821
+ }>;
822
+ } | null;
823
+ isPending: boolean;
824
+ isRefetching: boolean;
825
+ error: import("@better-fetch/fetch").BetterFetchError | null;
826
+ refetch: (queryParams?: {
827
+ query?: import("better-auth/types").SessionQueryParams;
828
+ } | undefined) => Promise<void>;
829
+ }, signIn: {
830
+ social: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
831
+ provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
832
+ callbackURL?: string | undefined;
833
+ newUserCallbackURL?: string | undefined;
834
+ errorCallbackURL?: string | undefined;
835
+ disableRedirect?: boolean | undefined;
836
+ idToken?: {
837
+ token: string;
838
+ nonce?: string | undefined;
839
+ accessToken?: string | undefined;
840
+ refreshToken?: string | undefined;
841
+ expiresAt?: number | undefined;
842
+ user?: {
843
+ name?: {
844
+ firstName?: string | undefined;
845
+ lastName?: string | undefined;
846
+ } | undefined;
847
+ email?: string | undefined;
848
+ } | undefined;
849
+ } | undefined;
850
+ scopes?: string[] | undefined;
851
+ requestSignUp?: boolean | undefined;
852
+ loginHint?: string | undefined;
853
+ additionalData?: Record<string, any> | undefined;
854
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
855
+ provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
856
+ callbackURL?: string | undefined;
857
+ newUserCallbackURL?: string | undefined;
858
+ errorCallbackURL?: string | undefined;
859
+ disableRedirect?: boolean | undefined;
860
+ idToken?: {
861
+ token: string;
862
+ nonce?: string | undefined;
863
+ accessToken?: string | undefined;
864
+ refreshToken?: string | undefined;
865
+ expiresAt?: number | undefined;
866
+ user?: {
867
+ name?: {
868
+ firstName?: string | undefined;
869
+ lastName?: string | undefined;
870
+ } | undefined;
871
+ email?: string | undefined;
872
+ } | undefined;
873
+ } | undefined;
874
+ scopes?: string[] | undefined;
875
+ requestSignUp?: boolean | undefined;
876
+ loginHint?: string | undefined;
877
+ additionalData?: Record<string, any> | undefined;
878
+ } & {
879
+ fetchOptions?: FetchOptions | undefined;
880
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
881
+ redirect: boolean;
882
+ url: string;
883
+ } | (Omit<{
884
+ redirect: boolean;
885
+ token: string;
886
+ url: undefined;
887
+ user: {
888
+ id: string;
889
+ createdAt: Date;
890
+ updatedAt: Date;
891
+ email: string;
892
+ emailVerified: boolean;
893
+ name: string;
894
+ image?: string | null | undefined | undefined;
895
+ };
896
+ }, "user"> & {
897
+ user: import("better-auth/react").StripEmptyObjects<{
898
+ id: string;
899
+ createdAt: Date;
900
+ updatedAt: Date;
901
+ email: string;
902
+ emailVerified: boolean;
903
+ name: string;
904
+ image?: string | null | undefined;
905
+ }>;
906
+ }), {
907
+ code?: string | undefined;
908
+ message?: string | undefined;
909
+ }, FetchOptions["throw"] extends true ? true : false>>;
910
+ } & {
911
+ email: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
912
+ email: string;
913
+ password: string;
914
+ callbackURL?: string | undefined;
915
+ rememberMe?: boolean | undefined;
916
+ }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
917
+ email: string;
918
+ password: string;
919
+ callbackURL?: string | undefined;
920
+ rememberMe?: boolean | undefined;
921
+ } & {
922
+ fetchOptions?: FetchOptions | undefined;
923
+ }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<Omit<{
924
+ redirect: boolean;
925
+ token: string;
926
+ url?: string | undefined;
927
+ user: {
928
+ id: string;
929
+ createdAt: Date;
930
+ updatedAt: Date;
931
+ email: string;
932
+ emailVerified: boolean;
933
+ name: string;
934
+ image?: string | null | undefined | undefined;
935
+ };
936
+ }, "user"> & {
937
+ user: import("better-auth/react").StripEmptyObjects<{
938
+ id: string;
939
+ createdAt: Date;
940
+ updatedAt: Date;
941
+ email: string;
942
+ emailVerified: boolean;
943
+ name: string;
944
+ image?: string | null | undefined;
945
+ }>;
946
+ }, {
947
+ code?: string | undefined;
948
+ message?: string | undefined;
949
+ }, FetchOptions["throw"] extends true ? true : false>>;
950
+ }, signOut: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth/react").Prettify<{
951
+ query?: Record<string, any> | undefined;
952
+ fetchOptions?: FetchOptions | undefined;
953
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
954
+ success: boolean;
955
+ }, {
956
+ code?: string | undefined;
957
+ message?: string | undefined;
958
+ }, FetchOptions["throw"] extends true ? true : false>>;
959
+ /**
960
+ * NextAuth-compatible useSession wrapper.
961
+ *
962
+ * Maps Better Auth's { data, error, isPending } to NextAuth's { data, status, update }.
963
+ * Drop-in replacement — no destructure changes needed in consuming components.
964
+ */
965
+ export declare function useSessionCompat(): {
966
+ data: {
967
+ user: import("better-auth/react").StripEmptyObjects<{
968
+ id: string;
969
+ createdAt: Date;
970
+ updatedAt: Date;
971
+ email: string;
972
+ emailVerified: boolean;
973
+ name: string;
974
+ image?: string | null | undefined;
975
+ }>;
976
+ expires: string;
977
+ session: import("better-auth/react").StripEmptyObjects<{
978
+ id: string;
979
+ createdAt: Date;
980
+ updatedAt: Date;
981
+ userId: string;
982
+ expiresAt: Date;
983
+ token: string;
984
+ ipAddress?: string | null | undefined;
985
+ userAgent?: string | null | undefined;
986
+ }>;
987
+ } | null;
988
+ status: "loading" | "authenticated" | "unauthenticated";
989
+ update: () => Promise<{
990
+ user: import("better-auth/react").StripEmptyObjects<{
991
+ id: string;
992
+ createdAt: Date;
993
+ updatedAt: Date;
994
+ email: string;
995
+ emailVerified: boolean;
996
+ name: string;
997
+ image?: string | null | undefined;
998
+ }>;
999
+ expires: string;
1000
+ session: import("better-auth/react").StripEmptyObjects<{
1001
+ id: string;
1002
+ createdAt: Date;
1003
+ updatedAt: Date;
1004
+ userId: string;
1005
+ expiresAt: Date;
1006
+ token: string;
1007
+ ipAddress?: string | null | undefined;
1008
+ userAgent?: string | null | undefined;
1009
+ }>;
1010
+ } | null>;
1011
+ };
1012
+ /**
1013
+ * NextAuth-compatible signOut wrapper.
1014
+ *
1015
+ * Maps NextAuth signOut({ redirect, callbackUrl }) to Better Auth.
1016
+ */
1017
+ export declare function signOutCompat(options?: {
1018
+ redirect?: boolean;
1019
+ callbackUrl?: string;
1020
+ }): Promise<void>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * Better Auth Client (Phase 3)
4
+ *
5
+ * Drop-in replacement for next-auth/react hooks and functions.
6
+ * Import from '@payez/next-mvp/client/better-auth-client'.
7
+ *
8
+ * Includes useSessionCompat() — returns NextAuth-shaped { data, status }
9
+ * so existing components don't need destructure pattern changes.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.signOut = exports.signIn = exports.useSession = exports.authClient = void 0;
13
+ exports.useSessionCompat = useSessionCompat;
14
+ exports.signOutCompat = signOutCompat;
15
+ const react_1 = require("better-auth/react");
16
+ const react_2 = require("react");
17
+ exports.authClient = (0, react_1.createAuthClient)({
18
+ // baseURL derived from BETTER_AUTH_URL or window.location.origin
19
+ });
20
+ // Convenience exports
21
+ exports.useSession = exports.authClient.useSession, exports.signIn = exports.authClient.signIn, exports.signOut = exports.authClient.signOut;
22
+ /**
23
+ * NextAuth-compatible useSession wrapper.
24
+ *
25
+ * Maps Better Auth's { data, error, isPending } to NextAuth's { data, status, update }.
26
+ * Drop-in replacement — no destructure changes needed in consuming components.
27
+ */
28
+ function useSessionCompat() {
29
+ const baSession = exports.authClient.useSession();
30
+ const status = (0, react_2.useMemo)(() => {
31
+ if (baSession.isPending)
32
+ return 'loading';
33
+ if (baSession.data)
34
+ return 'authenticated';
35
+ return 'unauthenticated';
36
+ }, [baSession.isPending, baSession.data]);
37
+ // Map Better Auth session shape to NextAuth session shape
38
+ const data = (0, react_2.useMemo)(() => {
39
+ if (!baSession.data)
40
+ return null;
41
+ return {
42
+ ...baSession.data,
43
+ user: baSession.data.user,
44
+ expires: '', // Better Auth handles expiry differently
45
+ };
46
+ }, [baSession.data]);
47
+ return {
48
+ data,
49
+ status,
50
+ update: async () => {
51
+ // Better Auth doesn't have a direct "refresh session" call.
52
+ // Force refetch by invalidating the query.
53
+ // TODO: Wire to proper session refresh when available.
54
+ return data;
55
+ },
56
+ };
57
+ }
58
+ /**
59
+ * NextAuth-compatible signOut wrapper.
60
+ *
61
+ * Maps NextAuth signOut({ redirect, callbackUrl }) to Better Auth.
62
+ */
63
+ async function signOutCompat(options) {
64
+ await exports.authClient.signOut();
65
+ if (options?.redirect !== false && options?.callbackUrl) {
66
+ window.location.href = options.callbackUrl;
67
+ }
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payez/next-mvp",
3
- "version": "3.8.2",
3
+ "version": "3.9.1",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,6 +32,11 @@
32
32
  "require": "./dist/client/index.js",
33
33
  "default": "./dist/client/index.js"
34
34
  },
35
+ "./client/better-auth-client": {
36
+ "types": "./dist/client/better-auth-client.d.ts",
37
+ "require": "./dist/client/better-auth-client.js",
38
+ "default": "./dist/client/better-auth-client.js"
39
+ },
35
40
  "./client/AuthContext": {
36
41
  "types": "./dist/client/AuthContext.d.ts",
37
42
  "require": "./dist/client/AuthContext.js",
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Better Auth Client (Phase 3)
3
+ *
4
+ * Drop-in replacement for next-auth/react hooks and functions.
5
+ * Import from '@payez/next-mvp/client/better-auth-client'.
6
+ *
7
+ * Includes useSessionCompat() — returns NextAuth-shaped { data, status }
8
+ * so existing components don't need destructure pattern changes.
9
+ */
10
+
11
+ import { createAuthClient } from 'better-auth/react';
12
+ import { useMemo } from 'react';
13
+
14
+ export const authClient = createAuthClient({
15
+ // baseURL derived from BETTER_AUTH_URL or window.location.origin
16
+ });
17
+
18
+ // Convenience exports
19
+ export const { useSession, signIn, signOut } = authClient;
20
+
21
+ /**
22
+ * NextAuth-compatible useSession wrapper.
23
+ *
24
+ * Maps Better Auth's { data, error, isPending } to NextAuth's { data, status, update }.
25
+ * Drop-in replacement — no destructure changes needed in consuming components.
26
+ */
27
+ export function useSessionCompat() {
28
+ const baSession = authClient.useSession();
29
+
30
+ const status = useMemo(() => {
31
+ if (baSession.isPending) return 'loading' as const;
32
+ if (baSession.data) return 'authenticated' as const;
33
+ return 'unauthenticated' as const;
34
+ }, [baSession.isPending, baSession.data]);
35
+
36
+ // Map Better Auth session shape to NextAuth session shape
37
+ const data = useMemo(() => {
38
+ if (!baSession.data) return null;
39
+ return {
40
+ ...baSession.data,
41
+ user: baSession.data.user,
42
+ expires: '', // Better Auth handles expiry differently
43
+ };
44
+ }, [baSession.data]);
45
+
46
+ return {
47
+ data,
48
+ status,
49
+ update: async () => {
50
+ // Better Auth doesn't have a direct "refresh session" call.
51
+ // Force refetch by invalidating the query.
52
+ // TODO: Wire to proper session refresh when available.
53
+ return data;
54
+ },
55
+ };
56
+ }
57
+
58
+ /**
59
+ * NextAuth-compatible signOut wrapper.
60
+ *
61
+ * Maps NextAuth signOut({ redirect, callbackUrl }) to Better Auth.
62
+ */
63
+ export async function signOutCompat(options?: { redirect?: boolean; callbackUrl?: string }) {
64
+ await authClient.signOut();
65
+ if (options?.redirect !== false && options?.callbackUrl) {
66
+ window.location.href = options.callbackUrl;
67
+ }
68
+ }