cloudflare-next-intl 0.10.20 → 0.10.21

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/README.md CHANGED
@@ -516,7 +516,7 @@ Features include:
516
516
  - `createForgotPasswordAction(locale, actionCodeSettings?)`: Accepts optional Firebase `AuthActionCodeSettings` (e.g. `url` redirect link).
517
517
  - `sendVerificationEmail(actionCodeSettings?)` on `useAuthUser()`: Custom action email settings when resending email verification.
518
518
  - `followSameOriginContinueUrl`: Automatically forwards emailed action links with `continueUrl` to the specified path (or external URL) directly from `intlMiddleware` (default `true`; set `false` on `firebaseAuth` config to disable). If `continueUrl` points to home root (`/`), it resolves to `actionLinkPath` (if set) or the mode target path (e.g. `/reset-password`).
519
- - `appCheck`: Firebase App Check integration supporting reCAPTCHA Enterprise (`recaptchaEnterpriseSiteKey`) and reCAPTCHA v3 (`recaptchaV3SiteKey`). For reCAPTCHA v3, defaults to a `CustomProvider` using an explicit `render=explicit` script tag to avoid iframe/webworker CDN integrity issues in private windows (`useExplicitRecaptchaScript: false` to opt out). When `appCheck` is configured, `getFirebaseAuthClient()` waits for App Check to initialize before returning, so every request made through its `auth` (sign-in included) carries an `X-Firebase-AppCheck` header and passes App Check enforcement. The trade-off: App Check (and, with token auto-refresh on, the reCAPTCHA script) now starts on the first `getFirebaseAuthClient()` call instead of the first token mint. If App Check initialization fails, the client is still returned, just without App Check. Supports server-side token minting via service accounts.
519
+ - `appCheck`: Firebase App Check integration supporting reCAPTCHA Enterprise (`recaptchaEnterpriseSiteKey`) and reCAPTCHA v3 (`recaptchaV3SiteKey`). For reCAPTCHA v3, defaults to a `CustomProvider` using an explicit `render=explicit` script tag to avoid iframe/webworker CDN integrity issues in private windows (`useExplicitRecaptchaScript: false` to opt out). When `appCheck` is configured, `getFirebaseAuthClient()` initializes App Check before it creates `auth`, so every request made through `auth` carries an `X-Firebase-AppCheck` header and passes App Check enforcement. That includes the `accounts:lookup` call Firebase makes on page load to restore a signed-in user, as well as sign-in. The trade-off: App Check (and, with token auto-refresh on, the reCAPTCHA script) now starts on the first `getFirebaseAuthClient()` call instead of the first token mint. If App Check initialization fails, the client is still returned, just without App Check. Supports server-side token minting via service accounts.
520
520
  - `resolveOptionalAuthUser()` (`cloudflare-next-intl/resolveOptionalAuthUser`): best-effort variant of `getAuthUser()` for callers that want to *attach* the current user when one happens to be known — error/telemetry reporting, analytics, logging — without failing or changing behavior when no request/session context is available. Swallows every failure and resolves `{ user: null }` instead of throwing. Use `getAuthUser()` (not this) whenever your own output actually depends on who's signed in — `checkDynamicPages` (below) treats `getAuthUser()`/`useAuthUser()`/`withUserDb()` as page-blocking dynamic-API signals but does not follow into this helper, so it's also the way to read "whoever's signed in, if anyone" from a page or a module it imports without forcing that page dynamic.
521
521
  - `resolveErrorReportingUser(useAuthUser?)` (same subpath): gated form of `resolveOptionalAuthUser()` for an `onError` sink — pass `ErrorHandlingParams.useAuthUser` straight through. Defaults to `false`: when not `true`, resolves `{ user: null }` immediately without calling `getAuthUser()` at all, so a page reached only through your `onError` sink's default path stays static-eligible. A specific `reportError({ ..., useAuthUser: true })` call site opts in per-call when it actually wants the user on that report.
522
522
 
@@ -122,15 +122,10 @@ async function initializeFirebaseAppCheck(app, appCheckConfig) {
122
122
  }
123
123
  const APP_CHECK_TOKEN_TIMEOUT_MS = 10000;
124
124
  let appCheckInitPromise;
125
- async function ensureAppCheck() {
126
- if (appCheckInitPromise)
127
- return appCheckInitPromise;
125
+ function initAppCheckFor(app) {
128
126
  const appCheckConfig = config.firebaseAuth?.appCheck;
129
127
  if (!appCheckConfig || typeof window === 'undefined')
130
- return;
131
- const { app } = await loadFirebaseAuthClient();
132
- if (appCheckInitPromise)
133
- return appCheckInitPromise;
128
+ return undefined;
134
129
  appCheckInitPromise = (async () => {
135
130
  try {
136
131
  cachedAppCheck = await initializeFirebaseAppCheck(app, appCheckConfig);
@@ -141,6 +136,9 @@ async function ensureAppCheck() {
141
136
  })();
142
137
  return appCheckInitPromise;
143
138
  }
139
+ async function ensureAppCheck() {
140
+ await getFirebaseAuthClient();
141
+ }
144
142
  export async function getAppCheckToken() {
145
143
  await ensureAppCheck().catch(() => undefined);
146
144
  if (!cachedAppCheck)
@@ -160,7 +158,7 @@ export async function getAppCheckToken() {
160
158
  }
161
159
  let cached;
162
160
  let cachedPromise;
163
- async function loadFirebaseAuthClient() {
161
+ export async function getFirebaseAuthClient() {
164
162
  requireFirebaseAuthConfig(config.firebaseAuth);
165
163
  if (cached)
166
164
  return cached;
@@ -183,6 +181,7 @@ async function loadFirebaseAuthClient() {
183
181
  measurementId: fa.measurementId,
184
182
  };
185
183
  const app = getApps().length ? getApp() : initializeApp(firebaseConfig);
184
+ await initAppCheckFor(app);
186
185
  if (perfModule) {
187
186
  cachedPerformance = perfModule.initializePerformance(app, { instrumentationEnabled: false });
188
187
  }
@@ -204,11 +203,6 @@ async function loadFirebaseAuthClient() {
204
203
  }
205
204
  return cachedPromise;
206
205
  }
207
- export async function getFirebaseAuthClient() {
208
- const client = await loadFirebaseAuthClient();
209
- await ensureAppCheck().catch(() => undefined);
210
- return client;
211
- }
212
206
  export function getFirebaseAuthClientSync() {
213
207
  return cached;
214
208
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.10.20",
3
+ "version": "0.10.21",
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",