@icure/api 8.10.2 → 8.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/icc-api/api/IccPatientApi.d.ts +1 -1
  2. package/icc-api/api/IccPatientApi.js +4 -2
  3. package/icc-api/api/IccPatientApi.js.map +1 -1
  4. package/icc-api/api/IccUserApi.d.ts +1 -1
  5. package/icc-api/api/IccUserApi.js +2 -2
  6. package/icc-api/api/IccUserApi.js.map +1 -1
  7. package/icc-api/model/HealthElement.d.ts +5 -0
  8. package/icc-api/model/HealthElement.js.map +1 -1
  9. package/icc-api/model/HealthElementQualifiedLink.d.ts +31 -0
  10. package/icc-api/model/HealthElementQualifiedLink.js +26 -0
  11. package/icc-api/model/HealthElementQualifiedLink.js.map +1 -0
  12. package/icc-api/model/models.d.ts +1 -0
  13. package/icc-api/model/models.js +1 -0
  14. package/icc-api/model/models.js.map +1 -1
  15. package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +11 -0
  16. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +75 -13
  17. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
  18. package/icc-x-api/crypto/SecurityMetadataDecryptor.d.ts +14 -0
  19. package/icc-x-api/crypto/SecurityMetadataDecryptor.js +28 -0
  20. package/icc-x-api/crypto/SecurityMetadataDecryptor.js.map +1 -1
  21. package/icc-x-api/filters/HealthElementByAssociationIdFilter.d.ts +23 -0
  22. package/icc-x-api/filters/HealthElementByAssociationIdFilter.js +30 -0
  23. package/icc-x-api/filters/HealthElementByAssociationIdFilter.js.map +1 -0
  24. package/icc-x-api/filters/HealthElementByQualifiedLinkFilter.d.ts +24 -0
  25. package/icc-x-api/filters/HealthElementByQualifiedLinkFilter.js +30 -0
  26. package/icc-x-api/filters/HealthElementByQualifiedLinkFilter.js.map +1 -0
  27. package/icc-x-api/filters/filters.d.ts +2 -0
  28. package/icc-x-api/filters/filters.js +2 -0
  29. package/icc-x-api/filters/filters.js.map +1 -1
  30. package/icc-x-api/icc-patient-x-api.d.ts +4 -1
  31. package/icc-x-api/icc-patient-x-api.js +5 -2
  32. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  33. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SecurityMetadataDecryptor.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/SecurityMetadataDecryptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAA4G;AAQ5G,uDAAmG;AAEnG,IAAO,eAAe,GAAG,yBAAgB,CAAC,eAAe,CAAA;AAUzD,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,uEAAY,CAAA;IACZ,iFAAa,CAAA;IACb,mFAAc,CAAA;AAChB,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B;AAED,MAAa,yBAAyB;IACpC,YACmB,mBAAwC,EACxC,UAA4B,EAC5B,YAAiC,EACjC,eAAuC,EACvC,2BAAwD,EACxD,YAA8B;QAL9B,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,eAAU,GAAV,UAAU,CAAkB;QAC5B,iBAAY,GAAZ,YAAY,CAAqB;QACjC,oBAAe,GAAf,eAAe,CAAwB;QACvC,gCAA2B,GAA3B,2BAA2B,CAA6B;QACxD,iBAAY,GAAZ,YAAY,CAAkB;IAC9C,CAAC;IAEE,wBAAwB,CAC5B,QAAmD,EACnD,yBAAmC,EACnC,YAAkC;;YAElC,uEAAuE;YACvE,MAAM,GAAG,GAAqC,EAAE,CAAA;YAChD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;gBACzB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,4BAA4B,CAAC,CAAC,EAAE,yBAAyB,EAAE,YAAY,CAAC,CAAA;gBACxG,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,C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ex2ua, ua2string } from '../utils'\nimport { ExchangeKeysManager } from './ExchangeKeysManager'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { Delegation } from '../../icc-api/model/Delegation'\nimport { ExchangeDataManager } from './ExchangeDataManager'\nimport { ExchangeDataMapManager } from './ExchangeDataMapManager'\nimport { SecureDelegationsEncryption } from './SecureDelegationsEncryption'\nimport { IccDataOwnerXApi } from '../icc-data-owner-x-api'\nimport { EncryptedEntity, EncryptedEntityStub, SecureDelegation } from '../../icc-api/model/models'\nimport { ExchangeData } from '../../icc-api/model/internal/ExchangeData'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\n\nexport type DelegationMembersDetails = {\n delegator: string | undefined\n delegate: string | undefined\n fullyExplicit: boolean\n accessControlSecret: string | undefined\n accessLevel: AccessLevelEnum\n}\n\nexport enum SecurityMetadataType {\n SecretId = 1, // Start from 1, avoids issues with SecretId being falsy\n EncryptionKey,\n OwningEntityId,\n}\n\nexport class SecurityMetadataDecryptor {\n constructor(\n private readonly exchangeKeysManager: ExchangeKeysManager,\n private readonly primitives: CryptoPrimitives,\n private readonly exchangeData: ExchangeDataManager,\n private readonly exchangeDataMap: ExchangeDataMapManager,\n private readonly secureDelegationsEncryption: SecureDelegationsEncryption,\n private readonly dataOwnerApi: IccDataOwnerXApi\n ) {}\n\n async decryptLegacyDelegations(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n // For legacy delegations there is no advantage in doing stuff in bulk.\n const res: { [entityId: string]: string[] } = {}\n for (const e of entities) {\n const allDecrypted = await this.extractFromLegacyDelegations(e, dataOwnersHierarchySubset, metadataType)\n const deduplicatedDecrypted = new Set(allDecrypted.map((x) => x.decrypted))\n res[e.id!] = [...deduplicatedDecrypted]\n }\n return res\n }\n\n private async extractFromLegacyDelegations(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ decrypted: string; dataOwnersWithAccess: string[] }[]> {\n if (!dataOwnersHierarchySubset.length) throw new Error(\"`dataOwnersHierarchySubset` can't be empty\")\n let delegations: { [delegateId: string]: Delegation[] }\n let validateDecrypted: (result: string) => Promise<boolean> = (x) => Promise.resolve(!!x)\n let mapDecrypted: (result: string) => string = (x) => x\n switch (metadataType) {\n case SecurityMetadataType.SecretId:\n delegations = entity.delegations ?? {}\n break\n case SecurityMetadataType.EncryptionKey:\n delegations = entity.encryptionKeys ?? {}\n validateDecrypted = async (key) => {\n if (!/^[0-9A-Fa-f\\-]+$/g.test(key)) return false\n try {\n await this.primitives.AES.importKey('raw', hex2ua(key.replace(/-/g, '')))\n return true\n } catch (e) {\n console.warn(`Could not import key ${key} as an encryption key.`, e)\n return false\n }\n }\n mapDecrypted = (key) => key.replace(/-/g, '')\n break\n case SecurityMetadataType.OwningEntityId:\n delegations = entity.cryptedForeignKeys ?? {}\n break\n default:\n throw new Error(`Internal error: invalid SecurityMetadataType ${metadataType}`)\n }\n const delegationsWithOwner = Object.entries(delegations).flatMap(([delegateId, delegations]) =>\n dataOwnersHierarchySubset.some((dataOwnerId) => dataOwnerId === delegateId)\n ? this.populateLegacyDelegationDelegate(delegateId, delegations)\n : this.populateLegacyDelegationDelegate(\n delegateId,\n delegations.filter((d) => dataOwnersHierarchySubset.some((dataOwnerId) => d.owner === dataOwnerId))\n )\n )\n const res: { decrypted: string; dataOwnersWithAccess: string[] }[] = []\n for (const delegation of delegationsWithOwner) {\n const decrypted = await this.tryDecryptLegacyDelegation(delegation, (k) => validateDecrypted(k))\n if (decrypted)\n res.push({\n decrypted: mapDecrypted(decrypted),\n dataOwnersWithAccess: delegation.owner ? [delegation.owner, delegation.delegatedTo!] : [delegation.delegatedTo!],\n })\n }\n return res\n }\n\n private populateLegacyDelegationDelegate(delegateId: string, delegations: Delegation[]): Delegation[] {\n return delegations.map((d) => (d.delegatedTo === delegateId ? d : { ...d, delegatedTo: delegateId }))\n }\n\n private async tryDecryptLegacyDelegation(\n delegation: Delegation,\n validateDecrypted: (result: string) => Promise<boolean>\n ): Promise<string | undefined> {\n const exchangeKeys = await this.exchangeKeysManager.getDecryptionExchangeKeysFor(delegation.owner!, delegation.delegatedTo!)\n for (const key of exchangeKeys) {\n try {\n // Format of encrypted key for any delegation should be entityId:key, but with the merging of entities the entityId might not match the\n // current id. As a checksum we are only verifying that the decrypted bytes can be represented as a string with exactly one ':'.\n // Additionally, we also have a validator that is specific for each type of delegation content (encryption key, secret id, ...)\n const decrypted = ua2string(await this.primitives.AES.decrypt(key, hex2ua(delegation.key!)))\n const decryptedSplit = decrypted.split(':')\n if (decryptedSplit.length === 2) {\n if (await validateDecrypted(decryptedSplit[1])) return decryptedSplit[1]\n } else {\n console.warn(\"Error in the decrypted delegation: content should contain exactly 1 ':', the delegation is ignored.\")\n }\n } catch (e) {\n // Do nothing: the delegation uses another exchange key owner->delegator\n }\n }\n }\n\n async decryptSecureDelegationsUsingCache(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n const toSearchById: Set<string> = new Set([])\n const toSearchByDelegationKey: Set<string> = new Set([])\n for (const e of entities) {\n for (const [delegationKey, delegation] of Object.entries(e.securityMetadata?.secureDelegations ?? {})) {\n if (\n !delegation.delegator ||\n !delegation.delegate ||\n dataOwnersHierarchySubset.some((it) => it == delegation.delegator || it == delegation.delegate)\n ) {\n if (delegation.exchangeDataId) {\n toSearchById.add(delegation.exchangeDataId)\n } else {\n toSearchByDelegationKey.add(delegationKey)\n }\n }\n }\n }\n const cachedByExchangeDataId = await this.exchangeData.getDecryptionDataKeyByIds([...toSearchById], false)\n const cachedByDelegationKey = await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash([...toSearchByDelegationKey])\n const res: { [entityId: string]: string[] } = {}\n for (const entity of entities) {\n const currEntityRes: Set<string> = new Set([])\n for (const [delegationKey, delegation] of Object.entries(entity.securityMetadata?.secureDelegations ?? {})) {\n const cached = delegation.exchangeDataId ? cachedByExchangeDataId[delegation.exchangeDataId] : cachedByDelegationKey[delegationKey]\n if (\n cached?.exchangeKey &&\n dataOwnersHierarchySubset.some((it) => it == cached?.exchangeData?.delegator || it == cached?.exchangeData?.delegate)\n ) {\n ;(await this.decryptSecureDelegationMetadata(delegation, metadataType, cached.exchangeKey)).forEach((decrypted) =>\n currEntityRes.add(decrypted)\n )\n }\n }\n res[entity.id!] = [...currEntityRes]\n }\n return res\n }\n\n hasSecurityMetadataOfType(delegation: SecureDelegation, metadataType: SecurityMetadataType): boolean {\n switch (metadataType) {\n case SecurityMetadataType.SecretId:\n return (delegation.secretIds ?? []).length > 0\n case SecurityMetadataType.EncryptionKey:\n return (delegation.encryptionKeys ?? []).length > 0\n case SecurityMetadataType.OwningEntityId:\n return (delegation.owningEntityIds ?? []).length > 0\n default:\n throw new Error('Internal error: invalid metadata type')\n }\n }\n\n async decryptSecureDelegationsUsingKnownExchangeData(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n const toSearchById: Set<string> = new Set([])\n for (const e of entities) {\n for (const delegation of Object.values(e.securityMetadata?.secureDelegations ?? {})) {\n if (dataOwnersHierarchySubset.some((it) => it == delegation.delegator || it == delegation.delegate)) {\n if (delegation.exchangeDataId && this.hasSecurityMetadataOfType(delegation, metadataType)) {\n toSearchById.add(delegation.exchangeDataId)\n }\n }\n }\n }\n const retrievedByExchangeDataId = toSearchById.size > 0 ? await this.exchangeData.getDecryptionDataKeyByIds([...toSearchById], true) : {}\n const res: { [entityId: string]: string[] } = {}\n for (const entity of entities) {\n const currEntityRes: Set<string> = new Set([])\n for (const delegation of Object.values(entity.securityMetadata?.secureDelegations ?? {})) {\n const currDelegationExchangeData = delegation.exchangeDataId ? retrievedByExchangeDataId[delegation.exchangeDataId] : undefined\n if (currDelegationExchangeData?.exchangeKey) {\n ;(await this.decryptSecureDelegationMetadata(delegation, metadataType, currDelegationExchangeData.exchangeKey)).forEach((decrypted) =>\n currEntityRes.add(decrypted)\n )\n }\n }\n res[entity.id!] = [...currEntityRes]\n }\n return res\n }\n\n async decryptSecureDelegationsUsingExchangeDataMap(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n const toSearchByExchangeDataMap: Set<string> = new Set([])\n for (const e of entities) {\n for (const [delegationKey, delegation] of Object.entries(e.securityMetadata?.secureDelegations ?? {})) {\n if (dataOwnersHierarchySubset.some((it) => it == delegation.delegator || it == delegation.delegate)) {\n if (!delegation.exchangeDataId && this.hasSecurityMetadataOfType(delegation, metadataType)) {\n toSearchByExchangeDataMap.add(delegationKey)\n }\n }\n }\n }\n const exchangeDataMaps =\n toSearchByExchangeDataMap.size > 0 ? await this.exchangeDataMap.getExchangeDataMapBatch([...toSearchByExchangeDataMap]) : []\n const exchangeDataIdByDelegationKey: { [delegationKey: string]: string } = {}\n for (const exchangeDataMap of exchangeDataMaps) {\n const decrypted = await this.secureDelegationsEncryption.decryptExchangeDataId(exchangeDataMap.encryptedExchangeDataIds)\n if (decrypted) {\n exchangeDataIdByDelegationKey[exchangeDataMap.id] = decrypted\n }\n }\n if (Object.keys(exchangeDataIdByDelegationKey).length == 0) return {}\n const retrievedByExchangeDataId =\n Object.values(exchangeDataIdByDelegationKey).length > 0\n ? await this.exchangeData.getDecryptionDataKeyByIds([...new Set(Object.values(exchangeDataIdByDelegationKey))], true)\n : {}\n const res: { [entityId: string]: string[] } = {}\n for (const entity of entities) {\n const currEntityRes: Set<string> = new Set([])\n for (const [delegationKey, delegation] of Object.entries(entity.securityMetadata?.secureDelegations ?? {})) {\n const exchangeDataId = exchangeDataIdByDelegationKey[delegationKey]\n const cached = exchangeDataId ? retrievedByExchangeDataId[exchangeDataId] : undefined\n if (cached?.exchangeKey) {\n ;(await this.decryptSecureDelegationMetadata(delegation, metadataType, cached.exchangeKey)).forEach((decrypted) =>\n currEntityRes.add(decrypted)\n )\n }\n }\n res[entity.id!] = [...currEntityRes]\n }\n return res\n }\n\n async decryptAll(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ ownerId: string; extracted: string[] }[]> {\n const allExtractedWithDataOwners = [\n ...(await this.decryptAllLegacyDelegations(entity, dataOwnersHierarchySubset, metadataType)),\n ...(await this.decryptAllSecureDelegations(entity, dataOwnersHierarchySubset, metadataType)),\n ]\n return dataOwnersHierarchySubset.map((dataOwner) => {\n const decryptedEntriesForDataOwner = allExtractedWithDataOwners\n .filter((x) => x.dataOwnersWithAccess.some((d) => dataOwner == d))\n .map((x) => x.decrypted)\n return {\n ownerId: dataOwner,\n extracted: [...new Set(decryptedEntriesForDataOwner)],\n }\n })\n }\n\n async decryptAllLegacyDelegations(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ decrypted: string; dataOwnersWithAccess: string[] }[]> {\n return this.extractFromLegacyDelegations(entity, dataOwnersHierarchySubset, metadataType)\n }\n\n async decryptAllSecureDelegations(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ decrypted: string; dataOwnersWithAccess: string[] }[]> {\n const secureDelegationEntries: [string, SecureDelegation][] = Object.entries(entity.securityMetadata?.secureDelegations ?? {})\n const toSearchByDelegationKey: string[] = secureDelegationEntries.flatMap(([delegationKey, delegation]): string[] => {\n if (!delegation.exchangeDataId) {\n return [delegationKey]\n } else {\n return []\n }\n })\n const exchangeDataByDelegationKey = await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash(toSearchByDelegationKey)\n const toSearchWithExchangeDataMap = secureDelegationEntries.flatMap(([delegationKey, delegation]): string[] => {\n if (\n !delegation.exchangeDataId &&\n dataOwnersHierarchySubset.some((it) => delegation.delegate == it || delegation.delegator == it) &&\n !exchangeDataByDelegationKey[delegationKey] &&\n this.hasSecurityMetadataOfType(delegation, metadataType)\n ) {\n return [delegationKey]\n } else {\n return []\n }\n })\n const exchangeDataMaps =\n toSearchWithExchangeDataMap.length > 0 ? await this.exchangeDataMap.getExchangeDataMapBatch(toSearchWithExchangeDataMap) : []\n const exchangeDataIdByDelegationKey: { [delegationKey: string]: string } = {}\n for (const exchangeDataMap of exchangeDataMaps) {\n const decrypted = await this.secureDelegationsEncryption.decryptExchangeDataId(exchangeDataMap.encryptedExchangeDataIds)\n if (decrypted) {\n exchangeDataIdByDelegationKey[exchangeDataMap.id] = decrypted\n }\n }\n const toSearchDirectlyById = secureDelegationEntries.flatMap(([delegationKey, delegation]): string[] => {\n if (\n delegation.exchangeDataId &&\n dataOwnersHierarchySubset.some((it) => delegation.delegate == it || delegation.delegator == it) &&\n !exchangeDataByDelegationKey[delegationKey] &&\n this.hasSecurityMetadataOfType(delegation, metadataType)\n ) {\n return [delegation.exchangeDataId]\n } else {\n return []\n }\n })\n const allExchangeDataIdToRetrieve = [...new Set([...toSearchDirectlyById, ...Object.values(exchangeDataIdByDelegationKey)])]\n const exchangeDataById =\n allExchangeDataIdToRetrieve.length > 0 ? await this.exchangeData.getDecryptionDataKeyByIds(allExchangeDataIdToRetrieve, true) : {}\n const allExtractedWithDataOwners: { decrypted: string; dataOwnersWithAccess: string[] }[] = []\n for (const [delegationKey, delegation] of secureDelegationEntries) {\n let exchangeData:\n | {\n exchangeKey: CryptoKey | undefined\n accessControlSecret: string | undefined\n exchangeData: ExchangeData\n }\n | undefined = undefined\n if (exchangeDataByDelegationKey[delegationKey]) {\n exchangeData = exchangeDataByDelegationKey[delegationKey]\n } else if (delegation.exchangeDataId) {\n exchangeData = exchangeDataById[delegation.exchangeDataId]\n } else if (exchangeDataIdByDelegationKey[delegationKey]) {\n exchangeData = exchangeDataById[exchangeDataIdByDelegationKey[delegationKey]]\n }\n if (exchangeData && exchangeData.exchangeKey) {\n const decrypted = await this.decryptSecureDelegationMetadata(delegation, metadataType, exchangeData.exchangeKey)\n for (const d of decrypted) {\n allExtractedWithDataOwners.push({\n decrypted: d,\n dataOwnersWithAccess: [exchangeData.exchangeData.delegator, exchangeData.exchangeData.delegate],\n })\n }\n }\n }\n return allExtractedWithDataOwners\n }\n\n async getDelegationMemberDetails(typedEntity: EncryptedEntityWithType): Promise<{\n [delegationKey: string]: DelegationMembersDetails\n }> {\n const res: { [delegationKey: string]: DelegationMembersDetails } = {}\n // 1. Add all explicit data owners, keep only delegations with at least an anonymous data owner to check later\n let remainingDelegations = Object.entries(typedEntity.entity.securityMetadata?.secureDelegations ?? {})\n let updatedRemainingDelegations: [string, SecureDelegation][] = []\n for (const delegationEntry of remainingDelegations) {\n const delegation = delegationEntry[1]\n if (delegation.delegator && delegation.delegate) {\n res[delegationEntry[0]] = {\n delegate: delegation.delegate,\n delegator: delegation.delegator,\n fullyExplicit: true,\n accessLevel: delegation.permissions,\n accessControlSecret: undefined,\n }\n } else {\n updatedRemainingDelegations.push(delegationEntry)\n }\n }\n remainingDelegations = updatedRemainingDelegations\n if (!remainingDelegations.length) return res\n updatedRemainingDelegations = []\n // 2. Attempt to identify the anonymous data owner of remaining delegations by checking if we have the exchange data cached by hash\n // Note: we can find exchange data by hash only if we could successfully decrypt it\n const cachedExchangeData = await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash(remainingDelegations.map((d) => d[0]))\n for (const delegationEntry of remainingDelegations) {\n const exchangeDataOfDelegation = cachedExchangeData[delegationEntry[0]]\n if (exchangeDataOfDelegation) {\n res[delegationEntry[0]] = {\n delegate: exchangeDataOfDelegation.exchangeData.delegate,\n delegator: exchangeDataOfDelegation.exchangeData.delegator,\n fullyExplicit: false,\n accessLevel: delegationEntry[1].permissions,\n accessControlSecret: exchangeDataOfDelegation.accessControlSecret,\n }\n } else {\n updatedRemainingDelegations.push(delegationEntry)\n }\n }\n remainingDelegations = updatedRemainingDelegations\n if (!remainingDelegations.length) return res\n updatedRemainingDelegations = []\n // 3. Attempt to identify the anonymous data owner of remaining delegations between us (or one of our parents) and an anonymous data owner\n const hierarchy = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()\n const remainingExchangeDataMaps = await this.exchangeDataMap.getExchangeDataMapBatch(\n remainingDelegations\n .filter(([_, delegation]) => hierarchy.some((x) => x == delegation.delegator || x == delegation.delegate))\n .map(([hash, _]) => hash)\n )\n const exchangeDataIdByDelegationKey: { [delegationKey: string]: string } = {}\n for (const exchangeDataMap of remainingExchangeDataMaps) {\n if (!!exchangeDataMap.encryptedExchangeDataIds) {\n const decrypted = await this.secureDelegationsEncryption.decryptExchangeDataId(exchangeDataMap.encryptedExchangeDataIds)\n if (decrypted) {\n exchangeDataIdByDelegationKey[exchangeDataMap.id] = decrypted\n }\n }\n }\n const exchangeDataByIds = await this.exchangeData.getDecryptionDataKeyByIds(Object.values(exchangeDataIdByDelegationKey), true)\n for (const [hash, delegation] of remainingDelegations) {\n if (hierarchy.some((x) => x === delegation.delegate || x === delegation.delegator)) {\n const dataId = exchangeDataIdByDelegationKey[hash]\n const exchangeDataInfo = dataId ? exchangeDataByIds[dataId] : undefined\n if (exchangeDataInfo) {\n res[hash] = {\n delegator: exchangeDataInfo.exchangeData.delegator,\n delegate: exchangeDataInfo.exchangeData.delegate,\n fullyExplicit: false,\n accessLevel: delegation.permissions,\n accessControlSecret: exchangeDataInfo.accessControlSecret,\n }\n } else {\n updatedRemainingDelegations.push([hash, delegation])\n }\n } else {\n updatedRemainingDelegations.push([hash, delegation])\n }\n }\n return {\n ...res,\n ...Object.fromEntries(\n updatedRemainingDelegations.map(([hash, secureDelegation]) => [\n hash,\n {\n delegator: secureDelegation.delegator,\n delegate: secureDelegation.delegate,\n fullyExplicit: false,\n accessLevel: secureDelegation.permissions,\n accessControlSecret: undefined,\n },\n ])\n ),\n }\n }\n\n async decryptSecureDelegationMetadata(delegation: SecureDelegation, metadataType: SecurityMetadataType, key: CryptoKey): Promise<string[]> {\n switch (metadataType) {\n case SecurityMetadataType.SecretId:\n return this.secureDelegationsEncryption.decryptSecretIds(delegation, key)\n case SecurityMetadataType.EncryptionKey:\n return this.secureDelegationsEncryption.decryptEncryptionKeys(delegation, key)\n case SecurityMetadataType.OwningEntityId:\n return this.secureDelegationsEncryption.decryptOwningEntityIds(delegation, key)\n default:\n throw new Error(`Internal error: invalid SecurityMetadataType ${metadataType}`)\n }\n }\n\n async getEntityLegacyDelegationAccessLevel(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[]\n ): Promise<AccessLevelEnum | undefined> {\n if (!dataOwnersHierarchySubset.length) throw new Error(\"`dataOwnersHierarchySubset` can't be empty\")\n // Legacy delegations provide write access\n if (Object.keys(entity.delegations ?? {}).some((delegate) => dataOwnersHierarchySubset.includes(delegate))) {\n return AccessLevelEnum.WRITE\n }\n return undefined\n }\n\n async getEntitySecureDelegationAccessLevel(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[]\n ): Promise<AccessLevelEnum | undefined> {\n if (!dataOwnersHierarchySubset.length) throw new Error(\"`dataOwnersHierarchySubset` can't be empty\")\n // If the data owner is explicit all delegations he can access has his id. If the delegator is anonymous all delegations he can access are\n // accessible by hash. No mixed scenario possible.\n let accessibleDelegations: SecureDelegation[] = Object.values(entity.securityMetadata?.secureDelegations ?? {}).filter((secureDelegation) =>\n dataOwnersHierarchySubset.some((dataOwner) => dataOwner === secureDelegation.delegator || dataOwner === secureDelegation.delegate)\n )\n if (!accessibleDelegations.length) {\n const availableCanonicalHashes = Object.keys(\n await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash(Object.keys(entity.securityMetadata?.secureDelegations ?? {}))\n )\n accessibleDelegations = availableCanonicalHashes.map((hash) => (entity.securityMetadata?.secureDelegations ?? {})[hash])\n }\n const permissions = accessibleDelegations.map((secureDelegation) => secureDelegation.permissions)\n let maxLevel: AccessLevelEnum | undefined = undefined\n for (const permission of permissions) {\n if (permission === AccessLevelEnum.WRITE) {\n return AccessLevelEnum.WRITE\n }\n if (permission === AccessLevelEnum.READ) {\n maxLevel = AccessLevelEnum.READ\n }\n }\n return maxLevel\n }\n\n async getEntityAccessLevel(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[]\n ): Promise<AccessLevelEnum | undefined> {\n const legacyAccess = await this.getEntityLegacyDelegationAccessLevel(entity, dataOwnersHierarchySubset)\n if (legacyAccess != undefined) return legacyAccess\n return this.getEntitySecureDelegationAccessLevel(entity, dataOwnersHierarchySubset)\n }\n\n hasAnyEncryptionKeys(entity: EncryptedEntityStub | EncryptedEntity): boolean {\n return Object.keys(entity.encryptionKeys ?? {}).length > 0 || Object.keys(entity.securityMetadata?.secureDelegations ?? {}).length > 0\n }\n}\n"]}
1
+ {"version":3,"file":"SecurityMetadataDecryptor.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/SecurityMetadataDecryptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAA4G;AAQ5G,uDAAmG;AAEnG,IAAO,eAAe,GAAG,yBAAgB,CAAC,eAAe,CAAA;AAUzD,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,uEAAY,CAAA;IACZ,iFAAa,CAAA;IACb,mFAAc,CAAA;AAChB,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B;AAED,MAAa,yBAAyB;IACpC,YACmB,mBAAwC,EACxC,UAA4B,EAC5B,YAAiC,EACjC,eAAuC,EACvC,2BAAwD,EACxD,YAA8B;QAL9B,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,eAAU,GAAV,UAAU,CAAkB;QAC5B,iBAAY,GAAZ,YAAY,CAAqB;QACjC,oBAAe,GAAf,eAAe,CAAwB;QACvC,gCAA2B,GAA3B,2BAA2B,CAA6B;QACxD,iBAAY,GAAZ,YAAY,CA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qB,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;YACjG,IAAI,QAAQ,GAAgC,SAAS,CAAA;YACrD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,IAAI,UAAU,KAAK,eAAe,CAAC,KAAK,EAAE,CAAC;oBACzC,OAAO,eAAe,CAAC,KAAK,CAAA;gBAC9B,CAAC;gBACD,IAAI,UAAU,KAAK,eAAe,CAAC,IAAI,EAAE,CAAC;oBACxC,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAA;gBACjC,CAAC;YACH,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC;KAAA;IAEK,oBAAoB,CACxB,MAA6C,EAC7C,yBAAmC;;YAEnC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,oCAAoC,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;YACvG,IAAI,YAAY,IAAI,SAAS;gBAAE,OAAO,YAAY,CAAA;YAClD,OAAO,IAAI,CAAC,oCAAoC,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;QACrF,CAAC;KAAA;IAED,oBAAoB,CAAC,MAA6C;;QAChE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAA,MAAM,CAAC,cAAc,mCAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAA,MAAA,MAAM,CAAC,gBAAgB,0CAAE,iBAAiB,mCAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IACxI,CAAC;CACF;AA1hBD,8DA0hBC","sourcesContent":["import { b64_2ab, EncryptedEntityWithType, EntityWithDelegationTypeName, hex2ua, ua2string } from '../utils'\nimport { ExchangeKeysManager } from './ExchangeKeysManager'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { Delegation } from '../../icc-api/model/Delegation'\nimport { ExchangeDataManager } from './ExchangeDataManager'\nimport { ExchangeDataMapManager } from './ExchangeDataMapManager'\nimport { SecureDelegationsEncryption } from './SecureDelegationsEncryption'\nimport { IccDataOwnerXApi } from '../icc-data-owner-x-api'\nimport { EncryptedEntity, EncryptedEntityStub, SecureDelegation } from '../../icc-api/model/models'\nimport { ExchangeData } from '../../icc-api/model/internal/ExchangeData'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\n\nexport type DelegationMembersDetails = {\n delegator: string | undefined\n delegate: string | undefined\n fullyExplicit: boolean\n accessControlSecret: string | undefined\n accessLevel: AccessLevelEnum\n}\n\nexport enum SecurityMetadataType {\n SecretId = 1, // Start from 1, avoids issues with SecretId being falsy\n EncryptionKey,\n OwningEntityId,\n}\n\nexport class SecurityMetadataDecryptor {\n constructor(\n private readonly exchangeKeysManager: ExchangeKeysManager,\n private readonly primitives: CryptoPrimitives,\n private readonly exchangeData: ExchangeDataManager,\n private readonly exchangeDataMap: ExchangeDataMapManager,\n private readonly secureDelegationsEncryption: SecureDelegationsEncryption,\n private readonly dataOwnerApi: IccDataOwnerXApi\n ) {}\n\n async decryptLegacyDelegations(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n // For legacy delegations there is no advantage in doing stuff in bulk.\n const res: { [entityId: string]: string[] } = {}\n for (const e of entities) {\n const allDecrypted = await this.extractFromLegacyDelegations(e, dataOwnersHierarchySubset, metadataType)\n const deduplicatedDecrypted = new Set(allDecrypted.map((x) => x.decrypted))\n res[e.id!] = [...deduplicatedDecrypted]\n }\n return res\n }\n\n private async extractFromLegacyDelegations(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ decrypted: string; dataOwnersWithAccess: string[] }[]> {\n if (!dataOwnersHierarchySubset.length) throw new Error(\"`dataOwnersHierarchySubset` can't be empty\")\n let delegations: { [delegateId: string]: Delegation[] }\n let validateDecrypted: (result: string) => Promise<boolean> = (x) => Promise.resolve(!!x)\n let mapDecrypted: (result: string) => string = (x) => x\n switch (metadataType) {\n case SecurityMetadataType.SecretId:\n delegations = entity.delegations ?? {}\n break\n case SecurityMetadataType.EncryptionKey:\n delegations = entity.encryptionKeys ?? {}\n validateDecrypted = async (key) => {\n if (!/^[0-9A-Fa-f\\-]+$/g.test(key)) return false\n try {\n await this.primitives.AES.importKey('raw', hex2ua(key.replace(/-/g, '')))\n return true\n } catch (e) {\n console.warn(`Could not import key ${key} as an encryption key.`, e)\n return false\n }\n }\n mapDecrypted = (key) => key.replace(/-/g, '')\n break\n case SecurityMetadataType.OwningEntityId:\n delegations = entity.cryptedForeignKeys ?? {}\n break\n default:\n throw new Error(`Internal error: invalid SecurityMetadataType ${metadataType}`)\n }\n const delegationsWithOwner = Object.entries(delegations).flatMap(([delegateId, delegations]) =>\n dataOwnersHierarchySubset.some((dataOwnerId) => dataOwnerId === delegateId)\n ? this.populateLegacyDelegationDelegate(delegateId, delegations)\n : this.populateLegacyDelegationDelegate(\n delegateId,\n delegations.filter((d) => dataOwnersHierarchySubset.some((dataOwnerId) => d.owner === dataOwnerId))\n )\n )\n const res: { decrypted: string; dataOwnersWithAccess: string[] }[] = []\n for (const delegation of delegationsWithOwner) {\n const decrypted = await this.tryDecryptLegacyDelegation(delegation, (k) => validateDecrypted(k))\n if (decrypted)\n res.push({\n decrypted: mapDecrypted(decrypted),\n dataOwnersWithAccess: delegation.owner ? [delegation.owner, delegation.delegatedTo!] : [delegation.delegatedTo!],\n })\n }\n return res\n }\n\n private populateLegacyDelegationDelegate(delegateId: string, delegations: Delegation[]): Delegation[] {\n return delegations.map((d) => (d.delegatedTo === delegateId ? d : { ...d, delegatedTo: delegateId }))\n }\n\n private async tryDecryptLegacyDelegation(\n delegation: Delegation,\n validateDecrypted: (result: string) => Promise<boolean>\n ): Promise<string | undefined> {\n const exchangeKeys = await this.exchangeKeysManager.getDecryptionExchangeKeysFor(delegation.owner!, delegation.delegatedTo!)\n for (const key of exchangeKeys) {\n try {\n // Format of encrypted key for any delegation should be entityId:key, but with the merging of entities the entityId might not match the\n // current id. As a checksum we are only verifying that the decrypted bytes can be represented as a string with exactly one ':'.\n // Additionally, we also have a validator that is specific for each type of delegation content (encryption key, secret id, ...)\n const decrypted = ua2string(await this.primitives.AES.decrypt(key, hex2ua(delegation.key!)))\n const decryptedSplit = decrypted.split(':')\n if (decryptedSplit.length === 2) {\n if (await validateDecrypted(decryptedSplit[1])) return decryptedSplit[1]\n } else {\n console.warn(\"Error in the decrypted delegation: content should contain exactly 1 ':', the delegation is ignored.\")\n }\n } catch (e) {\n // Do nothing: the delegation uses another exchange key owner->delegator\n }\n }\n }\n\n async decryptSecureDelegationsUsingCache(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n const toSearchById: Set<string> = new Set([])\n const toSearchByDelegationKey: Set<string> = new Set([])\n for (const e of entities) {\n for (const [delegationKey, delegation] of Object.entries(e.securityMetadata?.secureDelegations ?? {})) {\n if (\n !delegation.delegator ||\n !delegation.delegate ||\n dataOwnersHierarchySubset.some((it) => it == delegation.delegator || it == delegation.delegate)\n ) {\n if (delegation.exchangeDataId) {\n toSearchById.add(delegation.exchangeDataId)\n } else {\n toSearchByDelegationKey.add(delegationKey)\n }\n }\n }\n }\n const cachedByExchangeDataId = await this.exchangeData.getDecryptionDataKeyByIds([...toSearchById], false)\n const cachedByDelegationKey = await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash([...toSearchByDelegationKey])\n const res: { [entityId: string]: string[] } = {}\n for (const entity of entities) {\n const currEntityRes: Set<string> = new Set([])\n for (const [delegationKey, delegation] of Object.entries(entity.securityMetadata?.secureDelegations ?? {})) {\n const cached = delegation.exchangeDataId ? cachedByExchangeDataId[delegation.exchangeDataId] : cachedByDelegationKey[delegationKey]\n if (\n cached?.exchangeKey &&\n dataOwnersHierarchySubset.some((it) => it == cached?.exchangeData?.delegator || it == cached?.exchangeData?.delegate)\n ) {\n ;(await this.decryptSecureDelegationMetadata(delegation, metadataType, cached.exchangeKey)).forEach((decrypted) =>\n currEntityRes.add(decrypted)\n )\n }\n }\n res[entity.id!] = [...currEntityRes]\n }\n return res\n }\n\n hasSecurityMetadataOfType(delegation: SecureDelegation, metadataType: SecurityMetadataType): boolean {\n switch (metadataType) {\n case SecurityMetadataType.SecretId:\n return (delegation.secretIds ?? []).length > 0\n case SecurityMetadataType.EncryptionKey:\n return (delegation.encryptionKeys ?? []).length > 0\n case SecurityMetadataType.OwningEntityId:\n return (delegation.owningEntityIds ?? []).length > 0\n default:\n throw new Error('Internal error: invalid metadata type')\n }\n }\n\n async decryptSecureDelegationsUsingKnownExchangeData(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n const toSearchById: Set<string> = new Set([])\n for (const e of entities) {\n for (const delegation of Object.values(e.securityMetadata?.secureDelegations ?? {})) {\n if (dataOwnersHierarchySubset.some((it) => it == delegation.delegator || it == delegation.delegate)) {\n if (delegation.exchangeDataId && this.hasSecurityMetadataOfType(delegation, metadataType)) {\n toSearchById.add(delegation.exchangeDataId)\n }\n }\n }\n }\n const retrievedByExchangeDataId = toSearchById.size > 0 ? await this.exchangeData.getDecryptionDataKeyByIds([...toSearchById], true) : {}\n const res: { [entityId: string]: string[] } = {}\n for (const entity of entities) {\n const currEntityRes: Set<string> = new Set([])\n for (const delegation of Object.values(entity.securityMetadata?.secureDelegations ?? {})) {\n const currDelegationExchangeData = delegation.exchangeDataId ? retrievedByExchangeDataId[delegation.exchangeDataId] : undefined\n if (currDelegationExchangeData?.exchangeKey) {\n ;(await this.decryptSecureDelegationMetadata(delegation, metadataType, currDelegationExchangeData.exchangeKey)).forEach((decrypted) =>\n currEntityRes.add(decrypted)\n )\n }\n }\n res[entity.id!] = [...currEntityRes]\n }\n return res\n }\n\n async decryptSecureDelegationsUsingExchangeDataMap(\n entities: (EncryptedEntityStub | EncryptedEntity)[],\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [entityId: string]: string[] }> {\n const toSearchByExchangeDataMap: Set<string> = new Set([])\n for (const e of entities) {\n for (const [delegationKey, delegation] of Object.entries(e.securityMetadata?.secureDelegations ?? {})) {\n if (dataOwnersHierarchySubset.some((it) => it == delegation.delegator || it == delegation.delegate)) {\n if (!delegation.exchangeDataId && this.hasSecurityMetadataOfType(delegation, metadataType)) {\n toSearchByExchangeDataMap.add(delegationKey)\n }\n }\n }\n }\n const exchangeDataMaps =\n toSearchByExchangeDataMap.size > 0 ? await this.exchangeDataMap.getExchangeDataMapBatch([...toSearchByExchangeDataMap]) : []\n const exchangeDataIdByDelegationKey: { [delegationKey: string]: string } = {}\n for (const exchangeDataMap of exchangeDataMaps) {\n const decrypted = await this.secureDelegationsEncryption.decryptExchangeDataId(exchangeDataMap.encryptedExchangeDataIds)\n if (decrypted) {\n exchangeDataIdByDelegationKey[exchangeDataMap.id] = decrypted\n }\n }\n if (Object.keys(exchangeDataIdByDelegationKey).length == 0) return {}\n const retrievedByExchangeDataId =\n Object.values(exchangeDataIdByDelegationKey).length > 0\n ? await this.exchangeData.getDecryptionDataKeyByIds([...new Set(Object.values(exchangeDataIdByDelegationKey))], true)\n : {}\n const res: { [entityId: string]: string[] } = {}\n for (const entity of entities) {\n const currEntityRes: Set<string> = new Set([])\n for (const [delegationKey, delegation] of Object.entries(entity.securityMetadata?.secureDelegations ?? {})) {\n const exchangeDataId = exchangeDataIdByDelegationKey[delegationKey]\n const cached = exchangeDataId ? retrievedByExchangeDataId[exchangeDataId] : undefined\n if (cached?.exchangeKey) {\n ;(await this.decryptSecureDelegationMetadata(delegation, metadataType, cached.exchangeKey)).forEach((decrypted) =>\n currEntityRes.add(decrypted)\n )\n }\n }\n res[entity.id!] = [...currEntityRes]\n }\n return res\n }\n\n async decryptAll(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ ownerId: string; extracted: string[] }[]> {\n const allExtractedWithDataOwners = [\n ...(await this.decryptAllLegacyDelegations(entity, dataOwnersHierarchySubset, metadataType)),\n ...(await this.decryptAllSecureDelegations(entity, dataOwnersHierarchySubset, metadataType)),\n ]\n return dataOwnersHierarchySubset.map((dataOwner) => {\n const decryptedEntriesForDataOwner = allExtractedWithDataOwners\n .filter((x) => x.dataOwnersWithAccess.some((d) => dataOwner == d))\n .map((x) => x.decrypted)\n return {\n ownerId: dataOwner,\n extracted: [...new Set(decryptedEntriesForDataOwner)],\n }\n })\n }\n\n async decryptAllLegacyDelegations(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ decrypted: string; dataOwnersWithAccess: string[] }[]> {\n return this.extractFromLegacyDelegations(entity, dataOwnersHierarchySubset, metadataType)\n }\n\n /**\n * For every value (secret id / encryption key / owning entity id, depending on metadataType) decryptable by the\n * given hierarchy, returns which data owners have DIRECT access to it: i.e. are explicitly named as either party\n * (delegator/delegate, owner/delegatedTo) of the specific delegation edge that carries that value - never a data\n * owner merely reachable by inference through a parent/child hierarchy relationship. Both parties of an edge get\n * equal credit for its content because they have equal decrypt access to it by construction (the edge's exchange\n * key can be unwrapped by either party's private key).\n *\n * Used to check whether sharing a value with a delegate would be redundant because some other, already-decryptable\n * delegation on the entity already grants that delegate the exact same value directly.\n */\n async directlyAccessibleValuesByDataOwner(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ [dataOwnerId: string]: Set<string> }> {\n const edges = [\n ...(await this.decryptAllLegacyDelegations(entity, dataOwnersHierarchySubset, metadataType)),\n ...(await this.decryptAllSecureDelegations(entity, dataOwnersHierarchySubset, metadataType)),\n ]\n const result: { [dataOwnerId: string]: Set<string> } = {}\n for (const edge of edges) {\n for (const partyId of edge.dataOwnersWithAccess) {\n ;(result[partyId] ??= new Set()).add(edge.decrypted)\n }\n }\n return result\n }\n\n async decryptAllSecureDelegations(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[],\n metadataType: SecurityMetadataType\n ): Promise<{ decrypted: string; dataOwnersWithAccess: string[] }[]> {\n const secureDelegationEntries: [string, SecureDelegation][] = Object.entries(entity.securityMetadata?.secureDelegations ?? {})\n const toSearchByDelegationKey: string[] = secureDelegationEntries.flatMap(([delegationKey, delegation]): string[] => {\n if (!delegation.exchangeDataId) {\n return [delegationKey]\n } else {\n return []\n }\n })\n const exchangeDataByDelegationKey = await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash(toSearchByDelegationKey)\n const toSearchWithExchangeDataMap = secureDelegationEntries.flatMap(([delegationKey, delegation]): string[] => {\n if (\n !delegation.exchangeDataId &&\n dataOwnersHierarchySubset.some((it) => delegation.delegate == it || delegation.delegator == it) &&\n !exchangeDataByDelegationKey[delegationKey] &&\n this.hasSecurityMetadataOfType(delegation, metadataType)\n ) {\n return [delegationKey]\n } else {\n return []\n }\n })\n const exchangeDataMaps =\n toSearchWithExchangeDataMap.length > 0 ? await this.exchangeDataMap.getExchangeDataMapBatch(toSearchWithExchangeDataMap) : []\n const exchangeDataIdByDelegationKey: { [delegationKey: string]: string } = {}\n for (const exchangeDataMap of exchangeDataMaps) {\n const decrypted = await this.secureDelegationsEncryption.decryptExchangeDataId(exchangeDataMap.encryptedExchangeDataIds)\n if (decrypted) {\n exchangeDataIdByDelegationKey[exchangeDataMap.id] = decrypted\n }\n }\n const toSearchDirectlyById = secureDelegationEntries.flatMap(([delegationKey, delegation]): string[] => {\n if (\n delegation.exchangeDataId &&\n dataOwnersHierarchySubset.some((it) => delegation.delegate == it || delegation.delegator == it) &&\n !exchangeDataByDelegationKey[delegationKey] &&\n this.hasSecurityMetadataOfType(delegation, metadataType)\n ) {\n return [delegation.exchangeDataId]\n } else {\n return []\n }\n })\n const allExchangeDataIdToRetrieve = [...new Set([...toSearchDirectlyById, ...Object.values(exchangeDataIdByDelegationKey)])]\n const exchangeDataById =\n allExchangeDataIdToRetrieve.length > 0 ? await this.exchangeData.getDecryptionDataKeyByIds(allExchangeDataIdToRetrieve, true) : {}\n const allExtractedWithDataOwners: { decrypted: string; dataOwnersWithAccess: string[] }[] = []\n for (const [delegationKey, delegation] of secureDelegationEntries) {\n let exchangeData:\n | {\n exchangeKey: CryptoKey | undefined\n accessControlSecret: string | undefined\n exchangeData: ExchangeData\n }\n | undefined = undefined\n if (exchangeDataByDelegationKey[delegationKey]) {\n exchangeData = exchangeDataByDelegationKey[delegationKey]\n } else if (delegation.exchangeDataId) {\n exchangeData = exchangeDataById[delegation.exchangeDataId]\n } else if (exchangeDataIdByDelegationKey[delegationKey]) {\n exchangeData = exchangeDataById[exchangeDataIdByDelegationKey[delegationKey]]\n }\n if (exchangeData && exchangeData.exchangeKey) {\n const decrypted = await this.decryptSecureDelegationMetadata(delegation, metadataType, exchangeData.exchangeKey)\n for (const d of decrypted) {\n allExtractedWithDataOwners.push({\n decrypted: d,\n dataOwnersWithAccess: [exchangeData.exchangeData.delegator, exchangeData.exchangeData.delegate],\n })\n }\n }\n }\n return allExtractedWithDataOwners\n }\n\n async getDelegationMemberDetails(typedEntity: EncryptedEntityWithType): Promise<{\n [delegationKey: string]: DelegationMembersDetails\n }> {\n const res: { [delegationKey: string]: DelegationMembersDetails } = {}\n // 1. Add all explicit data owners, keep only delegations with at least an anonymous data owner to check later\n let remainingDelegations = Object.entries(typedEntity.entity.securityMetadata?.secureDelegations ?? {})\n let updatedRemainingDelegations: [string, SecureDelegation][] = []\n for (const delegationEntry of remainingDelegations) {\n const delegation = delegationEntry[1]\n if (delegation.delegator && delegation.delegate) {\n res[delegationEntry[0]] = {\n delegate: delegation.delegate,\n delegator: delegation.delegator,\n fullyExplicit: true,\n accessLevel: delegation.permissions,\n accessControlSecret: undefined,\n }\n } else {\n updatedRemainingDelegations.push(delegationEntry)\n }\n }\n remainingDelegations = updatedRemainingDelegations\n if (!remainingDelegations.length) return res\n updatedRemainingDelegations = []\n // 2. Attempt to identify the anonymous data owner of remaining delegations by checking if we have the exchange data cached by hash\n // Note: we can find exchange data by hash only if we could successfully decrypt it\n const cachedExchangeData = await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash(remainingDelegations.map((d) => d[0]))\n for (const delegationEntry of remainingDelegations) {\n const exchangeDataOfDelegation = cachedExchangeData[delegationEntry[0]]\n if (exchangeDataOfDelegation) {\n res[delegationEntry[0]] = {\n delegate: exchangeDataOfDelegation.exchangeData.delegate,\n delegator: exchangeDataOfDelegation.exchangeData.delegator,\n fullyExplicit: false,\n accessLevel: delegationEntry[1].permissions,\n accessControlSecret: exchangeDataOfDelegation.accessControlSecret,\n }\n } else {\n updatedRemainingDelegations.push(delegationEntry)\n }\n }\n remainingDelegations = updatedRemainingDelegations\n if (!remainingDelegations.length) return res\n updatedRemainingDelegations = []\n // 3. Attempt to identify the anonymous data owner of remaining delegations between us (or one of our parents) and an anonymous data owner\n const hierarchy = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()\n const remainingExchangeDataMaps = await this.exchangeDataMap.getExchangeDataMapBatch(\n remainingDelegations\n .filter(([_, delegation]) => hierarchy.some((x) => x == delegation.delegator || x == delegation.delegate))\n .map(([hash, _]) => hash)\n )\n const exchangeDataIdByDelegationKey: { [delegationKey: string]: string } = {}\n for (const exchangeDataMap of remainingExchangeDataMaps) {\n if (!!exchangeDataMap.encryptedExchangeDataIds) {\n const decrypted = await this.secureDelegationsEncryption.decryptExchangeDataId(exchangeDataMap.encryptedExchangeDataIds)\n if (decrypted) {\n exchangeDataIdByDelegationKey[exchangeDataMap.id] = decrypted\n }\n }\n }\n const exchangeDataByIds = await this.exchangeData.getDecryptionDataKeyByIds(Object.values(exchangeDataIdByDelegationKey), true)\n for (const [hash, delegation] of remainingDelegations) {\n if (hierarchy.some((x) => x === delegation.delegate || x === delegation.delegator)) {\n const dataId = exchangeDataIdByDelegationKey[hash]\n const exchangeDataInfo = dataId ? exchangeDataByIds[dataId] : undefined\n if (exchangeDataInfo) {\n res[hash] = {\n delegator: exchangeDataInfo.exchangeData.delegator,\n delegate: exchangeDataInfo.exchangeData.delegate,\n fullyExplicit: false,\n accessLevel: delegation.permissions,\n accessControlSecret: exchangeDataInfo.accessControlSecret,\n }\n } else {\n updatedRemainingDelegations.push([hash, delegation])\n }\n } else {\n updatedRemainingDelegations.push([hash, delegation])\n }\n }\n return {\n ...res,\n ...Object.fromEntries(\n updatedRemainingDelegations.map(([hash, secureDelegation]) => [\n hash,\n {\n delegator: secureDelegation.delegator,\n delegate: secureDelegation.delegate,\n fullyExplicit: false,\n accessLevel: secureDelegation.permissions,\n accessControlSecret: undefined,\n },\n ])\n ),\n }\n }\n\n async decryptSecureDelegationMetadata(delegation: SecureDelegation, metadataType: SecurityMetadataType, key: CryptoKey): Promise<string[]> {\n switch (metadataType) {\n case SecurityMetadataType.SecretId:\n return this.secureDelegationsEncryption.decryptSecretIds(delegation, key)\n case SecurityMetadataType.EncryptionKey:\n return this.secureDelegationsEncryption.decryptEncryptionKeys(delegation, key)\n case SecurityMetadataType.OwningEntityId:\n return this.secureDelegationsEncryption.decryptOwningEntityIds(delegation, key)\n default:\n throw new Error(`Internal error: invalid SecurityMetadataType ${metadataType}`)\n }\n }\n\n async getEntityLegacyDelegationAccessLevel(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[]\n ): Promise<AccessLevelEnum | undefined> {\n if (!dataOwnersHierarchySubset.length) throw new Error(\"`dataOwnersHierarchySubset` can't be empty\")\n // Legacy delegations provide write access\n if (Object.keys(entity.delegations ?? {}).some((delegate) => dataOwnersHierarchySubset.includes(delegate))) {\n return AccessLevelEnum.WRITE\n }\n return undefined\n }\n\n async getEntitySecureDelegationAccessLevel(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[]\n ): Promise<AccessLevelEnum | undefined> {\n if (!dataOwnersHierarchySubset.length) throw new Error(\"`dataOwnersHierarchySubset` can't be empty\")\n // If the data owner is explicit all delegations he can access has his id. If the delegator is anonymous all delegations he can access are\n // accessible by hash. No mixed scenario possible.\n let accessibleDelegations: SecureDelegation[] = Object.values(entity.securityMetadata?.secureDelegations ?? {}).filter((secureDelegation) =>\n dataOwnersHierarchySubset.some((dataOwner) => dataOwner === secureDelegation.delegator || dataOwner === secureDelegation.delegate)\n )\n if (!accessibleDelegations.length) {\n const availableCanonicalHashes = Object.keys(\n await this.exchangeData.getCachedDecryptionDataKeyByAccessControlHash(Object.keys(entity.securityMetadata?.secureDelegations ?? {}))\n )\n accessibleDelegations = availableCanonicalHashes.map((hash) => (entity.securityMetadata?.secureDelegations ?? {})[hash])\n }\n const permissions = accessibleDelegations.map((secureDelegation) => secureDelegation.permissions)\n let maxLevel: AccessLevelEnum | undefined = undefined\n for (const permission of permissions) {\n if (permission === AccessLevelEnum.WRITE) {\n return AccessLevelEnum.WRITE\n }\n if (permission === AccessLevelEnum.READ) {\n maxLevel = AccessLevelEnum.READ\n }\n }\n return maxLevel\n }\n\n async getEntityAccessLevel(\n entity: EncryptedEntityStub | EncryptedEntity,\n dataOwnersHierarchySubset: string[]\n ): Promise<AccessLevelEnum | undefined> {\n const legacyAccess = await this.getEntityLegacyDelegationAccessLevel(entity, dataOwnersHierarchySubset)\n if (legacyAccess != undefined) return legacyAccess\n return this.getEntitySecureDelegationAccessLevel(entity, dataOwnersHierarchySubset)\n }\n\n hasAnyEncryptionKeys(entity: EncryptedEntityStub | EncryptedEntity): boolean {\n return Object.keys(entity.encryptionKeys ?? {}).length > 0 || Object.keys(entity.securityMetadata?.secureDelegations ?? {}).length > 0\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * iCure Data Stack API Documentation
3
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
4
+ *
5
+ * OpenAPI spec version: v1
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by the swagger code generator program.
9
+ * https://github.com/swagger-api/swagger-codegen.git
10
+ * Do not edit the class manually.
11
+ */
12
+ import { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement';
13
+ /**
14
+ * Retrieves the HealthElements that have in their qualifiedLinks, for any type of qualification, a link
15
+ * with an association id equal to associationId.
16
+ * As HealthElement is an encryptable entity and this filter does not specify a data owner id, a special
17
+ * permission is required to use this filter.
18
+ */
19
+ export declare class HealthElementByAssociationIdFilter extends AbstractFilterHealthElement {
20
+ $type: string;
21
+ constructor(json: JSON | any);
22
+ associationId?: string;
23
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HealthElementByAssociationIdFilter = void 0;
4
+ /**
5
+ * iCure Data Stack API Documentation
6
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
7
+ *
8
+ * OpenAPI spec version: v1
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by the swagger code generator program.
12
+ * https://github.com/swagger-api/swagger-codegen.git
13
+ * Do not edit the class manually.
14
+ */
15
+ const AbstractFilterHealthElement_1 = require("../../icc-api/model/AbstractFilterHealthElement");
16
+ /**
17
+ * Retrieves the HealthElements that have in their qualifiedLinks, for any type of qualification, a link
18
+ * with an association id equal to associationId.
19
+ * As HealthElement is an encryptable entity and this filter does not specify a data owner id, a special
20
+ * permission is required to use this filter.
21
+ */
22
+ class HealthElementByAssociationIdFilter extends AbstractFilterHealthElement_1.AbstractFilterHealthElement {
23
+ constructor(json) {
24
+ super(json);
25
+ this.$type = 'HealthElementByAssociationIdFilter';
26
+ Object.assign(this, json);
27
+ }
28
+ }
29
+ exports.HealthElementByAssociationIdFilter = HealthElementByAssociationIdFilter;
30
+ //# sourceMappingURL=HealthElementByAssociationIdFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HealthElementByAssociationIdFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/HealthElementByAssociationIdFilter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,iGAA6F;AAE7F;;;;;GAKG;AACH,MAAa,kCAAmC,SAAQ,yDAA2B;IAEjF,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,oCAAoC,CAAA;QAIlD,MAAM,CAAC,MAAM,CAAC,IAA0C,EAAE,IAAI,CAAC,CAAA;IACjE,CAAC;CAGF;AATD,gFASC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\n\n/**\n * Retrieves the HealthElements that have in their qualifiedLinks, for any type of qualification, a link\n * with an association id equal to associationId.\n * As HealthElement is an encryptable entity and this filter does not specify a data owner id, a special\n * permission is required to use this filter.\n */\nexport class HealthElementByAssociationIdFilter extends AbstractFilterHealthElement {\n $type: string = 'HealthElementByAssociationIdFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as HealthElementByAssociationIdFilter, json)\n }\n\n associationId?: string\n}\n"]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * iCure Data Stack API Documentation
3
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
4
+ *
5
+ * OpenAPI spec version: v1
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by the swagger code generator program.
9
+ * https://github.com/swagger-api/swagger-codegen.git
10
+ * Do not edit the class manually.
11
+ */
12
+ import { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement';
13
+ /**
14
+ * Retrieves the HealthElement ids that have in their qualifiedLinks at least one link towards one of
15
+ * linkedIds. If type is not null, then only links with that qualification type are considered.
16
+ * As HealthElement is an encryptable entity and this filter does not specify a data owner id, a special
17
+ * permission is required to use this filter.
18
+ */
19
+ export declare class HealthElementByQualifiedLinkFilter extends AbstractFilterHealthElement {
20
+ $type: string;
21
+ constructor(json: JSON | any);
22
+ linkedIds?: Array<string>;
23
+ type?: string;
24
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HealthElementByQualifiedLinkFilter = void 0;
4
+ /**
5
+ * iCure Data Stack API Documentation
6
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
7
+ *
8
+ * OpenAPI spec version: v1
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by the swagger code generator program.
12
+ * https://github.com/swagger-api/swagger-codegen.git
13
+ * Do not edit the class manually.
14
+ */
15
+ const AbstractFilterHealthElement_1 = require("../../icc-api/model/AbstractFilterHealthElement");
16
+ /**
17
+ * Retrieves the HealthElement ids that have in their qualifiedLinks at least one link towards one of
18
+ * linkedIds. If type is not null, then only links with that qualification type are considered.
19
+ * As HealthElement is an encryptable entity and this filter does not specify a data owner id, a special
20
+ * permission is required to use this filter.
21
+ */
22
+ class HealthElementByQualifiedLinkFilter extends AbstractFilterHealthElement_1.AbstractFilterHealthElement {
23
+ constructor(json) {
24
+ super(json);
25
+ this.$type = 'HealthElementByQualifiedLinkFilter';
26
+ Object.assign(this, json);
27
+ }
28
+ }
29
+ exports.HealthElementByQualifiedLinkFilter = HealthElementByQualifiedLinkFilter;
30
+ //# sourceMappingURL=HealthElementByQualifiedLinkFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HealthElementByQualifiedLinkFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/HealthElementByQualifiedLinkFilter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,iGAA6F;AAE7F;;;;;GAKG;AACH,MAAa,kCAAmC,SAAQ,yDAA2B;IAEjF,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,oCAAoC,CAAA;QAIlD,MAAM,CAAC,MAAM,CAAC,IAA0C,EAAE,IAAI,CAAC,CAAA;IACjE,CAAC;CAIF;AAVD,gFAUC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\n\n/**\n * Retrieves the HealthElement ids that have in their qualifiedLinks at least one link towards one of\n * linkedIds. If type is not null, then only links with that qualification type are considered.\n * As HealthElement is an encryptable entity and this filter does not specify a data owner id, a special\n * permission is required to use this filter.\n */\nexport class HealthElementByQualifiedLinkFilter extends AbstractFilterHealthElement {\n $type: string = 'HealthElementByQualifiedLinkFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as HealthElementByQualifiedLinkFilter, json)\n }\n\n linkedIds?: Array<string>\n type?: string\n}\n"]}
@@ -45,6 +45,7 @@ export * from './ContactByHcPartyTagCodeDateFilter';
45
45
  export * from './ContactByServiceIdsFilter';
46
46
  export * from './DeviceByHcPartyFilter';
47
47
  export * from './DeviceByIdsFilter';
48
+ export * from './HealthElementByAssociationIdFilter';
48
49
  export * from './HealthElementByHcPartyCodeFilter';
49
50
  export * from './HealthElementByHcPartyFilter';
50
51
  export * from './HealthElementByHcPartyIdentifiersFilter';
@@ -54,6 +55,7 @@ export * from './HealthElementByHcPartyStatusVersioningFilter';
54
55
  export * from './HealthElementByHcPartyTagCodeFilter';
55
56
  export * from './HealthElementByHcPartyTagFilter';
56
57
  export * from './HealthElementByIdsFilter';
58
+ export * from './HealthElementByQualifiedLinkFilter';
57
59
  export * from './HealthcarePartyByIdsFilter';
58
60
  export * from './HealthcarePartyByNameFilter';
59
61
  export * from './HealthcarePartyByTagCodeFilter';
@@ -49,6 +49,7 @@ __exportStar(require("./ContactByHcPartyTagCodeDateFilter"), exports);
49
49
  __exportStar(require("./ContactByServiceIdsFilter"), exports);
50
50
  __exportStar(require("./DeviceByHcPartyFilter"), exports);
51
51
  __exportStar(require("./DeviceByIdsFilter"), exports);
52
+ __exportStar(require("./HealthElementByAssociationIdFilter"), exports);
52
53
  __exportStar(require("./HealthElementByHcPartyCodeFilter"), exports);
53
54
  __exportStar(require("./HealthElementByHcPartyFilter"), exports);
54
55
  __exportStar(require("./HealthElementByHcPartyIdentifiersFilter"), exports);
@@ -58,6 +59,7 @@ __exportStar(require("./HealthElementByHcPartyStatusVersioningFilter"), exports)
58
59
  __exportStar(require("./HealthElementByHcPartyTagCodeFilter"), exports);
59
60
  __exportStar(require("./HealthElementByHcPartyTagFilter"), exports);
60
61
  __exportStar(require("./HealthElementByIdsFilter"), exports);
62
+ __exportStar(require("./HealthElementByQualifiedLinkFilter"), exports);
61
63
  __exportStar(require("./HealthcarePartyByIdsFilter"), exports);
62
64
  __exportStar(require("./HealthcarePartyByNameFilter"), exports);
63
65
  __exportStar(require("./HealthcarePartyByTagCodeFilter"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../icc-x-api/filters/filters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAiD;AAOjD,6DAAyD;AACzD,+CAA2C;AAC3C,yDAAqD;AACrD,uFAAmF;AACnF,yFAAqF;AACrF,+FAA2F;AAC3F,qFAAiF;AACjF,yGAAqG;AACrG,2FAAuF;AAEvF,uCAAsC;AACtC,qEAAiE;AACjE,uHAAmH;AACnH,6DAAyD;AACzD,uGAAmG;AAGnG,qEAAiE;AAoBjE,mDAAgC;AAChC,qDAAkC;AAClC,uDAAoC;AACpC,+DAA4C;AAC5C,wDAAqC;AACrC,mDAAgC;AAChC,qDAAkC;AAClC,oDAAiC;AACjC,s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E,UAAU;SACvB,CAAC,EACJ,IAAI,CAAC,KAAK,CACX,CACsB,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,GAAa;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,oBAAoB,CAAC,GAAG,EAAE,CAAC,IAAI,uCAAkB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAyB,CAAA;IACtI,CAAC;IAED,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,QAAQ,CAClB,IAAI,EACJ,IAAI,oBAAoB,CACtB,GAAG,EAAE,CACH,IAAI,iFAAuC,CAAC;YAC1C,iBAAiB,EAAE,IAAI,CAAC,KAAK;YAC7B,YAAY,EAAE,IAAI;SACnB,CAAC,EACJ,IAAI,CAAC,KAAK,CACX,CACsB,CAAA;IAC3B,CAAC;IAED,KAAK;;QACH,OAAO,CAAA,MAAA,IAAI,CAAC,cAAc,oDAAI,KAAI,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAA;IACtD,CAAC;CACF","sourcesContent":["import { ConstantFilter } from './ConstantFilter'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { AbstractFilterPatient } from '../../icc-api/model/AbstractFilterPatient'\nimport { AbstractFilterContact } from '../../icc-api/model/AbstractFilterContact'\nimport { AbstractFilterService } from '../../icc-api/model/AbstractFilterService'\nimport { Service } from '../../icc-api/model/Service'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { IntersectionFilter } from './IntersectionFilter'\nimport { UnionFilter } from './UnionFilter'\nimport { ComplementFilter } from './ComplementFilter'\nimport { PatientByHcPartyAndActiveFilter } from './PatientByHcPartyAndActiveFilter'\nimport { PatientByHcPartyAndAddressFilter } from './PatientByHcPartyAndAddressFilter'\nimport { PatientByHcPartyAndExternalIdFilter } from './PatientByHcPartyAndExternalIdFilter'\nimport { PatientByHcPartyAndSsinsFilter } from './PatientByHcPartyAndSsinsFilter'\nimport { PatientByHcPartyDateOfBirthBetweenFilter } from './PatientByHcPartyDateOfBirthBetweenFilter'\nimport { PatientByHcPartyDateOfBirthFilter } from './PatientByHcPartyDateOfBirthFilter'\n\nimport { add, format } from 'date-fns'\nimport { PatientByHcPartyFilter } from './PatientByHcPartyFilter'\nimport { PatientByHcPartyGenderEducationProfessionFilter } from './PatientByHcPartyGenderEducationProfessionFilter'\nimport { PatientByIdsFilter } from './PatientByIdsFilter'\nimport { PatientByHcPartyNameContainsFuzzyFilter } from './PatientByHcPartyNameContainsFuzzyFilter'\n\nimport GenderEnum = Patient.GenderEnum\nimport { ContactByHcPartyFilter } from './ContactByHcPartyFilter'\nimport { Device } from '../../icc-api/model/Device'\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\nimport { MaintenanceTask } from '../../icc-api/model/MaintenanceTask'\nimport { AbstractFilterMaintenanceTask } from '../../icc-api/model/AbstractFilterMaintenanceTask'\nimport { Code } from '../../icc-api/model/Code'\nimport { AbstractFilterCode } from '../../icc-api/model/AbstractFilterCode'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\nimport { Invoice } from '../../icc-api/model/Invoice'\nimport { AbstractFilterInvoice } from '../../icc-api/model/AbstractFilterInvoice'\nimport { User } from '../../icc-api/model/User'\nimport { AbstractFilterUser } from '../../icc-api/model/AbstractFilterUser'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { AbstractFilterHealthcareParty } from '../../icc-api/model/AbstractFilterHealthcareParty'\nimport { Tarification } from '../../icc-api/model/Tarification'\nimport { AbstractFilterPricing } from '../../icc-api/model/AbstractFilterPricing'\nimport { Insurance } from '../../icc-api/model/Insurance'\nimport { AbstractFilterInsurance } from '../../icc-api/model/AbstractFilterInsurance'\n\nexport * from './AllCodesFilter'\nexport * from './AllDevicesFilter'\nexport * from './AllDocumentsFilter'\nexport * from './AllHealthcarePartiesFilter'\nexport * from './AllInsurancesFilter'\nexport * from './AllUsersFilter'\nexport * from './AllPricingFilter'\nexport * from './CodeByIdsFilter'\nexport * from './CodeByRegionTypeCodeVersionFilter'\nexport * from './CodeByRegionTypeLabelLanguageFilter'\nexport * from './ComplementFilter'\nexport * from './ConstantFilter'\nexport * from './ContactByHcPartyFilter'\nexport * from './ContactByHcPartyPatientTagCodeDateFilter'\nexport * from './ContactByHcPartyTagCodeDateFilter'\nexport * from './ContactByServiceIdsFilter'\nexport * from './DeviceByHcPartyFilter'\nexport * from './DeviceByIdsFilter'\nexport * from './HealthElementByHcPartyCodeFilter'\nexport * from './HealthElementByHcPartyFilter'\nexport * from './HealthElementByHcPartyIdentifiersFilter'\nexport * from './HealthElementByHcPartyIdentifiersVersioningFilter'\nexport * from './HealthElementByHcPartySecretForeignKeysFilter'\nexport * from './HealthElementByHcPartyStatusVersioningFilter'\nexport * from './HealthElementByHcPartyTagCodeFilter'\nexport * from './HealthElementByHcPartyTagFilter'\nexport * from './HealthElementByIdsFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './HealthcarePartyByNameFilter'\nexport * from './HealthcarePartyByTagCodeFilter'\nexport * from './HealthcarePartyByIdentifiersFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './IntersectionFilter'\nexport * from './InvoiceByHcPartyCodeDateFilter'\nexport * from './PatientByHcPartyAndActiveFilter'\nexport * from './PatientByHcPartyAndAddressFilter'\nexport * from './PatientByHcPartyAndExternalIdFilter'\nexport * from './PatientByHcPartyAndIdentifiersFilter'\nexport * from './PatientByHcPartyAndSsinFilter'\nexport * from './PatientByHcPartyAndSsinsFilter'\nexport * from './PatientByHcPartyDateOfBirthBetweenFilter'\nexport * from './PatientByHcPartyDateOfBirthFilter'\nexport * from './PatientByHcPartyFilter'\nexport * from './PatientByHcPartyGenderEducationProfessionFilter'\nexport * from './PatientByHcPartyNameContainsFuzzyFilter'\nexport * from './PatientByHcPartyNameFilter'\nexport * from './PatientByIdsFilter'\nexport * from './ServiceByContactsAndSubcontactsFilter'\nexport * from './ServiceByHcPartyFilter'\nexport * from './ServiceByHcPartyIdentifiersFilter'\nexport * from './ServiceByHcPartyHealthElementIdsFilter'\nexport * from './ServiceByHcPartyTagCodeDateFilter'\nexport * from './ServiceByHcPartyCodePrefixFilter'\nexport * from './ServiceByHcPartyTagPrefixFilter'\nexport * from './ServiceByHcPartyMonthCodePrefixFilter'\nexport * from './ServiceByHcPartyMonthTagPrefixFilter'\nexport * from './ServiceByHcPartyPatientCodePrefixFilter'\nexport * from './ServiceByHcPartyPatientTagPrefixFilter'\nexport * from './ServiceByHcPartyCodesFilter'\nexport * from './ServiceByHcPartyTagCodesFilter'\nexport * from './ServiceByHcPartyPatientCodesFilter'\nexport * from './ServiceByHcPartyPatientTagCodesFilter'\nexport * from './ServiceByIdsFilter'\nexport * from './ServiceBySecretForeignKeys'\nexport * from './UnionFilter'\nexport * from './UserByIdsFilter'\nexport * from './MaintenanceTaskByHcPartyAndIdentifiersFilter'\nexport * from './MaintenanceTaskByHcPartyAndTypeFilter'\nexport * from './MaintenanceTaskByIdsFilter'\nexport * from './MaintenanceTaskAfterDateFilter'\nexport * from './TopicByHcPartyFilter'\nexport * from './TopicByParticipantFilter'\nexport * from './MessageByHcPartyFilter'\nexport * from './MessageByHcPartyTransportGuidFilter'\nexport * from './LatestMessageByHcPartyTransportGuidFilter'\n\nexport class Filter {\n public static patient(): PatientFilterBuilder {\n return new PatientFilterBuilder()\n }\n}\n\nexport type AbstractFilter<T> =\n | (T extends Patient\n ? AbstractFilterPatient\n : T extends Contact\n ? AbstractFilterContact\n : T extends Service\n ? AbstractFilterService\n : T extends HealthcareParty\n ? AbstractFilterHealthcareParty\n : T extends Device\n ? AbstractFilterDevice\n : T extends MaintenanceTask\n ? AbstractFilterMaintenanceTask\n : T extends Code\n ? AbstractFilterCode\n : T extends HealthElement\n ? AbstractFilterHealthElement\n : T extends Insurance\n ? AbstractFilterInsurance\n : T extends Invoice\n ? AbstractFilterInvoice\n : T extends User\n ? AbstractFilterUser\n : T extends Tarification\n ? AbstractFilterPricing\n : never)\n | ConstantFilter<T>\n | IntersectionFilter<T>\n | UnionFilter<T>\n | ComplementFilter<T>\n\nconst f: AbstractFilterContact = new ComplementFilter<Contact>(new ContactByHcPartyFilter({}), new ContactByHcPartyFilter({}))\n\nabstract class FilterBuilder<T> {\n // This is the current generator for the filter, when we call build(), filterProvider() is going to be called\n filterProvider?: () => AbstractFilter<T>\n // This is the method that is called each time we chain a filter to another filter. The default behaviour is to\n // return a FilterBuilder with the provider set to the last element in the chain, except when we use combination\n // operators like or()/and()/… . After one of those, the composer is set to a function that will return a FilterBuilder\n\n protected constructor(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ) {\n this.filterProvider = filterProvider\n composer && (this.composer = composer)\n }\n\n // that combines the existing filterBuilder with the filter definition we just added.\n composer: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T> = (\n thisFilterBuilder: FilterBuilder<T>,\n otherFilterBuilder: FilterBuilder<T>\n ) => otherFilterBuilder\n\n abstract build(): AbstractFilter<T>\n\n abstract clone(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ): FilterBuilder<T>\n\n listOf(elements: T[]): FilterBuilder<T> {\n return this.clone(() => new ConstantFilter<T>(elements) as AbstractFilter<T>)\n }\n\n /**\n * There are two ways of doing and, or, …\n *\n * 1) for (...) or (...) we use the syntax ... .or((builder) => builder...)\n * ex: youngerThan(65).or((b) => b.olderThan(18).and().gender(M)) means any gender < 65 or male > 18\n * 2) for ((...) or ...) we use the syntax ... .or().…\n * ex: youngerThan(65).or().olderThan(18).and().gender(M) means males between 18 and 65\n *\n * When 1) is used we do not have to wait for anything to provide a resolved builder that can later be combined with extra elements in the chain.\n * In other words, we can build the current filter chain up to the or/and/… and we can build what is inside the or/and/… brackets and we can set\n * the filterProvider of the returned Builder to () => UnionFilter([leftHand.build(), innerBrackets.build()]).\n *\n * When 2) is used, things get more tricky because we will have to do an or/and/… between what we have on the leftHand and with what we do not have\n * yet on the right hand. What we do in that situation is to set the filterProvider() to undefined because calling build() without having provided a\n * rightHand doesn't make sense. We set a composer that is going to be called the next time we chain a filter.\n *\n * @param filterBuilderFactory\n */\n\n and(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new IntersectionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n or(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new UnionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n minus(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new ComplementFilter<T>(leftHandFilter, rightHandFilter) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n private makeLazyLeftRightFilterBuilder(\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const leftHandFilterBuilder: FilterBuilder<T> = this\n const leftHandFilter = leftHandFilterBuilder.build() // Freeze the leftHand filter\n\n return leftHandFilterBuilder.filterProvider\n ? this.clone(\n undefined, //filter provider is indeterminate until we have performed a composition\n (unused: FilterBuilder<T>, rightHandFilterBuilder: FilterBuilder<T>) => {\n // because we freeze the leftHand in the state it is right now, we are not going to use its value when the composition occurs\n const rightHandFilter = rightHandFilterBuilder.build()\n\n return rightHandFilter\n ? this.clone(leftHandRightHandFiltersCombiner(leftHandFilter, rightHandFilter), rightHandFilterBuilder.composer)\n : rightHandFilterBuilder //Can this happen ?\n }\n )\n : this\n }\n\n private makeEagerLeftRightFilterBuilder(\n rightHandFilterBuilderFactory: (it: FilterBuilder<T>) => FilterBuilder<T>,\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n const rightHandFilterBuilder = rightHandFilterBuilderFactory(this)\n return this.filterProvider ? this.clone(leftHandRightHandFiltersCombiner(this.build(), rightHandFilterBuilder.build())) : this\n }\n}\n\nclass PatientFilterBuilder extends FilterBuilder<Patient> {\n hcpId?: string\n\n constructor(\n filterProvider?: () => AbstractFilter<Patient>,\n hcpId?: string,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ) {\n super(filterProvider, composer)\n this.hcpId = hcpId\n }\n\n clone(\n filterProvider?: () => AbstractFilter<Patient>,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ): FilterBuilder<Patient> {\n return new PatientFilterBuilder(filterProvider, this.hcpId, composer)\n }\n\n listOf(elements: Patient[]): PatientFilterBuilder {\n return new PatientFilterBuilder(() => new ConstantFilter<Patient>(elements) as AbstractFilter<Patient>)\n }\n\n and(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.and(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n or(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.or(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n minus(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.minus(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n forHcp(hcpId: string): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(this.filterProvider, hcpId)) as PatientFilterBuilder\n }\n\n all(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyFilter({ healthcarePartyId: this.hcpId }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n activePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: true }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n inactivePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: false }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n byAddress(searchString?: string, postalCode?: string, houseNumber?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndAddressFilter({\n healthcarePartyId: this.hcpId,\n searchString,\n postalCode,\n houseNumber,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withExternalId(externalId: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndExternalIdFilter({\n healthcarePartyId: this.hcpId,\n externalId: externalId,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withSsins(ssins: string[]): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndSsinsFilter({ healthcarePartyId: this.hcpId, ssins: ssins }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n withDateOfBirthBetween(from?: number, to?: number): PatientFilterBuilder {\n return this.composer(\n this,\n this.clone(\n () =>\n new PatientByHcPartyDateOfBirthBetweenFilter({\n healthcarePartyId: this.hcpId,\n minDateOfBirth: from,\n maxDateOfBirth: to,\n })\n )\n ) as PatientFilterBuilder\n }\n\n byDateOfBirth(dateOfBirth: number): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyDateOfBirthFilter({\n healthcarePartyId: this.hcpId,\n dateOfBirth: dateOfBirth,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n olderThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(10000101, parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')))\n }\n\n youngerThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')), 99991231)\n }\n\n byGenderEducationProfession(gender?: GenderEnum, education?: string, profession?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyGenderEducationProfessionFilter({\n healthcarePartyId: this.hcpId,\n gender: gender,\n education: education,\n profession: profession,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n byIds(ids: string[]): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(() => new PatientByIdsFilter({ ids: ids }), this.hcpId)) as PatientFilterBuilder\n }\n\n searchByName(name: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyNameContainsFuzzyFilter({\n healthcarePartyId: this.hcpId,\n searchString: name,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n build(): AbstractFilter<Patient> {\n return this.filterProvider?.() || this.all().build()\n }\n}\n"]}
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":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B,CAAC,QAAQ,CAAC,IAAA,iBAAM,EAAC,IAAA,cAAG,EAAC,IAAI,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;IAC9G,CAAC;IAED,2BAA2B,CAAC,MAAmB,EAAE,SAAkB,EAAE,UAAmB;QACtF,OAAO,IAAI,CAAC,QAAQ,CAClB,IAAI,EACJ,IAAI,oBAAoB,CACtB,GAAG,EAAE,CACH,IAAI,iGAA+C,CAAC;YAClD,iBAAiB,EAAE,IAAI,CAAC,KAAK;YAC7B,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,SAAS;YACpB,UAAU,EAAE,UAAU;SACvB,CAAC,EACJ,IAAI,CAAC,KAAK,CACX,CACsB,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,GAAa;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,oBAAoB,CAAC,GAAG,EAAE,CAAC,IAAI,uCAAkB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAyB,CAAA;IACtI,CAAC;IAED,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,QAAQ,CAClB,IAAI,EACJ,IAAI,oBAAoB,CACtB,GAAG,EAAE,CACH,IAAI,iFAAuC,CAAC;YAC1C,iBAAiB,EAAE,IAAI,CAAC,KAAK;YAC7B,YAAY,EAAE,IAAI;SACnB,CAAC,EACJ,IAAI,CAAC,KAAK,CACX,CACsB,CAAA;IAC3B,CAAC;IAED,KAAK;;QACH,OAAO,CAAA,MAAA,IAAI,CAAC,cAAc,oDAAI,KAAI,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAA;IACtD,CAAC;CACF","sourcesContent":["import { ConstantFilter } from './ConstantFilter'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { AbstractFilterPatient } from '../../icc-api/model/AbstractFilterPatient'\nimport { AbstractFilterContact } from '../../icc-api/model/AbstractFilterContact'\nimport { AbstractFilterService } from '../../icc-api/model/AbstractFilterService'\nimport { Service } from '../../icc-api/model/Service'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { IntersectionFilter } from './IntersectionFilter'\nimport { UnionFilter } from './UnionFilter'\nimport { ComplementFilter } from './ComplementFilter'\nimport { PatientByHcPartyAndActiveFilter } from './PatientByHcPartyAndActiveFilter'\nimport { PatientByHcPartyAndAddressFilter } from './PatientByHcPartyAndAddressFilter'\nimport { PatientByHcPartyAndExternalIdFilter } from './PatientByHcPartyAndExternalIdFilter'\nimport { PatientByHcPartyAndSsinsFilter } from './PatientByHcPartyAndSsinsFilter'\nimport { PatientByHcPartyDateOfBirthBetweenFilter } from './PatientByHcPartyDateOfBirthBetweenFilter'\nimport { PatientByHcPartyDateOfBirthFilter } from './PatientByHcPartyDateOfBirthFilter'\n\nimport { add, format } from 'date-fns'\nimport { PatientByHcPartyFilter } from './PatientByHcPartyFilter'\nimport { PatientByHcPartyGenderEducationProfessionFilter } from './PatientByHcPartyGenderEducationProfessionFilter'\nimport { PatientByIdsFilter } from './PatientByIdsFilter'\nimport { PatientByHcPartyNameContainsFuzzyFilter } from './PatientByHcPartyNameContainsFuzzyFilter'\n\nimport GenderEnum = Patient.GenderEnum\nimport { ContactByHcPartyFilter } from './ContactByHcPartyFilter'\nimport { Device } from '../../icc-api/model/Device'\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\nimport { MaintenanceTask } from '../../icc-api/model/MaintenanceTask'\nimport { AbstractFilterMaintenanceTask } from '../../icc-api/model/AbstractFilterMaintenanceTask'\nimport { Code } from '../../icc-api/model/Code'\nimport { AbstractFilterCode } from '../../icc-api/model/AbstractFilterCode'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\nimport { Invoice } from '../../icc-api/model/Invoice'\nimport { AbstractFilterInvoice } from '../../icc-api/model/AbstractFilterInvoice'\nimport { User } from '../../icc-api/model/User'\nimport { AbstractFilterUser } from '../../icc-api/model/AbstractFilterUser'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { AbstractFilterHealthcareParty } from '../../icc-api/model/AbstractFilterHealthcareParty'\nimport { Tarification } from '../../icc-api/model/Tarification'\nimport { AbstractFilterPricing } from '../../icc-api/model/AbstractFilterPricing'\nimport { Insurance } from '../../icc-api/model/Insurance'\nimport { AbstractFilterInsurance } from '../../icc-api/model/AbstractFilterInsurance'\n\nexport * from './AllCodesFilter'\nexport * from './AllDevicesFilter'\nexport * from './AllDocumentsFilter'\nexport * from './AllHealthcarePartiesFilter'\nexport * from './AllInsurancesFilter'\nexport * from './AllUsersFilter'\nexport * from './AllPricingFilter'\nexport * from './CodeByIdsFilter'\nexport * from './CodeByRegionTypeCodeVersionFilter'\nexport * from './CodeByRegionTypeLabelLanguageFilter'\nexport * from './ComplementFilter'\nexport * from './ConstantFilter'\nexport * from './ContactByHcPartyFilter'\nexport * from './ContactByHcPartyPatientTagCodeDateFilter'\nexport * from './ContactByHcPartyTagCodeDateFilter'\nexport * from './ContactByServiceIdsFilter'\nexport * from './DeviceByHcPartyFilter'\nexport * from './DeviceByIdsFilter'\nexport * from './HealthElementByAssociationIdFilter'\nexport * from './HealthElementByHcPartyCodeFilter'\nexport * from './HealthElementByHcPartyFilter'\nexport * from './HealthElementByHcPartyIdentifiersFilter'\nexport * from './HealthElementByHcPartyIdentifiersVersioningFilter'\nexport * from './HealthElementByHcPartySecretForeignKeysFilter'\nexport * from './HealthElementByHcPartyStatusVersioningFilter'\nexport * from './HealthElementByHcPartyTagCodeFilter'\nexport * from './HealthElementByHcPartyTagFilter'\nexport * from './HealthElementByIdsFilter'\nexport * from './HealthElementByQualifiedLinkFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './HealthcarePartyByNameFilter'\nexport * from './HealthcarePartyByTagCodeFilter'\nexport * from './HealthcarePartyByIdentifiersFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './IntersectionFilter'\nexport * from './InvoiceByHcPartyCodeDateFilter'\nexport * from './PatientByHcPartyAndActiveFilter'\nexport * from './PatientByHcPartyAndAddressFilter'\nexport * from './PatientByHcPartyAndExternalIdFilter'\nexport * from './PatientByHcPartyAndIdentifiersFilter'\nexport * from './PatientByHcPartyAndSsinFilter'\nexport * from './PatientByHcPartyAndSsinsFilter'\nexport * from './PatientByHcPartyDateOfBirthBetweenFilter'\nexport * from './PatientByHcPartyDateOfBirthFilter'\nexport * from './PatientByHcPartyFilter'\nexport * from './PatientByHcPartyGenderEducationProfessionFilter'\nexport * from './PatientByHcPartyNameContainsFuzzyFilter'\nexport * from './PatientByHcPartyNameFilter'\nexport * from './PatientByIdsFilter'\nexport * from './ServiceByContactsAndSubcontactsFilter'\nexport * from './ServiceByHcPartyFilter'\nexport * from './ServiceByHcPartyIdentifiersFilter'\nexport * from './ServiceByHcPartyHealthElementIdsFilter'\nexport * from './ServiceByHcPartyTagCodeDateFilter'\nexport * from './ServiceByHcPartyCodePrefixFilter'\nexport * from './ServiceByHcPartyTagPrefixFilter'\nexport * from './ServiceByHcPartyMonthCodePrefixFilter'\nexport * from './ServiceByHcPartyMonthTagPrefixFilter'\nexport * from './ServiceByHcPartyPatientCodePrefixFilter'\nexport * from './ServiceByHcPartyPatientTagPrefixFilter'\nexport * from './ServiceByHcPartyCodesFilter'\nexport * from './ServiceByHcPartyTagCodesFilter'\nexport * from './ServiceByHcPartyPatientCodesFilter'\nexport * from './ServiceByHcPartyPatientTagCodesFilter'\nexport * from './ServiceByIdsFilter'\nexport * from './ServiceBySecretForeignKeys'\nexport * from './UnionFilter'\nexport * from './UserByIdsFilter'\nexport * from './MaintenanceTaskByHcPartyAndIdentifiersFilter'\nexport * from './MaintenanceTaskByHcPartyAndTypeFilter'\nexport * from './MaintenanceTaskByIdsFilter'\nexport * from './MaintenanceTaskAfterDateFilter'\nexport * from './TopicByHcPartyFilter'\nexport * from './TopicByParticipantFilter'\nexport * from './MessageByHcPartyFilter'\nexport * from './MessageByHcPartyTransportGuidFilter'\nexport * from './LatestMessageByHcPartyTransportGuidFilter'\n\nexport class Filter {\n public static patient(): PatientFilterBuilder {\n return new PatientFilterBuilder()\n }\n}\n\nexport type AbstractFilter<T> =\n | (T extends Patient\n ? AbstractFilterPatient\n : T extends Contact\n ? AbstractFilterContact\n : T extends Service\n ? AbstractFilterService\n : T extends HealthcareParty\n ? AbstractFilterHealthcareParty\n : T extends Device\n ? AbstractFilterDevice\n : T extends MaintenanceTask\n ? AbstractFilterMaintenanceTask\n : T extends Code\n ? AbstractFilterCode\n : T extends HealthElement\n ? AbstractFilterHealthElement\n : T extends Insurance\n ? AbstractFilterInsurance\n : T extends Invoice\n ? AbstractFilterInvoice\n : T extends User\n ? AbstractFilterUser\n : T extends Tarification\n ? AbstractFilterPricing\n : never)\n | ConstantFilter<T>\n | IntersectionFilter<T>\n | UnionFilter<T>\n | ComplementFilter<T>\n\nconst f: AbstractFilterContact = new ComplementFilter<Contact>(new ContactByHcPartyFilter({}), new ContactByHcPartyFilter({}))\n\nabstract class FilterBuilder<T> {\n // This is the current generator for the filter, when we call build(), filterProvider() is going to be called\n filterProvider?: () => AbstractFilter<T>\n // This is the method that is called each time we chain a filter to another filter. The default behaviour is to\n // return a FilterBuilder with the provider set to the last element in the chain, except when we use combination\n // operators like or()/and()/… . After one of those, the composer is set to a function that will return a FilterBuilder\n\n protected constructor(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ) {\n this.filterProvider = filterProvider\n composer && (this.composer = composer)\n }\n\n // that combines the existing filterBuilder with the filter definition we just added.\n composer: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T> = (\n thisFilterBuilder: FilterBuilder<T>,\n otherFilterBuilder: FilterBuilder<T>\n ) => otherFilterBuilder\n\n abstract build(): AbstractFilter<T>\n\n abstract clone(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ): FilterBuilder<T>\n\n listOf(elements: T[]): FilterBuilder<T> {\n return this.clone(() => new ConstantFilter<T>(elements) as AbstractFilter<T>)\n }\n\n /**\n * There are two ways of doing and, or, …\n *\n * 1) for (...) or (...) we use the syntax ... .or((builder) => builder...)\n * ex: youngerThan(65).or((b) => b.olderThan(18).and().gender(M)) means any gender < 65 or male > 18\n * 2) for ((...) or ...) we use the syntax ... .or().…\n * ex: youngerThan(65).or().olderThan(18).and().gender(M) means males between 18 and 65\n *\n * When 1) is used we do not have to wait for anything to provide a resolved builder that can later be combined with extra elements in the chain.\n * In other words, we can build the current filter chain up to the or/and/… and we can build what is inside the or/and/… brackets and we can set\n * the filterProvider of the returned Builder to () => UnionFilter([leftHand.build(), innerBrackets.build()]).\n *\n * When 2) is used, things get more tricky because we will have to do an or/and/… between what we have on the leftHand and with what we do not have\n * yet on the right hand. What we do in that situation is to set the filterProvider() to undefined because calling build() without having provided a\n * rightHand doesn't make sense. We set a composer that is going to be called the next time we chain a filter.\n *\n * @param filterBuilderFactory\n */\n\n and(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new IntersectionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n or(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new UnionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n minus(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new ComplementFilter<T>(leftHandFilter, rightHandFilter) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n private makeLazyLeftRightFilterBuilder(\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const leftHandFilterBuilder: FilterBuilder<T> = this\n const leftHandFilter = leftHandFilterBuilder.build() // Freeze the leftHand filter\n\n return leftHandFilterBuilder.filterProvider\n ? this.clone(\n undefined, //filter provider is indeterminate until we have performed a composition\n (unused: FilterBuilder<T>, rightHandFilterBuilder: FilterBuilder<T>) => {\n // because we freeze the leftHand in the state it is right now, we are not going to use its value when the composition occurs\n const rightHandFilter = rightHandFilterBuilder.build()\n\n return rightHandFilter\n ? this.clone(leftHandRightHandFiltersCombiner(leftHandFilter, rightHandFilter), rightHandFilterBuilder.composer)\n : rightHandFilterBuilder //Can this happen ?\n }\n )\n : this\n }\n\n private makeEagerLeftRightFilterBuilder(\n rightHandFilterBuilderFactory: (it: FilterBuilder<T>) => FilterBuilder<T>,\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n const rightHandFilterBuilder = rightHandFilterBuilderFactory(this)\n return this.filterProvider ? this.clone(leftHandRightHandFiltersCombiner(this.build(), rightHandFilterBuilder.build())) : this\n }\n}\n\nclass PatientFilterBuilder extends FilterBuilder<Patient> {\n hcpId?: string\n\n constructor(\n filterProvider?: () => AbstractFilter<Patient>,\n hcpId?: string,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ) {\n super(filterProvider, composer)\n this.hcpId = hcpId\n }\n\n clone(\n filterProvider?: () => AbstractFilter<Patient>,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ): FilterBuilder<Patient> {\n return new PatientFilterBuilder(filterProvider, this.hcpId, composer)\n }\n\n listOf(elements: Patient[]): PatientFilterBuilder {\n return new PatientFilterBuilder(() => new ConstantFilter<Patient>(elements) as AbstractFilter<Patient>)\n }\n\n and(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.and(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n or(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.or(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n minus(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.minus(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n forHcp(hcpId: string): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(this.filterProvider, hcpId)) as PatientFilterBuilder\n }\n\n all(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyFilter({ healthcarePartyId: this.hcpId }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n activePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: true }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n inactivePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: false }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n byAddress(searchString?: string, postalCode?: string, houseNumber?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndAddressFilter({\n healthcarePartyId: this.hcpId,\n searchString,\n postalCode,\n houseNumber,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withExternalId(externalId: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndExternalIdFilter({\n healthcarePartyId: this.hcpId,\n externalId: externalId,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withSsins(ssins: string[]): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndSsinsFilter({ healthcarePartyId: this.hcpId, ssins: ssins }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n withDateOfBirthBetween(from?: number, to?: number): PatientFilterBuilder {\n return this.composer(\n this,\n this.clone(\n () =>\n new PatientByHcPartyDateOfBirthBetweenFilter({\n healthcarePartyId: this.hcpId,\n minDateOfBirth: from,\n maxDateOfBirth: to,\n })\n )\n ) as PatientFilterBuilder\n }\n\n byDateOfBirth(dateOfBirth: number): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyDateOfBirthFilter({\n healthcarePartyId: this.hcpId,\n dateOfBirth: dateOfBirth,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n olderThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(10000101, parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')))\n }\n\n youngerThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')), 99991231)\n }\n\n byGenderEducationProfession(gender?: GenderEnum, education?: string, profession?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyGenderEducationProfessionFilter({\n healthcarePartyId: this.hcpId,\n gender: gender,\n education: education,\n profession: profession,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n byIds(ids: string[]): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(() => new PatientByIdsFilter({ ids: ids }), this.hcpId)) as PatientFilterBuilder\n }\n\n searchByName(name: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyNameContainsFuzzyFilter({\n healthcarePartyId: this.hcpId,\n searchString: name,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n build(): AbstractFilter<Patient> {\n return this.filterProvider?.() || this.all().build()\n }\n}\n"]}
@@ -497,7 +497,10 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
497
497
  */
498
498
  getEncryptionKeysOf(entity: models.Patient): Promise<string[]>;
499
499
  /**
500
- * Merge two patients into one. This method performs the following operations:
500
+ * Merge two patients into one.
501
+ * Both the from and mergedInto patient must be decrypted patients, otherwise the method may have unexpected behavior.
502
+ *
503
+ * This method performs the following operations:
501
504
  * - The `from` patient will be soft-deleted, and it will point to the `into` patient. Only the `deletionDate` and `mergeToPatientId` fields of the
502
505
  * patient will be changed (automatically by this method). Note that the value of {@link from} is only used to verify that the client is aware of
503
506
  * the last version of the `from` patient: any changes to its content and/or metadata compared to what is actually stored in the database will be
@@ -1017,7 +1017,10 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
1017
1017
  return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName_1.EntityWithDelegationTypeName.Patient }, undefined);
1018
1018
  }
1019
1019
  /**
1020
- * Merge two patients into one. This method performs the following operations:
1020
+ * Merge two patients into one.
1021
+ * Both the from and mergedInto patient must be decrypted patients, otherwise the method may have unexpected behavior.
1022
+ *
1023
+ * This method performs the following operations:
1021
1024
  * - The `from` patient will be soft-deleted, and it will point to the `into` patient. Only the `deletionDate` and `mergeToPatientId` fields of the
1022
1025
  * patient will be changed (automatically by this method). Note that the value of {@link from} is only used to verify that the client is aware of
1023
1026
  * the last version of the `from` patient: any changes to its content and/or metadata compared to what is actually stored in the database will be
@@ -1059,7 +1062,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
1059
1062
  });
1060
1063
  return __awaiter(this, void 0, void 0, function* () {
1061
1064
  const encryptedMerged = (yield this.encryptAs(yield this.dataOwnerApi.getCurrentDataOwnerId(), [mergedInto]))[0];
1062
- const merged = yield _super.baseMergePatients.call(this, from.id, from.rev, encryptedMerged);
1065
+ const merged = yield _super.baseMergePatients.call(this, from.id, from.rev, encryptedMerged, true);
1063
1066
  return (yield this.tryDecryptOrReturnOriginal([merged]))[0].entity;
1064
1067
  });
1065
1068
  }