@icure/api 7.1.33 → 7.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/icc-api/api/IccAuthApi.d.ts +1 -0
  2. package/icc-api/api/IccAuthApi.js +1 -0
  3. package/icc-api/api/IccAuthApi.js.map +1 -1
  4. package/icc-api/api/IccInsuranceApi.js +4 -3
  5. package/icc-api/api/IccInsuranceApi.js.map +1 -1
  6. package/icc-api/api/IccUserApi.d.ts +8 -10
  7. package/icc-api/api/IccUserApi.js +14 -18
  8. package/icc-api/api/IccUserApi.js.map +1 -1
  9. package/icc-x-api/index.d.ts +22 -29
  10. package/icc-x-api/index.js +60 -38
  11. package/icc-x-api/index.js.map +1 -1
  12. package/package.json +1 -1
  13. package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
  14. package/test/icc-api/api/IccDocumentApi.js +200 -0
  15. package/test/icc-api/api/IccDocumentApi.js.map +1 -0
  16. package/test/icc-api/api/IccGroupApi.d.ts +1 -0
  17. package/test/icc-api/api/IccGroupApi.js +50 -0
  18. package/test/icc-api/api/IccGroupApi.js.map +1 -0
  19. package/test/icc-api/api/IccRoleApi.d.ts +1 -0
  20. package/test/icc-api/api/IccRoleApi.js +34 -0
  21. package/test/icc-api/api/IccRoleApi.js.map +1 -0
  22. package/test/icc-api/api/IccUserApi.d.ts +1 -0
  23. package/test/icc-api/api/IccUserApi.js +80 -0
  24. package/test/icc-api/api/IccUserApi.js.map +1 -0
  25. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
  26. package/test/icc-api/e2e/IccCalendarItemApi.js +45 -0
  27. package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
  28. package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
  29. package/test/icc-api/model/modelHelpersTest.js +45 -0
  30. package/test/icc-api/model/modelHelpersTest.js.map +1 -0
  31. package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
  32. package/test/icc-x-api/auth/group-switch-test.js +81 -0
  33. package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
  34. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
  35. package/test/icc-x-api/auth/jwt-concurrency-test.js +113 -0
  36. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
  37. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
  38. package/test/icc-x-api/auth/smart-auth-provider-test.js +222 -0
  39. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
  40. package/test/icc-x-api/crypto/KeyManager-test.d.ts +1 -0
  41. package/test/icc-x-api/crypto/KeyManager-test.js +225 -0
  42. package/test/icc-x-api/crypto/KeyManager-test.js.map +1 -0
  43. package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
  44. package/test/icc-x-api/crypto/concurrency.js +35 -0
  45. package/test/icc-x-api/crypto/concurrency.js.map +1 -0
  46. package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
  47. package/test/icc-x-api/crypto/crypto-utils.js +80 -0
  48. package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
  49. package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
  50. package/test/icc-x-api/crypto/cryptoTest.js +275 -0
  51. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
  52. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
  53. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +132 -0
  54. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
  55. package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
  56. package/test/icc-x-api/crypto/full-crypto-test.js +458 -0
  57. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
  58. package/test/icc-x-api/crypto/shamir.d.ts +2 -0
  59. package/test/icc-x-api/crypto/shamir.js +156 -0
  60. package/test/icc-x-api/crypto/shamir.js.map +1 -0
  61. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
  62. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +75 -0
  63. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
  64. package/test/icc-x-api/data-compatibility-test-7to6.d.ts +1 -0
  65. package/test/icc-x-api/data-compatibility-test-7to6.js +343 -0
  66. package/test/icc-x-api/data-compatibility-test-7to6.js.map +1 -0
  67. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
  68. package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
  69. package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
  70. package/test/icc-x-api/filters/filters.d.ts +1 -0
  71. package/test/icc-x-api/filters/filters.js +49 -0
  72. package/test/icc-x-api/filters/filters.js.map +1 -0
  73. package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
  74. package/test/icc-x-api/icc-accesslog-x-api.js +121 -0
  75. package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
  76. package/test/icc-x-api/icc-auth-api.d.ts +1 -0
  77. package/test/icc-x-api/icc-auth-api.js +46 -0
  78. package/test/icc-x-api/icc-auth-api.js.map +1 -0
  79. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
  80. package/test/icc-x-api/icc-calendar-item-x-api.js +146 -0
  81. package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
  82. package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
  83. package/test/icc-x-api/icc-contact-x-api.js +311 -0
  84. package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
  85. package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
  86. package/test/icc-x-api/icc-form-x-api.js +331 -0
  87. package/test/icc-x-api/icc-form-x-api.js.map +1 -0
  88. package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
  89. package/test/icc-x-api/icc-helement-x-api-test.js +158 -0
  90. package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
  91. package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
  92. package/test/icc-x-api/icc-invoice-x-api.js +115 -0
  93. package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
  94. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
  95. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +230 -0
  96. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
  97. package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
  98. package/test/icc-x-api/icc-patient-x-api-test.js +169 -0
  99. package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
  100. package/test/icc-x-api/icc-time-table-x-api.d.ts +1 -0
  101. package/test/icc-x-api/icc-time-table-x-api.js +110 -0
  102. package/test/icc-x-api/icc-time-table-x-api.js.map +1 -0
  103. package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
  104. package/test/icc-x-api/icc-user-x-api-test.js +108 -0
  105. package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
  106. package/test/icc-x-api/icureapi-group-test.d.ts +1 -0
  107. package/test/icc-x-api/icureapi-group-test.js +130 -0
  108. package/test/icc-x-api/icureapi-group-test.js.map +1 -0
  109. package/test/icc-x-api/patient-user.d.ts +2 -0
  110. package/test/icc-x-api/patient-user.js +117 -0
  111. package/test/icc-x-api/patient-user.js.map +1 -0
  112. package/test/icc-x-api/storage/storage.d.ts +1 -0
  113. package/test/icc-x-api/storage/storage.js +50 -0
  114. package/test/icc-x-api/storage/storage.js.map +1 -0
  115. package/test/icc-x-api/subscription-apis.d.ts +2 -0
  116. package/test/icc-x-api/subscription-apis.js +498 -0
  117. package/test/icc-x-api/subscription-apis.js.map +1 -0
  118. package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
  119. package/test/icc-x-api/test-api-no-parent.js +79 -0
  120. package/test/icc-x-api/test-api-no-parent.js.map +1 -0
  121. package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
  122. package/test/icc-x-api/test-legacy-data-support.js +231 -0
  123. package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
  124. package/test/icc-x-api/utils/crypto-utils-test.d.ts +1 -0
  125. package/test/icc-x-api/utils/crypto-utils-test.js +586 -0
  126. package/test/icc-x-api/utils/crypto-utils-test.js.map +1 -0
  127. package/test/icc-x-api/utils/graph-test.d.ts +1 -0
  128. package/test/icc-x-api/utils/graph-test.js +54 -0
  129. package/test/icc-x-api/utils/graph-test.js.map +1 -0
  130. package/test/support/CSM-185.d.ts +1 -0
  131. package/test/support/CSM-185.js +120 -0
  132. package/test/support/CSM-185.js.map +1 -0
  133. package/test/support/CSM-87.d.ts +0 -0
  134. package/test/support/CSM-87.js +21 -0
  135. package/test/support/CSM-87.js.map +1 -0
  136. package/test/support/CSM-93.d.ts +1 -0
  137. package/test/support/CSM-93.js +111 -0
  138. package/test/support/CSM-93.js.map +1 -0
  139. package/test/utils/TestApi.d.ts +3 -0
  140. package/test/utils/TestApi.js +27 -0
  141. package/test/utils/TestApi.js.map +1 -0
  142. package/test/utils/TestCollectionUtils.d.ts +1 -0
  143. package/test/utils/TestCollectionUtils.js +109 -0
  144. package/test/utils/TestCollectionUtils.js.map +1 -0
  145. package/test/utils/TestCryptoStrategies.d.ts +37 -0
  146. package/test/utils/TestCryptoStrategies.js +72 -0
  147. package/test/utils/TestCryptoStrategies.js.map +1 -0
  148. package/test/utils/TestStorage.d.ts +31 -0
  149. package/test/utils/TestStorage.js +88 -0
  150. package/test/utils/TestStorage.js.map +1 -0
  151. package/test/utils/test_utils.d.ts +60 -0
  152. package/test/utils/test_utils.js +313 -0
  153. package/test/utils/test_utils.js.map +1 -0
@@ -0,0 +1,343 @@
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 types_1 = require("@icure/test-setup/types");
13
+ const mocha_1 = require("mocha");
14
+ const test_utils_1 = require("../utils/test_utils");
15
+ const _ = require("lodash");
16
+ const apiV6_1 = require("@icure/apiV6");
17
+ const icc_x_api_1 = require("../../icc-x-api");
18
+ const crypto_1 = require("crypto");
19
+ const TestStorage_1 = require("../utils/TestStorage");
20
+ const TestCryptoStrategies_1 = require("../utils/TestCryptoStrategies");
21
+ const icc_api_1 = require("../../icc-api");
22
+ const chai_1 = require("chai");
23
+ require("isomorphic-fetch");
24
+ const IccMaintenanceTaskApi_1 = require("../../icc-api/api/IccMaintenanceTaskApi");
25
+ (0, test_utils_1.setLocalStorage)(fetch);
26
+ let env;
27
+ let apiV6;
28
+ let apiV7;
29
+ let userV6;
30
+ let userV7;
31
+ let patient;
32
+ describe('iCure API v6 and v7 (current) should be fully data compatible', () => __awaiter(void 0, void 0, void 0, function* () {
33
+ (0, mocha_1.before)(function () {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ this.timeout(600000);
36
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
37
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
38
+ apiV6 = yield (0, apiV6_1.Api)(env.iCureUrl + '/rest/v1', env.dataOwnerDetails[test_utils_1.hcp1Username].user, env.dataOwnerDetails[test_utils_1.hcp1Username].password, crypto_1.webcrypto, fetch, false, false, new TestStorage_1.TestStorage(), new TestStorage_1.TestKeyStorage());
39
+ yield apiV6.cryptoApi.loadKeyPairsAsTextInBrowserLocalStorage(env.dataOwnerDetails[test_utils_1.hcp1Username].dataOwnerId, (0, icc_x_api_1.hex2ua)(env.dataOwnerDetails[test_utils_1.hcp1Username].privateKey));
40
+ apiV6.patientApi = new apiV6_1.IccPatientXApi(// Want to override encryption keys
41
+ env.iCureUrl + '/rest/v1', {}, apiV6.cryptoApi, apiV6.contactApi, apiV6.formApi, apiV6.healthcareElementApi, apiV6.invoiceApi, apiV6.documentApi, apiV6.healthcarePartyApi, apiV6.classificationApi, apiV6.dataOwnerApi, apiV6.calendarItemApi, ['note', 'properties.*.typedValue'], apiV6.authApi.authenticationProvider, fetch);
42
+ apiV7 = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: env.dataOwnerDetails[test_utils_1.hcp1Username].user, password: env.dataOwnerDetails[test_utils_1.hcp1Username].password }, new TestCryptoStrategies_1.TestCryptoStrategies({
43
+ publicKey: yield apiV6.cryptoApi.RSA.importKey('spki', (0, icc_x_api_1.hex2ua)(env.dataOwnerDetails[test_utils_1.hcp1Username].publicKey), ['encrypt']),
44
+ privateKey: yield apiV6.cryptoApi.RSA.importKey('pkcs8', (0, icc_x_api_1.hex2ua)(env.dataOwnerDetails[test_utils_1.hcp1Username].privateKey), ['decrypt']),
45
+ }), crypto_1.webcrypto, fetch, {
46
+ storage: new TestStorage_1.TestStorage(),
47
+ keyStorage: new TestStorage_1.TestKeyStorage(),
48
+ encryptedFieldsConfig: {
49
+ patient: ['note', 'properties[].typedValue'],
50
+ service: [], // For full v6-v7 compatibility service should not have any encrypted fields apart from implicit 'content'
51
+ },
52
+ });
53
+ userV6 = yield apiV6.userApi.getCurrentUser();
54
+ userV7 = yield apiV7.userApi.getCurrentUser();
55
+ patient = yield apiV6.patientApi.createPatientWithUser(userV6, yield apiV6.patientApi.newInstance(userV6, { firstName: 'Joe', lastName: 'Dhon' }));
56
+ });
57
+ });
58
+ it('An AccessLog created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', () => __awaiter(void 0, void 0, void 0, function* () {
59
+ const baseApi = new icc_api_1.IccAccesslogApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch);
60
+ const accessLogData = {
61
+ detail: 'secret',
62
+ objectId: 'secret2',
63
+ medicalLocationId: 'notSecret',
64
+ };
65
+ const createdV6 = yield apiV6.accessLogApi.createAccessLogWithUser(userV6, yield apiV6.accessLogApi.newInstance(userV6, patient, _.cloneDeep(accessLogData)));
66
+ const createdV7 = yield apiV7.accessLogApi.createAccessLogWithUser(userV7, yield apiV7.accessLogApi.newInstance(userV7, patient, _.cloneDeep(accessLogData)));
67
+ [
68
+ yield apiV6.accessLogApi.getAccessLogWithUser(userV6, createdV7.id),
69
+ yield apiV7.accessLogApi.getAccessLogWithUser(userV7, createdV6.id),
70
+ ].forEach((decrypted) => {
71
+ (0, chai_1.expect)(decrypted.medicalLocationId).to.equal(accessLogData.medicalLocationId);
72
+ (0, chai_1.expect)(decrypted.detail).to.equal(accessLogData.detail);
73
+ (0, chai_1.expect)(decrypted.objectId).to.equal(accessLogData.objectId);
74
+ });
75
+ const encryptedV6 = yield baseApi.getAccessLog(createdV6.id);
76
+ const encryptedV7 = yield baseApi.getAccessLog(createdV7.id);
77
+ [encryptedV6, encryptedV7].forEach((encrypted) => {
78
+ (0, chai_1.expect)(encrypted.detail).to.be.undefined;
79
+ (0, chai_1.expect)(encrypted.objectId).to.be.undefined;
80
+ (0, chai_1.expect)(encrypted.medicalLocationId).to.equal(accessLogData.medicalLocationId);
81
+ (0, chai_1.expect)(encrypted.encryptedSelf).to.not.be.undefined;
82
+ });
83
+ (0, chai_1.expect)(encryptedV6.encryptedSelf.length).to.equal(encryptedV7.encryptedSelf.length);
84
+ }));
85
+ it('A CalendarItem created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', () => __awaiter(void 0, void 0, void 0, function* () {
86
+ const baseApi = new icc_api_1.IccCalendarItemApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch);
87
+ const calendarItemData = {
88
+ patientId: apiV7.cryptoApi.primitives.randomUuid(),
89
+ details: 'Hello',
90
+ placeId: '123',
91
+ };
92
+ const createdV6 = yield apiV6.calendarItemApi.createCalendarItemWithHcParty(userV6, yield apiV6.calendarItemApi.newInstance(userV6, _.cloneDeep(calendarItemData)));
93
+ const createdV7 = yield apiV7.calendarItemApi.createCalendarItemWithHcParty(userV7, yield apiV7.calendarItemApi.newInstance(userV7, _.cloneDeep(calendarItemData)));
94
+ [
95
+ yield apiV6.calendarItemApi.getCalendarItemWithUser(userV6, createdV7.id),
96
+ yield apiV7.calendarItemApi.getCalendarItemWithUser(userV7, createdV6.id),
97
+ ].forEach((decrypted) => {
98
+ (0, chai_1.expect)(decrypted.patientId).to.equal(calendarItemData.patientId);
99
+ (0, chai_1.expect)(decrypted.details).to.equal(calendarItemData.details);
100
+ (0, chai_1.expect)(decrypted.placeId).to.equal(calendarItemData.placeId);
101
+ });
102
+ const encryptedV6 = yield baseApi.getCalendarItem(createdV6.id);
103
+ const encryptedV7 = yield baseApi.getCalendarItem(createdV7.id);
104
+ [encryptedV6, encryptedV7].forEach((encrypted) => {
105
+ (0, chai_1.expect)(encrypted.placeId).to.equal(calendarItemData.placeId);
106
+ (0, chai_1.expect)(encrypted.details).to.be.undefined;
107
+ (0, chai_1.expect)(encrypted.patientId).to.be.undefined;
108
+ (0, chai_1.expect)(encrypted.encryptedSelf).to.not.be.undefined;
109
+ });
110
+ (0, chai_1.expect)(encryptedV6.encryptedSelf.length).to.equal(encryptedV7.encryptedSelf.length);
111
+ }));
112
+ it('A Contact created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', () => __awaiter(void 0, void 0, void 0, function* () {
113
+ const baseApi = new icc_api_1.IccContactApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch);
114
+ const contactData = {
115
+ descr: 'secret',
116
+ location: 'notSecret',
117
+ services: [
118
+ {
119
+ id: 'flat',
120
+ label: 'notSecret1',
121
+ comment: 'notSecret2',
122
+ content: { fr: { stringValue: 'Salut' }, nl: { stringValue: 'Halo' } },
123
+ },
124
+ {
125
+ id: 'compound',
126
+ content: {
127
+ fr: {
128
+ compoundValue: [
129
+ {
130
+ id: 'nested1',
131
+ label: 'notSecret3',
132
+ comment: 'notSecret4',
133
+ content: { fr: { stringValue: 'A' } },
134
+ },
135
+ {
136
+ id: 'nested2',
137
+ label: 'notSecret5',
138
+ comment: 'notSecret6',
139
+ content: { fr: { stringValue: 'B' } },
140
+ },
141
+ {
142
+ id: 'nested3',
143
+ label: 'notSecret7',
144
+ comment: 'notSecret8',
145
+ content: {
146
+ fr: {
147
+ compoundValue: [
148
+ {
149
+ id: 'deeplyNested',
150
+ label: 'notSecret9',
151
+ comment: 'notSecret10',
152
+ content: { fr: { stringValue: 'C' } },
153
+ },
154
+ ],
155
+ },
156
+ },
157
+ },
158
+ ],
159
+ },
160
+ },
161
+ },
162
+ ],
163
+ };
164
+ const createdV6 = yield apiV6.contactApi.createContactWithUser(userV6, yield apiV6.contactApi.newInstance(userV6, patient, _.cloneDeep(contactData)));
165
+ const createdV7 = yield apiV7.contactApi.createContactWithUser(userV7, yield apiV7.contactApi.newInstance(userV7, patient, _.cloneDeep(contactData)));
166
+ [
167
+ yield apiV6.contactApi.getContactWithUser(userV6, createdV7.id),
168
+ yield apiV7.contactApi.getContactWithUser(userV7, createdV6.id),
169
+ ].forEach((decrypted) => {
170
+ (0, chai_1.expect)(decrypted.descr).to.equal(contactData.descr);
171
+ (0, chai_1.expect)(decrypted.location).to.equal(contactData.location);
172
+ const flat = decrypted.services.find((s) => s.id === 'flat');
173
+ (0, chai_1.expect)(flat.label).to.equal(contactData.services[0].label);
174
+ (0, chai_1.expect)(flat.comment).to.equal(contactData.services[0].comment);
175
+ (0, chai_1.expect)(flat.content).to.deep.equal(contactData.services[0].content);
176
+ const compound = decrypted.services.find((s) => s.id === 'compound');
177
+ (0, chai_1.expect)(compound.label).to.equal(contactData.services[1].label);
178
+ (0, chai_1.expect)(compound.comment).to.equal(contactData.services[1].comment);
179
+ const nested1 = compound.content.fr.compoundValue.find((s) => s.id === 'nested1');
180
+ (0, chai_1.expect)(nested1.label).to.equal(contactData.services[1].content.fr.compoundValue[0].label);
181
+ (0, chai_1.expect)(nested1.comment).to.equal(contactData.services[1].content.fr.compoundValue[0].comment);
182
+ (0, chai_1.expect)(nested1.content).to.deep.equal(contactData.services[1].content.fr.compoundValue[0].content);
183
+ const nested2 = compound.content.fr.compoundValue.find((s) => s.id === 'nested2');
184
+ (0, chai_1.expect)(nested2.label).to.equal(contactData.services[1].content.fr.compoundValue[1].label);
185
+ (0, chai_1.expect)(nested2.comment).to.equal(contactData.services[1].content.fr.compoundValue[1].comment);
186
+ (0, chai_1.expect)(nested2.content).to.deep.equal(contactData.services[1].content.fr.compoundValue[1].content);
187
+ const nested3 = compound.content.fr.compoundValue.find((s) => s.id === 'nested3');
188
+ (0, chai_1.expect)(nested3.label).to.equal(contactData.services[1].content.fr.compoundValue[2].label);
189
+ (0, chai_1.expect)(nested3.comment).to.equal(contactData.services[1].content.fr.compoundValue[2].comment);
190
+ const deeplyNested = nested3.content.fr.compoundValue.find((s) => s.id === 'deeplyNested');
191
+ (0, chai_1.expect)(deeplyNested.label).to.equal(contactData.services[1].content.fr.compoundValue[2].content.fr.compoundValue[0].label);
192
+ (0, chai_1.expect)(deeplyNested.comment).to.equal(contactData.services[1].content.fr.compoundValue[2].content.fr.compoundValue[0].comment);
193
+ (0, chai_1.expect)(deeplyNested.content).to.deep.equal(contactData.services[1].content.fr.compoundValue[2].content.fr.compoundValue[0].content);
194
+ });
195
+ const encryptedV6 = yield baseApi.getContact(createdV6.id);
196
+ const encryptedV7 = yield baseApi.getContact(createdV7.id);
197
+ [encryptedV6, encryptedV7].forEach((encrypted) => {
198
+ var _a, _b, _c, _d;
199
+ (0, chai_1.expect)(encrypted.descr).to.be.undefined;
200
+ (0, chai_1.expect)(encrypted.location).to.equal(contactData.location);
201
+ const flat = encrypted.services.find((s) => s.id === 'flat');
202
+ (0, chai_1.expect)(flat.label).to.equal(contactData.services[0].label);
203
+ (0, chai_1.expect)(flat.comment).to.equal(contactData.services[0].comment);
204
+ (0, chai_1.expect)(Object.keys((_a = flat.content) !== null && _a !== void 0 ? _a : {})).to.have.length(0);
205
+ (0, chai_1.expect)(flat.encryptedSelf).to.not.be.undefined;
206
+ const compound = encrypted.services.find((s) => s.id === 'compound');
207
+ (0, chai_1.expect)(compound.label).to.equal(contactData.services[1].label);
208
+ (0, chai_1.expect)(compound.comment).to.equal(contactData.services[1].comment);
209
+ (0, chai_1.expect)(compound.encryptedSelf).to.be.undefined;
210
+ const nested1 = compound.content.fr.compoundValue.find((s) => s.id === 'nested1');
211
+ (0, chai_1.expect)(nested1.label).to.equal(contactData.services[1].content.fr.compoundValue[0].label);
212
+ (0, chai_1.expect)(nested1.comment).to.equal(contactData.services[1].content.fr.compoundValue[0].comment);
213
+ (0, chai_1.expect)(Object.keys((_b = nested1.content) !== null && _b !== void 0 ? _b : {})).to.have.length(0);
214
+ (0, chai_1.expect)(nested1.encryptedSelf).to.not.be.undefined;
215
+ const nested2 = compound.content.fr.compoundValue.find((s) => s.id === 'nested2');
216
+ (0, chai_1.expect)(nested2.label).to.equal(contactData.services[1].content.fr.compoundValue[1].label);
217
+ (0, chai_1.expect)(nested2.comment).to.equal(contactData.services[1].content.fr.compoundValue[1].comment);
218
+ (0, chai_1.expect)(Object.keys((_c = nested2.content) !== null && _c !== void 0 ? _c : {})).to.have.length(0);
219
+ (0, chai_1.expect)(nested2.encryptedSelf).to.not.be.undefined;
220
+ const nested3 = compound.content.fr.compoundValue.find((s) => s.id === 'nested3');
221
+ (0, chai_1.expect)(nested3.label).to.equal(contactData.services[1].content.fr.compoundValue[2].label);
222
+ (0, chai_1.expect)(nested3.comment).to.equal(contactData.services[1].content.fr.compoundValue[2].comment);
223
+ (0, chai_1.expect)(nested3.encryptedSelf).to.be.undefined;
224
+ const deeplyNested = nested3.content.fr.compoundValue.find((s) => s.id === 'deeplyNested');
225
+ (0, chai_1.expect)(deeplyNested.label).to.equal(contactData.services[1].content.fr.compoundValue[2].content.fr.compoundValue[0].label);
226
+ (0, chai_1.expect)(deeplyNested.comment).to.equal(contactData.services[1].content.fr.compoundValue[2].content.fr.compoundValue[0].comment);
227
+ (0, chai_1.expect)(Object.keys((_d = deeplyNested.content) !== null && _d !== void 0 ? _d : {})).to.have.length(0);
228
+ (0, chai_1.expect)(deeplyNested.encryptedSelf).to.not.be.undefined;
229
+ });
230
+ (0, chai_1.expect)(encryptedV6.encryptedSelf.length).to.equal(encryptedV7.encryptedSelf.length);
231
+ }));
232
+ it('A HealthElement created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', () => __awaiter(void 0, void 0, void 0, function* () {
233
+ const baseApi = new icc_api_1.IccHelementApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch);
234
+ const healthElementData = {
235
+ note: 'secret',
236
+ descr: 'secret2',
237
+ idOpeningContact: 'notSecret',
238
+ };
239
+ const createdV6 = yield apiV6.healthcareElementApi.createHealthElementWithUser(userV6, yield apiV6.healthcareElementApi.newInstance(userV6, patient, _.cloneDeep(healthElementData)));
240
+ const createdV7 = yield apiV7.healthcareElementApi.createHealthElementWithUser(userV7, yield apiV7.healthcareElementApi.newInstance(userV7, patient, _.cloneDeep(healthElementData)));
241
+ [
242
+ yield apiV6.healthcareElementApi.getHealthElementWithUser(userV6, createdV7.id),
243
+ yield apiV7.healthcareElementApi.getHealthElementWithUser(userV7, createdV6.id),
244
+ ].forEach((decrypted) => {
245
+ (0, chai_1.expect)(decrypted.idOpeningContact).to.equal(healthElementData.idOpeningContact);
246
+ (0, chai_1.expect)(decrypted.note).to.equal(healthElementData.note);
247
+ (0, chai_1.expect)(decrypted.descr).to.equal(healthElementData.descr);
248
+ });
249
+ const encryptedV6 = yield baseApi.getHealthElement(createdV6.id);
250
+ const encryptedV7 = yield baseApi.getHealthElement(createdV7.id);
251
+ [encryptedV6, encryptedV7].forEach((encrypted) => {
252
+ (0, chai_1.expect)(encrypted.idOpeningContact).to.equal(healthElementData.idOpeningContact);
253
+ (0, chai_1.expect)(encrypted.note).to.be.undefined;
254
+ (0, chai_1.expect)(encrypted.descr).to.be.undefined;
255
+ (0, chai_1.expect)(encrypted.encryptedSelf).to.not.be.undefined;
256
+ });
257
+ (0, chai_1.expect)(encryptedV6.encryptedSelf.length).to.equal(encryptedV7.encryptedSelf.length);
258
+ }));
259
+ it('A MaintenanceTask created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', () => __awaiter(void 0, void 0, void 0, function* () {
260
+ const baseApi = new IccMaintenanceTaskApi_1.IccMaintenanceTaskApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch);
261
+ const maintenanceTaskData = {
262
+ taskType: 'notSecret',
263
+ properties: [
264
+ { id: 'test1', typedValue: { type: 'string', value: 'secret1' } },
265
+ { id: 'test2', typedValue: { type: 'string', value: 'secret2' } },
266
+ ],
267
+ };
268
+ const createdV6 = yield apiV6.maintenanceTaskApi.createMaintenanceTaskWithUser(userV6, yield apiV6.maintenanceTaskApi.newInstance(userV6, _.cloneDeep(maintenanceTaskData)));
269
+ const createdV7 = yield apiV7.maintenanceTaskApi.createMaintenanceTaskWithUser(userV7, yield apiV7.maintenanceTaskApi.newInstance(userV7, _.cloneDeep(maintenanceTaskData)));
270
+ [
271
+ yield apiV6.maintenanceTaskApi.getMaintenanceTaskWithUser(userV6, createdV7.id),
272
+ yield apiV7.maintenanceTaskApi.getMaintenanceTaskWithUser(userV7, createdV6.id),
273
+ ].forEach((decrypted) => {
274
+ (0, chai_1.expect)(decrypted.taskType).to.equal(maintenanceTaskData.taskType);
275
+ ['test1', 'test2'].forEach((propId) => {
276
+ const prop = decrypted.properties.find((p) => p.id === propId);
277
+ const ogProp = maintenanceTaskData.properties.find((p) => p.id === propId);
278
+ (0, chai_1.expect)(prop).to.not.be.undefined;
279
+ (0, chai_1.expect)(prop.typedValue).to.deep.equal(ogProp.typedValue);
280
+ });
281
+ });
282
+ const encryptedV6 = yield baseApi.getMaintenanceTask(createdV6.id);
283
+ const encryptedV7 = yield baseApi.getMaintenanceTask(createdV7.id);
284
+ [encryptedV6, encryptedV7].forEach((encrypted) => {
285
+ var _a;
286
+ (0, chai_1.expect)(encrypted.taskType).to.equal(maintenanceTaskData.taskType);
287
+ (0, chai_1.expect)((_a = encrypted.properties) !== null && _a !== void 0 ? _a : []).to.have.length(0);
288
+ (0, chai_1.expect)(encrypted.encryptedSelf).to.not.be.undefined;
289
+ });
290
+ (0, chai_1.expect)(encryptedV6.encryptedSelf.length).to.equal(encryptedV7.encryptedSelf.length);
291
+ }));
292
+ it('A Patient created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', () => __awaiter(void 0, void 0, void 0, function* () {
293
+ const baseApi = new icc_api_1.IccPatientApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch);
294
+ const patientData = {
295
+ firstName: 'John',
296
+ lastName: 'Doe',
297
+ note: 'This is a note',
298
+ properties: [
299
+ { id: 'test1', typedValue: { type: 'string', value: 'test1' } },
300
+ { id: 'test2', typedValue: { type: 'string', value: 'test2' } },
301
+ ],
302
+ };
303
+ const createdV6 = yield apiV6.patientApi.createPatientWithUser(userV6, yield apiV6.patientApi.newInstance(userV6, _.cloneDeep(patientData)));
304
+ const createdV7 = yield apiV7.patientApi.createPatientWithUser(userV7, yield apiV7.patientApi.newInstance(userV7, _.cloneDeep(patientData)));
305
+ [
306
+ yield apiV6.patientApi.getPatientWithUser(userV6, createdV7.id),
307
+ yield apiV7.patientApi.getPatientWithUser(userV7, createdV6.id),
308
+ ].forEach((decrypted) => {
309
+ var _a;
310
+ (0, chai_1.expect)(decrypted.firstName).to.equal(patientData.firstName);
311
+ (0, chai_1.expect)(decrypted.lastName).to.equal(patientData.lastName);
312
+ (0, chai_1.expect)(decrypted.note).to.equal(patientData.note);
313
+ (0, chai_1.expect)((_a = decrypted.properties) !== null && _a !== void 0 ? _a : []).to.have.length(2);
314
+ ['test1', 'test2'].forEach((propId) => {
315
+ const prop = decrypted.properties.find((p) => p.id === propId);
316
+ const ogProp = patientData.properties.find((p) => p.id === propId);
317
+ (0, chai_1.expect)(prop).to.not.be.undefined;
318
+ (0, chai_1.expect)(prop.typedValue).to.deep.equal(ogProp.typedValue);
319
+ });
320
+ });
321
+ const encryptedV6 = yield baseApi.getPatient(createdV6.id);
322
+ const encryptedV7 = yield baseApi.getPatient(createdV7.id);
323
+ [encryptedV6, encryptedV7].forEach((encrypted) => {
324
+ var _a;
325
+ (0, chai_1.expect)(encrypted.firstName).to.equal(patientData.firstName);
326
+ (0, chai_1.expect)(encrypted.lastName).to.equal(patientData.lastName);
327
+ (0, chai_1.expect)(encrypted.note).to.be.undefined;
328
+ (0, chai_1.expect)(encrypted.encryptedSelf).to.not.be.undefined;
329
+ (0, chai_1.expect)((_a = encrypted.properties) !== null && _a !== void 0 ? _a : []).to.have.length(2);
330
+ ['test1', 'test2'].forEach((propId) => {
331
+ const prop = encrypted.properties.find((p) => p.id === propId);
332
+ (0, chai_1.expect)(prop).to.not.be.undefined;
333
+ (0, chai_1.expect)(prop.typedValue).to.be.undefined;
334
+ (0, chai_1.expect)(prop.encryptedSelf).to.not.be.undefined;
335
+ });
336
+ });
337
+ (0, chai_1.expect)(encryptedV6.encryptedSelf.length).to.equal(encryptedV7.encryptedSelf.length);
338
+ ['test1', 'test2'].forEach((propId) => {
339
+ (0, chai_1.expect)(encryptedV6.properties.find((p) => p.id === propId).encryptedSelf.length).to.equal(encryptedV7.properties.find((p) => p.id === propId).encryptedSelf.length);
340
+ });
341
+ }));
342
+ }));
343
+ //# sourceMappingURL=data-compatibility-test-7to6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-compatibility-test-7to6.js","sourceRoot":"","sources":["../../../test/icc-x-api/data-compatibility-test-7to6.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mDAAmE;AACnE,iCAA8B;AAC9B,oDAAyG;AACzG,4BAA2B;AAC3B,wCAAmH;AACnH,+CAAkD;AAClD,mCAAkC;AAClC,sDAAkE;AAClE,wEAAoE;AACpE,2CAA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,SAAS,CAAC,UAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAA;gBAC/D,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAA;gBAChC,IAAA,aAAM,EAAC,IAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAA;gBACxC,IAAA,aAAM,EAAC,IAAK,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAA;YACjD,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAA,aAAM,EAAC,WAAW,CAAC,aAAc,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,aAAc,CAAC,MAAM,CAAC,CACpF;QAAA,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACrC,IAAA,aAAM,EAAC,WAAW,CAAC,UAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAE,CAAC,aAAc,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAC1F,WAAW,CAAC,UAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAE,CAAC,aAAc,CAAC,MAAM,CAC5E,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAA,CAAC,CAAA","sourcesContent":["import { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { before } from 'mocha'\nimport { getEnvironmentInitializer, hcp1Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport * as _ from 'lodash'\nimport { Api as initApiV6, Apis as ApisV6, IccPatientXApi as IccPatientXApiV6, User as UserV6 } from '@icure/apiV6'\nimport { hex2ua, IcureApi } from '../../icc-x-api'\nimport { webcrypto } from 'crypto'\nimport { TestKeyStorage, TestStorage } from '../utils/TestStorage'\nimport { TestCryptoStrategies } from '../utils/TestCryptoStrategies'\nimport { IccAccesslogApi, IccCalendarItemApi, IccContactApi, IccHelementApi, IccPatientApi } from '../../icc-api'\nimport { expect } from 'chai'\nimport { User } from '../../icc-api/model/User'\nimport 'isomorphic-fetch'\nimport { IccMaintenanceTaskApi } from '../../icc-api/api/IccMaintenanceTaskApi'\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\nlet apiV6: ApisV6\nlet apiV7: IcureApi\nlet userV6: UserV6\nlet userV7: User\nlet patient: any\n\ndescribe('iCure API v6 and v7 (current) should be fully data compatible', async () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n apiV6 = await initApiV6(\n env.iCureUrl + '/rest/v1',\n env.dataOwnerDetails[hcp1Username].user,\n env.dataOwnerDetails[hcp1Username].password,\n webcrypto as any,\n fetch,\n false,\n false,\n new TestStorage(),\n new TestKeyStorage()\n )\n await apiV6.cryptoApi.loadKeyPairsAsTextInBrowserLocalStorage(\n env.dataOwnerDetails[hcp1Username].dataOwnerId,\n hex2ua(env.dataOwnerDetails[hcp1Username].privateKey)\n )\n apiV6.patientApi = new IccPatientXApiV6( // Want to override encryption keys\n env.iCureUrl + '/rest/v1',\n {},\n apiV6.cryptoApi,\n apiV6.contactApi,\n apiV6.formApi,\n apiV6.healthcareElementApi,\n apiV6.invoiceApi,\n apiV6.documentApi,\n apiV6.healthcarePartyApi,\n apiV6.classificationApi,\n apiV6.dataOwnerApi,\n apiV6.calendarItemApi,\n ['note', 'properties.*.typedValue'],\n apiV6.authApi.authenticationProvider,\n fetch\n )\n apiV7 = await IcureApi.initialise(\n env.iCureUrl,\n { username: env.dataOwnerDetails[hcp1Username].user, password: env.dataOwnerDetails[hcp1Username].password },\n new TestCryptoStrategies({\n publicKey: await apiV6.cryptoApi.RSA.importKey('spki', hex2ua(env.dataOwnerDetails[hcp1Username].publicKey), ['encrypt']),\n privateKey: await apiV6.cryptoApi.RSA.importKey('pkcs8', hex2ua(env.dataOwnerDetails[hcp1Username].privateKey), ['decrypt']),\n }),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n encryptedFieldsConfig: {\n patient: ['note', 'properties[].typedValue'],\n service: [], // For full v6-v7 compatibility service should not have any encrypted fields apart from implicit 'content'\n },\n }\n )\n userV6 = await apiV6.userApi.getCurrentUser()\n userV7 = await apiV7.userApi.getCurrentUser()\n patient = await apiV6.patientApi.createPatientWithUser(userV6, await apiV6.patientApi.newInstance(userV6, { firstName: 'Joe', lastName: 'Dhon' }))\n })\n\n it('An AccessLog created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', async () => {\n const baseApi = new IccAccesslogApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch)\n const accessLogData = {\n detail: 'secret',\n objectId: 'secret2',\n medicalLocationId: 'notSecret',\n }\n const createdV6 = await apiV6.accessLogApi.createAccessLogWithUser(\n userV6,\n await apiV6.accessLogApi.newInstance(userV6, patient, _.cloneDeep(accessLogData))\n )\n const createdV7 = await apiV7.accessLogApi.createAccessLogWithUser(\n userV7,\n await apiV7.accessLogApi.newInstance(userV7, patient, _.cloneDeep(accessLogData))\n )\n ;[\n await apiV6.accessLogApi.getAccessLogWithUser(userV6, createdV7.id), // Read V7 from V6,\n await apiV7.accessLogApi.getAccessLogWithUser(userV7, createdV6.id), // Read V6 from V7\n ].forEach((decrypted) => {\n expect(decrypted.medicalLocationId).to.equal(accessLogData.medicalLocationId)\n expect(decrypted.detail).to.equal(accessLogData.detail)\n expect(decrypted.objectId).to.equal(accessLogData.objectId)\n })\n const encryptedV6 = await baseApi.getAccessLog(createdV6.id)\n const encryptedV7 = await baseApi.getAccessLog(createdV7.id)\n ;[encryptedV6, encryptedV7].forEach((encrypted) => {\n expect(encrypted.detail).to.be.undefined\n expect(encrypted.objectId).to.be.undefined\n expect(encrypted.medicalLocationId).to.equal(accessLogData.medicalLocationId)\n expect(encrypted.encryptedSelf).to.not.be.undefined\n })\n expect(encryptedV6.encryptedSelf!.length).to.equal(encryptedV7.encryptedSelf!.length)\n })\n\n it('A CalendarItem created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', async () => {\n const baseApi = new IccCalendarItemApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch)\n const calendarItemData = {\n patientId: apiV7.cryptoApi.primitives.randomUuid(),\n details: 'Hello',\n placeId: '123',\n }\n const createdV6 = await apiV6.calendarItemApi.createCalendarItemWithHcParty(\n userV6,\n await apiV6.calendarItemApi.newInstance(userV6, _.cloneDeep(calendarItemData))\n )\n const createdV7 = await apiV7.calendarItemApi.createCalendarItemWithHcParty(\n userV7,\n await apiV7.calendarItemApi.newInstance(userV7, _.cloneDeep(calendarItemData))\n )\n ;[\n await apiV6.calendarItemApi.getCalendarItemWithUser(userV6, createdV7.id), // Read V7 from V6,\n await apiV7.calendarItemApi.getCalendarItemWithUser(userV7, createdV6.id), // Read V6 from V7\n ].forEach((decrypted) => {\n expect(decrypted.patientId).to.equal(calendarItemData.patientId)\n expect(decrypted.details).to.equal(calendarItemData.details)\n expect(decrypted.placeId).to.equal(calendarItemData.placeId)\n })\n const encryptedV6 = await baseApi.getCalendarItem(createdV6.id)\n const encryptedV7 = await baseApi.getCalendarItem(createdV7.id)\n ;[encryptedV6, encryptedV7].forEach((encrypted) => {\n expect(encrypted.placeId).to.equal(calendarItemData.placeId)\n expect(encrypted.details).to.be.undefined\n expect(encrypted.patientId).to.be.undefined\n expect(encrypted.encryptedSelf).to.not.be.undefined\n })\n expect(encryptedV6.encryptedSelf!.length).to.equal(encryptedV7.encryptedSelf!.length)\n })\n\n it('A Contact created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', async () => {\n const baseApi = new IccContactApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch)\n const contactData = {\n descr: 'secret',\n location: 'notSecret',\n services: [\n {\n id: 'flat',\n label: 'notSecret1',\n comment: 'notSecret2',\n content: { fr: { stringValue: 'Salut' }, nl: { stringValue: 'Halo' } },\n },\n {\n id: 'compound',\n content: {\n fr: {\n compoundValue: [\n {\n id: 'nested1',\n label: 'notSecret3',\n comment: 'notSecret4',\n content: { fr: { stringValue: 'A' } },\n },\n {\n id: 'nested2',\n label: 'notSecret5',\n comment: 'notSecret6',\n content: { fr: { stringValue: 'B' } },\n },\n {\n id: 'nested3',\n label: 'notSecret7',\n comment: 'notSecret8',\n content: {\n fr: {\n compoundValue: [\n {\n id: 'deeplyNested',\n label: 'notSecret9',\n comment: 'notSecret10',\n content: { fr: { stringValue: 'C' } },\n },\n ],\n },\n },\n },\n ],\n },\n },\n },\n ],\n }\n const createdV6 = await apiV6.contactApi.createContactWithUser(\n userV6,\n await apiV6.contactApi.newInstance(userV6, patient, _.cloneDeep(contactData))\n )\n const createdV7 = await apiV7.contactApi.createContactWithUser(\n userV7,\n await apiV7.contactApi.newInstance(userV7, patient, _.cloneDeep(contactData))\n )\n ;[\n await apiV6.contactApi.getContactWithUser(userV6, createdV7!.id!), // Read V7 from V6,\n await apiV7.contactApi.getContactWithUser(userV7, createdV6.id), // Read V6 from V7\n ].forEach((decrypted: any) => {\n expect(decrypted.descr).to.equal(contactData.descr)\n expect(decrypted.location).to.equal(contactData.location)\n const flat = decrypted.services.find((s: any) => s.id === 'flat')\n expect(flat.label).to.equal(contactData.services[0].label)\n expect(flat.comment).to.equal(contactData.services[0].comment)\n expect(flat.content).to.deep.equal(contactData.services[0].content)\n const compound = decrypted.services.find((s: any) => s.id === 'compound')\n expect(compound.label).to.equal(contactData.services[1].label)\n expect(compound.comment).to.equal(contactData.services[1].comment)\n const nested1 = compound.content.fr.compoundValue.find((s: any) => s.id === 'nested1')\n expect(nested1.label).to.equal(contactData.services[1].content.fr.compoundValue![0].label)\n expect(nested1.comment).to.equal(contactData.services[1].content.fr.compoundValue![0].comment)\n expect(nested1.content).to.deep.equal(contactData.services[1].content.fr.compoundValue![0].content)\n const nested2 = compound.content.fr.compoundValue.find((s: any) => s.id === 'nested2')\n expect(nested2.label).to.equal(contactData.services[1].content.fr.compoundValue![1].label)\n expect(nested2.comment).to.equal(contactData.services[1].content.fr.compoundValue![1].comment)\n expect(nested2.content).to.deep.equal(contactData.services[1].content.fr.compoundValue![1].content)\n const nested3 = compound.content.fr.compoundValue.find((s: any) => s.id === 'nested3')\n expect(nested3.label).to.equal(contactData.services[1].content.fr.compoundValue![2].label)\n expect(nested3.comment).to.equal(contactData.services[1].content.fr.compoundValue![2].comment)\n const deeplyNested = nested3.content.fr.compoundValue.find((s: any) => s.id === 'deeplyNested')\n expect(deeplyNested.label).to.equal(contactData.services[1].content.fr.compoundValue![2].content.fr.compoundValue![0].label)\n expect(deeplyNested.comment).to.equal(contactData.services[1].content.fr.compoundValue![2].content.fr.compoundValue![0].comment)\n expect(deeplyNested.content).to.deep.equal(contactData.services[1].content.fr.compoundValue![2].content.fr.compoundValue![0].content)\n })\n const encryptedV6 = await baseApi.getContact(createdV6.id)\n const encryptedV7 = await baseApi.getContact(createdV7!.id!)\n ;[encryptedV6, encryptedV7].forEach((encrypted: any) => {\n expect(encrypted.descr).to.be.undefined\n expect(encrypted.location).to.equal(contactData.location)\n const flat = encrypted.services!.find((s: any) => s.id === 'flat')!\n expect(flat.label).to.equal(contactData.services[0].label)\n expect(flat.comment).to.equal(contactData.services[0].comment)\n expect(Object.keys(flat.content ?? {})).to.have.length(0)\n expect(flat.encryptedSelf).to.not.be.undefined\n const compound = encrypted.services!.find((s: any) => s.id === 'compound')!\n expect(compound.label).to.equal(contactData.services[1].label)\n expect(compound.comment).to.equal(contactData.services[1].comment)\n expect(compound.encryptedSelf).to.be.undefined\n const nested1 = compound.content!.fr.compoundValue!.find((s: any) => s.id === 'nested1')!\n expect(nested1.label).to.equal(contactData.services[1].content.fr.compoundValue![0].label)\n expect(nested1.comment).to.equal(contactData.services[1].content.fr.compoundValue![0].comment)\n expect(Object.keys(nested1.content ?? {})).to.have.length(0)\n expect(nested1.encryptedSelf).to.not.be.undefined\n const nested2 = compound.content!.fr.compoundValue!.find((s: any) => s.id === 'nested2')!\n expect(nested2.label).to.equal(contactData.services[1].content.fr.compoundValue![1].label)\n expect(nested2.comment).to.equal(contactData.services[1].content.fr.compoundValue![1].comment)\n expect(Object.keys(nested2.content ?? {})).to.have.length(0)\n expect(nested2.encryptedSelf).to.not.be.undefined\n const nested3 = compound.content!.fr.compoundValue!.find((s: any) => s.id === 'nested3')!\n expect(nested3.label).to.equal(contactData.services[1].content.fr.compoundValue![2].label)\n expect(nested3.comment).to.equal(contactData.services[1].content.fr.compoundValue![2].comment)\n expect(nested3.encryptedSelf).to.be.undefined\n const deeplyNested = nested3.content!.fr.compoundValue!.find((s: any) => s.id === 'deeplyNested')!\n expect(deeplyNested.label).to.equal(contactData.services[1].content.fr.compoundValue![2].content.fr.compoundValue![0].label)\n expect(deeplyNested.comment).to.equal(contactData.services[1].content.fr.compoundValue![2].content.fr.compoundValue![0].comment)\n expect(Object.keys(deeplyNested.content ?? {})).to.have.length(0)\n expect(deeplyNested.encryptedSelf).to.not.be.undefined\n })\n expect(encryptedV6.encryptedSelf!.length).to.equal(encryptedV7.encryptedSelf!.length)\n })\n\n it('A HealthElement created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', async () => {\n const baseApi = new IccHelementApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch)\n const healthElementData = {\n note: 'secret',\n descr: 'secret2',\n idOpeningContact: 'notSecret',\n }\n const createdV6 = await apiV6.healthcareElementApi.createHealthElementWithUser(\n userV6,\n await apiV6.healthcareElementApi.newInstance(userV6, patient, _.cloneDeep(healthElementData))\n )\n const createdV7 = await apiV7.healthcareElementApi.createHealthElementWithUser(\n userV7,\n await apiV7.healthcareElementApi.newInstance(userV7, patient, _.cloneDeep(healthElementData))\n )\n ;[\n await apiV6.healthcareElementApi.getHealthElementWithUser(userV6, createdV7.id), // Read V7 from V6,\n await apiV7.healthcareElementApi.getHealthElementWithUser(userV7, createdV6.id), // Read V6 from V7\n ].forEach((decrypted) => {\n expect(decrypted.idOpeningContact).to.equal(healthElementData.idOpeningContact)\n expect(decrypted.note).to.equal(healthElementData.note)\n expect(decrypted.descr).to.equal(healthElementData.descr)\n })\n const encryptedV6 = await baseApi.getHealthElement(createdV6.id)\n const encryptedV7 = await baseApi.getHealthElement(createdV7.id)\n ;[encryptedV6, encryptedV7].forEach((encrypted) => {\n expect(encrypted.idOpeningContact).to.equal(healthElementData.idOpeningContact)\n expect(encrypted.note).to.be.undefined\n expect(encrypted.descr).to.be.undefined\n expect(encrypted.encryptedSelf).to.not.be.undefined\n })\n expect(encryptedV6.encryptedSelf!.length).to.equal(encryptedV7.encryptedSelf!.length)\n })\n\n it('A MaintenanceTask created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', async () => {\n const baseApi = new IccMaintenanceTaskApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch)\n const maintenanceTaskData = {\n taskType: 'notSecret',\n properties: [\n { id: 'test1', typedValue: { type: 'string', value: 'secret1' } },\n { id: 'test2', typedValue: { type: 'string', value: 'secret2' } },\n ],\n }\n const createdV6 = await apiV6.maintenanceTaskApi.createMaintenanceTaskWithUser(\n userV6,\n await apiV6.maintenanceTaskApi.newInstance(userV6, _.cloneDeep(maintenanceTaskData))\n )\n const createdV7 = await apiV7.maintenanceTaskApi.createMaintenanceTaskWithUser(\n userV7,\n await apiV7.maintenanceTaskApi.newInstance(userV7, _.cloneDeep(maintenanceTaskData))\n )\n ;[\n await apiV6.maintenanceTaskApi.getMaintenanceTaskWithUser(userV6, createdV7!.id!), // Read V7 from V6,\n await apiV7.maintenanceTaskApi.getMaintenanceTaskWithUser(userV7, createdV6.id), // Read V6 from V7\n ].forEach((decrypted) => {\n expect(decrypted.taskType).to.equal(maintenanceTaskData.taskType)\n ;['test1', 'test2'].forEach((propId) => {\n const prop = decrypted.properties!.find((p: any) => p.id === propId)\n const ogProp = maintenanceTaskData.properties!.find((p) => p.id === propId)\n expect(prop).to.not.be.undefined\n expect(prop!.typedValue).to.deep.equal(ogProp!.typedValue)\n })\n })\n const encryptedV6 = await baseApi.getMaintenanceTask(createdV6.id)\n const encryptedV7 = await baseApi.getMaintenanceTask(createdV7!.id!)\n ;[encryptedV6, encryptedV7].forEach((encrypted) => {\n expect(encrypted.taskType).to.equal(maintenanceTaskData.taskType)\n expect(encrypted.properties ?? []).to.have.length(0)\n expect(encrypted.encryptedSelf).to.not.be.undefined\n })\n expect(encryptedV6.encryptedSelf!.length).to.equal(encryptedV7.encryptedSelf!.length)\n })\n\n it('A Patient created from V6 should be readable from v7 and vice versa, and the structure of their encrypted data should be equivalent.', async () => {\n const baseApi = new IccPatientApi(env.iCureUrl, {}, apiV7.authApi.authenticationProvider, fetch)\n const patientData = {\n firstName: 'John',\n lastName: 'Doe',\n note: 'This is a note',\n properties: [\n { id: 'test1', typedValue: { type: 'string', value: 'test1' } },\n { id: 'test2', typedValue: { type: 'string', value: 'test2' } },\n ],\n }\n const createdV6 = await apiV6.patientApi.createPatientWithUser(userV6, await apiV6.patientApi.newInstance(userV6, _.cloneDeep(patientData)))\n const createdV7 = await apiV7.patientApi.createPatientWithUser(userV7, await apiV7.patientApi.newInstance(userV7, _.cloneDeep(patientData)))\n ;[\n await apiV6.patientApi.getPatientWithUser(userV6, createdV7.id), // Read V7 from V6,\n await apiV7.patientApi.getPatientWithUser(userV7, createdV6.id), // Read V6 from V7\n ].forEach((decrypted) => {\n expect(decrypted.firstName).to.equal(patientData.firstName)\n expect(decrypted.lastName).to.equal(patientData.lastName)\n expect(decrypted.note).to.equal(patientData.note)\n expect(decrypted.properties ?? []).to.have.length(2)\n ;['test1', 'test2'].forEach((propId) => {\n const prop = decrypted.properties!.find((p: any) => p.id === propId)\n const ogProp = patientData.properties!.find((p) => p.id === propId)\n expect(prop).to.not.be.undefined\n expect(prop!.typedValue).to.deep.equal(ogProp!.typedValue)\n })\n })\n const encryptedV6 = await baseApi.getPatient(createdV6.id)\n const encryptedV7 = await baseApi.getPatient(createdV7.id)\n ;[encryptedV6, encryptedV7].forEach((encrypted) => {\n expect(encrypted.firstName).to.equal(patientData.firstName)\n expect(encrypted.lastName).to.equal(patientData.lastName)\n expect(encrypted.note).to.be.undefined\n expect(encrypted.encryptedSelf).to.not.be.undefined\n expect(encrypted.properties ?? []).to.have.length(2)\n ;['test1', 'test2'].forEach((propId) => {\n const prop = encrypted.properties!.find((p) => p.id === propId)\n expect(prop).to.not.be.undefined\n expect(prop!.typedValue).to.be.undefined\n expect(prop!.encryptedSelf).to.not.be.undefined\n })\n })\n expect(encryptedV6.encryptedSelf!.length).to.equal(encryptedV7.encryptedSelf!.length)\n ;['test1', 'test2'].forEach((propId) => {\n expect(encryptedV6.properties!.find((p) => p.id === propId)!.encryptedSelf!.length).to.equal(\n encryptedV7.properties!.find((p) => p.id === propId)!.encryptedSelf!.length\n )\n })\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ require("isomorphic-fetch");
13
+ const test_utils_1 = require("../utils/test_utils");
14
+ const mocha_1 = require("mocha");
15
+ const icc_x_api_1 = require("../../icc-x-api");
16
+ var initApi = test_utils_1.TestUtils.initApi;
17
+ const chai_1 = require("chai");
18
+ const types_1 = require("@icure/test-setup/types");
19
+ (0, test_utils_1.setLocalStorage)(fetch);
20
+ let env;
21
+ let apis;
22
+ let user;
23
+ const entityWithAttachmentApis = {
24
+ docMainAttachment: (apis, currentUser) => ({
25
+ createEntity() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return apis.documentApi.createDocument(yield apis.documentApi.newInstance(currentUser));
28
+ });
29
+ },
30
+ encryptAndSetAttachment(entity, attachment) {
31
+ return apis.documentApi.encryptAndSetDocumentAttachment(entity, attachment);
32
+ },
33
+ getAndDecryptAttachment(entity, validator) {
34
+ return apis.documentApi.getAndDecryptDocumentAttachment(entity, validator);
35
+ },
36
+ getEncryptedAttachment(entity) {
37
+ return apis.documentApi.getDocumentAttachment(entity.id, 'unused');
38
+ },
39
+ }),
40
+ docSecondaryAttachment: (apis, currentUser) => ({
41
+ createEntity() {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ return apis.documentApi.createDocument(yield apis.documentApi.newInstance(currentUser));
44
+ });
45
+ },
46
+ encryptAndSetAttachment(entity, attachment) {
47
+ return apis.documentApi.encryptAndSetSecondaryDocumentAttachment(entity, 'secondary', attachment);
48
+ },
49
+ getAndDecryptAttachment(entity, validator) {
50
+ return apis.documentApi.getAndDecryptSecondaryDocumentAttachment(entity, 'secondary', validator);
51
+ },
52
+ getEncryptedAttachment(entity) {
53
+ return apis.documentApi.getSecondaryAttachment(entity.id, 'secondary');
54
+ },
55
+ }),
56
+ receipt: (apis, currentUser) => ({
57
+ createEntity() {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ return apis.receiptApi.createReceipt(yield apis.receiptApi.newInstance(currentUser, {}));
60
+ });
61
+ },
62
+ encryptAndSetAttachment(entity, attachment) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ return apis.receiptApi.encryptAndSetReceiptAttachment(entity, 'tack', attachment);
65
+ });
66
+ },
67
+ getAndDecryptAttachment(entity, validator) {
68
+ var _a;
69
+ return apis.receiptApi.getAndDecryptReceiptAttachment(entity, ((_a = entity.attachmentIds) !== null && _a !== void 0 ? _a : {})['tack'], validator);
70
+ },
71
+ getEncryptedAttachment(entity) {
72
+ var _a;
73
+ return apis.receiptApi.getReceiptAttachment(entity.id, ((_a = entity.attachmentIds) !== null && _a !== void 0 ? _a : {})['tack'], '');
74
+ },
75
+ }),
76
+ };
77
+ (0, mocha_1.before)(function () {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ this.timeout(600000);
80
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
81
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
82
+ for (const [a, b] of Object.entries(env.dataOwnerDetails)) {
83
+ console.log(a);
84
+ console.log(b.password);
85
+ console.log('');
86
+ }
87
+ apis = yield initApi(env, test_utils_1.hcp1Username);
88
+ user = yield apis.userApi.getCurrentUser();
89
+ });
90
+ });
91
+ describe('Entity attachment update methods', function () {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ Object.entries(entityWithAttachmentApis).forEach(([type, attachmentApiInitialiser]) => {
94
+ it(`should automatically encrypt and decrypt attachments (${type})`, () => __awaiter(this, void 0, void 0, function* () {
95
+ const attachmentApi = attachmentApiInitialiser(apis, user);
96
+ const entity = yield attachmentApi.createEntity();
97
+ console.log(`entity id ${entity.id}`);
98
+ const attachmentContent = 'This is some secret attachment';
99
+ const entityWithEncrypted = yield attachmentApi.encryptAndSetAttachment(entity, (0, icc_x_api_1.utf8_2ua)(attachmentContent));
100
+ const decryptedAttachment = yield attachmentApi.getAndDecryptAttachment(entityWithEncrypted, (d) => __awaiter(this, void 0, void 0, function* () {
101
+ try {
102
+ return (0, icc_x_api_1.ua2utf8)(d) === attachmentContent;
103
+ }
104
+ catch (_c) {
105
+ return false;
106
+ }
107
+ }));
108
+ (0, chai_1.expect)((0, icc_x_api_1.ua2utf8)(decryptedAttachment)).to.equal(attachmentContent);
109
+ const encryptedAttachment = yield attachmentApi.getEncryptedAttachment(entityWithEncrypted);
110
+ let conversionFailed;
111
+ try {
112
+ conversionFailed = (0, icc_x_api_1.ua2utf8)(encryptedAttachment) !== attachmentContent;
113
+ }
114
+ catch (_a) {
115
+ conversionFailed = true;
116
+ }
117
+ (0, chai_1.expect)(conversionFailed).to.be.true;
118
+ const attachmentContent2 = 'This is an updated secret attachment';
119
+ const entityWithEncrypted2 = yield attachmentApi.encryptAndSetAttachment(entityWithEncrypted, (0, icc_x_api_1.utf8_2ua)(attachmentContent2));
120
+ const decryptedAttachment2 = yield attachmentApi.getAndDecryptAttachment(entityWithEncrypted2, (d) => __awaiter(this, void 0, void 0, function* () {
121
+ try {
122
+ return (0, icc_x_api_1.ua2utf8)(d) === attachmentContent2;
123
+ }
124
+ catch (_d) {
125
+ return false;
126
+ }
127
+ }));
128
+ (0, chai_1.expect)((0, icc_x_api_1.ua2utf8)(decryptedAttachment2)).to.equal(attachmentContent2);
129
+ const encryptedAttachment2 = yield attachmentApi.getEncryptedAttachment(entityWithEncrypted2);
130
+ let conversionFailed2;
131
+ try {
132
+ conversionFailed2 = (0, icc_x_api_1.ua2utf8)(encryptedAttachment2) !== attachmentContent2;
133
+ }
134
+ catch (_b) {
135
+ conversionFailed2 = true;
136
+ }
137
+ (0, chai_1.expect)(conversionFailed2).to.be.true;
138
+ }));
139
+ });
140
+ });
141
+ });
142
+ //# sourceMappingURL=entity-with-attachments-api-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-with-attachments-api-test.js","sourceRoot":"","sources":["../../../test/icc-x-api/entity-with-attachments-api-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAyG;AACzG,iCAA8B;AAG9B,+CAAyD;AACzD,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,+BAA6B;AAC7B,mDAAmE;AAEnE,IAAA,4BAA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AAA;iBACzB;gBACD,IAAA,aAAM,EAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAA;YACtC,CAAC,CAAA,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { getEnvironmentInitializer, hcp1Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport * as models from '../../icc-api/model/models'\nimport { User } from '../../icc-api/model/User'\nimport { Apis, ua2utf8, utf8_2ua } from '../../icc-x-api'\nimport initApi = TestUtils.initApi\nimport { expect } from 'chai'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\nsetLocalStorage(fetch)\nlet env: TestVars\nlet apis: Apis\nlet user: User\n\ninterface EntityWithAttachmentApi<T> {\n createEntity(): Promise<T>\n encryptAndSetAttachment(entity: T, attachment: ArrayBuffer | Uint8Array): Promise<T>\n getAndDecryptAttachment(entity: T, validator: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<ArrayBuffer>\n getEncryptedAttachment(entity: T): Promise<ArrayBuffer>\n}\n\nconst entityWithAttachmentApis = {\n docMainAttachment: (apis: Apis, currentUser: User) =>\n <EntityWithAttachmentApi<models.Document>>{\n async createEntity(): Promise<models.Document> {\n return apis.documentApi.createDocument(await apis.documentApi.newInstance(currentUser))\n },\n encryptAndSetAttachment(entity: models.Document, attachment: ArrayBuffer | Uint8Array): Promise<models.Document> {\n return apis.documentApi.encryptAndSetDocumentAttachment(entity, attachment)\n },\n getAndDecryptAttachment(entity: models.Document, validator: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<ArrayBuffer> {\n return apis.documentApi.getAndDecryptDocumentAttachment(entity, validator)\n },\n getEncryptedAttachment(entity: models.Document): Promise<ArrayBuffer> {\n return apis.documentApi.getDocumentAttachment(entity.id!, 'unused')\n },\n },\n docSecondaryAttachment: (apis: Apis, currentUser: User) =>\n <EntityWithAttachmentApi<models.Document>>{\n async createEntity(): Promise<models.Document> {\n return apis.documentApi.createDocument(await apis.documentApi.newInstance(currentUser))\n },\n encryptAndSetAttachment(entity: models.Document, attachment: ArrayBuffer | Uint8Array): Promise<models.Document> {\n return apis.documentApi.encryptAndSetSecondaryDocumentAttachment(entity, 'secondary', attachment)\n },\n getAndDecryptAttachment(entity: models.Document, validator: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<ArrayBuffer> {\n return apis.documentApi.getAndDecryptSecondaryDocumentAttachment(entity, 'secondary', validator)\n },\n getEncryptedAttachment(entity: models.Document): Promise<ArrayBuffer> {\n return apis.documentApi.getSecondaryAttachment(entity.id!, 'secondary')\n },\n },\n receipt: (apis: Apis, currentUser: User) =>\n <EntityWithAttachmentApi<models.Receipt>>{\n async createEntity(): Promise<models.Receipt> {\n return apis.receiptApi.createReceipt(await apis.receiptApi.newInstance(currentUser, {}))\n },\n async encryptAndSetAttachment(entity: models.Receipt, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n return apis.receiptApi.encryptAndSetReceiptAttachment(entity, 'tack', attachment)\n },\n getAndDecryptAttachment(entity: models.Receipt, validator: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<ArrayBuffer> {\n return apis.receiptApi.getAndDecryptReceiptAttachment(entity, (entity.attachmentIds ?? {})['tack'], validator)\n },\n getEncryptedAttachment(entity: models.Receipt): Promise<ArrayBuffer> {\n return apis.receiptApi.getReceiptAttachment(entity.id!, (entity.attachmentIds ?? {})['tack'], '')\n },\n },\n}\n\nbefore(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n for (const [a, b] of Object.entries(env.dataOwnerDetails)) {\n console.log(a)\n console.log(b.password)\n console.log('')\n }\n apis = await initApi(env!, hcp1Username)\n user = await apis.userApi.getCurrentUser()\n})\n\ndescribe('Entity attachment update methods', async function () {\n Object.entries(entityWithAttachmentApis).forEach(([type, attachmentApiInitialiser]) => {\n it(`should automatically encrypt and decrypt attachments (${type})`, async () => {\n const attachmentApi = attachmentApiInitialiser(apis, user)\n const entity = await attachmentApi.createEntity()\n console.log(`entity id ${entity.id}`)\n const attachmentContent = 'This is some secret attachment'\n const entityWithEncrypted = await attachmentApi.encryptAndSetAttachment(entity, utf8_2ua(attachmentContent))\n const decryptedAttachment = await attachmentApi.getAndDecryptAttachment(entityWithEncrypted, async (d) => {\n try {\n return ua2utf8(d) === attachmentContent\n } catch {\n return false\n }\n })\n expect(ua2utf8(decryptedAttachment)).to.equal(attachmentContent)\n const encryptedAttachment = await attachmentApi.getEncryptedAttachment(entityWithEncrypted)\n let conversionFailed\n try {\n conversionFailed = ua2utf8(encryptedAttachment) !== attachmentContent\n } catch {\n conversionFailed = true\n }\n expect(conversionFailed).to.be.true\n const attachmentContent2 = 'This is an updated secret attachment'\n const entityWithEncrypted2 = await attachmentApi.encryptAndSetAttachment(entityWithEncrypted, utf8_2ua(attachmentContent2))\n const decryptedAttachment2 = await attachmentApi.getAndDecryptAttachment(entityWithEncrypted2, async (d) => {\n try {\n return ua2utf8(d) === attachmentContent2\n } catch {\n return false\n }\n })\n expect(ua2utf8(decryptedAttachment2)).to.equal(attachmentContent2)\n const encryptedAttachment2 = await attachmentApi.getEncryptedAttachment(entityWithEncrypted2)\n let conversionFailed2\n try {\n conversionFailed2 = ua2utf8(encryptedAttachment2) !== attachmentContent2\n } catch {\n conversionFailed2 = true\n }\n expect(conversionFailed2).to.be.true\n })\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'mocha';