cloudflare-next-intl 0.6.26 → 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');
@@ -10,9 +10,13 @@ import type { FirebaseAppCheckConfig } from '../../types/types';
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>;
@@ -13,12 +13,16 @@ const DEFAULT_CUSTOM_TOKEN_LIFETIME = '1h';
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' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.6.26",
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",