@icure/api 8.3.5 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccAuthApi.d.ts +10 -1
- package/icc-api/api/IccAuthApi.js +20 -3
- package/icc-api/api/IccAuthApi.js.map +1 -1
- package/icc-api/api/IccClassificationApi.d.ts +1 -0
- package/icc-api/api/IccClassificationApi.js +12 -0
- package/icc-api/api/IccClassificationApi.js.map +1 -1
- package/icc-api/api/IccMessageApi.d.ts +0 -6
- package/icc-api/api/IccMessageApi.js +0 -15
- package/icc-api/api/IccMessageApi.js.map +1 -1
- package/icc-x-api/auth/SmartAuthProvider.d.ts +37 -13
- package/icc-x-api/auth/SmartAuthProvider.js +105 -29
- package/icc-x-api/auth/SmartAuthProvider.js.map +1 -1
- package/icc-x-api/icc-bekmehr-x-api.js +2 -1
- package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +51 -6
- package/icc-x-api/icc-document-x-api.js +231 -69
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +45 -6
- package/icc-x-api/icc-message-x-api.js +202 -30
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +9 -1
- package/icc-x-api/icc-patient-x-api.js +92 -100
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +14 -14
- package/icc-x-api/index.js +5 -4
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-api/api/IccDocumentApi.js +27 -35
- package/test/icc-api/api/IccDocumentApi.js.map +1 -1
- package/test/icc-x-api/auth/group-switch-test.js +5 -5
- package/test/icc-x-api/auth/group-switch-test.js.map +1 -1
- package/test/icc-x-api/auth/jwt-provider-test.js +1 -1
- package/test/icc-x-api/auth/jwt-provider-test.js.map +1 -1
- package/test/icc-x-api/auth/smart-auth-provider-test.js +5 -5
- package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -1
- package/test/icc-x-api/icc-document-x-api.js +28 -4
- package/test/icc-x-api/icc-document-x-api.js.map +1 -1
- package/test/icc-x-api/icc-message-x-api.js +19 -293
- package/test/icc-x-api/icc-message-x-api.js.map +1 -1
- package/test/icc-x-api/icc-user-x-api-test.js +1 -1
- package/test/icc-x-api/icc-user-x-api-test.js.map +1 -1
- package/test/utils/test_utils.d.ts +4 -2
- package/test/utils/test_utils.js +4 -3
- package/test/utils/test_utils.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAqJ;AACrJ,iCAA4C;AAC5C,+CAA4F;AAC5F,yDAAqD;AAErD,mCAAmC;AACnC,mDAAmE;AAEnE,qDAA4D;AAC5D,2EAAuE;AACvE,+CAA2C;AAC3C,yDAAqD;AACrD,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAElC,+EAA2E;AAC3E,2FAAuF;AACvF,qHAAiH;AACjH,iIAA6H;AAE7H,+BAA6C;AAC7C,mDAAkD;AAClD,2CAA6C;AAE7C,IAAA,UAAO,EAAC,cAAc,CAAC,CAAA;AACvB,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,MAAA,IAAA,2BAAc,EAAC,qCAAqC,EAAE,GAAG,EAAE;IACzD,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,UAA0B,E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C,MAAM,yBAAyB,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IACjD,CAAC,CAAA,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAEjB,IAAA,UAAE,EAAC,6BAA6B,EAAE,GAAS,EAAE;QAC3C,MAAM,yBAAyB,CAC7B;YACE,yBAAyB,EAAE,KAAM;YACjC,kBAAkB,EAAE,CAAC;SACtB,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IACH,CAAC,CAAA,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AACnB,CAAC,CAAC,0CAAE,OAAO,CAAC,KAAM,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { describeNoLite, getEnvironmentInitializer, hcp1Username, hcp2Username, hcp3Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before, it, describe } from 'mocha'\nimport { IccMessageXApi, IccPatientXApi, sleep, SubscriptionOptions } from '../../icc-x-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { IccTopicXApi } from '../../icc-x-api/icc-topic-x-api'\nimport { Topic, TopicRole } from '../../icc-api/model/Topic'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { Message } from '../../icc-api/model/Message'\nimport initApi = TestUtils.initApi\nimport XHRError = XHR.XHRError\nimport { FilterChainMessage } from '../../icc-api/model/FilterChainMessage'\nimport { MessageByHcPartyFilter } from '../../icc-x-api/filters/MessageByHcPartyFilter'\nimport { MessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/MessageByHcPartyTransportGuidFilter'\nimport { LatestMessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter'\nimport { Connection } from '../../icc-api/model/Connection'\nimport { expect, use as chaiUse } from 'chai'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { IccMessageApi } from '../../icc-api'\n\nchaiUse(chaiAsPromised)\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribeNoLite('icc-message-x-api Topic-based 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 createMessage(messageApi: IccMessageXApi, hcpUser: User, patient: Patient | null, topic: Topic) {\n return messageApi.encryptAndCreateMessageInTopic(\n await messageApi.newInstanceWithPatient(\n hcpUser,\n patient,\n new Message({\n id: randomUUID(),\n subject: 'Message Subject',\n sent: new Date().getTime(),\n transportGuid: topic.id,\n readStatus: Object.fromEntries(\n Object.keys(topic.activeParticipants ?? {})\n .filter((p) => p != hcpUser.healthcarePartyId)\n .map((hcpId) => [hcpId, { read: false }])\n ),\n fromHealthcarePartyId: hcpUser.healthcarePartyId,\n }),\n {\n additionalDelegates: Object.fromEntries(\n Object.keys(topic.activeParticipants ?? {})\n .filter((hcpId) => hcpId != hcpUser.healthcarePartyId)\n .map((hcpId) => [hcpId, SecureDelegation.AccessLevelEnum.READ])\n ),\n }\n )\n )\n }\n\n async function createTopic(topicApi: IccTopicXApi, hcpUser: User, patient: Patient, ...additionalUser: { user: User; role: TopicRole }[]) {\n return topicApi.createTopic(\n await topicApi.newInstance(\n hcpUser,\n patient,\n new Topic({\n id: randomUUID(),\n description: 'Topic description',\n activeParticipants: {\n ...Object.fromEntries(additionalUser.map((u) => [u.user.healthcarePartyId!, u.role])),\n [hcpUser.healthcarePartyId!]: TopicRole.OWNER,\n },\n }),\n {\n additionalDelegates: Object.fromEntries(additionalUser.map((u) => [u.user.healthcarePartyId!, SecureDelegation.AccessLevelEnum.WRITE])),\n }\n )\n )\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('An HCP should be able to publish a message on a topic and a participant can read it', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n const message2 = await messageApiForHcp2.getAndDecryptMessage(createdMessage.id!)\n\n expect(message).to.deep.equal(createdMessage)\n expect(message).to.deep.equal(message2)\n })\n\n it('An HCP should be able to publish an encrypted message on a topic', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username, {\n encryptedFieldsConfig: {\n message: ['subject'],\n },\n })\n\n const baseMessageApi = new IccMessageApi(\n env!.iCureUrl,\n messageApiForHcp._headers,\n messageApiForHcp.authenticationProvider,\n messageApiForHcp.fetchImpl\n )\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient)\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n expect(message).to.deep.equal(createdMessage)\n expect(message.subject).to.not.be.undefined\n\n const notDecryptedMessage = await baseMessageApi.getMessage(createdMessage.id!)\n expect(notDecryptedMessage).to.not.deep.equal(createdMessage)\n expect(notDecryptedMessage.subject).to.be.undefined\n })\n\n it('An HCP should be able to publish a message on a topic and a non-participant cannot read it', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const { messageApi: messageApiForHcp3 } = await initApi(env!, hcp3Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n expect(message).to.not.be.null\n\n await messageApiForHcp3.getAndDecryptMessage(createdMessage.id!).then(\n () => expect.fail('Should not be able to read the message'),\n (e) => {\n expect(e).to.be.instanceOf(XHR.XHRError)\n expect((e as XHRError).statusCode).to.equal(403)\n }\n )\n })\n\n it('An HCP should be able to publish a message on a topic and a participant could query it through MessageByHcPartyFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyFilter({\n hcpId: hcpId,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!))\n expect(filterResultForHcp.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!))\n expect(filterResultForHcp2.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n }).timeout(60_000)\n\n it('An HCP should be able to publish a message on a topic and a non-participant should not be able to query it through MessageByHcPartyFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const { messageApi: messageApiForHcp3, userApi: userApiForHcp3 } = await initApi(env!, hcp3Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n const hcpUser3 = await userApiForHcp3.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyFilter({\n hcpId: hcpId,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!))\n expect(filterResultForHcp.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!))\n expect(filterResultForHcp2.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp3 = await messageApiForHcp3.filterMessagesBy(filterChain(hcpUser3.healthcarePartyId!))\n expect(filterResultForHcp3.rows!.find((m) => m.id === message.id)).to.be.undefined\n })\n\n it('An HCP should be able to publish a message on a topic and a participant could query it through MessageByHcPartyTransportGuidFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string, transportGuid: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyTransportGuidFilter({\n healthcarePartyId: hcpId,\n transportGuid: transportGuid,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp.rows).to.have.length(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp2.rows).to.have.length(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n })\n\n it('An HCP should be able to publish a message on a topic and a non-participant should not be able to query it through MessageByHcPartyTransportGuidFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const { userApi: userApiForHcp3, messageApi: messageApiForHcp3 } = await initApi(env!, hcp3Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n const hcpUser3 = await userApiForHcp3.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string, transportGuid: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyTransportGuidFilter({\n healthcarePartyId: hcpId,\n transportGuid: transportGuid,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp.rows).to.have.length(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp2.rows).to.have.length(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp3 = await messageApiForHcp3.filterMessagesBy(filterChain(hcpUser3.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp3.rows!.find((m) => m.id === message.id)).to.be.undefined\n })\n\n it('An HCP should be able to publish a message on a topic and a participant should be able to query it through LatestMessageByHcPartyTransportGuidFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n let latestMessage: Message | null = null\n for (let i = 0; i < 5; i++) {\n // Creating 5 messages\n latestMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n }\n\n const filterChain = (hcpId: string, transportGuid: string) =>\n new FilterChainMessage({\n filter: new LatestMessageByHcPartyTransportGuidFilter({\n healthcarePartyId: hcpId,\n transportGuid: transportGuid,\n }),\n })\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!, latestMessage!.transportGuid!))\n expect(filterResultForHcp2.rows).to.have.length(1) // Only one message should be returned\n expect(filterResultForHcp2.rows![0]).to.deep.equal(latestMessage) // It should be the latest message\n })\n\n async function doXOnYAndSubscribe<Y>(\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 const subscribeAndCreateMessage = async (options: SubscriptionOptions, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp2Username)\n\n const loggedUser = await userApiForHcp.getCurrentUser()\n const connectionPromise = async (options: {}, eventListener: (healthcareElement: Message) => Promise<void>) =>\n messageApiForHcp.subscribeToMessageEvents(\n eventTypes,\n new MessageByHcPartyFilter({\n hcpId: loggedUser!.healthcarePartyId!,\n }),\n eventListener,\n options\n )\n\n const events: Message[] = []\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 connectionPromise(options, async (healthcareElement) => {\n events.push(healthcareElement)\n eventReceivedPromiseResolve()\n }),\n async () => {\n const user = await userApiForHcp.getCurrentUser()\n\n const patient = await patientApiForHcp.createPatientWithUser(\n user,\n await patientApiForHcp.newInstance(\n user,\n new Patient({\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n\n const topic = await topicApiForHcp.createTopic(\n await topicApiForHcp.newInstance(\n loggedUser,\n patient,\n new Topic({\n description: 'Topic description',\n activeParticipants: {\n [loggedUser.healthcarePartyId!]: TopicRole.OWNER,\n },\n })\n )\n )\n\n const createdMessage = await messageApiForHcp.encryptAndCreateMessageInTopic(\n await messageApiForHcp.newInstanceWithPatient(\n loggedUser,\n null,\n new Message({\n id: randomUUID(),\n subject: 'Message Subject',\n sent: new Date().getTime(),\n transportGuid: topic.id,\n readStatus: Object.fromEntries(\n Object.keys(topic.activeParticipants ?? {})\n .filter((hcpId) => hcpId != loggedUser.healthcarePartyId)\n .map((hcpId) => [hcpId, { read: false }])\n ),\n fromHealthcarePartyId: loggedUser.healthcarePartyId,\n }),\n {\n additionalDelegates: {},\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 expect(statuses).to.have.length(2)\n expect(events).to.have.length(1)\n expect(events.every((event) => event instanceof Message)).to.be.true\n }\n\n it('CREATE Message without options', async () => {\n await subscribeAndCreateMessage({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE Message with options', async () => {\n await subscribeAndCreateMessage(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n})?.timeout(60_000)\n"]}
|
|
1
|
+
{"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAS4B;AAC5B,iCAA4C;AAI5C,mCAAmC;AACnC,mDAAmE;AAanE,+BAA6C;AAC7C,mDAAkD;AAClD,2CAA6C;AAI7C,IAAA,UAAO,EAAC,cAAc,CAAC,CAAA;AACvB,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,IAAA,gBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,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,IAAA,UAAE,EAAC,qBAAqB,EAAE,GAAS,EAAE;QACnC,MAAM,GAAG,GAAG,MAAM,IAAA,4BAAe,EAAC,GAAG,EAAE;YACrC,qBAAqB,EAAE;gBACrB,OAAO,EAAE,CAAC,SAAS,CAAC;a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aAAa,CAAC,CAAA;IACtD,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport {\n createNewHcpApi,\n describeNoLite,\n getEnvironmentInitializer,\n hcp1Username,\n hcp2Username,\n hcp3Username,\n setLocalStorage,\n TestUtils,\n} from '../utils/test_utils'\nimport { before, it, describe } from 'mocha'\nimport { IccMessageXApi, IccPatientXApi, sleep, SubscriptionOptions } from '../../icc-x-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { IccTopicXApi } from '../../icc-x-api/icc-topic-x-api'\nimport { Topic, TopicRole } from '../../icc-api/model/Topic'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { Message } from '../../icc-api/model/Message'\nimport initApi = TestUtils.initApi\nimport XHRError = XHR.XHRError\nimport { FilterChainMessage } from '../../icc-api/model/FilterChainMessage'\nimport { MessageByHcPartyFilter } from '../../icc-x-api/filters/MessageByHcPartyFilter'\nimport { MessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/MessageByHcPartyTransportGuidFilter'\nimport { LatestMessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter'\nimport { Connection } from '../../icc-api/model/Connection'\nimport { expect, use as chaiUse } from 'chai'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { IccMessageApi } from '../../icc-api'\nimport undefinedError = Mocha.utils.undefinedError\nimport { create } from 'lodash'\n\nchaiUse(chaiAsPromised)\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribe('icc-message-x-api', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('Should be encrypted', async () => {\n const hcp = await createNewHcpApi(env, {\n encryptedFieldsConfig: {\n message: ['subject'],\n },\n })\n const subject = 'Hello'\n const transportGuid = randomUUID()\n const created = await hcp.api.messageApi.createMessageWithUser(\n undefined,\n await hcp.api.messageApi.newInstance(hcp.user, {\n id: randomUUID(),\n subject,\n transportGuid,\n })\n )\n expect(created.subject).to.eq(subject)\n expect(created.transportGuid).to.eq(transportGuid)\n const retrieved = await hcp.api.messageApi.getMessageWithUser(undefined, created.id!)\n expect(retrieved.subject).to.eq(subject)\n expect(retrieved.transportGuid).to.eq(transportGuid)\n const encrypted = await new IccMessageApi(env.iCureUrl, {}, hcp.api.authApi.authenticationProvider, fetch).getMessage(created.id!)\n expect(encrypted.subject).to.be.undefined\n expect(encrypted.transportGuid).to.eq(transportGuid)\n })\n})\n"]}
|
|
@@ -71,7 +71,7 @@ describe('icc-x-user-api Tests', () => {
|
|
|
71
71
|
} }));
|
|
72
72
|
let longLivedTokenRequested = false;
|
|
73
73
|
let shortLivedTokenRequested = false;
|
|
74
|
-
const authProvider = SmartAuthProvider_1.SmartAuthProvider.initialise(authApi, credentials.user, {
|
|
74
|
+
const authProvider = yield SmartAuthProvider_1.SmartAuthProvider.initialise(authApi, credentials.user, {
|
|
75
75
|
getSecret: (acceptedSecrets, previousAttempts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
76
|
if (acceptedSecrets.includes(SmartAuthProvider_1.AuthSecretType.LONG_LIVED_TOKEN)) {
|
|
77
77
|
longLivedTokenRequested = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-user-x-api-test.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-user-x-api-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAoI;AACpI,iCAA8B;AAC9B,mDAA0C;AAC1C,8CAA0C;AAC1C,mDAAmE;AACnE,+CAAsI;AACtI,mCAAkC;AAClC,+BAAqC;AACrC,mDAA+C;AAC/C,+BAAiC;AACjC,IAAO,aAAa,GAAG,sBAAS,CAAC,aAAa,CAAA;AAC9C,8E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AE,GAAG,EAAE,QAAQ,CAAC,CAAA;oBAC7E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,kCAAc,CAAC,iBAAiB,EAAE,CAAA;gBAC1E,CAAC;;oBAAM,aAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAA;YAC5E,CAAC,CAAA;SACF,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAA;QACjD,IAAA,aAAM,EAAC,CAAC,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;QAC5E,IAAA,aAAM,EAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAA;QAC1C,IAAA,aAAM,EAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAA;QAE5C,MAAM,KAAK,GAAG,IAAA,mBAAU,GAAE,CAAA;QAC1B,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,UAAU,iCAAM,iBAAiB,KAAE,YAAY,EAAE,KAAK,IAAG,CAAA;QAE7F,IAAA,aAAM,EAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;QAC7D,IAAA,aAAM,EAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAA;IAC7C,CAAC,CAAA,CACF,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { createNewHcpApi, getEnvironmentInitializer, hcp1Username, itNoLite, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport { crypto } from '../../node-compat'\nimport { TestApi } from '../utils/TestApi'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { AuthenticationProvider, CryptoPrimitives, WebCryptoPrimitives, IccUserXApi, NoAuthenticationProvider } from '../../icc-x-api'\nimport { webcrypto } from 'crypto'\nimport { assert, expect } from 'chai'\nimport { User } from '../../icc-api/model/User'\nimport { v4 as uuid } from 'uuid'\nimport initMasterApi = TestUtils.initMasterApi\nimport { AuthSecretDetails, AuthSecretType, SmartAuthProvider } from '../../icc-x-api/auth/SmartAuthProvider'\nimport { randomUUID } from 'crypto'\nimport { IccAuthApi, IccUserApi } from '../../icc-api'\n\nsetLocalStorage(fetch)\nlet env: TestVars\nlet authApi: IccAuthApi\n\ndescribe('icc-x-user-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n authApi = new IccAuthApi(env.iCureUrl, {}, new NoAuthenticationProvider(), fetch)\n })\n\n function userApiWithProvider(authProvider: AuthenticationProvider): IccUserApi {\n return new IccUserXApi(env.iCureUrl, {}, authProvider, new IccAuthApi(env.iCureUrl, {}, new NoAuthenticationProvider(), fetch))\n }\n\n it('Can instantiate an API and get the current user', async () => {\n // Given\n const api = await TestApi(env.iCureUrl, env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password, crypto)\n await api.userApi.getCurrentUser()\n })\n\n it('Can get an user by its phoneNumber', async () => {\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const phoneNumber = `+${primitives.randomUuid()}`\n\n const api = await initMasterApi(env)\n\n const createdUser = await api.userApi.createUser(\n new User({\n id: uuid(),\n name: `user-${primitives.randomUuid()}`,\n login: `user-${primitives.randomUuid()}`,\n email: `user-${primitives.randomUuid()}@icure.com`,\n mobilePhone: phoneNumber,\n })\n )\n\n const user = await api.userApi.getUserByPhoneNumber(phoneNumber)\n\n expect(user).to.be.deep.equal(createdUser)\n })\n\n itNoLite(\n 'Should automatically ask for a more powerful secret to perform elevated-security operations if the available secret/token is not good enough. When a new token is created during this process, the modifyUser does not fail with a 409',\n async () => {\n const { credentials, api } = await createNewHcpApi(env)\n const initialUser = await api.userApi.getCurrentUser()\n const masterApi = await initMasterApi(env)\n const userToken = randomUUID()\n const userWithLongToken = await masterApi.userApi.modifyUser({\n ...initialUser,\n authenticationTokens: {\n 'test-long-lived-token': {\n token: userToken,\n creationTime: Date.now(),\n validity: 60 * 60 * 24 * 7,\n },\n },\n })\n let longLivedTokenRequested = false\n let shortLivedTokenRequested = false\n const authProvider = await SmartAuthProvider.initialise(authApi, credentials.user, {\n getSecret: async (acceptedSecrets: AuthSecretType[], previousAttempts: AuthSecretDetails[]) => {\n if (acceptedSecrets.includes(AuthSecretType.LONG_LIVED_TOKEN)) {\n longLivedTokenRequested = true\n return { value: userToken, secretType: AuthSecretType.LONG_LIVED_TOKEN }\n } else if (acceptedSecrets.includes(AuthSecretType.SHORT_LIVED_TOKEN)) {\n shortLivedTokenRequested = true\n await masterApi.userApi.getToken(userWithLongToken.id!, 'tmp', 300, '123456')\n return { value: '123456', secretType: AuthSecretType.SHORT_LIVED_TOKEN }\n } else assert.fail('Should request LONG_LIVED_TOKEN or SHORT_LIVED_TOKEN')\n },\n })\n const userApi = userApiWithProvider(authProvider)\n expect((await userApi.getCurrentUser()).rev).to.equal(userWithLongToken.rev)\n expect(longLivedTokenRequested).to.be.true\n expect(shortLivedTokenRequested).to.be.false\n\n const newPw = randomUUID()\n const userWithNewPw = await userApi.modifyUser({ ...userWithLongToken, passwordHash: newPw })\n\n expect(userWithNewPw.rev).to.not.equal(userWithLongToken.rev)\n expect(shortLivedTokenRequested).to.be.true\n }\n )\n})\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IcureApi, IcureApiOptions } from '../../icc-x-api';
|
|
1
|
+
import { EncryptedFieldsConfig, IcureApi, IcureApiOptions } from '../../icc-x-api';
|
|
2
2
|
import { IcureApi as TestSetupApi } from '@icure/apiV7';
|
|
3
3
|
import { User } from '../../icc-api/model/User';
|
|
4
4
|
import { TestVars, UserDetails } from '@icure/test-setup/types';
|
|
@@ -19,7 +19,9 @@ export declare namespace TestUtils {
|
|
|
19
19
|
function initMasterApi(envVars: TestVars, options?: IcureApiOptions): Promise<IcureApi>;
|
|
20
20
|
}
|
|
21
21
|
export declare function getApiAndAddPrivateKeysForUser(iCureUrl: string, details: UserDetails, options?: IcureApiOptions): Promise<IcureApi>;
|
|
22
|
-
export declare function createNewHcpApi(env: TestVars
|
|
22
|
+
export declare function createNewHcpApi(env: TestVars, options?: {
|
|
23
|
+
encryptedFieldsConfig?: EncryptedFieldsConfig;
|
|
24
|
+
}): Promise<{
|
|
23
25
|
api: IcureApi;
|
|
24
26
|
credentials: UserDetails;
|
|
25
27
|
user: User;
|
package/test/utils/test_utils.js
CHANGED
|
@@ -150,11 +150,11 @@ function createHealthcarePartyUser(api, userLogin, userToken, publicKey, private
|
|
|
150
150
|
};
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
function createNewHcpApi(
|
|
154
|
-
return __awaiter(this,
|
|
153
|
+
function createNewHcpApi(env_1) {
|
|
154
|
+
return __awaiter(this, arguments, void 0, function* (env, options = {}) {
|
|
155
155
|
const initialisationApi = yield testSetupMasterApi(env);
|
|
156
156
|
const primitives = new icc_x_api_1.WebCryptoPrimitives(crypto_1.webcrypto);
|
|
157
|
-
const credentials = yield createHealthcarePartyUser(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
157
|
+
const credentials = yield createHealthcarePartyUser(initialisationApi, `user-${primitives.randomUuid()}@icure.com`, primitives.randomUuid());
|
|
158
158
|
const storage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
159
159
|
{
|
|
160
160
|
dataOwnerId: credentials.dataOwnerId,
|
|
@@ -165,6 +165,7 @@ function createNewHcpApi(env) {
|
|
|
165
165
|
storage: storage.storage,
|
|
166
166
|
keyStorage: storage.keyStorage,
|
|
167
167
|
entryKeysFactory: storage.keyFactory,
|
|
168
|
+
encryptedFieldsConfig: options.encryptedFieldsConfig,
|
|
168
169
|
});
|
|
169
170
|
return { api, credentials, user: yield api.userApi.getCurr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YACP,SAAS;SACV,CAAA;IACH,CAAC;CAAA;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAe,GAAE,CAAC,eAAe,IAAI,KAAK,CAAA;AACnD,CAAC;AAED,SAAgB,cAAc,CAAC,KAAa,EAAE,EAAyB;IACrE,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,OAAO,gBAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACjC,CAAC;SAAM,CAAC;QACN,OAAO,IAAA,gBAAQ,EAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC5B,CAAC;AACH,CAAC;AAED,SAAgB,QAAQ,CAAC,KAAa,EAAE,EAAuC;IAC7E,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC3B,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtB,CAAC;AACH,CAAC","sourcesContent":["import {\n BasicAuthenticationProvider,\n CryptoPrimitives,\n CryptoStrategies,\n hex2ua,\n IcureApi,\n IcureApiOptions,\n IcureBasicApi,\n KeyPair,\n retry,\n RSAUtilsImpl,\n ShaVersion,\n ua2hex,\n WebCryptoPrimitives,\n} from '../../icc-x-api'\nimport { tmpdir } from 'os'\nimport { TextDecoder, TextEncoder } from 'util'\nimport { v4 as uuid } from 'uuid'\nimport { randomUUID, webcrypto } from 'crypto'\nimport { TestApi } from './TestApi'\nimport { IcureApi as TestSetupApi } from '@icure/apiV7'\nimport { testStorageWithKeys } from './TestStorage'\nimport { TestCryptoStrategies } from './TestCryptoStrategies'\nimport { User } from '../../icc-api/model/User'\nimport { TestEnvironmentBuilder } from '@icure/test-setup/builder'\nimport { getEnvVariables, TestVars, UserDetails } from '@icure/test-setup/types'\nimport { EnvInitializer } from '@icure/test-setup/decorators'\nimport 'isomorphic-fetch'\nimport { createPatientUser } from '@icure/test-setup/creation'\nimport { IccUserApi } from '../../icc-api'\nimport { Context, describe, Suite, Test } from 'mocha'\nimport { Group } from '../../icc-api/model/Group'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { KeyPairRecoverer } from '../../icc-x-api/crypto/KeyPairRecoverer'\nimport { KeylessCryptoStrategies } from './KeylessCryptoStrategies'\n\nexport function getTempEmail(): string {\n return `${uuid().substring(0, 8)}@icure.com`\n}\n\nexport function setLocalStorage(fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>) {\n ;(global as any).localStorage = new (require('node-localstorage').LocalStorage)(tmpdir(), 5 * 1024 ** 3)\n ;(global as any).fetch = fetch\n ;(global as any).Storage = ''\n ;(global as any).TextDecoder = TextDecoder\n ;(global as any).TextEncoder = TextEncoder\n ;(global as any).headers = Headers\n}\n\nexport const hcp1Username = process.env.ICURE_TS_TEST_HCP_USER ?? getTempEmail()\nexport const hcp2Username = process.env.ICURE_TS_TEST_HCP_2_USER ?? getTempEmail()\nexport const hcp3Username = process.env.ICURE_TS_TEST_HCP_3_USER ?? getTempEmail()\nexport const patUsername = process.env.ICURE_TS_TEST_PAT_USER ?? getTempEmail()\n\nexport const deviceUsername = getTempEmail()\n\nlet cachedInitializer: EnvInitializer | undefined\n\nexport async function getEnvironmentInitializer(): Promise<EnvInitializer> {\n if (!cachedInitializer) {\n const env = getEnvVariables()\n const scratchDir = 'test/scratch'\n const baseEnvironment =\n env.testEnvironment === 'docker' || env.testEnvironment === 'oss'\n ? new TestEnvironmentBuilder().setUpDockerEnvironment(scratchDir, ['mock'])\n : new TestEnvironmentBuilder()\n cachedInitializer = await baseEnvironment\n .withGroup(fetch, {\n patient: ['BASIC_USER', 'BASIC_DATA_OWNER'],\n hcp: [\n 'BASIC_USER',\n 'BASIC_DATA_OWNER',\n 'PATIENT_USER_MANAGER',\n 'HIERARCHICAL_DATA_OWNER',\n 'TOPIC_MANAGER',\n 'TOPIC_PARTICIPANT',\n 'LEGACY_MESSAGE_MANAGER',\n ],\n device: ['BASIC_USER', 'BASIC_DATA_OWNER'],\n user: ['BASIC_USER'],\n })\n .withMasterUser(fetch)\n .addHcp({ login: hcp1Username })\n .addHcp({ login: hcp2Username })\n .addHcp({ login: hcp3Username })\n .addPatient({ login: patUsername })\n .addDevice({ login: deviceUsername })\n .withSafeguard()\n .withEnvironmentSummary()\n .build()\n }\n return cachedInitializer\n}\n\nexport namespace TestUtils {\n export async function initApi(envVars: TestVars, userName: string = hcp1Username, options?: IcureApiOptions): Promise<IcureApi> {\n return await getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.dataOwnerDetails[userName], options)\n }\n\n export async function initMasterApi(envVars: TestVars, options?: IcureApiOptions): Promise<IcureApi> {\n return await getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.masterHcp!, options)\n }\n}\n\nexport async function getApiAndAddPrivateKeysForUser(iCureUrl: string, details: UserDetails, options?: IcureApiOptions) {\n const RSA = new RSAUtilsImpl(webcrypto as any)\n const keys = {\n publicKey: await RSA.importKey('spki', hex2ua(details.publicKey), ['encrypt'], ShaVersion.Sha1),\n privateKey: await RSA.importKey('pkcs8', hex2ua(details.privateKey), ['decrypt'], ShaVersion.Sha1),\n }\n return await TestApi(iCureUrl, details.user, details.password, webcrypto as any, keys, options)\n}\n\nasync function createHealthcarePartyUser(\n api: TestSetupApi,\n userLogin: string,\n userToken: string,\n publicKey?: string,\n privateKey?: string\n): Promise<UserDetails> {\n const { publicKey: newPublicKey, privateKey: newPrivateKey } = await api.cryptoApi.RSA.generateKeyPair()\n\n const publicKeyHex = !!publicKey && !!privateKey ? publicKey : ua2hex(await api.cryptoApi.RSA.exportKey(newPublicKey, 'spki'))\n const privateKeyHex = !!publicKey && !!privateKey ? privateKey : ua2hex(await api.cryptoApi.RSA.exportKey(newPrivateKey, 'pkcs8'))\n\n const hcp = await api.healthcarePartyApi.createHealthcareParty({\n id: uuid(),\n firstName: uuid().substring(0, 6),\n lastName: uuid().substring(0, 6),\n publicKey: publicKeyHex,\n })\n const hcpUser = await api.userApi.createUser(\n new User({\n id: uuid(),\n name: userLogin,\n login: userLogin,\n email: userLogin,\n healthcarePartyId: hcp.id,\n })\n )\n const token = await api.userApi.getToken(hcpUser.id!, uuid(), 24 * 60 * 60, userToken)\n return {\n user: hcpUser.login!,\n dataOwnerId: hcp.id!,\n password: token,\n publicKey: publicKeyHex,\n privateKey: privateKeyHex,\n }\n}\n\nexport async function createNewHcpApi(env: TestVars): Promise<{\n api: IcureApi\n credentials: UserDetails\n user: User\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const credentials = await createHealthcarePartyUser(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid())\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const api = await IcureApi.initialise(\n env.iCureUrl,\n { username: credentials.user, password: credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: storage.storage,\n keyStorage: storage.keyStorage,\n entryKeysFactory: storage.keyFactory,\n }\n )\n return { api, credentials, user: await api.userApi.getCurrentUser() }\n}\n\nexport async function createNewPatientApi(env: TestVars): Promise<{\n api: IcureApi\n credentials: UserDetails\n user: User\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const credentials = await createPatientUser(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid())\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const api = await IcureApi.initialise(\n env.iCureUrl,\n { username: credentials.user, password: credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: storage.storage,\n keyStorage: storage.keyStorage,\n entryKeysFactory: storage.keyFactory,\n }\n )\n return { api, credentials, user: await api.userApi.getCurrentUser() }\n}\n\nexport async function createNewKeylessApi(env: TestVars): Promise<{\n api: IcureApi\n credentials: { username: string; password: string }\n}> {\n const initialisationApi = await IcureBasicApi.initialise(env.iCureUrl, { username: env.masterHcp!.user, password: env.masterHcp!.password }, fetch)\n const login = `${randomUUID()}@test.icure.com`\n const password = randomUUID()\n const patient = new Patient({\n id: randomUUID(),\n firstName: 'Gino',\n lastName: 'Pino',\n })\n const user = new User({\n id: randomUUID(),\n login,\n passwordHash: password,\n patientId: patient.id,\n })\n await initialisationApi.userApi.createUser(user)\n await initialisationApi.patientApi.createPatient(patient)\n const credentials = { username: login, password }\n const cryptoStrategies = new KeylessCryptoStrategies()\n const api = await IcureApi.initialise(env.iCureUrl, credentials, cryptoStrategies, webcrypto as any, fetch, {})\n if (!cryptoStrategies.requestedKey) throw new Error('Illegal state: did not request key')\n return { api, credentials }\n}\n\n/**\n * Creates a hierarchy of HCPs with the following structure:\n * grand HCP -+-> parent HCP ---> child HCP\n * |\n * +-> child2 HCP\n */\nexport async function createHcpHierarchyApis(\n env: TestVars,\n setupAutodelegations: boolean = true,\n disableParentKeysInitialisation: boolean = false\n): Promise<{\n grandApi: IcureApi\n grandUser: User\n grandCredentials: UserDetails\n parentApi: IcureApi\n parentUser: User\n parentCredentials: UserDetails\n childApi: IcureApi\n childUser: User\n childCredentials: UserDetails\n child2Api: IcureApi\n child2User: User\n child2Credentials: UserDetails\n}> {\n const shaVersion = ShaVersion.Sha1\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const grandCredentials = await createHealthcarePartyUser(initialisationApi, `grand-${primitives.randomUuid()}`, primitives.randomUuid())\n const parentCredentials = await createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid())\n const childCredentials = await createHealthcarePartyUser(initialisationApi, `child-${primitives.randomUuid()}`, primitives.randomUuid())\n const child2Credentials = await createHealthcarePartyUser(initialisationApi, `child2-${primitives.randomUuid()}`, primitives.randomUuid())\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(parentCredentials.dataOwnerId)),\n parentId: grandCredentials.dataOwnerId,\n })\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(childCredentials.dataOwnerId)),\n parentId: parentCredentials.dataOwnerId,\n })\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(child2Credentials.dataOwnerId)),\n parentId: grandCredentials.dataOwnerId,\n })\n const grandStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const grandApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: grandCredentials.user, password: grandCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: grandStorage.storage,\n keyStorage: grandStorage.keyStorage,\n entryKeysFactory: grandStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const parentStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: parentCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const parentApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: parentCredentials.user, password: parentCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: parentStorage.storage,\n keyStorage: parentStorage.keyStorage,\n entryKeysFactory: parentStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const parentUser = setupAutodelegations\n ? await parentApi.userApi.modifyUser({\n ...(await parentApi.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId] },\n })\n : await parentApi.userApi.getCurrentUser()\n const childStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: parentCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: childCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: childCredentials.privateKey, publicKey: childCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const childApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: childCredentials.user, password: childCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: childStorage.storage,\n keyStorage: childStorage.keyStorage,\n entryKeysFactory: childStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const childUser = setupAutodelegations\n ? await childApi.userApi.modifyUser({\n ...(await childApi.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId, parentCredentials.dataOwnerId] },\n })\n : await childApi.userApi.getCurrentUser()\n const child2Storage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: child2Credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: child2Credentials.privateKey, publicKey: child2Credentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const child2Api = await IcureApi.initialise(\n env.iCureUrl,\n { username: child2Credentials.user, password: child2Credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: child2Storage.storage,\n keyStorage: child2Storage.keyStorage,\n entryKeysFactory: child2Storage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const child2User = setupAutodelegations\n ? await child2Api.userApi.modifyUser({\n ...(await child2Api.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId] },\n })\n : await child2Api.userApi.getCurrentUser()\n return {\n grandApi,\n grandUser: await grandApi.userApi.getCurrentUser(),\n grandCredentials,\n parentApi,\n parentUser,\n parentCredentials,\n childApi,\n childUser,\n childCredentials,\n child2Api,\n child2User,\n child2Credentials,\n }\n}\n\n/**\n * Create a parent HCP with a key and a child HCP without any initialised key\n */\nexport async function createNewHcpWithoutKeyAndParentWithKey(\n env: TestVars,\n props: {\n initialiseEmptyKeyForChild?: boolean\n } = {}\n): Promise<{\n parentCredentials: UserDetails\n childUser: string\n childDataOwnerId: string\n childPassword: string\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const parentCredentials = await createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid())\n const childUser = uuid() + '@email.com'\n const childPassword = uuid()\n const childHcp = {\n id: uuid(),\n firstName: uuid().substring(0, 6),\n lastName: uuid().substring(0, 6),\n parentId: parentCredentials.dataOwnerId,\n publicKey: undefined as string | undefined,\n }\n if (props.initialiseEmptyKeyForChild) {\n childHcp.publicKey = ''\n }\n await initialisationApi.healthcarePartyApi.createHealthcareParty(childHcp)\n await initialisationApi.userApi.createUser(\n new User({\n id: uuid(),\n name: childUser,\n login: childUser,\n email: childUser,\n passwordHash: childPassword,\n healthcarePartyId: childHcp.id,\n })\n )\n return {\n parentCredentials,\n childUser,\n childPassword,\n childDataOwnerId: childHcp.id!,\n }\n}\n\nexport function testSetupMasterApi(env: TestVars): Promise<TestSetupApi> {\n return TestSetupApi.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n {\n generateNewKeyForDataOwner(): Promise<boolean> {\n return Promise.resolve(true)\n },\n recoverAndVerifySelfHierarchyKeys(): never {\n throw new Error('Unsupported')\n },\n verifyDelegatePublicKeys(delegate: any, publicKeys: string[]): Promise<string[]> {\n return Promise.resolve(publicKeys)\n },\n },\n webcrypto as any,\n fetch\n )\n}\n\nexport type UserInManyGroupsDetails = {\n user1: User\n user2: User\n group3: Group\n userPw3: string\n user3: User\n group2: Group\n group1: Group\n userPw12: string\n userLogin: string\n}\nexport async function createUserInMultipleGroups(env: TestVars): Promise<UserInManyGroupsDetails> {\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const userGroup1Id: string = primitives.randomUuid() // Same username-pw as group 2\n const userGroup2Id: string = primitives.randomUuid() // Same username-pw as group 1\n const userGroup3Id: string = primitives.randomUuid() // Same username as group 1/2, different pw\n const userLogin: string = `maria-${primitives.randomUuid()}@pompei.it`\n const userPw12: string = `geppetto-${primitives.randomUuid()}`\n const userPw3: string = `pinocchio-${primitives.randomUuid()}`\n const user1Id: string = primitives.randomUuid()\n const user2Id: string = primitives.randomUuid()\n const user3Id: string = primitives.randomUuid()\n const api = await IcureBasicApi.initialise(env.iCureUrl, { username: 'john', password: 'LetMeIn' }, fetch) // pragma: allowlist secret\n const group1 = await api.groupApi.createGroup(\n userGroup1Id,\n `test-group-1-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const group2 = await api.groupApi.createGroup(\n userGroup2Id,\n `test-group-2-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const group3 = await api.groupApi.createGroup(\n userGroup3Id,\n `test-group-3-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const user1 = await api.userApi.createUserInGroup(userGroup1Id, {\n id: user1Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw12,\n })\n const user2 = await api.userApi.createUserInGroup(userGroup2Id, {\n id: user2Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw12,\n })\n const user3 = await api.userApi.createUserInGroup(userGroup3Id, {\n id: user3Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw3,\n })\n console.log(`Waiting for user to be created - ${userLogin}`)\n await retry(\n async () => {\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup1Id}/${user1Id}`, userPw12), fetch).getCurrentUser()\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup2Id}/${user2Id}`, userPw12), fetch).getCurrentUser()\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup3Id}/${user3Id}`, userPw3), fetch).getCurrentUser()\n },\n 10,\n 5_000,\n 1\n )\n return {\n user1,\n user2,\n user3,\n group1,\n group2,\n group3,\n userPw12,\n userPw3,\n userLogin,\n }\n}\n\nexport function isLiteTest() {\n return getEnvVariables().testEnvironment == 'oss'\n}\n\nexport function describeNoLite(title: string, fn: (this: Suite) => void): Suite | void {\n if (isLiteTest()) {\n return describe.skip(title, fn)\n } else {\n return describe(title, fn)\n }\n}\n\nexport function itNoLite(title: string, fn: (this: Context) => PromiseLike<any>): Test {\n if (isLiteTest()) {\n return it.skip(title, fn)\n } else {\n return it(title, fn)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test_utils.js","sourceRoot":"","sources":["../../../test/utils/test_utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAwCA,oCAEC;AAED,0CAOC;AAWD,8DAkCC;AAYD,wEAOC;AAuCD,0CAiCC;AAED,kDA2BC;AAED,kDAyBC;AAQD,wDAiKC;AAKD,wFA2CC;AAED,gDAkBC;AAaD,gE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,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACjC,CAAC;SAAM,CAAC;QACN,OAAO,IAAA,gBAAQ,EAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC5B,CAAC;AACH,CAAC;AAED,SAAgB,QAAQ,CAAC,KAAa,EAAE,EAAuC;IAC7E,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC3B,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtB,CAAC;AACH,CAAC","sourcesContent":["import {\n BasicAuthenticationProvider,\n CryptoPrimitives,\n CryptoStrategies,\n EncryptedFieldsConfig,\n hex2ua,\n IcureApi,\n IcureApiOptions,\n IcureBasicApi,\n KeyPair,\n retry,\n RSAUtilsImpl,\n ShaVersion,\n ua2hex,\n WebCryptoPrimitives,\n} from '../../icc-x-api'\nimport { tmpdir } from 'os'\nimport { TextDecoder, TextEncoder } from 'util'\nimport { v4 as uuid } from 'uuid'\nimport { randomUUID, webcrypto } from 'crypto'\nimport { TestApi } from './TestApi'\nimport { IcureApi as TestSetupApi } from '@icure/apiV7'\nimport { testStorageWithKeys } from './TestStorage'\nimport { TestCryptoStrategies } from './TestCryptoStrategies'\nimport { User } from '../../icc-api/model/User'\nimport { TestEnvironmentBuilder } from '@icure/test-setup/builder'\nimport { getEnvVariables, TestVars, UserDetails } from '@icure/test-setup/types'\nimport { EnvInitializer } from '@icure/test-setup/decorators'\nimport 'isomorphic-fetch'\nimport { createPatientUser } from '@icure/test-setup/creation'\nimport { IccUserApi } from '../../icc-api'\nimport { Context, describe, Suite, Test } from 'mocha'\nimport { Group } from '../../icc-api/model/Group'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { KeyPairRecoverer } from '../../icc-x-api/crypto/KeyPairRecoverer'\nimport { KeylessCryptoStrategies } from './KeylessCryptoStrategies'\n\nexport function getTempEmail(): string {\n return `${uuid().substring(0, 8)}@icure.com`\n}\n\nexport function setLocalStorage(fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>) {\n ;(global as any).localStorage = new (require('node-localstorage').LocalStorage)(tmpdir(), 5 * 1024 ** 3)\n ;(global as any).fetch = fetch\n ;(global as any).Storage = ''\n ;(global as any).TextDecoder = TextDecoder\n ;(global as any).TextEncoder = TextEncoder\n ;(global as any).headers = Headers\n}\n\nexport const hcp1Username = process.env.ICURE_TS_TEST_HCP_USER ?? getTempEmail()\nexport const hcp2Username = process.env.ICURE_TS_TEST_HCP_2_USER ?? getTempEmail()\nexport const hcp3Username = process.env.ICURE_TS_TEST_HCP_3_USER ?? getTempEmail()\nexport const patUsername = process.env.ICURE_TS_TEST_PAT_USER ?? getTempEmail()\n\nexport const deviceUsername = getTempEmail()\n\nlet cachedInitializer: EnvInitializer | undefined\n\nexport async function getEnvironmentInitializer(): Promise<EnvInitializer> {\n if (!cachedInitializer) {\n const env = getEnvVariables()\n const scratchDir = 'test/scratch'\n const baseEnvironment =\n env.testEnvironment === 'docker' || env.testEnvironment === 'oss'\n ? new TestEnvironmentBuilder().setUpDockerEnvironment(scratchDir, ['mock'])\n : new TestEnvironmentBuilder()\n cachedInitializer = await baseEnvironment\n .withGroup(fetch, {\n patient: ['BASIC_USER', 'BASIC_DATA_OWNER'],\n hcp: [\n 'BASIC_USER',\n 'BASIC_DATA_OWNER',\n 'PATIENT_USER_MANAGER',\n 'HIERARCHICAL_DATA_OWNER',\n 'TOPIC_MANAGER',\n 'TOPIC_PARTICIPANT',\n 'LEGACY_MESSAGE_MANAGER',\n ],\n device: ['BASIC_USER', 'BASIC_DATA_OWNER'],\n user: ['BASIC_USER'],\n })\n .withMasterUser(fetch)\n .addHcp({ login: hcp1Username })\n .addHcp({ login: hcp2Username })\n .addHcp({ login: hcp3Username })\n .addPatient({ login: patUsername })\n .addDevice({ login: deviceUsername })\n .withSafeguard()\n .withEnvironmentSummary()\n .build()\n }\n return cachedInitializer\n}\n\nexport namespace TestUtils {\n export async function initApi(envVars: TestVars, userName: string = hcp1Username, options?: IcureApiOptions): Promise<IcureApi> {\n return await getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.dataOwnerDetails[userName], options)\n }\n\n export async function initMasterApi(envVars: TestVars, options?: IcureApiOptions): Promise<IcureApi> {\n return await getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.masterHcp!, options)\n }\n}\n\nexport async function getApiAndAddPrivateKeysForUser(iCureUrl: string, details: UserDetails, options?: IcureApiOptions) {\n const RSA = new RSAUtilsImpl(webcrypto as any)\n const keys = {\n publicKey: await RSA.importKey('spki', hex2ua(details.publicKey), ['encrypt'], ShaVersion.Sha1),\n privateKey: await RSA.importKey('pkcs8', hex2ua(details.privateKey), ['decrypt'], ShaVersion.Sha1),\n }\n return await TestApi(iCureUrl, details.user, details.password, webcrypto as any, keys, options)\n}\n\nasync function createHealthcarePartyUser(\n api: TestSetupApi,\n userLogin: string,\n userToken: string,\n publicKey?: string,\n privateKey?: string\n): Promise<UserDetails> {\n const { publicKey: newPublicKey, privateKey: newPrivateKey } = await api.cryptoApi.RSA.generateKeyPair()\n\n const publicKeyHex = !!publicKey && !!privateKey ? publicKey : ua2hex(await api.cryptoApi.RSA.exportKey(newPublicKey, 'spki'))\n const privateKeyHex = !!publicKey && !!privateKey ? privateKey : ua2hex(await api.cryptoApi.RSA.exportKey(newPrivateKey, 'pkcs8'))\n\n const hcp = await api.healthcarePartyApi.createHealthcareParty({\n id: uuid(),\n firstName: uuid().substring(0, 6),\n lastName: uuid().substring(0, 6),\n publicKey: publicKeyHex,\n })\n const hcpUser = await api.userApi.createUser(\n new User({\n id: uuid(),\n name: userLogin,\n login: userLogin,\n email: userLogin,\n healthcarePartyId: hcp.id,\n })\n )\n const token = await api.userApi.getToken(hcpUser.id!, uuid(), 24 * 60 * 60, userToken)\n return {\n user: hcpUser.login!,\n dataOwnerId: hcp.id!,\n password: token,\n publicKey: publicKeyHex,\n privateKey: privateKeyHex,\n }\n}\n\nexport async function createNewHcpApi(\n env: TestVars,\n options: {\n encryptedFieldsConfig?: EncryptedFieldsConfig\n } = {}\n): Promise<{\n api: IcureApi\n credentials: UserDetails\n user: User\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const credentials = await createHealthcarePartyUser(initialisationApi, `user-${primitives.randomUuid()}@icure.com`, primitives.randomUuid())\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const api = await IcureApi.initialise(\n env.iCureUrl,\n { username: credentials.user, password: credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: storage.storage,\n keyStorage: storage.keyStorage,\n entryKeysFactory: storage.keyFactory,\n encryptedFieldsConfig: options.encryptedFieldsConfig,\n }\n )\n return { api, credentials, user: await api.userApi.getCurrentUser() }\n}\n\nexport async function createNewPatientApi(env: TestVars): Promise<{\n api: IcureApi\n credentials: UserDetails\n user: User\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const credentials = await createPatientUser(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid())\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const api = await IcureApi.initialise(\n env.iCureUrl,\n { username: credentials.user, password: credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: storage.storage,\n keyStorage: storage.keyStorage,\n entryKeysFactory: storage.keyFactory,\n }\n )\n return { api, credentials, user: await api.userApi.getCurrentUser() }\n}\n\nexport async function createNewKeylessApi(env: TestVars): Promise<{\n api: IcureApi\n credentials: { username: string; password: string }\n}> {\n const initialisationApi = await IcureBasicApi.initialise(env.iCureUrl, { username: env.masterHcp!.user, password: env.masterHcp!.password }, fetch)\n const login = `${randomUUID()}@test.icure.com`\n const password = randomUUID()\n const patient = new Patient({\n id: randomUUID(),\n firstName: 'Gino',\n lastName: 'Pino',\n })\n const user = new User({\n id: randomUUID(),\n login,\n passwordHash: password,\n patientId: patient.id,\n })\n await initialisationApi.userApi.createUser(user)\n await initialisationApi.patientApi.createPatient(patient)\n const credentials = { username: login, password }\n const cryptoStrategies = new KeylessCryptoStrategies()\n const api = await IcureApi.initialise(env.iCureUrl, credentials, cryptoStrategies, webcrypto as any, fetch, {})\n if (!cryptoStrategies.requestedKey) throw new Error('Illegal state: did not request key')\n return { api, credentials }\n}\n\n/**\n * Creates a hierarchy of HCPs with the following structure:\n * grand HCP -+-> parent HCP ---> child HCP\n * |\n * +-> child2 HCP\n */\nexport async function createHcpHierarchyApis(\n env: TestVars,\n setupAutodelegations: boolean = true,\n disableParentKeysInitialisation: boolean = false\n): Promise<{\n grandApi: IcureApi\n grandUser: User\n grandCredentials: UserDetails\n parentApi: IcureApi\n parentUser: User\n parentCredentials: UserDetails\n childApi: IcureApi\n childUser: User\n childCredentials: UserDetails\n child2Api: IcureApi\n child2User: User\n child2Credentials: UserDetails\n}> {\n const shaVersion = ShaVersion.Sha1\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const grandCredentials = await createHealthcarePartyUser(initialisationApi, `grand-${primitives.randomUuid()}`, primitives.randomUuid())\n const parentCredentials = await createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid())\n const childCredentials = await createHealthcarePartyUser(initialisationApi, `child-${primitives.randomUuid()}`, primitives.randomUuid())\n const child2Credentials = await createHealthcarePartyUser(initialisationApi, `child2-${primitives.randomUuid()}`, primitives.randomUuid())\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(parentCredentials.dataOwnerId)),\n parentId: grandCredentials.dataOwnerId,\n })\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(childCredentials.dataOwnerId)),\n parentId: parentCredentials.dataOwnerId,\n })\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(child2Credentials.dataOwnerId)),\n parentId: grandCredentials.dataOwnerId,\n })\n const grandStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const grandApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: grandCredentials.user, password: grandCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: grandStorage.storage,\n keyStorage: grandStorage.keyStorage,\n entryKeysFactory: grandStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const parentStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: parentCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const parentApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: parentCredentials.user, password: parentCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: parentStorage.storage,\n keyStorage: parentStorage.keyStorage,\n entryKeysFactory: parentStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const parentUser = setupAutodelegations\n ? await parentApi.userApi.modifyUser({\n ...(await parentApi.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId] },\n })\n : await parentApi.userApi.getCurrentUser()\n const childStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: parentCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: childCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: childCredentials.privateKey, publicKey: childCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const childApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: childCredentials.user, password: childCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: childStorage.storage,\n keyStorage: childStorage.keyStorage,\n entryKeysFactory: childStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const childUser = setupAutodelegations\n ? await childApi.userApi.modifyUser({\n ...(await childApi.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId, parentCredentials.dataOwnerId] },\n })\n : await childApi.userApi.getCurrentUser()\n const child2Storage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: child2Credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: child2Credentials.privateKey, publicKey: child2Credentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const child2Api = await IcureApi.initialise(\n env.iCureUrl,\n { username: child2Credentials.user, password: child2Credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: child2Storage.storage,\n keyStorage: child2Storage.keyStorage,\n entryKeysFactory: child2Storage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const child2User = setupAutodelegations\n ? await child2Api.userApi.modifyUser({\n ...(await child2Api.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId] },\n })\n : await child2Api.userApi.getCurrentUser()\n return {\n grandApi,\n grandUser: await grandApi.userApi.getCurrentUser(),\n grandCredentials,\n parentApi,\n parentUser,\n parentCredentials,\n childApi,\n childUser,\n childCredentials,\n child2Api,\n child2User,\n child2Credentials,\n }\n}\n\n/**\n * Create a parent HCP with a key and a child HCP without any initialised key\n */\nexport async function createNewHcpWithoutKeyAndParentWithKey(\n env: TestVars,\n props: {\n initialiseEmptyKeyForChild?: boolean\n } = {}\n): Promise<{\n parentCredentials: UserDetails\n childUser: string\n childDataOwnerId: string\n childPassword: string\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const parentCredentials = await createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid())\n const childUser = uuid() + '@email.com'\n const childPassword = uuid()\n const childHcp = {\n id: uuid(),\n firstName: uuid().substring(0, 6),\n lastName: uuid().substring(0, 6),\n parentId: parentCredentials.dataOwnerId,\n publicKey: undefined as string | undefined,\n }\n if (props.initialiseEmptyKeyForChild) {\n childHcp.publicKey = ''\n }\n await initialisationApi.healthcarePartyApi.createHealthcareParty(childHcp)\n await initialisationApi.userApi.createUser(\n new User({\n id: uuid(),\n name: childUser,\n login: childUser,\n email: childUser,\n passwordHash: childPassword,\n healthcarePartyId: childHcp.id,\n })\n )\n return {\n parentCredentials,\n childUser,\n childPassword,\n childDataOwnerId: childHcp.id!,\n }\n}\n\nexport function testSetupMasterApi(env: TestVars): Promise<TestSetupApi> {\n return TestSetupApi.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n {\n generateNewKeyForDataOwner(): Promise<boolean> {\n return Promise.resolve(true)\n },\n recoverAndVerifySelfHierarchyKeys(): never {\n throw new Error('Unsupported')\n },\n verifyDelegatePublicKeys(delegate: any, publicKeys: string[]): Promise<string[]> {\n return Promise.resolve(publicKeys)\n },\n },\n webcrypto as any,\n fetch\n )\n}\n\nexport type UserInManyGroupsDetails = {\n user1: User\n user2: User\n group3: Group\n userPw3: string\n user3: User\n group2: Group\n group1: Group\n userPw12: string\n userLogin: string\n}\nexport async function createUserInMultipleGroups(env: TestVars): Promise<UserInManyGroupsDetails> {\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const userGroup1Id: string = primitives.randomUuid() // Same username-pw as group 2\n const userGroup2Id: string = primitives.randomUuid() // Same username-pw as group 1\n const userGroup3Id: string = primitives.randomUuid() // Same username as group 1/2, different pw\n const userLogin: string = `maria-${primitives.randomUuid()}@pompei.it`\n const userPw12: string = `geppetto-${primitives.randomUuid()}`\n const userPw3: string = `pinocchio-${primitives.randomUuid()}`\n const user1Id: string = primitives.randomUuid()\n const user2Id: string = primitives.randomUuid()\n const user3Id: string = primitives.randomUuid()\n const api = await IcureBasicApi.initialise(env.iCureUrl, { username: 'john', password: 'LetMeIn' }, fetch) // pragma: allowlist secret\n const group1 = await api.groupApi.createGroup(\n userGroup1Id,\n `test-group-1-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const group2 = await api.groupApi.createGroup(\n userGroup2Id,\n `test-group-2-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const group3 = await api.groupApi.createGroup(\n userGroup3Id,\n `test-group-3-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const user1 = await api.userApi.createUserInGroup(userGroup1Id, {\n id: user1Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw12,\n })\n const user2 = await api.userApi.createUserInGroup(userGroup2Id, {\n id: user2Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw12,\n })\n const user3 = await api.userApi.createUserInGroup(userGroup3Id, {\n id: user3Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw3,\n })\n console.log(`Waiting for user to be created - ${userLogin}`)\n await retry(\n async () => {\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup1Id}/${user1Id}`, userPw12), fetch).getCurrentUser()\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup2Id}/${user2Id}`, userPw12), fetch).getCurrentUser()\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup3Id}/${user3Id}`, userPw3), fetch).getCurrentUser()\n },\n 10,\n 5_000,\n 1\n )\n return {\n user1,\n user2,\n user3,\n group1,\n group2,\n group3,\n userPw12,\n userPw3,\n userLogin,\n }\n}\n\nexport function isLiteTest() {\n return getEnvVariables().testEnvironment == 'oss'\n}\n\nexport function describeNoLite(title: string, fn: (this: Suite) => void): Suite | void {\n if (isLiteTest()) {\n return describe.skip(title, fn)\n } else {\n return describe(title, fn)\n }\n}\n\nexport function itNoLite(title: string, fn: (this: Context) => PromiseLike<any>): Test {\n if (isLiteTest()) {\n return it.skip(title, fn)\n } else {\n return it(title, fn)\n }\n}\n"]}
|