@payez/next-mvp 4.0.14 → 4.0.15
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.
|
@@ -99,16 +99,30 @@ async function tryBetterAuthSession(requestCookies) {
|
|
|
99
99
|
if (!result?.session || !result?.user) {
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
|
-
//
|
|
102
|
+
// Read IDP tokens from BA Redis session (stored by post-login hook)
|
|
103
|
+
let idpTokens = null;
|
|
104
|
+
try {
|
|
105
|
+
const { getRedis } = await Promise.resolve().then(() => __importStar(require('../lib/redis')));
|
|
106
|
+
const { getAppSlug } = await Promise.resolve().then(() => __importStar(require('../lib/app-slug')));
|
|
107
|
+
const baKey = `ba:${getAppSlug()}:${result.session.token}`;
|
|
108
|
+
const baRaw = await getRedis().get(baKey);
|
|
109
|
+
if (baRaw) {
|
|
110
|
+
const baData = JSON.parse(baRaw);
|
|
111
|
+
idpTokens = baData.idpTokens;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch { /* Redis unavailable */ }
|
|
115
|
+
// Map Better Auth session + IDP tokens to SessionData
|
|
103
116
|
const sessionData = {
|
|
104
|
-
userId: result.user.id || '',
|
|
105
|
-
email: result.user.email || '',
|
|
106
|
-
name: result.user.name || undefined,
|
|
107
|
-
roles: [],
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
userId: idpTokens?.userId || result.user.id || '',
|
|
118
|
+
email: idpTokens?.email || result.user.email || '',
|
|
119
|
+
name: idpTokens?.name || result.user.name || undefined,
|
|
120
|
+
roles: idpTokens?.roles || [],
|
|
121
|
+
idpAccessToken: idpTokens?.idpAccessToken,
|
|
122
|
+
idpRefreshToken: idpTokens?.idpRefreshToken,
|
|
123
|
+
idpAccessTokenExpires: idpTokens?.idpAccessTokenExpires
|
|
124
|
+
|| (result.session.expiresAt ? new Date(result.session.expiresAt).getTime() : Date.now() + 24 * 60 * 60 * 1000),
|
|
125
|
+
mfaVerified: true,
|
|
112
126
|
oauthProvider: 'google',
|
|
113
127
|
};
|
|
114
128
|
const jwtPayload = {
|
package/package.json
CHANGED
|
@@ -75,16 +75,30 @@ async function tryBetterAuthSession(
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
//
|
|
78
|
+
// Read IDP tokens from BA Redis session (stored by post-login hook)
|
|
79
|
+
let idpTokens: any = null;
|
|
80
|
+
try {
|
|
81
|
+
const { getRedis } = await import('../lib/redis');
|
|
82
|
+
const { getAppSlug } = await import('../lib/app-slug');
|
|
83
|
+
const baKey = `ba:${getAppSlug()}:${result.session.token}`;
|
|
84
|
+
const baRaw = await getRedis().get(baKey);
|
|
85
|
+
if (baRaw) {
|
|
86
|
+
const baData = JSON.parse(baRaw);
|
|
87
|
+
idpTokens = baData.idpTokens;
|
|
88
|
+
}
|
|
89
|
+
} catch { /* Redis unavailable */ }
|
|
90
|
+
|
|
91
|
+
// Map Better Auth session + IDP tokens to SessionData
|
|
79
92
|
const sessionData: SessionData = {
|
|
80
|
-
userId: result.user.id || '',
|
|
81
|
-
email: result.user.email || '',
|
|
82
|
-
name: result.user.name || undefined,
|
|
83
|
-
roles: [],
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
userId: idpTokens?.userId || result.user.id || '',
|
|
94
|
+
email: idpTokens?.email || result.user.email || '',
|
|
95
|
+
name: idpTokens?.name || result.user.name || undefined,
|
|
96
|
+
roles: idpTokens?.roles || [],
|
|
97
|
+
idpAccessToken: idpTokens?.idpAccessToken,
|
|
98
|
+
idpRefreshToken: idpTokens?.idpRefreshToken,
|
|
99
|
+
idpAccessTokenExpires: idpTokens?.idpAccessTokenExpires
|
|
100
|
+
|| (result.session.expiresAt ? new Date(result.session.expiresAt).getTime() : Date.now() + 24 * 60 * 60 * 1000),
|
|
101
|
+
mfaVerified: true,
|
|
88
102
|
oauthProvider: 'google',
|
|
89
103
|
};
|
|
90
104
|
|