@payez/next-mvp 4.0.7 → 4.0.8
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.
|
@@ -33,11 +33,15 @@ export declare function createBetterAuthInstance(idpConfig: IDPClientConfig): im
|
|
|
33
33
|
secret: string;
|
|
34
34
|
socialProviders: Record<string, BetterAuthSocialProvider>;
|
|
35
35
|
trustedOrigins: string[];
|
|
36
|
+
secondaryStorage: {
|
|
37
|
+
get: (key: string) => Promise<string | null>;
|
|
38
|
+
set: (key: string, value: string, ttl?: number) => Promise<void>;
|
|
39
|
+
delete: (key: string) => Promise<void>;
|
|
40
|
+
};
|
|
36
41
|
session: {
|
|
37
42
|
cookieCache: {
|
|
38
43
|
enabled: true;
|
|
39
44
|
maxAge: number;
|
|
40
|
-
refreshCache: true;
|
|
41
45
|
};
|
|
42
46
|
};
|
|
43
47
|
advanced: {
|
package/dist/auth/better-auth.js
CHANGED
|
@@ -22,6 +22,7 @@ const next_js_1 = require("better-auth/next-js");
|
|
|
22
22
|
const next_js_2 = require("better-auth/next-js");
|
|
23
23
|
const idp_client_config_1 = require("../lib/idp-client-config");
|
|
24
24
|
const app_slug_1 = require("../lib/app-slug");
|
|
25
|
+
const redis_1 = require("../lib/redis");
|
|
25
26
|
/**
|
|
26
27
|
* Build Better Auth social providers from IDP config.
|
|
27
28
|
*/
|
|
@@ -63,13 +64,39 @@ function createBetterAuthInstance(idpConfig) {
|
|
|
63
64
|
'http://localhost:3400',
|
|
64
65
|
'http://localhost:3600',
|
|
65
66
|
],
|
|
66
|
-
//
|
|
67
|
-
|
|
67
|
+
// Redis-backed session storage via secondaryStorage
|
|
68
|
+
secondaryStorage: {
|
|
69
|
+
get: async (key) => {
|
|
70
|
+
try {
|
|
71
|
+
return await (0, redis_1.getRedis)().get(`ba:${appSlug}:${key}`);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
set: async (key, value, ttl) => {
|
|
78
|
+
try {
|
|
79
|
+
const redis = (0, redis_1.getRedis)();
|
|
80
|
+
if (ttl) {
|
|
81
|
+
await redis.setex(`ba:${appSlug}:${key}`, ttl, value);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
await redis.setex(`ba:${appSlug}:${key}`, 7 * 24 * 60 * 60, value);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch { /* Redis unavailable — cookie cache still works */ }
|
|
88
|
+
},
|
|
89
|
+
delete: async (key) => {
|
|
90
|
+
try {
|
|
91
|
+
await (0, redis_1.getRedis)().del(`ba:${appSlug}:${key}`);
|
|
92
|
+
}
|
|
93
|
+
catch { /* ignore */ }
|
|
94
|
+
},
|
|
95
|
+
},
|
|
68
96
|
session: {
|
|
69
97
|
cookieCache: {
|
|
70
98
|
enabled: true,
|
|
71
99
|
maxAge: 300,
|
|
72
|
-
refreshCache: true,
|
|
73
100
|
},
|
|
74
101
|
},
|
|
75
102
|
// Cookie prefix must match slim-middleware expectations ({slug}.session-token)
|
package/dist/server/auth.d.ts
CHANGED
|
@@ -16,11 +16,15 @@ export declare function getAuthInstance(): Promise<import("better-auth/types").A
|
|
|
16
16
|
secret: string;
|
|
17
17
|
socialProviders: Record<string, import("../auth/better-auth").BetterAuthSocialProvider>;
|
|
18
18
|
trustedOrigins: string[];
|
|
19
|
+
secondaryStorage: {
|
|
20
|
+
get: (key: string) => Promise<string | null>;
|
|
21
|
+
set: (key: string, value: string, ttl?: number) => Promise<void>;
|
|
22
|
+
delete: (key: string) => Promise<void>;
|
|
23
|
+
};
|
|
19
24
|
session: {
|
|
20
25
|
cookieCache: {
|
|
21
26
|
enabled: true;
|
|
22
27
|
maxAge: number;
|
|
23
|
-
refreshCache: true;
|
|
24
28
|
};
|
|
25
29
|
};
|
|
26
30
|
advanced: {
|
package/package.json
CHANGED
package/src/auth/better-auth.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { toNextJsHandler } from 'better-auth/next-js';
|
|
|
16
16
|
import type { IDPClientConfig } from '../lib/idp-client-config';
|
|
17
17
|
import { getIDPClientConfig } from '../lib/idp-client-config';
|
|
18
18
|
import { getAppSlug } from '../lib/app-slug';
|
|
19
|
+
import { getRedis } from '../lib/redis';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Better Auth social provider config shape.
|
|
@@ -76,13 +77,34 @@ export function createBetterAuthInstance(idpConfig: IDPClientConfig) {
|
|
|
76
77
|
'http://localhost:3600',
|
|
77
78
|
],
|
|
78
79
|
|
|
79
|
-
//
|
|
80
|
-
|
|
80
|
+
// Redis-backed session storage via secondaryStorage
|
|
81
|
+
secondaryStorage: {
|
|
82
|
+
get: async (key: string) => {
|
|
83
|
+
try {
|
|
84
|
+
return await getRedis().get(`ba:${appSlug}:${key}`);
|
|
85
|
+
} catch { return null; }
|
|
86
|
+
},
|
|
87
|
+
set: async (key: string, value: string, ttl?: number) => {
|
|
88
|
+
try {
|
|
89
|
+
const redis = getRedis();
|
|
90
|
+
if (ttl) {
|
|
91
|
+
await redis.setex(`ba:${appSlug}:${key}`, ttl, value);
|
|
92
|
+
} else {
|
|
93
|
+
await redis.setex(`ba:${appSlug}:${key}`, 7 * 24 * 60 * 60, value);
|
|
94
|
+
}
|
|
95
|
+
} catch { /* Redis unavailable — cookie cache still works */ }
|
|
96
|
+
},
|
|
97
|
+
delete: async (key: string) => {
|
|
98
|
+
try {
|
|
99
|
+
await getRedis().del(`ba:${appSlug}:${key}`);
|
|
100
|
+
} catch { /* ignore */ }
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
|
|
81
104
|
session: {
|
|
82
105
|
cookieCache: {
|
|
83
106
|
enabled: true,
|
|
84
107
|
maxAge: 300,
|
|
85
|
-
refreshCache: true,
|
|
86
108
|
},
|
|
87
109
|
},
|
|
88
110
|
|