@startinblox/core 2.0.6-beta.6 → 2.0.6-beta.8

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.
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { l as isUrlOrRelativePath, m as jsonldContextParserExports, o as getRawContext, n as normalizeContext, q as mergeContexts, c as doesResourceContainList, r as requireJsonldContextParser, v as requireErrorCoded, w as requireLink } from "./helpers-vZrb1UDN.js";
5
- let StoreService, formatAttributesToServerSearchOptions, base_context, StoreType, StoreFactory, hasQueryIndex, formatAttributesToServerPaginationOptions, getDefaultExportFromCjs, hasSetLocalData, sibStore, mergeServerSearchOptions, semantizer;
5
+ let AuthFetchResolver, DEFAULT_AUTH_SELECTORS, StoreService, formatAttributesToServerSearchOptions, base_context, StoreType, StoreFactory, hasQueryIndex, formatAttributesToServerPaginationOptions, getDefaultExportFromCjs, hasSetLocalData, sibStore, mergeServerSearchOptions, semantizer;
6
6
  let __tla = (async () => {
7
7
  var _a;
8
8
  getDefaultExportFromCjs = function(x) {
@@ -278,12 +278,13 @@ let __tla = (async () => {
278
278
  protocol: "dataspace-protocol-http",
279
279
  policy: {
280
280
  "@context": "http://www.w3.org/ns/odrl.jsonld",
281
- "@id": policy["@id"],
282
- "@type": "Offer",
283
- assigner: counterPartyId || "provider",
281
+ ...policy,
282
+ "@type": policy["@type"] || "Offer",
283
+ assigner: policy.assigner || counterPartyId || "provider",
284
284
  target: policy.target
285
285
  }
286
286
  };
287
+ console.log("[DataspaceConnectorStore] Contract negotiation request:", JSON.stringify(negotiationRequest, null, 2));
287
288
  const response = await this.fetchAuthn(this.config.contractNegotiationEndpoint, {
288
289
  method: "POST",
289
290
  headers: this.headers,
@@ -589,6 +590,86 @@ let __tla = (async () => {
589
590
  }
590
591
  return await this.fetchWithEDRToken(edrDataAddress, additionalPath);
591
592
  }
593
+ async fetchProtectedResource(resourceUrl, consumerParticipantId, providerConnectorUrl, existingAgreementId, maxNegotiationRetries = 30, negotiationRetryDelay = 2e3) {
594
+ console.log(`\u{1F510} Requesting protected resource: ${resourceUrl}`);
595
+ if (existingAgreementId) {
596
+ console.log(`\u{1F4DC} Using existing agreement: ${existingAgreementId}`);
597
+ return await this._fetchWithAgreement(resourceUrl, consumerParticipantId, providerConnectorUrl, existingAgreementId);
598
+ }
599
+ const initialResponse = await fetch(resourceUrl, {
600
+ method: "GET",
601
+ headers: {
602
+ "DSP-PARTICIPANT-ID": consumerParticipantId,
603
+ "DSP-CONSUMER-CONNECTORURL": providerConnectorUrl,
604
+ Accept: "application/json"
605
+ },
606
+ mode: "cors"
607
+ });
608
+ if (initialResponse.ok) {
609
+ const data = await initialResponse.json();
610
+ console.log("\u2705 Resource accessed successfully (no agreement required)");
611
+ return data;
612
+ }
613
+ if (initialResponse.status !== 449) {
614
+ const errorText = await initialResponse.text();
615
+ throw new Error(`Unexpected response: ${initialResponse.status} ${initialResponse.statusText} - ${errorText}`);
616
+ }
617
+ const agreementId = await this._handlePolicyDiscovery(initialResponse, providerConnectorUrl, maxNegotiationRetries, negotiationRetryDelay);
618
+ console.log("\u{1F504} Retrying resource request with agreement...");
619
+ return await this._fetchWithAgreement(resourceUrl, consumerParticipantId, providerConnectorUrl, agreementId);
620
+ }
621
+ async _handlePolicyDiscovery(initialResponse, providerConnectorUrl, maxNegotiationRetries, negotiationRetryDelay) {
622
+ console.log("\u{1F4CB} Contract negotiation required (449 response)");
623
+ const errorResponse = await initialResponse.json();
624
+ const suggestedPolicies = errorResponse.suggested_policies;
625
+ if (!suggestedPolicies || suggestedPolicies.length === 0) {
626
+ throw new Error("No suggested policies returned in 449 response");
627
+ }
628
+ const bestPolicy = suggestedPolicies.reduce((best, current) => {
629
+ return current.openness_score > best.openness_score ? current : best;
630
+ });
631
+ console.log(`\u{1F4DC} Selected policy: ${bestPolicy.policy_id} (openness: ${bestPolicy.openness_score})`);
632
+ console.log("\u{1F91D} Initiating contract negotiation...");
633
+ const negotiationId = await this.negotiateContract(providerConnectorUrl, errorResponse.asset_id, bestPolicy.policy, errorResponse.participant_id);
634
+ console.log(`\u{1F4DD} Negotiation initiated: ${negotiationId}`);
635
+ for (let attempt = 1; attempt <= maxNegotiationRetries; attempt++) {
636
+ await new Promise((resolve) => setTimeout(resolve, negotiationRetryDelay));
637
+ const status = await this._getNegotiationStatus(negotiationId);
638
+ console.log(`\u23F3 Negotiation status (${attempt}/${maxNegotiationRetries}): ${status.state}`);
639
+ if (status.state === "FINALIZED") {
640
+ const agreement = await this.getContractAgreement(negotiationId);
641
+ if (!agreement) {
642
+ throw new Error(`Failed to retrieve contract agreement for negotiation ${negotiationId}`);
643
+ }
644
+ console.log(`\u2705 Agreement obtained: ${agreement["@id"]}`);
645
+ return agreement["@id"];
646
+ }
647
+ if (status.state === "TERMINATED") {
648
+ throw new Error(`Negotiation terminated: ${status.errorDetail || "Unknown reason"}`);
649
+ }
650
+ }
651
+ throw new Error(`Negotiation ${negotiationId} failed or timed out after ${maxNegotiationRetries} attempts`);
652
+ }
653
+ async _fetchWithAgreement(resourceUrl, consumerParticipantId, providerConnectorUrl, agreementId) {
654
+ console.log(`\u{1F510} Requesting protected resource: ${resourceUrl} (with agreement)`);
655
+ const response = await fetch(resourceUrl, {
656
+ method: "GET",
657
+ headers: {
658
+ "DSP-PARTICIPANT-ID": consumerParticipantId,
659
+ "DSP-CONSUMER-CONNECTORURL": providerConnectorUrl,
660
+ "DSP-AGREEMENT-ID": agreementId,
661
+ Accept: "application/json"
662
+ },
663
+ mode: "cors"
664
+ });
665
+ if (!response.ok) {
666
+ const errorText = await response.text();
667
+ throw new Error(`Failed to access protected resource: ${response.status} ${response.statusText} - ${errorText}`);
668
+ }
669
+ const data = await response.json();
670
+ console.log("\u2705 Resource accessed successfully");
671
+ return data;
672
+ }
592
673
  async fetchThroughDataspace(resourceId) {
593
674
  try {
594
675
  const catalog = await this.getCatalog();
@@ -1273,67 +1354,279 @@ let __tla = (async () => {
1273
1354
  };
1274
1355
  __publicField(_DataspaceConnectorStoreAdapter, "store");
1275
1356
  let DataspaceConnectorStoreAdapter = _DataspaceConnectorStoreAdapter;
1276
- class FederatedCatalogueAPIWrapper {
1277
- constructor(options, fcBaseUrl) {
1278
- __publicField(this, "fcBaseUrl");
1279
- __publicField(this, "connect");
1280
- this.fcBaseUrl = fcBaseUrl;
1357
+ DEFAULT_AUTH_SELECTORS = [
1358
+ "sib-auth-oidc",
1359
+ "sib-auth"
1360
+ ];
1361
+ function findAuthElement(selectors = [
1362
+ ...DEFAULT_AUTH_SELECTORS
1363
+ ]) {
1364
+ for (const selector of selectors) {
1365
+ const element = document.querySelector(selector);
1366
+ if (element && typeof element.getFetch === "function") {
1367
+ return element;
1368
+ }
1369
+ }
1370
+ return null;
1371
+ }
1372
+ function getAuthFetch(selectors) {
1373
+ const authElement = findAuthElement(selectors);
1374
+ if (authElement) {
1281
1375
  try {
1282
- const connection = this.firstConnect(options);
1283
- this.connect = () => connection;
1284
- } catch (e) {
1285
- console.log("Error while establishing the first connection", e);
1286
- this.connect = null;
1376
+ const authFetch = authElement.getFetch();
1377
+ if (typeof authFetch === "function") {
1378
+ return authFetch;
1379
+ }
1380
+ } catch (error2) {
1381
+ console.warn("[AuthFetchResolver] Error getting auth fetch:", error2);
1287
1382
  }
1288
1383
  }
1289
- async firstConnect(options) {
1290
- const body = new URLSearchParams({
1291
- grant_type: options.kc_grant_type,
1292
- client_id: options.kc_client_id,
1293
- client_secret: options.kc_client_secret,
1294
- scope: options.kc_scope,
1295
- username: options.kc_username,
1296
- password: options.kc_password
1297
- });
1298
- const headers = new Headers({
1299
- "Content-Type": "application/x-www-form-urlencoded"
1384
+ return fetch;
1385
+ }
1386
+ function onAuthActivated(callback, eventName = "sib-auth:activated") {
1387
+ const handler2 = (event) => {
1388
+ var _a2;
1389
+ if (((_a2 = event.detail) == null ? void 0 : _a2.fetch) && typeof event.detail.fetch === "function") {
1390
+ callback(event);
1391
+ }
1392
+ };
1393
+ document.addEventListener(eventName, handler2);
1394
+ return () => {
1395
+ document.removeEventListener(eventName, handler2);
1396
+ };
1397
+ }
1398
+ async function waitForAuthElement(selectors = [
1399
+ ...DEFAULT_AUTH_SELECTORS
1400
+ ], timeout = 5e3) {
1401
+ const existing = findAuthElement(selectors);
1402
+ if (existing) {
1403
+ return existing;
1404
+ }
1405
+ return new Promise((resolve, reject) => {
1406
+ const observer = new MutationObserver(() => {
1407
+ const element = findAuthElement(selectors);
1408
+ if (element) {
1409
+ observer.disconnect();
1410
+ resolve(element);
1411
+ }
1300
1412
  });
1301
- const response = await fetch(options.kc_url, {
1302
- method: "POST",
1303
- headers,
1304
- body
1413
+ observer.observe(document.body, {
1414
+ childList: true,
1415
+ subtree: true
1305
1416
  });
1306
- const data = await response.json();
1307
- const token = data.access_token;
1308
- if (token == null) {
1309
- throw new Error("connexion fails", {
1310
- cause: data
1417
+ setTimeout(() => {
1418
+ observer.disconnect();
1419
+ reject(new Error(`No auth element found with selectors: ${selectors.join(", ")}`));
1420
+ }, timeout);
1421
+ });
1422
+ }
1423
+ AuthFetchResolver = {
1424
+ findAuthElement,
1425
+ getAuthFetch,
1426
+ onAuthActivated,
1427
+ waitForAuthElement
1428
+ };
1429
+ const _LocalStorageCacheMetadataManager = class _LocalStorageCacheMetadataManager {
1430
+ constructor(endpoint, ttlMs = _LocalStorageCacheMetadataManager.DEFAULT_TTL_MS) {
1431
+ this.endpoint = endpoint;
1432
+ this.ttlMs = ttlMs;
1433
+ this.cleanupOldCacheFormat();
1434
+ }
1435
+ cleanupOldCacheFormat() {
1436
+ try {
1437
+ const endpointHash = this.endpoint.replace(/[^a-zA-Z0-9]/g, "");
1438
+ const oldKey = `fc-cache-meta-${endpointHash}`;
1439
+ if (localStorage.getItem(oldKey)) {
1440
+ localStorage.removeItem(oldKey);
1441
+ }
1442
+ } catch (error2) {
1443
+ console.warn("[LocalStorageCache] Error cleaning up old cache format:", error2);
1444
+ }
1445
+ }
1446
+ getStorageKey() {
1447
+ const endpointHash = this.endpoint.replace(/[^a-zA-Z0-9]/g, "");
1448
+ return `${_LocalStorageCacheMetadataManager.STORAGE_KEY_PREFIX}-${endpointHash}`;
1449
+ }
1450
+ getCacheData() {
1451
+ try {
1452
+ const key = this.getStorageKey();
1453
+ const data = localStorage.getItem(key);
1454
+ if (!data) {
1455
+ return null;
1456
+ }
1457
+ const parsed = JSON.parse(data);
1458
+ const items = /* @__PURE__ */ new Map();
1459
+ if (parsed.items) {
1460
+ for (const [hash, metadata] of Object.entries(parsed.items)) {
1461
+ items.set(hash, metadata);
1462
+ }
1463
+ }
1464
+ return {
1465
+ version: parsed.version,
1466
+ lastFetchTimestamp: parsed.lastFetchTimestamp,
1467
+ cacheExpirationTimestamp: parsed.cacheExpirationTimestamp,
1468
+ resource: parsed.resource,
1469
+ items
1470
+ };
1471
+ } catch (error2) {
1472
+ console.error("[LocalStorageCache] Error reading cache data:", error2);
1473
+ return null;
1474
+ }
1475
+ }
1476
+ getCacheMetadata() {
1477
+ return this.getCacheData();
1478
+ }
1479
+ setCacheData(cacheData) {
1480
+ try {
1481
+ const key = this.getStorageKey();
1482
+ const itemsObj = {};
1483
+ cacheData.items.forEach((value, hash) => {
1484
+ itemsObj[hash] = value;
1485
+ });
1486
+ const data = JSON.stringify({
1487
+ version: cacheData.version,
1488
+ lastFetchTimestamp: cacheData.lastFetchTimestamp,
1489
+ cacheExpirationTimestamp: cacheData.cacheExpirationTimestamp,
1490
+ resource: cacheData.resource,
1491
+ items: itemsObj
1492
+ });
1493
+ localStorage.setItem(key, data);
1494
+ return true;
1495
+ } catch (error2) {
1496
+ console.error("[LocalStorageCache] Error writing cache data:", error2);
1497
+ return false;
1498
+ }
1499
+ }
1500
+ setCacheMetadata(cacheData) {
1501
+ return this.setCacheData(cacheData);
1502
+ }
1503
+ isCacheValid() {
1504
+ const cacheData = this.getCacheData();
1505
+ if (!cacheData) {
1506
+ return false;
1507
+ }
1508
+ if (cacheData.version !== _LocalStorageCacheMetadataManager.CACHE_VERSION) {
1509
+ console.log("[LocalStorageCache] Cache version mismatch, invalidating");
1510
+ return false;
1511
+ }
1512
+ const now = Date.now();
1513
+ if (now > cacheData.cacheExpirationTimestamp) {
1514
+ console.log("[LocalStorageCache] Cache TTL expired");
1515
+ return false;
1516
+ }
1517
+ return true;
1518
+ }
1519
+ getResource() {
1520
+ const cacheData = this.getCacheData();
1521
+ return (cacheData == null ? void 0 : cacheData.resource) || null;
1522
+ }
1523
+ getKnownHashes() {
1524
+ const cacheData = this.getCacheData();
1525
+ if (!cacheData) {
1526
+ return /* @__PURE__ */ new Set();
1527
+ }
1528
+ return new Set(cacheData.items.keys());
1529
+ }
1530
+ getItemMetadata(sdHash) {
1531
+ const cacheData = this.getCacheData();
1532
+ if (!cacheData) {
1533
+ return null;
1534
+ }
1535
+ return cacheData.items.get(sdHash) || null;
1536
+ }
1537
+ updateCache(resource, items) {
1538
+ const now = Date.now();
1539
+ let cacheData = this.getCacheData();
1540
+ if (!cacheData || !this.isCacheValid()) {
1541
+ cacheData = {
1542
+ version: _LocalStorageCacheMetadataManager.CACHE_VERSION,
1543
+ lastFetchTimestamp: now,
1544
+ cacheExpirationTimestamp: now + this.ttlMs,
1545
+ resource,
1546
+ items: /* @__PURE__ */ new Map()
1547
+ };
1548
+ } else {
1549
+ cacheData.resource = resource;
1550
+ }
1551
+ for (const item of items) {
1552
+ cacheData.items.set(item.sdHash, {
1553
+ ...item,
1554
+ cachedAt: now
1311
1555
  });
1312
1556
  }
1313
- return token;
1557
+ cacheData.lastFetchTimestamp = now;
1558
+ return this.setCacheData(cacheData);
1559
+ }
1560
+ removeItems(sdHashes) {
1561
+ var _a2;
1562
+ const cacheData = this.getCacheData();
1563
+ if (!cacheData) {
1564
+ return false;
1565
+ }
1566
+ for (const hash of sdHashes) {
1567
+ cacheData.items.delete(hash);
1568
+ }
1569
+ if ((_a2 = cacheData.resource) == null ? void 0 : _a2["ldp:contains"]) {
1570
+ const resourceIdsToRemove = /* @__PURE__ */ new Set();
1571
+ for (const hash of sdHashes) {
1572
+ const meta = cacheData.items.get(hash);
1573
+ if (meta) {
1574
+ resourceIdsToRemove.add(meta.resourceId);
1575
+ }
1576
+ }
1577
+ cacheData.resource["ldp:contains"] = cacheData.resource["ldp:contains"].filter((item) => !resourceIdsToRemove.has(item["@id"]));
1578
+ }
1579
+ return this.setCacheData(cacheData);
1580
+ }
1581
+ clear() {
1582
+ try {
1583
+ const key = this.getStorageKey();
1584
+ localStorage.removeItem(key);
1585
+ return true;
1586
+ } catch (error2) {
1587
+ console.error("[LocalStorageCache] Error clearing cache data:", error2);
1588
+ return false;
1589
+ }
1590
+ }
1591
+ getCacheStats() {
1592
+ const cacheData = this.getCacheData();
1593
+ if (!cacheData) {
1594
+ return {
1595
+ itemCount: 0,
1596
+ lastFetch: null,
1597
+ expiresAt: null,
1598
+ isValid: false
1599
+ };
1600
+ }
1601
+ return {
1602
+ itemCount: cacheData.items.size,
1603
+ lastFetch: new Date(cacheData.lastFetchTimestamp),
1604
+ expiresAt: new Date(cacheData.cacheExpirationTimestamp),
1605
+ isValid: this.isCacheValid()
1606
+ };
1607
+ }
1608
+ };
1609
+ __publicField(_LocalStorageCacheMetadataManager, "STORAGE_KEY_PREFIX", "fc-cache-data");
1610
+ __publicField(_LocalStorageCacheMetadataManager, "CACHE_VERSION", "2.0.0");
1611
+ __publicField(_LocalStorageCacheMetadataManager, "DEFAULT_TTL_MS", 2 * 60 * 60 * 1e3);
1612
+ let LocalStorageCacheMetadataManager = _LocalStorageCacheMetadataManager;
1613
+ class FederatedCatalogueAPIWrapper {
1614
+ constructor(fcBaseUrl, fetchAuth) {
1615
+ __publicField(this, "fcBaseUrl");
1616
+ __publicField(this, "fetch");
1617
+ this.fcBaseUrl = fcBaseUrl;
1618
+ const baseFetch = fetchAuth || fetch;
1619
+ this.fetch = baseFetch.bind(globalThis);
1314
1620
  }
1315
1621
  async getAllSelfDescriptions() {
1316
- if (!this.connect) return null;
1317
- const token = await this.connect();
1318
1622
  const url2 = `${this.fcBaseUrl}/self-descriptions`;
1319
- const headers = new Headers({
1320
- Authorization: `Bearer ${token}`
1321
- });
1322
- const response = await fetch(url2, {
1323
- headers
1324
- });
1623
+ const response = await this.fetch(url2);
1325
1624
  return await response.json();
1326
1625
  }
1327
1626
  async getSelfDescriptionByHash(sdHash) {
1328
- if (!this.connect) return null;
1329
- const token = await this.connect();
1330
1627
  const url2 = `${this.fcBaseUrl}/self-descriptions/${sdHash}`;
1331
- const headers = new Headers({
1332
- Authorization: `Bearer ${token}`
1333
- });
1334
- const response = await fetch(url2, {
1335
- method: "GET",
1336
- headers
1628
+ const response = await this.fetch(url2, {
1629
+ method: "GET"
1337
1630
  });
1338
1631
  if (!response.ok) throw new Error(`GET /self-descriptions/${sdHash} failed: ${response.status} ${response.statusText}`, {
1339
1632
  cause: response
@@ -1341,18 +1634,15 @@ let __tla = (async () => {
1341
1634
  return await response.json();
1342
1635
  }
1343
1636
  async postQuery(statement, parameters = {}) {
1344
- if (!this.connect) return null;
1345
- const token = await this.connect();
1346
1637
  const url2 = `${this.fcBaseUrl}/query`;
1347
1638
  const headers = new Headers({
1348
- Authorization: `Bearer ${token}`,
1349
1639
  "Content-Type": "application/json"
1350
1640
  });
1351
1641
  const body = JSON.stringify({
1352
1642
  statement,
1353
1643
  parameters
1354
1644
  });
1355
- const response = await fetch(url2, {
1645
+ const response = await this.fetch(url2, {
1356
1646
  method: "POST",
1357
1647
  headers,
1358
1648
  body
@@ -1365,11 +1655,8 @@ let __tla = (async () => {
1365
1655
  return await response.json();
1366
1656
  }
1367
1657
  async postQuerySearch(statement, parameters = {}, queryLanguage = "OPENCYPHER", annotations) {
1368
- if (!this.connect) return null;
1369
- const token = await this.connect();
1370
1658
  const url2 = `${this.fcBaseUrl}/query/search`;
1371
1659
  const headers = new Headers({
1372
- Authorization: `Bearer ${token}`,
1373
1660
  "Content-Type": "application/json"
1374
1661
  });
1375
1662
  const body = JSON.stringify({
@@ -1379,7 +1666,7 @@ let __tla = (async () => {
1379
1666
  queryLanguage
1380
1667
  }
1381
1668
  });
1382
- const response = await fetch(url2, {
1669
+ const response = await this.fetch(url2, {
1383
1670
  method: "POST",
1384
1671
  headers,
1385
1672
  body
@@ -1392,28 +1679,65 @@ let __tla = (async () => {
1392
1679
  return await response.json();
1393
1680
  }
1394
1681
  }
1395
- function getFederatedCatalogueAPIWrapper(baseUrl, loginOptions) {
1396
- return new FederatedCatalogueAPIWrapper(loginOptions, baseUrl);
1682
+ function getFederatedCatalogueAPIWrapper(baseUrl, fetch2) {
1683
+ return new FederatedCatalogueAPIWrapper(baseUrl, fetch2);
1397
1684
  }
1398
1685
  class FederatedCatalogueStore {
1399
1686
  constructor(cfg) {
1400
1687
  __publicField(this, "cache");
1401
- __publicField(this, "session");
1402
1688
  __publicField(this, "fcApi");
1689
+ __publicField(this, "metadataManager");
1690
+ __publicField(this, "enableCaching");
1691
+ __publicField(this, "cleanupAuth");
1692
+ __publicField(this, "resolveFetch", (event) => {
1693
+ if (!this.cfg.endpoint) {
1694
+ throw new Error("Missing required `endpoint` in StoreConfig for FederatedCatalogueStore");
1695
+ }
1696
+ if (event.detail.fetch) {
1697
+ this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, event.detail.fetch);
1698
+ }
1699
+ });
1403
1700
  this.cfg = cfg;
1404
- if (!this.cfg.login) {
1405
- throw new Error("Login must be provided for FederatedCatalogueStore");
1406
- }
1407
1701
  if (!this.cfg.endpoint) {
1408
1702
  throw new Error("Missing required `endpoint` in StoreConfig for FederatedCatalogueStore");
1409
1703
  }
1410
- try {
1411
- this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, this.cfg.login);
1412
- } catch (e) {
1413
- console.error("[FederatedCatalogueStore] Failed to initialize API wrapper:", e);
1704
+ const fetchAuth = AuthFetchResolver.getAuthFetch();
1705
+ this.cleanupAuth = AuthFetchResolver.onAuthActivated(this.resolveFetch.bind(this));
1706
+ if (fetchAuth) {
1707
+ this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, fetchAuth);
1708
+ } else {
1414
1709
  this.fcApi = null;
1415
1710
  }
1416
1711
  this.cache = new InMemoryCacheManager();
1712
+ this.enableCaching = this.cfg.enableLocalStorageMetadata === true;
1713
+ if (this.enableCaching && this.cfg.endpoint) {
1714
+ const cacheTTL = this.cfg.cacheTTL || 2 * 60 * 60 * 1e3;
1715
+ this.metadataManager = new LocalStorageCacheMetadataManager(this.cfg.endpoint, cacheTTL);
1716
+ this.handlePageReload();
1717
+ } else {
1718
+ this.metadataManager = null;
1719
+ }
1720
+ }
1721
+ disconnectedCallback() {
1722
+ var _a2;
1723
+ (_a2 = this.cleanupAuth) == null ? void 0 : _a2.call(this);
1724
+ }
1725
+ handlePageReload() {
1726
+ var _a2, _b;
1727
+ try {
1728
+ const SESSION_KEY = "fc-session-id";
1729
+ let sessionId = sessionStorage.getItem(SESSION_KEY);
1730
+ if (!sessionId) {
1731
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1732
+ sessionStorage.setItem(SESSION_KEY, sessionId);
1733
+ (_a2 = this.metadataManager) == null ? void 0 : _a2.clear();
1734
+ }
1735
+ const stats = (_b = this.metadataManager) == null ? void 0 : _b.getCacheStats();
1736
+ if (stats) {
1737
+ }
1738
+ } catch (error2) {
1739
+ console.warn("[FederatedCatalogueStore] Error handling page reload:", error2);
1740
+ }
1417
1741
  }
1418
1742
  resolveTargetType(args) {
1419
1743
  if (typeof args === "string") return args;
@@ -1422,28 +1746,184 @@ let __tla = (async () => {
1422
1746
  }
1423
1747
  return "";
1424
1748
  }
1749
+ buildContainerId(containerType = "default") {
1750
+ var _a2;
1751
+ const endpointHash = ((_a2 = this.cfg.endpoint) == null ? void 0 : _a2.replace(/[^a-zA-Z0-9]/g, "")) || "unknown";
1752
+ return `store://local.fc-${endpointHash}-${containerType}/`;
1753
+ }
1425
1754
  async getData(args) {
1755
+ var _a2;
1426
1756
  const targetType = this.resolveTargetType(args);
1427
1757
  if (!this.fcApi) {
1428
1758
  throw new Error("Federated API not initialized, returning empty data.");
1429
1759
  }
1430
- let resource = await this.get(targetType);
1431
- if (!resource || resource["ldp:contains"].length === 0) {
1432
- resource = await this.initLocalDataSourceContainer(targetType);
1433
- const dataset2 = await this.fcApi.getAllSelfDescriptions();
1434
- if (dataset2) for (const item in dataset2.items) {
1435
- const sd = await this.fcApi.getSelfDescriptionByHash(dataset2.items[item].meta.sdHash);
1760
+ const cacheIsValid = this.enableCaching && ((_a2 = this.metadataManager) == null ? void 0 : _a2.isCacheValid());
1761
+ const hasCached = this.hasCachedData();
1762
+ if (cacheIsValid && hasCached) {
1763
+ return await this.getDeltaUpdatedData(targetType);
1764
+ }
1765
+ if (cacheIsValid && !hasCached && this.metadataManager) {
1766
+ this.metadataManager.clear();
1767
+ }
1768
+ return await this.getFullData(targetType);
1769
+ }
1770
+ hasCachedData() {
1771
+ try {
1772
+ if (!this.metadataManager) {
1773
+ return false;
1774
+ }
1775
+ const resource = this.metadataManager.getResource();
1776
+ const hasResourceData = !!((resource == null ? void 0 : resource["ldp:contains"]) && resource["ldp:contains"].length > 0);
1777
+ const metadataItemCount = this.metadataManager.getCacheStats().itemCount || 0;
1778
+ return hasResourceData && metadataItemCount > 0;
1779
+ } catch (error2) {
1780
+ console.error("[FederatedCatalogueStore] Error checking cached data:", error2);
1781
+ return false;
1782
+ }
1783
+ }
1784
+ async getDeltaUpdatedData(targetType) {
1785
+ if (!this.fcApi || !this.metadataManager) {
1786
+ return await this.getFullData(targetType);
1787
+ }
1788
+ try {
1789
+ const apiList = await this.fcApi.getAllSelfDescriptions();
1790
+ if (!apiList || !apiList.items) {
1791
+ console.warn("[FederatedCatalogueStore] No items returned from API");
1792
+ return await this.getFullData(targetType);
1793
+ }
1794
+ const resource = this.metadataManager.getResource();
1795
+ if (!resource) {
1796
+ return await this.getFullData(targetType);
1797
+ }
1798
+ if (!resource["@id"]) {
1799
+ resource["@id"] = this.buildContainerId();
1800
+ }
1801
+ if (!resource["ldp:contains"]) {
1802
+ resource["ldp:contains"] = [];
1803
+ }
1804
+ const knownHashes = this.metadataManager.getKnownHashes();
1805
+ const items = (apiList == null ? void 0 : apiList.items) || [];
1806
+ if (!Array.isArray(items)) {
1807
+ console.warn("[FederatedCatalogueStore] apiList.items is not an array");
1808
+ return resource;
1809
+ }
1810
+ const apiHashes = new Set(items.map((item) => item.meta.sdHash));
1811
+ const newHashes = [];
1812
+ const updatedHashes = [];
1813
+ const deletedHashes = [];
1814
+ for (const item of items) {
1815
+ const hash = item.meta.sdHash;
1816
+ if (!knownHashes.has(hash)) {
1817
+ newHashes.push(hash);
1818
+ } else {
1819
+ const cachedMeta = this.metadataManager.getItemMetadata(hash);
1820
+ if (cachedMeta) {
1821
+ if (item.meta.uploadDatetime > cachedMeta.uploadDatetime || item.meta.statusDatetime > cachedMeta.statusDatetime) {
1822
+ updatedHashes.push(hash);
1823
+ }
1824
+ }
1825
+ }
1826
+ }
1827
+ for (const hash of knownHashes) {
1828
+ if (!apiHashes.has(hash)) {
1829
+ deletedHashes.push(hash);
1830
+ }
1831
+ }
1832
+ const toFetch = [
1833
+ ...newHashes,
1834
+ ...updatedHashes
1835
+ ];
1836
+ const newMetadata = [];
1837
+ if (toFetch.length > 0) {
1838
+ for (const hash of toFetch) {
1839
+ try {
1840
+ const sd = await this.fcApi.getSelfDescriptionByHash(hash);
1841
+ if (sd) {
1842
+ const mappedResource = this.mapSourceToDestination(sd, {
1843
+ temsServiceBase: this.cfg.temsServiceBase,
1844
+ temsCategoryBase: this.cfg.temsCategoryBase,
1845
+ temsImageBase: this.cfg.temsImageBase,
1846
+ temsProviderBase: this.cfg.temsProviderBase
1847
+ });
1848
+ if (updatedHashes.includes(hash)) {
1849
+ const index = resource["ldp:contains"].findIndex((r) => r["@id"] === mappedResource["@id"]);
1850
+ if (index !== -1) {
1851
+ resource["ldp:contains"].splice(index, 1);
1852
+ }
1853
+ }
1854
+ resource["ldp:contains"].push(mappedResource);
1855
+ const apiItem = apiList.items.find((i) => i.meta.sdHash === hash);
1856
+ if (apiItem) {
1857
+ newMetadata.push({
1858
+ sdHash: hash,
1859
+ uploadDatetime: apiItem.meta.uploadDatetime,
1860
+ statusDatetime: apiItem.meta.statusDatetime,
1861
+ cachedAt: Date.now(),
1862
+ resourceId: mappedResource["@id"]
1863
+ });
1864
+ }
1865
+ }
1866
+ } catch (error2) {
1867
+ console.error(`[FederatedCatalogueStore] Error fetching hash ${hash}:`, error2);
1868
+ }
1869
+ }
1870
+ }
1871
+ if (deletedHashes.length > 0) {
1872
+ this.metadataManager.removeItems(deletedHashes);
1873
+ }
1874
+ if (newMetadata.length > 0) {
1875
+ this.metadataManager.updateCache(resource, newMetadata);
1876
+ }
1877
+ document.dispatchEvent(new CustomEvent("save", {
1878
+ detail: {
1879
+ resource: {
1880
+ "@id": resource == null ? void 0 : resource["@id"]
1881
+ }
1882
+ },
1883
+ bubbles: true
1884
+ }));
1885
+ return resource;
1886
+ } catch (error2) {
1887
+ console.error("[FederatedCatalogueStore] Delta update failed, falling back to full fetch:", error2);
1888
+ return await this.getFullData(targetType);
1889
+ }
1890
+ }
1891
+ async getFullData(_targetType) {
1892
+ if (!this.fcApi) {
1893
+ throw new Error("Federated API not initialized");
1894
+ }
1895
+ const resource = await this.initLocalDataSourceContainer();
1896
+ const dataset2 = await this.fcApi.getAllSelfDescriptions();
1897
+ const newMetadata = [];
1898
+ if ((dataset2 == null ? void 0 : dataset2.items) && Array.isArray(dataset2.items)) {
1899
+ for (const item of dataset2.items) {
1900
+ const sd = await this.fcApi.getSelfDescriptionByHash(item.meta.sdHash);
1436
1901
  if (sd) {
1437
- const mappedResource = this.mapSourceToDestination(sd, {
1438
- temsServiceBase: this.cfg.temsServiceBase,
1439
- temsCategoryBase: this.cfg.temsCategoryBase,
1440
- temsImageBase: this.cfg.temsImageBase,
1441
- temsProviderBase: this.cfg.temsProviderBase
1442
- });
1443
- resource["ldp:contains"].push(mappedResource);
1902
+ try {
1903
+ const mappedResource = this.mapSourceToDestination(sd, {
1904
+ temsServiceBase: this.cfg.temsServiceBase,
1905
+ temsCategoryBase: this.cfg.temsCategoryBase,
1906
+ temsImageBase: this.cfg.temsImageBase,
1907
+ temsProviderBase: this.cfg.temsProviderBase
1908
+ });
1909
+ resource["ldp:contains"].push(mappedResource);
1910
+ if (this.enableCaching) {
1911
+ newMetadata.push({
1912
+ sdHash: item.meta.sdHash,
1913
+ uploadDatetime: item.meta.uploadDatetime,
1914
+ statusDatetime: item.meta.statusDatetime,
1915
+ cachedAt: Date.now(),
1916
+ resourceId: mappedResource["@id"]
1917
+ });
1918
+ }
1919
+ } catch (error2) {
1920
+ console.error("[FederatedCatalogueStore] Error mapping resource:", error2);
1921
+ }
1444
1922
  }
1445
1923
  }
1446
- this.setLocalData(resource, targetType);
1924
+ }
1925
+ if (this.enableCaching && this.metadataManager && newMetadata.length > 0) {
1926
+ this.metadataManager.updateCache(resource, newMetadata);
1447
1927
  }
1448
1928
  document.dispatchEvent(new CustomEvent("save", {
1449
1929
  detail: {
@@ -1456,11 +1936,8 @@ let __tla = (async () => {
1456
1936
  return resource;
1457
1937
  }
1458
1938
  async initLocalDataSourceContainer(dataSrc = "", containerType = "default") {
1459
- var _a2;
1460
- const endpointHash = ((_a2 = this.cfg.endpoint) == null ? void 0 : _a2.replace(/[^a-zA-Z0-9]/g, "")) || "unknown";
1461
- const idField = `fc-${endpointHash}-${containerType}`;
1462
1939
  if (!dataSrc) {
1463
- dataSrc = `store://local.${idField}/`;
1940
+ dataSrc = this.buildContainerId(containerType);
1464
1941
  }
1465
1942
  const localContainer = {
1466
1943
  "@context": "https://cdn.startinblox.com/owl/context.jsonld",
@@ -1521,8 +1998,8 @@ let __tla = (async () => {
1521
1998
  }
1522
1999
  subscribeResourceTo(_resourceId, _nestedResourceId) {
1523
2000
  }
1524
- fetchAuthn(_iri, _options) {
1525
- return Promise.resolve({});
2001
+ async fetchAuthn(_iri, _options) {
2002
+ return await Promise.resolve({});
1526
2003
  }
1527
2004
  async setLocalData(resource, id) {
1528
2005
  try {
@@ -1548,8 +2025,39 @@ let __tla = (async () => {
1548
2025
  bubbles: true
1549
2026
  }));
1550
2027
  }
2028
+ stripUrnPrefix(id, prefix) {
2029
+ if (id == null ? void 0 : id.startsWith(prefix)) {
2030
+ return id.substring(prefix.length);
2031
+ }
2032
+ return id;
2033
+ }
2034
+ stripTemsUrnFromPolicy(obj) {
2035
+ if (obj === null || obj === void 0) {
2036
+ return obj;
2037
+ }
2038
+ if (typeof obj === "string") {
2039
+ return this.stripUrnPrefix(obj, "urn:tems:");
2040
+ }
2041
+ if (Array.isArray(obj)) {
2042
+ return obj.map((item) => this.stripTemsUrnFromPolicy(item));
2043
+ }
2044
+ if (typeof obj === "object") {
2045
+ const result = {};
2046
+ for (const key in obj) {
2047
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
2048
+ if (key === "@id") {
2049
+ result[key] = this.stripUrnPrefix(obj[key], "urn:tems:");
2050
+ } else {
2051
+ result[key] = this.stripTemsUrnFromPolicy(obj[key]);
2052
+ }
2053
+ }
2054
+ }
2055
+ return result;
2056
+ }
2057
+ return obj;
2058
+ }
1551
2059
  mapSourceToDestination(src, opts) {
1552
- var _a2, _b, _c, _d, _e, _f, _g, _h;
2060
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1553
2061
  const vc = src.verifiableCredential;
1554
2062
  const cs = vc.credentialSubject;
1555
2063
  let catInfo;
@@ -1560,9 +2068,16 @@ let __tla = (async () => {
1560
2068
  usedKey = "service";
1561
2069
  type = "tems:Service";
1562
2070
  } else if (cs["dcat:dataset"] && cs["dcat:dataset"].length > 0) {
1563
- catInfo = cs["dcat:dataset"][0];
1564
- usedKey = "dataset";
1565
- type = "tems:DataOffer";
2071
+ const dataset2 = cs["dcat:dataset"][0];
2072
+ if (dataset2["dcat:service"]) {
2073
+ catInfo = dataset2["dcat:service"];
2074
+ usedKey = "nested-service";
2075
+ type = "tems:Service";
2076
+ } else {
2077
+ catInfo = dataset2;
2078
+ usedKey = "dataset";
2079
+ type = "tems:DataOffer";
2080
+ }
1566
2081
  } else {
1567
2082
  throw new Error("Expected either credentialSubject['dcat:service'] or a non-empty array in ['dcat:dataset']");
1568
2083
  }
@@ -1571,7 +2086,7 @@ let __tla = (async () => {
1571
2086
  const serviceId = `${opts.temsServiceBase}${encodeURIComponent(slug)}/`;
1572
2087
  const creation_date = vc.issuanceDate;
1573
2088
  const update_date = vc.expirationDate;
1574
- const name = catInfo["dcterms:title"];
2089
+ const name = catInfo["dcterms:title"] || catInfo["dct:title"];
1575
2090
  const description = catInfo["rdfs:comment"];
1576
2091
  const keywords = catInfo["dcat:keyword"] || [];
1577
2092
  const long_description = keywords.length > 0 ? `Keywords: ${keywords.join(", ")}` : "";
@@ -1611,19 +2126,24 @@ let __tla = (async () => {
1611
2126
  const contact_url = catInfo["dcat:endpointDescription"] || "";
1612
2127
  const documentation_url = contact_url || "";
1613
2128
  let service_url = catInfo["dcat:endpointURL"] || "";
2129
+ if (!service_url) {
2130
+ console.warn("[FederatedCatalogueStore] dcat:endpointURL is missing from dcat:service. Available fields:", Object.keys(catInfo));
2131
+ }
1614
2132
  if (service_url.includes("demo.isan.org")) service_url = new URL(service_url).origin;
1615
2133
  let providerRef;
1616
2134
  if (usedKey === "service") {
1617
2135
  providerRef = ((_d = cs["gax-core:operatedBy"]) == null ? void 0 : _d["@id"]) || "";
2136
+ } else if (usedKey === "nested-service") {
2137
+ providerRef = ((_e = cs["gax-core:operatedBy"]) == null ? void 0 : _e["@id"]) || ((_f = cs["gax-core:offeredBy"]) == null ? void 0 : _f["@id"]) || "";
1618
2138
  } else {
1619
- providerRef = ((_e = cs["gax-core:offeredBy"]) == null ? void 0 : _e["@id"]) || "";
2139
+ providerRef = ((_g = cs["gax-core:offeredBy"]) == null ? void 0 : _g["@id"]) || "";
1620
2140
  }
1621
2141
  const providerSlug = providerRef.split(":").pop() + String(Math.random()) || "0";
1622
- const providerLogo = ((_g = (_f = catInfo["dcterms:creator"]) == null ? void 0 : _f["foaf:thumbnail"]) == null ? void 0 : _g["rdf:resource"]) || "";
2142
+ const providerLogo = ((_i = (_h = catInfo["dcterms:creator"]) == null ? void 0 : _h["foaf:thumbnail"]) == null ? void 0 : _i["rdf:resource"]) || "";
1623
2143
  const provider = {
1624
2144
  "@id": `${opts.temsProviderBase}${encodeURIComponent(providerSlug)}/`,
1625
2145
  "@type": "tems:Provider",
1626
- name: ((_h = catInfo["dcterms:creator"]) == null ? void 0 : _h["foaf:name"]) || "",
2146
+ name: ((_j = catInfo["dcterms:creator"]) == null ? void 0 : _j["foaf:name"]) || "",
1627
2147
  image: {
1628
2148
  "@id": `${opts.temsImageBase}${encodeURIComponent(providerLogo.split("/").pop() || "0")}/`,
1629
2149
  "@type": "tems:Image",
@@ -1633,6 +2153,23 @@ let __tla = (async () => {
1633
2153
  }
1634
2154
  };
1635
2155
  const data_offers = [];
2156
+ const counterPartyAddress = cs["dcat:endpointURL"];
2157
+ const counterPartyId = cs["dspace:participantId"];
2158
+ const assetId = this.stripUrnPrefix(cs["@id"], "urn:uuid:");
2159
+ let datasetId;
2160
+ let policy;
2161
+ if (cs["dcat:dataset"] && cs["dcat:dataset"].length > 0) {
2162
+ const dataset2 = cs["dcat:dataset"][0];
2163
+ if (dataset2["@id"]) {
2164
+ datasetId = this.stripUrnPrefix(dataset2["@id"], "urn:uuid:");
2165
+ }
2166
+ if (dataset2["odrl:hasPolicy"]) {
2167
+ policy = this.stripTemsUrnFromPolicy(JSON.parse(JSON.stringify(dataset2["odrl:hasPolicy"])));
2168
+ if (datasetId) {
2169
+ policy.target = datasetId;
2170
+ }
2171
+ }
2172
+ }
1636
2173
  const dest = {
1637
2174
  "@id": serviceId,
1638
2175
  creation_date,
@@ -1656,7 +2193,22 @@ let __tla = (async () => {
1656
2193
  url: service_url,
1657
2194
  provider,
1658
2195
  data_offers,
1659
- "@type": type
2196
+ "@type": type,
2197
+ ...counterPartyAddress && {
2198
+ counterPartyAddress
2199
+ },
2200
+ ...counterPartyId && {
2201
+ counterPartyId
2202
+ },
2203
+ ...assetId && {
2204
+ assetId
2205
+ },
2206
+ ...datasetId && {
2207
+ datasetId
2208
+ },
2209
+ ...policy && {
2210
+ policy
2211
+ }
1660
2212
  };
1661
2213
  return dest;
1662
2214
  }
@@ -28538,9 +29090,9 @@ sh:property [
28538
29090
  __publicField(this, "loadingList");
28539
29091
  __publicField(this, "headers");
28540
29092
  __publicField(this, "fetch");
28541
- __publicField(this, "session");
28542
29093
  __publicField(this, "contextParser");
28543
29094
  __publicField(this, "searchProvider");
29095
+ __publicField(this, "cleanupAuth");
28544
29096
  __publicField(this, "resolveResource", (id, resolve) => {
28545
29097
  const handler2 = (event) => {
28546
29098
  if (event.detail.id === id) {
@@ -28554,6 +29106,11 @@ sh:property [
28554
29106
  };
28555
29107
  return handler2;
28556
29108
  });
29109
+ __publicField(this, "resolveFetch", (event) => {
29110
+ if (event.detail.fetch) {
29111
+ this.fetch = event.detail.fetch.bind ? event.detail.fetch.bind(globalThis) : event.detail.fetch;
29112
+ }
29113
+ });
28557
29114
  this.storeOptions = storeOptions;
28558
29115
  this.cache = this.storeOptions.cacheManager ?? new InMemoryCacheManager();
28559
29116
  this.subscriptionIndex = /* @__PURE__ */ new Map();
@@ -28564,15 +29121,35 @@ sh:property [
28564
29121
  "Content-Type": "application/ld+json",
28565
29122
  "Cache-Control": "must-revalidate"
28566
29123
  };
28567
- this.fetch = this.storeOptions.fetchMethod;
28568
- this.session = this.storeOptions.session;
28569
29124
  this.contextParser = new jsonldContextParserExports.ContextParser();
28570
29125
  this.searchProvider = new SolidIndexingSearchProvider(this.getData.bind(this));
29126
+ if (this.storeOptions.fetchMethod) {
29127
+ this.fetch = this.storeOptions.fetchMethod.bind(globalThis);
29128
+ } else {
29129
+ const authFetch = AuthFetchResolver.getAuthFetch();
29130
+ this.fetch = authFetch.bind ? authFetch.bind(globalThis) : authFetch;
29131
+ this.cleanupAuth = AuthFetchResolver.onAuthActivated(this.resolveFetch.bind(this));
29132
+ }
29133
+ if (!this.fetch) {
29134
+ this.fetch = fetch;
29135
+ }
29136
+ const event = new CustomEvent("sib-core:loaded", {
29137
+ bubbles: true,
29138
+ composed: true,
29139
+ detail: {
29140
+ store: this
29141
+ }
29142
+ });
29143
+ window.dispatchEvent(event);
28571
29144
  }
28572
29145
  async initGetter() {
28573
- const { CustomGetter } = await import("./custom-getter-D-s4T-Sk.js");
29146
+ const { CustomGetter } = await import("./custom-getter-WZPa-O0k.js");
28574
29147
  return CustomGetter;
28575
29148
  }
29149
+ disconnectedCallback() {
29150
+ var _a2;
29151
+ (_a2 = this.cleanupAuth) == null ? void 0 : _a2.call(this);
29152
+ }
28576
29153
  async getData(id, context2, parentId, localData, forceFetch, serverPagination, serverSearch, headers, bypassLoadingList) {
28577
29154
  var _a2;
28578
29155
  let key = id;
@@ -28638,17 +29215,7 @@ sh:property [
28638
29215
  if (!this.fetch) {
28639
29216
  console.warn("No fetch method available");
28640
29217
  }
28641
- let authenticated = false;
28642
- if (this.session) authenticated = await this.session;
28643
- if (this.fetch && authenticated) {
28644
- return this.fetch.then((fn) => {
28645
- return fn(iri, options);
28646
- });
28647
- }
28648
- if (options.headers) {
28649
- options.headers = this._convertHeaders(options.headers);
28650
- }
28651
- return fetch(iri, options).then((response) => response);
29218
+ return await this.fetch(iri, options);
28652
29219
  }
28653
29220
  async fetchData(id, context2 = null, parentId = "", serverPagination, serverSearch, headers) {
28654
29221
  let iri = this._getAbsoluteIri(id, context2, parentId);
@@ -28891,19 +29458,19 @@ sh:property [
28891
29458
  ]);
28892
29459
  }
28893
29460
  _getAbsoluteIri(id, context2, parentId) {
29461
+ var _a2;
28894
29462
  let iri = normalizeContext(context2, base_context).expandTerm(id);
28895
29463
  if (!iri) return "";
28896
- if (parentId && !parentId.startsWith("store://local")) {
28897
- const parentIri = new URL(parentId, document.location.href).href;
28898
- iri = new URL(iri, parentIri).href;
28899
- } else {
28900
- iri = new URL(iri, document.location.href).href;
29464
+ try {
29465
+ const baseHref = ((_a2 = document == null ? void 0 : document.location) == null ? void 0 : _a2.href) || "";
29466
+ const canUseParent = parentId && !parentId.startsWith("store://local");
29467
+ const base = canUseParent ? new URL(parentId, baseHref).href : baseHref;
29468
+ iri = new URL(iri, base).href;
29469
+ } catch (err) {
29470
+ console.log("[LDPStore _getAbsoluteIri()]", err);
28901
29471
  }
28902
29472
  return iri;
28903
29473
  }
28904
- async getSession() {
28905
- return await this.session;
28906
- }
28907
29474
  _getLanguage() {
28908
29475
  return localStorage.getItem("language") || window.navigator.language.slice(0, 2);
28909
29476
  }
@@ -28921,16 +29488,8 @@ sh:property [
28921
29488
  if (window.sibStore) {
28922
29489
  return window.sibStore;
28923
29490
  }
28924
- const storeOptions = {};
28925
- const sibAuth = document.querySelector("sib-auth");
28926
- if (sibAuth) {
28927
- const sibAuthDefined = customElements.whenDefined(sibAuth.localName);
28928
- storeOptions.session = sibAuthDefined.then(() => sibAuth.session);
28929
- storeOptions.fetchMethod = sibAuthDefined.then(() => sibAuth.getFetch());
28930
- }
28931
29491
  const store2 = new LdpStore({
28932
- ..._cfg == null ? void 0 : _cfg.options,
28933
- ...storeOptions
29492
+ ..._cfg == null ? void 0 : _cfg.options
28934
29493
  });
28935
29494
  window.sibStore = store2;
28936
29495
  return store2;
@@ -33104,6 +33663,8 @@ sh:property [
33104
33663
  semantizer = globalThis.SEMANTIZER;
33105
33664
  })();
33106
33665
  export {
33666
+ AuthFetchResolver as A,
33667
+ DEFAULT_AUTH_SELECTORS as D,
33107
33668
  StoreService as S,
33108
33669
  __tla,
33109
33670
  formatAttributesToServerSearchOptions as a,