@icure/api 5.2.38 → 5.3.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.
@@ -6,12 +6,18 @@ import { Delegation, Device, Document, EncryptedEntity, EncryptedParentEntity, H
6
6
  import { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api';
7
7
  import { StorageFacade } from './storage/StorageFacade';
8
8
  import { KeyStorageFacade } from './storage/KeyStorageFacade';
9
- interface DelegatorAndKeys {
9
+ /**
10
+ * @internal may be changed without notice
11
+ */
12
+ export interface DelegatorAndKeys {
10
13
  delegatorId: string;
11
14
  key: CryptoKey;
12
15
  rawKey: string;
13
16
  }
14
- declare type CachedDataOwner = {
17
+ /**
18
+ * @internal may be changed without notice
19
+ */
20
+ export declare type CachedDataOwner = {
15
21
  type: 'patient';
16
22
  dataOwner: Patient;
17
23
  } | {
@@ -46,13 +52,20 @@ export declare class IccCryptoXApi {
46
52
  };
47
53
  emptyHcpCache(hcpartyId: string): void;
48
54
  /**
55
+ * @internal may be changed without notice
49
56
  * Gets all delegate encrypted HcParty keys of the delegate with the given `delegateHcPartyId`, and for each key the delegator id
50
57
  * If the keys are not cached, they are retrieved from the backend.
51
58
  *
52
59
  * @param delegateHcPartyId The Health Care Party id
53
60
  * @returns \{delegatorId: delegateEncryptedHcPartyKey\}
54
61
  */
55
- private getEncryptedAesExchangeKeysForDelegate;
62
+ getEncryptedAesExchangeKeysForDelegate(delegateHcPartyId: string): Promise<{
63
+ [key: string]: {
64
+ [key: string]: {
65
+ [key: string]: string;
66
+ };
67
+ };
68
+ }>;
56
69
  private forceGetEncryptedAesExchangeKeysForDelegate;
57
70
  keychainLocalStoreIdPrefix: string;
58
71
  keychainValidityDateLocalStoreIdPrefix: string;
@@ -64,7 +77,15 @@ export declare class IccCryptoXApi {
64
77
  private deviceBaseApi;
65
78
  private readonly _crypto;
66
79
  private generateKeyConcurrencyMap;
67
- private rsaKeyPairs;
80
+ /**
81
+ * @internal may be changed without notice
82
+ */
83
+ rsaKeyPairs: {
84
+ [pubKeyFingerprint: string]: {
85
+ publicKey: CryptoKey;
86
+ privateKey: CryptoKey;
87
+ };
88
+ };
68
89
  private readonly _AES;
69
90
  private readonly _RSA;
70
91
  private readonly _shamir;
@@ -488,5 +509,18 @@ export declare class IccCryptoXApi {
488
509
  };
489
510
  };
490
511
  };
512
+ /**
513
+ * Specifies if the error reporting is enabled
514
+ */
515
+ enableErrorReporting: boolean;
516
+ /**
517
+ * Allows to specify the behaviour for saving the error report
518
+ */
519
+ saveErrorReportCallback: (collectedData: {
520
+ fullData: object;
521
+ minimalData: object;
522
+ }) => Promise<void>;
523
+ reportError(description: string, // Description of what caused the error
524
+ involvedEntities: EncryptedEntity[], // Entities that were being processed when the error occurred
525
+ dataOwnerId: string): Promise<void>;
491
526
  }
492
- export {};
@@ -17,6 +17,7 @@ const _ = require("lodash");
17
17
  const models_1 = require("../icc-api/model/models");
18
18
  const binary_utils_1 = require("./utils/binary-utils");
19
19
  const utils_1 = require("./utils");
20
+ const error_reporting_1 = require("./utils/error-reporting");
20
21
  class IccCryptoXApi {
21
22
  constructor(host, headers, hcpartyBaseApi, //Init with a hcparty x api for better performances
22
23
  patientBaseApi, deviceBaseApi, crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : {}, storage, keyStorage) {
@@ -31,7 +32,23 @@ class IccCryptoXApi {
31
32
  this.hcpPreferenceKeyEhealthCert = 'eHealthCRTCrypt';
32
33
  this.hcpPreferenceKeyEhealthCertDate = 'eHealthCRTDate';
33
34
  this.rsaLocalStoreIdPrefix = 'org.taktik.icure.rsa.';
35
+ /**
36
+ * @internal may be changed without notice
37
+ */
34
38
  this.rsaKeyPairs = {};
39
+ /**
40
+ * Specifies if the error reporting is enabled
41
+ */
42
+ this.enableErrorReporting = true;
43
+ /**
44
+ * Allows to specify the behaviour for saving the error report
45
+ */
46
+ this.saveErrorReportCallback = (collectedData) => __awaiter(this, void 0, void 0, function* () {
47
+ const entryPrefix = `icure.errorreports.${new Date() / 1}.${this.randomUuid()}.`;
48
+ console.warn('Storage entry prefix: ' + entryPrefix);
49
+ this.storage.setItem(entryPrefix + 'full', JSON.stringify(collectedData.fullData));
50
+ this.storage.setItem(entryPrefix + 'minimal', JSON.stringify(collectedData.minimalData));
51
+ });
35
52
  this.hcpartyBaseApi = hcpartyBaseApi;
36
53
  this.patientBaseApi = patientBaseApi;
37
54
  this.deviceBaseApi = deviceBaseApi;
@@ -66,6 +83,7 @@ class IccCryptoXApi {
66
83
  delete this.dataOwnerCache[hcpartyId];
67
84
  }
68
85
  /**
86
+ * @internal may be changed without notice
69
87
  * Gets all delegate encrypted HcParty keys of the delegate with the given `delegateHcPartyId`, and for each key the delegator id
70
88
  * If the keys are not cached, they are retrieved from the backend.
71
89
  *
@@ -1747,6 +1765,24 @@ class IccCryptoXApi {
1747
1765
  ])),
1748
1766
  ]));
1749
1767
  }
1768
+ reportError(description, // Description of what caused the error
1769
+ involvedEntities, // Entities that were being processed when the error occurred
1770
+ dataOwnerId // Id of the data owner who was doing the processing when the error occurred
1771
+ ) {
1772
+ return __awaiter(this, void 0, void 0, function* () {
1773
+ if (this.enableErrorReporting) {
1774
+ try {
1775
+ const collectedData = yield new error_reporting_1.ErrorReporting(this).collectDataForReport(description, involvedEntities, dataOwnerId);
1776
+ console.warn('Reporting error for ' + description);
1777
+ yield this.saveErrorReportCallback(collectedData);
1778
+ }
1779
+ catch (e) {
1780
+ console.error('Failed to report error for ' + description);
1781
+ console.error(e);
1782
+ }
1783
+ }
1784
+ });
1785
+ }
1750
1786
  }
1751
1787
  exports.IccCryptoXApi = IccCryptoXApi;
1752
1788
  //# sourceMappingURL=icc-crypto-x-api.js.map