@payez/next-mvp 4.0.39 → 4.0.40
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.
|
@@ -84,27 +84,33 @@ async function getTokenTestAware(req) {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
// Fallback: NextAuth JWT cookie (for sites still on NextAuth like localhost.api.payez.net)
|
|
87
|
-
// Use
|
|
87
|
+
// Use eval'd require to bypass bundler analysis entirely
|
|
88
88
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
let nextAuthJwt = null;
|
|
90
|
+
try {
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-eval
|
|
92
|
+
const dynamicRequire = eval('require');
|
|
93
|
+
nextAuthJwt = dynamicRequire('next-auth/jwt');
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
logger_1.logger.debug('[GET_TOKEN] next-auth/jwt not installed in consumer');
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
92
99
|
if (nextAuthJwt?.getToken) {
|
|
93
100
|
const { resolveNextAuthSecret } = await Promise.resolve().then(() => __importStar(require('./nextauth-secret')));
|
|
94
101
|
const secret = await resolveNextAuthSecret();
|
|
95
|
-
// Use the app-slug-prefixed cookie name (e.g., payez_idp_admin_web.session-token)
|
|
96
102
|
const cookieName = (0, app_slug_1.getSessionCookieName)();
|
|
103
|
+
logger_1.logger.info('[GET_TOKEN] Trying NextAuth fallback', { cookieName });
|
|
97
104
|
const nextAuthToken = await nextAuthJwt.getToken({
|
|
98
105
|
req,
|
|
99
106
|
secret,
|
|
100
107
|
cookieName,
|
|
101
|
-
secureCookie: false,
|
|
108
|
+
secureCookie: false,
|
|
102
109
|
});
|
|
103
110
|
if (nextAuthToken) {
|
|
104
|
-
logger_1.logger.
|
|
111
|
+
logger_1.logger.info('[GET_TOKEN] Resolved via NextAuth JWT fallback');
|
|
105
112
|
return nextAuthToken;
|
|
106
113
|
}
|
|
107
|
-
// Try with the secure cookie name as a second attempt
|
|
108
114
|
const { getSecureSessionCookieName } = await Promise.resolve().then(() => __importStar(require('./app-slug')));
|
|
109
115
|
const secureCookieName = getSecureSessionCookieName();
|
|
110
116
|
const secureToken = await nextAuthJwt.getToken({
|
|
@@ -114,14 +120,14 @@ async function getTokenTestAware(req) {
|
|
|
114
120
|
secureCookie: true,
|
|
115
121
|
});
|
|
116
122
|
if (secureToken) {
|
|
117
|
-
logger_1.logger.
|
|
123
|
+
logger_1.logger.info('[GET_TOKEN] Resolved via NextAuth JWT fallback (secure)');
|
|
118
124
|
return secureToken;
|
|
119
125
|
}
|
|
120
|
-
logger_1.logger.
|
|
126
|
+
logger_1.logger.warn('[GET_TOKEN] NextAuth getToken returned null for both cookie names', { cookieName, secureCookieName });
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
catch (error) {
|
|
124
|
-
logger_1.logger.
|
|
130
|
+
logger_1.logger.warn('[GET_TOKEN] NextAuth fallback failed', { error: error instanceof Error ? error.message : String(error) });
|
|
125
131
|
}
|
|
126
132
|
return null;
|
|
127
133
|
}
|
package/package.json
CHANGED
|
@@ -40,27 +40,32 @@ export async function getTokenTestAware(req: NextRequest): Promise<any> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// Fallback: NextAuth JWT cookie (for sites still on NextAuth like localhost.api.payez.net)
|
|
43
|
-
// Use
|
|
43
|
+
// Use eval'd require to bypass bundler analysis entirely
|
|
44
44
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
let nextAuthJwt: any = null;
|
|
46
|
+
try {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-eval
|
|
48
|
+
const dynamicRequire = eval('require') as NodeRequire;
|
|
49
|
+
nextAuthJwt = dynamicRequire('next-auth/jwt');
|
|
50
|
+
} catch {
|
|
51
|
+
logger.debug('[GET_TOKEN] next-auth/jwt not installed in consumer');
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
48
54
|
if (nextAuthJwt?.getToken) {
|
|
49
55
|
const { resolveNextAuthSecret } = await import('./nextauth-secret');
|
|
50
56
|
const secret = await resolveNextAuthSecret();
|
|
51
|
-
// Use the app-slug-prefixed cookie name (e.g., payez_idp_admin_web.session-token)
|
|
52
57
|
const cookieName = getSessionCookieName();
|
|
58
|
+
logger.info('[GET_TOKEN] Trying NextAuth fallback', { cookieName });
|
|
53
59
|
const nextAuthToken = await nextAuthJwt.getToken({
|
|
54
60
|
req,
|
|
55
61
|
secret,
|
|
56
62
|
cookieName,
|
|
57
|
-
secureCookie: false,
|
|
63
|
+
secureCookie: false,
|
|
58
64
|
});
|
|
59
65
|
if (nextAuthToken) {
|
|
60
|
-
logger.
|
|
66
|
+
logger.info('[GET_TOKEN] Resolved via NextAuth JWT fallback');
|
|
61
67
|
return nextAuthToken;
|
|
62
68
|
}
|
|
63
|
-
// Try with the secure cookie name as a second attempt
|
|
64
69
|
const { getSecureSessionCookieName } = await import('./app-slug');
|
|
65
70
|
const secureCookieName = getSecureSessionCookieName();
|
|
66
71
|
const secureToken = await nextAuthJwt.getToken({
|
|
@@ -70,13 +75,13 @@ export async function getTokenTestAware(req: NextRequest): Promise<any> {
|
|
|
70
75
|
secureCookie: true,
|
|
71
76
|
});
|
|
72
77
|
if (secureToken) {
|
|
73
|
-
logger.
|
|
78
|
+
logger.info('[GET_TOKEN] Resolved via NextAuth JWT fallback (secure)');
|
|
74
79
|
return secureToken;
|
|
75
80
|
}
|
|
76
|
-
logger.
|
|
81
|
+
logger.warn('[GET_TOKEN] NextAuth getToken returned null for both cookie names', { cookieName, secureCookieName });
|
|
77
82
|
}
|
|
78
83
|
} catch (error) {
|
|
79
|
-
logger.
|
|
84
|
+
logger.warn('[GET_TOKEN] NextAuth fallback failed', { error: error instanceof Error ? error.message : String(error) });
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
return null;
|