@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.
- package/icc-api/api/IccDeviceApi.d.ts +1 -1
- package/icc-api/api/IccDeviceApi.js.map +1 -1
- package/icc-api/api/IccDoctemplateApi.js.map +1 -1
- package/icc-api/api/IccDocumentTemplateApi.js.map +1 -1
- package/icc-api/api/IccHcpartyApi.d.ts +1 -1
- package/icc-api/api/IccHcpartyApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.d.ts +1 -1
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/model/MaintenanceTask.d.ts +6 -5
- package/icc-api/model/MaintenanceTask.js +5 -0
- package/icc-api/model/MaintenanceTask.js.map +1 -1
- package/icc-api/model/User.d.ts +23 -1
- package/icc-api/model/User.js +21 -0
- package/icc-api/model/User.js.map +1 -1
- package/icc-api/model/models.d.ts +14 -0
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/crypto/AES.d.ts +2 -0
- package/icc-x-api/crypto/AES.js +12 -0
- package/icc-x-api/crypto/AES.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeKeysManager.d.ts +122 -0
- package/icc-x-api/crypto/BaseExchangeKeysManager.js +356 -0
- package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -0
- package/icc-x-api/crypto/ConfidentialEntities.d.ts +58 -0
- package/icc-x-api/crypto/ConfidentialEntities.js +99 -0
- package/icc-x-api/crypto/ConfidentialEntities.js.map +1 -0
- package/icc-x-api/crypto/CryptoPrimitives.d.ts +31 -0
- package/icc-x-api/crypto/CryptoPrimitives.js +55 -0
- package/icc-x-api/crypto/CryptoPrimitives.js.map +1 -0
- package/icc-x-api/crypto/CryptoStrategies.d.ts +82 -0
- package/icc-x-api/crypto/CryptoStrategies.js +3 -0
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -0
- package/icc-x-api/crypto/EntitiesEncryption.d.ts +254 -0
- package/icc-x-api/crypto/EntitiesEncryption.js +700 -0
- package/icc-x-api/crypto/EntitiesEncryption.js.map +1 -0
- package/icc-x-api/crypto/ExchangeKeysManager.d.ts +56 -0
- package/icc-x-api/crypto/ExchangeKeysManager.js +147 -0
- package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -0
- package/icc-x-api/crypto/KeyManager.d.ts +103 -0
- package/icc-x-api/crypto/KeyManager.js +288 -0
- package/icc-x-api/crypto/KeyManager.js.map +1 -0
- package/icc-x-api/crypto/KeyRecovery.d.ts +34 -0
- package/icc-x-api/crypto/KeyRecovery.js +253 -0
- package/icc-x-api/crypto/KeyRecovery.js.map +1 -0
- package/icc-x-api/crypto/LegacyCryptoStrategies.d.ts +28 -0
- package/icc-x-api/crypto/LegacyCryptoStrategies.js +22 -0
- package/icc-x-api/crypto/LegacyCryptoStrategies.js.map +1 -0
- package/icc-x-api/crypto/RSA.d.ts +19 -20
- package/icc-x-api/crypto/RSA.js +30 -1
- package/icc-x-api/crypto/RSA.js.map +1 -1
- package/icc-x-api/crypto/ShamirKeysManager.d.ts +43 -0
- package/icc-x-api/crypto/ShamirKeysManager.js +150 -0
- package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -0
- package/icc-x-api/crypto/ShareMetadataBehaviour.d.ts +19 -0
- package/icc-x-api/crypto/ShareMetadataBehaviour.js +24 -0
- package/icc-x-api/crypto/ShareMetadataBehaviour.js.map +1 -0
- package/icc-x-api/crypto/TransferKeysManager.d.ts +29 -0
- package/icc-x-api/crypto/TransferKeysManager.js +121 -0
- package/icc-x-api/crypto/TransferKeysManager.js.map +1 -0
- package/icc-x-api/crypto/utils.d.ts +46 -0
- package/icc-x-api/crypto/utils.js +128 -0
- package/icc-x-api/crypto/utils.js.map +1 -1
- package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.d.ts +11 -0
- package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.js +11 -0
- package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.js.map +1 -1
- package/icc-x-api/filters/DeviceByHcPartyFilter.d.ts +11 -0
- package/icc-x-api/filters/DeviceByHcPartyFilter.js +11 -0
- package/icc-x-api/filters/DeviceByHcPartyFilter.js.map +1 -1
- package/icc-x-api/filters/DeviceByIdsFilter.d.ts +11 -0
- package/icc-x-api/filters/DeviceByIdsFilter.js +11 -0
- package/icc-x-api/filters/DeviceByIdsFilter.js.map +1 -1
- package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.d.ts +11 -0
- package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.js +11 -0
- package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +49 -4
- package/icc-x-api/icc-accesslog-x-api.js +112 -102
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +53 -5
- package/icc-x-api/icc-calendar-item-x-api.js +112 -100
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +45 -2
- package/icc-x-api/icc-classification-x-api.js +89 -41
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +57 -19
- package/icc-x-api/icc-contact-x-api.js +149 -154
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +266 -366
- package/icc-x-api/icc-crypto-x-api.js +416 -1327
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-data-owner-x-api.d.ts +110 -11
- package/icc-x-api/icc-data-owner-x-api.js +188 -14
- package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.js +3 -3
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +76 -5
- package/icc-x-api/icc-document-x-api.js +137 -59
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +47 -7
- package/icc-x-api/icc-form-x-api.js +85 -86
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.d.ts +1 -1
- package/icc-x-api/icc-hcparty-x-api.js +1 -1
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +50 -3
- package/icc-x-api/icc-helement-x-api.js +101 -118
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-icure-maintenance-x-api.d.ts +31 -0
- package/icc-x-api/icc-icure-maintenance-x-api.js +124 -0
- package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -0
- package/icc-x-api/icc-invoice-x-api.d.ts +45 -5
- package/icc-x-api/icc-invoice-x-api.js +89 -64
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +38 -6
- package/icc-x-api/icc-maintenance-task-x-api.js +73 -102
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +55 -2
- package/icc-x-api/icc-message-x-api.js +92 -33
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +67 -7
- package/icc-x-api/icc-patient-x-api.js +409 -473
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +49 -5
- package/icc-x-api/icc-receipt-x-api.js +85 -47
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.d.ts +34 -10
- package/icc-x-api/icc-time-table-x-api.js +61 -18
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +30 -1
- package/icc-x-api/index.js +112 -49
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/maintenance/KeyPairUpdateRequest.d.ts +35 -0
- package/icc-x-api/maintenance/KeyPairUpdateRequest.js +54 -0
- package/icc-x-api/maintenance/KeyPairUpdateRequest.js.map +1 -0
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.d.ts +9 -0
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js +23 -0
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js.map +1 -0
- package/icc-x-api/storage/IcureStorageFacade.d.ts +55 -0
- package/icc-x-api/storage/IcureStorageFacade.js +95 -0
- package/icc-x-api/storage/IcureStorageFacade.js.map +1 -0
- package/icc-x-api/storage/StorageEntryKeysFactory.d.ts +31 -0
- package/icc-x-api/storage/StorageEntryKeysFactory.js +3 -0
- package/icc-x-api/storage/StorageEntryKeysFactory.js.map +1 -0
- package/icc-x-api/utils/collection-utils.d.ts +8 -0
- package/icc-x-api/utils/collection-utils.js +26 -0
- package/icc-x-api/utils/collection-utils.js.map +1 -0
- package/icc-x-api/utils/crypto-utils.d.ts +8 -1
- package/icc-x-api/utils/crypto-utils.js +19 -3
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/icc-x-api/utils/graph-utils.d.ts +45 -0
- package/icc-x-api/utils/graph-utils.js +203 -0
- package/icc-x-api/utils/graph-utils.js.map +1 -0
- package/icc-x-api/utils/lru-temporised-async-cache.d.ts +27 -0
- package/icc-x-api/utils/lru-temporised-async-cache.js +120 -0
- package/icc-x-api/utils/lru-temporised-async-cache.js.map +1 -0
- package/package.json +1 -1
package/icc-x-api/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Api = exports.KeyStorageImpl = exports.LocalStorageImpl = void 0;
|
|
26
|
+
exports.BasicApis = exports.Api = exports.KeyStorageImpl = exports.LocalStorageImpl = void 0;
|
|
27
27
|
const icc_api_1 = require("../icc-api");
|
|
28
28
|
const icc_user_x_api_1 = require("./icc-user-x-api");
|
|
29
29
|
const icc_crypto_x_api_1 = require("./icc-crypto-x-api");
|
|
@@ -44,10 +44,22 @@ const IccDeviceApi_1 = require("../icc-api/api/IccDeviceApi");
|
|
|
44
44
|
const icc_code_x_api_1 = require("./icc-code-x-api");
|
|
45
45
|
const icc_maintenance_task_x_api_1 = require("./icc-maintenance-task-x-api");
|
|
46
46
|
const icc_data_owner_x_api_1 = require("./icc-data-owner-x-api");
|
|
47
|
-
const utils_1 = require("./utils");
|
|
48
47
|
const LocalStorageImpl_1 = require("./storage/LocalStorageImpl");
|
|
49
48
|
const KeyStorageImpl_1 = require("./storage/KeyStorageImpl");
|
|
50
49
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
50
|
+
const CryptoPrimitives_1 = require("./crypto/CryptoPrimitives");
|
|
51
|
+
const KeyManager_1 = require("./crypto/KeyManager");
|
|
52
|
+
const IcureStorageFacade_1 = require("./storage/IcureStorageFacade");
|
|
53
|
+
const DefaultStorageEntryKeysFactory_1 = require("./storage/DefaultStorageEntryKeysFactory");
|
|
54
|
+
const KeyRecovery_1 = require("./crypto/KeyRecovery");
|
|
55
|
+
const BaseExchangeKeysManager_1 = require("./crypto/BaseExchangeKeysManager");
|
|
56
|
+
const ExchangeKeysManager_1 = require("./crypto/ExchangeKeysManager");
|
|
57
|
+
const ShamirKeysManager_1 = require("./crypto/ShamirKeysManager");
|
|
58
|
+
const TransferKeysManager_1 = require("./crypto/TransferKeysManager");
|
|
59
|
+
const icc_icure_maintenance_x_api_1 = require("./icc-icure-maintenance-x-api");
|
|
60
|
+
const EntitiesEncryption_1 = require("./crypto/EntitiesEncryption");
|
|
61
|
+
const ConfidentialEntities_1 = require("./crypto/ConfidentialEntities");
|
|
62
|
+
const utils_1 = require("./crypto/utils");
|
|
51
63
|
__exportStar(require("./icc-accesslog-x-api"), exports);
|
|
52
64
|
__exportStar(require("./icc-bekmehr-x-api"), exports);
|
|
53
65
|
__exportStar(require("./icc-calendar-item-x-api"), exports);
|
|
@@ -71,59 +83,78 @@ var LocalStorageImpl_2 = require("./storage/LocalStorageImpl");
|
|
|
71
83
|
Object.defineProperty(exports, "LocalStorageImpl", { enumerable: true, get: function () { return LocalStorageImpl_2.LocalStorageImpl; } });
|
|
72
84
|
var KeyStorageImpl_2 = require("./storage/KeyStorageImpl");
|
|
73
85
|
Object.defineProperty(exports, "KeyStorageImpl", { enumerable: true, get: function () { return KeyStorageImpl_2.KeyStorageImpl; } });
|
|
74
|
-
|
|
86
|
+
class NamedApiParametersWithDefault {
|
|
87
|
+
constructor(custom) {
|
|
88
|
+
var _a, _b, _c, _d, _e;
|
|
89
|
+
this.entryKeysFactory = (_a = custom.entryKeysFactory) !== null && _a !== void 0 ? _a : new DefaultStorageEntryKeysFactory_1.DefaultStorageEntryKeysFactory();
|
|
90
|
+
this.createMaintenanceTasksOnNewKey = (_b = custom.createMaintenanceTasksOnNewKey) !== null && _b !== void 0 ? _b : false;
|
|
91
|
+
this.storage = (_c = custom.storage) !== null && _c !== void 0 ? _c : new LocalStorageImpl_1.LocalStorageImpl();
|
|
92
|
+
this.keyStorage = (_d = custom.keyStorage) !== null && _d !== void 0 ? _d : new KeyStorageImpl_1.KeyStorageImpl(this.storage);
|
|
93
|
+
this.headers = (_e = custom.headers) !== null && _e !== void 0 ? _e : {};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const Api = function (host, authenticationOptions, cryptoStrategies, crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : {}, fetchImpl = typeof window !== 'undefined'
|
|
75
97
|
? window.fetch
|
|
76
98
|
: typeof self !== 'undefined'
|
|
77
99
|
? self.fetch
|
|
78
|
-
: fetch,
|
|
100
|
+
: fetch, options = {}) {
|
|
79
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
: new AuthenticationProvider_1.EnsembleAuthenticationProvider(new icc_api_1.IccAuthApi(host, headers, new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl), username, password);
|
|
87
|
-
// Here I instantiate a separate instance of the AuthApi that can call also login-protected methods (logout)
|
|
88
|
-
const authApi = new icc_api_1.IccAuthApi(host, headers, authenticationProvider, fetchImpl);
|
|
89
|
-
const codeApi = new icc_code_x_api_1.IccCodeXApi(host, headers, authenticationProvider, fetchImpl);
|
|
90
|
-
const entityReferenceApi = new icc_api_1.IccEntityrefApi(host, headers, authenticationProvider, fetchImpl);
|
|
91
|
-
const userApi = new icc_user_x_api_1.IccUserXApi(host, headers, authenticationProvider, fetchImpl);
|
|
92
|
-
const permissionApi = new icc_api_1.IccPermissionApi(host, headers, authenticationProvider, fetchImpl);
|
|
93
|
-
const healthcarePartyApi = new icc_hcparty_x_api_1.IccHcpartyXApi(host, headers, authenticationProvider, fetchImpl);
|
|
94
|
-
const deviceApi = new IccDeviceApi_1.IccDeviceApi(host, headers, authenticationProvider, fetchImpl);
|
|
95
|
-
const cryptoApi = new icc_crypto_x_api_1.IccCryptoXApi(host, headers, healthcarePartyApi, new icc_api_1.IccPatientApi(host, headers, authenticationProvider, fetchImpl), deviceApi, crypto, _storage, _keyStorage);
|
|
96
|
-
const dataOwnerApi = new icc_data_owner_x_api_1.IccDataOwnerXApi(cryptoApi, new icc_api_1.IccPatientApi(host, headers, authenticationProvider, fetchImpl));
|
|
97
|
-
const accessLogApi = new icc_accesslog_x_api_1.IccAccesslogXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
98
|
-
const agendaApi = new icc_api_1.IccAgendaApi(host, headers, authenticationProvider, fetchImpl);
|
|
99
|
-
const contactApi = new icc_contact_x_api_1.IccContactXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
100
|
-
const formApi = new icc_form_x_api_1.IccFormXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
101
|
-
const groupApi = new icc_api_1.IccGroupApi(host, headers, authenticationProvider);
|
|
102
|
-
const medicalLocationApi = new icc_api_1.IccMedicallocationApi(host, headers, authenticationProvider);
|
|
103
|
-
const calendarItemTypeApi = new icc_api_1.IccCalendarItemTypeApi(host, headers, authenticationProvider);
|
|
104
|
-
const invoiceApi = new icc_invoice_x_api_1.IccInvoiceXApi(host, headers, cryptoApi, entityReferenceApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
105
|
-
const insuranceApi = new icc_api_1.IccInsuranceApi(host, headers, authenticationProvider, fetchImpl);
|
|
106
|
-
const documentApi = new icc_document_x_api_1.IccDocumentXApi(host, headers, cryptoApi, authApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
107
|
-
const healthcareElementApi = new icc_helement_x_api_1.IccHelementXApi(host, headers, cryptoApi, dataOwnerApi, ['descr', 'note'], authenticationProvider, fetchImpl);
|
|
108
|
-
const classificationApi = new icc_classification_x_api_1.IccClassificationXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
109
|
-
const calendarItemApi = new icc_calendar_item_x_api_1.IccCalendarItemXApi(host, headers, cryptoApi, dataOwnerApi, ['details', 'title', 'patientId'], authenticationProvider, fetchImpl);
|
|
110
|
-
const receiptApi = new icc_receipt_x_api_1.IccReceiptXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
111
|
-
const timetableApi = new icc_time_table_x_api_1.IccTimeTableXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
112
|
-
const patientApi = new icc_patient_x_api_1.IccPatientXApi(host, headers, cryptoApi, contactApi, formApi, healthcareElementApi, invoiceApi, documentApi, healthcarePartyApi, classificationApi, dataOwnerApi, calendarItemApi, ['note'], authenticationProvider, fetchImpl);
|
|
113
|
-
const messageApi = new icc_message_x_api_1.IccMessageXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
114
|
-
const maintenanceTaskApi = new icc_maintenance_task_x_api_1.IccMaintenanceTaskXApi(host, headers, cryptoApi, healthcarePartyApi, dataOwnerApi, ['properties'], authenticationProvider, fetchImpl);
|
|
115
|
-
if (autoLogin) {
|
|
116
|
-
if (username != undefined && password != undefined) {
|
|
117
|
-
try {
|
|
118
|
-
yield (0, utils_1.retry)(() => authApi.login({ username, password }), 3, 1000, 1.5);
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
console.error('Incorrect user and password used to instantiate Api, or network problem', e);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
102
|
+
const params = new NamedApiParametersWithDefault(options);
|
|
103
|
+
let authenticationProvider;
|
|
104
|
+
if ('username' in authenticationOptions && 'password' in authenticationOptions) {
|
|
105
|
+
authenticationProvider = authenticationOptions.forceBasic
|
|
106
|
+
? new AuthenticationProvider_1.BasicAuthenticationProvider(authenticationOptions.username, authenticationOptions.password)
|
|
107
|
+
: new AuthenticationProvider_1.EnsembleAuthenticationProvider(new icc_api_1.IccAuthApi(host, params.headers, new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl), authenticationOptions.username, authenticationOptions.password);
|
|
124
108
|
}
|
|
125
109
|
else {
|
|
126
|
-
|
|
110
|
+
authenticationProvider = authenticationOptions;
|
|
111
|
+
}
|
|
112
|
+
// Here I instantiate a separate instance of the AuthApi that can call also login-protected methods (logout)
|
|
113
|
+
const authApi = new icc_api_1.IccAuthApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
114
|
+
const codeApi = new icc_code_x_api_1.IccCodeXApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
115
|
+
const entityReferenceApi = new icc_api_1.IccEntityrefApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
116
|
+
const userApi = new icc_user_x_api_1.IccUserXApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
117
|
+
const permissionApi = new icc_api_1.IccPermissionApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
118
|
+
const healthcarePartyApi = new icc_hcparty_x_api_1.IccHcpartyXApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
119
|
+
const deviceApi = new IccDeviceApi_1.IccDeviceApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
120
|
+
const basePatientApi = new icc_api_1.IccPatientApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
121
|
+
const dataOwnerApi = new icc_data_owner_x_api_1.IccDataOwnerXApi(userApi, healthcarePartyApi, basePatientApi, deviceApi);
|
|
122
|
+
// Crypto initialisation
|
|
123
|
+
const icureStorage = new IcureStorageFacade_1.IcureStorageFacade(params.keyStorage, params.storage, params.entryKeysFactory);
|
|
124
|
+
const cryptoPrimitives = new CryptoPrimitives_1.CryptoPrimitives(crypto);
|
|
125
|
+
const baseExchangeKeysManager = new BaseExchangeKeysManager_1.BaseExchangeKeysManager(cryptoPrimitives, dataOwnerApi, healthcarePartyApi, basePatientApi, deviceApi);
|
|
126
|
+
const keyRecovery = new KeyRecovery_1.KeyRecovery(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi);
|
|
127
|
+
const keyManager = new KeyManager_1.KeyManager(cryptoPrimitives, dataOwnerApi, icureStorage, keyRecovery, baseExchangeKeysManager, cryptoStrategies);
|
|
128
|
+
const newKey = yield keyManager.initialiseKeys();
|
|
129
|
+
yield new TransferKeysManager_1.TransferKeysManager(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi, keyManager, icureStorage).updateTransferKeys(yield dataOwnerApi.getCurrentDataOwner());
|
|
130
|
+
// TODO customise cache size?
|
|
131
|
+
const exchangeKeysManager = new ExchangeKeysManager_1.ExchangeKeysManager(100, 500, 60000, 600000, cryptoStrategies, cryptoPrimitives, keyManager, baseExchangeKeysManager, dataOwnerApi, icureStorage);
|
|
132
|
+
const entitiesEncryption = new EntitiesEncryption_1.EntitiesEncryption(cryptoPrimitives, dataOwnerApi, exchangeKeysManager);
|
|
133
|
+
const shamirManager = new ShamirKeysManager_1.ShamirKeysManager(cryptoPrimitives, dataOwnerApi, keyManager, exchangeKeysManager);
|
|
134
|
+
const confidentialEntitites = new ConfidentialEntities_1.ConfidentialEntities(entitiesEncryption, cryptoPrimitives, dataOwnerApi);
|
|
135
|
+
yield (0, utils_1.ensureDelegationForSelf)(dataOwnerApi, entitiesEncryption, cryptoPrimitives);
|
|
136
|
+
const cryptoApi = new icc_crypto_x_api_1.IccCryptoXApi(exchangeKeysManager, cryptoPrimitives, keyManager, dataOwnerApi, entitiesEncryption, shamirManager, params.storage, params.keyStorage, icureStorage, healthcarePartyApi, confidentialEntitites);
|
|
137
|
+
const accessLogApi = new icc_accesslog_x_api_1.IccAccesslogXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
138
|
+
const agendaApi = new icc_api_1.IccAgendaApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
139
|
+
const contactApi = new icc_contact_x_api_1.IccContactXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
140
|
+
const formApi = new icc_form_x_api_1.IccFormXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
141
|
+
const groupApi = new icc_api_1.IccGroupApi(host, params.headers, authenticationProvider);
|
|
142
|
+
const medicalLocationApi = new icc_api_1.IccMedicallocationApi(host, params.headers, authenticationProvider);
|
|
143
|
+
const calendarItemTypeApi = new icc_api_1.IccCalendarItemTypeApi(host, params.headers, authenticationProvider);
|
|
144
|
+
const invoiceApi = new icc_invoice_x_api_1.IccInvoiceXApi(host, params.headers, cryptoApi, entityReferenceApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
145
|
+
const insuranceApi = new icc_api_1.IccInsuranceApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
146
|
+
const documentApi = new icc_document_x_api_1.IccDocumentXApi(host, params.headers, cryptoApi, authApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
147
|
+
const healthcareElementApi = new icc_helement_x_api_1.IccHelementXApi(host, params.headers, cryptoApi, dataOwnerApi, ['descr', 'note'], authenticationProvider, fetchImpl);
|
|
148
|
+
const classificationApi = new icc_classification_x_api_1.IccClassificationXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
149
|
+
const calendarItemApi = new icc_calendar_item_x_api_1.IccCalendarItemXApi(host, params.headers, cryptoApi, dataOwnerApi, ['details', 'title', 'patientId'], authenticationProvider, fetchImpl);
|
|
150
|
+
const receiptApi = new icc_receipt_x_api_1.IccReceiptXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
151
|
+
const timetableApi = new icc_time_table_x_api_1.IccTimeTableXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
152
|
+
const patientApi = new icc_patient_x_api_1.IccPatientXApi(host, params.headers, cryptoApi, contactApi, formApi, healthcareElementApi, invoiceApi, documentApi, healthcarePartyApi, classificationApi, dataOwnerApi, calendarItemApi, ['note'], authenticationProvider, fetchImpl);
|
|
153
|
+
const messageApi = new icc_message_x_api_1.IccMessageXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
154
|
+
const maintenanceTaskApi = new icc_maintenance_task_x_api_1.IccMaintenanceTaskXApi(host, params.headers, cryptoApi, healthcarePartyApi, dataOwnerApi, ['properties'], authenticationProvider, fetchImpl);
|
|
155
|
+
const icureMaintenanceTaskApi = new icc_icure_maintenance_x_api_1.IccIcureMaintenanceXApi(cryptoApi, maintenanceTaskApi, dataOwnerApi);
|
|
156
|
+
if (newKey && params.createMaintenanceTasksOnNewKey) {
|
|
157
|
+
yield icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(yield userApi.getCurrentUser(), newKey.newKeyPair);
|
|
127
158
|
}
|
|
128
159
|
return {
|
|
129
160
|
cryptoApi,
|
|
@@ -153,8 +184,40 @@ const Api = function (host, username, password, crypto = typeof window !== 'unde
|
|
|
153
184
|
groupApi,
|
|
154
185
|
maintenanceTaskApi,
|
|
155
186
|
dataOwnerApi,
|
|
187
|
+
icureMaintenanceTaskApi,
|
|
156
188
|
};
|
|
157
189
|
});
|
|
158
190
|
};
|
|
159
191
|
exports.Api = Api;
|
|
192
|
+
const BasicApis = function (host, username, password, crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : {}, fetchImpl = typeof window !== 'undefined'
|
|
193
|
+
? window.fetch
|
|
194
|
+
: typeof self !== 'undefined'
|
|
195
|
+
? self.fetch
|
|
196
|
+
: fetch, forceBasic = false) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
const headers = {};
|
|
199
|
+
const authenticationProvider = forceBasic
|
|
200
|
+
? new AuthenticationProvider_1.BasicAuthenticationProvider(username, password)
|
|
201
|
+
: new AuthenticationProvider_1.EnsembleAuthenticationProvider(new icc_api_1.IccAuthApi(host, headers, new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl), username, password);
|
|
202
|
+
const authApi = new icc_api_1.IccAuthApi(host, headers, authenticationProvider, fetchImpl);
|
|
203
|
+
const codeApi = new icc_code_x_api_1.IccCodeXApi(host, headers, authenticationProvider, fetchImpl);
|
|
204
|
+
const entityReferenceApi = new icc_api_1.IccEntityrefApi(host, headers, authenticationProvider, fetchImpl);
|
|
205
|
+
const userApi = new icc_user_x_api_1.IccUserXApi(host, headers, authenticationProvider, fetchImpl);
|
|
206
|
+
const permissionApi = new icc_api_1.IccPermissionApi(host, headers, authenticationProvider, fetchImpl);
|
|
207
|
+
const agendaApi = new icc_api_1.IccAgendaApi(host, headers, authenticationProvider, fetchImpl);
|
|
208
|
+
const groupApi = new icc_api_1.IccGroupApi(host, headers, authenticationProvider);
|
|
209
|
+
const insuranceApi = new icc_api_1.IccInsuranceApi(host, headers, authenticationProvider, fetchImpl);
|
|
210
|
+
return {
|
|
211
|
+
authApi,
|
|
212
|
+
codeApi,
|
|
213
|
+
userApi,
|
|
214
|
+
permissionApi,
|
|
215
|
+
insuranceApi,
|
|
216
|
+
entityReferenceApi,
|
|
217
|
+
agendaApi,
|
|
218
|
+
groupApi,
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
exports.BasicApis = BasicApis;
|
|
160
223
|
//# sourceMappingURL=index.js.map
|
package/icc-x-api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAUmB;AACnB,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD;AACpD,6DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,6DAAsD;AACtD,yEAAkE;AAClE,uEAA+D;AAC/D,2DAAoD;AACpD,2DAAoD;AACpD,2DAAoD;AACpD,+DAAwD;AACxD,iEAAyD;AACzD,8DAA0D;AAC1D,qDAA8C;AAC9C,6EAAqE;AACrE,iEAAyD;AACzD,mCAA+B;AAG/B,iEAA6D;AAC7D,6DAAyD;AACzD,0EAAqI;AAErI,wDAAqC;AACrC,sDAAmC;AACnC,4DAAyC;AACzC,6DAA0C;AAC1C,mDAAgC;AAChC,sDAAmC;AACnC,qDAAkC;AAClC,0DAAuC;AACvC,uDAAoC;AACpC,mDAAgC;AAChC,sDAAmC;AACnC,uDAAoC;AACpC,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,mDAAgC;AAChC,yDAAsC;AACtC,sDAAmC;AACnC,0CAAuB;AAEvB,+DAA6D;AAApD,oHAAA,gBAAgB,OAAA;AAEzB,2DAAyD;AAAhD,gHAAA,cAAc,OAAA;AAgChB,MAAM,GAAG,GAAG,UACjB,IAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,SAAiB,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,C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;IACH,CAAC;CAAA,CAAA;AAxIY,QAAA,GAAG,OAwIf","sourcesContent":["import {\n IccAgendaApi,\n IccAuthApi,\n IccCalendarItemTypeApi,\n IccEntityrefApi,\n IccGroupApi,\n IccInsuranceApi,\n IccMedicallocationApi,\n IccPatientApi,\n IccPermissionApi,\n} from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccDeviceApi } from '../icc-api/api/IccDeviceApi'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { retry } from './utils'\nimport { StorageFacade } from './storage/StorageFacade'\nimport { KeyStorageFacade } from './storage/KeyStorageFacade'\nimport { LocalStorageImpl } from './storage/LocalStorageImpl'\nimport { KeyStorageImpl } from './storage/KeyStorageImpl'\nimport { BasicAuthenticationProvider, EnsembleAuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './utils'\nexport { KeyStorageFacade } from './storage/KeyStorageFacade'\nexport { LocalStorageImpl } from './storage/LocalStorageImpl'\nexport { StorageFacade } from './storage/StorageFacade'\nexport { KeyStorageImpl } from './storage/KeyStorageImpl'\n\nexport interface Apis {\n authApi: IccAuthApi\n codeApi: IccCodeXApi\n calendarItemTypeApi: IccCalendarItemTypeApi\n medicalLocationApi: IccMedicallocationApi\n entityReferenceApi: IccEntityrefApi\n userApi: IccUserXApi\n permissionApi: IccPermissionApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceApi\n cryptoApi: IccCryptoXApi\n accessLogApi: IccAccesslogXApi\n agendaApi: IccAgendaApi\n contactApi: IccContactXApi\n formApi: IccFormXApi\n groupApi: IccGroupApi\n invoiceApi: IccInvoiceXApi\n insuranceApi: IccInsuranceApi\n documentApi: IccDocumentXApi\n healthcareElementApi: IccHelementXApi\n classificationApi: IccClassificationXApi\n calendarItemApi: IccCalendarItemXApi\n receiptApi: IccReceiptXApi\n timetableApi: IccTimeTableXApi\n patientApi: IccPatientXApi\n messageApi: IccMessageXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n dataOwnerApi: IccDataOwnerXApi\n}\n\nexport const Api = async function (\n host: string,\n username: string,\n password: string,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n forceBasic = false,\n autoLogin = false,\n storage?: StorageFacade<string>,\n keyStorage?: KeyStorageFacade\n): Promise<Apis> {\n const _storage = storage || new LocalStorageImpl()\n const _keyStorage = keyStorage || new KeyStorageImpl(_storage)\n\n // The AuthenticationProvider needs a AuthApi without authentication because it will only call methods without authentication\n const headers = {}\n const authenticationProvider = forceBasic\n ? new BasicAuthenticationProvider(username, password)\n : new EnsembleAuthenticationProvider(new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl), username, password)\n\n // Here I instantiate a separate instance of the AuthApi that can call also login-protected methods (logout)\n const authApi = new IccAuthApi(host, headers, authenticationProvider, fetchImpl)\n const codeApi = new IccCodeXApi(host, headers, authenticationProvider, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, headers, authenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, headers, authenticationProvider, fetchImpl)\n const permissionApi = new IccPermissionApi(host, headers, authenticationProvider, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, headers, authenticationProvider, fetchImpl)\n const deviceApi = new IccDeviceApi(host, headers, authenticationProvider, fetchImpl)\n const cryptoApi = new IccCryptoXApi(\n host,\n headers,\n healthcarePartyApi,\n new IccPatientApi(host, headers, authenticationProvider, fetchImpl),\n deviceApi,\n crypto,\n _storage,\n _keyStorage\n )\n const dataOwnerApi = new IccDataOwnerXApi(cryptoApi, new IccPatientApi(host, headers, authenticationProvider, fetchImpl))\n const accessLogApi = new IccAccesslogXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const agendaApi = new IccAgendaApi(host, headers, authenticationProvider, fetchImpl)\n const contactApi = new IccContactXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const formApi = new IccFormXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const groupApi = new IccGroupApi(host, headers, authenticationProvider)\n const medicalLocationApi = new IccMedicallocationApi(host, headers, authenticationProvider)\n const calendarItemTypeApi = new IccCalendarItemTypeApi(host, headers, authenticationProvider)\n const invoiceApi = new IccInvoiceXApi(host, headers, cryptoApi, entityReferenceApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const insuranceApi = new IccInsuranceApi(host, headers, authenticationProvider, fetchImpl)\n const documentApi = new IccDocumentXApi(host, headers, cryptoApi, authApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const healthcareElementApi = new IccHelementXApi(host, headers, cryptoApi, dataOwnerApi, ['descr', 'note'], authenticationProvider, fetchImpl)\n const classificationApi = new IccClassificationXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const calendarItemApi = new IccCalendarItemXApi(\n host,\n headers,\n cryptoApi,\n dataOwnerApi,\n ['details', 'title', 'patientId'],\n authenticationProvider,\n fetchImpl\n )\n const receiptApi = new IccReceiptXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const timetableApi = new IccTimeTableXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const patientApi = new IccPatientXApi(\n host,\n headers,\n cryptoApi,\n contactApi,\n formApi,\n healthcareElementApi,\n invoiceApi,\n documentApi,\n healthcarePartyApi,\n classificationApi,\n dataOwnerApi,\n calendarItemApi,\n ['note'],\n authenticationProvider,\n fetchImpl\n )\n const messageApi = new IccMessageXApi(host, headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(\n host,\n headers,\n cryptoApi,\n healthcarePartyApi,\n dataOwnerApi,\n ['properties'],\n authenticationProvider,\n fetchImpl\n )\n\n if (autoLogin) {\n if (username != undefined && password != undefined) {\n try {\n await retry(() => authApi.login({ username, password }), 3, 1000, 1.5)\n } catch (e) {\n console.error('Incorrect user and password used to instantiate Api, or network problem', e)\n }\n }\n } else {\n console.info('Auto login skipped')\n }\n\n return {\n cryptoApi,\n authApi,\n codeApi,\n calendarItemTypeApi,\n medicalLocationApi,\n userApi,\n permissionApi,\n patientApi,\n healthcarePartyApi,\n deviceApi,\n accessLogApi,\n contactApi,\n healthcareElementApi,\n documentApi,\n formApi,\n invoiceApi,\n insuranceApi,\n messageApi,\n entityReferenceApi,\n receiptApi,\n agendaApi,\n calendarItemApi,\n classificationApi,\n timetableApi,\n groupApi,\n maintenanceTaskApi,\n dataOwnerApi,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAUmB;AACnB,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD;AACpD,6DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,6DAAsD;AACtD,yEAAkE;AAClE,uEAA+D;AAC/D,2DAAoD;AACpD,2DAAoD;AACpD,2DAAoD;AACpD,+DAAwD;AACxD,iEAAyD;AACzD,8DAA0D;AAC1D,qDAA8C;AAC9C,6EAAqE;AACrE,iEAAyD;AAGzD,iEAA6D;AAC7D,6DAAyD;AACzD,0EAKsC;AACtC,gEAA4D;AAC5D,oDAAgD;AAChD,qEAAiE;AACjE,6FAAyF;AACzF,sDAAkD;AAClD,8EAA0E;AAG1E,sEAAkE;AAClE,kEAA8D;AAC9D,sEAAkE;AAClE,+EAAuE;AACvE,oEAAgE;AAChE,wEAAoE;AACpE,0CAAwD;AAExD,wDAAqC;AACrC,sDAAmC;AACnC,4DAAyC;AACzC,6DAA0C;AAC1C,mDAAgC;AAChC,sDAAmC;AACnC,qDAAkC;AAClC,0DAAuC;AACvC,uDAAoC;AACpC,mDAAgC;AAChC,sDAAmC;AACnC,uDAAoC;AACpC,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,mDAAgC;AAChC,yDAAsC;AACtC,sDAAmC;AACnC,0CAAuB;AAEvB,+DAA6D;AAApD,oHAAA,gBAAgB,OAAA;AAEzB,2DAAyD;AAAhD,gHAAA,cAAc,OAAA;AAyCvB,MAAM,6BAA6B;IACjC,YAAY,MAAkB;;QAC5B,IAAI,CAAC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AAsB,CAAC,CAAA;QACvE,MAAM,YAAY,GAAG,IAAI,yBAAe,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAE1F,OAAO;YACL,OAAO;YACP,OAAO;YACP,OAAO;YACP,aAAa;YACb,YAAY;YACZ,kBAAkB;YAClB,SAAS;YACT,QAAQ;SACT,CAAA;IACH,CAAC;CAAA,CAAA;AApCY,QAAA,SAAS,aAoCrB","sourcesContent":["import {\n IccAgendaApi,\n IccAuthApi,\n IccCalendarItemTypeApi,\n IccEntityrefApi,\n IccGroupApi,\n IccInsuranceApi,\n IccMedicallocationApi,\n IccPatientApi,\n IccPermissionApi,\n} from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccDeviceApi } from '../icc-api/api/IccDeviceApi'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { StorageFacade } from './storage/StorageFacade'\nimport { KeyStorageFacade } from './storage/KeyStorageFacade'\nimport { LocalStorageImpl } from './storage/LocalStorageImpl'\nimport { KeyStorageImpl } from './storage/KeyStorageImpl'\nimport {\n AuthenticationProvider,\n BasicAuthenticationProvider,\n EnsembleAuthenticationProvider,\n NoAuthenticationProvider,\n} from './auth/AuthenticationProvider'\nimport { CryptoPrimitives } from './crypto/CryptoPrimitives'\nimport { KeyManager } from './crypto/KeyManager'\nimport { IcureStorageFacade } from './storage/IcureStorageFacade'\nimport { DefaultStorageEntryKeysFactory } from './storage/DefaultStorageEntryKeysFactory'\nimport { KeyRecovery } from './crypto/KeyRecovery'\nimport { BaseExchangeKeysManager } from './crypto/BaseExchangeKeysManager'\nimport { StorageEntryKeysFactory } from './storage/StorageEntryKeysFactory'\nimport { CryptoStrategies } from './crypto/CryptoStrategies'\nimport { ExchangeKeysManager } from './crypto/ExchangeKeysManager'\nimport { ShamirKeysManager } from './crypto/ShamirKeysManager'\nimport { TransferKeysManager } from './crypto/TransferKeysManager'\nimport { IccIcureMaintenanceXApi } from './icc-icure-maintenance-x-api'\nimport { EntitiesEncryption } from './crypto/EntitiesEncryption'\nimport { ConfidentialEntities } from './crypto/ConfidentialEntities'\nimport { ensureDelegationForSelf } from './crypto/utils'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './utils'\nexport { KeyStorageFacade } from './storage/KeyStorageFacade'\nexport { LocalStorageImpl } from './storage/LocalStorageImpl'\nexport { StorageFacade } from './storage/StorageFacade'\nexport { KeyStorageImpl } from './storage/KeyStorageImpl'\n\nexport interface Apis {\n authApi: IccAuthApi\n codeApi: IccCodeXApi\n calendarItemTypeApi: IccCalendarItemTypeApi\n medicalLocationApi: IccMedicallocationApi\n entityReferenceApi: IccEntityrefApi\n userApi: IccUserXApi\n permissionApi: IccPermissionApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceApi\n cryptoApi: IccCryptoXApi\n accessLogApi: IccAccesslogXApi\n agendaApi: IccAgendaApi\n contactApi: IccContactXApi\n formApi: IccFormXApi\n groupApi: IccGroupApi\n invoiceApi: IccInvoiceXApi\n insuranceApi: IccInsuranceApi\n documentApi: IccDocumentXApi\n healthcareElementApi: IccHelementXApi\n classificationApi: IccClassificationXApi\n calendarItemApi: IccCalendarItemXApi\n receiptApi: IccReceiptXApi\n timetableApi: IccTimeTableXApi\n patientApi: IccPatientXApi\n messageApi: IccMessageXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n dataOwnerApi: IccDataOwnerXApi\n icureMaintenanceTaskApi: IccIcureMaintenanceXApi\n}\n\nexport type ApiOptions = {\n readonly entryKeysFactory?: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey?: boolean\n readonly storage?: StorageFacade<string>\n readonly keyStorage?: KeyStorageFacade\n readonly headers?: { [headerName: string]: string }\n}\n\nclass NamedApiParametersWithDefault implements ApiOptions {\n constructor(custom: ApiOptions) {\n this.entryKeysFactory = custom.entryKeysFactory ?? new DefaultStorageEntryKeysFactory()\n this.createMaintenanceTasksOnNewKey = custom.createMaintenanceTasksOnNewKey ?? false\n this.storage = custom.storage ?? new LocalStorageImpl()\n this.keyStorage = custom.keyStorage ?? new KeyStorageImpl(this.storage)\n this.headers = custom.headers ?? {}\n }\n\n readonly entryKeysFactory: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey: boolean\n readonly storage: StorageFacade<string>\n readonly keyStorage: KeyStorageFacade\n readonly headers: { [headerName: string]: string }\n}\n\nexport type AuthenticationDetails = {\n username: string\n password: string\n forceBasic?: boolean // default false\n}\n\nexport const Api = async function (\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n cryptoStrategies: CryptoStrategies,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n options: ApiOptions = {}\n): Promise<Apis> {\n const params = new NamedApiParametersWithDefault(options)\n let authenticationProvider: AuthenticationProvider\n if ('username' in authenticationOptions && 'password' in authenticationOptions) {\n authenticationProvider = authenticationOptions.forceBasic\n ? new BasicAuthenticationProvider(authenticationOptions.username, authenticationOptions.password)\n : new EnsembleAuthenticationProvider(\n new IccAuthApi(host, params.headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions.username,\n authenticationOptions.password\n )\n } else {\n authenticationProvider = authenticationOptions\n }\n\n // Here I instantiate a separate instance of the AuthApi that can call also login-protected methods (logout)\n const authApi = new IccAuthApi(host, params.headers, authenticationProvider, fetchImpl)\n const codeApi = new IccCodeXApi(host, params.headers, authenticationProvider, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, params.headers, authenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, params.headers, authenticationProvider, fetchImpl)\n const permissionApi = new IccPermissionApi(host, params.headers, authenticationProvider, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, params.headers, authenticationProvider, fetchImpl)\n const deviceApi = new IccDeviceApi(host, params.headers, authenticationProvider, fetchImpl)\n const basePatientApi = new IccPatientApi(host, params.headers, authenticationProvider, fetchImpl)\n const dataOwnerApi = new IccDataOwnerXApi(userApi, healthcarePartyApi, basePatientApi, deviceApi)\n // Crypto initialisation\n const icureStorage = new IcureStorageFacade(params.keyStorage, params.storage, params.entryKeysFactory)\n const cryptoPrimitives = new CryptoPrimitives(crypto)\n const baseExchangeKeysManager = new BaseExchangeKeysManager(cryptoPrimitives, dataOwnerApi, healthcarePartyApi, basePatientApi, deviceApi)\n const keyRecovery = new KeyRecovery(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi)\n const keyManager = new KeyManager(cryptoPrimitives, dataOwnerApi, icureStorage, keyRecovery, baseExchangeKeysManager, cryptoStrategies)\n const newKey = await keyManager.initialiseKeys()\n await new TransferKeysManager(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi, keyManager, icureStorage).updateTransferKeys(\n await dataOwnerApi.getCurrentDataOwner()\n )\n // TODO customise cache size?\n const exchangeKeysManager = new ExchangeKeysManager(\n 100,\n 500,\n 60000,\n 600000,\n cryptoStrategies,\n cryptoPrimitives,\n keyManager,\n baseExchangeKeysManager,\n dataOwnerApi,\n icureStorage\n )\n const entitiesEncryption = new EntitiesEncryption(cryptoPrimitives, dataOwnerApi, exchangeKeysManager)\n const shamirManager = new ShamirKeysManager(cryptoPrimitives, dataOwnerApi, keyManager, exchangeKeysManager)\n const confidentialEntitites = new ConfidentialEntities(entitiesEncryption, cryptoPrimitives, dataOwnerApi)\n await ensureDelegationForSelf(dataOwnerApi, entitiesEncryption, cryptoPrimitives)\n const cryptoApi = new IccCryptoXApi(\n exchangeKeysManager,\n cryptoPrimitives,\n keyManager,\n dataOwnerApi,\n entitiesEncryption,\n shamirManager,\n params.storage,\n params.keyStorage,\n icureStorage,\n healthcarePartyApi,\n confidentialEntitites\n )\n const accessLogApi = new IccAccesslogXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const agendaApi = new IccAgendaApi(host, params.headers, authenticationProvider, fetchImpl)\n const contactApi = new IccContactXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const formApi = new IccFormXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const groupApi = new IccGroupApi(host, params.headers, authenticationProvider)\n const medicalLocationApi = new IccMedicallocationApi(host, params.headers, authenticationProvider)\n const calendarItemTypeApi = new IccCalendarItemTypeApi(host, params.headers, authenticationProvider)\n const invoiceApi = new IccInvoiceXApi(host, params.headers, cryptoApi, entityReferenceApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const insuranceApi = new IccInsuranceApi(host, params.headers, authenticationProvider, fetchImpl)\n const documentApi = new IccDocumentXApi(host, params.headers, cryptoApi, authApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const healthcareElementApi = new IccHelementXApi(\n host,\n params.headers,\n cryptoApi,\n dataOwnerApi,\n ['descr', 'note'],\n authenticationProvider,\n fetchImpl\n )\n const classificationApi = new IccClassificationXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const calendarItemApi = new IccCalendarItemXApi(\n host,\n params.headers,\n cryptoApi,\n dataOwnerApi,\n ['details', 'title', 'patientId'],\n authenticationProvider,\n fetchImpl\n )\n const receiptApi = new IccReceiptXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const timetableApi = new IccTimeTableXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const patientApi = new IccPatientXApi(\n host,\n params.headers,\n cryptoApi,\n contactApi,\n formApi,\n healthcareElementApi,\n invoiceApi,\n documentApi,\n healthcarePartyApi,\n classificationApi,\n dataOwnerApi,\n calendarItemApi,\n ['note'],\n authenticationProvider,\n fetchImpl\n )\n const messageApi = new IccMessageXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(\n host,\n params.headers,\n cryptoApi,\n healthcarePartyApi,\n dataOwnerApi,\n ['properties'],\n authenticationProvider,\n fetchImpl\n )\n const icureMaintenanceTaskApi = new IccIcureMaintenanceXApi(cryptoApi, maintenanceTaskApi, dataOwnerApi)\n\n if (newKey && params.createMaintenanceTasksOnNewKey) {\n await icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(await userApi.getCurrentUser(), newKey.newKeyPair)\n }\n return {\n cryptoApi,\n authApi,\n codeApi,\n calendarItemTypeApi,\n medicalLocationApi,\n userApi,\n permissionApi,\n patientApi,\n healthcarePartyApi,\n deviceApi,\n accessLogApi,\n contactApi,\n healthcareElementApi,\n documentApi,\n formApi,\n invoiceApi,\n insuranceApi,\n messageApi,\n entityReferenceApi,\n receiptApi,\n agendaApi,\n calendarItemApi,\n classificationApi,\n timetableApi,\n groupApi,\n maintenanceTaskApi,\n dataOwnerApi,\n icureMaintenanceTaskApi,\n }\n}\n\nexport const BasicApis = async function (\n host: string,\n username: string,\n password: string,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n forceBasic: boolean = false\n) {\n const headers = {}\n const authenticationProvider = forceBasic\n ? new BasicAuthenticationProvider(username, password)\n : new EnsembleAuthenticationProvider(new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl), username, password)\n const authApi = new IccAuthApi(host, headers, authenticationProvider, fetchImpl)\n\n const codeApi = new IccCodeXApi(host, headers, authenticationProvider, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, headers, authenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, headers, authenticationProvider, fetchImpl)\n const permissionApi = new IccPermissionApi(host, headers, authenticationProvider, fetchImpl)\n const agendaApi = new IccAgendaApi(host, headers, authenticationProvider, fetchImpl)\n const groupApi = new IccGroupApi(host, headers, authenticationProvider)\n const insuranceApi = new IccInsuranceApi(host, headers, authenticationProvider, fetchImpl)\n\n return {\n authApi,\n codeApi,\n userApi,\n permissionApi,\n insuranceApi,\n entityReferenceApi,\n agendaApi,\n groupApi,\n }\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a request to update aes exchange keys following the creation of a new key pair for a data owner.
|
|
3
|
+
*/
|
|
4
|
+
import { MaintenanceTask } from '../../icc-api/model/MaintenanceTask';
|
|
5
|
+
export declare class KeyPairUpdateRequest {
|
|
6
|
+
/**
|
|
7
|
+
* @internal this field is intended for internal use only and may be changed in future without notice
|
|
8
|
+
*/
|
|
9
|
+
readonly originalTask: MaintenanceTask;
|
|
10
|
+
private readonly _concernedDataOwnerId;
|
|
11
|
+
private readonly _newPublicKey;
|
|
12
|
+
/**
|
|
13
|
+
* Id of the data owner which created a new key pair and wants to regain access to his exchange keys.
|
|
14
|
+
*/
|
|
15
|
+
get concernedDataOwnerId(): string;
|
|
16
|
+
/**
|
|
17
|
+
* New public key of the data owner, in hex-encoded spki format.
|
|
18
|
+
*/
|
|
19
|
+
get newPublicKey(): string;
|
|
20
|
+
constructor(task: MaintenanceTask);
|
|
21
|
+
}
|
|
22
|
+
export declare namespace KeyPairUpdateRequest {
|
|
23
|
+
/**
|
|
24
|
+
* @internal this field is intended for internal use only and may be changed in future without notice
|
|
25
|
+
*/
|
|
26
|
+
const OWNER_ID_PROP_ID = "dataOwnerConcernedId";
|
|
27
|
+
/**
|
|
28
|
+
* @internal this field is intended for internal use only and may be changed in future without notice
|
|
29
|
+
*/
|
|
30
|
+
const OWNER_PUB_PROP_ID = "dataOwnerConcernedPubKey";
|
|
31
|
+
/**
|
|
32
|
+
* @internal this field is intended for internal use only and may be changed in future without notice
|
|
33
|
+
*/
|
|
34
|
+
const TASK_TYPE: MaintenanceTask.TaskTypeEnum;
|
|
35
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyPairUpdateRequest = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a request to update aes exchange keys following the creation of a new key pair for a data owner.
|
|
6
|
+
*/
|
|
7
|
+
const MaintenanceTask_1 = require("../../icc-api/model/MaintenanceTask");
|
|
8
|
+
class KeyPairUpdateRequest {
|
|
9
|
+
/**
|
|
10
|
+
* Id of the data owner which created a new key pair and wants to regain access to his exchange keys.
|
|
11
|
+
*/
|
|
12
|
+
get concernedDataOwnerId() {
|
|
13
|
+
return this._concernedDataOwnerId;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* New public key of the data owner, in hex-encoded spki format.
|
|
17
|
+
*/
|
|
18
|
+
get newPublicKey() {
|
|
19
|
+
return this._newPublicKey;
|
|
20
|
+
}
|
|
21
|
+
constructor(task) {
|
|
22
|
+
if (task.taskType !== KeyPairUpdateRequest.TASK_TYPE)
|
|
23
|
+
throw new Error(`Key pair update tasks should have task type ${KeyPairUpdateRequest.TASK_TYPE}, but got task with type ${task.taskType}`);
|
|
24
|
+
this.originalTask = task;
|
|
25
|
+
function findStringProp(propId) {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
const prop = (_a = task.properties) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === propId);
|
|
28
|
+
if (!prop)
|
|
29
|
+
throw new Error(`Task is missing required string property ${propId} for KeyPairUpdateRequest. ${JSON.stringify(task)}`);
|
|
30
|
+
const propValue = (_b = prop.typedValue) === null || _b === void 0 ? void 0 : _b.stringValue;
|
|
31
|
+
if (!propValue)
|
|
32
|
+
throw new Error(`Invalid value ${(_c = prop.typedValue) === null || _c === void 0 ? void 0 : _c.stringValue} for property ${propId} for KeyPairUpdateRequest. ${JSON.stringify(task)}`);
|
|
33
|
+
return propValue;
|
|
34
|
+
}
|
|
35
|
+
this._concernedDataOwnerId = findStringProp(KeyPairUpdateRequest.OWNER_ID_PROP_ID);
|
|
36
|
+
this._newPublicKey = findStringProp(KeyPairUpdateRequest.OWNER_PUB_PROP_ID);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.KeyPairUpdateRequest = KeyPairUpdateRequest;
|
|
40
|
+
(function (KeyPairUpdateRequest) {
|
|
41
|
+
/**
|
|
42
|
+
* @internal this field is intended for internal use only and may be changed in future without notice
|
|
43
|
+
*/
|
|
44
|
+
KeyPairUpdateRequest.OWNER_ID_PROP_ID = 'dataOwnerConcernedId';
|
|
45
|
+
/**
|
|
46
|
+
* @internal this field is intended for internal use only and may be changed in future without notice
|
|
47
|
+
*/
|
|
48
|
+
KeyPairUpdateRequest.OWNER_PUB_PROP_ID = 'dataOwnerConcernedPubKey';
|
|
49
|
+
/**
|
|
50
|
+
* @internal this field is intended for internal use only and may be changed in future without notice
|
|
51
|
+
*/
|
|
52
|
+
KeyPairUpdateRequest.TASK_TYPE = MaintenanceTask_1.MaintenanceTask.TaskTypeEnum.KeyPairUpdate;
|
|
53
|
+
})(KeyPairUpdateRequest = exports.KeyPairUpdateRequest || (exports.KeyPairUpdateRequest = {}));
|
|
54
|
+
//# sourceMappingURL=KeyPairUpdateRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyPairUpdateRequest.js","sourceRoot":"","sources":["../../../icc-x-api/maintenance/KeyPairUpdateRequest.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yEAAqE;AAGrE,MAAa,oBAAoB;IAQ/B;;OAEG;IACH,IAAI,oBAAoB;QACtB,OAAO,IAAI,CAAC,qBAAqB,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,YAAY,IAAqB;QAC/B,IAAI,IAAI,CAAC,QAAQ,KAAK,oBAAoB,CAAC,SAAS;YAClD,MAAM,IAAI,KAAK,CAAC,+CAA+C,oBAAoB,CAAC,SAAS,4BAA4B,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC3I,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QAExB,SAAS,cAAc,CAAC,MAAc;;YACpC,MAAM,IAAI,GAA6B,MAAA,IAAI,CAAC,UAAU,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAA;YACpF,IAAI,CAAC,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,MAAM,8BAA8B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAClI,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,CAAA;YAC9C,IAAI,CAAC,SAAS;gBACZ,MAAM,IAAI,KAAK,CAAC,iBAAiB,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,iBAAiB,MAAM,8BAA8B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAC3I,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,IAAI,CAAC,qBAAqB,GAAG,cAAc,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;QAClF,IAAI,CAAC,aAAa,GAAG,cAAc,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAA;IAC7E,CAAC;CACF;AAvCD,oDAuCC;AACD,WAAiB,oBAAoB;IACnC;;OAEG;IACU,qCAAgB,GAAG,sBAAsB,CAAA;IACtD;;OAEG;IACU,sCAAiB,GAAG,0BAA0B,CAAA;IAC3D;;OAEG;IACU,8BAAS,GAAG,iCAAe,CAAC,YAAY,CAAC,aAAa,CAAA;AACrE,CAAC,EAbgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAapC","sourcesContent":["/**\n * Represents a request to update aes exchange keys following the creation of a new key pair for a data owner.\n */\nimport { MaintenanceTask } from '../../icc-api/model/MaintenanceTask'\nimport { PropertyStub } from '../../icc-api/model/PropertyStub'\n\nexport class KeyPairUpdateRequest {\n /**\n * @internal this field is intended for internal use only and may be changed in future without notice\n */\n readonly originalTask: MaintenanceTask\n private readonly _concernedDataOwnerId: string\n private readonly _newPublicKey: string\n\n /**\n * Id of the data owner which created a new key pair and wants to regain access to his exchange keys.\n */\n get concernedDataOwnerId(): string {\n return this._concernedDataOwnerId\n }\n\n /**\n * New public key of the data owner, in hex-encoded spki format.\n */\n get newPublicKey(): string {\n return this._newPublicKey\n }\n\n constructor(task: MaintenanceTask) {\n if (task.taskType !== KeyPairUpdateRequest.TASK_TYPE)\n throw new Error(`Key pair update tasks should have task type ${KeyPairUpdateRequest.TASK_TYPE}, but got task with type ${task.taskType}`)\n this.originalTask = task\n\n function findStringProp(propId: string): string {\n const prop: PropertyStub | undefined = task.properties?.find((x) => x.id === propId)\n if (!prop) throw new Error(`Task is missing required string property ${propId} for KeyPairUpdateRequest. ${JSON.stringify(task)}`)\n const propValue = prop.typedValue?.stringValue\n if (!propValue)\n throw new Error(`Invalid value ${prop.typedValue?.stringValue} for property ${propId} for KeyPairUpdateRequest. ${JSON.stringify(task)}`)\n return propValue\n }\n\n this._concernedDataOwnerId = findStringProp(KeyPairUpdateRequest.OWNER_ID_PROP_ID)\n this._newPublicKey = findStringProp(KeyPairUpdateRequest.OWNER_PUB_PROP_ID)\n }\n}\nexport namespace KeyPairUpdateRequest {\n /**\n * @internal this field is intended for internal use only and may be changed in future without notice\n */\n export const OWNER_ID_PROP_ID = 'dataOwnerConcernedId'\n /**\n * @internal this field is intended for internal use only and may be changed in future without notice\n */\n export const OWNER_PUB_PROP_ID = 'dataOwnerConcernedPubKey'\n /**\n * @internal this field is intended for internal use only and may be changed in future without notice\n */\n export const TASK_TYPE = MaintenanceTask.TaskTypeEnum.KeyPairUpdate\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StorageEntryKeysFactory } from './StorageEntryKeysFactory';
|
|
2
|
+
/**
|
|
3
|
+
* Default implementation for {@link StorageEntryKeysFactory}, compatible with legacy local storage keys.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DefaultStorageEntryKeysFactory implements StorageEntryKeysFactory {
|
|
6
|
+
cachedRecoveredKeypairOfDataOwner(dataOwnerId: string, publicKeyFingerprint: string): string;
|
|
7
|
+
deviceKeypairOfDataOwner(dataOwnerId: string, publicKeyFingerprint: string): string;
|
|
8
|
+
selfPublicKeysVerificationCacheForDataOwner(dataOwnerId: string): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultStorageEntryKeysFactory = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default implementation for {@link StorageEntryKeysFactory}, compatible with legacy local storage keys.
|
|
6
|
+
*/
|
|
7
|
+
class DefaultStorageEntryKeysFactory {
|
|
8
|
+
cachedRecoveredKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint) {
|
|
9
|
+
if (publicKeyFingerprint.length != 32)
|
|
10
|
+
throw new Error(`Invalid key fingerprint: ${publicKeyFingerprint}`);
|
|
11
|
+
return `org.taktik.icure.rsa.recovered.${dataOwnerId}.${publicKeyFingerprint}`;
|
|
12
|
+
}
|
|
13
|
+
deviceKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint) {
|
|
14
|
+
if (publicKeyFingerprint.length != 32)
|
|
15
|
+
throw new Error(`Invalid key fingerprint: ${publicKeyFingerprint}`);
|
|
16
|
+
return `org.taktik.icure.rsa.device.${dataOwnerId}.${publicKeyFingerprint}`;
|
|
17
|
+
}
|
|
18
|
+
selfPublicKeysVerificationCacheForDataOwner(dataOwnerId) {
|
|
19
|
+
return `org.taktik.icure.rsa.${dataOwnerId}.verification.self`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DefaultStorageEntryKeysFactory = DefaultStorageEntryKeysFactory;
|
|
23
|
+
//# sourceMappingURL=DefaultStorageEntryKeysFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultStorageEntryKeysFactory.js","sourceRoot":"","sources":["../../../icc-x-api/storage/DefaultStorageEntryKeysFactory.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,8BAA8B;IACzC,iCAAiC,CAAC,WAAmB,EAAE,oBAA4B;QACjF,IAAI,oBAAoB,CAAC,MAAM,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,oBAAoB,EAAE,CAAC,CAAA;QAC1G,OAAO,kCAAkC,WAAW,IAAI,oBAAoB,EAAE,CAAA;IAChF,CAAC;IAED,wBAAwB,CAAC,WAAmB,EAAE,oBAA4B;QACxE,IAAI,oBAAoB,CAAC,MAAM,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,oBAAoB,EAAE,CAAC,CAAA;QAC1G,OAAO,+BAA+B,WAAW,IAAI,oBAAoB,EAAE,CAAA;IAC7E,CAAC;IAED,2CAA2C,CAAC,WAAmB;QAC7D,OAAO,wBAAwB,WAAW,oBAAoB,CAAA;IAChE,CAAC;CACF;AAdD,wEAcC","sourcesContent":["import { StorageEntryKeysFactory } from './StorageEntryKeysFactory'\n\n/**\n * Default implementation for {@link StorageEntryKeysFactory}, compatible with legacy local storage keys.\n */\nexport class DefaultStorageEntryKeysFactory implements StorageEntryKeysFactory {\n cachedRecoveredKeypairOfDataOwner(dataOwnerId: string, publicKeyFingerprint: string): string {\n if (publicKeyFingerprint.length != 32) throw new Error(`Invalid key fingerprint: ${publicKeyFingerprint}`)\n return `org.taktik.icure.rsa.recovered.${dataOwnerId}.${publicKeyFingerprint}`\n }\n\n deviceKeypairOfDataOwner(dataOwnerId: string, publicKeyFingerprint: string): string {\n if (publicKeyFingerprint.length != 32) throw new Error(`Invalid key fingerprint: ${publicKeyFingerprint}`)\n return `org.taktik.icure.rsa.device.${dataOwnerId}.${publicKeyFingerprint}`\n }\n\n selfPublicKeysVerificationCacheForDataOwner(dataOwnerId: string): string {\n return `org.taktik.icure.rsa.${dataOwnerId}.verification.self`\n }\n}\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { KeyStorageFacade } from './KeyStorageFacade';
|
|
2
|
+
import { StorageFacade } from './StorageFacade';
|
|
3
|
+
import { StorageEntryKeysFactory } from './StorageEntryKeysFactory';
|
|
4
|
+
import { KeyPair } from '../crypto/RSA';
|
|
5
|
+
/**
|
|
6
|
+
* @internal This class is meant for internal use only and may be changed without notice.
|
|
7
|
+
* Simplifies access to the storage facades for iCure-specific data storage.
|
|
8
|
+
*/
|
|
9
|
+
export declare class IcureStorageFacade {
|
|
10
|
+
private readonly keys;
|
|
11
|
+
private readonly data;
|
|
12
|
+
private readonly entryFor;
|
|
13
|
+
constructor(keyStorage: KeyStorageFacade, storage: StorageFacade<string>, entryKeysFactory: StorageEntryKeysFactory);
|
|
14
|
+
/**
|
|
15
|
+
* Saves a key pair for the data owner.
|
|
16
|
+
* @param dataOwnerId id of the data owner with the key.
|
|
17
|
+
* @param publicKeyFingerprint fingerprint of the public key of the pair.
|
|
18
|
+
* @param keyPair a key pair of the data owner.
|
|
19
|
+
* @param isDevice true if the key was generated on this device.
|
|
20
|
+
*/
|
|
21
|
+
saveKey(dataOwnerId: string, publicKeyFingerprint: string, keyPair: KeyPair<JsonWebKey>, isDevice: boolean): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get an existing key pair for the data owner.
|
|
24
|
+
* @param dataOwnerId id of the data owner with the key.
|
|
25
|
+
* @param publicKeyFingerprint fingerprint of a public key of the data owner.
|
|
26
|
+
* @param legacyPublicKey the legacy public key of the data owner, if present
|
|
27
|
+
* @return the keypair and if the key was generated on this device or undefined if the key pair could not be found.
|
|
28
|
+
*/
|
|
29
|
+
loadKey(dataOwnerId: string, publicKeyFingerprint: string, legacyPublicKey: string | undefined): Promise<{
|
|
30
|
+
pair: KeyPair<JsonWebKey>;
|
|
31
|
+
isDevice: boolean;
|
|
32
|
+
} | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Save the results of public key verification. If there were already results stored the entries will be merged. In case of conflicts the new
|
|
35
|
+
* {@link verificationDetails} take priority over the stored data.
|
|
36
|
+
* @param dataOwnerId id of a data owner.
|
|
37
|
+
* @param verificationDetails results of verification, associates key fingerprints to true if they were verified by the user or false otherwise.
|
|
38
|
+
* @return the udpated keys
|
|
39
|
+
*/
|
|
40
|
+
saveSelfVerifiedKeys(dataOwnerId: string, verificationDetails: {
|
|
41
|
+
[keyFingerprint: string]: boolean;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
[keyFingerprint: string]: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the last saved results of public key verification.
|
|
47
|
+
* @param dataOwnerId id of a data owner.
|
|
48
|
+
* @return saved results of verification, associates key fingerprints to true if they were verified by the user or false otherwise. If no results
|
|
49
|
+
* were saved returns an empty object instead.
|
|
50
|
+
* @throws if the stored results are not in a valid format.
|
|
51
|
+
*/
|
|
52
|
+
loadSelfVerifiedKeys(dataOwnerId: string): Promise<{
|
|
53
|
+
[keyFingerprint: string]: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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.IcureStorageFacade = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* @internal This class is meant for internal use only and may be changed without notice.
|
|
15
|
+
* Simplifies access to the storage facades for iCure-specific data storage.
|
|
16
|
+
*/
|
|
17
|
+
class IcureStorageFacade {
|
|
18
|
+
constructor(keyStorage, storage, entryKeysFactory) {
|
|
19
|
+
this.keys = keyStorage;
|
|
20
|
+
this.data = storage;
|
|
21
|
+
this.entryFor = entryKeysFactory;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Saves a key pair for the data owner.
|
|
25
|
+
* @param dataOwnerId id of the data owner with the key.
|
|
26
|
+
* @param publicKeyFingerprint fingerprint of the public key of the pair.
|
|
27
|
+
* @param keyPair a key pair of the data owner.
|
|
28
|
+
* @param isDevice true if the key was generated on this device.
|
|
29
|
+
*/
|
|
30
|
+
saveKey(dataOwnerId, publicKeyFingerprint, keyPair, isDevice) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const key = isDevice
|
|
33
|
+
? this.entryFor.deviceKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint)
|
|
34
|
+
: this.entryFor.cachedRecoveredKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint);
|
|
35
|
+
yield this.keys.storeKeyPair(key, keyPair);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get an existing key pair for the data owner.
|
|
40
|
+
* @param dataOwnerId id of the data owner with the key.
|
|
41
|
+
* @param publicKeyFingerprint fingerprint of a public key of the data owner.
|
|
42
|
+
* @param legacyPublicKey the legacy public key of the data owner, if present
|
|
43
|
+
* @return the keypair and if the key was generated on this device or undefined if the key pair could not be found.
|
|
44
|
+
*/
|
|
45
|
+
loadKey(dataOwnerId, publicKeyFingerprint, legacyPublicKey) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const deviceKey = (_b = (_a = (yield this.keys.getKeypair(this.entryFor.deviceKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint)))) !== null && _a !== void 0 ? _a : (yield this.keys.getKeypair(`org.taktik.icure.rsa.${dataOwnerId}.${publicKeyFingerprint}`))) !== null && _b !== void 0 ? _b : ((legacyPublicKey === null || legacyPublicKey === void 0 ? void 0 : legacyPublicKey.slice(-32)) === publicKeyFingerprint ? yield this.keys.getKeypair(`org.taktik.icure.rsa.${dataOwnerId}`) : undefined);
|
|
49
|
+
if (deviceKey)
|
|
50
|
+
return { pair: deviceKey, isDevice: true };
|
|
51
|
+
const cachedKey = yield this.keys.getKeypair(this.entryFor.cachedRecoveredKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint));
|
|
52
|
+
if (cachedKey)
|
|
53
|
+
return { pair: cachedKey, isDevice: false };
|
|
54
|
+
return undefined;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Save the results of public key verification. If there were already results stored the entries will be merged. In case of conflicts the new
|
|
59
|
+
* {@link verificationDetails} take priority over the stored data.
|
|
60
|
+
* @param dataOwnerId id of a data owner.
|
|
61
|
+
* @param verificationDetails results of verification, associates key fingerprints to true if they were verified by the user or false otherwise.
|
|
62
|
+
* @return the udpated keys
|
|
63
|
+
*/
|
|
64
|
+
saveSelfVerifiedKeys(dataOwnerId, verificationDetails) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const updated = Object.assign(Object.assign({}, (yield this.loadSelfVerifiedKeys(dataOwnerId))), verificationDetails);
|
|
67
|
+
yield this.data.setItem(this.entryFor.selfPublicKeysVerificationCacheForDataOwner(dataOwnerId), JSON.stringify(updated));
|
|
68
|
+
return updated;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get the last saved results of public key verification.
|
|
73
|
+
* @param dataOwnerId id of a data owner.
|
|
74
|
+
* @return saved results of verification, associates key fingerprints to true if they were verified by the user or false otherwise. If no results
|
|
75
|
+
* were saved returns an empty object instead.
|
|
76
|
+
* @throws if the stored results are not in a valid format.
|
|
77
|
+
*/
|
|
78
|
+
loadSelfVerifiedKeys(dataOwnerId) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const dataString = yield this.data.getItem(this.entryFor.selfPublicKeysVerificationCacheForDataOwner(dataOwnerId));
|
|
81
|
+
if (dataString) {
|
|
82
|
+
const parsed = JSON.parse(dataString);
|
|
83
|
+
Object.entries(parsed).forEach(([k, v]) => {
|
|
84
|
+
if (v !== true && v !== false)
|
|
85
|
+
throw new Error(`Unexpected entry ${k}:${v}`);
|
|
86
|
+
});
|
|
87
|
+
return parsed;
|
|
88
|
+
}
|
|
89
|
+
else
|
|
90
|
+
return {};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.IcureStorageFacade = IcureStorageFacade;
|
|
95
|
+
//# sourceMappingURL=IcureStorageFacade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IcureStorageFacade.js","sourceRoot":"","sources":["../../../icc-x-api/storage/IcureStorageFacade.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA;;;GAGG;AACH,MAAa,kBAAkB;IAK7B,YAAY,UAA4B,EAAE,OAA8B,EAAE,gBAAyC;QACjH,IAAI,CAAC,IAAI,GAAG,UAAU,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAA;QACnB,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAA;IAClC,CAAC;IAED;;;;;;OAMG;IACG,OAAO,CAAC,WAAmB,EAAE,oBAA4B,EAAE,OAA4B,EAAE,QAAiB;;YAC9G,MAAM,GAAG,GAAG,QAAQ;gBAClB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,WAAW,EAAE,oBAAoB,CAAC;gBAC3E,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAA;YACtF,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC5C,CAAC;KAAA;IAED;;;;;;OAMG;IACG,OAAO,CACX,WAAmB,EACnB,oBAA4B,EAC5B,eAAmC;;;YAEnC,MAAM,SAAS,GACb,MAAA,MAAA,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAA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CAAC,2CAA2C,CAAC,WAAW,CAAC,CAAC,CAAA;YAClH,IAAI,UAAU,EAAE;gBACd,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;gBACrC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;oBACxC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK;wBAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAC9E,CAAC,CAAC,CAAA;gBACF,OAAO,MAAM,CAAA;aACd;;gBAAM,OAAO,EAAE,CAAA;QAClB,CAAC;KAAA;CACF;AAnFD,gDAmFC","sourcesContent":["import { KeyStorageFacade } from './KeyStorageFacade'\nimport { StorageFacade } from './StorageFacade'\nimport { StorageEntryKeysFactory } from './StorageEntryKeysFactory'\nimport { KeyPair } from '../crypto/RSA'\n\n/**\n * @internal This class is meant for internal use only and may be changed without notice.\n * Simplifies access to the storage facades for iCure-specific data storage.\n */\nexport class IcureStorageFacade {\n private readonly keys: KeyStorageFacade\n private readonly data: StorageFacade<string>\n private readonly entryFor: StorageEntryKeysFactory\n\n constructor(keyStorage: KeyStorageFacade, storage: StorageFacade<string>, entryKeysFactory: StorageEntryKeysFactory) {\n this.keys = keyStorage\n this.data = storage\n this.entryFor = entryKeysFactory\n }\n\n /**\n * Saves a key pair for the data owner.\n * @param dataOwnerId id of the data owner with the key.\n * @param publicKeyFingerprint fingerprint of the public key of the pair.\n * @param keyPair a key pair of the data owner.\n * @param isDevice true if the key was generated on this device.\n */\n async saveKey(dataOwnerId: string, publicKeyFingerprint: string, keyPair: KeyPair<JsonWebKey>, isDevice: boolean): Promise<void> {\n const key = isDevice\n ? this.entryFor.deviceKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint)\n : this.entryFor.cachedRecoveredKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint)\n await this.keys.storeKeyPair(key, keyPair)\n }\n\n /**\n * Get an existing key pair for the data owner.\n * @param dataOwnerId id of the data owner with the key.\n * @param publicKeyFingerprint fingerprint of a public key of the data owner.\n * @param legacyPublicKey the legacy public key of the data owner, if present\n * @return the keypair and if the key was generated on this device or undefined if the key pair could not be found.\n */\n async loadKey(\n dataOwnerId: string,\n publicKeyFingerprint: string,\n legacyPublicKey: string | undefined\n ): Promise<{ pair: KeyPair<JsonWebKey>; isDevice: boolean } | undefined> {\n const deviceKey =\n (await this.keys.getKeypair(this.entryFor.deviceKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint))) ??\n (await this.keys.getKeypair(`org.taktik.icure.rsa.${dataOwnerId}.${publicKeyFingerprint}`)) ??\n (legacyPublicKey?.slice(-32) === publicKeyFingerprint ? await this.keys.getKeypair(`org.taktik.icure.rsa.${dataOwnerId}`) : undefined)\n if (deviceKey) return { pair: deviceKey, isDevice: true }\n const cachedKey = await this.keys.getKeypair(this.entryFor.cachedRecoveredKeypairOfDataOwner(dataOwnerId, publicKeyFingerprint))\n if (cachedKey) return { pair: cachedKey, isDevice: false }\n return undefined\n }\n\n /**\n * Save the results of public key verification. If there were already results stored the entries will be merged. In case of conflicts the new\n * {@link verificationDetails} take priority over the stored data.\n * @param dataOwnerId id of a data owner.\n * @param verificationDetails results of verification, associates key fingerprints to true if they were verified by the user or false otherwise.\n * @return the udpated keys\n */\n async saveSelfVerifiedKeys(\n dataOwnerId: string,\n verificationDetails: { [keyFingerprint: string]: boolean }\n ): Promise<{ [keyFingerprint: string]: boolean }> {\n const updated = {\n ...(await this.loadSelfVerifiedKeys(dataOwnerId)),\n ...verificationDetails,\n }\n await this.data.setItem(this.entryFor.selfPublicKeysVerificationCacheForDataOwner(dataOwnerId), JSON.stringify(updated))\n return updated\n }\n\n /**\n * Get the last saved results of public key verification.\n * @param dataOwnerId id of a data owner.\n * @return saved results of verification, associates key fingerprints to true if they were verified by the user or false otherwise. If no results\n * were saved returns an empty object instead.\n * @throws if the stored results are not in a valid format.\n */\n async loadSelfVerifiedKeys(dataOwnerId: string): Promise<{ [keyFingerprint: string]: boolean }> {\n const dataString = await this.data.getItem(this.entryFor.selfPublicKeysVerificationCacheForDataOwner(dataOwnerId))\n if (dataString) {\n const parsed = JSON.parse(dataString)\n Object.entries(parsed).forEach(([k, v]) => {\n if (v !== true && v !== false) throw new Error(`Unexpected entry ${k}:${v}`)\n })\n return parsed\n } else return {}\n }\n}\n"]}
|