cloudflare-next-intl 0.6.27 → 0.6.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.
@@ -1,7 +1,22 @@
1
1
  import config from '@intl-config';
2
2
  import reportError from '../../error_handling/report_error';
3
- const APP_CHECK_CUSTOM_TOKEN_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.FirebaseAppCheck';
4
- const DEFAULT_CUSTOM_TOKEN_LIFETIME = '1h';
3
+ // Matches `firebase-admin`'s own `AppCheckTokenGenerator.createCustomToken`
4
+ // exactly (`token-generator.js`) — this specific audience (the App Check
5
+ // TOKEN EXCHANGE service, not the App Check API resource name itself) is
6
+ // REQUIRED. The wrong-but-plausible-looking
7
+ // `.../google.firebase.appcheck.v1.FirebaseAppCheck` audience gets rejected
8
+ // by `exchangeCustomToken` with an opaque `403 App attestation failed`, with
9
+ // no indication the audience is the problem.
10
+ const APP_CHECK_CUSTOM_TOKEN_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.TokenExchangeService';
11
+ // `firebase-admin` hardcodes this custom token's own lifetime to 5 minutes
12
+ // and does not expose it as configurable — it's a short-lived credential
13
+ // whose only job is to be immediately exchanged for the actual App Check
14
+ // token (whose own lifetime is controlled by Firebase, separately). Mirrored
15
+ // here as a fixed value rather than the configurable
16
+ // `customTokenLifetime` this used to be: Google's real backend rejects
17
+ // longer lifetimes outright, so making it configurable only offered a
18
+ // footgun with no working range above this default.
19
+ const CUSTOM_TOKEN_LIFETIME = '5m';
5
20
  /**
6
21
  * Mints a fresh App Check token server-side via a service account, for use
7
22
  * when the client-written App Check cookie (see `appCheckTokenCookieName`)
@@ -34,7 +49,7 @@ export default async function mintServerAppCheckToken(projectId, apiKey, appChec
34
49
  .setSubject(appCheck.clientEmail)
35
50
  .setAudience(APP_CHECK_CUSTOM_TOKEN_AUDIENCE)
36
51
  .setIssuedAt()
37
- .setExpirationTime(appCheck.customTokenLifetime ?? DEFAULT_CUSTOM_TOKEN_LIFETIME)
52
+ .setExpirationTime(CUSTOM_TOKEN_LIFETIME)
38
53
  .sign(privateKey);
39
54
  const url = `https://firebaseappcheck.googleapis.com/v1/projects/${projectId}/apps/${appCheck.appId}:exchangeCustomToken?key=${apiKey}`;
40
55
  const res = await fetch(url, {
@@ -596,17 +596,6 @@ export interface FirebaseAppCheckConfig {
596
596
  * itself — App Check registers apps separately.
597
597
  */
598
598
  appId: string;
599
- /**
600
- * Lifetime of the custom JWT signed for the `exchangeCustomToken`
601
- * server-side mint, as a `jose` `setExpirationTime` duration string
602
- * (e.g. `'1h'`, `'30m'`, `'7d'`). Defaults to `'1h'`. This is the custom
603
- * token's own lifetime, not the resulting App Check token's — Firebase
604
- * controls that separately. Google's custom-token minting generally
605
- * rejects lifetimes beyond 1 hour regardless of what's set here, so
606
- * values longer than `'1h'` are unlikely to have any practical effect —
607
- * kept configurable in case that constraint changes.
608
- */
609
- customTokenLifetime?: string;
610
599
  }
611
600
  export interface CookieAttributes {
612
601
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.6.27",
3
+ "version": "0.6.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",