@icure/api 4.2.36 → 4.2.37

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 (74) hide show
  1. package/icc-api/api/XHR.js +1 -1
  2. package/icc-api/api/XHR.js.map +1 -1
  3. package/icc-api/iccApi.js +1 -5
  4. package/icc-api/iccApi.js.map +1 -1
  5. package/icc-api/index.js +1 -5
  6. package/icc-api/index.js.map +1 -1
  7. package/icc-api/model/Body.js +1 -1
  8. package/icc-api/model/Body.js.map +1 -1
  9. package/icc-api/model/Body1.js +1 -1
  10. package/icc-api/model/Body1.js.map +1 -1
  11. package/icc-api/model/Body2.js +1 -1
  12. package/icc-api/model/Body2.js.map +1 -1
  13. package/icc-api/model/Body3.js +1 -1
  14. package/icc-api/model/Body3.js.map +1 -1
  15. package/icc-api/model/ByteArray.js +1 -1
  16. package/icc-api/model/ByteArray.js.map +1 -1
  17. package/icc-api/model/Content.js +1 -1
  18. package/icc-api/model/Content.js.map +1 -1
  19. package/icc-api/model/Device.js +1 -1
  20. package/icc-api/model/Device.js.map +1 -1
  21. package/icc-api/model/Document.js +1 -1
  22. package/icc-api/model/Document.js.map +1 -1
  23. package/icc-api/model/DocumentTemplate.js +1 -1
  24. package/icc-api/model/DocumentTemplate.js.map +1 -1
  25. package/icc-api/model/HealthcareParty.js +1 -1
  26. package/icc-api/model/HealthcareParty.js.map +1 -1
  27. package/icc-api/model/MimeAttachment.js +1 -1
  28. package/icc-api/model/MimeAttachment.js.map +1 -1
  29. package/icc-api/model/Patient.js +1 -1
  30. package/icc-api/model/Patient.js.map +1 -1
  31. package/icc-api/model/models.js +1 -5
  32. package/icc-api/model/models.js.map +1 -1
  33. package/icc-x-api/crypto/AES.js +1 -1
  34. package/icc-x-api/crypto/AES.js.map +1 -1
  35. package/icc-x-api/crypto/utils.js +36 -36
  36. package/icc-x-api/crypto/utils.js.map +1 -1
  37. package/icc-x-api/filters/filters.js +3 -7
  38. package/icc-x-api/filters/filters.js.map +1 -1
  39. package/icc-x-api/icc-accesslog-x-api.js +4 -4
  40. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  41. package/icc-x-api/icc-bekmehr-x-api.js +2 -2
  42. package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
  43. package/icc-x-api/icc-calendar-item-x-api.js +4 -4
  44. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  45. package/icc-x-api/icc-contact-x-api.js +11 -11
  46. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  47. package/icc-x-api/icc-crypto-x-api.js +46 -46
  48. package/icc-x-api/icc-crypto-x-api.js.map +1 -1
  49. package/icc-x-api/icc-doctemplate-x-api.js +2 -2
  50. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  51. package/icc-x-api/icc-document-x-api.js +3 -3
  52. package/icc-x-api/icc-document-x-api.js.map +1 -1
  53. package/icc-x-api/icc-form-x-api.js +3 -3
  54. package/icc-x-api/icc-form-x-api.js.map +1 -1
  55. package/icc-x-api/icc-hcparty-x-api.js +4 -4
  56. package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
  57. package/icc-x-api/icc-helement-x-api.js +5 -5
  58. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  59. package/icc-x-api/icc-maintenance-task-x-api.js +5 -5
  60. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  61. package/icc-x-api/icc-patient-x-api.js +36 -36
  62. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  63. package/icc-x-api/index.d.ts +1 -1
  64. package/icc-x-api/index.js +14 -13
  65. package/icc-x-api/index.js.map +1 -1
  66. package/icc-x-api/utils/binary-utils.js +5 -5
  67. package/icc-x-api/utils/binary-utils.js.map +1 -1
  68. package/icc-x-api/utils/formatting-util.js +3 -3
  69. package/icc-x-api/utils/formatting-util.js.map +1 -1
  70. package/icc-x-api/utils/index.js +1 -5
  71. package/icc-x-api/utils/index.js.map +1 -1
  72. package/index.js +1 -5
  73. package/index.js.map +1 -1
  74. 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((0, binary_utils_1.ua2hex)(privateKey), nLen, threshold || nLen).map((share) => (0, binary_utils_1.hex2ua)(share));
92
+ const shares = nLen == 1 ? [privateKey] : this._shamir.share(binary_utils_1.ua2hex(privateKey), nLen, threshold || nLen).map((share) => 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] = (0, binary_utils_1.ua2hex)(encryptedShamirPartition);
100
+ hcParty.privateKeyShamirPartitions[notary.id] = 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 = (0, binary_utils_1.ua2hex)(yield this.AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(cryptedPrivatedKey)));
124
+ decryptedPrivatedKey = binary_utils_1.ua2hex(yield this.AES.decrypt(importedAESHcPartyKey.key, 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 = (0, binary_utils_1.ua2hex)(yield this.AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(encryptedShare)));
135
+ const decryptedShamirPartition = binary_utils_1.ua2hex(yield this.AES.decrypt(importedAESHcPartyKey.key, 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', (0, binary_utils_1.hex2ua)(decryptedPrivatedKey), ['decrypt']);
147
- const importedPublicKey = yield this.RSA.importKey('spki', (0, binary_utils_1.hex2ua)(hcp.publicKey), ['encrypt']);
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']);
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, (0, binary_utils_1.hex2ua)(encryptedHcPartyKey)))
181
+ .then((keyPair) => this._RSA.decrypt(keyPair.privateKey, 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: (0, binary_utils_1.ua2hex)(new Uint8Array(decryptedHcPartyKey)),
193
+ rawKey: 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, (0, binary_utils_1.string2ua)(createdObject.id + ':' + secretId).buffer, importedAESHcPartyKey.rawKey),
317
+ this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(createdObject.id + ':' + secretId).buffer, importedAESHcPartyKey.rawKey),
318
318
  parentObject
319
- ? this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(createdObject.id + ':' + parentObject.id).buffer, importedAESHcPartyKey.rawKey)
319
+ ? this._AES.encrypt(importedAESHcPartyKey.key, 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: (0, binary_utils_1.ua2hex)(encryptedDelegationAndSecretForeignKey[0]),
330
+ key: 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: (0, binary_utils_1.ua2hex)(encryptedDelegationAndSecretForeignKey[1]),
343
+ key: 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, (0, binary_utils_1.hex2ua)(d.key), importedAESHcPartyKey.rawKey).catch(() => {
388
+ this._AES.decrypt(importedAESHcPartyKey.key, 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, (0, binary_utils_1.hex2ua)(d.key), importedAESHcPartyKey.rawKey).catch(() => {
395
+ this._AES.decrypt(importedAESHcPartyKey.key, 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, (0, binary_utils_1.string2ua)(modifiedObject.id + ':' + secretIdOfModifiedObject).buffer, importedAESHcPartyKey.rawKey),
400
+ this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(modifiedObject.id + ':' + secretIdOfModifiedObject).buffer, importedAESHcPartyKey.rawKey),
401
401
  parentObject
402
- ? this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(modifiedObject.id + ':' + parentObject.id).buffer, importedAESHcPartyKey.rawKey)
402
+ ? this._AES.encrypt(importedAESHcPartyKey.key, 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 ? (0, binary_utils_1.ua2string)(dd) : null)).map((k) => ({ k })))
413
+ })), (previousDecryptedDelegations || []).map((dd) => (dd ? 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: (0, binary_utils_1.ua2hex)(cryptedDelegation),
421
+ key: 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 ? (0, binary_utils_1.ua2string)(dd) : null)).map((k) => ({ k })))
431
+ })), (previousDecryptedCryptedForeignKeys || []).map((dd) => (dd ? 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: (0, binary_utils_1.ua2hex)(cryptedForeignKey),
440
+ key: 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, (0, binary_utils_1.string2ua)(createdObject.id + ':' + secretId)))
475
+ .then((importedAESHcPartyKey) => this._AES.encrypt(importedAESHcPartyKey.key, 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: (0, binary_utils_1.ua2hex)(encryptedEncryptionKeys),
484
+ key: binary_utils_1.ua2hex(encryptedEncryptionKeys),
485
485
  },
486
486
  ],
487
487
  ],
@@ -512,12 +512,12 @@ class IccCryptoXApi {
512
512
  .then((importedAESHcPartyKey) => Promise.all([
513
513
  Promise.all(((modifiedObject.encryptionKeys || {})[delegateId] || []).map((d) => (d.key &&
514
514
  d.owner === ownerId &&
515
- this._AES.decrypt(importedAESHcPartyKey.key, (0, binary_utils_1.hex2ua)(d.key), importedAESHcPartyKey.rawKey).catch(() => {
515
+ this._AES.decrypt(importedAESHcPartyKey.key, binary_utils_1.hex2ua(d.key), importedAESHcPartyKey.rawKey).catch(() => {
516
516
  console.log(`Cannot decrypt encryption key from ${d.owner} to ${d.delegatedTo} for object with id ${modifiedObject.id}:`, modifiedObject);
517
517
  return null;
518
518
  })) ||
519
519
  Promise.resolve(null))),
520
- this._AES.encrypt(importedAESHcPartyKey.key, (0, binary_utils_1.string2ua)(modifiedObject.id + ':' + secretEncryptionKeyOfObject)),
520
+ this._AES.encrypt(importedAESHcPartyKey.key, binary_utils_1.string2ua(modifiedObject.id + ':' + secretEncryptionKeyOfObject)),
521
521
  ]))
522
522
  .then(([previousDecryptedEncryptionKeys, encryptedEncryptionKey]) => {
523
523
  //try to limit the extent of the modifications to the delegations by preserving the redundant encryption keys already present and removing duplicates
@@ -527,7 +527,7 @@ class IccCryptoXApi {
527
527
  // We merge them to get one array of objects: { d: {owner,delegatedTo,encrypted(key)}, k: decrypted(key)}
528
528
  const encryptionKeysCryptedDecrypted = _.merge(((modifiedObject.encryptionKeys || {})[delegateId] || []).map((d) => ({
529
529
  d,
530
- })), (previousDecryptedEncryptionKeys || []).map((dd) => (dd ? (0, binary_utils_1.ua2string)(dd) : null)).map((k) => ({ k })))
530
+ })), (previousDecryptedEncryptionKeys || []).map((dd) => (dd ? binary_utils_1.ua2string(dd) : null)).map((k) => ({ k })))
531
531
  .filter(({ d, k }) => !!k || d.owner !== ownerId) //Only keep the ones created by us that can still be decrypted
532
532
  .map(({ d, k }) => ({ d, k: k || this.randomUuid() }))
533
533
  .concat([
@@ -535,7 +535,7 @@ class IccCryptoXApi {
535
535
  d: {
536
536
  owner: ownerId,
537
537
  delegatedTo: delegateId,
538
- key: (0, binary_utils_1.ua2hex)(encryptedEncryptionKey),
538
+ key: binary_utils_1.ua2hex(encryptedEncryptionKey),
539
539
  },
540
540
  k: modifiedObject.id + ':' + secretEncryptionKeyOfObject,
541
541
  },
@@ -737,9 +737,9 @@ class IccCryptoXApi {
737
737
  const aesKey = aesKeys[genericDelegationItem.owner];
738
738
  if (aesKey) {
739
739
  decryptPromises.push(this._AES
740
- .decrypt(aesKey.key, (0, binary_utils_1.hex2ua)(genericDelegationItem.key), aesKey.rawKey)
740
+ .decrypt(aesKey.key, binary_utils_1.hex2ua(genericDelegationItem.key), aesKey.rawKey)
741
741
  .then((decryptedGenericDelegationKey) => {
742
- const results = (0, binary_utils_1.ua2string)(decryptedGenericDelegationKey).split(':');
742
+ const results = binary_utils_1.ua2string(decryptedGenericDelegationKey).split(':');
743
743
  const objectId = results[0]; //must be the ID of the object, for checksum
744
744
  const genericSecretId = results[1];
745
745
  const details = 'object ID: ' + masterId + '; generic delegation from ' + genericDelegationItem.owner + ' to ' + genericDelegationItem.delegatedTo;
@@ -773,7 +773,7 @@ class IccCryptoXApi {
773
773
  if (!publicKey) {
774
774
  throw new Error('No public key has been defined for hcp');
775
775
  }
776
- return this._RSA.importKeyPair('jwk', this._utils.pkcs8ToJwk(privateKey), 'jwk', this._utils.spkiToJwk((0, binary_utils_1.hex2ua)(publicKey)));
776
+ return this._RSA.importKeyPair('jwk', this._utils.pkcs8ToJwk(privateKey), 'jwk', this._utils.spkiToJwk(binary_utils_1.hex2ua(publicKey)));
777
777
  })
778
778
  .then((keyPair) => {
779
779
  this._RSA.rsaKeyPairs[healthcarePartyId] = keyPair;
@@ -787,7 +787,7 @@ class IccCryptoXApi {
787
787
  loadKeyPairsAsJwkInBrowserLocalStorage(healthcarePartyId, privKey) {
788
788
  return this.getDataOwner(healthcarePartyId)
789
789
  .then(({ dataOwner }) => {
790
- const pubKey = this._utils.spkiToJwk((0, binary_utils_1.hex2ua)(dataOwner.publicKey));
790
+ const pubKey = this._utils.spkiToJwk(binary_utils_1.hex2ua(dataOwner.publicKey));
791
791
  privKey.n = pubKey.n;
792
792
  privKey.e = pubKey.e;
793
793
  return this._RSA.importKeyPair('jwk', privKey, 'jwk', pubKey);
@@ -809,14 +809,14 @@ class IccCryptoXApi {
809
809
  fr.onload = (e) => {
810
810
  //TODO remove any
811
811
  const privateKey = e.target.result;
812
- this.loadKeyPairsAsTextInBrowserLocalStorage(healthcarePartyId, (0, binary_utils_1.hex2ua)(privateKey)).then(resolve).catch(reject);
812
+ this.loadKeyPairsAsTextInBrowserLocalStorage(healthcarePartyId, binary_utils_1.hex2ua(privateKey)).then(resolve).catch(reject);
813
813
  };
814
814
  fr.readAsText(file);
815
815
  });
816
816
  }
817
817
  // noinspection JSUnusedGlobalSymbols
818
818
  saveKeychainInBrowserLocalStorage(id, keychain) {
819
- localStorage.setItem(this.keychainLocalStoreIdPrefix + id, (0, binary_utils_1.b2a)(new Uint8Array(keychain).reduce((data, byte) => data + String.fromCharCode(byte), '')));
819
+ localStorage.setItem(this.keychainLocalStoreIdPrefix + id, binary_utils_1.b2a(new Uint8Array(keychain).reduce((data, byte) => data + String.fromCharCode(byte), '')));
820
820
  }
821
821
  saveKeychainInBrowserLocalStorageAsBase64(id, keyChainB64) {
822
822
  localStorage.setItem(this.keychainLocalStoreIdPrefix + id, keyChainB64);
@@ -856,13 +856,13 @@ class IccCryptoXApi {
856
856
  if (!!aesKey && !!crt) {
857
857
  let crtEncrypted = null;
858
858
  try {
859
- crtEncrypted = yield this.AES.encrypt(aesKey, new Uint8Array((0, binary_utils_1.string2ua)(atob(crt))));
859
+ crtEncrypted = yield this.AES.encrypt(aesKey, new Uint8Array(binary_utils_1.string2ua(atob(crt))));
860
860
  }
861
861
  catch (e) {
862
862
  console.error('Error while encrypting the certificate', e);
863
863
  }
864
864
  // add the encrypted certificate to the options
865
- _.set(opts, this.hcpPreferenceKeyEhealthCert, (0, binary_utils_1.ua2string)(new Uint8Array(crtEncrypted)));
865
+ _.set(opts, this.hcpPreferenceKeyEhealthCert, binary_utils_1.ua2string(new Uint8Array(crtEncrypted)));
866
866
  }
867
867
  const crtValidityDate = this.getKeychainValidityDateInBrowserLocalStorage(hcp.id);
868
868
  if (!!crtValidityDate) {
@@ -877,7 +877,7 @@ class IccCryptoXApi {
877
877
  return this.hcpartyBaseApi.getHealthcareParty(hcpId).then((hcp) => __awaiter(this, void 0, void 0, function* () {
878
878
  let crtCryp = null;
879
879
  if (!!hcp.options && !!hcp.options[this.hcpPreferenceKeyEhealthCert]) {
880
- crtCryp = (0, binary_utils_1.string2ua)(hcp.options[this.hcpPreferenceKeyEhealthCert]);
880
+ crtCryp = binary_utils_1.string2ua(hcp.options[this.hcpPreferenceKeyEhealthCert]);
881
881
  }
882
882
  const crtValidityDate = _.get(hcp.options, this.hcpPreferenceKeyEhealthCertDate);
883
883
  // store the validity date
@@ -943,7 +943,7 @@ class IccCryptoXApi {
943
943
  // noinspection JSUnusedGlobalSymbols
944
944
  loadKeychainFromBrowserLocalStorage(id) {
945
945
  const lsItem = localStorage.getItem('org.taktik.icure.ehealth.keychain.' + id);
946
- return lsItem !== null ? (0, binary_utils_1.b64_2uas)(lsItem) : null;
946
+ return lsItem !== null ? binary_utils_1.b64_2uas(lsItem) : null;
947
947
  }
948
948
  generateKeyForDelegate(ownerId, delegateId) {
949
949
  //Preload hcp and patient because we need them and they are going to be invalidated from the caches
@@ -956,17 +956,17 @@ class IccCryptoXApi {
956
956
  ? this._AES
957
957
  .generateCryptoKey(true)
958
958
  .then((AESKey) => {
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
+ const ownerPubKey = this._utils.spkiToJwk(binary_utils_1.hex2ua(owner.publicKey));
960
+ const delegatePubKey = this._utils.spkiToJwk(binary_utils_1.hex2ua(delegate.publicKey));
961
961
  return Promise.all([
962
962
  this._RSA.importKey('jwk', ownerPubKey, ['encrypt']),
963
963
  this._RSA.importKey('jwk', delegatePubKey, ['encrypt']),
964
964
  ]).then(([ownerImportedKey, delegateImportedKey]) => Promise.all([
965
- this._RSA.encrypt(ownerImportedKey, (0, binary_utils_1.hex2ua)(AESKey)),
966
- this._RSA.encrypt(delegateImportedKey, (0, binary_utils_1.hex2ua)(AESKey)),
965
+ this._RSA.encrypt(ownerImportedKey, binary_utils_1.hex2ua(AESKey)),
966
+ this._RSA.encrypt(delegateImportedKey, binary_utils_1.hex2ua(AESKey)),
967
967
  ]));
968
968
  })
969
- .then(([ownerKey, delegateKey]) => (owner.hcPartyKeys[delegateId] = [(0, binary_utils_1.ua2hex)(ownerKey), (0, binary_utils_1.ua2hex)(delegateKey)]))
969
+ .then(([ownerKey, delegateKey]) => (owner.hcPartyKeys[delegateId] = [binary_utils_1.ua2hex(ownerKey), binary_utils_1.ua2hex(delegateKey)]))
970
970
  .then(() => {
971
971
  return ownerType === 'hcp'
972
972
  ? (this.dataOwnerCache[owner.id] = this.hcpartyBaseApi
@@ -1009,8 +1009,8 @@ class IccCryptoXApi {
1009
1009
  checkPrivateKeyValidity(dataOwner) {
1010
1010
  return new Promise((resolve) => {
1011
1011
  this._RSA
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
+ .importKey('jwk', this._utils.spkiToJwk(binary_utils_1.hex2ua(dataOwner.publicKey)), ['encrypt'])
1013
+ .then((k) => this._RSA.encrypt(k, binary_utils_1.utf8_2ua('shibboleth')))
1014
1014
  .then((cipher) => {
1015
1015
  const kp = this._RSA.loadKeyPairNotImported(dataOwner.id);
1016
1016
  return this._RSA
@@ -1018,7 +1018,7 @@ class IccCryptoXApi {
1018
1018
  .then((ikp) => this._RSA.decrypt(ikp.privateKey, new Uint8Array(cipher)));
1019
1019
  })
1020
1020
  .then((plainText) => {
1021
- const pt = (0, binary_utils_1.ua2utf8)(plainText);
1021
+ const pt = binary_utils_1.ua2utf8(plainText);
1022
1022
  console.log(pt);
1023
1023
  resolve(pt === 'shibboleth');
1024
1024
  })
@@ -1052,7 +1052,7 @@ class IccCryptoXApi {
1052
1052
  if (!content || !(edKey || ((user === null || user === void 0 ? void 0 : user.healthcarePartyId) && documentObject)))
1053
1053
  return content;
1054
1054
  if (edKey) {
1055
- const importedEdKey = yield this._AES.importKey('raw', (0, binary_utils_1.hex2ua)(edKey.replace(/-/g, '')));
1055
+ const importedEdKey = yield this._AES.importKey('raw', binary_utils_1.hex2ua(edKey.replace(/-/g, '')));
1056
1056
  try {
1057
1057
  return yield this._AES[method](importedEdKey, content);
1058
1058
  }
@@ -1061,7 +1061,7 @@ class IccCryptoXApi {
1061
1061
  }
1062
1062
  }
1063
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);
1064
- const importedEdKey = yield this._AES.importKey('raw', (0, binary_utils_1.hex2ua)(sfks.extractedKeys[0].replace(/-/g, '')));
1064
+ const importedEdKey = yield this._AES.importKey('raw', binary_utils_1.hex2ua(sfks.extractedKeys[0].replace(/-/g, '')));
1065
1065
  try {
1066
1066
  return yield this._AES[method](importedEdKey, content);
1067
1067
  }