@icure/api 7.1.16 → 8.0.0-RC.2
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.d.ts +12 -1
- package/icc-api/api/IccAccesslogApi.js +142 -98
- package/icc-api/api/IccAccesslogApi.js.map +1 -1
- package/icc-api/api/IccBemikronoApi.d.ts +81 -0
- package/icc-api/api/IccBemikronoApi.js +163 -0
- package/icc-api/api/IccBemikronoApi.js.map +1 -0
- package/icc-api/api/IccCalendarItemApi.d.ts +21 -1
- package/icc-api/api/IccCalendarItemApi.js +183 -117
- package/icc-api/api/IccCalendarItemApi.js.map +1 -1
- package/icc-api/api/IccClassificationApi.d.ts +21 -1
- package/icc-api/api/IccClassificationApi.js +119 -63
- package/icc-api/api/IccClassificationApi.js.map +1 -1
- package/icc-api/api/IccContactApi.d.ts +21 -1
- package/icc-api/api/IccContactApi.js +385 -294
- package/icc-api/api/IccContactApi.js.map +1 -1
- package/icc-api/api/IccDocumentApi.d.ts +38 -25
- package/icc-api/api/IccDocumentApi.js +279 -212
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/api/IccExchangeDataApi.d.ts +19 -0
- package/icc-api/api/IccExchangeDataApi.js +85 -0
- package/icc-api/api/IccExchangeDataApi.js.map +1 -0
- package/icc-api/api/IccExchangeDataMapApi.d.ts +18 -0
- package/icc-api/api/IccExchangeDataMapApi.js +65 -0
- package/icc-api/api/IccExchangeDataMapApi.js.map +1 -0
- package/icc-api/api/IccFormApi.d.ts +21 -1
- package/icc-api/api/IccFormApi.js +321 -229
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/api/IccHelementApi.d.ts +21 -1
- package/icc-api/api/IccHelementApi.js +207 -137
- package/icc-api/api/IccHelementApi.js.map +1 -1
- package/icc-api/api/IccInvoiceApi.d.ts +21 -1
- package/icc-api/api/IccInvoiceApi.js +404 -298
- package/icc-api/api/IccInvoiceApi.js.map +1 -1
- package/icc-api/api/IccMaintenanceTaskApi.d.ts +12 -1
- package/icc-api/api/IccMaintenanceTaskApi.js +79 -43
- package/icc-api/api/IccMaintenanceTaskApi.js.map +1 -1
- package/icc-api/api/IccMessageApi.d.ts +28 -1
- package/icc-api/api/IccMessageApi.js +294 -191
- package/icc-api/api/IccMessageApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.d.ts +12 -1
- package/icc-api/api/IccPatientApi.js +447 -351
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/api/IccReceiptApi.d.ts +22 -8
- package/icc-api/api/IccReceiptApi.js +121 -64
- package/icc-api/api/IccReceiptApi.js.map +1 -1
- package/icc-api/api/IccRestApiPath.js +1 -1
- package/icc-api/api/IccRestApiPath.js.map +1 -1
- package/icc-api/api/IccSecureDelegationKeyMapApi.d.ts +26 -0
- package/icc-api/api/IccSecureDelegationKeyMapApi.js +71 -0
- package/icc-api/api/IccSecureDelegationKeyMapApi.js.map +1 -0
- package/icc-api/api/IccTimeTableApi.d.ts +12 -1
- package/icc-api/api/IccTimeTableApi.js +86 -48
- package/icc-api/api/IccTimeTableApi.js.map +1 -1
- package/icc-api/api/IccTopicApi.d.ts +90 -0
- package/icc-api/api/IccTopicApi.js +193 -0
- package/icc-api/api/IccTopicApi.js.map +1 -0
- package/icc-api/index.d.ts +2 -0
- package/icc-api/index.js +2 -0
- package/icc-api/index.js.map +1 -1
- package/icc-api/model/AbstractFilterMessage.d.ts +15 -0
- package/icc-api/model/AbstractFilterMessage.js +21 -0
- package/icc-api/model/AbstractFilterMessage.js.map +1 -0
- package/icc-api/model/AbstractFilterTopic.d.ts +15 -0
- package/icc-api/model/AbstractFilterTopic.js +21 -0
- package/icc-api/model/AbstractFilterTopic.js.map +1 -0
- package/icc-api/model/AccessLog.d.ts +2 -0
- package/icc-api/model/AccessLog.js.map +1 -1
- package/icc-api/model/Article.d.ts +2 -0
- package/icc-api/model/Article.js.map +1 -1
- package/icc-api/model/CalendarItem.d.ts +2 -0
- package/icc-api/model/CalendarItem.js.map +1 -1
- package/icc-api/model/Classification.d.ts +2 -0
- package/icc-api/model/Classification.js.map +1 -1
- package/icc-api/model/ClassificationTemplate.d.ts +2 -0
- package/icc-api/model/ClassificationTemplate.js.map +1 -1
- package/icc-api/model/Connection.d.ts +1 -1
- package/icc-api/model/Connection.js.map +1 -1
- package/icc-api/model/Contact.d.ts +2 -0
- package/icc-api/model/Contact.js.map +1 -1
- package/icc-api/model/Device.d.ts +4 -4
- package/icc-api/model/Device.js.map +1 -1
- package/icc-api/model/Document.d.ts +2 -0
- package/icc-api/model/Document.js.map +1 -1
- package/icc-api/model/ExchangeDataMapCreationBatch.d.ts +13 -0
- package/icc-api/model/ExchangeDataMapCreationBatch.js +10 -0
- package/icc-api/model/ExchangeDataMapCreationBatch.js.map +1 -0
- package/icc-api/model/FilterChainMessage.d.ts +19 -0
- package/icc-api/model/FilterChainMessage.js +11 -0
- package/icc-api/model/FilterChainMessage.js.map +1 -0
- package/icc-api/model/FilterChainTopic.d.ts +19 -0
- package/icc-api/model/FilterChainTopic.js +11 -0
- package/icc-api/model/FilterChainTopic.js.map +1 -0
- package/icc-api/model/Form.d.ts +2 -0
- package/icc-api/model/Form.js.map +1 -1
- package/icc-api/model/HealthElement.d.ts +2 -0
- package/icc-api/model/HealthElement.js.map +1 -1
- package/icc-api/model/HealthcareParty.d.ts +2 -2
- package/icc-api/model/HealthcareParty.js +13 -1
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/IcureStub.d.ts +2 -0
- package/icc-api/model/IcureStub.js.map +1 -1
- package/icc-api/model/Invoice.d.ts +2 -0
- package/icc-api/model/Invoice.js.map +1 -1
- package/icc-api/model/MaintenanceTask.d.ts +13 -10
- package/icc-api/model/MaintenanceTask.js +13 -11
- package/icc-api/model/MaintenanceTask.js.map +1 -1
- package/icc-api/model/Message.d.ts +2 -0
- package/icc-api/model/Message.js.map +1 -1
- package/icc-api/model/PaginatedListExchangeData.d.ts +9 -0
- package/icc-api/model/PaginatedListExchangeData.js +10 -0
- package/icc-api/model/PaginatedListExchangeData.js.map +1 -0
- package/icc-api/model/PaginatedListTopic.d.ts +20 -0
- package/icc-api/model/PaginatedListTopic.js +10 -0
- package/icc-api/model/PaginatedListTopic.js.map +1 -0
- package/icc-api/model/Patient.d.ts +4 -2
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-api/model/PatientByHcPartyGenderEducationProfession.d.ts +31 -0
- package/icc-api/model/PatientByHcPartyGenderEducationProfession.js +32 -0
- package/icc-api/model/PatientByHcPartyGenderEducationProfession.js.map +1 -0
- package/icc-api/model/Receipt.d.ts +2 -0
- package/icc-api/model/Receipt.js.map +1 -1
- package/icc-api/model/SecureDelegation.d.ts +52 -0
- package/icc-api/model/SecureDelegation.js +16 -0
- package/icc-api/model/SecureDelegation.js.map +1 -0
- package/icc-api/model/SecurityMetadata.d.ts +33 -0
- package/icc-api/model/SecurityMetadata.js +13 -0
- package/icc-api/model/SecurityMetadata.js.map +1 -0
- package/icc-api/model/Service.d.ts +2 -0
- package/icc-api/model/Service.js.map +1 -1
- package/icc-api/model/TimeTable.d.ts +2 -0
- package/icc-api/model/TimeTable.js.map +1 -1
- package/icc-api/model/Topic.d.ts +95 -0
- package/icc-api/model/Topic.js +16 -0
- package/icc-api/model/Topic.js.map +1 -0
- package/icc-api/model/internal/ExchangeData.d.ts +64 -0
- package/icc-api/model/internal/ExchangeData.js +15 -0
- package/icc-api/model/internal/ExchangeData.js.map +1 -0
- package/icc-api/model/internal/ExchangeDataMap.d.ts +24 -0
- package/icc-api/model/internal/ExchangeDataMap.js +13 -0
- package/icc-api/model/internal/ExchangeDataMap.js.map +1 -0
- package/icc-api/model/internal/SecureDelegationKeyMap.d.ts +14 -0
- package/icc-api/model/internal/SecureDelegationKeyMap.js +13 -0
- package/icc-api/model/internal/SecureDelegationKeyMap.js.map +1 -0
- package/icc-api/model/models.d.ts +26 -40
- package/icc-api/model/models.js +19 -37
- package/icc-api/model/models.js.map +1 -1
- package/icc-api/model/requests/EntityBulkShareResult.d.ts +28 -0
- package/icc-api/model/requests/EntityBulkShareResult.js +16 -0
- package/icc-api/model/requests/EntityBulkShareResult.js.map +1 -0
- package/icc-api/model/requests/EntityShareOrMetadataUpdateRequest.d.ts +10 -0
- package/icc-api/model/requests/EntityShareOrMetadataUpdateRequest.js +17 -0
- package/icc-api/model/requests/EntityShareOrMetadataUpdateRequest.js.map +1 -0
- package/icc-api/model/requests/EntityShareRequest.d.ts +110 -0
- package/icc-api/model/requests/EntityShareRequest.js +63 -0
- package/icc-api/model/requests/EntityShareRequest.js.map +1 -0
- package/icc-api/model/requests/EntitySharedMetadataUpdateRequest.d.ts +54 -0
- package/icc-api/model/requests/EntitySharedMetadataUpdateRequest.js +24 -0
- package/icc-api/model/requests/EntitySharedMetadataUpdateRequest.js.map +1 -0
- package/icc-api/model/requests/MinimalEntityBulkShareResult.d.ts +23 -0
- package/icc-api/model/requests/MinimalEntityBulkShareResult.js +13 -0
- package/icc-api/model/requests/MinimalEntityBulkShareResult.js.map +1 -0
- package/icc-api/model/requests/RejectedShareOrMetadataUpdateRequest.d.ts +21 -0
- package/icc-api/model/requests/RejectedShareOrMetadataUpdateRequest.js +14 -0
- package/icc-api/model/requests/RejectedShareOrMetadataUpdateRequest.js.map +1 -0
- package/icc-x-api/basexapi/EncryptedEntityXApi.d.ts +55 -6
- package/icc-x-api/basexapi/EncryptedEntityXApi.js.map +1 -1
- package/icc-x-api/crypto/AES.js +1 -1
- package/icc-x-api/crypto/AES.js.map +1 -1
- package/icc-x-api/crypto/AccessControlKeysHeadersProvider.d.ts +18 -0
- package/icc-x-api/crypto/AccessControlKeysHeadersProvider.js +50 -0
- package/icc-x-api/crypto/AccessControlKeysHeadersProvider.js.map +1 -0
- package/icc-x-api/crypto/AccessControlSecretUtils.d.ts +43 -0
- package/icc-x-api/crypto/AccessControlSecretUtils.js +97 -0
- package/icc-x-api/crypto/AccessControlSecretUtils.js.map +1 -0
- package/icc-x-api/crypto/BaseExchangeDataManager.d.ts +146 -0
- package/icc-x-api/crypto/BaseExchangeDataManager.js +342 -0
- package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -0
- package/icc-x-api/crypto/BaseExchangeKeysManager.d.ts +0 -18
- package/icc-x-api/crypto/BaseExchangeKeysManager.js +11 -85
- package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
- package/icc-x-api/crypto/ConfidentialEntities.d.ts +26 -16
- package/icc-x-api/crypto/ConfidentialEntities.js +30 -17
- package/icc-x-api/crypto/ConfidentialEntities.js.map +1 -1
- package/icc-x-api/crypto/CryptoStrategies.d.ts +8 -1
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/DelegationsDeAnonymization.d.ts +44 -0
- package/icc-x-api/crypto/DelegationsDeAnonymization.js +235 -0
- package/icc-x-api/crypto/DelegationsDeAnonymization.js.map +1 -0
- package/icc-x-api/crypto/ExchangeDataManager.d.ts +97 -0
- package/icc-x-api/crypto/ExchangeDataManager.js +501 -0
- package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -0
- package/icc-x-api/crypto/ExchangeDataMapManager.d.ts +32 -0
- package/icc-x-api/crypto/ExchangeDataMapManager.js +70 -0
- package/icc-x-api/crypto/ExchangeDataMapManager.js.map +1 -0
- package/icc-x-api/crypto/ExchangeKeysManager.d.ts +4 -16
- package/icc-x-api/crypto/ExchangeKeysManager.js +4 -62
- package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtils.d.ts +326 -0
- package/icc-x-api/crypto/ExtendedApisUtils.js +3 -0
- package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -0
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +174 -0
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +559 -0
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -0
- package/icc-x-api/crypto/KeyRecovery.d.ts +5 -2
- package/icc-x-api/crypto/KeyRecovery.js +59 -29
- package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
- package/icc-x-api/crypto/LegacyCryptoStrategies.d.ts +7 -2
- package/icc-x-api/crypto/LegacyCryptoStrategies.js +8 -1
- package/icc-x-api/crypto/LegacyCryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.d.ts +33 -0
- package/icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.js +141 -0
- package/icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.js.map +1 -0
- package/icc-x-api/crypto/RSA.d.ts +34 -8
- package/icc-x-api/crypto/RSA.js +80 -13
- package/icc-x-api/crypto/RSA.js.map +1 -1
- package/icc-x-api/crypto/SecureDelegationsEncryption.d.ts +54 -0
- package/icc-x-api/crypto/SecureDelegationsEncryption.js +178 -0
- package/icc-x-api/crypto/SecureDelegationsEncryption.js.map +1 -0
- package/icc-x-api/crypto/SecureDelegationsManager.d.ts +66 -0
- package/icc-x-api/crypto/SecureDelegationsManager.js +261 -0
- package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -0
- package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.d.ts +46 -0
- package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.js +312 -0
- package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.js.map +1 -0
- package/icc-x-api/crypto/SecurityMetadataDecryptor.d.ts +97 -0
- package/icc-x-api/crypto/SecurityMetadataDecryptor.js +79 -0
- package/icc-x-api/crypto/SecurityMetadataDecryptor.js.map +1 -0
- package/icc-x-api/crypto/ShamirKeysManager.d.ts +5 -5
- package/icc-x-api/crypto/ShamirKeysManager.js +6 -9
- package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
- package/icc-x-api/crypto/TransferKeysManager.d.ts +8 -6
- package/icc-x-api/crypto/TransferKeysManager.js +75 -52
- package/icc-x-api/crypto/TransferKeysManager.js.map +1 -1
- package/icc-x-api/crypto/{KeyManager.d.ts → UserEncryptionKeysManager.d.ts} +4 -6
- package/icc-x-api/crypto/{KeyManager.js → UserEncryptionKeysManager.js} +43 -23
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -0
- package/icc-x-api/crypto/UserSignatureKeysManager.d.ts +26 -0
- package/icc-x-api/crypto/UserSignatureKeysManager.js +74 -0
- package/icc-x-api/crypto/UserSignatureKeysManager.js.map +1 -0
- package/icc-x-api/crypto/utils.d.ts +61 -11
- package/icc-x-api/crypto/utils.js +113 -44
- package/icc-x-api/crypto/utils.js.map +1 -1
- package/icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter.d.ts +8 -0
- package/icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter.js +13 -0
- package/icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter.js.map +1 -0
- package/icc-x-api/filters/MessageByHcPartyFilter.d.ts +7 -0
- package/icc-x-api/filters/MessageByHcPartyFilter.js +13 -0
- package/icc-x-api/filters/MessageByHcPartyFilter.js.map +1 -0
- package/icc-x-api/filters/MessageByHcPartyTransportGuidFilter.d.ts +8 -0
- package/icc-x-api/filters/MessageByHcPartyTransportGuidFilter.js +13 -0
- package/icc-x-api/filters/MessageByHcPartyTransportGuidFilter.js.map +1 -0
- package/icc-x-api/filters/TopicByHcPartyFilter.d.ts +7 -0
- package/icc-x-api/filters/TopicByHcPartyFilter.js +13 -0
- package/icc-x-api/filters/TopicByHcPartyFilter.js.map +1 -0
- package/icc-x-api/filters/TopicByParticipantFilter.d.ts +7 -0
- package/icc-x-api/filters/TopicByParticipantFilter.js +13 -0
- package/icc-x-api/filters/TopicByParticipantFilter.js.map +1 -0
- package/icc-x-api/filters/filters.d.ts +5 -0
- package/icc-x-api/filters/filters.js +5 -0
- package/icc-x-api/filters/filters.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +49 -12
- package/icc-x-api/icc-accesslog-x-api.js +81 -44
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +53 -15
- package/icc-x-api/icc-calendar-item-x-api.js +105 -51
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +47 -10
- package/icc-x-api/icc-classification-x-api.js +62 -33
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +59 -33
- package/icc-x-api/icc-contact-x-api.js +101 -66
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +33 -333
- package/icc-x-api/icc-crypto-x-api.js +47 -764
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-data-owner-x-api.d.ts +20 -8
- package/icc-x-api/icc-data-owner-x-api.js +31 -10
- package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +51 -12
- package/icc-x-api/icc-document-x-api.js +117 -66
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +48 -11
- package/icc-x-api/icc-form-x-api.js +71 -37
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.d.ts +2 -2
- package/icc-x-api/icc-hcparty-x-api.js +3 -3
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +59 -20
- package/icc-x-api/icc-helement-x-api.js +78 -43
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-icure-maintenance-x-api.d.ts +7 -2
- package/icc-x-api/icc-icure-maintenance-x-api.js +38 -27
- package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.d.ts +53 -16
- package/icc-x-api/icc-invoice-x-api.js +69 -35
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +56 -22
- package/icc-x-api/icc-maintenance-task-x-api.js +77 -36
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +75 -19
- package/icc-x-api/icc-message-x-api.js +126 -37
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +86 -29
- package/icc-x-api/icc-patient-x-api.js +318 -379
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +47 -13
- package/icc-x-api/icc-receipt-x-api.js +72 -36
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.d.ts +46 -13
- package/icc-x-api/icc-time-table-x-api.js +61 -27
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.d.ts +191 -0
- package/icc-x-api/icc-topic-x-api.js +307 -0
- package/icc-x-api/icc-topic-x-api.js.map +1 -0
- package/icc-x-api/icc-user-x-api.d.ts +2 -2
- package/icc-x-api/icc-user-x-api.js +3 -3
- package/icc-x-api/icc-user-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +18 -2
- package/icc-x-api/index.js +203 -156
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/maintenance/KeyPairUpdateRequest.d.ts +1 -1
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.d.ts +2 -0
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js +9 -2
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js.map +1 -1
- package/icc-x-api/storage/IcureStorageFacade.d.ts +23 -2
- package/icc-x-api/storage/IcureStorageFacade.js +36 -2
- package/icc-x-api/storage/IcureStorageFacade.js.map +1 -1
- package/icc-x-api/storage/KeyStorageFacade.d.ts +12 -0
- package/icc-x-api/storage/KeyStorageFacade.js.map +1 -1
- package/icc-x-api/storage/KeyStorageImpl.d.ts +2 -0
- package/icc-x-api/storage/KeyStorageImpl.js +10 -0
- package/icc-x-api/storage/KeyStorageImpl.js.map +1 -1
- package/icc-x-api/storage/StorageEntryKeysFactory.d.ts +14 -1
- package/icc-x-api/storage/StorageEntryKeysFactory.js.map +1 -1
- package/icc-x-api/utils/EntityWithDelegationTypeName.d.ts +32 -0
- package/icc-x-api/utils/EntityWithDelegationTypeName.js +75 -0
- package/icc-x-api/utils/EntityWithDelegationTypeName.js.map +1 -0
- package/icc-x-api/utils/ShareResult.d.ts +74 -0
- package/icc-x-api/utils/ShareResult.js +61 -0
- package/icc-x-api/utils/ShareResult.js.map +1 -0
- package/icc-x-api/utils/binary-utils.d.ts +1 -0
- package/icc-x-api/utils/binary-utils.js +8 -1
- package/icc-x-api/utils/binary-utils.js.map +1 -1
- package/icc-x-api/utils/collection-utils.d.ts +5 -0
- package/icc-x-api/utils/collection-utils.js +26 -1
- package/icc-x-api/utils/collection-utils.js.map +1 -1
- package/icc-x-api/utils/crypto-utils.d.ts +4 -3
- package/icc-x-api/utils/crypto-utils.js +5 -4
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/icc-x-api/utils/lru-temporised-async-cache.d.ts +26 -3
- package/icc-x-api/utils/lru-temporised-async-cache.js +75 -15
- package/icc-x-api/utils/lru-temporised-async-cache.js.map +1 -1
- package/icc-x-api/utils/websocket.d.ts +14 -10
- package/icc-x-api/utils/websocket.js +26 -9
- package/icc-x-api/utils/websocket.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/package.json +2 -3
- package/icc-x-api/crypto/EntitiesEncryption.d.ts +0 -275
- package/icc-x-api/crypto/EntitiesEncryption.js +0 -734
- package/icc-x-api/crypto/EntitiesEncryption.js.map +0 -1
- package/icc-x-api/crypto/KeyManager.js.map +0 -1
|
@@ -11,18 +11,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.IccMessageXApi = void 0;
|
|
13
13
|
const icc_api_1 = require("../icc-api");
|
|
14
|
-
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
15
14
|
const models = require("../icc-api/model/models");
|
|
15
|
+
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
16
|
+
const SecureDelegation_1 = require("../icc-api/model/SecureDelegation");
|
|
17
|
+
var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
const Connection_1 = require("../icc-api/model/Connection");
|
|
16
20
|
class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
17
|
-
|
|
21
|
+
get headers() {
|
|
22
|
+
return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'Message'));
|
|
23
|
+
}
|
|
24
|
+
constructor(host, headers, crypto, dataOwnerApi, authApi, autofillAuthor, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), encryptedKeys = [], fetchImpl = typeof window !== 'undefined'
|
|
18
25
|
? window.fetch
|
|
19
26
|
: typeof self !== 'undefined'
|
|
20
27
|
? self.fetch
|
|
21
28
|
: fetch) {
|
|
22
29
|
super(host, headers, authenticationProvider, fetchImpl);
|
|
23
30
|
this.crypto = crypto;
|
|
24
|
-
this.crypto = crypto;
|
|
25
31
|
this.dataOwnerApi = dataOwnerApi;
|
|
32
|
+
this.authApi = authApi;
|
|
33
|
+
this.autofillAuthor = autofillAuthor;
|
|
34
|
+
this.encryptedFields = (0, utils_1.parseEncryptedFields)(encryptedKeys, 'Message.');
|
|
26
35
|
}
|
|
27
36
|
// noinspection JSUnusedGlobalSymbols
|
|
28
37
|
newInstance(user, m) {
|
|
@@ -37,9 +46,8 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
37
46
|
* @param options optional parameters:
|
|
38
47
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
39
48
|
* auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
|
|
40
|
-
* auto-delegations, in such case the access level specified here will be used.
|
|
41
|
-
*
|
|
42
|
-
* - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a
|
|
49
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
50
|
+
* - preferredSfk: secret id of the patient to use as the secret foreign key to use for the message. The default value will be a
|
|
43
51
|
* secret id of patient known by the topmost parent in the current data owner hierarchy.
|
|
44
52
|
* @return a new instance of message.
|
|
45
53
|
*/
|
|
@@ -48,23 +56,27 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
48
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
57
|
if (!patient && options.preferredSfk)
|
|
50
58
|
throw new Error('You need to specify parent patient in order to use secret foreign keys.');
|
|
51
|
-
const message = Object.assign(Object.assign({}, (m !== null && m !== void 0 ? m : {})), { _type: 'org.taktik.icure.entities.Message', id: (_a = m === null || m === void 0 ? void 0 : m.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = m === null || m === void 0 ? void 0 : m.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = m === null || m === void 0 ? void 0 : m.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = m === null || m === void 0 ? void 0 : m.responsible) !== null && _d !== void 0 ? _d : this.dataOwnerApi.getDataOwnerIdOf(user), author: (_e = m === null || m === void 0 ? void 0 : m.author) !== null && _e !== void 0 ? _e : user.id, codes: (_f = m === null || m === void 0 ? void 0 : m.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = m === null || m === void 0 ? void 0 : m.tags) !== null && _g !== void 0 ? _g : [] });
|
|
59
|
+
const message = Object.assign(Object.assign({}, (m !== null && m !== void 0 ? m : {})), { _type: 'org.taktik.icure.entities.Message', id: (_a = m === null || m === void 0 ? void 0 : m.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = m === null || m === void 0 ? void 0 : m.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = m === null || m === void 0 ? void 0 : m.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = m === null || m === void 0 ? void 0 : m.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = m === null || m === void 0 ? void 0 : m.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined), codes: (_f = m === null || m === void 0 ? void 0 : m.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = m === null || m === void 0 ? void 0 : m.tags) !== null && _g !== void 0 ? _g : [] });
|
|
52
60
|
const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
|
|
53
61
|
if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
|
|
54
62
|
throw new Error('Can only initialise entities as current data owner.');
|
|
55
|
-
const sfk = patient
|
|
63
|
+
const sfk = patient
|
|
64
|
+
? (_h = options.preferredSfk) !== null && _h !== void 0 ? _h : (yield this.crypto.confidential.getAnySecretIdSharedWithParents({ entity: patient, type: 'Patient' }))
|
|
65
|
+
: undefined;
|
|
56
66
|
if (patient && !sfk)
|
|
57
67
|
throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`);
|
|
58
|
-
const extraDelegations = [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
...((_o = (_m = user.autoDelegations) === null || _m === void 0 ? void 0 : _m.medicalInformation) !== null && _o !== void 0 ? _o : []),
|
|
62
|
-
];
|
|
63
|
-
return new models.Message(yield this.crypto.entities
|
|
64
|
-
.entityWithInitialisedEncryptedMetadata(message, patient === null || patient === void 0 ? void 0 : patient.id, sfk, true, extraDelegations)
|
|
68
|
+
const extraDelegations = Object.assign(Object.assign({}, Object.fromEntries([...((_k = (_j = user.autoDelegations) === null || _j === void 0 ? void 0 : _j.all) !== null && _k !== void 0 ? _k : []), ...((_m = (_l = user.autoDelegations) === null || _l === void 0 ? void 0 : _l.medicalInformation) !== null && _m !== void 0 ? _m : [])].map((d) => [d, AccessLevelEnum.WRITE]))), ((_o = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _o !== void 0 ? _o : {}));
|
|
69
|
+
return new models.Message(yield this.crypto.xapi
|
|
70
|
+
.entityWithInitialisedEncryptedMetadata(message, 'Message', patient === null || patient === void 0 ? void 0 : patient.id, sfk, true, true, extraDelegations)
|
|
65
71
|
.then((x) => x.updatedEntity));
|
|
66
72
|
});
|
|
67
73
|
}
|
|
74
|
+
decrypt(messages) {
|
|
75
|
+
return Promise.all(messages.map((message) => this.crypto.xapi.decryptEntity(message, 'Message', (x) => new models.Message(x))));
|
|
76
|
+
}
|
|
77
|
+
encrypt(messages) {
|
|
78
|
+
return Promise.all(messages.map((p) => this.crypto.xapi.tryEncryptEntity(p, 'Message', this.encryptedFields, true, false, (x) => new models.Message(x))));
|
|
79
|
+
}
|
|
68
80
|
/**
|
|
69
81
|
* @param message a message
|
|
70
82
|
* @return the id of the patient that the message refers to, retrieved from the encrypted metadata. Normally there should only be one element
|
|
@@ -72,12 +84,20 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
72
84
|
*/
|
|
73
85
|
decryptPatientIdOf(message) {
|
|
74
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
return this.crypto.
|
|
87
|
+
return this.crypto.xapi.owningEntityIdsOf({ entity: message, type: 'Message' }, undefined);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @return if the logged data owner has write access to the content of the given message
|
|
92
|
+
*/
|
|
93
|
+
hasWriteAccess(message) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
return this.crypto.xapi.hasWriteAccess({ entity: message, type: 'Message' });
|
|
76
96
|
});
|
|
77
97
|
}
|
|
78
98
|
/**
|
|
79
99
|
* Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also
|
|
80
|
-
* the encrypted content.
|
|
100
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
81
101
|
* @param delegateId the id of the data owner which will be granted access to the message.
|
|
82
102
|
* @param message the message to share.
|
|
83
103
|
* @param shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the
|
|
@@ -88,42 +108,64 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
88
108
|
* message does not have encrypted content.
|
|
89
109
|
* - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to
|
|
90
110
|
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
91
|
-
*
|
|
111
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
112
|
+
* @return the updated entity
|
|
92
113
|
*/
|
|
93
114
|
shareWith(delegateId, message, shareSecretIds, options = {}) {
|
|
94
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
return this.shareWithMany(message, { [delegateId]: Object.assign({
|
|
116
|
+
return this.shareWithMany(message, { [delegateId]: Object.assign(Object.assign({}, options), { shareSecretIds }) });
|
|
96
117
|
});
|
|
97
118
|
}
|
|
98
119
|
/**
|
|
99
120
|
* Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also
|
|
100
|
-
* the encrypted content.
|
|
121
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
101
122
|
* @param message the message to share.
|
|
102
|
-
* @param delegates
|
|
123
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
124
|
+
* - shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the
|
|
125
|
+
* shared Message is the owning entity id. Mandatory.
|
|
103
126
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
104
127
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
105
128
|
* message does not have encrypted content.
|
|
106
129
|
* - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to
|
|
107
130
|
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
131
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
132
|
+
* @return the updated entity
|
|
133
|
+
*/
|
|
134
|
+
shareWithMany(message, delegates) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
return (yield this.tryShareWithMany(message, delegates)).updatedEntityOrThrow;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also
|
|
141
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
142
|
+
* @param message the message to share.
|
|
143
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
108
144
|
* - shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the
|
|
109
|
-
* shared Message is the owning entity id.
|
|
110
|
-
*
|
|
145
|
+
* shared Message is the owning entity id. Mandatory.
|
|
146
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
147
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
148
|
+
* message does not have encrypted content.
|
|
149
|
+
* - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to
|
|
150
|
+
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
151
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
152
|
+
* @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if
|
|
153
|
+
* the operation failed.
|
|
111
154
|
*/
|
|
112
|
-
|
|
155
|
+
tryShareWithMany(message, delegates) {
|
|
113
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
|
|
157
|
+
// All entities should have an encryption key.
|
|
158
|
+
const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(message, 'Message');
|
|
159
|
+
const updatedEntity = entityWithEncryptionKey ? yield this.modifyMessage(entityWithEncryptionKey) : message;
|
|
160
|
+
return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata({ entity: updatedEntity, type: 'Message' }, false, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
115
161
|
delegateId,
|
|
116
162
|
{
|
|
117
|
-
|
|
118
|
-
|
|
163
|
+
requestedPermissions: options.requestedPermissions,
|
|
164
|
+
shareEncryptionKeys: options.shareEncryptionKey,
|
|
119
165
|
shareOwningEntityIds: options.sharePatientId,
|
|
166
|
+
shareSecretIds: options.shareSecretIds,
|
|
120
167
|
},
|
|
121
|
-
])));
|
|
122
|
-
if (!!extended) {
|
|
123
|
-
return yield this.modifyMessage(extended);
|
|
124
|
-
}
|
|
125
|
-
else
|
|
126
|
-
return message;
|
|
168
|
+
])), (x) => this.bulkShareMessages(x));
|
|
127
169
|
});
|
|
128
170
|
}
|
|
129
171
|
/**
|
|
@@ -132,18 +174,65 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
132
174
|
* the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.
|
|
133
175
|
*/
|
|
134
176
|
decryptSecretIdsOf(message) {
|
|
135
|
-
return this.crypto.
|
|
177
|
+
return this.crypto.xapi.secretIdsOf({ entity: message, type: 'Message' }, undefined);
|
|
136
178
|
}
|
|
137
179
|
getDataOwnersWithAccessTo(entity) {
|
|
180
|
+
return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: 'Message' });
|
|
181
|
+
}
|
|
182
|
+
getEncryptionKeysOf(entity) {
|
|
183
|
+
return this.crypto.xapi.encryptionKeysOf({ entity, type: 'Message' }, undefined);
|
|
184
|
+
}
|
|
185
|
+
filterMessagesBy(body, startDocumentId, limit) {
|
|
186
|
+
const _super = Object.create(null, {
|
|
187
|
+
filterMessagesBy: { get: () => super.filterMessagesBy }
|
|
188
|
+
});
|
|
189
|
+
var _a;
|
|
138
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
|
|
191
|
+
const page = yield _super.filterMessagesBy.call(this, body, startDocumentId, limit);
|
|
192
|
+
const decryptedMessages = yield this.decrypt((_a = page.rows) !== null && _a !== void 0 ? _a : []);
|
|
193
|
+
if (decryptedMessages.some((m) => !m.decrypted))
|
|
194
|
+
throw new Error('Some messages could not be decrypted');
|
|
195
|
+
return Object.assign(Object.assign({}, page), { rows: decryptedMessages.map((m) => m.entity) });
|
|
140
196
|
});
|
|
141
197
|
}
|
|
142
|
-
|
|
198
|
+
encryptAndCreateMessage(body) {
|
|
199
|
+
const _super = Object.create(null, {
|
|
200
|
+
createMessage: { get: () => super.createMessage }
|
|
201
|
+
});
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
const encryptedMessage = yield this.encrypt([body]);
|
|
204
|
+
const createdMessage = yield _super.createMessage.call(this, encryptedMessage[0]);
|
|
205
|
+
return (yield this.decrypt([createdMessage]))[0].entity;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
setMessagesReadStatus(body) {
|
|
209
|
+
const _super = Object.create(null, {
|
|
210
|
+
setMessagesReadStatus: { get: () => super.setMessagesReadStatus }
|
|
211
|
+
});
|
|
143
212
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
return yield this.
|
|
213
|
+
return (yield this.decrypt(yield _super.setMessagesReadStatus.call(this, body))).map((m) => m.entity);
|
|
145
214
|
});
|
|
146
215
|
}
|
|
216
|
+
getAndDecryptMessage(messageId) {
|
|
217
|
+
const _super = Object.create(null, {
|
|
218
|
+
getMessage: { get: () => super.getMessage }
|
|
219
|
+
});
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const encryptedMessage = yield _super.getMessage.call(this, messageId);
|
|
222
|
+
const decryptedMessage = yield this.decrypt([encryptedMessage]);
|
|
223
|
+
if (!decryptedMessage[0].decrypted)
|
|
224
|
+
throw new Error('Message could not be decrypted');
|
|
225
|
+
return decryptedMessage[0].entity;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
subscribeToMessageEvents(eventTypes, filter, eventFired, options = {}) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
return yield (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, 'Message', eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt([encrypted]))[0].entity; })).then((rs) => new Connection_1.ConnectionImpl(rs));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
234
|
+
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: 'Message' }, delegates);
|
|
235
|
+
}
|
|
147
236
|
}
|
|
148
237
|
exports.IccMessageXApi = IccMessageXApi;
|
|
149
238
|
//# sourceMappingURL=icc-message-x-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA0C;AAO1C,0EAAgG;AAChG,kDAAiD;AAIjD,MAAa,cAAe,SAAQ,uBAAa;IAG/C,YACE,IAAY,EACZ,OAAkC,EAC1B,MAAqB,EAC7B,YAA8B,EAC9B,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAT/C,WAAM,GA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AC,yBAAyB,CAAC,MAAM,CAAC,CAAA;QACrE,CAAC;KAAA;IAEK,mBAAmB,CAAC,MAAsB;;YAC9C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC5D,CAAC;KAAA;CACF;AA/KD,wCA+KC","sourcesContent":["import { IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as _ from 'lodash'\n\nimport { Patient, User } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport * as models from '../icc-api/model/models'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\n\nexport class IccMessageXApi extends IccMessageApi implements EncryptedEntityXApi<models.Message> {\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n // noinspection JSUnusedGlobalSymbols\n newInstance(user: User, m: any) {\n return this.newInstanceWithPatient(user, null, m)\n }\n\n /**\n * Creates a new instance of message with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this message refers to.\n * @param m initialised data for the message. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read\n * access will be possible.\n * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\n * @return a new instance of message.\n */\n async newInstanceWithPatient(\n user: User,\n patient: Patient | null,\n m: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n preferredSfk?: string\n } = {}\n ) {\n if (!patient && options.preferredSfk) throw new Error('You need to specify parent patient in order to use secret foreign keys.')\n const message = {\n ...(m ?? {}),\n _type: 'org.taktik.icure.entities.Message',\n id: m?.id ?? this.crypto.primitives.randomUuid(),\n created: m?.created ?? new Date().getTime(),\n modified: m?.modified ?? new Date().getTime(),\n responsible: m?.responsible ?? this.dataOwnerApi.getDataOwnerIdOf(user),\n author: m?.author ?? user.id,\n codes: m?.codes ?? [],\n tags: m?.tags ?? [],\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = patient ? options?.preferredSfk ?? (await this.crypto.confidential.getAnySecretIdSharedWithParents(patient)) : undefined\n if (patient && !sfk) throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`)\n const extraDelegations = [\n ...Object.keys(options?.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.medicalInformation ?? []),\n ]\n return new models.Message(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(message, patient?.id, sfk, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @param message a message\n * @return the id of the patient that the message refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(message: models.Message): Promise<string[]> {\n return this.crypto.entities.owningEntityIdsOf(message, undefined)\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content.\n * @param delegateId the id of the data owner which will be granted access to the message.\n * @param message the message to share.\n * @param shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * @return a promise which will contain the updated message\n */\n async shareWith(\n delegateId: string,\n message: models.Message,\n shareSecretIds: string[],\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Message> {\n return this.shareWithMany(message, { [delegateId]: { shareSecretIds, ...options } })\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content.\n * @param message the message to share.\n * @param delegates sharing options for each delegate.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id.\n * @return a promise which will contain the updated message\n */\n async shareWithMany(\n message: models.Message,\n delegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n } = {}\n ): Promise<models.Message> {\n const extended = await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(\n message,\n false,\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n shareSecretIds: options.shareSecretIds,\n shareEncryptionKey: options.shareEncryptionKey,\n shareOwningEntityIds: options.sharePatientId,\n },\n ])\n )\n )\n if (!!extended) {\n return await this.modifyMessage(extended)\n } else return message\n }\n\n /**\n * @param message a message\n * @return the secret ids of the message, retrieved from the encrypted metadata. The result may be used to find entities where the message is\n * the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptSecretIdsOf(message: models.Message): Promise<string[]> {\n return this.crypto.entities.secretIdsOf(message, undefined)\n }\n\n async getDataOwnersWithAccessTo(\n entity: models.Message\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: 'WRITE' }; hasUnknownAnonymousDataOwners: boolean }> {\n return await this.crypto.entities.getDataOwnersWithAccessTo(entity)\n }\n\n async getEncryptionKeysOf(entity: models.Message): Promise<string[]> {\n return await this.crypto.entities.encryptionKeysOf(entity)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsD;AAGtD,kDAAiD;AAGjD,0EAAgG;AAChG,wEAAoE;AAOpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAGzD,mCAAqH;AACrH,4DAAwE;AAExE,MAAa,cAAe,SAAQ,uBAAa;IAG/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA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,CAAC,CAAC,CAAA;YAC/D,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;YACrF,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QACnC,CAAC;KAAA;IAEK,wBAAwB,CAC5B,UAA8C,EAC9C,MAA2C,EAC3C,UAA+C,EAC/C,UAA+B,EAAE;;YAEjC,OAAO,MAAM,IAAA,+BAAuB,EAClC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,OAAO,EACZ,SAAS,EACT,UAAU,EACV,MAAM,EACN,UAAU,EACV,OAAO,EACP,CAAO,SAAS,EAAE,EAAE,gDAAC,OAAA,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA,GAAA,CACjE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,2BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;QACxC,CAAC;KAAA;IAED,uCAAuC,CAAC,MAAe,EAAE,SAAmB;QAC1E,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,CAAA;IACzH,CAAC;CACF;AA7RD,wCA6RC","sourcesContent":["import { IccAuthApi, IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport {MaintenanceTask, Message, MessagesReadStatusUpdate, PaginatedListMessage, Patient, User} from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { FilterChainMessage } from '../icc-api/model/FilterChainMessage'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { AbstractFilter } from './filters/filters'\nimport { EncryptedFieldsManifest, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\n\nexport class IccMessageXApi extends IccMessageApi implements EncryptedEntityXApi<models.Message> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'Message'))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n encryptedKeys: Array<string> = [],\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'Message.')\n }\n\n // noinspection JSUnusedGlobalSymbols\n newInstance(user: User, m: any) {\n return this.newInstanceWithPatient(user, null, m)\n }\n\n /**\n * Creates a new instance of message with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this message refers to.\n * @param m initialised data for the message. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the message. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\n * @return a new instance of message.\n */\n async newInstanceWithPatient(\n user: User,\n patient: Patient | null,\n m: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n preferredSfk?: string\n } = {}\n ) {\n if (!patient && options.preferredSfk) throw new Error('You need to specify parent patient in order to use secret foreign keys.')\n const message = {\n ...(m ?? {}),\n _type: 'org.taktik.icure.entities.Message',\n id: m?.id ?? this.crypto.primitives.randomUuid(),\n created: m?.created ?? new Date().getTime(),\n modified: m?.modified ?? new Date().getTime(),\n responsible: m?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: m?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: m?.codes ?? [],\n tags: m?.tags ?? [],\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = patient\n ? options.preferredSfk ?? (await this.crypto.confidential.getAnySecretIdSharedWithParents({ entity: patient, type: 'Patient' }))\n : undefined\n if (patient && !sfk) throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`)\n const extraDelegations = {\n ...Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n ),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Message(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(message, 'Message', patient?.id, sfk, true, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n decrypt(messages: Array<models.Message>) {\n return Promise.all(messages.map((message) => this.crypto.xapi.decryptEntity(message, 'Message', (x) => new models.Message(x))))\n }\n\n encrypt(messages: Array<models.Message>): Promise<Array<models.Message>> {\n return Promise.all(\n messages.map((p) => this.crypto.xapi.tryEncryptEntity(p, 'Message', this.encryptedFields, true, false, (x) => new models.Message(x)))\n )\n }\n\n /**\n * @param message a message\n * @return the id of the patient that the message refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(message: models.Message): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: message, type: 'Message' }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given message\n */\n async hasWriteAccess(message: models.Message): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: message, type: 'Message' })\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the message.\n * @param message the message to share.\n * @param shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n message: models.Message,\n shareSecretIds: string[],\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Message> {\n return this.shareWithMany(message, { [delegateId]: { ...options, shareSecretIds } })\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param message the message to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id. Mandatory.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n message: models.Message,\n delegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Message> {\n return (await this.tryShareWithMany(message, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param message the message to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id. Mandatory.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n message: models.Message,\n delegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Message>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(message, 'Message')\n const updatedEntity = entityWithEncryptionKey ? await this.modifyMessage(entityWithEncryptionKey) : message\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n { entity: updatedEntity, type: 'Message' },\n false,\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: options.sharePatientId,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareMessages(x)\n )\n }\n\n /**\n * @param message a message\n * @return the secret ids of the message, retrieved from the encrypted metadata. The result may be used to find entities where the message is\n * the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptSecretIdsOf(message: models.Message): Promise<string[]> {\n return this.crypto.xapi.secretIdsOf({ entity: message, type: 'Message' }, undefined)\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Message\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: 'Message' })\n }\n\n getEncryptionKeysOf(entity: models.Message): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: 'Message' }, undefined)\n }\n\n override async filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): Promise<PaginatedListMessage> {\n const page = await super.filterMessagesBy(body, startDocumentId, limit)\n const decryptedMessages = await this.decrypt(page.rows ?? [])\n if (decryptedMessages.some((m) => !m.decrypted)) throw new Error('Some messages could not be decrypted')\n return {\n ...page,\n rows: decryptedMessages.map((m) => m.entity),\n }\n }\n\n async encryptAndCreateMessage(body: Message): Promise<Message> {\n const encryptedMessage = await this.encrypt([body])\n const createdMessage = await super.createMessage(encryptedMessage[0])\n return (await this.decrypt([createdMessage]))[0].entity\n }\n\n async setMessagesReadStatus(body?: MessagesReadStatusUpdate): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesReadStatus(body))).map((m) => m.entity)\n }\n\n async getAndDecryptMessage(messageId: string): Promise<Message> {\n const encryptedMessage = await super.getMessage(messageId)\n const decryptedMessage = await this.decrypt([encryptedMessage])\n if (!decryptedMessage[0].decrypted) throw new Error('Message could not be decrypted')\n return decryptedMessage[0].entity\n }\n\n async subscribeToMessageEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Message> | undefined,\n eventFired: (message: Message) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n return await subscribeToEntityEvents(\n this.host,\n this.authApi,\n 'Message',\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt([encrypted]))[0].entity\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n createDelegationDeAnonymizationMetadata(entity: Message, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: 'Message' }, delegates)\n }\n}\n"]}
|
|
@@ -13,28 +13,37 @@ import { IccCalendarItemXApi } from './icc-calendar-item-x-api';
|
|
|
13
13
|
import { SubscriptionOptions } from './utils';
|
|
14
14
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
15
15
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
16
|
+
import { EntityWithDelegationTypeName } from './utils/EntityWithDelegationTypeName';
|
|
17
|
+
import { SecureDelegation } from '../icc-api/model/SecureDelegation';
|
|
18
|
+
import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest';
|
|
16
19
|
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
|
|
20
|
+
import { ShareResult } from './utils/ShareResult';
|
|
21
|
+
import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
|
|
22
|
+
import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
|
|
23
|
+
import { XHR } from '../icc-api/api/XHR';
|
|
17
24
|
import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
25
|
+
import { IccUserXApi } from './icc-user-x-api';
|
|
26
|
+
import { AbstractFilter } from './filters/filters';
|
|
27
|
+
import { Connection } from '../icc-api/model/Connection';
|
|
21
28
|
export declare class IccPatientXApi extends IccPatientApi implements EncryptedEntityXApi<models.Patient> {
|
|
22
|
-
crypto
|
|
23
|
-
contactApi
|
|
24
|
-
formApi
|
|
25
|
-
helementApi
|
|
26
|
-
invoiceApi
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
classificationApi
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
private readonly crypto;
|
|
30
|
+
private readonly contactApi;
|
|
31
|
+
private readonly formApi;
|
|
32
|
+
private readonly helementApi;
|
|
33
|
+
private readonly invoiceApi;
|
|
34
|
+
private readonly documentApi;
|
|
35
|
+
private readonly hcpartyApi;
|
|
36
|
+
private readonly classificationApi;
|
|
37
|
+
private readonly dataOwnerApi;
|
|
38
|
+
private readonly calendarItemApi;
|
|
32
39
|
private readonly userApi;
|
|
33
40
|
private readonly authApi;
|
|
41
|
+
private readonly autofillAuthor;
|
|
34
42
|
private readonly encryptedFields;
|
|
43
|
+
get headers(): Promise<Array<XHR.Header>>;
|
|
35
44
|
constructor(host: string, headers: {
|
|
36
45
|
[key: string]: string;
|
|
37
|
-
}, crypto: IccCryptoXApi, contactApi: IccContactXApi, formApi: IccFormXApi, helementApi: IccHelementXApi, invoiceApi: IccInvoiceXApi, documentApi: IccDocumentXApi, hcpartyApi: IccHcpartyXApi, classificationApi: IccClassificationXApi, dataOwnerApi: IccDataOwnerXApi,
|
|
46
|
+
}, crypto: IccCryptoXApi, contactApi: IccContactXApi, formApi: IccFormXApi, helementApi: IccHelementXApi, invoiceApi: IccInvoiceXApi, documentApi: IccDocumentXApi, hcpartyApi: IccHcpartyXApi, classificationApi: IccClassificationXApi, dataOwnerApi: IccDataOwnerXApi, calendarItemApi: IccCalendarItemXApi, userApi: IccUserXApi, authApi: IccAuthApi, autofillAuthor: boolean, encryptedKeys?: Array<string>, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
38
47
|
/**
|
|
39
48
|
* Creates a new instance of patient with initialised encryption metadata (not in the database).
|
|
40
49
|
* @param user the current user.
|
|
@@ -43,13 +52,12 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
|
|
|
43
52
|
* @param options optional parameters:
|
|
44
53
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
45
54
|
* auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
|
|
46
|
-
* auto-delegations, in such case the access level specified here will be used.
|
|
47
|
-
* access will be possible.
|
|
55
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
48
56
|
* @return a new instance of patient.
|
|
49
57
|
*/
|
|
50
58
|
newInstance(user: models.User, p?: any, options?: {
|
|
51
59
|
additionalDelegates?: {
|
|
52
|
-
[dataOwnerId: string]:
|
|
60
|
+
[dataOwnerId: string]: AccessLevelEnum;
|
|
53
61
|
};
|
|
54
62
|
}): Promise<models.Patient>;
|
|
55
63
|
completeNames(patient: models.Patient): models.Patient;
|
|
@@ -103,18 +111,25 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
|
|
|
103
111
|
mergeInto(toId: string, fromIds: string): never;
|
|
104
112
|
mergeIntoWithUser(user: models.User, toId: string, fromIds: string): Promise<models.Patient | any>;
|
|
105
113
|
modifyPatient(body?: models.Patient): never;
|
|
114
|
+
/**
|
|
115
|
+
* @internal this method is for internal use only and may be changed without notice.
|
|
116
|
+
*/
|
|
106
117
|
modifyPatientRaw(body?: models.Patient): Promise<models.Patient | any>;
|
|
107
118
|
modifyPatientWithUser(user: models.User, body?: models.Patient): Promise<models.Patient | null>;
|
|
108
|
-
|
|
119
|
+
private modifyPatientAs;
|
|
109
120
|
modifyPatientReferral(patientId: string, referralId: string, start?: number, end?: number): never;
|
|
110
121
|
modifyPatientReferralWithUser(user: models.User, patientId: string, referralId: string, start?: number, end?: number): Promise<models.Patient | any>;
|
|
111
122
|
encrypt(user: models.User, pats: Array<models.Patient>): Promise<Array<models.Patient>>;
|
|
112
123
|
private encryptAs;
|
|
113
124
|
decrypt(user: models.User, patients: Array<models.Patient>, fillDelegations?: boolean): Promise<Array<models.Patient>>;
|
|
114
|
-
|
|
125
|
+
private decryptAs;
|
|
126
|
+
tryDecryptOrReturnOriginal(patients: Array<models.Patient>): Promise<{
|
|
115
127
|
entity: models.Patient;
|
|
116
128
|
decrypted: boolean;
|
|
117
129
|
}[]>;
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated replace with {@link shareAllDataOfPatient}
|
|
132
|
+
*/
|
|
118
133
|
share(user: models.User, patId: string, ownerId: string, delegateIds: Array<string>, delegationTags: {
|
|
119
134
|
[key: string]: Array<string>;
|
|
120
135
|
}, usingPost?: boolean): Promise<{
|
|
@@ -126,15 +141,30 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
|
|
|
126
141
|
};
|
|
127
142
|
};
|
|
128
143
|
} | null>;
|
|
144
|
+
shareAllDataOfPatient(user: models.User, patId: string, ownerId: string, delegateIds: Array<string>, delegationTags: {
|
|
145
|
+
[key: string]: Array<string>;
|
|
146
|
+
}, usingPost?: boolean): Promise<{
|
|
147
|
+
patient: models.Patient | null;
|
|
148
|
+
statuses: {
|
|
149
|
+
[key: string]: {
|
|
150
|
+
success: boolean | null;
|
|
151
|
+
error: Error | null;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
} | null>;
|
|
129
155
|
export(user: models.User, patId: string, ownerId: string, usingPost?: boolean): Promise<{
|
|
130
156
|
id: string;
|
|
131
157
|
}>;
|
|
132
158
|
checkInami(inami: string): boolean;
|
|
133
159
|
isValidSsin(ssin: string): boolean;
|
|
134
|
-
getPatientIdOfChildDocumentForHcpAndHcpParents(childDocument: models.Invoice | models.CalendarItem | models.Contact | models.AccessLog, hcpId: string): Promise<string>;
|
|
160
|
+
getPatientIdOfChildDocumentForHcpAndHcpParents(childDocument: models.Invoice | models.CalendarItem | models.Contact | models.AccessLog, hcpId: string, childDocumentType: EntityWithDelegationTypeName): Promise<string>;
|
|
161
|
+
/**
|
|
162
|
+
* @return if the logged data owner has write access to the content of the given patient
|
|
163
|
+
*/
|
|
164
|
+
hasWriteAccess(patient: models.Patient): Promise<boolean>;
|
|
135
165
|
/**
|
|
136
166
|
* Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also
|
|
137
|
-
* the encrypted content.
|
|
167
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
138
168
|
* @param delegateId the id of the data owner which will be granted access to the patient.
|
|
139
169
|
* @param patient the patient to share.
|
|
140
170
|
* @param shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the
|
|
@@ -144,30 +174,56 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
|
|
|
144
174
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
145
175
|
* patient does not have encrypted content.
|
|
146
176
|
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
147
|
-
*
|
|
177
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
178
|
+
* @return the updated entity
|
|
148
179
|
*/
|
|
149
180
|
shareWith(delegateId: string, patient: models.Patient, shareSecretIds: string[], options?: {
|
|
181
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
150
182
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
151
183
|
}): Promise<models.Patient>;
|
|
152
184
|
/**
|
|
153
185
|
* Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also
|
|
154
|
-
* the encrypted content.
|
|
186
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
155
187
|
* @param patient the patient to share.
|
|
156
|
-
* @param delegates
|
|
188
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
189
|
+
* - shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the
|
|
190
|
+
* shared Patient is the owning entity id.
|
|
157
191
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
158
192
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
159
193
|
* patient does not have encrypted content.
|
|
160
|
-
* - shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the
|
|
161
|
-
* shared Patient is the owning entity id.
|
|
162
194
|
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
163
|
-
*
|
|
195
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
196
|
+
* @return the updated entity
|
|
164
197
|
*/
|
|
165
198
|
shareWithMany(patient: models.Patient, delegates: {
|
|
166
|
-
[
|
|
199
|
+
[delegateIds: string]: {
|
|
167
200
|
shareSecretIds: string[];
|
|
201
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
168
202
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
169
203
|
};
|
|
170
204
|
}): Promise<models.Patient>;
|
|
205
|
+
/**
|
|
206
|
+
* Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also
|
|
207
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
208
|
+
* @param patient the patient to share.
|
|
209
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
210
|
+
* - shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the
|
|
211
|
+
* shared Patient is the owning entity id.
|
|
212
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
213
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
214
|
+
* patient does not have encrypted content.
|
|
215
|
+
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
216
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
217
|
+
* @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if
|
|
218
|
+
* the operation failed.
|
|
219
|
+
*/
|
|
220
|
+
tryShareWithMany(patient: models.Patient, delegates: {
|
|
221
|
+
[delegateIds: string]: {
|
|
222
|
+
shareSecretIds: string[];
|
|
223
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
224
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
225
|
+
};
|
|
226
|
+
}): Promise<ShareResult<models.Patient>>;
|
|
171
227
|
/**
|
|
172
228
|
* @param patient a patient
|
|
173
229
|
* @return all the decryptable secret ids of the patient, retrieved from the encrypted metadata. The result may be used to find entities where the
|
|
@@ -188,7 +244,7 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
|
|
|
188
244
|
decryptNonConfidentialSecretIdsOf(patient: models.Patient): Promise<string[]>;
|
|
189
245
|
getDataOwnersWithAccessTo(entity: models.Patient): Promise<{
|
|
190
246
|
permissionsByDataOwnerId: {
|
|
191
|
-
[p: string]:
|
|
247
|
+
[p: string]: AccessLevelEnum;
|
|
192
248
|
};
|
|
193
249
|
hasUnknownAnonymousDataOwners: boolean;
|
|
194
250
|
}>;
|
|
@@ -232,4 +288,5 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
|
|
|
232
288
|
*/
|
|
233
289
|
mergePatients(from: Patient, mergedInto: Patient): Promise<Patient>;
|
|
234
290
|
subscribeToPatientEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter<Patient> | undefined, eventFired: (patient: Patient) => Promise<void>, options?: SubscriptionOptions): Promise<Connection>;
|
|
291
|
+
createDelegationDeAnonymizationMetadata(entity: Patient, delegates: string[]): Promise<void>;
|
|
235
292
|
}
|