@icure/api 8.6.3 → 8.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/icc-api/model/ModelHelper.d.ts +1 -1
  2. package/icc-api/model/ModelHelper.js +15 -2
  3. package/icc-api/model/ModelHelper.js.map +1 -1
  4. package/icc-api/model/User.d.ts +1 -0
  5. package/icc-api/model/User.js.map +1 -1
  6. package/icc-x-api/crypto/AES.js +1 -1
  7. package/icc-x-api/crypto/AES.js.map +1 -1
  8. package/icc-x-api/crypto/BaseExchangeDataManager.js +14 -14
  9. package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
  10. package/icc-x-api/crypto/BaseExchangeKeysManager.js +1 -1
  11. package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
  12. package/icc-x-api/crypto/CryptoPrimitives.js +3 -2
  13. package/icc-x-api/crypto/CryptoPrimitives.js.map +1 -1
  14. package/icc-x-api/crypto/ExchangeDataManager.js +3 -3
  15. package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
  16. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +1 -1
  17. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
  18. package/icc-x-api/crypto/KeyRecovery.js +3 -3
  19. package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
  20. package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js +13 -13
  21. package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js.map +1 -1
  22. package/icc-x-api/crypto/RSA.js +2 -2
  23. package/icc-x-api/crypto/RSA.js.map +1 -1
  24. package/icc-x-api/crypto/RecoveryDataEncryption.js +5 -5
  25. package/icc-x-api/crypto/RecoveryDataEncryption.js.map +1 -1
  26. package/icc-x-api/crypto/SecureDelegationsManager.js +1 -1
  27. package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
  28. package/icc-x-api/crypto/ShamirKeysManager.js +1 -1
  29. package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
  30. package/icc-x-api/crypto/utils.js +1 -1
  31. package/icc-x-api/crypto/utils.js.map +1 -1
  32. package/icc-x-api/filters/HealthElementByHcPartyCodeFilter.d.ts +24 -0
  33. package/icc-x-api/filters/HealthElementByHcPartyCodeFilter.js +24 -0
  34. package/icc-x-api/filters/HealthElementByHcPartyCodeFilter.js.map +1 -0
  35. package/icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter.d.ts +22 -0
  36. package/icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter.js +24 -0
  37. package/icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter.js.map +1 -0
  38. package/icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter.d.ts +21 -0
  39. package/icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter.js +24 -0
  40. package/icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter.js.map +1 -0
  41. package/icc-x-api/filters/HealthElementByHcPartyTagFilter.d.ts +24 -0
  42. package/icc-x-api/filters/HealthElementByHcPartyTagFilter.js +24 -0
  43. package/icc-x-api/filters/HealthElementByHcPartyTagFilter.js.map +1 -0
  44. package/icc-x-api/filters/VersionFiltering.d.ts +14 -0
  45. package/icc-x-api/filters/VersionFiltering.js +19 -0
  46. package/icc-x-api/filters/VersionFiltering.js.map +1 -0
  47. package/icc-x-api/filters/filters.d.ts +8 -4
  48. package/icc-x-api/filters/filters.js +4 -0
  49. package/icc-x-api/filters/filters.js.map +1 -1
  50. package/icc-x-api/icc-receipt-x-api.js +1 -1
  51. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  52. package/icc-x-api/utils/binary-utils.js +1 -1
  53. package/icc-x-api/utils/binary-utils.js.map +1 -1
  54. package/package.json +1 -1
  55. package/test/icc-api/api/IccAnonymousAccessApi.js +1 -1
  56. package/test/icc-api/api/IccAnonymousAccessApi.js.map +1 -1
  57. package/test/icc-api/api/IccDocumentApi.js +13 -12
  58. package/test/icc-api/api/IccDocumentApi.js.map +1 -1
  59. package/test/icc-x-api/crud/comprehensive-crud-test.js +2 -2
  60. package/test/icc-x-api/crud/comprehensive-crud-test.js.map +1 -1
  61. package/test/icc-x-api/crypto/crypto-utils.js +1 -1
  62. package/test/icc-x-api/crypto/crypto-utils.js.map +1 -1
  63. package/test/icc-x-api/crypto/soft-deleted-data-owners.js +1 -1
  64. package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +1 -1
  65. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +1 -1
  66. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +1 -1
  67. package/test/icc-x-api/filters/healthelement.d.ts +1 -0
  68. package/test/icc-x-api/filters/healthelement.js +333 -0
  69. package/test/icc-x-api/filters/healthelement.js.map +1 -0
  70. package/test/icc-x-api/test-legacy-data-support.js +4 -4
  71. package/test/icc-x-api/test-legacy-data-support.js.map +1 -1
  72. package/test/utils/TestCryptoStrategies.js +1 -1
  73. package/test/utils/TestCryptoStrategies.js.map +1 -1
  74. package/test/utils/roles.d.ts +1 -0
  75. package/test/utils/roles.js +1 -0
  76. package/test/utils/roles.js.map +1 -1
  77. package/test/utils/test_utils.js +2 -2
  78. package/test/utils/test_utils.js.map +1 -1
@@ -0,0 +1,333 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const mocha_1 = require("mocha");
13
+ require("isomorphic-fetch");
14
+ const chai_1 = require("chai");
15
+ const crypto_1 = require("crypto");
16
+ const test_utils_1 = require("../../utils/test_utils");
17
+ const types_1 = require("@icure/test-setup/types");
18
+ const HealthElement_1 = require("../../../icc-api/model/HealthElement");
19
+ const Patient_1 = require("../../../icc-api/model/Patient");
20
+ const CodeStub_1 = require("../../../icc-api/model/CodeStub");
21
+ const Identifier_1 = require("../../../icc-api/model/Identifier");
22
+ const HealthElementByHcPartyTagFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyTagFilter");
23
+ const HealthElementByHcPartyCodeFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyCodeFilter");
24
+ const HealthElementByHcPartyIdentifiersVersioningFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter");
25
+ const HealthElementByHcPartyStatusVersioningFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter");
26
+ const VersionFiltering_1 = require("../../../icc-x-api/filters/VersionFiltering");
27
+ (0, test_utils_1.setLocalStorage)(fetch);
28
+ let env;
29
+ function initHcpApiAndPatient() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const { api, user } = yield (0, test_utils_1.createNewHcpApi)(env);
32
+ const patient = yield api.patientApi.createPatientWithUser(user, yield api.patientApi.newInstance(user, new Patient_1.Patient({
33
+ id: (0, crypto_1.randomUUID)(),
34
+ firstName: 'Test',
35
+ lastName: 'Patient',
36
+ })));
37
+ return { api, user, patient };
38
+ });
39
+ }
40
+ describe('HealthElement Filters Tests', () => {
41
+ (0, mocha_1.before)(function () {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ this.timeout(600000);
44
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
45
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
46
+ });
47
+ });
48
+ it('HealthElementByHcPartyTagFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
49
+ // Given - Create a new HCP and initialize the api
50
+ const { api, user, patient } = yield initHcpApiAndPatient();
51
+ const hcpId = user.healthcarePartyId;
52
+ // Target tag to search for
53
+ const targetTagType = 'CD-LIFECYCLE';
54
+ const targetTagCode = 'active';
55
+ const matchingTag = new CodeStub_1.CodeStub({ id: `${targetTagType}|${targetTagCode}|1`, type: targetTagType, code: targetTagCode, version: '1' });
56
+ const nonMatchingTag = new CodeStub_1.CodeStub({ id: 'CD-LIFECYCLE|inactive|1', type: 'CD-LIFECYCLE', code: 'inactive', version: '1' });
57
+ // Helper to create and save a health element
58
+ function createHealthElement(opts) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
61
+ id: (0, crypto_1.randomUUID)(),
62
+ healthElementId: opts.healthElementId,
63
+ tags: opts.tags,
64
+ modified: opts.modified,
65
+ note: 'Test health element',
66
+ }));
67
+ return api.healthcareElementApi.createHealthElementWithUser(user, he);
68
+ });
69
+ }
70
+ // 1. A health element with the matching tag and no healthElementId
71
+ const he1 = yield createHealthElement({ tags: [matchingTag] });
72
+ // 2. A health element with the matching tag and a healthElementId
73
+ const he2HealthElementId = (0, crypto_1.randomUUID)();
74
+ const he2 = yield createHealthElement({ tags: [matchingTag], healthElementId: he2HealthElementId });
75
+ // 3. Two health elements with same healthElementId, different modified times:
76
+ // 3a. lowest modified has matching tag
77
+ // 3b. highest modified does not have matching tag (this is the latest version)
78
+ const he3HealthElementId = (0, crypto_1.randomUUID)();
79
+ const he3a = yield createHealthElement({
80
+ tags: [matchingTag],
81
+ healthElementId: he3HealthElementId,
82
+ modified: 1000,
83
+ });
84
+ const he3b = yield createHealthElement({
85
+ tags: [nonMatchingTag],
86
+ healthElementId: he3HealthElementId,
87
+ modified: 2000,
88
+ });
89
+ // 4. Two health elements with same healthElementId, different modified times:
90
+ // 4a. lowest modified does not have matching tag
91
+ // 4b. highest modified has matching tag (this is the latest version)
92
+ const he4HealthElementId = (0, crypto_1.randomUUID)();
93
+ const he4a = yield createHealthElement({
94
+ tags: [nonMatchingTag],
95
+ healthElementId: he4HealthElementId,
96
+ modified: 1000,
97
+ });
98
+ const he4b = yield createHealthElement({
99
+ tags: [matchingTag],
100
+ healthElementId: he4HealthElementId,
101
+ modified: 2000,
102
+ });
103
+ // 5. A health element without the matching tag and no healthElementId
104
+ const he5 = yield createHealthElement({ tags: [nonMatchingTag] });
105
+ // 6. A health element without the matching tag and a healthElementId
106
+ const he6HealthElementId = (0, crypto_1.randomUUID)();
107
+ const he6 = yield createHealthElement({ tags: [nonMatchingTag], healthElementId: he6HealthElementId });
108
+ // When - Use the filter with match method
109
+ const filter = new HealthElementByHcPartyTagFilter_1.HealthElementByHcPartyTagFilter({
110
+ healthcarePartyId: hcpId,
111
+ tagType: targetTagType,
112
+ tagCode: targetTagCode,
113
+ versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
114
+ });
115
+ const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
116
+ // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
117
+ (0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
118
+ }));
119
+ it('HealthElementByHcPartyCodeFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
120
+ // Given - Create a new HCP and initialize the api
121
+ const { api, user, patient } = yield initHcpApiAndPatient();
122
+ const hcpId = user.healthcarePartyId;
123
+ // Target code to search for
124
+ const targetCodeType = 'SNOMED';
125
+ const targetCodeCode = '38341003';
126
+ const matchingCode = new CodeStub_1.CodeStub({ id: `${targetCodeType}|${targetCodeCode}|2`, type: targetCodeType, code: targetCodeCode, version: '2' });
127
+ const nonMatchingCode = new CodeStub_1.CodeStub({ id: 'SNOMED|73211009|2', type: 'SNOMED', code: '73211009', version: '2' });
128
+ // Helper to create and save a health element
129
+ function createHealthElement(opts) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
132
+ id: (0, crypto_1.randomUUID)(),
133
+ healthElementId: opts.healthElementId,
134
+ codes: opts.codes,
135
+ modified: opts.modified,
136
+ note: 'Test health element',
137
+ }));
138
+ return api.healthcareElementApi.createHealthElementWithUser(user, he);
139
+ });
140
+ }
141
+ // 1. A health element with the matching code and no healthElementId
142
+ const he1 = yield createHealthElement({ codes: [matchingCode] });
143
+ // 2. A health element with the matching code and a healthElementId
144
+ const he2HealthElementId = (0, crypto_1.randomUUID)();
145
+ const he2 = yield createHealthElement({ codes: [matchingCode], healthElementId: he2HealthElementId });
146
+ // 3. Two health elements with same healthElementId, different modified times:
147
+ // 3a. lowest modified has matching code
148
+ // 3b. highest modified does not have matching code (this is the latest version)
149
+ const he3HealthElementId = (0, crypto_1.randomUUID)();
150
+ const he3a = yield createHealthElement({
151
+ codes: [matchingCode],
152
+ healthElementId: he3HealthElementId,
153
+ modified: 1000,
154
+ });
155
+ const he3b = yield createHealthElement({
156
+ codes: [nonMatchingCode],
157
+ healthElementId: he3HealthElementId,
158
+ modified: 2000,
159
+ });
160
+ // 4. Two health elements with same healthElementId, different modified times:
161
+ // 4a. lowest modified does not have matching code
162
+ // 4b. highest modified has matching code (this is the latest version)
163
+ const he4HealthElementId = (0, crypto_1.randomUUID)();
164
+ const he4a = yield createHealthElement({
165
+ codes: [nonMatchingCode],
166
+ healthElementId: he4HealthElementId,
167
+ modified: 1000,
168
+ });
169
+ const he4b = yield createHealthElement({
170
+ codes: [matchingCode],
171
+ healthElementId: he4HealthElementId,
172
+ modified: 2000,
173
+ });
174
+ // 5. A health element without the matching code and no healthElementId
175
+ const he5 = yield createHealthElement({ codes: [nonMatchingCode] });
176
+ // 6. A health element without the matching code and a healthElementId
177
+ const he6HealthElementId = (0, crypto_1.randomUUID)();
178
+ const he6 = yield createHealthElement({ codes: [nonMatchingCode], healthElementId: he6HealthElementId });
179
+ // When - Use the filter with match method
180
+ const filter = new HealthElementByHcPartyCodeFilter_1.HealthElementByHcPartyCodeFilter({
181
+ healthcarePartyId: hcpId,
182
+ codeType: targetCodeType,
183
+ codeCode: targetCodeCode,
184
+ versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
185
+ });
186
+ const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
187
+ // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
188
+ (0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
189
+ }));
190
+ it('HealthElementByHcPartyIdentifiersVersioningFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
191
+ // Given - Create a new HCP and initialize the api
192
+ const { api, user, patient } = yield initHcpApiAndPatient();
193
+ const hcpId = user.healthcarePartyId;
194
+ // Target identifier to search for
195
+ const matchingIdentifier = new Identifier_1.Identifier({
196
+ system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',
197
+ value: 'test-identifier-123',
198
+ });
199
+ const nonMatchingIdentifier = new Identifier_1.Identifier({
200
+ system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',
201
+ value: 'other-identifier-456',
202
+ });
203
+ // Helper to create and save a health element
204
+ function createHealthElement(opts) {
205
+ return __awaiter(this, void 0, void 0, function* () {
206
+ const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
207
+ id: (0, crypto_1.randomUUID)(),
208
+ healthElementId: opts.healthElementId,
209
+ identifiers: opts.identifiers,
210
+ modified: opts.modified,
211
+ note: 'Test health element',
212
+ }));
213
+ return api.healthcareElementApi.createHealthElementWithUser(user, he);
214
+ });
215
+ }
216
+ // 1. A health element with the matching identifier and no healthElementId
217
+ const he1 = yield createHealthElement({ identifiers: [matchingIdentifier] });
218
+ // 2. A health element with the matching identifier and a healthElementId
219
+ const he2HealthElementId = (0, crypto_1.randomUUID)();
220
+ const he2 = yield createHealthElement({ identifiers: [matchingIdentifier], healthElementId: he2HealthElementId });
221
+ // 3. Two health elements with same healthElementId, different modified times:
222
+ // 3a. lowest modified has matching identifier
223
+ // 3b. highest modified does not have matching identifier (this is the latest version)
224
+ const he3HealthElementId = (0, crypto_1.randomUUID)();
225
+ const he3a = yield createHealthElement({
226
+ identifiers: [matchingIdentifier],
227
+ healthElementId: he3HealthElementId,
228
+ modified: 1000,
229
+ });
230
+ const he3b = yield createHealthElement({
231
+ identifiers: [nonMatchingIdentifier],
232
+ healthElementId: he3HealthElementId,
233
+ modified: 2000,
234
+ });
235
+ // 4. Two health elements with same healthElementId, different modified times:
236
+ // 4a. lowest modified does not have matching identifier
237
+ // 4b. highest modified has matching identifier (this is the latest version)
238
+ const he4HealthElementId = (0, crypto_1.randomUUID)();
239
+ const he4a = yield createHealthElement({
240
+ identifiers: [nonMatchingIdentifier],
241
+ healthElementId: he4HealthElementId,
242
+ modified: 1000,
243
+ });
244
+ const he4b = yield createHealthElement({
245
+ identifiers: [matchingIdentifier],
246
+ healthElementId: he4HealthElementId,
247
+ modified: 2000,
248
+ });
249
+ // 5. A health element without the matching identifier and no healthElementId
250
+ const he5 = yield createHealthElement({ identifiers: [nonMatchingIdentifier] });
251
+ // 6. A health element without the matching identifier and a healthElementId
252
+ const he6HealthElementId = (0, crypto_1.randomUUID)();
253
+ const he6 = yield createHealthElement({ identifiers: [nonMatchingIdentifier], healthElementId: he6HealthElementId });
254
+ // When - Use the filter with match method
255
+ const filter = new HealthElementByHcPartyIdentifiersVersioningFilter_1.HealthElementByHcPartyIdentifiersVersioningFilter({
256
+ hcPartyId: hcpId,
257
+ identifiers: [matchingIdentifier],
258
+ versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
259
+ });
260
+ const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
261
+ // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
262
+ (0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
263
+ }));
264
+ it('HealthElementByHcPartyStatusVersioningFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
265
+ // Given - Create a new HCP and initialize the api
266
+ const { api, user, patient } = yield initHcpApiAndPatient();
267
+ const hcpId = user.healthcarePartyId;
268
+ // Target status to search for (bit 0: active=0/inactive=1, bit 1: relevant=0/irrelevant=1, bit 2: present=0/absent=1)
269
+ const matchingStatus = 0; // active, relevant, present
270
+ const nonMatchingStatus = 1; // inactive, relevant, present
271
+ // Helper to create and save a health element
272
+ function createHealthElement(opts) {
273
+ return __awaiter(this, void 0, void 0, function* () {
274
+ const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
275
+ id: (0, crypto_1.randomUUID)(),
276
+ healthElementId: opts.healthElementId,
277
+ status: opts.status,
278
+ modified: opts.modified,
279
+ note: 'Test health element',
280
+ }));
281
+ return api.healthcareElementApi.createHealthElementWithUser(user, he);
282
+ });
283
+ }
284
+ // 1. A health element with the matching status and no healthElementId
285
+ const he1 = yield createHealthElement({ status: matchingStatus });
286
+ // 2. A health element with the matching status and a healthElementId
287
+ const he2HealthElementId = (0, crypto_1.randomUUID)();
288
+ const he2 = yield createHealthElement({ status: matchingStatus, healthElementId: he2HealthElementId });
289
+ // 3. Two health elements with same healthElementId, different modified times:
290
+ // 3a. lowest modified has matching status
291
+ // 3b. highest modified does not have matching status (this is the latest version)
292
+ const he3HealthElementId = (0, crypto_1.randomUUID)();
293
+ const he3a = yield createHealthElement({
294
+ status: matchingStatus,
295
+ healthElementId: he3HealthElementId,
296
+ modified: 1000,
297
+ });
298
+ const he3b = yield createHealthElement({
299
+ status: nonMatchingStatus,
300
+ healthElementId: he3HealthElementId,
301
+ modified: 2000,
302
+ });
303
+ // 4. Two health elements with same healthElementId, different modified times:
304
+ // 4a. lowest modified does not have matching status
305
+ // 4b. highest modified has matching status (this is the latest version)
306
+ const he4HealthElementId = (0, crypto_1.randomUUID)();
307
+ const he4a = yield createHealthElement({
308
+ status: nonMatchingStatus,
309
+ healthElementId: he4HealthElementId,
310
+ modified: 1000,
311
+ });
312
+ const he4b = yield createHealthElement({
313
+ status: matchingStatus,
314
+ healthElementId: he4HealthElementId,
315
+ modified: 2000,
316
+ });
317
+ // 5. A health element without the matching status and no healthElementId
318
+ const he5 = yield createHealthElement({ status: nonMatchingStatus });
319
+ // 6. A health element without the matching status and a healthElementId
320
+ const he6HealthElementId = (0, crypto_1.randomUUID)();
321
+ const he6 = yield createHealthElement({ status: nonMatchingStatus, healthElementId: he6HealthElementId });
322
+ // When - Use the filter with match method
323
+ const filter = new HealthElementByHcPartyStatusVersioningFilter_1.HealthElementByHcPartyStatusVersioningFilter({
324
+ hcPartyId: hcpId,
325
+ status: matchingStatus,
326
+ versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
327
+ });
328
+ const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
329
+ // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
330
+ (0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
331
+ }));
332
+ });
333
+ //# sourceMappingURL=healthelement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthelement.js","sourceRoot":"","sources":["../../../../test/icc-x-api/filters/healthelement.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA8B;AAC9B,4BAAyB;AACzB,+BAA6B;AAC7B,mCAAmC;AACnC,uDAAoG;AACpG,mDAAmE;AACnE,wEAAoE;AACpE,4DAAwD;AACxD,8DAA0D;AAC1D,kEAA8D;AAC9D,gHAA4G;AAC5G,kHAA8G;AAC9G,oJAAgJ;AAChJ,0IAAsI;AACtI,kFAA8E;AAE9E,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,SAAe,oBAAoB;;QACjC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,4BAAe,EAAC,GAAG,CAAC,CAAA;QAEhD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,qB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ACF,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC;YACrC,MAAM,EAAE,cAAc;YACtB,eAAe,EAAE,kBAAkB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;QAEF,yEAAyE;QACzE,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAA;QAEpE,wEAAwE;QACxE,MAAM,kBAAkB,GAAG,IAAA,mBAAU,GAAE,CAAA;QACvC,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC,CAAA;QAEzG,0CAA0C;QAC1C,MAAM,MAAM,GAAG,IAAI,2FAA4C,CAAC;YAC9D,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,cAAc;YACtB,gBAAgB,EAAE,mCAAgB,CAAC,MAAM;SAC1C,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;QAE/E,uDAAuD;QACvD,IAAA,aAAM,EAAC,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/D,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { before } from 'mocha'\nimport 'isomorphic-fetch'\nimport { expect } from 'chai'\nimport { randomUUID } from 'crypto'\nimport { getEnvironmentInitializer, setLocalStorage, createNewHcpApi } from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { HealthElement } from '../../../icc-api/model/HealthElement'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport { CodeStub } from '../../../icc-api/model/CodeStub'\nimport { Identifier } from '../../../icc-api/model/Identifier'\nimport { HealthElementByHcPartyTagFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyTagFilter'\nimport { HealthElementByHcPartyCodeFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyCodeFilter'\nimport { HealthElementByHcPartyIdentifiersVersioningFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter'\nimport { HealthElementByHcPartyStatusVersioningFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter'\nimport { VersionFiltering } from '../../../icc-x-api/filters/VersionFiltering'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\nasync function initHcpApiAndPatient() {\n const { api, user } = await createNewHcpApi(env)\n\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(\n user,\n new Patient({\n id: randomUUID(),\n firstName: 'Test',\n lastName: 'Patient',\n })\n )\n )\n\n return { api, user, patient }\n}\n\ndescribe('HealthElement Filters Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('HealthElementByHcPartyTagFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target tag to search for\n const targetTagType = 'CD-LIFECYCLE'\n const targetTagCode = 'active'\n const matchingTag = new CodeStub({ id: `${targetTagType}|${targetTagCode}|1`, type: targetTagType, code: targetTagCode, version: '1' })\n const nonMatchingTag = new CodeStub({ id: 'CD-LIFECYCLE|inactive|1', type: 'CD-LIFECYCLE', code: 'inactive', version: '1' })\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { tags: CodeStub[]; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n tags: opts.tags,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching tag and no healthElementId\n const he1 = await createHealthElement({ tags: [matchingTag] })\n\n // 2. A health element with the matching tag and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ tags: [matchingTag], healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching tag\n // 3b. highest modified does not have matching tag (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n tags: [matchingTag],\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n tags: [nonMatchingTag],\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching tag\n // 4b. highest modified has matching tag (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n tags: [nonMatchingTag],\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n tags: [matchingTag],\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching tag and no healthElementId\n const he5 = await createHealthElement({ tags: [nonMatchingTag] })\n\n // 6. A health element without the matching tag and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ tags: [nonMatchingTag], healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyTagFilter({\n healthcarePartyId: hcpId,\n tagType: targetTagType,\n tagCode: targetTagCode,\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n\n it('HealthElementByHcPartyCodeFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target code to search for\n const targetCodeType = 'SNOMED'\n const targetCodeCode = '38341003'\n const matchingCode = new CodeStub({ id: `${targetCodeType}|${targetCodeCode}|2`, type: targetCodeType, code: targetCodeCode, version: '2' })\n const nonMatchingCode = new CodeStub({ id: 'SNOMED|73211009|2', type: 'SNOMED', code: '73211009', version: '2' })\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { codes: CodeStub[]; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n codes: opts.codes,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching code and no healthElementId\n const he1 = await createHealthElement({ codes: [matchingCode] })\n\n // 2. A health element with the matching code and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ codes: [matchingCode], healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching code\n // 3b. highest modified does not have matching code (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n codes: [matchingCode],\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n codes: [nonMatchingCode],\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching code\n // 4b. highest modified has matching code (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n codes: [nonMatchingCode],\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n codes: [matchingCode],\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching code and no healthElementId\n const he5 = await createHealthElement({ codes: [nonMatchingCode] })\n\n // 6. A health element without the matching code and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ codes: [nonMatchingCode], healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyCodeFilter({\n healthcarePartyId: hcpId,\n codeType: targetCodeType,\n codeCode: targetCodeCode,\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n\n it('HealthElementByHcPartyIdentifiersVersioningFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target identifier to search for\n const matchingIdentifier = new Identifier({\n system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',\n value: 'test-identifier-123',\n })\n const nonMatchingIdentifier = new Identifier({\n system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',\n value: 'other-identifier-456',\n })\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { identifiers: Identifier[]; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n identifiers: opts.identifiers,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching identifier and no healthElementId\n const he1 = await createHealthElement({ identifiers: [matchingIdentifier] })\n\n // 2. A health element with the matching identifier and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ identifiers: [matchingIdentifier], healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching identifier\n // 3b. highest modified does not have matching identifier (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n identifiers: [matchingIdentifier],\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n identifiers: [nonMatchingIdentifier],\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching identifier\n // 4b. highest modified has matching identifier (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n identifiers: [nonMatchingIdentifier],\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n identifiers: [matchingIdentifier],\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching identifier and no healthElementId\n const he5 = await createHealthElement({ identifiers: [nonMatchingIdentifier] })\n\n // 6. A health element without the matching identifier and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ identifiers: [nonMatchingIdentifier], healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyIdentifiersVersioningFilter({\n hcPartyId: hcpId,\n identifiers: [matchingIdentifier],\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n\n it('HealthElementByHcPartyStatusVersioningFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target status to search for (bit 0: active=0/inactive=1, bit 1: relevant=0/irrelevant=1, bit 2: present=0/absent=1)\n const matchingStatus = 0 // active, relevant, present\n const nonMatchingStatus = 1 // inactive, relevant, present\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { status: number; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n status: opts.status,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching status and no healthElementId\n const he1 = await createHealthElement({ status: matchingStatus })\n\n // 2. A health element with the matching status and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ status: matchingStatus, healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching status\n // 3b. highest modified does not have matching status (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n status: matchingStatus,\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n status: nonMatchingStatus,\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching status\n // 4b. highest modified has matching status (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n status: nonMatchingStatus,\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n status: matchingStatus,\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching status and no healthElementId\n const he5 = await createHealthElement({ status: nonMatchingStatus })\n\n // 6. A health element without the matching status and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ status: nonMatchingStatus, healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyStatusVersioningFilter({\n hcPartyId: hcpId,\n status: matchingStatus,\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n})\n"]}
@@ -157,8 +157,8 @@ class ApiFactoryV7 {
157
157
  masterApi(env) {
158
158
  return __awaiter(this, void 0, void 0, function* () {
159
159
  const key = {
160
- privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
161
- publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
160
+ privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey)), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
161
+ publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey)), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
162
162
  };
163
163
  const apis = yield apiV7_1.IcureApi.initialise(env.iCureUrl, { username: env.masterHcp.user, password: env.masterHcp.password }, new TestCryptoStrategiesV7(key), crypto_1.webcrypto, fetch, {
164
164
  storage: new TestStorage_1.TestStorage(),
@@ -252,8 +252,8 @@ class ApiFactoryV8 {
252
252
  masterApi(env) {
253
253
  return __awaiter(this, void 0, void 0, function* () {
254
254
  const key = {
255
- privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
256
- publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
255
+ privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey)), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
256
+ publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey)), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
257
257
  };
258
258
  const apis = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: env.masterHcp.user, password: env.masterHcp.password }, new TestCryptoStrategies_1.TestCryptoStrategies(key), crypto_1.webcrypto, fetch, {
259
259
  storage: new TestStorage_1.TestStorage(),
@@ -1 +1 @@
1
- {"version":3,"file":"test-legacy-data-support.js","sourceRoot":"","sources":["../../../test/icc-x-api/test-legacy-data-support.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,wCAA2D;AAC3D,wCAAkJ;AAClJ,+CASwB;AACxB,oDAAgF;AAEhF,+BAA6B;AAC7B,mCAAkC;AAElC,+BAAiC;AACjC,yEAAqE;AACrE,sDAAuF;AACvF,wEAAoE;AACpE,wFAAoF;AACpF,mDAAmE;AACnE,wDAAiG;AACjG,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AA+B3E,SAAS,kBAAkB,CAAC,MAAqB,EAAE,QAAuB,EAAE,UAAkB;IAC5F,IAAA,aAAM,EAAC,MAAM,CAAC,aAAa,EAAE,GAAG,UAAU,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC/F,IAAA,aAAM,EAAC,MAAM,CAAC,SAAS,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAChG,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QAC5C,IAAA,aAAM,EAAC,MAAM,CAAC,SAAS,EAAE,GAAG,UAAU,cAAc,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC9E,CAAC;IACD,IAAA,aAAM,EAAC,MAAM,CAAC,eAAe,EAAE,GAAG,UAAU,qBAAqB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CA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E,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,CAAC;wBAChE,kBAAkB,CAAC,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,6CAA6C,OAAO,GAAG,CAAC,CAAA;wBACnI,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,MAAM,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,CAAA;wBAChG,kBAAkB,CAAC,MAAM,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,+BAA+B,OAAO,GAAG,CAAC,CAAA;oBACjH,CAAC;oBACD,kBAAkB,CAAC,MAAM,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,2CAA2C,CAAC,CAAA;gBACtH,CAAC;aAAA,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { Api as ApiV6, User as UserV6 } from '@icure/apiV6'\nimport { CryptoStrategies as CryptoStrategiesV7, DataOwnerWithType as DataOwnerWithTypeV7, IcureApi as ApiV7, User as UserV7 } from '@icure/apiV7'\nimport {\n WebCryptoPrimitives,\n EntityWithDelegationTypeName,\n hex2ua,\n IcureApi as ApiV8,\n RSAUtils,\n RSAUtilsImpl,\n ShaVersion,\n ua2hex,\n} from '../../icc-x-api'\nimport { getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { KeyPair } from '../../icc-x-api/crypto/RSA'\nimport { expect } from 'chai'\nimport { webcrypto } from 'crypto'\nimport { CryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { v4 as uuid } from 'uuid'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../utils/TestStorage'\nimport { TestCryptoStrategies } from '../utils/TestCryptoStrategies'\nimport { EntityShareRequest } from '../../icc-api/model/requests/EntityShareRequest'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of } from '../../icc-x-api/crypto/utils'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\ntype UserCredentials = {\n login: string\n password: string\n ownerId: string\n key: KeyPair<CryptoKey>\n}\ntype EncryptedData = {\n secretContent: string\n secretIds: string[]\n owningEntityIds: string[]\n}\n\ninterface UniformizedMasterApi {\n createUser(): Promise<UserCredentials>\n}\n\ninterface UniformizedTestApi {\n userDetails(): Promise<{ userId: string; dataOwnerId: string }>\n createEncryptedData(): Promise<{ id: string } & EncryptedData>\n getDecryptedData(id: string): Promise<EncryptedData>\n shareEncryptedData(dataId: string, delegateId: string): Promise<void>\n}\n\ninterface ApiFactory {\n readonly version: string\n masterApi(env: TestVars): Promise<UniformizedMasterApi>\n testApi(credentials: UserCredentials): Promise<UniformizedTestApi>\n}\n\nfunction checkEncryptedData(actual: EncryptedData, expected: EncryptedData, actualName: string) {\n expect(actual.secretContent, `${actualName} - secret content`).to.equal(expected.secretContent)\n expect(actual.secretIds, `${actualName} - secret ids`).to.have.length(expected.secretIds.length)\n for (const expectedId of expected.secretIds) {\n expect(actual.secretIds, `${actualName} - secret id`).to.contain(expectedId)\n }\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.have.length(expected.owningEntityIds.length)\n for (const expectedId of expected.owningEntityIds) {\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.contain(expectedId)\n }\n}\n\nsetLocalStorage(fetch)\nconst cryptoPrimitives = new WebCryptoPrimitives(webcrypto as any)\nlet env: TestVars\n\nclass ApiFactoryV6 implements ApiFactory {\n readonly version: string = 'apiV6.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const apis = await ApiV6(\n env.iCureUrl + '/rest/v1',\n env.masterHcp!.user,\n env.masterHcp!.password,\n webcrypto as any,\n fetch,\n false,\n false,\n new TestStorage(),\n new TestKeyStorage()\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v6' }))\n const user = await apis.userApi.createUser(\n new UserV6({\n id: uuid(),\n login: `v6-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const apis = await ApiV6(env.iCureUrl + '/rest/v1', credentials.login, credentials.password, webcrypto as any, fetch)\n // await apis.cryptoApi.cacheKeyPair(await cryptoPrimitives.RSA.exportKeys(credentials.key, \"jwk\", \"jwk\"))\n const user = await apis.userApi.getCurrentUser()\n await apis.cryptoApi.addKeyPairForOwner(\n apis.maintenanceTaskApi,\n user,\n await apis.cryptoApi.getDataOwner(credentials.ownerId),\n credentials.key,\n false,\n false\n )\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v6 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: (await apis.cryptoApi.extractCryptedFKs(healthdata, credentials.ownerId)).extractedKeys,\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const patientIds = (await apis.cryptoApi.extractCryptedFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(patientIds).to.have.length(1)\n const patient = await apis.patientApi.getPatientWithUser(user, patientIds[0])\n const secretIds = (await apis.cryptoApi.extractDelegationsSFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(secretIds).to.have.length(1)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n (\n await apis.cryptoApi.extendedDelegationsAndCryptedForeignKeys(healthElement, patient, credentials.ownerId, delegateId, secretIds[0])\n ).modifiedObject\n )\n },\n }\n }\n}\n\nclass TestCryptoStrategiesV7 implements CryptoStrategiesV7 {\n private readonly RSA = new RSAUtilsImpl(webcrypto as any)\n constructor(private readonly key: KeyPair<CryptoKey> | undefined) {}\n\n async generateNewKeyForDataOwner(self: DataOwnerWithTypeV7): Promise<KeyPair<CryptoKey> | boolean> {\n if (!this.key) return false\n const knownKeys = new Set(...hexPublicKeysWithSha1Of(self))\n if (knownKeys.size <= 0) return this.key\n return false\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithTypeV7\n unknownKeys: string[]\n unavailableKeys: string[]\n }[]\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n const self = keysData[keysData.length - 1].dataOwner\n const knownKeys = new Set([...hexPublicKeysWithSha1Of(self.dataOwner), ...hexPublicKeysWithSha256Of(self.dataOwner)])\n const publicKey = this.key ? ua2hex(await this.RSA.exportKey(this.key.publicKey, 'spki')) : undefined\n return Object.fromEntries(\n await Promise.all(\n keysData.map(async (currData) => {\n if (currData.dataOwner.dataOwner.id! !== self.dataOwner.id!) {\n return [\n currData.dataOwner.dataOwner.id!,\n {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n ]\n } else if (publicKey === undefined || !knownKeys.has(publicKey)) {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: {}, keyAuthenticity: {} }]\n } else {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: { [publicKey.slice(-32)]: this.key }, keyAuthenticity: {} }]\n }\n })\n )\n )\n }\n\n verifyDelegatePublicKeys(delegate: any, publicKeys: string[]): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\nclass ApiFactoryV7 implements ApiFactory {\n readonly version: string = 'apiV7.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', hex2ua(env.masterHcp!.privateKey), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', hex2ua(env.masterHcp!.publicKey), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategiesV7(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategiesV7(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v7 note ${uuid}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthdata)\n expect(secretIds).to.have.length(1)\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.entities.secretIdsOf(healthdata),\n owningEntityIds: await apis.cryptoApi.entities.owningEntityIdsOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const encryptionKeys = await apis.cryptoApi.entities.encryptionKeysOf(healthElement)\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthElement)\n const owningEntityIds = await apis.cryptoApi.entities.owningEntityIdsOf(healthElement)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n await apis.cryptoApi.entities.entityWithExtendedEncryptedMetadata(healthElement, delegateId, secretIds, encryptionKeys, owningEntityIds, [])\n )\n },\n }\n }\n}\n\nclass ApiFactoryV8 implements ApiFactory {\n readonly version: string = 'apiV8.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', hex2ua(env.masterHcp!.privateKey), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', hex2ua(env.masterHcp!.publicKey), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategies(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategies(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v8 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: [],\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.xapi.secretIdsOf({ entity: healthdata, type: EntityWithDelegationTypeName.HealthElement }, undefined),\n owningEntityIds: await apis.healthcareElementApi.decryptPatientIdOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n await apis.healthcareElementApi.shareWith(delegateId, healthElement, { requestedPermissions: RequestedPermissionEnum.MAX_WRITE })\n },\n }\n }\n}\n\n// Api factories in chronological version order\nlet chronologicalApiFactories: ApiFactory[] = [new ApiFactoryV6(), new ApiFactoryV7(), new ApiFactoryV8()]\n\ndescribe('All apis versions', async function () {\n before(async function () {\n this.timeout(600_000)\n env = await getEnvironmentInitializer().then((initializer) => initializer.execute(getEnvVariables()))\n })\n\n for (let legacyApiIndex = 0; legacyApiIndex < chronologicalApiFactories.length - 1; legacyApiIndex++) {\n const legacyApiFactory = chronologicalApiFactories[legacyApiIndex]\n const newApiFactories = chronologicalApiFactories.slice(legacyApiIndex + 1)\n it(`should be able to read and share data from older apis without affecting accessibility for older apis - ${legacyApiFactory.version}`, async function () {\n const legacyMasterApi = await legacyApiFactory.masterApi(env)\n const legacyUserCredentials = await legacyMasterApi.createUser()\n const legacyUserApi = await legacyApiFactory.testApi(legacyUserCredentials)\n const data = await legacyUserApi.createEncryptedData()\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, 'Original decrypted data')\n const newApis = await Promise.all(\n newApiFactories.map(async (factory) => {\n const newLegacyUserApi = await factory.testApi(legacyUserCredentials)\n const newUser = await factory.masterApi(env).then((masterApi) => masterApi.createUser())\n const newUserApi = await factory.testApi(newUser)\n return { newLegacyUserApi, newUserApi, version: factory.version }\n })\n )\n for (const { newLegacyUserApi, newUserApi, version } of newApis) {\n checkEncryptedData(await newLegacyUserApi.getDecryptedData(data.id), data, `Data decrypted by legacy user on new api (${version})`)\n await newLegacyUserApi.shareEncryptedData(data.id, (await newUserApi.userDetails()).dataOwnerId)\n checkEncryptedData(await newUserApi.getDecryptedData(data.id), data, `Data decrypted by new user (${version})`)\n }\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, `Data after changes by new versions of api`)\n })\n }\n})\n"]}
1
+ {"version":3,"file":"test-legacy-data-support.js","sourceRoot":"","sources":["../../../test/icc-x-api/test-legacy-data-support.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,wCAA2D;AAC3D,wCAAkJ;AAClJ,+CAUwB;AACxB,oDAAgF;AAEhF,+BAA6B;AAC7B,mCAAkC;AAElC,+BAAiC;AACjC,yEAAqE;AACrE,sDAAuF;AACvF,wEAAoE;AACpE,wFAAoF;AACpF,mDAAmE;AACnE,wDAAiG;AACjG,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AA+B3E,SAAS,kBAAkB,CAAC,MAAqB,EAAE,QAAuB,EAAE,UAAkB;IAC5F,IAAA,aAAM,EAAC,MAAM,CAAC,aAAa,EAAE,GAAG,UAAU,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC/F,IAAA,aAAM,EAAC,MAAM,CAAC,SAAS,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC,E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ptoStrategies as CryptoStrategiesV7, DataOwnerWithType as DataOwnerWithTypeV7, IcureApi as ApiV7, User as UserV7 } from '@icure/apiV7'\nimport {\n WebCryptoPrimitives,\n EntityWithDelegationTypeName,\n hex2ua,\n IcureApi as ApiV8,\n RSAUtils,\n RSAUtilsImpl,\n ShaVersion,\n ua2hex,\n ua2ab,\n} from '../../icc-x-api'\nimport { getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { KeyPair } from '../../icc-x-api/crypto/RSA'\nimport { expect } from 'chai'\nimport { webcrypto } from 'crypto'\nimport { CryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { v4 as uuid } from 'uuid'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../utils/TestStorage'\nimport { TestCryptoStrategies } from '../utils/TestCryptoStrategies'\nimport { EntityShareRequest } from '../../icc-api/model/requests/EntityShareRequest'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of } from '../../icc-x-api/crypto/utils'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\ntype UserCredentials = {\n login: string\n password: string\n ownerId: string\n key: KeyPair<CryptoKey>\n}\ntype EncryptedData = {\n secretContent: string\n secretIds: string[]\n owningEntityIds: string[]\n}\n\ninterface UniformizedMasterApi {\n createUser(): Promise<UserCredentials>\n}\n\ninterface UniformizedTestApi {\n userDetails(): Promise<{ userId: string; dataOwnerId: string }>\n createEncryptedData(): Promise<{ id: string } & EncryptedData>\n getDecryptedData(id: string): Promise<EncryptedData>\n shareEncryptedData(dataId: string, delegateId: string): Promise<void>\n}\n\ninterface ApiFactory {\n readonly version: string\n masterApi(env: TestVars): Promise<UniformizedMasterApi>\n testApi(credentials: UserCredentials): Promise<UniformizedTestApi>\n}\n\nfunction checkEncryptedData(actual: EncryptedData, expected: EncryptedData, actualName: string) {\n expect(actual.secretContent, `${actualName} - secret content`).to.equal(expected.secretContent)\n expect(actual.secretIds, `${actualName} - secret ids`).to.have.length(expected.secretIds.length)\n for (const expectedId of expected.secretIds) {\n expect(actual.secretIds, `${actualName} - secret id`).to.contain(expectedId)\n }\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.have.length(expected.owningEntityIds.length)\n for (const expectedId of expected.owningEntityIds) {\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.contain(expectedId)\n }\n}\n\nsetLocalStorage(fetch)\nconst cryptoPrimitives = new WebCryptoPrimitives(webcrypto as any)\nlet env: TestVars\n\nclass ApiFactoryV6 implements ApiFactory {\n readonly version: string = 'apiV6.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const apis = await ApiV6(\n env.iCureUrl + '/rest/v1',\n env.masterHcp!.user,\n env.masterHcp!.password,\n webcrypto as any,\n fetch,\n false,\n false,\n new TestStorage(),\n new TestKeyStorage()\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v6' }))\n const user = await apis.userApi.createUser(\n new UserV6({\n id: uuid(),\n login: `v6-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const apis = await ApiV6(env.iCureUrl + '/rest/v1', credentials.login, credentials.password, webcrypto as any, fetch)\n // await apis.cryptoApi.cacheKeyPair(await cryptoPrimitives.RSA.exportKeys(credentials.key, \"jwk\", \"jwk\"))\n const user = await apis.userApi.getCurrentUser()\n await apis.cryptoApi.addKeyPairForOwner(\n apis.maintenanceTaskApi,\n user,\n await apis.cryptoApi.getDataOwner(credentials.ownerId),\n credentials.key,\n false,\n false\n )\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v6 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: (await apis.cryptoApi.extractCryptedFKs(healthdata, credentials.ownerId)).extractedKeys,\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const patientIds = (await apis.cryptoApi.extractCryptedFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(patientIds).to.have.length(1)\n const patient = await apis.patientApi.getPatientWithUser(user, patientIds[0])\n const secretIds = (await apis.cryptoApi.extractDelegationsSFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(secretIds).to.have.length(1)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n (\n await apis.cryptoApi.extendedDelegationsAndCryptedForeignKeys(healthElement, patient, credentials.ownerId, delegateId, secretIds[0])\n ).modifiedObject\n )\n },\n }\n }\n}\n\nclass TestCryptoStrategiesV7 implements CryptoStrategiesV7 {\n private readonly RSA = new RSAUtilsImpl(webcrypto as any)\n constructor(private readonly key: KeyPair<CryptoKey> | undefined) {}\n\n async generateNewKeyForDataOwner(self: DataOwnerWithTypeV7): Promise<KeyPair<CryptoKey> | boolean> {\n if (!this.key) return false\n const knownKeys = new Set(...hexPublicKeysWithSha1Of(self))\n if (knownKeys.size <= 0) return this.key\n return false\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithTypeV7\n unknownKeys: string[]\n unavailableKeys: string[]\n }[]\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n const self = keysData[keysData.length - 1].dataOwner\n const knownKeys = new Set([...hexPublicKeysWithSha1Of(self.dataOwner), ...hexPublicKeysWithSha256Of(self.dataOwner)])\n const publicKey = this.key ? ua2hex(await this.RSA.exportKey(this.key.publicKey, 'spki')) : undefined\n return Object.fromEntries(\n await Promise.all(\n keysData.map(async (currData) => {\n if (currData.dataOwner.dataOwner.id! !== self.dataOwner.id!) {\n return [\n currData.dataOwner.dataOwner.id!,\n {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n ]\n } else if (publicKey === undefined || !knownKeys.has(publicKey)) {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: {}, keyAuthenticity: {} }]\n } else {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: { [publicKey.slice(-32)]: this.key }, keyAuthenticity: {} }]\n }\n })\n )\n )\n }\n\n verifyDelegatePublicKeys(delegate: any, publicKeys: string[]): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\nclass ApiFactoryV7 implements ApiFactory {\n readonly version: string = 'apiV7.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', ua2ab(hex2ua(env.masterHcp!.privateKey)), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', ua2ab(hex2ua(env.masterHcp!.publicKey)), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategiesV7(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategiesV7(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v7 note ${uuid}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthdata)\n expect(secretIds).to.have.length(1)\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.entities.secretIdsOf(healthdata),\n owningEntityIds: await apis.cryptoApi.entities.owningEntityIdsOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const encryptionKeys = await apis.cryptoApi.entities.encryptionKeysOf(healthElement)\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthElement)\n const owningEntityIds = await apis.cryptoApi.entities.owningEntityIdsOf(healthElement)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n await apis.cryptoApi.entities.entityWithExtendedEncryptedMetadata(healthElement, delegateId, secretIds, encryptionKeys, owningEntityIds, [])\n )\n },\n }\n }\n}\n\nclass ApiFactoryV8 implements ApiFactory {\n readonly version: string = 'apiV8.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', ua2ab(hex2ua(env.masterHcp!.privateKey)), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', ua2ab(hex2ua(env.masterHcp!.publicKey)), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategies(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategies(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v8 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: [],\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.xapi.secretIdsOf({ entity: healthdata, type: EntityWithDelegationTypeName.HealthElement }, undefined),\n owningEntityIds: await apis.healthcareElementApi.decryptPatientIdOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n await apis.healthcareElementApi.shareWith(delegateId, healthElement, { requestedPermissions: RequestedPermissionEnum.MAX_WRITE })\n },\n }\n }\n}\n\n// Api factories in chronological version order\nlet chronologicalApiFactories: ApiFactory[] = [new ApiFactoryV6(), new ApiFactoryV7(), new ApiFactoryV8()]\n\ndescribe('All apis versions', async function () {\n before(async function () {\n this.timeout(600_000)\n env = await getEnvironmentInitializer().then((initializer) => initializer.execute(getEnvVariables()))\n })\n\n for (let legacyApiIndex = 0; legacyApiIndex < chronologicalApiFactories.length - 1; legacyApiIndex++) {\n const legacyApiFactory = chronologicalApiFactories[legacyApiIndex]\n const newApiFactories = chronologicalApiFactories.slice(legacyApiIndex + 1)\n it(`should be able to read and share data from older apis without affecting accessibility for older apis - ${legacyApiFactory.version}`, async function () {\n const legacyMasterApi = await legacyApiFactory.masterApi(env)\n const legacyUserCredentials = await legacyMasterApi.createUser()\n const legacyUserApi = await legacyApiFactory.testApi(legacyUserCredentials)\n const data = await legacyUserApi.createEncryptedData()\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, 'Original decrypted data')\n const newApis = await Promise.all(\n newApiFactories.map(async (factory) => {\n const newLegacyUserApi = await factory.testApi(legacyUserCredentials)\n const newUser = await factory.masterApi(env).then((masterApi) => masterApi.createUser())\n const newUserApi = await factory.testApi(newUser)\n return { newLegacyUserApi, newUserApi, version: factory.version }\n })\n )\n for (const { newLegacyUserApi, newUserApi, version } of newApis) {\n checkEncryptedData(await newLegacyUserApi.getDecryptedData(data.id), data, `Data decrypted by legacy user on new api (${version})`)\n await newLegacyUserApi.shareEncryptedData(data.id, (await newUserApi.userDetails()).dataOwnerId)\n checkEncryptedData(await newUserApi.getDecryptedData(data.id), data, `Data decrypted by new user (${version})`)\n }\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, `Data after changes by new versions of api`)\n })\n }\n})\n"]}
@@ -46,7 +46,7 @@ class TestCryptoStrategies {
46
46
  {
47
47
  recoveredKeys: recoveredKey
48
48
  ? {
49
- [recoveredKey.pair.publicKey.slice(-32)]: yield cryptoPrimitives.RSA.importKeyPair('pkcs8', (0, icc_x_api_1.hex2ua)(recoveredKey.pair.privateKey), 'spki', (0, icc_x_api_1.hex2ua)(recoveredKey.pair.publicKey), recoveredKey.shaVersion),
49
+ [recoveredKey.pair.publicKey.slice(-32)]: yield cryptoPrimitives.RSA.importKeyPair('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(recoveredKey.pair.privateKey)), 'spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(recoveredKey.pair.publicKey)), recoveredKey.shaVersion),
50
50
  }
51
51
  : {},
52
52
  keyAuthenticity: {},