@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
|
@@ -4,13 +4,21 @@ import * as models from '../icc-api/model/models';
|
|
|
4
4
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
5
5
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
6
6
|
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
|
|
7
|
+
import { ShareResult } from './utils/ShareResult';
|
|
8
|
+
import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest';
|
|
9
|
+
import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
|
|
10
|
+
import { SecureDelegation } from '../icc-api/model/SecureDelegation';
|
|
11
|
+
import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
|
|
12
|
+
import { XHR } from '../icc-api/api/XHR';
|
|
7
13
|
import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
|
|
8
14
|
export declare class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {
|
|
9
|
-
private crypto;
|
|
10
|
-
dataOwnerApi
|
|
15
|
+
private readonly crypto;
|
|
16
|
+
private readonly dataOwnerApi;
|
|
17
|
+
private readonly autofillAuthor;
|
|
18
|
+
get headers(): Promise<Array<XHR.Header>>;
|
|
11
19
|
constructor(host: string, headers: {
|
|
12
20
|
[key: string]: string;
|
|
13
|
-
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
21
|
+
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
14
22
|
/**
|
|
15
23
|
* Creates a new instance of receipt with initialised encryption metadata (not in the database).
|
|
16
24
|
* @param user the current user.
|
|
@@ -19,13 +27,12 @@ export declare class IccReceiptXApi extends IccReceiptApi implements EncryptedEn
|
|
|
19
27
|
* @param options optional parameters:
|
|
20
28
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
21
29
|
* 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
|
|
22
|
-
* auto-delegations, in such case the access level specified here will be used.
|
|
23
|
-
* access will be possible.
|
|
30
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
24
31
|
* @return a new instance of receipt.
|
|
25
32
|
*/
|
|
26
33
|
newInstance(user: models.User, r: any, options?: {
|
|
27
34
|
additionalDelegates?: {
|
|
28
|
-
[dataOwnerId: string]:
|
|
35
|
+
[dataOwnerId: string]: AccessLevelEnum;
|
|
29
36
|
};
|
|
30
37
|
}): Promise<models.Receipt>;
|
|
31
38
|
logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer): Promise<models.Receipt>;
|
|
@@ -46,7 +53,7 @@ export declare class IccReceiptXApi extends IccReceiptApi implements EncryptedEn
|
|
|
46
53
|
*/
|
|
47
54
|
setClearReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt>;
|
|
48
55
|
/**
|
|
49
|
-
* Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt
|
|
56
|
+
* Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.
|
|
50
57
|
* @param receipt a receipt.
|
|
51
58
|
* @param attachmentId id of the attachment of this receipt to retrieve.
|
|
52
59
|
* @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption
|
|
@@ -68,40 +75,67 @@ export declare class IccReceiptXApi extends IccReceiptApi implements EncryptedEn
|
|
|
68
75
|
data: ArrayBuffer;
|
|
69
76
|
wasDecrypted: boolean;
|
|
70
77
|
}>;
|
|
78
|
+
/**
|
|
79
|
+
* @return if the logged data owner has write access to the content of the given receipt
|
|
80
|
+
*/
|
|
81
|
+
hasWriteAccess(receipt: models.Receipt): Promise<boolean>;
|
|
71
82
|
/**
|
|
72
83
|
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
73
|
-
* the encrypted content.
|
|
84
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
74
85
|
* @param delegateId the id of the data owner which will be granted access to the receipt.
|
|
75
86
|
* @param receipt the receipt to share.
|
|
76
87
|
* @param options optional parameters to customize the sharing behaviour:
|
|
77
88
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
78
89
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
79
90
|
* receipt does not have encrypted content.
|
|
80
|
-
*
|
|
91
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
92
|
+
* @return the updated entity
|
|
81
93
|
*/
|
|
82
94
|
shareWith(delegateId: string, receipt: models.Receipt, options?: {
|
|
95
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
83
96
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
84
97
|
}): Promise<models.Receipt>;
|
|
85
98
|
/**
|
|
86
99
|
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
87
|
-
* the encrypted content.
|
|
100
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
88
101
|
* @param receipt the receipt to share.
|
|
89
|
-
* @param delegates
|
|
102
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
90
103
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
91
104
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
92
105
|
* receipt does not have encrypted content.
|
|
93
|
-
*
|
|
106
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
107
|
+
* @return the updated entity
|
|
94
108
|
*/
|
|
95
109
|
shareWithMany(receipt: models.Receipt, delegates: {
|
|
96
110
|
[delegateId: string]: {
|
|
111
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
97
112
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
98
113
|
};
|
|
99
114
|
}): Promise<models.Receipt>;
|
|
115
|
+
/**
|
|
116
|
+
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
117
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
118
|
+
* @param receipt the receipt to share.
|
|
119
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
120
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
121
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
122
|
+
* receipt does not have encrypted content.
|
|
123
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
124
|
+
* @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
|
|
125
|
+
* the operation failed.
|
|
126
|
+
*/
|
|
127
|
+
tryShareWithMany(receipt: models.Receipt, delegates: {
|
|
128
|
+
[delegateId: string]: {
|
|
129
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
130
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
131
|
+
};
|
|
132
|
+
}): Promise<ShareResult<models.Receipt>>;
|
|
100
133
|
getDataOwnersWithAccessTo(entity: models.Receipt): Promise<{
|
|
101
134
|
permissionsByDataOwnerId: {
|
|
102
|
-
[
|
|
135
|
+
[p: string]: AccessLevelEnum;
|
|
103
136
|
};
|
|
104
137
|
hasUnknownAnonymousDataOwners: boolean;
|
|
105
138
|
}>;
|
|
106
139
|
getEncryptionKeysOf(entity: models.Receipt): Promise<string[]>;
|
|
140
|
+
createDelegationDeAnonymizationMetadata(entity: models.Receipt, delegates: string[]): Promise<void>;
|
|
107
141
|
}
|
|
@@ -13,8 +13,14 @@ exports.IccReceiptXApi = void 0;
|
|
|
13
13
|
const icc_api_1 = require("../icc-api");
|
|
14
14
|
const models = require("../icc-api/model/models");
|
|
15
15
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
16
|
+
const ShareMetadataBehaviour_1 = require("./crypto/ShareMetadataBehaviour");
|
|
17
|
+
const SecureDelegation_1 = require("../icc-api/model/SecureDelegation");
|
|
18
|
+
var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
|
|
16
19
|
class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
17
|
-
|
|
20
|
+
get headers() {
|
|
21
|
+
return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'Receipt'));
|
|
22
|
+
}
|
|
23
|
+
constructor(host, headers, crypto, dataOwnerApi, autofillAuthor, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
18
24
|
? window.fetch
|
|
19
25
|
: typeof self !== 'undefined'
|
|
20
26
|
? self.fetch
|
|
@@ -22,6 +28,8 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
22
28
|
super(host, headers, authenticationProvider, fetchImpl);
|
|
23
29
|
this.crypto = crypto;
|
|
24
30
|
this.dataOwnerApi = dataOwnerApi;
|
|
31
|
+
this.autofillAuthor = autofillAuthor;
|
|
32
|
+
this.dataOwnerApi = dataOwnerApi;
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
27
35
|
* Creates a new instance of receipt with initialised encryption metadata (not in the database).
|
|
@@ -31,28 +39,23 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
31
39
|
* @param options optional parameters:
|
|
32
40
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
33
41
|
* 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
|
|
34
|
-
* auto-delegations, in such case the access level specified here will be used.
|
|
35
|
-
* access will be possible.
|
|
42
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
36
43
|
* @return a new instance of receipt.
|
|
37
44
|
*/
|
|
38
45
|
newInstance(user, r, options = {}) {
|
|
39
46
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
40
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const receipt = new models.Receipt(Object.assign(Object.assign({}, (r !== null && r !== void 0 ? r : {})), { _type: 'org.taktik.icure.entities.Receipt', id: (_a = r === null || r === void 0 ? void 0 : r.id) !== null && _a !== void 0 ? _a : this.crypto.randomUuid(), created: (_b = r === null || r === void 0 ? void 0 : r.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = r === null || r === void 0 ? void 0 : r.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = r === null || r === void 0 ? void 0 : r.responsible) !== null && _d !== void 0 ? _d : this.dataOwnerApi.getDataOwnerIdOf(user), author: (_e = r === null || r === void 0 ? void 0 : r.author) !== null && _e !== void 0 ? _e : user.id, codes: (_f = r === null || r === void 0 ? void 0 : r.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = r === null || r === void 0 ? void 0 : r.tags) !== null && _g !== void 0 ? _g : [] }));
|
|
42
|
-
const extraDelegations = [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...((_m = (_l = user.autoDelegations) === null || _l === void 0 ? void 0 : _l.medicalInformation) !== null && _m !== void 0 ? _m : []),
|
|
46
|
-
];
|
|
47
|
-
return new models.Receipt(yield this.crypto.entities
|
|
48
|
-
.entityWithInitialisedEncryptedMetadata(receipt, undefined, undefined, true, extraDelegations)
|
|
48
|
+
const receipt = new models.Receipt(Object.assign(Object.assign({}, (r !== null && r !== void 0 ? r : {})), { _type: 'org.taktik.icure.entities.Receipt', id: (_a = r === null || r === void 0 ? void 0 : r.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = r === null || r === void 0 ? void 0 : r.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = r === null || r === void 0 ? void 0 : r.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = r === null || r === void 0 ? void 0 : r.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = r === null || r === void 0 ? void 0 : r.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined), codes: (_f = r === null || r === void 0 ? void 0 : r.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = r === null || r === void 0 ? void 0 : r.tags) !== null && _g !== void 0 ? _g : [] }));
|
|
49
|
+
const extraDelegations = Object.assign(Object.assign({}, Object.fromEntries([...((_j = (_h = user.autoDelegations) === null || _h === void 0 ? void 0 : _h.all) !== null && _j !== void 0 ? _j : []), ...((_l = (_k = user.autoDelegations) === null || _k === void 0 ? void 0 : _k.medicalInformation) !== null && _l !== void 0 ? _l : [])].map((d) => [d, AccessLevelEnum.WRITE]))), ((_m = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _m !== void 0 ? _m : {}));
|
|
50
|
+
return new models.Receipt(yield this.crypto.xapi
|
|
51
|
+
.entityWithInitialisedEncryptedMetadata(receipt, 'Receipt', undefined, undefined, true, false, extraDelegations)
|
|
49
52
|
.then((x) => x.updatedEntity));
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
55
|
logReceipt(user, docId, refs, blobType, blob) {
|
|
53
56
|
return this.newInstance(user, { documentId: docId, references: refs })
|
|
54
57
|
.then((rcpt) => this.createReceipt(rcpt))
|
|
55
|
-
.then((rcpt) => (blob.byteLength != 0 ? this.
|
|
58
|
+
.then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachmentForBlobType(rcpt.id, rcpt.rev, blobType, blob) : Promise.resolve(rcpt)));
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.
|
|
@@ -62,9 +65,10 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
62
65
|
* @return the updated receipt.
|
|
63
66
|
*/
|
|
64
67
|
encryptAndSetReceiptAttachment(receipt, blobType, attachment) {
|
|
68
|
+
var _a;
|
|
65
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const encryptedData = yield this.crypto.
|
|
67
|
-
return yield this.
|
|
70
|
+
const { encryptedData, updatedEntity } = yield this.crypto.xapi.encryptDataOf(receipt, 'Receipt', attachment, (r) => this.modifyReceipt(r));
|
|
71
|
+
return yield this.setReceiptAttachmentForBlobType(receipt.id, (_a = updatedEntity === null || updatedEntity === void 0 ? void 0 : updatedEntity.rev) !== null && _a !== void 0 ? _a : receipt.rev, blobType, encryptedData);
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
@@ -76,11 +80,11 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
76
80
|
*/
|
|
77
81
|
setClearReceiptAttachment(receipt, blobType, attachment) {
|
|
78
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
return yield this.
|
|
83
|
+
return yield this.setReceiptAttachmentForBlobType(receipt.id, receipt.rev, blobType, attachment);
|
|
80
84
|
});
|
|
81
85
|
}
|
|
82
86
|
/**
|
|
83
|
-
* Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt
|
|
87
|
+
* Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.
|
|
84
88
|
* @param receipt a receipt.
|
|
85
89
|
* @param attachmentId id of the attachment of this receipt to retrieve.
|
|
86
90
|
* @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption
|
|
@@ -89,10 +93,10 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
89
93
|
*/
|
|
90
94
|
getAndDecryptReceiptAttachment(receipt, attachmentId, validator = () => Promise.resolve(true)) {
|
|
91
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const
|
|
93
|
-
if (!wasDecrypted)
|
|
96
|
+
const retrieved = yield this.getAndTryDecryptReceiptAttachment(receipt, attachmentId, (x) => validator(x));
|
|
97
|
+
if (!retrieved.wasDecrypted)
|
|
94
98
|
throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`);
|
|
95
|
-
return data;
|
|
99
|
+
return retrieved.data;
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
@@ -107,19 +111,28 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
107
111
|
*/
|
|
108
112
|
getAndTryDecryptReceiptAttachment(receipt, attachmentId, validator = () => Promise.resolve(true)) {
|
|
109
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
return yield this.crypto.
|
|
114
|
+
return yield this.crypto.xapi.tryDecryptDataOf({ entity: receipt, type: 'Receipt' }, yield this.getReceiptAttachment(receipt.id, attachmentId), (x) => validator(x));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @return if the logged data owner has write access to the content of the given receipt
|
|
119
|
+
*/
|
|
120
|
+
hasWriteAccess(receipt) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
return this.crypto.xapi.hasWriteAccess({ entity: receipt, type: 'Receipt' });
|
|
111
123
|
});
|
|
112
124
|
}
|
|
113
125
|
/**
|
|
114
126
|
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
115
|
-
* the encrypted content.
|
|
127
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
116
128
|
* @param delegateId the id of the data owner which will be granted access to the receipt.
|
|
117
129
|
* @param receipt the receipt to share.
|
|
118
130
|
* @param options optional parameters to customize the sharing behaviour:
|
|
119
131
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
120
132
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
121
133
|
* receipt does not have encrypted content.
|
|
122
|
-
*
|
|
134
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
135
|
+
* @return the updated entity
|
|
123
136
|
*/
|
|
124
137
|
shareWith(delegateId, receipt, options = {}) {
|
|
125
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -128,33 +141,56 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
128
141
|
}
|
|
129
142
|
/**
|
|
130
143
|
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
131
|
-
* the encrypted content.
|
|
144
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
132
145
|
* @param receipt the receipt to share.
|
|
133
|
-
* @param delegates
|
|
146
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
134
147
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
135
148
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
136
149
|
* receipt does not have encrypted content.
|
|
137
|
-
*
|
|
150
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
151
|
+
* @return the updated entity
|
|
138
152
|
*/
|
|
139
153
|
shareWithMany(receipt, delegates) {
|
|
140
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
|
|
142
|
-
if (!!extended) {
|
|
143
|
-
return yield this.modifyReceipt(extended);
|
|
144
|
-
}
|
|
145
|
-
else
|
|
146
|
-
return receipt;
|
|
155
|
+
return (yield this.tryShareWithMany(receipt, delegates)).updatedEntityOrThrow;
|
|
147
156
|
});
|
|
148
157
|
}
|
|
149
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
160
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
161
|
+
* @param receipt the receipt to share.
|
|
162
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
163
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
164
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
165
|
+
* receipt does not have encrypted content.
|
|
166
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
167
|
+
* @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
|
|
168
|
+
* the operation failed.
|
|
169
|
+
*/
|
|
170
|
+
tryShareWithMany(receipt, delegates) {
|
|
150
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
|
|
172
|
+
// All entities should have an encryption key.
|
|
173
|
+
const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(receipt, 'Receipt');
|
|
174
|
+
const updatedEntity = entityWithEncryptionKey ? yield this.modifyReceipt(entityWithEncryptionKey) : receipt;
|
|
175
|
+
return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata({ entity: updatedEntity, type: 'Receipt' }, true, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
176
|
+
delegateId,
|
|
177
|
+
{
|
|
178
|
+
requestedPermissions: options.requestedPermissions,
|
|
179
|
+
shareEncryptionKeys: options.shareEncryptionKey,
|
|
180
|
+
shareOwningEntityIds: ShareMetadataBehaviour_1.ShareMetadataBehaviour.NEVER,
|
|
181
|
+
shareSecretIds: undefined,
|
|
182
|
+
},
|
|
183
|
+
])), (x) => this.bulkShareReceipt(x));
|
|
152
184
|
});
|
|
153
185
|
}
|
|
186
|
+
getDataOwnersWithAccessTo(entity) {
|
|
187
|
+
return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: 'Receipt' });
|
|
188
|
+
}
|
|
154
189
|
getEncryptionKeysOf(entity) {
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
|
|
190
|
+
return this.crypto.xapi.encryptionKeysOf({ entity, type: 'Receipt' }, undefined);
|
|
191
|
+
}
|
|
192
|
+
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
193
|
+
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: 'Receipt' }, delegates);
|
|
158
194
|
}
|
|
159
195
|
}
|
|
160
196
|
exports.IccReceiptXApi = IccReceiptXApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA0C;AAG1C,kDAAiD;AAEjD,0EAAgG;AAIhG,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,GAAN,MAAM,CAAe;QAU7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;OAWG;IACG,WAAW,CACf,IAAiB,EACjB,CAAM,EACN,UAEI,EAAE;;;YAEN,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,OAAO,iCAC7B,CAAC,CAAC,aAAD,CAAC,cAAD,CAAC,GAAI,EAAE,CAAC,KACZ,KAAK,EAAE,mCAAmC,EAC1C,EAAE,EAAE,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,EAAE,mCAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EACrC,OAAO,EAAE,MAAA,CAAC,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AAC,MAAM,CAAC,QAAQ,CAAC,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;AA1LD,wCA0LC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as _ from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\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.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of receipt with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param r initialised data for the receipt. 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 * @return a new instance of receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n } = {}\n ): Promise<models.Receipt> {\n const receipt = new models.Receipt({\n ...(r ?? {}),\n _type: 'org.taktik.icure.entities.Receipt',\n id: r?.id ?? this.crypto.randomUuid(),\n created: r?.created ?? new Date().getTime(),\n modified: r?.modified ?? new Date().getTime(),\n responsible: r?.responsible ?? this.dataOwnerApi.getDataOwnerIdOf(user),\n author: r?.author ?? user.id,\n codes: r?.codes ?? [],\n tags: r?.tags ?? [],\n })\n\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.medicalInformation ?? []),\n ]\n return new models.Receipt(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(receipt, undefined, undefined, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer) {\n return this.newInstance(user, { documentId: docId, references: refs })\n .then((rcpt) => this.createReceipt(rcpt))\n .then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachment(rcpt.id!, blobType, '', <any>blob) : Promise.resolve(rcpt)))\n }\n\n /**\n * Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async encryptAndSetReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n const encryptedData = await this.crypto.entities.encryptDataOf(receipt, attachment)\n return await this.setReceiptAttachment(receipt.id!, blobType, undefined, encryptedData)\n }\n\n /**\n * Adds an unencrypted attachment to a receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async setClearReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n return await this.setReceiptAttachment(receipt.id!, blobType, undefined, attachment)\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt, throwing an error if the operation fails.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n */\n async getAndDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const { data, wasDecrypted } = await this.crypto.entities.tryDecryptDataOf(\n receipt,\n await this.getReceiptAttachment(receipt.id!, attachmentId, ''),\n (x) => validator(x)\n )\n if (!wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return data\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return an object containing:\n * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n * - wasDecrypted: if the data was successfully decrypted or not\n */\n async getAndTryDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n return await this.crypto.entities.tryDecryptDataOf(receipt, await this.getReceiptAttachment(receipt.id!, attachmentId, ''), (x) => validator(x))\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content.\n * @param delegateId the id of the data owner which will be granted access to the receipt.\n * @param receipt the receipt to share.\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 * receipt does not have encrypted content.\n * @return a promise which will contain the updated receipt.\n */\n async shareWith(\n delegateId: string,\n receipt: models.Receipt,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Receipt> {\n return this.shareWithMany(receipt, { [delegateId]: options })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content.\n * @param receipt the receipt to share.\n * @param delegates sharing options for each delegate which will gain access to the entity:\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 * receipt does not have encrypted content.\n * @return a promise which will contain the updated receipt.\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n const extended = await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(receipt, true, delegates)\n if (!!extended) {\n return await this.modifyReceipt(extended)\n } else return receipt\n }\n\n async getDataOwnersWithAccessTo(entity: models.Receipt): Promise<{\n permissionsByDataOwnerId: { [dataOwnerId: string]: 'WRITE' }\n hasUnknownAnonymousDataOwners: boolean\n }> {\n return await this.crypto.entities.getDataOwnersWithAccessTo(entity)\n }\n\n async getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return await this.crypto.entities.encryptionKeysOf(entity)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":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AC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAChC,CAAA;QACH,CAAC;KAAA;IAED,yBAAyB,CACvB,MAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IACtG,CAAC;IAED,mBAAmB,CAAC,MAAsB;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,CAAA;IAClF,CAAC;IAED,uCAAuC,CAAC,MAAsB,EAAE,SAAmB;QACjF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,CAAA;IACzH,CAAC;CACF;AAlPD,wCAkPC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as _ from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { MaintenanceTask } from '../icc-api/model/models'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'Receipt'))\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 autofillAuthor: boolean,\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.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of receipt with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param r initialised data for the receipt. 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 * @return a new instance of receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n } = {}\n ): Promise<models.Receipt> {\n const receipt = new models.Receipt({\n ...(r ?? {}),\n _type: 'org.taktik.icure.entities.Receipt',\n id: r?.id ?? this.crypto.primitives.randomUuid(),\n created: r?.created ?? new Date().getTime(),\n modified: r?.modified ?? new Date().getTime(),\n responsible: r?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: r?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: r?.codes ?? [],\n tags: r?.tags ?? [],\n })\n\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.Receipt(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(receipt, 'Receipt', undefined, undefined, true, false, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer) {\n return this.newInstance(user, { documentId: docId, references: refs })\n .then((rcpt) => this.createReceipt(rcpt))\n .then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachmentForBlobType(rcpt.id!, rcpt.rev!, blobType, <any>blob) : Promise.resolve(rcpt)))\n }\n\n /**\n * Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async encryptAndSetReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n const { encryptedData, updatedEntity } = await this.crypto.xapi.encryptDataOf(receipt, 'Receipt', attachment, (r) => this.modifyReceipt(r))\n return await this.setReceiptAttachmentForBlobType(receipt.id!, updatedEntity?.rev ?? receipt.rev!, blobType, encryptedData)\n }\n\n /**\n * Adds an unencrypted attachment to a receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async setClearReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n return await this.setReceiptAttachmentForBlobType(receipt.id!, receipt.rev!, blobType, attachment)\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n */\n async getAndDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const retrieved = await this.getAndTryDecryptReceiptAttachment(receipt, attachmentId, (x) => validator(x))\n if (!retrieved.wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return retrieved.data\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return an object containing:\n * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n * - wasDecrypted: if the data was successfully decrypted or not\n */\n async getAndTryDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n return await this.crypto.xapi.tryDecryptDataOf(\n { entity: receipt, type: 'Receipt' },\n await this.getReceiptAttachment(receipt.id!, attachmentId),\n (x) => validator(x)\n )\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given receipt\n */\n async hasWriteAccess(receipt: models.Receipt): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: receipt, type: 'Receipt' })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt 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 receipt.\n * @param receipt the receipt to share.\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 * receipt does not have encrypted content.\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 receipt: models.Receipt,\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Receipt> {\n return this.shareWithMany(receipt, { [delegateId]: options })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param receipt the receipt 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 * - 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 * receipt does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n return (await this.tryShareWithMany(receipt, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param receipt the receipt 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 * - 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 * receipt does not have encrypted content.\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 receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Receipt>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(receipt, 'Receipt')\n const updatedEntity = entityWithEncryptionKey ? await this.modifyReceipt(entityWithEncryptionKey) : receipt\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n { entity: updatedEntity, type: 'Receipt' },\n true,\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: undefined,\n },\n ])\n ),\n (x) => this.bulkShareReceipt(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Receipt\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: 'Receipt' })\n }\n\n getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: 'Receipt' }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Receipt, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: 'Receipt' }, delegates)\n }\n}\n"]}
|
|
@@ -6,14 +6,22 @@ import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
|
6
6
|
import * as models from '../icc-api/model/models';
|
|
7
7
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
8
8
|
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
|
|
9
|
+
import { ShareResult } from './utils/ShareResult';
|
|
10
|
+
import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest';
|
|
11
|
+
import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
|
|
12
|
+
import { SecureDelegation } from '../icc-api/model/SecureDelegation';
|
|
13
|
+
import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
|
|
14
|
+
import { XHR } from '../icc-api/api/XHR';
|
|
9
15
|
import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
|
|
10
|
-
export declare class IccTimeTableXApi extends IccTimeTableApi implements EncryptedEntityXApi<TimeTable> {
|
|
16
|
+
export declare class IccTimeTableXApi extends IccTimeTableApi implements EncryptedEntityXApi<models.TimeTable> {
|
|
17
|
+
private readonly crypto;
|
|
18
|
+
private readonly dataOwnerApi;
|
|
19
|
+
private readonly autofillAuthor;
|
|
11
20
|
i18n: any;
|
|
12
|
-
|
|
13
|
-
dataOwnerApi: IccDataOwnerXApi;
|
|
21
|
+
get headers(): Promise<Array<XHR.Header>>;
|
|
14
22
|
constructor(host: string, headers: {
|
|
15
23
|
[key: string]: string;
|
|
16
|
-
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
24
|
+
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
17
25
|
/**
|
|
18
26
|
* Creates a new instance of timetable with initialised encryption metadata (not in the database).
|
|
19
27
|
* @param user the current user.
|
|
@@ -22,15 +30,19 @@ export declare class IccTimeTableXApi extends IccTimeTableApi implements Encrypt
|
|
|
22
30
|
* @param options optional parameters:
|
|
23
31
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
24
32
|
* 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
|
|
25
|
-
* auto-delegations, in such case the access level specified here will be used.
|
|
26
|
-
* access will be possible.
|
|
33
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
27
34
|
* @return a new instance of timetable.
|
|
28
35
|
*/
|
|
29
36
|
newInstance(user: User, tt: TimeTable, options?: {
|
|
30
37
|
additionalDelegates?: {
|
|
31
|
-
[dataOwnerId: string]:
|
|
38
|
+
[dataOwnerId: string]: AccessLevelEnum;
|
|
32
39
|
};
|
|
40
|
+
preferredSfk?: string;
|
|
33
41
|
}): Promise<TimeTable>;
|
|
42
|
+
/**
|
|
43
|
+
* @return if the logged data owner has write access to the content of the given time table
|
|
44
|
+
*/
|
|
45
|
+
hasWriteAccess(timeTable: models.TimeTable): Promise<boolean>;
|
|
34
46
|
/**
|
|
35
47
|
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
36
48
|
* the encrypted content, with read-only or read-write permissions.
|
|
@@ -40,33 +52,54 @@ export declare class IccTimeTableXApi extends IccTimeTableApi implements Encrypt
|
|
|
40
52
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
41
53
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
42
54
|
* time table does not have encrypted content.
|
|
43
|
-
*
|
|
44
|
-
* the
|
|
55
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
56
|
+
* @return the updated entity
|
|
45
57
|
*/
|
|
46
58
|
shareWith(delegateId: string, timeTable: models.TimeTable, options?: {
|
|
59
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
47
60
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
48
61
|
}): Promise<models.TimeTable>;
|
|
49
62
|
/**
|
|
50
63
|
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
51
64
|
* the encrypted content, with read-only or read-write permissions.
|
|
52
65
|
* @param timeTable the time table to share.
|
|
53
|
-
* @param delegates
|
|
66
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
54
67
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
55
68
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
56
69
|
* time table does not have encrypted content.
|
|
57
|
-
*
|
|
58
|
-
* the
|
|
70
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
71
|
+
* @return the updated entity
|
|
59
72
|
*/
|
|
60
73
|
shareWithMany(timeTable: models.TimeTable, delegates: {
|
|
61
74
|
[delegateId: string]: {
|
|
75
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
62
76
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
63
77
|
};
|
|
64
78
|
}): Promise<models.TimeTable>;
|
|
79
|
+
/**
|
|
80
|
+
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
81
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
82
|
+
* @param timeTable the time table to share.
|
|
83
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
84
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
85
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
86
|
+
* time table does not have encrypted content.
|
|
87
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
88
|
+
* @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
|
|
89
|
+
* the operation failed.
|
|
90
|
+
*/
|
|
91
|
+
tryShareWithMany(timeTable: models.TimeTable, delegates: {
|
|
92
|
+
[delegateId: string]: {
|
|
93
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
94
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
95
|
+
};
|
|
96
|
+
}): Promise<ShareResult<models.TimeTable>>;
|
|
65
97
|
getDataOwnersWithAccessTo(entity: models.TimeTable): Promise<{
|
|
66
98
|
permissionsByDataOwnerId: {
|
|
67
|
-
[p: string]:
|
|
99
|
+
[p: string]: AccessLevelEnum;
|
|
68
100
|
};
|
|
69
101
|
hasUnknownAnonymousDataOwners: boolean;
|
|
70
102
|
}>;
|
|
71
103
|
getEncryptionKeysOf(entity: models.TimeTable): Promise<string[]>;
|
|
104
|
+
createDelegationDeAnonymizationMetadata(entity: models.TimeTable, delegates: string[]): Promise<void>;
|
|
72
105
|
}
|