@payez/next-mvp 4.0.34 → 4.0.35
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/api/auth-handler.js
CHANGED
|
@@ -235,6 +235,9 @@ function createAuthHandler(options = {}) {
|
|
|
235
235
|
function needsRefresh(auth) {
|
|
236
236
|
if (!autoRefresh)
|
|
237
237
|
return false;
|
|
238
|
+
// No refresh token = nothing to refresh with, skip entirely
|
|
239
|
+
if (!auth.refreshToken)
|
|
240
|
+
return false;
|
|
238
241
|
// Check if we have token expiry information
|
|
239
242
|
const token = auth.token;
|
|
240
243
|
const expiresAt = token.accessTokenExpires || token.exp;
|
package/dist/lib/api-handler.js
CHANGED
|
@@ -184,9 +184,11 @@ class ApiHandler {
|
|
|
184
184
|
}
|
|
185
185
|
catch { /* ignore */ }
|
|
186
186
|
// Check if token needs refresh
|
|
187
|
+
// Skip entirely if there's no refresh token — nothing to refresh with
|
|
187
188
|
const thresholdMs = 5 * 60 * 1000;
|
|
188
189
|
const expires = sessionData.idpAccessTokenExpires || 0;
|
|
189
|
-
const
|
|
190
|
+
const hasRefreshToken = !!sessionData.idpRefreshToken;
|
|
191
|
+
const needsRefresh = hasRefreshToken && (!accessToken || (expires - Date.now()) <= thresholdMs);
|
|
190
192
|
if (needsRefresh) {
|
|
191
193
|
const refreshResult = await this.handleCoordinatedRefresh(req, token, sessionData, ctx);
|
|
192
194
|
if (refreshResult.blocked) {
|
package/package.json
CHANGED
package/src/api/auth-handler.ts
CHANGED
|
@@ -337,6 +337,8 @@ export function createAuthHandler(options: AuthHandlerOptions = {}) {
|
|
|
337
337
|
*/
|
|
338
338
|
function needsRefresh(auth: AuthContext): boolean {
|
|
339
339
|
if (!autoRefresh) return false;
|
|
340
|
+
// No refresh token = nothing to refresh with, skip entirely
|
|
341
|
+
if (!auth.refreshToken) return false;
|
|
340
342
|
|
|
341
343
|
// Check if we have token expiry information
|
|
342
344
|
const token = auth.token as any;
|
package/src/lib/api-handler.ts
CHANGED
|
@@ -279,9 +279,11 @@ export class ApiHandler {
|
|
|
279
279
|
} catch { /* ignore */ }
|
|
280
280
|
|
|
281
281
|
// Check if token needs refresh
|
|
282
|
+
// Skip entirely if there's no refresh token — nothing to refresh with
|
|
282
283
|
const thresholdMs = 5 * 60 * 1000;
|
|
283
284
|
const expires = sessionData.idpAccessTokenExpires || 0;
|
|
284
|
-
const
|
|
285
|
+
const hasRefreshToken = !!sessionData.idpRefreshToken;
|
|
286
|
+
const needsRefresh = hasRefreshToken && (!accessToken || (expires - Date.now()) <= thresholdMs);
|
|
285
287
|
|
|
286
288
|
if (needsRefresh) {
|
|
287
289
|
const refreshResult = await this.handleCoordinatedRefresh(req, token, sessionData, ctx);
|