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

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.
package/dist/index.mjs CHANGED
@@ -2843,7 +2843,13 @@ import {
2843
2843
  CREX_READMODEL_CACHE_STATIC_PAGES_TAG
2844
2844
  } from "@c-rex/core/requests";
2845
2845
  import { CrexLogger as CrexLogger2 } from "@c-rex/core/logger";
2846
- import { RENDITION_LINK_RELS } from "@c-rex/constants";
2846
+ import {
2847
+ CREX_TOKEN_HEADER_KEY,
2848
+ RENDITION_LINK_RELS,
2849
+ TOKEN_SOURCES
2850
+ } from "@c-rex/constants";
2851
+ import { cookies as cookies2 } from "next/headers";
2852
+ import { CrexSDK as CrexSDK2 } from "@c-rex/core/sdk";
2847
2853
  var DEFAULT_SORT = ["-informationSubjects.id"];
2848
2854
  var DEFAULT_PAGE_SIZE = 100;
2849
2855
  var RENDITION_FETCH_TIMEOUT_MS = 5e3;
@@ -2981,9 +2987,23 @@ var getStaticPagesCached = unstable_cache5(
2981
2987
  ]
2982
2988
  }
2983
2989
  );
2990
+ var getCurrentUserAuthToken = async () => {
2991
+ try {
2992
+ const config = new CrexSDK2().getServerConfig();
2993
+ if (config.OIDC.tokenSource !== TOKEN_SOURCES.USER_LOGIN) return void 0;
2994
+ const token = (await cookies2()).get(CREX_TOKEN_HEADER_KEY)?.value.trim();
2995
+ return token || void 0;
2996
+ } catch {
2997
+ return void 0;
2998
+ }
2999
+ };
2984
3000
  var getStaticPages = async (query) => {
2985
3001
  try {
2986
- const pages = await getStaticPagesCached(query);
3002
+ const authToken = await getCurrentUserAuthToken();
3003
+ const pages = authToken ? await withServerRequestContext(
3004
+ { skipCookieTokenLookup: true, authToken },
3005
+ () => fetchStaticPages(query)
3006
+ ) : await getStaticPagesCached(query);
2987
3007
  return { status: "ok", pages };
2988
3008
  } catch (error) {
2989
3009
  const logger = new CrexLogger2();