@icure/api 5.0.23 → 5.0.24

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.
@@ -879,7 +879,8 @@ class IccCryptoXApi {
879
879
  extractKeysFromDelegationsForHcpHierarchy(
880
880
  //TODO suggested name: getSecretIdsOfHcpAndParentsFromGenericDelegations
881
881
  dataOwnerId, objectId, delegations) {
882
- return this.getDataOwner(dataOwnerId).then(({ dataOwner: hcp }) => (delegations[dataOwnerId] && delegations[dataOwnerId].length
882
+ return this.getDataOwner(dataOwnerId)
883
+ .then(({ dataOwner: hcp }) => (delegations[dataOwnerId] && delegations[dataOwnerId].length
883
884
  ? this.getDecryptedAesExchangeKeysOfDelegateAndParentsFromGenericDelegations(dataOwnerId, delegations, false).then((decryptedAndImportedAesHcPartyKeys) => {
884
885
  const collatedAesKeysFromDelegatorToHcpartyId = {};
885
886
  decryptedAndImportedAesHcPartyKeys.forEach((k) => {
@@ -889,11 +890,17 @@ class IccCryptoXApi {
889
890
  });
890
891
  return this.decryptKeyInDelegationLikes(delegations[dataOwnerId], collatedAesKeysFromDelegatorToHcpartyId, objectId);
891
892
  })
892
- : Promise.resolve([])).then((extractedKeys) => hcp.parentId
893
- ? this.extractKeysFromDelegationsForHcpHierarchy(hcp.parentId, objectId, delegations).then((parentResponse) => _.assign(parentResponse, {
894
- extractedKeys: parentResponse.extractedKeys.concat(extractedKeys),
895
- }))
896
- : { extractedKeys: extractedKeys, hcpartyId: dataOwnerId }));
893
+ : Promise.resolve([])).then((extractedKeys) => __awaiter(this, void 0, void 0, function* () {
894
+ var _a;
895
+ const parentExtractedKeys = hcp.parentId
896
+ ? yield this.extractKeysFromDelegationsForHcpHierarchy(hcp.parentId, objectId, delegations)
897
+ : { extractedKeys: [], hcpartyId: undefined };
898
+ return { extractedKeys: extractedKeys.concat(parentExtractedKeys.extractedKeys), hcpartyId: (_a = parentExtractedKeys.hcpartyId) !== null && _a !== void 0 ? _a : dataOwnerId };
899
+ })))
900
+ .catch((e) => {
901
+ console.error(`Dataowner with id ${dataOwnerId} cannot be resolved`);
902
+ throw e;
903
+ });
897
904
  }
898
905
  /**
899
906
  * Gets an array of generic secret IDs decrypted from a list of generic delegations (SPKs, CFKs, EKs) `delegationsArray`