@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.js CHANGED
@@ -3224,6 +3224,8 @@ var import_cache5 = require("next/cache");
3224
3224
  var import_requests6 = require("@c-rex/core/requests");
3225
3225
  var import_logger2 = require("@c-rex/core/logger");
3226
3226
  var import_constants2 = require("@c-rex/constants");
3227
+ var import_headers2 = require("next/headers");
3228
+ var import_sdk2 = require("@c-rex/core/sdk");
3227
3229
  var DEFAULT_SORT = ["-informationSubjects.id"];
3228
3230
  var DEFAULT_PAGE_SIZE = 100;
3229
3231
  var RENDITION_FETCH_TIMEOUT_MS = 5e3;
@@ -3361,9 +3363,23 @@ var getStaticPagesCached = (0, import_cache5.unstable_cache)(
3361
3363
  ]
3362
3364
  }
3363
3365
  );
3366
+ var getCurrentUserAuthToken = async () => {
3367
+ try {
3368
+ const config = new import_sdk2.CrexSDK().getServerConfig();
3369
+ if (config.OIDC.tokenSource !== import_constants2.TOKEN_SOURCES.USER_LOGIN) return void 0;
3370
+ const token = (await (0, import_headers2.cookies)()).get(import_constants2.CREX_TOKEN_HEADER_KEY)?.value.trim();
3371
+ return token || void 0;
3372
+ } catch {
3373
+ return void 0;
3374
+ }
3375
+ };
3364
3376
  var getStaticPages = async (query) => {
3365
3377
  try {
3366
- const pages = await getStaticPagesCached(query);
3378
+ const authToken = await getCurrentUserAuthToken();
3379
+ const pages = authToken ? await withServerRequestContext(
3380
+ { skipCookieTokenLookup: true, authToken },
3381
+ () => fetchStaticPages(query)
3382
+ ) : await getStaticPagesCached(query);
3367
3383
  return { status: "ok", pages };
3368
3384
  } catch (error) {
3369
3385
  const logger = new import_logger2.CrexLogger();