@payez/next-mvp 4.0.49 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/better-auth.d.ts +122 -2
- package/dist/auth/better-auth.js +24 -2
- package/dist/client/better-auth-client.d.ts +194 -5
- package/dist/client/better-auth-client.js +3 -1
- package/dist/lib/session-store.js +21 -21
- package/dist/server/auth.d.ts +96 -25
- package/dist/server/auth.js +49 -103
- package/dist/vibe/hooks/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/auth/better-auth.ts +408 -368
- package/src/client/better-auth-client.ts +2 -0
- package/src/lib/session-store.ts +689 -689
- package/src/server/auth.ts +78 -188
- package/src/server/decode-session.ts +200 -200
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @see BETTER-AUTH-MIGRATION-SPEC.md
|
|
10
10
|
*/
|
|
11
11
|
import 'server-only';
|
|
12
|
+
import { type MagicLinkOptions } from 'better-auth/plugins/magic-link';
|
|
12
13
|
import type { IDPClientConfig } from '../lib/idp-client-config';
|
|
13
14
|
/**
|
|
14
15
|
* Better Auth social provider config shape.
|
|
@@ -22,13 +23,25 @@ export interface BetterAuthSocialProvider {
|
|
|
22
23
|
* Build Better Auth social providers from IDP config.
|
|
23
24
|
*/
|
|
24
25
|
export declare function buildBetterAuthProviders(config: IDPClientConfig): Record<string, BetterAuthSocialProvider>;
|
|
26
|
+
/**
|
|
27
|
+
* Optional configuration for `createBetterAuthInstance`.
|
|
28
|
+
*
|
|
29
|
+
* - `magicLink`: if provided, registers Better Auth's magic-link plugin.
|
|
30
|
+
* The host app supplies its own `sendMagicLink` callback — typically a
|
|
31
|
+
* fetch to its email service (e.g. ACP's `/v1/auth/magic-link/email`).
|
|
32
|
+
* Omit the `magicLink` key entirely to skip the plugin; the consuming
|
|
33
|
+
* app will not have a magic-link flow.
|
|
34
|
+
*/
|
|
35
|
+
export interface CreateBetterAuthInstanceOptions {
|
|
36
|
+
magicLink?: MagicLinkOptions;
|
|
37
|
+
}
|
|
25
38
|
/**
|
|
26
39
|
* Create Better Auth instance from IDP config.
|
|
27
40
|
*
|
|
28
41
|
* No database — runs in stateless mode with JWE cookie cache.
|
|
29
42
|
* Call after getIDPClientConfig() resolves.
|
|
30
43
|
*/
|
|
31
|
-
export declare function createBetterAuthInstance(idpConfig: IDPClientConfig): import("better-auth").Auth<{
|
|
44
|
+
export declare function createBetterAuthInstance(idpConfig: IDPClientConfig, opts?: CreateBetterAuthInstanceOptions): import("better-auth").Auth<{
|
|
32
45
|
baseURL: string;
|
|
33
46
|
secret: string;
|
|
34
47
|
socialProviders: Record<string, BetterAuthSocialProvider>;
|
|
@@ -65,7 +78,102 @@ export declare function createBetterAuthInstance(idpConfig: IDPClientConfig): im
|
|
|
65
78
|
handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>;
|
|
66
79
|
}[];
|
|
67
80
|
};
|
|
68
|
-
}
|
|
81
|
+
}, ...{
|
|
82
|
+
id: "magic-link";
|
|
83
|
+
endpoints: {
|
|
84
|
+
signInMagicLink: import("better-auth").StrictEndpoint<"/sign-in/magic-link", {
|
|
85
|
+
method: "POST";
|
|
86
|
+
requireHeaders: true;
|
|
87
|
+
body: import("better-auth").ZodObject<{
|
|
88
|
+
email: import("better-auth").ZodEmail;
|
|
89
|
+
name: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
90
|
+
callbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
91
|
+
newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
92
|
+
errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
93
|
+
metadata: import("better-auth").ZodOptional<import("better-auth").ZodRecord<import("better-auth").ZodString, import("better-auth").ZodAny>>;
|
|
94
|
+
}, import("better-auth").$strip>;
|
|
95
|
+
metadata: {
|
|
96
|
+
openapi: {
|
|
97
|
+
operationId: string;
|
|
98
|
+
description: string;
|
|
99
|
+
responses: {
|
|
100
|
+
200: {
|
|
101
|
+
description: string;
|
|
102
|
+
content: {
|
|
103
|
+
"application/json": {
|
|
104
|
+
schema: {
|
|
105
|
+
type: "object";
|
|
106
|
+
properties: {
|
|
107
|
+
status: {
|
|
108
|
+
type: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
}, {
|
|
119
|
+
status: boolean;
|
|
120
|
+
}>;
|
|
121
|
+
magicLinkVerify: import("better-auth").StrictEndpoint<"/magic-link/verify", {
|
|
122
|
+
method: "GET";
|
|
123
|
+
query: import("better-auth").ZodObject<{
|
|
124
|
+
token: import("better-auth").ZodString;
|
|
125
|
+
callbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
126
|
+
errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
127
|
+
newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
|
|
128
|
+
}, import("better-auth").$strip>;
|
|
129
|
+
use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>)[];
|
|
130
|
+
requireHeaders: true;
|
|
131
|
+
metadata: {
|
|
132
|
+
openapi: {
|
|
133
|
+
operationId: string;
|
|
134
|
+
description: string;
|
|
135
|
+
responses: {
|
|
136
|
+
200: {
|
|
137
|
+
description: string;
|
|
138
|
+
content: {
|
|
139
|
+
"application/json": {
|
|
140
|
+
schema: {
|
|
141
|
+
type: "object";
|
|
142
|
+
properties: {
|
|
143
|
+
session: {
|
|
144
|
+
$ref: string;
|
|
145
|
+
};
|
|
146
|
+
user: {
|
|
147
|
+
$ref: string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
}, {
|
|
158
|
+
token: string;
|
|
159
|
+
user: {
|
|
160
|
+
id: string;
|
|
161
|
+
createdAt: Date;
|
|
162
|
+
updatedAt: Date;
|
|
163
|
+
email: string;
|
|
164
|
+
emailVerified: boolean;
|
|
165
|
+
name: string;
|
|
166
|
+
image?: string | null | undefined;
|
|
167
|
+
};
|
|
168
|
+
}>;
|
|
169
|
+
};
|
|
170
|
+
rateLimit: {
|
|
171
|
+
pathMatcher(path: string): boolean;
|
|
172
|
+
window: number;
|
|
173
|
+
max: number;
|
|
174
|
+
}[];
|
|
175
|
+
options: MagicLinkOptions;
|
|
176
|
+
}[]];
|
|
69
177
|
}>;
|
|
70
178
|
/**
|
|
71
179
|
* Better Auth is always enabled (NextAuth removed in 4.0).
|
|
@@ -77,6 +185,18 @@ export declare function isBetterAuthEnabled(): boolean;
|
|
|
77
185
|
*/
|
|
78
186
|
declare let cachedInstance: any;
|
|
79
187
|
export { cachedInstance as __betterAuthInstance };
|
|
188
|
+
/**
|
|
189
|
+
* Configure Better Auth instance options for this process.
|
|
190
|
+
*
|
|
191
|
+
* Must be called before the first auth request — before
|
|
192
|
+
* `getBetterAuthInstance()` caches an instance. Typically called once at
|
|
193
|
+
* app startup, e.g. from Next.js `instrumentation.ts` or an equivalent
|
|
194
|
+
* server bootstrap hook.
|
|
195
|
+
*
|
|
196
|
+
* Throws if called after the instance has already been resolved: options
|
|
197
|
+
* cannot be applied retroactively.
|
|
198
|
+
*/
|
|
199
|
+
export declare function configureBetterAuth(opts: CreateBetterAuthInstanceOptions): void;
|
|
80
200
|
export declare function getBetterAuthInstance(): Promise<any>;
|
|
81
201
|
/**
|
|
82
202
|
* Get flag-gated auth handler for Next.js route.
|
package/dist/auth/better-auth.js
CHANGED
|
@@ -47,6 +47,7 @@ exports.__betterAuthInstance = void 0;
|
|
|
47
47
|
exports.buildBetterAuthProviders = buildBetterAuthProviders;
|
|
48
48
|
exports.createBetterAuthInstance = createBetterAuthInstance;
|
|
49
49
|
exports.isBetterAuthEnabled = isBetterAuthEnabled;
|
|
50
|
+
exports.configureBetterAuth = configureBetterAuth;
|
|
50
51
|
exports.getBetterAuthInstance = getBetterAuthInstance;
|
|
51
52
|
exports.getBetterAuthHandler = getBetterAuthHandler;
|
|
52
53
|
exports.exchangeOAuthForIdpTokens = exchangeOAuthForIdpTokens;
|
|
@@ -55,6 +56,7 @@ require("server-only");
|
|
|
55
56
|
const better_auth_1 = require("better-auth");
|
|
56
57
|
const next_js_1 = require("better-auth/next-js");
|
|
57
58
|
const next_js_2 = require("better-auth/next-js");
|
|
59
|
+
const magic_link_1 = require("better-auth/plugins/magic-link");
|
|
58
60
|
const idp_client_config_1 = require("../lib/idp-client-config");
|
|
59
61
|
const app_slug_1 = require("../lib/app-slug");
|
|
60
62
|
const redis_1 = require("../lib/redis");
|
|
@@ -81,7 +83,7 @@ function buildBetterAuthProviders(config) {
|
|
|
81
83
|
* No database — runs in stateless mode with JWE cookie cache.
|
|
82
84
|
* Call after getIDPClientConfig() resolves.
|
|
83
85
|
*/
|
|
84
|
-
function createBetterAuthInstance(idpConfig) {
|
|
86
|
+
function createBetterAuthInstance(idpConfig, opts = {}) {
|
|
85
87
|
const appSlug = idpConfig.clientSlug || (0, app_slug_1.getAppSlug)();
|
|
86
88
|
// Resolve base URL: BETTER_AUTH_URL env > IDP config > localhost fallback
|
|
87
89
|
// Must include /api/auth since that's where the catch-all route is mounted
|
|
@@ -149,6 +151,7 @@ function createBetterAuthInstance(idpConfig) {
|
|
|
149
151
|
},
|
|
150
152
|
plugins: [
|
|
151
153
|
(0, next_js_1.nextCookies)(),
|
|
154
|
+
...(opts.magicLink ? [(0, magic_link_1.magicLink)(opts.magicLink)] : []),
|
|
152
155
|
],
|
|
153
156
|
});
|
|
154
157
|
}
|
|
@@ -167,12 +170,31 @@ let cachedInstance = null;
|
|
|
167
170
|
exports.__betterAuthInstance = cachedInstance;
|
|
168
171
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
172
|
let initPromise = null;
|
|
173
|
+
let configuredOpts = {};
|
|
174
|
+
/**
|
|
175
|
+
* Configure Better Auth instance options for this process.
|
|
176
|
+
*
|
|
177
|
+
* Must be called before the first auth request — before
|
|
178
|
+
* `getBetterAuthInstance()` caches an instance. Typically called once at
|
|
179
|
+
* app startup, e.g. from Next.js `instrumentation.ts` or an equivalent
|
|
180
|
+
* server bootstrap hook.
|
|
181
|
+
*
|
|
182
|
+
* Throws if called after the instance has already been resolved: options
|
|
183
|
+
* cannot be applied retroactively.
|
|
184
|
+
*/
|
|
185
|
+
function configureBetterAuth(opts) {
|
|
186
|
+
if (cachedInstance) {
|
|
187
|
+
throw new Error('[BETTER_AUTH] configureBetterAuth() must run before the instance is first resolved. ' +
|
|
188
|
+
'Call it in Next.js instrumentation.ts or an equivalent startup hook.');
|
|
189
|
+
}
|
|
190
|
+
configuredOpts = opts;
|
|
191
|
+
}
|
|
170
192
|
async function getBetterAuthInstance() {
|
|
171
193
|
if (cachedInstance)
|
|
172
194
|
return cachedInstance;
|
|
173
195
|
if (!initPromise) {
|
|
174
196
|
initPromise = (0, idp_client_config_1.getIDPClientConfig)(true).then(config => {
|
|
175
|
-
const instance = createBetterAuthInstance(config);
|
|
197
|
+
const instance = createBetterAuthInstance(config, configuredOpts);
|
|
176
198
|
exports.__betterAuthInstance = cachedInstance = instance;
|
|
177
199
|
console.log('[BETTER_AUTH] Instance created for', config.clientSlug || config.clientId);
|
|
178
200
|
return instance;
|
|
@@ -7,9 +7,75 @@
|
|
|
7
7
|
* components written against the legacy hook don't need destructure changes.
|
|
8
8
|
*/
|
|
9
9
|
export declare const authClient: {
|
|
10
|
+
signIn: {
|
|
11
|
+
magicLink: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
12
|
+
email: string;
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
callbackURL?: string | undefined;
|
|
15
|
+
newUserCallbackURL?: string | undefined;
|
|
16
|
+
errorCallbackURL?: string | undefined;
|
|
17
|
+
metadata?: Record<string, any> | undefined;
|
|
18
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
19
|
+
email: string;
|
|
20
|
+
name?: string | undefined;
|
|
21
|
+
callbackURL?: string | undefined;
|
|
22
|
+
newUserCallbackURL?: string | undefined;
|
|
23
|
+
errorCallbackURL?: string | undefined;
|
|
24
|
+
metadata?: Record<string, any> | undefined;
|
|
25
|
+
} & {
|
|
26
|
+
fetchOptions?: FetchOptions | undefined;
|
|
27
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
|
|
28
|
+
status: boolean;
|
|
29
|
+
}, {
|
|
30
|
+
code?: string | undefined;
|
|
31
|
+
message?: string | undefined;
|
|
32
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
33
|
+
};
|
|
34
|
+
} & {
|
|
35
|
+
magicLink: {
|
|
36
|
+
verify: <FetchOptions extends import("@better-auth/core").ClientFetchOption<never, Partial<{
|
|
37
|
+
token: string;
|
|
38
|
+
callbackURL?: string | undefined;
|
|
39
|
+
errorCallbackURL?: string | undefined;
|
|
40
|
+
newUserCallbackURL?: string | undefined;
|
|
41
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
42
|
+
query: {
|
|
43
|
+
token: string;
|
|
44
|
+
callbackURL?: string | undefined;
|
|
45
|
+
errorCallbackURL?: string | undefined;
|
|
46
|
+
newUserCallbackURL?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
fetchOptions?: FetchOptions | undefined;
|
|
49
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<Omit<{
|
|
50
|
+
token: string;
|
|
51
|
+
user: {
|
|
52
|
+
id: string;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
email: string;
|
|
56
|
+
emailVerified: boolean;
|
|
57
|
+
name: string;
|
|
58
|
+
image?: string | null | undefined;
|
|
59
|
+
};
|
|
60
|
+
}, "user"> & {
|
|
61
|
+
user: import("better-auth/react").StripEmptyObjects<{
|
|
62
|
+
id: string;
|
|
63
|
+
createdAt: Date;
|
|
64
|
+
updatedAt: Date;
|
|
65
|
+
email: string;
|
|
66
|
+
emailVerified: boolean;
|
|
67
|
+
name: string;
|
|
68
|
+
image?: string | null | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
}, {
|
|
71
|
+
code?: string | undefined;
|
|
72
|
+
message?: string | undefined;
|
|
73
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
74
|
+
};
|
|
75
|
+
} & {
|
|
10
76
|
signIn: {
|
|
11
77
|
social: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
12
|
-
provider: "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "
|
|
78
|
+
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";
|
|
13
79
|
callbackURL?: string | undefined;
|
|
14
80
|
newUserCallbackURL?: string | undefined;
|
|
15
81
|
errorCallbackURL?: string | undefined;
|
|
@@ -33,7 +99,7 @@ export declare const authClient: {
|
|
|
33
99
|
loginHint?: string | undefined;
|
|
34
100
|
additionalData?: Record<string, any> | undefined;
|
|
35
101
|
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
36
|
-
provider: "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "
|
|
102
|
+
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";
|
|
37
103
|
callbackURL?: string | undefined;
|
|
38
104
|
newUserCallbackURL?: string | undefined;
|
|
39
105
|
errorCallbackURL?: string | undefined;
|
|
@@ -333,7 +399,107 @@ export declare const authClient: {
|
|
|
333
399
|
updateUser: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<Partial<{}> & {
|
|
334
400
|
name?: string | undefined;
|
|
335
401
|
image?: string | undefined | null;
|
|
336
|
-
}> & 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<{
|
|
402
|
+
}> & 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<{
|
|
403
|
+
plugins: {
|
|
404
|
+
id: "magic-link";
|
|
405
|
+
$InferServerPlugin: ReturnType<(options: import("better-auth/plugins/magic-link").MagicLinkOptions) => {
|
|
406
|
+
id: "magic-link";
|
|
407
|
+
endpoints: {
|
|
408
|
+
signInMagicLink: import("better-call").StrictEndpoint<"/sign-in/magic-link", {
|
|
409
|
+
method: "POST";
|
|
410
|
+
requireHeaders: true;
|
|
411
|
+
body: import("zod").ZodObject<{
|
|
412
|
+
email: import("zod").ZodEmail;
|
|
413
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
414
|
+
callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
415
|
+
newUserCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
416
|
+
errorCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
417
|
+
metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
418
|
+
}, import("better-auth/*").$strip>;
|
|
419
|
+
metadata: {
|
|
420
|
+
openapi: {
|
|
421
|
+
operationId: string;
|
|
422
|
+
description: string;
|
|
423
|
+
responses: {
|
|
424
|
+
200: {
|
|
425
|
+
description: string;
|
|
426
|
+
content: {
|
|
427
|
+
"application/json": {
|
|
428
|
+
schema: {
|
|
429
|
+
type: "object";
|
|
430
|
+
properties: {
|
|
431
|
+
status: {
|
|
432
|
+
type: string;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
}, {
|
|
443
|
+
status: boolean;
|
|
444
|
+
}>;
|
|
445
|
+
magicLinkVerify: import("better-call").StrictEndpoint<"/magic-link/verify", {
|
|
446
|
+
method: "GET";
|
|
447
|
+
query: import("zod").ZodObject<{
|
|
448
|
+
token: import("zod").ZodString;
|
|
449
|
+
callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
450
|
+
errorCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
451
|
+
newUserCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
452
|
+
}, import("better-auth/*").$strip>;
|
|
453
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
454
|
+
requireHeaders: true;
|
|
455
|
+
metadata: {
|
|
456
|
+
openapi: {
|
|
457
|
+
operationId: string;
|
|
458
|
+
description: string;
|
|
459
|
+
responses: {
|
|
460
|
+
200: {
|
|
461
|
+
description: string;
|
|
462
|
+
content: {
|
|
463
|
+
"application/json": {
|
|
464
|
+
schema: {
|
|
465
|
+
type: "object";
|
|
466
|
+
properties: {
|
|
467
|
+
session: {
|
|
468
|
+
$ref: string;
|
|
469
|
+
};
|
|
470
|
+
user: {
|
|
471
|
+
$ref: string;
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
}, {
|
|
482
|
+
token: string;
|
|
483
|
+
user: {
|
|
484
|
+
id: string;
|
|
485
|
+
createdAt: Date;
|
|
486
|
+
updatedAt: Date;
|
|
487
|
+
email: string;
|
|
488
|
+
emailVerified: boolean;
|
|
489
|
+
name: string;
|
|
490
|
+
image?: string | null | undefined;
|
|
491
|
+
};
|
|
492
|
+
}>;
|
|
493
|
+
};
|
|
494
|
+
rateLimit: {
|
|
495
|
+
pathMatcher(path: string): boolean;
|
|
496
|
+
window: number;
|
|
497
|
+
max: number;
|
|
498
|
+
}[];
|
|
499
|
+
options: import("better-auth/plugins/magic-link").MagicLinkOptions;
|
|
500
|
+
}>;
|
|
501
|
+
}[];
|
|
502
|
+
}, FetchOptions>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
|
|
337
503
|
status: boolean;
|
|
338
504
|
}, {
|
|
339
505
|
code?: string | undefined;
|
|
@@ -826,8 +992,31 @@ export declare const useSession: () => {
|
|
|
826
992
|
query?: import("better-auth/types").SessionQueryParams;
|
|
827
993
|
} | undefined) => Promise<void>;
|
|
828
994
|
}, signIn: {
|
|
995
|
+
magicLink: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
996
|
+
email: string;
|
|
997
|
+
name?: string | undefined;
|
|
998
|
+
callbackURL?: string | undefined;
|
|
999
|
+
newUserCallbackURL?: string | undefined;
|
|
1000
|
+
errorCallbackURL?: string | undefined;
|
|
1001
|
+
metadata?: Record<string, any> | undefined;
|
|
1002
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
1003
|
+
email: string;
|
|
1004
|
+
name?: string | undefined;
|
|
1005
|
+
callbackURL?: string | undefined;
|
|
1006
|
+
newUserCallbackURL?: string | undefined;
|
|
1007
|
+
errorCallbackURL?: string | undefined;
|
|
1008
|
+
metadata?: Record<string, any> | undefined;
|
|
1009
|
+
} & {
|
|
1010
|
+
fetchOptions?: FetchOptions | undefined;
|
|
1011
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
|
|
1012
|
+
status: boolean;
|
|
1013
|
+
}, {
|
|
1014
|
+
code?: string | undefined;
|
|
1015
|
+
message?: string | undefined;
|
|
1016
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
1017
|
+
} & {
|
|
829
1018
|
social: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
830
|
-
provider: "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "
|
|
1019
|
+
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";
|
|
831
1020
|
callbackURL?: string | undefined;
|
|
832
1021
|
newUserCallbackURL?: string | undefined;
|
|
833
1022
|
errorCallbackURL?: string | undefined;
|
|
@@ -851,7 +1040,7 @@ export declare const useSession: () => {
|
|
|
851
1040
|
loginHint?: string | undefined;
|
|
852
1041
|
additionalData?: Record<string, any> | undefined;
|
|
853
1042
|
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth/react").Prettify<{
|
|
854
|
-
provider: "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "
|
|
1043
|
+
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";
|
|
855
1044
|
callbackURL?: string | undefined;
|
|
856
1045
|
newUserCallbackURL?: string | undefined;
|
|
857
1046
|
errorCallbackURL?: string | undefined;
|
|
@@ -12,9 +12,11 @@ exports.signOut = exports.signIn = exports.useSession = exports.authClient = voi
|
|
|
12
12
|
exports.useSessionCompat = useSessionCompat;
|
|
13
13
|
exports.signOutCompat = signOutCompat;
|
|
14
14
|
const react_1 = require("better-auth/react");
|
|
15
|
+
const plugins_1 = require("better-auth/client/plugins");
|
|
15
16
|
const react_2 = require("react");
|
|
16
17
|
exports.authClient = (0, react_1.createAuthClient)({
|
|
17
|
-
// baseURL derived from BETTER_AUTH_URL or window.location.origin
|
|
18
|
+
// baseURL derived from BETTER_AUTH_URL or window.location.origin
|
|
19
|
+
plugins: [(0, plugins_1.magicLinkClient)()],
|
|
18
20
|
});
|
|
19
21
|
// Convenience exports
|
|
20
22
|
exports.useSession = exports.authClient.useSession, exports.signIn = exports.authClient.signIn, exports.signOut = exports.authClient.signOut;
|
|
@@ -482,27 +482,27 @@ async function releaseRefreshLock(sessionToken, requestId, lockVersion) {
|
|
|
482
482
|
const lockKey = getRefreshLockKey(sessionToken);
|
|
483
483
|
try {
|
|
484
484
|
// Lua script for atomic lock validation and release
|
|
485
|
-
const luaScript = `
|
|
486
|
-
local lockKey = KEYS[1]
|
|
487
|
-
local expectedRequestId = ARGV[1]
|
|
488
|
-
local expectedVersion = ARGV[2]
|
|
489
|
-
|
|
490
|
-
local lockData = redis.call('GET', lockKey)
|
|
491
|
-
if not lockData then
|
|
492
|
-
return 0 -- Lock doesn't exist
|
|
493
|
-
end
|
|
494
|
-
|
|
495
|
-
local lockInfo = cjson.decode(lockData)
|
|
496
|
-
if lockInfo.acquiredBy == expectedRequestId then
|
|
497
|
-
if not expectedVersion or expectedVersion == '' or tostring(lockInfo.lockVersion) == expectedVersion then
|
|
498
|
-
redis.call('DEL', lockKey)
|
|
499
|
-
return 1 -- Successfully released
|
|
500
|
-
else
|
|
501
|
-
return -2 -- Version mismatch
|
|
502
|
-
end
|
|
503
|
-
else
|
|
504
|
-
return -1 -- Wrong owner
|
|
505
|
-
end
|
|
485
|
+
const luaScript = `
|
|
486
|
+
local lockKey = KEYS[1]
|
|
487
|
+
local expectedRequestId = ARGV[1]
|
|
488
|
+
local expectedVersion = ARGV[2]
|
|
489
|
+
|
|
490
|
+
local lockData = redis.call('GET', lockKey)
|
|
491
|
+
if not lockData then
|
|
492
|
+
return 0 -- Lock doesn't exist
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
local lockInfo = cjson.decode(lockData)
|
|
496
|
+
if lockInfo.acquiredBy == expectedRequestId then
|
|
497
|
+
if not expectedVersion or expectedVersion == '' or tostring(lockInfo.lockVersion) == expectedVersion then
|
|
498
|
+
redis.call('DEL', lockKey)
|
|
499
|
+
return 1 -- Successfully released
|
|
500
|
+
else
|
|
501
|
+
return -2 -- Version mismatch
|
|
502
|
+
end
|
|
503
|
+
else
|
|
504
|
+
return -1 -- Wrong owner
|
|
505
|
+
end
|
|
506
506
|
`;
|
|
507
507
|
const result = await redis_1.default.eval(luaScript, 1, lockKey, requestId, lockVersion ? lockVersion.toString() : '');
|
|
508
508
|
if (result === 1) {
|