@icure/api 6.2.1 → 6.3.0

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.
@@ -224,6 +224,7 @@ export declare class IccCryptoXApi {
224
224
  initEncryptionKeys(createdObject: any, ownerId: string): Promise<{
225
225
  encryptionKeys: any;
226
226
  secretId: string;
227
+ modifiedOwner: Patient | Device | HealthcareParty;
227
228
  }>;
228
229
  /**
229
230
  * Gets an updated instance of the EKs of `modifiedObject`.
@@ -427,6 +427,7 @@ class IccCryptoXApi {
427
427
  this.throwDetailedExceptionForInvalidParameter('parentObject.id', parentObject.id, 'initObjectDelegations', arguments);
428
428
  const secretId = this.randomUuid();
429
429
  return this.getDataOwner(ownerId).then(({ dataOwner: owner }) => __awaiter(this, void 0, void 0, function* () {
430
+ var _a, _b;
430
431
  const { owner: modifiedOwner, aesExchangeKeys } = yield this.getOrCreateHcPartyKeys(owner, ownerId);
431
432
  const importedAESHcPartyKey = yield this.decryptAnyAesExchangeKeyForOwner(aesExchangeKeys, ownerId, ownerId, ownerId, publicKeys);
432
433
  const encryptedDelegation = yield this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(createdObject.id + ':' + secretId).buffer, importedAESHcPartyKey.rawKey);
@@ -435,33 +436,22 @@ class IccCryptoXApi {
435
436
  : undefined;
436
437
  return {
437
438
  owner: modifiedOwner,
438
- delegations: _.fromPairs([
439
- [
440
- ownerId,
441
- [
439
+ delegations: Object.assign(Object.assign({}, ((_a = createdObject.delegations) !== null && _a !== void 0 ? _a : {})), { [ownerId]: [
440
+ {
441
+ owner: ownerId,
442
+ delegatedTo: ownerId,
443
+ key: (0, binary_utils_1.ua2hex)(encryptedDelegation),
444
+ },
445
+ ] }),
446
+ cryptedForeignKeys: (encryptedSecretForeignKey
447
+ ? Object.assign(Object.assign({}, ((_b = createdObject.cryptedForeignKeys) !== null && _b !== void 0 ? _b : {})), { [ownerId]: [
442
448
  {
443
449
  owner: ownerId,
444
450
  delegatedTo: ownerId,
445
- key: (0, binary_utils_1.ua2hex)(encryptedDelegation),
451
+ key: (0, binary_utils_1.ua2hex)(encryptedSecretForeignKey),
446
452
  },
447
- ],
448
- ],
449
- ]),
450
- cryptedForeignKeys: (encryptedSecretForeignKey
451
- ? _.fromPairs([
452
- [
453
- ownerId,
454
- [
455
- {
456
- owner: ownerId,
457
- delegatedTo: ownerId,
458
- key: (0, binary_utils_1.ua2hex)(encryptedSecretForeignKey),
459
- },
460
- ],
461
- ],
462
- ])
463
- : {}) || {},
464
- secretForeignKeys: (secretForeignKeyOfParent && [secretForeignKeyOfParent]) || [],
453
+ ] }) : {}) || {},
454
+ secretForeignKeys: secretForeignKeyOfParent ? [secretForeignKeyOfParent] : [],
465
455
  secretId: secretId,
466
456
  };
467
457
  }));
@@ -675,6 +665,7 @@ class IccCryptoXApi {
675
665
  ],
676
666
  ]),
677
667
  secretId: secretId,
668
+ modifiedOwner
678
669
  };
679
670
  }));
680
671
  }