cloudflare-next-intl 0.6.25 → 0.6.27

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.
@@ -45,7 +45,7 @@ export const getAuthenticatedAppForUser = cache(async function getAuthenticatedA
45
45
  // so apps that never configure server-side minting keep today's exact
46
46
  // behavior.
47
47
  const appCheckToken = cookieStore.get(appCheckTokenCookieName)?.value
48
- ?? await mintServerAppCheckToken(fa.projectId, fa.appCheck);
48
+ ?? await mintServerAppCheckToken(fa.projectId, fa.apiKey, fa.appCheck);
49
49
  try {
50
50
  if (!firebaseAppModule)
51
51
  firebaseAppModule = await import('firebase/app');
@@ -4,15 +4,19 @@ import type { FirebaseAppCheckConfig } from '../../types/types';
4
4
  * when the client-written App Check cookie (see `appCheckTokenCookieName`)
5
5
  * is absent — e.g. a cold navigation before `AuthUserProvider` has run and
6
6
  * had a chance to write it. Requires `clientEmail`/`privateKey`/`appId` on
7
- * `firebaseAuth.appCheck`; returns `undefined` (never throws) if any of
8
- * those are missing or the exchange fails, so a caller can always fall back
9
- * to "no App Check token" exactly as before this existed.
7
+ * `firebaseAuth.appCheck`; returns `undefined` (never throws) if the
8
+ * exchange fails, so a caller can always fall back to "no App Check token"
9
+ * exactly as before this existed.
10
10
  *
11
11
  * Signs a short-lived custom JWT with the service account's private key
12
12
  * (`jose`, Edge/WebCrypto-compatible — no `firebase-admin`), then exchanges
13
- * it for an App Check token via `exchangeCustomToken`. Not cached beyond the
14
- * caller's own request-scoped `cache()` wrapper a fresh mint costs one
15
- * signing operation plus one network round-trip, acceptable per-request but
16
- * not worth doing more than once per request.
13
+ * it for an App Check token via `exchangeCustomToken`, authenticated with
14
+ * the project's Web API key (`?key=`) — `exchangeCustomToken` otherwise
15
+ * rejects the call outright as an unregistered/unidentified caller
16
+ * (403 `PERMISSION_DENIED`), before the custom token itself is even
17
+ * evaluated. Not cached beyond the caller's own request-scoped `cache()`
18
+ * wrapper — a fresh mint costs one signing operation plus one network
19
+ * round-trip, acceptable per-request but not worth doing more than once per
20
+ * request.
17
21
  */
18
- export default function mintServerAppCheckToken(projectId: string, appCheck: FirebaseAppCheckConfig | undefined): Promise<string | undefined>;
22
+ export default function mintServerAppCheckToken(projectId: string, apiKey: string, appCheck: FirebaseAppCheckConfig | undefined): Promise<string | undefined>;
@@ -7,18 +7,22 @@ const DEFAULT_CUSTOM_TOKEN_LIFETIME = '1h';
7
7
  * when the client-written App Check cookie (see `appCheckTokenCookieName`)
8
8
  * is absent — e.g. a cold navigation before `AuthUserProvider` has run and
9
9
  * had a chance to write it. Requires `clientEmail`/`privateKey`/`appId` on
10
- * `firebaseAuth.appCheck`; returns `undefined` (never throws) if any of
11
- * those are missing or the exchange fails, so a caller can always fall back
12
- * to "no App Check token" exactly as before this existed.
10
+ * `firebaseAuth.appCheck`; returns `undefined` (never throws) if the
11
+ * exchange fails, so a caller can always fall back to "no App Check token"
12
+ * exactly as before this existed.
13
13
  *
14
14
  * Signs a short-lived custom JWT with the service account's private key
15
15
  * (`jose`, Edge/WebCrypto-compatible — no `firebase-admin`), then exchanges
16
- * it for an App Check token via `exchangeCustomToken`. Not cached beyond the
17
- * caller's own request-scoped `cache()` wrapper a fresh mint costs one
18
- * signing operation plus one network round-trip, acceptable per-request but
19
- * not worth doing more than once per request.
16
+ * it for an App Check token via `exchangeCustomToken`, authenticated with
17
+ * the project's Web API key (`?key=`) — `exchangeCustomToken` otherwise
18
+ * rejects the call outright as an unregistered/unidentified caller
19
+ * (403 `PERMISSION_DENIED`), before the custom token itself is even
20
+ * evaluated. Not cached beyond the caller's own request-scoped `cache()`
21
+ * wrapper — a fresh mint costs one signing operation plus one network
22
+ * round-trip, acceptable per-request but not worth doing more than once per
23
+ * request.
20
24
  */
21
- export default async function mintServerAppCheckToken(projectId, appCheck) {
25
+ export default async function mintServerAppCheckToken(projectId, apiKey, appCheck) {
22
26
  if (!appCheck?.clientEmail || !appCheck.privateKey || !appCheck.appId)
23
27
  return undefined;
24
28
  try {
@@ -32,7 +36,7 @@ export default async function mintServerAppCheckToken(projectId, appCheck) {
32
36
  .setIssuedAt()
33
37
  .setExpirationTime(appCheck.customTokenLifetime ?? DEFAULT_CUSTOM_TOKEN_LIFETIME)
34
38
  .sign(privateKey);
35
- const url = `https://firebaseappcheck.googleapis.com/v1/projects/${projectId}/apps/${appCheck.appId}:exchangeCustomToken`;
39
+ const url = `https://firebaseappcheck.googleapis.com/v1/projects/${projectId}/apps/${appCheck.appId}:exchangeCustomToken?key=${apiKey}`;
36
40
  const res = await fetch(url, {
37
41
  method: 'POST',
38
42
  headers: { 'Content-Type': 'application/json' },
@@ -575,13 +575,11 @@ export interface FirebaseAppCheckConfig {
575
575
  * Service account client email, used ONLY server-side to mint an App
576
576
  * Check token when the client-written App Check cookie is absent (e.g.
577
577
  * a cold navigation before `AuthUserProvider` has run — see
578
- * `appCheckTokenCookieName`). Omit to skip server-side minting entirely;
579
- * `getAuthenticatedAppForUser` then behaves exactly as it did before this
580
- * option existed (falls back to no App Check token). Never sent to the
581
- * client — read only by `firebase_server.ts`. Required alongside
582
- * `privateKey` and `appId` for minting to activate.
578
+ * `appCheckTokenCookieName`). Required alongside `privateKey` and
579
+ * `appId` for server-side minting. Never sent to the client — read only
580
+ * by `firebase_server.ts`.
583
581
  */
584
- clientEmail?: string;
582
+ clientEmail: string;
585
583
  /**
586
584
  * Service account private key (PEM), paired with `clientEmail` for
587
585
  * server-side App Check token minting. Same server-only, secret-bearing
@@ -590,14 +588,14 @@ export interface FirebaseAppCheckConfig {
590
588
  * browser. Escaped `\n` sequences (common when stored in a single-line
591
589
  * env var) are unescaped automatically before use.
592
590
  */
593
- privateKey?: string;
591
+ privateKey: string;
594
592
  /**
595
593
  * Firebase App Check app ID (e.g. `"1:1234567890:web:abcdef123456"`),
596
594
  * required alongside `clientEmail`/`privateKey` for server-side minting.
597
595
  * Distinct from the Firebase Auth `appId` on `FirebaseAuthRoutingConfig`
598
596
  * itself — App Check registers apps separately.
599
597
  */
600
- appId?: string;
598
+ appId: string;
601
599
  /**
602
600
  * Lifetime of the custom JWT signed for the `exchangeCustomToken`
603
601
  * server-side mint, as a `jose` `setExpirationTime` duration string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.6.25",
3
+ "version": "0.6.27",
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",