@icure/api 4.2.33 → 4.2.36

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.
Files changed (109) hide show
  1. package/icc-api/api/IccAuthApi.d.ts +6 -0
  2. package/icc-api/api/IccAuthApi.js +15 -0
  3. package/icc-api/api/IccAuthApi.js.map +1 -1
  4. package/icc-api/api/XHR.js +1 -1
  5. package/icc-api/api/XHR.js.map +1 -1
  6. package/icc-api/iccApi.js +5 -1
  7. package/icc-api/iccApi.js.map +1 -1
  8. package/icc-api/index.js +5 -1
  9. package/icc-api/index.js.map +1 -1
  10. package/icc-api/model/Body.js +1 -1
  11. package/icc-api/model/Body.js.map +1 -1
  12. package/icc-api/model/Body1.js +1 -1
  13. package/icc-api/model/Body1.js.map +1 -1
  14. package/icc-api/model/Body2.js +1 -1
  15. package/icc-api/model/Body2.js.map +1 -1
  16. package/icc-api/model/Body3.js +1 -1
  17. package/icc-api/model/Body3.js.map +1 -1
  18. package/icc-api/model/ByteArray.js +1 -1
  19. package/icc-api/model/ByteArray.js.map +1 -1
  20. package/icc-api/model/Content.js +1 -1
  21. package/icc-api/model/Content.js.map +1 -1
  22. package/icc-api/model/Device.js +1 -1
  23. package/icc-api/model/Device.js.map +1 -1
  24. package/icc-api/model/Document.js +1 -1
  25. package/icc-api/model/Document.js.map +1 -1
  26. package/icc-api/model/DocumentTemplate.js +1 -1
  27. package/icc-api/model/DocumentTemplate.js.map +1 -1
  28. package/icc-api/model/HealthcareParty.js +1 -1
  29. package/icc-api/model/HealthcareParty.js.map +1 -1
  30. package/icc-api/model/MimeAttachment.js +1 -1
  31. package/icc-api/model/MimeAttachment.js.map +1 -1
  32. package/icc-api/model/Patient.js +1 -1
  33. package/icc-api/model/Patient.js.map +1 -1
  34. package/icc-api/model/models.js +5 -1
  35. package/icc-api/model/models.js.map +1 -1
  36. package/icc-x-api/crypto/AES.js +1 -1
  37. package/icc-x-api/crypto/AES.js.map +1 -1
  38. package/icc-x-api/crypto/utils.js +37 -36
  39. package/icc-x-api/crypto/utils.js.map +1 -1
  40. package/icc-x-api/filters/filters.js +7 -3
  41. package/icc-x-api/filters/filters.js.map +1 -1
  42. package/icc-x-api/icc-accesslog-x-api.d.ts +3 -3
  43. package/icc-x-api/icc-accesslog-x-api.js +15 -15
  44. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  45. package/icc-x-api/icc-bekmehr-x-api.js +2 -2
  46. package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
  47. package/icc-x-api/icc-calendar-item-x-api.d.ts +3 -3
  48. package/icc-x-api/icc-calendar-item-x-api.js +17 -17
  49. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  50. package/icc-x-api/icc-classification-x-api.d.ts +3 -3
  51. package/icc-x-api/icc-classification-x-api.js +4 -4
  52. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  53. package/icc-x-api/icc-contact-x-api.d.ts +3 -3
  54. package/icc-x-api/icc-contact-x-api.js +27 -27
  55. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  56. package/icc-x-api/icc-crypto-x-api.d.ts +4 -2
  57. package/icc-x-api/icc-crypto-x-api.js +50 -48
  58. package/icc-x-api/icc-crypto-x-api.js.map +1 -1
  59. package/icc-x-api/icc-data-owner-x-api.d.ts +14 -0
  60. package/icc-x-api/icc-data-owner-x-api.js +44 -0
  61. package/icc-x-api/icc-data-owner-x-api.js.map +1 -0
  62. package/icc-x-api/icc-doctemplate-x-api.js +2 -2
  63. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  64. package/icc-x-api/icc-document-x-api.d.ts +3 -3
  65. package/icc-x-api/icc-document-x-api.js +8 -8
  66. package/icc-x-api/icc-document-x-api.js.map +1 -1
  67. package/icc-x-api/icc-form-x-api.d.ts +3 -3
  68. package/icc-x-api/icc-form-x-api.js +8 -8
  69. package/icc-x-api/icc-form-x-api.js.map +1 -1
  70. package/icc-x-api/icc-hcparty-x-api.js +4 -4
  71. package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
  72. package/icc-x-api/icc-helement-x-api.d.ts +3 -3
  73. package/icc-x-api/icc-helement-x-api.js +15 -15
  74. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  75. package/icc-x-api/icc-invoice-x-api.d.ts +3 -3
  76. package/icc-x-api/icc-invoice-x-api.js +5 -5
  77. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  78. package/icc-x-api/icc-maintenance-task-x-api.d.ts +6 -3
  79. package/icc-x-api/icc-maintenance-task-x-api.js +26 -12
  80. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  81. package/icc-x-api/icc-message-x-api.d.ts +3 -3
  82. package/icc-x-api/icc-message-x-api.js +4 -4
  83. package/icc-x-api/icc-message-x-api.js.map +1 -1
  84. package/icc-x-api/icc-patient-x-api.d.ts +3 -3
  85. package/icc-x-api/icc-patient-x-api.js +44 -44
  86. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  87. package/icc-x-api/icc-receipt-x-api.d.ts +3 -3
  88. package/icc-x-api/icc-receipt-x-api.js +5 -5
  89. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  90. package/icc-x-api/icc-time-table-x-api.d.ts +3 -3
  91. package/icc-x-api/icc-time-table-x-api.js +5 -5
  92. package/icc-x-api/icc-time-table-x-api.js.map +1 -1
  93. package/icc-x-api/icc-user-x-api.d.ts +0 -2
  94. package/icc-x-api/icc-user-x-api.js +0 -8
  95. package/icc-x-api/icc-user-x-api.js.map +1 -1
  96. package/icc-x-api/index.d.ts +3 -1
  97. package/icc-x-api/index.js +29 -20
  98. package/icc-x-api/index.js.map +1 -1
  99. package/icc-x-api/utils/binary-utils.js +5 -5
  100. package/icc-x-api/utils/binary-utils.js.map +1 -1
  101. package/icc-x-api/utils/formatting-util.js +3 -3
  102. package/icc-x-api/utils/formatting-util.js.map +1 -1
  103. package/icc-x-api/utils/index.js +5 -1
  104. package/icc-x-api/utils/index.js.map +1 -1
  105. package/icc-x-api/utils/uuid-encoder.js +2 -0
  106. package/icc-x-api/utils/uuid-encoder.js.map +1 -1
  107. package/index.js +5 -1
  108. package/index.js.map +1 -1
  109. package/package.json +1 -1
@@ -89,7 +89,7 @@ class IccCryptoXApi {
89
89
  return this._RSA.loadKeyPairImported(hcp.id).then((keyPair) => this._RSA.exportKey(keyPair.privateKey, 'pkcs8').then((exportedKey) => {
90
90
  const privateKey = exportedKey;
91
91
  const nLen = notaries.length;
92
- const shares = nLen == 1 ? [privateKey] : this._shamir.share(binary_utils_1.ua2hex(privateKey), nLen, threshold || nLen).map((share) => binary_utils_1.hex2ua(share));
92
+ const shares = nLen == 1 ? [privateKey] : this._shamir.share((0, binary_utils_1.ua2hex)(privateKey), nLen, threshold || nLen).map((share) => (0, binary_utils_1.hex2ua)(share));
93
93
  return _.reduce(notaries, (queue, notary, idx) => {
94
94
  return queue.then((hcp) => __awaiter(this, void 0, void 0, function* () {
95
95
  const hcParty = hcp.hcPartyKeys[notary.id] ? hcp : (yield this.generateKeyForDelegate(hcp.id, notary.id));
@@ -97,7 +97,7 @@ class IccCryptoXApi {
97
97
  const importedAESHcPartyKey = yield this.decryptHcPartyKey(hcParty.id, notary.id, hcParty.hcPartyKeys[notary.id][1], false);
98
98
  const encryptedShamirPartition = yield this.AES.encrypt(importedAESHcPartyKey.key, shares[idx]);
99
99
  hcParty.privateKeyShamirPartitions = hcParty.privateKeyShamirPartitions || {};
100
- hcParty.privateKeyShamirPartitions[notary.id] = binary_utils_1.ua2hex(encryptedShamirPartition);
100
+ hcParty.privateKeyShamirPartitions[notary.id] = (0, binary_utils_1.ua2hex)(encryptedShamirPartition);
101
101
  }
102
102
  catch (e) {
103
103
  console.log('Error during encryptedShamirRSAKey', notary.id, e);
@@ -121,7 +121,7 @@ class IccCryptoXApi {
121
121
  if (nLen == 1) {
122
122
  const importedAESHcPartyKey = yield this.decryptHcPartyKey(hcp.id, notaries[0].id, hcp.hcPartyKeys[notaries[0].id][1], false);
123
123
  const cryptedPrivatedKey = hcp.privateKeyShamirPartitions[notaries[0].id];
124
- decryptedPrivatedKey = binary_utils_1.ua2hex(yield this.AES.decrypt(importedAESHcPartyKey.key, binary_utils_1.hex2ua(cryptedPrivatedKey)));
124
+ decryptedPrivatedKey = (0, binary_utils_1.ua2hex)(yield this.AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(cryptedPrivatedKey)));
125
125
  }
126
126
  else {
127
127
  const decryptedShares = yield _.reduce(notaries, (queue, notary) => {
@@ -132,7 +132,7 @@ class IccCryptoXApi {
132
132
  // give hcp the decrypted shares without having to also share their private keys.
133
133
  const importedAESHcPartyKey = yield this.decryptHcPartyKey(hcp.id, notary.id, hcp.hcPartyKeys[notary.id][1], false);
134
134
  const encryptedShare = hcp.privateKeyShamirPartitions[notary.id];
135
- const decryptedShamirPartition = binary_utils_1.ua2hex(yield this.AES.decrypt(importedAESHcPartyKey.key, binary_utils_1.hex2ua(encryptedShare)));
135
+ const decryptedShamirPartition = (0, binary_utils_1.ua2hex)(yield this.AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(encryptedShare)));
136
136
  shares.push(decryptedShamirPartition);
137
137
  }
138
138
  catch (e) {
@@ -143,8 +143,8 @@ class IccCryptoXApi {
143
143
  }, Promise.resolve([]));
144
144
  decryptedPrivatedKey = this._shamir.combine(decryptedShares);
145
145
  }
146
- const importedPrivateKey = yield this.RSA.importKey('pkcs8', binary_utils_1.hex2ua(decryptedPrivatedKey), ['decrypt']);
147
- const importedPublicKey = yield this.RSA.importKey('spki', binary_utils_1.hex2ua(hcp.publicKey), ['encrypt']);
146
+ const importedPrivateKey = yield this.RSA.importKey('pkcs8', (0, binary_utils_1.hex2ua)(decryptedPrivatedKey), ['decrypt']);
147
+ const importedPublicKey = yield this.RSA.importKey('spki', (0, binary_utils_1.hex2ua)(hcp.publicKey), ['encrypt']);
148
148
  const exportedKeyPair = yield this.RSA.exportKeys({ publicKey: importedPublicKey, privateKey: importedPrivateKey }, 'jwk', 'jwk');
149
149
  this.RSA.storeKeyPair(hcp.id, exportedKeyPair);
150
150
  }
@@ -178,7 +178,7 @@ class IccCryptoXApi {
178
178
  return (keyPair
179
179
  ? Promise.resolve(keyPair)
180
180
  : Promise.resolve(this._RSA.loadKeyPairNotImported(hcPartyKeyOwner)).then((keyPairInJwk) => this.cacheKeyPair(keyPairInJwk, hcPartyKeyOwner)))
181
- .then((keyPair) => this._RSA.decrypt(keyPair.privateKey, binary_utils_1.hex2ua(encryptedHcPartyKey)))
181
+ .then((keyPair) => this._RSA.decrypt(keyPair.privateKey, (0, binary_utils_1.hex2ua)(encryptedHcPartyKey)))
182
182
  .catch((e) => {
183
183
  console.log(`Cannot decrypt RSA encrypted AES HcPartyKey from ${delegatorId} to ${delegateHcPartyId} as ${encryptedForDelegator ? 'delegator' : 'delegate'}`);
184
184
  throw e;
@@ -190,7 +190,7 @@ class IccCryptoXApi {
190
190
  .then(({ decryptedHcPartyKey, decryptedImportedHcPartyKey }) => (this.hcPartyKeysCache[cacheKey] = {
191
191
  delegatorId: delegatorId,
192
192
  key: decryptedImportedHcPartyKey,
193
- rawKey: binary_utils_1.ua2hex(new Uint8Array(decryptedHcPartyKey)),
193
+ rawKey: (0, binary_utils_1.ua2hex)(new Uint8Array(decryptedHcPartyKey)),
194
194
  }));
195
195
  }
196
196
  }
@@ -314,9 +314,9 @@ class IccCryptoXApi {
314
314
  })
315
315
  .then((encryptedHcPartyKey) => this.decryptHcPartyKey(ownerId, ownerId, encryptedHcPartyKey, true))
316
316
  .then((importedAESHcPartyKey) => Promise.all([
317
- this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(createdObject.id + ':' + secretId).buffer, importedAESHcPartyKey.rawKey),
317
+ this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(createdObject.id + ':' + secretId).buffer, importedAESHcPartyKey.rawKey),
318
318
  parentObject
319
- ? this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(createdObject.id + ':' + parentObject.id).buffer, importedAESHcPartyKey.rawKey)
319
+ ? this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(createdObject.id + ':' + parentObject.id).buffer, importedAESHcPartyKey.rawKey)
320
320
  : Promise.resolve(null),
321
321
  ]))
322
322
  .then((encryptedDelegationAndSecretForeignKey) => ({
@@ -327,7 +327,7 @@ class IccCryptoXApi {
327
327
  {
328
328
  owner: ownerId,
329
329
  delegatedTo: ownerId,
330
- key: binary_utils_1.ua2hex(encryptedDelegationAndSecretForeignKey[0]),
330
+ key: (0, binary_utils_1.ua2hex)(encryptedDelegationAndSecretForeignKey[0]),
331
331
  },
332
332
  ],
333
333
  ],
@@ -340,7 +340,7 @@ class IccCryptoXApi {
340
340
  {
341
341
  owner: ownerId,
342
342
  delegatedTo: ownerId,
343
- key: binary_utils_1.ua2hex(encryptedDelegationAndSecretForeignKey[1]),
343
+ key: (0, binary_utils_1.ua2hex)(encryptedDelegationAndSecretForeignKey[1]),
344
344
  },
345
345
  ],
346
346
  ],
@@ -385,21 +385,21 @@ class IccCryptoXApi {
385
385
  .then((importedAESHcPartyKey) => Promise.all([
386
386
  Promise.all(((modifiedObject.delegations || {})[delegateId] || []).map((d) => (d.key &&
387
387
  d.owner === ownerId &&
388
- this._AES.decrypt(importedAESHcPartyKey.key, binary_utils_1.hex2ua(d.key), importedAESHcPartyKey.rawKey).catch(() => {
388
+ this._AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(d.key), importedAESHcPartyKey.rawKey).catch(() => {
389
389
  console.log(`Cannot decrypt delegation from ${d.owner} to ${d.delegatedTo} for object with id ${modifiedObject.id}:`, modifiedObject);
390
390
  return null;
391
391
  })) ||
392
392
  Promise.resolve(null))),
393
393
  Promise.all(((modifiedObject.cryptedForeignKeys || {})[delegateId] || []).map((d) => (d.key &&
394
394
  d.owner === ownerId &&
395
- this._AES.decrypt(importedAESHcPartyKey.key, binary_utils_1.hex2ua(d.key), importedAESHcPartyKey.rawKey).catch(() => {
395
+ this._AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(d.key), importedAESHcPartyKey.rawKey).catch(() => {
396
396
  console.log(`Cannot decrypt cryptedForeignKeys from ${d.owner} to ${d.delegatedTo} for object with id ${modifiedObject.id}:`, modifiedObject);
397
397
  return null;
398
398
  })) ||
399
399
  Promise.resolve(null))),
400
- this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(modifiedObject.id + ':' + secretIdOfModifiedObject).buffer, importedAESHcPartyKey.rawKey),
400
+ this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(modifiedObject.id + ':' + secretIdOfModifiedObject).buffer, importedAESHcPartyKey.rawKey),
401
401
  parentObject
402
- ? this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(modifiedObject.id + ':' + parentObject.id).buffer, importedAESHcPartyKey.rawKey)
402
+ ? this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(modifiedObject.id + ':' + parentObject.id).buffer, importedAESHcPartyKey.rawKey)
403
403
  : Promise.resolve(null),
404
404
  ]))
405
405
  .then(([previousDecryptedDelegations, previousDecryptedCryptedForeignKeys, cryptedDelegation, cryptedForeignKey]) => {
@@ -410,7 +410,7 @@ class IccCryptoXApi {
410
410
  // We merge them to get one array of objects: { d: {owner,delegatedTo,encrypted(key)}, k: decrypted(key)}
411
411
  const delegationCryptedDecrypted = _.merge(((modifiedObject.delegations || {})[delegateId] || []).map((d) => ({
412
412
  d,
413
- })), (previousDecryptedDelegations || []).map((dd) => (dd ? binary_utils_1.ua2string(dd) : null)).map((k) => ({ k })))
413
+ })), (previousDecryptedDelegations || []).map((dd) => (dd ? (0, binary_utils_1.ua2string)(dd) : null)).map((k) => ({ k })))
414
414
  .filter(({ d, k }) => !!k || d.owner !== ownerId) //Only keep the ones created by us that can still be decrypted
415
415
  .map(({ d, k }) => ({ d, k: k || this.randomUuid() })) // Use some unique id that ensures the delegation not created by us are going to be held
416
416
  .concat([
@@ -418,7 +418,7 @@ class IccCryptoXApi {
418
418
  d: {
419
419
  owner: ownerId,
420
420
  delegatedTo: delegateId,
421
- key: binary_utils_1.ua2hex(cryptedDelegation),
421
+ key: (0, binary_utils_1.ua2hex)(cryptedDelegation),
422
422
  },
423
423
  k: modifiedObject.id + ':' + secretIdOfModifiedObject,
424
424
  },
@@ -428,7 +428,7 @@ class IccCryptoXApi {
428
428
  allDelegations[delegateId] = _.uniqBy(delegationCryptedDecrypted, (x) => x.k).map((x) => x.d);
429
429
  const cryptedForeignKeysCryptedDecrypted = _.merge(((modifiedObject.cryptedForeignKeys || {})[delegateId] || []).map((d) => ({
430
430
  d,
431
- })), (previousDecryptedCryptedForeignKeys || []).map((dd) => (dd ? binary_utils_1.ua2string(dd) : null)).map((k) => ({ k })))
431
+ })), (previousDecryptedCryptedForeignKeys || []).map((dd) => (dd ? (0, binary_utils_1.ua2string)(dd) : null)).map((k) => ({ k })))
432
432
  .filter(({ d, k }) => !!k || d.owner !== ownerId) //Only keep the ones created by us that can still be decrypted
433
433
  .map(({ d, k }) => ({ d, k: k || this.randomUuid() })) // Use some unique id that ensures the delegation not created by us are going to be held
434
434
  .concat(cryptedForeignKey
@@ -437,7 +437,7 @@ class IccCryptoXApi {
437
437
  d: {
438
438
  owner: ownerId,
439
439
  delegatedTo: delegateId,
440
- key: binary_utils_1.ua2hex(cryptedForeignKey),
440
+ key: (0, binary_utils_1.ua2hex)(cryptedForeignKey),
441
441
  },
442
442
  k: modifiedObject.id + ':' + parentObject.id,
443
443
  },
@@ -472,7 +472,7 @@ class IccCryptoXApi {
472
472
  return this.getDataOwner(ownerId)
473
473
  .then(({ dataOwner: owner }) => this.getOrCreateHcPartyKey(owner, ownerId))
474
474
  .then((encryptedHcPartyKey) => this.decryptHcPartyKey(ownerId, ownerId, encryptedHcPartyKey, true))
475
- .then((importedAESHcPartyKey) => this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(createdObject.id + ':' + secretId)))
475
+ .then((importedAESHcPartyKey) => this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(createdObject.id + ':' + secretId)))
476
476
  .then((encryptedEncryptionKeys) => ({
477
477
  encryptionKeys: _.fromPairs([
478
478
  [
@@ -481,7 +481,7 @@ class IccCryptoXApi {
481
481
  {
482
482
  owner: ownerId,
483
483
  delegatedTo: ownerId,
484
- key: binary_utils_1.ua2hex(encryptedEncryptionKeys),
484
+ key: (0, binary_utils_1.ua2hex)(encryptedEncryptionKeys),
485
485
  },
486
486
  ],
487
487
  ],
@@ -496,8 +496,10 @@ class IccCryptoXApi {
496
496
  * @param ownerId : delegator HcP id
497
497
  * @param delegateId : delegate HcP id
498
498
  * @param secretEncryptionKeyOfObject : secret Id for the EK (Content Encryption Key)
499
- * @returns - **encryptionKeys** existing EKs of the `modifiedObject`, appended with a new EK item (owner: `ownerId`, delegatedTo: `delegateId`, encrypted key with secretId: `secretEncryptionKeyOfObject` )
500
- * - **secretId** which is the given input parameter `secretEncryptionKeyOfObject`
499
+ * @returns
500
+ * - **encryptionKeys** existing EKs of the `modifiedObject`, appended with a new EK item (owner: `ownerId`, delegatedTo: `delegateId`, encrypted key with secretId:
501
+ * `secretEncryptionKeyOfObject` )
502
+ * - **secretId** which is the given input parameter `secretEncryptionKeyOfObject`
501
503
  */
502
504
  appendEncryptionKeys(
503
505
  //TODO: suggested name: getExtendedEKwithDelegationFromDelegatorToDelegate
@@ -510,12 +512,12 @@ class IccCryptoXApi {
510
512
  .then((importedAESHcPartyKey) => Promise.all([
511
513
  Promise.all(((modifiedObject.encryptionKeys || {})[delegateId] || []).map((d) => (d.key &&
512
514
  d.owner === ownerId &&
513
- this._AES.decrypt(importedAESHcPartyKey.key, binary_utils_1.hex2ua(d.key), importedAESHcPartyKey.rawKey).catch(() => {
515
+ this._AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(d.key), importedAESHcPartyKey.rawKey).catch(() => {
514
516
  console.log(`Cannot decrypt encryption key from ${d.owner} to ${d.delegatedTo} for object with id ${modifiedObject.id}:`, modifiedObject);
515
517
  return null;
516
518
  })) ||
517
519
  Promise.resolve(null))),
518
- this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(modifiedObject.id + ':' + secretEncryptionKeyOfObject)),
520
+ this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(modifiedObject.id + ':' + secretEncryptionKeyOfObject)),
519
521
  ]))
520
522
  .then(([previousDecryptedEncryptionKeys, encryptedEncryptionKey]) => {
521
523
  //try to limit the extent of the modifications to the delegations by preserving the redundant encryption keys already present and removing duplicates
@@ -525,7 +527,7 @@ class IccCryptoXApi {
525
527
  // We merge them to get one array of objects: { d: {owner,delegatedTo,encrypted(key)}, k: decrypted(key)}
526
528
  const encryptionKeysCryptedDecrypted = _.merge(((modifiedObject.encryptionKeys || {})[delegateId] || []).map((d) => ({
527
529
  d,
528
- })), (previousDecryptedEncryptionKeys || []).map((dd) => (dd ? binary_utils_1.ua2string(dd) : null)).map((k) => ({ k })))
530
+ })), (previousDecryptedEncryptionKeys || []).map((dd) => (dd ? (0, binary_utils_1.ua2string)(dd) : null)).map((k) => ({ k })))
529
531
  .filter(({ d, k }) => !!k || d.owner !== ownerId) //Only keep the ones created by us that can still be decrypted
530
532
  .map(({ d, k }) => ({ d, k: k || this.randomUuid() }))
531
533
  .concat([
@@ -533,7 +535,7 @@ class IccCryptoXApi {
533
535
  d: {
534
536
  owner: ownerId,
535
537
  delegatedTo: delegateId,
536
- key: binary_utils_1.ua2hex(encryptedEncryptionKey),
538
+ key: (0, binary_utils_1.ua2hex)(encryptedEncryptionKey),
537
539
  },
538
540
  k: modifiedObject.id + ':' + secretEncryptionKeyOfObject,
539
541
  },
@@ -735,9 +737,9 @@ class IccCryptoXApi {
735
737
  const aesKey = aesKeys[genericDelegationItem.owner];
736
738
  if (aesKey) {
737
739
  decryptPromises.push(this._AES
738
- .decrypt(aesKey.key, binary_utils_1.hex2ua(genericDelegationItem.key), aesKey.rawKey)
740
+ .decrypt(aesKey.key, (0, binary_utils_1.hex2ua)(genericDelegationItem.key), aesKey.rawKey)
739
741
  .then((decryptedGenericDelegationKey) => {
740
- const results = binary_utils_1.ua2string(decryptedGenericDelegationKey).split(':');
742
+ const results = (0, binary_utils_1.ua2string)(decryptedGenericDelegationKey).split(':');
741
743
  const objectId = results[0]; //must be the ID of the object, for checksum
742
744
  const genericSecretId = results[1];
743
745
  const details = 'object ID: ' + masterId + '; generic delegation from ' + genericDelegationItem.owner + ' to ' + genericDelegationItem.delegatedTo;
@@ -771,7 +773,7 @@ class IccCryptoXApi {
771
773
  if (!publicKey) {
772
774
  throw new Error('No public key has been defined for hcp');
773
775
  }
774
- return this._RSA.importKeyPair('jwk', this._utils.pkcs8ToJwk(privateKey), 'jwk', this._utils.spkiToJwk(binary_utils_1.hex2ua(publicKey)));
776
+ return this._RSA.importKeyPair('jwk', this._utils.pkcs8ToJwk(privateKey), 'jwk', this._utils.spkiToJwk((0, binary_utils_1.hex2ua)(publicKey)));
775
777
  })
776
778
  .then((keyPair) => {
777
779
  this._RSA.rsaKeyPairs[healthcarePartyId] = keyPair;
@@ -785,7 +787,7 @@ class IccCryptoXApi {
785
787
  loadKeyPairsAsJwkInBrowserLocalStorage(healthcarePartyId, privKey) {
786
788
  return this.getDataOwner(healthcarePartyId)
787
789
  .then(({ dataOwner }) => {
788
- const pubKey = this._utils.spkiToJwk(binary_utils_1.hex2ua(dataOwner.publicKey));
790
+ const pubKey = this._utils.spkiToJwk((0, binary_utils_1.hex2ua)(dataOwner.publicKey));
789
791
  privKey.n = pubKey.n;
790
792
  privKey.e = pubKey.e;
791
793
  return this._RSA.importKeyPair('jwk', privKey, 'jwk', pubKey);
@@ -807,14 +809,14 @@ class IccCryptoXApi {
807
809
  fr.onload = (e) => {
808
810
  //TODO remove any
809
811
  const privateKey = e.target.result;
810
- this.loadKeyPairsAsTextInBrowserLocalStorage(healthcarePartyId, binary_utils_1.hex2ua(privateKey)).then(resolve).catch(reject);
812
+ this.loadKeyPairsAsTextInBrowserLocalStorage(healthcarePartyId, (0, binary_utils_1.hex2ua)(privateKey)).then(resolve).catch(reject);
811
813
  };
812
814
  fr.readAsText(file);
813
815
  });
814
816
  }
815
817
  // noinspection JSUnusedGlobalSymbols
816
818
  saveKeychainInBrowserLocalStorage(id, keychain) {
817
- localStorage.setItem(this.keychainLocalStoreIdPrefix + id, binary_utils_1.b2a(new Uint8Array(keychain).reduce((data, byte) => data + String.fromCharCode(byte), '')));
819
+ localStorage.setItem(this.keychainLocalStoreIdPrefix + id, (0, binary_utils_1.b2a)(new Uint8Array(keychain).reduce((data, byte) => data + String.fromCharCode(byte), '')));
818
820
  }
819
821
  saveKeychainInBrowserLocalStorageAsBase64(id, keyChainB64) {
820
822
  localStorage.setItem(this.keychainLocalStoreIdPrefix + id, keyChainB64);
@@ -854,13 +856,13 @@ class IccCryptoXApi {
854
856
  if (!!aesKey && !!crt) {
855
857
  let crtEncrypted = null;
856
858
  try {
857
- crtEncrypted = yield this.AES.encrypt(aesKey, new Uint8Array(binary_utils_1.string2ua(atob(crt))));
859
+ crtEncrypted = yield this.AES.encrypt(aesKey, new Uint8Array((0, binary_utils_1.string2ua)(atob(crt))));
858
860
  }
859
861
  catch (e) {
860
862
  console.error('Error while encrypting the certificate', e);
861
863
  }
862
864
  // add the encrypted certificate to the options
863
- _.set(opts, this.hcpPreferenceKeyEhealthCert, binary_utils_1.ua2string(new Uint8Array(crtEncrypted)));
865
+ _.set(opts, this.hcpPreferenceKeyEhealthCert, (0, binary_utils_1.ua2string)(new Uint8Array(crtEncrypted)));
864
866
  }
865
867
  const crtValidityDate = this.getKeychainValidityDateInBrowserLocalStorage(hcp.id);
866
868
  if (!!crtValidityDate) {
@@ -875,7 +877,7 @@ class IccCryptoXApi {
875
877
  return this.hcpartyBaseApi.getHealthcareParty(hcpId).then((hcp) => __awaiter(this, void 0, void 0, function* () {
876
878
  let crtCryp = null;
877
879
  if (!!hcp.options && !!hcp.options[this.hcpPreferenceKeyEhealthCert]) {
878
- crtCryp = binary_utils_1.string2ua(hcp.options[this.hcpPreferenceKeyEhealthCert]);
880
+ crtCryp = (0, binary_utils_1.string2ua)(hcp.options[this.hcpPreferenceKeyEhealthCert]);
879
881
  }
880
882
  const crtValidityDate = _.get(hcp.options, this.hcpPreferenceKeyEhealthCertDate);
881
883
  // store the validity date
@@ -941,7 +943,7 @@ class IccCryptoXApi {
941
943
  // noinspection JSUnusedGlobalSymbols
942
944
  loadKeychainFromBrowserLocalStorage(id) {
943
945
  const lsItem = localStorage.getItem('org.taktik.icure.ehealth.keychain.' + id);
944
- return lsItem !== null ? binary_utils_1.b64_2uas(lsItem) : null;
946
+ return lsItem !== null ? (0, binary_utils_1.b64_2uas)(lsItem) : null;
945
947
  }
946
948
  generateKeyForDelegate(ownerId, delegateId) {
947
949
  //Preload hcp and patient because we need them and they are going to be invalidated from the caches
@@ -954,17 +956,17 @@ class IccCryptoXApi {
954
956
  ? this._AES
955
957
  .generateCryptoKey(true)
956
958
  .then((AESKey) => {
957
- const ownerPubKey = this._utils.spkiToJwk(binary_utils_1.hex2ua(owner.publicKey));
958
- const delegatePubKey = this._utils.spkiToJwk(binary_utils_1.hex2ua(delegate.publicKey));
959
+ const ownerPubKey = this._utils.spkiToJwk((0, binary_utils_1.hex2ua)(owner.publicKey));
960
+ const delegatePubKey = this._utils.spkiToJwk((0, binary_utils_1.hex2ua)(delegate.publicKey));
959
961
  return Promise.all([
960
962
  this._RSA.importKey('jwk', ownerPubKey, ['encrypt']),
961
963
  this._RSA.importKey('jwk', delegatePubKey, ['encrypt']),
962
964
  ]).then(([ownerImportedKey, delegateImportedKey]) => Promise.all([
963
- this._RSA.encrypt(ownerImportedKey, binary_utils_1.hex2ua(AESKey)),
964
- this._RSA.encrypt(delegateImportedKey, binary_utils_1.hex2ua(AESKey)),
965
+ this._RSA.encrypt(ownerImportedKey, (0, binary_utils_1.hex2ua)(AESKey)),
966
+ this._RSA.encrypt(delegateImportedKey, (0, binary_utils_1.hex2ua)(AESKey)),
965
967
  ]));
966
968
  })
967
- .then(([ownerKey, delegateKey]) => (owner.hcPartyKeys[delegateId] = [binary_utils_1.ua2hex(ownerKey), binary_utils_1.ua2hex(delegateKey)]))
969
+ .then(([ownerKey, delegateKey]) => (owner.hcPartyKeys[delegateId] = [(0, binary_utils_1.ua2hex)(ownerKey), (0, binary_utils_1.ua2hex)(delegateKey)]))
968
970
  .then(() => {
969
971
  return ownerType === 'hcp'
970
972
  ? (this.dataOwnerCache[owner.id] = this.hcpartyBaseApi
@@ -1007,8 +1009,8 @@ class IccCryptoXApi {
1007
1009
  checkPrivateKeyValidity(dataOwner) {
1008
1010
  return new Promise((resolve) => {
1009
1011
  this._RSA
1010
- .importKey('jwk', this._utils.spkiToJwk(binary_utils_1.hex2ua(dataOwner.publicKey)), ['encrypt'])
1011
- .then((k) => this._RSA.encrypt(k, binary_utils_1.utf8_2ua('shibboleth')))
1012
+ .importKey('jwk', this._utils.spkiToJwk((0, binary_utils_1.hex2ua)(dataOwner.publicKey)), ['encrypt'])
1013
+ .then((k) => this._RSA.encrypt(k, (0, binary_utils_1.utf8_2ua)('shibboleth')))
1012
1014
  .then((cipher) => {
1013
1015
  const kp = this._RSA.loadKeyPairNotImported(dataOwner.id);
1014
1016
  return this._RSA
@@ -1016,7 +1018,7 @@ class IccCryptoXApi {
1016
1018
  .then((ikp) => this._RSA.decrypt(ikp.privateKey, new Uint8Array(cipher)));
1017
1019
  })
1018
1020
  .then((plainText) => {
1019
- const pt = binary_utils_1.ua2utf8(plainText);
1021
+ const pt = (0, binary_utils_1.ua2utf8)(plainText);
1020
1022
  console.log(pt);
1021
1023
  resolve(pt === 'shibboleth');
1022
1024
  })
@@ -1050,7 +1052,7 @@ class IccCryptoXApi {
1050
1052
  if (!content || !(edKey || ((user === null || user === void 0 ? void 0 : user.healthcarePartyId) && documentObject)))
1051
1053
  return content;
1052
1054
  if (edKey) {
1053
- const importedEdKey = yield this._AES.importKey('raw', binary_utils_1.hex2ua(edKey.replace(/-/g, '')));
1055
+ const importedEdKey = yield this._AES.importKey('raw', (0, binary_utils_1.hex2ua)(edKey.replace(/-/g, '')));
1054
1056
  try {
1055
1057
  return yield this._AES[method](importedEdKey, content);
1056
1058
  }
@@ -1059,7 +1061,7 @@ class IccCryptoXApi {
1059
1061
  }
1060
1062
  }
1061
1063
  const sfks = yield this.extractKeysFromDelegationsForHcpHierarchy(user === null || user === void 0 ? void 0 : user.healthcarePartyId, documentObject === null || documentObject === void 0 ? void 0 : documentObject.id, documentObject === null || documentObject === void 0 ? void 0 : documentObject.encryptionKeys);
1062
- const importedEdKey = yield this._AES.importKey('raw', binary_utils_1.hex2ua(sfks.extractedKeys[0].replace(/-/g, '')));
1064
+ const importedEdKey = yield this._AES.importKey('raw', (0, binary_utils_1.hex2ua)(sfks.extractedKeys[0].replace(/-/g, '')));
1063
1065
  try {
1064
1066
  return yield this._AES[method](importedEdKey, content);
1065
1067
  }