@icure/api 8.0.7 → 8.0.9
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/model/models.d.ts +1 -0
- package/icc-api/model/models.js +1 -0
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/crypto/ExchangeDataManager.js +3 -2
- package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/KeyRecovery.js +5 -4
- package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
- package/icc-x-api/crypto/RSA.d.ts +4 -1
- package/icc-x-api/crypto/RSA.js +6 -1
- package/icc-x-api/crypto/RSA.js.map +1 -1
- package/icc-x-api/crypto/SecureDelegationsManager.js +2 -1
- package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
- package/icc-x-api/crypto/TransferKeysManager.js +4 -3
- package/icc-x-api/crypto/TransferKeysManager.js.map +1 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js +2 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
- package/icc-x-api/crypto/utils.d.ts +1 -4
- package/icc-x-api/crypto/utils.js +6 -8
- package/icc-x-api/crypto/utils.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.js +16 -14
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +2 -2
- package/icc-x-api/icc-calendar-item-x-api.js +17 -17
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.js +12 -11
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +2 -2
- package/icc-x-api/icc-contact-x-api.js +23 -20
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.js +17 -16
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +13 -12
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.js +18 -16
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.js +12 -11
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +11 -11
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.js +14 -14
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.js +28 -27
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.js +11 -10
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-recovery-x-api.js +3 -2
- package/icc-x-api/icc-recovery-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.js +9 -8
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.js +13 -13
- package/icc-x-api/icc-topic-x-api.js.map +1 -1
- package/icc-x-api/utils/EntityWithDelegationTypeName.d.ts +17 -1
- package/icc-x-api/utils/EntityWithDelegationTypeName.js +33 -15
- package/icc-x-api/utils/EntityWithDelegationTypeName.js.map +1 -1
- package/icc-x-api/utils/index.d.ts +1 -0
- package/icc-x-api/utils/index.js +1 -0
- package/icc-x-api/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-api/api/IccAnonymousAccessApi.d.ts +1 -0
- package/test/icc-api/api/IccAnonymousAccessApi.js +58 -0
- package/test/icc-api/api/IccAnonymousAccessApi.js.map +1 -0
- package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
- package/test/icc-api/api/IccDocumentApi.js +208 -0
- package/test/icc-api/api/IccDocumentApi.js.map +1 -0
- package/test/icc-api/api/IccGroupApi.d.ts +1 -0
- package/test/icc-api/api/IccGroupApi.js +50 -0
- package/test/icc-api/api/IccGroupApi.js.map +1 -0
- package/test/icc-api/api/IccRecoveryDataApi.d.ts +1 -0
- package/test/icc-api/api/IccRecoveryDataApi.js +95 -0
- package/test/icc-api/api/IccRecoveryDataApi.js.map +1 -0
- package/test/icc-api/api/IccRoleApi.d.ts +1 -0
- package/test/icc-api/api/IccRoleApi.js +34 -0
- package/test/icc-api/api/IccRoleApi.js.map +1 -0
- package/test/icc-api/api/IccUserApi.d.ts +1 -0
- package/test/icc-api/api/IccUserApi.js +96 -0
- package/test/icc-api/api/IccUserApi.js.map +1 -0
- package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
- package/test/icc-api/e2e/IccCalendarItemApi.js +46 -0
- package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
- package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
- package/test/icc-api/model/modelHelpersTest.js +45 -0
- package/test/icc-api/model/modelHelpersTest.js.map +1 -0
- package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
- package/test/icc-x-api/auth/group-switch-test.js +81 -0
- package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
- package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
- package/test/icc-x-api/auth/jwt-concurrency-test.js +113 -0
- package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
- package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
- package/test/icc-x-api/auth/smart-auth-provider-test.js +224 -0
- package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
- package/test/icc-x-api/autofix-anonymity-test.d.ts +1 -0
- package/test/icc-x-api/autofix-anonymity-test.js +108 -0
- package/test/icc-x-api/autofix-anonymity-test.js.map +1 -0
- package/test/icc-x-api/confidential-entities-test.d.ts +1 -0
- package/test/icc-x-api/confidential-entities-test.js +110 -0
- package/test/icc-x-api/confidential-entities-test.js.map +1 -0
- package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +1 -0
- package/test/icc-x-api/crud/comprehensive-crud-test.js +276 -0
- package/test/icc-x-api/crud/comprehensive-crud-test.js.map +1 -0
- package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +16 -0
- package/test/icc-x-api/crud/entities-crud-test-interface.js +422 -0
- package/test/icc-x-api/crud/entities-crud-test-interface.js.map +1 -0
- package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +1 -0
- package/test/icc-x-api/crypto/anonymous-delegations-test.js +588 -0
- package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +1 -0
- package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
- package/test/icc-x-api/crypto/concurrency.js +35 -0
- package/test/icc-x-api/crypto/concurrency.js.map +1 -0
- package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
- package/test/icc-x-api/crypto/crypto-utils.js +80 -0
- package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
- package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
- package/test/icc-x-api/crypto/cryptoTest.js +302 -0
- package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +166 -0
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
- package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +1 -0
- package/test/icc-x-api/crypto/exchange-data-manager-test.js +690 -0
- package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -0
- package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
- package/test/icc-x-api/crypto/full-crypto-test.js +457 -0
- package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
- package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +1 -0
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js +266 -0
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -0
- package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.d.ts +1 -0
- package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js +393 -0
- package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js.map +1 -0
- package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.d.ts +1 -0
- package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js +213 -0
- package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js.map +1 -0
- package/test/icc-x-api/crypto/shamir.d.ts +2 -0
- package/test/icc-x-api/crypto/shamir.js +166 -0
- package/test/icc-x-api/crypto/shamir.js.map +1 -0
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +71 -0
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
- package/test/icc-x-api/crypto/signature-keys-manager-test.d.ts +1 -0
- package/test/icc-x-api/crypto/signature-keys-manager-test.js +44 -0
- package/test/icc-x-api/crypto/signature-keys-manager-test.js.map +1 -0
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +1 -0
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +246 -0
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +1 -0
- package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
- package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
- package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
- package/test/icc-x-api/filters/filters.d.ts +1 -0
- package/test/icc-x-api/filters/filters.js +49 -0
- package/test/icc-x-api/filters/filters.js.map +1 -0
- package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-accesslog-x-api.js +106 -0
- package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
- package/test/icc-x-api/icc-auth-api.d.ts +1 -0
- package/test/icc-x-api/icc-auth-api.js +47 -0
- package/test/icc-x-api/icc-auth-api.js.map +1 -0
- package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-calendar-item-x-api.js +150 -0
- package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
- package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-contact-x-api.js +279 -0
- package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
- package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-form-x-api.js +98 -0
- package/test/icc-x-api/icc-form-x-api.js.map +1 -0
- package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-helement-x-api-test.js +153 -0
- package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
- package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-invoice-x-api.js +99 -0
- package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
- package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js +221 -0
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
- package/test/icc-x-api/icc-message-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-message-x-api.js +328 -0
- package/test/icc-x-api/icc-message-x-api.js.map +1 -0
- package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-patient-x-api-test.js +158 -0
- package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
- package/test/icc-x-api/icc-recovery-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-recovery-x-api.js +170 -0
- package/test/icc-x-api/icc-recovery-x-api.js.map +1 -0
- package/test/icc-x-api/icc-time-table-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-time-table-x-api.js +100 -0
- package/test/icc-x-api/icc-time-table-x-api.js.map +1 -0
- package/test/icc-x-api/icc-topic-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-topic-x-api.js +269 -0
- package/test/icc-x-api/icc-topic-x-api.js.map +1 -0
- package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-user-x-api-test.js +99 -0
- package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
- package/test/icc-x-api/patient-user.d.ts +2 -0
- package/test/icc-x-api/patient-user.js +104 -0
- package/test/icc-x-api/patient-user.js.map +1 -0
- package/test/icc-x-api/storage/storage.d.ts +1 -0
- package/test/icc-x-api/storage/storage.js +48 -0
- package/test/icc-x-api/storage/storage.js.map +1 -0
- package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
- package/test/icc-x-api/test-api-no-parent.js +79 -0
- package/test/icc-x-api/test-api-no-parent.js.map +1 -0
- package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
- package/test/icc-x-api/test-legacy-data-support.js +376 -0
- package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
- package/test/icc-x-api/utils/graph-test.d.ts +1 -0
- package/test/icc-x-api/utils/graph-test.js +54 -0
- package/test/icc-x-api/utils/graph-test.js.map +1 -0
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +1 -0
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +364 -0
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +1 -0
- package/test/support/CSM-185.d.ts +1 -0
- package/test/support/CSM-185.js +124 -0
- package/test/support/CSM-185.js.map +1 -0
- package/test/support/CSM-243.d.ts +1 -0
- package/test/support/CSM-243.js +120 -0
- package/test/support/CSM-243.js.map +1 -0
- package/test/support/CSM-87.d.ts +0 -0
- package/test/support/CSM-87.js +21 -0
- package/test/support/CSM-87.js.map +1 -0
- package/test/support/CSM-93.d.ts +1 -0
- package/test/support/CSM-93.js +112 -0
- package/test/support/CSM-93.js.map +1 -0
- package/test/utils/FakeDataOwnerApi.d.ts +32 -0
- package/test/utils/FakeDataOwnerApi.js +136 -0
- package/test/utils/FakeDataOwnerApi.js.map +1 -0
- package/test/utils/FakeEncryptionKeysManager.d.ts +35 -0
- package/test/utils/FakeEncryptionKeysManager.js +87 -0
- package/test/utils/FakeEncryptionKeysManager.js.map +1 -0
- package/test/utils/FakeExchangeDataApi.d.ts +30 -0
- package/test/utils/FakeExchangeDataApi.js +74 -0
- package/test/utils/FakeExchangeDataApi.js.map +1 -0
- package/test/utils/FakeExchangeDataManager.d.ts +40 -0
- package/test/utils/FakeExchangeDataManager.js +89 -0
- package/test/utils/FakeExchangeDataManager.js.map +1 -0
- package/test/utils/FakeExchangeDataMapManager.d.ts +12 -0
- package/test/utils/FakeExchangeDataMapManager.js +38 -0
- package/test/utils/FakeExchangeDataMapManager.js.map +1 -0
- package/test/utils/FakeGenericApi.d.ts +16 -0
- package/test/utils/FakeGenericApi.js +65 -0
- package/test/utils/FakeGenericApi.js.map +1 -0
- package/test/utils/FakeSignatureKeysManager.d.ts +16 -0
- package/test/utils/FakeSignatureKeysManager.js +54 -0
- package/test/utils/FakeSignatureKeysManager.js.map +1 -0
- package/test/utils/TestApi.d.ts +3 -0
- package/test/utils/TestApi.js +30 -0
- package/test/utils/TestApi.js.map +1 -0
- package/test/utils/TestCollectionUtils.d.ts +1 -0
- package/test/utils/TestCollectionUtils.js +109 -0
- package/test/utils/TestCollectionUtils.js.map +1 -0
- package/test/utils/TestCryptoStrategies.d.ts +42 -0
- package/test/utils/TestCryptoStrategies.js +80 -0
- package/test/utils/TestCryptoStrategies.js.map +1 -0
- package/test/utils/TestStorage.d.ts +23 -0
- package/test/utils/TestStorage.js +61 -0
- package/test/utils/TestStorage.js.map +1 -0
- package/test/utils/test_utils.d.ts +76 -0
- package/test/utils/test_utils.js +419 -0
- package/test/utils/test_utils.js.map +1 -0
|
@@ -0,0 +1,419 @@
|
|
|
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
|
+
var _a, _b, _c, _d;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.itNoLite = exports.describeNoLite = exports.isLiteTest = exports.createUserInMultipleGroups = exports.createNewHcpWithoutKeyAndParentWithKey = exports.createHcpHierarchyApis = exports.createNewPatientApi = exports.createNewHcpApi = exports.getApiAndAddPrivateKeysForUser = exports.TestUtils = exports.getEnvironmentInitializer = exports.deviceUsername = exports.patUsername = exports.hcp3Username = exports.hcp2Username = exports.hcp1Username = exports.setLocalStorage = exports.getTempEmail = void 0;
|
|
14
|
+
const icc_x_api_1 = require("../../icc-x-api");
|
|
15
|
+
const os_1 = require("os");
|
|
16
|
+
const util_1 = require("util");
|
|
17
|
+
const uuid_1 = require("uuid");
|
|
18
|
+
const crypto_1 = require("crypto");
|
|
19
|
+
const TestApi_1 = require("./TestApi");
|
|
20
|
+
const api_1 = require("@icure/api");
|
|
21
|
+
const TestStorage_1 = require("./TestStorage");
|
|
22
|
+
const TestCryptoStrategies_1 = require("./TestCryptoStrategies");
|
|
23
|
+
const User_1 = require("../../icc-api/model/User");
|
|
24
|
+
const builder_1 = require("@icure/test-setup/builder");
|
|
25
|
+
const types_1 = require("@icure/test-setup/types");
|
|
26
|
+
require("isomorphic-fetch");
|
|
27
|
+
const creation_1 = require("@icure/test-setup/creation");
|
|
28
|
+
const icc_api_1 = require("../../icc-api");
|
|
29
|
+
const mocha_1 = require("mocha");
|
|
30
|
+
function getTempEmail() {
|
|
31
|
+
return `${(0, uuid_1.v4)().substring(0, 8)}@icure.com`;
|
|
32
|
+
}
|
|
33
|
+
exports.getTempEmail = getTempEmail;
|
|
34
|
+
function setLocalStorage(fetch) {
|
|
35
|
+
;
|
|
36
|
+
global.localStorage = new (require('node-localstorage').LocalStorage)((0, os_1.tmpdir)(), 5 * Math.pow(1024, 3));
|
|
37
|
+
global.fetch = fetch;
|
|
38
|
+
global.Storage = '';
|
|
39
|
+
global.TextDecoder = util_1.TextDecoder;
|
|
40
|
+
global.TextEncoder = util_1.TextEncoder;
|
|
41
|
+
global.headers = Headers;
|
|
42
|
+
}
|
|
43
|
+
exports.setLocalStorage = setLocalStorage;
|
|
44
|
+
exports.hcp1Username = (_a = process.env.ICURE_TS_TEST_HCP_USER) !== null && _a !== void 0 ? _a : getTempEmail();
|
|
45
|
+
exports.hcp2Username = (_b = process.env.ICURE_TS_TEST_HCP_2_USER) !== null && _b !== void 0 ? _b : getTempEmail();
|
|
46
|
+
exports.hcp3Username = (_c = process.env.ICURE_TS_TEST_HCP_3_USER) !== null && _c !== void 0 ? _c : getTempEmail();
|
|
47
|
+
exports.patUsername = (_d = process.env.ICURE_TS_TEST_PAT_USER) !== null && _d !== void 0 ? _d : getTempEmail();
|
|
48
|
+
exports.deviceUsername = getTempEmail();
|
|
49
|
+
let cachedInitializer;
|
|
50
|
+
function getEnvironmentInitializer() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
if (!cachedInitializer) {
|
|
53
|
+
const env = (0, types_1.getEnvVariables)();
|
|
54
|
+
const scratchDir = 'test/scratch';
|
|
55
|
+
const baseEnvironment = env.testEnvironment === 'docker' || env.testEnvironment === 'oss'
|
|
56
|
+
? new builder_1.TestEnvironmentBuilder().setUpDockerEnvironment(scratchDir, ['mock'])
|
|
57
|
+
: new builder_1.TestEnvironmentBuilder();
|
|
58
|
+
cachedInitializer = yield baseEnvironment
|
|
59
|
+
.withGroup(fetch, {
|
|
60
|
+
patient: ['BASIC_USER', 'BASIC_DATA_OWNER'],
|
|
61
|
+
hcp: [
|
|
62
|
+
'BASIC_USER',
|
|
63
|
+
'BASIC_DATA_OWNER',
|
|
64
|
+
'PATIENT_USER_MANAGER',
|
|
65
|
+
'HIERARCHICAL_DATA_OWNER',
|
|
66
|
+
'TOPIC_MANAGER',
|
|
67
|
+
'TOPIC_PARTICIPANT',
|
|
68
|
+
'LEGACY_MESSAGE_MANAGER',
|
|
69
|
+
],
|
|
70
|
+
device: ['BASIC_USER', 'BASIC_DATA_OWNER'],
|
|
71
|
+
user: ['BASIC_USER'],
|
|
72
|
+
})
|
|
73
|
+
.withMasterUser(fetch)
|
|
74
|
+
.addHcp({ login: exports.hcp1Username })
|
|
75
|
+
.addHcp({ login: exports.hcp2Username })
|
|
76
|
+
.addHcp({ login: exports.hcp3Username })
|
|
77
|
+
.addPatient({ login: exports.patUsername })
|
|
78
|
+
.addDevice({ login: exports.deviceUsername })
|
|
79
|
+
.withSafeguard()
|
|
80
|
+
.withEnvironmentSummary()
|
|
81
|
+
.build();
|
|
82
|
+
}
|
|
83
|
+
return cachedInitializer;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.getEnvironmentInitializer = getEnvironmentInitializer;
|
|
87
|
+
var TestUtils;
|
|
88
|
+
(function (TestUtils) {
|
|
89
|
+
function initApi(envVars, userName = exports.hcp1Username, options) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
return yield getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.dataOwnerDetails[userName], options);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
TestUtils.initApi = initApi;
|
|
95
|
+
function initMasterApi(envVars, options) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
return yield getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.masterHcp, options);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
TestUtils.initMasterApi = initMasterApi;
|
|
101
|
+
})(TestUtils = exports.TestUtils || (exports.TestUtils = {}));
|
|
102
|
+
function getApiAndAddPrivateKeysForUser(iCureUrl, details, options) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const RSA = new icc_x_api_1.RSAUtils(crypto_1.webcrypto);
|
|
105
|
+
const keys = {
|
|
106
|
+
publicKey: yield RSA.importKey('spki', (0, icc_x_api_1.hex2ua)(details.publicKey), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
107
|
+
privateKey: yield RSA.importKey('pkcs8', (0, icc_x_api_1.hex2ua)(details.privateKey), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
108
|
+
};
|
|
109
|
+
return yield (0, TestApi_1.TestApi)(iCureUrl, details.user, details.password, crypto_1.webcrypto, keys, options);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
exports.getApiAndAddPrivateKeysForUser = getApiAndAddPrivateKeysForUser;
|
|
113
|
+
function createHealthcarePartyUser(api, userLogin, userToken, publicKey, privateKey) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const { publicKey: newPublicKey, privateKey: newPrivateKey } = yield api.cryptoApi.RSA.generateKeyPair();
|
|
116
|
+
const publicKeyHex = !!publicKey && !!privateKey ? publicKey : (0, icc_x_api_1.ua2hex)(yield api.cryptoApi.RSA.exportKey(newPublicKey, 'spki'));
|
|
117
|
+
const privateKeyHex = !!publicKey && !!privateKey ? privateKey : (0, icc_x_api_1.ua2hex)(yield api.cryptoApi.RSA.exportKey(newPrivateKey, 'pkcs8'));
|
|
118
|
+
const hcp = yield api.healthcarePartyApi.createHealthcareParty({
|
|
119
|
+
id: (0, uuid_1.v4)(),
|
|
120
|
+
firstName: (0, uuid_1.v4)().substring(0, 6),
|
|
121
|
+
lastName: (0, uuid_1.v4)().substring(0, 6),
|
|
122
|
+
publicKey: publicKeyHex,
|
|
123
|
+
});
|
|
124
|
+
const hcpUser = yield api.userApi.createUser(new User_1.User({
|
|
125
|
+
id: (0, uuid_1.v4)(),
|
|
126
|
+
name: userLogin,
|
|
127
|
+
login: userLogin,
|
|
128
|
+
email: userLogin,
|
|
129
|
+
healthcarePartyId: hcp.id,
|
|
130
|
+
}));
|
|
131
|
+
const token = yield api.userApi.getToken(hcpUser.id, (0, uuid_1.v4)(), 24 * 60 * 60, userToken);
|
|
132
|
+
return {
|
|
133
|
+
user: hcpUser.login,
|
|
134
|
+
dataOwnerId: hcp.id,
|
|
135
|
+
password: token,
|
|
136
|
+
publicKey: publicKeyHex,
|
|
137
|
+
privateKey: privateKeyHex,
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function createNewHcpApi(env) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const initialisationApi = yield testSetupMasterApi(env);
|
|
144
|
+
const primitives = new icc_x_api_1.CryptoPrimitives(crypto_1.webcrypto);
|
|
145
|
+
const credentials = yield createHealthcarePartyUser(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
146
|
+
const storage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
147
|
+
{
|
|
148
|
+
dataOwnerId: credentials.dataOwnerId,
|
|
149
|
+
pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: icc_x_api_1.ShaVersion.Sha1 }],
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
152
|
+
const api = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: credentials.user, password: credentials.password }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
|
|
153
|
+
storage: storage.storage,
|
|
154
|
+
keyStorage: storage.keyStorage,
|
|
155
|
+
entryKeysFactory: storage.keyFactory,
|
|
156
|
+
});
|
|
157
|
+
return { api, credentials, user: yield api.userApi.getCurrentUser() };
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
exports.createNewHcpApi = createNewHcpApi;
|
|
161
|
+
function createNewPatientApi(env) {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
const initialisationApi = yield testSetupMasterApi(env);
|
|
164
|
+
const primitives = new icc_x_api_1.CryptoPrimitives(crypto_1.webcrypto);
|
|
165
|
+
const credentials = yield (0, creation_1.createPatientUser)(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
166
|
+
const storage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
167
|
+
{
|
|
168
|
+
dataOwnerId: credentials.dataOwnerId,
|
|
169
|
+
pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: icc_x_api_1.ShaVersion.Sha1 }],
|
|
170
|
+
},
|
|
171
|
+
]);
|
|
172
|
+
const api = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: credentials.user, password: credentials.password }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
|
|
173
|
+
storage: storage.storage,
|
|
174
|
+
keyStorage: storage.keyStorage,
|
|
175
|
+
entryKeysFactory: storage.keyFactory,
|
|
176
|
+
});
|
|
177
|
+
return { api, credentials, user: yield api.userApi.getCurrentUser() };
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
exports.createNewPatientApi = createNewPatientApi;
|
|
181
|
+
/**
|
|
182
|
+
* Creates a hierarchy of HCPs with the following structure:
|
|
183
|
+
* grand HCP -+-> parent HCP ---> child HCP
|
|
184
|
+
* |
|
|
185
|
+
* +-> child2 HCP
|
|
186
|
+
*/
|
|
187
|
+
function createHcpHierarchyApis(env, setupAutodelegations = true, disableParentKeysInitialisation = false) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
const shaVersion = icc_x_api_1.ShaVersion.Sha1;
|
|
190
|
+
const initialisationApi = yield testSetupMasterApi(env);
|
|
191
|
+
const primitives = new icc_x_api_1.CryptoPrimitives(crypto_1.webcrypto);
|
|
192
|
+
const grandCredentials = yield createHealthcarePartyUser(initialisationApi, `grand-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
193
|
+
const parentCredentials = yield createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
194
|
+
const childCredentials = yield createHealthcarePartyUser(initialisationApi, `child-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
195
|
+
const child2Credentials = yield createHealthcarePartyUser(initialisationApi, `child2-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
196
|
+
yield initialisationApi.healthcarePartyApi.modifyHealthcareParty(Object.assign(Object.assign({}, (yield initialisationApi.healthcarePartyApi.getHealthcareParty(parentCredentials.dataOwnerId))), { parentId: grandCredentials.dataOwnerId }));
|
|
197
|
+
yield initialisationApi.healthcarePartyApi.modifyHealthcareParty(Object.assign(Object.assign({}, (yield initialisationApi.healthcarePartyApi.getHealthcareParty(childCredentials.dataOwnerId))), { parentId: parentCredentials.dataOwnerId }));
|
|
198
|
+
yield initialisationApi.healthcarePartyApi.modifyHealthcareParty(Object.assign(Object.assign({}, (yield initialisationApi.healthcarePartyApi.getHealthcareParty(child2Credentials.dataOwnerId))), { parentId: grandCredentials.dataOwnerId }));
|
|
199
|
+
const grandStorage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
200
|
+
{
|
|
201
|
+
dataOwnerId: grandCredentials.dataOwnerId,
|
|
202
|
+
pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],
|
|
203
|
+
},
|
|
204
|
+
]);
|
|
205
|
+
const grandApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: grandCredentials.user, password: grandCredentials.password }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
|
|
206
|
+
storage: grandStorage.storage,
|
|
207
|
+
keyStorage: grandStorage.keyStorage,
|
|
208
|
+
entryKeysFactory: grandStorage.keyFactory,
|
|
209
|
+
disableParentKeysInitialisation,
|
|
210
|
+
});
|
|
211
|
+
const parentStorage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
212
|
+
{
|
|
213
|
+
dataOwnerId: grandCredentials.dataOwnerId,
|
|
214
|
+
pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
dataOwnerId: parentCredentials.dataOwnerId,
|
|
218
|
+
pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],
|
|
219
|
+
},
|
|
220
|
+
]);
|
|
221
|
+
const parentApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: parentCredentials.user, password: parentCredentials.password }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
|
|
222
|
+
storage: parentStorage.storage,
|
|
223
|
+
keyStorage: parentStorage.keyStorage,
|
|
224
|
+
entryKeysFactory: parentStorage.keyFactory,
|
|
225
|
+
disableParentKeysInitialisation,
|
|
226
|
+
});
|
|
227
|
+
const parentUser = setupAutodelegations
|
|
228
|
+
? yield parentApi.userApi.modifyUser(Object.assign(Object.assign({}, (yield parentApi.userApi.getCurrentUser())), { autoDelegations: { all: [grandCredentials.dataOwnerId] } }))
|
|
229
|
+
: yield parentApi.userApi.getCurrentUser();
|
|
230
|
+
const childStorage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
231
|
+
{
|
|
232
|
+
dataOwnerId: grandCredentials.dataOwnerId,
|
|
233
|
+
pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
dataOwnerId: parentCredentials.dataOwnerId,
|
|
237
|
+
pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
dataOwnerId: childCredentials.dataOwnerId,
|
|
241
|
+
pairs: [{ keyPair: { privateKey: childCredentials.privateKey, publicKey: childCredentials.publicKey }, shaVersion: shaVersion }],
|
|
242
|
+
},
|
|
243
|
+
]);
|
|
244
|
+
const childApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: childCredentials.user, password: childCredentials.password }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
|
|
245
|
+
storage: childStorage.storage,
|
|
246
|
+
keyStorage: childStorage.keyStorage,
|
|
247
|
+
entryKeysFactory: childStorage.keyFactory,
|
|
248
|
+
disableParentKeysInitialisation,
|
|
249
|
+
});
|
|
250
|
+
const childUser = setupAutodelegations
|
|
251
|
+
? yield childApi.userApi.modifyUser(Object.assign(Object.assign({}, (yield childApi.userApi.getCurrentUser())), { autoDelegations: { all: [grandCredentials.dataOwnerId, parentCredentials.dataOwnerId] } }))
|
|
252
|
+
: yield childApi.userApi.getCurrentUser();
|
|
253
|
+
const child2Storage = yield (0, TestStorage_1.testStorageWithKeys)([
|
|
254
|
+
{
|
|
255
|
+
dataOwnerId: grandCredentials.dataOwnerId,
|
|
256
|
+
pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
dataOwnerId: child2Credentials.dataOwnerId,
|
|
260
|
+
pairs: [{ keyPair: { privateKey: child2Credentials.privateKey, publicKey: child2Credentials.publicKey }, shaVersion: shaVersion }],
|
|
261
|
+
},
|
|
262
|
+
]);
|
|
263
|
+
const child2Api = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: child2Credentials.user, password: child2Credentials.password }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
|
|
264
|
+
storage: child2Storage.storage,
|
|
265
|
+
keyStorage: child2Storage.keyStorage,
|
|
266
|
+
entryKeysFactory: child2Storage.keyFactory,
|
|
267
|
+
disableParentKeysInitialisation,
|
|
268
|
+
});
|
|
269
|
+
const child2User = setupAutodelegations
|
|
270
|
+
? yield child2Api.userApi.modifyUser(Object.assign(Object.assign({}, (yield child2Api.userApi.getCurrentUser())), { autoDelegations: { all: [grandCredentials.dataOwnerId] } }))
|
|
271
|
+
: yield child2Api.userApi.getCurrentUser();
|
|
272
|
+
return {
|
|
273
|
+
grandApi,
|
|
274
|
+
grandUser: yield grandApi.userApi.getCurrentUser(),
|
|
275
|
+
grandCredentials,
|
|
276
|
+
parentApi,
|
|
277
|
+
parentUser,
|
|
278
|
+
parentCredentials,
|
|
279
|
+
childApi,
|
|
280
|
+
childUser,
|
|
281
|
+
childCredentials,
|
|
282
|
+
child2Api,
|
|
283
|
+
child2User,
|
|
284
|
+
child2Credentials,
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
exports.createHcpHierarchyApis = createHcpHierarchyApis;
|
|
289
|
+
/**
|
|
290
|
+
* Create a parent HCP with a key and a child HCP without any initialised key
|
|
291
|
+
*/
|
|
292
|
+
function createNewHcpWithoutKeyAndParentWithKey(env, props = {}) {
|
|
293
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
294
|
+
const initialisationApi = yield testSetupMasterApi(env);
|
|
295
|
+
const primitives = new icc_x_api_1.CryptoPrimitives(crypto_1.webcrypto);
|
|
296
|
+
const parentCredentials = yield createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid());
|
|
297
|
+
const childUser = (0, uuid_1.v4)() + '@email.com';
|
|
298
|
+
const childPassword = (0, uuid_1.v4)();
|
|
299
|
+
const childHcp = {
|
|
300
|
+
id: (0, uuid_1.v4)(),
|
|
301
|
+
firstName: (0, uuid_1.v4)().substring(0, 6),
|
|
302
|
+
lastName: (0, uuid_1.v4)().substring(0, 6),
|
|
303
|
+
parentId: parentCredentials.dataOwnerId,
|
|
304
|
+
publicKey: undefined,
|
|
305
|
+
};
|
|
306
|
+
if (props.initialiseEmptyKeyForChild) {
|
|
307
|
+
childHcp.publicKey = '';
|
|
308
|
+
}
|
|
309
|
+
yield initialisationApi.healthcarePartyApi.createHealthcareParty(childHcp);
|
|
310
|
+
yield initialisationApi.userApi.createUser(new User_1.User({
|
|
311
|
+
id: (0, uuid_1.v4)(),
|
|
312
|
+
name: childUser,
|
|
313
|
+
login: childUser,
|
|
314
|
+
email: childUser,
|
|
315
|
+
passwordHash: childPassword,
|
|
316
|
+
healthcarePartyId: childHcp.id,
|
|
317
|
+
}));
|
|
318
|
+
return {
|
|
319
|
+
parentCredentials,
|
|
320
|
+
childUser,
|
|
321
|
+
childPassword,
|
|
322
|
+
childDataOwnerId: childHcp.id,
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
exports.createNewHcpWithoutKeyAndParentWithKey = createNewHcpWithoutKeyAndParentWithKey;
|
|
327
|
+
function testSetupMasterApi(env) {
|
|
328
|
+
return api_1.IcureApi.initialise(env.iCureUrl, { username: env.masterHcp.user, password: env.masterHcp.password }, {
|
|
329
|
+
generateNewKeyForDataOwner() {
|
|
330
|
+
return Promise.resolve(true);
|
|
331
|
+
},
|
|
332
|
+
recoverAndVerifySelfHierarchyKeys() {
|
|
333
|
+
throw new Error('Unsupported');
|
|
334
|
+
},
|
|
335
|
+
verifyDelegatePublicKeys(delegate, publicKeys) {
|
|
336
|
+
return Promise.resolve(publicKeys);
|
|
337
|
+
},
|
|
338
|
+
}, crypto_1.webcrypto, fetch);
|
|
339
|
+
}
|
|
340
|
+
function createUserInMultipleGroups(env) {
|
|
341
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
342
|
+
const primitives = new icc_x_api_1.CryptoPrimitives(crypto_1.webcrypto);
|
|
343
|
+
const userGroup1Id = primitives.randomUuid(); // Same username-pw as group 2
|
|
344
|
+
const userGroup2Id = primitives.randomUuid(); // Same username-pw as group 1
|
|
345
|
+
const userGroup3Id = primitives.randomUuid(); // Same username as group 1/2, different pw
|
|
346
|
+
const userLogin = `maria-${primitives.randomUuid()}@pompei.it`;
|
|
347
|
+
const userPw12 = `geppetto-${primitives.randomUuid()}`;
|
|
348
|
+
const userPw3 = `pinocchio-${primitives.randomUuid()}`;
|
|
349
|
+
const user1Id = primitives.randomUuid();
|
|
350
|
+
const user2Id = primitives.randomUuid();
|
|
351
|
+
const user3Id = primitives.randomUuid();
|
|
352
|
+
const api = yield (0, icc_x_api_1.BasicApis)(env.iCureUrl, { username: 'john', password: 'LetMeIn' }, crypto_1.webcrypto, fetch); // pragma: allowlist secret
|
|
353
|
+
const group1 = yield api.groupApi.createGroup(userGroup1Id, `test-group-1-${primitives.randomUuid()}`, primitives.randomUuid(), undefined, undefined, undefined, undefined, undefined, {});
|
|
354
|
+
const group2 = yield api.groupApi.createGroup(userGroup2Id, `test-group-2-${primitives.randomUuid()}`, primitives.randomUuid(), undefined, undefined, undefined, undefined, undefined, {});
|
|
355
|
+
const group3 = yield api.groupApi.createGroup(userGroup3Id, `test-group-3-${primitives.randomUuid()}`, primitives.randomUuid(), undefined, undefined, undefined, undefined, undefined, {});
|
|
356
|
+
const user1 = yield api.userApi.createUserInGroup(userGroup1Id, {
|
|
357
|
+
id: user1Id,
|
|
358
|
+
name: userLogin,
|
|
359
|
+
login: userLogin,
|
|
360
|
+
email: userLogin,
|
|
361
|
+
passwordHash: userPw12,
|
|
362
|
+
});
|
|
363
|
+
const user2 = yield api.userApi.createUserInGroup(userGroup2Id, {
|
|
364
|
+
id: user2Id,
|
|
365
|
+
name: userLogin,
|
|
366
|
+
login: userLogin,
|
|
367
|
+
email: userLogin,
|
|
368
|
+
passwordHash: userPw12,
|
|
369
|
+
});
|
|
370
|
+
const user3 = yield api.userApi.createUserInGroup(userGroup3Id, {
|
|
371
|
+
id: user3Id,
|
|
372
|
+
name: userLogin,
|
|
373
|
+
login: userLogin,
|
|
374
|
+
email: userLogin,
|
|
375
|
+
passwordHash: userPw3,
|
|
376
|
+
});
|
|
377
|
+
console.log(`Waiting for user to be created - ${userLogin}`);
|
|
378
|
+
yield (0, icc_x_api_1.retry)(() => __awaiter(this, void 0, void 0, function* () {
|
|
379
|
+
yield new icc_api_1.IccUserApi(env.iCureUrl, {}, new icc_x_api_1.BasicAuthenticationProvider(`${userGroup1Id}/${user1Id}`, userPw12), fetch).getCurrentUser();
|
|
380
|
+
yield new icc_api_1.IccUserApi(env.iCureUrl, {}, new icc_x_api_1.BasicAuthenticationProvider(`${userGroup2Id}/${user2Id}`, userPw12), fetch).getCurrentUser();
|
|
381
|
+
yield new icc_api_1.IccUserApi(env.iCureUrl, {}, new icc_x_api_1.BasicAuthenticationProvider(`${userGroup3Id}/${user3Id}`, userPw3), fetch).getCurrentUser();
|
|
382
|
+
}), 10, 5000, 1);
|
|
383
|
+
return {
|
|
384
|
+
user1,
|
|
385
|
+
user2,
|
|
386
|
+
user3,
|
|
387
|
+
group1,
|
|
388
|
+
group2,
|
|
389
|
+
group3,
|
|
390
|
+
userPw12,
|
|
391
|
+
userPw3,
|
|
392
|
+
userLogin,
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
exports.createUserInMultipleGroups = createUserInMultipleGroups;
|
|
397
|
+
function isLiteTest() {
|
|
398
|
+
return (0, types_1.getEnvVariables)().testEnvironment == 'oss';
|
|
399
|
+
}
|
|
400
|
+
exports.isLiteTest = isLiteTest;
|
|
401
|
+
function describeNoLite(title, fn) {
|
|
402
|
+
if (isLiteTest()) {
|
|
403
|
+
return mocha_1.describe.skip(title, fn);
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
return (0, mocha_1.describe)(title, fn);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
exports.describeNoLite = describeNoLite;
|
|
410
|
+
function itNoLite(title, fn) {
|
|
411
|
+
if (isLiteTest()) {
|
|
412
|
+
return it.skip(title, fn);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
return it(title, fn);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
exports.itNoLite = itNoLite;
|
|
419
|
+
//# sourceMappingURL=test_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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yB;IACrE,IAAI,UAAU,EAAE,EAAE;QAChB,OAAO,gBAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;KAChC;SAAM;QACL,OAAO,IAAA,gBAAQ,EAAC,KAAK,EAAE,EAAE,CAAC,CAAA;KAC3B;AACH,CAAC;AAND,wCAMC;AAED,SAAgB,QAAQ,CAAC,KAAa,EAAE,EAAuC;IAC7E,IAAI,UAAU,EAAE,EAAE;QAChB,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;KAC1B;SAAM;QACL,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;KACrB;AACH,CAAC;AAND,4BAMC","sourcesContent":["import {\n BasicApis,\n BasicAuthenticationProvider,\n CryptoPrimitives,\n hex2ua,\n IcureApi,\n IcureApiOptions,\n retry,\n RSAUtils,\n ShaVersion,\n ua2hex,\n} from '../../icc-x-api'\nimport { tmpdir } from 'os'\nimport { TextDecoder, TextEncoder } from 'util'\nimport { v4 as uuid } from 'uuid'\nimport { webcrypto } from 'crypto'\nimport { TestApi } from './TestApi'\nimport { IcureApi as TestSetupApi } from '@icure/api'\nimport { testStorageWithKeys } from './TestStorage'\nimport { TestCryptoStrategies } from './TestCryptoStrategies'\nimport { User } from '../../icc-api/model/User'\nimport { TestEnvironmentBuilder } from '@icure/test-setup/builder'\nimport { getEnvVariables, TestVars, UserDetails } from '@icure/test-setup/types'\nimport { EnvInitializer } from '@icure/test-setup/decorators'\nimport 'isomorphic-fetch'\nimport { createPatientUser } from '@icure/test-setup/creation'\nimport { IccUserApi } from '../../icc-api'\nimport { Context, describe, Suite, Test } from 'mocha'\nimport { Group } from '../../icc-api/model/Group'\n\nexport function getTempEmail(): string {\n return `${uuid().substring(0, 8)}@icure.com`\n}\n\nexport function setLocalStorage(fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>) {\n ;(global as any).localStorage = new (require('node-localstorage').LocalStorage)(tmpdir(), 5 * 1024 ** 3)\n ;(global as any).fetch = fetch\n ;(global as any).Storage = ''\n ;(global as any).TextDecoder = TextDecoder\n ;(global as any).TextEncoder = TextEncoder\n ;(global as any).headers = Headers\n}\n\nexport const hcp1Username = process.env.ICURE_TS_TEST_HCP_USER ?? getTempEmail()\nexport const hcp2Username = process.env.ICURE_TS_TEST_HCP_2_USER ?? getTempEmail()\nexport const hcp3Username = process.env.ICURE_TS_TEST_HCP_3_USER ?? getTempEmail()\nexport const patUsername = process.env.ICURE_TS_TEST_PAT_USER ?? getTempEmail()\n\nexport const deviceUsername = getTempEmail()\n\nlet cachedInitializer: EnvInitializer | undefined\n\nexport async function getEnvironmentInitializer(): Promise<EnvInitializer> {\n if (!cachedInitializer) {\n const env = getEnvVariables()\n const scratchDir = 'test/scratch'\n const baseEnvironment =\n env.testEnvironment === 'docker' || env.testEnvironment === 'oss'\n ? new TestEnvironmentBuilder().setUpDockerEnvironment(scratchDir, ['mock'])\n : new TestEnvironmentBuilder()\n cachedInitializer = await baseEnvironment\n .withGroup(fetch, {\n patient: ['BASIC_USER', 'BASIC_DATA_OWNER'],\n hcp: [\n 'BASIC_USER',\n 'BASIC_DATA_OWNER',\n 'PATIENT_USER_MANAGER',\n 'HIERARCHICAL_DATA_OWNER',\n 'TOPIC_MANAGER',\n 'TOPIC_PARTICIPANT',\n 'LEGACY_MESSAGE_MANAGER',\n ],\n device: ['BASIC_USER', 'BASIC_DATA_OWNER'],\n user: ['BASIC_USER'],\n })\n .withMasterUser(fetch)\n .addHcp({ login: hcp1Username })\n .addHcp({ login: hcp2Username })\n .addHcp({ login: hcp3Username })\n .addPatient({ login: patUsername })\n .addDevice({ login: deviceUsername })\n .withSafeguard()\n .withEnvironmentSummary()\n .build()\n }\n return cachedInitializer\n}\n\nexport namespace TestUtils {\n export async function initApi(envVars: TestVars, userName: string = hcp1Username, options?: IcureApiOptions): Promise<IcureApi> {\n return await getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.dataOwnerDetails[userName], options)\n }\n\n export async function initMasterApi(envVars: TestVars, options?: IcureApiOptions): Promise<IcureApi> {\n return await getApiAndAddPrivateKeysForUser(envVars.iCureUrl, envVars.masterHcp!, options)\n }\n}\n\nexport async function getApiAndAddPrivateKeysForUser(iCureUrl: string, details: UserDetails, options?: IcureApiOptions) {\n const RSA = new RSAUtils(webcrypto as any)\n const keys = {\n publicKey: await RSA.importKey('spki', hex2ua(details.publicKey), ['encrypt'], ShaVersion.Sha1),\n privateKey: await RSA.importKey('pkcs8', hex2ua(details.privateKey), ['decrypt'], ShaVersion.Sha1),\n }\n return await TestApi(iCureUrl, details.user, details.password, webcrypto as any, keys, options)\n}\n\nasync function createHealthcarePartyUser(\n api: TestSetupApi,\n userLogin: string,\n userToken: string,\n publicKey?: string,\n privateKey?: string\n): Promise<UserDetails> {\n const { publicKey: newPublicKey, privateKey: newPrivateKey } = await api.cryptoApi.RSA.generateKeyPair()\n\n const publicKeyHex = !!publicKey && !!privateKey ? publicKey : ua2hex(await api.cryptoApi.RSA.exportKey(newPublicKey, 'spki'))\n const privateKeyHex = !!publicKey && !!privateKey ? privateKey : ua2hex(await api.cryptoApi.RSA.exportKey(newPrivateKey, 'pkcs8'))\n\n const hcp = await api.healthcarePartyApi.createHealthcareParty({\n id: uuid(),\n firstName: uuid().substring(0, 6),\n lastName: uuid().substring(0, 6),\n publicKey: publicKeyHex,\n })\n const hcpUser = await api.userApi.createUser(\n new User({\n id: uuid(),\n name: userLogin,\n login: userLogin,\n email: userLogin,\n healthcarePartyId: hcp.id,\n })\n )\n const token = await api.userApi.getToken(hcpUser.id!, uuid(), 24 * 60 * 60, userToken)\n return {\n user: hcpUser.login!,\n dataOwnerId: hcp.id!,\n password: token,\n publicKey: publicKeyHex,\n privateKey: privateKeyHex,\n }\n}\n\nexport async function createNewHcpApi(env: TestVars): Promise<{\n api: IcureApi\n credentials: UserDetails\n user: User\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new CryptoPrimitives(webcrypto as any)\n const credentials = await createHealthcarePartyUser(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid())\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const api = await IcureApi.initialise(\n env.iCureUrl,\n { username: credentials.user, password: credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: storage.storage,\n keyStorage: storage.keyStorage,\n entryKeysFactory: storage.keyFactory,\n }\n )\n return { api, credentials, user: await api.userApi.getCurrentUser() }\n}\n\nexport async function createNewPatientApi(env: TestVars): Promise<{\n api: IcureApi\n credentials: UserDetails\n user: User\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new CryptoPrimitives(webcrypto as any)\n const credentials = await createPatientUser(initialisationApi, `user-${primitives.randomUuid()}`, primitives.randomUuid())\n const storage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: credentials.privateKey, publicKey: credentials.publicKey }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const api = await IcureApi.initialise(\n env.iCureUrl,\n { username: credentials.user, password: credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: storage.storage,\n keyStorage: storage.keyStorage,\n entryKeysFactory: storage.keyFactory,\n }\n )\n return { api, credentials, user: await api.userApi.getCurrentUser() }\n}\n\n/**\n * Creates a hierarchy of HCPs with the following structure:\n * grand HCP -+-> parent HCP ---> child HCP\n * |\n * +-> child2 HCP\n */\nexport async function createHcpHierarchyApis(\n env: TestVars,\n setupAutodelegations: boolean = true,\n disableParentKeysInitialisation: boolean = false\n): Promise<{\n grandApi: IcureApi\n grandUser: User\n grandCredentials: UserDetails\n parentApi: IcureApi\n parentUser: User\n parentCredentials: UserDetails\n childApi: IcureApi\n childUser: User\n childCredentials: UserDetails\n child2Api: IcureApi\n child2User: User\n child2Credentials: UserDetails\n}> {\n const shaVersion = ShaVersion.Sha1\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new CryptoPrimitives(webcrypto as any)\n const grandCredentials = await createHealthcarePartyUser(initialisationApi, `grand-${primitives.randomUuid()}`, primitives.randomUuid())\n const parentCredentials = await createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid())\n const childCredentials = await createHealthcarePartyUser(initialisationApi, `child-${primitives.randomUuid()}`, primitives.randomUuid())\n const child2Credentials = await createHealthcarePartyUser(initialisationApi, `child2-${primitives.randomUuid()}`, primitives.randomUuid())\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(parentCredentials.dataOwnerId)),\n parentId: grandCredentials.dataOwnerId,\n })\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(childCredentials.dataOwnerId)),\n parentId: parentCredentials.dataOwnerId,\n })\n await initialisationApi.healthcarePartyApi.modifyHealthcareParty({\n ...(await initialisationApi.healthcarePartyApi.getHealthcareParty(child2Credentials.dataOwnerId)),\n parentId: grandCredentials.dataOwnerId,\n })\n const grandStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const grandApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: grandCredentials.user, password: grandCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: grandStorage.storage,\n keyStorage: grandStorage.keyStorage,\n entryKeysFactory: grandStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const parentStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: parentCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const parentApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: parentCredentials.user, password: parentCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: parentStorage.storage,\n keyStorage: parentStorage.keyStorage,\n entryKeysFactory: parentStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const parentUser = setupAutodelegations\n ? await parentApi.userApi.modifyUser({\n ...(await parentApi.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId] },\n })\n : await parentApi.userApi.getCurrentUser()\n const childStorage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: parentCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: childCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: childCredentials.privateKey, publicKey: childCredentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const childApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: childCredentials.user, password: childCredentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: childStorage.storage,\n keyStorage: childStorage.keyStorage,\n entryKeysFactory: childStorage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const childUser = setupAutodelegations\n ? await childApi.userApi.modifyUser({\n ...(await childApi.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId, parentCredentials.dataOwnerId] },\n })\n : await childApi.userApi.getCurrentUser()\n const child2Storage = await testStorageWithKeys([\n {\n dataOwnerId: grandCredentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: grandCredentials.privateKey, publicKey: grandCredentials.publicKey }, shaVersion: shaVersion }],\n },\n {\n dataOwnerId: child2Credentials.dataOwnerId,\n pairs: [{ keyPair: { privateKey: child2Credentials.privateKey, publicKey: child2Credentials.publicKey }, shaVersion: shaVersion }],\n },\n ])\n const child2Api = await IcureApi.initialise(\n env.iCureUrl,\n { username: child2Credentials.user, password: child2Credentials.password },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: child2Storage.storage,\n keyStorage: child2Storage.keyStorage,\n entryKeysFactory: child2Storage.keyFactory,\n disableParentKeysInitialisation,\n }\n )\n const child2User = setupAutodelegations\n ? await child2Api.userApi.modifyUser({\n ...(await child2Api.userApi.getCurrentUser()),\n autoDelegations: { all: [grandCredentials.dataOwnerId] },\n })\n : await child2Api.userApi.getCurrentUser()\n return {\n grandApi,\n grandUser: await grandApi.userApi.getCurrentUser(),\n grandCredentials,\n parentApi,\n parentUser,\n parentCredentials,\n childApi,\n childUser,\n childCredentials,\n child2Api,\n child2User,\n child2Credentials,\n }\n}\n\n/**\n * Create a parent HCP with a key and a child HCP without any initialised key\n */\nexport async function createNewHcpWithoutKeyAndParentWithKey(\n env: TestVars,\n props: {\n initialiseEmptyKeyForChild?: boolean\n } = {}\n): Promise<{\n parentCredentials: UserDetails\n childUser: string\n childDataOwnerId: string\n childPassword: string\n}> {\n const initialisationApi = await testSetupMasterApi(env)\n const primitives = new CryptoPrimitives(webcrypto as any)\n const parentCredentials = await createHealthcarePartyUser(initialisationApi, `parent-${primitives.randomUuid()}`, primitives.randomUuid())\n const childUser = uuid() + '@email.com'\n const childPassword = uuid()\n const childHcp = {\n id: uuid(),\n firstName: uuid().substring(0, 6),\n lastName: uuid().substring(0, 6),\n parentId: parentCredentials.dataOwnerId,\n publicKey: undefined as string | undefined,\n }\n if (props.initialiseEmptyKeyForChild) {\n childHcp.publicKey = ''\n }\n await initialisationApi.healthcarePartyApi.createHealthcareParty(childHcp)\n await initialisationApi.userApi.createUser(\n new User({\n id: uuid(),\n name: childUser,\n login: childUser,\n email: childUser,\n passwordHash: childPassword,\n healthcarePartyId: childHcp.id,\n })\n )\n return {\n parentCredentials,\n childUser,\n childPassword,\n childDataOwnerId: childHcp.id!,\n }\n}\n\nfunction testSetupMasterApi(env: TestVars): Promise<TestSetupApi> {\n return TestSetupApi.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n {\n generateNewKeyForDataOwner(): Promise<boolean> {\n return Promise.resolve(true)\n },\n recoverAndVerifySelfHierarchyKeys(): never {\n throw new Error('Unsupported')\n },\n verifyDelegatePublicKeys(delegate: any, publicKeys: string[]): Promise<string[]> {\n return Promise.resolve(publicKeys)\n },\n },\n webcrypto as any,\n fetch\n )\n}\n\nexport type UserInManyGroupsDetails = {\n user1: User\n user2: User\n group3: Group\n userPw3: string\n user3: User\n group2: Group\n group1: Group\n userPw12: string\n userLogin: string\n}\nexport async function createUserInMultipleGroups(env: TestVars): Promise<UserInManyGroupsDetails> {\n const primitives = new CryptoPrimitives(webcrypto as any)\n const userGroup1Id: string = primitives.randomUuid() // Same username-pw as group 2\n const userGroup2Id: string = primitives.randomUuid() // Same username-pw as group 1\n const userGroup3Id: string = primitives.randomUuid() // Same username as group 1/2, different pw\n const userLogin: string = `maria-${primitives.randomUuid()}@pompei.it`\n const userPw12: string = `geppetto-${primitives.randomUuid()}`\n const userPw3: string = `pinocchio-${primitives.randomUuid()}`\n const user1Id: string = primitives.randomUuid()\n const user2Id: string = primitives.randomUuid()\n const user3Id: string = primitives.randomUuid()\n const api = await BasicApis(env.iCureUrl, { username: 'john', password: 'LetMeIn' }, webcrypto as any, fetch) // pragma: allowlist secret\n const group1 = await api.groupApi.createGroup(\n userGroup1Id,\n `test-group-1-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const group2 = await api.groupApi.createGroup(\n userGroup2Id,\n `test-group-2-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const group3 = await api.groupApi.createGroup(\n userGroup3Id,\n `test-group-3-${primitives.randomUuid()}`,\n primitives.randomUuid(),\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n {}\n )\n const user1 = await api.userApi.createUserInGroup(userGroup1Id, {\n id: user1Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw12,\n })\n const user2 = await api.userApi.createUserInGroup(userGroup2Id, {\n id: user2Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw12,\n })\n const user3 = await api.userApi.createUserInGroup(userGroup3Id, {\n id: user3Id,\n name: userLogin,\n login: userLogin,\n email: userLogin,\n passwordHash: userPw3,\n })\n console.log(`Waiting for user to be created - ${userLogin}`)\n await retry(\n async () => {\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup1Id}/${user1Id}`, userPw12), fetch).getCurrentUser()\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup2Id}/${user2Id}`, userPw12), fetch).getCurrentUser()\n await new IccUserApi(env.iCureUrl, {}, new BasicAuthenticationProvider(`${userGroup3Id}/${user3Id}`, userPw3), fetch).getCurrentUser()\n },\n 10,\n 5_000,\n 1\n )\n return {\n user1,\n user2,\n user3,\n group1,\n group2,\n group3,\n userPw12,\n userPw3,\n userLogin,\n }\n}\n\nexport function isLiteTest() {\n return getEnvVariables().testEnvironment == 'oss'\n}\n\nexport function describeNoLite(title: string, fn: (this: Suite) => void): Suite | void {\n if (isLiteTest()) {\n return describe.skip(title, fn)\n } else {\n return describe(title, fn)\n }\n}\n\nexport function itNoLite(title: string, fn: (this: Context) => PromiseLike<any>): Test {\n if (isLiteTest()) {\n return it.skip(title, fn)\n } else {\n return it(title, fn)\n }\n}\n"]}
|