@icure/api 7.1.14 → 8.0.0-RC.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-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 +32 -25
- package/icc-api/api/IccDocumentApi.js +264 -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 +12 -1
- package/icc-api/api/IccMessageApi.js +257 -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/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/index.d.ts +1 -0
- package/icc-api/index.js +1 -0
- package/icc-api/index.js.map +1 -1
- package/icc-api/model/AccessLog.d.ts +4 -0
- package/icc-api/model/AccessLog.js +1 -0
- package/icc-api/model/AccessLog.js.map +1 -1
- package/icc-api/model/Article.d.ts +4 -0
- package/icc-api/model/Article.js +1 -0
- package/icc-api/model/Article.js.map +1 -1
- package/icc-api/model/CalendarItem.d.ts +4 -0
- package/icc-api/model/CalendarItem.js +1 -0
- package/icc-api/model/CalendarItem.js.map +1 -1
- package/icc-api/model/Classification.d.ts +4 -0
- package/icc-api/model/Classification.js +1 -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/Contact.d.ts +4 -0
- package/icc-api/model/Contact.js +1 -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 +4 -0
- package/icc-api/model/Document.js +1 -0
- package/icc-api/model/Document.js.map +1 -1
- package/icc-api/model/ExchangeData.d.ts +61 -0
- package/icc-api/model/ExchangeData.js +12 -0
- package/icc-api/model/ExchangeData.js.map +1 -0
- package/icc-api/model/ExchangeDataMap.d.ts +21 -0
- package/icc-api/model/ExchangeDataMap.js +10 -0
- package/icc-api/model/ExchangeDataMap.js.map +1 -0
- 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/Form.d.ts +4 -0
- package/icc-api/model/Form.js +1 -0
- package/icc-api/model/Form.js.map +1 -1
- package/icc-api/model/HealthElement.d.ts +4 -0
- package/icc-api/model/HealthElement.js +1 -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.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 +4 -0
- package/icc-api/model/Invoice.js +1 -0
- package/icc-api/model/Invoice.js.map +1 -1
- package/icc-api/model/MaintenanceTask.d.ts +4 -0
- package/icc-api/model/MaintenanceTask.js +1 -0
- package/icc-api/model/MaintenanceTask.js.map +1 -1
- package/icc-api/model/Message.d.ts +4 -0
- package/icc-api/model/Message.js +1 -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/Patient.d.ts +6 -2
- package/icc-api/model/Patient.js +1 -0
- 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 +4 -0
- package/icc-api/model/Receipt.js +1 -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 +4 -0
- package/icc-api/model/TimeTable.js +1 -0
- package/icc-api/model/TimeTable.js.map +1 -1
- package/icc-api/model/models.d.ts +20 -39
- package/icc-api/model/models.js +15 -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 +3 -2
- 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 +16 -0
- package/icc-x-api/crypto/AccessControlKeysHeadersProvider.js +41 -0
- package/icc-x-api/crypto/AccessControlKeysHeadersProvider.js.map +1 -0
- package/icc-x-api/crypto/AccessControlSecretUtils.d.ts +42 -0
- package/icc-x-api/crypto/AccessControlSecretUtils.js +86 -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/ExchangeDataManager.d.ts +95 -0
- package/icc-x-api/crypto/ExchangeDataManager.js +493 -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 +336 -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 +181 -0
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +562 -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 +39 -0
- package/icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.js +150 -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 +37 -0
- package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.js +294 -0
- package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.js.map +1 -0
- package/icc-x-api/crypto/SecurityMetadataDecryptor.d.ts +114 -0
- package/icc-x-api/crypto/SecurityMetadataDecryptor.js +98 -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/filters.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +46 -11
- package/icc-x-api/icc-accesslog-x-api.js +75 -42
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +50 -14
- package/icc-x-api/icc-calendar-item-x-api.js +99 -49
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +44 -9
- package/icc-x-api/icc-classification-x-api.js +56 -31
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +56 -32
- package/icc-x-api/icc-contact-x-api.js +95 -64
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +28 -334
- package/icc-x-api/icc-crypto-x-api.js +41 -765
- 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 +48 -11
- package/icc-x-api/icc-document-x-api.js +111 -64
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +45 -10
- package/icc-x-api/icc-form-x-api.js +65 -35
- 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 +55 -18
- package/icc-x-api/icc-helement-x-api.js +76 -41
- 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 +50 -15
- package/icc-x-api/icc-invoice-x-api.js +63 -33
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +53 -21
- package/icc-x-api/icc-maintenance-task-x-api.js +72 -35
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +53 -15
- package/icc-x-api/icc-message-x-api.js +65 -36
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +84 -29
- package/icc-x-api/icc-patient-x-api.js +313 -378
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +44 -12
- package/icc-x-api/icc-receipt-x-api.js +67 -35
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.d.ts +43 -12
- package/icc-x-api/icc-time-table-x-api.js +56 -26
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- 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 +4 -2
- package/icc-x-api/index.js +154 -135
- package/icc-x-api/index.js.map +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 +10 -10
- package/icc-x-api/utils/websocket.js +18 -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
|
@@ -13,7 +13,13 @@ 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 {
|
|
20
|
+
get headers() {
|
|
21
|
+
return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'Receipt'));
|
|
22
|
+
}
|
|
17
23
|
constructor(host, headers, crypto, dataOwnerApi, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
18
24
|
? window.fetch
|
|
19
25
|
: typeof self !== 'undefined'
|
|
@@ -22,6 +28,7 @@ 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.dataOwnerApi = dataOwnerApi;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Creates a new instance of receipt with initialised encryption metadata (not in the database).
|
|
@@ -31,28 +38,23 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
31
38
|
* @param options optional parameters:
|
|
32
39
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
33
40
|
* 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.
|
|
41
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
36
42
|
* @return a new instance of receipt.
|
|
37
43
|
*/
|
|
38
44
|
newInstance(user, r, options = {}) {
|
|
39
45
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
40
46
|
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)
|
|
47
|
+
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.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 : [] }));
|
|
48
|
+
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 : {}));
|
|
49
|
+
return new models.Receipt(yield this.crypto.xapi
|
|
50
|
+
.entityWithInitialisedEncryptedMetadata(receipt, 'Receipt', undefined, undefined, true, false, extraDelegations)
|
|
49
51
|
.then((x) => x.updatedEntity));
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
logReceipt(user, docId, refs, blobType, blob) {
|
|
53
55
|
return this.newInstance(user, { documentId: docId, references: refs })
|
|
54
56
|
.then((rcpt) => this.createReceipt(rcpt))
|
|
55
|
-
.then((rcpt) => (blob.byteLength != 0 ? this.
|
|
57
|
+
.then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachmentForBlobType(rcpt.id, rcpt.rev, blobType, blob) : Promise.resolve(rcpt)));
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.
|
|
@@ -62,9 +64,10 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
62
64
|
* @return the updated receipt.
|
|
63
65
|
*/
|
|
64
66
|
encryptAndSetReceiptAttachment(receipt, blobType, attachment) {
|
|
67
|
+
var _a;
|
|
65
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const encryptedData = yield this.crypto.
|
|
67
|
-
return yield this.
|
|
69
|
+
const { encryptedData, updatedEntity } = yield this.crypto.xapi.encryptDataOf(receipt, 'Receipt', attachment, (r) => this.modifyReceipt(r));
|
|
70
|
+
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
71
|
});
|
|
69
72
|
}
|
|
70
73
|
/**
|
|
@@ -76,11 +79,11 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
76
79
|
*/
|
|
77
80
|
setClearReceiptAttachment(receipt, blobType, attachment) {
|
|
78
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
return yield this.
|
|
82
|
+
return yield this.setReceiptAttachmentForBlobType(receipt.id, receipt.rev, blobType, attachment);
|
|
80
83
|
});
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
83
|
-
* Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt
|
|
86
|
+
* Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.
|
|
84
87
|
* @param receipt a receipt.
|
|
85
88
|
* @param attachmentId id of the attachment of this receipt to retrieve.
|
|
86
89
|
* @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption
|
|
@@ -89,10 +92,10 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
89
92
|
*/
|
|
90
93
|
getAndDecryptReceiptAttachment(receipt, attachmentId, validator = () => Promise.resolve(true)) {
|
|
91
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const
|
|
93
|
-
if (!wasDecrypted)
|
|
95
|
+
const retrieved = yield this.getAndTryDecryptReceiptAttachment(receipt, attachmentId, (x) => validator(x));
|
|
96
|
+
if (!retrieved.wasDecrypted)
|
|
94
97
|
throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`);
|
|
95
|
-
return data;
|
|
98
|
+
return retrieved.data;
|
|
96
99
|
});
|
|
97
100
|
}
|
|
98
101
|
/**
|
|
@@ -107,19 +110,28 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
107
110
|
*/
|
|
108
111
|
getAndTryDecryptReceiptAttachment(receipt, attachmentId, validator = () => Promise.resolve(true)) {
|
|
109
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
return yield this.crypto.
|
|
113
|
+
return yield this.crypto.xapi.tryDecryptDataOf({ entity: receipt, type: 'Receipt' }, yield this.getReceiptAttachment(receipt.id, attachmentId), (x) => validator(x));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @return if the logged data owner has write access to the content of the given receipt
|
|
118
|
+
*/
|
|
119
|
+
hasWriteAccess(receipt) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
return this.crypto.xapi.hasWriteAccess({ entity: receipt, type: 'Receipt' });
|
|
111
122
|
});
|
|
112
123
|
}
|
|
113
124
|
/**
|
|
114
125
|
* 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.
|
|
126
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
116
127
|
* @param delegateId the id of the data owner which will be granted access to the receipt.
|
|
117
128
|
* @param receipt the receipt to share.
|
|
118
129
|
* @param options optional parameters to customize the sharing behaviour:
|
|
119
130
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
120
131
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
121
132
|
* receipt does not have encrypted content.
|
|
122
|
-
*
|
|
133
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
134
|
+
* @return the updated entity
|
|
123
135
|
*/
|
|
124
136
|
shareWith(delegateId, receipt, options = {}) {
|
|
125
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -128,33 +140,53 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
128
140
|
}
|
|
129
141
|
/**
|
|
130
142
|
* 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.
|
|
143
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
132
144
|
* @param receipt the receipt to share.
|
|
133
|
-
* @param delegates
|
|
145
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
134
146
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
135
147
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
136
148
|
* receipt does not have encrypted content.
|
|
137
|
-
*
|
|
149
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
150
|
+
* @return the updated entity
|
|
138
151
|
*/
|
|
139
152
|
shareWithMany(receipt, delegates) {
|
|
140
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
|
|
142
|
-
if (!!extended) {
|
|
143
|
-
return yield this.modifyReceipt(extended);
|
|
144
|
-
}
|
|
145
|
-
else
|
|
146
|
-
return receipt;
|
|
154
|
+
return (yield this.tryShareWithMany(receipt, delegates)).updatedEntityOrThrow;
|
|
147
155
|
});
|
|
148
156
|
}
|
|
149
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
159
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
160
|
+
* @param receipt the receipt to share.
|
|
161
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
162
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
163
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
164
|
+
* receipt does not have encrypted content.
|
|
165
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
166
|
+
* @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
|
|
167
|
+
* the operation failed.
|
|
168
|
+
*/
|
|
169
|
+
tryShareWithMany(receipt, delegates) {
|
|
150
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
|
|
171
|
+
// All entities should have an encryption key.
|
|
172
|
+
const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(receipt, 'Receipt');
|
|
173
|
+
const updatedEntity = entityWithEncryptionKey ? yield this.modifyReceipt(entityWithEncryptionKey) : receipt;
|
|
174
|
+
return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata({ entity: updatedEntity, type: 'Receipt' }, true, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
175
|
+
delegateId,
|
|
176
|
+
{
|
|
177
|
+
requestedPermissions: options.requestedPermissions,
|
|
178
|
+
shareEncryptionKeys: options.shareEncryptionKey,
|
|
179
|
+
shareOwningEntityIds: ShareMetadataBehaviour_1.ShareMetadataBehaviour.NEVER,
|
|
180
|
+
shareSecretIds: undefined,
|
|
181
|
+
},
|
|
182
|
+
])), (x) => this.bulkShareReceipt(x));
|
|
152
183
|
});
|
|
153
184
|
}
|
|
185
|
+
getDataOwnersWithAccessTo(entity) {
|
|
186
|
+
return this.crypto.xapi.getDataOwnersWithAccessTo({ entity, type: 'Receipt' });
|
|
187
|
+
}
|
|
154
188
|
getEncryptionKeysOf(entity) {
|
|
155
|
-
return
|
|
156
|
-
return yield this.crypto.entities.encryptionKeysOf(entity);
|
|
157
|
-
});
|
|
189
|
+
return this.crypto.xapi.encryptionKeysOf({ entity, type: 'Receipt' }, undefined);
|
|
158
190
|
}
|
|
159
191
|
}
|
|
160
192
|
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,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C,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/D,CAAC;KAAA;IAED;;;;;;;;;OASG;IACG,aAAa,CACjB,OAAuB,EACvB,SAIC;;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,uCAAuC,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;YAC7G,IAAI,CAAC,CAAC,QAAQ,EAAE;gBACd,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;aAC1C;;gBAAM,OAAO,OAAO,CAAA;QACvB,CAAC;KAAA;IAEK,yBAAyB,CAAC,MAAsB;;YAIpD,OAAO,MAAM,IAAI,CAAC,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":";;;;;;;;;;;;AAAA,wCAA0C;AAG1C,kDAAiD;AAEjD,0EAAgG;AAChG,4EAAwE;AAIxE,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,MAAa,cAAe,SAAQ,uBAAa;IAC/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;IAClH,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,YAA8B,EAC/C,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;QATtC,WAAM,GAAN,MAAM,CAAe;Q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AAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;gBACvD,UAAU;gBACV;oBACE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;oBAClD,mBAAmB,EAAE,OAAO,CAAC,kBAAkB;oBAC/C,oBAAoB,EAAE,+CAAsB,CAAC,KAAK;oBAClD,cAAc,EAAE,SAAS;iBAC1B;aACF,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAChC,CAAA;QACH,CAAC;KAAA;IAED,yBAAyB,CACvB,MAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IAChF,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;CACF;AA7OD,wCA6OC","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'\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 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.dataOwnerApi.getDataOwnerIdOf(user),\n author: r?.author ?? user.id,\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.xapi.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"]}
|
|
@@ -6,11 +6,18 @@ 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;
|
|
11
19
|
i18n: any;
|
|
12
|
-
|
|
13
|
-
dataOwnerApi: IccDataOwnerXApi;
|
|
20
|
+
get headers(): Promise<Array<XHR.Header>>;
|
|
14
21
|
constructor(host: string, headers: {
|
|
15
22
|
[key: string]: string;
|
|
16
23
|
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
@@ -22,15 +29,19 @@ export declare class IccTimeTableXApi extends IccTimeTableApi implements Encrypt
|
|
|
22
29
|
* @param options optional parameters:
|
|
23
30
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
24
31
|
* 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.
|
|
32
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
27
33
|
* @return a new instance of timetable.
|
|
28
34
|
*/
|
|
29
35
|
newInstance(user: User, tt: TimeTable, options?: {
|
|
30
36
|
additionalDelegates?: {
|
|
31
|
-
[dataOwnerId: string]:
|
|
37
|
+
[dataOwnerId: string]: AccessLevelEnum;
|
|
32
38
|
};
|
|
39
|
+
preferredSfk?: string;
|
|
33
40
|
}): Promise<TimeTable>;
|
|
41
|
+
/**
|
|
42
|
+
* @return if the logged data owner has write access to the content of the given time table
|
|
43
|
+
*/
|
|
44
|
+
hasWriteAccess(timeTable: models.TimeTable): Promise<boolean>;
|
|
34
45
|
/**
|
|
35
46
|
* 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
47
|
* the encrypted content, with read-only or read-write permissions.
|
|
@@ -40,31 +51,51 @@ export declare class IccTimeTableXApi extends IccTimeTableApi implements Encrypt
|
|
|
40
51
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
41
52
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
42
53
|
* time table does not have encrypted content.
|
|
43
|
-
*
|
|
44
|
-
* the
|
|
54
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
55
|
+
* @return the updated entity
|
|
45
56
|
*/
|
|
46
57
|
shareWith(delegateId: string, timeTable: models.TimeTable, options?: {
|
|
58
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
47
59
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
48
60
|
}): Promise<models.TimeTable>;
|
|
49
61
|
/**
|
|
50
62
|
* 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
63
|
* the encrypted content, with read-only or read-write permissions.
|
|
52
64
|
* @param timeTable the time table to share.
|
|
53
|
-
* @param delegates
|
|
65
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
54
66
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
55
67
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
56
68
|
* time table does not have encrypted content.
|
|
57
|
-
*
|
|
58
|
-
* the
|
|
69
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
70
|
+
* @return the updated entity
|
|
59
71
|
*/
|
|
60
72
|
shareWithMany(timeTable: models.TimeTable, delegates: {
|
|
61
73
|
[delegateId: string]: {
|
|
74
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
62
75
|
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
63
76
|
};
|
|
64
77
|
}): Promise<models.TimeTable>;
|
|
78
|
+
/**
|
|
79
|
+
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
80
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
81
|
+
* @param timeTable the time table to share.
|
|
82
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
83
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
84
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
85
|
+
* time table does not have encrypted content.
|
|
86
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
87
|
+
* @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
|
|
88
|
+
* the operation failed.
|
|
89
|
+
*/
|
|
90
|
+
tryShareWithMany(timeTable: models.TimeTable, delegates: {
|
|
91
|
+
[delegateId: string]: {
|
|
92
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
93
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
94
|
+
};
|
|
95
|
+
}): Promise<ShareResult<models.TimeTable>>;
|
|
65
96
|
getDataOwnersWithAccessTo(entity: models.TimeTable): Promise<{
|
|
66
97
|
permissionsByDataOwnerId: {
|
|
67
|
-
[p: string]:
|
|
98
|
+
[p: string]: AccessLevelEnum;
|
|
68
99
|
};
|
|
69
100
|
hasUnknownAnonymousDataOwners: boolean;
|
|
70
101
|
}>;
|
|
@@ -14,13 +14,21 @@ const i18n = require("./rsrc/contact.i18n");
|
|
|
14
14
|
const icc_api_1 = require("../icc-api");
|
|
15
15
|
const models = require("../icc-api/model/models");
|
|
16
16
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
17
|
+
const ShareMetadataBehaviour_1 = require("./crypto/ShareMetadataBehaviour");
|
|
18
|
+
const SecureDelegation_1 = require("../icc-api/model/SecureDelegation");
|
|
19
|
+
var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
|
|
17
20
|
class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
21
|
+
get headers() {
|
|
22
|
+
return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'TimeTable'));
|
|
23
|
+
}
|
|
18
24
|
constructor(host, headers, crypto, dataOwnerApi, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
19
25
|
? window.fetch
|
|
20
26
|
: typeof self !== 'undefined'
|
|
21
27
|
? self.fetch
|
|
22
28
|
: fetch) {
|
|
23
29
|
super(host, headers, authenticationProvider, fetchImpl);
|
|
30
|
+
this.crypto = crypto;
|
|
31
|
+
this.dataOwnerApi = dataOwnerApi;
|
|
24
32
|
this.i18n = i18n;
|
|
25
33
|
this.crypto = crypto;
|
|
26
34
|
this.dataOwnerApi = dataOwnerApi;
|
|
@@ -33,24 +41,27 @@ class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
|
33
41
|
* @param options optional parameters:
|
|
34
42
|
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
35
43
|
* 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
|
|
36
|
-
* auto-delegations, in such case the access level specified here will be used.
|
|
37
|
-
* access will be possible.
|
|
44
|
+
* auto-delegations, in such case the access level specified here will be used.
|
|
38
45
|
* @return a new instance of timetable.
|
|
39
46
|
*/
|
|
40
47
|
newInstance(user, tt, options = {}) {
|
|
41
48
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
42
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const timeTable = Object.assign(Object.assign({}, (tt !== null && tt !== void 0 ? tt : {})), { _type: '
|
|
44
|
-
const extraDelegations = [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...((_m = (_l = user.autoDelegations) === null || _l === void 0 ? void 0 : _l.administrativeData) !== null && _m !== void 0 ? _m : []),
|
|
48
|
-
];
|
|
49
|
-
return new models.TimeTable(yield this.crypto.entities
|
|
50
|
-
.entityWithInitialisedEncryptedMetadata(timeTable, undefined, undefined, true, extraDelegations)
|
|
50
|
+
const timeTable = Object.assign(Object.assign({}, (tt !== null && tt !== void 0 ? tt : {})), { _type: 'TimeTable', id: (_a = tt === null || tt === void 0 ? void 0 : tt.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = tt === null || tt === void 0 ? void 0 : tt.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = tt === null || tt === void 0 ? void 0 : tt.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = tt === null || tt === void 0 ? void 0 : tt.responsible) !== null && _d !== void 0 ? _d : this.dataOwnerApi.getDataOwnerIdOf(user), author: (_e = tt === null || tt === void 0 ? void 0 : tt.author) !== null && _e !== void 0 ? _e : user.id, codes: (_f = tt === null || tt === void 0 ? void 0 : tt.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = tt === null || tt === void 0 ? void 0 : tt.tags) !== null && _g !== void 0 ? _g : [] });
|
|
51
|
+
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.administrativeData) !== 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 : {}));
|
|
52
|
+
return new models.TimeTable(yield this.crypto.xapi
|
|
53
|
+
.entityWithInitialisedEncryptedMetadata(timeTable, 'TimeTable', undefined, undefined, true, false, extraDelegations)
|
|
51
54
|
.then((x) => x.updatedEntity));
|
|
52
55
|
});
|
|
53
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* @return if the logged data owner has write access to the content of the given time table
|
|
59
|
+
*/
|
|
60
|
+
hasWriteAccess(timeTable) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return this.crypto.xapi.hasWriteAccess({ entity: timeTable, type: 'TimeTable' });
|
|
63
|
+
});
|
|
64
|
+
}
|
|
54
65
|
/**
|
|
55
66
|
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
56
67
|
* the encrypted content, with read-only or read-write permissions.
|
|
@@ -60,8 +71,8 @@ class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
|
60
71
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
61
72
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
62
73
|
* time table does not have encrypted content.
|
|
63
|
-
*
|
|
64
|
-
* the
|
|
74
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
75
|
+
* @return the updated entity
|
|
65
76
|
*/
|
|
66
77
|
shareWith(delegateId, timeTable, options = {}) {
|
|
67
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -72,32 +83,51 @@ class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
|
72
83
|
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
73
84
|
* the encrypted content, with read-only or read-write permissions.
|
|
74
85
|
* @param timeTable the time table to share.
|
|
75
|
-
* @param delegates
|
|
86
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
76
87
|
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
77
88
|
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
78
89
|
* time table does not have encrypted content.
|
|
79
|
-
*
|
|
80
|
-
* the
|
|
90
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
91
|
+
* @return the updated entity
|
|
81
92
|
*/
|
|
82
93
|
shareWithMany(timeTable, delegates) {
|
|
83
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
|
|
85
|
-
if (!!extended) {
|
|
86
|
-
return yield this.modifyTimeTable(extended);
|
|
87
|
-
}
|
|
88
|
-
else
|
|
89
|
-
return timeTable;
|
|
95
|
+
return (yield this.tryShareWithMany(timeTable, delegates)).updatedEntityOrThrow;
|
|
90
96
|
});
|
|
91
97
|
}
|
|
92
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
100
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
101
|
+
* @param timeTable the time table to share.
|
|
102
|
+
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
103
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
104
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
105
|
+
* time table does not have encrypted content.
|
|
106
|
+
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
107
|
+
* @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
|
|
108
|
+
* the operation failed.
|
|
109
|
+
*/
|
|
110
|
+
tryShareWithMany(timeTable, delegates) {
|
|
93
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
|
|
112
|
+
// All entities should have an encryption key.
|
|
113
|
+
const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(timeTable, 'TimeTable');
|
|
114
|
+
const updatedEntity = entityWithEncryptionKey ? yield this.modifyTimeTable(entityWithEncryptionKey) : timeTable;
|
|
115
|
+
return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata({ entity: updatedEntity, type: 'TimeTable' }, true, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
116
|
+
delegateId,
|
|
117
|
+
{
|
|
118
|
+
requestedPermissions: options.requestedPermissions,
|
|
119
|
+
shareEncryptionKeys: options.shareEncryptionKey,
|
|
120
|
+
shareOwningEntityIds: ShareMetadataBehaviour_1.ShareMetadataBehaviour.NEVER,
|
|
121
|
+
shareSecretIds: undefined,
|
|
122
|
+
},
|
|
123
|
+
])), (x) => this.bulkShareTimeTable(x));
|
|
95
124
|
});
|
|
96
125
|
}
|
|
126
|
+
getDataOwnersWithAccessTo(entity) {
|
|
127
|
+
return this.crypto.xapi.getDataOwnersWithAccessTo({ entity, type: 'TimeTable' });
|
|
128
|
+
}
|
|
97
129
|
getEncryptionKeysOf(entity) {
|
|
98
|
-
return
|
|
99
|
-
return yield this.crypto.entities.encryptionKeysOf(entity);
|
|
100
|
-
});
|
|
130
|
+
return this.crypto.xapi.encryptionKeysOf({ entity, type: 'TimeTable' }, undefined);
|
|
101
131
|
}
|
|
102
132
|
}
|
|
103
133
|
exports.IccTimeTableXApi = IccTimeTableXApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-time-table-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA2C;AAG3C,wCAA4C;AAK5C,kDAAiD;AACjD,0EAAgG;AAIhG,MAAa,gBAAiB,SAAQ,yBAAe;IAKnD,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA8B,EAC9B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AAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAA;QACrE,CAAC;KAAA;IAEK,mBAAmB,CAAC,MAAwB;;YAChD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC5D,CAAC;KAAA;CACF;AAzHD,4CAyHC","sourcesContent":["import * as i18n from './rsrc/contact.i18n'\n\nimport * as _ from 'lodash'\nimport { IccTimeTableApi } from '../icc-api'\nimport { User } from '../icc-api/model/User'\nimport { TimeTable } from '../icc-api/model/TimeTable'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport * as models from '../icc-api/model/models'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\n\nexport class IccTimeTableXApi extends IccTimeTableApi implements EncryptedEntityXApi<TimeTable> {\n i18n: any = i18n\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of timetable with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param tt initialised data for the timetable. 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 timetable.\n */\n async newInstance(\n user: User,\n tt: TimeTable,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n } = {}\n ) {\n const timeTable = {\n ...(tt ?? {}),\n _type: 'org.taktik.icure.entities.TimeTable',\n id: tt?.id ?? this.crypto.primitives.randomUuid(),\n created: tt?.created ?? new Date().getTime(),\n modified: tt?.modified ?? new Date().getTime(),\n responsible: tt?.responsible ?? this.dataOwnerApi.getDataOwnerIdOf(user),\n author: tt?.author ?? user.id,\n codes: tt?.codes ?? [],\n tags: tt?.tags ?? [],\n }\n\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.administrativeData ?? []),\n ]\n return new models.TimeTable(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(timeTable, undefined, undefined, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table 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 time table.\n * @param timeTable the time table 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 * time table does not have encrypted content.\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 shareWith(\n delegateId: string,\n timeTable: models.TimeTable,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.TimeTable> {\n return this.shareWithMany(timeTable, { [delegateId]: options })\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param timeTable the time table to share.\n * @param delegates sharing options for each delegate.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * time table does not have encrypted content.\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 shareWithMany(\n timeTable: models.TimeTable,\n delegates: {\n [delegateId: string]: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.TimeTable> {\n const extended = await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(timeTable, true, delegates)\n if (!!extended) {\n return await this.modifyTimeTable(extended)\n } else return timeTable\n }\n\n async getDataOwnersWithAccessTo(\n entity: models.TimeTable\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: 'WRITE' }; hasUnknownAnonymousDataOwners: boolean }> {\n return await this.crypto.entities.getDataOwnersWithAccessTo(entity)\n }\n\n async getEncryptionKeysOf(entity: models.TimeTable): Promise<string[]> {\n return await this.crypto.entities.encryptionKeysOf(entity)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-time-table-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA2C;AAG3C,wCAA4C;AAK5C,kDAAiD;AACjD,0EAAgG;AAChG,4EAAwE;AAIxE,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,MAAa,gBAAiB,SAAQ,yBAAe;IAGnD,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CA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AI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAA;IAClF,CAAC;IAED,mBAAmB,CAAC,MAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,SAAS,CAAC,CAAA;IACpF,CAAC;CACF;AA7KD,4CA6KC","sourcesContent":["import * as i18n from './rsrc/contact.i18n'\n\nimport * as _ from 'lodash'\nimport { IccTimeTableApi } from '../icc-api'\nimport { User } from '../icc-api/model/User'\nimport { TimeTable } from '../icc-api/model/TimeTable'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport * as models from '../icc-api/model/models'\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'\n\nexport class IccTimeTableXApi extends IccTimeTableApi implements EncryptedEntityXApi<models.TimeTable> {\n i18n: any = i18n\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'TimeTable'))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of timetable with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param tt initialised data for the timetable. 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 timetable.\n */\n async newInstance(\n user: User,\n tt: TimeTable,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n preferredSfk?: string\n } = {}\n ) {\n const timeTable: TimeTable = {\n ...(tt ?? {}),\n _type: 'TimeTable',\n id: tt?.id ?? this.crypto.primitives.randomUuid(),\n created: tt?.created ?? new Date().getTime(),\n modified: tt?.modified ?? new Date().getTime(),\n responsible: tt?.responsible ?? this.dataOwnerApi.getDataOwnerIdOf(user),\n author: tt?.author ?? user.id,\n codes: tt?.codes ?? [],\n tags: tt?.tags ?? [],\n }\n\n const extraDelegations = {\n ...Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.administrativeData ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n ),\n ...(options?.additionalDelegates ?? {}),\n }\n\n return new models.TimeTable(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(timeTable, 'TimeTable', undefined, undefined, true, false, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given time table\n */\n async hasWriteAccess(timeTable: models.TimeTable): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: timeTable, type: 'TimeTable' })\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table 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 time table.\n * @param timeTable the time table 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 * time table 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 timeTable: models.TimeTable,\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.TimeTable> {\n return this.shareWithMany(timeTable, { [delegateId]: options })\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param timeTable the time table 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 * time table 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 timeTable: models.TimeTable,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.TimeTable> {\n return (await this.tryShareWithMany(timeTable, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param timeTable the time table 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 * time table 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 timeTable: models.TimeTable,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.TimeTable>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(timeTable, 'TimeTable')\n const updatedEntity = entityWithEncryptionKey ? await this.modifyTimeTable(entityWithEncryptionKey) : timeTable\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n { entity: updatedEntity, type: 'TimeTable' },\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.bulkShareTimeTable(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.TimeTable\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.xapi.getDataOwnersWithAccessTo({ entity, type: 'TimeTable' })\n }\n\n getEncryptionKeysOf(entity: models.TimeTable): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: 'TimeTable' }, undefined)\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IccUserApi } from '../icc-api';
|
|
1
|
+
import { IccUserApi } from '../icc-api/api/IccUserApi';
|
|
2
2
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
3
3
|
import { AbstractFilter } from './filters/filters';
|
|
4
4
|
import { User } from '../icc-api/model/User';
|
|
@@ -6,8 +6,8 @@ import { Connection } from '../icc-api/model/Connection';
|
|
|
6
6
|
import { SubscriptionOptions } from './utils';
|
|
7
7
|
import { IccAuthApi } from '../icc-api';
|
|
8
8
|
export declare class IccUserXApi extends IccUserApi {
|
|
9
|
+
private readonly authApi;
|
|
9
10
|
fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
10
|
-
authApi: IccAuthApi;
|
|
11
11
|
private cachedCurrentUser;
|
|
12
12
|
constructor(host: string, headers: {
|
|
13
13
|
[key: string]: string;
|