@icure/api 8.6.6 → 8.6.8
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/IccAccesslogApi.d.ts +14 -0
- package/icc-api/api/IccAccesslogApi.js +31 -0
- package/icc-api/api/IccAccesslogApi.js.map +1 -1
- package/icc-api/api/IccFormApi.d.ts +8 -0
- package/icc-api/api/IccFormApi.js +21 -0
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/model/AbstractFilterAccessLog.d.ts +15 -0
- package/icc-api/model/AbstractFilterAccessLog.js +21 -0
- package/icc-api/model/AbstractFilterAccessLog.js.map +1 -0
- package/icc-api/model/ChapterParagraph.d.ts +16 -0
- package/icc-api/model/ChapterParagraph.js +21 -0
- package/icc-api/model/ChapterParagraph.js.map +1 -0
- package/icc-api/model/CryptoActorStub.d.ts +2 -0
- package/icc-api/model/CryptoActorStub.js.map +1 -1
- package/icc-api/model/Device.d.ts +1 -0
- package/icc-api/model/Device.js.map +1 -1
- package/icc-api/model/HealthcareParty.d.ts +1 -0
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/Patient.d.ts +1 -0
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-api/model/Reimbursement.d.ts +2 -0
- package/icc-api/model/Reimbursement.js.map +1 -1
- package/icc-x-api/crypto/CryptoStrategies.d.ts +2 -1
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +2 -2
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js +2 -2
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
- package/icc-x-api/filters/AccessLogByDataOwnerPatientDateFilter.d.ts +22 -0
- package/icc-x-api/filters/AccessLogByDataOwnerPatientDateFilter.js +24 -0
- package/icc-x-api/filters/AccessLogByDataOwnerPatientDateFilter.js.map +1 -0
- package/icc-x-api/filters/AccessLogByDateFilter.d.ts +20 -0
- package/icc-x-api/filters/AccessLogByDateFilter.js +24 -0
- package/icc-x-api/filters/AccessLogByDateFilter.js.map +1 -0
- package/icc-x-api/filters/AccessLogByUserIdUserTypeDateFilter.d.ts +21 -0
- package/icc-x-api/filters/AccessLogByUserIdUserTypeDateFilter.js +24 -0
- package/icc-x-api/filters/AccessLogByUserIdUserTypeDateFilter.js.map +1 -0
- package/icc-x-api/icc-contact-x-api.js +3 -3
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/utils/crypto-utils.d.ts +2 -1
- package/icc-x-api/utils/crypto-utils.js +57 -6
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.js +1 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +1 -1
- package/test/icc-x-api/crypto/cryptoTest.js +99 -1
- package/test/icc-x-api/crypto/cryptoTest.js.map +1 -1
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.js +3 -3
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +1 -1
- package/test/icc-x-api/entity-with-attachments-api-test.js +2 -2
- package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -1
- package/test/icc-x-api/icc-form-x-api.js +51 -0
- package/test/icc-x-api/icc-form-x-api.js.map +1 -1
- package/test/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/support/CSM-243.js +5 -5
- package/test/support/CSM-243.js.map +1 -1
- package/test/support/CSM-729.d.ts +1 -0
- package/test/support/CSM-729.js +225 -0
- package/test/support/CSM-729.js.map +1 -0
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const icc_api_1 = require("../../../icc-api");
|
|
13
12
|
require("isomorphic-fetch");
|
|
14
13
|
const chai_1 = require("chai");
|
|
15
14
|
require("mocha");
|
|
@@ -20,6 +19,8 @@ const icc_x_api_1 = require("../../../icc-x-api");
|
|
|
20
19
|
var initApi = test_utils_1.TestUtils.initApi;
|
|
21
20
|
const SecretIdUseOption_1 = require("../../../icc-x-api/crypto/SecretIdUseOption");
|
|
22
21
|
var UseAnyConfidential = SecretIdUseOption_1.SecretIdUseOption.UseAnyConfidential;
|
|
22
|
+
const icc_api_1 = require("../../../icc-api");
|
|
23
|
+
const crypto_1 = require("crypto");
|
|
23
24
|
(0, chai_1.use)(require('chai-as-promised'));
|
|
24
25
|
let env;
|
|
25
26
|
(0, test_utils_1.setLocalStorage)(fetch);
|
|
@@ -52,6 +53,103 @@ describe('Create a patient from scratch', () => {
|
|
|
52
53
|
(0, chai_1.expect)(fetchedWithoutDecryption.note).to.be.undefined;
|
|
53
54
|
}));
|
|
54
55
|
});
|
|
56
|
+
describe('Entity encryption', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
it('encrypted self should not change after re-encryption if encrypted data do not change', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const api = yield initApi(env, test_utils_1.hcp1Username);
|
|
59
|
+
const user = yield api.userApi.getCurrentUser();
|
|
60
|
+
const note = 'A secured note that is encrypted';
|
|
61
|
+
const patient = yield api.patientApi.createPatientWithUser(user, yield api.patientApi.newInstance(user, new Patient_1.Patient({
|
|
62
|
+
lastName: 'Biden',
|
|
63
|
+
firstName: 'Joe',
|
|
64
|
+
note,
|
|
65
|
+
})));
|
|
66
|
+
(0, chai_1.expect)(patient.note).to.equal(note);
|
|
67
|
+
(0, chai_1.expect)(patient.encryptedSelf).to.not.be.empty;
|
|
68
|
+
const updatedPatient = yield api.patientApi.modifyPatientWithUser(user, Object.assign(Object.assign({}, patient), { firstName: 'John' }));
|
|
69
|
+
(0, chai_1.expect)(updatedPatient === null || updatedPatient === void 0 ? void 0 : updatedPatient.firstName).to.equal('John');
|
|
70
|
+
(0, chai_1.expect)(updatedPatient === null || updatedPatient === void 0 ? void 0 : updatedPatient.note).to.equal(patient.note);
|
|
71
|
+
(0, chai_1.expect)(updatedPatient === null || updatedPatient === void 0 ? void 0 : updatedPatient.encryptedSelf).to.equal(patient.encryptedSelf);
|
|
72
|
+
const contactWithBasicContent = (yield api.contactApi.createContactWithUser(user, yield api.contactApi.newInstance(user, patient, {
|
|
73
|
+
services: [
|
|
74
|
+
{
|
|
75
|
+
id: (0, crypto_1.randomUUID)(),
|
|
76
|
+
valueDate: 20250101000000,
|
|
77
|
+
content: {
|
|
78
|
+
en: {
|
|
79
|
+
stringValue: 'A service with only basic content',
|
|
80
|
+
numberValue: 1234,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
descr: 'Demo',
|
|
86
|
+
})));
|
|
87
|
+
(0, chai_1.expect)(contactWithBasicContent.encryptedSelf).to.not.be.empty;
|
|
88
|
+
(0, chai_1.expect)(contactWithBasicContent.services[0].encryptedSelf).to.not.be.empty;
|
|
89
|
+
const updatedContactWithBasicContent = yield api.contactApi.modifyContactWithUser(user, Object.assign(Object.assign({}, contactWithBasicContent), { services: [
|
|
90
|
+
Object.assign(Object.assign({}, contactWithBasicContent.services[0]), { valueDate: 20250101120000 }),
|
|
91
|
+
] }));
|
|
92
|
+
(0, chai_1.expect)(updatedContactWithBasicContent === null || updatedContactWithBasicContent === void 0 ? void 0 : updatedContactWithBasicContent.services[0].valueDate).to.equal(20250101120000);
|
|
93
|
+
(0, chai_1.expect)(updatedContactWithBasicContent === null || updatedContactWithBasicContent === void 0 ? void 0 : updatedContactWithBasicContent.services[0].encryptedSelf).to.equal(contactWithBasicContent.services[0].encryptedSelf);
|
|
94
|
+
(0, chai_1.expect)(updatedContactWithBasicContent === null || updatedContactWithBasicContent === void 0 ? void 0 : updatedContactWithBasicContent.encryptedSelf).to.equal(contactWithBasicContent.encryptedSelf);
|
|
95
|
+
const contactWithCompoundContent = (yield api.contactApi.createContactWithUser(user, yield api.contactApi.newInstance(user, patient, {
|
|
96
|
+
services: [
|
|
97
|
+
{
|
|
98
|
+
id: (0, crypto_1.randomUUID)(),
|
|
99
|
+
valueDate: 20250101000000,
|
|
100
|
+
content: {
|
|
101
|
+
en: {
|
|
102
|
+
compoundValue: [
|
|
103
|
+
{
|
|
104
|
+
id: (0, crypto_1.randomUUID)(),
|
|
105
|
+
content: {
|
|
106
|
+
en: {
|
|
107
|
+
stringValue: 'Compound service sub 1',
|
|
108
|
+
numberValue: 1,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
comment: 'A comment on the compound service sub 1',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: (0, crypto_1.randomUUID)(),
|
|
115
|
+
content: {
|
|
116
|
+
en: {
|
|
117
|
+
stringValue: 'Compound service sub 2',
|
|
118
|
+
numberValue: 2,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
comment: 'A comment on the compound service sub 2',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
descr: 'Demo 2',
|
|
129
|
+
})));
|
|
130
|
+
(0, chai_1.expect)(contactWithCompoundContent.encryptedSelf).to.not.be.empty;
|
|
131
|
+
(0, chai_1.expect)(contactWithCompoundContent.services[0].encryptedSelf).to.not.be.empty; // Still going to encrypt {}
|
|
132
|
+
(0, chai_1.expect)(contactWithCompoundContent.services[0].content.en.compoundValue[0].encryptedSelf).to.not.be.empty;
|
|
133
|
+
(0, chai_1.expect)(contactWithCompoundContent.services[0].content.en.compoundValue[1].encryptedSelf).to.not.be.empty;
|
|
134
|
+
// Modify compound values comment and check that encryptedSelf does not change since the content does not change
|
|
135
|
+
const updatedContactWithCompoundContent = (yield api.contactApi.modifyContactWithUser(user, Object.assign(Object.assign({}, contactWithCompoundContent), { services: [
|
|
136
|
+
Object.assign(Object.assign({}, contactWithCompoundContent.services[0]), { content: {
|
|
137
|
+
en: {
|
|
138
|
+
compoundValue: [
|
|
139
|
+
Object.assign(Object.assign({}, contactWithCompoundContent.services[0].content.en.compoundValue[0]), { comment: 'An updated comment on the compound service sub 1' }),
|
|
140
|
+
Object.assign(Object.assign({}, contactWithCompoundContent.services[0].content.en.compoundValue[1]), { comment: 'An updated comment on the compound service sub 2' }),
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
} }),
|
|
144
|
+
] })));
|
|
145
|
+
(0, chai_1.expect)(updatedContactWithCompoundContent.services[0].content.en.compoundValue[0].comment).to.equal('An updated comment on the compound service sub 1');
|
|
146
|
+
(0, chai_1.expect)(updatedContactWithCompoundContent.services[0].content.en.compoundValue[1].comment).to.equal('An updated comment on the compound service sub 2');
|
|
147
|
+
(0, chai_1.expect)(updatedContactWithCompoundContent.encryptedSelf).to.equal(contactWithCompoundContent.encryptedSelf);
|
|
148
|
+
(0, chai_1.expect)(updatedContactWithCompoundContent.services[0].encryptedSelf).to.equal(contactWithCompoundContent.services[0].encryptedSelf);
|
|
149
|
+
(0, chai_1.expect)(updatedContactWithCompoundContent.services[0].content.en.compoundValue[0].encryptedSelf).to.equal(contactWithCompoundContent.services[0].content.en.compoundValue[0].encryptedSelf);
|
|
150
|
+
(0, chai_1.expect)(updatedContactWithCompoundContent.services[0].content.en.compoundValue[1].encryptedSelf).to.equal(contactWithCompoundContent.services[0].content.en.compoundValue[1].encryptedSelf);
|
|
151
|
+
}));
|
|
152
|
+
}));
|
|
55
153
|
describe('Init confidential delegation in patient', () => {
|
|
56
154
|
before(function () {
|
|
57
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoTest.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/cryptoTest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,8CAAgD;AAChD,4BAAyB;AACzB,+BAA6C;AAC7C,iB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C,EAAE;aAC1I,QAAQ,CAAA;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;QACrI,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;IACvH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { IccPatientApi } from '../../../icc-api'\nimport 'isomorphic-fetch'\nimport { expect, use as chaiUse } from 'chai'\nimport 'mocha'\n\nimport { Patient } from '../../../icc-api/model/Patient'\nimport {\n createHcpHierarchyApis,\n createNewHcpApi,\n getEnvironmentInitializer,\n hcp1Username,\n isLiteTest,\n setLocalStorage,\n TestUtils,\n} from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { BasicAuthenticationProvider, EntityWithDelegationTypeName } from '../../../icc-x-api'\nimport initApi = TestUtils.initApi\nimport { SecretIdUseOption } from '../../../icc-x-api/crypto/SecretIdUseOption'\nimport UseAnyConfidential = SecretIdUseOption.UseAnyConfidential\n\nchaiUse(require('chai-as-promised'))\n\nlet env: TestVars\n\nsetLocalStorage(fetch)\n\ndescribe('Create a patient from scratch', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should create a patient in the database', async () => {\n const api = await initApi(env, hcp1Username)\n const user = await api.userApi.getCurrentUser()\n\n const note = 'A secured note that is encrypted'\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(\n user,\n new Patient({\n lastName: 'Biden',\n firstName: 'Joe',\n note,\n })\n )\n )\n expect(patient.note).to.equal(note)\n\n console.log(\n `Created patient (decrypted): ${patient.id}: ${patient.firstName} ${patient.lastName} [note:${patient.note}, encryptedSelf:${patient.encryptedSelf}]`\n )\n\n const fetched = await api.patientApi.getPatientWithUser(user, patient.id)\n console.log(\n `Fetched patient (decrypted): ${fetched.id}: ${fetched.firstName} ${fetched.lastName} [note:${fetched.note}, encryptedSelf:${fetched.encryptedSelf}]`\n )\n expect(fetched.id).to.equal(patient.id)\n expect(fetched.note).to.equal(note)\n\n const fetchedWithoutDecryption = await new IccPatientApi(\n env.iCureUrl,\n {},\n new BasicAuthenticationProvider(env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password),\n fetch as any\n ).getPatient(patient.id)\n\n console.log(\n `Fetched patient (encrypted):${fetchedWithoutDecryption.id}: ${fetchedWithoutDecryption.firstName} ${fetchedWithoutDecryption.lastName} [note: ${fetchedWithoutDecryption.note}]`\n )\n expect(fetchedWithoutDecryption.id).to.equal(patient.id)\n expect(fetchedWithoutDecryption.note).to.be.undefined\n })\n})\n\ndescribe('Init confidential delegation in patient', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a patient with a confidential delegation', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const note = 'Some note'\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe', note })\n )\n\n // All parents and siblings should have access to the decrypted data and to the initial secret id\n expect(await childApi.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n const originalSecretId = (await childApi.patientApi.decryptSecretIdsOf(pat))[0]\n for (const { api, user } of others) {\n expect(await api.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await api.patientApi.decryptSecretIdsOf(pat))[0]).to.equal(originalSecretId)\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // Initially there shouldn't be any secret confidential secret id\n expect(await childApi.patientApi.decryptConfidentialSecretIdsOf(pat)).to.be.empty\n\n // Now create a confidential delegation\n const patWithConfidential = await childApi.patientApi.initConfidentialSecretId(pat, childUser)\n\n // Confidential secret id should be different from the original secret id\n const confidentialDelegationKeys = await childApi.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)\n const nonConfidentialDelegationKeys = await childApi.patientApi.decryptNonConfidentialSecretIdsOf(patWithConfidential)\n expect(confidentialDelegationKeys).to.have.length(1)\n expect(nonConfidentialDelegationKeys).to.have.length(1)\n expect(confidentialDelegationKeys[0]).to.not.equal(nonConfidentialDelegationKeys)\n expect(nonConfidentialDelegationKeys[0]).to.equal(originalSecretId)\n\n // Child has access to confidential and not confidential secret ids.\n const childSecretIds = await childApi.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(childSecretIds).to.have.length(2)\n expect(childSecretIds).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIds).to.have.contain(confidentialDelegationKeys[0])\n\n // All parents and siblings should have access to the decrypted data even after initialising confidential delegations...\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n for (const { api, user } of others) {\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // ...but not to the confidential secret id\n for (const { api } of others) {\n const secretIds = await api.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(secretIds).to.have.length(1)\n expect(secretIds).to.contain(nonConfidentialDelegationKeys[0])\n }\n\n // If a secret delegation is already available there is no need to create a new one\n const patWithConfidentialAgain = await childApi.patientApi.initConfidentialSecretId(patWithConfidential, childUser)\n expect(patWithConfidentialAgain.rev).to.equal(patWithConfidentialAgain.rev)\n expect(await childApi.patientApi.decryptSecretIdsOf(patWithConfidentialAgain)).to.have.length(2)\n\n // Different users will have different confidential secret ids...\n expect(await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)).to.be.empty\n const patWithMoreConfidentialIds = await child2Api.patientApi.initConfidentialSecretId(patWithConfidential, child2User)\n\n // ...child continues to know the same secret ids...\n const childSecretIdsRepeat = await childApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n expect(childSecretIdsRepeat).to.have.length(2)\n expect(childSecretIdsRepeat).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIdsRepeat).to.have.contain(confidentialDelegationKeys[0])\n\n // ...but child2 now also knows a different secret id...\n const child2secretIds = await child2Api.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n const child2confidential = await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithMoreConfidentialIds)\n expect(child2confidential).to.have.length(1)\n expect(child2confidential[0]).to.not.equal(confidentialDelegationKeys[0])\n expect(child2confidential[0]).to.not.equal(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.have.length(2)\n expect(child2secretIds).to.contain(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.contain(child2confidential[0])\n\n // ...and their parents still don't know them\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n })\n})\n\ndescribe('Test that contact information can be decrypted', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a contact with decrypted information', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const allApis = [\n { api: childApi, user: childUser },\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n const idFlat = childApi.cryptoApi.primitives.randomUuid()\n const idCompound = childApi.cryptoApi.primitives.randomUuid()\n const idSalut = childApi.cryptoApi.primitives.randomUuid()\n const idAtoi = childApi.cryptoApi.primitives.randomUuid()\n const instance = await childApi.contactApi.newInstance(childUser, pat, {\n services: [\n {\n id: idFlat,\n content: { fr: { stringValue: 'Salut' }, nl: { stringValue: 'Halo' } },\n },\n {\n id: idCompound,\n content: {\n fr: {\n compoundValue: [\n { id: idSalut, content: { fr: { stringValue: 'Salut' } } },\n { id: idAtoi, content: { fr: { stringValue: 'à toi' } } },\n ],\n },\n },\n },\n ],\n })\n const created = await childApi.contactApi.createContactWithUser(childUser, instance)\n const createdFlat = created!.services!.find((x) => x.id === idFlat)!\n const createdCompound = created!.services!.find((x) => x.id === idCompound)!\n const createdSalut = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const createdAtoi = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n for (const { api, user } of allApis) {\n console.log('Trying with user: ' + user.login)\n const check = await api.contactApi.getContactWithUser(user, created!.id!)\n const checkFlat = check!.services!.find((x) => x.id == idFlat)!\n const checkCompound = check!.services!.find((x) => x.id == idCompound)!\n const checkSalut = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const checkAtoi = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n expect(checkFlat).to.not.be.undefined\n expect(checkFlat).to.not.be.null\n expect(checkSalut).to.not.be.undefined\n expect(checkSalut).to.not.be.null\n expect(checkAtoi).to.not.be.undefined\n expect(checkAtoi).to.not.be.null\n\n expect(checkFlat.content!.fr.stringValue).to.equal(createdFlat!.content!.fr.stringValue)\n expect(checkFlat.content!.nl.stringValue).to.equal(createdFlat!.content!.nl.stringValue)\n expect(checkFlat.content!.encryptedSelf).to.not.be.null\n\n expect(checkSalut.content!.fr.stringValue).to.equal(createdSalut.content!.fr.stringValue)\n expect(checkSalut.encryptedSelf).to.not.be.null\n\n expect(checkAtoi.content!.fr.stringValue).to.equal(createdAtoi.content!.fr.stringValue)\n expect(checkAtoi.encryptedSelf).to.not.be.null\n }\n })\n})\n\ndescribe('test that confidential helement information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsUser.length).to.equal(1, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedHesAsMh = await api.healthcareElementApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsMh.length).to.equal(0, 'MH should not see confidential data')\n let failedToRetrieve = false\n try {\n await api.healthcareElementApi.getHealthElementWithUser(user, confidentialHe.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialHe!, type: EntityWithDelegationTypeName.HealthElement }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('test that confidential contact information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialCtc = await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(\n childUser,\n modifiedPatient,\n\n { descr: 'Confidential info', services: [], subContacts: [] },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n\n await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(childUser, modifiedPatient, { descr: 'Non confidential info', services: [], subContacts: [] })\n )\n\n const retrievedCtcsAsUser = await childApi.contactApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsUser.length).to.equal(2, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedCtcsAsMh = await api.contactApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsMh.length).to.equal(1, 'MH should not see confidential data')\n // Even if in some way I could get the contact id I should not be able to get it\n let failedToRetrieve = false\n try {\n await api.contactApi.getContactWithUser(user, confidentialCtc!.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialCtc!, type: EntityWithDelegationTypeName.Contact }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('Share entity behaviour', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it(\"share method should fail if the user attempts to share an entity he can't access\", async () => {\n const hcp1 = await createNewHcpApi(env)\n const hcp2 = await createNewHcpApi(env)\n const hcp3 = await createNewHcpApi(env)\n const patient: Patient = await hcp1.api.patientApi.createPatientWithUser(\n hcp1.user,\n await hcp1.api.patientApi.newInstance(hcp1.user, { firstName: 'John', lastName: 'Doe', note: 'Secret' })\n )\n const encryptedPatient = await new IccPatientApi(env.iCureUrl, {}, hcp1.api.authApi.authenticationProvider, fetch).getPatient(patient.id!)\n await expect(hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, encryptedPatient, [], { requestedPermissions: 'FULL_WRITE' })).to.be\n .rejected\n const shared = await hcp1.api.patientApi.shareWith(hcp2.credentials.dataOwnerId, patient, [], { requestedPermissions: 'FULL_WRITE' })\n await hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, shared, [], { requestedPermissions: 'FULL_WRITE' })\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"cryptoTest.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/cryptoTest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,+BAA6C;AAC7C,iBAAc;AACd,4DAAwD;AACxD,uDAQ+B;AAC/B,mDAAmE;AACnE,kDAA8F;AAC9F,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mFAA+E;AAC/E,IAAO,kBAAkB,GAAG,qCAAiB,CAAC,kBAAkB,CAAA;AAChE,8CAAgD;AAEhD,mCAAmC;AAEnC,IA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M,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,qBAAqB,CACtE,IAAI,CAAC,IAAI,EACT,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CACzG,CAAA;QACD,MAAM,gBAAgB,GAAG,MAAM,IAAI,uBAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAG,CAAC,CAAA;QAC1I,MAAM,IAAA,aAAM,EAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;aAC1I,QAAQ,CAAA;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;QACrI,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC,CAAA;IACvH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { expect, use as chaiUse } from 'chai'\nimport 'mocha'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport {\n createHcpHierarchyApis,\n createNewHcpApi,\n getEnvironmentInitializer,\n hcp1Username,\n isLiteTest,\n setLocalStorage,\n TestUtils,\n} from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { BasicAuthenticationProvider, EntityWithDelegationTypeName } from '../../../icc-x-api'\nimport initApi = TestUtils.initApi\nimport { SecretIdUseOption } from '../../../icc-x-api/crypto/SecretIdUseOption'\nimport UseAnyConfidential = SecretIdUseOption.UseAnyConfidential\nimport { IccPatientApi } from '../../../icc-api'\nimport { Contact } from '../../../icc-api/model/Contact'\nimport { randomUUID } from 'crypto'\n\nchaiUse(require('chai-as-promised'))\n\nlet env: TestVars\n\nsetLocalStorage(fetch)\n\ndescribe('Create a patient from scratch', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should create a patient in the database', async () => {\n const api = await initApi(env, hcp1Username)\n const user = await api.userApi.getCurrentUser()\n\n const note = 'A secured note that is encrypted'\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(\n user,\n new Patient({\n lastName: 'Biden',\n firstName: 'Joe',\n note,\n })\n )\n )\n expect(patient.note).to.equal(note)\n\n console.log(\n `Created patient (decrypted): ${patient.id}: ${patient.firstName} ${patient.lastName} [note:${patient.note}, encryptedSelf:${patient.encryptedSelf}]`\n )\n\n const fetched = await api.patientApi.getPatientWithUser(user, patient.id)\n console.log(\n `Fetched patient (decrypted): ${fetched.id}: ${fetched.firstName} ${fetched.lastName} [note:${fetched.note}, encryptedSelf:${fetched.encryptedSelf}]`\n )\n expect(fetched.id).to.equal(patient.id)\n expect(fetched.note).to.equal(note)\n\n const fetchedWithoutDecryption = await new IccPatientApi(\n env.iCureUrl,\n {},\n new BasicAuthenticationProvider(env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password),\n fetch as any\n ).getPatient(patient.id)\n\n console.log(\n `Fetched patient (encrypted):${fetchedWithoutDecryption.id}: ${fetchedWithoutDecryption.firstName} ${fetchedWithoutDecryption.lastName} [note: ${fetchedWithoutDecryption.note}]`\n )\n expect(fetchedWithoutDecryption.id).to.equal(patient.id)\n expect(fetchedWithoutDecryption.note).to.be.undefined\n })\n})\n\ndescribe('Entity encryption', async () => {\n it('encrypted self should not change after re-encryption if encrypted data do not change', async () => {\n const api = await initApi(env, hcp1Username)\n const user = await api.userApi.getCurrentUser()\n\n const note = 'A secured note that is encrypted'\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(\n user,\n new Patient({\n lastName: 'Biden',\n firstName: 'Joe',\n note,\n })\n )\n )\n expect(patient.note).to.equal(note)\n expect(patient.encryptedSelf).to.not.be.empty\n const updatedPatient = await api.patientApi.modifyPatientWithUser(user, { ...patient, firstName: 'John' })\n expect(updatedPatient?.firstName).to.equal('John')\n expect(updatedPatient?.note).to.equal(patient.note)\n expect(updatedPatient?.encryptedSelf).to.equal(patient.encryptedSelf)\n const contactWithBasicContent = (await api.contactApi.createContactWithUser(\n user,\n await api.contactApi.newInstance(user, patient, {\n services: [\n {\n id: randomUUID(),\n valueDate: 20250101000000,\n content: {\n en: {\n stringValue: 'A service with only basic content',\n numberValue: 1234,\n },\n },\n },\n ],\n descr: 'Demo',\n })\n ))!\n expect(contactWithBasicContent.encryptedSelf).to.not.be.empty\n expect(contactWithBasicContent.services![0].encryptedSelf).to.not.be.empty\n const updatedContactWithBasicContent = await api.contactApi.modifyContactWithUser(user, {\n ...contactWithBasicContent,\n services: [\n {\n ...contactWithBasicContent.services![0],\n valueDate: 20250101120000,\n },\n ],\n })\n expect(updatedContactWithBasicContent?.services![0].valueDate).to.equal(20250101120000)\n expect(updatedContactWithBasicContent?.services![0].encryptedSelf).to.equal(contactWithBasicContent.services![0].encryptedSelf)\n expect(updatedContactWithBasicContent?.encryptedSelf).to.equal(contactWithBasicContent.encryptedSelf)\n const contactWithCompoundContent = (await api.contactApi.createContactWithUser(\n user,\n await api.contactApi.newInstance(user, patient, {\n services: [\n {\n id: randomUUID(),\n valueDate: 20250101000000,\n content: {\n en: {\n compoundValue: [\n {\n id: randomUUID(),\n content: {\n en: {\n stringValue: 'Compound service sub 1',\n numberValue: 1,\n },\n },\n comment: 'A comment on the compound service sub 1',\n },\n {\n id: randomUUID(),\n content: {\n en: {\n stringValue: 'Compound service sub 2',\n numberValue: 2,\n },\n },\n comment: 'A comment on the compound service sub 2',\n },\n ],\n },\n },\n },\n ],\n descr: 'Demo 2',\n })\n ))!\n expect(contactWithCompoundContent.encryptedSelf).to.not.be.empty\n expect(contactWithCompoundContent.services![0].encryptedSelf).to.not.be.empty // Still going to encrypt {}\n expect(contactWithCompoundContent.services![0].content!.en.compoundValue![0].encryptedSelf).to.not.be.empty\n expect(contactWithCompoundContent.services![0].content!.en.compoundValue![1].encryptedSelf).to.not.be.empty\n\n // Modify compound values comment and check that encryptedSelf does not change since the content does not change\n const updatedContactWithCompoundContent = (await api.contactApi.modifyContactWithUser(user, {\n ...contactWithCompoundContent,\n services: [\n {\n ...contactWithCompoundContent.services![0],\n content: {\n en: {\n compoundValue: [\n {\n ...contactWithCompoundContent.services![0].content!.en.compoundValue![0],\n comment: 'An updated comment on the compound service sub 1',\n },\n {\n ...contactWithCompoundContent.services![0].content!.en.compoundValue![1],\n comment: 'An updated comment on the compound service sub 2',\n },\n ],\n },\n },\n },\n ],\n }))!\n expect(updatedContactWithCompoundContent.services![0].content!.en.compoundValue![0].comment).to.equal(\n 'An updated comment on the compound service sub 1'\n )\n expect(updatedContactWithCompoundContent.services![0].content!.en.compoundValue![1].comment).to.equal(\n 'An updated comment on the compound service sub 2'\n )\n expect(updatedContactWithCompoundContent.encryptedSelf).to.equal(contactWithCompoundContent.encryptedSelf)\n expect(updatedContactWithCompoundContent.services![0].encryptedSelf).to.equal(contactWithCompoundContent.services![0].encryptedSelf)\n expect(updatedContactWithCompoundContent.services![0].content!.en.compoundValue![0].encryptedSelf).to.equal(\n contactWithCompoundContent.services![0].content!.en.compoundValue![0].encryptedSelf\n )\n expect(updatedContactWithCompoundContent.services![0].content!.en.compoundValue![1].encryptedSelf).to.equal(\n contactWithCompoundContent.services![0].content!.en.compoundValue![1].encryptedSelf\n )\n })\n})\n\ndescribe('Init confidential delegation in patient', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a patient with a confidential delegation', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const note = 'Some note'\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe', note })\n )\n\n // All parents and siblings should have access to the decrypted data and to the initial secret id\n expect(await childApi.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n const originalSecretId = (await childApi.patientApi.decryptSecretIdsOf(pat))[0]\n for (const { api, user } of others) {\n expect(await api.patientApi.decryptSecretIdsOf(pat)).to.have.length(1)\n expect((await api.patientApi.decryptSecretIdsOf(pat))[0]).to.equal(originalSecretId)\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // Initially there shouldn't be any secret confidential secret id\n expect(await childApi.patientApi.decryptConfidentialSecretIdsOf(pat)).to.be.empty\n\n // Now create a confidential delegation\n const patWithConfidential = await childApi.patientApi.initConfidentialSecretId(pat, childUser)\n\n // Confidential secret id should be different from the original secret id\n const confidentialDelegationKeys = await childApi.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)\n const nonConfidentialDelegationKeys = await childApi.patientApi.decryptNonConfidentialSecretIdsOf(patWithConfidential)\n expect(confidentialDelegationKeys).to.have.length(1)\n expect(nonConfidentialDelegationKeys).to.have.length(1)\n expect(confidentialDelegationKeys[0]).to.not.equal(nonConfidentialDelegationKeys)\n expect(nonConfidentialDelegationKeys[0]).to.equal(originalSecretId)\n\n // Child has access to confidential and not confidential secret ids.\n const childSecretIds = await childApi.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(childSecretIds).to.have.length(2)\n expect(childSecretIds).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIds).to.have.contain(confidentialDelegationKeys[0])\n\n // All parents and siblings should have access to the decrypted data even after initialising confidential delegations...\n expect((await childApi.patientApi.getPatientWithUser(childUser, pat.id)).note).to.equal(note)\n for (const { api, user } of others) {\n expect((await api.patientApi.getPatientWithUser(user, pat.id)).note).to.equal(note)\n }\n\n // ...but not to the confidential secret id\n for (const { api } of others) {\n const secretIds = await api.patientApi.decryptSecretIdsOf(patWithConfidential)\n expect(secretIds).to.have.length(1)\n expect(secretIds).to.contain(nonConfidentialDelegationKeys[0])\n }\n\n // If a secret delegation is already available there is no need to create a new one\n const patWithConfidentialAgain = await childApi.patientApi.initConfidentialSecretId(patWithConfidential, childUser)\n expect(patWithConfidentialAgain.rev).to.equal(patWithConfidentialAgain.rev)\n expect(await childApi.patientApi.decryptSecretIdsOf(patWithConfidentialAgain)).to.have.length(2)\n\n // Different users will have different confidential secret ids...\n expect(await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithConfidential)).to.be.empty\n const patWithMoreConfidentialIds = await child2Api.patientApi.initConfidentialSecretId(patWithConfidential, child2User)\n\n // ...child continues to know the same secret ids...\n const childSecretIdsRepeat = await childApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n expect(childSecretIdsRepeat).to.have.length(2)\n expect(childSecretIdsRepeat).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(childSecretIdsRepeat).to.have.contain(confidentialDelegationKeys[0])\n\n // ...but child2 now also knows a different secret id...\n const child2secretIds = await child2Api.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)\n const child2confidential = await child2Api.patientApi.decryptConfidentialSecretIdsOf(patWithMoreConfidentialIds)\n expect(child2confidential).to.have.length(1)\n expect(child2confidential[0]).to.not.equal(confidentialDelegationKeys[0])\n expect(child2confidential[0]).to.not.equal(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.have.length(2)\n expect(child2secretIds).to.contain(nonConfidentialDelegationKeys[0])\n expect(child2secretIds).to.contain(child2confidential[0])\n\n // ...and their parents still don't know them\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await grandApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.length(1)\n expect(await parentApi.patientApi.decryptSecretIdsOf(patWithMoreConfidentialIds)).to.have.contain(nonConfidentialDelegationKeys[0])\n })\n})\n\ndescribe('Test that contact information can be decrypted', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should return a contact with decrypted information', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const allApis = [\n { api: childApi, user: childUser },\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.createPatientWithUser(\n childUser,\n await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n )\n const idFlat = childApi.cryptoApi.primitives.randomUuid()\n const idCompound = childApi.cryptoApi.primitives.randomUuid()\n const idSalut = childApi.cryptoApi.primitives.randomUuid()\n const idAtoi = childApi.cryptoApi.primitives.randomUuid()\n const instance = await childApi.contactApi.newInstance(childUser, pat, {\n services: [\n {\n id: idFlat,\n content: { fr: { stringValue: 'Salut' }, nl: { stringValue: 'Halo' } },\n },\n {\n id: idCompound,\n content: {\n fr: {\n compoundValue: [\n { id: idSalut, content: { fr: { stringValue: 'Salut' } } },\n { id: idAtoi, content: { fr: { stringValue: 'à toi' } } },\n ],\n },\n },\n },\n ],\n })\n const created = await childApi.contactApi.createContactWithUser(childUser, instance)\n const createdFlat = created!.services!.find((x) => x.id === idFlat)!\n const createdCompound = created!.services!.find((x) => x.id === idCompound)!\n const createdSalut = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const createdAtoi = createdCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n for (const { api, user } of allApis) {\n console.log('Trying with user: ' + user.login)\n const check = await api.contactApi.getContactWithUser(user, created!.id!)\n const checkFlat = check!.services!.find((x) => x.id == idFlat)!\n const checkCompound = check!.services!.find((x) => x.id == idCompound)!\n const checkSalut = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idSalut)!\n const checkAtoi = checkCompound.content!.fr.compoundValue!.find((x) => x.id === idAtoi)!\n\n expect(checkFlat).to.not.be.undefined\n expect(checkFlat).to.not.be.null\n expect(checkSalut).to.not.be.undefined\n expect(checkSalut).to.not.be.null\n expect(checkAtoi).to.not.be.undefined\n expect(checkAtoi).to.not.be.null\n\n expect(checkFlat.content!.fr.stringValue).to.equal(createdFlat!.content!.fr.stringValue)\n expect(checkFlat.content!.nl.stringValue).to.equal(createdFlat!.content!.nl.stringValue)\n expect(checkFlat.content!.encryptedSelf).to.not.be.null\n\n expect(checkSalut.content!.fr.stringValue).to.equal(createdSalut.content!.fr.stringValue)\n expect(checkSalut.encryptedSelf).to.not.be.null\n\n expect(checkAtoi.content!.fr.stringValue).to.equal(createdAtoi.content!.fr.stringValue)\n expect(checkAtoi.encryptedSelf).to.not.be.null\n }\n })\n})\n\ndescribe('test that confidential helement information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialHe = await childApi.healthcareElementApi.createHealthElementWithUser(\n childUser,\n await childApi.healthcareElementApi.newInstance(\n childUser,\n modifiedPatient,\n { descr: 'Confidential info' },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n\n const retrievedHesAsUser = await childApi.healthcareElementApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsUser.length).to.equal(1, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedHesAsMh = await api.healthcareElementApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedHesAsMh.length).to.equal(0, 'MH should not see confidential data')\n let failedToRetrieve = false\n try {\n await api.healthcareElementApi.getHealthElementWithUser(user, confidentialHe.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialHe!, type: EntityWithDelegationTypeName.HealthElement }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('test that confidential contact information cannot be retrieved at MH level', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('should find the confidential data only when logged as the user', async () => {\n const { grandApi, grandUser, childApi, childUser, parentApi, parentUser, child2Api, child2User } = await createHcpHierarchyApis(env!)\n const others = [\n { api: child2Api, user: child2User },\n { api: parentApi, user: parentUser },\n { api: grandApi, user: grandUser },\n ]\n\n const pat = await childApi.patientApi.newInstance(childUser, { firstName: 'John', lastName: 'Doe' })\n const modifiedPatient = (await childApi.patientApi.initConfidentialSecretId(pat, childUser))!\n\n const confidentialCtc = await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(\n childUser,\n modifiedPatient,\n\n { descr: 'Confidential info', services: [], subContacts: [] },\n { sfkOption: UseAnyConfidential, ignoreAutoDelegations: true }\n )\n )\n\n await childApi.contactApi.createContactWithUser(\n childUser,\n await childApi.contactApi.newInstance(childUser, modifiedPatient, { descr: 'Non confidential info', services: [], subContacts: [] })\n )\n\n const retrievedCtcsAsUser = await childApi.contactApi.findBy(childUser.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsUser.length).to.equal(2, 'User should see its confidential data')\n\n for (const { api, user } of others) {\n const retrievedCtcsAsMh = await api.contactApi.findBy(user.healthcarePartyId!, modifiedPatient)\n expect(retrievedCtcsAsMh.length).to.equal(1, 'MH should not see confidential data')\n // Even if in some way I could get the contact id I should not be able to get it\n let failedToRetrieve = false\n try {\n await api.contactApi.getContactWithUser(user, confidentialCtc!.id!)\n } catch (e) {\n console.log(e)\n failedToRetrieve = true\n }\n if (!isLiteTest()) {\n expect(failedToRetrieve).to.equal(true, 'MH should fail to retrieve confidential data')\n }\n // Even if in some way I could get the contact I should not be able to decrypt it\n expect(\n await api.cryptoApi.xapi.encryptionKeysOf({ entity: confidentialCtc!, type: EntityWithDelegationTypeName.Contact }, undefined)\n ).to.have.length(0)\n }\n })\n})\n\ndescribe('Share entity behaviour', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it(\"share method should fail if the user attempts to share an entity he can't access\", async () => {\n const hcp1 = await createNewHcpApi(env)\n const hcp2 = await createNewHcpApi(env)\n const hcp3 = await createNewHcpApi(env)\n const patient: Patient = await hcp1.api.patientApi.createPatientWithUser(\n hcp1.user,\n await hcp1.api.patientApi.newInstance(hcp1.user, { firstName: 'John', lastName: 'Doe', note: 'Secret' })\n )\n const encryptedPatient = await new IccPatientApi(env.iCureUrl, {}, hcp1.api.authApi.authenticationProvider, fetch).getPatient(patient.id!)\n await expect(hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, encryptedPatient, [], { requestedPermissions: 'FULL_WRITE' })).to.be\n .rejected\n const shared = await hcp1.api.patientApi.shareWith(hcp2.credentials.dataOwnerId, patient, [], { requestedPermissions: 'FULL_WRITE' })\n await hcp2.api.patientApi.shareWith(hcp3.credentials.dataOwnerId, shared, [], { requestedPermissions: 'FULL_WRITE' })\n })\n})\n"]}
|
|
@@ -72,7 +72,7 @@ describe('Legacy delegations migration test', () => {
|
|
|
72
72
|
login: pLogin,
|
|
73
73
|
passwordHash: pPassword,
|
|
74
74
|
healthcarePartyId: pId,
|
|
75
|
-
email: pLogin
|
|
75
|
+
email: `${pLogin}@icure.com`
|
|
76
76
|
};
|
|
77
77
|
const aId = (0, crypto_1.randomUUID)();
|
|
78
78
|
const aLogin = `childA-${(0, crypto_1.randomUUID)()}`;
|
|
@@ -108,7 +108,7 @@ describe('Legacy delegations migration test', () => {
|
|
|
108
108
|
autoDelegations: {
|
|
109
109
|
all: [pId],
|
|
110
110
|
},
|
|
111
|
-
email: aLogin
|
|
111
|
+
email: `${aLogin}@icure.com`
|
|
112
112
|
};
|
|
113
113
|
const bId = (0, crypto_1.randomUUID)();
|
|
114
114
|
const bLogin = `childB-${(0, crypto_1.randomUUID)()}`;
|
|
@@ -143,7 +143,7 @@ describe('Legacy delegations migration test', () => {
|
|
|
143
143
|
autoDelegations: {
|
|
144
144
|
all: [pId],
|
|
145
145
|
},
|
|
146
|
-
email: bLogin
|
|
146
|
+
email: `${bLogin}@icure.com`
|
|
147
147
|
};
|
|
148
148
|
const patientConfidentialSecretId = '24cd8cf5-0958-4ee9-8e90-95f3d25a47d7';
|
|
149
149
|
const patientBase = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-metadata-migration-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/legacy-metadata-migration-test.ts"],"names":[],"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AI,CAAC,CAAC,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IACvG,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/*\n * Participants: A, B children hcp of P ; X external hcp, not related to A/B/P.\n *\n\n * Situation 2:\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * A wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation for A\n * - A->A includes the confidential secret id known by A\n * - A delegation from A to P\n * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)\n */\n\nimport { EntityWithDelegationTypeName, IcureApi, ShaVersion } from '../../../icc-x-api'\nimport { randomUUID, webcrypto } from 'crypto'\nimport { createNewHcpApi, getEnvironmentInitializer, setLocalStorage, TestUtils } from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { User } from '../../../icc-api/model/User'\nimport { HealthcareParty } from '../../../icc-api/model/HealthcareParty'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport { testStorageWithKeys } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { IccPatientApi } from '../../../icc-api'\nimport { expect } from 'chai'\nimport { EntityShareRequest } from '../../../icc-api/model/requests/EntityShareRequest'\nimport initMasterApi = TestUtils.initMasterApi\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\n\ndescribe('Legacy delegations migration test', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n /**\n * Participants:\n *\n * A, B children hcp of P\n * X, X2 are external hcps, not related to A/B/P.\n */\n // prettier-ignore\n async function createTestDataAndApis(\n useFakeKeyForAesExchangeKeyEntry: boolean = false\n ): Promise<{\n patientConfidentialSecretId: string\n apis: { a: IcureApi; b: IcureApi; p: IcureApi; x: IcureApi; x2: IcureApi }\n users: { a: User; b: User; p: User; x: User; x2: User }\n patient: Patient\n patientNote: string\n ids: { p: string; a: string; b: string; x: string; x2: string }\n }> {\n // The following data was created for test purposes only and does not contain any real key / secrets.\n const pId = randomUUID()\n const pLogin = `parent-${randomUUID()}`\n const pPassword = randomUUID()\n const pPrivateKey =\n '308204be020100300d06092a864886f70d0101010500048204a8308204a40201000282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001028201000e18c171b03dab58dd5830eff34a7080780b60d952b721eed8927292090b8e308f8dd6fba7a9b9ec929668f94b091b880198ffd84c2eede6d5a41ba779b24da9622687e76bac629f95efb3fbc56cd87289cc13fe058892c7f77ac18b815d1250b58dc7ff20f2f6a95dc7135926a79daca0fdbd1ed756d4c19be8447bd0a200e17419cdd90af54e3b204c1297054d61a6ba9183dfd280d571ee52ee3ed39959abb36ecf575429727d8130bfb070131a46b473a94798834707431bdd248e873d9a716cc469d7f21b545dc2eb21d892e8d94ee6544bd82e8112e697eeaecf6a01d31bffaaf37558aec381f8d12c8491ff77ce00a1da4e2fe6ddf4e5dd14fe1ef90102818100dd2b49e13111593e91a882ae522c1363e2b5e3a10e71c4599e32eec56d9d01682983232b582f2e0923dd107e259771382dd7ff738be31cbba5095153a636dd44e8b08f47e044bbf5814aebdcfed33f0a32fc2f62bf3a0ded9d8aed48fc8034debbf5399862ca2bac72d9d4ab70f90a6a246c6cf4a62c9cb887ea776dce57511902818100d61925b811da57c10e444528230bdb0156516b5ca9ff89a9e57da8373bf5911d009bf5e8a6ee0d40edb89f01e638a528ce592e27d3e7f2172ce373a3b510f2f5045a5dd9aa4ae28b088553a5d099f95611447df464da04168d88ba69751046229131b5a820f9215548de643a82a04ad062ddd74a2e2f30d88480b115c2aa372502818031e374dbce14aabbd9615870f7ea27498db717ac99b481e4f1316df8acbc10b82d3cfe6ee58a66e8fae4ffb664c65f6c9bb2b055a1054ed2e8ec4c23014838eb354db654313b6fe6760eaf5b7f43a961a4948c1fcb20ce497e12fb694e43a12968de6cea79c63ec9bc72746d63a3597d0dd04357803069fd99f302938b4ad8e902818100c167f835ff12b2417924dd2074006ab81b84f3aac2fb501e056d6d3f704fd6e64f3d9478b60bc83746488883cbb8922279be003f0463bcc388ce741188292681868c27c9d0d7532d6be61d7966272221c8f9899af45c2a63413a29c3c8778a1401fbd8f167d00677a79b1709f024e350ba6f52e3f532b63a72005b789fe0ea6d02818100cd0855c641e6294a1c05667f043eedf539c38bbd357dd20dacb182c96455593c689eafc7844d2ba8cd86ce77a3f3151aa261434cdb4d21367c9c62f73289aecb2719de0aca9857365eb16cc56bffbd9b28835eaa4499971996e63306bfdfea35c86179bd749992501aa6c0f45c0123ef6a8a3bb4344c198a0046b94c3bf506f5' // pragma: allowlist secret\n const pHcpBase: HealthcareParty = {\n id: pId,\n lastName: '8ed642',\n firstName: 'c9d727',\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001', // pragma: allowlist secret\n }\n const pUserBase: User = {\n id: randomUUID(),\n name: pLogin,\n status: User.StatusEnum.ACTIVE,\n login: pLogin,\n passwordHash: pPassword,\n healthcarePartyId: pId,\n email: pLogin,\n }\n const aId = randomUUID()\n const aLogin = `childA-${randomUUID()}`\n const aPassword = randomUUID()\n const aPrivateKey =\n '308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced020301000102820100129e03bed566d42be33a2ea48dcabfd37cc004c13c98e3af3beb8eaee9ebed2d0f2316f667e3d8772b35c3b8eab9cea0e795f356c81d63dd5edacbd325646d7a837367220149e71a97751c73857609ca1cabdea898509508cb49beb88e7c63099ef79bf36302381dfa6e833f2e6496fa8e1df81c04db7971a335d87f7c7660ba6ffb6cc0b3089086df855145b69dba0404ae77b1d533693030e8aa17b851c313d9de7b98a2cd5333fbd1b7d9d7d8d4296c2fc794a50003438eccf0d6dc0a0b34c2695d4f40fa8a5d2de12d5579bc3b33208227cff350413702643f31e0d02317da8165c3f7f1b6a18f00fcea5d981904cb1f5c2bd85d30da963184611f0a06d902818100f6860c1d1c53ad2489bc5e967365e226b25bf292c9ca4f01bbee6d7665f544834f553275e6dc373ed69c942d2e889be2537ae5f5672988c63993bc4f95cbb3dc25b3b8cdf7e274b61532b0e101df22cd54735c2d3f353a4d2d48a1e8dcf11089545b3d8b37f4fa2d3d91129d92e67d9937b065a0bf07c7801df87dd8c1c95f4702818100f2261c810d62345f806345b909e8b1d399d961d5f1bd3c580c96c44ba2e6e532ac93f12cdb25fb6fa9e7a823052c2983611b6c359df98be6c7d0e6377a27cd7f0f67f4568fb72c42d7c3bb13afead3b25a30b7827c1f059d9f75c939fc8608afe2882fdeeb3c292ba45647f373c8ff5719c6da1152c94871b722e8129851a42b028181008fe65945d8d6233833ca27f06c75e957ab3f2ece6e49d06a73b7ce5f914e64eabd313f1e415f044482e3ad3ede6dd188803039f15081971c1659dd4f1b62679fb6c63cb6c5de834012099fe407c2a73ef1efd0bb7cace6564c7b9c3f2050fad51ecf8f92275cb1781cfb04c1c41114f98ddf42c35d1efe5e13a08c5d2d690d5b02818033d7a2fca22fe744970929f13ec4d9e592a7aec18e3ad483895671fa3b8b3180d2dfed9f8bdfaae032410d8749e1359612213bde92cecd7c0045a234386bf31c03e15eb7759762db80b440062c009b8830b50364e54c02f8c71e0191ef9586a099604cd76e07784d06a70e4a79fc8b664b777e527d25e8e3a7b0ca7cc8ad99f70281803b9df4b2e66d849b269300fe42c3136d929fdc184d51283a9fe25772a796ed710b475e85a4e442519a207eeb66e0d89d552798a9b2eb2ebb329109cf4fbce35feba75025a157b57c98776dbe9f04c8937e5cd34021b68ffac95c23c3129967a3aa82ddda35098ba55958e3531fa226825a2685e1ce94353a22a03a1eb9b1a9a0' // pragma: allowlist secret\n const aHcpBase: HealthcareParty = {\n id: aId,\n lastName: '6144e2',\n firstName: '6ca3b4',\n parentId: pId,\n aesExchangeKeys: {\n [useFakeKeyForAesExchangeKeyEntry ? 'x0' : '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001']: // pragma: allowlist secret\n {\n [pId]: {\n '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret\n '4ca457e66519a3f403e089f56f3838a18af16e47029d33ca40eca6a24d1f213809851920b8d159e3879284e5e8d1e0c64be874261d3e0003c43a21ddab9301f8a54161911d3bebe3b1ee6d2a040ec88caa484b6ffd46200bc6eb1a767f309e960f977b9e82d81a0b4961b517e89f24cbc9d0133f955a8d6f792486b1e5dcd9088fe5ecc07b11230b1960013c914041e5de3e9b3c37fa4c2a44dcf2136aae57e000acfe824dacd900bf6be5f6b4f3c41534237a01e14d728065c586dbfd3eeb81ad070218be3e2f70757e9ca5d940afa0b67e02d41e68c1c10935157bc6bd3c06eda95f23c10ca60b649a5ec32903c2a995c0b97fb40cdf454c53621304b0d5b0', // pragma: allowlist secret\n b59b1e44efebd4db537ced0203010001:\n '50864963c90cc12704b35ec6cd15ee40a2f4fd4dcb1cf287612346eab4df139008adef1c6d778e35aa7cb58251ff34d6bf1b0faa59d5453c328fa381b175143f41ce66463146b9a02d546cea0065bf62d1ce58e27a8d3bb8bebbb97b76c7e0d7a67b481fdc5082e99aa0521026eb89344b9404da04b0a69988e03724421747e47ab544ed2c55d0424f2837e641f9df4f4ece731e38f9a16d056d9fcf442730c50b3cabcdfbd8241677648639af75198bd30ded0f0fa2db0f8ce80cf86350cef278ce1c7a5426262ceebcc6be5579892d8e066763e216e1592f3f5faa13c561f73400549f5ba2bd618fb308ef99d52cc360ce30988af058caca8c23113933f588', // pragma: allowlist secret\n },\n [aId]: {\n b59b1e44efebd4db537ced0203010001:\n '189ab5f91d1401fe4c8d2be8e044dcb80211fbf1f310d154a21e32b2b7c0cca715178b42a9a5bbd136b81eed1158da5c8e600e265b38c2b608127b343f0d8da301d80eb24a620ed64bec091771a092a2072a922c2852de55942cc99ae0f9c609150c9621cbaf27740105b28e33668ad0a960c13f884029bb1c8253d646b503ac597f8dbb6ce79b64e7b3929b3a3b649805fb327c2d855f47947e8d5dbf9aa4a0da56b9c1030e9fb1f415d0ee48d91d11c320d1bcba9b96a50574ab406f84629edbb86c68ca548d9dcdd08b4d63c93b3d654e810baaf0782068bc91934fb19f9ab46d940dd3d3e27fc6ac1bcd47440f098d97a9b454df929ba60ae0aa5efe7861', // pragma: allowlist secret\n },\n },\n },\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001', // pragma: allowlist secret\n }\n const aUserBase: User = {\n id: randomUUID(),\n name: aLogin,\n status: User.StatusEnum.ACTIVE,\n login: aLogin,\n passwordHash: aPassword,\n healthcarePartyId: aId,\n autoDelegations: {\n all: [pId],\n },\n email: aLogin,\n }\n const bId = randomUUID()\n const bLogin = `childB-${randomUUID()}`\n const bPassword = randomUUID()\n const bPrivateKey =\n '308204bc020100300d06092a864886f70d0101010500048204a6308204a20201000282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001028201002a9bac7afc9ae5399f4242cf4b36110e9de8570e1f46704dd374cf4a8425c7115f9e022b59475b23336bf1b4208a1052a8e183217010d358c88a26fe75fc6242c1be45c696bf8dff8c53f838bef9a0ef9774e486bf15b27e12dbd69775b3a1bbb5410e303019fd1eb4efcd6c2fd2a5a5c53e6388466d6210f8ec4474ecb35c76d2c4269d3a585cdce972673c56818015b9f097ff528e26272b76810cb4f8a1ee5ea04ea26f4cf3c6f78b77c5f58d80628f513a4da76cc1e35a6867af1ab76fe0354e549340221d19bfe04783e34f84eca7bd80867134710adc0665a52eb689d2cf6ecb38ca77d84f4feb8c23539e92ac870b3175c174d8f5643aabc0e7ef3cd102818100ba44b38b24e28d9fb85279c0098b4505e0852ba88b54d2cb8b0e77368c1600bb40b4c0f6dee8b97788e082af0f9045dd54f05ee583fffabc473d16272d03c1aef301541176e7a95f948f8d77b6aad087c54f2de713909efdd5d90a8bbec61067172a97480ba844c25cf64a8b1f0698e2f4dd73af798dd8ab329f7f9bf9a0f9ff02818100d11781567bde00a256ac7ef2c4bf10a5b8b2ebab77c941b7665817f17aa496f166ecd89bb4c50c53d4e836b3369edc2f0f49e64f8dbe7ddaf0fb3898075f6e82ab2c69bc925368904ba459ce08a40ce621dceefa78b64d8eb68752d1cc2a53a1db9718ab1a8703333065cf9b8407174c18f8b085e4aebf32a5bf9b259a6bab71028180492352b04f025a039df75c70e80e7442b37ef6be8e3ef72a0ee6d62e67e0f7d68eb8aa9004c4b29659fb75b4d1529fec213ee4b4101981d54dcf91943e5b9c405a9069f7158e2ef625ba1c1d266f79c3e5d88a38927915c4aba4363cdae2a06c2a2f82093af28e5516f56a1da84809de0bb1ac8bf919963ada7cc039795218f70281802b0aceaa31f78263e8b9bbac580a08f04474388564b43e5df5a87ecd4bf4e3c9afe963b1b1e5ba62eb7a1e008866ed66969c1cd81592b82fc0d9c64dad7edcadf374c2137a7fc70fa532a0f603db59786a5223b3d5f399459e977eda0750534507823426cce02c2d76720ee9b1a5100baf3c4a8255900f75ea9ee5de38ca9f510281802c19faaa1e08ac6337c48af1529f8b8685d2582586986b180377aee8cf4eaadcdbb5869c6f994275b0ae3ecc6aa0ead81296ab9a96eecb44f14fcd9e50ef34d9725e97809b3ed2ed6105102c96ea55a096f292a8d9769c05779f303dc6ad3b30c3c9bea749d58636b3977c9c593557c048b2f82e90fead32b5b510966e548e7a' // pragma: allowlist secret\n const bHcpBase: HealthcareParty = {\n id: bId,\n lastName: '95ee22',\n firstName: '2af696',\n parentId: pId,\n aesExchangeKeys: {\n [useFakeKeyForAesExchangeKeyEntry ? 'x0' : '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001']: // pragma: allowlist secret\n {\n [pId]: {\n '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret\n '5e186cec6d6ddb277aa5421a345045f5f44aa125844e833529fccfeb3a002dd4aef78d84b5b8710ff0aa375436e2abdea07a2cb186cd914fa8b8fb86ab1201b109d802927b49517322ac6521600a123ee03d9383154b6f0fa0e99a8ca6e73e07ceed4aeb835649a850316c5585b2a69ac6703c7154f2db981913bac36a0cea515c70c505d1dc3a7e3a6db519cf7b68737a80ad102cc575959b08fbe327644e7d1b7da0737bfa6ededdd7bf0538fd3dc040ac57937bebdf3146a566c2619314935bc610e900b9c350fcf21a9b20c47f0ee25112578dc210b6b17c4cad9687d2bd9abab12f03f8b778b74186ac3c61d57058037d0e00903c74d2eaa8b2fdb90e3f', // pragma: allowlist secret\n '36108978e3371e9aa0ae8f0203010001': // pragma: allowlist secret\n '89764feb4d23d8313d58c0568088ecf9f320dd285eb762eaee8593a9ecc884a54e4eb6cd93a87f1383f345b94b8a7f1d20dda33d972ab4460aef742d44837648403234700a5a9f85032b025c533aebdc7bea07dec17c7a1737a51f873ec36c689a29b3314fa2d0f77d7e83e71e5a1de1392a6e92fb9881d811253f2bc00db0798e213899a85bcf0bafeaf8b972c40b1a0d1dd3109e6a8bc9309caa5ada9bc41ea62c72fbdf7cf49cbbe15cd048e6d614a4d65e09f5bed014975ea19c160e3754abd9031e8a41283fa369fa621685aee16c5a5d18a1811fde27869cb156a00fe28ae42c9ff498f2c3dd88a392ac9d68d9885556effe62850681fa8fbe5e02781f', // pragma: allowlist secret\n },\n },\n },\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001', // pragma: allowlist secret\n }\n const bUserBase: User = {\n id: randomUUID(),\n name: bLogin,\n status: User.StatusEnum.ACTIVE,\n login: bLogin,\n passwordHash: bPassword,\n groupId: 'test-group',\n healthcarePartyId: bId,\n autoDelegations: {\n all: [pId],\n },\n email: bLogin,\n }\n const patientConfidentialSecretId = '24cd8cf5-0958-4ee9-8e90-95f3d25a47d7'\n const patientBase: Patient = {\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Doe',\n delegations: {\n [aId]: [\n {\n owner: aId,\n delegatedTo: aId,\n key: '4bd1316d494e858496f1d6c1200726cb76c7ff98fb47eddb1c0bf5b79712230db3f02bdf60599816e0601628ee349674a0509720e9972d87b2370b60bcbbb19adb2980bc1ab5bab8b9c8adc5516d39d0cf2d6c373fe7285ce0f1018058e52fcc', // pragma: allowlist secret\n tags: ['confidential'],\n },\n {\n owner: aId,\n delegatedTo: aId,\n key: '6121912dea437ddaf92c41a43deba576976a2b7c10c1cbba79624634ded8bb5d0210db5e339e3e26d33e6e2d18d6b8acc91f8415e5ab488b9227f7c6f6f370873f1d5b5ff3afd28dfe6e47ed10b0cb435676a4db039469a50547f3e1e515fc63', // pragma: allowlist secret\n },\n ],\n [pId]: [\n {\n owner: aId,\n delegatedTo: pId,\n key: '0b293a861d76b21928c6689fb80c373f16bfbe8269ef201b5af35ff4634e51af1c5d3c535c384efea3126acee3572b815db950c52298b1ee99868041641110100c51ad3bc6d0bafddd5021b50b8e0fd16c44f5fd05617eae4f5a00c090c0ccfb', // pragma: allowlist secret\n },\n ],\n },\n encryptionKeys: {\n [aId]: [\n {\n owner: aId,\n delegatedTo: aId,\n key: '42e625cb8930ca763f6b604d08775b4231e9414fa953feeafbd7cfc6acc138bdbf5013aa211935f9f429a627db5d41efa617b2ae9d46f93d83db73b36dab7892c07b03408ee4ab50974b0d4081162b4e9a2a448ce00e35d05aac4d7e675e99b3', // pragma: allowlist secret\n },\n ],\n [pId]: [\n {\n owner: aId,\n delegatedTo: pId,\n key: '194ee902b4780178fd88ffddd1e0744537ddf952d306dfe1123b14bec4405dc1f6b9aea7444cc74f5acca0d18062c0e12d7d9bb6c7b7bff27efb681c7e5ca52f25797f45207f63c13778637a40a541a2e33d79dc1660d7f898d69c92a93aedcf', // pragma: allowlist secret\n },\n ],\n },\n encryptedSelf: 'jgAFAlmd2QStXpOt3LnIhs4upJv2e10fp0u6/PburW7mq1r3vo/Q5/a4Yk7EWXG7oydMWb2i1UCCiNN80czGdA==', // pragma: allowlist secret\n }\n\n const testSetupApi = await initMasterApi(env)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(pHcpBase)\n const pUser = await testSetupApi.userApi.createUser(pUserBase)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(aHcpBase)\n const aUser = await testSetupApi.userApi.createUser(aUserBase)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(bHcpBase)\n const bUser = await testSetupApi.userApi.createUser(bUserBase)\n const pStorage = await testStorageWithKeys([\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const aStorage = await testStorageWithKeys([\n {\n dataOwnerId: aHcpBase.id!,\n pairs: [{ keyPair: { privateKey: aPrivateKey, publicKey: aHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const bStorage = await testStorageWithKeys([\n {\n dataOwnerId: bHcpBase.id!,\n pairs: [{ keyPair: { privateKey: bPrivateKey, publicKey: bHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const pApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: pLogin, password: pPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: pStorage.storage,\n keyStorage: pStorage.keyStorage,\n entryKeysFactory: pStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const aApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: aLogin, password: aPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: aStorage.storage,\n keyStorage: aStorage.keyStorage,\n entryKeysFactory: aStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const bApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: bLogin, password: bPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: bStorage.storage,\n keyStorage: bStorage.keyStorage,\n entryKeysFactory: bStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const xInfo = await createNewHcpApi(env)\n const x2Info = await createNewHcpApi(env)\n const apis = { a: aApi, b: bApi, p: pApi, x: xInfo.api, x2: x2Info.api }\n const xUser = xInfo.user\n const xCredentials = xInfo.credentials\n const x2User = x2Info.user\n const x2Credentials = x2Info.credentials\n const patient = await new IccPatientApi(env.iCureUrl, {}, aApi.authApi.authenticationProvider, fetch).createPatient(patientBase)\n const ids = {\n a: aId,\n b: bId,\n p: pId,\n x: xCredentials.dataOwnerId,\n x2: x2Credentials.dataOwnerId,\n }\n console.log(JSON.stringify(ids, undefined, 2))\n return {\n apis,\n ids,\n users: {\n a: aUser,\n b: bUser,\n p: pUser,\n x: xUser,\n x2: x2User,\n },\n patient,\n patientConfidentialSecretId,\n patientNote: 'This is just a test patient',\n }\n }\n\n /*\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * B wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation B->B\n * - A delegation B->P\n * - Through the delegation B->P A and P can access all the legacy metadata available to P (but not the confidential secret id known by A)\n * - A delegation from B->X\n * - Through B->X X can access only the shared information and has read access only\n *\n * Now A wants to share with X2.\n * Expected outcome:\n * - A new root secure delegation A->A is available, which gives access to the confidential secret id\n * - A delegation A->X2 with the shared information.\n * - Parents of the new delegation are the new A->A root delegation and the existing A->P delegation.\n * - B and P still can't access the confidential secret id.\n */\n it('sharing data as a child of a parent with legacy access should work', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis()\n console.log('Starting test')\n const secretIdsKnownByA = new Set(await apis.a.patientApi.decryptSecretIdsOf(patient))\n const secretIdsKnownByB = new Set(await apis.b.patientApi.decryptSecretIdsOf(patient))\n expect(secretIdsKnownByB.size).to.eq(1)\n expect(secretIdsKnownByB.has(patientConfidentialSecretId)).to.be.false\n expect(secretIdsKnownByA.size).to.eq(2)\n expect(secretIdsKnownByA.has(patientConfidentialSecretId)).to.be.true\n expect(secretIdsKnownByA.has([...secretIdsKnownByB][0])).to.be.true\n const sharedPatient = await apis.b.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations = Object.values(sharedPatient.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations).to.have.length(3)\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.b)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.p)).to.not.be.undefined\n const sharedPatientWithoutLegacyDetails: Patient = { ...sharedPatient, delegations: {}, encryptionKeys: {} }\n expect(await apis.a.patientApi.getEncryptionKeysOf(sharedPatientWithoutLegacyDetails)).to.have.length(1)\n expect(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB])\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.x)).to.not.be.undefined\n expect((await apis.x.patientApi.getPatientWithUser(users.x, patient.id!)).note).to.eq(patientNote)\n expect(await apis.x.cryptoApi.xapi.hasWriteAccess({ entity: sharedPatient, type: EntityWithDelegationTypeName.Patient })).to.be.false\n expect(\n await apis.x.patientApi.modifyPatientWithUser(users.x, { ...sharedPatient, firstName: 'New name' }).then(\n () => true,\n () => false\n )\n ).to.be.false\n expect(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n const sharedPatient2 = await apis.a.patientApi.shareWith(ids.x2, sharedPatient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations2 = Object.values(sharedPatient2.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations2).to.have.length(5)\n expect(secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined\n const secureDelegationAtoX2 = secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.x2)\n expect(secureDelegationAtoX2).to.not.be.undefined\n expect(secureDelegationAtoX2?.parentDelegations).to.have.length(2)\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient2)).to.have.members([...secretIdsKnownByB])\n })\n\n /*\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * A wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation for A\n * - A->A includes the confidential secret id known by A\n * - A delegation from A to P\n * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)\n */\n it('sharing data created with legacy api by the same user ', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis()\n console.log('Starting test')\n const secretIdsKnownByA = new Set(await apis.a.patientApi.decryptSecretIdsOf(patient))\n const secretIdsKnownByB = new Set(await apis.b.patientApi.decryptSecretIdsOf(patient))\n const sharedPatient = await apis.a.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations = Object.values(sharedPatient.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations).to.have.length(3)\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.p)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.x)).to.not.be.undefined\n const sharedPatientWithoutLegacyDetails: Patient = { ...sharedPatient, delegations: {}, encryptionKeys: {} }\n console.log(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails))\n console.log(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient))\n console.log(await apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails))\n console.log(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient))\n expect(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByA])\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB])\n expect(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n console.log(JSON.stringify(sharedPatient, undefined, 2))\n })\n\n it('should be able to use aesExchangeKeysEntries with fake public key', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis(true)\n console.log('Starting test')\n console.log(users.a.healthcarePartyId)\n console.log(users.b.healthcarePartyId)\n console.log(patient.id)\n expect((await apis.a.patientApi.getPatientWithUser(users.a, patient.id!)).note).to.equal(patientNote)\n expect((await apis.b.patientApi.getPatientWithUser(users.a, patient.id!)).note).to.equal(patientNote)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"legacy-metadata-migration-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/legacy-metadata-migration-test.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;AAEH,kDAAuF;AACvF,mCAA8C;AAC9C,uDAA+G;AAC/G,mDAAmE;AACnE,sDAAkD;AAGlD,yDAA6D;AAC7D,2EAAuE;AACvE,8CAAgD;AAChD,+BAA6B;AAC7B,2FAAuF;AACvF,IAAO,aAAa,GAAG,sBAAS,CAAC,aAAa,CAAA;AAC9C,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAE3E,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAI,GAAa,CAAA;AAEjB,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,MAAM,CAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAA,uBAAe,GAAE,CAAC,CAAA;QACpD,CAAC;KAAA,CAAC,CAAA;IAEF;;;;;OAKG;IACH,kBAAkB;IAClB,SAAe,qBAAqB;6DAClC,mCAA4C,KAAK;YASjD,qGAAqG;YACrG,MAAM,GAAG,GAAG,IAAA,mBAAU,GAAE,CAAA;YACxB,MAAM,MAAM,GAAG,UAAU,IAAA,mBAAU,GAAE,EAAE,CAAA;YACvC,MAAM,SAAS,GAAG,IAAA,mBAAU,GAAE,CAAA;YAC9B,MAAM,WAAW,GACf,s4EAAs4E,CAAA,CAAC,2BAA2B;YACp6E,MAAM,QAAQ,GAAoB;gBAChC,EAAE,EAAE,GAAG;gBACP,QAAQ,EAAE,QAAQ;gBAClB,SAAS,EAAE,QAAQ;gBACnB,SAAS,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,CAAC,CAAC,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QACrG,IAAA,aAAM,EAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IACvG,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/*\n * Participants: A, B children hcp of P ; X external hcp, not related to A/B/P.\n *\n\n * Situation 2:\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * A wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation for A\n * - A->A includes the confidential secret id known by A\n * - A delegation from A to P\n * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)\n */\n\nimport { EntityWithDelegationTypeName, IcureApi, ShaVersion } from '../../../icc-x-api'\nimport { randomUUID, webcrypto } from 'crypto'\nimport { createNewHcpApi, getEnvironmentInitializer, setLocalStorage, TestUtils } from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { User } from '../../../icc-api/model/User'\nimport { HealthcareParty } from '../../../icc-api/model/HealthcareParty'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport { testStorageWithKeys } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { IccPatientApi } from '../../../icc-api'\nimport { expect } from 'chai'\nimport { EntityShareRequest } from '../../../icc-api/model/requests/EntityShareRequest'\nimport initMasterApi = TestUtils.initMasterApi\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\n\ndescribe('Legacy delegations migration test', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n /**\n * Participants:\n *\n * A, B children hcp of P\n * X, X2 are external hcps, not related to A/B/P.\n */\n // prettier-ignore\n async function createTestDataAndApis(\n useFakeKeyForAesExchangeKeyEntry: boolean = false\n ): Promise<{\n patientConfidentialSecretId: string\n apis: { a: IcureApi; b: IcureApi; p: IcureApi; x: IcureApi; x2: IcureApi }\n users: { a: User; b: User; p: User; x: User; x2: User }\n patient: Patient\n patientNote: string\n ids: { p: string; a: string; b: string; x: string; x2: string }\n }> {\n // The following data was created for test purposes only and does not contain any real key / secrets.\n const pId = randomUUID()\n const pLogin = `parent-${randomUUID()}`\n const pPassword = randomUUID()\n const pPrivateKey =\n '308204be020100300d06092a864886f70d0101010500048204a8308204a40201000282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001028201000e18c171b03dab58dd5830eff34a7080780b60d952b721eed8927292090b8e308f8dd6fba7a9b9ec929668f94b091b880198ffd84c2eede6d5a41ba779b24da9622687e76bac629f95efb3fbc56cd87289cc13fe058892c7f77ac18b815d1250b58dc7ff20f2f6a95dc7135926a79daca0fdbd1ed756d4c19be8447bd0a200e17419cdd90af54e3b204c1297054d61a6ba9183dfd280d571ee52ee3ed39959abb36ecf575429727d8130bfb070131a46b473a94798834707431bdd248e873d9a716cc469d7f21b545dc2eb21d892e8d94ee6544bd82e8112e697eeaecf6a01d31bffaaf37558aec381f8d12c8491ff77ce00a1da4e2fe6ddf4e5dd14fe1ef90102818100dd2b49e13111593e91a882ae522c1363e2b5e3a10e71c4599e32eec56d9d01682983232b582f2e0923dd107e259771382dd7ff738be31cbba5095153a636dd44e8b08f47e044bbf5814aebdcfed33f0a32fc2f62bf3a0ded9d8aed48fc8034debbf5399862ca2bac72d9d4ab70f90a6a246c6cf4a62c9cb887ea776dce57511902818100d61925b811da57c10e444528230bdb0156516b5ca9ff89a9e57da8373bf5911d009bf5e8a6ee0d40edb89f01e638a528ce592e27d3e7f2172ce373a3b510f2f5045a5dd9aa4ae28b088553a5d099f95611447df464da04168d88ba69751046229131b5a820f9215548de643a82a04ad062ddd74a2e2f30d88480b115c2aa372502818031e374dbce14aabbd9615870f7ea27498db717ac99b481e4f1316df8acbc10b82d3cfe6ee58a66e8fae4ffb664c65f6c9bb2b055a1054ed2e8ec4c23014838eb354db654313b6fe6760eaf5b7f43a961a4948c1fcb20ce497e12fb694e43a12968de6cea79c63ec9bc72746d63a3597d0dd04357803069fd99f302938b4ad8e902818100c167f835ff12b2417924dd2074006ab81b84f3aac2fb501e056d6d3f704fd6e64f3d9478b60bc83746488883cbb8922279be003f0463bcc388ce741188292681868c27c9d0d7532d6be61d7966272221c8f9899af45c2a63413a29c3c8778a1401fbd8f167d00677a79b1709f024e350ba6f52e3f532b63a72005b789fe0ea6d02818100cd0855c641e6294a1c05667f043eedf539c38bbd357dd20dacb182c96455593c689eafc7844d2ba8cd86ce77a3f3151aa261434cdb4d21367c9c62f73289aecb2719de0aca9857365eb16cc56bffbd9b28835eaa4499971996e63306bfdfea35c86179bd749992501aa6c0f45c0123ef6a8a3bb4344c198a0046b94c3bf506f5' // pragma: allowlist secret\n const pHcpBase: HealthcareParty = {\n id: pId,\n lastName: '8ed642',\n firstName: 'c9d727',\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001', // pragma: allowlist secret\n }\n const pUserBase: User = {\n id: randomUUID(),\n name: pLogin,\n status: User.StatusEnum.ACTIVE,\n login: pLogin,\n passwordHash: pPassword,\n healthcarePartyId: pId,\n email: `${pLogin}@icure.com`\n }\n const aId = randomUUID()\n const aLogin = `childA-${randomUUID()}`\n const aPassword = randomUUID()\n const aPrivateKey =\n '308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced020301000102820100129e03bed566d42be33a2ea48dcabfd37cc004c13c98e3af3beb8eaee9ebed2d0f2316f667e3d8772b35c3b8eab9cea0e795f356c81d63dd5edacbd325646d7a837367220149e71a97751c73857609ca1cabdea898509508cb49beb88e7c63099ef79bf36302381dfa6e833f2e6496fa8e1df81c04db7971a335d87f7c7660ba6ffb6cc0b3089086df855145b69dba0404ae77b1d533693030e8aa17b851c313d9de7b98a2cd5333fbd1b7d9d7d8d4296c2fc794a50003438eccf0d6dc0a0b34c2695d4f40fa8a5d2de12d5579bc3b33208227cff350413702643f31e0d02317da8165c3f7f1b6a18f00fcea5d981904cb1f5c2bd85d30da963184611f0a06d902818100f6860c1d1c53ad2489bc5e967365e226b25bf292c9ca4f01bbee6d7665f544834f553275e6dc373ed69c942d2e889be2537ae5f5672988c63993bc4f95cbb3dc25b3b8cdf7e274b61532b0e101df22cd54735c2d3f353a4d2d48a1e8dcf11089545b3d8b37f4fa2d3d91129d92e67d9937b065a0bf07c7801df87dd8c1c95f4702818100f2261c810d62345f806345b909e8b1d399d961d5f1bd3c580c96c44ba2e6e532ac93f12cdb25fb6fa9e7a823052c2983611b6c359df98be6c7d0e6377a27cd7f0f67f4568fb72c42d7c3bb13afead3b25a30b7827c1f059d9f75c939fc8608afe2882fdeeb3c292ba45647f373c8ff5719c6da1152c94871b722e8129851a42b028181008fe65945d8d6233833ca27f06c75e957ab3f2ece6e49d06a73b7ce5f914e64eabd313f1e415f044482e3ad3ede6dd188803039f15081971c1659dd4f1b62679fb6c63cb6c5de834012099fe407c2a73ef1efd0bb7cace6564c7b9c3f2050fad51ecf8f92275cb1781cfb04c1c41114f98ddf42c35d1efe5e13a08c5d2d690d5b02818033d7a2fca22fe744970929f13ec4d9e592a7aec18e3ad483895671fa3b8b3180d2dfed9f8bdfaae032410d8749e1359612213bde92cecd7c0045a234386bf31c03e15eb7759762db80b440062c009b8830b50364e54c02f8c71e0191ef9586a099604cd76e07784d06a70e4a79fc8b664b777e527d25e8e3a7b0ca7cc8ad99f70281803b9df4b2e66d849b269300fe42c3136d929fdc184d51283a9fe25772a796ed710b475e85a4e442519a207eeb66e0d89d552798a9b2eb2ebb329109cf4fbce35feba75025a157b57c98776dbe9f04c8937e5cd34021b68ffac95c23c3129967a3aa82ddda35098ba55958e3531fa226825a2685e1ce94353a22a03a1eb9b1a9a0' // pragma: allowlist secret\n const aHcpBase: HealthcareParty = {\n id: aId,\n lastName: '6144e2',\n firstName: '6ca3b4',\n parentId: pId,\n aesExchangeKeys: {\n [useFakeKeyForAesExchangeKeyEntry ? 'x0' : '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001']: // pragma: allowlist secret\n {\n [pId]: {\n '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret\n '4ca457e66519a3f403e089f56f3838a18af16e47029d33ca40eca6a24d1f213809851920b8d159e3879284e5e8d1e0c64be874261d3e0003c43a21ddab9301f8a54161911d3bebe3b1ee6d2a040ec88caa484b6ffd46200bc6eb1a767f309e960f977b9e82d81a0b4961b517e89f24cbc9d0133f955a8d6f792486b1e5dcd9088fe5ecc07b11230b1960013c914041e5de3e9b3c37fa4c2a44dcf2136aae57e000acfe824dacd900bf6be5f6b4f3c41534237a01e14d728065c586dbfd3eeb81ad070218be3e2f70757e9ca5d940afa0b67e02d41e68c1c10935157bc6bd3c06eda95f23c10ca60b649a5ec32903c2a995c0b97fb40cdf454c53621304b0d5b0', // pragma: allowlist secret\n b59b1e44efebd4db537ced0203010001:\n '50864963c90cc12704b35ec6cd15ee40a2f4fd4dcb1cf287612346eab4df139008adef1c6d778e35aa7cb58251ff34d6bf1b0faa59d5453c328fa381b175143f41ce66463146b9a02d546cea0065bf62d1ce58e27a8d3bb8bebbb97b76c7e0d7a67b481fdc5082e99aa0521026eb89344b9404da04b0a69988e03724421747e47ab544ed2c55d0424f2837e641f9df4f4ece731e38f9a16d056d9fcf442730c50b3cabcdfbd8241677648639af75198bd30ded0f0fa2db0f8ce80cf86350cef278ce1c7a5426262ceebcc6be5579892d8e066763e216e1592f3f5faa13c561f73400549f5ba2bd618fb308ef99d52cc360ce30988af058caca8c23113933f588', // pragma: allowlist secret\n },\n [aId]: {\n b59b1e44efebd4db537ced0203010001:\n '189ab5f91d1401fe4c8d2be8e044dcb80211fbf1f310d154a21e32b2b7c0cca715178b42a9a5bbd136b81eed1158da5c8e600e265b38c2b608127b343f0d8da301d80eb24a620ed64bec091771a092a2072a922c2852de55942cc99ae0f9c609150c9621cbaf27740105b28e33668ad0a960c13f884029bb1c8253d646b503ac597f8dbb6ce79b64e7b3929b3a3b649805fb327c2d855f47947e8d5dbf9aa4a0da56b9c1030e9fb1f415d0ee48d91d11c320d1bcba9b96a50574ab406f84629edbb86c68ca548d9dcdd08b4d63c93b3d654e810baaf0782068bc91934fb19f9ab46d940dd3d3e27fc6ac1bcd47440f098d97a9b454df929ba60ae0aa5efe7861', // pragma: allowlist secret\n },\n },\n },\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001', // pragma: allowlist secret\n }\n const aUserBase: User = {\n id: randomUUID(),\n name: aLogin,\n status: User.StatusEnum.ACTIVE,\n login: aLogin,\n passwordHash: aPassword,\n healthcarePartyId: aId,\n autoDelegations: {\n all: [pId],\n },\n email: `${aLogin}@icure.com`\n }\n const bId = randomUUID()\n const bLogin = `childB-${randomUUID()}`\n const bPassword = randomUUID()\n const bPrivateKey =\n '308204bc020100300d06092a864886f70d0101010500048204a6308204a20201000282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001028201002a9bac7afc9ae5399f4242cf4b36110e9de8570e1f46704dd374cf4a8425c7115f9e022b59475b23336bf1b4208a1052a8e183217010d358c88a26fe75fc6242c1be45c696bf8dff8c53f838bef9a0ef9774e486bf15b27e12dbd69775b3a1bbb5410e303019fd1eb4efcd6c2fd2a5a5c53e6388466d6210f8ec4474ecb35c76d2c4269d3a585cdce972673c56818015b9f097ff528e26272b76810cb4f8a1ee5ea04ea26f4cf3c6f78b77c5f58d80628f513a4da76cc1e35a6867af1ab76fe0354e549340221d19bfe04783e34f84eca7bd80867134710adc0665a52eb689d2cf6ecb38ca77d84f4feb8c23539e92ac870b3175c174d8f5643aabc0e7ef3cd102818100ba44b38b24e28d9fb85279c0098b4505e0852ba88b54d2cb8b0e77368c1600bb40b4c0f6dee8b97788e082af0f9045dd54f05ee583fffabc473d16272d03c1aef301541176e7a95f948f8d77b6aad087c54f2de713909efdd5d90a8bbec61067172a97480ba844c25cf64a8b1f0698e2f4dd73af798dd8ab329f7f9bf9a0f9ff02818100d11781567bde00a256ac7ef2c4bf10a5b8b2ebab77c941b7665817f17aa496f166ecd89bb4c50c53d4e836b3369edc2f0f49e64f8dbe7ddaf0fb3898075f6e82ab2c69bc925368904ba459ce08a40ce621dceefa78b64d8eb68752d1cc2a53a1db9718ab1a8703333065cf9b8407174c18f8b085e4aebf32a5bf9b259a6bab71028180492352b04f025a039df75c70e80e7442b37ef6be8e3ef72a0ee6d62e67e0f7d68eb8aa9004c4b29659fb75b4d1529fec213ee4b4101981d54dcf91943e5b9c405a9069f7158e2ef625ba1c1d266f79c3e5d88a38927915c4aba4363cdae2a06c2a2f82093af28e5516f56a1da84809de0bb1ac8bf919963ada7cc039795218f70281802b0aceaa31f78263e8b9bbac580a08f04474388564b43e5df5a87ecd4bf4e3c9afe963b1b1e5ba62eb7a1e008866ed66969c1cd81592b82fc0d9c64dad7edcadf374c2137a7fc70fa532a0f603db59786a5223b3d5f399459e977eda0750534507823426cce02c2d76720ee9b1a5100baf3c4a8255900f75ea9ee5de38ca9f510281802c19faaa1e08ac6337c48af1529f8b8685d2582586986b180377aee8cf4eaadcdbb5869c6f994275b0ae3ecc6aa0ead81296ab9a96eecb44f14fcd9e50ef34d9725e97809b3ed2ed6105102c96ea55a096f292a8d9769c05779f303dc6ad3b30c3c9bea749d58636b3977c9c593557c048b2f82e90fead32b5b510966e548e7a' // pragma: allowlist secret\n const bHcpBase: HealthcareParty = {\n id: bId,\n lastName: '95ee22',\n firstName: '2af696',\n parentId: pId,\n aesExchangeKeys: {\n [useFakeKeyForAesExchangeKeyEntry ? 'x0' : '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001']: // pragma: allowlist secret\n {\n [pId]: {\n '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret\n '5e186cec6d6ddb277aa5421a345045f5f44aa125844e833529fccfeb3a002dd4aef78d84b5b8710ff0aa375436e2abdea07a2cb186cd914fa8b8fb86ab1201b109d802927b49517322ac6521600a123ee03d9383154b6f0fa0e99a8ca6e73e07ceed4aeb835649a850316c5585b2a69ac6703c7154f2db981913bac36a0cea515c70c505d1dc3a7e3a6db519cf7b68737a80ad102cc575959b08fbe327644e7d1b7da0737bfa6ededdd7bf0538fd3dc040ac57937bebdf3146a566c2619314935bc610e900b9c350fcf21a9b20c47f0ee25112578dc210b6b17c4cad9687d2bd9abab12f03f8b778b74186ac3c61d57058037d0e00903c74d2eaa8b2fdb90e3f', // pragma: allowlist secret\n '36108978e3371e9aa0ae8f0203010001': // pragma: allowlist secret\n '89764feb4d23d8313d58c0568088ecf9f320dd285eb762eaee8593a9ecc884a54e4eb6cd93a87f1383f345b94b8a7f1d20dda33d972ab4460aef742d44837648403234700a5a9f85032b025c533aebdc7bea07dec17c7a1737a51f873ec36c689a29b3314fa2d0f77d7e83e71e5a1de1392a6e92fb9881d811253f2bc00db0798e213899a85bcf0bafeaf8b972c40b1a0d1dd3109e6a8bc9309caa5ada9bc41ea62c72fbdf7cf49cbbe15cd048e6d614a4d65e09f5bed014975ea19c160e3754abd9031e8a41283fa369fa621685aee16c5a5d18a1811fde27869cb156a00fe28ae42c9ff498f2c3dd88a392ac9d68d9885556effe62850681fa8fbe5e02781f', // pragma: allowlist secret\n },\n },\n },\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001', // pragma: allowlist secret\n }\n const bUserBase: User = {\n id: randomUUID(),\n name: bLogin,\n status: User.StatusEnum.ACTIVE,\n login: bLogin,\n passwordHash: bPassword,\n groupId: 'test-group',\n healthcarePartyId: bId,\n autoDelegations: {\n all: [pId],\n },\n email: `${bLogin}@icure.com`\n }\n const patientConfidentialSecretId = '24cd8cf5-0958-4ee9-8e90-95f3d25a47d7'\n const patientBase: Patient = {\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Doe',\n delegations: {\n [aId]: [\n {\n owner: aId,\n delegatedTo: aId,\n key: '4bd1316d494e858496f1d6c1200726cb76c7ff98fb47eddb1c0bf5b79712230db3f02bdf60599816e0601628ee349674a0509720e9972d87b2370b60bcbbb19adb2980bc1ab5bab8b9c8adc5516d39d0cf2d6c373fe7285ce0f1018058e52fcc', // pragma: allowlist secret\n tags: ['confidential'],\n },\n {\n owner: aId,\n delegatedTo: aId,\n key: '6121912dea437ddaf92c41a43deba576976a2b7c10c1cbba79624634ded8bb5d0210db5e339e3e26d33e6e2d18d6b8acc91f8415e5ab488b9227f7c6f6f370873f1d5b5ff3afd28dfe6e47ed10b0cb435676a4db039469a50547f3e1e515fc63', // pragma: allowlist secret\n },\n ],\n [pId]: [\n {\n owner: aId,\n delegatedTo: pId,\n key: '0b293a861d76b21928c6689fb80c373f16bfbe8269ef201b5af35ff4634e51af1c5d3c535c384efea3126acee3572b815db950c52298b1ee99868041641110100c51ad3bc6d0bafddd5021b50b8e0fd16c44f5fd05617eae4f5a00c090c0ccfb', // pragma: allowlist secret\n },\n ],\n },\n encryptionKeys: {\n [aId]: [\n {\n owner: aId,\n delegatedTo: aId,\n key: '42e625cb8930ca763f6b604d08775b4231e9414fa953feeafbd7cfc6acc138bdbf5013aa211935f9f429a627db5d41efa617b2ae9d46f93d83db73b36dab7892c07b03408ee4ab50974b0d4081162b4e9a2a448ce00e35d05aac4d7e675e99b3', // pragma: allowlist secret\n },\n ],\n [pId]: [\n {\n owner: aId,\n delegatedTo: pId,\n key: '194ee902b4780178fd88ffddd1e0744537ddf952d306dfe1123b14bec4405dc1f6b9aea7444cc74f5acca0d18062c0e12d7d9bb6c7b7bff27efb681c7e5ca52f25797f45207f63c13778637a40a541a2e33d79dc1660d7f898d69c92a93aedcf', // pragma: allowlist secret\n },\n ],\n },\n encryptedSelf: 'jgAFAlmd2QStXpOt3LnIhs4upJv2e10fp0u6/PburW7mq1r3vo/Q5/a4Yk7EWXG7oydMWb2i1UCCiNN80czGdA==', // pragma: allowlist secret\n }\n\n const testSetupApi = await initMasterApi(env)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(pHcpBase)\n const pUser = await testSetupApi.userApi.createUser(pUserBase)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(aHcpBase)\n const aUser = await testSetupApi.userApi.createUser(aUserBase)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(bHcpBase)\n const bUser = await testSetupApi.userApi.createUser(bUserBase)\n const pStorage = await testStorageWithKeys([\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const aStorage = await testStorageWithKeys([\n {\n dataOwnerId: aHcpBase.id!,\n pairs: [{ keyPair: { privateKey: aPrivateKey, publicKey: aHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const bStorage = await testStorageWithKeys([\n {\n dataOwnerId: bHcpBase.id!,\n pairs: [{ keyPair: { privateKey: bPrivateKey, publicKey: bHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const pApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: pLogin, password: pPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: pStorage.storage,\n keyStorage: pStorage.keyStorage,\n entryKeysFactory: pStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const aApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: aLogin, password: aPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: aStorage.storage,\n keyStorage: aStorage.keyStorage,\n entryKeysFactory: aStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const bApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: bLogin, password: bPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: bStorage.storage,\n keyStorage: bStorage.keyStorage,\n entryKeysFactory: bStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const xInfo = await createNewHcpApi(env)\n const x2Info = await createNewHcpApi(env)\n const apis = { a: aApi, b: bApi, p: pApi, x: xInfo.api, x2: x2Info.api }\n const xUser = xInfo.user\n const xCredentials = xInfo.credentials\n const x2User = x2Info.user\n const x2Credentials = x2Info.credentials\n const patient = await new IccPatientApi(env.iCureUrl, {}, aApi.authApi.authenticationProvider, fetch).createPatient(patientBase)\n const ids = {\n a: aId,\n b: bId,\n p: pId,\n x: xCredentials.dataOwnerId,\n x2: x2Credentials.dataOwnerId,\n }\n console.log(JSON.stringify(ids, undefined, 2))\n return {\n apis,\n ids,\n users: {\n a: aUser,\n b: bUser,\n p: pUser,\n x: xUser,\n x2: x2User,\n },\n patient,\n patientConfidentialSecretId,\n patientNote: 'This is just a test patient',\n }\n }\n\n /*\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * B wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation B->B\n * - A delegation B->P\n * - Through the delegation B->P A and P can access all the legacy metadata available to P (but not the confidential secret id known by A)\n * - A delegation from B->X\n * - Through B->X X can access only the shared information and has read access only\n *\n * Now A wants to share with X2.\n * Expected outcome:\n * - A new root secure delegation A->A is available, which gives access to the confidential secret id\n * - A delegation A->X2 with the shared information.\n * - Parents of the new delegation are the new A->A root delegation and the existing A->P delegation.\n * - B and P still can't access the confidential secret id.\n */\n it('sharing data as a child of a parent with legacy access should work', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis()\n console.log('Starting test')\n const secretIdsKnownByA = new Set(await apis.a.patientApi.decryptSecretIdsOf(patient))\n const secretIdsKnownByB = new Set(await apis.b.patientApi.decryptSecretIdsOf(patient))\n expect(secretIdsKnownByB.size).to.eq(1)\n expect(secretIdsKnownByB.has(patientConfidentialSecretId)).to.be.false\n expect(secretIdsKnownByA.size).to.eq(2)\n expect(secretIdsKnownByA.has(patientConfidentialSecretId)).to.be.true\n expect(secretIdsKnownByA.has([...secretIdsKnownByB][0])).to.be.true\n const sharedPatient = await apis.b.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations = Object.values(sharedPatient.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations).to.have.length(3)\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.b)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.p)).to.not.be.undefined\n const sharedPatientWithoutLegacyDetails: Patient = { ...sharedPatient, delegations: {}, encryptionKeys: {} }\n expect(await apis.a.patientApi.getEncryptionKeysOf(sharedPatientWithoutLegacyDetails)).to.have.length(1)\n expect(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB])\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.x)).to.not.be.undefined\n expect((await apis.x.patientApi.getPatientWithUser(users.x, patient.id!)).note).to.eq(patientNote)\n expect(await apis.x.cryptoApi.xapi.hasWriteAccess({ entity: sharedPatient, type: EntityWithDelegationTypeName.Patient })).to.be.false\n expect(\n await apis.x.patientApi.modifyPatientWithUser(users.x, { ...sharedPatient, firstName: 'New name' }).then(\n () => true,\n () => false\n )\n ).to.be.false\n expect(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n const sharedPatient2 = await apis.a.patientApi.shareWith(ids.x2, sharedPatient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations2 = Object.values(sharedPatient2.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations2).to.have.length(5)\n expect(secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined\n const secureDelegationAtoX2 = secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.x2)\n expect(secureDelegationAtoX2).to.not.be.undefined\n expect(secureDelegationAtoX2?.parentDelegations).to.have.length(2)\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient2)).to.have.members([...secretIdsKnownByB])\n })\n\n /*\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * A wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation for A\n * - A->A includes the confidential secret id known by A\n * - A delegation from A to P\n * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)\n */\n it('sharing data created with legacy api by the same user ', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis()\n console.log('Starting test')\n const secretIdsKnownByA = new Set(await apis.a.patientApi.decryptSecretIdsOf(patient))\n const secretIdsKnownByB = new Set(await apis.b.patientApi.decryptSecretIdsOf(patient))\n const sharedPatient = await apis.a.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations = Object.values(sharedPatient.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations).to.have.length(3)\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.p)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.x)).to.not.be.undefined\n const sharedPatientWithoutLegacyDetails: Patient = { ...sharedPatient, delegations: {}, encryptionKeys: {} }\n console.log(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails))\n console.log(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient))\n console.log(await apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails))\n console.log(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient))\n expect(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByA])\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB])\n expect(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n console.log(JSON.stringify(sharedPatient, undefined, 2))\n })\n\n it('should be able to use aesExchangeKeysEntries with fake public key', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis(true)\n console.log('Starting test')\n console.log(users.a.healthcarePartyId)\n console.log(users.b.healthcarePartyId)\n console.log(patient.id)\n expect((await apis.a.patientApi.getPatientWithUser(users.a, patient.id!)).note).to.equal(patientNote)\n expect((await apis.b.patientApi.getPatientWithUser(users.a, patient.id!)).note).to.equal(patientNote)\n })\n})\n"]}
|
|
@@ -24,7 +24,7 @@ const entityWithAttachmentApis = {
|
|
|
24
24
|
docMainAttachment: (apis, currentUser) => ({
|
|
25
25
|
createEntity() {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
return apis.documentApi.
|
|
27
|
+
return apis.documentApi.createDocumentWithUser(currentUser, yield apis.documentApi.newInstance(currentUser));
|
|
28
28
|
});
|
|
29
29
|
},
|
|
30
30
|
encryptAndSetAttachment(entity, attachment) {
|
|
@@ -40,7 +40,7 @@ const entityWithAttachmentApis = {
|
|
|
40
40
|
docSecondaryAttachment: (apis, currentUser) => ({
|
|
41
41
|
createEntity() {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return apis.documentApi.
|
|
43
|
+
return apis.documentApi.createDocumentWithUser(currentUser, yield apis.documentApi.newInstance(currentUser));
|
|
44
44
|
});
|
|
45
45
|
},
|
|
46
46
|
encryptAndSetAttachment(entity, attachment) {
|