@c-rex/services 0.3.0-build.51 → 0.3.0-build.53

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.
@@ -198,7 +198,10 @@ declare const resolveStaticPageResourceHref: (shortId: string) => Promise<string
198
198
  * informationSubjects): external links plus content-backed pages whose HTML is
199
199
  * fetched while the signed rendition URL is valid and cached alongside — so
200
200
  * nothing cached ever expires with the URL signature. Fetched with the
201
- * application token and cached server-side, shared across all users.
201
+ * application token and cached server-side, shared across all users. In
202
+ * user-login mode, an authenticated request is fetched with that user's token
203
+ * and bypasses the shared read-model cache so role/license-specific content
204
+ * cannot be served from another user's cache entry.
202
205
  * Consumers: footer menu, search-info modal, no-license message, ...
203
206
  *
204
207
  * API failures throw inside the cache (errors are not cached): while a stale
@@ -198,7 +198,10 @@ declare const resolveStaticPageResourceHref: (shortId: string) => Promise<string
198
198
  * informationSubjects): external links plus content-backed pages whose HTML is
199
199
  * fetched while the signed rendition URL is valid and cached alongside — so
200
200
  * nothing cached ever expires with the URL signature. Fetched with the
201
- * application token and cached server-side, shared across all users.
201
+ * application token and cached server-side, shared across all users. In
202
+ * user-login mode, an authenticated request is fetched with that user's token
203
+ * and bypasses the shared read-model cache so role/license-specific content
204
+ * cannot be served from another user's cache entry.
202
205
  * Consumers: footer menu, search-info modal, no-license message, ...
203
206
  *
204
207
  * API failures throw inside the cache (errors are not cached): while a stale
@@ -1576,6 +1576,8 @@ var import_cache4 = require("next/cache");
1576
1576
  var import_requests5 = require("@c-rex/core/requests");
1577
1577
  var import_logger2 = require("@c-rex/core/logger");
1578
1578
  var import_constants2 = require("@c-rex/constants");
1579
+ var import_headers2 = require("next/headers");
1580
+ var import_sdk2 = require("@c-rex/core/sdk");
1579
1581
  var DEFAULT_SORT = ["-informationSubjects.id"];
1580
1582
  var DEFAULT_PAGE_SIZE = 100;
1581
1583
  var RENDITION_FETCH_TIMEOUT_MS = 5e3;
@@ -1713,9 +1715,23 @@ var getStaticPagesCached = (0, import_cache4.unstable_cache)(
1713
1715
  ]
1714
1716
  }
1715
1717
  );
1718
+ var getCurrentUserAuthToken = async () => {
1719
+ try {
1720
+ const config = new import_sdk2.CrexSDK().getServerConfig();
1721
+ if (config.OIDC.tokenSource !== import_constants2.TOKEN_SOURCES.USER_LOGIN) return void 0;
1722
+ const token = (await (0, import_headers2.cookies)()).get(import_constants2.CREX_TOKEN_HEADER_KEY)?.value.trim();
1723
+ return token || void 0;
1724
+ } catch {
1725
+ return void 0;
1726
+ }
1727
+ };
1716
1728
  var getStaticPages = async (query) => {
1717
1729
  try {
1718
- const pages = await getStaticPagesCached(query);
1730
+ const authToken = await getCurrentUserAuthToken();
1731
+ const pages = authToken ? await withServerRequestContext(
1732
+ { skipCookieTokenLookup: true, authToken },
1733
+ () => fetchStaticPages(query)
1734
+ ) : await getStaticPagesCached(query);
1719
1735
  return { status: "ok", pages };
1720
1736
  } catch (error) {
1721
1737
  const logger = new import_logger2.CrexLogger();