@icure/api 6.4.0 → 7.0.0-beta.1

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 (154) hide show
  1. package/icc-api/api/IccDeviceApi.d.ts +1 -1
  2. package/icc-api/api/IccDeviceApi.js.map +1 -1
  3. package/icc-api/api/IccDoctemplateApi.js.map +1 -1
  4. package/icc-api/api/IccDocumentTemplateApi.js.map +1 -1
  5. package/icc-api/api/IccHcpartyApi.d.ts +1 -1
  6. package/icc-api/api/IccHcpartyApi.js.map +1 -1
  7. package/icc-api/api/IccPatientApi.d.ts +1 -1
  8. package/icc-api/api/IccPatientApi.js.map +1 -1
  9. package/icc-api/model/MaintenanceTask.d.ts +6 -5
  10. package/icc-api/model/MaintenanceTask.js +5 -0
  11. package/icc-api/model/MaintenanceTask.js.map +1 -1
  12. package/icc-api/model/User.d.ts +23 -1
  13. package/icc-api/model/User.js +21 -0
  14. package/icc-api/model/User.js.map +1 -1
  15. package/icc-api/model/models.d.ts +14 -0
  16. package/icc-api/model/models.js.map +1 -1
  17. package/icc-x-api/crypto/AES.d.ts +2 -0
  18. package/icc-x-api/crypto/AES.js +12 -0
  19. package/icc-x-api/crypto/AES.js.map +1 -1
  20. package/icc-x-api/crypto/BaseExchangeKeysManager.d.ts +122 -0
  21. package/icc-x-api/crypto/BaseExchangeKeysManager.js +356 -0
  22. package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -0
  23. package/icc-x-api/crypto/ConfidentialEntities.d.ts +58 -0
  24. package/icc-x-api/crypto/ConfidentialEntities.js +99 -0
  25. package/icc-x-api/crypto/ConfidentialEntities.js.map +1 -0
  26. package/icc-x-api/crypto/CryptoPrimitives.d.ts +31 -0
  27. package/icc-x-api/crypto/CryptoPrimitives.js +55 -0
  28. package/icc-x-api/crypto/CryptoPrimitives.js.map +1 -0
  29. package/icc-x-api/crypto/CryptoStrategies.d.ts +82 -0
  30. package/icc-x-api/crypto/CryptoStrategies.js +3 -0
  31. package/icc-x-api/crypto/CryptoStrategies.js.map +1 -0
  32. package/icc-x-api/crypto/EntitiesEncryption.d.ts +254 -0
  33. package/icc-x-api/crypto/EntitiesEncryption.js +700 -0
  34. package/icc-x-api/crypto/EntitiesEncryption.js.map +1 -0
  35. package/icc-x-api/crypto/ExchangeKeysManager.d.ts +56 -0
  36. package/icc-x-api/crypto/ExchangeKeysManager.js +147 -0
  37. package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -0
  38. package/icc-x-api/crypto/KeyManager.d.ts +103 -0
  39. package/icc-x-api/crypto/KeyManager.js +288 -0
  40. package/icc-x-api/crypto/KeyManager.js.map +1 -0
  41. package/icc-x-api/crypto/KeyRecovery.d.ts +34 -0
  42. package/icc-x-api/crypto/KeyRecovery.js +253 -0
  43. package/icc-x-api/crypto/KeyRecovery.js.map +1 -0
  44. package/icc-x-api/crypto/LegacyCryptoStrategies.d.ts +28 -0
  45. package/icc-x-api/crypto/LegacyCryptoStrategies.js +22 -0
  46. package/icc-x-api/crypto/LegacyCryptoStrategies.js.map +1 -0
  47. package/icc-x-api/crypto/RSA.d.ts +19 -20
  48. package/icc-x-api/crypto/RSA.js +30 -1
  49. package/icc-x-api/crypto/RSA.js.map +1 -1
  50. package/icc-x-api/crypto/ShamirKeysManager.d.ts +43 -0
  51. package/icc-x-api/crypto/ShamirKeysManager.js +150 -0
  52. package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -0
  53. package/icc-x-api/crypto/ShareMetadataBehaviour.d.ts +19 -0
  54. package/icc-x-api/crypto/ShareMetadataBehaviour.js +24 -0
  55. package/icc-x-api/crypto/ShareMetadataBehaviour.js.map +1 -0
  56. package/icc-x-api/crypto/TransferKeysManager.d.ts +29 -0
  57. package/icc-x-api/crypto/TransferKeysManager.js +121 -0
  58. package/icc-x-api/crypto/TransferKeysManager.js.map +1 -0
  59. package/icc-x-api/crypto/utils.d.ts +46 -0
  60. package/icc-x-api/crypto/utils.js +128 -0
  61. package/icc-x-api/crypto/utils.js.map +1 -1
  62. package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.d.ts +11 -0
  63. package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.js +11 -0
  64. package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.js.map +1 -1
  65. package/icc-x-api/filters/DeviceByHcPartyFilter.d.ts +11 -0
  66. package/icc-x-api/filters/DeviceByHcPartyFilter.js +11 -0
  67. package/icc-x-api/filters/DeviceByHcPartyFilter.js.map +1 -1
  68. package/icc-x-api/filters/DeviceByIdsFilter.d.ts +11 -0
  69. package/icc-x-api/filters/DeviceByIdsFilter.js +11 -0
  70. package/icc-x-api/filters/DeviceByIdsFilter.js.map +1 -1
  71. package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.d.ts +11 -0
  72. package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.js +11 -0
  73. package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.js.map +1 -1
  74. package/icc-x-api/icc-accesslog-x-api.d.ts +49 -4
  75. package/icc-x-api/icc-accesslog-x-api.js +112 -102
  76. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  77. package/icc-x-api/icc-calendar-item-x-api.d.ts +53 -5
  78. package/icc-x-api/icc-calendar-item-x-api.js +112 -100
  79. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  80. package/icc-x-api/icc-classification-x-api.d.ts +45 -2
  81. package/icc-x-api/icc-classification-x-api.js +89 -41
  82. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  83. package/icc-x-api/icc-contact-x-api.d.ts +57 -19
  84. package/icc-x-api/icc-contact-x-api.js +149 -154
  85. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  86. package/icc-x-api/icc-crypto-x-api.d.ts +266 -366
  87. package/icc-x-api/icc-crypto-x-api.js +416 -1327
  88. package/icc-x-api/icc-crypto-x-api.js.map +1 -1
  89. package/icc-x-api/icc-data-owner-x-api.d.ts +110 -11
  90. package/icc-x-api/icc-data-owner-x-api.js +188 -14
  91. package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
  92. package/icc-x-api/icc-doctemplate-x-api.js +3 -3
  93. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  94. package/icc-x-api/icc-document-x-api.d.ts +76 -5
  95. package/icc-x-api/icc-document-x-api.js +137 -59
  96. package/icc-x-api/icc-document-x-api.js.map +1 -1
  97. package/icc-x-api/icc-form-x-api.d.ts +47 -7
  98. package/icc-x-api/icc-form-x-api.js +85 -86
  99. package/icc-x-api/icc-form-x-api.js.map +1 -1
  100. package/icc-x-api/icc-hcparty-x-api.d.ts +1 -1
  101. package/icc-x-api/icc-hcparty-x-api.js +1 -1
  102. package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
  103. package/icc-x-api/icc-helement-x-api.d.ts +50 -3
  104. package/icc-x-api/icc-helement-x-api.js +101 -118
  105. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  106. package/icc-x-api/icc-icure-maintenance-x-api.d.ts +31 -0
  107. package/icc-x-api/icc-icure-maintenance-x-api.js +124 -0
  108. package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -0
  109. package/icc-x-api/icc-invoice-x-api.d.ts +45 -5
  110. package/icc-x-api/icc-invoice-x-api.js +89 -64
  111. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  112. package/icc-x-api/icc-maintenance-task-x-api.d.ts +38 -6
  113. package/icc-x-api/icc-maintenance-task-x-api.js +73 -102
  114. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  115. package/icc-x-api/icc-message-x-api.d.ts +55 -2
  116. package/icc-x-api/icc-message-x-api.js +92 -33
  117. package/icc-x-api/icc-message-x-api.js.map +1 -1
  118. package/icc-x-api/icc-patient-x-api.d.ts +67 -7
  119. package/icc-x-api/icc-patient-x-api.js +409 -473
  120. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  121. package/icc-x-api/icc-receipt-x-api.d.ts +49 -5
  122. package/icc-x-api/icc-receipt-x-api.js +85 -47
  123. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  124. package/icc-x-api/icc-time-table-x-api.d.ts +34 -10
  125. package/icc-x-api/icc-time-table-x-api.js +61 -18
  126. package/icc-x-api/icc-time-table-x-api.js.map +1 -1
  127. package/icc-x-api/index.d.ts +30 -1
  128. package/icc-x-api/index.js +112 -49
  129. package/icc-x-api/index.js.map +1 -1
  130. package/icc-x-api/maintenance/KeyPairUpdateRequest.d.ts +35 -0
  131. package/icc-x-api/maintenance/KeyPairUpdateRequest.js +54 -0
  132. package/icc-x-api/maintenance/KeyPairUpdateRequest.js.map +1 -0
  133. package/icc-x-api/storage/DefaultStorageEntryKeysFactory.d.ts +9 -0
  134. package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js +23 -0
  135. package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js.map +1 -0
  136. package/icc-x-api/storage/IcureStorageFacade.d.ts +55 -0
  137. package/icc-x-api/storage/IcureStorageFacade.js +95 -0
  138. package/icc-x-api/storage/IcureStorageFacade.js.map +1 -0
  139. package/icc-x-api/storage/StorageEntryKeysFactory.d.ts +31 -0
  140. package/icc-x-api/storage/StorageEntryKeysFactory.js +3 -0
  141. package/icc-x-api/storage/StorageEntryKeysFactory.js.map +1 -0
  142. package/icc-x-api/utils/collection-utils.d.ts +8 -0
  143. package/icc-x-api/utils/collection-utils.js +26 -0
  144. package/icc-x-api/utils/collection-utils.js.map +1 -0
  145. package/icc-x-api/utils/crypto-utils.d.ts +8 -1
  146. package/icc-x-api/utils/crypto-utils.js +19 -3
  147. package/icc-x-api/utils/crypto-utils.js.map +1 -1
  148. package/icc-x-api/utils/graph-utils.d.ts +45 -0
  149. package/icc-x-api/utils/graph-utils.js +203 -0
  150. package/icc-x-api/utils/graph-utils.js.map +1 -0
  151. package/icc-x-api/utils/lru-temporised-async-cache.d.ts +27 -0
  152. package/icc-x-api/utils/lru-temporised-async-cache.js +120 -0
  153. package/icc-x-api/utils/lru-temporised-async-cache.js.map +1 -0
  154. package/package.json +1 -1
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContactByHcPartyTagCodeDateFilter = void 0;
4
+ /**
5
+ * iCure Data Stack API Documentation
6
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
7
+ *
8
+ * OpenAPI spec version: v1
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by the swagger code generator program.
12
+ * https://github.com/swagger-api/swagger-codegen.git
13
+ * Do not edit the class manually.
14
+ */
4
15
  const AbstractFilterContact_1 = require("../../icc-api/model/AbstractFilterContact");
5
16
  class ContactByHcPartyTagCodeDateFilter extends AbstractFilterContact_1.AbstractFilterContact {
6
17
  constructor(json) {
@@ -1 +1 @@
1
- {"version":3,"file":"ContactByHcPartyTagCodeDateFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.ts"],"names":[],"mappings":";;;AAaA,qFAAiF;AAEjF,MAAa,iCAAkC,SAAQ,6CAAqB;IAE1E,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,mCAAmC,CAAA;QAIjD,MAAM,CAAC,MAAM,CAAC,IAAyC,EAAE,IAAI,CAAC,CAAA;IAChE,CAAC;CAUF;AAhBD,8EAgBC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { Filter } from './filters'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { AbstractFilterContact } from '../../icc-api/model/AbstractFilterContact'\n\nexport class ContactByHcPartyTagCodeDateFilter extends AbstractFilterContact {\n $type: string = 'ContactByHcPartyTagCodeDateFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as ContactByHcPartyTagCodeDateFilter, json)\n }\n\n desc?: string\n healthcarePartyId?: string\n tagType?: string\n tagCode?: string\n codeType?: string\n codeCode?: string\n startOfContactOpeningDate?: number\n endOfContactOpeningDate?: number\n}\n"]}
1
+ {"version":3,"file":"ContactByHcPartyTagCodeDateFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,qFAAiF;AAEjF,MAAa,iCAAkC,SAAQ,6CAAqB;IAE1E,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,mCAAmC,CAAA;QAIjD,MAAM,CAAC,MAAM,CAAC,IAAyC,EAAE,IAAI,CAAC,CAAA;IAChE,CAAC;CAUF;AAhBD,8EAgBC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { AbstractFilterContact } from '../../icc-api/model/AbstractFilterContact'\n\nexport class ContactByHcPartyTagCodeDateFilter extends AbstractFilterContact {\n $type: string = 'ContactByHcPartyTagCodeDateFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as ContactByHcPartyTagCodeDateFilter, json)\n }\n\n desc?: string\n healthcarePartyId?: string\n tagType?: string\n tagCode?: string\n codeType?: string\n codeCode?: string\n startOfContactOpeningDate?: number\n endOfContactOpeningDate?: number\n}\n"]}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * iCure Data Stack API Documentation
3
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
4
+ *
5
+ * OpenAPI spec version: v1
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by the swagger code generator program.
9
+ * https://github.com/swagger-api/swagger-codegen.git
10
+ * Do not edit the class manually.
11
+ */
1
12
  import { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice';
2
13
  export declare class DeviceByHcPartyFilter extends AbstractFilterDevice {
3
14
  $type: string;
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceByHcPartyFilter = void 0;
4
+ /**
5
+ * iCure Data Stack API Documentation
6
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
7
+ *
8
+ * OpenAPI spec version: v1
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by the swagger code generator program.
12
+ * https://github.com/swagger-api/swagger-codegen.git
13
+ * Do not edit the class manually.
14
+ */
4
15
  const AbstractFilterDevice_1 = require("../../icc-api/model/AbstractFilterDevice");
5
16
  class DeviceByHcPartyFilter extends AbstractFilterDevice_1.AbstractFilterDevice {
6
17
  constructor(json) {
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceByHcPartyFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/DeviceByHcPartyFilter.ts"],"names":[],"mappings":";;;AAaA,mFAA+E;AAE/E,MAAa,qBAAsB,SAAQ,2CAAoB;IAE7D,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,uBAAuB,CAAA;QAIrC,MAAM,CAAC,MAAM,CAAC,IAA6B,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC;CAIF;AAVD,sDAUC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { Filter } from './filters'\nimport { Device } from '../../icc-api/model/Device'\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\n\nexport class DeviceByHcPartyFilter extends AbstractFilterDevice {\n $type: string = 'DeviceByHcPartyFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as DeviceByHcPartyFilter, json)\n }\n\n desc?: string\n responsibleId?: string\n}\n"]}
1
+ {"version":3,"file":"DeviceByHcPartyFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/DeviceByHcPartyFilter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,mFAA+E;AAE/E,MAAa,qBAAsB,SAAQ,2CAAoB;IAE7D,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,uBAAuB,CAAA;QAIrC,MAAM,CAAC,MAAM,CAAC,IAA6B,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC;CAIF;AAVD,sDAUC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\n\nexport class DeviceByHcPartyFilter extends AbstractFilterDevice {\n $type: string = 'DeviceByHcPartyFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as DeviceByHcPartyFilter, json)\n }\n\n desc?: string\n responsibleId?: string\n}\n"]}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * iCure Data Stack API Documentation
3
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
4
+ *
5
+ * OpenAPI spec version: v1
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by the swagger code generator program.
9
+ * https://github.com/swagger-api/swagger-codegen.git
10
+ * Do not edit the class manually.
11
+ */
1
12
  import { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice';
2
13
  export declare class DeviceByIdsFilter extends AbstractFilterDevice {
3
14
  $type: string;
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceByIdsFilter = void 0;
4
+ /**
5
+ * iCure Data Stack API Documentation
6
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
7
+ *
8
+ * OpenAPI spec version: v1
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by the swagger code generator program.
12
+ * https://github.com/swagger-api/swagger-codegen.git
13
+ * Do not edit the class manually.
14
+ */
4
15
  const AbstractFilterDevice_1 = require("../../icc-api/model/AbstractFilterDevice");
5
16
  class DeviceByIdsFilter extends AbstractFilterDevice_1.AbstractFilterDevice {
6
17
  constructor(json) {
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceByIdsFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/DeviceByIdsFilter.ts"],"names":[],"mappings":";;;AAaA,mFAA+E;AAE/E,MAAa,iBAAkB,SAAQ,2CAAoB;IAEzD,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,mBAAmB,CAAA;QAIjC,MAAM,CAAC,MAAM,CAAC,IAAyB,EAAE,IAAI,CAAC,CAAA;IAChD,CAAC;CAIF;AAVD,8CAUC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { Filter } from './filters'\nimport { Device } from '../../icc-api/model/Device'\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\n\nexport class DeviceByIdsFilter extends AbstractFilterDevice {\n $type: string = 'DeviceByIdsFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as DeviceByIdsFilter, json)\n }\n\n ids?: Array<string>\n desc?: string\n}\n"]}
1
+ {"version":3,"file":"DeviceByIdsFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/DeviceByIdsFilter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,mFAA+E;AAE/E,MAAa,iBAAkB,SAAQ,2CAAoB;IAEzD,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,mBAAmB,CAAA;QAIjC,MAAM,CAAC,MAAM,CAAC,IAAyB,EAAE,IAAI,CAAC,CAAA;IAChD,CAAC;CAIF;AAVD,8CAUC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\n\nexport class DeviceByIdsFilter extends AbstractFilterDevice {\n $type: string = 'DeviceByIdsFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as DeviceByIdsFilter, json)\n }\n\n ids?: Array<string>\n desc?: string\n}\n"]}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * iCure Data Stack API Documentation
3
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
4
+ *
5
+ * OpenAPI spec version: v1
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by the swagger code generator program.
9
+ * https://github.com/swagger-api/swagger-codegen.git
10
+ * Do not edit the class manually.
11
+ */
1
12
  import { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement';
2
13
  export declare class HealthElementByHcPartySecretForeignKeysFilter extends AbstractFilterHealthElement {
3
14
  $type: string;
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HealthElementByHcPartySecretForeignKeysFilter = void 0;
4
+ /**
5
+ * iCure Data Stack API Documentation
6
+ * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
7
+ *
8
+ * OpenAPI spec version: v1
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by the swagger code generator program.
12
+ * https://github.com/swagger-api/swagger-codegen.git
13
+ * Do not edit the class manually.
14
+ */
4
15
  const AbstractFilterHealthElement_1 = require("../../icc-api/model/AbstractFilterHealthElement");
5
16
  class HealthElementByHcPartySecretForeignKeysFilter extends AbstractFilterHealthElement_1.AbstractFilterHealthElement {
6
17
  constructor(json) {
@@ -1 +1 @@
1
- {"version":3,"file":"HealthElementByHcPartySecretForeignKeysFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.ts"],"names":[],"mappings":";;;AAaA,iGAA6F;AAE7F,MAAa,6CAA8C,SAAQ,yDAA2B;IAE5F,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,+CAA+C,CAAA;QAI7D,MAAM,CAAC,MAAM,CAAC,IAAqD,EAAE,IAAI,CAAC,CAAA;IAC5E,CAAC;CAKF;AAXD,sGAWC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { Filter } from './filters'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\n\nexport class HealthElementByHcPartySecretForeignKeysFilter extends AbstractFilterHealthElement {\n $type: string = 'HealthElementByHcPartySecretForeignKeysFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as HealthElementByHcPartySecretForeignKeysFilter, json)\n }\n\n desc?: string\n healthcarePartyId?: string\n patientSecretForeignKeys?: Array<string>\n}\n"]}
1
+ {"version":3,"file":"HealthElementByHcPartySecretForeignKeysFilter.js","sourceRoot":"","sources":["../../../icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,iGAA6F;AAE7F,MAAa,6CAA8C,SAAQ,yDAA2B;IAE5F,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAFb,UAAK,GAAW,+CAA+C,CAAA;QAI7D,MAAM,CAAC,MAAM,CAAC,IAAqD,EAAE,IAAI,CAAC,CAAA;IAC5E,CAAC;CAKF;AAXD,sGAWC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\n\nexport class HealthElementByHcPartySecretForeignKeysFilter extends AbstractFilterHealthElement {\n $type: string = 'HealthElementByHcPartySecretForeignKeysFilter'\n constructor(json: JSON | any) {\n super(json)\n\n Object.assign(this as HealthElementByHcPartySecretForeignKeysFilter, json)\n }\n\n desc?: string\n healthcarePartyId?: string\n patientSecretForeignKeys?: Array<string>\n}\n"]}
@@ -4,6 +4,7 @@ import * as models from '../icc-api/model/models';
4
4
  import { AccessLog, PaginatedListAccessLog } from '../icc-api/model/models';
5
5
  import { IccDataOwnerXApi } from './icc-data-owner-x-api';
6
6
  import { AuthenticationProvider } from './auth/AuthenticationProvider';
7
+ import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
7
8
  export interface AccessLogWithPatientId extends AccessLog {
8
9
  patientId: string;
9
10
  }
@@ -14,7 +15,27 @@ export declare class IccAccesslogXApi extends IccAccesslogApi {
14
15
  constructor(host: string, headers: {
15
16
  [key: string]: string;
16
17
  }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
17
- newInstance(user: models.User, patient: models.Patient, h: any): Promise<any>;
18
+ /**
19
+ * Creates a new instance of access log with initialised encryption metadata (not in the database).
20
+ * @param user the current user.
21
+ * @param patient the patient this access log refers to.
22
+ * @param h initialised data for the access log. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
23
+ * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
24
+ * @param options optional parameters:
25
+ * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
26
+ * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
27
+ * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
28
+ * access will be possible.
29
+ * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the access log. The default value will be a
30
+ * secret id of patient known by the topmost parent in the current data owner hierarchy.
31
+ * @return a new instance of access log.
32
+ */
33
+ newInstance(user: models.User, patient: models.Patient, h: any, options?: {
34
+ additionalDelegates?: {
35
+ [dataOwnerId: string]: 'WRITE';
36
+ };
37
+ preferredSfk?: string;
38
+ }): Promise<models.AccessLog>;
18
39
  /**
19
40
  * 1. Check whether there is a delegation with 'hcpartyId' or not.
20
41
  * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him.
@@ -32,12 +53,12 @@ export declare class IccAccesslogXApi extends IccAccesslogApi {
32
53
  * @param keepObsoleteVersions
33
54
  * @param usingPost
34
55
  */
35
- findBy(hcpartyId: string, patient: models.Patient, usingPost?: boolean): Promise<any>;
36
- findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise<Array<AccessLog> | any>;
56
+ findBy(hcpartyId: string, patient: models.Patient, usingPost?: boolean): Promise<models.AccessLog[]>;
57
+ findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise<AccessLog[]>;
37
58
  findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise<Array<AccessLog> | any>;
38
59
  decrypt(hcpId: string, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>>;
39
- initEncryptionKeys(user: models.User, accessLog: models.AccessLog): Promise<models.AccessLog>;
40
60
  encrypt(user: models.User, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>>;
61
+ private encryptAs;
41
62
  createAccessLog(body?: models.AccessLog): never;
42
63
  createAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise<models.AccessLog | any>;
43
64
  getAccessLog(accessLogId: string): never;
@@ -46,7 +67,31 @@ export declare class IccAccesslogXApi extends IccAccesslogApi {
46
67
  listAccessLogsWithUser(user: models.User, fromEpoch?: number, toEpoch?: number, startKey?: number, startDocumentId?: string, limit?: number, descending?: boolean): Promise<PaginatedListAccessLog>;
47
68
  modifyAccessLog(body?: models.AccessLog): never;
48
69
  modifyAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise<models.AccessLog | null>;
70
+ private modifyAs;
49
71
  findByUserAfterDate(userId: string, accessType?: string, startDate?: number, startKey?: string, startDocumentId?: string, limit?: number, descending?: boolean): never;
50
72
  findByUserAfterDateWithUser(user: models.User, userId: string, accessType?: string, startDate?: number, startKey?: string, startDocumentId?: string, limit?: number, descending?: boolean): Promise<models.AccessLog | any>;
51
73
  findLatestAccessLogsOfPatientsWithUser(user: models.User, userId: string, limit?: number, startDate?: number): Promise<models.AccessLog[]>;
74
+ /**
75
+ * @param accessLog an access log
76
+ * @return the id of the patient that the access log refers to, retrieved from the encrypted metadata (not from the decrypted entity body). Normally
77
+ * there should only be one element in the returned array, but in case of entity merges there could be multiple values.
78
+ */
79
+ decryptPatientIdOf(accessLog: AccessLog): Promise<string[]>;
80
+ /**
81
+ * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the
82
+ * encrypted content.
83
+ * @param delegateId the id of the data owner which will be granted access to the access log.
84
+ * @param accessLog the access log to share.
85
+ * @param options optional parameters to customize the sharing behaviour:
86
+ * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
87
+ * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}).
88
+ * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would
89
+ * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other
90
+ * encrypted data of the access log (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}).
91
+ * @return a promise which will contain the updated entity.
92
+ */
93
+ shareWith(delegateId: string, accessLog: AccessLog, options?: {
94
+ shareEncryptionKey?: ShareMetadataBehaviour;
95
+ sharePatientId?: ShareMetadataBehaviour;
96
+ }): Promise<AccessLog>;
52
97
  }
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.IccAccesslogXApi = void 0;
13
13
  const icc_api_1 = require("../icc-api");
14
+ const models_1 = require("../icc-api/model/models");
14
15
  const _ = require("lodash");
15
- const utils_1 = require("./utils");
16
16
  const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
17
17
  class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
18
18
  constructor(host, headers, crypto, dataOwnerApi, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
@@ -25,38 +25,54 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
25
25
  this.crypto = crypto;
26
26
  this.dataOwnerApi = dataOwnerApi;
27
27
  }
28
- newInstance(user, patient, h) {
29
- const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user);
30
- const accessslog = _.assign({
31
- id: this.crypto.randomUuid(),
32
- _type: 'org.taktik.icure.entities.AccessLog',
33
- created: new Date().getTime(),
34
- modified: new Date().getTime(),
35
- date: +new Date(),
36
- responsible: dataOwnerId,
37
- author: user.id,
38
- codes: [],
39
- tags: [],
40
- user: user.id,
41
- patientId: patient.id,
42
- accessType: 'USER_ACCESS',
43
- }, h || {});
44
- return this.crypto.extractDelegationsSFKs(patient, dataOwnerId).then((secretForeignKeys) => __awaiter(this, void 0, void 0, function* () {
45
- const dels = yield this.crypto.initObjectDelegations(accessslog, patient, dataOwnerId, secretForeignKeys.extractedKeys[0]);
46
- const eks = yield this.crypto.initEncryptionKeys(accessslog, dataOwnerId);
47
- _.extend(accessslog, {
48
- delegations: dels.delegations,
49
- cryptedForeignKeys: dels.cryptedForeignKeys,
50
- secretForeignKeys: dels.secretForeignKeys,
51
- encryptionKeys: eks.encryptionKeys,
52
- });
53
- let promise = Promise.resolve(accessslog);
54
- (user.autoDelegations ? (user.autoDelegations.all || []).concat(user.autoDelegations.medicalInformation || []) : []).forEach((delegateId) => (promise = promise.then(() => this.crypto.addDelegationsAndEncryptionKeys(patient, accessslog, dataOwnerId, delegateId, dels.secretId, eks.secretId).catch((e) => {
55
- console.log(e);
56
- return accessslog;
57
- }))));
58
- return promise;
59
- }));
28
+ /**
29
+ * Creates a new instance of access log with initialised encryption metadata (not in the database).
30
+ * @param user the current user.
31
+ * @param patient the patient this access log refers to.
32
+ * @param h initialised data for the access log. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
33
+ * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
34
+ * @param options optional parameters:
35
+ * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
36
+ * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
37
+ * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
38
+ * access will be possible.
39
+ * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the access log. The default value will be a
40
+ * secret id of patient known by the topmost parent in the current data owner hierarchy.
41
+ * @return a new instance of access log.
42
+ */
43
+ newInstance(user, patient, h, options = {}) {
44
+ var _a, _b, _c, _d, _e, _f;
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user);
47
+ const accessLog = _.assign({
48
+ id: this.crypto.primitives.randomUuid(),
49
+ _type: 'org.taktik.icure.entities.AccessLog',
50
+ created: new Date().getTime(),
51
+ modified: new Date().getTime(),
52
+ date: +new Date(),
53
+ responsible: dataOwnerId,
54
+ author: user.id,
55
+ codes: [],
56
+ tags: [],
57
+ user: user.id,
58
+ patientId: patient.id,
59
+ accessType: 'USER_ACCESS',
60
+ }, h || {});
61
+ const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
62
+ if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
63
+ throw new Error('Can only initialise entities as current data owner.');
64
+ const sfk = (_a = options.preferredSfk) !== null && _a !== void 0 ? _a : (yield this.crypto.confidential.getAnySecretIdSharedWithParents(patient));
65
+ if (!sfk)
66
+ throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`);
67
+ const extraDelegations = [
68
+ ...Object.keys((_b = options.additionalDelegates) !== null && _b !== void 0 ? _b : {}),
69
+ ...((_d = (_c = user.autoDelegations) === null || _c === void 0 ? void 0 : _c.all) !== null && _d !== void 0 ? _d : []),
70
+ ...((_f = (_e = user.autoDelegations) === null || _e === void 0 ? void 0 : _e.administrativeData) !== null && _f !== void 0 ? _f : []),
71
+ ];
72
+ return new models_1.AccessLog(yield this.crypto.entities
73
+ .entityWithInitialisedEncryptedMetadata(accessLog, patient.id, sfk, true, extraDelegations)
74
+ .then((x) => x.updatedEntity));
75
+ });
60
76
  }
61
77
  // noinspection JSUnusedGlobalSymbols
62
78
  /**
@@ -77,69 +93,36 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
77
93
  * @param usingPost
78
94
  */
79
95
  findBy(hcpartyId, patient, usingPost = false) {
80
- return this.crypto
81
- .extractDelegationsSFKs(patient, hcpartyId)
82
- .then((secretForeignKeys) => secretForeignKeys && secretForeignKeys.extractedKeys && secretForeignKeys.extractedKeys.length > 0
83
- ? (usingPost ?
84
- this.findByHCPartyPatientSecretFKeysArray(secretForeignKeys.hcpartyId, _.uniq(secretForeignKeys.extractedKeys)) :
85
- this.findByHCPartyPatientSecretFKeys(secretForeignKeys.hcpartyId, _.uniq(secretForeignKeys.extractedKeys).join(',')))
86
- : Promise.resolve([]));
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const extractedKeys = yield this.crypto.entities.secretIdsOf(patient, hcpartyId);
98
+ const topmostParentId = (yield this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0];
99
+ return extractedKeys && extractedKeys.length > 0
100
+ ? usingPost
101
+ ? this.findByHCPartyPatientSecretFKeysArray(topmostParentId, _.uniq(extractedKeys))
102
+ : this.findByHCPartyPatientSecretFKeys(topmostParentId, _.uniq(extractedKeys).join(','))
103
+ : Promise.resolve([]);
104
+ });
87
105
  }
88
106
  findByHCPartyPatientSecretFKeys(hcPartyId, secretFKeys) {
89
- return super.findAccessLogsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys).then((accesslogs) => this.decrypt(hcPartyId, accesslogs));
107
+ const _super = Object.create(null, {
108
+ findAccessLogsByHCPartyPatientForeignKeys: { get: () => super.findAccessLogsByHCPartyPatientForeignKeys }
109
+ });
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const accessLogs = yield _super.findAccessLogsByHCPartyPatientForeignKeys.call(this, hcPartyId, secretFKeys);
112
+ return yield this.decrypt(hcPartyId, accessLogs);
113
+ });
90
114
  }
91
115
  findByHCPartyPatientSecretFKeysArray(hcPartyId, secretFKeys) {
92
116
  return super.findAccessLogsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys).then((accesslogs) => this.decrypt(hcPartyId, accesslogs));
93
117
  }
94
118
  decrypt(hcpId, accessLogs) {
95
- //First check that we have no dangling delegation
96
- return Promise.all(accessLogs.map((accessLog) => {
97
- return accessLog.encryptedSelf
98
- ? this.crypto
99
- .extractKeysFromDelegationsForHcpHierarchy(hcpId, accessLog.id, _.size(accessLog.encryptionKeys) ? accessLog.encryptionKeys : accessLog.delegations)
100
- .then(({ extractedKeys: sfks }) => {
101
- if (!sfks || !sfks.length) {
102
- //console.log("Cannot decrypt contact", ctc.id)
103
- return Promise.resolve(accessLog);
104
- }
105
- return this.crypto.AES.importKey('raw', (0, utils_1.hex2ua)(sfks[0].replace(/-/g, ''))).then((key) => (0, utils_1.decrypt)(accessLog, (ec) => this.crypto.AES.decrypt(key, ec).then((dec) => {
106
- const jsonContent = dec && (0, utils_1.ua2utf8)(dec);
107
- try {
108
- return JSON.parse(jsonContent);
109
- }
110
- catch (e) {
111
- console.log('Cannot parse access log', accessLog.id, jsonContent || 'Invalid content');
112
- return {};
113
- }
114
- })));
115
- })
116
- : Promise.resolve(accessLog);
117
- }));
118
- }
119
- initEncryptionKeys(user, accessLog) {
120
- const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user);
121
- return this.crypto.initEncryptionKeys(accessLog, dataOwnerId).then((eks) => {
122
- let promise = Promise.resolve(_.extend(accessLog, {
123
- encryptionKeys: eks.encryptionKeys,
124
- }));
125
- (user.autoDelegations ? (user.autoDelegations.all || []).concat(user.autoDelegations.medicalInformation || []) : []).forEach((delegateId) => (promise = promise.then((accessLog) => this.crypto.appendEncryptionKeys(accessLog, dataOwnerId, delegateId, eks.secretId).then((extraEks) => {
126
- return _.extend(extraEks.modifiedObject, {
127
- encryptionKeys: extraEks.encryptionKeys,
128
- });
129
- }))));
130
- return promise;
131
- });
119
+ return Promise.all(accessLogs.map((x) => this.crypto.entities.decryptEntity(x, hcpId, (json) => new models_1.AccessLog(json)).then(({ entity }) => entity)));
132
120
  }
133
121
  encrypt(user, accessLogs) {
134
- return Promise.all(accessLogs.map((accessLog) => (accessLog.encryptionKeys && Object.keys(accessLog.encryptionKeys).length
135
- ? Promise.resolve(accessLog)
136
- : this.initEncryptionKeys(user, accessLog))
137
- .then((accessLog) => this.crypto.extractKeysFromDelegationsForHcpHierarchy(this.dataOwnerApi.getDataOwnerOf(user), accessLog.id, accessLog.encryptionKeys))
138
- .then((eks) => __awaiter(this, void 0, void 0, function* () {
139
- const rawKey = eks.extractedKeys[0].replace(/-/g, '');
140
- const key = yield this.crypto.AES.importKey('raw', (0, utils_1.hex2ua)(rawKey));
141
- return (0, utils_1.crypt)(accessLog, (obj) => this.crypto.AES.encrypt(key, (0, utils_1.utf8_2ua)(JSON.stringify(obj)), rawKey), this.cryptedKeys);
142
- }))));
122
+ return this.encryptAs(this.dataOwnerApi.getDataOwnerIdOf(user), accessLogs);
123
+ }
124
+ encryptAs(dataOwner, accessLogs) {
125
+ return Promise.all(accessLogs.map((x) => this.crypto.entities.tryEncryptEntity(x, dataOwner, this.cryptedKeys, false, true, (json) => new models_1.AccessLog(json))));
143
126
  }
144
127
  createAccessLog(body) {
145
128
  throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption');
@@ -148,7 +131,7 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
148
131
  return body
149
132
  ? this.encrypt(user, [_.cloneDeep(body)])
150
133
  .then((als) => super.createAccessLog(als[0]))
151
- .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerOf(user), [accessLog]))
134
+ .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [accessLog]))
152
135
  .then((als) => als[0])
153
136
  : Promise.resolve();
154
137
  }
@@ -158,7 +141,7 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
158
141
  getAccessLogWithUser(user, accessLogId) {
159
142
  return super
160
143
  .getAccessLog(accessLogId)
161
- .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerOf(user), [accessLog]))
144
+ .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [accessLog]))
162
145
  .then((als) => als[0]);
163
146
  }
164
147
  listAccessLogs(fromEpoch, toEpoch, startKey, startDocumentId, limit) {
@@ -167,31 +150,29 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
167
150
  listAccessLogsWithUser(user, fromEpoch, toEpoch, startKey, startDocumentId, limit, descending) {
168
151
  return super
169
152
  .listAccessLogs(fromEpoch, toEpoch, startKey, startDocumentId, limit, descending)
170
- .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerOf(user), accessLog.rows).then((dr) => Object.assign(accessLog, { rows: dr })));
153
+ .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), accessLog.rows).then((dr) => Object.assign(accessLog, { rows: dr })));
171
154
  }
172
155
  modifyAccessLog(body) {
173
156
  throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption');
174
157
  }
175
158
  modifyAccessLogWithUser(user, body) {
176
- const _super = Object.create(null, {
177
- modifyAccessLog: { get: () => super.modifyAccessLog }
178
- });
179
159
  return __awaiter(this, void 0, void 0, function* () {
180
- return body
181
- ? this.encrypt(user, [_.cloneDeep(body)])
182
- .then((als) => _super.modifyAccessLog.call(this, als[0]))
183
- .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerOf(user), [accessLog]))
184
- .then((als) => als[0])
185
- : null;
160
+ return body ? this.modifyAs(this.dataOwnerApi.getDataOwnerIdOf(user), _.cloneDeep(body)) : null;
186
161
  });
187
162
  }
163
+ modifyAs(dataOwner, accessLog) {
164
+ return this.encryptAs(dataOwner, [_.cloneDeep(accessLog)])
165
+ .then((als) => super.modifyAccessLog(als[0]))
166
+ .then((accessLog) => this.decrypt(dataOwner, [accessLog]))
167
+ .then((als) => als[0]);
168
+ }
188
169
  findByUserAfterDate(userId, accessType, startDate, startKey, startDocumentId, limit, descending) {
189
170
  throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption');
190
171
  }
191
172
  findByUserAfterDateWithUser(user, userId, accessType, startDate, startKey, startDocumentId, limit, descending) {
192
173
  return super
193
174
  .findByUserAfterDate(userId, accessType, startDate, startKey, startDocumentId, limit, descending)
194
- .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerOf(user), accessLog.rows).then((dr) => Object.assign(accessLog, { rows: dr })));
175
+ .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), accessLog.rows).then((dr) => Object.assign(accessLog, { rows: dr })));
195
176
  }
196
177
  findLatestAccessLogsOfPatientsWithUser(user, userId, limit = 100, startDate) {
197
178
  const _super = Object.create(null, {
@@ -204,8 +185,8 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
204
185
  for (let currentIteration = 0; foundAccessLogs.length < limit && currentIteration < MAX_WHILE_ITERATIONS; currentIteration++) {
205
186
  const currentLimit = limit - foundAccessLogs.length;
206
187
  const { rows: logs, nextKeyPair: newNextKeyPair } = (yield _super.findByUserAfterDate.call(this, userId, 'USER_ACCESS', startDate, nextKeyPair && JSON.stringify(nextKeyPair.startKey), nextKeyPair && nextKeyPair.startKeyDocId, numberRequestedAccessLogs, true));
207
- const logsWithPatientId = yield this.decrypt(this.dataOwnerApi.getDataOwnerOf(user), logs).then((decryptedLogs) => Promise.all(_.map(decryptedLogs, (decryptedLog) => {
208
- return this.crypto.extractCryptedFKs(decryptedLog, user.healthcarePartyId).then((keys) => (Object.assign(Object.assign({}, decryptedLog), { patientId: _.head(keys.extractedKeys) })));
188
+ const logsWithPatientId = yield this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), logs).then((decryptedLogs) => Promise.all(_.map(decryptedLogs, (decryptedLog) => {
189
+ return this.crypto.entities.owningEntityIdsOf(decryptedLog, user.healthcarePartyId).then((keys) => (Object.assign(Object.assign({}, decryptedLog), { patientId: _.head(keys) })));
209
190
  })));
210
191
  const uniqueLogs = _.chain(logsWithPatientId)
211
192
  .reject((log) => _.some(foundAccessLogs, ({ patientId }) => patientId === log.patientId))
@@ -226,6 +207,35 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
226
207
  return foundAccessLogs;
227
208
  });
228
209
  }
210
+ /**
211
+ * @param accessLog an access log
212
+ * @return the id of the patient that the access log refers to, retrieved from the encrypted metadata (not from the decrypted entity body). Normally
213
+ * there should only be one element in the returned array, but in case of entity merges there could be multiple values.
214
+ */
215
+ decryptPatientIdOf(accessLog) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ return this.crypto.entities.owningEntityIdsOf(accessLog, undefined);
218
+ });
219
+ }
220
+ /**
221
+ * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the
222
+ * encrypted content.
223
+ * @param delegateId the id of the data owner which will be granted access to the access log.
224
+ * @param accessLog the access log to share.
225
+ * @param options optional parameters to customize the sharing behaviour:
226
+ * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
227
+ * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}).
228
+ * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would
229
+ * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other
230
+ * encrypted data of the access log (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}).
231
+ * @return a promise which will contain the updated entity.
232
+ */
233
+ shareWith(delegateId, accessLog, options = {}) {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ const self = yield this.dataOwnerApi.getCurrentDataOwnerId();
236
+ return yield this.modifyAs(self, yield this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(accessLog, delegateId, undefined, options.shareEncryptionKey, options.sharePatientId));
237
+ });
238
+ }
229
239
  }
230
240
  exports.IccAccesslogXApi = IccAccesslogXApi;
231
241
  //# sourceMappingURL=icc-accesslog-x-api.js.map