@startinblox/core 2.0.5-beta.5 → 2.0.6-beta.1
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 { q as mergeContexts, o as getRawContext, n as normalizeContext } from "./helpers-vZrb1UDN.js";
|
|
5
|
-
import { S as StoreService } from "./store-
|
|
5
|
+
import { S as StoreService } from "./store-_JtvdYph.js";
|
|
6
6
|
const store = StoreService.getInstance();
|
|
7
7
|
class CustomGetter {
|
|
8
8
|
// search attributes to give to server
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-
|
|
4
|
+
import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-_JtvdYph.js";
|
|
5
5
|
import { d as defineComponent, n as normalizeContext, u as uniqID, f as fuzzyCompare, a as asyncQuerySelector, i as importInlineCSS, b as importCSS, c as doesResourceContainList, e as findClosingBracketMatchIndex, p as parseFieldsString, g as evalTemplateString, h as compare, j as generalComparator, t as transformArrayToContainer, s as setDeepProperty } from "./helpers-vZrb1UDN.js";
|
|
6
6
|
import { k } from "./helpers-vZrb1UDN.js";
|
|
7
7
|
let index$4, BaseWidgetMixin, index$3, CounterMixin, EdcAssetsDisplay, EdcCatalogDisplay, EdcFederatedCatalogDisplay, FederationMixin, FilterMixin, GrouperMixin, HighlighterMixin, ListMixin, NextMixin, PaginateMixin, RequiredMixin, Sib, SolidAcChecker, SolidDelete, SolidDisplay, SolidForm, SolidFormSearch, SolidLang, SolidMemberAdd, SolidMemberDelete, SolidMembership, SolidTable, SolidTemplateElement, SolidWidget, SorterMixin, StoreMixin, index$2, index$1, index, TranslationMixin, ValidationMixin, WidgetMixin, x, o$2, newWidgetFactory, B, o$1, m, widgetFactory;
|
|
@@ -1636,8 +1636,7 @@ Component: ${componentName}
|
|
|
1636
1636
|
const nestedResource = resource ? await resource[this.nestedField] : null;
|
|
1637
1637
|
this.resourceId = nestedResource ? await nestedResource["@id"] : null;
|
|
1638
1638
|
if (resource && !this.resourceId && !nestedResource) {
|
|
1639
|
-
for (const
|
|
1640
|
-
console.log(`${property}: ${await resource[property]}`);
|
|
1639
|
+
for (const _property in await resource) {
|
|
1641
1640
|
}
|
|
1642
1641
|
throw `Error: the key "${this.nestedField}" does not exist on the resource at id "${resource["@id"]}"`;
|
|
1643
1642
|
}
|
|
@@ -2819,12 +2818,9 @@ Component: ${componentName}
|
|
|
2819
2818
|
return this.currentPostProcessors;
|
|
2820
2819
|
}
|
|
2821
2820
|
printCurrentCallbacks() {
|
|
2822
|
-
if (this.currentPostProcessors.length === 0)
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
console.log("Registered post-processors:");
|
|
2826
|
-
for (const postProcessor of this.currentPostProcessors) {
|
|
2827
|
-
console.log(`- ${postProcessor.name}`);
|
|
2821
|
+
if (this.currentPostProcessors.length === 0) ;
|
|
2822
|
+
else {
|
|
2823
|
+
for (const _postProcessor of this.currentPostProcessors) {
|
|
2828
2824
|
}
|
|
2829
2825
|
}
|
|
2830
2826
|
}
|
|
@@ -99487,6 +99483,7 @@ ${escapeText(this.code(index2, length))}
|
|
|
99487
99483
|
},
|
|
99488
99484
|
async getFields() {
|
|
99489
99485
|
var _a3;
|
|
99486
|
+
this.nameWidgets = [];
|
|
99490
99487
|
const attr = this.fields;
|
|
99491
99488
|
if (attr === "") return [];
|
|
99492
99489
|
if (attr) return parseFieldsString(attr);
|
|
@@ -99822,7 +99819,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
99822
99819
|
}
|
|
99823
99820
|
},
|
|
99824
99821
|
async fetchAssets() {
|
|
99825
|
-
console.log("fetchAssets", this.connectorUri, this.apiKey);
|
|
99826
99822
|
if (!this.connectorUri || !this.apiKey) return;
|
|
99827
99823
|
this.loading = true;
|
|
99828
99824
|
this.error = null;
|
|
@@ -99841,7 +99837,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
99841
99837
|
timeout: 3e4
|
|
99842
99838
|
};
|
|
99843
99839
|
const store2 = StoreFactory.create(config2);
|
|
99844
|
-
console.log("store", store2);
|
|
99845
99840
|
const assetsRaw = await store2.getAssets();
|
|
99846
99841
|
this.assets = Array.isArray(assetsRaw) ? assetsRaw : assetsRaw ? [
|
|
99847
99842
|
assetsRaw
|
|
@@ -99856,7 +99851,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
99856
99851
|
}
|
|
99857
99852
|
},
|
|
99858
99853
|
render() {
|
|
99859
|
-
console.log("render", this.assets);
|
|
99860
99854
|
if (this.loading) {
|
|
99861
99855
|
B(x`<div class="loading">Loading assets...</div>`, this.element);
|
|
99862
99856
|
return;
|
|
@@ -99989,9 +99983,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
99989
99983
|
const offer = dataset["odrl:hasPolicy"][0];
|
|
99990
99984
|
const offerId = offer["@id"];
|
|
99991
99985
|
const assetId = dataset["@id"];
|
|
99992
|
-
console.log(`Starting negotiation for asset ${assetId} with offer ${offerId}`);
|
|
99993
|
-
console.log("Dataset:", dataset);
|
|
99994
|
-
console.log("Offer policy:", offer);
|
|
99995
99986
|
this.negotiations.set(assetId, {
|
|
99996
99987
|
status: "negotiating",
|
|
99997
99988
|
offerId
|
|
@@ -100007,7 +99998,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100007
99998
|
target: assetId
|
|
100008
99999
|
};
|
|
100009
100000
|
const negotiationId = await store2.initiateNegotiation(this.counterPartyAddress, assetId, modifiedOffer);
|
|
100010
|
-
console.log(`Negotiation initiated: ${negotiationId}`);
|
|
100011
100001
|
this.negotiations.set(assetId, {
|
|
100012
100002
|
status: "pending",
|
|
100013
100003
|
negotiationId,
|
|
@@ -100035,7 +100025,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100035
100025
|
}
|
|
100036
100026
|
const store2 = this.store;
|
|
100037
100027
|
const status = await store2.getNegotiationStatus(negotiationId);
|
|
100038
|
-
console.log(`Polling attempt ${attempt + 1}: Negotiation ${negotiationId} state: ${status.state}`);
|
|
100039
100028
|
this.negotiations.set(assetId, {
|
|
100040
100029
|
status: "pending",
|
|
100041
100030
|
negotiationId,
|
|
@@ -100244,7 +100233,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100244
100233
|
var _a3;
|
|
100245
100234
|
try {
|
|
100246
100235
|
this._providersArray = value ? JSON.parse(value) : [];
|
|
100247
|
-
console.log("Providers parsed:", this._providersArray);
|
|
100248
100236
|
this.initializeProviderRegistry();
|
|
100249
100237
|
if (((_a3 = this._providersArray) == null ? void 0 : _a3.length) > 0 && this.consumerConnector && this.apiKey) {
|
|
100250
100238
|
this.fetchFederatedCatalog();
|
|
@@ -100291,7 +100279,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100291
100279
|
},
|
|
100292
100280
|
initializeProviderRegistry() {
|
|
100293
100281
|
if (!this._providersArray || this._providersArray.length === 0) {
|
|
100294
|
-
console.log("No providers available for registry initialization");
|
|
100295
100282
|
return;
|
|
100296
100283
|
}
|
|
100297
100284
|
const providerInfos = this._providersArray.map((provider) => ({
|
|
@@ -100302,7 +100289,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100302
100289
|
status: "unknown"
|
|
100303
100290
|
}));
|
|
100304
100291
|
this.providerRegistry = new ProviderRegistry(providerInfos);
|
|
100305
|
-
console.log("\u2705 Provider registry initialized with", providerInfos.length, "providers:", providerInfos);
|
|
100306
100292
|
},
|
|
100307
100293
|
async fetchFederatedCatalog() {
|
|
100308
100294
|
var _a3;
|
|
@@ -100325,6 +100311,7 @@ ${escapeText(this.code(index2, length))}
|
|
|
100325
100311
|
catalogEndpoint: `${this.consumerConnector}/v3/catalog/request`,
|
|
100326
100312
|
contractNegotiationEndpoint: `${this.consumerConnector}/v3/contractnegotiations`,
|
|
100327
100313
|
transferProcessEndpoint: `${this.consumerConnector}/v3/transferprocesses`,
|
|
100314
|
+
edrsEndpoint: `${this.consumerConnector}/v3/edrs`,
|
|
100328
100315
|
authMethod: "edc-api-key",
|
|
100329
100316
|
edcApiKey: this.apiKey,
|
|
100330
100317
|
retryAttempts: 8,
|
|
@@ -100335,7 +100322,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100335
100322
|
this.loadingProviders.add(provider.address);
|
|
100336
100323
|
this.render();
|
|
100337
100324
|
try {
|
|
100338
|
-
console.log(`Fetching catalog from ${provider.name} (${provider.address})`);
|
|
100339
100325
|
const catalog = await store2.getCatalog(provider.address);
|
|
100340
100326
|
if (catalog) {
|
|
100341
100327
|
this.catalogs.set(provider.address, {
|
|
@@ -100352,7 +100338,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100352
100338
|
registryProvider.participantId = catalog.participantId;
|
|
100353
100339
|
registryProvider.status = "online";
|
|
100354
100340
|
registryProvider.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
100355
|
-
console.log(`\u2705 Discovered participant ID for ${provider.name}: ${catalog.participantId}`);
|
|
100356
100341
|
}
|
|
100357
100342
|
}
|
|
100358
100343
|
this.providerStats.set(provider.address, {
|
|
@@ -100398,7 +100383,8 @@ ${escapeText(this.code(index2, length))}
|
|
|
100398
100383
|
const allFederatedDatasets = await Promise.all(catalogPromises);
|
|
100399
100384
|
this.federatedDatasets = this.deduplicateDatasets(allFederatedDatasets.flat());
|
|
100400
100385
|
this.stores.set("default", store2);
|
|
100401
|
-
|
|
100386
|
+
await store2.loadExistingAgreements();
|
|
100387
|
+
this.render();
|
|
100402
100388
|
} catch (error2) {
|
|
100403
100389
|
console.error("Failed to fetch federated catalog:", error2);
|
|
100404
100390
|
this.error = error2.message;
|
|
@@ -100436,13 +100422,10 @@ ${escapeText(this.code(index2, length))}
|
|
|
100436
100422
|
return deduplicated;
|
|
100437
100423
|
},
|
|
100438
100424
|
getFilteredDatasets() {
|
|
100439
|
-
console.log("getFilteredDatasets called with searchQuery:", this.searchQuery);
|
|
100440
100425
|
let filtered = this.federatedDatasets;
|
|
100441
100426
|
filtered = filtered.filter((item) => this.selectedProviders.has(item.provider.address));
|
|
100442
|
-
console.log("After provider filtering:", filtered.length, "datasets");
|
|
100443
100427
|
if (this.searchQuery.trim()) {
|
|
100444
100428
|
const query = this.searchQuery.toLowerCase().trim();
|
|
100445
|
-
console.log("Applying search filter for:", query);
|
|
100446
100429
|
filtered = filtered.filter((item) => {
|
|
100447
100430
|
var _a3, _b;
|
|
100448
100431
|
const dataset = item.dataset;
|
|
@@ -100451,10 +100434,8 @@ ${escapeText(this.code(index2, length))}
|
|
|
100451
100434
|
const keywords = (dataset["dcat:keyword"] || []).join(" ").toLowerCase();
|
|
100452
100435
|
const providername = item.provider.name.toLowerCase();
|
|
100453
100436
|
const matches = title.includes(query) || description.includes(query) || keywords.includes(query) || providername.includes(query) || dataset["@id"].toLowerCase().includes(query);
|
|
100454
|
-
console.log(`Dataset ${dataset["@id"]}: title="${title}", matches=${matches}`);
|
|
100455
100437
|
return matches;
|
|
100456
100438
|
});
|
|
100457
|
-
console.log("After search filtering:", filtered.length, "datasets");
|
|
100458
100439
|
}
|
|
100459
100440
|
return filtered;
|
|
100460
100441
|
},
|
|
@@ -100483,8 +100464,30 @@ ${escapeText(this.code(index2, length))}
|
|
|
100483
100464
|
return policies;
|
|
100484
100465
|
},
|
|
100485
100466
|
async negotiateAccess(federatedDataset) {
|
|
100486
|
-
var _a3;
|
|
100467
|
+
var _a3, _b, _c;
|
|
100487
100468
|
const { dataset, provider } = federatedDataset;
|
|
100469
|
+
const assetId = dataset["@id"];
|
|
100470
|
+
const negotiationKey = `${assetId}@${provider.address}`;
|
|
100471
|
+
const store2 = this.stores.get("default");
|
|
100472
|
+
if (!store2) {
|
|
100473
|
+
console.error("Store not available for negotiation");
|
|
100474
|
+
return;
|
|
100475
|
+
}
|
|
100476
|
+
const existingAgreement = store2.getAssetAgreement(assetId);
|
|
100477
|
+
if (existingAgreement) {
|
|
100478
|
+
this.negotiations.set(negotiationKey, {
|
|
100479
|
+
status: "granted",
|
|
100480
|
+
contractId: existingAgreement.agreementId,
|
|
100481
|
+
agreement: existingAgreement.agreement,
|
|
100482
|
+
provider,
|
|
100483
|
+
assetId,
|
|
100484
|
+
offerId: ((_b = (_a3 = existingAgreement.agreement) == null ? void 0 : _a3.policy) == null ? void 0 : _b["@id"]) || "existing",
|
|
100485
|
+
transferId: existingAgreement.transferId,
|
|
100486
|
+
edrToken: existingAgreement.edrToken
|
|
100487
|
+
});
|
|
100488
|
+
this.render();
|
|
100489
|
+
return;
|
|
100490
|
+
}
|
|
100488
100491
|
const policies = this.getPoliciesFromDataset(dataset);
|
|
100489
100492
|
if (policies.length === 0) {
|
|
100490
100493
|
console.error("No policies available for dataset:", dataset["@id"]);
|
|
@@ -100492,15 +100495,10 @@ ${escapeText(this.code(index2, length))}
|
|
|
100492
100495
|
}
|
|
100493
100496
|
try {
|
|
100494
100497
|
const policyDefinition = policies[0];
|
|
100495
|
-
console.log("Selected policy for negotiation:", dataset, policyDefinition);
|
|
100496
100498
|
if (!policyDefinition) {
|
|
100497
100499
|
throw new Error("No valid policy found for negotiation");
|
|
100498
100500
|
}
|
|
100499
|
-
const assetId = dataset["@id"];
|
|
100500
100501
|
const offerId = policyDefinition["@id"];
|
|
100501
|
-
console.log(`Starting negotiation for asset ${assetId} with provider ${provider.name} (${provider.address})`);
|
|
100502
|
-
console.log("Selected policy definition:", policyDefinition);
|
|
100503
|
-
const negotiationKey = `${assetId}@${provider.address}`;
|
|
100504
100502
|
this.negotiations.set(negotiationKey, {
|
|
100505
100503
|
status: "negotiating",
|
|
100506
100504
|
offerId,
|
|
@@ -100508,35 +100506,16 @@ ${escapeText(this.code(index2, length))}
|
|
|
100508
100506
|
assetId
|
|
100509
100507
|
});
|
|
100510
100508
|
this.render();
|
|
100511
|
-
const
|
|
100512
|
-
if (!store2) {
|
|
100513
|
-
console.error("Store not available for negotiation");
|
|
100514
|
-
return;
|
|
100515
|
-
}
|
|
100516
|
-
const contractOffer = {
|
|
100517
|
-
"@context": "http://www.w3.org/ns/odrl.jsonld",
|
|
100518
|
-
"@type": "odrl:Offer",
|
|
100519
|
-
"@id": policyDefinition["@id"],
|
|
100520
|
-
"odrl:permission": policyDefinition["odrl:permission"] || {
|
|
100521
|
-
"odrl:action": {
|
|
100522
|
-
"@id": "use"
|
|
100523
|
-
}
|
|
100524
|
-
},
|
|
100525
|
-
"odrl:prohibition": policyDefinition["odrl:prohibition"] || [],
|
|
100526
|
-
"odrl:obligation": policyDefinition["odrl:obligation"] || [],
|
|
100527
|
-
assigner: policyDefinition["assigner"] || federatedDataset.participantId,
|
|
100528
|
-
target: assetId
|
|
100529
|
-
};
|
|
100530
|
-
console.log("Contract offer for negotiation:", contractOffer);
|
|
100531
|
-
console.log("Provider Registry:", this.providerRegistry);
|
|
100532
|
-
console.log("Provider:", provider);
|
|
100533
|
-
const registryProvider = (_a3 = this.providerRegistry) == null ? void 0 : _a3.getProviderByAddress(provider.address);
|
|
100509
|
+
const registryProvider = (_c = this.providerRegistry) == null ? void 0 : _c.getProviderByAddress(provider.address);
|
|
100534
100510
|
const participantId = (registryProvider == null ? void 0 : registryProvider.participantId) || federatedDataset.participantId;
|
|
100535
100511
|
if (!participantId) {
|
|
100536
100512
|
throw new Error(`No participant ID found for provider ${provider.name}`);
|
|
100537
100513
|
}
|
|
100538
|
-
const
|
|
100539
|
-
|
|
100514
|
+
const processedPolicy = {
|
|
100515
|
+
...policyDefinition,
|
|
100516
|
+
target: policyDefinition.target || assetId
|
|
100517
|
+
};
|
|
100518
|
+
const negotiationId = await store2.negotiateContract(provider.address, assetId, processedPolicy, participantId);
|
|
100540
100519
|
this.negotiations.set(negotiationKey, {
|
|
100541
100520
|
status: "pending",
|
|
100542
100521
|
negotiationId,
|
|
@@ -100548,8 +100527,8 @@ ${escapeText(this.code(index2, length))}
|
|
|
100548
100527
|
this.pollNegotiationStatus(negotiationKey, negotiationId);
|
|
100549
100528
|
} catch (error2) {
|
|
100550
100529
|
console.error("Contract negotiation failed:", error2);
|
|
100551
|
-
const
|
|
100552
|
-
this.negotiations.set(
|
|
100530
|
+
const negotiationKey2 = `${dataset["@id"]}@${provider.address}`;
|
|
100531
|
+
this.negotiations.set(negotiationKey2, {
|
|
100553
100532
|
status: "failed",
|
|
100554
100533
|
error: error2.message,
|
|
100555
100534
|
provider,
|
|
@@ -100570,7 +100549,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
100570
100549
|
}
|
|
100571
100550
|
const status = await store2.getNegotiationStatus(negotiationId);
|
|
100572
100551
|
const negotiation2 = this.negotiations.get(negotiationKey);
|
|
100573
|
-
console.log(`Polling attempt ${attempt + 1}: Negotiation ${negotiationId} state: ${status.state}`);
|
|
100574
100552
|
this.negotiations.set(negotiationKey, {
|
|
100575
100553
|
...negotiation2,
|
|
100576
100554
|
status: "pending",
|
|
@@ -100580,11 +100558,23 @@ ${escapeText(this.code(index2, length))}
|
|
|
100580
100558
|
});
|
|
100581
100559
|
this.render();
|
|
100582
100560
|
if (status.state === "FINALIZED" || status.state === "AGREED") {
|
|
100583
|
-
|
|
100584
|
-
|
|
100585
|
-
|
|
100586
|
-
|
|
100587
|
-
|
|
100561
|
+
try {
|
|
100562
|
+
const agreement = await store2.getContractAgreement(negotiationId);
|
|
100563
|
+
const contractId = agreement ? agreement["@id"] : status.contractAgreementId || negotiationId;
|
|
100564
|
+
this.negotiations.set(negotiationKey, {
|
|
100565
|
+
...negotiation2,
|
|
100566
|
+
status: "granted",
|
|
100567
|
+
contractId,
|
|
100568
|
+
agreement
|
|
100569
|
+
});
|
|
100570
|
+
} catch (error2) {
|
|
100571
|
+
console.error("Failed to retrieve contract agreement:", error2);
|
|
100572
|
+
this.negotiations.set(negotiationKey, {
|
|
100573
|
+
...negotiation2,
|
|
100574
|
+
status: "granted",
|
|
100575
|
+
contractId: status.contractAgreementId || negotiationId
|
|
100576
|
+
});
|
|
100577
|
+
}
|
|
100588
100578
|
this.render();
|
|
100589
100579
|
return;
|
|
100590
100580
|
}
|
|
@@ -100611,6 +100601,144 @@ ${escapeText(this.code(index2, length))}
|
|
|
100611
100601
|
});
|
|
100612
100602
|
this.render();
|
|
100613
100603
|
},
|
|
100604
|
+
async initiateEDRTransfer(federatedDataset, negotiation) {
|
|
100605
|
+
const { dataset, provider } = federatedDataset;
|
|
100606
|
+
const assetId = dataset["@id"];
|
|
100607
|
+
const negotiationKey = `${assetId}@${provider.address}`;
|
|
100608
|
+
try {
|
|
100609
|
+
this.negotiations.set(negotiationKey, {
|
|
100610
|
+
...negotiation,
|
|
100611
|
+
status: "transferring"
|
|
100612
|
+
});
|
|
100613
|
+
this.render();
|
|
100614
|
+
const store2 = this.stores.get("default");
|
|
100615
|
+
if (!store2) {
|
|
100616
|
+
throw new Error("Store not available for EDR transfer");
|
|
100617
|
+
}
|
|
100618
|
+
const transferId = await store2.initiateEDRTransfer(assetId, provider.address, negotiation.contractId);
|
|
100619
|
+
const edrDataAddress = await store2.getEDRToken(transferId);
|
|
100620
|
+
if (!edrDataAddress) {
|
|
100621
|
+
throw new Error("Failed to retrieve EDR token");
|
|
100622
|
+
}
|
|
100623
|
+
let transformedEndpoint = edrDataAddress.endpoint;
|
|
100624
|
+
if (transformedEndpoint.includes("localhost") || transformedEndpoint.includes("127.0.0.1")) {
|
|
100625
|
+
const providerBase = provider.address.replace("/protocol", "");
|
|
100626
|
+
const localUrl = new URL(transformedEndpoint);
|
|
100627
|
+
transformedEndpoint = `${providerBase}${localUrl.pathname}${localUrl.search}`;
|
|
100628
|
+
}
|
|
100629
|
+
this.negotiations.set(negotiationKey, {
|
|
100630
|
+
...negotiation,
|
|
100631
|
+
status: "granted",
|
|
100632
|
+
transferId,
|
|
100633
|
+
edrToken: edrDataAddress.authorization,
|
|
100634
|
+
edrEndpoint: transformedEndpoint
|
|
100635
|
+
});
|
|
100636
|
+
this.render();
|
|
100637
|
+
} catch (error2) {
|
|
100638
|
+
console.error("EDR transfer failed:", error2);
|
|
100639
|
+
this.negotiations.set(negotiationKey, {
|
|
100640
|
+
...negotiation,
|
|
100641
|
+
status: "granted",
|
|
100642
|
+
transferError: error2.message
|
|
100643
|
+
});
|
|
100644
|
+
this.render();
|
|
100645
|
+
}
|
|
100646
|
+
},
|
|
100647
|
+
async accessData(federatedDataset, negotiation) {
|
|
100648
|
+
const { dataset, provider } = federatedDataset;
|
|
100649
|
+
const assetId = dataset["@id"];
|
|
100650
|
+
const negotiationKey = `${assetId}@${provider.address}`;
|
|
100651
|
+
try {
|
|
100652
|
+
this.negotiations.set(negotiationKey, {
|
|
100653
|
+
...negotiation,
|
|
100654
|
+
status: "accessing-data"
|
|
100655
|
+
});
|
|
100656
|
+
this.render();
|
|
100657
|
+
const store2 = this.stores.get("default");
|
|
100658
|
+
if (!store2 || !negotiation.edrToken || !negotiation.edrEndpoint) {
|
|
100659
|
+
throw new Error("Missing store or EDR token information");
|
|
100660
|
+
}
|
|
100661
|
+
let transformedEndpoint = negotiation.edrEndpoint;
|
|
100662
|
+
if (transformedEndpoint.includes("localhost") || transformedEndpoint.includes("127.0.0.1")) {
|
|
100663
|
+
const providerBase = provider.address.replace("/protocol", "");
|
|
100664
|
+
const localUrl = new URL(transformedEndpoint);
|
|
100665
|
+
transformedEndpoint = `${providerBase}${localUrl.pathname}${localUrl.search}`;
|
|
100666
|
+
}
|
|
100667
|
+
const edrDataAddress = {
|
|
100668
|
+
endpoint: transformedEndpoint,
|
|
100669
|
+
authorization: negotiation.edrToken,
|
|
100670
|
+
authType: "bearer",
|
|
100671
|
+
type: "https://w3id.org/idsa/v4.1/HTTP",
|
|
100672
|
+
endpointType: "https://w3id.org/idsa/v4.1/HTTP"
|
|
100673
|
+
};
|
|
100674
|
+
const data = await this.fetchDataWithLongPolling(store2, edrDataAddress, assetId, provider);
|
|
100675
|
+
const preview = JSON.stringify(data, null, 2).substring(0, 500);
|
|
100676
|
+
alert(`Data retrieved successfully!
|
|
100677
|
+
|
|
100678
|
+
Preview (first 500 chars):
|
|
100679
|
+
${preview}${JSON.stringify(data).length > 500 ? "..." : ""}`);
|
|
100680
|
+
this.negotiations.set(negotiationKey, {
|
|
100681
|
+
...negotiation,
|
|
100682
|
+
status: "granted"
|
|
100683
|
+
});
|
|
100684
|
+
this.render();
|
|
100685
|
+
} catch (error2) {
|
|
100686
|
+
console.error("Data access failed:", error2);
|
|
100687
|
+
this.negotiations.set(negotiationKey, {
|
|
100688
|
+
...negotiation,
|
|
100689
|
+
status: "granted",
|
|
100690
|
+
dataAccessError: error2.message
|
|
100691
|
+
});
|
|
100692
|
+
this.render();
|
|
100693
|
+
alert(`Data access failed: ${error2.message}`);
|
|
100694
|
+
}
|
|
100695
|
+
},
|
|
100696
|
+
async fetchDataWithLongPolling(store2, edrDataAddress, assetId, provider, maxAttempts = 12, pollInterval = 5e3) {
|
|
100697
|
+
const negotiationKey = `${assetId}@${provider.address}`;
|
|
100698
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
100699
|
+
const currentNegotiation = this.negotiations.get(negotiationKey);
|
|
100700
|
+
if (currentNegotiation) {
|
|
100701
|
+
this.negotiations.set(negotiationKey, {
|
|
100702
|
+
...currentNegotiation,
|
|
100703
|
+
status: "accessing-data",
|
|
100704
|
+
dataAccessAttempt: attempt,
|
|
100705
|
+
dataAccessMaxAttempts: maxAttempts
|
|
100706
|
+
});
|
|
100707
|
+
this.render();
|
|
100708
|
+
}
|
|
100709
|
+
try {
|
|
100710
|
+
const data = await store2.fetchWithEDRToken(edrDataAddress);
|
|
100711
|
+
if (data) {
|
|
100712
|
+
return data;
|
|
100713
|
+
}
|
|
100714
|
+
} catch (error2) {
|
|
100715
|
+
const errorMessage = error2.message;
|
|
100716
|
+
console.warn(`\u26A0\uFE0F Data access attempt ${attempt}/${maxAttempts} failed:`, errorMessage);
|
|
100717
|
+
const isRetryableError = errorMessage.includes("404") || errorMessage.includes("503") || errorMessage.includes("502") || errorMessage.includes("timeout") || errorMessage.includes("not ready") || errorMessage.includes("processing");
|
|
100718
|
+
if (attempt === maxAttempts || !isRetryableError) {
|
|
100719
|
+
console.error(`\u274C Final data access attempt failed: ${errorMessage}`);
|
|
100720
|
+
throw error2;
|
|
100721
|
+
}
|
|
100722
|
+
}
|
|
100723
|
+
if (attempt < maxAttempts) {
|
|
100724
|
+
for (let countdown = pollInterval / 1e3; countdown > 0; countdown--) {
|
|
100725
|
+
const currentNegotiation2 = this.negotiations.get(negotiationKey);
|
|
100726
|
+
if (currentNegotiation2) {
|
|
100727
|
+
this.negotiations.set(negotiationKey, {
|
|
100728
|
+
...currentNegotiation2,
|
|
100729
|
+
status: "accessing-data",
|
|
100730
|
+
dataAccessAttempt: attempt,
|
|
100731
|
+
dataAccessMaxAttempts: maxAttempts,
|
|
100732
|
+
countdown
|
|
100733
|
+
});
|
|
100734
|
+
this.render();
|
|
100735
|
+
}
|
|
100736
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
100737
|
+
}
|
|
100738
|
+
}
|
|
100739
|
+
}
|
|
100740
|
+
throw new Error(`Data access failed after ${maxAttempts} attempts over ${maxAttempts * pollInterval / 1e3} seconds`);
|
|
100741
|
+
},
|
|
100614
100742
|
toggleProvider(providerAddress) {
|
|
100615
100743
|
if (this.selectedProviders.has(providerAddress)) {
|
|
100616
100744
|
this.selectedProviders.delete(providerAddress);
|
|
@@ -100621,9 +100749,7 @@ ${escapeText(this.code(index2, length))}
|
|
|
100621
100749
|
},
|
|
100622
100750
|
handleSearchInput(event) {
|
|
100623
100751
|
const input = event.target;
|
|
100624
|
-
console.log("Search input changed:", input.value);
|
|
100625
100752
|
this.searchQuery = input.value;
|
|
100626
|
-
console.log("Updated searchQuery state:", this.searchQuery);
|
|
100627
100753
|
this.render();
|
|
100628
100754
|
},
|
|
100629
100755
|
render() {
|
|
@@ -100777,32 +100903,83 @@ ${escapeText(this.code(index2, length))}
|
|
|
100777
100903
|
renderNegotiationButton(item, negotiationKey) {
|
|
100778
100904
|
const { dataset, provider } = item;
|
|
100779
100905
|
const negotiation = this.negotiations.get(negotiationKey);
|
|
100906
|
+
const assetId = dataset["@id"];
|
|
100780
100907
|
const policies = this.getPoliciesFromDataset(dataset);
|
|
100781
100908
|
if (policies.length === 0) {
|
|
100782
100909
|
return x`<span class="no-policy">No policies available</span>`;
|
|
100783
100910
|
}
|
|
100911
|
+
if (!negotiation) {
|
|
100912
|
+
const store2 = this.stores.get("default");
|
|
100913
|
+
if (store2) {
|
|
100914
|
+
const existingAgreement = store2.getAssetAgreement(assetId);
|
|
100915
|
+
if (existingAgreement) {
|
|
100916
|
+
return x`<button class="negotiate-btn existing-agreement" @click=${() => this.negotiateAccess(item)}>
|
|
100917
|
+
♻️ Use Existing Agreement
|
|
100918
|
+
</button>`;
|
|
100919
|
+
}
|
|
100920
|
+
}
|
|
100921
|
+
}
|
|
100784
100922
|
if (negotiation) {
|
|
100785
100923
|
switch (negotiation.status) {
|
|
100786
100924
|
case "negotiating":
|
|
100787
100925
|
return x`<button class="negotiate-btn negotiating" disabled>
|
|
100788
|
-
Negotiating with ${provider.name}...
|
|
100926
|
+
<span class="spinner">⏳</span> Negotiating with ${provider.name}...
|
|
100789
100927
|
</button>`;
|
|
100790
100928
|
case "pending":
|
|
100791
100929
|
return x`<div class="negotiation-info">
|
|
100792
100930
|
<span class="negotiation-provider">Provider: ${provider.name}</span>
|
|
100793
100931
|
<span class="negotiation-id">Negotiation: ${negotiation.negotiationId}</span>
|
|
100794
100932
|
<span class="negotiation-status pending">
|
|
100795
|
-
|
|
100933
|
+
<span class="spinner">⏳</span>
|
|
100934
|
+
${negotiation.currentState || "Pending"}
|
|
100796
100935
|
${negotiation.attempt ? `(${negotiation.attempt}/${negotiation.maxAttempts})` : ""}
|
|
100797
100936
|
</span>
|
|
100798
100937
|
</div>`;
|
|
100938
|
+
case "transferring":
|
|
100939
|
+
return x`<div class="negotiation-info">
|
|
100940
|
+
<span class="negotiation-provider">Provider: ${provider.name}</span>
|
|
100941
|
+
<span class="contract-id">Contract: ${negotiation.contractId}</span>
|
|
100942
|
+
<span class="negotiation-status pending">
|
|
100943
|
+
<span class="spinner">🚀</span> Getting EDR Token...
|
|
100944
|
+
</span>
|
|
100945
|
+
</div>`;
|
|
100946
|
+
case "accessing-data": {
|
|
100947
|
+
const progressPercent = negotiation.dataAccessAttempt && negotiation.dataAccessMaxAttempts ? negotiation.dataAccessAttempt / negotiation.dataAccessMaxAttempts * 100 : 0;
|
|
100948
|
+
return x`<div class="negotiation-info">
|
|
100949
|
+
<span class="negotiation-provider">Provider: ${provider.name}</span>
|
|
100950
|
+
<span class="contract-id">Contract: ${negotiation.contractId}</span>
|
|
100951
|
+
<span class="negotiation-status pending">
|
|
100952
|
+
<span class="spinner">📡</span> Accessing Data
|
|
100953
|
+
${negotiation.dataAccessAttempt ? ` (${negotiation.dataAccessAttempt}/${negotiation.dataAccessMaxAttempts})` : "..."}
|
|
100954
|
+
${negotiation.countdown ? x`<br><span class="countdown">⏳ Next retry in ${negotiation.countdown}s</span>` : ""}
|
|
100955
|
+
</span>
|
|
100956
|
+
${negotiation.dataAccessAttempt ? x`<div class="progress-container">
|
|
100957
|
+
<div class="progress-bar" style="width: ${progressPercent}%"></div>
|
|
100958
|
+
</div>` : ""}
|
|
100959
|
+
</div>`;
|
|
100960
|
+
}
|
|
100799
100961
|
case "granted":
|
|
100800
100962
|
return x`<div class="negotiation-success">
|
|
100801
100963
|
<span class="access-granted">✅ Access Granted via ${provider.name}</span>
|
|
100802
100964
|
<span class="contract-id">Contract: ${negotiation.contractId}</span>
|
|
100803
|
-
|
|
100804
|
-
|
|
100805
|
-
|
|
100965
|
+
${negotiation.transferError ? x`
|
|
100966
|
+
<span class="transfer-error">⚠️ ${negotiation.transferError}</span>
|
|
100967
|
+
<button class="negotiate-btn retry" @click=${() => this.initiateEDRTransfer(item, negotiation)}>
|
|
100968
|
+
🔄 Retry EDR
|
|
100969
|
+
</button>
|
|
100970
|
+
` : ""}
|
|
100971
|
+
<div class="api-access-actions">
|
|
100972
|
+
${!negotiation.edrToken ? x`
|
|
100973
|
+
<button class="negotiate-btn" @click=${() => this.initiateEDRTransfer(item, negotiation)}>
|
|
100974
|
+
🚀 Get EDR Token
|
|
100975
|
+
</button>
|
|
100976
|
+
` : x`
|
|
100977
|
+
<span class="edr-ready">🔑 EDR Token Ready</span>
|
|
100978
|
+
<button class="negotiate-btn" @click=${() => this.accessData(item, negotiation)}>
|
|
100979
|
+
📁 Access Data
|
|
100980
|
+
</button>
|
|
100981
|
+
`}
|
|
100982
|
+
</div>
|
|
100806
100983
|
</div>`;
|
|
100807
100984
|
case "failed":
|
|
100808
100985
|
return x`<div class="negotiation-error">
|
|
@@ -101094,7 +101271,6 @@ ${escapeText(this.code(index2, length))}
|
|
|
101094
101271
|
this.searchForm = document.getElementById(filteredBy);
|
|
101095
101272
|
if (!filteredBy) throw "#Missing filtered-by attribute";
|
|
101096
101273
|
await this.initLocalDataSourceContainerForSearchResults();
|
|
101097
|
-
console.log("Init index based search", this.dataSrcIndex, this.dataSrcProfile);
|
|
101098
101274
|
const filterValues = this.searchForm.component.value;
|
|
101099
101275
|
this.triggerIndexSearch(filterValues);
|
|
101100
101276
|
this.searchForm.addEventListener("submit", this.onIndexSearch.bind(this));
|