@icure/api 6.4.0 → 6.4.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.
- package/icc-x-api/crypto/AES.d.ts +1 -0
- package/icc-x-api/crypto/AES.js +10 -1
- package/icc-x-api/crypto/AES.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.js +10 -7
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.js +14 -6
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.js +12 -9
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +6 -0
- package/icc-x-api/icc-crypto-x-api.js +19 -6
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +5 -4
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.js +8 -2
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +8 -2
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.js +70 -64
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -85,7 +85,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
85
85
|
rev: dataOwner.rev,
|
|
86
86
|
publicKey: dataOwner.publicKey,
|
|
87
87
|
aesExchangeKeys: dataOwner.aesExchangeKeys,
|
|
88
|
-
hcPartyKeys: dataOwner.hcPartyKeys
|
|
88
|
+
hcPartyKeys: dataOwner.hcPartyKeys,
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -306,12 +306,16 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
306
306
|
tryEncrypt(user, pats, requireAccessibleKey) {
|
|
307
307
|
const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user);
|
|
308
308
|
return Promise.all(pats.map((p) => __awaiter(this, void 0, void 0, function* () {
|
|
309
|
-
const patientWithInitialisedEks =
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
309
|
+
const patientWithInitialisedEks = p.encryptionKeys && Object.values(p.encryptionKeys).some((v) => !!v.length) ? p : yield this.initEncryptionKeys(user, p);
|
|
310
|
+
const decryptedKeys = yield this.crypto
|
|
311
|
+
.extractKeysFromDelegationsForHcpHierarchy(dataOwnerId, patientWithInitialisedEks.id, patientWithInitialisedEks.encryptionKeys)
|
|
312
|
+
.catch((e) => {
|
|
313
|
+
console.error(e);
|
|
314
|
+
throw e;
|
|
315
|
+
});
|
|
316
|
+
const fixedKeys = this.crypto.filterAndFixValidEntityEncryptionKeyStrings(decryptedKeys.extractedKeys);
|
|
317
|
+
if (fixedKeys.length) {
|
|
318
|
+
const key = yield this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(fixedKeys[0]));
|
|
315
319
|
return (0, utils_1.crypt)(patientWithInitialisedEks, (obj) => this.crypto.AES.encrypt(key, (0, binary_utils_1.utf8_2ua)(JSON.stringify(obj, (k, v) => {
|
|
316
320
|
return v instanceof ArrayBuffer || v instanceof Uint8Array
|
|
317
321
|
? (0, binary_utils_1.b2a)(new Uint8Array(v).reduce((d, b) => d + String.fromCharCode(b), ''))
|
|
@@ -337,7 +341,9 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
337
341
|
tryDecryptOrReturnOriginal(user, patients, fillDelegations = true) {
|
|
338
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
339
343
|
const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user);
|
|
340
|
-
const ids = yield (user.healthcarePartyId
|
|
344
|
+
const ids = yield (user.healthcarePartyId
|
|
345
|
+
? this.hcpartyApi.getHealthcarePartyHierarchyIds(user.healthcarePartyId)
|
|
346
|
+
: Promise.resolve([dataOwnerId]));
|
|
341
347
|
//First check that we have no dangling delegation
|
|
342
348
|
const patsWithMissingDelegations = patients.filter((p) => p.delegations &&
|
|
343
349
|
ids.some((id) => p.delegations[id] && !p.delegations[id].length) &&
|
|
@@ -359,10 +365,11 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
359
365
|
? yield this.crypto
|
|
360
366
|
.extractKeysFromDelegationsForHcpHierarchy(hcpId, p.id, _.size(p.encryptionKeys) ? p.encryptionKeys : p.delegations)
|
|
361
367
|
.then(({ extractedKeys: sfks }) => {
|
|
368
|
+
sfks = this.crypto.filterAndFixValidEntityEncryptionKeyStrings(sfks);
|
|
362
369
|
if (!sfks || !sfks.length) {
|
|
363
370
|
return Promise.resolve(undefined);
|
|
364
371
|
}
|
|
365
|
-
return this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(sfks[0]
|
|
372
|
+
return this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(sfks[0])).then((key) => (0, utils_1.decrypt)(p, (ec) => this.crypto.AES.decrypt(key, ec)
|
|
366
373
|
.then((dec) => {
|
|
367
374
|
const jsonContent = dec && (0, binary_utils_1.ua2utf8)(dec);
|
|
368
375
|
try {
|
|
@@ -486,31 +493,30 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
486
493
|
return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
|
|
487
494
|
return delSfks.length
|
|
488
495
|
? Promise.all([
|
|
489
|
-
(0, utils_1.retry)(() => (usingPost
|
|
490
|
-
.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
491
|
-
.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(',')))
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
.
|
|
495
|
-
.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
|
|
496
|
+
(0, utils_1.retry)(() => (usingPost
|
|
497
|
+
? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
498
|
+
: this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((hes) => parentId
|
|
499
|
+
? (usingPost
|
|
500
|
+
? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
|
|
501
|
+
: this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
|
|
496
502
|
: hes)),
|
|
497
|
-
(0, utils_1.retry)(() => (usingPost
|
|
498
|
-
.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
499
|
-
.findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((frms) => parentId
|
|
500
|
-
? (usingPost
|
|
501
|
-
.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
|
|
502
|
-
.findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
|
|
503
|
+
(0, utils_1.retry)(() => (usingPost
|
|
504
|
+
? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
505
|
+
: this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((frms) => parentId
|
|
506
|
+
? (usingPost
|
|
507
|
+
? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
|
|
508
|
+
: this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
|
|
503
509
|
: frms)),
|
|
504
|
-
(0, utils_1.retry)(() => (usingPost
|
|
505
|
-
.findByHCPartyPatientSecretFKeysUsingPost(ownerId, undefined, undefined, _.uniq(delSfks))
|
|
506
|
-
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((ctcs) => parentId
|
|
507
|
-
? (usingPost
|
|
508
|
-
.findByHCPartyPatientSecretFKeysUsingPost(parentId, undefined, undefined, _.uniq(delSfks))
|
|
509
|
-
.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
|
|
510
|
+
(0, utils_1.retry)(() => (usingPost
|
|
511
|
+
? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(ownerId, undefined, undefined, _.uniq(delSfks))
|
|
512
|
+
: this.contactApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((ctcs) => parentId
|
|
513
|
+
? (usingPost
|
|
514
|
+
? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(parentId, undefined, undefined, _.uniq(delSfks))
|
|
515
|
+
: this.contactApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
|
|
510
516
|
: ctcs)),
|
|
511
|
-
(0, utils_1.retry)(() => (usingPost
|
|
512
|
-
.findInvoicesDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
513
|
-
.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((ivs) => parentId
|
|
517
|
+
(0, utils_1.retry)(() => (usingPost
|
|
518
|
+
? this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
519
|
+
: this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((ivs) => parentId
|
|
514
520
|
? this.invoiceApi
|
|
515
521
|
.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
516
522
|
.then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
|
|
@@ -522,12 +528,12 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
522
528
|
.findClassificationsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
523
529
|
.then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
|
|
524
530
|
: cls)),
|
|
525
|
-
(0, utils_1.retry)(() => (usingPost
|
|
526
|
-
.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
527
|
-
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((cls) => parentId
|
|
528
|
-
? (usingPost
|
|
529
|
-
.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
|
|
530
|
-
.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
|
|
531
|
+
(0, utils_1.retry)(() => (usingPost
|
|
532
|
+
? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
533
|
+
: this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((cls) => parentId
|
|
534
|
+
? (usingPost
|
|
535
|
+
? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
|
|
536
|
+
: this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
|
|
531
537
|
: cls)),
|
|
532
538
|
]).then(([hes, frms, ctcs, ivs, cls, cis]) => {
|
|
533
539
|
const cloneKeysAndDelegations = function (x) {
|
|
@@ -746,33 +752,33 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
746
752
|
return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
|
|
747
753
|
return delSfks.length
|
|
748
754
|
? Promise.all([
|
|
749
|
-
(0, utils_1.retry)(() => (usingPost
|
|
750
|
-
.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
751
|
-
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((hes) => parentId
|
|
755
|
+
(0, utils_1.retry)(() => (usingPost
|
|
756
|
+
? this.helementApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
757
|
+
: this.helementApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((hes) => parentId
|
|
752
758
|
? this.helementApi
|
|
753
759
|
.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
|
|
754
760
|
.then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
|
|
755
761
|
: hes)),
|
|
756
|
-
(0, utils_1.retry)(() => (usingPost
|
|
757
|
-
.findFormsByHCPartyPatientForeignKeysUsingPost(ownerId, undefined, undefined, undefined, _.uniq(delSfks))
|
|
758
|
-
.findFormsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((frms) => parentId
|
|
759
|
-
? (usingPost
|
|
760
|
-
.findFormsByHCPartyPatientForeignKeysUsingPost(parentId, undefined, undefined, undefined, _.uniq(delSfks))
|
|
761
|
-
.findFormsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
|
|
762
|
+
(0, utils_1.retry)(() => (usingPost
|
|
763
|
+
? this.formApi.findFormsByHCPartyPatientForeignKeysUsingPost(ownerId, undefined, undefined, undefined, _.uniq(delSfks))
|
|
764
|
+
: this.formApi.findFormsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((frms) => parentId
|
|
765
|
+
? (usingPost
|
|
766
|
+
? this.formApi.findFormsByHCPartyPatientForeignKeysUsingPost(parentId, undefined, undefined, undefined, _.uniq(delSfks))
|
|
767
|
+
: this.formApi.findFormsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
|
|
762
768
|
: frms)),
|
|
763
|
-
(0, utils_1.retry)(() => (usingPost
|
|
764
|
-
.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
765
|
-
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((ctcs) => parentId
|
|
766
|
-
? (usingPost
|
|
767
|
-
.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
|
|
768
|
-
.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
|
|
769
|
+
(0, utils_1.retry)(() => (usingPost
|
|
770
|
+
? this.contactApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
771
|
+
: this.contactApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((ctcs) => parentId
|
|
772
|
+
? (usingPost
|
|
773
|
+
? this.contactApi.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
|
|
774
|
+
: this.contactApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
|
|
769
775
|
: ctcs)),
|
|
770
|
-
(0, utils_1.retry)(() => (usingPost
|
|
771
|
-
.findInvoicesByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
772
|
-
.findInvoicesByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((ivs) => parentId
|
|
773
|
-
? (usingPost
|
|
774
|
-
.findInvoicesByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
|
|
775
|
-
.findInvoicesByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
|
|
776
|
+
(0, utils_1.retry)(() => (usingPost
|
|
777
|
+
? this.invoiceApi.findInvoicesByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
|
|
778
|
+
: this.invoiceApi.findInvoicesByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((ivs) => parentId
|
|
779
|
+
? (usingPost
|
|
780
|
+
? this.invoiceApi.findInvoicesByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
|
|
781
|
+
: this.invoiceApi.findInvoicesByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
|
|
776
782
|
: ivs)),
|
|
777
783
|
(0, utils_1.retry)(() => this.classificationApi
|
|
778
784
|
.findClassificationsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
@@ -784,13 +790,13 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
784
790
|
(0, utils_1.retry)(() => __awaiter(this, void 0, void 0, function* () {
|
|
785
791
|
const delegationSFKs = _.uniq(delSfks).join(',');
|
|
786
792
|
try {
|
|
787
|
-
let calendarItems = yield (usingPost
|
|
788
|
-
this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
789
|
-
this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(',')));
|
|
793
|
+
let calendarItems = yield (usingPost
|
|
794
|
+
? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
|
|
795
|
+
: this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(',')));
|
|
790
796
|
if (parentId) {
|
|
791
|
-
const moreCalendarItems = yield (usingPost
|
|
792
|
-
this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
|
|
793
|
-
this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(',')));
|
|
797
|
+
const moreCalendarItems = yield (usingPost
|
|
798
|
+
? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
|
|
799
|
+
: this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(',')));
|
|
794
800
|
calendarItems = _.uniqBy(calendarItems.concat(moreCalendarItems), 'id');
|
|
795
801
|
}
|
|
796
802
|
return calendarItems;
|