@icure/api 8.11.0 → 8.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/icc-api/api/IccUserApi.d.ts +1 -1
  2. package/icc-api/api/IccUserApi.js +2 -2
  3. package/icc-api/api/IccUserApi.js.map +1 -1
  4. package/icc-api/model/HealthElement.d.ts +5 -0
  5. package/icc-api/model/HealthElement.js.map +1 -1
  6. package/icc-api/model/HealthElementQualifiedLink.d.ts +31 -0
  7. package/icc-api/model/HealthElementQualifiedLink.js +26 -0
  8. package/icc-api/model/HealthElementQualifiedLink.js.map +1 -0
  9. package/icc-api/model/models.d.ts +1 -0
  10. package/icc-api/model/models.js +1 -0
  11. package/icc-api/model/models.js.map +1 -1
  12. package/icc-x-api/filters/HealthElementByAssociationIdFilter.d.ts +23 -0
  13. package/icc-x-api/filters/HealthElementByAssociationIdFilter.js +30 -0
  14. package/icc-x-api/filters/HealthElementByAssociationIdFilter.js.map +1 -0
  15. package/icc-x-api/filters/HealthElementByQualifiedLinkFilter.d.ts +24 -0
  16. package/icc-x-api/filters/HealthElementByQualifiedLinkFilter.js +30 -0
  17. package/icc-x-api/filters/HealthElementByQualifiedLinkFilter.js.map +1 -0
  18. package/icc-x-api/filters/filters.d.ts +2 -0
  19. package/icc-x-api/filters/filters.js +2 -0
  20. package/icc-x-api/filters/filters.js.map +1 -1
  21. package/package.json +1 -1
  22. package/test/benchmarks/lzma-benchmark.spec.d.ts +0 -1
  23. package/test/benchmarks/lzma-benchmark.spec.js +0 -131
  24. package/test/benchmarks/lzma-benchmark.spec.js.map +0 -1
  25. package/test/benchmarks/lzma-compat.spec.d.ts +0 -1
  26. package/test/benchmarks/lzma-compat.spec.js +0 -187
  27. package/test/benchmarks/lzma-compat.spec.js.map +0 -1
  28. package/test/benchmarks/playwright.config.d.ts +0 -2
  29. package/test/benchmarks/playwright.config.js +0 -18
  30. package/test/benchmarks/playwright.config.js.map +0 -1
  31. package/test/icc-api/api/IccAgendaApi.d.ts +0 -1
  32. package/test/icc-api/api/IccAgendaApi.js +0 -64
  33. package/test/icc-api/api/IccAgendaApi.js.map +0 -1
  34. package/test/icc-api/api/IccAnonymousAccessApi.d.ts +0 -1
  35. package/test/icc-api/api/IccAnonymousAccessApi.js +0 -58
  36. package/test/icc-api/api/IccAnonymousAccessApi.js.map +0 -1
  37. package/test/icc-api/api/IccCalendarItemApi.d.ts +0 -1
  38. package/test/icc-api/api/IccCalendarItemApi.js +0 -67
  39. package/test/icc-api/api/IccCalendarItemApi.js.map +0 -1
  40. package/test/icc-api/api/IccCalendarItemTypeApi.d.ts +0 -1
  41. package/test/icc-api/api/IccCalendarItemTypeApi.js +0 -96
  42. package/test/icc-api/api/IccCalendarItemTypeApi.js.map +0 -1
  43. package/test/icc-api/api/IccCodeApi.d.ts +0 -1
  44. package/test/icc-api/api/IccCodeApi.js +0 -38
  45. package/test/icc-api/api/IccCodeApi.js.map +0 -1
  46. package/test/icc-api/api/IccDocumentApi.d.ts +0 -1
  47. package/test/icc-api/api/IccDocumentApi.js +0 -199
  48. package/test/icc-api/api/IccDocumentApi.js.map +0 -1
  49. package/test/icc-api/api/IccGroupApi.d.ts +0 -1
  50. package/test/icc-api/api/IccGroupApi.js +0 -50
  51. package/test/icc-api/api/IccGroupApi.js.map +0 -1
  52. package/test/icc-api/api/IccKeywordApi.d.ts +0 -1
  53. package/test/icc-api/api/IccKeywordApi.js +0 -64
  54. package/test/icc-api/api/IccKeywordApi.js.map +0 -1
  55. package/test/icc-api/api/IccMedicalLocationApi.d.ts +0 -1
  56. package/test/icc-api/api/IccMedicalLocationApi.js +0 -64
  57. package/test/icc-api/api/IccMedicalLocationApi.js.map +0 -1
  58. package/test/icc-api/api/IccPlaceApi.d.ts +0 -1
  59. package/test/icc-api/api/IccPlaceApi.js +0 -64
  60. package/test/icc-api/api/IccPlaceApi.js.map +0 -1
  61. package/test/icc-api/api/IccRecoveryDataApi.d.ts +0 -1
  62. package/test/icc-api/api/IccRecoveryDataApi.js +0 -95
  63. package/test/icc-api/api/IccRecoveryDataApi.js.map +0 -1
  64. package/test/icc-api/api/IccRoleApi.d.ts +0 -1
  65. package/test/icc-api/api/IccRoleApi.js +0 -34
  66. package/test/icc-api/api/IccRoleApi.js.map +0 -1
  67. package/test/icc-api/api/IccUserApi.d.ts +0 -1
  68. package/test/icc-api/api/IccUserApi.js +0 -96
  69. package/test/icc-api/api/IccUserApi.js.map +0 -1
  70. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +0 -1
  71. package/test/icc-api/e2e/IccCalendarItemApi.js +0 -46
  72. package/test/icc-api/e2e/IccCalendarItemApi.js.map +0 -1
  73. package/test/icc-api/model/modelHelpersTest.d.ts +0 -1
  74. package/test/icc-api/model/modelHelpersTest.js +0 -45
  75. package/test/icc-api/model/modelHelpersTest.js.map +0 -1
  76. package/test/icc-x-api/auth/group-switch-test.d.ts +0 -1
  77. package/test/icc-x-api/auth/group-switch-test.js +0 -81
  78. package/test/icc-x-api/auth/group-switch-test.js.map +0 -1
  79. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +0 -2
  80. package/test/icc-x-api/auth/jwt-concurrency-test.js +0 -112
  81. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +0 -1
  82. package/test/icc-x-api/auth/jwt-provider-test.d.ts +0 -1
  83. package/test/icc-x-api/auth/jwt-provider-test.js +0 -197
  84. package/test/icc-x-api/auth/jwt-provider-test.js.map +0 -1
  85. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +0 -1
  86. package/test/icc-x-api/auth/smart-auth-provider-test.js +0 -224
  87. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +0 -1
  88. package/test/icc-x-api/autofix-anonymity-test.d.ts +0 -1
  89. package/test/icc-x-api/autofix-anonymity-test.js +0 -122
  90. package/test/icc-x-api/autofix-anonymity-test.js.map +0 -1
  91. package/test/icc-x-api/confidential-entities-test.d.ts +0 -1
  92. package/test/icc-x-api/confidential-entities-test.js +0 -168
  93. package/test/icc-x-api/confidential-entities-test.js.map +0 -1
  94. package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +0 -1
  95. package/test/icc-x-api/crud/comprehensive-crud-test.js +0 -276
  96. package/test/icc-x-api/crud/comprehensive-crud-test.js.map +0 -1
  97. package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +0 -16
  98. package/test/icc-x-api/crud/entities-crud-test-interface.js +0 -407
  99. package/test/icc-x-api/crud/entities-crud-test-interface.js.map +0 -1
  100. package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +0 -1
  101. package/test/icc-x-api/crypto/anonymous-delegations-test.js +0 -587
  102. package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +0 -1
  103. package/test/icc-x-api/crypto/concurrency.d.ts +0 -1
  104. package/test/icc-x-api/crypto/concurrency.js +0 -35
  105. package/test/icc-x-api/crypto/concurrency.js.map +0 -1
  106. package/test/icc-x-api/crypto/crypto-utils.d.ts +0 -1
  107. package/test/icc-x-api/crypto/crypto-utils.js +0 -79
  108. package/test/icc-x-api/crypto/crypto-utils.js.map +0 -1
  109. package/test/icc-x-api/crypto/cryptoTest.d.ts +0 -2
  110. package/test/icc-x-api/crypto/cryptoTest.js +0 -402
  111. package/test/icc-x-api/crypto/cryptoTest.js.map +0 -1
  112. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +0 -1
  113. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +0 -166
  114. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +0 -1
  115. package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +0 -1
  116. package/test/icc-x-api/crypto/exchange-data-manager-test.js +0 -674
  117. package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +0 -1
  118. package/test/icc-x-api/crypto/full-crypto-test.d.ts +0 -1
  119. package/test/icc-x-api/crypto/full-crypto-test.js +0 -454
  120. package/test/icc-x-api/crypto/full-crypto-test.js.map +0 -1
  121. package/test/icc-x-api/crypto/legacy-metadata-migration-test.d.ts +0 -1
  122. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js +0 -379
  123. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +0 -1
  124. package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +0 -1
  125. package/test/icc-x-api/crypto/secure-delegations-manager-test.js +0 -278
  126. package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +0 -1
  127. package/test/icc-x-api/crypto/shamir.d.ts +0 -2
  128. package/test/icc-x-api/crypto/shamir.js +0 -167
  129. package/test/icc-x-api/crypto/shamir.js.map +0 -1
  130. package/test/icc-x-api/crypto/share-deduplication-test.d.ts +0 -1
  131. package/test/icc-x-api/crypto/share-deduplication-test.js +0 -250
  132. package/test/icc-x-api/crypto/share-deduplication-test.js.map +0 -1
  133. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +0 -1
  134. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +0 -71
  135. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +0 -1
  136. package/test/icc-x-api/crypto/soft-deleted-data-owners.d.ts +0 -2
  137. package/test/icc-x-api/crypto/soft-deleted-data-owners.js +0 -113
  138. package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +0 -1
  139. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +0 -1
  140. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +0 -246
  141. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +0 -1
  142. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +0 -1
  143. package/test/icc-x-api/entity-with-attachments-api-test.js +0 -142
  144. package/test/icc-x-api/entity-with-attachments-api-test.js.map +0 -1
  145. package/test/icc-x-api/filters/filters.d.ts +0 -1
  146. package/test/icc-x-api/filters/filters.js +0 -49
  147. package/test/icc-x-api/filters/filters.js.map +0 -1
  148. package/test/icc-x-api/filters/healthelement.d.ts +0 -1
  149. package/test/icc-x-api/filters/healthelement.js +0 -333
  150. package/test/icc-x-api/filters/healthelement.js.map +0 -1
  151. package/test/icc-x-api/icc-accesslog-x-api.d.ts +0 -1
  152. package/test/icc-x-api/icc-accesslog-x-api.js +0 -106
  153. package/test/icc-x-api/icc-accesslog-x-api.js.map +0 -1
  154. package/test/icc-x-api/icc-application-settings-x-api.d.ts +0 -1
  155. package/test/icc-x-api/icc-application-settings-x-api.js +0 -91
  156. package/test/icc-x-api/icc-application-settings-x-api.js.map +0 -1
  157. package/test/icc-x-api/icc-auth-api.d.ts +0 -1
  158. package/test/icc-x-api/icc-auth-api.js +0 -47
  159. package/test/icc-x-api/icc-auth-api.js.map +0 -1
  160. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +0 -1
  161. package/test/icc-x-api/icc-calendar-item-x-api.js +0 -150
  162. package/test/icc-x-api/icc-calendar-item-x-api.js.map +0 -1
  163. package/test/icc-x-api/icc-code-x-api-test.d.ts +0 -1
  164. package/test/icc-x-api/icc-code-x-api-test.js +0 -74
  165. package/test/icc-x-api/icc-code-x-api-test.js.map +0 -1
  166. package/test/icc-x-api/icc-contact-x-api.d.ts +0 -1
  167. package/test/icc-x-api/icc-contact-x-api.js +0 -355
  168. package/test/icc-x-api/icc-contact-x-api.js.map +0 -1
  169. package/test/icc-x-api/icc-document-x-api.d.ts +0 -1
  170. package/test/icc-x-api/icc-document-x-api.js +0 -76
  171. package/test/icc-x-api/icc-document-x-api.js.map +0 -1
  172. package/test/icc-x-api/icc-form-x-api.d.ts +0 -1
  173. package/test/icc-x-api/icc-form-x-api.js +0 -413
  174. package/test/icc-x-api/icc-form-x-api.js.map +0 -1
  175. package/test/icc-x-api/icc-hcparty-x-api-test.d.ts +0 -1
  176. package/test/icc-x-api/icc-hcparty-x-api-test.js +0 -43
  177. package/test/icc-x-api/icc-hcparty-x-api-test.js.map +0 -1
  178. package/test/icc-x-api/icc-helement-x-api-test.d.ts +0 -1
  179. package/test/icc-x-api/icc-helement-x-api-test.js +0 -155
  180. package/test/icc-x-api/icc-helement-x-api-test.js.map +0 -1
  181. package/test/icc-x-api/icc-invoice-x-api.d.ts +0 -1
  182. package/test/icc-x-api/icc-invoice-x-api.js +0 -99
  183. package/test/icc-x-api/icc-invoice-x-api.js.map +0 -1
  184. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +0 -1
  185. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +0 -222
  186. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +0 -1
  187. package/test/icc-x-api/icc-message-x-api.d.ts +0 -1
  188. package/test/icc-x-api/icc-message-x-api.js +0 -54
  189. package/test/icc-x-api/icc-message-x-api.js.map +0 -1
  190. package/test/icc-x-api/icc-patient-x-api-test.d.ts +0 -1
  191. package/test/icc-x-api/icc-patient-x-api-test.js +0 -209
  192. package/test/icc-x-api/icc-patient-x-api-test.js.map +0 -1
  193. package/test/icc-x-api/icc-recovery-x-api.d.ts +0 -1
  194. package/test/icc-x-api/icc-recovery-x-api.js +0 -175
  195. package/test/icc-x-api/icc-recovery-x-api.js.map +0 -1
  196. package/test/icc-x-api/icc-topic-x-api.d.ts +0 -1
  197. package/test/icc-x-api/icc-topic-x-api.js +0 -269
  198. package/test/icc-x-api/icc-topic-x-api.js.map +0 -1
  199. package/test/icc-x-api/icc-user-x-api-test.d.ts +0 -1
  200. package/test/icc-x-api/icc-user-x-api-test.js +0 -99
  201. package/test/icc-x-api/icc-user-x-api-test.js.map +0 -1
  202. package/test/icc-x-api/keyless-api.d.ts +0 -1
  203. package/test/icc-x-api/keyless-api.js +0 -125
  204. package/test/icc-x-api/keyless-api.js.map +0 -1
  205. package/test/icc-x-api/patient-user.d.ts +0 -2
  206. package/test/icc-x-api/patient-user.js +0 -103
  207. package/test/icc-x-api/patient-user.js.map +0 -1
  208. package/test/icc-x-api/storage/storage.d.ts +0 -1
  209. package/test/icc-x-api/storage/storage.js +0 -48
  210. package/test/icc-x-api/storage/storage.js.map +0 -1
  211. package/test/icc-x-api/test-api-no-parent.d.ts +0 -1
  212. package/test/icc-x-api/test-api-no-parent.js +0 -79
  213. package/test/icc-x-api/test-api-no-parent.js.map +0 -1
  214. package/test/icc-x-api/test-legacy-data-support.d.ts +0 -1
  215. package/test/icc-x-api/test-legacy-data-support.js +0 -375
  216. package/test/icc-x-api/test-legacy-data-support.js.map +0 -1
  217. package/test/icc-x-api/utils/date-encode-test.d.ts +0 -1
  218. package/test/icc-x-api/utils/date-encode-test.js +0 -150
  219. package/test/icc-x-api/utils/date-encode-test.js.map +0 -1
  220. package/test/icc-x-api/utils/graph-test.d.ts +0 -1
  221. package/test/icc-x-api/utils/graph-test.js +0 -54
  222. package/test/icc-x-api/utils/graph-test.js.map +0 -1
  223. package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +0 -1
  224. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +0 -364
  225. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +0 -1
  226. package/test/icc-x-api/utils/lzma-benchmark-test.d.ts +0 -1
  227. package/test/icc-x-api/utils/lzma-benchmark-test.js +0 -132
  228. package/test/icc-x-api/utils/lzma-benchmark-test.js.map +0 -1
  229. package/test/icc-x-api/utils/lzma-compat-test.d.ts +0 -1
  230. package/test/icc-x-api/utils/lzma-compat-test.js +0 -218
  231. package/test/icc-x-api/utils/lzma-compat-test.js.map +0 -1
  232. package/test/icc-x-api/utils/mutex-test.d.ts +0 -1
  233. package/test/icc-x-api/utils/mutex-test.js +0 -114
  234. package/test/icc-x-api/utils/mutex-test.js.map +0 -1
  235. package/test/icc-x-api/utils/to-moment-test.d.ts +0 -1
  236. package/test/icc-x-api/utils/to-moment-test.js +0 -110
  237. package/test/icc-x-api/utils/to-moment-test.js.map +0 -1
  238. package/test/support/CSM-185.d.ts +0 -1
  239. package/test/support/CSM-185.js +0 -124
  240. package/test/support/CSM-185.js.map +0 -1
  241. package/test/support/CSM-243.d.ts +0 -1
  242. package/test/support/CSM-243.js +0 -120
  243. package/test/support/CSM-243.js.map +0 -1
  244. package/test/support/CSM-543.d.ts +0 -1
  245. package/test/support/CSM-543.js +0 -164
  246. package/test/support/CSM-543.js.map +0 -1
  247. package/test/support/CSM-729.d.ts +0 -1
  248. package/test/support/CSM-729.js +0 -225
  249. package/test/support/CSM-729.js.map +0 -1
  250. package/test/support/CSM-814.d.ts +0 -1
  251. package/test/support/CSM-814.js +0 -475
  252. package/test/support/CSM-814.js.map +0 -1
  253. package/test/support/CSM-87.d.ts +0 -0
  254. package/test/support/CSM-87.js +0 -21
  255. package/test/support/CSM-87.js.map +0 -1
  256. package/test/support/CSM-93.d.ts +0 -1
  257. package/test/support/CSM-93.js +0 -112
  258. package/test/support/CSM-93.js.map +0 -1
  259. package/test/utils/FakeDataOwnerApi.d.ts +0 -32
  260. package/test/utils/FakeDataOwnerApi.js +0 -136
  261. package/test/utils/FakeDataOwnerApi.js.map +0 -1
  262. package/test/utils/FakeEncryptionKeysManager.d.ts +0 -36
  263. package/test/utils/FakeEncryptionKeysManager.js +0 -97
  264. package/test/utils/FakeEncryptionKeysManager.js.map +0 -1
  265. package/test/utils/FakeExchangeDataApi.d.ts +0 -32
  266. package/test/utils/FakeExchangeDataApi.js +0 -92
  267. package/test/utils/FakeExchangeDataApi.js.map +0 -1
  268. package/test/utils/FakeExchangeDataManager.d.ts +0 -48
  269. package/test/utils/FakeExchangeDataManager.js +0 -82
  270. package/test/utils/FakeExchangeDataManager.js.map +0 -1
  271. package/test/utils/FakeExchangeDataMapManager.d.ts +0 -12
  272. package/test/utils/FakeExchangeDataMapManager.js +0 -38
  273. package/test/utils/FakeExchangeDataMapManager.js.map +0 -1
  274. package/test/utils/FakeGenericApi.d.ts +0 -16
  275. package/test/utils/FakeGenericApi.js +0 -65
  276. package/test/utils/FakeGenericApi.js.map +0 -1
  277. package/test/utils/KeylessCryptoStrategies.d.ts +0 -23
  278. package/test/utils/KeylessCryptoStrategies.js +0 -26
  279. package/test/utils/KeylessCryptoStrategies.js.map +0 -1
  280. package/test/utils/TestApi.d.ts +0 -3
  281. package/test/utils/TestApi.js +0 -30
  282. package/test/utils/TestApi.js.map +0 -1
  283. package/test/utils/TestCollectionUtils.d.ts +0 -1
  284. package/test/utils/TestCollectionUtils.js +0 -310
  285. package/test/utils/TestCollectionUtils.js.map +0 -1
  286. package/test/utils/TestCryptoStrategies.d.ts +0 -42
  287. package/test/utils/TestCryptoStrategies.js +0 -80
  288. package/test/utils/TestCryptoStrategies.js.map +0 -1
  289. package/test/utils/TestStorage.d.ts +0 -23
  290. package/test/utils/TestStorage.js +0 -61
  291. package/test/utils/TestStorage.js.map +0 -1
  292. package/test/utils/roles.d.ts +0 -14
  293. package/test/utils/roles.js +0 -345
  294. package/test/utils/roles.js.map +0 -1
  295. package/test/utils/test_utils.d.ts +0 -87
  296. package/test/utils/test_utils.js +0 -452
  297. package/test/utils/test_utils.js.map +0 -1
@@ -1,166 +0,0 @@
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 icc_x_api_1 = require("../../../icc-x-api");
13
- const CalendarItem_1 = require("../../../icc-api/model/CalendarItem");
14
- const models_1 = require("../../../icc-api/model/models");
15
- const mocha_1 = require("mocha");
16
- const crypto_1 = require("crypto");
17
- require("isomorphic-fetch");
18
- const chai_1 = require("chai");
19
- const MaintenanceTaskAfterDateFilter_1 = require("../../../icc-x-api/filters/MaintenanceTaskAfterDateFilter");
20
- const test_utils_1 = require("../../utils/test_utils");
21
- const TestStorage_1 = require("../../utils/TestStorage");
22
- const TestCryptoStrategies_1 = require("../../utils/TestCryptoStrategies");
23
- const KeyPairUpdateRequest_1 = require("../../../icc-x-api/maintenance/KeyPairUpdateRequest");
24
- const SecureDelegation_1 = require("../../../icc-api/model/SecureDelegation");
25
- const types_1 = require("@icure/test-setup/types");
26
- var AccessLevel = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
27
- function _getHcpKeyUpdateMaintenanceTask(delegateApi) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const delegateUser = yield delegateApi.userApi.getCurrentUser();
30
- const notifications = yield delegateApi.maintenanceTaskApi.filterMaintenanceTasksByWithUser(delegateUser, undefined, undefined, new models_1.FilterChainMaintenanceTask({
31
- filter: new MaintenanceTaskAfterDateFilter_1.MaintenanceTaskAfterDateFilter({
32
- date: new Date().getTime() - 100000,
33
- }),
34
- }));
35
- return notifications.rows.sort((a, b) => a.created - b.created)[notifications.rows.length - 1];
36
- });
37
- }
38
- (0, test_utils_1.setLocalStorage)(fetch);
39
- let env;
40
- (0, mocha_1.describe)('Full battery of tests on crypto and keys', function () {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- (0, mocha_1.before)(function () {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- this.timeout(600000);
45
- const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
46
- env = yield initializer.execute((0, types_1.getEnvVariables)());
47
- });
48
- });
49
- // TODO should give access back to old and new keys
50
- (0, mocha_1.it)(`Create calendar item as a patient and get access back`, () => __awaiter(this, void 0, void 0, function* () {
51
- function decryptDataForPair(api, dataOwner1, dataOwner2) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const allExchangeData = [
54
- ...(yield api.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(dataOwner1, dataOwner2)),
55
- ...(yield api.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(dataOwner2, dataOwner1)),
56
- ];
57
- let failedDecryptionsCount = 0;
58
- const successfulDecryptions = [];
59
- for (const exchangeData of allExchangeData) {
60
- const decryptedKey = yield api.cryptoApi.exchangeData.base.tryDecryptExchangeKeys([exchangeData], api.cryptoApi.userKeysManager.getDecryptionKeys());
61
- const decryptedAccessControlSecret = yield api.cryptoApi.exchangeData.base.tryDecryptAccessControlSecret([exchangeData], api.cryptoApi.userKeysManager.getDecryptionKeys());
62
- if (decryptedKey.failedDecryptions.length > 0 || decryptedAccessControlSecret.failedDecryptions.length > 0) {
63
- failedDecryptionsCount++;
64
- }
65
- else {
66
- successfulDecryptions.push({
67
- rawKey: (0, icc_x_api_1.ua2hex)(yield api.cryptoApi.primitives.AES.exportKey(decryptedKey.successfulDecryptions[0], 'raw')),
68
- accessControlSecret: decryptedAccessControlSecret.successfulDecryptions[0],
69
- });
70
- }
71
- }
72
- return { failedDecryptionsCount, successfulDecryptions };
73
- });
74
- }
75
- function checkDecryptedDataHas(decryptedData, expected) {
76
- (0, chai_1.expect)(decryptedData.filter((d) => d.rawKey === expected.rawKey && d.accessControlSecret === expected.accessControlSecret)).to.have.length(1);
77
- }
78
- const previousPubKey = env.dataOwnerDetails[test_utils_1.patUsername].publicKey;
79
- const api = yield (0, test_utils_1.getApiAndAddPrivateKeysForUser)(env.iCureUrl, env.dataOwnerDetails[test_utils_1.patUsername]);
80
- const u = yield api.userApi.getCurrentUser();
81
- const delegateInfo = yield (0, test_utils_1.createNewHcpApi)(env);
82
- const delegateApi = delegateInfo.api;
83
- const delegateUser = delegateInfo.user;
84
- const delegateHcp = yield delegateApi.healthcarePartyApi.getHealthcareParty(delegateUser.healthcarePartyId);
85
- const patient = yield api.patientApi.getPatientWithUser(u, u.patientId);
86
- // Create a Record to share with delegateHcp: this will trigger the creation of a new aes exchange key as well
87
- const initialRecordToDelegate = yield api.calendarItemApi.createCalendarItemWithHcParty(u, yield api.calendarItemApi.newInstance(u, new CalendarItem_1.CalendarItem({ id: `${u.id}-ci-initial-to`, title: 'CI-INITIAL-TO' }), {
88
- additionalDelegates: {
89
- [delegateHcp.id]: AccessLevel.WRITE,
90
- },
91
- }));
92
- const initialRecordFromDelegate = yield delegateApi.calendarItemApi.createCalendarItemWithHcParty(u, yield delegateApi.calendarItemApi.newInstance(delegateUser, new CalendarItem_1.CalendarItem({ id: `${u.id}-ci-initial-from`, title: 'CI-INITIAL-FROM' }), {
93
- additionalDelegates: {
94
- [u.patientId]: AccessLevel.WRITE,
95
- },
96
- }));
97
- // Decrypting this AES Key to compare it with AES key decrypted with new key in the next steps
98
- yield api.cryptoApi.forceReload();
99
- const originalDecryptedData = yield decryptDataForPair(api, u.patientId, delegateUser.healthcarePartyId);
100
- (0, chai_1.expect)(originalDecryptedData.failedDecryptionsCount).to.equal(0);
101
- (0, chai_1.expect)(originalDecryptedData.successfulDecryptions.length).to.equal(2);
102
- // And creates a new one
103
- const newKey = yield api.cryptoApi.primitives.RSA.generateKeyPair(icc_x_api_1.ShaVersion.Sha256);
104
- const publicKey = (0, icc_x_api_1.ua2hex)(yield api.cryptoApi.primitives.RSA.exportKey(newKey.publicKey, 'spki'));
105
- const apiAfterNewKey = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, {
106
- username: env.dataOwnerDetails[test_utils_1.patUsername].user,
107
- password: env.dataOwnerDetails[test_utils_1.patUsername].password,
108
- }, new TestCryptoStrategies_1.TestCryptoStrategies(newKey), crypto_1.webcrypto, fetch, {
109
- storage: new TestStorage_1.TestStorage(),
110
- keyStorage: new TestStorage_1.TestKeyStorage(),
111
- });
112
- const user = yield apiAfterNewKey.userApi.getCurrentUser();
113
- yield apiAfterNewKey.icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(user, newKey);
114
- // User can get not encrypted information from iCure (HCP, ...)
115
- const hcp = yield apiAfterNewKey.healthcarePartyApi.getHealthcareParty(delegateUser.healthcarePartyId);
116
- // User can create new data, using its new keyPair
117
- const newRecordToDelegate = yield apiAfterNewKey.calendarItemApi.createCalendarItemWithHcParty(u, yield apiAfterNewKey.calendarItemApi.newInstance(u, new CalendarItem_1.CalendarItem({ id: `${u.id}-ci-to`, title: 'CI-TO' }), {
118
- additionalDelegates: {
119
- [hcp.id]: SecureDelegation_1.SecureDelegation.AccessLevelEnum.WRITE,
120
- },
121
- }));
122
- (0, chai_1.expect)(newRecordToDelegate.id).to.be.not.null;
123
- (0, chai_1.expect)(newRecordToDelegate.rev).to.be.not.null;
124
- // But user can not decrypt data he previously created
125
- const decryptedWithNewKey = yield decryptDataForPair(apiAfterNewKey, u.patientId, delegateUser.healthcarePartyId);
126
- (0, chai_1.expect)(decryptedWithNewKey.failedDecryptionsCount).to.equal(2);
127
- (0, chai_1.expect)(decryptedWithNewKey.successfulDecryptions.length).to.equal(1);
128
- // Delegate user will therefore give user access back to data he previously created
129
- // Hcp gets his maintenance tasks
130
- yield delegateApi.cryptoApi.forceReload();
131
- const maintenanceTask = KeyPairUpdateRequest_1.KeyPairUpdateRequest.fromMaintenanceTask(yield _getHcpKeyUpdateMaintenanceTask(delegateApi));
132
- (0, chai_1.expect)(maintenanceTask.concernedDataOwnerId).equals(patient.id);
133
- (0, chai_1.expect)(maintenanceTask.newPublicKey).equals(publicKey);
134
- yield delegateApi.icureMaintenanceTaskApi.applyKeyPairUpdate(maintenanceTask);
135
- const updatedDataOwner = yield delegateApi.dataOwnerApi.getCryptoActorStub(maintenanceTask.concernedDataOwnerId);
136
- (0, chai_1.expect)(updatedDataOwner.type).to.be.equal('patient');
137
- (0, chai_1.expect)(updatedDataOwner.stub).to.not.be.undefined;
138
- (0, chai_1.expect)(updatedDataOwner.stub).to.not.be.null;
139
- const apiAfterSharedBack = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, {
140
- username: env.dataOwnerDetails[test_utils_1.patUsername].user,
141
- password: env.dataOwnerDetails[test_utils_1.patUsername].password,
142
- }, new TestCryptoStrategies_1.TestCryptoStrategies(newKey), crypto_1.webcrypto, fetch, {
143
- storage: new TestStorage_1.TestStorage(),
144
- keyStorage: new TestStorage_1.TestKeyStorage(),
145
- });
146
- // User can access his previous data again
147
- yield apiAfterSharedBack.cryptoApi.forceReload();
148
- const decryptedAfterShareBack = yield decryptDataForPair(apiAfterSharedBack, u.patientId, delegateUser.healthcarePartyId);
149
- (0, chai_1.expect)(decryptedAfterShareBack.failedDecryptionsCount).to.equal(0);
150
- (0, chai_1.expect)(decryptedAfterShareBack.successfulDecryptions.length).to.equal(3);
151
- checkDecryptedDataHas(decryptedAfterShareBack.successfulDecryptions, originalDecryptedData.successfulDecryptions[0]);
152
- checkDecryptedDataHas(decryptedAfterShareBack.successfulDecryptions, originalDecryptedData.successfulDecryptions[1]);
153
- checkDecryptedDataHas(decryptedAfterShareBack.successfulDecryptions, decryptedWithNewKey.successfulDecryptions[0]);
154
- const initialRecordFromDelegateAfterSharedBack = yield apiAfterSharedBack.calendarItemApi.getCalendarItemWithUser(u, initialRecordFromDelegate.id);
155
- (0, chai_1.expect)(initialRecordFromDelegateAfterSharedBack.id).to.be.equal(initialRecordFromDelegate.id);
156
- (0, chai_1.expect)(initialRecordFromDelegateAfterSharedBack.rev).to.be.equal(initialRecordFromDelegate.rev);
157
- (0, chai_1.expect)(initialRecordFromDelegateAfterSharedBack.title).to.be.equal(initialRecordFromDelegate.title);
158
- const initialRecordToDelegateAfterSharedBack = yield apiAfterSharedBack.calendarItemApi.getCalendarItemWithUser(u, initialRecordToDelegate.id);
159
- (0, chai_1.expect)(initialRecordToDelegateAfterSharedBack.id).to.be.equal(initialRecordToDelegate.id);
160
- (0, chai_1.expect)(initialRecordToDelegateAfterSharedBack.rev).to.be.equal(initialRecordToDelegate.rev);
161
- (0, chai_1.expect)(initialRecordToDelegateAfterSharedBack.title).to.be.equal(initialRecordToDelegate.title);
162
- }));
163
- });
164
- });
165
- // TODO test that EXACTLY ONE maintenance task is created for each delegator AND delegate in a exchange key with the data owner with the new key
166
- //# sourceMappingURL=delegate-ci-to-patient-with-missing-keys-test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delegate-ci-to-patient-with-missing-keys-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAAuE;AACvE,sEAAkE;AAClE,0DAAyH;AACzH,iCAA4C;AAE5C,mCAAkC;AAClC,4BAAyB;AAEzB,+BAA6B;AAC7B,8GAA0G;AAC1G,uDAAiJ;AACjJ,yDAAqE;AACrE,2EAAuE;AACvE,8FAA0F;AAC1F,8EAA0E;AAC1E,mDAAmE;AACnE,IAAO,WAAW,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAErD,SAAe,+BAA+B,CAAC,WAAiB;;QAC9D,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QAC/D,MAAM,aAAa,GAAiC,MAAM,WAAW,CAAC,kBAAkB,CAAC,gCAAgC,CACvH,YAAa,EACb,SAAS,EACT,SAAS,EACT,IAAI,mCAA0B,CAAC;YAC7B,MAAM,EAAE,IAAI,+DAA8B,CAAC;gBACzC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,MAAM;aACpC,CAAC;SACH,CAAC,CACH,CAAA;QAED,OAAO,aAAa,CAAC,IAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAQ,GAAG,CAAC,CAAC,OAAQ,CAAC,CAAC,aAAa,CAAC,IAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACpG,CAAC;CAAA;AAED,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAI,GAAa,CAAA;AAEjB,IAAA,gBAAQ,EAAC,0CAA0C,EAAE;;QACnD,IAAA,cAAM,EAAC;;gBACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;gBACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;gBACrD,GAAG,GAA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apis, IcureApi, ShaVersion, ua2hex } from '../../../icc-x-api'\nimport { CalendarItem } from '../../../icc-api/model/CalendarItem'\nimport { FilterChainMaintenanceTask, MaintenanceTask, PaginatedListMaintenanceTask } from '../../../icc-api/model/models'\nimport { before, describe, it } from 'mocha'\n\nimport { webcrypto } from 'crypto'\nimport 'isomorphic-fetch'\n\nimport { expect } from 'chai'\nimport { MaintenanceTaskAfterDateFilter } from '../../../icc-x-api/filters/MaintenanceTaskAfterDateFilter'\nimport { createNewHcpApi, getApiAndAddPrivateKeysForUser, getEnvironmentInitializer, patUsername, setLocalStorage } from '../../utils/test_utils'\nimport { TestKeyStorage, TestStorage } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { KeyPairUpdateRequest } from '../../../icc-x-api/maintenance/KeyPairUpdateRequest'\nimport { SecureDelegation } from '../../../icc-api/model/SecureDelegation'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport AccessLevel = SecureDelegation.AccessLevelEnum\n\nasync function _getHcpKeyUpdateMaintenanceTask(delegateApi: Apis): Promise<MaintenanceTask> {\n const delegateUser = await delegateApi.userApi.getCurrentUser()\n const notifications: PaginatedListMaintenanceTask = await delegateApi.maintenanceTaskApi.filterMaintenanceTasksByWithUser(\n delegateUser!,\n undefined,\n undefined,\n new FilterChainMaintenanceTask({\n filter: new MaintenanceTaskAfterDateFilter({\n date: new Date().getTime() - 100000,\n }),\n })\n )\n\n return notifications.rows!.sort((a, b) => a.created! - b.created!)[notifications.rows!.length - 1]\n}\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\n\ndescribe('Full battery of tests on crypto and keys', async function () {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n // TODO should give access back to old and new keys\n it(`Create calendar item as a patient and get access back`, async () => {\n async function decryptDataForPair(\n api: Apis,\n dataOwner1: string,\n dataOwner2: string\n ): Promise<{\n failedDecryptionsCount: number\n successfulDecryptions: { rawKey: string; accessControlSecret: string }[]\n }> {\n const allExchangeData = [\n ...(await api.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(dataOwner1, dataOwner2)),\n ...(await api.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(dataOwner2, dataOwner1)),\n ]\n let failedDecryptionsCount = 0\n const successfulDecryptions: { rawKey: string; accessControlSecret: string }[] = []\n for (const exchangeData of allExchangeData) {\n const decryptedKey = await api.cryptoApi.exchangeData.base.tryDecryptExchangeKeys(\n [exchangeData],\n api.cryptoApi.userKeysManager.getDecryptionKeys()\n )\n const decryptedAccessControlSecret = await api.cryptoApi.exchangeData.base.tryDecryptAccessControlSecret(\n [exchangeData],\n api.cryptoApi.userKeysManager.getDecryptionKeys()\n )\n if (decryptedKey.failedDecryptions.length > 0 || decryptedAccessControlSecret.failedDecryptions.length > 0) {\n failedDecryptionsCount++\n } else {\n successfulDecryptions.push({\n rawKey: ua2hex(await api.cryptoApi.primitives.AES.exportKey(decryptedKey.successfulDecryptions[0], 'raw')),\n accessControlSecret: decryptedAccessControlSecret.successfulDecryptions[0],\n })\n }\n }\n return { failedDecryptionsCount, successfulDecryptions }\n }\n\n function checkDecryptedDataHas(\n decryptedData: { rawKey: string; accessControlSecret: string }[],\n expected: { rawKey: string; accessControlSecret: string }\n ) {\n expect(decryptedData.filter((d) => d.rawKey === expected.rawKey && d.accessControlSecret === expected.accessControlSecret)).to.have.length(1)\n }\n\n const previousPubKey = env!.dataOwnerDetails[patUsername].publicKey\n const api = await getApiAndAddPrivateKeysForUser(env!.iCureUrl, env!.dataOwnerDetails[patUsername])\n const u = await api.userApi.getCurrentUser()\n\n const delegateInfo = await createNewHcpApi(env!)\n const delegateApi = delegateInfo.api\n const delegateUser = delegateInfo.user\n const delegateHcp = await delegateApi.healthcarePartyApi.getHealthcareParty(delegateUser.healthcarePartyId!)\n\n const patient = await api.patientApi.getPatientWithUser(u, u.patientId!)\n\n // Create a Record to share with delegateHcp: this will trigger the creation of a new aes exchange key as well\n const initialRecordToDelegate = await api.calendarItemApi.createCalendarItemWithHcParty(\n u,\n await api.calendarItemApi.newInstance(u, new CalendarItem({ id: `${u.id}-ci-initial-to`, title: 'CI-INITIAL-TO' }), {\n additionalDelegates: {\n [delegateHcp!.id!]: AccessLevel.WRITE,\n },\n })\n )\n const initialRecordFromDelegate = await delegateApi.calendarItemApi.createCalendarItemWithHcParty(\n u,\n await delegateApi.calendarItemApi.newInstance(delegateUser, new CalendarItem({ id: `${u.id}-ci-initial-from`, title: 'CI-INITIAL-FROM' }), {\n additionalDelegates: {\n [u.patientId!]: AccessLevel.WRITE,\n },\n })\n )\n\n // Decrypting this AES Key to compare it with AES key decrypted with new key in the next steps\n await api.cryptoApi.forceReload()\n const originalDecryptedData = await decryptDataForPair(api, u.patientId!, delegateUser.healthcarePartyId!)\n expect(originalDecryptedData.failedDecryptionsCount).to.equal(0)\n expect(originalDecryptedData.successfulDecryptions.length).to.equal(2)\n\n // And creates a new one\n const newKey = await api.cryptoApi.primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const publicKey = ua2hex(await api.cryptoApi.primitives.RSA.exportKey(newKey.publicKey, 'spki'))\n const apiAfterNewKey = await IcureApi.initialise(\n env!.iCureUrl,\n {\n username: env!.dataOwnerDetails[patUsername].user,\n password: env!.dataOwnerDetails[patUsername].password,\n },\n new TestCryptoStrategies(newKey),\n webcrypto as unknown as Crypto,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n const user = await apiAfterNewKey.userApi.getCurrentUser()\n await apiAfterNewKey.icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(user, newKey)\n\n // User can get not encrypted information from iCure (HCP, ...)\n const hcp = await apiAfterNewKey.healthcarePartyApi.getHealthcareParty(delegateUser!.healthcarePartyId!)\n\n // User can create new data, using its new keyPair\n const newRecordToDelegate = await apiAfterNewKey.calendarItemApi.createCalendarItemWithHcParty(\n u,\n await apiAfterNewKey.calendarItemApi.newInstance(u, new CalendarItem({ id: `${u.id}-ci-to`, title: 'CI-TO' }), {\n additionalDelegates: {\n [hcp!.id!]: SecureDelegation.AccessLevelEnum.WRITE,\n },\n })\n )\n expect(newRecordToDelegate.id).to.be.not.null\n expect(newRecordToDelegate.rev).to.be.not.null\n\n // But user can not decrypt data he previously created\n const decryptedWithNewKey = await decryptDataForPair(apiAfterNewKey, u.patientId!, delegateUser.healthcarePartyId!)\n expect(decryptedWithNewKey.failedDecryptionsCount).to.equal(2)\n expect(decryptedWithNewKey.successfulDecryptions.length).to.equal(1)\n\n // Delegate user will therefore give user access back to data he previously created\n\n // Hcp gets his maintenance tasks\n await delegateApi.cryptoApi.forceReload()\n const maintenanceTask = KeyPairUpdateRequest.fromMaintenanceTask(await _getHcpKeyUpdateMaintenanceTask(delegateApi))\n\n expect(maintenanceTask.concernedDataOwnerId).equals(patient.id)\n expect(maintenanceTask.newPublicKey).equals(publicKey)\n\n await delegateApi.icureMaintenanceTaskApi.applyKeyPairUpdate(maintenanceTask)\n const updatedDataOwner = await delegateApi.dataOwnerApi.getCryptoActorStub(maintenanceTask.concernedDataOwnerId)\n\n expect(updatedDataOwner.type).to.be.equal('patient')\n expect(updatedDataOwner.stub).to.not.be.undefined\n expect(updatedDataOwner.stub).to.not.be.null\n\n const apiAfterSharedBack = await IcureApi.initialise(\n env!.iCureUrl,\n {\n username: env!.dataOwnerDetails[patUsername].user,\n password: env!.dataOwnerDetails[patUsername].password,\n },\n new TestCryptoStrategies(newKey),\n webcrypto as unknown as Crypto,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n // User can access his previous data again\n await apiAfterSharedBack.cryptoApi.forceReload()\n const decryptedAfterShareBack = await decryptDataForPair(apiAfterSharedBack, u.patientId!, delegateUser.healthcarePartyId!)\n expect(decryptedAfterShareBack.failedDecryptionsCount).to.equal(0)\n expect(decryptedAfterShareBack.successfulDecryptions.length).to.equal(3)\n checkDecryptedDataHas(decryptedAfterShareBack.successfulDecryptions, originalDecryptedData.successfulDecryptions[0])\n checkDecryptedDataHas(decryptedAfterShareBack.successfulDecryptions, originalDecryptedData.successfulDecryptions[1])\n checkDecryptedDataHas(decryptedAfterShareBack.successfulDecryptions, decryptedWithNewKey.successfulDecryptions[0])\n\n const initialRecordFromDelegateAfterSharedBack = await apiAfterSharedBack.calendarItemApi.getCalendarItemWithUser(\n u,\n initialRecordFromDelegate.id!\n )\n expect(initialRecordFromDelegateAfterSharedBack.id).to.be.equal(initialRecordFromDelegate.id)\n expect(initialRecordFromDelegateAfterSharedBack.rev).to.be.equal(initialRecordFromDelegate.rev)\n expect(initialRecordFromDelegateAfterSharedBack.title).to.be.equal(initialRecordFromDelegate.title)\n const initialRecordToDelegateAfterSharedBack = await apiAfterSharedBack.calendarItemApi.getCalendarItemWithUser(u, initialRecordToDelegate.id!)\n expect(initialRecordToDelegateAfterSharedBack.id).to.be.equal(initialRecordToDelegate.id)\n expect(initialRecordToDelegateAfterSharedBack.rev).to.be.equal(initialRecordToDelegate.rev)\n expect(initialRecordToDelegateAfterSharedBack.title).to.be.equal(initialRecordToDelegate.title)\n })\n})\n\n// TODO test that EXACTLY ONE maintenance task is created for each delegator AND delegate in a exchange key with the data owner with the new key\n"]}
@@ -1 +0,0 @@
1
- import 'isomorphic-fetch';