@icure/api 8.6.18 → 8.7.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 (328) hide show
  1. package/icc-api/api/IccDocumentApi.d.ts +10 -2
  2. package/icc-api/api/IccDocumentApi.js +22 -4
  3. package/icc-api/api/IccDocumentApi.js.map +1 -1
  4. package/icc-api/api/IccReceiptApi.d.ts +17 -0
  5. package/icc-api/api/IccReceiptApi.js +52 -0
  6. package/icc-api/api/IccReceiptApi.js.map +1 -1
  7. package/icc-api/model/DataAttachment.d.ts +22 -0
  8. package/icc-api/model/DataAttachment.js.map +1 -1
  9. package/icc-api/model/Document.d.ts +6 -0
  10. package/icc-api/model/Document.js.map +1 -1
  11. package/icc-api/model/Receipt.d.ts +6 -0
  12. package/icc-api/model/Receipt.js.map +1 -1
  13. package/icc-x-api/crypto/BaseExchangeDataManager.js +2 -2
  14. package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
  15. package/icc-x-api/crypto/ExchangeDataManager.js +3 -3
  16. package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
  17. package/icc-x-api/crypto/ExtendedApisUtils.d.ts +1 -1
  18. package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -1
  19. package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +1 -1
  20. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +8 -2
  21. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
  22. package/icc-x-api/crypto/RecoveryDataEncryption.js.map +1 -1
  23. package/icc-x-api/icc-accesslog-x-api.js +7 -7
  24. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  25. package/icc-x-api/icc-calendar-item-x-api.js +7 -7
  26. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  27. package/icc-x-api/icc-classification-x-api.js +4 -5
  28. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  29. package/icc-x-api/icc-code-x-api.d.ts +2 -2
  30. package/icc-x-api/icc-code-x-api.js +3 -33
  31. package/icc-x-api/icc-code-x-api.js.map +1 -1
  32. package/icc-x-api/icc-contact-x-api.js +20 -33
  33. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  34. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  35. package/icc-x-api/icc-document-x-api.d.ts +8 -7
  36. package/icc-x-api/icc-document-x-api.js +64 -22
  37. package/icc-x-api/icc-document-x-api.js.map +1 -1
  38. package/icc-x-api/icc-form-x-api.js +3 -4
  39. package/icc-x-api/icc-form-x-api.js.map +1 -1
  40. package/icc-x-api/icc-helement-x-api.js +11 -11
  41. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  42. package/icc-x-api/icc-invoice-x-api.js +3 -4
  43. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  44. package/icc-x-api/icc-maintenance-task-x-api.js +3 -3
  45. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  46. package/icc-x-api/icc-patient-x-api.js +29 -29
  47. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  48. package/icc-x-api/icc-receipt-x-api.d.ts +40 -0
  49. package/icc-x-api/icc-receipt-x-api.js +79 -1
  50. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  51. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  52. package/icc-x-api/index.js +1 -1
  53. package/icc-x-api/index.js.map +1 -1
  54. package/icc-x-api/utils/code-util.d.ts +23 -0
  55. package/icc-x-api/utils/code-util.js +39 -2
  56. package/icc-x-api/utils/code-util.js.map +1 -1
  57. package/icc-x-api/utils/collection-utils.d.ts +13 -0
  58. package/icc-x-api/utils/collection-utils.js +69 -0
  59. package/icc-x-api/utils/collection-utils.js.map +1 -1
  60. package/icc-x-api/utils/compression-utils.d.ts +28 -0
  61. package/icc-x-api/utils/compression-utils.js +106 -0
  62. package/icc-x-api/utils/compression-utils.js.map +1 -0
  63. package/icc-x-api/utils/crypto-utils.js +7 -7
  64. package/icc-x-api/utils/crypto-utils.js.map +1 -1
  65. package/icc-x-api/utils/formatting-util.d.ts +1 -3
  66. package/icc-x-api/utils/formatting-util.js +15 -17
  67. package/icc-x-api/utils/formatting-util.js.map +1 -1
  68. package/icc-x-api/utils/hcp-util.js +2 -3
  69. package/icc-x-api/utils/hcp-util.js.map +1 -1
  70. package/icc-x-api/utils/insurability-util.js +10 -8
  71. package/icc-x-api/utils/insurability-util.js.map +1 -1
  72. package/icc-x-api/utils/lzma-wasm.d.ts +6 -0
  73. package/icc-x-api/utils/lzma-wasm.js +81 -0
  74. package/icc-x-api/utils/lzma-wasm.js.map +1 -0
  75. package/icc-x-api/utils/mutex.d.ts +12 -0
  76. package/icc-x-api/utils/mutex.js +26 -0
  77. package/icc-x-api/utils/mutex.js.map +1 -0
  78. package/icc-x-api/utils/websocket.js +7 -7
  79. package/icc-x-api/utils/websocket.js.map +1 -1
  80. package/icc-x-api/wasm/lzma/lzma.js +2 -0
  81. package/icc-x-api/wasm/lzma/lzma.wasm +0 -0
  82. package/package.json +2 -11
  83. package/icc-x-api/utils/uuid-encoder.d.ts +0 -44
  84. package/icc-x-api/utils/uuid-encoder.js +0 -114
  85. package/icc-x-api/utils/uuid-encoder.js.map +0 -1
  86. package/test/icc-api/api/IccAgendaApi.d.ts +0 -1
  87. package/test/icc-api/api/IccAgendaApi.js +0 -64
  88. package/test/icc-api/api/IccAgendaApi.js.map +0 -1
  89. package/test/icc-api/api/IccAnonymousAccessApi.d.ts +0 -1
  90. package/test/icc-api/api/IccAnonymousAccessApi.js +0 -58
  91. package/test/icc-api/api/IccAnonymousAccessApi.js.map +0 -1
  92. package/test/icc-api/api/IccCalendarItemApi.d.ts +0 -1
  93. package/test/icc-api/api/IccCalendarItemApi.js +0 -67
  94. package/test/icc-api/api/IccCalendarItemApi.js.map +0 -1
  95. package/test/icc-api/api/IccCalendarItemTypeApi.d.ts +0 -1
  96. package/test/icc-api/api/IccCalendarItemTypeApi.js +0 -96
  97. package/test/icc-api/api/IccCalendarItemTypeApi.js.map +0 -1
  98. package/test/icc-api/api/IccCodeApi.d.ts +0 -1
  99. package/test/icc-api/api/IccCodeApi.js +0 -38
  100. package/test/icc-api/api/IccCodeApi.js.map +0 -1
  101. package/test/icc-api/api/IccDocumentApi.d.ts +0 -1
  102. package/test/icc-api/api/IccDocumentApi.js +0 -199
  103. package/test/icc-api/api/IccDocumentApi.js.map +0 -1
  104. package/test/icc-api/api/IccGroupApi.d.ts +0 -1
  105. package/test/icc-api/api/IccGroupApi.js +0 -50
  106. package/test/icc-api/api/IccGroupApi.js.map +0 -1
  107. package/test/icc-api/api/IccKeywordApi.d.ts +0 -1
  108. package/test/icc-api/api/IccKeywordApi.js +0 -64
  109. package/test/icc-api/api/IccKeywordApi.js.map +0 -1
  110. package/test/icc-api/api/IccMedicalLocationApi.d.ts +0 -1
  111. package/test/icc-api/api/IccMedicalLocationApi.js +0 -64
  112. package/test/icc-api/api/IccMedicalLocationApi.js.map +0 -1
  113. package/test/icc-api/api/IccPlaceApi.d.ts +0 -1
  114. package/test/icc-api/api/IccPlaceApi.js +0 -64
  115. package/test/icc-api/api/IccPlaceApi.js.map +0 -1
  116. package/test/icc-api/api/IccRecoveryDataApi.d.ts +0 -1
  117. package/test/icc-api/api/IccRecoveryDataApi.js +0 -95
  118. package/test/icc-api/api/IccRecoveryDataApi.js.map +0 -1
  119. package/test/icc-api/api/IccRoleApi.d.ts +0 -1
  120. package/test/icc-api/api/IccRoleApi.js +0 -34
  121. package/test/icc-api/api/IccRoleApi.js.map +0 -1
  122. package/test/icc-api/api/IccUserApi.d.ts +0 -1
  123. package/test/icc-api/api/IccUserApi.js +0 -96
  124. package/test/icc-api/api/IccUserApi.js.map +0 -1
  125. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +0 -1
  126. package/test/icc-api/e2e/IccCalendarItemApi.js +0 -46
  127. package/test/icc-api/e2e/IccCalendarItemApi.js.map +0 -1
  128. package/test/icc-api/model/modelHelpersTest.d.ts +0 -1
  129. package/test/icc-api/model/modelHelpersTest.js +0 -45
  130. package/test/icc-api/model/modelHelpersTest.js.map +0 -1
  131. package/test/icc-x-api/auth/group-switch-test.d.ts +0 -1
  132. package/test/icc-x-api/auth/group-switch-test.js +0 -81
  133. package/test/icc-x-api/auth/group-switch-test.js.map +0 -1
  134. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +0 -2
  135. package/test/icc-x-api/auth/jwt-concurrency-test.js +0 -112
  136. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +0 -1
  137. package/test/icc-x-api/auth/jwt-provider-test.d.ts +0 -1
  138. package/test/icc-x-api/auth/jwt-provider-test.js +0 -197
  139. package/test/icc-x-api/auth/jwt-provider-test.js.map +0 -1
  140. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +0 -1
  141. package/test/icc-x-api/auth/smart-auth-provider-test.js +0 -224
  142. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +0 -1
  143. package/test/icc-x-api/autofix-anonymity-test.d.ts +0 -1
  144. package/test/icc-x-api/autofix-anonymity-test.js +0 -122
  145. package/test/icc-x-api/autofix-anonymity-test.js.map +0 -1
  146. package/test/icc-x-api/confidential-entities-test.d.ts +0 -1
  147. package/test/icc-x-api/confidential-entities-test.js +0 -168
  148. package/test/icc-x-api/confidential-entities-test.js.map +0 -1
  149. package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +0 -1
  150. package/test/icc-x-api/crud/comprehensive-crud-test.js +0 -276
  151. package/test/icc-x-api/crud/comprehensive-crud-test.js.map +0 -1
  152. package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +0 -16
  153. package/test/icc-x-api/crud/entities-crud-test-interface.js +0 -408
  154. package/test/icc-x-api/crud/entities-crud-test-interface.js.map +0 -1
  155. package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +0 -1
  156. package/test/icc-x-api/crypto/anonymous-delegations-test.js +0 -587
  157. package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +0 -1
  158. package/test/icc-x-api/crypto/concurrency.d.ts +0 -1
  159. package/test/icc-x-api/crypto/concurrency.js +0 -35
  160. package/test/icc-x-api/crypto/concurrency.js.map +0 -1
  161. package/test/icc-x-api/crypto/crypto-utils.d.ts +0 -1
  162. package/test/icc-x-api/crypto/crypto-utils.js +0 -79
  163. package/test/icc-x-api/crypto/crypto-utils.js.map +0 -1
  164. package/test/icc-x-api/crypto/cryptoTest.d.ts +0 -2
  165. package/test/icc-x-api/crypto/cryptoTest.js +0 -402
  166. package/test/icc-x-api/crypto/cryptoTest.js.map +0 -1
  167. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +0 -1
  168. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +0 -166
  169. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +0 -1
  170. package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +0 -1
  171. package/test/icc-x-api/crypto/exchange-data-manager-test.js +0 -674
  172. package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +0 -1
  173. package/test/icc-x-api/crypto/full-crypto-test.d.ts +0 -1
  174. package/test/icc-x-api/crypto/full-crypto-test.js +0 -454
  175. package/test/icc-x-api/crypto/full-crypto-test.js.map +0 -1
  176. package/test/icc-x-api/crypto/legacy-metadata-migration-test.d.ts +0 -1
  177. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js +0 -379
  178. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +0 -1
  179. package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +0 -1
  180. package/test/icc-x-api/crypto/secure-delegations-manager-test.js +0 -278
  181. package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +0 -1
  182. package/test/icc-x-api/crypto/shamir.d.ts +0 -2
  183. package/test/icc-x-api/crypto/shamir.js +0 -167
  184. package/test/icc-x-api/crypto/shamir.js.map +0 -1
  185. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +0 -1
  186. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +0 -71
  187. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +0 -1
  188. package/test/icc-x-api/crypto/soft-deleted-data-owners.d.ts +0 -2
  189. package/test/icc-x-api/crypto/soft-deleted-data-owners.js +0 -113
  190. package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +0 -1
  191. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +0 -1
  192. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +0 -246
  193. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +0 -1
  194. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +0 -1
  195. package/test/icc-x-api/entity-with-attachments-api-test.js +0 -142
  196. package/test/icc-x-api/entity-with-attachments-api-test.js.map +0 -1
  197. package/test/icc-x-api/filters/filters.d.ts +0 -1
  198. package/test/icc-x-api/filters/filters.js +0 -49
  199. package/test/icc-x-api/filters/filters.js.map +0 -1
  200. package/test/icc-x-api/filters/healthelement.d.ts +0 -1
  201. package/test/icc-x-api/filters/healthelement.js +0 -333
  202. package/test/icc-x-api/filters/healthelement.js.map +0 -1
  203. package/test/icc-x-api/icc-accesslog-x-api.d.ts +0 -1
  204. package/test/icc-x-api/icc-accesslog-x-api.js +0 -106
  205. package/test/icc-x-api/icc-accesslog-x-api.js.map +0 -1
  206. package/test/icc-x-api/icc-application-settings-x-api.d.ts +0 -1
  207. package/test/icc-x-api/icc-application-settings-x-api.js +0 -91
  208. package/test/icc-x-api/icc-application-settings-x-api.js.map +0 -1
  209. package/test/icc-x-api/icc-auth-api.d.ts +0 -1
  210. package/test/icc-x-api/icc-auth-api.js +0 -47
  211. package/test/icc-x-api/icc-auth-api.js.map +0 -1
  212. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +0 -1
  213. package/test/icc-x-api/icc-calendar-item-x-api.js +0 -150
  214. package/test/icc-x-api/icc-calendar-item-x-api.js.map +0 -1
  215. package/test/icc-x-api/icc-contact-x-api.d.ts +0 -1
  216. package/test/icc-x-api/icc-contact-x-api.js +0 -355
  217. package/test/icc-x-api/icc-contact-x-api.js.map +0 -1
  218. package/test/icc-x-api/icc-document-x-api.d.ts +0 -1
  219. package/test/icc-x-api/icc-document-x-api.js +0 -76
  220. package/test/icc-x-api/icc-document-x-api.js.map +0 -1
  221. package/test/icc-x-api/icc-form-x-api.d.ts +0 -1
  222. package/test/icc-x-api/icc-form-x-api.js +0 -413
  223. package/test/icc-x-api/icc-form-x-api.js.map +0 -1
  224. package/test/icc-x-api/icc-hcparty-x-api-test.d.ts +0 -1
  225. package/test/icc-x-api/icc-hcparty-x-api-test.js +0 -43
  226. package/test/icc-x-api/icc-hcparty-x-api-test.js.map +0 -1
  227. package/test/icc-x-api/icc-helement-x-api-test.d.ts +0 -1
  228. package/test/icc-x-api/icc-helement-x-api-test.js +0 -155
  229. package/test/icc-x-api/icc-helement-x-api-test.js.map +0 -1
  230. package/test/icc-x-api/icc-invoice-x-api.d.ts +0 -1
  231. package/test/icc-x-api/icc-invoice-x-api.js +0 -99
  232. package/test/icc-x-api/icc-invoice-x-api.js.map +0 -1
  233. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +0 -1
  234. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +0 -222
  235. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +0 -1
  236. package/test/icc-x-api/icc-message-x-api.d.ts +0 -1
  237. package/test/icc-x-api/icc-message-x-api.js +0 -54
  238. package/test/icc-x-api/icc-message-x-api.js.map +0 -1
  239. package/test/icc-x-api/icc-patient-x-api-test.d.ts +0 -1
  240. package/test/icc-x-api/icc-patient-x-api-test.js +0 -165
  241. package/test/icc-x-api/icc-patient-x-api-test.js.map +0 -1
  242. package/test/icc-x-api/icc-recovery-x-api.d.ts +0 -1
  243. package/test/icc-x-api/icc-recovery-x-api.js +0 -175
  244. package/test/icc-x-api/icc-recovery-x-api.js.map +0 -1
  245. package/test/icc-x-api/icc-topic-x-api.d.ts +0 -1
  246. package/test/icc-x-api/icc-topic-x-api.js +0 -269
  247. package/test/icc-x-api/icc-topic-x-api.js.map +0 -1
  248. package/test/icc-x-api/icc-user-x-api-test.d.ts +0 -1
  249. package/test/icc-x-api/icc-user-x-api-test.js +0 -99
  250. package/test/icc-x-api/icc-user-x-api-test.js.map +0 -1
  251. package/test/icc-x-api/keyless-api.d.ts +0 -1
  252. package/test/icc-x-api/keyless-api.js +0 -125
  253. package/test/icc-x-api/keyless-api.js.map +0 -1
  254. package/test/icc-x-api/patient-user.d.ts +0 -2
  255. package/test/icc-x-api/patient-user.js +0 -103
  256. package/test/icc-x-api/patient-user.js.map +0 -1
  257. package/test/icc-x-api/storage/storage.d.ts +0 -1
  258. package/test/icc-x-api/storage/storage.js +0 -48
  259. package/test/icc-x-api/storage/storage.js.map +0 -1
  260. package/test/icc-x-api/test-api-no-parent.d.ts +0 -1
  261. package/test/icc-x-api/test-api-no-parent.js +0 -79
  262. package/test/icc-x-api/test-api-no-parent.js.map +0 -1
  263. package/test/icc-x-api/test-legacy-data-support.d.ts +0 -1
  264. package/test/icc-x-api/test-legacy-data-support.js +0 -375
  265. package/test/icc-x-api/test-legacy-data-support.js.map +0 -1
  266. package/test/icc-x-api/utils/graph-test.d.ts +0 -1
  267. package/test/icc-x-api/utils/graph-test.js +0 -54
  268. package/test/icc-x-api/utils/graph-test.js.map +0 -1
  269. package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +0 -1
  270. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +0 -364
  271. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +0 -1
  272. package/test/support/CSM-185.d.ts +0 -1
  273. package/test/support/CSM-185.js +0 -124
  274. package/test/support/CSM-185.js.map +0 -1
  275. package/test/support/CSM-243.d.ts +0 -1
  276. package/test/support/CSM-243.js +0 -120
  277. package/test/support/CSM-243.js.map +0 -1
  278. package/test/support/CSM-543.d.ts +0 -1
  279. package/test/support/CSM-543.js +0 -164
  280. package/test/support/CSM-543.js.map +0 -1
  281. package/test/support/CSM-729.d.ts +0 -1
  282. package/test/support/CSM-729.js +0 -225
  283. package/test/support/CSM-729.js.map +0 -1
  284. package/test/support/CSM-87.d.ts +0 -0
  285. package/test/support/CSM-87.js +0 -21
  286. package/test/support/CSM-87.js.map +0 -1
  287. package/test/support/CSM-93.d.ts +0 -1
  288. package/test/support/CSM-93.js +0 -112
  289. package/test/support/CSM-93.js.map +0 -1
  290. package/test/utils/FakeDataOwnerApi.d.ts +0 -32
  291. package/test/utils/FakeDataOwnerApi.js +0 -136
  292. package/test/utils/FakeDataOwnerApi.js.map +0 -1
  293. package/test/utils/FakeEncryptionKeysManager.d.ts +0 -36
  294. package/test/utils/FakeEncryptionKeysManager.js +0 -98
  295. package/test/utils/FakeEncryptionKeysManager.js.map +0 -1
  296. package/test/utils/FakeExchangeDataApi.d.ts +0 -32
  297. package/test/utils/FakeExchangeDataApi.js +0 -92
  298. package/test/utils/FakeExchangeDataApi.js.map +0 -1
  299. package/test/utils/FakeExchangeDataManager.d.ts +0 -48
  300. package/test/utils/FakeExchangeDataManager.js +0 -82
  301. package/test/utils/FakeExchangeDataManager.js.map +0 -1
  302. package/test/utils/FakeExchangeDataMapManager.d.ts +0 -12
  303. package/test/utils/FakeExchangeDataMapManager.js +0 -38
  304. package/test/utils/FakeExchangeDataMapManager.js.map +0 -1
  305. package/test/utils/FakeGenericApi.d.ts +0 -16
  306. package/test/utils/FakeGenericApi.js +0 -65
  307. package/test/utils/FakeGenericApi.js.map +0 -1
  308. package/test/utils/KeylessCryptoStrategies.d.ts +0 -23
  309. package/test/utils/KeylessCryptoStrategies.js +0 -26
  310. package/test/utils/KeylessCryptoStrategies.js.map +0 -1
  311. package/test/utils/TestApi.d.ts +0 -3
  312. package/test/utils/TestApi.js +0 -30
  313. package/test/utils/TestApi.js.map +0 -1
  314. package/test/utils/TestCollectionUtils.d.ts +0 -1
  315. package/test/utils/TestCollectionUtils.js +0 -109
  316. package/test/utils/TestCollectionUtils.js.map +0 -1
  317. package/test/utils/TestCryptoStrategies.d.ts +0 -42
  318. package/test/utils/TestCryptoStrategies.js +0 -80
  319. package/test/utils/TestCryptoStrategies.js.map +0 -1
  320. package/test/utils/TestStorage.d.ts +0 -23
  321. package/test/utils/TestStorage.js +0 -61
  322. package/test/utils/TestStorage.js.map +0 -1
  323. package/test/utils/roles.d.ts +0 -14
  324. package/test/utils/roles.js +0 -345
  325. package/test/utils/roles.js.map +0 -1
  326. package/test/utils/test_utils.d.ts +0 -87
  327. package/test/utils/test_utils.js +0 -452
  328. package/test/utils/test_utils.js.map +0 -1
@@ -1,120 +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 test_utils_1 = require("../utils/test_utils");
13
- const crypto_1 = require("crypto");
14
- const chai_1 = require("chai");
15
- require("isomorphic-fetch");
16
- const types_1 = require("@icure/test-setup/types");
17
- (0, test_utils_1.setLocalStorage)(fetch);
18
- const chaiAsPromised = require("chai-as-promised");
19
- (0, chai_1.use)(chaiAsPromised);
20
- let env;
21
- function createMessage(api, user, props) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- var _a, _b;
24
- const messageBase = {
25
- subject: `Test message - ${api.cryptoApi.primitives.randomUuid()}`,
26
- fromAddress: (_a = props.includeFromAddress) !== null && _a !== void 0 ? _a : api.cryptoApi.primitives.randomUuid(),
27
- toAddresses: [api.cryptoApi.primitives.randomUuid(), (_b = props.includeToAddress) !== null && _b !== void 0 ? _b : api.cryptoApi.primitives.randomUuid()],
28
- received: props.includeRandomReceived ? Math.floor(Math.random() * 1000000) : undefined,
29
- };
30
- return yield api.messageApi.createMessageWithUser(undefined, yield api.messageApi.newInstance(user, messageBase));
31
- });
32
- }
33
- function createTestMessages(api, user, propsForAccessibleMessages, propsForInaccessibleMessages) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const expectedMessages = [];
36
- for (let i = 0; i < 100; i++) {
37
- expectedMessages.push(yield createMessage(api, user, propsForAccessibleMessages));
38
- yield createMessage(api, user, propsForInaccessibleMessages);
39
- }
40
- // Also creates some messages from an unrelated hcp and same from address that should not be retrieved by the test.
41
- const { api: otherApi, user: otherUser } = yield (0, test_utils_1.createNewHcpApi)(env);
42
- for (let i = 0; i < 100; i++) {
43
- yield createMessage(otherApi, otherUser, propsForAccessibleMessages);
44
- }
45
- return expectedMessages;
46
- });
47
- }
48
- function getAllPaginatedMessages(listFunction) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- var _a, _b, _c;
51
- let latestRetrieved;
52
- let allResults = [];
53
- do {
54
- const nextKey = (_a = latestRetrieved === null || latestRetrieved === void 0 ? void 0 : latestRetrieved.nextKeyPair) === null || _a === void 0 ? void 0 : _a.startKey;
55
- latestRetrieved = yield listFunction(nextKey ? JSON.stringify(nextKey) : undefined, (_b = latestRetrieved === null || latestRetrieved === void 0 ? void 0 : latestRetrieved.nextKeyPair) === null || _b === void 0 ? void 0 : _b.startKeyDocId);
56
- allResults.push(...latestRetrieved.rows);
57
- } while (((_c = latestRetrieved === null || latestRetrieved === void 0 ? void 0 : latestRetrieved.nextKeyPair) === null || _c === void 0 ? void 0 : _c.startKey) !== undefined);
58
- console.log(JSON.stringify(allResults.map((m) => m.received)));
59
- return allResults;
60
- });
61
- }
62
- describe('CSM-243', function () {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- before(function () {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- this.timeout(600000);
67
- const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
68
- env = yield initializer.execute((0, types_1.getEnvVariables)());
69
- });
70
- });
71
- function doTestWithoutReceived(propsForAccessibleMessages, listFunction) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const { api, user } = yield (0, test_utils_1.createNewHcpApi)(env);
74
- const expectedMessages = yield createTestMessages(api, user, Object.assign(Object.assign({}, propsForAccessibleMessages), { includeRandomReceived: false }), { includeRandomReceived: false });
75
- let allResults = yield getAllPaginatedMessages((nextKey, nextKeyDocId) => listFunction(api.messageApi, nextKey, nextKeyDocId, 30));
76
- (0, chai_1.expect)(allResults.length).to.equal(expectedMessages.length);
77
- (0, chai_1.expect)(allResults.map((m) => m.id)).to.have.members(expectedMessages.map((m) => m.id));
78
- });
79
- }
80
- function doTestWithReceived(propsForAccessibleMessages, listFunction) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- const { api, user } = yield (0, test_utils_1.createNewHcpApi)(env);
83
- const expectedMessagesWithReceived = yield createTestMessages(api, user, Object.assign(Object.assign({}, propsForAccessibleMessages), { includeRandomReceived: true }), { includeRandomReceived: true });
84
- const messageWithoutReceived = yield createMessage(api, user, Object.assign(Object.assign({}, propsForAccessibleMessages), { includeRandomReceived: false }));
85
- let allResults = yield getAllPaginatedMessages((nextKey, nextKeyDocId) => listFunction(api.messageApi, nextKey, nextKeyDocId, 30));
86
- (0, chai_1.expect)(allResults.length).to.equal(expectedMessagesWithReceived.length + 1);
87
- (0, chai_1.expect)(allResults.map((m) => m.id)).to.have.members([...expectedMessagesWithReceived.map((m) => m.id), messageWithoutReceived.id]);
88
- (0, chai_1.expect)(allResults.map((m) => m.received)).to.deep.equal([
89
- undefined,
90
- ...expectedMessagesWithReceived.sort((a, b) => b.received - a.received).map((m) => m.received),
91
- ]);
92
- });
93
- }
94
- it('A user should be able to retrieve paginated messages without received date by fromAddress', function () {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- const targetAddress = (0, crypto_1.randomUUID)();
97
- yield doTestWithoutReceived({ includeFromAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) => messageApi.findMessagesByFromAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit));
98
- });
99
- });
100
- it('A user should be able to retrieve paginated messages with received date by fromAddress', function () {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- const targetAddress = (0, crypto_1.randomUUID)();
103
- yield doTestWithReceived({ includeFromAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) => messageApi.findMessagesByFromAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit));
104
- });
105
- });
106
- it('A user should be able to retrieve paginated messages without received date by toAddress', function () {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const targetAddress = (0, crypto_1.randomUUID)();
109
- yield doTestWithoutReceived({ includeToAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) => messageApi.findMessagesByToAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit));
110
- });
111
- });
112
- it('A user should be able to retrieve paginated messages with received date by toAddress', function () {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- const targetAddress = (0, crypto_1.randomUUID)();
115
- yield doTestWithReceived({ includeToAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) => messageApi.findMessagesByToAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit));
116
- });
117
- });
118
- });
119
- });
120
- //# sourceMappingURL=CSM-243.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CSM-243.js","sourceRoot":"","sources":["../../../test/support/CSM-243.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAiG;AAEjG,mCAAmC;AACnC,+BAA6C;AAC7C,4BAAyB;AACzB,mDAAmE;AAEnE,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,mDAAkD;AAIlD,IAAA,UAAO,EAAC,cAAc,CAAC,CAAA;AAEvB,IAAI,GAAa,CAAA;AAEjB,SAAe,aAAa,CAC1B,GAAa,EAC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cesContent":["import { createNewHcpApi, getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { IccMessageXApi, IcureApi } from '../../icc-x-api'\nimport { randomUUID } from 'crypto'\nimport { expect, use as chaiUse } from 'chai'\nimport 'isomorphic-fetch'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\nsetLocalStorage(fetch)\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { User } from '../../icc-api/model/User'\nimport { Message } from '../../icc-api/model/Message'\nimport { PaginatedListMessage } from '../../icc-api/model/PaginatedListMessage'\nchaiUse(chaiAsPromised)\n\nlet env: TestVars\n\nasync function createMessage(\n api: IcureApi,\n user: User,\n props: {\n includeToAddress?: string\n includeFromAddress?: string\n includeRandomReceived: boolean\n }\n): Promise<Message> {\n const messageBase: Message = {\n subject: `Test message - ${api.cryptoApi.primitives.randomUuid()}`,\n fromAddress: props.includeFromAddress ?? api.cryptoApi.primitives.randomUuid(),\n toAddresses: [api.cryptoApi.primitives.randomUuid(), props.includeToAddress ?? api.cryptoApi.primitives.randomUuid()],\n received: props.includeRandomReceived ? Math.floor(Math.random() * 1000000) : undefined,\n }\n return await api.messageApi.createMessageWithUser(undefined, await api.messageApi.newInstance(user, messageBase))\n}\n\nasync function createTestMessages(\n api: IcureApi,\n user: User,\n propsForAccessibleMessages: {\n includeToAddress?: string\n includeFromAddress?: string\n includeRandomReceived: boolean\n },\n propsForInaccessibleMessages: {\n includeToAddress?: string\n includeFromAddress?: string\n includeRandomReceived: boolean\n }\n): Promise<Message[]> {\n const expectedMessages: Message[] = []\n for (let i = 0; i < 100; i++) {\n expectedMessages.push(await createMessage(api, user, propsForAccessibleMessages))\n await createMessage(api, user, propsForInaccessibleMessages)\n }\n // Also creates some messages from an unrelated hcp and same from address that should not be retrieved by the test.\n const { api: otherApi, user: otherUser } = await createNewHcpApi(env)\n for (let i = 0; i < 100; i++) {\n await createMessage(otherApi, otherUser, propsForAccessibleMessages)\n }\n return expectedMessages\n}\n\nasync function getAllPaginatedMessages(listFunction: (nextKey?: string, nextKeyDocId?: string) => Promise<PaginatedListMessage>): Promise<Message[]> {\n let latestRetrieved: PaginatedListMessage | undefined\n let allResults: Message[] = []\n do {\n const nextKey = latestRetrieved?.nextKeyPair?.startKey\n latestRetrieved = await listFunction(nextKey ? JSON.stringify(nextKey) : undefined, latestRetrieved?.nextKeyPair?.startKeyDocId)\n allResults.push(...latestRetrieved.rows!)\n } while (latestRetrieved?.nextKeyPair?.startKey !== undefined)\n console.log(JSON.stringify(allResults.map((m) => m.received)))\n return allResults\n}\n\ndescribe('CSM-243', async function () {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n async function doTestWithoutReceived(\n propsForAccessibleMessages: {\n includeToAddress?: string\n includeFromAddress?: string\n },\n listFunction: (\n messageApi: IccMessageXApi,\n nextKey: string | undefined,\n nextKeyDocId: string | undefined,\n limit: number\n ) => Promise<PaginatedListMessage>\n ) {\n const { api, user } = await createNewHcpApi(env)\n const expectedMessages: Message[] = await createTestMessages(\n api,\n user,\n { ...propsForAccessibleMessages, includeRandomReceived: false },\n { includeRandomReceived: false }\n )\n let allResults: Message[] = await getAllPaginatedMessages((nextKey?: string, nextKeyDocId?: string) =>\n listFunction(api.messageApi, nextKey, nextKeyDocId, 30)\n )\n expect(allResults.length).to.equal(expectedMessages.length)\n expect(allResults.map((m) => m.id)).to.have.members(expectedMessages.map((m) => m.id))\n }\n\n async function doTestWithReceived(\n propsForAccessibleMessages: {\n includeToAddress?: string\n includeFromAddress?: string\n },\n listFunction: (\n messageApi: IccMessageXApi,\n nextKey: string | undefined,\n nextKeyDocId: string | undefined,\n limit: number\n ) => Promise<PaginatedListMessage>\n ) {\n const { api, user } = await createNewHcpApi(env)\n const expectedMessagesWithReceived: Message[] = await createTestMessages(\n api,\n user,\n { ...propsForAccessibleMessages, includeRandomReceived: true },\n { includeRandomReceived: true }\n )\n const messageWithoutReceived = await createMessage(api, user, { ...propsForAccessibleMessages, includeRandomReceived: false })\n let allResults: Message[] = await getAllPaginatedMessages((nextKey?: string, nextKeyDocId?: string) =>\n listFunction(api.messageApi, nextKey, nextKeyDocId, 30)\n )\n expect(allResults.length).to.equal(expectedMessagesWithReceived.length + 1)\n expect(allResults.map((m) => m.id)).to.have.members([...expectedMessagesWithReceived.map((m) => m.id), messageWithoutReceived.id!])\n expect(allResults.map((m) => m.received)).to.deep.equal([\n undefined,\n ...expectedMessagesWithReceived.sort((a, b) => b.received! - a.received!).map((m) => m.received),\n ])\n }\n it('A user should be able to retrieve paginated messages without received date by fromAddress', async function () {\n const targetAddress = randomUUID()\n await doTestWithoutReceived({ includeFromAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) =>\n messageApi.findMessagesByFromAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit)\n )\n })\n\n it('A user should be able to retrieve paginated messages with received date by fromAddress', async function () {\n const targetAddress = randomUUID()\n await doTestWithReceived({ includeFromAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) =>\n messageApi.findMessagesByFromAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit)\n )\n })\n\n it('A user should be able to retrieve paginated messages without received date by toAddress', async function () {\n const targetAddress = randomUUID()\n await doTestWithoutReceived({ includeToAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) =>\n messageApi.findMessagesByToAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit)\n )\n })\n\n it('A user should be able to retrieve paginated messages with received date by toAddress', async function () {\n const targetAddress = randomUUID()\n await doTestWithReceived({ includeToAddress: targetAddress }, (messageApi, nextKey, nextKeyDocId, limit) =>\n messageApi.findMessagesByToAddressWithUser(undefined, targetAddress, nextKey, nextKeyDocId, limit)\n )\n })\n})\n"]}
@@ -1 +0,0 @@
1
- import 'isomorphic-fetch';
@@ -1,164 +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 test_utils_1 = require("../utils/test_utils");
13
- const icc_x_api_1 = require("../../icc-x-api");
14
- const crypto_1 = require("crypto");
15
- const chai_1 = require("chai");
16
- require("isomorphic-fetch");
17
- const types_1 = require("@icure/test-setup/types");
18
- const chaiAsPromised = require("chai-as-promised");
19
- const utils_1 = require("../../icc-x-api/crypto/utils");
20
- const TestStorage_1 = require("../utils/TestStorage");
21
- const DataOwnerTypeEnum_1 = require("../../icc-api/model/DataOwnerTypeEnum");
22
- (0, test_utils_1.setLocalStorage)(fetch);
23
- (0, chai_1.use)(chaiAsPromised);
24
- let env;
25
- class RecoverParentKeyVerifySelfKeyStrategy {
26
- constructor(parentKeys, selfPub) {
27
- this.parentKeys = parentKeys;
28
- this.selfPub = selfPub;
29
- }
30
- dataOwnerRequiresAnonymousDelegation(dataOwner) {
31
- return dataOwner.type != DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp;
32
- }
33
- generateNewKeyForDataOwner(self, cryptoPrimitives) {
34
- return Promise.resolve(false);
35
- }
36
- recoverAndVerifySelfHierarchyKeys(keysData, cryptoPrimitives, keyPairRecoverer) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- (0, chai_1.expect)(keysData).to.have.length(2);
39
- return {
40
- [keysData[0].dataOwner.dataOwner.id]: {
41
- recoveredKeys: {
42
- [(0, utils_1.fingerprintV1)((0, icc_x_api_1.ua2hex)(yield cryptoPrimitives.RSA.exportKey(this.parentKeys.publicKey, 'spki')))]: this.parentKeys,
43
- },
44
- keyAuthenticity: {},
45
- },
46
- [keysData[1].dataOwner.dataOwner.id]: {
47
- recoveredKeys: {},
48
- keyAuthenticity: {
49
- [(0, utils_1.fingerprintV1)(this.selfPub)]: true,
50
- },
51
- },
52
- };
53
- });
54
- }
55
- verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
56
- return Promise.resolve(publicKeys);
57
- }
58
- }
59
- class VerifySelfKeyStrategy {
60
- constructor(selfPub) {
61
- this.selfPub = selfPub;
62
- }
63
- dataOwnerRequiresAnonymousDelegation(dataOwner) {
64
- return dataOwner.type != DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp;
65
- }
66
- generateNewKeyForDataOwner(self, cryptoPrimitives) {
67
- return Promise.resolve(false);
68
- }
69
- recoverAndVerifySelfHierarchyKeys(keysData, cryptoPrimitives, keyPairRecoverer) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- (0, chai_1.expect)(keysData).to.have.length(2);
72
- (0, chai_1.expect)(keysData.every((x) => x.unavailableKeys.length == 0)).to.be.true;
73
- (0, chai_1.expect)(keysData[1].unknownKeys).to.have.length(1);
74
- (0, chai_1.expect)(keysData[1].unknownKeys[0]).to.eq(this.selfPub);
75
- return {
76
- [keysData[0].dataOwner.dataOwner.id]: {
77
- recoveredKeys: {},
78
- keyAuthenticity: {},
79
- },
80
- [keysData[1].dataOwner.dataOwner.id]: {
81
- recoveredKeys: {},
82
- keyAuthenticity: { [(0, utils_1.fingerprintV1)(this.selfPub)]: true },
83
- },
84
- };
85
- });
86
- }
87
- verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
88
- return Promise.resolve(publicKeys);
89
- }
90
- }
91
- describe('CSM-543', function () {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- before(function () {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- this.timeout(600000);
96
- const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
97
- env = yield initializer.execute((0, types_1.getEnvVariables)());
98
- });
99
- });
100
- function init() {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- const { grandUser: parentUser, grandApi: parentApi, grandCredentials: parentCredentials, parentUser: childUser, parentApi: childApi, parentCredentials: childCredentials, } = yield (0, test_utils_1.createHcpHierarchyApis)(env);
103
- const initialKeys = yield childApi.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy();
104
- (0, chai_1.expect)(initialKeys.self.keys).to.have.length(1);
105
- (0, chai_1.expect)(initialKeys.self.keys[0].verified).to.eq(true);
106
- (0, chai_1.expect)(initialKeys.parents).to.have.length(1);
107
- (0, chai_1.expect)(initialKeys.parents[0].keys).to.have.length(1);
108
- (0, chai_1.expect)(initialKeys.parents[0].keys[0].verified).to.eq(true);
109
- const selfKeyPub = (0, icc_x_api_1.ua2hex)(yield childApi.cryptoApi.primitives.RSA.exportKey(initialKeys.self.keys[0].pair.publicKey, 'spki'));
110
- yield childApi.cryptoApi.shamirKeysManager.updateSelfSplits({ [(0, utils_1.fingerprintV1)(selfKeyPub)]: { notariesIds: [parentCredentials.dataOwnerId], minShares: 1 } }, []);
111
- return {
112
- childCredentials,
113
- selfKeyPub,
114
- parentKey: initialKeys.parents[0].keys[0].pair,
115
- parentCredentials,
116
- };
117
- });
118
- }
119
- function checkKeys(api, expectedSelfKey) {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- const recoveredKeys = yield api.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy();
122
- (0, chai_1.expect)(recoveredKeys.self.keys).to.have.length(1);
123
- (0, chai_1.expect)(recoveredKeys.self.keys[0].verified).to.eq(true);
124
- (0, chai_1.expect)(recoveredKeys.parents).to.have.length(1);
125
- (0, chai_1.expect)(recoveredKeys.parents[0].keys).to.have.length(1);
126
- (0, chai_1.expect)(recoveredKeys.parents[0].keys[0].verified).to.eq(true);
127
- (0, chai_1.expect)((0, icc_x_api_1.ua2hex)(yield api.cryptoApi.primitives.RSA.exportKey(recoveredKeys.self.keys[0].pair.publicKey, 'spki'))).to.eq(expectedSelfKey);
128
- });
129
- }
130
- it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key recovered by crypto strategies', function () {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- const { childCredentials, selfKeyPub, parentKey } = yield init();
133
- const apiWithLostKey = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: childCredentials.user, password: childCredentials.password }, new RecoverParentKeyVerifySelfKeyStrategy(parentKey, selfKeyPub), crypto_1.webcrypto, fetch, {
134
- storage: new TestStorage_1.TestStorage(),
135
- keyStorage: new TestStorage_1.TestKeyStorage(),
136
- });
137
- yield checkKeys(apiWithLostKey, selfKeyPub);
138
- });
139
- });
140
- it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key available in storage', function () {
141
- return __awaiter(this, void 0, void 0, function* () {
142
- const { childCredentials, selfKeyPub, parentCredentials } = yield init();
143
- const storageWithParentKey = yield (0, TestStorage_1.testStorageWithKeys)([
144
- {
145
- dataOwnerId: parentCredentials.dataOwnerId,
146
- pairs: [
147
- {
148
- keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey },
149
- shaVersion: icc_x_api_1.ShaVersion.Sha1,
150
- },
151
- ],
152
- },
153
- ]);
154
- const apiWithLostKey = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: childCredentials.user, password: childCredentials.password }, new VerifySelfKeyStrategy(selfKeyPub), crypto_1.webcrypto, fetch, {
155
- storage: storageWithParentKey.storage,
156
- keyStorage: storageWithParentKey.keyStorage,
157
- entryKeysFactory: storageWithParentKey.keyFactory,
158
- });
159
- yield checkKeys(apiWithLostKey, selfKeyPub);
160
- });
161
- });
162
- });
163
- });
164
- //# sourceMappingURL=CSM-543.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CSM-543.js","sourceRoot":"","sources":["../../../test/support/CSM-543.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAwG;AACxG,+CAA2G;AAC3G,mCAAkC;AAClC,+BAA6C;AAC7C,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,EACL;oBACE,OAAO,EAAE,IAAI,yBAAW,EAAE;oBAC1B,UAAU,EAAE,IAAI,4BAAc,EAAE;iBACjC,CACF,CAAA;gBACD,MAAM,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;YAC7C,CAAC;SAAA,CAAC,CAAA;QAEF,EAAE,CAAC,6HAA6H,EAAE;;gBAChI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;gBACxE,MAAM,oBAAoB,GAAG,MAAM,IAAA,iCAAmB,EAAC;oBACrD;wBACE,WAAW,EAAE,iBAAiB,CAAC,WAAY;wBAC3C,KAAK,EAAE;4BACL;gCACE,OAAO,EAAE,EAAE,UAAU,EAAE,iBAAiB,CAAC,UAAU,EAAE,SAAS,EAAE,iBAAiB,CAAC,SAAS,EAAE;gCAC7F,UAAU,EAAE,sBAAU,CAAC,IAAI;6BAC5B;yBACF;qBACF;iBACF,CAAC,CAAA;gBACF,MAAM,cAAc,GAAG,MAAM,oBAAQ,CAAC,UAAU,CAC9C,GAAG,CAAC,QAAQ,EACZ,EAAE,QAAQ,EAAE,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,EAAE,EACxE,IAAI,qBAAqB,CAAC,UAAU,CAAC,EACrC,kBAAgB,EAChB,KAAK,EACL;oBACE,OAAO,EAAE,oBAAoB,CAAC,OAAO;oBACrC,UAAU,EAAE,oBAAoB,CAAC,UAAU;oBAC3C,gBAAgB,EAAE,oBAAoB,CAAC,UAAU;iBAClD,CACF,CAAA;gBACD,MAAM,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;YAC7C,CAAC;SAAA,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { createHcpHierarchyApis, getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { CryptoPrimitives, CryptoStrategies, IcureApi, KeyPair, ShaVersion, ua2hex } from '../../icc-x-api'\nimport { webcrypto } from 'crypto'\nimport { expect, use as chaiUse } from 'chai'\nimport 'isomorphic-fetch'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { fingerprintV1 } from '../../icc-x-api/crypto/utils'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../utils/TestStorage'\nimport { KeyPairRecoverer } from '../../icc-x-api/crypto/KeyPairRecoverer'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\n\nsetLocalStorage(fetch)\n\nchaiUse(chaiAsPromised)\n\nlet env: TestVars\n\nclass RecoverParentKeyVerifySelfKeyStrategy implements CryptoStrategies {\n constructor(private readonly parentKeys: KeyPair<CryptoKey>, private readonly selfPub: string) {}\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return dataOwner.type != DataOwnerTypeEnum.Hcp\n }\n\n generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean | 'keyless'> {\n return Promise.resolve(false)\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives,\n keyPairRecoverer: KeyPairRecoverer\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n expect(keysData).to.have.length(2)\n return {\n [keysData[0].dataOwner.dataOwner.id!]: {\n recoveredKeys: {\n [fingerprintV1(ua2hex(await cryptoPrimitives.RSA.exportKey(this.parentKeys.publicKey, 'spki')))]: this.parentKeys,\n },\n keyAuthenticity: {},\n },\n [keysData[1].dataOwner.dataOwner.id!]: {\n recoveredKeys: {},\n keyAuthenticity: {\n [fingerprintV1(this.selfPub)]: true,\n },\n },\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\n\nclass VerifySelfKeyStrategy implements CryptoStrategies {\n constructor(private readonly selfPub: string) {}\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return dataOwner.type != DataOwnerTypeEnum.Hcp\n }\n\n generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean | 'keyless'> {\n return Promise.resolve(false)\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives,\n keyPairRecoverer: KeyPairRecoverer\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n expect(keysData).to.have.length(2)\n expect(keysData.every((x) => x.unavailableKeys.length == 0)).to.be.true\n expect(keysData[1].unknownKeys).to.have.length(1)\n expect(keysData[1].unknownKeys[0]).to.eq(this.selfPub)\n return {\n [keysData[0].dataOwner.dataOwner.id!]: {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n [keysData[1].dataOwner.dataOwner.id!]: {\n recoveredKeys: {},\n keyAuthenticity: { [fingerprintV1(this.selfPub)]: true },\n },\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\n\ndescribe('CSM-543', async function () {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n async function init() {\n const {\n grandUser: parentUser,\n grandApi: parentApi,\n grandCredentials: parentCredentials,\n parentUser: childUser,\n parentApi: childApi,\n parentCredentials: childCredentials,\n } = await createHcpHierarchyApis(env)\n const initialKeys = await childApi.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy()\n expect(initialKeys.self.keys).to.have.length(1)\n expect(initialKeys.self.keys[0].verified).to.eq(true)\n expect(initialKeys.parents).to.have.length(1)\n expect(initialKeys.parents[0].keys).to.have.length(1)\n expect(initialKeys.parents[0].keys[0].verified).to.eq(true)\n const selfKeyPub = ua2hex(await childApi.cryptoApi.primitives.RSA.exportKey(initialKeys.self.keys[0].pair.publicKey, 'spki'))\n await childApi.cryptoApi.shamirKeysManager.updateSelfSplits(\n { [fingerprintV1(selfKeyPub)]: { notariesIds: [parentCredentials.dataOwnerId], minShares: 1 } },\n []\n )\n return {\n childCredentials,\n selfKeyPub,\n parentKey: initialKeys.parents[0].keys[0].pair,\n parentCredentials,\n }\n }\n\n async function checkKeys(api: IcureApi, expectedSelfKey: string) {\n const recoveredKeys = await api.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy()\n expect(recoveredKeys.self.keys).to.have.length(1)\n expect(recoveredKeys.self.keys[0].verified).to.eq(true)\n expect(recoveredKeys.parents).to.have.length(1)\n expect(recoveredKeys.parents[0].keys).to.have.length(1)\n expect(recoveredKeys.parents[0].keys[0].verified).to.eq(true)\n expect(ua2hex(await api.cryptoApi.primitives.RSA.exportKey(recoveredKeys.self.keys[0].pair.publicKey, 'spki'))).to.eq(expectedSelfKey)\n }\n\n it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key recovered by crypto strategies', async function () {\n const { childCredentials, selfKeyPub, parentKey } = await init()\n const apiWithLostKey = await IcureApi.initialise(\n env.iCureUrl,\n { username: childCredentials.user, password: childCredentials.password },\n new RecoverParentKeyVerifySelfKeyStrategy(parentKey, selfKeyPub),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n await checkKeys(apiWithLostKey, selfKeyPub)\n })\n\n it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key available in storage', async function () {\n const { childCredentials, selfKeyPub, parentCredentials } = await init()\n const storageWithParentKey = await testStorageWithKeys([\n {\n dataOwnerId: parentCredentials.dataOwnerId!,\n pairs: [\n {\n keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apiWithLostKey = await IcureApi.initialise(\n env.iCureUrl,\n { username: childCredentials.user, password: childCredentials.password },\n new VerifySelfKeyStrategy(selfKeyPub),\n webcrypto as any,\n fetch,\n {\n storage: storageWithParentKey.storage,\n keyStorage: storageWithParentKey.keyStorage,\n entryKeysFactory: storageWithParentKey.keyFactory,\n }\n )\n await checkKeys(apiWithLostKey, selfKeyPub)\n })\n})\n"]}
@@ -1 +0,0 @@
1
- import 'isomorphic-fetch';
@@ -1,225 +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 test_utils_1 = require("../utils/test_utils");
13
- const icc_x_api_1 = require("../../icc-x-api");
14
- const chai_1 = require("chai");
15
- require("isomorphic-fetch");
16
- const types_1 = require("@icure/test-setup/types");
17
- const chaiAsPromised = require("chai-as-promised");
18
- const utils_1 = require("../../icc-x-api/crypto/utils");
19
- const DataOwnerTypeEnum_1 = require("../../icc-api/model/DataOwnerTypeEnum");
20
- const crypto_1 = require("crypto");
21
- const TestStorage_1 = require("../utils/TestStorage");
22
- const SecureDelegation_1 = require("../../icc-api/model/SecureDelegation");
23
- var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
24
- var initMasterApi = test_utils_1.TestUtils.initMasterApi;
25
- (0, test_utils_1.setLocalStorage)(fetch);
26
- (0, chai_1.use)(chaiAsPromised);
27
- let env;
28
- const untrustedKeyPropId = 'untrustedKey';
29
- class TrustedKeysStrategy {
30
- constructor(parentKeys, selfKeys, options = {}) {
31
- this.parentKeys = parentKeys;
32
- this.selfKeys = selfKeys;
33
- this.options = options;
34
- }
35
- dataOwnerRequiresAnonymousDelegation(dataOwner) {
36
- return dataOwner.type != DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp;
37
- }
38
- recoverAndVerifySelfHierarchyKeys(keysData, cryptoPrimitives, keyPairRecoverer) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- if (this.options.failRecoverAndVerifySelfHierarchyKeys) {
41
- throw new Error("Shouldn't call this method now");
42
- }
43
- (0, chai_1.expect)(keysData).to.have.length(2);
44
- const parentKeysWithFp = yield Promise.all(this.parentKeys.map((k) => __awaiter(this, void 0, void 0, function* () {
45
- return ({
46
- trusted: k.trusted,
47
- fp: (0, utils_1.fingerprintV1)(k.pub),
48
- keypair: yield cryptoPrimitives.RSA.importKeyPair('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.priv)), 'spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.pub)), k.shaVersion),
49
- });
50
- })));
51
- const selfKeysWithFp = yield Promise.all(this.selfKeys.map((k) => __awaiter(this, void 0, void 0, function* () {
52
- return ({
53
- trusted: k.trusted,
54
- fp: (0, utils_1.fingerprintV1)(k.pub),
55
- keypair: yield cryptoPrimitives.RSA.importKeyPair('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.priv)), 'spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(k.pub)), k.shaVersion),
56
- });
57
- })));
58
- return {
59
- [keysData[0].dataOwner.dataOwner.id]: {
60
- recoveredKeys: Object.fromEntries(parentKeysWithFp.map((k) => [k.fp, k.keypair])),
61
- keyAuthenticity: Object.fromEntries(parentKeysWithFp.map((k) => [k.fp, k.trusted])),
62
- },
63
- [keysData[1].dataOwner.dataOwner.id]: {
64
- recoveredKeys: Object.fromEntries(selfKeysWithFp.map((k) => [k.fp, k.keypair])),
65
- keyAuthenticity: Object.fromEntries(selfKeysWithFp.map((k) => [k.fp, k.trusted])),
66
- },
67
- };
68
- });
69
- }
70
- verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
71
- var _a;
72
- const untrusted = new Set((_a = delegate.stub.cryptoActorProperties) === null || _a === void 0 ? void 0 : _a.flatMap((p) => {
73
- var _a;
74
- if (p.id == untrustedKeyPropId && ((_a = p.typedValue) === null || _a === void 0 ? void 0 : _a.stringValue) != undefined) {
75
- return [p.typedValue.stringValue];
76
- }
77
- else {
78
- return [];
79
- }
80
- }));
81
- return Promise.resolve(publicKeys.filter((k) => !untrusted.has((0, utils_1.fingerprintV2)(k))));
82
- }
83
- generateNewKeyForDataOwner(self, cryptoPrimitives) {
84
- if (this.options.overrideGenerateNewKeyForDataOwner) {
85
- return this.options.overrideGenerateNewKeyForDataOwner();
86
- }
87
- return Promise.reject(new Error('Should not be called now'));
88
- }
89
- }
90
- describe('CSM-729', function () {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- before(function () {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- this.timeout(600000);
95
- const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
96
- env = yield initializer.execute((0, types_1.getEnvVariables)());
97
- });
98
- });
99
- it('User with untrusted key', function () {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- const { grandCredentials: parent, parentCredentials: hcp } = yield (0, test_utils_1.createHcpHierarchyApis)(env);
102
- // Create some data to use the original keys
103
- const initialApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: hcp.user, password: hcp.password }, new TrustedKeysStrategy([{ priv: parent.privateKey, pub: parent.publicKey, trusted: true, shaVersion: icc_x_api_1.ShaVersion.Sha1 }], [{ priv: hcp.privateKey, pub: hcp.publicKey, trusted: true, shaVersion: icc_x_api_1.ShaVersion.Sha1 }]), crypto_1.webcrypto, fetch, {
104
- storage: new TestStorage_1.TestStorage(),
105
- keyStorage: new TestStorage_1.TestKeyStorage(),
106
- });
107
- const user = yield initialApi.userApi.getCurrentUser();
108
- const pat1 = yield initialApi.patientApi.createPatientWithUser(user, yield initialApi.patientApi.newInstance(user, {
109
- firstName: 'John',
110
- lastName: 'Doe',
111
- note: 'Secret note',
112
- }, {
113
- additionalDelegates: { [parent.dataOwnerId]: AccessLevelEnum.WRITE },
114
- }));
115
- // Check exchange data was created as expected
116
- const selfSelfXdata = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, hcp.dataOwnerId);
117
- const selfParentXdata = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, parent.dataOwnerId);
118
- (0, chai_1.expect)(selfSelfXdata).to.not.be.undefined;
119
- (0, chai_1.expect)(selfParentXdata).to.not.be.undefined;
120
- (0, chai_1.expect)(selfSelfXdata).to.have.length(1);
121
- (0, chai_1.expect)(selfParentXdata).to.have.length(1);
122
- // Prepare for new api with untrusted key
123
- //// Mark self hcp keys as untrusted
124
- let selfHcp = yield initialApi.healthcarePartyApi.getCurrentHealthcareParty();
125
- selfHcp = yield initialApi.healthcarePartyApi.modifyHealthcareParty(Object.assign(Object.assign({}, selfHcp), { cryptoActorProperties: [
126
- ...(selfHcp.cryptoActorProperties || []),
127
- {
128
- id: untrustedKeyPropId,
129
- typedValue: { stringValue: (0, utils_1.fingerprintV2)(hcp.publicKey) },
130
- },
131
- ] }));
132
- //// Mark parent hcp keys as untrusted and add new key (currently can't be done through crypto strategies)
133
- const newParentKey = yield initialApi.cryptoApi.primitives.RSA.generateKeyPair(icc_x_api_1.ShaVersion.Sha256);
134
- const newParentKeySpki = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newParentKey.publicKey, 'spki'));
135
- const newParentKeyPkcs8 = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newParentKey.privateKey, 'pkcs8'));
136
- const adminApi = yield initMasterApi(env);
137
- let parentHcp = yield adminApi.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId);
138
- parentHcp = yield adminApi.healthcarePartyApi.modifyHealthcareParty(Object.assign(Object.assign({}, parentHcp), { cryptoActorProperties: [
139
- ...(parentHcp.cryptoActorProperties || []),
140
- {
141
- id: untrustedKeyPropId,
142
- typedValue: { stringValue: (0, utils_1.fingerprintV2)(parent.publicKey) },
143
- },
144
- ], publicKeysForOaepWithSha256: [...(parentHcp.publicKeysForOaepWithSha256 || []), newParentKeySpki] }));
145
- //// No need to invalidate exchange data, as untrusted keys are not used to validate it
146
- // Setup new api
147
- let didCreateNewKey = false;
148
- const newHcpKey = yield initialApi.cryptoApi.primitives.RSA.generateKeyPair(icc_x_api_1.ShaVersion.Sha256);
149
- const newHcpKeySpki = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newHcpKey.publicKey, 'spki'));
150
- const newHcpKeyPkcs8 = (0, icc_x_api_1.ua2hex)(yield initialApi.cryptoApi.primitives.RSA.exportKey(newHcpKey.privateKey, 'pkcs8'));
151
- const apiWithUntrustedKeysStorages = {
152
- // Using a new storage, simulates wiping the local storage
153
- storage: new TestStorage_1.TestStorage(),
154
- keyStorage: new TestStorage_1.TestKeyStorage(),
155
- };
156
- const apiWithUntrustedKey = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: hcp.user, password: hcp.password }, new TrustedKeysStrategy([
157
- { priv: parent.privateKey, pub: parent.publicKey, trusted: false, shaVersion: icc_x_api_1.ShaVersion.Sha1 },
158
- { priv: newParentKeyPkcs8, pub: newParentKeySpki, trusted: true, shaVersion: icc_x_api_1.ShaVersion.Sha256 },
159
- ], [{ priv: hcp.privateKey, pub: hcp.publicKey, trusted: false, shaVersion: icc_x_api_1.ShaVersion.Sha1 }], {
160
- overrideGenerateNewKeyForDataOwner: () => {
161
- didCreateNewKey = true;
162
- return Promise.resolve(newHcpKey);
163
- },
164
- }), crypto_1.webcrypto, fetch, apiWithUntrustedKeysStorages);
165
- (0, chai_1.expect)(didCreateNewKey).to.eq(true);
166
- // Check all keys are available but only new keys are trusted
167
- (0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey.healthcarePartyApi.getHealthcareParty(hcp.dataOwnerId))).to.have.members([newHcpKeySpki]);
168
- (0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId))).to.have.members([newParentKeySpki]);
169
- (0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getCurrentUserHierarchyAvailablePublicKeysHex()).to.have.members([
170
- newHcpKeySpki,
171
- hcp.publicKey,
172
- parent.publicKey,
173
- newParentKeySpki,
174
- ]);
175
- (0, chai_1.expect)(yield apiWithUntrustedKey.cryptoApi.userKeysManager.getCurrentUserAvailablePublicKeysHex(false)).to.have.members([
176
- newHcpKeySpki,
177
- hcp.publicKey,
178
- ]);
179
- // Check can still read old data
180
- const pat1Recovered = yield apiWithUntrustedKey.patientApi.getPatientWithUser(user, pat1.id);
181
- (0, chai_1.expect)(pat1Recovered.note).to.eq('Secret note');
182
- // Check can create new data
183
- const pat2 = yield initialApi.patientApi.createPatientWithUser(user, yield initialApi.patientApi.newInstance(user, {
184
- firstName: 'Joe',
185
- lastName: 'Doe',
186
- note: 'Secret note',
187
- }, {
188
- additionalDelegates: { [parent.dataOwnerId]: AccessLevelEnum.WRITE },
189
- }));
190
- // Check created new exchange data and only used the new trusted keys for it
191
- const selfSelfXdata2 = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, hcp.dataOwnerId);
192
- const selfParentXdata2 = yield initialApi.cryptoApi.exchangeData.base.getExchangeDataByDelegatorDelegatePair(hcp.dataOwnerId, parent.dataOwnerId);
193
- (0, chai_1.expect)(selfSelfXdata2).to.not.be.undefined;
194
- (0, chai_1.expect)(selfParentXdata2).to.not.be.undefined;
195
- (0, chai_1.expect)(selfSelfXdata2).to.have.length(2);
196
- (0, chai_1.expect)(selfParentXdata2).to.have.length(2);
197
- const newSelfSelfXdata = selfSelfXdata2.filter((xd) => xd.id !== selfSelfXdata[0].id);
198
- (0, chai_1.expect)(newSelfSelfXdata).to.have.length(1);
199
- const newSelfSelfXDataUsedFps = Object.keys(newSelfSelfXdata[0].exchangeKey);
200
- (0, chai_1.expect)(newSelfSelfXDataUsedFps).to.have.length(1);
201
- (0, chai_1.expect)(newSelfSelfXDataUsedFps[0]).to.eq((0, utils_1.fingerprintV2)(newHcpKeySpki));
202
- const newSelfParentXdata = selfParentXdata2.filter((xd) => xd.id !== selfParentXdata[0].id);
203
- (0, chai_1.expect)(newSelfParentXdata).to.have.length(1);
204
- const newSelfParentXDataUsedFps = Object.keys(newSelfParentXdata[0].exchangeKey);
205
- (0, chai_1.expect)(newSelfParentXDataUsedFps).to.have.length(2);
206
- (0, chai_1.expect)(newSelfParentXDataUsedFps).to.have.members([(0, utils_1.fingerprintV2)(newHcpKeySpki), (0, utils_1.fingerprintV2)(newParentKeySpki)]);
207
- // Check after reinitialization with keys already in storage the "verified" situation is unchanged.
208
- const apiWithUntrustedKey2 = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: hcp.user, password: hcp.password }, new TrustedKeysStrategy([], [], { failRecoverAndVerifySelfHierarchyKeys: true }), crypto_1.webcrypto, fetch, apiWithUntrustedKeysStorages);
209
- (0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey2.healthcarePartyApi.getHealthcareParty(hcp.dataOwnerId))).to.have.members([newHcpKeySpki]);
210
- (0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getVerifiedPublicKeysFor(yield apiWithUntrustedKey2.healthcarePartyApi.getHealthcareParty(parent.dataOwnerId))).to.have.members([newParentKeySpki]);
211
- (0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getCurrentUserHierarchyAvailablePublicKeysHex()).to.have.members([
212
- newHcpKeySpki,
213
- hcp.publicKey,
214
- parent.publicKey,
215
- newParentKeySpki,
216
- ]);
217
- (0, chai_1.expect)(yield apiWithUntrustedKey2.cryptoApi.userKeysManager.getCurrentUserAvailablePublicKeysHex(false)).to.have.members([
218
- newHcpKeySpki,
219
- hcp.publicKey,
220
- ]);
221
- });
222
- });
223
- });
224
- });
225
- //# sourceMappingURL=CSM-729.js.map