@icure/api 7.1.34 → 7.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/icc-api/api/IccAuthApi.d.ts +1 -0
  2. package/icc-api/api/IccAuthApi.js +1 -0
  3. package/icc-api/api/IccAuthApi.js.map +1 -1
  4. package/icc-x-api/index.d.ts +22 -29
  5. package/icc-x-api/index.js +60 -38
  6. package/icc-x-api/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
  9. package/test/icc-api/api/IccDocumentApi.js +200 -0
  10. package/test/icc-api/api/IccDocumentApi.js.map +1 -0
  11. package/test/icc-api/api/IccGroupApi.d.ts +1 -0
  12. package/test/icc-api/api/IccGroupApi.js +50 -0
  13. package/test/icc-api/api/IccGroupApi.js.map +1 -0
  14. package/test/icc-api/api/IccRoleApi.d.ts +1 -0
  15. package/test/icc-api/api/IccRoleApi.js +34 -0
  16. package/test/icc-api/api/IccRoleApi.js.map +1 -0
  17. package/test/icc-api/api/IccUserApi.d.ts +1 -0
  18. package/test/icc-api/api/IccUserApi.js +80 -0
  19. package/test/icc-api/api/IccUserApi.js.map +1 -0
  20. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
  21. package/test/icc-api/e2e/IccCalendarItemApi.js +45 -0
  22. package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
  23. package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
  24. package/test/icc-api/model/modelHelpersTest.js +45 -0
  25. package/test/icc-api/model/modelHelpersTest.js.map +1 -0
  26. package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
  27. package/test/icc-x-api/auth/group-switch-test.js +81 -0
  28. package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
  29. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
  30. package/test/icc-x-api/auth/jwt-concurrency-test.js +113 -0
  31. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
  32. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
  33. package/test/icc-x-api/auth/smart-auth-provider-test.js +222 -0
  34. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
  35. package/test/icc-x-api/crypto/KeyManager-test.d.ts +1 -0
  36. package/test/icc-x-api/crypto/KeyManager-test.js +225 -0
  37. package/test/icc-x-api/crypto/KeyManager-test.js.map +1 -0
  38. package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
  39. package/test/icc-x-api/crypto/concurrency.js +35 -0
  40. package/test/icc-x-api/crypto/concurrency.js.map +1 -0
  41. package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
  42. package/test/icc-x-api/crypto/crypto-utils.js +80 -0
  43. package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
  44. package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
  45. package/test/icc-x-api/crypto/cryptoTest.js +275 -0
  46. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
  47. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
  48. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +132 -0
  49. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
  50. package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
  51. package/test/icc-x-api/crypto/full-crypto-test.js +458 -0
  52. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
  53. package/test/icc-x-api/crypto/shamir.d.ts +2 -0
  54. package/test/icc-x-api/crypto/shamir.js +156 -0
  55. package/test/icc-x-api/crypto/shamir.js.map +1 -0
  56. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
  57. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +75 -0
  58. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
  59. package/test/icc-x-api/data-compatibility-test-7to6.d.ts +1 -0
  60. package/test/icc-x-api/data-compatibility-test-7to6.js +343 -0
  61. package/test/icc-x-api/data-compatibility-test-7to6.js.map +1 -0
  62. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
  63. package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
  64. package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
  65. package/test/icc-x-api/filters/filters.d.ts +1 -0
  66. package/test/icc-x-api/filters/filters.js +49 -0
  67. package/test/icc-x-api/filters/filters.js.map +1 -0
  68. package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
  69. package/test/icc-x-api/icc-accesslog-x-api.js +121 -0
  70. package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
  71. package/test/icc-x-api/icc-auth-api.d.ts +1 -0
  72. package/test/icc-x-api/icc-auth-api.js +46 -0
  73. package/test/icc-x-api/icc-auth-api.js.map +1 -0
  74. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
  75. package/test/icc-x-api/icc-calendar-item-x-api.js +146 -0
  76. package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
  77. package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
  78. package/test/icc-x-api/icc-contact-x-api.js +311 -0
  79. package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
  80. package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
  81. package/test/icc-x-api/icc-form-x-api.js +331 -0
  82. package/test/icc-x-api/icc-form-x-api.js.map +1 -0
  83. package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
  84. package/test/icc-x-api/icc-helement-x-api-test.js +158 -0
  85. package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
  86. package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
  87. package/test/icc-x-api/icc-invoice-x-api.js +115 -0
  88. package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
  89. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
  90. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +230 -0
  91. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
  92. package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
  93. package/test/icc-x-api/icc-patient-x-api-test.js +169 -0
  94. package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
  95. package/test/icc-x-api/icc-time-table-x-api.d.ts +1 -0
  96. package/test/icc-x-api/icc-time-table-x-api.js +110 -0
  97. package/test/icc-x-api/icc-time-table-x-api.js.map +1 -0
  98. package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
  99. package/test/icc-x-api/icc-user-x-api-test.js +108 -0
  100. package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
  101. package/test/icc-x-api/icureapi-group-test.d.ts +1 -0
  102. package/test/icc-x-api/icureapi-group-test.js +130 -0
  103. package/test/icc-x-api/icureapi-group-test.js.map +1 -0
  104. package/test/icc-x-api/patient-user.d.ts +2 -0
  105. package/test/icc-x-api/patient-user.js +117 -0
  106. package/test/icc-x-api/patient-user.js.map +1 -0
  107. package/test/icc-x-api/storage/storage.d.ts +1 -0
  108. package/test/icc-x-api/storage/storage.js +50 -0
  109. package/test/icc-x-api/storage/storage.js.map +1 -0
  110. package/test/icc-x-api/subscription-apis.d.ts +2 -0
  111. package/test/icc-x-api/subscription-apis.js +498 -0
  112. package/test/icc-x-api/subscription-apis.js.map +1 -0
  113. package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
  114. package/test/icc-x-api/test-api-no-parent.js +79 -0
  115. package/test/icc-x-api/test-api-no-parent.js.map +1 -0
  116. package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
  117. package/test/icc-x-api/test-legacy-data-support.js +231 -0
  118. package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
  119. package/test/icc-x-api/utils/crypto-utils-test.d.ts +1 -0
  120. package/test/icc-x-api/utils/crypto-utils-test.js +586 -0
  121. package/test/icc-x-api/utils/crypto-utils-test.js.map +1 -0
  122. package/test/icc-x-api/utils/graph-test.d.ts +1 -0
  123. package/test/icc-x-api/utils/graph-test.js +54 -0
  124. package/test/icc-x-api/utils/graph-test.js.map +1 -0
  125. package/test/support/CSM-185.d.ts +1 -0
  126. package/test/support/CSM-185.js +120 -0
  127. package/test/support/CSM-185.js.map +1 -0
  128. package/test/support/CSM-87.d.ts +0 -0
  129. package/test/support/CSM-87.js +21 -0
  130. package/test/support/CSM-87.js.map +1 -0
  131. package/test/support/CSM-93.d.ts +1 -0
  132. package/test/support/CSM-93.js +111 -0
  133. package/test/support/CSM-93.js.map +1 -0
  134. package/test/utils/TestApi.d.ts +3 -0
  135. package/test/utils/TestApi.js +27 -0
  136. package/test/utils/TestApi.js.map +1 -0
  137. package/test/utils/TestCollectionUtils.d.ts +1 -0
  138. package/test/utils/TestCollectionUtils.js +109 -0
  139. package/test/utils/TestCollectionUtils.js.map +1 -0
  140. package/test/utils/TestCryptoStrategies.d.ts +37 -0
  141. package/test/utils/TestCryptoStrategies.js +72 -0
  142. package/test/utils/TestCryptoStrategies.js.map +1 -0
  143. package/test/utils/TestStorage.d.ts +31 -0
  144. package/test/utils/TestStorage.js +88 -0
  145. package/test/utils/TestStorage.js.map +1 -0
  146. package/test/utils/test_utils.d.ts +60 -0
  147. package/test/utils/test_utils.js +313 -0
  148. package/test/utils/test_utils.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-apis.js","sourceRoot":"","sources":["../../../test/icc-x-api/subscription-apis.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iBAAc;AACd,4BAAyB;AAEzB,oCAAkC;AAElC,+BAA6B;AAC7B,mDAAmE;AACnE,oDAAuH;AAEvH,mDAA+C;AAE/C,yDAAqD;AACrD,yDAAqD;AACrD,yDAAqD;AACrD,2DAAuD;AACvD,yDAAqD;AACrD,2FAAuF;AACvF,yHAAqH;AACrH,yEAAqE;AACrE,+BAAiC;AACjC,qEAAiE;AACjE,qHAAiH;AACjH,6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,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACvC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAC/C,EACD,CAAC,IAAI,EAAE,EAAE;gBACP,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAA;YACzB,CAAC,CACF,CAAA;YAED,MAAM,IAAA,WAAK,EAAC,KAAK,CAAC,CAAA;YAElB,IAAA,aAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,EAAE,EAAE,qCAAqC,CAAC,CAAA;YACrE,IAAA,aAAM,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE,kCAAkC,CAAC,CAAA;YACzG,IAAA,aAAM,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE,kCAAkC,CAAC,CAAA;QAC5G,CAAC,CAAA,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'mocha'\nimport 'isomorphic-fetch'\n\nimport { sleep } from '@icure/api'\n\nimport { assert } from 'chai'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { getEnvironmentInitializer, hcp1Username, hcp3Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { IcureApi } from '../../icc-x-api'\nimport { User } from '../../icc-api/model/User'\nimport { Connection } from '../../icc-api/model/Connection'\nimport { Service } from '../../icc-api/model/Service'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { Content } from '../../icc-api/model/Content'\nimport { CodeStub } from '../../icc-api/model/CodeStub'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { ServiceByHcPartyFilter } from '../../icc-x-api/filters/ServiceByHcPartyFilter'\nimport { MaintenanceTaskByHcPartyAndTypeFilter } from '../../icc-x-api/filters/MaintenanceTaskByHcPartyAndTypeFilter'\nimport { MaintenanceTask } from '../../icc-api/model/MaintenanceTask'\nimport { v4 as uuid } from 'uuid'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { HealthElementByHcPartyTagCodeFilter } from '../../icc-x-api/filters/HealthElementByHcPartyTagCodeFilter'\nimport { PatientByHcPartyNameContainsFuzzyFilter } from '../../icc-x-api/filters/PatientByHcPartyNameContainsFuzzyFilter'\nimport { WebSocketWrapper } from '../../icc-x-api/utils/websocket'\nimport { AllUsersFilter } from '../../icc-x-api/filters/AllUsersFilter'\nimport { ContactByHcPartyFilter } from '../../icc-x-api/filters/ContactByHcPartyFilter'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { Device } from '../../icc-api/model/Device'\nimport { AllHealthcarePartiesFilter } from '../../icc-x-api/filters/AllHealthcarePartiesFilter'\nimport { AllDevicesFilter } from '../../icc-x-api/filters/AllDevicesFilter'\nimport initApi = TestUtils.initApi\nimport initMasterApi = TestUtils.initMasterApi\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\nconst testType = 'IC-TEST'\nconst testCode = 'TEST'\n\nlet api: IcureApi\nlet hcp1Api: IcureApi\nlet hcp1User: User\nlet masterApi: IcureApi\n\ndescribe('Subscription API', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n\n if (env.backendType === 'oss') this.skip()\n\n api = await initApi(env, hcp3Username)\n\n hcp1Api = await initApi(env, hcp1Username)\n hcp1User = await hcp1Api.userApi.getCurrentUser()\n masterApi = await initMasterApi(env)\n })\n\n async function doXOnYAndSubscribe<Y>(\n api: IcureApi,\n options: {},\n connectionPromise: Promise<Connection>,\n x: () => Promise<Y>,\n statusListener: (status: string) => void,\n eventReceivedPromiseReject: (reason?: any) => void,\n eventReceivedPromise: Promise<void>\n ) {\n const connection = (await connectionPromise)\n .onClosed(async () => {\n statusListener('CLOSED')\n await sleep(3_000)\n })\n .onConnected(async () => {\n statusListener('CONNECTED')\n await sleep(2_000)\n await x()\n })\n\n const timeout = setTimeout(eventReceivedPromiseReject, 20_000)\n await eventReceivedPromise.then(() => clearTimeout(timeout)).catch(() => {})\n\n connection.close()\n\n await sleep(3_000)\n }\n\n describe('Can subscribe to Service and Contact', async () => {\n const subscribeAndCreateContactOrService = async (\n options: { connectionMaxRetry?: number; connectionRetryIntervalMs?: number },\n eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[],\n creationApi: IcureApi,\n subscriptionApi: IcureApi,\n supplier: () => Promise<void>,\n target: 'service' | 'contact'\n ) => {\n const connectionPromise = async (\n options: { connectionMaxRetry?: number; connectionRetryIntervalMs?: number },\n dataOwnerId: string,\n eventListener: (ds: Service | Contact) => Promise<void>\n ) =>\n target === 'service'\n ? subscriptionApi!.contactApi.subscribeToServiceEvents(\n eventTypes,\n new ServiceByHcPartyFilter({\n hcpId: dataOwnerId,\n }),\n eventListener,\n options\n )\n : subscriptionApi!.contactApi.subscribeToContactEvents(\n eventTypes,\n new ContactByHcPartyFilter({\n hcpId: dataOwnerId,\n }),\n eventListener,\n options\n )\n\n const loggedUser = await creationApi!!.userApi.getCurrentUser()\n const events: Service[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n\n await doXOnYAndSubscribe(\n creationApi!!,\n options,\n connectionPromise({}, loggedUser.healthcarePartyId!, async (ds) => {\n events.push(ds)\n eventReceivedPromiseResolve()\n }),\n supplier,\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n assert(events.length === 1, 'The events have not been recorded')\n assert(statuses.length === 2, 'The statuses have not been recorded')\n assert(\n events.every((event) => (target === 'service' && event) || (target === 'contact' && event)),\n 'The events are not of type ' + target\n )\n }\n\n const createService = async () => {\n const user = await api!!.userApi.getCurrentUser()\n\n const newPatient = new Patient({\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n\n const newInstanceOfPatient = await api!!.patientApi.newInstance(user, newPatient)\n\n const patient = await api!!.patientApi.createPatientWithUser(user, newInstanceOfPatient)\n\n const newContact = new Contact({\n id: uuid(),\n services: [\n new Service({\n id: uuid(),\n labels: new Set([new CodeStub({ type: testType, code: testCode })]),\n content: { en: new Content({ stringValue: 'Hello world' }) },\n }),\n ],\n })\n\n const newInstanceOfContact = await api!!.contactApi.newInstance(user, patient, newContact)\n\n const createdContact = await api!!.contactApi.createContactWithUser(user, newInstanceOfContact)\n\n return {\n contact: createdContact,\n service: createdContact!!.services!![0],\n patient: patient,\n }\n }\n\n const deleteService = async () => {\n const { service, patient } = await createService()\n const user = await api!!.userApi.getCurrentUser()\n\n const contactToDeleteServices = await api!.contactApi.newInstance(\n user,\n patient,\n new Contact({\n id: uuid(),\n services: [\n new Service({\n id: service.id,\n created: service.created,\n modified: +new Date(),\n endOfLife: +new Date(),\n }),\n ],\n })\n )\n\n const contactToDelete = await api!.contactApi.createContactWithUser(user, contactToDeleteServices)\n }\n\n it('CREATE Service without options', async () => {\n await subscribeAndCreateContactOrService(\n {},\n ['CREATE'],\n api!!,\n api!!,\n async () => {\n await createService()\n },\n 'service'\n )\n }).timeout(60000)\n\n it('CREATE Service with options', async () => {\n await subscribeAndCreateContactOrService(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE'],\n api!!,\n api!!,\n async () => {\n await createService()\n },\n 'service'\n )\n }).timeout(60000)\n\n it('CREATE Service without options with another instance of api', async () => {\n const subscriptionApi = await initApi(env, hcp3Username)\n\n await subscribeAndCreateContactOrService(\n {},\n ['CREATE'],\n api!!,\n subscriptionApi!!,\n async () => {\n await createService()\n },\n 'service'\n )\n }).timeout(60000)\n\n it('CREATE Service with options with another instance of api', async () => {\n const subscriptionApi = await initApi(env, hcp3Username)\n\n await subscribeAndCreateContactOrService(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE'],\n api!!,\n subscriptionApi!!,\n async () => {\n await createService()\n },\n 'service'\n )\n }).timeout(60000)\n\n it('CREATE Contact without options with another instance of api', async () => {\n const subscriptionApi = await initApi(env, hcp3Username)\n\n await subscribeAndCreateContactOrService(\n {},\n ['CREATE'],\n api!!,\n subscriptionApi!!,\n async () => {\n await createService()\n },\n 'contact'\n )\n }).timeout(60000)\n\n it('CREATE Contact with options with another instance of api', async () => {\n const subscriptionApi = await initApi(env, hcp3Username)\n\n await subscribeAndCreateContactOrService(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE'],\n api!!,\n subscriptionApi!!,\n async () => {\n await createService()\n },\n 'contact'\n )\n }).timeout(60000)\n\n it('DELETE Service without options', async () => {\n await subscribeAndCreateContactOrService({}, ['DELETE'], api!!, api!!, async () => deleteService(), 'service')\n }).timeout(60000)\n\n it('DELETE Service with options', async () => {\n await subscribeAndCreateContactOrService(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['DELETE'],\n api!!,\n api!!,\n async () => deleteService(),\n 'service'\n )\n }).timeout(60000)\n })\n\n describe('Can subscribe to MaintenanceTasks', async () => {\n const subscribeAndCreateMaintenanceTask = async (options: {}, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const loggedUser = await api!.userApi.getCurrentUser()\n\n const connectionPromise = async (options: {}, dataOwnerId: string, eventListener: (notification: MaintenanceTask) => Promise<void>) =>\n api!.maintenanceTaskApi.subscribeToMaintenanceTaskEvents(\n eventTypes,\n new MaintenanceTaskByHcPartyAndTypeFilter({\n healthcarePartyId: loggedUser!.healthcarePartyId!,\n type: MaintenanceTask.TaskTypeEnum.KeyPairUpdate,\n }),\n eventListener,\n options\n )\n\n const events: MaintenanceTask[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n await doXOnYAndSubscribe(\n api!!,\n options,\n connectionPromise({}, loggedUser.healthcarePartyId!, async (notification) => {\n events.push(notification)\n eventReceivedPromiseResolve()\n }),\n async () => {\n const notificationId = uuid()\n const notification = await api!.maintenanceTaskApi.newInstance(\n loggedUser,\n new MaintenanceTask({\n id: notificationId,\n status: 'pending',\n taskType: MaintenanceTask.TaskTypeEnum.KeyPairUpdate,\n })\n )\n const createdMaintenanceTask = await api!.maintenanceTaskApi.createMaintenanceTaskWithUser(loggedUser!!, notification)\n assert(!!createdMaintenanceTask)\n return createdMaintenanceTask\n },\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n assert(events.length === 1, 'The events have not been recorded')\n assert(statuses.length === 2, 'The statuses have not been recorded')\n assert(\n events.every((event) => event instanceof MaintenanceTask),\n 'The events are not of type MaintenanceTask'\n )\n }\n\n it('CREATE MaintenanceTask without options', async () => {\n await subscribeAndCreateMaintenanceTask({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE MaintenanceTask with options', async () => {\n await subscribeAndCreateMaintenanceTask(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n })\n\n describe('Can subscribe to HealthElements', async () => {\n const subscribeAndCreateHealthElement = async (options: {}, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const connectionPromise = async (options: {}, dataOwnerId: string, eventListener: (healthcareElement: HealthElement) => Promise<void>) =>\n api!.healthcareElementApi.subscribeToHealthElementEvents(\n eventTypes,\n new HealthElementByHcPartyTagCodeFilter({\n hcpId: hcp1User!.healthcarePartyId!,\n tagCode: testCode,\n tagType: testType,\n }),\n eventListener,\n options\n )\n\n const loggedUser = await api!!.userApi.getCurrentUser()\n const events: HealthElement[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n\n await doXOnYAndSubscribe(\n api!!,\n options,\n connectionPromise({}, loggedUser.healthcarePartyId!, async (healthcareElement) => {\n events.push(healthcareElement)\n eventReceivedPromiseResolve()\n }),\n async () => {\n const user = await api!!.userApi.getCurrentUser()\n\n const patient = await api!!.patientApi.createPatientWithUser(\n user,\n await api!!.patientApi.newInstance(\n user,\n new Patient({\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n\n await api!!.healthcareElementApi.createHealthElementWithUser(\n user,\n await api!!.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n note: 'Hero Syndrome',\n tags: [new CodeStub({ id: 'id', code: testCode, type: testType })],\n })\n )\n )\n },\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n assert(events.length === 1, 'The events have not been recorded')\n assert(statuses.length === 2, 'The statuses have not been recorded')\n assert(\n events.every((event) => event instanceof HealthElement),\n 'The events are not of type HealthElement'\n )\n }\n\n it('CREATE HealthElement without options', async () => {\n await subscribeAndCreateHealthElement({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE HealthElement with options', async () => {\n await subscribeAndCreateHealthElement(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n })\n\n describe('Can subscribe to Patients', async () => {\n const subscribeAndCreatePatient = async (options: {}, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const connectionPromise = async (options: {}, dataOwnerId: string, eventListener: (patient: Patient) => Promise<void>) => {\n await sleep(2000)\n return api!.patientApi.subscribeToPatientEvents(\n eventTypes,\n new PatientByHcPartyNameContainsFuzzyFilter({\n healthcarePartyId: loggedUser.healthcarePartyId!,\n searchString: 'John',\n }),\n eventListener,\n options\n )\n }\n\n const loggedUser = await api!!.userApi.getCurrentUser()\n\n const events: Patient[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n\n await doXOnYAndSubscribe(\n api!!,\n options,\n connectionPromise(options, loggedUser.healthcarePartyId!, async (patient) => {\n events.push(patient)\n eventReceivedPromiseResolve()\n }),\n async () => {\n const user = await api!!.userApi.getCurrentUser()\n await api!!.patientApi.createPatientWithUser(\n user,\n await api!!.patientApi.newInstance(\n user,\n new Patient({\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n },\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n assert(events.length === 1, 'The events have not been recorded')\n assert(statuses.length === 2, 'The statuses have not been recorded')\n assert(\n events.every((event) => event instanceof Patient),\n 'The events are not of type Patient'\n )\n }\n\n it('CREATE Patient without option', async () => {\n await subscribeAndCreatePatient({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE Patient with options', async () => {\n await subscribeAndCreatePatient(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n })\n\n describe('Can subscribe to HealthcareParty', async () => {\n const subscribeAndCreateHealthcareParty = async (options: {}, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const connectionPromise = async (options: {}, dataOwnerId: string, eventListener: (patient: HealthcareParty) => Promise<void>) => {\n await sleep(2000)\n return masterApi!.healthcarePartyApi.subscribeToHealthcarePartyEvents(eventTypes, new AllHealthcarePartiesFilter({}), eventListener, options)\n }\n\n const loggedUser = await masterApi.userApi.getCurrentUser()\n\n const events: HealthcareParty[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n\n await doXOnYAndSubscribe(\n masterApi,\n options,\n connectionPromise(options, loggedUser.healthcarePartyId!, async (patient) => {\n events.push(patient)\n eventReceivedPromiseResolve()\n }),\n async () => {\n await masterApi.healthcarePartyApi.createHealthcareParty(\n new HealthcareParty({ id: uuid(), firstName: 'Homer', lastName: 'Simpson', parentId: loggedUser.healthcarePartyId })\n )\n },\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n assert(events.length === 1, 'The events have not been recorded')\n assert(statuses.length === 2, 'The statuses have not been recorded')\n }\n\n it('CREATE HealthcareParty without option', async () => {\n await subscribeAndCreateHealthcareParty({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE HealthcareParty with options', async () => {\n await subscribeAndCreateHealthcareParty(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n })\n\n describe('Can subscribe to Device', async () => {\n const subscribeAndCreateDevice = async (options: {}, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const connectionPromise = async (options: {}, dataOwnerId: string, eventListener: (patient: Device) => Promise<void>) => {\n await sleep(2000)\n return api!.deviceApi.subscribeToDeviceEvents(eventTypes, new AllDevicesFilter({}), eventListener, options)\n }\n const loggedUser = await api!!.userApi.getCurrentUser()\n\n const events: Device[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n\n await doXOnYAndSubscribe(\n api!!,\n options,\n connectionPromise(options, loggedUser.healthcarePartyId!, async (patient) => {\n events.push(patient)\n eventReceivedPromiseResolve()\n }),\n async () => {\n await api!!.deviceApi.createDevice(new Device({ id: uuid(), brand: 'Apple', model: 'iPod Shuffle' }))\n },\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n assert(events.length === 1, 'The events have not been recorded')\n assert(statuses.length === 2, 'The statuses have not been recorded')\n assert(\n events.every((event) => event instanceof Device),\n 'The events are not of type Device'\n )\n }\n\n it('CREATE Device without option', async () => {\n await subscribeAndCreateDevice({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE Device with options', async () => {\n await subscribeAndCreateDevice(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n })\n\n describe('Can subscribe to User', async () => {\n const subscribeAndCreateUser = async (options: {}, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const connectionPromise = async (options: {}, dataOwnerId: string, eventListener: (user: User) => Promise<void>) => {\n await sleep(2000)\n return api!.userApi.subscribeToUserEvents(eventTypes, new AllUsersFilter({}), eventListener, options)\n }\n\n const loggedUser = await api!!.userApi.getCurrentUser()\n\n await sleep(2000)\n await sleep(2000)\n\n const events: User[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n\n await doXOnYAndSubscribe(\n api!!,\n options,\n connectionPromise(options, loggedUser.healthcarePartyId!, async (user) => {\n events.push(user)\n eventReceivedPromiseResolve()\n }),\n async () => {\n const user = await api!.userApi.createUser(\n new User({\n id: uuid(),\n login: `${uuid()}`,\n status: 'ACTIVE',\n patientId: uuid(),\n })\n )\n },\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n assert(events.length === 1, 'The events have not been recorded')\n assert(statuses.length === 2, 'The statuses have not been recorded')\n assert(\n events.every((event) => event instanceof User),\n 'The events are not of type User'\n )\n }\n\n it('CREATE User without options', async () => {\n await subscribeAndCreateUser({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE User with options', async () => {\n await subscribeAndCreateUser(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n })\n\n describe('Retry mechanism', async () => {\n it('Should fails 10 times and then cut', async () => {\n const statuses: string[] = []\n\n const ws = await WebSocketWrapper.create(\n env!.iCureUrl.replace('http', 'ws').replace('rest', 'ws') + '/notification/subscribe',\n {\n getBearerToken: () => Promise.resolve(undefined),\n getIcureOtt: () => Promise.resolve('fake-token'),\n },\n 10,\n 500,\n {\n CONNECTED: [() => statuses.push('CONNECTED')],\n CLOSED: [() => statuses.push('CLOSED')],\n ERROR: [(ws, error) => statuses.push('ERROR')],\n },\n (data) => {\n throw new Error('Test')\n }\n )\n\n await sleep(20000)\n\n assert(statuses.length === 20, 'The statuses have not been recorded')\n assert(statuses.filter((status) => status === 'ERROR').length === 10, 'There should be 10 errors status')\n assert(statuses.filter((status) => status === 'CLOSED').length === 10, 'There should be 10 closed status')\n }).timeout(60000)\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,79 @@
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 mocha_1 = require("mocha");
13
+ const test_utils_1 = require("../utils/test_utils");
14
+ const types_1 = require("@icure/test-setup/types");
15
+ const icc_x_api_1 = require("../../icc-x-api");
16
+ const TestCryptoStrategies_1 = require("../utils/TestCryptoStrategies");
17
+ const crypto_1 = require("crypto");
18
+ const TestStorage_1 = require("../utils/TestStorage");
19
+ const chai_1 = require("chai");
20
+ require("isomorphic-fetch");
21
+ var initMasterApi = test_utils_1.TestUtils.initMasterApi;
22
+ (0, chai_1.use)(require('chai-as-promised'));
23
+ (0, test_utils_1.setLocalStorage)(fetch);
24
+ let env;
25
+ let api;
26
+ let user;
27
+ let login;
28
+ let keypair;
29
+ describe('A user without access to parent data', () => {
30
+ (0, mocha_1.before)(function () {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ this.timeout(600000);
33
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
34
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
35
+ const initialisationApi = yield initMasterApi(env);
36
+ const initialisationUser = yield initialisationApi.userApi.getCurrentUser();
37
+ const childHcp = yield initialisationApi.healthcarePartyApi.createHealthcareParty({
38
+ id: initialisationApi.cryptoApi.primitives.randomUuid(),
39
+ name: 'Some hcp',
40
+ parentId: initialisationUser.healthcarePartyId,
41
+ });
42
+ login = `childUser-${initialisationApi.cryptoApi.primitives.randomUuid()}`;
43
+ const childUser = yield initialisationApi.userApi.createUser({
44
+ id: initialisationApi.cryptoApi.primitives.randomUuid(),
45
+ healthcarePartyId: childHcp.id,
46
+ login,
47
+ passwordHash: 'LetMeInForReal',
48
+ });
49
+ keypair = yield initialisationApi.cryptoApi.primitives.RSA.generateKeyPair();
50
+ api = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: childUser.login, password: 'LetMeInForReal' }, new TestCryptoStrategies_1.TestCryptoStrategies(keypair), crypto_1.webcrypto, fetch, {
51
+ storage: new TestStorage_1.TestStorage(),
52
+ keyStorage: new TestStorage_1.TestKeyStorage(),
53
+ disableParentKeysInitialisation: true,
54
+ });
55
+ user = yield api.userApi.getCurrentUser();
56
+ });
57
+ });
58
+ it('should not be able to initialise the api without disabling parent keys initialisation', () => __awaiter(void 0, void 0, void 0, function* () {
59
+ yield (0, chai_1.expect)(icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: login, password: 'LetMeInForReal' }, new TestCryptoStrategies_1.TestCryptoStrategies(keypair), crypto_1.webcrypto, fetch, {
60
+ storage: new TestStorage_1.TestStorage(),
61
+ keyStorage: new TestStorage_1.TestKeyStorage(),
62
+ })).to.be.rejected;
63
+ }));
64
+ it('should still be able to create and retrieve his data', () => __awaiter(void 0, void 0, void 0, function* () {
65
+ const patient = yield api.patientApi.createPatientWithUser(user, yield api.patientApi.newInstance(user, {
66
+ firstName: 'Tasty',
67
+ lastName: 'Test',
68
+ note: 'Secret',
69
+ }));
70
+ (0, chai_1.expect)(patient.note).to.equal('Secret');
71
+ const he = yield api.healthcareElementApi.createHealthElementWithUser(user, yield api.healthcareElementApi.newInstance(user, patient, {
72
+ note: 'Secret 2',
73
+ }));
74
+ (0, chai_1.expect)(he.note).to.equal('Secret 2');
75
+ (0, chai_1.expect)(he.secretForeignKeys).to.have.length(1);
76
+ (0, chai_1.expect)(he.secretForeignKeys).to.have.members(yield api.patientApi.decryptSecretIdsOf(patient));
77
+ }));
78
+ });
79
+ //# sourceMappingURL=test-api-no-parent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-api-no-parent.js","sourceRoot":"","sources":["../../../test/icc-x-api/test-api-no-parent.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA8B;AAC9B,oDAAyG;AACzG,mDAAmE;AACnE,+CAAwD;AAGxD,wEAAoE;AACpE,mCAAkC;AAClC,sDAAkE;AAClE,+BAA6C;AAC7C,4BAAyB;AAEzB,IAAO,aAAa,GAAG,sBAAS,CAAC,aAAa,CAAA;AAC9C,IAAA,UAAO,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAEpC,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AACjB,IAAI,GAAS,CAAA;AACb,IAAI,IAAU,CAAA;AACd,IAAI,KAAa,CAAA;AACjB,IAAI,OAA2B,CAAA;AAE/B,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACpD,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;YAClD,MAAM,iBAAiB,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;YAClD,MAAM,kBAAkB,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;YAC3E,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CA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cesContent":["import { before } from 'mocha'\nimport { getEnvironmentInitializer, hcp1Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { Apis, hex2ua, IcureApi } from '../../icc-x-api'\nimport { User } from '../../icc-api/model/User'\nimport initApi = TestUtils.initApi\nimport { TestCryptoStrategies } from '../utils/TestCryptoStrategies'\nimport { webcrypto } from 'crypto'\nimport { TestKeyStorage, TestStorage } from '../utils/TestStorage'\nimport { expect, use as chaiUse } from 'chai'\nimport 'isomorphic-fetch'\nimport { KeyPair } from '../../icc-x-api/crypto/RSA'\nimport initMasterApi = TestUtils.initMasterApi\nchaiUse(require('chai-as-promised'))\n\nsetLocalStorage(fetch)\nlet env: TestVars\nlet api: Apis\nlet user: User\nlet login: string\nlet keypair: KeyPair<CryptoKey>\n\ndescribe('A user without access to parent data', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n const initialisationApi = await initMasterApi(env)\n const initialisationUser = await initialisationApi.userApi.getCurrentUser()\n const childHcp = await initialisationApi.healthcarePartyApi.createHealthcareParty({\n id: initialisationApi.cryptoApi.primitives.randomUuid(),\n name: 'Some hcp',\n parentId: initialisationUser.healthcarePartyId,\n })\n login = `childUser-${initialisationApi.cryptoApi.primitives.randomUuid()}`\n const childUser = await initialisationApi.userApi.createUser({\n id: initialisationApi.cryptoApi.primitives.randomUuid(),\n healthcarePartyId: childHcp.id,\n login,\n passwordHash: 'LetMeInForReal',\n })\n keypair = await initialisationApi.cryptoApi.primitives.RSA.generateKeyPair()\n api = await IcureApi.initialise(\n env.iCureUrl,\n { username: childUser.login!, password: 'LetMeInForReal' },\n new TestCryptoStrategies(keypair),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n disableParentKeysInitialisation: true,\n }\n )\n user = await api.userApi.getCurrentUser()\n })\n\n it('should not be able to initialise the api without disabling parent keys initialisation', async () => {\n await expect(\n IcureApi.initialise(env.iCureUrl, { username: login, password: 'LetMeInForReal' }, new TestCryptoStrategies(keypair), webcrypto as any, fetch, {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n })\n ).to.be.rejected\n })\n\n it('should still be able to create and retrieve his data', async () => {\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(user, {\n firstName: 'Tasty',\n lastName: 'Test',\n note: 'Secret',\n })\n )\n expect(patient.note).to.equal('Secret')\n const he = await api.healthcareElementApi.createHealthElementWithUser(\n user,\n await api.healthcareElementApi.newInstance(user, patient, {\n note: 'Secret 2',\n })\n )\n expect(he.note).to.equal('Secret 2')\n expect(he.secretForeignKeys).to.have.length(1)\n expect(he.secretForeignKeys).to.have.members(await api.patientApi.decryptSecretIdsOf(patient))\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,231 @@
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
+ require("isomorphic-fetch");
13
+ const apiV6_1 = require("@icure/apiV6");
14
+ const apiV6_2 = require("@icure/apiV6");
15
+ const icc_x_api_1 = require("../../icc-x-api");
16
+ const User_1 = require("../../icc-api/model/User");
17
+ const test_utils_1 = require("../utils/test_utils");
18
+ const chai_1 = require("chai");
19
+ const crypto_1 = require("crypto");
20
+ const CryptoPrimitives_1 = require("../../icc-x-api/crypto/CryptoPrimitives");
21
+ const uuid_1 = require("uuid");
22
+ const HealthcareParty_1 = require("../../icc-api/model/HealthcareParty");
23
+ const TestStorage_1 = require("../utils/TestStorage");
24
+ const TestCryptoStrategies_1 = require("../utils/TestCryptoStrategies");
25
+ const types_1 = require("@icure/test-setup/types");
26
+ function checkEncryptedData(actual, expected, actualName) {
27
+ (0, chai_1.expect)(actual.secretContent, `${actualName} - secret content`).to.equal(expected.secretContent);
28
+ (0, chai_1.expect)(actual.secretIds, `${actualName} - secret ids`).to.have.length(1);
29
+ (0, chai_1.expect)(actual.secretIds[0], `${actualName} - secret ids`).to.equal(expected.secretIds[0]);
30
+ (0, chai_1.expect)(actual.owningEntityIds, `${actualName} - owning entity id`).to.have.length(1);
31
+ (0, chai_1.expect)(actual.owningEntityIds[0], `${actualName} - owning entity id`).to.equal(expected.owningEntityIds[0]);
32
+ }
33
+ (0, test_utils_1.setLocalStorage)(fetch);
34
+ const cryptoPrimitives = new CryptoPrimitives_1.CryptoPrimitives(crypto_1.webcrypto);
35
+ let env;
36
+ class ApiFactoryV6 {
37
+ constructor() {
38
+ this.version = 'apiV6.x';
39
+ }
40
+ masterApi(env) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const apis = yield (0, apiV6_1.Api)(env.iCureUrl + '/rest/v1', env.masterHcp.user, env.masterHcp.password, crypto_1.webcrypto, fetch, false, false, new TestStorage_1.TestStorage(), new TestStorage_1.TestKeyStorage());
43
+ return {
44
+ createUser: () => __awaiter(this, void 0, void 0, function* () {
45
+ const pair = yield cryptoPrimitives.RSA.generateKeyPair();
46
+ const hcp = yield apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty_1.HealthcareParty({ id: (0, uuid_1.v4)(), firstName: `name`, lastName: 'v6' }));
47
+ const user = yield apis.userApi.createUser(new apiV6_2.User({
48
+ id: (0, uuid_1.v4)(),
49
+ login: `v6-${(0, uuid_1.v4)()}`,
50
+ status: 'ACTIVE',
51
+ healthcarePartyId: hcp.id,
52
+ }));
53
+ return {
54
+ login: user.login,
55
+ password: yield apis.userApi.getToken(user.id, (0, uuid_1.v4)()),
56
+ key: pair,
57
+ ownerId: hcp.id,
58
+ };
59
+ }),
60
+ };
61
+ });
62
+ }
63
+ testApi(credentials) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const apis = yield (0, apiV6_1.Api)(env.iCureUrl + '/rest/v1', credentials.login, credentials.password, crypto_1.webcrypto, fetch);
66
+ // await apis.cryptoApi.cacheKeyPair(await cryptoPrimitives.RSA.exportKeys(credentials.key, "jwk", "jwk"))
67
+ const user = yield apis.userApi.getCurrentUser();
68
+ yield apis.cryptoApi.addKeyPairForOwner(apis.maintenanceTaskApi, user, yield apis.cryptoApi.getDataOwner(credentials.ownerId), credentials.key, false, false);
69
+ return {
70
+ userDetails: () => __awaiter(this, void 0, void 0, function* () {
71
+ return { userId: user.id, dataOwnerId: credentials.ownerId };
72
+ }),
73
+ createEncryptedData: () => __awaiter(this, void 0, void 0, function* () {
74
+ const note = `v6 note ${uuid_1.v4}`;
75
+ const patient = yield apis.patientApi.createPatientWithUser(user, yield apis.patientApi.newInstance(user));
76
+ const healthdata = yield apis.healthcareElementApi.createHealthElementWithUser(user, yield apis.healthcareElementApi.newInstance(user, patient, { note }));
77
+ return {
78
+ id: healthdata.id,
79
+ secretContent: note,
80
+ secretIds: (yield apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,
81
+ owningEntityIds: [patient.id],
82
+ };
83
+ }),
84
+ getDecryptedData: (id) => __awaiter(this, void 0, void 0, function* () {
85
+ const healthdata = yield apis.healthcareElementApi.getHealthElementWithUser(user, id);
86
+ return {
87
+ secretContent: healthdata.note,
88
+ secretIds: (yield apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,
89
+ owningEntityIds: (yield apis.cryptoApi.extractCryptedFKs(healthdata, credentials.ownerId)).extractedKeys,
90
+ };
91
+ }),
92
+ shareEncryptedData: (dataId, delegateId) => __awaiter(this, void 0, void 0, function* () {
93
+ const healthElement = yield apis.healthcareElementApi.getHealthElementWithUser(user, dataId);
94
+ const patientIds = (yield apis.cryptoApi.extractCryptedFKs(healthElement, credentials.ownerId)).extractedKeys;
95
+ (0, chai_1.expect)(patientIds).to.have.length(1);
96
+ const patient = yield apis.patientApi.getPatientWithUser(user, patientIds[0]);
97
+ const secretIds = (yield apis.cryptoApi.extractDelegationsSFKs(healthElement, credentials.ownerId)).extractedKeys;
98
+ (0, chai_1.expect)(secretIds).to.have.length(1);
99
+ yield apis.healthcareElementApi.modifyHealthElementWithUser(user, (yield apis.cryptoApi.extendedDelegationsAndCryptedForeignKeys(healthElement, patient, credentials.ownerId, delegateId, secretIds[0])).modifiedObject);
100
+ }),
101
+ };
102
+ });
103
+ }
104
+ }
105
+ class ApiFactoryV7 {
106
+ constructor() {
107
+ this.version = 'apiV7.x';
108
+ }
109
+ masterApi(env) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const key = {
112
+ privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey), ['decrypt']),
113
+ publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey), ['encrypt']),
114
+ };
115
+ const apis = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: env.masterHcp.user, password: env.masterHcp.password }, new TestCryptoStrategies_1.TestCryptoStrategies(key), crypto_1.webcrypto, fetch, {
116
+ storage: new TestStorage_1.TestStorage(),
117
+ keyStorage: new TestStorage_1.TestKeyStorage(),
118
+ });
119
+ return {
120
+ createUser: () => __awaiter(this, void 0, void 0, function* () {
121
+ const pair = yield cryptoPrimitives.RSA.generateKeyPair();
122
+ const hcp = yield apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty_1.HealthcareParty({ id: (0, uuid_1.v4)(), firstName: `name`, lastName: 'v7' }));
123
+ const user = yield apis.userApi.createUser(new User_1.User({
124
+ id: (0, uuid_1.v4)(),
125
+ login: `v7-${(0, uuid_1.v4)()}`,
126
+ status: 'ACTIVE',
127
+ healthcarePartyId: hcp.id,
128
+ }));
129
+ return {
130
+ login: user.login,
131
+ password: yield apis.userApi.getToken(user.id, (0, uuid_1.v4)()),
132
+ key: pair,
133
+ ownerId: hcp.id,
134
+ };
135
+ }),
136
+ };
137
+ });
138
+ }
139
+ testApi(credentials) {
140
+ return __awaiter(this, void 0, void 0, function* () {
141
+ const testStorage = yield (0, TestStorage_1.testStorageWithKeys)([
142
+ {
143
+ dataOwnerId: credentials.ownerId,
144
+ pairs: [
145
+ {
146
+ publicKey: (0, icc_x_api_1.ua2hex)(yield cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),
147
+ privateKey: (0, icc_x_api_1.ua2hex)(yield cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),
148
+ },
149
+ ],
150
+ },
151
+ ]);
152
+ const apis = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: credentials.login, password: credentials.password }, new TestCryptoStrategies_1.TestCryptoStrategies(credentials.key), crypto_1.webcrypto, fetch, {
153
+ entryKeysFactory: testStorage.keyFactory,
154
+ storage: testStorage.storage,
155
+ keyStorage: testStorage.keyStorage,
156
+ });
157
+ const user = yield apis.userApi.getCurrentUser();
158
+ return {
159
+ userDetails: () => __awaiter(this, void 0, void 0, function* () {
160
+ return { userId: user.id, dataOwnerId: credentials.ownerId };
161
+ }),
162
+ createEncryptedData: () => __awaiter(this, void 0, void 0, function* () {
163
+ const note = `v7 note ${uuid_1.v4}`;
164
+ const patient = yield apis.patientApi.createPatientWithUser(user, yield apis.patientApi.newInstance(user));
165
+ const healthdata = yield apis.healthcareElementApi.createHealthElementWithUser(user, yield apis.healthcareElementApi.newInstance(user, patient, { note }));
166
+ const secretIds = yield apis.cryptoApi.entities.secretIdsOf(healthdata);
167
+ (0, chai_1.expect)(secretIds).to.have.length(1);
168
+ return {
169
+ id: healthdata.id,
170
+ secretContent: note,
171
+ secretIds,
172
+ owningEntityIds: [patient.id],
173
+ };
174
+ }),
175
+ getDecryptedData: (id) => __awaiter(this, void 0, void 0, function* () {
176
+ const healthdata = yield apis.healthcareElementApi.getHealthElementWithUser(user, id);
177
+ return {
178
+ secretContent: healthdata.note,
179
+ secretIds: yield apis.cryptoApi.entities.secretIdsOf(healthdata),
180
+ owningEntityIds: yield apis.cryptoApi.entities.owningEntityIdsOf(healthdata),
181
+ };
182
+ }),
183
+ shareEncryptedData: (dataId, delegateId) => __awaiter(this, void 0, void 0, function* () {
184
+ const healthElement = yield apis.healthcareElementApi.getHealthElementWithUser(user, dataId);
185
+ const encryptionKeys = yield apis.cryptoApi.entities.encryptionKeysOf(healthElement);
186
+ const secretIds = yield apis.cryptoApi.entities.secretIdsOf(healthElement);
187
+ const owningEntityIds = yield apis.cryptoApi.entities.owningEntityIdsOf(healthElement);
188
+ yield apis.healthcareElementApi.modifyHealthElementWithUser(user, yield apis.cryptoApi.entities.entityWithExtendedEncryptedMetadata(healthElement, delegateId, secretIds, encryptionKeys, owningEntityIds, []));
189
+ }),
190
+ };
191
+ });
192
+ }
193
+ }
194
+ // Api factories in chronological version order
195
+ let chronologicalApiFactories = [new ApiFactoryV6(), new ApiFactoryV7()];
196
+ describe('All apis versions', function () {
197
+ return __awaiter(this, void 0, void 0, function* () {
198
+ before(function () {
199
+ return __awaiter(this, void 0, void 0, function* () {
200
+ this.timeout(600000);
201
+ env = yield (0, test_utils_1.getEnvironmentInitializer)().then((initializer) => initializer.execute((0, types_1.getEnvVariables)()));
202
+ });
203
+ });
204
+ for (let legacyApiIndex = 0; legacyApiIndex < chronologicalApiFactories.length - 1; legacyApiIndex++) {
205
+ const legacyApiFactory = chronologicalApiFactories[legacyApiIndex];
206
+ const newApiFactories = chronologicalApiFactories.slice(legacyApiIndex + 1);
207
+ it(`should be able to read data from older apis without affecting accessibility for older apis - ${legacyApiFactory.version}`, function () {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ const legacyMasterApi = yield legacyApiFactory.masterApi(env);
210
+ const legacyUserCredentials = yield legacyMasterApi.createUser();
211
+ const legacyUserApi = yield legacyApiFactory.testApi(legacyUserCredentials);
212
+ const data = yield legacyUserApi.createEncryptedData();
213
+ checkEncryptedData(yield legacyUserApi.getDecryptedData(data.id), data, 'Original decrypted data');
214
+ const newApis = yield Promise.all(newApiFactories.map((factory) => __awaiter(this, void 0, void 0, function* () {
215
+ const newLegacyUserApi = yield factory.testApi(legacyUserCredentials);
216
+ const newUser = yield factory.masterApi(env).then((masterApi) => masterApi.createUser());
217
+ const newUserApi = yield factory.testApi(newUser);
218
+ return { newLegacyUserApi, newUserApi, version: factory.version };
219
+ })));
220
+ for (const { newLegacyUserApi, newUserApi, version } of newApis) {
221
+ checkEncryptedData(yield newLegacyUserApi.getDecryptedData(data.id), data, `Data decrypted by legacy user on new api (${version})`);
222
+ yield newLegacyUserApi.shareEncryptedData(data.id, (yield newUserApi.userDetails()).dataOwnerId);
223
+ checkEncryptedData(yield newUserApi.getDecryptedData(data.id), data, `Data decrypted by new user (${version})`);
224
+ }
225
+ checkEncryptedData(yield legacyUserApi.getDecryptedData(data.id), data, `Data after changes by new versions of api`);
226
+ });
227
+ });
228
+ }
229
+ });
230
+ });
231
+ //# sourceMappingURL=test-legacy-data-support.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-legacy-data-support.js","sourceRoot":"","sources":["../../../test/icc-x-api/test-legacy-data-support.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,wCAA2C;AAC3C,wCAAmF;AACnF,+CAAmE;AACnE,mDAA+C;AAC/C,oDAAgF;AAEhF,+BAA6B;AAC7B,mCAAkC;AAClC,8EAA0E;AAC1E,+BAAiC;AACjC,yEAAqE;AACrE,sDAAuF;AACvF,wEAAoE;AACpE,mDAAmE;AA+BnE,SAAS,kBAAkB,CAAC,MAAqB,EAAE,QAAuB,EAAE,UAAkB;IAC5F,IAAA,aAAM,EAAC,MAA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AO,CAAC,OAAO,CAAC,CAAA;wBACjD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAA;oBACnE,CAAC,CAAA,CAAC,CACH,CAAA;oBACD,KAAK,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE;wBAC/D,kBAAkB,CAAC,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,6CAA6C,OAAO,GAAG,CAAC,CAAA;wBACnI,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,MAAM,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,CAAA;wBAChG,kBAAkB,CAAC,MAAM,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,+BAA+B,OAAO,GAAG,CAAC,CAAA;qBAChH;oBACD,kBAAkB,CAAC,MAAM,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,2CAA2C,CAAC,CAAA;gBACtH,CAAC;aAAA,CAAC,CAAA;SACH;IACH,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { Api as ApiV6 } from '@icure/apiV6'\nimport { User as UserV6, HealthcareParty as HealthcarePartyV6 } from '@icure/apiV6'\nimport { IcureApi as ApiV7, ua2hex, hex2ua } from '../../icc-x-api'\nimport { User } from '../../icc-api/model/User'\nimport { getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { KeyPair } from '../../icc-x-api/crypto/RSA'\nimport { expect } from 'chai'\nimport { webcrypto } from 'crypto'\nimport { CryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { v4 as uuid } from 'uuid'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../utils/TestStorage'\nimport { TestCryptoStrategies } from '../utils/TestCryptoStrategies'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\ntype UserCredentials = {\n login: string\n password: string\n ownerId: string\n key: KeyPair<CryptoKey>\n}\ntype EncryptedData = {\n secretContent: string\n secretIds: string[]\n owningEntityIds: string[]\n}\n\ninterface UniformizedMasterApi {\n createUser(): Promise<UserCredentials>\n}\n\ninterface UniformizedTestApi {\n userDetails(): Promise<{ userId: string; dataOwnerId: string }>\n createEncryptedData(): Promise<{ id: string } & EncryptedData>\n getDecryptedData(id: string): Promise<EncryptedData>\n shareEncryptedData(dataId: string, delegateId: string): Promise<void>\n}\n\ninterface ApiFactory {\n readonly version: string\n masterApi(env: TestVars): Promise<UniformizedMasterApi>\n testApi(credentials: UserCredentials): Promise<UniformizedTestApi>\n}\n\nfunction checkEncryptedData(actual: EncryptedData, expected: EncryptedData, actualName: string) {\n expect(actual.secretContent, `${actualName} - secret content`).to.equal(expected.secretContent)\n expect(actual.secretIds, `${actualName} - secret ids`).to.have.length(1)\n expect(actual.secretIds[0], `${actualName} - secret ids`).to.equal(expected.secretIds[0])\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.have.length(1)\n expect(actual.owningEntityIds[0], `${actualName} - owning entity id`).to.equal(expected.owningEntityIds[0])\n}\n\nsetLocalStorage(fetch)\nconst cryptoPrimitives = new CryptoPrimitives(webcrypto as any)\nlet env: TestVars\n\nclass ApiFactoryV6 implements ApiFactory {\n readonly version: string = 'apiV6.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const apis = await ApiV6(\n env.iCureUrl + '/rest/v1',\n env.masterHcp!.user,\n env.masterHcp!.password,\n webcrypto as any,\n fetch,\n false,\n false,\n new TestStorage(),\n new TestKeyStorage()\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair()\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(\n new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v6' }) as HealthcarePartyV6\n )\n const user = await apis.userApi.createUser(\n new UserV6({\n id: uuid(),\n login: `v6-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const apis = await ApiV6(env.iCureUrl + '/rest/v1', credentials.login, credentials.password, webcrypto as any, fetch)\n // await apis.cryptoApi.cacheKeyPair(await cryptoPrimitives.RSA.exportKeys(credentials.key, \"jwk\", \"jwk\"))\n const user = await apis.userApi.getCurrentUser()\n await apis.cryptoApi.addKeyPairForOwner(\n apis.maintenanceTaskApi,\n user,\n await apis.cryptoApi.getDataOwner(credentials.ownerId),\n credentials.key,\n false,\n false\n )\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v6 note ${uuid}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: (await apis.cryptoApi.extractCryptedFKs(healthdata, credentials.ownerId)).extractedKeys,\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const patientIds = (await apis.cryptoApi.extractCryptedFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(patientIds).to.have.length(1)\n const patient = await apis.patientApi.getPatientWithUser(user, patientIds[0])\n const secretIds = (await apis.cryptoApi.extractDelegationsSFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(secretIds).to.have.length(1)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n (\n await apis.cryptoApi.extendedDelegationsAndCryptedForeignKeys(healthElement, patient, credentials.ownerId, delegateId, secretIds[0])\n ).modifiedObject\n )\n },\n }\n }\n}\n\nclass ApiFactoryV7 implements ApiFactory {\n readonly version: string = 'apiV7.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', hex2ua(env.masterHcp!.privateKey), ['decrypt']),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', hex2ua(env.masterHcp!.publicKey), ['encrypt']),\n }\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategies(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair()\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new User({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n ],\n },\n ])\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n { username: credentials.login, password: credentials.password },\n new TestCryptoStrategies(credentials.key),\n webcrypto as any,\n fetch,\n {\n entryKeysFactory: testStorage.keyFactory,\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v7 note ${uuid}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthdata)\n expect(secretIds).to.have.length(1)\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.entities.secretIdsOf(healthdata),\n owningEntityIds: await apis.cryptoApi.entities.owningEntityIdsOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const encryptionKeys = await apis.cryptoApi.entities.encryptionKeysOf(healthElement)\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthElement)\n const owningEntityIds = await apis.cryptoApi.entities.owningEntityIdsOf(healthElement)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n await apis.cryptoApi.entities.entityWithExtendedEncryptedMetadata(healthElement, delegateId, secretIds, encryptionKeys, owningEntityIds, [])\n )\n },\n }\n }\n}\n\n// Api factories in chronological version order\nlet chronologicalApiFactories: ApiFactory[] = [new ApiFactoryV6(), new ApiFactoryV7()]\n\ndescribe('All apis versions', async function () {\n before(async function () {\n this.timeout(600_000)\n env = await getEnvironmentInitializer().then((initializer) => initializer.execute(getEnvVariables()))\n })\n\n for (let legacyApiIndex = 0; legacyApiIndex < chronologicalApiFactories.length - 1; legacyApiIndex++) {\n const legacyApiFactory = chronologicalApiFactories[legacyApiIndex]\n const newApiFactories = chronologicalApiFactories.slice(legacyApiIndex + 1)\n it(`should be able to read data from older apis without affecting accessibility for older apis - ${legacyApiFactory.version}`, async function () {\n const legacyMasterApi = await legacyApiFactory.masterApi(env)\n const legacyUserCredentials = await legacyMasterApi.createUser()\n const legacyUserApi = await legacyApiFactory.testApi(legacyUserCredentials)\n const data = await legacyUserApi.createEncryptedData()\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, 'Original decrypted data')\n const newApis = await Promise.all(\n newApiFactories.map(async (factory) => {\n const newLegacyUserApi = await factory.testApi(legacyUserCredentials)\n const newUser = await factory.masterApi(env).then((masterApi) => masterApi.createUser())\n const newUserApi = await factory.testApi(newUser)\n return { newLegacyUserApi, newUserApi, version: factory.version }\n })\n )\n for (const { newLegacyUserApi, newUserApi, version } of newApis) {\n checkEncryptedData(await newLegacyUserApi.getDecryptedData(data.id), data, `Data decrypted by legacy user on new api (${version})`)\n await newLegacyUserApi.shareEncryptedData(data.id, (await newUserApi.userDetails()).dataOwnerId)\n checkEncryptedData(await newUserApi.getDecryptedData(data.id), data, `Data decrypted by new user (${version})`)\n }\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, `Data after changes by new versions of api`)\n })\n }\n})\n"]}
@@ -0,0 +1 @@
1
+ export {};