cloudflare-next-intl 0.8.26 → 0.8.28

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.
@@ -374,11 +374,28 @@ export default async function updateSession(request, baseResponse, locale, rebui
374
374
  if (!hintConfirms && !refreshedToken) {
375
375
  const refreshToken = request.cookies.get(refreshTokenCookieName)?.value;
376
376
  if (refreshToken) {
377
- const result = await refreshIdToken(fa.apiKey, refreshToken);
377
+ // `skipCache`: the cached entry is what produced the very
378
+ // token whose claim is in question, so a normal refresh can
379
+ // hand back that same token and "confirm" nothing. Only a
380
+ // genuinely newly-minted token carries information here.
381
+ const previousToken = token;
382
+ const result = await refreshIdToken(fa.apiKey, refreshToken, { skipCache: true });
378
383
  if (result.status === 'refreshed') {
379
384
  refreshedToken = { idToken: result.idToken, refreshToken: result.refreshToken };
380
385
  token = refreshedToken.idToken;
381
- unverifiedEmail = decodeJwtPayload(token)?.email_verified === false;
386
+ // Redirecting to verifyEmailPath on a claim this refresh
387
+ // did not actually re-confirm is what caused an infinite
388
+ // loop: the destination page resolves the same user as
389
+ // VERIFIED via `getAuthUser()` (`initializeServerApp`
390
+ // reads live Auth-service state, not this frozen claim)
391
+ // and redirects straight back home. So only trust the
392
+ // claim when this mint genuinely re-stated it — the token
393
+ // changed — and never against a hint that already
394
+ // observed verification live.
395
+ const reconfirmed = result.idToken !== previousToken;
396
+ unverifiedEmail = hint !== 'true'
397
+ && reconfirmed
398
+ && decodeJwtPayload(token)?.email_verified === false;
382
399
  }
383
400
  else if (result.status === 'invalid') {
384
401
  clearInvalidSession = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.8.26",
3
+ "version": "0.8.28",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",