@icure/api 8.10.2 → 8.11.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 (289) hide show
  1. package/icc-api/api/IccPatientApi.d.ts +1 -1
  2. package/icc-api/api/IccPatientApi.js +4 -2
  3. package/icc-api/api/IccPatientApi.js.map +1 -1
  4. package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +11 -0
  5. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +75 -13
  6. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
  7. package/icc-x-api/crypto/SecurityMetadataDecryptor.d.ts +14 -0
  8. package/icc-x-api/crypto/SecurityMetadataDecryptor.js +28 -0
  9. package/icc-x-api/crypto/SecurityMetadataDecryptor.js.map +1 -1
  10. package/icc-x-api/icc-patient-x-api.d.ts +4 -1
  11. package/icc-x-api/icc-patient-x-api.js +5 -2
  12. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  13. package/package.json +1 -1
  14. package/test/benchmarks/lzma-benchmark.spec.d.ts +1 -0
  15. package/test/benchmarks/lzma-benchmark.spec.js +131 -0
  16. package/test/benchmarks/lzma-benchmark.spec.js.map +1 -0
  17. package/test/benchmarks/lzma-compat.spec.d.ts +1 -0
  18. package/test/benchmarks/lzma-compat.spec.js +187 -0
  19. package/test/benchmarks/lzma-compat.spec.js.map +1 -0
  20. package/test/benchmarks/playwright.config.d.ts +2 -0
  21. package/test/benchmarks/playwright.config.js +18 -0
  22. package/test/benchmarks/playwright.config.js.map +1 -0
  23. package/test/icc-api/api/IccAgendaApi.d.ts +1 -0
  24. package/test/icc-api/api/IccAgendaApi.js +64 -0
  25. package/test/icc-api/api/IccAgendaApi.js.map +1 -0
  26. package/test/icc-api/api/IccAnonymousAccessApi.d.ts +1 -0
  27. package/test/icc-api/api/IccAnonymousAccessApi.js +58 -0
  28. package/test/icc-api/api/IccAnonymousAccessApi.js.map +1 -0
  29. package/test/icc-api/api/IccCalendarItemApi.d.ts +1 -0
  30. package/test/icc-api/api/IccCalendarItemApi.js +67 -0
  31. package/test/icc-api/api/IccCalendarItemApi.js.map +1 -0
  32. package/test/icc-api/api/IccCalendarItemTypeApi.d.ts +1 -0
  33. package/test/icc-api/api/IccCalendarItemTypeApi.js +96 -0
  34. package/test/icc-api/api/IccCalendarItemTypeApi.js.map +1 -0
  35. package/test/icc-api/api/IccCodeApi.d.ts +1 -0
  36. package/test/icc-api/api/IccCodeApi.js +38 -0
  37. package/test/icc-api/api/IccCodeApi.js.map +1 -0
  38. package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
  39. package/test/icc-api/api/IccDocumentApi.js +199 -0
  40. package/test/icc-api/api/IccDocumentApi.js.map +1 -0
  41. package/test/icc-api/api/IccGroupApi.d.ts +1 -0
  42. package/test/icc-api/api/IccGroupApi.js +50 -0
  43. package/test/icc-api/api/IccGroupApi.js.map +1 -0
  44. package/test/icc-api/api/IccKeywordApi.d.ts +1 -0
  45. package/test/icc-api/api/IccKeywordApi.js +64 -0
  46. package/test/icc-api/api/IccKeywordApi.js.map +1 -0
  47. package/test/icc-api/api/IccMedicalLocationApi.d.ts +1 -0
  48. package/test/icc-api/api/IccMedicalLocationApi.js +64 -0
  49. package/test/icc-api/api/IccMedicalLocationApi.js.map +1 -0
  50. package/test/icc-api/api/IccPlaceApi.d.ts +1 -0
  51. package/test/icc-api/api/IccPlaceApi.js +64 -0
  52. package/test/icc-api/api/IccPlaceApi.js.map +1 -0
  53. package/test/icc-api/api/IccRecoveryDataApi.d.ts +1 -0
  54. package/test/icc-api/api/IccRecoveryDataApi.js +95 -0
  55. package/test/icc-api/api/IccRecoveryDataApi.js.map +1 -0
  56. package/test/icc-api/api/IccRoleApi.d.ts +1 -0
  57. package/test/icc-api/api/IccRoleApi.js +34 -0
  58. package/test/icc-api/api/IccRoleApi.js.map +1 -0
  59. package/test/icc-api/api/IccUserApi.d.ts +1 -0
  60. package/test/icc-api/api/IccUserApi.js +96 -0
  61. package/test/icc-api/api/IccUserApi.js.map +1 -0
  62. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
  63. package/test/icc-api/e2e/IccCalendarItemApi.js +46 -0
  64. package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
  65. package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
  66. package/test/icc-api/model/modelHelpersTest.js +45 -0
  67. package/test/icc-api/model/modelHelpersTest.js.map +1 -0
  68. package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
  69. package/test/icc-x-api/auth/group-switch-test.js +81 -0
  70. package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
  71. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
  72. package/test/icc-x-api/auth/jwt-concurrency-test.js +112 -0
  73. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
  74. package/test/icc-x-api/auth/jwt-provider-test.d.ts +1 -0
  75. package/test/icc-x-api/auth/jwt-provider-test.js +197 -0
  76. package/test/icc-x-api/auth/jwt-provider-test.js.map +1 -0
  77. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
  78. package/test/icc-x-api/auth/smart-auth-provider-test.js +224 -0
  79. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
  80. package/test/icc-x-api/autofix-anonymity-test.d.ts +1 -0
  81. package/test/icc-x-api/autofix-anonymity-test.js +122 -0
  82. package/test/icc-x-api/autofix-anonymity-test.js.map +1 -0
  83. package/test/icc-x-api/confidential-entities-test.d.ts +1 -0
  84. package/test/icc-x-api/confidential-entities-test.js +168 -0
  85. package/test/icc-x-api/confidential-entities-test.js.map +1 -0
  86. package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +1 -0
  87. package/test/icc-x-api/crud/comprehensive-crud-test.js +276 -0
  88. package/test/icc-x-api/crud/comprehensive-crud-test.js.map +1 -0
  89. package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +16 -0
  90. package/test/icc-x-api/crud/entities-crud-test-interface.js +407 -0
  91. package/test/icc-x-api/crud/entities-crud-test-interface.js.map +1 -0
  92. package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +1 -0
  93. package/test/icc-x-api/crypto/anonymous-delegations-test.js +587 -0
  94. package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +1 -0
  95. package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
  96. package/test/icc-x-api/crypto/concurrency.js +35 -0
  97. package/test/icc-x-api/crypto/concurrency.js.map +1 -0
  98. package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
  99. package/test/icc-x-api/crypto/crypto-utils.js +79 -0
  100. package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
  101. package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
  102. package/test/icc-x-api/crypto/cryptoTest.js +402 -0
  103. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
  104. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
  105. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +166 -0
  106. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
  107. package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +1 -0
  108. package/test/icc-x-api/crypto/exchange-data-manager-test.js +674 -0
  109. package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -0
  110. package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
  111. package/test/icc-x-api/crypto/full-crypto-test.js +454 -0
  112. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
  113. package/test/icc-x-api/crypto/legacy-metadata-migration-test.d.ts +1 -0
  114. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js +379 -0
  115. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +1 -0
  116. package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +1 -0
  117. package/test/icc-x-api/crypto/secure-delegations-manager-test.js +278 -0
  118. package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -0
  119. package/test/icc-x-api/crypto/shamir.d.ts +2 -0
  120. package/test/icc-x-api/crypto/shamir.js +167 -0
  121. package/test/icc-x-api/crypto/shamir.js.map +1 -0
  122. package/test/icc-x-api/crypto/share-deduplication-test.d.ts +1 -0
  123. package/test/icc-x-api/crypto/share-deduplication-test.js +250 -0
  124. package/test/icc-x-api/crypto/share-deduplication-test.js.map +1 -0
  125. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
  126. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +71 -0
  127. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
  128. package/test/icc-x-api/crypto/soft-deleted-data-owners.d.ts +2 -0
  129. package/test/icc-x-api/crypto/soft-deleted-data-owners.js +113 -0
  130. package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +1 -0
  131. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +1 -0
  132. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +246 -0
  133. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +1 -0
  134. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
  135. package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
  136. package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
  137. package/test/icc-x-api/filters/filters.d.ts +1 -0
  138. package/test/icc-x-api/filters/filters.js +49 -0
  139. package/test/icc-x-api/filters/filters.js.map +1 -0
  140. package/test/icc-x-api/filters/healthelement.d.ts +1 -0
  141. package/test/icc-x-api/filters/healthelement.js +333 -0
  142. package/test/icc-x-api/filters/healthelement.js.map +1 -0
  143. package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
  144. package/test/icc-x-api/icc-accesslog-x-api.js +106 -0
  145. package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
  146. package/test/icc-x-api/icc-application-settings-x-api.d.ts +1 -0
  147. package/test/icc-x-api/icc-application-settings-x-api.js +91 -0
  148. package/test/icc-x-api/icc-application-settings-x-api.js.map +1 -0
  149. package/test/icc-x-api/icc-auth-api.d.ts +1 -0
  150. package/test/icc-x-api/icc-auth-api.js +47 -0
  151. package/test/icc-x-api/icc-auth-api.js.map +1 -0
  152. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
  153. package/test/icc-x-api/icc-calendar-item-x-api.js +150 -0
  154. package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
  155. package/test/icc-x-api/icc-code-x-api-test.d.ts +1 -0
  156. package/test/icc-x-api/icc-code-x-api-test.js +74 -0
  157. package/test/icc-x-api/icc-code-x-api-test.js.map +1 -0
  158. package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
  159. package/test/icc-x-api/icc-contact-x-api.js +355 -0
  160. package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
  161. package/test/icc-x-api/icc-document-x-api.d.ts +1 -0
  162. package/test/icc-x-api/icc-document-x-api.js +76 -0
  163. package/test/icc-x-api/icc-document-x-api.js.map +1 -0
  164. package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
  165. package/test/icc-x-api/icc-form-x-api.js +413 -0
  166. package/test/icc-x-api/icc-form-x-api.js.map +1 -0
  167. package/test/icc-x-api/icc-hcparty-x-api-test.d.ts +1 -0
  168. package/test/icc-x-api/icc-hcparty-x-api-test.js +43 -0
  169. package/test/icc-x-api/icc-hcparty-x-api-test.js.map +1 -0
  170. package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
  171. package/test/icc-x-api/icc-helement-x-api-test.js +155 -0
  172. package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
  173. package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
  174. package/test/icc-x-api/icc-invoice-x-api.js +99 -0
  175. package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
  176. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
  177. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +222 -0
  178. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
  179. package/test/icc-x-api/icc-message-x-api.d.ts +1 -0
  180. package/test/icc-x-api/icc-message-x-api.js +54 -0
  181. package/test/icc-x-api/icc-message-x-api.js.map +1 -0
  182. package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
  183. package/test/icc-x-api/icc-patient-x-api-test.js +209 -0
  184. package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
  185. package/test/icc-x-api/icc-recovery-x-api.d.ts +1 -0
  186. package/test/icc-x-api/icc-recovery-x-api.js +175 -0
  187. package/test/icc-x-api/icc-recovery-x-api.js.map +1 -0
  188. package/test/icc-x-api/icc-topic-x-api.d.ts +1 -0
  189. package/test/icc-x-api/icc-topic-x-api.js +269 -0
  190. package/test/icc-x-api/icc-topic-x-api.js.map +1 -0
  191. package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
  192. package/test/icc-x-api/icc-user-x-api-test.js +99 -0
  193. package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
  194. package/test/icc-x-api/keyless-api.d.ts +1 -0
  195. package/test/icc-x-api/keyless-api.js +125 -0
  196. package/test/icc-x-api/keyless-api.js.map +1 -0
  197. package/test/icc-x-api/patient-user.d.ts +2 -0
  198. package/test/icc-x-api/patient-user.js +103 -0
  199. package/test/icc-x-api/patient-user.js.map +1 -0
  200. package/test/icc-x-api/storage/storage.d.ts +1 -0
  201. package/test/icc-x-api/storage/storage.js +48 -0
  202. package/test/icc-x-api/storage/storage.js.map +1 -0
  203. package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
  204. package/test/icc-x-api/test-api-no-parent.js +79 -0
  205. package/test/icc-x-api/test-api-no-parent.js.map +1 -0
  206. package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
  207. package/test/icc-x-api/test-legacy-data-support.js +375 -0
  208. package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
  209. package/test/icc-x-api/utils/date-encode-test.d.ts +1 -0
  210. package/test/icc-x-api/utils/date-encode-test.js +150 -0
  211. package/test/icc-x-api/utils/date-encode-test.js.map +1 -0
  212. package/test/icc-x-api/utils/graph-test.d.ts +1 -0
  213. package/test/icc-x-api/utils/graph-test.js +54 -0
  214. package/test/icc-x-api/utils/graph-test.js.map +1 -0
  215. package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +1 -0
  216. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +364 -0
  217. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +1 -0
  218. package/test/icc-x-api/utils/lzma-benchmark-test.d.ts +1 -0
  219. package/test/icc-x-api/utils/lzma-benchmark-test.js +132 -0
  220. package/test/icc-x-api/utils/lzma-benchmark-test.js.map +1 -0
  221. package/test/icc-x-api/utils/lzma-compat-test.d.ts +1 -0
  222. package/test/icc-x-api/utils/lzma-compat-test.js +218 -0
  223. package/test/icc-x-api/utils/lzma-compat-test.js.map +1 -0
  224. package/test/icc-x-api/utils/mutex-test.d.ts +1 -0
  225. package/test/icc-x-api/utils/mutex-test.js +114 -0
  226. package/test/icc-x-api/utils/mutex-test.js.map +1 -0
  227. package/test/icc-x-api/utils/to-moment-test.d.ts +1 -0
  228. package/test/icc-x-api/utils/to-moment-test.js +110 -0
  229. package/test/icc-x-api/utils/to-moment-test.js.map +1 -0
  230. package/test/support/CSM-185.d.ts +1 -0
  231. package/test/support/CSM-185.js +124 -0
  232. package/test/support/CSM-185.js.map +1 -0
  233. package/test/support/CSM-243.d.ts +1 -0
  234. package/test/support/CSM-243.js +120 -0
  235. package/test/support/CSM-243.js.map +1 -0
  236. package/test/support/CSM-543.d.ts +1 -0
  237. package/test/support/CSM-543.js +164 -0
  238. package/test/support/CSM-543.js.map +1 -0
  239. package/test/support/CSM-729.d.ts +1 -0
  240. package/test/support/CSM-729.js +225 -0
  241. package/test/support/CSM-729.js.map +1 -0
  242. package/test/support/CSM-814.d.ts +1 -0
  243. package/test/support/CSM-814.js +475 -0
  244. package/test/support/CSM-814.js.map +1 -0
  245. package/test/support/CSM-87.d.ts +0 -0
  246. package/test/support/CSM-87.js +21 -0
  247. package/test/support/CSM-87.js.map +1 -0
  248. package/test/support/CSM-93.d.ts +1 -0
  249. package/test/support/CSM-93.js +112 -0
  250. package/test/support/CSM-93.js.map +1 -0
  251. package/test/utils/FakeDataOwnerApi.d.ts +32 -0
  252. package/test/utils/FakeDataOwnerApi.js +136 -0
  253. package/test/utils/FakeDataOwnerApi.js.map +1 -0
  254. package/test/utils/FakeEncryptionKeysManager.d.ts +36 -0
  255. package/test/utils/FakeEncryptionKeysManager.js +97 -0
  256. package/test/utils/FakeEncryptionKeysManager.js.map +1 -0
  257. package/test/utils/FakeExchangeDataApi.d.ts +32 -0
  258. package/test/utils/FakeExchangeDataApi.js +92 -0
  259. package/test/utils/FakeExchangeDataApi.js.map +1 -0
  260. package/test/utils/FakeExchangeDataManager.d.ts +48 -0
  261. package/test/utils/FakeExchangeDataManager.js +82 -0
  262. package/test/utils/FakeExchangeDataManager.js.map +1 -0
  263. package/test/utils/FakeExchangeDataMapManager.d.ts +12 -0
  264. package/test/utils/FakeExchangeDataMapManager.js +38 -0
  265. package/test/utils/FakeExchangeDataMapManager.js.map +1 -0
  266. package/test/utils/FakeGenericApi.d.ts +16 -0
  267. package/test/utils/FakeGenericApi.js +65 -0
  268. package/test/utils/FakeGenericApi.js.map +1 -0
  269. package/test/utils/KeylessCryptoStrategies.d.ts +23 -0
  270. package/test/utils/KeylessCryptoStrategies.js +26 -0
  271. package/test/utils/KeylessCryptoStrategies.js.map +1 -0
  272. package/test/utils/TestApi.d.ts +3 -0
  273. package/test/utils/TestApi.js +30 -0
  274. package/test/utils/TestApi.js.map +1 -0
  275. package/test/utils/TestCollectionUtils.d.ts +1 -0
  276. package/test/utils/TestCollectionUtils.js +310 -0
  277. package/test/utils/TestCollectionUtils.js.map +1 -0
  278. package/test/utils/TestCryptoStrategies.d.ts +42 -0
  279. package/test/utils/TestCryptoStrategies.js +80 -0
  280. package/test/utils/TestCryptoStrategies.js.map +1 -0
  281. package/test/utils/TestStorage.d.ts +23 -0
  282. package/test/utils/TestStorage.js +61 -0
  283. package/test/utils/TestStorage.js.map +1 -0
  284. package/test/utils/roles.d.ts +14 -0
  285. package/test/utils/roles.js +345 -0
  286. package/test/utils/roles.js.map +1 -0
  287. package/test/utils/test_utils.d.ts +87 -0
  288. package/test/utils/test_utils.js +452 -0
  289. package/test/utils/test_utils.js.map +1 -0
@@ -0,0 +1,97 @@
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
+ exports.FakeEncryptionKeysManager = void 0;
13
+ const UserEncryptionKeysManager_1 = require("../../icc-x-api/crypto/UserEncryptionKeysManager");
14
+ const RSA_1 = require("../../icc-x-api/crypto/RSA");
15
+ const icc_x_api_1 = require("../../icc-x-api");
16
+ const utils_1 = require("../../icc-x-api/crypto/utils");
17
+ class FakeEncryptionKeysManager extends UserEncryptionKeysManager_1.UserEncryptionKeysManager {
18
+ constructor(keys) {
19
+ super(null, null, null, null, null, null, null, null);
20
+ this.keys = keys;
21
+ }
22
+ static create(primitives_1, verifiedKeys_1) {
23
+ return __awaiter(this, arguments, void 0, function* (primitives, verifiedKeys, unverifiedKeys = []) {
24
+ const keysByFingerprint = {};
25
+ for (const key of verifiedKeys) {
26
+ const fingerprint = (0, utils_1.fingerprintV1)((0, icc_x_api_1.ua2hex)(yield primitives.RSA.exportKey(key.publicKey, 'spki')));
27
+ keysByFingerprint[fingerprint] = { pair: key, verified: true };
28
+ }
29
+ for (const key of unverifiedKeys) {
30
+ const fingerprint = (0, utils_1.fingerprintV1)((0, icc_x_api_1.ua2hex)(yield primitives.RSA.exportKey(key.publicKey, 'spki')));
31
+ keysByFingerprint[fingerprint] = { pair: key, verified: false };
32
+ }
33
+ return new FakeEncryptionKeysManager(keysByFingerprint);
34
+ });
35
+ }
36
+ getCurrentUserAvailablePublicKeysHex(verifiedOnly) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ throw new Error('Not implemented');
39
+ });
40
+ }
41
+ getCurrentUserHierarchyAvailablePublicKeysHex() {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ throw new Error('Not implemented');
44
+ });
45
+ }
46
+ getKeyPairForFingerprint(fingerprint) {
47
+ const key = this.keys[fingerprint];
48
+ if (key)
49
+ return { pair: { publicKey: key.pair.publicKey, privateKey: key.pair.privateKey }, verified: key.verified };
50
+ return undefined;
51
+ }
52
+ initialiseKeys() {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ return Promise.resolve(undefined);
55
+ });
56
+ }
57
+ reloadKeys() {
58
+ return __awaiter(this, void 0, void 0, function* () { });
59
+ }
60
+ getSelfVerifiedKeys() {
61
+ const res = [];
62
+ for (const [fingerprint, { pair, verified }] of Object.entries(this.keys)) {
63
+ if (verified)
64
+ res.push({ fingerprint, pair });
65
+ }
66
+ return res;
67
+ }
68
+ getVerifiedPublicKeysFor(dataOwner) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ throw new Error('Not implemented');
71
+ });
72
+ }
73
+ getDecryptionKeys() {
74
+ return Object.fromEntries(Object.entries(this.keys).map(([fp, { pair }]) => [fp, pair]));
75
+ }
76
+ deleteKey(fp) {
77
+ delete this.keys[fp];
78
+ }
79
+ addOrUpdateKey(primitives, pair, verified) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const fp = (0, utils_1.fingerprintV1)((0, icc_x_api_1.ua2hex)(yield primitives.RSA.exportKey(pair.publicKey, 'spki')));
82
+ this.keys[fp] = { pair, verified };
83
+ });
84
+ }
85
+ unverifyExistingKeysAndCreateNewVerified(primitives) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ Object.values(this.keys).map((x) => {
88
+ x.verified = false;
89
+ });
90
+ const newKey = yield primitives.RSA.generateKeyPair(RSA_1.ShaVersion.Sha256);
91
+ const newKeyFp = (0, utils_1.fingerprintV1)((0, icc_x_api_1.ua2hex)(yield primitives.RSA.exportKey(newKey.publicKey, 'spki')));
92
+ this.keys[newKeyFp] = { pair: newKey, verified: true };
93
+ });
94
+ }
95
+ }
96
+ exports.FakeEncryptionKeysManager = FakeEncryptionKeysManager;
97
+ //# sourceMappingURL=FakeEncryptionKeysManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeEncryptionKeysManager.js","sourceRoot":"","sources":["../../../test/utils/FakeEncryptionKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gGAA4F;AAE5F,oDAAgE;AAEhE,+CAAwC;AACxC,wDAA4D;AAE5D,MAAa,yBAA0B,SAAQ,qDAAyB;IACtE,YAA6B,IAAgF;QAC3G,KAAK,CAAC,IAAW,EAAE,IAAW,EAAE,IAAW,EAAE,IAAW,EAAE,IAAW,EAAE,IAAW,EAAE,IAAW,EAAE,IAAW,CAAC,CAAA;QADlF,SAAI,GAAJ,IAAI,CAA4E;IAE7G,CAAC;IAED,MAAM,CAAO,MAAM;6DACjB,UAA4B,EAC5B,YAAkC,EAClC,iBAAuC,EAAE;YAEzC,MAAM,iBAAiB,GAAG,EAAgF,CAAA;YAC1G,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;gBAC/B,MAAM,WAAW,GAAG,IAAA,qBAAa,EAAC,IAAA,kBAAM,EAAC,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,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CAAC,eAAe,CAAC,gBAAU,CAAC,MAAM,CAAC,CAAA;YACtE,MAAM,QAAQ,GAAG,IAAA,qBAAa,EAAC,IAAA,kBAAM,EAAC,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;YAChG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QACxD,CAAC;KAAA;CACF;AA3ED,8DA2EC","sourcesContent":["import { UserEncryptionKeysManager } from '../../icc-x-api/crypto/UserEncryptionKeysManager'\nimport { DataOwner } from '../../icc-x-api/icc-data-owner-x-api'\nimport { KeyPair, ShaVersion } from '../../icc-x-api/crypto/RSA'\nimport { CryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { ua2hex } from '../../icc-x-api'\nimport { fingerprintV1 } from '../../icc-x-api/crypto/utils'\n\nexport class FakeEncryptionKeysManager extends UserEncryptionKeysManager {\n constructor(private readonly keys: { [fingerprint: string]: { pair: KeyPair<CryptoKey>; verified: boolean } }) {\n super(null as any, null as any, null as any, null as any, null as any, null as any, null as any, null as any)\n }\n\n static async create(\n primitives: CryptoPrimitives,\n verifiedKeys: KeyPair<CryptoKey>[],\n unverifiedKeys: KeyPair<CryptoKey>[] = []\n ): Promise<FakeEncryptionKeysManager> {\n const keysByFingerprint = {} as { [fingerprint: string]: { pair: KeyPair<CryptoKey>; verified: boolean } }\n for (const key of verifiedKeys) {\n const fingerprint = fingerprintV1(ua2hex(await primitives.RSA.exportKey(key.publicKey, 'spki')))\n keysByFingerprint[fingerprint] = { pair: key, verified: true }\n }\n for (const key of unverifiedKeys) {\n const fingerprint = fingerprintV1(ua2hex(await primitives.RSA.exportKey(key.publicKey, 'spki')))\n keysByFingerprint[fingerprint] = { pair: key, verified: false }\n }\n return new FakeEncryptionKeysManager(keysByFingerprint)\n }\n\n async getCurrentUserAvailablePublicKeysHex(verifiedOnly: boolean): Promise<string[]> {\n throw new Error('Not implemented')\n }\n\n async getCurrentUserHierarchyAvailablePublicKeysHex(): Promise<string[]> {\n throw new Error('Not implemented')\n }\n\n getKeyPairForFingerprint(fingerprint: string): { pair: KeyPair<CryptoKey>; verified: boolean } | undefined {\n const key = this.keys[fingerprint]\n if (key) return { pair: { publicKey: key.pair.publicKey, privateKey: key.pair.privateKey }, verified: key.verified }\n return undefined\n }\n\n async initialiseKeys(): Promise<{ newKeyPair: KeyPair<CryptoKey>; newKeyFingerprint: string } | undefined> {\n return Promise.resolve(undefined)\n }\n\n async reloadKeys(): Promise<void> {}\n\n getSelfVerifiedKeys(): { fingerprint: string; pair: KeyPair<CryptoKey> }[] {\n const res = []\n for (const [fingerprint, { pair, verified }] of Object.entries(this.keys)) {\n if (verified) res.push({ fingerprint, pair })\n }\n return res\n }\n\n async getVerifiedPublicKeysFor(dataOwner: DataOwner): Promise<string[]> {\n throw new Error('Not implemented')\n }\n\n getDecryptionKeys(): { [p: string]: KeyPair<CryptoKey> } {\n return Object.fromEntries(Object.entries(this.keys).map(([fp, { pair }]) => [fp, pair]))\n }\n\n deleteKey(fp: string) {\n delete this.keys[fp]\n }\n\n async addOrUpdateKey(primitives: CryptoPrimitives, pair: KeyPair<CryptoKey>, verified: boolean) {\n const fp = fingerprintV1(ua2hex(await primitives.RSA.exportKey(pair.publicKey, 'spki')))\n this.keys[fp] = { pair, verified }\n }\n\n async unverifyExistingKeysAndCreateNewVerified(primitives: CryptoPrimitives) {\n Object.values(this.keys).map((x) => {\n x.verified = false\n })\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const newKeyFp = fingerprintV1(ua2hex(await primitives.RSA.exportKey(newKey.publicKey, 'spki')))\n this.keys[newKeyFp] = { pair: newKey, verified: true }\n }\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import { IccExchangeDataApi } from '../../icc-api/api/internal/IccExchangeDataApi';
2
+ import { ExchangeData } from '../../icc-api/model/internal/ExchangeData';
3
+ import { PaginatedListExchangeData } from '../../icc-api/model/PaginatedListExchangeData';
4
+ import { ListOfIds } from '../../icc-api/model/ListOfIds';
5
+ export type CallCount = {
6
+ createExchangeData: number;
7
+ modifyExchangeData: number;
8
+ getExchangeDataByParticipant: number;
9
+ getExchangeDataByDelegatorDelegate: number;
10
+ getExchangeDataByIds: number;
11
+ };
12
+ export type ExpectedCallCount = {
13
+ createExchangeData?: number;
14
+ modifyExchangeData?: number;
15
+ getExchangeDataByParticipant?: number;
16
+ getExchangeDataByDelegatorDelegate?: number;
17
+ getExchangeDataByIds?: number;
18
+ };
19
+ export declare class FakeExchangeDataApi extends IccExchangeDataApi {
20
+ private readonly data;
21
+ private _callCount;
22
+ get callCount(): CallCount;
23
+ compareCallCountFromBaseline(baseline: CallCount, expected: ExpectedCallCount): void;
24
+ constructor();
25
+ createExchangeData(body: ExchangeData): Promise<ExchangeData>;
26
+ modifyExchangeData(body: ExchangeData): Promise<ExchangeData>;
27
+ getExchangeDataById(exchangeDataId: string): Promise<ExchangeData>;
28
+ getExchangeDataByIds(body: ListOfIds): Promise<ExchangeData[]>;
29
+ getExchangeDataByDelegatorDelegate(delegatorId: string, delegateId: string): Promise<ExchangeData[]>;
30
+ getExchangeDataByParticipant(dataOwnerId: string, startDocumentId?: string, limit?: number): Promise<PaginatedListExchangeData>;
31
+ getAll(): ExchangeData[];
32
+ }
@@ -0,0 +1,92 @@
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
+ exports.FakeExchangeDataApi = void 0;
13
+ const IccExchangeDataApi_1 = require("../../icc-api/api/internal/IccExchangeDataApi");
14
+ const ExchangeData_1 = require("../../icc-api/model/internal/ExchangeData");
15
+ const PaginatedListExchangeData_1 = require("../../icc-api/model/PaginatedListExchangeData");
16
+ const FakeGenericApi_1 = require("./FakeGenericApi");
17
+ const PaginatedDocumentKeyIdPairObject_1 = require("../../icc-api/model/PaginatedDocumentKeyIdPairObject");
18
+ const collection_utils_1 = require("../../icc-x-api/utils/collection-utils");
19
+ const chai_1 = require("chai");
20
+ class FakeExchangeDataApi extends IccExchangeDataApi_1.IccExchangeDataApi {
21
+ get callCount() {
22
+ return (0, collection_utils_1.cloneDeep)(this._callCount);
23
+ }
24
+ compareCallCountFromBaseline(baseline, expected) {
25
+ for (const [key, v] of Object.entries(expected)) {
26
+ const curr = this._callCount[key];
27
+ const currBaseline = baseline[key];
28
+ (0, chai_1.expect)(curr).to.equal(currBaseline + v, `Actual call count for ${key} does not match expected
29
+ Current: ${JSON.stringify(this._callCount)}
30
+ Baseline: ${JSON.stringify(baseline)}
31
+ ExpectedDifference: ${JSON.stringify(expected)}
32
+ `);
33
+ }
34
+ }
35
+ constructor() {
36
+ super('fake', {}, null, null);
37
+ this.data = new FakeGenericApi_1.FakeGenericApi();
38
+ this._callCount = {
39
+ createExchangeData: 0,
40
+ modifyExchangeData: 0,
41
+ getExchangeDataByDelegatorDelegate: 0,
42
+ getExchangeDataByParticipant: 0,
43
+ getExchangeDataByIds: 0,
44
+ };
45
+ }
46
+ createExchangeData(body) {
47
+ this._callCount.createExchangeData += 1;
48
+ return Promise.resolve(new ExchangeData_1.ExchangeData(this.data.createObject(body)));
49
+ }
50
+ modifyExchangeData(body) {
51
+ this._callCount.modifyExchangeData += 1;
52
+ return Promise.resolve(new ExchangeData_1.ExchangeData(this.data.modifyObject(body)));
53
+ }
54
+ getExchangeDataById(exchangeDataId) {
55
+ throw new Error('Individual retrieve should not be used anymore');
56
+ }
57
+ getExchangeDataByIds(body) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ this._callCount.getExchangeDataByIds += 1;
60
+ const allRetrieved = [];
61
+ for (const id of body.ids) {
62
+ const retrieved = this.data.getById(id);
63
+ if (retrieved) {
64
+ allRetrieved.push(new ExchangeData_1.ExchangeData(retrieved));
65
+ }
66
+ }
67
+ return Promise.resolve(allRetrieved);
68
+ });
69
+ }
70
+ getExchangeDataByDelegatorDelegate(delegatorId, delegateId) {
71
+ this._callCount.getExchangeDataByDelegatorDelegate += 1;
72
+ return Promise.resolve(this.data
73
+ .getAll()
74
+ .filter((x) => x.delegate === delegateId && x.delegator === delegatorId)
75
+ .map((x) => new ExchangeData_1.ExchangeData(x)));
76
+ }
77
+ getExchangeDataByParticipant(dataOwnerId, startDocumentId, limit) {
78
+ this._callCount.getExchangeDataByParticipant += 1;
79
+ const retrieved = this.data.getPaged(startDocumentId, limit !== null && limit !== void 0 ? limit : 1000);
80
+ return Promise.resolve(new PaginatedListExchangeData_1.PaginatedListExchangeData({
81
+ pageSize: retrieved.rows.length,
82
+ totalSize: retrieved.rows.length,
83
+ rows: retrieved.rows.filter((x) => x.delegator === dataOwnerId || x.delegate === dataOwnerId).map((x) => new ExchangeData_1.ExchangeData(x)),
84
+ nextKeyPair: new PaginatedDocumentKeyIdPairObject_1.PaginatedDocumentKeyIdPairObject({ startKeyDocId: retrieved.nextId }),
85
+ }));
86
+ }
87
+ getAll() {
88
+ return this.data.getAll().map((x) => new ExchangeData_1.ExchangeData(x));
89
+ }
90
+ }
91
+ exports.FakeExchangeDataApi = FakeExchangeDataApi;
92
+ //# sourceMappingURL=FakeExchangeDataApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeExchangeDataApi.js","sourceRoot":"","sources":["../../../test/utils/FakeExchangeDataApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sFAAkF;AACl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CAAC,WAAmB,EAAE,eAAwB,EAAE,KAAc;QACxF,IAAI,CAAC,UAAU,CAAC,4BAA4B,IAAI,CAAC,CAAA;QACjD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC,CAAA;QACpE,OAAO,OAAO,CAAC,OAAO,CACpB,IAAI,qDAAyB,CAAC;YAC5B,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM;YAC/B,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM;YAChC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,CAAC,QAAQ,KAAK,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,2BAAY,CAAC,CAAC,CAAC,CAAC;YAC7H,WAAW,EAAE,IAAI,mEAAgC,CAAC,EAAE,aAAa,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;SACvF,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,2BAAY,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3D,CAAC;CACF;AArFD,kDAqFC","sourcesContent":["import { IccExchangeDataApi } from '../../icc-api/api/internal/IccExchangeDataApi'\nimport { ExchangeData } from '../../icc-api/model/internal/ExchangeData'\nimport { PaginatedListExchangeData } from '../../icc-api/model/PaginatedListExchangeData'\nimport { FakeGenericApi } from './FakeGenericApi'\nimport { PaginatedDocumentKeyIdPairObject } from '../../icc-api/model/PaginatedDocumentKeyIdPairObject'\nimport { cloneDeep } from '../../icc-x-api/utils/collection-utils'\nimport { expect } from 'chai'\nimport base = Mocha.reporters.base\nimport { ListOfIds } from '../../icc-api/model/ListOfIds'\n\nexport type CallCount = {\n createExchangeData: number\n modifyExchangeData: number\n getExchangeDataByParticipant: number\n getExchangeDataByDelegatorDelegate: number\n getExchangeDataByIds: number\n}\n\nexport type ExpectedCallCount = {\n createExchangeData?: number\n modifyExchangeData?: number\n getExchangeDataByParticipant?: number\n getExchangeDataByDelegatorDelegate?: number\n getExchangeDataByIds?: number\n}\n\nexport class FakeExchangeDataApi extends IccExchangeDataApi {\n private readonly data = new FakeGenericApi<ExchangeData>()\n private _callCount: CallCount = {\n createExchangeData: 0,\n modifyExchangeData: 0,\n getExchangeDataByDelegatorDelegate: 0,\n getExchangeDataByParticipant: 0,\n getExchangeDataByIds: 0,\n }\n\n public get callCount(): CallCount {\n return cloneDeep(this._callCount)\n }\n\n compareCallCountFromBaseline(baseline: CallCount, expected: ExpectedCallCount) {\n for (const [key, v] of Object.entries(expected)) {\n const curr = (this._callCount as any)[key] as number\n const currBaseline = (baseline as any)[key] as number\n expect(curr).to.equal(\n currBaseline + v,\n `Actual call count for ${key} does not match expected\n Current: ${JSON.stringify(this._callCount)}\n Baseline: ${JSON.stringify(baseline)}\n ExpectedDifference: ${JSON.stringify(expected)}\n `\n )\n }\n }\n\n constructor() {\n super('fake', {}, null as any, null as any)\n }\n\n createExchangeData(body: ExchangeData): Promise<ExchangeData> {\n this._callCount.createExchangeData += 1\n return Promise.resolve(new ExchangeData(this.data.createObject(body)))\n }\n\n modifyExchangeData(body: ExchangeData): Promise<ExchangeData> {\n this._callCount.modifyExchangeData += 1\n return Promise.resolve(new ExchangeData(this.data.modifyObject(body)))\n }\n\n getExchangeDataById(exchangeDataId: string): Promise<ExchangeData> {\n throw new Error('Individual retrieve should not be used anymore')\n }\n\n async getExchangeDataByIds(body: ListOfIds): Promise<ExchangeData[]> {\n this._callCount.getExchangeDataByIds += 1\n const allRetrieved: ExchangeData[] = []\n for (const id of body.ids!) {\n const retrieved = this.data.getById(id)\n if (retrieved) {\n allRetrieved.push(new ExchangeData(retrieved))\n }\n }\n return Promise.resolve(allRetrieved)\n }\n\n getExchangeDataByDelegatorDelegate(delegatorId: string, delegateId: string): Promise<ExchangeData[]> {\n this._callCount.getExchangeDataByDelegatorDelegate += 1\n return Promise.resolve(\n this.data\n .getAll()\n .filter((x) => x.delegate === delegateId && x.delegator === delegatorId)\n .map((x) => new ExchangeData(x))\n )\n }\n\n getExchangeDataByParticipant(dataOwnerId: string, startDocumentId?: string, limit?: number): Promise<PaginatedListExchangeData> {\n this._callCount.getExchangeDataByParticipant += 1\n const retrieved = this.data.getPaged(startDocumentId, limit ?? 1000)\n return Promise.resolve(\n new PaginatedListExchangeData({\n pageSize: retrieved.rows.length,\n totalSize: retrieved.rows.length,\n rows: retrieved.rows.filter((x) => x.delegator === dataOwnerId || x.delegate === dataOwnerId).map((x) => new ExchangeData(x)),\n nextKeyPair: new PaginatedDocumentKeyIdPairObject({ startKeyDocId: retrieved.nextId }),\n })\n )\n }\n\n getAll(): ExchangeData[] {\n return this.data.getAll().map((x) => new ExchangeData(x))\n }\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import { ExchangeDataManager } from '../../icc-x-api/crypto/ExchangeDataManager';
2
+ import { EntityWithDelegationTypeName } from '../../icc-x-api/utils/EntityWithDelegationTypeName';
3
+ import { ExchangeData } from '../../icc-api/model/internal/ExchangeData';
4
+ import { BaseExchangeDataManager } from '../../icc-x-api/crypto/BaseExchangeDataManager';
5
+ import { CryptoPrimitives } from '../../icc-x-api';
6
+ export declare class FakeDecryptionExchangeDataManager implements ExchangeDataManager {
7
+ private readonly cryptoPrimitives;
8
+ constructor(cryptoPrimitives: CryptoPrimitives);
9
+ private readonly dataByHash;
10
+ private readonly dataById;
11
+ clearOrRepopulateCache(): Promise<void>;
12
+ getAccessControlKeysValue(entityType: EntityWithDelegationTypeName): Promise<string | undefined>;
13
+ getCachedDecryptionDataKeyByAccessControlHash(hashes: string[]): Promise<{
14
+ [p: string]: {
15
+ exchangeData: ExchangeData;
16
+ exchangeKey: CryptoKey;
17
+ accessControlSecret: string;
18
+ };
19
+ }>;
20
+ getDecryptionDataKeyByIds(ids: string[], retrieveIfNotCached: boolean): Promise<{
21
+ [id: string]: {
22
+ exchangeKey: CryptoKey | undefined;
23
+ accessControlSecret: string | undefined;
24
+ exchangeData: ExchangeData;
25
+ };
26
+ }>;
27
+ getOrCreateEncryptionDataTo(delegateId: string): Promise<{
28
+ exchangeData: ExchangeData;
29
+ accessControlSecret: string;
30
+ exchangeKey: CryptoKey;
31
+ sharedSignatureKey: CryptoKey;
32
+ }>;
33
+ cacheFakeData(exchangeData: ExchangeData, keyAndHashesFromSecret: {
34
+ exchangeKey: CryptoKey;
35
+ accessControlSecret?: string;
36
+ hashes: string[];
37
+ } | undefined, fakeNonCached?: boolean): void;
38
+ giveAccessBackTo(otherDataOwner: string, newDataOwnerPublicKey: string): Promise<void>;
39
+ getAllDelegationKeys(entityType: EntityWithDelegationTypeName): Promise<string[] | undefined>;
40
+ get base(): BaseExchangeDataManager;
41
+ injectDecryptedExchangeData(exchangeDataDetails: {
42
+ exchangeDataId: string;
43
+ accessControlSecret: ArrayBuffer;
44
+ exchangeKey: ArrayBuffer;
45
+ sharedSignatureKey: ArrayBuffer;
46
+ verified: boolean;
47
+ }[], reEncryptWithOwnKeys: boolean): Promise<void>;
48
+ }
@@ -0,0 +1,82 @@
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
+ exports.FakeDecryptionExchangeDataManager = void 0;
13
+ class FakeDecryptionExchangeDataManager {
14
+ constructor(cryptoPrimitives) {
15
+ this.cryptoPrimitives = cryptoPrimitives;
16
+ this.dataByHash = {};
17
+ this.dataById = {};
18
+ }
19
+ clearOrRepopulateCache() {
20
+ throw new Error('This method is not supported by fake exchange data manager and should not be used.');
21
+ }
22
+ getAccessControlKeysValue(entityType) {
23
+ throw new Error('This method is not supported by fake exchange data manager and should not be used.');
24
+ }
25
+ getCachedDecryptionDataKeyByAccessControlHash(hashes) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const res = {};
28
+ for (const hash of hashes) {
29
+ const retrieved = this.dataByHash[hash];
30
+ if (retrieved)
31
+ res[hash] = retrieved;
32
+ }
33
+ return res;
34
+ });
35
+ }
36
+ getDecryptionDataKeyByIds(ids, retrieveIfNotCached) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const res = {};
39
+ for (const id of ids) {
40
+ const retrieved = this.dataById[id];
41
+ if (retrieved) {
42
+ if (retrieveIfNotCached || !retrieved.fakeNonCached) {
43
+ res[id] = retrieved;
44
+ }
45
+ }
46
+ }
47
+ return res;
48
+ });
49
+ }
50
+ getOrCreateEncryptionDataTo(delegateId) {
51
+ throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported');
52
+ }
53
+ cacheFakeData(exchangeData, keyAndHashesFromSecret, fakeNonCached) {
54
+ var _a;
55
+ const acSecret = !!keyAndHashesFromSecret ? (_a = keyAndHashesFromSecret.accessControlSecret) !== null && _a !== void 0 ? _a : this.cryptoPrimitives.randomUuid() : undefined;
56
+ this.dataById[exchangeData.id] = {
57
+ exchangeData,
58
+ exchangeKey: keyAndHashesFromSecret === null || keyAndHashesFromSecret === void 0 ? void 0 : keyAndHashesFromSecret.exchangeKey,
59
+ fakeNonCached: fakeNonCached !== null && fakeNonCached !== void 0 ? fakeNonCached : false,
60
+ accessControlSecret: acSecret,
61
+ };
62
+ if (keyAndHashesFromSecret) {
63
+ for (const hash of keyAndHashesFromSecret.hashes) {
64
+ this.dataByHash[hash] = { exchangeData, exchangeKey: keyAndHashesFromSecret.exchangeKey, accessControlSecret: acSecret };
65
+ }
66
+ }
67
+ }
68
+ giveAccessBackTo(otherDataOwner, newDataOwnerPublicKey) {
69
+ throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported');
70
+ }
71
+ getAllDelegationKeys(entityType) {
72
+ throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported');
73
+ }
74
+ get base() {
75
+ throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported');
76
+ }
77
+ injectDecryptedExchangeData(exchangeDataDetails, reEncryptWithOwnKeys) {
78
+ throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported');
79
+ }
80
+ }
81
+ exports.FakeDecryptionExchangeDataManager = FakeDecryptionExchangeDataManager;
82
+ //# sourceMappingURL=FakeExchangeDataManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeExchangeDataManager.js","sourceRoot":"","sources":["../../../test/utils/FakeExchangeDataManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,MAAa,iCAAiC;IAC5C,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAE9C,eAAU,GAA4G,EAAE,CAAA;QACxH,aAAQ,GAErB,EAAE,CAAA;IAL4D,CAAC;IAOnE,sBAAsB;QACpB,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAA;IACvG,CAAC;IAED,yBAAyB,CAAC,UAAwC;QAChE,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAA;IACvG,CAAC;IAEK,6CAA6C,CACjD,MAAgB;;YAEhB,MAAM,GAAG,GAAyG,EAAE,CAAA;YACpH,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;gBAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;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,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,sBAAsB,CAAC,WAAW,EAAE,mBAAmB,EAAE,QAAS,EAAE,CAAA;YAC3H,CAAC;QACH,CAAC;IACH,CAAC;IAED,gBAAgB,CAAC,cAAsB,EAAE,qBAA6B;QACpE,MAAM,IAAI,KAAK,CAAC,kHAAkH,CAAC,CAAA;IACrI,CAAC;IAED,oBAAoB,CAAC,UAAwC;QAC3D,MAAM,IAAI,KAAK,CAAC,kHAAkH,CAAC,CAAA;IACrI,CAAC;IAED,IAAI,IAAI;QACN,MAAM,IAAI,KAAK,CAAC,kHAAkH,CAAC,CAAA;IACrI,CAAC;IAED,2BAA2B,CACzB,mBAMG,EACH,oBAA6B;QAE7B,MAAM,IAAI,KAAK,CAAC,kHAAkH,CAAC,CAAA;IACrI,CAAC;CACF;AAlGD,8EAkGC","sourcesContent":["import { ExchangeDataManager } from '../../icc-x-api/crypto/ExchangeDataManager'\nimport { EntityWithDelegationTypeName } from '../../icc-x-api/utils/EntityWithDelegationTypeName'\nimport { ExchangeData } from '../../icc-api/model/internal/ExchangeData'\nimport { expect } from 'chai'\nimport { BaseExchangeDataManager } from '../../icc-x-api/crypto/BaseExchangeDataManager'\nimport { CryptoPrimitives } from '../../icc-x-api'\nimport { id } from 'date-fns/locale'\n\nexport class FakeDecryptionExchangeDataManager implements ExchangeDataManager {\n constructor(private readonly cryptoPrimitives: CryptoPrimitives) {}\n\n private readonly dataByHash: { [hash: string]: { exchangeData: ExchangeData; exchangeKey: CryptoKey; accessControlSecret: string } } = {}\n private readonly dataById: {\n [id: string]: { exchangeData: ExchangeData; exchangeKey: CryptoKey | undefined; accessControlSecret: string | undefined; fakeNonCached: boolean }\n } = {}\n\n clearOrRepopulateCache(): Promise<void> {\n throw new Error('This method is not supported by fake exchange data manager and should not be used.')\n }\n\n getAccessControlKeysValue(entityType: EntityWithDelegationTypeName): Promise<string | undefined> {\n throw new Error('This method is not supported by fake exchange data manager and should not be used.')\n }\n\n async getCachedDecryptionDataKeyByAccessControlHash(\n hashes: string[]\n ): Promise<{ [p: string]: { exchangeData: ExchangeData; exchangeKey: CryptoKey; accessControlSecret: string } }> {\n const res: { [p: string]: { exchangeData: ExchangeData; accessControlSecret: string; exchangeKey: CryptoKey } } = {}\n for (const hash of hashes) {\n const retrieved = this.dataByHash[hash]\n if (retrieved) res[hash] = retrieved\n }\n return res\n }\n\n async getDecryptionDataKeyByIds(\n ids: string[],\n retrieveIfNotCached: boolean\n ): Promise<{ [id: string]: { exchangeKey: CryptoKey | undefined; accessControlSecret: string | undefined; exchangeData: ExchangeData } }> {\n const res: { [id: string]: { exchangeKey: CryptoKey | undefined; accessControlSecret: string | undefined; exchangeData: ExchangeData } } = {}\n for (const id of ids) {\n const retrieved = this.dataById[id]\n if (retrieved) {\n if (retrieveIfNotCached || !retrieved.fakeNonCached) {\n res[id] = retrieved\n }\n }\n }\n return res\n }\n\n getOrCreateEncryptionDataTo(\n delegateId: string\n ): Promise<{ exchangeData: ExchangeData; accessControlSecret: string; exchangeKey: CryptoKey; sharedSignatureKey: CryptoKey }> {\n throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported')\n }\n\n cacheFakeData(\n exchangeData: ExchangeData,\n keyAndHashesFromSecret:\n | {\n exchangeKey: CryptoKey\n accessControlSecret?: string\n hashes: string[]\n }\n | undefined,\n fakeNonCached?: boolean\n ) {\n const acSecret = !!keyAndHashesFromSecret ? keyAndHashesFromSecret.accessControlSecret ?? this.cryptoPrimitives.randomUuid() : undefined\n this.dataById[exchangeData.id!] = {\n exchangeData,\n exchangeKey: keyAndHashesFromSecret?.exchangeKey,\n fakeNonCached: fakeNonCached ?? false,\n accessControlSecret: acSecret,\n }\n if (keyAndHashesFromSecret) {\n for (const hash of keyAndHashesFromSecret.hashes) {\n this.dataByHash[hash] = { exchangeData, exchangeKey: keyAndHashesFromSecret.exchangeKey, accessControlSecret: acSecret! }\n }\n }\n }\n\n giveAccessBackTo(otherDataOwner: string, newDataOwnerPublicKey: string): Promise<void> {\n throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported')\n }\n\n getAllDelegationKeys(entityType: EntityWithDelegationTypeName): Promise<string[] | undefined> {\n throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported')\n }\n\n get base(): BaseExchangeDataManager {\n throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported')\n }\n\n injectDecryptedExchangeData(\n exchangeDataDetails: {\n exchangeDataId: string\n accessControlSecret: ArrayBuffer\n exchangeKey: ArrayBuffer\n sharedSignatureKey: ArrayBuffer\n verified: boolean\n }[],\n reEncryptWithOwnKeys: boolean\n ): Promise<void> {\n throw new Error('This method should not be used with this fake exchange data manager: only retrieval decryption data is supported')\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { ExchangeDataMapManager } from '../../icc-x-api/crypto/ExchangeDataMapManager';
2
+ import { ExchangeDataMap } from '../../icc-api/model/internal/ExchangeDataMap';
3
+ export declare class FakeExchangeDataMapManager extends ExchangeDataMapManager {
4
+ private fakeApi;
5
+ constructor();
6
+ createExchangeDataMaps(batch: {
7
+ [accessControlKeyHash: string]: {
8
+ [fp: string]: string;
9
+ };
10
+ }): Promise<void>;
11
+ getExchangeDataMapBatch(accessControlKeyHashes: string[]): Promise<ExchangeDataMap[]>;
12
+ }
@@ -0,0 +1,38 @@
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
+ exports.FakeExchangeDataMapManager = void 0;
13
+ const ExchangeDataMapManager_1 = require("../../icc-x-api/crypto/ExchangeDataMapManager");
14
+ const IccExchangeDataMapApi_1 = require("../../icc-api/api/internal/IccExchangeDataMapApi");
15
+ const ExchangeDataMap_1 = require("../../icc-api/model/internal/ExchangeDataMap");
16
+ const FakeGenericApi_1 = require("./FakeGenericApi");
17
+ class FakeExchangeDataMapManager extends ExchangeDataMapManager_1.ExchangeDataMapManager {
18
+ constructor() {
19
+ super(new IccExchangeDataMapApi_1.IccExchangeDataMapApi('', {}));
20
+ this.fakeApi = new FakeGenericApi_1.FakeGenericApi();
21
+ }
22
+ createExchangeDataMaps(batch) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ Object.entries(batch).forEach(([hash, encryptedIds]) => {
25
+ this.fakeApi.createObject(new ExchangeDataMap_1.ExchangeDataMap({ id: hash, encryptedExchangeDataIds: encryptedIds }));
26
+ });
27
+ });
28
+ }
29
+ getExchangeDataMapBatch(accessControlKeyHashes) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return accessControlKeyHashes.reduce((prev, curr) => {
32
+ return [...prev, this.fakeApi.getById(curr)];
33
+ }, []);
34
+ });
35
+ }
36
+ }
37
+ exports.FakeExchangeDataMapManager = FakeExchangeDataMapManager;
38
+ //# sourceMappingURL=FakeExchangeDataMapManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeExchangeDataMapManager.js","sourceRoot":"","sources":["../../../test/utils/FakeExchangeDataMapManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0FAAsF;AACtF,4FAAwF;AACxF,kFAA8E;AAC9E,qDAAiD;AAEjD,MAAa,0BAA2B,SAAQ,+CAAsB;IAGpE;QACE,KAAK,CAAC,IAAI,6CAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QAHlC,YAAO,GAAG,IAAI,+BAAc,EAAmB,CAAA;IAIvD,CAAC;IAEK,sBAAsB,CAAC,KAAmE;;YAC9F,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE;gBACrD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,iCAAe,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,YAAY,EAAE,CAAC,CAAC,CAAA;YACtG,CAAC,CAAC,CAAA;QACJ,CAAC;KAAA;IAEK,uBAAuB,CAAC,sBAAgC;;YAC5D,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;gBAClD,OAAO,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC,CAAA;YAC/C,CAAC,EAAE,EAAuB,CAAC,CAAA;QAC7B,CAAC;KAAA;CACF;AAlBD,gEAkBC","sourcesContent":["import { ExchangeDataMapManager } from '../../icc-x-api/crypto/ExchangeDataMapManager'\nimport { IccExchangeDataMapApi } from '../../icc-api/api/internal/IccExchangeDataMapApi'\nimport { ExchangeDataMap } from '../../icc-api/model/internal/ExchangeDataMap'\nimport { FakeGenericApi } from './FakeGenericApi'\n\nexport class FakeExchangeDataMapManager extends ExchangeDataMapManager {\n private fakeApi = new FakeGenericApi<ExchangeDataMap>()\n\n constructor() {\n super(new IccExchangeDataMapApi('', {}))\n }\n\n async createExchangeDataMaps(batch: { [accessControlKeyHash: string]: { [fp: string]: string } }): Promise<void> {\n Object.entries(batch).forEach(([hash, encryptedIds]) => {\n this.fakeApi.createObject(new ExchangeDataMap({ id: hash, encryptedExchangeDataIds: encryptedIds }))\n })\n }\n\n async getExchangeDataMapBatch(accessControlKeyHashes: string[]): Promise<ExchangeDataMap[]> {\n return accessControlKeyHashes.reduce((prev, curr) => {\n return [...prev, this.fakeApi.getById(curr)!]\n }, [] as ExchangeDataMap[])\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ export declare class FakeGenericApi<T extends {
2
+ id?: string;
3
+ rev?: string;
4
+ }> {
5
+ private readonly data;
6
+ private readonly primitives;
7
+ createObject(obj: T): T;
8
+ modifyObject(obj: T): T;
9
+ getAll(): T[];
10
+ getPaged(startId: string | undefined, limit: number): {
11
+ rows: T[];
12
+ nextId: string | undefined;
13
+ };
14
+ getById(id: string): T | undefined;
15
+ private nextRev;
16
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FakeGenericApi = void 0;
4
+ const collection_utils_1 = require("../../icc-x-api/utils/collection-utils");
5
+ const CryptoPrimitives_1 = require("../../icc-x-api/crypto/CryptoPrimitives");
6
+ const crypto_1 = require("crypto");
7
+ class FakeGenericApi {
8
+ constructor() {
9
+ this.data = new Map();
10
+ this.primitives = new CryptoPrimitives_1.WebCryptoPrimitives(crypto_1.webcrypto);
11
+ }
12
+ createObject(obj) {
13
+ if (!obj.id)
14
+ throw new Error(`New object should have id`);
15
+ if (obj.rev)
16
+ throw new Error(`New object should not have rev`);
17
+ if (this.data.get(obj.id))
18
+ throw new Error(`Object with id ${obj.id} already exists.`);
19
+ const withRev = (0, collection_utils_1.cloneDeep)(obj);
20
+ withRev.rev = this.nextRev(withRev.rev);
21
+ this.data.set(obj.id, withRev);
22
+ return (0, collection_utils_1.cloneDeep)(withRev);
23
+ }
24
+ modifyObject(obj) {
25
+ if (!obj.id)
26
+ throw new Error(`Modified object should have id`);
27
+ const existing = this.data.get(obj.id);
28
+ if (!existing)
29
+ throw new Error(`No object with id ${obj.id}`);
30
+ if (existing.rev !== obj.rev)
31
+ throw new Error(`Object with id ${obj.id} has wrong rev: ${obj.rev} but expected ${existing.rev}.`);
32
+ const withNewRev = (0, collection_utils_1.cloneDeep)(obj);
33
+ withNewRev.rev = this.nextRev(withNewRev.rev);
34
+ this.data.set(obj.id, withNewRev);
35
+ return (0, collection_utils_1.cloneDeep)(withNewRev);
36
+ }
37
+ getAll() {
38
+ return [...this.data.values()].map((x) => (0, collection_utils_1.cloneDeep)(x));
39
+ }
40
+ getPaged(startId, limit) {
41
+ let rows = [...this.data.values()];
42
+ let nextId = undefined;
43
+ if (startId) {
44
+ const startIndex = rows.findIndex((x) => x.id === startId);
45
+ rows = rows.slice(startIndex);
46
+ }
47
+ if (rows.length > limit) {
48
+ nextId = rows[limit].id;
49
+ rows = rows.slice(0, limit);
50
+ }
51
+ return { rows: rows.map((x) => (0, collection_utils_1.cloneDeep)(x)), nextId };
52
+ }
53
+ getById(id) {
54
+ const retrieved = this.data.get(id);
55
+ return retrieved ? (0, collection_utils_1.cloneDeep)(retrieved) : undefined;
56
+ }
57
+ nextRev(rev) {
58
+ if (!rev)
59
+ return `1-${this.primitives.randomUuid()}`;
60
+ const prevRevNumber = parseInt(rev.split('-')[0]);
61
+ return `${prevRevNumber + 1}-${this.primitives.randomUuid()}`;
62
+ }
63
+ }
64
+ exports.FakeGenericApi = FakeGenericApi;
65
+ //# sourceMappingURL=FakeGenericApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeGenericApi.js","sourceRoot":"","sources":["../../../test/utils/FakeGenericApi.ts"],"names":[],"mappings":";;;AAAA,6EAAkE;AAClE,8EAA+F;AAC/F,mCAAkC;AAElC,MAAa,cAAc;IAA3B;QACmB,SAAI,GAAmB,IAAI,GAAG,EAAE,CAAA;QAChC,eAAU,GAAqB,IAAI,sCAAmB,CAAC,kBAAgB,CAAC,CAAA;IAyD3F,CAAC;IAvDC,YAAY,CAAC,GAAM;QACjB,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACzD,IAAI,GAAG,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QAC9D,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,C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O,GAAG,aAAa,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAA;IAC/D,CAAC;CACF;AA3DD,wCA2DC","sourcesContent":["import { cloneDeep } from '../../icc-x-api/utils/collection-utils'\nimport { CryptoPrimitives, WebCryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { webcrypto } from 'crypto'\n\nexport class FakeGenericApi<T extends { id?: string; rev?: string }> {\n private readonly data: Map<string, T> = new Map()\n private readonly primitives: CryptoPrimitives = new WebCryptoPrimitives(webcrypto as any)\n\n createObject(obj: T): T {\n if (!obj.id) throw new Error(`New object should have id`)\n if (obj.rev) throw new Error(`New object should not have rev`)\n if (this.data.get(obj.id!)) throw new Error(`Object with id ${obj.id} already exists.`)\n const withRev = cloneDeep(obj)\n withRev.rev = this.nextRev(withRev.rev)\n this.data.set(obj.id, withRev)\n return cloneDeep(withRev)\n }\n\n modifyObject(obj: T): T {\n if (!obj.id) throw new Error(`Modified object should have id`)\n const existing = this.data.get(obj.id!)\n if (!existing) throw new Error(`No object with id ${obj.id}`)\n if (existing.rev !== obj.rev) throw new Error(`Object with id ${obj.id} has wrong rev: ${obj.rev} but expected ${existing.rev}.`)\n const withNewRev = cloneDeep(obj)\n withNewRev.rev = this.nextRev(withNewRev.rev)\n this.data.set(obj.id, withNewRev)\n return cloneDeep(withNewRev)\n }\n\n getAll(): T[] {\n return [...this.data.values()].map((x) => cloneDeep(x))\n }\n\n getPaged(\n startId: string | undefined,\n limit: number\n ): {\n rows: T[]\n nextId: string | undefined\n } {\n let rows = [...this.data.values()]\n let nextId = undefined\n if (startId) {\n const startIndex = rows.findIndex((x) => x.id === startId)\n rows = rows.slice(startIndex)\n }\n if (rows.length > limit) {\n nextId = rows[limit].id\n rows = rows.slice(0, limit)\n }\n return { rows: rows.map((x) => cloneDeep(x)), nextId }\n }\n\n getById(id: string): T | undefined {\n const retrieved = this.data.get(id)\n return retrieved ? cloneDeep(retrieved) : undefined\n }\n\n private nextRev(rev: string | undefined): string {\n if (!rev) return `1-${this.primitives.randomUuid()}`\n const prevRevNumber = parseInt(rev.split('-')[0])\n return `${prevRevNumber + 1}-${this.primitives.randomUuid()}`\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { CryptoPrimitives, CryptoStrategies, KeyPair } from '../../icc-x-api';
2
+ import { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub';
3
+ import { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType';
4
+ export declare class KeylessCryptoStrategies implements CryptoStrategies {
5
+ requestedKey: boolean;
6
+ dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean;
7
+ generateNewKeyForDataOwner(): Promise<KeyPair<CryptoKey> | boolean | 'keyless'>;
8
+ recoverAndVerifySelfHierarchyKeys(keysData: {
9
+ dataOwner: DataOwnerWithType;
10
+ unknownKeys: string[];
11
+ unavailableKeys: string[];
12
+ }[]): Promise<{
13
+ [p: string]: {
14
+ recoveredKeys: {
15
+ [p: string]: KeyPair<CryptoKey>;
16
+ };
17
+ keyAuthenticity: {
18
+ [p: string]: boolean;
19
+ };
20
+ };
21
+ }>;
22
+ verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]>;
23
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeylessCryptoStrategies = void 0;
4
+ const DataOwnerTypeEnum_1 = require("../../icc-api/model/DataOwnerTypeEnum");
5
+ class KeylessCryptoStrategies {
6
+ constructor() {
7
+ this.requestedKey = false;
8
+ }
9
+ dataOwnerRequiresAnonymousDelegation(dataOwner) {
10
+ return dataOwner.type != DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp;
11
+ }
12
+ generateNewKeyForDataOwner() {
13
+ this.requestedKey = true;
14
+ return Promise.resolve('keyless');
15
+ }
16
+ recoverAndVerifySelfHierarchyKeys(keysData) {
17
+ const res = {};
18
+ keysData.forEach((x) => (res[x.dataOwner.dataOwner.id] = { recoveredKeys: {}, keyAuthenticity: {} }));
19
+ return Promise.resolve(res);
20
+ }
21
+ verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
22
+ return Promise.resolve(publicKeys);
23
+ }
24
+ }
25
+ exports.KeylessCryptoStrategies = KeylessCryptoStrategies;
26
+ //# sourceMappingURL=KeylessCryptoStrategies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeylessCryptoStrategies.js","sourceRoot":"","sources":["../../../test/utils/KeylessCryptoStrategies.ts"],"names":[],"mappings":";;;AAEA,6EAAyE;AAGzE,MAAa,uBAAuB;IAApC;QACE,iBAAY,GAAY,KAAK,CAAA;IA8B/B,CAAC;IA5BC,oCAAoC,CAAC,SAAkC;QACrE,OAAO,SAAS,CAAC,IAAI,IAAI,qCAAiB,CAAC,GAAG,CAAA;IAChD,CAAC;IAED,0BAA0B;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACnC,CAAC;IAED,iCAAiC,CAC/B,QAIG;QAIH,MAAM,GAAG,GAEL,EAAE,CAAA;QACN,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,EAAG,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QACtG,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,wBAAwB,CAAC,QAAiC,EAAE,UAAoB,EAAE,gBAAkC;QAClH,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACpC,CAAC;CACF;AA/BD,0DA+BC","sourcesContent":["import { CryptoPrimitives, CryptoStrategies, KeyPair } from '../../icc-x-api'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\n\nexport class KeylessCryptoStrategies implements CryptoStrategies {\n requestedKey: boolean = false\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return dataOwner.type != DataOwnerTypeEnum.Hcp\n }\n\n generateNewKeyForDataOwner(): Promise<KeyPair<CryptoKey> | boolean | 'keyless'> {\n this.requestedKey = true\n return Promise.resolve('keyless')\n }\n\n recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[]\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n const res: {\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n } = {}\n keysData.forEach((x) => (res[x.dataOwner.dataOwner.id!] = { recoveredKeys: {}, keyAuthenticity: {} }))\n return Promise.resolve(res)\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { IcureApi, IcureApiOptions, KeyPair } from '../../icc-x-api';
2
+ import 'isomorphic-fetch';
3
+ export declare const TestApi: (host: string, username: string, password: string, crypto?: Crypto, keyPair?: KeyPair<CryptoKey>, options?: IcureApiOptions) => Promise<IcureApi>;