@icure/api 8.6.6 → 8.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccFormApi.d.ts +8 -0
- package/icc-api/api/IccFormApi.js +21 -0
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/model/CryptoActorStub.d.ts +2 -0
- package/icc-api/model/CryptoActorStub.js.map +1 -1
- package/icc-api/model/Device.d.ts +1 -0
- package/icc-api/model/Device.js.map +1 -1
- package/icc-api/model/HealthcareParty.d.ts +1 -0
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/Patient.d.ts +1 -0
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-x-api/crypto/CryptoStrategies.d.ts +2 -1
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js +2 -2
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/icc-form-x-api.js +51 -0
- package/test/icc-x-api/icc-form-x-api.js.map +1 -1
- package/test/support/CSM-729.d.ts +1 -0
- package/test/support/CSM-729.js +225 -0
- package/test/support/CSM-729.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-form-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-form-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAuI;AACvI,iCAA8B;AAC9B,+CAA6D;AAC7D,2CAA0C;AAC1C,yDAAqD;AAErD,mCAAmC;AACnC,mDAA+C;AAC/C,mEAA+D;AAC/D,2DAAuD;AACvD,+BAAqC;AACrC,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mDAAmE;AACnE,wFAAyF;AACzF,6DAAyD;AAEzD,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,Q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EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;YAE5C,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,0BAA0B,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAC/E,IAAA,aAAM,EAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;YAE7C,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,uBAAuB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAC7E,IAAA,aAAM,EAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;YAE9C,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,0BAA0B,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAC3E,IAAA,aAAM,EAAC,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;YAEzC,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,4BAA4B,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAC/E,IAAA,aAAM,EAAC,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;YAE3C,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,yBAAyB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YACzE,IAAA,aAAM,EAAC,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;QAC1C,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { describeNoLite, getEnvironmentInitializer, hcp1Username, hcp2Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport { IccPatientXApi, IccUserXApi } from '../../icc-x-api'\nimport { IccFormApi } from '../../icc-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { Form } from '../../icc-api/model/Form'\nimport { FormTemplate } from '../../icc-api/model/FormTemplate'\nimport { CodeStub } from '../../icc-api/model/CodeStub'\nimport { assert, expect } from 'chai'\nimport initApi = TestUtils.initApi\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { BasicAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { IdWithRev } from '../../icc-api/model/IdWithRev'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribe('icc-form-x-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n async function createPatient(patientApiForHcp: IccPatientXApi, hcpUser: User) {\n return patientApiForHcp.createPatientWithUser(\n hcpUser,\n await patientApiForHcp.newInstance(\n hcpUser,\n new Patient({\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n }\n\n it('Test', async () => {\n // Given\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n\n const userApi = new IccUserXApi(env.iCureUrl, {}, authProvider, null as any, fetch)\n const formApi = new IccFormApi(env.iCureUrl, {}, authProvider, fetch)\n\n const currentUser = await userApi.getCurrentUser()\n })\n\n it('Test findBy', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n cryptoApi: cryptoApiForHcp,\n dataOwnerApi: dateOwnerApiForHcp,\n formApi: formXApi,\n } = await initApi(env, hcp1Username)\n const hcpUser = await userApiForHcp.getCurrentUser()\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n\n const form = new Form({\n id: randomUUID(),\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: hcpUser.healthcarePartyId!,\n author: hcpUser.id,\n codes: [],\n tags: [],\n user: hcpUser.id,\n patient: patient.id,\n })\n const formToCreate = await formXApi.newInstance(hcpUser, patient, form)\n const createdForm = await formXApi.createForm(formToCreate)\n\n const foundItems: Form[] = (await formXApi.findBy(hcpUser.healthcarePartyId!, patient, false)) as Form[]\n const foundItemsUsingPost: Form[] = (await formXApi.findBy(hcpUser.healthcarePartyId!, patient, true)) as Form[]\n\n assert(foundItems.length == 1, 'Found items should be 1')\n assert(foundItems[0].id == createdForm.id, 'Found item should be the created one')\n\n assert(foundItemsUsingPost.length == 1, 'Found items using post should be 1')\n assert(foundItemsUsingPost[0].id == createdForm.id, 'Found item using post should be the created one')\n })\n\n it('Share with should work as expected', async () => {\n const api1 = await initApi(env!, hcp1Username)\n const user1 = await api1.userApi.getCurrentUser()\n const api2 = await initApi(env!, hcp2Username)\n const user2 = await api2.userApi.getCurrentUser()\n const samplePatient = await api1.patientApi.createPatientWithUser(\n user1,\n await api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const entity = await api1.formApi.createForm(await api1.formApi.newInstance(user1, samplePatient))\n await api2.formApi\n .getForm(entity.id!)\n .then(() => {\n throw new Error('Should not be able to get the entity')\n })\n .catch(() => {\n /* expected */\n })\n await api1.formApi.shareWith(user2.healthcarePartyId!, entity)\n const retrieved = await api2.formApi.getForm(entity.id!)\n expect((await api2.formApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id)\n })\n\n it('Tests for Form Templates', async () => {\n // Given\n const { formApi, userApi } = await initApi(env, hcp1Username)\n const guid = randomUUID()\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n const user = await userApi.getCurrentUser()\n\n const formTemplateToCreate = new FormTemplate({\n id: randomUUID(),\n guid: guid,\n author: user.id,\n name: 'My Test Template',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Description of the template',\n })\n\n // Create\n const createdTemplate = await formApi.createFormTemplate(formTemplateToCreate)\n expect(createdTemplate.id).to.not.be.undefined\n expect(createdTemplate.guid).to.equal(guid)\n expect(createdTemplate.name).to.equal('My Test Template')\n\n // Get\n const retrievedTemplate = await formApi.getFormTemplate(createdTemplate.id!)\n expect(retrievedTemplate.id).to.equal(createdTemplate.id)\n\n // Find all\n const allTemplates = await formApi.findFormTemplates()\n expect(allTemplates.map((t) => t.id)).to.include(createdTemplate.id)\n\n // Find by specialty\n const templatesBySpecialty = await formApi.findFormTemplatesBySpeciality(specialtyCode)\n expect(templatesBySpecialty.map((t) => t.id)).to.include(createdTemplate.id)\n expect(templatesBySpecialty.length).to.be.greaterThan(0)\n\n // Get by GUID (using getFormTemplatesByGuid)\n const templatesByGuid = await formApi.getFormTemplatesByGuid(guid, specialtyCode)\n expect(templatesByGuid.map((t) => t.id)).to.include(createdTemplate.id)\n\n // Update\n createdTemplate.name = 'Updated Name'\n const updatedTemplate = await formApi.updateFormTemplate(createdTemplate.id!, createdTemplate)\n expect(updatedTemplate.name).to.equal('Updated Name')\n\n // Delete\n await formApi.deleteFormTemplate(createdTemplate.id!)\n try {\n await formApi.getFormTemplate(createdTemplate.id!)\n assert.fail('Should have thrown an error')\n } catch (e) {\n // Expected\n }\n })\n\n describeNoLite('Form Templates in Group Tests', () => {\n it('should create, find, update and delete form templates in a group', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const guid = randomUUID()\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Use the existing test group ID\n const groupId = env.testGroupId\n\n const formTemplateToCreate = new FormTemplate({\n id: randomUUID(),\n guid: guid,\n author: currentUser.id,\n name: 'My Group Template',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Description of the group template',\n })\n\n // Create In Group\n const createdTemplate = await formApi.createFormTemplateInGroup(groupId, formTemplateToCreate)\n expect(createdTemplate.id).to.not.be.undefined\n expect(createdTemplate.guid).to.equal(guid)\n if (createdTemplate.group) {\n expect(createdTemplate.group.guid).to.equal(groupId)\n }\n\n // Get In Group\n const templatesInGroup = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n expect(templatesInGroup.map((t) => t.id)).to.include(createdTemplate.id)\n\n // Update In Group\n createdTemplate.name = 'Updated Group Name'\n const updatedTemplate = await formApi.updateFormTemplateInGroup(groupId, createdTemplate.id!, createdTemplate)\n expect(updatedTemplate.name).to.equal('Updated Group Name')\n\n // Delete In Group\n await formApi.deleteFormTemplateInGroup(groupId, updatedTemplate.id!, updatedTemplate.rev!)\n\n // Verify deletion\n const templatesInGroupAfterDelete = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n expect(templatesInGroupAfterDelete.map((t) => t.id)).to.not.include(createdTemplate.id)\n })\n })\n\n describeNoLite('Form Templates Batch Operations in Group Tests', () => {\n it('should create, get, and modify multiple form templates in a group (batch)', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const groupId = env.testGroupId\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Create multiple templates\n const templatesToCreate = [\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Batch Template 1',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'First batch template',\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Batch Template 2',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Second batch template',\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Batch Template 3',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Third batch template',\n }),\n ]\n\n // Create batch\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, templatesToCreate)\n expect(createdTemplates).to.have.lengthOf(3)\n expect(createdTemplates[0].name).to.equal('Batch Template 1')\n expect(createdTemplates[1].name).to.equal('Batch Template 2')\n expect(createdTemplates[2].name).to.equal('Batch Template 3')\n createdTemplates.forEach((template) => {\n expect(template.id).to.not.be.undefined\n expect(template.rev).to.not.be.undefined\n })\n\n // Get batch by IDs\n const retrievedTemplates = await formApi.getFormTemplatesInGroup(\n groupId,\n createdTemplates.map((t) => t.id!)\n )\n expect(retrievedTemplates).to.have.lengthOf(3)\n expect(retrievedTemplates.map((t) => t.id)).to.have.members(createdTemplates.map((t) => t.id))\n\n // Modify batch\n const templatesForUpdate = createdTemplates.map((t, index) => ({\n ...t,\n name: `Updated Batch Template ${index + 1}`,\n }))\n const updatedTemplates = await formApi.modifyFormTemplatesInGroup(groupId, templatesForUpdate)\n expect(updatedTemplates).to.have.lengthOf(3)\n expect(updatedTemplates[0].name).to.equal('Updated Batch Template 1')\n expect(updatedTemplates[1].name).to.equal('Updated Batch Template 2')\n expect(updatedTemplates[2].name).to.equal('Updated Batch Template 3')\n\n // Clean up - delete batch\n const idsAndRevs = updatedTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, idsAndRevs)\n expect(deleteResults).to.have.lengthOf(3)\n deleteResults.forEach((result) => {\n expect(result.id).to.not.be.undefined\n expect(result.rev).to.not.be.undefined\n })\n })\n\n it('should delete and undelete multiple form templates in a group (batch)', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const groupId = env.testGroupId\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Create templates\n const templatesToCreate = [\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Delete Test Template 1',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Delete Test Template 2',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n ]\n\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, templatesToCreate)\n expect(createdTemplates).to.have.lengthOf(2)\n\n // Delete batch\n const idsAndRevs = createdTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, idsAndRevs)\n expect(deleteResults).to.have.lengthOf(2)\n\n // Verify deletion - templates should not be in active list\n const allTemplates = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n const activeIds = allTemplates.map((t) => t.id)\n createdTemplates.forEach((t) => {\n expect(activeIds).to.not.include(t.id)\n })\n\n // Undelete batch - use the updated revisions from delete results\n const undeleteIdsAndRevs = deleteResults.map((result) => new IdWithRev({ id: result.id!, rev: result.rev! }))\n const undeletedTemplates = await formApi.undeleteFormTemplatesInGroup(groupId, undeleteIdsAndRevs)\n expect(undeletedTemplates).to.have.lengthOf(2)\n undeletedTemplates.forEach((template) => {\n expect(template.id).to.not.be.undefined\n expect(template.rev).to.not.be.undefined\n expect(template.deletionDate).to.be.undefined\n })\n\n // Verify undelete - templates should be back in active list\n const templatesAfterUndelete = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n const activeIdsAfterUndelete = templatesAfterUndelete.map((t) => t.id)\n undeletedTemplates.forEach((t) => {\n expect(activeIdsAfterUndelete).to.include(t.id)\n })\n\n // Final cleanup - delete again\n const finalIdsAndRevs = undeletedTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n await formApi.deleteFormTemplatesInGroup(groupId, finalIdsAndRevs)\n })\n\n it('should purge multiple form templates in a group (batch)', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const groupId = env.testGroupId\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Create templates\n const templatesToCreate = [\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Purge Test Template 1',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Purge Test Template 2',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n ]\n\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, templatesToCreate)\n expect(createdTemplates).to.have.lengthOf(2)\n\n // First delete them (purge requires deletion first)\n const deleteIdsAndRevs = createdTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, deleteIdsAndRevs)\n expect(deleteResults).to.have.lengthOf(2)\n\n // Purge batch\n const purgeIdsAndRevs = deleteResults.map((result) => new IdWithRev({ id: result.id!, rev: result.rev! }))\n const purgeResults = await formApi.purgeFormTemplatesInGroup(groupId, purgeIdsAndRevs)\n expect(purgeResults).to.have.lengthOf(2)\n purgeResults.forEach((result) => {\n expect(result.id).to.not.be.undefined\n })\n\n // Verify purge - trying to get the templates should fail or return empty\n const retrievedTemplates = await formApi.getFormTemplatesInGroup(\n groupId,\n createdTemplates.map((t) => t.id!)\n )\n expect(retrievedTemplates).to.have.lengthOf(0)\n })\n\n it('should handle empty batch operations gracefully', async () => {\n // Given\n const { formApi } = await initApi(env)\n const groupId = env.testGroupId\n\n // Test with empty arrays\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, [])\n expect(createdTemplates).to.have.lengthOf(0)\n\n const modifiedTemplates = await formApi.modifyFormTemplatesInGroup(groupId, [])\n expect(modifiedTemplates).to.have.lengthOf(0)\n\n const retrievedTemplates = await formApi.getFormTemplatesInGroup(groupId, [])\n expect(retrievedTemplates).to.have.lengthOf(0)\n\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, [])\n expect(deleteResults).to.have.lengthOf(0)\n\n const undeleteResults = await formApi.undeleteFormTemplatesInGroup(groupId, [])\n expect(undeleteResults).to.have.lengthOf(0)\n\n const purgeResults = await formApi.purgeFormTemplatesInGroup(groupId, [])\n expect(purgeResults).to.have.lengthOf(0)\n })\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"icc-form-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-form-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAuI;AACvI,iCAA8B;AAC9B,+CAA6D;AAC7D,2CAA0C;AAC1C,yDAAqD;AAErD,mCAAmC;AACnC,mDAA+C;AAC/C,mEAA+D;AAC/D,2DAAuD;AACvD,+BAAqC;AACrC,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mDAAmE;AACnE,wFAAyF;AACzF,6DAAyD;AAEzD,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAA,cAAM,EAAC;;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,SAAe,aAAa,CAAC,gBAAgC,EAAE,OAAa;;YAC1E,OAAO,gBAAgB,CAAC,qBAAqB,CAC3C,OAAO,EACP,MAAM,gBAAgB,CAAC,WAAW,CAChC,OAAO,EACP,IAAI,iBAAO,CAAC;gBACV,EAAE,EAAE,IAAA,mBAAU,GAAE;gBAChB,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,MAAM;gBAChB,IAAI,EAAE,kBAAkB;aACzB,CAAC,CACH,CACF,CAAA;QACH,CAAC;KAAA;IAED,EAAE,CAAC,MAAM,EAAE,GAAS,EAAE;QACpB,QAAQ;QACR,MAAM,QAAQ,GAAG,GAAG,CAAC,gBAAgB,CAAC,yBAA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EnvironmentInitializer, hcp1Username, hcp2Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport { IccPatientXApi, IccUserXApi } from '../../icc-x-api'\nimport { IccFormApi } from '../../icc-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { Form } from '../../icc-api/model/Form'\nimport { FormTemplate } from '../../icc-api/model/FormTemplate'\nimport { CodeStub } from '../../icc-api/model/CodeStub'\nimport { assert, expect } from 'chai'\nimport initApi = TestUtils.initApi\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { BasicAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { IdWithRev } from '../../icc-api/model/IdWithRev'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribe('icc-form-x-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n async function createPatient(patientApiForHcp: IccPatientXApi, hcpUser: User) {\n return patientApiForHcp.createPatientWithUser(\n hcpUser,\n await patientApiForHcp.newInstance(\n hcpUser,\n new Patient({\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n }\n\n it('Test', async () => {\n // Given\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n\n const userApi = new IccUserXApi(env.iCureUrl, {}, authProvider, null as any, fetch)\n const formApi = new IccFormApi(env.iCureUrl, {}, authProvider, fetch)\n\n const currentUser = await userApi.getCurrentUser()\n })\n\n it('Test findBy', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n cryptoApi: cryptoApiForHcp,\n dataOwnerApi: dateOwnerApiForHcp,\n formApi: formXApi,\n } = await initApi(env, hcp1Username)\n const hcpUser = await userApiForHcp.getCurrentUser()\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n\n const form = new Form({\n id: randomUUID(),\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: hcpUser.healthcarePartyId!,\n author: hcpUser.id,\n codes: [],\n tags: [],\n user: hcpUser.id,\n patient: patient.id,\n })\n const formToCreate = await formXApi.newInstance(hcpUser, patient, form)\n const createdForm = await formXApi.createForm(formToCreate)\n\n const foundItems: Form[] = (await formXApi.findBy(hcpUser.healthcarePartyId!, patient, false)) as Form[]\n const foundItemsUsingPost: Form[] = (await formXApi.findBy(hcpUser.healthcarePartyId!, patient, true)) as Form[]\n\n assert(foundItems.length == 1, 'Found items should be 1')\n assert(foundItems[0].id == createdForm.id, 'Found item should be the created one')\n\n assert(foundItemsUsingPost.length == 1, 'Found items using post should be 1')\n assert(foundItemsUsingPost[0].id == createdForm.id, 'Found item using post should be the created one')\n })\n\n it('Share with should work as expected', async () => {\n const api1 = await initApi(env!, hcp1Username)\n const user1 = await api1.userApi.getCurrentUser()\n const api2 = await initApi(env!, hcp2Username)\n const user2 = await api2.userApi.getCurrentUser()\n const samplePatient = await api1.patientApi.createPatientWithUser(\n user1,\n await api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const entity = await api1.formApi.createForm(await api1.formApi.newInstance(user1, samplePatient))\n await api2.formApi\n .getForm(entity.id!)\n .then(() => {\n throw new Error('Should not be able to get the entity')\n })\n .catch(() => {\n /* expected */\n })\n await api1.formApi.shareWith(user2.healthcarePartyId!, entity)\n const retrieved = await api2.formApi.getForm(entity.id!)\n expect((await api2.formApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id)\n })\n\n it('Tests for Form Templates', async () => {\n // Given\n const { formApi, userApi } = await initApi(env, hcp1Username)\n const guid = randomUUID()\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n const user = await userApi.getCurrentUser()\n\n const formTemplateToCreate = new FormTemplate({\n id: randomUUID(),\n guid: guid,\n author: user.id,\n name: 'My Test Template',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Description of the template',\n })\n\n // Create\n const createdTemplate = await formApi.createFormTemplate(formTemplateToCreate)\n expect(createdTemplate.id).to.not.be.undefined\n expect(createdTemplate.guid).to.equal(guid)\n expect(createdTemplate.name).to.equal('My Test Template')\n\n // Get\n const retrievedTemplate = await formApi.getFormTemplate(createdTemplate.id!)\n expect(retrievedTemplate.id).to.equal(createdTemplate.id)\n\n // Find all\n const allTemplates = await formApi.findFormTemplates()\n expect(allTemplates.map((t) => t.id)).to.include(createdTemplate.id)\n\n // Find by specialty\n const templatesBySpecialty = await formApi.findFormTemplatesBySpeciality(specialtyCode)\n expect(templatesBySpecialty.map((t) => t.id)).to.include(createdTemplate.id)\n expect(templatesBySpecialty.length).to.be.greaterThan(0)\n\n // Get by GUID (using getFormTemplatesByGuid)\n const templatesByGuid = await formApi.getFormTemplatesByGuid(guid, specialtyCode)\n expect(templatesByGuid.map((t) => t.id)).to.include(createdTemplate.id)\n\n // Update\n createdTemplate.name = 'Updated Name'\n const updatedTemplate = await formApi.updateFormTemplate(createdTemplate.id!, createdTemplate)\n expect(updatedTemplate.name).to.equal('Updated Name')\n\n // Delete\n await formApi.deleteFormTemplate(createdTemplate.id!)\n try {\n await formApi.getFormTemplate(createdTemplate.id!)\n assert.fail('Should have thrown an error')\n } catch (e) {\n // Expected\n }\n })\n\n describeNoLite('Form Templates in Group Tests', () => {\n it('should create, find, update and delete form templates in a group', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const guid = randomUUID()\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Use the existing test group ID\n const groupId = env.testGroupId\n\n const formTemplateToCreate = new FormTemplate({\n id: randomUUID(),\n guid: guid,\n author: currentUser.id,\n name: 'My Group Template',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Description of the group template',\n })\n\n // Create In Group\n const createdTemplate = await formApi.createFormTemplateInGroup(groupId, formTemplateToCreate)\n expect(createdTemplate.id).to.not.be.undefined\n expect(createdTemplate.guid).to.equal(guid)\n if (createdTemplate.group) {\n expect(createdTemplate.group.guid).to.equal(groupId)\n }\n\n // Get In Group\n const templatesInGroup = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n expect(templatesInGroup.map((t) => t.id)).to.include(createdTemplate.id)\n\n // Update In Group\n createdTemplate.name = 'Updated Group Name'\n const updatedTemplate = await formApi.updateFormTemplateInGroup(groupId, createdTemplate.id!, createdTemplate)\n expect(updatedTemplate.name).to.equal('Updated Group Name')\n\n // Delete In Group\n await formApi.deleteFormTemplateInGroup(groupId, updatedTemplate.id!, updatedTemplate.rev!)\n\n // Verify deletion\n const templatesInGroupAfterDelete = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n expect(templatesInGroupAfterDelete.map((t) => t.id)).to.not.include(createdTemplate.id)\n })\n\n it('should find form templates by specialty in a group', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const groupId = env.testGroupId\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n const otherSpecialtyCode = 'SPECIALTY-' + randomUUID()\n\n const templatesToCreate = [\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Specialty Template 1',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Specialty Template 2',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Other Specialty Template',\n specialty: new CodeStub({ code: otherSpecialtyCode, type: 'specialty', version: '1' }),\n }),\n ]\n\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, templatesToCreate)\n expect(createdTemplates).to.have.lengthOf(3)\n\n // When: find by specialty\n const templatesBySpecialty = await formApi.getFormTemplatesBySpecialtyInGroup(groupId, specialtyCode)\n\n // Then: should return only the 2 templates with the matching specialty\n expect(templatesBySpecialty.map((t) => t.id)).to.include(createdTemplates[0].id)\n expect(templatesBySpecialty.map((t) => t.id)).to.include(createdTemplates[1].id)\n expect(templatesBySpecialty.map((t) => t.id)).to.not.include(createdTemplates[2].id)\n\n // When: find by other specialty\n const otherTemplates = await formApi.getFormTemplatesBySpecialtyInGroup(groupId, otherSpecialtyCode)\n\n // Then: should return only the 1 template with the other specialty\n expect(otherTemplates.map((t) => t.id)).to.include(createdTemplates[2].id)\n expect(otherTemplates.map((t) => t.id)).to.not.include(createdTemplates[0].id)\n\n // When: find by non-existent specialty\n const emptyResult = await formApi.getFormTemplatesBySpecialtyInGroup(groupId, 'NONEXISTENT-' + randomUUID())\n\n // Then: should return empty\n expect(emptyResult).to.have.lengthOf(0)\n\n // Cleanup\n const idsAndRevs = createdTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n await formApi.deleteFormTemplatesInGroup(groupId, idsAndRevs)\n })\n })\n\n describeNoLite('Form Templates Batch Operations in Group Tests', () => {\n it('should create, get, and modify multiple form templates in a group (batch)', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const groupId = env.testGroupId\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Create multiple templates\n const templatesToCreate = [\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Batch Template 1',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'First batch template',\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Batch Template 2',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Second batch template',\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Batch Template 3',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n descr: 'Third batch template',\n }),\n ]\n\n // Create batch\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, templatesToCreate)\n expect(createdTemplates).to.have.lengthOf(3)\n expect(createdTemplates[0].name).to.equal('Batch Template 1')\n expect(createdTemplates[1].name).to.equal('Batch Template 2')\n expect(createdTemplates[2].name).to.equal('Batch Template 3')\n createdTemplates.forEach((template) => {\n expect(template.id).to.not.be.undefined\n expect(template.rev).to.not.be.undefined\n })\n\n // Get batch by IDs\n const retrievedTemplates = await formApi.getFormTemplatesInGroup(\n groupId,\n createdTemplates.map((t) => t.id!)\n )\n expect(retrievedTemplates).to.have.lengthOf(3)\n expect(retrievedTemplates.map((t) => t.id)).to.have.members(createdTemplates.map((t) => t.id))\n\n // Modify batch\n const templatesForUpdate = createdTemplates.map((t, index) => ({\n ...t,\n name: `Updated Batch Template ${index + 1}`,\n }))\n const updatedTemplates = await formApi.modifyFormTemplatesInGroup(groupId, templatesForUpdate)\n expect(updatedTemplates).to.have.lengthOf(3)\n expect(updatedTemplates[0].name).to.equal('Updated Batch Template 1')\n expect(updatedTemplates[1].name).to.equal('Updated Batch Template 2')\n expect(updatedTemplates[2].name).to.equal('Updated Batch Template 3')\n\n // Clean up - delete batch\n const idsAndRevs = updatedTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, idsAndRevs)\n expect(deleteResults).to.have.lengthOf(3)\n deleteResults.forEach((result) => {\n expect(result.id).to.not.be.undefined\n expect(result.rev).to.not.be.undefined\n })\n })\n\n it('should delete and undelete multiple form templates in a group (batch)', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const groupId = env.testGroupId\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Create templates\n const templatesToCreate = [\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Delete Test Template 1',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Delete Test Template 2',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n ]\n\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, templatesToCreate)\n expect(createdTemplates).to.have.lengthOf(2)\n\n // Delete batch\n const idsAndRevs = createdTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, idsAndRevs)\n expect(deleteResults).to.have.lengthOf(2)\n\n // Verify deletion - templates should not be in active list\n const allTemplates = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n const activeIds = allTemplates.map((t) => t.id)\n createdTemplates.forEach((t) => {\n expect(activeIds).to.not.include(t.id)\n })\n\n // Undelete batch - use the updated revisions from delete results\n const undeleteIdsAndRevs = deleteResults.map((result) => new IdWithRev({ id: result.id!, rev: result.rev! }))\n const undeletedTemplates = await formApi.undeleteFormTemplatesInGroup(groupId, undeleteIdsAndRevs)\n expect(undeletedTemplates).to.have.lengthOf(2)\n undeletedTemplates.forEach((template) => {\n expect(template.id).to.not.be.undefined\n expect(template.rev).to.not.be.undefined\n expect(template.deletionDate).to.be.undefined\n })\n\n // Verify undelete - templates should be back in active list\n const templatesAfterUndelete = await formApi.getFormTemplatesByUserInGroup(groupId, currentUser.id!)\n const activeIdsAfterUndelete = templatesAfterUndelete.map((t) => t.id)\n undeletedTemplates.forEach((t) => {\n expect(activeIdsAfterUndelete).to.include(t.id)\n })\n\n // Final cleanup - delete again\n const finalIdsAndRevs = undeletedTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n await formApi.deleteFormTemplatesInGroup(groupId, finalIdsAndRevs)\n })\n\n it('should purge multiple form templates in a group (batch)', async () => {\n // Given\n const { formApi, userApi } = await initApi(env)\n const currentUser = await userApi.getCurrentUser()\n const groupId = env.testGroupId\n const specialtyCode = 'SPECIALTY-' + randomUUID()\n\n // Create templates\n const templatesToCreate = [\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Purge Test Template 1',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n new FormTemplate({\n id: randomUUID(),\n guid: randomUUID(),\n author: currentUser.id,\n name: 'Purge Test Template 2',\n specialty: new CodeStub({ code: specialtyCode, type: 'specialty', version: '1' }),\n }),\n ]\n\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, templatesToCreate)\n expect(createdTemplates).to.have.lengthOf(2)\n\n // First delete them (purge requires deletion first)\n const deleteIdsAndRevs = createdTemplates.map((t) => new IdWithRev({ id: t.id!, rev: t.rev! }))\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, deleteIdsAndRevs)\n expect(deleteResults).to.have.lengthOf(2)\n\n // Purge batch\n const purgeIdsAndRevs = deleteResults.map((result) => new IdWithRev({ id: result.id!, rev: result.rev! }))\n const purgeResults = await formApi.purgeFormTemplatesInGroup(groupId, purgeIdsAndRevs)\n expect(purgeResults).to.have.lengthOf(2)\n purgeResults.forEach((result) => {\n expect(result.id).to.not.be.undefined\n })\n\n // Verify purge - trying to get the templates should fail or return empty\n const retrievedTemplates = await formApi.getFormTemplatesInGroup(\n groupId,\n createdTemplates.map((t) => t.id!)\n )\n expect(retrievedTemplates).to.have.lengthOf(0)\n })\n\n it('should handle empty batch operations gracefully', async () => {\n // Given\n const { formApi } = await initApi(env)\n const groupId = env.testGroupId\n\n // Test with empty arrays\n const createdTemplates = await formApi.createFormTemplatesInGroup(groupId, [])\n expect(createdTemplates).to.have.lengthOf(0)\n\n const modifiedTemplates = await formApi.modifyFormTemplatesInGroup(groupId, [])\n expect(modifiedTemplates).to.have.lengthOf(0)\n\n const retrievedTemplates = await formApi.getFormTemplatesInGroup(groupId, [])\n expect(retrievedTemplates).to.have.lengthOf(0)\n\n const deleteResults = await formApi.deleteFormTemplatesInGroup(groupId, [])\n expect(deleteResults).to.have.lengthOf(0)\n\n const undeleteResults = await formApi.undeleteFormTemplatesInGroup(groupId, [])\n expect(undeleteResults).to.have.lengthOf(0)\n\n const purgeResults = await formApi.purgeFormTemplatesInGroup(groupId, [])\n expect(purgeResults).to.have.lengthOf(0)\n })\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'isomorphic-fetch';
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const test_utils_1 = require("../utils/test_utils");
|
|
13
|
+
const icc_x_api_1 = require("../../icc-x-api");
|
|
14
|
+
const chai_1 = require("chai");
|
|
15
|
+
require("isomorphic-fetch");
|
|
16
|
+
const types_1 = require("@icure/test-setup/types");
|
|
17
|
+
const chaiAsPromised = require("chai-as-promised");
|
|
18
|
+
const utils_1 = require("../../icc-x-api/crypto/utils");
|
|
19
|
+
const DataOwnerTypeEnum_1 = require("../../icc-api/model/DataOwnerTypeEnum");
|
|
20
|
+
const crypto_1 = require("crypto");
|
|
21
|
+
const TestStorage_1 = require("../utils/TestStorage");
|
|
22
|
+
const SecureDelegation_1 = require("../../icc-api/model/SecureDelegation");
|
|
23
|
+
var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
|
|
24
|
+
var initMasterApi = test_utils_1.TestUtils.initMasterApi;
|
|
25
|
+
(0, test_utils_1.setLocalStorage)(fetch);
|
|
26
|
+
(0, chai_1.use)(chaiAsPromised);
|
|
27
|
+
let env;
|
|
28
|
+
const untrustedKeyPropId = 'untrustedKey';
|
|
29
|
+
class TrustedKeysStrategy {
|
|
30
|
+
constructor(parentKeys, selfKeys, options = {}) {
|
|
31
|
+
this.parentKeys = parentKeys;
|
|
32
|
+
this.selfKeys = selfKeys;
|
|
33
|
+
this.options = options;
|
|
34
|
+
}
|
|
35
|
+
dataOwnerRequiresAnonymousDelegation(dataOwner) {
|
|
36
|
+
return dataOwner.type != DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp;
|
|
37
|
+
}
|
|
38
|
+
recoverAndVerifySelfHierarchyKeys(keysData, cryptoPrimitives, keyPairRecoverer) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (this.options.failRecoverAndVerifySelfHierarchyKeys) {
|
|
41
|
+
throw new Error("Shouldn't call this method now");
|
|
42
|
+
}
|
|
43
|
+
(0, chai_1.expect)(keysData).to.have.length(2);
|
|
44
|
+
const parentKeysWithFp = yield Promise.all(this.parentKeys.map((k) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return ({
|
|
46
|
+
trusted: k.trusted,
|
|
47
|
+
fp: (0, utils_1.fingerprintV1)(k.pub),
|
|
48
|
+
keypair: yield cryptoPrimitives.RSA.importKeyPair('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.priv)), 'spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.pub)), k.shaVersion),
|
|
49
|
+
});
|
|
50
|
+
})));
|
|
51
|
+
const selfKeysWithFp = yield Promise.all(this.selfKeys.map((k) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return ({
|
|
53
|
+
trusted: k.trusted,
|
|
54
|
+
fp: (0, utils_1.fingerprintV1)(k.pub),
|
|
55
|
+
keypair: yield cryptoPrimitives.RSA.importKeyPair('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.priv)), 'spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.pub)), k.shaVersion),
|
|
56
|
+
});
|
|
57
|
+
})));
|
|
58
|
+
return {
|
|
59
|
+
[keysData[0].dataOwner.dataOwner.id]: {
|
|
60
|
+
recoveredKeys: Object.fromEntries(parentKeysWithFp.map((k) => [k.fp, k.keypair])),
|
|
61
|
+
keyAuthenticity: Object.fromEntries(parentKeysWithFp.map((k) => [k.fp, k.trusted])),
|
|
62
|
+
},
|
|
63
|
+
[keysData[1].dataOwner.dataOwner.id]: {
|
|
64
|
+
recoveredKeys: Object.fromEntries(selfKeysWithFp.map((k) => [k.fp, k.keypair])),
|
|
65
|
+
keyAuthenticity: Object.fromEntries(selfKeysWithFp.map((k) => [k.fp, k.trusted])),
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
|
|
71
|
+
var _a;
|
|
72
|
+
const untrusted = new Set((_a = delegate.stub.cryptoActorProperties) === null || _a === void 0 ? void 0 : _a.flatMap((p) => {
|
|
73
|
+
var _a;
|
|
74
|
+
if (p.id == untrustedKeyPropId && ((_a = p.typedValue) === null || _a === void 0 ? void 0 : _a.stringValue) != undefined) {
|
|
75
|
+
return [p.typedValue.stringValue];
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
return Promise.resolve(publicKeys.filter((k) => !untrusted.has((0, utils_1.fingerprintV2)(k))));
|
|
82
|
+
}
|
|
83
|
+
generateNewKeyForDataOwner(self, cryptoPrimitives) {
|
|
84
|
+
if (this.options.overrideGenerateNewKeyForDataOwner) {
|
|
85
|
+
return this.options.overrideGenerateNewKeyForDataOwner();
|
|
86
|
+
}
|
|
87
|
+
return Promise.reject(new Error('Should not be called now'));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
describe('CSM-729', function () {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
before(function () {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
this.timeout(600000);
|
|
95
|
+
const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
|
|
96
|
+
env = yield initializer.execute((0, types_1.getEnvVariables)());
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
it('User with untrusted key', function () {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const { grandCredentials: parent, parentCredentials: hcp } = yield (0, test_utils_1.createHcpHierarchyApis)(env);
|
|
102
|
+
// Create some data to use the original keys
|
|
103
|
+
const initialApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: hcp.user, password: hcp.password }, new TrustedKeysStrategy([{ priv: parent.privateKey, pub: parent.publicKey, trusted: true, shaVersion: icc_x_api_1.ShaVersion.Sha1 }], [{ priv: hcp.privateKey, pub: hcp.publicKey, trusted: true, shaVersion: icc_x_api_1.ShaVersion.Sha1 }]), crypto_1.webcrypto, fetch, {
|
|
104
|
+
storage: new TestStorage_1.TestStorage(),
|
|
105
|
+
keyStorage: new TestStorage_1.TestKeyStorage(),
|
|
106
|
+
});
|
|
107
|
+
const user = yield initialApi.userApi.getCurrentUser();
|
|
108
|
+
const pat1 = yield initialApi.patientApi.createPatientWithUser(user, yield initialApi.patientApi.newInstance(user, {
|
|
109
|
+
firstName: 'John',
|
|
110
|
+
lastName: 'Doe',
|
|
111
|
+
note: 'Secret note',
|
|
112
|
+
}, {
|
|
113
|
+
additionalDelegates: { [parent.dataOwnerId]: AccessLevelEnum.WRITE },
|
|
114
|
+
}));
|
|
115
|
+
// Check exchange data was created as expected
|
|
116
|
+
const selfSelfXdata = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, hcp.dataOwnerId);
|
|
117
|
+
const selfParentXdata = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, parent.dataOwnerId);
|
|
118
|
+
(0, chai_1.expect)(selfSelfXdata).to.not.be.undefined;
|
|
119
|
+
(0, chai_1.expect)(selfParentXdata).to.not.be.undefined;
|
|
120
|
+
(0, chai_1.expect)(selfSelfXdata).to.have.length(1);
|
|
121
|
+
(0, chai_1.expect)(selfParentXdata).to.have.length(1);
|
|
122
|
+
// Prepare for new api with untrusted key
|
|
123
|
+
//// Mark self hcp keys as untrusted
|
|
124
|
+
let selfHcp = yield initialApi.healthcarePartyApi.getCurrentHealthcareParty();
|
|
125
|
+
selfHcp = yield initialApi.healthcarePartyApi.modifyHealthcareParty(Object.assign(Object.assign({}, selfHcp), { cryptoActorProperties: [
|
|
126
|
+
...(selfHcp.cryptoActorProperties || []),
|
|
127
|
+
{
|
|
128
|
+
id: untrustedKeyPropId,
|
|
129
|
+
typedValue: { stringValue: (0, utils_1.fingerprintV2)(hcp.publicKey) },
|
|
130
|
+
},
|
|
131
|
+
] }));
|
|
132
|
+
//// Mark parent hcp keys as untrusted and add new key (currently can't be done through crypto strategies)
|
|
133
|
+
const newParentKey = yield initialApi.cryptoApi.primitives.RSA.generateKeyPair(icc_x_api_1.ShaVersion.Sha256);
|
|
134
|
+
const newParentKeySpki = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newParentKey.publicKey, 'spki'));
|
|
135
|
+
const newParentKeyPkcs8 = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newParentKey.privateKey, 'pkcs8'));
|
|
136
|
+
const adminApi = yield initMasterApi(env);
|
|
137
|
+
let parentHcp = yield adminApi.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId);
|
|
138
|
+
parentHcp = yield adminApi.healthcarePartyApi.modifyHealthcareParty(Object.assign(Object.assign({}, parentHcp), { cryptoActorProperties: [
|
|
139
|
+
...(parentHcp.cryptoActorProperties || []),
|
|
140
|
+
{
|
|
141
|
+
id: untrustedKeyPropId,
|
|
142
|
+
typedValue: { stringValue: (0, utils_1.fingerprintV2)(parent.publicKey) },
|
|
143
|
+
},
|
|
144
|
+
], publicKeysForOaepWithSha256: [...(parentHcp.publicKeysForOaepWithSha256 || []), newParentKeySpki] }));
|
|
145
|
+
//// No need to invalidate exchange data, as untrusted keys are not used to validate it
|
|
146
|
+
// Setup new api
|
|
147
|
+
let didCreateNewKey = false;
|
|
148
|
+
const newHcpKey = yield initialApi.cryptoApi.primitives.RSA.generateKeyPair(icc_x_api_1.ShaVersion.Sha256);
|
|
149
|
+
const newHcpKeySpki = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newHcpKey.publicKey, 'spki'));
|
|
150
|
+
const newHcpKeyPkcs8 = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newHcpKey.privateKey, 'pkcs8'));
|
|
151
|
+
const apiWithUntrustedKeysStorages = {
|
|
152
|
+
// Using a new storage, simulates wiping the local storage
|
|
153
|
+
storage: new TestStorage_1.TestStorage(),
|
|
154
|
+
keyStorage: new TestStorage_1.TestKeyStorage(),
|
|
155
|
+
};
|
|
156
|
+
const apiWithUntrustedKey = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: hcp.user, password: hcp.password }, new TrustedKeysStrategy([
|
|
157
|
+
{ priv: parent.privateKey, pub: parent.publicKey, trusted: false, shaVersion: icc_x_api_1.ShaVersion.Sha1 },
|
|
158
|
+
{ priv: newParentKeyPkcs8, pub: newParentKeySpki, trusted: true, shaVersion: icc_x_api_1.ShaVersion.Sha256 },
|
|
159
|
+
], [{ priv: hcp.privateKey, pub: hcp.publicKey, trusted: false, shaVersion: icc_x_api_1.ShaVersion.Sha1 }], {
|
|
160
|
+
overrideGenerateNewKeyForDataOwner: () => {
|
|
161
|
+
didCreateNewKey = true;
|
|
162
|
+
return Promise.resolve(newHcpKey);
|
|
163
|
+
},
|
|
164
|
+
}), crypto_1.webcrypto, fetch, apiWithUntrustedKeysStorages);
|
|
165
|
+
(0, chai_1.expect)(didCreateNewKey).to.eq(true);
|
|
166
|
+
// Check all keys are available but only new keys are trusted
|
|
167
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey.healthcarePartyApi.getHealthcareParty(hcp.dataOwnerId))).to.have.members([newHcpKeySpki]);
|
|
168
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId))).to.have.members([newParentKeySpki]);
|
|
169
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getCurrentUserHierarchyAvailablePublicKeysHex()).to.have.members([
|
|
170
|
+
newHcpKeySpki,
|
|
171
|
+
hcp.publicKey,
|
|
172
|
+
parent.publicKey,
|
|
173
|
+
newParentKeySpki,
|
|
174
|
+
]);
|
|
175
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getCurrentUserAvailablePublicKeysHex(false)).to.have.members([
|
|
176
|
+
newHcpKeySpki,
|
|
177
|
+
hcp.publicKey,
|
|
178
|
+
]);
|
|
179
|
+
// Check can still read old data
|
|
180
|
+
const pat1Recovered = yield apiWithUntrustedKey.patientApi.getPatientWithUser(user, pat1.id);
|
|
181
|
+
(0, chai_1.expect)(pat1Recovered.note).to.eq('Secret note');
|
|
182
|
+
// Check can create new data
|
|
183
|
+
const pat2 = yield initialApi.patientApi.createPatientWithUser(user, yield initialApi.patientApi.newInstance(user, {
|
|
184
|
+
firstName: 'Joe',
|
|
185
|
+
lastName: 'Doe',
|
|
186
|
+
note: 'Secret note',
|
|
187
|
+
}, {
|
|
188
|
+
additionalDelegates: { [parent.dataOwnerId]: AccessLevelEnum.WRITE },
|
|
189
|
+
}));
|
|
190
|
+
// Check created new exchange data and only used the new trusted keys for it
|
|
191
|
+
const selfSelfXdata2 = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, hcp.dataOwnerId);
|
|
192
|
+
const selfParentXdata2 = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, parent.dataOwnerId);
|
|
193
|
+
(0, chai_1.expect)(selfSelfXdata2).to.not.be.undefined;
|
|
194
|
+
(0, chai_1.expect)(selfParentXdata2).to.not.be.undefined;
|
|
195
|
+
(0, chai_1.expect)(selfSelfXdata2).to.have.length(2);
|
|
196
|
+
(0, chai_1.expect)(selfParentXdata2).to.have.length(2);
|
|
197
|
+
const newSelfSelfXdata = selfSelfXdata2.filter((xd) => xd.id !== selfSelfXdata[0].id);
|
|
198
|
+
(0, chai_1.expect)(newSelfSelfXdata).to.have.length(1);
|
|
199
|
+
const newSelfSelfXDataUsedFps = Object.keys(newSelfSelfXdata[0].exchangeKey);
|
|
200
|
+
(0, chai_1.expect)(newSelfSelfXDataUsedFps).to.have.length(1);
|
|
201
|
+
(0, chai_1.expect)(newSelfSelfXDataUsedFps[0]).to.eq((0, utils_1.fingerprintV2)(newHcpKeySpki));
|
|
202
|
+
const newSelfParentXdata = selfParentXdata2.filter((xd) => xd.id !== selfParentXdata[0].id);
|
|
203
|
+
(0, chai_1.expect)(newSelfParentXdata).to.have.length(1);
|
|
204
|
+
const newSelfParentXDataUsedFps = Object.keys(newSelfParentXdata[0].exchangeKey);
|
|
205
|
+
(0, chai_1.expect)(newSelfParentXDataUsedFps).to.have.length(2);
|
|
206
|
+
(0, chai_1.expect)(newSelfParentXDataUsedFps).to.have.members([(0, utils_1.fingerprintV2)(newHcpKeySpki), (0, utils_1.fingerprintV2)(newParentKeySpki)]);
|
|
207
|
+
// Check after reinitialization with keys already in storage the "verified" situation is unchanged.
|
|
208
|
+
const apiWithUntrustedKey2 = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: hcp.user, password: hcp.password }, new TrustedKeysStrategy([], [], { failRecoverAndVerifySelfHierarchyKeys: true }), crypto_1.webcrypto, fetch, apiWithUntrustedKeysStorages);
|
|
209
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey2.healthcarePartyApi.getHealthcareParty(hcp.dataOwnerId))).to.have.members([newHcpKeySpki]);
|
|
210
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey2.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId))).to.have.members([newParentKeySpki]);
|
|
211
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getCurrentUserHierarchyAvailablePublicKeysHex()).to.have.members([
|
|
212
|
+
newHcpKeySpki,
|
|
213
|
+
hcp.publicKey,
|
|
214
|
+
parent.publicKey,
|
|
215
|
+
newParentKeySpki,
|
|
216
|
+
]);
|
|
217
|
+
(0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getCurrentUserAvailablePublicKeysHex(false)).to.have.members([
|
|
218
|
+
newHcpKeySpki,
|
|
219
|
+
hcp.publicKey,
|
|
220
|
+
]);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
//# sourceMappingURL=CSM-729.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CSM-729.js","sourceRoot":"","sources":["../../../test/support/CSM-729.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAmH;AACnH,+CAA0H;AAC1H,+B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,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;oBACvH,aAAa;oBACb,GAAG,CAAC,SAAS;iBACd,CAAC,CAAA;YACJ,CAAC;SAAA,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { createHcpHierarchyApis, getEnvironmentInitializer, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { CryptoPrimitives, CryptoStrategies, hex2ua, IcureApi, KeyPair, ShaVersion, ua2ab, ua2hex } from '../../icc-x-api'\nimport { expect, use as chaiUse } from 'chai'\nimport 'isomorphic-fetch'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { fingerprintV1, fingerprintV2 } from '../../icc-x-api/crypto/utils'\nimport { KeyPairRecoverer } from '../../icc-x-api/crypto/KeyPairRecoverer'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\nimport { webcrypto } from 'crypto'\nimport { TestKeyStorage, TestStorage } from '../utils/TestStorage'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport initMasterApi = TestUtils.initMasterApi\n\nsetLocalStorage(fetch)\n\nchaiUse(chaiAsPromised)\n\nlet env: TestVars\n\nconst untrustedKeyPropId = 'untrustedKey'\n\nclass TrustedKeysStrategy implements CryptoStrategies {\n constructor(\n private readonly parentKeys: { pub: string; priv: string; trusted: boolean; shaVersion: ShaVersion }[],\n private readonly selfKeys: { pub: string; priv: string; trusted: boolean; shaVersion: ShaVersion }[],\n private readonly options: {\n failRecoverAndVerifySelfHierarchyKeys?: boolean\n overrideGenerateNewKeyForDataOwner?: () => Promise<KeyPair<CryptoKey> | boolean | 'keyless'>\n } = {}\n ) {}\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return dataOwner.type != DataOwnerTypeEnum.Hcp\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives,\n keyPairRecoverer: KeyPairRecoverer\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n if (this.options.failRecoverAndVerifySelfHierarchyKeys) {\n throw new Error(\"Shouldn't call this method now\")\n }\n expect(keysData).to.have.length(2)\n const parentKeysWithFp = await Promise.all(\n this.parentKeys.map(async (k) => ({\n trusted: k.trusted,\n fp: fingerprintV1(k.pub),\n keypair: await cryptoPrimitives.RSA.importKeyPair('pkcs8', ua2ab(hex2ua(k.priv)), 'spki', ua2ab(hex2ua(k.pub)), k.shaVersion),\n }))\n )\n const selfKeysWithFp = await Promise.all(\n this.selfKeys.map(async (k) => ({\n trusted: k.trusted,\n fp: fingerprintV1(k.pub),\n keypair: await cryptoPrimitives.RSA.importKeyPair('pkcs8', ua2ab(hex2ua(k.priv)), 'spki', ua2ab(hex2ua(k.pub)), k.shaVersion),\n }))\n )\n return {\n [keysData[0].dataOwner.dataOwner.id!]: {\n recoveredKeys: Object.fromEntries(parentKeysWithFp.map((k) => [k.fp, k.keypair])),\n keyAuthenticity: Object.fromEntries(parentKeysWithFp.map((k) => [k.fp, k.trusted])),\n },\n [keysData[1].dataOwner.dataOwner.id!]: {\n recoveredKeys: Object.fromEntries(selfKeysWithFp.map((k) => [k.fp, k.keypair])),\n keyAuthenticity: Object.fromEntries(selfKeysWithFp.map((k) => [k.fp, k.trusted])),\n },\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n const untrusted = new Set(\n delegate.stub.cryptoActorProperties?.flatMap((p) => {\n if (p.id == untrustedKeyPropId && p.typedValue?.stringValue != undefined) {\n return [p.typedValue.stringValue]\n } else {\n return []\n }\n })\n )\n return Promise.resolve(publicKeys.filter((k) => !untrusted.has(fingerprintV2(k))))\n }\n\n generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean | 'keyless'> {\n if (this.options.overrideGenerateNewKeyForDataOwner) {\n return this.options.overrideGenerateNewKeyForDataOwner()\n }\n return Promise.reject(new Error('Should not be called now'))\n }\n}\n\ndescribe('CSM-729', async function () {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('User with untrusted key', async function () {\n const { grandCredentials: parent, parentCredentials: hcp } = await createHcpHierarchyApis(env)\n // Create some data to use the original keys\n const initialApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: hcp.user, password: hcp.password },\n new TrustedKeysStrategy(\n [{ priv: parent.privateKey, pub: parent.publicKey, trusted: true, shaVersion: ShaVersion.Sha1 }],\n [{ priv: hcp.privateKey, pub: hcp.publicKey, trusted: true, shaVersion: ShaVersion.Sha1 }]\n ),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n const user = await initialApi.userApi.getCurrentUser()\n const pat1 = await initialApi.patientApi.createPatientWithUser(\n user,\n await initialApi.patientApi.newInstance(\n user,\n {\n firstName: 'John',\n lastName: 'Doe',\n note: 'Secret note',\n },\n {\n additionalDelegates: { [parent.dataOwnerId]: AccessLevelEnum.WRITE },\n }\n )\n )\n // Check exchange data was created as expected\n const selfSelfXdata = await initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, hcp.dataOwnerId)\n const selfParentXdata = await initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, parent.dataOwnerId)\n expect(selfSelfXdata).to.not.be.undefined\n expect(selfParentXdata).to.not.be.undefined\n expect(selfSelfXdata).to.have.length(1)\n expect(selfParentXdata).to.have.length(1)\n // Prepare for new api with untrusted key\n //// Mark self hcp keys as untrusted\n let selfHcp = await initialApi.healthcarePartyApi.getCurrentHealthcareParty()\n selfHcp = await initialApi.healthcarePartyApi.modifyHealthcareParty({\n ...selfHcp,\n cryptoActorProperties: [\n ...(selfHcp.cryptoActorProperties || []),\n {\n id: untrustedKeyPropId,\n typedValue: { stringValue: fingerprintV2(hcp.publicKey) },\n },\n ],\n })\n //// Mark parent hcp keys as untrusted and add new key (currently can't be done through crypto strategies)\n const newParentKey = await initialApi.cryptoApi.primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const newParentKeySpki = ua2hex(await initialApi.cryptoApi.primitives.RSA.exportKey(newParentKey.publicKey, 'spki'))\n const newParentKeyPkcs8 = ua2hex(await initialApi.cryptoApi.primitives.RSA.exportKey(newParentKey.privateKey, 'pkcs8'))\n const adminApi = await initMasterApi(env)\n let parentHcp = await adminApi.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId)\n parentHcp = await adminApi.healthcarePartyApi.modifyHealthcareParty({\n // Hcp normally doesn't have right to modify parent, depends on permissions\n ...parentHcp,\n cryptoActorProperties: [\n ...(parentHcp.cryptoActorProperties || []),\n {\n id: untrustedKeyPropId,\n typedValue: { stringValue: fingerprintV2(parent.publicKey) },\n },\n ],\n publicKeysForOaepWithSha256: [...(parentHcp.publicKeysForOaepWithSha256 || []), newParentKeySpki],\n })\n //// No need to invalidate exchange data, as untrusted keys are not used to validate it\n // Setup new api\n let didCreateNewKey = false\n const newHcpKey = await initialApi.cryptoApi.primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const newHcpKeySpki = ua2hex(await initialApi.cryptoApi.primitives.RSA.exportKey(newHcpKey.publicKey, 'spki'))\n const newHcpKeyPkcs8 = ua2hex(await initialApi.cryptoApi.primitives.RSA.exportKey(newHcpKey.privateKey, 'pkcs8'))\n const apiWithUntrustedKeysStorages = {\n // Using a new storage, simulates wiping the local storage\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n const apiWithUntrustedKey = await IcureApi.initialise(\n env.iCureUrl,\n { username: hcp.user, password: hcp.password },\n new TrustedKeysStrategy(\n [\n { priv: parent.privateKey, pub: parent.publicKey, trusted: false, shaVersion: ShaVersion.Sha1 },\n { priv: newParentKeyPkcs8, pub: newParentKeySpki, trusted: true, shaVersion: ShaVersion.Sha256 },\n ],\n [{ priv: hcp.privateKey, pub: hcp.publicKey, trusted: false, shaVersion: ShaVersion.Sha1 }],\n {\n overrideGenerateNewKeyForDataOwner: () => {\n didCreateNewKey = true\n return Promise.resolve(newHcpKey)\n },\n }\n ),\n webcrypto as any,\n fetch,\n apiWithUntrustedKeysStorages\n )\n expect(didCreateNewKey).to.eq(true)\n // Check all keys are available but only new keys are trusted\n expect(\n await apiWithUntrustedKey.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(\n await apiWithUntrustedKey.healthcarePartyApi.getHealthcareParty(hcp.dataOwnerId)\n )\n ).to.have.members([newHcpKeySpki])\n expect(\n await apiWithUntrustedKey.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(\n await apiWithUntrustedKey.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId)\n )\n ).to.have.members([newParentKeySpki])\n expect(await apiWithUntrustedKey.cryptoApi.userKeysManager.getCurrentUserHierarchyAvailablePublicKeysHex()).to.have.members([\n newHcpKeySpki,\n hcp.publicKey,\n parent.publicKey,\n newParentKeySpki,\n ])\n expect(await apiWithUntrustedKey.cryptoApi.userKeysManager.getCurrentUserAvailablePublicKeysHex(false)).to.have.members([\n newHcpKeySpki,\n hcp.publicKey,\n ])\n // Check can still read old data\n const pat1Recovered = await apiWithUntrustedKey.patientApi.getPatientWithUser(user, pat1.id!)\n expect(pat1Recovered.note).to.eq('Secret note')\n // Check can create new data\n const pat2 = await initialApi.patientApi.createPatientWithUser(\n user,\n await initialApi.patientApi.newInstance(\n user,\n {\n firstName: 'Joe',\n lastName: 'Doe',\n note: 'Secret note',\n },\n {\n additionalDelegates: { [parent.dataOwnerId]: AccessLevelEnum.WRITE },\n }\n )\n )\n // Check created new exchange data and only used the new trusted keys for it\n const selfSelfXdata2 = await initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, hcp.dataOwnerId)\n const selfParentXdata2 = await initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, parent.dataOwnerId)\n expect(selfSelfXdata2).to.not.be.undefined\n expect(selfParentXdata2).to.not.be.undefined\n expect(selfSelfXdata2).to.have.length(2)\n expect(selfParentXdata2).to.have.length(2)\n const newSelfSelfXdata = selfSelfXdata2.filter((xd) => xd.id !== selfSelfXdata[0].id)!\n expect(newSelfSelfXdata).to.have.length(1)\n const newSelfSelfXDataUsedFps = Object.keys(newSelfSelfXdata[0].exchangeKey)\n expect(newSelfSelfXDataUsedFps).to.have.length(1)\n expect(newSelfSelfXDataUsedFps[0]).to.eq(fingerprintV2(newHcpKeySpki))\n const newSelfParentXdata = selfParentXdata2.filter((xd) => xd.id !== selfParentXdata[0].id)!\n expect(newSelfParentXdata).to.have.length(1)\n const newSelfParentXDataUsedFps = Object.keys(newSelfParentXdata[0].exchangeKey)\n expect(newSelfParentXDataUsedFps).to.have.length(2)\n expect(newSelfParentXDataUsedFps).to.have.members([fingerprintV2(newHcpKeySpki), fingerprintV2(newParentKeySpki)])\n // Check after reinitialization with keys already in storage the \"verified\" situation is unchanged.\n const apiWithUntrustedKey2 = await IcureApi.initialise(\n env.iCureUrl,\n { username: hcp.user, password: hcp.password },\n new TrustedKeysStrategy([], [], { failRecoverAndVerifySelfHierarchyKeys: true }),\n webcrypto as any,\n fetch,\n apiWithUntrustedKeysStorages\n )\n expect(\n await apiWithUntrustedKey2.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(\n await apiWithUntrustedKey2.healthcarePartyApi.getHealthcareParty(hcp.dataOwnerId)\n )\n ).to.have.members([newHcpKeySpki])\n expect(\n await apiWithUntrustedKey2.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(\n await apiWithUntrustedKey2.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId)\n )\n ).to.have.members([newParentKeySpki])\n expect(await apiWithUntrustedKey2.cryptoApi.userKeysManager.getCurrentUserHierarchyAvailablePublicKeysHex()).to.have.members([\n newHcpKeySpki,\n hcp.publicKey,\n parent.publicKey,\n newParentKeySpki,\n ])\n expect(await apiWithUntrustedKey2.cryptoApi.userKeysManager.getCurrentUserAvailablePublicKeysHex(false)).to.have.members([\n newHcpKeySpki,\n hcp.publicKey,\n ])\n })\n})\n"]}
|