@icure/api 8.0.78 → 8.1.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.
- package/icc-x-api/crypto/ExchangeKeysManager.d.ts +1 -0
- package/icc-x-api/crypto/ExchangeKeysManager.js +26 -16
- package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtils.d.ts +47 -2
- package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +8 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +81 -2
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
- package/icc-x-api/crypto/SecretIdUseOption.d.ts +60 -0
- package/icc-x-api/crypto/SecretIdUseOption.js +60 -0
- package/icc-x-api/crypto/SecretIdUseOption.js.map +1 -0
- package/icc-x-api/icc-accesslog-x-api.d.ts +2 -1
- package/icc-x-api/icc-accesslog-x-api.js +2 -3
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +26 -3
- package/icc-x-api/icc-calendar-item-x-api.js +51 -16
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +2 -1
- package/icc-x-api/icc-classification-x-api.js +2 -3
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +3 -2
- package/icc-x-api/icc-contact-x-api.js +5 -8
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +1 -7
- package/icc-x-api/icc-crypto-x-api.js +1 -8
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +2 -1
- package/icc-x-api/icc-document-x-api.js +3 -6
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +2 -1
- package/icc-x-api/icc-form-x-api.js +2 -3
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +3 -2
- package/icc-x-api/icc-helement-x-api.js +5 -8
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.d.ts +2 -1
- package/icc-x-api/icc-invoice-x-api.js +2 -3
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +2 -1
- package/icc-x-api/icc-message-x-api.js +2 -3
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.js +4 -6
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.d.ts +2 -1
- package/icc-x-api/icc-topic-x-api.js +3 -2
- package/icc-x-api/icc-topic-x-api.js.map +1 -1
- package/icc-x-api/index.js +1 -3
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/confidential-entities-test.js +49 -6
- package/test/icc-x-api/confidential-entities-test.js.map +1 -1
- package/test/icc-x-api/crypto/cryptoTest.js +5 -3
- package/test/icc-x-api/crypto/cryptoTest.js.map +1 -1
- package/test/icc-x-api/crypto/full-crypto-test.js +0 -2
- package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -1
- package/test/icc-x-api/crypto/shamir.js +3 -1
- package/test/icc-x-api/crypto/shamir.js.map +1 -1
- package/test/icc-x-api/diocancaro.d.ts +1 -0
- package/test/icc-x-api/diocancaro.js +75 -0
- package/test/icc-x-api/diocancaro.js.map +1 -0
- package/test/icc-x-api/icc-calendar-item-x-api.js +1 -1
- package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/test/icc-x-api/icc-contact-x-api.js +4 -2
- package/test/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/test/icc-x-api/icc-helement-x-api-test.js +3 -1
- package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -1
- package/icc-x-api/crypto/ConfidentialEntities.d.ts +0 -64
- package/icc-x-api/crypto/ConfidentialEntities.js +0 -112
- package/icc-x-api/crypto/ConfidentialEntities.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confidential-entities-test.js","sourceRoot":"","sources":["../../../test/icc-x-api/confidential-entities-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAoH;AACpH,mDAAmE;AACnE,+BAA6B;AAC7B,4BAAyB;AAEzB,+CAA8D;AAE9D,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAI,GAAa,CAAA;AAEjB,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,MAAM,CAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAA,uBAAe,GAAE,CAAC,CAAA;QACpD,CAAC;KAAA,CAAC,CAAA;IAEF,EAAE,CAAC,6GAA6G,EAAE,GAAS,EAAE;QAC3H,+DAA+D;QAC/D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,mCAAsB,EAAC,GAAI,CAAC,CAAA;QAErI,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QACpG,MAAM,eAAe,GAAG,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,wBAAwB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAE,CAAA;QAE7F,MAAM,yBAAyB,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,kBAAkB,CAAC,eAAe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QACvH,IAAA,aAAM,EAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,EAAE,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAA;QACxG,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,CAAC,CAAA;QAC1F,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,iBAAiB,CAAC,EAAE,CAAC,CAAA;QAChG,IAAA,aAAM,EAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,CAAA;QACxD,IAAA,aAAM,EAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAA;QAE9D,MAAM,SAAS,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;IACpD,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { createHcpHierarchyApis, getEnvironmentInitializer, isLiteTest, setLocalStorage } from '../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { expect } from 'chai'\nimport 'isomorphic-fetch'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport { EntityWithDelegationTypeName } from '../../icc-x-api'\n\nsetLocalStorage(fetch)\n\nvar env: TestVars\n\ndescribe('test confidential helement', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('confidential entity should be accessible only to user, non confidential should be accessible also to parent', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!)\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const patientSecretIdsForParent = await parentApi.patientApi.decryptSecretIdsOf(modifiedPatient)\n const patientSecretIdsForChild = await childApi.patientApi.decryptSecretIdsOf(modifiedPatient)\n expect(patientSecretIdsForParent).to.have.length(1)\n expect(patientSecretIdsForChild).to.have.length(2)\n expect(patientSecretIdsForChild).to.contain(patientSecretIdsForParent[0])\n expect(patientSecretIdsForChild[0]).to.not.eq(patientSecretIdsForChild[1])\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(childUser, modifiedPatient, { descr: 'Confidential info' }, { confidential: true })\n )\n expect(confidentialHe.descr).to.eq('Confidential info')\n const nonConfidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(childUser, modifiedPatient, { descr: 'Non confidential info' }, { confidential: false })\n )\n expect(nonConfidentialHe.descr).to.eq('Non confidential info')\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsUser.length).to.equal(2, 'Child should see confidential and non-confidential data created by him')\n expect(retrievedHesAsUser.map((he) => he.id)).to.have.members([confidentialHe.id, nonConfidentialHe.id])\n const retrievedConfidential = retrievedHesAsUser.find((he) => he.id === confidentialHe.id)\n const retrievedNonConfidential = retrievedHesAsUser.find((he) => he.id === nonConfidentialHe.id)\n expect(retrievedConfidential).to.deep.eq(confidentialHe)\n expect(retrievedNonConfidential).to.deep.eq(nonConfidentialHe)\n\n const retrievedHesAsParent = await parentApi.healthcareElementApi.findBy(parentUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsParent.length).to.equal(1, 'Parent should not see confidential data, but only non-confidential data created by child')\n expect(retrievedHesAsParent[0]).to.deep.eq(nonConfidentialHe)\n let failedToRetrieve = false\n try {\n await parentApi.healthcareElementApi.getHealthElementWithUser(parentUser, confidentialHe.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'Parent should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await parentApi.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialHe!, type: EntityWithDelegationTypeName.HealthElement }, undefined)\n ).to.have.length(0)\n })\n\n it('creation of confidential data should fail if no confidential secret id is available for patient', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!)\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n let failed = false\n try {\n await childApi.healthcareElementApi.newInstance(childUser, pat, { descr: 'Confidential info' }, { confidential: true })\n } catch {\n failed = true\n }\n expect(failed).to.equal(true, 'Creation of confidential data should fail if no confidential secret id is available for patient')\n })\n\n it('creation of non-confidential data should fail if no secret id is available for parent', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!, false)\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n let failed = false\n try {\n await childApi.healthcareElementApi.newInstance(childUser, pat, { descr: 'Confidential info' }, { confidential: false })\n } catch {\n failed = true\n }\n expect(failed).to.equal(true, 'Creation of confidential data should fail if no non-confidential secret id is available for patient')\n })\n\n it('confidential or non-confidential is irrelevant if api is initialised without parent key initialisation: data created by user is only accessible to him', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!, false, true)\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(childUser, pat, { descr: 'Confidential info' }, { confidential: true })\n )\n expect(confidentialHe.descr).to.eq('Confidential info')\n const nonConfidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(childUser, pat, { descr: 'Non confidential info' }, { confidential: false })\n )\n expect(nonConfidentialHe.descr).to.eq('Non confidential info')\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, pat)\n expect(retrievedHesAsUser.length).to.equal(2, 'Child should see confidential and non-confidential data created by him')\n expect(retrievedHesAsUser.map((he) => he.id)).to.have.members([confidentialHe.id, nonConfidentialHe.id])\n const retrievedConfidential = retrievedHesAsUser.find((he) => he.id === confidentialHe.id)\n const retrievedNonConfidential = retrievedHesAsUser.find((he) => he.id === nonConfidentialHe.id)\n expect(retrievedConfidential).to.deep.eq(confidentialHe)\n expect(retrievedNonConfidential).to.deep.eq(nonConfidentialHe)\n\n await parentApi.patientApi.decryptSecretIdsOf(pat)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"confidential-entities-test.js","sourceRoot":"","sources":["../../../test/icc-x-api/confidential-entities-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAoH;AACpH,mDAAmE;AACnE,+BAA6B;AAC7B,4BAAyB;AAEzB,+CAA8D;AAC9D,gFAA4E;AAC5E,IAAO,kBAAkB,GAAG,qCAAiB,CAAC,kBAAkB,CAAA;AAChE,IAAO,sBAAsB,GAAG,qCAAiB,CAAC,sBAAsB,CAAA;AACxE,mCAAmC;AACnC,IAAO,kBAAkB,GAAG,qCAAiB,CAAC,kBAAkB,CAAA;AACh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,CAAC,CAAA","sourcesContent":["import { createHcpHierarchyApis, getEnvironmentInitializer, isLiteTest, setLocalStorage } from '../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { expect } from 'chai'\nimport 'isomorphic-fetch'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport { EntityWithDelegationTypeName } from '../../icc-x-api'\nimport { SecretIdUseOption } from '../../icc-x-api/crypto/SecretIdUseOption'\nimport UseAnyConfidential = SecretIdUseOption.UseAnyConfidential\nimport UseAnySharedWithParent = SecretIdUseOption.UseAnySharedWithParent\nimport { randomUUID } from 'crypto'\nimport UseAllConfidential = SecretIdUseOption.UseAllConfidential\nimport UseAllSharedWithParent = SecretIdUseOption.UseAllSharedWithParent\nimport UseNone = SecretIdUseOption.UseNone\n\nsetLocalStorage(fetch)\n\nvar env: TestVars\n\ndescribe('test confidential helement', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('confidential entity should be accessible only to user, non confidential should be accessible also to parent', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!)\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const patientSecretIdsForParent = await parentApi.patientApi.decryptSecretIdsOf(modifiedPatient)\n const patientSecretIdsForChild = await childApi.patientApi.decryptSecretIdsOf(modifiedPatient)\n expect(patientSecretIdsForParent).to.have.length(1)\n expect(patientSecretIdsForChild).to.have.length(2)\n expect(patientSecretIdsForChild).to.contain(patientSecretIdsForParent[0])\n expect(patientSecretIdsForChild[0]).to.not.eq(patientSecretIdsForChild[1])\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n expect(confidentialHe.descr).to.eq('Confidential info')\n const nonConfidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Non confidential info' },\n { sfkOption: UseAnySharedWithParent }\n )\n )\n expect(nonConfidentialHe.descr).to.eq('Non confidential info')\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsUser.length).to.equal(2, 'Child should see confidential and non-confidential data created by him')\n expect(retrievedHesAsUser.map((he) => he.id)).to.have.members([confidentialHe.id, nonConfidentialHe.id])\n const retrievedConfidential = retrievedHesAsUser.find((he) => he.id === confidentialHe.id)\n const retrievedNonConfidential = retrievedHesAsUser.find((he) => he.id === nonConfidentialHe.id)\n expect(retrievedConfidential).to.deep.eq(confidentialHe)\n expect(retrievedNonConfidential).to.deep.eq(nonConfidentialHe)\n\n const retrievedHesAsParent = await parentApi.healthcareElementApi.findBy(parentUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsParent.length).to.equal(1, 'Parent should not see confidential data, but only non-confidential data created by child')\n expect(retrievedHesAsParent[0]).to.deep.eq(nonConfidentialHe)\n let failedToRetrieve = false\n try {\n await parentApi.healthcareElementApi.getHealthElementWithUser(parentUser, confidentialHe.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'Parent should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await parentApi.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialHe!, type: EntityWithDelegationTypeName.HealthElement }, undefined)\n ).to.have.length(0)\n })\n\n it('creation of confidential data should fail if no confidential secret id is available for patient', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!)\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n let failed = false\n try {\n await childApi.healthcareElementApi.newInstance(\n childUser,\n pat,\n { descr: 'Confidential info' },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n } catch {\n failed = true\n }\n expect(failed).to.equal(true, 'Creation of confidential data should fail if no confidential secret id is available for patient')\n })\n\n it('creation of non-confidential data should fail if no secret id is available for parent', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!, false)\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n let failed = false\n try {\n await childApi.healthcareElementApi.newInstance(childUser, pat, { descr: 'Confidential info' }, { sfkOption: UseAnySharedWithParent })\n } catch {\n failed = true\n }\n expect(failed).to.equal(true, 'Creation of confidential data should fail if no non-confidential secret id is available for patient')\n })\n\n it('confidential or non-confidential is irrelevant if api is initialised without parent key initialisation: data created by user is only accessible to him', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!, false, true)\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(\n childUser,\n pat,\n { descr: 'Confidential info' },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n expect(confidentialHe.descr).to.eq('Confidential info')\n const nonConfidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(childUser, pat, { descr: 'Non confidential info' }, { sfkOption: UseAnySharedWithParent })\n )\n expect(nonConfidentialHe.descr).to.eq('Non confidential info')\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, pat)\n expect(retrievedHesAsUser.length).to.equal(2, 'Child should see confidential and non-confidential data created by him')\n expect(retrievedHesAsUser.map((he) => he.id)).to.have.members([confidentialHe.id, nonConfidentialHe.id])\n const retrievedConfidential = retrievedHesAsUser.find((he) => he.id === confidentialHe.id)\n const retrievedNonConfidential = retrievedHesAsUser.find((he) => he.id === nonConfidentialHe.id)\n expect(retrievedConfidential).to.deep.eq(confidentialHe)\n expect(retrievedNonConfidential).to.deep.eq(nonConfidentialHe)\n\n await parentApi.patientApi.decryptSecretIdsOf(pat)\n })\n\n it('sfk confidential option should use one or all secret ids as requested', async () => {\n // Use only the top of the hierarchy for simplicity of the test\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!)\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n let modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n modifiedPatient = await childApi.patientApi.shareWith(childUser.healthcarePartyId!, modifiedPatient, [randomUUID()])\n modifiedPatient = await childApi.patientApi.shareWith(parentUser.healthcarePartyId!, modifiedPatient, [randomUUID()])\n\n const patientSecretIdsForParent = await parentApi.patientApi.decryptSecretIdsOf(modifiedPatient)\n const patientSecretIdsForChild = await childApi.patientApi.decryptSecretIdsOf(modifiedPatient)\n expect(patientSecretIdsForParent).to.have.length(2)\n expect(patientSecretIdsForChild).to.have.length(4)\n const confidentialSecretIds = patientSecretIdsForChild.filter((x) => !patientSecretIdsForParent.includes(x))\n const nonConfidentialSecretIds = patientSecretIdsForParent\n expect(confidentialSecretIds).to.have.length(2)\n expect(await childApi.patientApi.decryptConfidentialSecretIdsOf(modifiedPatient)).to.have.members(confidentialSecretIds)\n expect(await childApi.patientApi.decryptNonConfidentialSecretIdsOf(modifiedPatient)).to.have.members(nonConfidentialSecretIds)\n const anyConfidentialHe = await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n expect(anyConfidentialHe.secretForeignKeys).to.have.length(1)\n expect(confidentialSecretIds).to.include(anyConfidentialHe.secretForeignKeys![0])\n const allConfidentialHe = await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAllConfidential, ignoreAutoDelegations: true }\n )\n expect(allConfidentialHe.secretForeignKeys).to.have.members(confidentialSecretIds)\n const anyNonConfidentialHe = await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAnySharedWithParent }\n )\n expect(anyNonConfidentialHe.secretForeignKeys).to.have.length(1)\n expect(nonConfidentialSecretIds).to.include(anyNonConfidentialHe.secretForeignKeys![0])\n const allNonConfidentialHe = await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAllSharedWithParent }\n )\n expect(allNonConfidentialHe.secretForeignKeys).to.have.members(confidentialSecretIds)\n })\n\n it('Should allow creation of half-links by using no sfk', async () => {\n const { parentApi: childApi, parentUser: childUser, grandApi: parentApi, grandUser: parentUser } = await createHcpHierarchyApis(env!)\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const halfLinkedHe = await childApi.healthcareElementApi.newInstance(\n childUser,\n pat,\n { descr: 'Confidential info' },\n { sfkOption: UseNone, ignoreAutoDelegations: true }\n )\n expect(halfLinkedHe.secretForeignKeys).to.have.length(0)\n const decryptedPatientId = await childApi.healthcareElementApi.decryptPatientIdOf(halfLinkedHe)\n expect(decryptedPatientId).to.have.length(1)\n expect(decryptedPatientId[0]).to.equal(pat.id)\n })\n})\n"]}
|
|
@@ -18,6 +18,8 @@ const test_utils_1 = require("../../utils/test_utils");
|
|
|
18
18
|
const types_1 = require("@icure/test-setup/types");
|
|
19
19
|
const icc_x_api_1 = require("../../../icc-x-api");
|
|
20
20
|
var initApi = test_utils_1.TestUtils.initApi;
|
|
21
|
+
const SecretIdUseOption_1 = require("../../../icc-x-api/crypto/SecretIdUseOption");
|
|
22
|
+
var UseAnyConfidential = SecretIdUseOption_1.SecretIdUseOption.UseAnyConfidential;
|
|
21
23
|
(0, chai_1.use)(require('chai-as-promised'));
|
|
22
24
|
let env;
|
|
23
25
|
(0, test_utils_1.setLocalStorage)(fetch);
|
|
@@ -216,7 +218,7 @@ describe('test that confidential helement information cannot be retrieved at MH
|
|
|
216
218
|
];
|
|
217
219
|
const pat = yield childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' });
|
|
218
220
|
const modifiedPatient = (yield childApi.patientApi.initConfidentialSecretId(pat, childUser));
|
|
219
|
-
const confidentialHe = yield childApi.healthcareElementApi.createHealthElementWithUser(childUser, yield childApi.healthcareElementApi.newInstance(childUser, modifiedPatient, { descr: 'Confidential info' }, {
|
|
221
|
+
const confidentialHe = yield childApi.healthcareElementApi.createHealthElementWithUser(childUser, yield childApi.healthcareElementApi.newInstance(childUser, modifiedPatient, { descr: 'Confidential info' }, { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }));
|
|
220
222
|
const retrievedHesAsUser = yield childApi.healthcareElementApi.findBy(childUser.healthcarePartyId, modifiedPatient);
|
|
221
223
|
(0, chai_1.expect)(retrievedHesAsUser.length).to.equal(1, 'User should see its confidential data');
|
|
222
224
|
for (const { api, user } of others) {
|
|
@@ -255,8 +257,8 @@ describe('test that confidential contact information cannot be retrieved at MH l
|
|
|
255
257
|
];
|
|
256
258
|
const pat = yield childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' });
|
|
257
259
|
const modifiedPatient = (yield childApi.patientApi.initConfidentialSecretId(pat, childUser));
|
|
258
|
-
const confidentialCtc = yield childApi.contactApi.createContactWithUser(childUser, yield childApi.contactApi.newInstance(childUser, modifiedPatient, { descr: 'Confidential info', services: [], subContacts: [] }, {
|
|
259
|
-
yield childApi.contactApi.createContactWithUser(childUser, yield childApi.contactApi.newInstance(childUser, modifiedPatient, { descr: 'Non confidential info', services: [], subContacts: [] }
|
|
260
|
+
const confidentialCtc = yield childApi.contactApi.createContactWithUser(childUser, yield childApi.contactApi.newInstance(childUser, modifiedPatient, { descr: 'Confidential info', services: [], subContacts: [] }, { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }));
|
|
261
|
+
yield childApi.contactApi.createContactWithUser(childUser, yield childApi.contactApi.newInstance(childUser, modifiedPatient, { descr: 'Non confidential info', services: [], subContacts: [] }));
|
|
260
262
|
const retrievedCtcsAsUser = yield childApi.contactApi.findBy(childUser.healthcarePartyId, modifiedPatient);
|
|
261
263
|
(0, chai_1.expect)(retrievedCtcsAsUser.length).to.equal(2, 'User should see its confidential data');
|
|
262
264
|
for (const { api, user } of others) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoTest.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/cryptoTest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,8CAAgD;AAChD,4BAAyB;AACzB,+BAA6C;AAC7C,iBAAc;AAEd,4DAAwD;AACxD,uDAQ+B;AAC/B,mDAAmE;AACnE,kDAA8F;AAC9F,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAElC,IAAA,UAAO,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAEpC,IAAI,GAAa,CAAA;AAEjB,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,MAAM,CAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,GA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AAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CACzG,CAAA;QACD,MAAM,gBAAgB,GAAG,MAAM,IAAI,uBAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAG,CAAC,CAAA;QAC1I,MAAM,IAAA,aAAM,EAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;aAC1I,QAAQ,CAAA;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;QACrI,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;IACvH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { IccPatientApi } from '../../../icc-api'\nimport 'isomorphic-fetch'\nimport { expect, use as chaiUse } from 'chai'\nimport 'mocha'\n\nimport { Patient } from '../../../icc-api/model/Patient'\nimport {\n createHcpHierarchyApis,\n createNewHcpApi,\n getEnvironmentInitializer,\n hcp1Username,\n isLiteTest,\n setLocalStorage,\n TestUtils,\n} from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { BasicAuthenticationProvider, EntityWithDelegationTypeName } from '../../../icc-x-api'\nimport initApi = TestUtils.initApi\n\nchaiUse(require('chai-as-promised'))\n\nlet env: TestVars\n\nsetLocalStorage(fetch)\n\ndescribe('Create a patient from scratch', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should create a patient in the database', async () => {\n const api = await initApi(env, hcp1Username)\n const user = await api.userApi.getCurrentUser()\n\n const note = 'A secured note that is encrypted'\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(\n user,\n new Patient({\n lastName: 'Biden',\n firstName: 'Joe',\n note,\n })\n )\n )\n expect(patient.note).to.equal(note)\n\n console.log(\n `Created patient (decrypted): ${patient.id}: ${patient.firstName} ${patient.lastName} [note:${patient.note}, encryptedSelf:${patient.encryptedSelf}]`\n )\n\n const fetched = await api.patientApi.getPatientWithUser(user, patient.id)\n console.log(\n `Fetched patient (decrypted): ${fetched.id}: ${fetched.firstName} ${fetched.lastName} [note:${fetched.note}, encryptedSelf:${fetched.encryptedSelf}]`\n )\n expect(fetched.id).to.equal(patient.id)\n expect(fetched.note).to.equal(note)\n\n const fetchedWithoutDecryption = await new IccPatientApi(\n env.iCureUrl,\n {},\n new BasicAuthenticationProvider(env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password),\n fetch as any\n ).getPatient(patient.id)\n\n console.log(\n `Fetched patient (encrypted):${fetchedWithoutDecryption.id}: ${fetchedWithoutDecryption.firstName} ${fetchedWithoutDecryption.lastName} [note: ${fetchedWithoutDecryption.note}]`\n )\n expect(fetchedWithoutDecryption.id).to.equal(patient.id)\n expect(fetchedWithoutDecryption.note).to.be.undefined\n })\n})\n\ndescribe('Init confidential delegation in patient', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a patient with a confidential delegation', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const note = 'Some note'\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe', note })\n )\n\n // All parents and siblings should have access to the decrypted data and to the initial secret id\n expect(await childApi.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n const originalSecretId = (await childApi.patientApi.decryptSecretIdsOf(pat))[0]\n for (const { api, user } of others) {\n expect(await api.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await api.patientApi.decryptSecretIdsOf(pat))[0]).to.equal(originalSecretId)\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // Initially there shouldn't be any secret confidential secret id\n expect(await childApi.patientApi.decryptConfidentialSecretIdsOf(pat)).to.be.empty\n\n // Now create a confidential delegation\n const patWithConfidential = await childApi.patientApi.initConfidentialSecretId(pat, childUser)\n\n // Confidential secret id should be different from the original secret id\n const confidentialDelegationKeys = await childApi.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)\n const nonConfidentialDelegationKeys = await childApi.patientApi.decryptNonConfidentialSecretIdsOf(patWithConfidential)\n expect(confidentialDelegationKeys).to.have.length(1)\n expect(nonConfidentialDelegationKeys).to.have.length(1)\n expect(confidentialDelegationKeys[0]).to.not.equal(nonConfidentialDelegationKeys)\n expect(nonConfidentialDelegationKeys[0]).to.equal(originalSecretId)\n\n // Child has access to confidential and not confidential secret ids.\n const childSecretIds = await childApi.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(childSecretIds).to.have.length(2)\n expect(childSecretIds).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIds).to.have.contain(confidentialDelegationKeys[0])\n\n // All parents and siblings should have access to the decrypted data even after initialising confidential delegations...\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n for (const { api, user } of others) {\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // ...but not to the confidential secret id\n for (const { api } of others) {\n const secretIds = await api.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(secretIds).to.have.length(1)\n expect(secretIds).to.contain(nonConfidentialDelegationKeys[0])\n }\n\n // If a secret delegation is already available there is no need to create a new one\n const patWithConfidentialAgain = await childApi.patientApi.initConfidentialSecretId(patWithConfidential, childUser)\n expect(patWithConfidentialAgain.rev).to.equal(patWithConfidentialAgain.rev)\n expect(await childApi.patientApi.decryptSecretIdsOf(patWithConfidentialAgain)).to.have.length(2)\n\n // Different users will have different confidential secret ids...\n expect(await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)).to.be.empty\n const patWithMoreConfidentialIds = await child2Api.patientApi.initConfidentialSecretId(patWithConfidential, child2User)\n\n // ...child continues to know the same secret ids...\n const childSecretIdsRepeat = await childApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n expect(childSecretIdsRepeat).to.have.length(2)\n expect(childSecretIdsRepeat).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIdsRepeat).to.have.contain(confidentialDelegationKeys[0])\n\n // ...but child2 now also knows a different secret id...\n const child2secretIds = await child2Api.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n const child2confidential = await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithMoreConfidentialIds)\n expect(child2confidential).to.have.length(1)\n expect(child2confidential[0]).to.not.equal(confidentialDelegationKeys[0])\n expect(child2confidential[0]).to.not.equal(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.have.length(2)\n expect(child2secretIds).to.contain(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.contain(child2confidential[0])\n\n // ...and their parents still don't know them\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n })\n})\n\ndescribe('Test that contact information can be decrypted', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a contact with decrypted information', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const allApis = [\n { api: childApi, user: childUser },\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n const idFlat = childApi.cryptoApi.primitives.randomUuid()\n const idCompound = childApi.cryptoApi.primitives.randomUuid()\n const idSalut = childApi.cryptoApi.primitives.randomUuid()\n const idAtoi = childApi.cryptoApi.primitives.randomUuid()\n const instance = await childApi.contactApi.newInstance(childUser, pat, {\n services: [\n {\n id: idFlat,\n content: { fr: { stringValue: 'Salut' }, nl: { stringValue: 'Halo' } },\n },\n {\n id: idCompound,\n content: {\n fr: {\n compoundValue: [\n { id: idSalut, content: { fr: { stringValue: 'Salut' } } },\n { id: idAtoi, content: { fr: { stringValue: 'à toi' } } },\n ],\n },\n },\n },\n ],\n })\n const created = await childApi.contactApi.createContactWithUser(childUser, instance)\n const createdFlat = created!.services!.find((x) => x.id === idFlat)!\n const createdCompound = created!.services!.find((x) => x.id === idCompound)!\n const createdSalut = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const createdAtoi = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n for (const { api, user } of allApis) {\n console.log('Trying with user: ' + user.login)\n const check = await api.contactApi.getContactWithUser(user, created!.id!)\n const checkFlat = check!.services!.find((x) => x.id == idFlat)!\n const checkCompound = check!.services!.find((x) => x.id == idCompound)!\n const checkSalut = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const checkAtoi = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n expect(checkFlat).to.not.be.undefined\n expect(checkFlat).to.not.be.null\n expect(checkSalut).to.not.be.undefined\n expect(checkSalut).to.not.be.null\n expect(checkAtoi).to.not.be.undefined\n expect(checkAtoi).to.not.be.null\n\n expect(checkFlat.content!.fr.stringValue).to.equal(createdFlat!.content!.fr.stringValue)\n expect(checkFlat.content!.nl.stringValue).to.equal(createdFlat!.content!.nl.stringValue)\n expect(checkFlat.content!.encryptedSelf).to.not.be.null\n\n expect(checkSalut.content!.fr.stringValue).to.equal(createdSalut.content!.fr.stringValue)\n expect(checkSalut.encryptedSelf).to.not.be.null\n\n expect(checkAtoi.content!.fr.stringValue).to.equal(createdAtoi.content!.fr.stringValue)\n expect(checkAtoi.encryptedSelf).to.not.be.null\n }\n })\n})\n\ndescribe('test that confidential helement information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(childUser, modifiedPatient, { descr: 'Confidential info' }, { confidential: true })\n )\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsUser.length).to.equal(1, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedHesAsMh = await api.healthcareElementApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsMh.length).to.equal(0, 'MH should not see confidential data')\n let failedToRetrieve = false\n try {\n await api.healthcareElementApi.getHealthElementWithUser(user, confidentialHe.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialHe!, type: EntityWithDelegationTypeName.HealthElement }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('test that confidential contact information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialCtc = await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(\n childUser,\n modifiedPatient,\n\n { descr: 'Confidential info', services: [], subContacts: [] },\n { confidential: true }\n )\n )\n\n await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Non confidential info', services: [], subContacts: [] },\n { confidential: false }\n )\n )\n\n const retrievedCtcsAsUser = await childApi.contactApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsUser.length).to.equal(2, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedCtcsAsMh = await api.contactApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsMh.length).to.equal(1, 'MH should not see confidential data')\n // Even if in some way I could get the contact id I should not be able to get it\n let failedToRetrieve = false\n try {\n await api.contactApi.getContactWithUser(user, confidentialCtc!.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialCtc!, type: EntityWithDelegationTypeName.Contact }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('Share entity behaviour', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it(\"share method should fail if the user attempts to share an entity he can't access\", async () => {\n const hcp1 = await createNewHcpApi(env)\n const hcp2 = await createNewHcpApi(env)\n const hcp3 = await createNewHcpApi(env)\n const patient: Patient = await hcp1.api.patientApi.createPatientWithUser(\n hcp1.user,\n await hcp1.api.patientApi.newInstance(hcp1.user, { firstName: 'John', lastName: 'Doe', note: 'Secret' })\n )\n const encryptedPatient = await new IccPatientApi(env.iCureUrl, {}, hcp1.api.authApi.authenticationProvider, fetch).getPatient(patient.id!)\n await expect(hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, encryptedPatient, [], { requestedPermissions: 'FULL_WRITE' })).to.be\n .rejected\n const shared = await hcp1.api.patientApi.shareWith(hcp2.credentials.dataOwnerId, patient, [], { requestedPermissions: 'FULL_WRITE' })\n await hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, shared, [], { requestedPermissions: 'FULL_WRITE' })\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"cryptoTest.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/cryptoTest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,8CAAgD;AAChD,4BAAyB;AACzB,+BAA6C;AAC7C,iBAAc;AAEd,4DAAwD;AACxD,uDAQ+B;AAC/B,mDAAmE;AACnE,kDAA8F;AAC9F,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mFAA+E;AAC/E,IAAO,kBAAkB,GAAG,qCAAiB,CAAC,kBAAkB,CAAA;AAEhE,IAAA,UAAO,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAEpC,IAAI,GAAa,CAAA;AAEjB,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,MAAM,CAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAA,uBAAe,GAAE,CAAC,CAAA;QACpD,CAAC;KAAA,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,GAAS,EAAE;QACvD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,yBAAY,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QAE/C,MAAM,IAAI,GAAG,kCAAkC,CAAA;QAC/C,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,qBAAqB,CACxD,IAAI,EACJ,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,CAC9B,IAAI,EACJ,IAAI,iBAAO,CAAC;YACV,QAAQ,EAAE,OAAO;YACjB,SAA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E,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;aAC1I,QAAQ,CAAA;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;QACrI,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;IACvH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { IccPatientApi } from '../../../icc-api'\nimport 'isomorphic-fetch'\nimport { expect, use as chaiUse } from 'chai'\nimport 'mocha'\n\nimport { Patient } from '../../../icc-api/model/Patient'\nimport {\n createHcpHierarchyApis,\n createNewHcpApi,\n getEnvironmentInitializer,\n hcp1Username,\n isLiteTest,\n setLocalStorage,\n TestUtils,\n} from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { BasicAuthenticationProvider, EntityWithDelegationTypeName } from '../../../icc-x-api'\nimport initApi = TestUtils.initApi\nimport { SecretIdUseOption } from '../../../icc-x-api/crypto/SecretIdUseOption'\nimport UseAnyConfidential = SecretIdUseOption.UseAnyConfidential\n\nchaiUse(require('chai-as-promised'))\n\nlet env: TestVars\n\nsetLocalStorage(fetch)\n\ndescribe('Create a patient from scratch', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should create a patient in the database', async () => {\n const api = await initApi(env, hcp1Username)\n const user = await api.userApi.getCurrentUser()\n\n const note = 'A secured note that is encrypted'\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(\n user,\n new Patient({\n lastName: 'Biden',\n firstName: 'Joe',\n note,\n })\n )\n )\n expect(patient.note).to.equal(note)\n\n console.log(\n `Created patient (decrypted): ${patient.id}: ${patient.firstName} ${patient.lastName} [note:${patient.note}, encryptedSelf:${patient.encryptedSelf}]`\n )\n\n const fetched = await api.patientApi.getPatientWithUser(user, patient.id)\n console.log(\n `Fetched patient (decrypted): ${fetched.id}: ${fetched.firstName} ${fetched.lastName} [note:${fetched.note}, encryptedSelf:${fetched.encryptedSelf}]`\n )\n expect(fetched.id).to.equal(patient.id)\n expect(fetched.note).to.equal(note)\n\n const fetchedWithoutDecryption = await new IccPatientApi(\n env.iCureUrl,\n {},\n new BasicAuthenticationProvider(env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password),\n fetch as any\n ).getPatient(patient.id)\n\n console.log(\n `Fetched patient (encrypted):${fetchedWithoutDecryption.id}: ${fetchedWithoutDecryption.firstName} ${fetchedWithoutDecryption.lastName} [note: ${fetchedWithoutDecryption.note}]`\n )\n expect(fetchedWithoutDecryption.id).to.equal(patient.id)\n expect(fetchedWithoutDecryption.note).to.be.undefined\n })\n})\n\ndescribe('Init confidential delegation in patient', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a patient with a confidential delegation', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const note = 'Some note'\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe', note })\n )\n\n // All parents and siblings should have access to the decrypted data and to the initial secret id\n expect(await childApi.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n const originalSecretId = (await childApi.patientApi.decryptSecretIdsOf(pat))[0]\n for (const { api, user } of others) {\n expect(await api.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await api.patientApi.decryptSecretIdsOf(pat))[0]).to.equal(originalSecretId)\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // Initially there shouldn't be any secret confidential secret id\n expect(await childApi.patientApi.decryptConfidentialSecretIdsOf(pat)).to.be.empty\n\n // Now create a confidential delegation\n const patWithConfidential = await childApi.patientApi.initConfidentialSecretId(pat, childUser)\n\n // Confidential secret id should be different from the original secret id\n const confidentialDelegationKeys = await childApi.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)\n const nonConfidentialDelegationKeys = await childApi.patientApi.decryptNonConfidentialSecretIdsOf(patWithConfidential)\n expect(confidentialDelegationKeys).to.have.length(1)\n expect(nonConfidentialDelegationKeys).to.have.length(1)\n expect(confidentialDelegationKeys[0]).to.not.equal(nonConfidentialDelegationKeys)\n expect(nonConfidentialDelegationKeys[0]).to.equal(originalSecretId)\n\n // Child has access to confidential and not confidential secret ids.\n const childSecretIds = await childApi.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(childSecretIds).to.have.length(2)\n expect(childSecretIds).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIds).to.have.contain(confidentialDelegationKeys[0])\n\n // All parents and siblings should have access to the decrypted data even after initialising confidential delegations...\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n for (const { api, user } of others) {\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // ...but not to the confidential secret id\n for (const { api } of others) {\n const secretIds = await api.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(secretIds).to.have.length(1)\n expect(secretIds).to.contain(nonConfidentialDelegationKeys[0])\n }\n\n // If a secret delegation is already available there is no need to create a new one\n const patWithConfidentialAgain = await childApi.patientApi.initConfidentialSecretId(patWithConfidential, childUser)\n expect(patWithConfidentialAgain.rev).to.equal(patWithConfidentialAgain.rev)\n expect(await childApi.patientApi.decryptSecretIdsOf(patWithConfidentialAgain)).to.have.length(2)\n\n // Different users will have different confidential secret ids...\n expect(await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)).to.be.empty\n const patWithMoreConfidentialIds = await child2Api.patientApi.initConfidentialSecretId(patWithConfidential, child2User)\n\n // ...child continues to know the same secret ids...\n const childSecretIdsRepeat = await childApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n expect(childSecretIdsRepeat).to.have.length(2)\n expect(childSecretIdsRepeat).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIdsRepeat).to.have.contain(confidentialDelegationKeys[0])\n\n // ...but child2 now also knows a different secret id...\n const child2secretIds = await child2Api.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n const child2confidential = await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithMoreConfidentialIds)\n expect(child2confidential).to.have.length(1)\n expect(child2confidential[0]).to.not.equal(confidentialDelegationKeys[0])\n expect(child2confidential[0]).to.not.equal(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.have.length(2)\n expect(child2secretIds).to.contain(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.contain(child2confidential[0])\n\n // ...and their parents still don't know them\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n })\n})\n\ndescribe('Test that contact information can be decrypted', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a contact with decrypted information', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const allApis = [\n { api: childApi, user: childUser },\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n const idFlat = childApi.cryptoApi.primitives.randomUuid()\n const idCompound = childApi.cryptoApi.primitives.randomUuid()\n const idSalut = childApi.cryptoApi.primitives.randomUuid()\n const idAtoi = childApi.cryptoApi.primitives.randomUuid()\n const instance = await childApi.contactApi.newInstance(childUser, pat, {\n services: [\n {\n id: idFlat,\n content: { fr: { stringValue: 'Salut' }, nl: { stringValue: 'Halo' } },\n },\n {\n id: idCompound,\n content: {\n fr: {\n compoundValue: [\n { id: idSalut, content: { fr: { stringValue: 'Salut' } } },\n { id: idAtoi, content: { fr: { stringValue: 'à toi' } } },\n ],\n },\n },\n },\n ],\n })\n const created = await childApi.contactApi.createContactWithUser(childUser, instance)\n const createdFlat = created!.services!.find((x) => x.id === idFlat)!\n const createdCompound = created!.services!.find((x) => x.id === idCompound)!\n const createdSalut = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const createdAtoi = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n for (const { api, user } of allApis) {\n console.log('Trying with user: ' + user.login)\n const check = await api.contactApi.getContactWithUser(user, created!.id!)\n const checkFlat = check!.services!.find((x) => x.id == idFlat)!\n const checkCompound = check!.services!.find((x) => x.id == idCompound)!\n const checkSalut = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const checkAtoi = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n expect(checkFlat).to.not.be.undefined\n expect(checkFlat).to.not.be.null\n expect(checkSalut).to.not.be.undefined\n expect(checkSalut).to.not.be.null\n expect(checkAtoi).to.not.be.undefined\n expect(checkAtoi).to.not.be.null\n\n expect(checkFlat.content!.fr.stringValue).to.equal(createdFlat!.content!.fr.stringValue)\n expect(checkFlat.content!.nl.stringValue).to.equal(createdFlat!.content!.nl.stringValue)\n expect(checkFlat.content!.encryptedSelf).to.not.be.null\n\n expect(checkSalut.content!.fr.stringValue).to.equal(createdSalut.content!.fr.stringValue)\n expect(checkSalut.encryptedSelf).to.not.be.null\n\n expect(checkAtoi.content!.fr.stringValue).to.equal(createdAtoi.content!.fr.stringValue)\n expect(checkAtoi.encryptedSelf).to.not.be.null\n }\n })\n})\n\ndescribe('test that confidential helement information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsUser.length).to.equal(1, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedHesAsMh = await api.healthcareElementApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsMh.length).to.equal(0, 'MH should not see confidential data')\n let failedToRetrieve = false\n try {\n await api.healthcareElementApi.getHealthElementWithUser(user, confidentialHe.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialHe!, type: EntityWithDelegationTypeName.HealthElement }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('test that confidential contact information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialCtc = await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(\n childUser,\n modifiedPatient,\n\n { descr: 'Confidential info', services: [], subContacts: [] },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n\n await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(childUser, modifiedPatient, { descr: 'Non confidential info', services: [], subContacts: [] })\n )\n\n const retrievedCtcsAsUser = await childApi.contactApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsUser.length).to.equal(2, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedCtcsAsMh = await api.contactApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsMh.length).to.equal(1, 'MH should not see confidential data')\n // Even if in some way I could get the contact id I should not be able to get it\n let failedToRetrieve = false\n try {\n await api.contactApi.getContactWithUser(user, confidentialCtc!.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialCtc!, type: EntityWithDelegationTypeName.Contact }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('Share entity behaviour', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it(\"share method should fail if the user attempts to share an entity he can't access\", async () => {\n const hcp1 = await createNewHcpApi(env)\n const hcp2 = await createNewHcpApi(env)\n const hcp3 = await createNewHcpApi(env)\n const patient: Patient = await hcp1.api.patientApi.createPatientWithUser(\n hcp1.user,\n await hcp1.api.patientApi.newInstance(hcp1.user, { firstName: 'John', lastName: 'Doe', note: 'Secret' })\n )\n const encryptedPatient = await new IccPatientApi(env.iCureUrl, {}, hcp1.api.authApi.authenticationProvider, fetch).getPatient(patient.id!)\n await expect(hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, encryptedPatient, [], { requestedPermissions: 'FULL_WRITE' })).to.be\n .rejected\n const shared = await hcp1.api.patientApi.shareWith(hcp2.credentials.dataOwnerId, patient, [], { requestedPermissions: 'FULL_WRITE' })\n await hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, shared, [], { requestedPermissions: 'FULL_WRITE' })\n })\n})\n"]}
|
|
@@ -97,14 +97,12 @@ const entities = {
|
|
|
97
97
|
var _a;
|
|
98
98
|
return contactApi.newInstance(user, patient, new Contact_1.Contact({ id, services: [new models_1.Service({ label: 'svc', content: { fr: { stringValue: 'data' } } })] }), {
|
|
99
99
|
additionalDelegates: Object.fromEntries((_a = delegateIds === null || delegateIds === void 0 ? void 0 : delegateIds.map((id) => [id, AccessLevel.WRITE])) !== null && _a !== void 0 ? _a : []),
|
|
100
|
-
confidential: false,
|
|
101
100
|
});
|
|
102
101
|
},
|
|
103
102
|
HealthElement: ({ healthcareElementApi }, id, user, patient, delegateIds) => {
|
|
104
103
|
var _a;
|
|
105
104
|
return healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({ id, descr: 'HE' }), {
|
|
106
105
|
additionalDelegates: Object.fromEntries((_a = delegateIds === null || delegateIds === void 0 ? void 0 : delegateIds.map((id) => [id, AccessLevel.WRITE])) !== null && _a !== void 0 ? _a : []),
|
|
107
|
-
confidential: false,
|
|
108
106
|
});
|
|
109
107
|
},
|
|
110
108
|
CalendarItem: ({ calendarItemApi }, id, user, patient, delegateIds) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full-crypto-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/full-crypto-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAA4F;AAC5F,+BAAiC;AACjC,4DAAwD;AACxD,4DAAwD;AACxD,wEAAoE;AACpE,sEAAkE;AAClE,0DAA2H;AAC3H,iCAA4C;AAE5C,mCAAkC;AAClC,4BAAyB;AAEzB,+BAA6B;AAC7B,uDAAwH;AACxH,iDAA6C;AAG7C,yDAA0F;AAC1F,2EAAuE;AACvE,8GAA0G;AAC1G,8FAA0F;AAC1F,IAAO,aAAa,GAAG,sBAAS,CAAC,aAAa,CAAA;AAC9C,8EAA0E;AAC1E,IAAO,WAAW,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACrD,2FAAuF;AACvF,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAC3E,mDAAmE;AACnE,2DAA+D;AAE/D,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,MAAM,UAAU,GAAG,uBAAuB,CAAC,UAAU,CAAA;AA2BrD,MAAM,OAAO,GAAkB;IAC7B,OAAO,EAAE;QACP,MAAM,EAAE,CAAO,GAAG,EAAE,CAAC,EAAE,EAAE,kDAAC,OAAA,GAAG,CAAC,UAAU,CAAC,qB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../../../icc-x-api'\nimport { v4 as uuid } from 'uuid'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport { Contact } from '../../../icc-api/model/Contact'\nimport { HealthElement } from '../../../icc-api/model/HealthElement'\nimport { CalendarItem } from '../../../icc-api/model/CalendarItem'\nimport { EncryptedEntity, FilterChainMaintenanceTask, HealthcareParty, Service, User } from '../../../icc-api/model/models'\nimport { before, describe, it } from 'mocha'\n\nimport { webcrypto } from 'crypto'\nimport 'isomorphic-fetch'\n\nimport { expect } from 'chai'\nimport { getEnvironmentInitializer, getTempEmail, isLiteTest, setLocalStorage, TestUtils } from '../../utils/test_utils'\nimport { TestApi } from '../../utils/TestApi'\nimport { KeyPair } from '../../../icc-x-api/crypto/RSA'\nimport { CryptoPrimitives } from '../../../icc-x-api/crypto/CryptoPrimitives'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { MaintenanceTaskAfterDateFilter } from '../../../icc-x-api/filters/MaintenanceTaskAfterDateFilter'\nimport { KeyPairUpdateRequest } from '../../../icc-x-api/maintenance/KeyPairUpdateRequest'\nimport initMasterApi = TestUtils.initMasterApi\nimport { SecureDelegation } from '../../../icc-api/model/SecureDelegation'\nimport AccessLevel = SecureDelegation.AccessLevelEnum\nimport { EntityShareRequest } from '../../../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { fingerprintV1 } from '../../../icc-x-api/crypto/utils'\n\nsetLocalStorage(fetch)\n\nconst FULL_WRITE = RequestedPermissionEnum.FULL_WRITE\n\ntype TestedEntity = 'Patient' | 'Contact' | 'HealthElement' | 'CalendarItem'\n\ninterface EntityFacade<T extends EncryptedEntity> {\n create: (api: Apis, record: Omit<T, 'rev'>) => Promise<T>\n get: (api: Apis, id: string) => Promise<T>\n share: (api: Apis, record: T, dataOwnerId: string) => Promise<T>\n isDecrypted: (entityToCheck: T) => Promise<boolean>\n}\n\ntype EntityCreator<T> = (api: Apis, id: string, user: User, patient?: Patient, delegateIds?: string[]) => Promise<T>\n\ninterface EntityFacades {\n Patient: EntityFacade<Patient>\n Contact: EntityFacade<Contact>\n HealthElement: EntityFacade<HealthElement>\n CalendarItem: EntityFacade<CalendarItem>\n}\n\ninterface EntityCreators {\n Patient: EntityCreator<Patient>\n Contact: EntityCreator<Contact>\n HealthElement: EntityCreator<HealthElement>\n CalendarItem: EntityCreator<CalendarItem>\n}\n\nconst facades: EntityFacades = {\n Patient: {\n create: async (api, r) => api.patientApi.createPatientWithUser(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.patientApi.getPatientWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.patientApi.shareWith(doId, r, await api.patientApi.decryptSecretIdsOf(r), { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.note != undefined\n },\n } as EntityFacade<Patient>,\n Contact: {\n create: async (api, r) => api.contactApi.createContactWithUser(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.contactApi.getContactWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.contactApi.shareWith(doId, r, { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.services?.[0].content != undefined && Object.entries(entityToCheck.services?.[0].content).length > 0\n },\n } as EntityFacade<Contact>,\n HealthElement: {\n create: async (api, r) => api.healthcareElementApi.createHealthElementWithUser(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.healthcareElementApi.getHealthElementWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.healthcareElementApi.shareWith(doId, r, { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.descr != undefined\n },\n } as EntityFacade<HealthElement>,\n CalendarItem: {\n create: async (api, r) => api.calendarItemApi.createCalendarItemWithHcParty(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.calendarItemApi.getCalendarItemWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.calendarItemApi.shareWith(doId, r, { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.title != undefined\n },\n } as EntityFacade<CalendarItem>,\n}\n\nconst users: { user: User; password: string }[] = []\nconst primitives = new WebCryptoPrimitives(webcrypto as any)\nlet delegateUser: User | undefined = undefined\nlet delegateHcp: HealthcareParty | undefined = undefined\nlet delegateHcpPassword: string | undefined = undefined\n\nlet userGivingAccessBack: User | undefined = undefined\nlet userGivingAccessBackPassword: string | undefined = undefined\nlet hcpGivingAccessBack: HealthcareParty | undefined = undefined\n\nconst entities: EntityCreators = {\n Patient: ({ patientApi }, id, user, _, delegateIds) => {\n return patientApi.newInstance(user, new Patient({ id, firstName: 'test', lastName: 'test', note: 'data', dateOfBirth: 20000101 }), {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n })\n },\n Contact: ({ contactApi }, id, user, patient, delegateIds) => {\n return contactApi.newInstance(\n user,\n patient!,\n new Contact({ id, services: [new Service({ label: 'svc', content: { fr: { stringValue: 'data' } } })] }),\n {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n confidential: false,\n }\n )\n },\n HealthElement: ({ healthcareElementApi }, id, user, patient, delegateIds) => {\n return healthcareElementApi.newInstance(user, patient!, new HealthElement({ id, descr: 'HE' }), {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n confidential: false,\n })\n },\n CalendarItem: ({ calendarItemApi }, id, user, patient, delegateIds) => {\n return calendarItemApi.newInstancePatient(user, patient!, new CalendarItem({ id, title: 'CI' }), {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n })\n },\n}\n\nconst userDefinitions: Record<string, (user: User, password: string, pair: KeyPair<CryptoKey>) => Promise<{ user: User; apis: Apis }>> = {\n 'one available key and one lost key recoverable through transfer keys': async (user, password, originalKey) => {\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const apiWithOnlyNewKey = await IcureApi.initialise(\n env!.iCureUrl,\n {\n username: user.login!,\n password,\n },\n new TestCryptoStrategies(newKey, {\n [fingerprintV1(ua2hex(await primitives.RSA.exportKey(originalKey.publicKey, 'spki')))]: true,\n }),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n const apis = await IcureApi.initialise(\n env!.iCureUrl,\n {\n username: user.login!,\n password,\n },\n new TestCryptoStrategies(originalKey, {\n [fingerprintV1(ua2hex(await primitives.RSA.exportKey(newKey.publicKey, 'spki')))]: true,\n }),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n expect(Object.keys(apis.cryptoApi.userKeysManager.getDecryptionKeys())).to.have.length(2)\n await apiWithOnlyNewKey.cryptoApi.forceReload()\n expect(Object.keys(apiWithOnlyNewKey.cryptoApi.userKeysManager.getDecryptionKeys())).to.have.length(2)\n return { user, apis: apiWithOnlyNewKey }\n },\n 'two available keys': async (user, password, originalKey) => {\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const apiWithOnlyNewKey = await IcureApi.initialise(\n env!.iCureUrl,\n { username: user.login!, password },\n new TestCryptoStrategies(newKey),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n ) // Initializes the new key for the data owner\n const keyStrings = await Promise.all(\n [originalKey, newKey].map(async (pair) => ({\n publicKey: ua2hex(await primitives.RSA.exportKey(pair.publicKey, 'spki')),\n privateKey: ua2hex(await primitives.RSA.exportKey(pair.privateKey, 'pkcs8')),\n }))\n )\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: user.healthcarePartyId ?? user.patientId!,\n pairs: keyStrings.map((key) => {\n return { keyPair: key, shaVersion: ShaVersion.Sha256 }\n }),\n },\n ])\n const apis = await IcureApi.initialise(env!.iCureUrl, { username: user.login!, password }, new TestCryptoStrategies(), webcrypto as any, fetch, {\n entryKeysFactory: storage.keyFactory,\n keyStorage: storage.keyStorage,\n storage: storage.storage,\n })\n return { user, apis }\n },\n 'a single available key in old format': async (user, password, originalKey) => ({\n user,\n apis: await TestApi(env.iCureUrl, user.login!, password, webcrypto as any, originalKey),\n }),\n 'one lost key and one available key': async (user, password) => {\n const newKeyPair = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const apis = await TestApi(env.iCureUrl, user.login!, password, webcrypto as any, newKeyPair)\n await apis.icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(user, newKeyPair)\n return { user, apis }\n },\n 'one lost key and one upgraded available key thanks to delegate who gave access back to previous data': async (user, password) => {\n const newKeyPair = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const api = await TestApi(env.iCureUrl, user.login!, password, webcrypto as any, newKeyPair)\n await api.icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(user, newKeyPair)\n const giveAccessBackApi = apis['givingAccessBack']\n const keyPairUpdateRequests = (\n await giveAccessBackApi.maintenanceTaskApi.filterMaintenanceTasksByWithUser(\n userGivingAccessBack!,\n undefined,\n undefined,\n new FilterChainMaintenanceTask({\n filter: new MaintenanceTaskAfterDateFilter({\n date: new Date().getTime() - 100000,\n }),\n })\n )\n ).rows!.map((x) => KeyPairUpdateRequest.fromMaintenanceTask(x))\n const concernedRequest = keyPairUpdateRequests.find((x) => x.concernedDataOwnerId === (user.healthcarePartyId ?? user.patientId))\n if (!concernedRequest) throw new Error('Could not find maintenance task')\n await giveAccessBackApi.icureMaintenanceTaskApi.applyKeyPairUpdate(concernedRequest)\n\n await api.cryptoApi.forceReload()\n\n return { user, apis: api }\n },\n}\n\nasync function createPartialsForHcp(\n entityFacades: EntityFacades,\n entityCreators: EntityCreators,\n user: User,\n password: string\n): Promise<KeyPair<CryptoKey>> {\n const key = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const api1 = await TestApi(env!.iCureUrl, user.login!, password, webcrypto as any, key)\n await Object.entries(entityFacades).reduce(async (p, f) => {\n await p\n const type = f[0]\n const facade = f[1]\n const parent = type !== 'Patient' ? await api1.patientApi.getPatientWithUser(user, `partial-${user.id}-Patient`) : undefined\n const record = await entityCreators[type as TestedEntity](api1, `partial-${user.id}-${type}`, user, parent, [hcpGivingAccessBack!.id!])\n await facade.create(api1, record)\n }, Promise.resolve())\n return key\n}\n\nasync function createPartialsForPatient(\n entityFacades: EntityFacades,\n entityCreators: EntityCreators,\n user: User,\n password: string,\n patientCreatorUser: User,\n patientCreatorApis: Apis\n): Promise<KeyPair<CryptoKey>> {\n const key = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const api1 = await TestApi(env!.iCureUrl, user.login!, password, webcrypto as any, key)\n const pat = await patientCreatorApis.patientApi.getPatientWithUser(patientCreatorUser, user.patientId!)\n await patientCreatorApis.patientApi.shareWith(user.patientId!, pat, await patientCreatorApis.patientApi.decryptSecretIdsOf(pat), {\n requestedPermissions: FULL_WRITE,\n })\n await Object.entries(entityFacades)\n .filter((it) => it[0] !== 'Patient')\n .reduce(async (p, f) => {\n await p\n const type = f[0]\n const facade = f[1]\n const parent = await api1.patientApi.getPatientWithUser(user, user.patientId!)\n const record = await entityCreators[type as TestedEntity](api1, `partial-${user.id}-${type}`, user, parent, [hcpGivingAccessBack!.id!])\n await facade.create(api1, record)\n }, Promise.resolve())\n return key\n}\n\nlet env: TestVars\nlet apis: { [key: string]: Apis }\n\ndescribe('Full crypto test - Creation scenarios', async function () {\n before(async function () {\n this.timeout(6000000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n\n const api = await initMasterApi(env!)\n const user = await api.userApi.getCurrentUser()\n const dataOwnerId = api.dataOwnerApi.getDataOwnerIdOf(user)\n\n const { userApi, patientApi, healthcarePartyApi, cryptoApi } = api\n\n delegateHcp = await healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: 'test', lastName: 'test' }))\n delegateUser = await userApi.createUser(\n new User({\n id: `user-${uuid()}-hcp`,\n login: `hcp-delegate-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: delegateHcp.id,\n })\n )\n delegateHcpPassword = await userApi.getToken(delegateUser!.id!, uuid())\n\n hcpGivingAccessBack = await healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: 'test', lastName: 'test' }))\n userGivingAccessBack = await userApi.createUser(\n new User({\n id: `user-${uuid()}-hcp`,\n login: `hcp-giving-access-back-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcpGivingAccessBack.id,\n })\n )\n userGivingAccessBackPassword = await userApi.getToken(userGivingAccessBack!.id!, uuid())\n\n apis = {\n delegate: await TestApi(env.iCureUrl!, delegateUser.login!, delegateHcpPassword, webcrypto as any),\n givingAccessBack: await TestApi(env.iCureUrl!, userGivingAccessBack.login!, userGivingAccessBackPassword, webcrypto as any),\n }\n\n await Object.entries(userDefinitions).reduce(async (p, [login, creationProcess]) => {\n await p\n const newPatientEmail = getTempEmail()\n const patientToCreate = await patientApi.newInstance(user, new Patient({ id: uuid(), firstName: 'test', lastName: 'test' }))\n const patient = await patientApi.createPatientWithUser(user, patientToCreate)\n\n const newHcpEmail = getTempEmail()\n const hcp = await healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: 'test', lastName: 'test' }))\n\n const newPatientUser = await userApi.createUser(\n new User({\n id: `user-${uuid()}-patient`,\n name: `patient-${login}`,\n login: newPatientEmail,\n email: newPatientEmail,\n status: 'ACTIVE',\n patientId: patient.id,\n })\n )\n const newPatientUserPassword = await userApi.getToken(newPatientUser!.id!, uuid())\n\n const newHcpUser = await userApi.createUser(\n new User({\n id: `user-${uuid()}-hcp`,\n login: newHcpEmail,\n email: newHcpEmail,\n name: `hcp-${login}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n const newHcpUserPassword = await userApi.getToken(newHcpUser!.id!, uuid())\n\n const originalKeyPat = await createPartialsForPatient(facades, entities, newPatientUser, newPatientUserPassword, user, api)\n const originalKeyHcp = await createPartialsForHcp(facades, entities, newHcpUser, newHcpUserPassword)\n\n const patDetails = await creationProcess(newPatientUser, newPatientUserPassword, originalKeyPat)\n const hcpDetails = await creationProcess(newHcpUser, newHcpUserPassword, originalKeyHcp)\n\n users.push({ user: patDetails.user, password: newPatientUserPassword })\n apis[patDetails.user.name!] = patDetails.apis\n users.push({ user: hcpDetails.user, password: newHcpUserPassword })\n apis[hcpDetails.user.name!] = hcpDetails.apis\n }, Promise.resolve())\n\n await users\n .filter((it) => it.user.id!.endsWith('patient'))\n .map((it) => it.user)\n .reduce(async (prev, it) => {\n await prev\n const otherUsers = users.filter((u) => u.user.id!.endsWith('patient') && u.user.id !== it.id).map((u) => u.user)\n\n await otherUsers.reduce(async (p, u) => {\n await p\n const patientToShare = await facades.Patient.get(api, it.patientId!)\n const sharedPatient = await facades.Patient.share(api, patientToShare, u.patientId!)\n return Promise.resolve()\n }, Promise.resolve())\n\n return Promise.resolve()\n }, Promise.resolve())\n })\n ;['patient', 'hcp'].forEach((uType) => {\n Object.keys(userDefinitions).forEach((uId) => {\n Object.entries(facades).forEach((f) => {\n it(`Create ${f[0]} as a ${uType} with ${uId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade: EntityFacade<any> = f[1]\n const api = apis[`${uType}-${uId}`]\n\n const parent =\n f[0] !== 'Patient'\n ? uType === 'patient'\n ? await api.patientApi.getPatientWithUser(user, user.patientId!)\n : await api.patientApi.getPatientWithUser(user, `${user.id}-Patient`)\n : undefined\n const record = await entities[f[0] as TestedEntity](api, `${user.id}-${f[0]}`, user, parent)\n const entity = await facade.create(api, record)\n const retrieved = await facade.get(api, entity.id)\n\n expect(entity.id).to.be.not.null\n expect(entity.rev).to.equal(retrieved.rev)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n it(`Create ${f[0]} as delegate with delegation for ${uType} with ${uId}`, async function () {\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade: EntityFacade<any> = f[1]\n\n const api = apis['delegate']\n const patApi = apis[`${uType}-${uId}`]\n const dataOwnerId = api.dataOwnerApi.getDataOwnerIdOf(user)\n const dataOwner = (await patApi.dataOwnerApi.getCryptoActorStub(dataOwnerId))!.stub\n\n const parent = f[0] !== 'Patient' ? await api.patientApi.getPatientWithUser(delegateUser!, `delegate-${user.id}-Patient`) : undefined\n\n const record = await entities[f[0] as TestedEntity](api, `delegate-${user.id}-${f[0]}`, delegateUser!, parent, [\n (user.patientId ?? user.healthcarePartyId ?? user.deviceId)!,\n ])\n const entity = await facade.create(api, record)\n const retrieved = await facade.get(api, entity.id)\n expect(entity.id).to.be.not.null\n expect(entity.rev).to.equal(retrieved.rev)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n })\n })\n })\n})\n\ndescribe('Full crypto test - Read/Share scenarios', async function () {\n ;['patient', 'hcp'].forEach((uType) => {\n Object.keys(userDefinitions).forEach((uId) => {\n Object.entries(facades).forEach((f) => {\n it(`Read ${f[0]} as the initial ${uType} with ${uId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n\n const retrievePromise = facade.get(api, `partial-${user.id}-${f[0]}`)\n const lostInitialKey = uId.includes('one lost key and one available key')\n if (uType === 'patient' && lostInitialKey && !isLiteTest()) {\n // Patient with lost key can't prove he has access to data: he will get an error\n let gaveError = false\n try {\n await retrievePromise\n } catch {\n gaveError = true\n }\n expect(gaveError).to.equal(true, 'Patient with lost key should not be able to retrieve data')\n } else {\n const entity = await retrievePromise\n expect(entity.id).to.equal(`partial-${user.id}-${f[0]}`)\n expect(await facade.isDecrypted(entity)).to.equal(!lostInitialKey) // data is accessible only with initial key for this test.\n }\n })\n it(`Read ${f[0]} as a ${uType} with ${uId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n\n const entity = await facade.get(api, `${user.id}-${f[0]}`)\n expect(entity.id).to.equal(`${user.id}-${f[0]}`)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n it(`Read ${f[0]} shared by delegate as a ${uType} with ${uId}`, async () => {\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n await api.cryptoApi.forceReload()\n const entity = await facade.get(api, `delegate-${user.id}-${f[0]}`)\n expect(entity.id).to.equal(`delegate-${user.id}-${f[0]}`)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n ;['patient', 'hcp'].forEach((duType) => {\n Object.keys(userDefinitions).forEach((duId) => {\n it(`Share ${f[0]} as a ${uType} with ${uId} to a ${duType} with ${duId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const { user: delUser } = users.find((it) => it.user.name === `${duType}-${duId}`)!\n const delegateDoId = delUser.healthcarePartyId ?? delUser.patientId\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n const delApi = apis[`${duType}-${duId}`]\n // Data was created (in a previous test) after lost key -> fully accessible\n const entity = await facade.share(api, await facade.get(api, `${user.id}-${f[0]}`), delegateDoId)\n const retrieved = await facade.get(api, entity.id)\n expect(entity.rev).to.equal(retrieved.rev)\n\n await delApi.cryptoApi.forceReload()\n const obj = await facade.get(delApi, `${user.id}-${f[0]}`)\n expect(await delApi.cryptoApi.xapi.hasWriteAccess({ entity: obj, type: f[0] as any })).to.equal(true)\n expect(await facade.isDecrypted(obj)).to.equal(true)\n })\n })\n })\n })\n })\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"full-crypto-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/full-crypto-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAA4F;AAC5F,+BAAiC;AACjC,4DAAwD;AACxD,4DAAwD;AACxD,wEAAoE;AACpE,sEAAkE;AAClE,0DAA2H;AAC3H,iCAA4C;AAE5C,mCAAkC;AAClC,4BAAyB;AAEzB,+BAA6B;AAC7B,uDAAwH;AACxH,iDAA6C;AAG7C,yDAA0F;AAC1F,2EAAuE;AACvE,8GAA0G;AAC1G,8FAA0F;AAC1F,IAAO,aAAa,GAAG,sBAAS,CAAC,aAAa,CAAA;AAC9C,8EAA0E;AAC1E,IAAO,WAAW,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACrD,2FAAuF;AACvF,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAC3E,mDAAmE;AACnE,2DAA+D;AAE/D,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,MAAM,UAAU,GAAG,uBAAuB,CAAC,UAAU,CAAA;AA2BrD,MAAM,OAAO,GAAkB;IAC7B,OAAO,EAAE;QACP,MAAM,EAAE,CAAO,GAAG,EAAE,CAAC,EAAE,EAAE,kDAAC,OAAA,GAAG,CAAC,UAAU,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAA,GAAA;QACrG,GAAG,EAAE,CAAO,GAAG,EAAE,EAAE,EAAE,EAAE,kDAAC,OAAA,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,EAAE,CAAC,CAAA,GAAA;QACjG,KAAK,EAAE,CAAO,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,EAA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AAM,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;oCAE1C,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAA;oCACpC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;oCAC1D,IAAA,aAAM,EAAC,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;oCACrG,IAAA,aAAM,EAAC,MAAM,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;;6BACrD,CAAC,CAAA;wBACJ,CAAC,CAAC,CAAA;oBACJ,CAAC,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { Apis, WebCryptoPrimitives, IcureApi, ShaVersion, ua2hex } from '../../../icc-x-api'\nimport { v4 as uuid } from 'uuid'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport { Contact } from '../../../icc-api/model/Contact'\nimport { HealthElement } from '../../../icc-api/model/HealthElement'\nimport { CalendarItem } from '../../../icc-api/model/CalendarItem'\nimport { EncryptedEntity, FilterChainMaintenanceTask, HealthcareParty, Service, User } from '../../../icc-api/model/models'\nimport { before, describe, it } from 'mocha'\n\nimport { webcrypto } from 'crypto'\nimport 'isomorphic-fetch'\n\nimport { expect } from 'chai'\nimport { getEnvironmentInitializer, getTempEmail, isLiteTest, setLocalStorage, TestUtils } from '../../utils/test_utils'\nimport { TestApi } from '../../utils/TestApi'\nimport { KeyPair } from '../../../icc-x-api/crypto/RSA'\nimport { CryptoPrimitives } from '../../../icc-x-api/crypto/CryptoPrimitives'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { MaintenanceTaskAfterDateFilter } from '../../../icc-x-api/filters/MaintenanceTaskAfterDateFilter'\nimport { KeyPairUpdateRequest } from '../../../icc-x-api/maintenance/KeyPairUpdateRequest'\nimport initMasterApi = TestUtils.initMasterApi\nimport { SecureDelegation } from '../../../icc-api/model/SecureDelegation'\nimport AccessLevel = SecureDelegation.AccessLevelEnum\nimport { EntityShareRequest } from '../../../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { fingerprintV1 } from '../../../icc-x-api/crypto/utils'\n\nsetLocalStorage(fetch)\n\nconst FULL_WRITE = RequestedPermissionEnum.FULL_WRITE\n\ntype TestedEntity = 'Patient' | 'Contact' | 'HealthElement' | 'CalendarItem'\n\ninterface EntityFacade<T extends EncryptedEntity> {\n create: (api: Apis, record: Omit<T, 'rev'>) => Promise<T>\n get: (api: Apis, id: string) => Promise<T>\n share: (api: Apis, record: T, dataOwnerId: string) => Promise<T>\n isDecrypted: (entityToCheck: T) => Promise<boolean>\n}\n\ntype EntityCreator<T> = (api: Apis, id: string, user: User, patient?: Patient, delegateIds?: string[]) => Promise<T>\n\ninterface EntityFacades {\n Patient: EntityFacade<Patient>\n Contact: EntityFacade<Contact>\n HealthElement: EntityFacade<HealthElement>\n CalendarItem: EntityFacade<CalendarItem>\n}\n\ninterface EntityCreators {\n Patient: EntityCreator<Patient>\n Contact: EntityCreator<Contact>\n HealthElement: EntityCreator<HealthElement>\n CalendarItem: EntityCreator<CalendarItem>\n}\n\nconst facades: EntityFacades = {\n Patient: {\n create: async (api, r) => api.patientApi.createPatientWithUser(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.patientApi.getPatientWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.patientApi.shareWith(doId, r, await api.patientApi.decryptSecretIdsOf(r), { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.note != undefined\n },\n } as EntityFacade<Patient>,\n Contact: {\n create: async (api, r) => api.contactApi.createContactWithUser(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.contactApi.getContactWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.contactApi.shareWith(doId, r, { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.services?.[0].content != undefined && Object.entries(entityToCheck.services?.[0].content).length > 0\n },\n } as EntityFacade<Contact>,\n HealthElement: {\n create: async (api, r) => api.healthcareElementApi.createHealthElementWithUser(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.healthcareElementApi.getHealthElementWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.healthcareElementApi.shareWith(doId, r, { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.descr != undefined\n },\n } as EntityFacade<HealthElement>,\n CalendarItem: {\n create: async (api, r) => api.calendarItemApi.createCalendarItemWithHcParty(await api.userApi.getCurrentUser(), r),\n get: async (api, id) => api.calendarItemApi.getCalendarItemWithUser(await api.userApi.getCurrentUser(), id),\n share: async (api, r, doId) => {\n return await api.calendarItemApi.shareWith(doId, r, { requestedPermissions: FULL_WRITE })\n },\n isDecrypted: async (entityToCheck) => {\n return entityToCheck.title != undefined\n },\n } as EntityFacade<CalendarItem>,\n}\n\nconst users: { user: User; password: string }[] = []\nconst primitives = new WebCryptoPrimitives(webcrypto as any)\nlet delegateUser: User | undefined = undefined\nlet delegateHcp: HealthcareParty | undefined = undefined\nlet delegateHcpPassword: string | undefined = undefined\n\nlet userGivingAccessBack: User | undefined = undefined\nlet userGivingAccessBackPassword: string | undefined = undefined\nlet hcpGivingAccessBack: HealthcareParty | undefined = undefined\n\nconst entities: EntityCreators = {\n Patient: ({ patientApi }, id, user, _, delegateIds) => {\n return patientApi.newInstance(user, new Patient({ id, firstName: 'test', lastName: 'test', note: 'data', dateOfBirth: 20000101 }), {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n })\n },\n Contact: ({ contactApi }, id, user, patient, delegateIds) => {\n return contactApi.newInstance(\n user,\n patient!,\n new Contact({ id, services: [new Service({ label: 'svc', content: { fr: { stringValue: 'data' } } })] }),\n {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n }\n )\n },\n HealthElement: ({ healthcareElementApi }, id, user, patient, delegateIds) => {\n return healthcareElementApi.newInstance(user, patient!, new HealthElement({ id, descr: 'HE' }), {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n })\n },\n CalendarItem: ({ calendarItemApi }, id, user, patient, delegateIds) => {\n return calendarItemApi.newInstancePatient(user, patient!, new CalendarItem({ id, title: 'CI' }), {\n additionalDelegates: Object.fromEntries(delegateIds?.map((id) => [id, AccessLevel.WRITE]) ?? []),\n })\n },\n}\n\nconst userDefinitions: Record<string, (user: User, password: string, pair: KeyPair<CryptoKey>) => Promise<{ user: User; apis: Apis }>> = {\n 'one available key and one lost key recoverable through transfer keys': async (user, password, originalKey) => {\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const apiWithOnlyNewKey = await IcureApi.initialise(\n env!.iCureUrl,\n {\n username: user.login!,\n password,\n },\n new TestCryptoStrategies(newKey, {\n [fingerprintV1(ua2hex(await primitives.RSA.exportKey(originalKey.publicKey, 'spki')))]: true,\n }),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n const apis = await IcureApi.initialise(\n env!.iCureUrl,\n {\n username: user.login!,\n password,\n },\n new TestCryptoStrategies(originalKey, {\n [fingerprintV1(ua2hex(await primitives.RSA.exportKey(newKey.publicKey, 'spki')))]: true,\n }),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n expect(Object.keys(apis.cryptoApi.userKeysManager.getDecryptionKeys())).to.have.length(2)\n await apiWithOnlyNewKey.cryptoApi.forceReload()\n expect(Object.keys(apiWithOnlyNewKey.cryptoApi.userKeysManager.getDecryptionKeys())).to.have.length(2)\n return { user, apis: apiWithOnlyNewKey }\n },\n 'two available keys': async (user, password, originalKey) => {\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const apiWithOnlyNewKey = await IcureApi.initialise(\n env!.iCureUrl,\n { username: user.login!, password },\n new TestCryptoStrategies(newKey),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n ) // Initializes the new key for the data owner\n const keyStrings = await Promise.all(\n [originalKey, newKey].map(async (pair) => ({\n publicKey: ua2hex(await primitives.RSA.exportKey(pair.publicKey, 'spki')),\n privateKey: ua2hex(await primitives.RSA.exportKey(pair.privateKey, 'pkcs8')),\n }))\n )\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: user.healthcarePartyId ?? user.patientId!,\n pairs: keyStrings.map((key) => {\n return { keyPair: key, shaVersion: ShaVersion.Sha256 }\n }),\n },\n ])\n const apis = await IcureApi.initialise(env!.iCureUrl, { username: user.login!, password }, new TestCryptoStrategies(), webcrypto as any, fetch, {\n entryKeysFactory: storage.keyFactory,\n keyStorage: storage.keyStorage,\n storage: storage.storage,\n })\n return { user, apis }\n },\n 'a single available key in old format': async (user, password, originalKey) => ({\n user,\n apis: await TestApi(env.iCureUrl, user.login!, password, webcrypto as any, originalKey),\n }),\n 'one lost key and one available key': async (user, password) => {\n const newKeyPair = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const apis = await TestApi(env.iCureUrl, user.login!, password, webcrypto as any, newKeyPair)\n await apis.icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(user, newKeyPair)\n return { user, apis }\n },\n 'one lost key and one upgraded available key thanks to delegate who gave access back to previous data': async (user, password) => {\n const newKeyPair = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const api = await TestApi(env.iCureUrl, user.login!, password, webcrypto as any, newKeyPair)\n await api.icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(user, newKeyPair)\n const giveAccessBackApi = apis['givingAccessBack']\n const keyPairUpdateRequests = (\n await giveAccessBackApi.maintenanceTaskApi.filterMaintenanceTasksByWithUser(\n userGivingAccessBack!,\n undefined,\n undefined,\n new FilterChainMaintenanceTask({\n filter: new MaintenanceTaskAfterDateFilter({\n date: new Date().getTime() - 100000,\n }),\n })\n )\n ).rows!.map((x) => KeyPairUpdateRequest.fromMaintenanceTask(x))\n const concernedRequest = keyPairUpdateRequests.find((x) => x.concernedDataOwnerId === (user.healthcarePartyId ?? user.patientId))\n if (!concernedRequest) throw new Error('Could not find maintenance task')\n await giveAccessBackApi.icureMaintenanceTaskApi.applyKeyPairUpdate(concernedRequest)\n\n await api.cryptoApi.forceReload()\n\n return { user, apis: api }\n },\n}\n\nasync function createPartialsForHcp(\n entityFacades: EntityFacades,\n entityCreators: EntityCreators,\n user: User,\n password: string\n): Promise<KeyPair<CryptoKey>> {\n const key = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const api1 = await TestApi(env!.iCureUrl, user.login!, password, webcrypto as any, key)\n await Object.entries(entityFacades).reduce(async (p, f) => {\n await p\n const type = f[0]\n const facade = f[1]\n const parent = type !== 'Patient' ? await api1.patientApi.getPatientWithUser(user, `partial-${user.id}-Patient`) : undefined\n const record = await entityCreators[type as TestedEntity](api1, `partial-${user.id}-${type}`, user, parent, [hcpGivingAccessBack!.id!])\n await facade.create(api1, record)\n }, Promise.resolve())\n return key\n}\n\nasync function createPartialsForPatient(\n entityFacades: EntityFacades,\n entityCreators: EntityCreators,\n user: User,\n password: string,\n patientCreatorUser: User,\n patientCreatorApis: Apis\n): Promise<KeyPair<CryptoKey>> {\n const key = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const api1 = await TestApi(env!.iCureUrl, user.login!, password, webcrypto as any, key)\n const pat = await patientCreatorApis.patientApi.getPatientWithUser(patientCreatorUser, user.patientId!)\n await patientCreatorApis.patientApi.shareWith(user.patientId!, pat, await patientCreatorApis.patientApi.decryptSecretIdsOf(pat), {\n requestedPermissions: FULL_WRITE,\n })\n await Object.entries(entityFacades)\n .filter((it) => it[0] !== 'Patient')\n .reduce(async (p, f) => {\n await p\n const type = f[0]\n const facade = f[1]\n const parent = await api1.patientApi.getPatientWithUser(user, user.patientId!)\n const record = await entityCreators[type as TestedEntity](api1, `partial-${user.id}-${type}`, user, parent, [hcpGivingAccessBack!.id!])\n await facade.create(api1, record)\n }, Promise.resolve())\n return key\n}\n\nlet env: TestVars\nlet apis: { [key: string]: Apis }\n\ndescribe('Full crypto test - Creation scenarios', async function () {\n before(async function () {\n this.timeout(6000000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n\n const api = await initMasterApi(env!)\n const user = await api.userApi.getCurrentUser()\n const dataOwnerId = api.dataOwnerApi.getDataOwnerIdOf(user)\n\n const { userApi, patientApi, healthcarePartyApi, cryptoApi } = api\n\n delegateHcp = await healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: 'test', lastName: 'test' }))\n delegateUser = await userApi.createUser(\n new User({\n id: `user-${uuid()}-hcp`,\n login: `hcp-delegate-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: delegateHcp.id,\n })\n )\n delegateHcpPassword = await userApi.getToken(delegateUser!.id!, uuid())\n\n hcpGivingAccessBack = await healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: 'test', lastName: 'test' }))\n userGivingAccessBack = await userApi.createUser(\n new User({\n id: `user-${uuid()}-hcp`,\n login: `hcp-giving-access-back-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcpGivingAccessBack.id,\n })\n )\n userGivingAccessBackPassword = await userApi.getToken(userGivingAccessBack!.id!, uuid())\n\n apis = {\n delegate: await TestApi(env.iCureUrl!, delegateUser.login!, delegateHcpPassword, webcrypto as any),\n givingAccessBack: await TestApi(env.iCureUrl!, userGivingAccessBack.login!, userGivingAccessBackPassword, webcrypto as any),\n }\n\n await Object.entries(userDefinitions).reduce(async (p, [login, creationProcess]) => {\n await p\n const newPatientEmail = getTempEmail()\n const patientToCreate = await patientApi.newInstance(user, new Patient({ id: uuid(), firstName: 'test', lastName: 'test' }))\n const patient = await patientApi.createPatientWithUser(user, patientToCreate)\n\n const newHcpEmail = getTempEmail()\n const hcp = await healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: 'test', lastName: 'test' }))\n\n const newPatientUser = await userApi.createUser(\n new User({\n id: `user-${uuid()}-patient`,\n name: `patient-${login}`,\n login: newPatientEmail,\n email: newPatientEmail,\n status: 'ACTIVE',\n patientId: patient.id,\n })\n )\n const newPatientUserPassword = await userApi.getToken(newPatientUser!.id!, uuid())\n\n const newHcpUser = await userApi.createUser(\n new User({\n id: `user-${uuid()}-hcp`,\n login: newHcpEmail,\n email: newHcpEmail,\n name: `hcp-${login}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n const newHcpUserPassword = await userApi.getToken(newHcpUser!.id!, uuid())\n\n const originalKeyPat = await createPartialsForPatient(facades, entities, newPatientUser, newPatientUserPassword, user, api)\n const originalKeyHcp = await createPartialsForHcp(facades, entities, newHcpUser, newHcpUserPassword)\n\n const patDetails = await creationProcess(newPatientUser, newPatientUserPassword, originalKeyPat)\n const hcpDetails = await creationProcess(newHcpUser, newHcpUserPassword, originalKeyHcp)\n\n users.push({ user: patDetails.user, password: newPatientUserPassword })\n apis[patDetails.user.name!] = patDetails.apis\n users.push({ user: hcpDetails.user, password: newHcpUserPassword })\n apis[hcpDetails.user.name!] = hcpDetails.apis\n }, Promise.resolve())\n\n await users\n .filter((it) => it.user.id!.endsWith('patient'))\n .map((it) => it.user)\n .reduce(async (prev, it) => {\n await prev\n const otherUsers = users.filter((u) => u.user.id!.endsWith('patient') && u.user.id !== it.id).map((u) => u.user)\n\n await otherUsers.reduce(async (p, u) => {\n await p\n const patientToShare = await facades.Patient.get(api, it.patientId!)\n const sharedPatient = await facades.Patient.share(api, patientToShare, u.patientId!)\n return Promise.resolve()\n }, Promise.resolve())\n\n return Promise.resolve()\n }, Promise.resolve())\n })\n ;['patient', 'hcp'].forEach((uType) => {\n Object.keys(userDefinitions).forEach((uId) => {\n Object.entries(facades).forEach((f) => {\n it(`Create ${f[0]} as a ${uType} with ${uId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade: EntityFacade<any> = f[1]\n const api = apis[`${uType}-${uId}`]\n\n const parent =\n f[0] !== 'Patient'\n ? uType === 'patient'\n ? await api.patientApi.getPatientWithUser(user, user.patientId!)\n : await api.patientApi.getPatientWithUser(user, `${user.id}-Patient`)\n : undefined\n const record = await entities[f[0] as TestedEntity](api, `${user.id}-${f[0]}`, user, parent)\n const entity = await facade.create(api, record)\n const retrieved = await facade.get(api, entity.id)\n\n expect(entity.id).to.be.not.null\n expect(entity.rev).to.equal(retrieved.rev)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n it(`Create ${f[0]} as delegate with delegation for ${uType} with ${uId}`, async function () {\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade: EntityFacade<any> = f[1]\n\n const api = apis['delegate']\n const patApi = apis[`${uType}-${uId}`]\n const dataOwnerId = api.dataOwnerApi.getDataOwnerIdOf(user)\n const dataOwner = (await patApi.dataOwnerApi.getCryptoActorStub(dataOwnerId))!.stub\n\n const parent = f[0] !== 'Patient' ? await api.patientApi.getPatientWithUser(delegateUser!, `delegate-${user.id}-Patient`) : undefined\n\n const record = await entities[f[0] as TestedEntity](api, `delegate-${user.id}-${f[0]}`, delegateUser!, parent, [\n (user.patientId ?? user.healthcarePartyId ?? user.deviceId)!,\n ])\n const entity = await facade.create(api, record)\n const retrieved = await facade.get(api, entity.id)\n expect(entity.id).to.be.not.null\n expect(entity.rev).to.equal(retrieved.rev)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n })\n })\n })\n})\n\ndescribe('Full crypto test - Read/Share scenarios', async function () {\n ;['patient', 'hcp'].forEach((uType) => {\n Object.keys(userDefinitions).forEach((uId) => {\n Object.entries(facades).forEach((f) => {\n it(`Read ${f[0]} as the initial ${uType} with ${uId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n\n const retrievePromise = facade.get(api, `partial-${user.id}-${f[0]}`)\n const lostInitialKey = uId.includes('one lost key and one available key')\n if (uType === 'patient' && lostInitialKey && !isLiteTest()) {\n // Patient with lost key can't prove he has access to data: he will get an error\n let gaveError = false\n try {\n await retrievePromise\n } catch {\n gaveError = true\n }\n expect(gaveError).to.equal(true, 'Patient with lost key should not be able to retrieve data')\n } else {\n const entity = await retrievePromise\n expect(entity.id).to.equal(`partial-${user.id}-${f[0]}`)\n expect(await facade.isDecrypted(entity)).to.equal(!lostInitialKey) // data is accessible only with initial key for this test.\n }\n })\n it(`Read ${f[0]} as a ${uType} with ${uId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n\n const entity = await facade.get(api, `${user.id}-${f[0]}`)\n expect(entity.id).to.equal(`${user.id}-${f[0]}`)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n it(`Read ${f[0]} shared by delegate as a ${uType} with ${uId}`, async () => {\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n await api.cryptoApi.forceReload()\n const entity = await facade.get(api, `delegate-${user.id}-${f[0]}`)\n expect(entity.id).to.equal(`delegate-${user.id}-${f[0]}`)\n expect(await facade.isDecrypted(entity)).to.equal(true)\n })\n ;['patient', 'hcp'].forEach((duType) => {\n Object.keys(userDefinitions).forEach((duId) => {\n it(`Share ${f[0]} as a ${uType} with ${uId} to a ${duType} with ${duId}`, async function () {\n if (f[0] === 'Patient' && uType === 'patient') {\n this.skip()\n }\n const { user } = users.find((it) => it.user.name === `${uType}-${uId}`)!\n const { user: delUser } = users.find((it) => it.user.name === `${duType}-${duId}`)!\n const delegateDoId = delUser.healthcarePartyId ?? delUser.patientId\n const facade = f[1]\n const api = apis[`${uType}-${uId}`]\n const delApi = apis[`${duType}-${duId}`]\n // Data was created (in a previous test) after lost key -> fully accessible\n const entity = await facade.share(api, await facade.get(api, `${user.id}-${f[0]}`), delegateDoId)\n const retrieved = await facade.get(api, entity.id)\n expect(entity.rev).to.equal(retrieved.rev)\n\n await delApi.cryptoApi.forceReload()\n const obj = await facade.get(delApi, `${user.id}-${f[0]}`)\n expect(await delApi.cryptoApi.xapi.hasWriteAccess({ entity: obj, type: f[0] as any })).to.equal(true)\n expect(await facade.isDecrypted(obj)).to.equal(true)\n })\n })\n })\n })\n })\n })\n})\n"]}
|
|
@@ -25,6 +25,8 @@ const MaintenanceTaskAfterDateFilter_1 = require("../../../icc-x-api/filters/Mai
|
|
|
25
25
|
const KeyPairUpdateRequest_1 = require("../../../icc-x-api/maintenance/KeyPairUpdateRequest");
|
|
26
26
|
const types_1 = require("@icure/test-setup/types");
|
|
27
27
|
const utils_1 = require("../../../icc-x-api/crypto/utils");
|
|
28
|
+
const SecretIdUseOption_1 = require("../../../icc-x-api/crypto/SecretIdUseOption");
|
|
29
|
+
var UseAnyConfidential = SecretIdUseOption_1.SecretIdUseOption.UseAnyConfidential;
|
|
28
30
|
// Data was randomly generated, not based on any real key
|
|
29
31
|
const data = '77b3bb3ac6852a388b2aea8ba1794e63c95a87d10753afbdf8672b607b0ca7c03b39b30b2303bc417de1c78b326cf52810469914ea7dd8128b9f2e5d8f376cdb16b75a8e9dffb12b7c839d6fcf9ef8b6e220ab7973ad76e057038988d9a084f06a9d83cc9c3ee998ad0fcc317bb6c7a1bed8126ceb8463d59e84b50087d15d293970606cfe61f874e3f4efb182107aa971304a88b9821e74b1e6c88e7d0bb8882ab0ba35591e4e8d829fb973a26b480fe7432537b025c1177077689e86b5ff65b39a9d618e1cd8c129ae2b2a981664074301e9265e9842ec0c9e9a95f27a1066336578e06e3f3373d3a98b3b8182e55accc6795bbe9aaaf758179d09eccecc8a21f9f77e660a99e0e652cf39077ef083020d9c9d479fb6751de39e29feb7bcf9c73ee9e9d25f54683d55a82768f603b910b40ccb006d96c25f23ccf88e620c20d5495e11e83859d38bb5314a763c76149b3bcf6d987e6e98b83583f028fd6cfc363cb544673eb5d6cf5a7f9887d78a5a5d5b0a862ca3127a6d359a1a2ea8f332360fb7c4a8fe855eac200735322cd322eab431e659377ad9f9289a2d97152598333f4ca97e8003bdbc2d8b714a72a3bdd4f1b124674d6c2eda71b59f07f073de030795c562658c1a63e03d7de12f6ff57e328f83e05462c588ec7371af9b19f726f04162db61860e2c40e3d01b46cdab6f38a526ba555d09bdbde5702d6ae977f38e51314b20d333e84e645fc08ccc59be6e87aa349ec30e9b3a6c06c9b58693b8d67e8a7259be86b240431f44fb75c05d6a8578ffced3514fecc10e5ed7a052c85484d8b86276f7cd74a57402d79e0de85cb8006272b4c61d6f71ebe6cb039c0604fd4ab6bf2e5c686c5cb10be41a06087c3a598c6115153ad0ff6fd6644de8838b877b63a1c9ad348806e6e5e4962630ce84926b0596028c9bf4fb78cad55a0c7dac4e1b46eef6f76cea2707afc5499c055e56b9545501029b714cff01e3aea3ae955607b686d21f6c453bd6291627cad9502a1d200deb13ca47f45aae1a88c7ee288d5e59c10ea5aecdd681c1f30b67720ba045c6a1174b4b1bf2ba5af90a22d6be4f281d946666015dda5ad79a20bd0c7c43c4e52ddbe10776464e76ae2e883bc5cd2ba965c775227b3ce482f1f764a95a99888ca68c023a530df6ebe0193742f233db700a100cd568342a3d4bd648ee18b6d1de8a9b7cefdcee7858feb886c013286fbafd489d57a46f70b1b676bf6a7cf74a52f13c6d09a7b23cff8a366e78d35c5c69952445739fe1cf5a5815c111808d731d37f6a33f477cee2dcfbaccba65a43e1e1b5dad4c81549a1ebef5ac1bb5814cdf58ba5849ec66095f1e3bb5a1ea48f9fa746553c15580cf98f1a06f630d0b86b95711f3d9381d50711c1f6b8e63e677c77a21a772b921935ccb17a017ce4955e8fcf8fca4bb72e9c4457bf80c471004083676b1410e697b15db4ae9026b9dd2bc222faf9e68a9e4a2eb7bf1ffbd23b23500b1f97e49f1348f64a467fae59a0d2a34c4a7d084d445a86018a48aedad5b0f7b523e5e1af3d3d66a9323cd4fd1a6f1d78611a85204fb5baf09c5b3c559e6e7b574cec7d3a62d81f3b36c43f93de072fa8477b898e824aa18cf971983f931257dccd902fac7766ef934a2e942dfe6a4bb06b103fba46e77d15e780cc58ccc343b83b310f548f46e8a49ed1750722dade4c9acb8cbc0c0fa0de153';
|
|
30
32
|
const shares = [
|
|
@@ -92,7 +94,7 @@ describe('Shamir key recovery', function () {
|
|
|
92
94
|
const notariesIds = (yield Promise.all(notariesApis.map((x) => x.healthcarePartyApi.getCurrentHealthcareParty()))).map((x) => x.id);
|
|
93
95
|
const pat = yield api.patientApi.initConfidentialSecretId(yield api.patientApi.newInstance(user), user);
|
|
94
96
|
const descr = 'Confidential info';
|
|
95
|
-
const confidentialData = yield api.healthcareElementApi.createHealthElementWithUser(user, yield api.healthcareElementApi.newInstance(user, pat, { descr }, {
|
|
97
|
+
const confidentialData = yield api.healthcareElementApi.createHealthElementWithUser(user, yield api.healthcareElementApi.newInstance(user, pat, { descr }, { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }));
|
|
96
98
|
yield api.cryptoApi.shamirKeysManager.updateSelfSplits({ [(0, utils_1.fingerprintV1)(hierarchyApis.childCredentials.publicKey)]: { notariesIds, minShares: 3 } }, []);
|
|
97
99
|
const lostKeyStorage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
98
100
|
{
|