cloudflare-next-intl 0.8.58 → 0.8.60
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.
|
@@ -5,9 +5,9 @@ import requireFirebaseAuthConfig from '../require_config';
|
|
|
5
5
|
import { defaultAppCheckTokenCookieName, defaultRefreshTokenCookieName, defaultSessionCookieName, isIdTokenExpired, refreshIdToken, sessionCookieOptions } from '../middleware/update_session';
|
|
6
6
|
import reportError from '../../error_handling/report_error';
|
|
7
7
|
import mintServerAppCheckToken from './mint_server_app_check_token';
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
8
|
+
let baseAppReady;
|
|
9
|
+
let firebaseAppModuleReady;
|
|
10
|
+
let firebaseAuthModuleReady;
|
|
11
11
|
/**
|
|
12
12
|
* Writes a freshly-minted session/refresh pair back to the cookie jar so the
|
|
13
13
|
* NEXT request doesn't repeat the rejected-token round-trip. Next only allows
|
|
@@ -89,12 +89,10 @@ export const getAuthenticatedAppForUser = cache(async function getAuthenticatedA
|
|
|
89
89
|
// with `currentUser === null`. So a null user (not a throw) is the signal
|
|
90
90
|
// to drop the bad token and mint a replacement from the refresh cookie.
|
|
91
91
|
const attempt = async (idToken) => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const { initializeApp, initializeServerApp } = firebaseAppModule;
|
|
97
|
-
const { getAuth } = firebaseAuthModule;
|
|
92
|
+
firebaseAppModuleReady ?? (firebaseAppModuleReady = import('firebase/app'));
|
|
93
|
+
firebaseAuthModuleReady ?? (firebaseAuthModuleReady = import('firebase/auth'));
|
|
94
|
+
const { initializeApp, initializeServerApp } = await firebaseAppModuleReady;
|
|
95
|
+
const { getAuth } = await firebaseAuthModuleReady;
|
|
98
96
|
const firebaseConfig = {
|
|
99
97
|
apiKey: fa.apiKey,
|
|
100
98
|
authDomain: fa.authDomain,
|
|
@@ -109,8 +107,12 @@ export const getAuthenticatedAppForUser = cache(async function getAuthenticatedA
|
|
|
109
107
|
// named app per token: `initializeServerApp` derives a distinct,
|
|
110
108
|
// token-scoped auth context from this same base app without
|
|
111
109
|
// registering a new named app in Firebase's global app registry.
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
// Cached as a promise (not the resolved app) so concurrent requests
|
|
111
|
+
// racing this on a cold start share one `initializeApp` call instead
|
|
112
|
+
// of each calling `initializeApp` with the same name and racing
|
|
113
|
+
// Firebase's internal app registry.
|
|
114
|
+
baseAppReady ?? (baseAppReady = (async () => initializeApp(firebaseConfig, 'firebase-auth-server-base'))());
|
|
115
|
+
const baseApp = await baseAppReady;
|
|
114
116
|
const firebaseServerApp = initializeServerApp(baseApp, { authIdToken: idToken, appCheckToken });
|
|
115
117
|
const auth = getAuth(firebaseServerApp);
|
|
116
118
|
await auth.authStateReady();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import NextImage, { getImageProps as nextGetImageProps } from "next/image";
|
|
3
|
-
import manifest from "virtual:cloudflare-next-intl-images-manifest";
|
|
4
3
|
import { getImageBlurSvg } from "./blur_svg.js";
|
|
5
4
|
/**
|
|
6
5
|
* When an image was generated at multiple widths (because it's used at
|
|
@@ -19,7 +18,13 @@ function pickVariant(entry, requestedWidth) {
|
|
|
19
18
|
}
|
|
20
19
|
return entry.variants.reduce((best, v) => (v.width > best.width ? v : best));
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
let manifestData;
|
|
22
|
+
try {
|
|
23
|
+
manifestData = (await import(/* @vite-ignore */ "virtual:cloudflare-next-intl-images-manifest")).default;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
manifestData = undefined;
|
|
27
|
+
}
|
|
23
28
|
const images = (manifestData && typeof manifestData === "object" && manifestData.images)
|
|
24
29
|
? manifestData.images
|
|
25
30
|
: {};
|