@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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IccExchangeDataMapApi } from '../../icc-api/api/IccExchangeDataMapApi';
|
|
2
|
+
import { ExchangeDataMap } from '../../icc-api/model/internal/ExchangeDataMap';
|
|
3
|
+
/**
|
|
4
|
+
* @internal this class is intended for internal use only and may be modified without notice
|
|
5
|
+
* This class manages the Exchange Data Map entities, caching with an LRU cache on retrieval.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ExchangeDataMapManager {
|
|
8
|
+
private readonly api;
|
|
9
|
+
constructor(api: IccExchangeDataMapApi);
|
|
10
|
+
private exchangeDataMapCache;
|
|
11
|
+
/**
|
|
12
|
+
* This function creates a batch of Exchange Data Map, ignoring the one that already exist and are already present in the cache.
|
|
13
|
+
* The ones that are not are created and their ids are cached.
|
|
14
|
+
* @param batch a map where each key is the hex-encoded access control key to another map that associates the encoded id of an
|
|
15
|
+
* Exchange Data entity to the fingerprint of the key used to encrypt it.
|
|
16
|
+
*/
|
|
17
|
+
createExchangeDataMaps(batch: {
|
|
18
|
+
[accessControlKey: string]: {
|
|
19
|
+
[fp: string]: string;
|
|
20
|
+
};
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves an Exchange Data Map.
|
|
24
|
+
* @param accessControlKeyHash the hex-encoded hash of the Exchange Data Map to retrieve.
|
|
25
|
+
*/
|
|
26
|
+
getExchangeDataMap(accessControlKeyHash: string): Promise<ExchangeDataMap>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves a batch of Exchange Data Maps.
|
|
29
|
+
* @param accessControlKeyHashes the hex-encoded hashes of the Exchange Data Maps to retrieve.
|
|
30
|
+
*/
|
|
31
|
+
getExchangeDataMapBatch(accessControlKeyHashes: string[]): Promise<ExchangeDataMap[]>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ExchangeDataMapManager = void 0;
|
|
13
|
+
const lru_temporised_async_cache_1 = require("../utils/lru-temporised-async-cache");
|
|
14
|
+
const ExchangeDataMapCreationBatch_1 = require("../../icc-api/model/ExchangeDataMapCreationBatch");
|
|
15
|
+
/**
|
|
16
|
+
* @internal this class is intended for internal use only and may be modified without notice
|
|
17
|
+
* This class manages the Exchange Data Map entities, caching with an LRU cache on retrieval.
|
|
18
|
+
*/
|
|
19
|
+
class ExchangeDataMapManager {
|
|
20
|
+
constructor(api) {
|
|
21
|
+
this.api = api;
|
|
22
|
+
this.exchangeDataMapCache = new lru_temporised_async_cache_1.LruTemporisedAsyncCache(1000, () => -1);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This function creates a batch of Exchange Data Map, ignoring the one that already exist and are already present in the cache.
|
|
26
|
+
* The ones that are not are created and their ids are cached.
|
|
27
|
+
* @param batch a map where each key is the hex-encoded access control key to another map that associates the encoded id of an
|
|
28
|
+
* Exchange Data entity to the fingerprint of the key used to encrypt it.
|
|
29
|
+
*/
|
|
30
|
+
createExchangeDataMaps(batch) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const entriesToCreate = {};
|
|
33
|
+
for (const [k, v] of Object.entries(batch)) {
|
|
34
|
+
if (!(yield this.exchangeDataMapCache.getIfCachedJob(k))) {
|
|
35
|
+
entriesToCreate[k] = v;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
yield this.api.createExchangeDataMapBatch(new ExchangeDataMapCreationBatch_1.ExchangeDataMapCreationBatch({ batch: entriesToCreate }));
|
|
39
|
+
yield Promise.all(Object.keys(entriesToCreate).map((entry) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
yield this.exchangeDataMapCache.get(entry, () => Promise.resolve({ item: null }));
|
|
41
|
+
})));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves an Exchange Data Map.
|
|
46
|
+
* @param accessControlKeyHash the hex-encoded hash of the Exchange Data Map to retrieve.
|
|
47
|
+
*/
|
|
48
|
+
getExchangeDataMap(accessControlKeyHash) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const exchangeDataMap = yield this.api.getExchangeDataMapById(accessControlKeyHash);
|
|
51
|
+
yield this.exchangeDataMapCache.get(exchangeDataMap.id, () => Promise.resolve({ item: null }));
|
|
52
|
+
return exchangeDataMap;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves a batch of Exchange Data Maps.
|
|
57
|
+
* @param accessControlKeyHashes the hex-encoded hashes of the Exchange Data Maps to retrieve.
|
|
58
|
+
*/
|
|
59
|
+
getExchangeDataMapBatch(accessControlKeyHashes) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const exchangeDataMaps = yield this.api.getExchangeDataMapByBatch(accessControlKeyHashes);
|
|
62
|
+
yield Promise.all(exchangeDataMaps.map((entry) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield this.exchangeDataMapCache.get(entry.id, () => Promise.resolve({ item: null }));
|
|
64
|
+
})));
|
|
65
|
+
return exchangeDataMaps;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ExchangeDataMapManager = ExchangeDataMapManager;
|
|
70
|
+
//# sourceMappingURL=ExchangeDataMapManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExchangeDataMapManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExchangeDataM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EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;YAC9F,OAAO,eAAe,CAAA;QACxB,CAAC;KAAA;IAED;;;OAGG;IACG,uBAAuB,CAAC,sBAAgC;;YAC5D,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAA;YACzF,MAAM,OAAO,CAAC,GAAG,CACf,gBAAgB,CAAC,GAAG,CAAC,CAAO,KAAK,EAAE,EAAE;gBACnC,MAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;YACtF,CAAC,CAAA,CAAC,CACH,CAAA;YACD,OAAO,gBAAgB,CAAA;QACzB,CAAC;KAAA;CACF;AAjDD,wDAiDC","sourcesContent":["import { IccExchangeDataMapApi } from '../../icc-api/api/IccExchangeDataMapApi'\nimport { LruTemporisedAsyncCache } from '../utils/lru-temporised-async-cache'\nimport { ExchangeDataMap } from '../../icc-api/model/internal/ExchangeDataMap'\nimport { ExchangeDataMapCreationBatch } from '../../icc-api/model/ExchangeDataMapCreationBatch'\n\n/**\n * @internal this class is intended for internal use only and may be modified without notice\n * This class manages the Exchange Data Map entities, caching with an LRU cache on retrieval.\n */\nexport class ExchangeDataMapManager {\n constructor(private readonly api: IccExchangeDataMapApi) {}\n\n private exchangeDataMapCache: LruTemporisedAsyncCache<string, null> = new LruTemporisedAsyncCache(1000, () => -1)\n\n /**\n * This function creates a batch of Exchange Data Map, ignoring the one that already exist and are already present in the cache.\n * The ones that are not are created and their ids are cached.\n * @param batch a map where each key is the hex-encoded access control key to another map that associates the encoded id of an\n * Exchange Data entity to the fingerprint of the key used to encrypt it.\n */\n async createExchangeDataMaps(batch: { [accessControlKey: string]: { [fp: string]: string } }): Promise<void> {\n const entriesToCreate: { [accessControlKey: string]: { [fp: string]: string } } = {}\n for (const [k, v] of Object.entries(batch)) {\n if (!(await this.exchangeDataMapCache.getIfCachedJob(k))) {\n entriesToCreate[k] = v\n }\n }\n await this.api.createExchangeDataMapBatch(new ExchangeDataMapCreationBatch({ batch: entriesToCreate }))\n await Promise.all(\n Object.keys(entriesToCreate).map(async (entry) => {\n await this.exchangeDataMapCache.get(entry, () => Promise.resolve({ item: null }))\n })\n )\n }\n\n /**\n * Retrieves an Exchange Data Map.\n * @param accessControlKeyHash the hex-encoded hash of the Exchange Data Map to retrieve.\n */\n async getExchangeDataMap(accessControlKeyHash: string): Promise<ExchangeDataMap> {\n const exchangeDataMap = await this.api.getExchangeDataMapById(accessControlKeyHash)\n await this.exchangeDataMapCache.get(exchangeDataMap.id, () => Promise.resolve({ item: null }))\n return exchangeDataMap\n }\n\n /**\n * Retrieves a batch of Exchange Data Maps.\n * @param accessControlKeyHashes the hex-encoded hashes of the Exchange Data Maps to retrieve.\n */\n async getExchangeDataMapBatch(accessControlKeyHashes: string[]): Promise<ExchangeDataMap[]> {\n const exchangeDataMaps = await this.api.getExchangeDataMapByBatch(accessControlKeyHashes)\n await Promise.all(\n exchangeDataMaps.map(async (entry) => {\n await this.exchangeDataMapCache.get(entry.id, () => Promise.resolve({ item: null }))\n })\n )\n return exchangeDataMaps\n }\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserEncryptionKeysManager } from './UserEncryptionKeysManager';
|
|
2
2
|
import { BaseExchangeKeysManager } from './BaseExchangeKeysManager';
|
|
3
3
|
import { IccDataOwnerXApi } from '../icc-data-owner-x-api';
|
|
4
4
|
import { CryptoPrimitives } from './CryptoPrimitives';
|
|
5
5
|
import { CryptoStrategies } from './CryptoStrategies';
|
|
6
|
-
import {
|
|
6
|
+
import { IcureStorageFacade } from '../storage/IcureStorageFacade';
|
|
7
7
|
/**
|
|
8
8
|
* @internal This class is meant only for internal use and may be changed without notice.
|
|
9
9
|
* More powerful version of {@link BaseExchangeKeysManager} with a simplified interface. Has the following functionalities:
|
|
@@ -19,22 +19,11 @@ export declare class ExchangeKeysManager {
|
|
|
19
19
|
private readonly baseExchangeKeysManager;
|
|
20
20
|
private readonly dataOwnerApi;
|
|
21
21
|
private readonly useParentKeys;
|
|
22
|
+
private readonly icureStorage;
|
|
22
23
|
private delegatorExchangeKeysCache;
|
|
23
24
|
private delegatedExchangeKeysCache;
|
|
24
25
|
get base(): BaseExchangeKeysManager;
|
|
25
|
-
constructor(delegatorKeysCacheSize: number, delegatedKeysCacheSize: number, delegatedKeysCacheLifetimeMsBase: number, delegatedKeysCacheLifetimeMsNoKeys: number, cryptoStrategies: CryptoStrategies, primitives: CryptoPrimitives, keyManager:
|
|
26
|
-
/**
|
|
27
|
-
* Get exchange keys from the current data owner to the provided delegate which are safe for encryption according to the locally verified keys.
|
|
28
|
-
* If currently there is no exchange key towards the provided delegate which is safe for encryption a new one will be automatically created.
|
|
29
|
-
* @param delegateId a delegate
|
|
30
|
-
* @return an object with the following fields:
|
|
31
|
-
* - keys: all available exchange keys which are safe for encryption.
|
|
32
|
-
* - updatedDelegator (optional): if a new key creation job was started when the function was invoked the updated delegator, else undefined.
|
|
33
|
-
*/
|
|
34
|
-
getOrCreateEncryptionExchangeKeysTo(delegateId: string): Promise<{
|
|
35
|
-
updatedDelegator?: CryptoActorStubWithType;
|
|
36
|
-
keys: CryptoKey[];
|
|
37
|
-
}>;
|
|
26
|
+
constructor(delegatorKeysCacheSize: number, delegatedKeysCacheSize: number, delegatedKeysCacheLifetimeMsBase: number, delegatedKeysCacheLifetimeMsNoKeys: number, cryptoStrategies: CryptoStrategies, primitives: CryptoPrimitives, keyManager: UserEncryptionKeysManager, baseExchangeKeysManager: BaseExchangeKeysManager, dataOwnerApi: IccDataOwnerXApi, useParentKeys: boolean, icureStorage: IcureStorageFacade);
|
|
38
27
|
/**
|
|
39
28
|
* Get all keys currently available for a delegator-delegate pair. At least one of the two data owners must be part of the hierarchy for the current
|
|
40
29
|
* data owner.
|
|
@@ -52,5 +41,4 @@ export declare class ExchangeKeysManager {
|
|
|
52
41
|
private forceGetExchangeKeysFor;
|
|
53
42
|
private getSelfExchangeKeysTo;
|
|
54
43
|
private forceGetSelfExchangeKeysTo;
|
|
55
|
-
private forceCreateVerifiedExchangeKeyTo;
|
|
56
44
|
}
|
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ExchangeKeysManager = void 0;
|
|
13
13
|
const lru_temporised_async_cache_1 = require("../utils/lru-temporised-async-cache");
|
|
14
|
-
const utils_1 = require("./utils");
|
|
15
14
|
/**
|
|
16
15
|
* @internal This class is meant only for internal use and may be changed without notice.
|
|
17
16
|
* More powerful version of {@link BaseExchangeKeysManager} with a simplified interface. Has the following functionalities:
|
|
@@ -24,53 +23,17 @@ class ExchangeKeysManager {
|
|
|
24
23
|
get base() {
|
|
25
24
|
return this.baseExchangeKeysManager;
|
|
26
25
|
}
|
|
27
|
-
constructor(delegatorKeysCacheSize, delegatedKeysCacheSize, delegatedKeysCacheLifetimeMsBase, delegatedKeysCacheLifetimeMsNoKeys, cryptoStrategies, primitives, keyManager, baseExchangeKeysManager, dataOwnerApi, useParentKeys) {
|
|
26
|
+
constructor(delegatorKeysCacheSize, delegatedKeysCacheSize, delegatedKeysCacheLifetimeMsBase, delegatedKeysCacheLifetimeMsNoKeys, cryptoStrategies, primitives, keyManager, baseExchangeKeysManager, dataOwnerApi, useParentKeys, icureStorage) {
|
|
28
27
|
this.cryptoStrategies = cryptoStrategies;
|
|
29
28
|
this.primitives = primitives;
|
|
30
29
|
this.keyManager = keyManager;
|
|
31
30
|
this.baseExchangeKeysManager = baseExchangeKeysManager;
|
|
32
31
|
this.dataOwnerApi = dataOwnerApi;
|
|
33
32
|
this.useParentKeys = useParentKeys;
|
|
33
|
+
this.icureStorage = icureStorage;
|
|
34
34
|
this.delegatedExchangeKeysCache = new lru_temporised_async_cache_1.LruTemporisedAsyncCache(delegatedKeysCacheSize, (keys) => keys.length > 0 ? delegatedKeysCacheLifetimeMsBase : delegatedKeysCacheLifetimeMsNoKeys);
|
|
35
35
|
this.delegatorExchangeKeysCache = new lru_temporised_async_cache_1.LruTemporisedAsyncCache(delegatorKeysCacheSize, () => -1);
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Get exchange keys from the current data owner to the provided delegate which are safe for encryption according to the locally verified keys.
|
|
39
|
-
* If currently there is no exchange key towards the provided delegate which is safe for encryption a new one will be automatically created.
|
|
40
|
-
* @param delegateId a delegate
|
|
41
|
-
* @return an object with the following fields:
|
|
42
|
-
* - keys: all available exchange keys which are safe for encryption.
|
|
43
|
-
* - updatedDelegator (optional): if a new key creation job was started when the function was invoked the updated delegator, else undefined.
|
|
44
|
-
*/
|
|
45
|
-
getOrCreateEncryptionExchangeKeysTo(delegateId) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const currentKeys = yield this.getSelfExchangeKeysTo(delegateId);
|
|
48
|
-
if (currentKeys.length > 0) {
|
|
49
|
-
return { keys: currentKeys };
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
while (true) {
|
|
53
|
-
let updatedDelegatorJob = undefined;
|
|
54
|
-
const keysWithNew = yield this.delegatorExchangeKeysCache.get(delegateId, (previous) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const fullJob = this.forceCreateVerifiedExchangeKeyTo(delegateId);
|
|
56
|
-
updatedDelegatorJob = fullJob.then(({ updatedDelegator }) => updatedDelegator);
|
|
57
|
-
let existingKeys = previous ? previous : yield this.forceGetSelfExchangeKeysTo(delegateId);
|
|
58
|
-
return fullJob.then(({ key }) => [...existingKeys, key]);
|
|
59
|
-
}), (v) => !v.length);
|
|
60
|
-
if (keysWithNew.length > 0) {
|
|
61
|
-
const updatedDelegator = updatedDelegatorJob ? yield updatedDelegatorJob : undefined;
|
|
62
|
-
return updatedDelegator ? { keys: keysWithNew, updatedDelegator } : { keys: keysWithNew };
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/*NOTE:
|
|
66
|
-
* in case of two concurrent calls to `getOrCreateEncryptionExchangeKeysTo` only one of the calls will receive the updated delegator. This could
|
|
67
|
-
* be a problem if one of the callers would want to update the delegator for other reasons as well, as the request would result in a database
|
|
68
|
-
* conflict. This situation however should be very rare and will be fully resolved in the near future when delegations will be moved out of the
|
|
69
|
-
* data owner objects and into a specific database.
|
|
70
|
-
*/
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
37
|
/**
|
|
75
38
|
* Get all keys currently available for a delegator-delegate pair. At least one of the two data owners must be part of the hierarchy for the current
|
|
76
39
|
* data owner.
|
|
@@ -89,7 +52,7 @@ class ExchangeKeysManager {
|
|
|
89
52
|
const hierarchyIds = yield this.dataOwnerApi.getCurrentDataOwnerHierarchyIds();
|
|
90
53
|
if (!hierarchyIds.some((x) => x === delegateId || x === delegatorId))
|
|
91
54
|
throw new Error(`Trying to retrieve exchange key ${key} but current data owner hierarchy is ${hierarchyIds}`);
|
|
92
|
-
return yield this.delegatedExchangeKeysCache.get(key, () => this.forceGetExchangeKeysFor(delegatorId, delegateId));
|
|
55
|
+
return yield this.delegatedExchangeKeysCache.get(key, () => this.forceGetExchangeKeysFor(delegatorId, delegateId).then((x) => ({ item: x })));
|
|
93
56
|
}
|
|
94
57
|
});
|
|
95
58
|
}
|
|
@@ -110,7 +73,7 @@ class ExchangeKeysManager {
|
|
|
110
73
|
}
|
|
111
74
|
getSelfExchangeKeysTo(delegateId) {
|
|
112
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
return yield this.delegatorExchangeKeysCache.get(delegateId, () => this.forceGetSelfExchangeKeysTo(delegateId));
|
|
76
|
+
return yield this.delegatorExchangeKeysCache.get(delegateId, () => this.forceGetSelfExchangeKeysTo(delegateId).then((x) => ({ item: x })));
|
|
114
77
|
});
|
|
115
78
|
}
|
|
116
79
|
forceGetSelfExchangeKeysTo(delegateId) {
|
|
@@ -121,27 +84,6 @@ class ExchangeKeysManager {
|
|
|
121
84
|
return successfulDecryptions;
|
|
122
85
|
});
|
|
123
86
|
}
|
|
124
|
-
forceCreateVerifiedExchangeKeyTo(delegateId) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const [mainKey, ...otherSelfKeys] = this.keyManager.getSelfVerifiedKeys();
|
|
127
|
-
let otherPublicKeys = Object.fromEntries(otherSelfKeys.map((x) => [x.fingerprint, x.pair.publicKey]));
|
|
128
|
-
if (delegateId !== (yield this.dataOwnerApi.getCurrentDataOwnerId())) {
|
|
129
|
-
const delegate = yield this.dataOwnerApi.getCryptoActorStub(delegateId);
|
|
130
|
-
const delegatePublicKeys = Array.from(this.dataOwnerApi.getHexPublicKeysOf(delegate.stub));
|
|
131
|
-
let verifiedDelegatePublicKeys;
|
|
132
|
-
if (this.useParentKeys && (yield this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()).includes(delegateId)) {
|
|
133
|
-
verifiedDelegatePublicKeys = yield this.keyManager.getVerifiedPublicKeysFor(delegate.stub);
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
verifiedDelegatePublicKeys = yield this.cryptoStrategies.verifyDelegatePublicKeys(delegate, delegatePublicKeys, this.primitives);
|
|
137
|
-
}
|
|
138
|
-
if (!verifiedDelegatePublicKeys || verifiedDelegatePublicKeys.length == 0)
|
|
139
|
-
throw new Error(`No verified public keys for delegate ${delegateId}: impossible to create new exchange key.`);
|
|
140
|
-
otherPublicKeys = Object.assign(Object.assign({}, otherPublicKeys), (yield (0, utils_1.loadPublicKeys)(this.primitives.RSA, verifiedDelegatePublicKeys)));
|
|
141
|
-
}
|
|
142
|
-
return yield this.baseExchangeKeysManager.createOrUpdateEncryptedExchangeKeyTo(delegateId, mainKey.pair, otherPublicKeys);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
87
|
}
|
|
146
88
|
exports.ExchangeKeysManager = ExchangeKeysManager;
|
|
147
89
|
//# sourceMappingURL=ExchangeKeysManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExchangeKeysManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExchangeKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,oFAA6E;AAC7E,mCAAwC;AAKxC;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAc9B,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,uBAAuB,CAAA;IACrC,CAAC;IAED,YACE,sBAA8B,EAC9B,sBAA8B,EAC9B,gCAAwC,EACxC,kCAA0C,EACzB,gBAAkC,EAClC,UAA4B,EAC5B,UAAsB,EACtB,uBAAgD,EAChD,YAA8B,EAC9B,aAAsB;QALtB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,eAAU,GAAV,UAAU,CAAkB;QAC5B,eAAU,GAAV,UAAU,CAAY;QACtB,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,kBAAa,GAAb,aAAa,CAAS;QAEvC,IAAI,CAAC,0BAA0B,GAAG,IAAI,oDAAuB,CAAC,sBAAsB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC7F,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,kCAAkC,CACxF,CAAA;QACD,IAAI,CAAC,0BAA0B,GAAG,IAAI,oDAAuB,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACjG,CAAC;IAED;;;;;;;OAOG;IACG,mCAAmC,CAAC,UAAkB;;YAC1D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;YAChE,IAAI,W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AAE;oBAC1G,0BAA0B,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;iBAC3F;qBAAM;oBACL,0BAA0B,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;iBACjI;gBACD,IAAI,CAAC,0BAA0B,IAAI,0BAA0B,CAAC,MAAM,IAAI,CAAC;oBACvE,MAAM,IAAI,KAAK,CAAC,wCAAwC,UAAU,0CAA0C,CAAC,CAAA;gBAC/G,eAAe,mCACV,eAAe,GACf,CAAC,MAAM,IAAA,sBAAc,EAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAC,CAC3E,CAAA;aACF;YACD,OAAO,MAAM,IAAI,CAAC,uBAAuB,CAAC,oCAAoC,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;QAC3H,CAAC;KAAA;CACF;AA7ID,kDA6IC","sourcesContent":["import { KeyManager } from './KeyManager'\nimport { BaseExchangeKeysManager } from './BaseExchangeKeysManager'\nimport { IccDataOwnerXApi } from '../icc-data-owner-x-api'\nimport { LruTemporisedAsyncCache } from '../utils/lru-temporised-async-cache'\nimport { loadPublicKeys } from './utils'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { CryptoStrategies } from './CryptoStrategies'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\n\n/**\n * @internal This class is meant only for internal use and may be changed without notice.\n * More powerful version of {@link BaseExchangeKeysManager} with a simplified interface. Has the following functionalities:\n * - Caches results\n * - Automatically creates new exchange keys if none is available\n * - Automatically choose the public keys to use during the creation of new exchange keys\n * - Automatically retrieves the private keys to use during decryption.\n */\nexport class ExchangeKeysManager {\n /*\n * Exchange keys cache where the current user is the delegator. The keys where the delegator is the current user should never change without\n * an action from the delegator (unless he does this action from another device), so it should be safe to store them without expiration. However,\n * the delegator may still have a lot of exchange keys (e.g. doctor -> all patients), so it is not safe to have a cache with unlimited size.\n */\n private delegatorExchangeKeysCache: LruTemporisedAsyncCache<string, CryptoKey[]>\n /*\n * Exchange keys cache where the current user is not the delegator. There may be many keys where the current user is the delegate,\n * and they may change over time without any action from the current data owner, since the delegator is someone else. For this reason the cache must\n * be limited in size and it should not use data that is too old, as it may be outdated.\n */\n private delegatedExchangeKeysCache: LruTemporisedAsyncCache<string, CryptoKey[]>\n\n get base(): BaseExchangeKeysManager {\n return this.baseExchangeKeysManager\n }\n\n constructor(\n delegatorKeysCacheSize: number,\n delegatedKeysCacheSize: number,\n delegatedKeysCacheLifetimeMsBase: number,\n delegatedKeysCacheLifetimeMsNoKeys: number,\n private readonly cryptoStrategies: CryptoStrategies,\n private readonly primitives: CryptoPrimitives,\n private readonly keyManager: KeyManager,\n private readonly baseExchangeKeysManager: BaseExchangeKeysManager,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly useParentKeys: boolean\n ) {\n this.delegatedExchangeKeysCache = new LruTemporisedAsyncCache(delegatedKeysCacheSize, (keys) =>\n keys.length > 0 ? delegatedKeysCacheLifetimeMsBase : delegatedKeysCacheLifetimeMsNoKeys\n )\n this.delegatorExchangeKeysCache = new LruTemporisedAsyncCache(delegatorKeysCacheSize, () => -1)\n }\n\n /**\n * Get exchange keys from the current data owner to the provided delegate which are safe for encryption according to the locally verified keys.\n * If currently there is no exchange key towards the provided delegate which is safe for encryption a new one will be automatically created.\n * @param delegateId a delegate\n * @return an object with the following fields:\n * - keys: all available exchange keys which are safe for encryption.\n * - updatedDelegator (optional): if a new key creation job was started when the function was invoked the updated delegator, else undefined.\n */\n async getOrCreateEncryptionExchangeKeysTo(delegateId: string): Promise<{ updatedDelegator?: CryptoActorStubWithType; keys: CryptoKey[] }> {\n const currentKeys = await this.getSelfExchangeKeysTo(delegateId)\n if (currentKeys.length > 0) {\n return { keys: currentKeys }\n } else {\n while (true) {\n let updatedDelegatorJob: Promise<CryptoActorStubWithType> | undefined = undefined\n const keysWithNew = await this.delegatorExchangeKeysCache.get(\n delegateId,\n async (previous) => {\n const fullJob = this.forceCreateVerifiedExchangeKeyTo(delegateId)\n updatedDelegatorJob = fullJob.then(({ updatedDelegator }) => updatedDelegator)\n let existingKeys = previous ? previous : await this.forceGetSelfExchangeKeysTo(delegateId)\n return fullJob.then(({ key }) => [...existingKeys, key])\n },\n (v) => !v.length\n )\n if (keysWithNew.length > 0) {\n const updatedDelegator = updatedDelegatorJob ? await updatedDelegatorJob : undefined\n return updatedDelegator ? { keys: keysWithNew, updatedDelegator } : { keys: keysWithNew }\n }\n }\n /*NOTE:\n * in case of two concurrent calls to `getOrCreateEncryptionExchangeKeysTo` only one of the calls will receive the updated delegator. This could\n * be a problem if one of the callers would want to update the delegator for other reasons as well, as the request would result in a database\n * conflict. This situation however should be very rare and will be fully resolved in the near future when delegations will be moved out of the\n * data owner objects and into a specific database.\n */\n }\n }\n\n /**\n * Get all keys currently available for a delegator-delegate pair. At least one of the two data owners must be part of the hierarchy for the current\n * data owner.\n * @param delegatorId id of a delegator\n * @param delegateId id of a delegate\n * @throws if neither the delegator nor the delegate is part of the hierarchy of the current data owner.\n * @return all available exchange keys from the delegator-delegate pair.\n */\n async getDecryptionExchangeKeysFor(delegatorId: string, delegateId: string): Promise<CryptoKey[]> {\n if (delegatorId === (await this.dataOwnerApi.getCurrentDataOwnerId())) {\n return await this.getSelfExchangeKeysTo(delegateId)\n } else {\n const key = `${delegatorId}->${delegateId}`\n const hierarchyIds = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()\n if (!hierarchyIds.some((x) => x === delegateId || x === delegatorId))\n throw new Error(`Trying to retrieve exchange key ${key} but current data owner hierarchy is ${hierarchyIds}`)\n return await this.delegatedExchangeKeysCache.get(key, () => this.forceGetExchangeKeysFor(delegatorId, delegateId))\n }\n }\n\n /**\n * Empties the exchange keys cache.\n * @param includeKeysFromCurrentDataOwner if true also clears the\n */\n clearCache(includeKeysFromCurrentDataOwner: boolean) {\n if (includeKeysFromCurrentDataOwner) this.delegatorExchangeKeysCache.clear()\n this.delegatedExchangeKeysCache.clear()\n }\n\n private async forceGetExchangeKeysFor(delegatorId: string, delegateId: string): Promise<CryptoKey[]> {\n const encKeys = await this.baseExchangeKeysManager.getEncryptedExchangeKeysFor(delegatorId, delegateId)\n return (await this.baseExchangeKeysManager.tryDecryptExchangeKeys(encKeys, this.keyManager.getDecryptionKeys())).successfulDecryptions\n }\n\n private async getSelfExchangeKeysTo(delegateId: string): Promise<CryptoKey[]> {\n return await this.delegatorExchangeKeysCache.get(delegateId, () => this.forceGetSelfExchangeKeysTo(delegateId))\n }\n\n private async forceGetSelfExchangeKeysTo(delegateId: string): Promise<CryptoKey[]> {\n // Retrieve then try to decrypt with own and parent key pairs\n const encKeys = await this.baseExchangeKeysManager.getEncryptedExchangeKeysFor(await this.dataOwnerApi.getCurrentDataOwnerId(), delegateId)\n const { successfulDecryptions } = await this.baseExchangeKeysManager.tryDecryptExchangeKeys(encKeys, this.keyManager.getDecryptionKeys())\n return successfulDecryptions\n }\n\n private async forceCreateVerifiedExchangeKeyTo(delegateId: string): Promise<{ updatedDelegator: CryptoActorStubWithType; key: CryptoKey }> {\n const [mainKey, ...otherSelfKeys] = this.keyManager.getSelfVerifiedKeys()\n let otherPublicKeys = Object.fromEntries(otherSelfKeys.map((x) => [x.fingerprint, x.pair.publicKey]))\n if (delegateId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) {\n const delegate = await this.dataOwnerApi.getCryptoActorStub(delegateId)\n const delegatePublicKeys = Array.from(this.dataOwnerApi.getHexPublicKeysOf(delegate.stub))\n let verifiedDelegatePublicKeys: string[]\n if (this.useParentKeys && (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()).includes(delegateId)) {\n verifiedDelegatePublicKeys = await this.keyManager.getVerifiedPublicKeysFor(delegate.stub)\n } else {\n verifiedDelegatePublicKeys = await this.cryptoStrategies.verifyDelegatePublicKeys(delegate, delegatePublicKeys, this.primitives)\n }\n if (!verifiedDelegatePublicKeys || verifiedDelegatePublicKeys.length == 0)\n throw new Error(`No verified public keys for delegate ${delegateId}: impossible to create new exchange key.`)\n otherPublicKeys = {\n ...otherPublicKeys,\n ...(await loadPublicKeys(this.primitives.RSA, verifiedDelegatePublicKeys)),\n }\n }\n return await this.baseExchangeKeysManager.createOrUpdateEncryptedExchangeKeyTo(delegateId, mainKey.pair, otherPublicKeys)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExchangeKeysManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExchangeKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,oFAA6E;AAQ7E;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAc9B,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,uBAAuB,CAAA;IACrC,CAAC;IAED,YACE,sBAA8B,EAC9B,sBAA8B,EAC9B,gCAAwC,EACxC,kCAA0C,EACzB,gBAAkC,EAClC,UAA4B,EAC5B,UAAqC,EACrC,uBAAgD,EAChD,YAA8B,EAC9B,aAAsB,EACtB,YAAgC;QANhC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,eAAU,GAAV,UAAU,CAAkB;QAC5B,eAAU,GAAV,UAAU,CAA2B;QACrC,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,kBAAa,GAAb,aAAa,CAAS;QACtB,iBAAY,GAAZ,YAAY,CAAoB;QAEjD,IAAI,CAAC,0BAA0B,GAAG,IAAI,oDAAuB,CAAC,sBAAsB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC7F,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,kCAAkC,CACxF,CAAA;QACD,IAAI,CAAC,0BAA0B,GAAG,IAAI,oDAAuB,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC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CAAC,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAA;QACxI,CAAC;KAAA;IAEa,qBAAqB,CAAC,UAAkB;;YACpD,OAAO,MAAM,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAC5I,CAAC;KAAA;IAEa,0BAA0B,CAAC,UAAkB;;YACzD,6DAA6D;YAC7D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,2BAA2B,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,EAAE,UAAU,CAAC,CAAA;YAC3I,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAA;YACzI,OAAO,qBAAqB,CAAA;QAC9B,CAAC;KAAA;CACF;AAjFD,kDAiFC","sourcesContent":["import { UserEncryptionKeysManager } from './UserEncryptionKeysManager'\nimport { BaseExchangeKeysManager } from './BaseExchangeKeysManager'\nimport { IccDataOwnerXApi } from '../icc-data-owner-x-api'\nimport { LruTemporisedAsyncCache } from '../utils/lru-temporised-async-cache'\nimport { getShaVersionForKey, loadPublicKeys } from './utils'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { CryptoStrategies } from './CryptoStrategies'\nimport { IcureStorageFacade } from '../storage/IcureStorageFacade'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\n\n/**\n * @internal This class is meant only for internal use and may be changed without notice.\n * More powerful version of {@link BaseExchangeKeysManager} with a simplified interface. Has the following functionalities:\n * - Caches results\n * - Automatically creates new exchange keys if none is available\n * - Automatically choose the public keys to use during the creation of new exchange keys\n * - Automatically retrieves the private keys to use during decryption.\n */\nexport class ExchangeKeysManager {\n /*\n * Exchange keys cache where the current user is the delegator. The keys where the delegator is the current user should never change without\n * an action from the delegator (unless he does this action from another device), so it should be safe to store them without expiration. However,\n * the delegator may still have a lot of exchange keys (e.g. doctor -> all patients), so it is not safe to have a cache with unlimited size.\n */\n private delegatorExchangeKeysCache: LruTemporisedAsyncCache<string, CryptoKey[]>\n /*\n * Exchange keys cache where the current user is not the delegator. There may be many keys where the current user is the delegate,\n * and they may change over time without any action from the current data owner, since the delegator is someone else. For this reason the cache must\n * be limited in size and it should not use data that is too old, as it may be outdated.\n */\n private delegatedExchangeKeysCache: LruTemporisedAsyncCache<string, CryptoKey[]>\n\n get base(): BaseExchangeKeysManager {\n return this.baseExchangeKeysManager\n }\n\n constructor(\n delegatorKeysCacheSize: number,\n delegatedKeysCacheSize: number,\n delegatedKeysCacheLifetimeMsBase: number,\n delegatedKeysCacheLifetimeMsNoKeys: number,\n private readonly cryptoStrategies: CryptoStrategies,\n private readonly primitives: CryptoPrimitives,\n private readonly keyManager: UserEncryptionKeysManager,\n private readonly baseExchangeKeysManager: BaseExchangeKeysManager,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly useParentKeys: boolean,\n private readonly icureStorage: IcureStorageFacade\n ) {\n this.delegatedExchangeKeysCache = new LruTemporisedAsyncCache(delegatedKeysCacheSize, (keys) =>\n keys.length > 0 ? delegatedKeysCacheLifetimeMsBase : delegatedKeysCacheLifetimeMsNoKeys\n )\n this.delegatorExchangeKeysCache = new LruTemporisedAsyncCache(delegatorKeysCacheSize, () => -1)\n }\n\n /**\n * Get all keys currently available for a delegator-delegate pair. At least one of the two data owners must be part of the hierarchy for the current\n * data owner.\n * @param delegatorId id of a delegator\n * @param delegateId id of a delegate\n * @throws if neither the delegator nor the delegate is part of the hierarchy of the current data owner.\n * @return all available exchange keys from the delegator-delegate pair.\n */\n async getDecryptionExchangeKeysFor(delegatorId: string, delegateId: string): Promise<CryptoKey[]> {\n if (delegatorId === (await this.dataOwnerApi.getCurrentDataOwnerId())) {\n return await this.getSelfExchangeKeysTo(delegateId)\n } else {\n const key = `${delegatorId}->${delegateId}`\n const hierarchyIds = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()\n if (!hierarchyIds.some((x) => x === delegateId || x === delegatorId))\n throw new Error(`Trying to retrieve exchange key ${key} but current data owner hierarchy is ${hierarchyIds}`)\n return await this.delegatedExchangeKeysCache.get(key, () => this.forceGetExchangeKeysFor(delegatorId, delegateId).then((x) => ({ item: x })))\n }\n }\n\n /**\n * Empties the exchange keys cache.\n * @param includeKeysFromCurrentDataOwner if true also clears the\n */\n clearCache(includeKeysFromCurrentDataOwner: boolean) {\n if (includeKeysFromCurrentDataOwner) this.delegatorExchangeKeysCache.clear()\n this.delegatedExchangeKeysCache.clear()\n }\n\n private async forceGetExchangeKeysFor(delegatorId: string, delegateId: string): Promise<CryptoKey[]> {\n const encKeys = await this.baseExchangeKeysManager.getEncryptedExchangeKeysFor(delegatorId, delegateId)\n return (await this.baseExchangeKeysManager.tryDecryptExchangeKeys(encKeys, this.keyManager.getDecryptionKeys())).successfulDecryptions\n }\n\n private async getSelfExchangeKeysTo(delegateId: string): Promise<CryptoKey[]> {\n return await this.delegatorExchangeKeysCache.get(delegateId, () => this.forceGetSelfExchangeKeysTo(delegateId).then((x) => ({ item: x })))\n }\n\n private async forceGetSelfExchangeKeysTo(delegateId: string): Promise<CryptoKey[]> {\n // Retrieve then try to decrypt with own and parent key pairs\n const encKeys = await this.baseExchangeKeysManager.getEncryptedExchangeKeysFor(await this.dataOwnerApi.getCurrentDataOwnerId(), delegateId)\n const { successfulDecryptions } = await this.baseExchangeKeysManager.tryDecryptExchangeKeys(encKeys, this.keyManager.getDecryptionKeys())\n return successfulDecryptions\n }\n}\n"]}
|