@icure/api 7.0.0-beta.3 → 7.0.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.
- package/icc-api/api/IccAccesslogApi.js +2 -1
- package/icc-api/api/IccAccesslogApi.js.map +1 -1
- package/icc-api/api/IccAgendaApi.js +2 -1
- package/icc-api/api/IccAgendaApi.js.map +1 -1
- package/icc-api/api/IccAnonymousAccessApi.js +2 -1
- package/icc-api/api/IccAnonymousAccessApi.js.map +1 -1
- package/icc-api/api/IccApplicationsettingsApi.js +2 -1
- package/icc-api/api/IccApplicationsettingsApi.js.map +1 -1
- package/icc-api/api/IccArticleApi.js +2 -1
- package/icc-api/api/IccArticleApi.js.map +1 -1
- package/icc-api/api/IccAuthApi.d.ts +23 -0
- package/icc-api/api/IccAuthApi.js +59 -2
- package/icc-api/api/IccAuthApi.js.map +1 -1
- package/icc-api/api/IccBeefactApi.js +2 -1
- package/icc-api/api/IccBeefactApi.js.map +1 -1
- package/icc-api/api/IccBekmehrApi.js +2 -1
- package/icc-api/api/IccBekmehrApi.js.map +1 -1
- package/icc-api/api/IccBeresultexportApi.js +2 -1
- package/icc-api/api/IccBeresultexportApi.js.map +1 -1
- package/icc-api/api/IccBeresultimportApi.js +2 -1
- package/icc-api/api/IccBeresultimportApi.js.map +1 -1
- package/icc-api/api/IccBesamv2Api.d.ts +6 -0
- package/icc-api/api/IccBesamv2Api.js +15 -1
- package/icc-api/api/IccBesamv2Api.js.map +1 -1
- package/icc-api/api/IccCalendarItemApi.js +2 -1
- package/icc-api/api/IccCalendarItemApi.js.map +1 -1
- package/icc-api/api/IccCalendarItemTypeApi.js +2 -1
- package/icc-api/api/IccCalendarItemTypeApi.js.map +1 -1
- package/icc-api/api/IccClassificationApi.js +2 -1
- package/icc-api/api/IccClassificationApi.js.map +1 -1
- package/icc-api/api/IccClassificationTemplateApi.js +2 -1
- package/icc-api/api/IccClassificationTemplateApi.js.map +1 -1
- package/icc-api/api/IccCodeApi.js +2 -1
- package/icc-api/api/IccCodeApi.js.map +1 -1
- package/icc-api/api/IccContactApi.d.ts +6 -0
- package/icc-api/api/IccContactApi.js +26 -1
- package/icc-api/api/IccContactApi.js.map +1 -1
- package/icc-api/api/IccDataownerApi.js +2 -1
- package/icc-api/api/IccDataownerApi.js.map +1 -1
- package/icc-api/api/IccDeviceApi.js +2 -1
- package/icc-api/api/IccDeviceApi.js.map +1 -1
- package/icc-api/api/IccDoctemplateApi.js +2 -1
- package/icc-api/api/IccDoctemplateApi.js.map +1 -1
- package/icc-api/api/IccDocumentApi.d.ts +6 -4
- package/icc-api/api/IccDocumentApi.js +10 -6
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/api/IccDocumentTemplateApi.js +2 -1
- package/icc-api/api/IccDocumentTemplateApi.js.map +1 -1
- package/icc-api/api/IccEntityrefApi.js +2 -1
- package/icc-api/api/IccEntityrefApi.js.map +1 -1
- package/icc-api/api/IccEntitytemplateApi.js +2 -1
- package/icc-api/api/IccEntitytemplateApi.js.map +1 -1
- package/icc-api/api/IccFormApi.js +2 -1
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/api/IccFrontendmigrationApi.js +2 -1
- package/icc-api/api/IccFrontendmigrationApi.js.map +1 -1
- package/icc-api/api/IccGroupApi.d.ts +6 -0
- package/icc-api/api/IccGroupApi.js +15 -1
- package/icc-api/api/IccGroupApi.js.map +1 -1
- package/icc-api/api/IccHcpartyApi.js +2 -1
- package/icc-api/api/IccHcpartyApi.js.map +1 -1
- package/icc-api/api/IccHelementApi.js +2 -1
- package/icc-api/api/IccHelementApi.js.map +1 -1
- package/icc-api/api/IccIcureApi.js +2 -1
- package/icc-api/api/IccIcureApi.js.map +1 -1
- package/icc-api/api/IccInsuranceApi.js +2 -1
- package/icc-api/api/IccInsuranceApi.js.map +1 -1
- package/icc-api/api/IccInvoiceApi.js +2 -1
- package/icc-api/api/IccInvoiceApi.js.map +1 -1
- package/icc-api/api/IccKeywordApi.js +2 -1
- package/icc-api/api/IccKeywordApi.js.map +1 -1
- package/icc-api/api/IccMaintenanceTaskApi.js +2 -1
- package/icc-api/api/IccMaintenanceTaskApi.js.map +1 -1
- package/icc-api/api/IccMedexApi.js +2 -1
- package/icc-api/api/IccMedexApi.js.map +1 -1
- package/icc-api/api/IccMedicallocationApi.js +2 -1
- package/icc-api/api/IccMedicallocationApi.js.map +1 -1
- package/icc-api/api/IccMessageApi.js +2 -1
- package/icc-api/api/IccMessageApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.js +2 -1
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/api/IccPermissionApi.js +2 -1
- package/icc-api/api/IccPermissionApi.js.map +1 -1
- package/icc-api/api/IccPlaceApi.js +2 -1
- package/icc-api/api/IccPlaceApi.js.map +1 -1
- package/icc-api/api/IccPubsubApi.js +2 -1
- package/icc-api/api/IccPubsubApi.js.map +1 -1
- package/icc-api/api/IccReceiptApi.js +2 -1
- package/icc-api/api/IccReceiptApi.js.map +1 -1
- package/icc-api/api/IccReplicationApi.js +2 -1
- package/icc-api/api/IccReplicationApi.js.map +1 -1
- package/icc-api/api/IccRestApiPath.d.ts +1 -0
- package/icc-api/api/IccRestApiPath.js +10 -0
- package/icc-api/api/IccRestApiPath.js.map +1 -0
- package/icc-api/api/IccTarificationApi.js +2 -1
- package/icc-api/api/IccTarificationApi.js.map +1 -1
- package/icc-api/api/IccTimeTableApi.js +2 -1
- package/icc-api/api/IccTimeTableApi.js.map +1 -1
- package/icc-api/api/IccTmpApi.js +2 -1
- package/icc-api/api/IccTmpApi.js.map +1 -1
- package/icc-api/api/IccUserApi.js +2 -1
- package/icc-api/api/IccUserApi.js.map +1 -1
- package/icc-api/index.d.ts +0 -1
- package/icc-api/index.js +0 -1
- package/icc-api/index.js.map +1 -1
- package/icc-api/model/Address.d.ts +6 -0
- package/icc-api/model/Address.js.map +1 -1
- package/icc-api/model/Annotation.d.ts +18 -0
- package/icc-api/model/Annotation.js.map +1 -1
- package/icc-api/model/AuthenticationToken.d.ts +1 -0
- package/icc-api/model/AuthenticationToken.js.map +1 -1
- package/icc-api/model/Content.js +1 -1
- package/icc-api/model/Content.js.map +1 -1
- package/icc-api/model/CryptoActorStub.d.ts +5 -0
- package/icc-api/model/CryptoActorStub.js +1 -0
- package/icc-api/model/CryptoActorStub.js.map +1 -1
- package/icc-api/model/Delegation.d.ts +3 -0
- package/icc-api/model/Delegation.js.map +1 -1
- package/icc-api/model/FlatRateTarification.d.ts +4 -1
- package/icc-api/model/FlatRateTarification.js +3 -0
- package/icc-api/model/FlatRateTarification.js.map +1 -1
- package/icc-api/model/HealthElement.d.ts +6 -0
- package/icc-api/model/HealthElement.js.map +1 -1
- package/icc-api/model/HealthcareParty.js +1 -1
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/ISO639_1.d.ts +8 -0
- package/icc-api/model/ISO639_1.js +3 -0
- package/icc-api/model/ISO639_1.js.map +1 -0
- package/icc-api/model/Patient.d.ts +7 -0
- package/icc-api/model/Patient.js +1 -1
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-api/model/UserGroup.d.ts +1 -0
- package/icc-api/model/UserGroup.js.map +1 -1
- package/icc-api/model/models.d.ts +1 -0
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/auth/AuthenticationProvider.d.ts +67 -6
- package/icc-x-api/auth/AuthenticationProvider.js +100 -7
- package/icc-x-api/auth/AuthenticationProvider.js.map +1 -1
- package/icc-x-api/auth/EnsembleAuthService.d.ts +7 -2
- package/icc-x-api/auth/EnsembleAuthService.js +9 -0
- package/icc-x-api/auth/EnsembleAuthService.js.map +1 -1
- package/icc-x-api/auth/JwtAuthService.d.ts +10 -5
- package/icc-x-api/auth/JwtAuthService.js +22 -26
- package/icc-x-api/auth/JwtAuthService.js.map +1 -1
- package/icc-x-api/auth/JwtBridgedAuthService.d.ts +27 -0
- package/icc-x-api/auth/JwtBridgedAuthService.js +131 -0
- package/icc-x-api/auth/JwtBridgedAuthService.js.map +1 -0
- package/icc-x-api/crypto/EntitiesEncryption.d.ts +5 -4
- package/icc-x-api/crypto/EntitiesEncryption.js +20 -16
- package/icc-x-api/crypto/EntitiesEncryption.js.map +1 -1
- package/icc-x-api/filters/ServiceByHcPartyTagCodeDateFilter.d.ts +1 -0
- package/icc-x-api/filters/ServiceByHcPartyTagCodeDateFilter.js.map +1 -1
- package/icc-x-api/filters/filters.d.ts +4 -0
- package/icc-x-api/filters/filters.js +4 -0
- package/icc-x-api/filters/filters.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +2 -2
- package/icc-x-api/icc-accesslog-x-api.js +17 -24
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +1 -1
- package/icc-x-api/icc-calendar-item-x-api.js +18 -22
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.js +13 -19
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +17 -1
- package/icc-x-api/icc-contact-x-api.js +81 -99
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-data-owner-x-api.d.ts +1 -1
- package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.js +2 -13
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +12 -4
- package/icc-x-api/icc-document-x-api.js +29 -25
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +13 -17
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +1 -1
- package/icc-x-api/icc-helement-x-api.js +15 -20
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-icure-maintenance-x-api.js +4 -4
- package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.js +13 -19
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +13 -14
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.js +13 -18
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +5 -2
- package/icc-x-api/icc-patient-x-api.js +17 -24
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.js +11 -16
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.js +11 -16
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +284 -35
- package/icc-x-api/index.js +303 -79
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/maintenance/KeyPairUpdateRequest.d.ts +12 -9
- package/icc-x-api/maintenance/KeyPairUpdateRequest.js +11 -17
- package/icc-x-api/maintenance/KeyPairUpdateRequest.js.map +1 -1
- package/icc-x-api/utils/crypto-utils.d.ts +140 -11
- package/icc-x-api/utils/crypto-utils.js +285 -36
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/package.json +1 -1
- package/icc-api/api/IccBemikronoApi.d.ts +0 -81
- package/icc-api/api/IccBemikronoApi.js +0 -162
- package/icc-api/api/IccBemikronoApi.js.map +0 -1
|
@@ -11,9 +11,24 @@ export declare class IccContactXApi extends IccContactApi implements EncryptedEn
|
|
|
11
11
|
i18n: any;
|
|
12
12
|
crypto: IccCryptoXApi;
|
|
13
13
|
dataOwnerApi: IccDataOwnerXApi;
|
|
14
|
+
private readonly contactEncryptedFields;
|
|
15
|
+
private readonly serviceEncryptedFieldsNoContent;
|
|
16
|
+
private readonly serviceEncryptedFieldsWithContent;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param host
|
|
20
|
+
* @param headers
|
|
21
|
+
* @param crypto
|
|
22
|
+
* @param dataOwnerApi
|
|
23
|
+
* @param authenticationProvider
|
|
24
|
+
* @param fetchImpl
|
|
25
|
+
* @param contactEncryptedKeys custom encrypted fields for Contact. Note that to customise the encryption of contained services (`services` field),
|
|
26
|
+
* you need to use the serviceEncryptedKeys parameter.
|
|
27
|
+
* @param serviceEncryptedKeys custom encrypted fields for Service. Note that you can't customise encryption of the `content` field
|
|
28
|
+
*/
|
|
14
29
|
constructor(host: string, headers: {
|
|
15
30
|
[key: string]: string;
|
|
16
|
-
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response
|
|
31
|
+
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>, contactEncryptedKeys?: string[], serviceEncryptedKeys?: string[]);
|
|
17
32
|
/**
|
|
18
33
|
* Creates a new instance of contact with initialised encryption metadata (not in the database).
|
|
19
34
|
* @param user the current user.
|
|
@@ -70,6 +85,7 @@ export declare class IccContactXApi extends IccContactApi implements EncryptedEn
|
|
|
70
85
|
findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[], planOfActionIds?: string, skipClosedContacts?: boolean): Promise<Array<models.Contact> | any>;
|
|
71
86
|
filterByWithUser(user: models.User, startDocumentId?: string, limit?: number, body?: models.FilterChainContact): Promise<PaginatedListContact | any>;
|
|
72
87
|
listContactsByOpeningDateWithUser(user: models.User, startKey: number, endKey: number, hcpartyid: string, startDocumentId?: string, limit?: number): Promise<PaginatedListContact | any>;
|
|
88
|
+
getServiceWithUser(user: models.User, serviceId: string): Promise<Service>;
|
|
73
89
|
listServicesWithUser(user: models.User, serviceIds: ListOfIds): Promise<Array<Service> | any>;
|
|
74
90
|
findByHCPartyFormIdWithUser(user: models.User, hcPartyId: string, formId: string): Promise<Array<models.Contact> | any>;
|
|
75
91
|
findByHCPartyFormIdsWithUser(user: models.User, hcPartyId: string, body: models.ListOfIds): Promise<Array<models.Contact> | any>;
|
|
@@ -21,15 +21,39 @@ const ServiceByIdsFilter_1 = require("./filters/ServiceByIdsFilter");
|
|
|
21
21
|
const utils_1 = require("./utils");
|
|
22
22
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
23
23
|
class IccContactXApi extends icc_api_1.IccContactApi {
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param host
|
|
27
|
+
* @param headers
|
|
28
|
+
* @param crypto
|
|
29
|
+
* @param dataOwnerApi
|
|
30
|
+
* @param authenticationProvider
|
|
31
|
+
* @param fetchImpl
|
|
32
|
+
* @param contactEncryptedKeys custom encrypted fields for Contact. Note that to customise the encryption of contained services (`services` field),
|
|
33
|
+
* you need to use the serviceEncryptedKeys parameter.
|
|
34
|
+
* @param serviceEncryptedKeys custom encrypted fields for Service. Note that you can't customise encryption of the `content` field
|
|
35
|
+
*/
|
|
24
36
|
constructor(host, headers, crypto, dataOwnerApi, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
25
37
|
? window.fetch
|
|
26
38
|
: typeof self !== 'undefined'
|
|
27
39
|
? self.fetch
|
|
28
|
-
: fetch) {
|
|
40
|
+
: fetch, contactEncryptedKeys = ['descr'], serviceEncryptedKeys = []) {
|
|
29
41
|
super(host, headers, authenticationProvider, fetchImpl);
|
|
30
42
|
this.i18n = contact_i18n_1.default;
|
|
43
|
+
if (contactEncryptedKeys.some((key) => key.startsWith('services'))) {
|
|
44
|
+
throw new Error("You can't customise encryption of the `services` field of Contact. Use the serviceEncryptedKeys parameter instead.");
|
|
45
|
+
}
|
|
46
|
+
if (serviceEncryptedKeys.some((key) => key.startsWith('content'))) {
|
|
47
|
+
throw new Error("You can't customise encryption of the `content` of a Service. The content values for services is automatically encrypted.");
|
|
48
|
+
}
|
|
31
49
|
this.crypto = crypto;
|
|
32
50
|
this.dataOwnerApi = dataOwnerApi;
|
|
51
|
+
this.contactEncryptedFields = (0, utils_1.parseEncryptedFields)(contactEncryptedKeys, 'Contact.');
|
|
52
|
+
const customServiceEncryptedFields = (0, utils_1.parseEncryptedFields)(serviceEncryptedKeys, 'Service.');
|
|
53
|
+
if (serviceEncryptedKeys.length > 0) {
|
|
54
|
+
this.serviceEncryptedFieldsNoContent = customServiceEncryptedFields;
|
|
55
|
+
}
|
|
56
|
+
this.serviceEncryptedFieldsWithContent = Object.assign(Object.assign({}, customServiceEncryptedFields), { topLevelFields: [...customServiceEncryptedFields.topLevelFields, { fieldName: 'content', fieldPath: 'Service.content' }] });
|
|
33
57
|
}
|
|
34
58
|
/**
|
|
35
59
|
* Creates a new instance of contact with initialised encryption metadata (not in the database).
|
|
@@ -49,33 +73,20 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
49
73
|
* @return a new instance of contact.
|
|
50
74
|
*/
|
|
51
75
|
newInstance(user, patient, c, options = {}) {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f;
|
|
76
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
53
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const contact = new models.Contact(
|
|
55
|
-
id: this.crypto.primitives.randomUuid(),
|
|
56
|
-
_type: 'org.taktik.icure.entities.Contact',
|
|
57
|
-
created: new Date().getTime(),
|
|
58
|
-
modified: new Date().getTime(),
|
|
59
|
-
responsible: this.dataOwnerApi.getDataOwnerIdOf(user),
|
|
60
|
-
author: user.id,
|
|
61
|
-
codes: [],
|
|
62
|
-
tags: [],
|
|
63
|
-
groupId: this.crypto.primitives.randomUuid(),
|
|
64
|
-
subContacts: [],
|
|
65
|
-
services: [],
|
|
66
|
-
openingDate: parseInt(moment().format('YYYYMMDDHHmmss')),
|
|
67
|
-
}, c || {}));
|
|
78
|
+
const contact = new models.Contact(Object.assign(Object.assign({}, (c !== null && c !== void 0 ? c : {})), { _type: 'org.taktik.icure.entities.Contact', id: (_a = c === null || c === void 0 ? void 0 : c.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = c === null || c === void 0 ? void 0 : c.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = c === null || c === void 0 ? void 0 : c.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = c === null || c === void 0 ? void 0 : c.responsible) !== null && _d !== void 0 ? _d : this.dataOwnerApi.getDataOwnerIdOf(user), author: (_e = c === null || c === void 0 ? void 0 : c.author) !== null && _e !== void 0 ? _e : user.id, codes: (_f = c === null || c === void 0 ? void 0 : c.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = c === null || c === void 0 ? void 0 : c.tags) !== null && _g !== void 0 ? _g : [], groupId: (_h = c === null || c === void 0 ? void 0 : c.groupId) !== null && _h !== void 0 ? _h : this.crypto.primitives.randomUuid(), subContacts: (_j = c === null || c === void 0 ? void 0 : c.subContacts) !== null && _j !== void 0 ? _j : [], services: (_k = c === null || c === void 0 ? void 0 : c.services) !== null && _k !== void 0 ? _k : [], openingDate: (_l = c === null || c === void 0 ? void 0 : c.openingDate) !== null && _l !== void 0 ? _l : parseInt(moment().format('YYYYMMDDHHmmss')) }));
|
|
68
79
|
const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
|
|
69
80
|
if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
|
|
70
81
|
throw new Error('Can only initialise entities as current data owner.');
|
|
71
|
-
const sfk = (
|
|
82
|
+
const sfk = (_m = options.preferredSfk) !== null && _m !== void 0 ? _m : (!!options.confidential
|
|
72
83
|
? yield this.crypto.confidential.getConfidentialSecretId(patient)
|
|
73
84
|
: yield this.crypto.confidential.getAnySecretIdSharedWithParents(patient));
|
|
74
85
|
if (!sfk)
|
|
75
86
|
throw new Error(`Couldn't find any sfk of parent patient ${patient.id} for confidential=${!!options.confidential}`);
|
|
76
87
|
const extraDelegations = [
|
|
77
|
-
...Object.keys((
|
|
78
|
-
...(options.confidential ? [] : [...((
|
|
88
|
+
...Object.keys((_o = options.additionalDelegates) !== null && _o !== void 0 ? _o : {}),
|
|
89
|
+
...(options.confidential ? [] : [...((_q = (_p = user.autoDelegations) === null || _p === void 0 ? void 0 : _p.all) !== null && _q !== void 0 ? _q : []), ...((_s = (_r = user.autoDelegations) === null || _r === void 0 ? void 0 : _r.medicalInformation) !== null && _s !== void 0 ? _s : [])]),
|
|
79
90
|
];
|
|
80
91
|
const initialisationInfo = yield this.crypto.entities.entityWithInitialisedEncryptedMetadata(contact, patient.id, sfk, true, extraDelegations);
|
|
81
92
|
return new models.Contact(initialisationInfo.updatedEntity);
|
|
@@ -191,11 +202,17 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
191
202
|
.listContactsByOpeningDate(startKey, endKey, hcpartyid, startDocumentId, limit)
|
|
192
203
|
.then((ctcs) => this.decrypt(user.healthcarePartyId || user.patientId, ctcs.rows).then((decryptedRows) => Object.assign(ctcs, { rows: decryptedRows })));
|
|
193
204
|
}
|
|
205
|
+
getServiceWithUser(user, serviceId) {
|
|
206
|
+
return super
|
|
207
|
+
.getService(serviceId)
|
|
208
|
+
.then((service) => { var _a, _b; return this.decryptServices((_b = (_a = user.healthcarePartyId) !== null && _a !== void 0 ? _a : user.patientId) !== null && _b !== void 0 ? _b : user.deviceId, [service]); })
|
|
209
|
+
.then((decrypted) => decrypted[0]);
|
|
210
|
+
}
|
|
194
211
|
listServicesWithUser(user, serviceIds) {
|
|
195
212
|
var _a;
|
|
196
213
|
return super
|
|
197
214
|
.filterServicesBy(undefined, (_a = serviceIds.ids) === null || _a === void 0 ? void 0 : _a.length, new models_1.FilterChainService({ filter: new ServiceByIdsFilter_1.ServiceByIdsFilter({ ids: serviceIds.ids }) }))
|
|
198
|
-
.then((paginatedList) => { var _a; return this.decryptServices(user.healthcarePartyId
|
|
215
|
+
.then((paginatedList) => { var _a, _b, _c; return this.decryptServices((_b = (_a = user.healthcarePartyId) !== null && _a !== void 0 ? _a : user.patientId) !== null && _b !== void 0 ? _b : user.deviceId, (_c = paginatedList.rows) !== null && _c !== void 0 ? _c : []); });
|
|
199
216
|
}
|
|
200
217
|
findByHCPartyFormIdWithUser(user, hcPartyId, formId) {
|
|
201
218
|
return super.findByHCPartyFormId(hcPartyId, formId).then((ctcs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), ctcs));
|
|
@@ -262,32 +279,37 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
262
279
|
}
|
|
263
280
|
encryptServices(key, rawKey, services) {
|
|
264
281
|
return Promise.all(services.map((svc) => __awaiter(this, void 0, void 0, function* () {
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
!c.binaryValue)) {
|
|
278
|
-
svc.content = _.fromPairs(yield Promise.all(_.toPairs(svc.content).map((p) => __awaiter(this, void 0, void 0, function* () {
|
|
282
|
+
if (svc.content &&
|
|
283
|
+
Object.values(svc.content).every((c) => c.compoundValue &&
|
|
284
|
+
!c.stringValue &&
|
|
285
|
+
!c.documentId &&
|
|
286
|
+
!c.measureValue &&
|
|
287
|
+
!c.medicationValue &&
|
|
288
|
+
(c.booleanValue === null || c.booleanValue === undefined) &&
|
|
289
|
+
(c.numberValue === null || c.numberValue === undefined) &&
|
|
290
|
+
!c.instantValue &&
|
|
291
|
+
!c.fuzzyDateValue &&
|
|
292
|
+
!c.binaryValue)) {
|
|
293
|
+
const recursivelyEncryptedContent = Object.fromEntries(yield Promise.all(Object.entries(svc.content).map((p) => __awaiter(this, void 0, void 0, function* () {
|
|
279
294
|
var _a;
|
|
280
295
|
if ((_a = p[1].compoundValue) === null || _a === void 0 ? void 0 : _a.length) {
|
|
281
|
-
p[1]
|
|
296
|
+
return [p[0], Object.assign(Object.assign({}, p[1]), { compoundValue: yield this.encryptServices(key, rawKey, p[1].compoundValue) })];
|
|
282
297
|
}
|
|
283
|
-
|
|
298
|
+
else
|
|
299
|
+
return p;
|
|
284
300
|
}))));
|
|
301
|
+
const copyWithEncryptedContent = Object.assign(Object.assign({}, svc), { content: recursivelyEncryptedContent });
|
|
302
|
+
return this.serviceEncryptedFieldsNoContent
|
|
303
|
+
? (0, utils_1.encryptObject)(copyWithEncryptedContent, (obj) => {
|
|
304
|
+
return this.crypto.primitives.AES.encrypt(key, (0, binary_utils_1.utf8_2ua)(JSON.stringify(obj)), rawKey);
|
|
305
|
+
}, this.serviceEncryptedFieldsNoContent, 'service')
|
|
306
|
+
: copyWithEncryptedContent;
|
|
285
307
|
}
|
|
286
308
|
else {
|
|
287
|
-
|
|
288
|
-
|
|
309
|
+
return (0, utils_1.encryptObject)(svc, (obj) => {
|
|
310
|
+
return this.crypto.primitives.AES.encrypt(key, (0, binary_utils_1.utf8_2ua)(JSON.stringify(obj)), rawKey);
|
|
311
|
+
}, this.serviceEncryptedFieldsWithContent, 'service');
|
|
289
312
|
}
|
|
290
|
-
return svc;
|
|
291
313
|
})));
|
|
292
314
|
}
|
|
293
315
|
encrypt(user, ctcs) {
|
|
@@ -296,14 +318,14 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
296
318
|
encryptAs(hcpartyId, ctcs) {
|
|
297
319
|
const bypassEncryption = false; //Used for debug
|
|
298
320
|
return Promise.all(ctcs.map((ctc) => __awaiter(this, void 0, void 0, function* () {
|
|
321
|
+
var _a;
|
|
299
322
|
const initialisedCtc = bypassEncryption //Prevent encryption for test ctc
|
|
300
323
|
? ctc
|
|
301
|
-
: yield this.crypto.entities.ensureEncryptionKeysInitialised(ctc);
|
|
324
|
+
: (_a = (yield this.crypto.entities.ensureEncryptionKeysInitialised(ctc))) !== null && _a !== void 0 ? _a : ctc;
|
|
302
325
|
const encryptionKey = yield this.crypto.entities.importFirstValidKey(yield this.crypto.entities.encryptionKeysOf(ctc, hcpartyId), ctc.id);
|
|
303
|
-
initialisedCtc.services
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
return initialisedCtc;
|
|
326
|
+
return new models_1.Contact(yield (0, utils_1.encryptObject)(Object.assign(Object.assign({}, initialisedCtc), { services: initialisedCtc.services ? yield this.encryptServices(encryptionKey.key, encryptionKey.raw, initialisedCtc.services) : [] }), (obj) => {
|
|
327
|
+
return this.crypto.primitives.AES.encrypt(encryptionKey.key, (0, binary_utils_1.utf8_2ua)(JSON.stringify(obj)), encryptionKey.raw);
|
|
328
|
+
}, this.contactEncryptedFields, 'contact'));
|
|
307
329
|
})));
|
|
308
330
|
}
|
|
309
331
|
decrypt(hcpartyId, ctcs) {
|
|
@@ -313,22 +335,10 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
313
335
|
console.log('Cannot decrypt contact', ctc.id);
|
|
314
336
|
return ctc;
|
|
315
337
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (json) {
|
|
321
|
-
_.assign(ctc, json);
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
console.log('Cannot decrypt ctc: no valid key could produce valid json', ctc.id);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
catch (e) {
|
|
328
|
-
console.log('Failed to decrypt ctc', ctc.id, e);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return ctc;
|
|
338
|
+
return new models_1.Contact(yield (0, utils_1.decryptObject)(ctc, (encrypted) => __awaiter(this, void 0, void 0, function* () {
|
|
339
|
+
var _a;
|
|
340
|
+
return (_a = (yield this.crypto.entities.tryDecryptJson(keys, encrypted, false))) !== null && _a !== void 0 ? _a : {};
|
|
341
|
+
})));
|
|
332
342
|
})));
|
|
333
343
|
}
|
|
334
344
|
decryptServices(hcpartyId, svcs, keys) {
|
|
@@ -336,43 +346,10 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
336
346
|
if (!keys) {
|
|
337
347
|
keys = yield this.crypto.entities.importAllValidKeys(yield this.crypto.entities.encryptionKeysOf(svc, hcpartyId));
|
|
338
348
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
Object.assign(svc, { content: json });
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
console.log('Cannot decrypt service: no valid key could produce valid json', svc.id);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
catch (e) {
|
|
350
|
-
console.log('Cannot decrypt service', svc.id, e);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
else if (svc.encryptedSelf) {
|
|
354
|
-
try {
|
|
355
|
-
const json = yield this.crypto.entities.tryDecryptJson(keys, (0, binary_utils_1.string2ua)((0, binary_utils_1.a2b)(svc.encryptedSelf)), true);
|
|
356
|
-
if (json) {
|
|
357
|
-
Object.assign(svc, json);
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
console.log('Cannot decrypt service: no valid key could produce valid json', svc.id);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
catch (e) {
|
|
364
|
-
console.log('Cannot decrypt service', svc.id, e);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
svc.content = _.fromPairs(yield Promise.all(_.toPairs(svc.content).map((p) => __awaiter(this, void 0, void 0, function* () {
|
|
369
|
-
if (p[1].compoundValue) {
|
|
370
|
-
p[1].compoundValue = yield this.decryptServices(hcpartyId, p[1].compoundValue, keys);
|
|
371
|
-
}
|
|
372
|
-
return p;
|
|
373
|
-
}))));
|
|
374
|
-
}
|
|
375
|
-
return svc;
|
|
349
|
+
return new models_1.Contact(yield (0, utils_1.decryptObject)(svc, (encrypted) => __awaiter(this, void 0, void 0, function* () {
|
|
350
|
+
var _a;
|
|
351
|
+
return (_a = (yield this.crypto.entities.tryDecryptJson(keys, encrypted, false))) !== null && _a !== void 0 ? _a : {};
|
|
352
|
+
})));
|
|
376
353
|
})));
|
|
377
354
|
}
|
|
378
355
|
contactOfService(ctcs, svcId) {
|
|
@@ -773,13 +750,18 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
773
750
|
shareWithMany(contact, delegates) {
|
|
774
751
|
return __awaiter(this, void 0, void 0, function* () {
|
|
775
752
|
const self = yield this.dataOwnerApi.getCurrentDataOwnerId();
|
|
776
|
-
|
|
753
|
+
const extended = yield this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(contact, true, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
777
754
|
delegateId,
|
|
778
755
|
{
|
|
779
756
|
shareEncryptionKey: options.shareEncryptionKey,
|
|
780
757
|
shareOwningEntityIds: options.sharePatientId,
|
|
781
758
|
},
|
|
782
|
-
])))
|
|
759
|
+
])));
|
|
760
|
+
if (!!extended) {
|
|
761
|
+
return yield this.modifyAs(self, extended);
|
|
762
|
+
}
|
|
763
|
+
else
|
|
764
|
+
return contact;
|
|
783
765
|
});
|
|
784
766
|
}
|
|
785
767
|
getDataOwnersWithAccessTo(entity) {
|