@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
|
@@ -1,10 +1,20 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.IccReceiptXApi = void 0;
|
|
4
13
|
const icc_api_1 = require("../icc-api");
|
|
5
14
|
const _ = require("lodash");
|
|
6
15
|
const models = require("../icc-api/model/models");
|
|
7
16
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
17
|
+
const ShareMetadataBehaviour_1 = require("./crypto/ShareMetadataBehaviour");
|
|
8
18
|
class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
9
19
|
constructor(host, headers, crypto, dataOwnerApi, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
10
20
|
? window.fetch
|
|
@@ -15,53 +25,39 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
15
25
|
this.crypto = crypto;
|
|
16
26
|
this.dataOwnerApi = dataOwnerApi;
|
|
17
27
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.crypto.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const dels = initData[0];
|
|
52
|
-
const eks = initData[1];
|
|
53
|
-
_.extend(receipt, {
|
|
54
|
-
delegations: dels.delegations,
|
|
55
|
-
cryptedForeignKeys: dels.cryptedForeignKeys,
|
|
56
|
-
secretForeignKeys: dels.secretForeignKeys,
|
|
57
|
-
encryptionKeys: eks.encryptionKeys,
|
|
58
|
-
});
|
|
59
|
-
let promise = Promise.resolve(receipt);
|
|
60
|
-
(user.autoDelegations ? (user.autoDelegations.all || []).concat(user.autoDelegations.medicalInformation || []) : []).forEach((delegateId) => (promise = promise.then((receipt) => this.crypto.addDelegationsAndEncryptionKeys(null, receipt, dataOwnerId, delegateId, dels.secretId, eks.secretId).catch((e) => {
|
|
61
|
-
console.log(e);
|
|
62
|
-
return receipt;
|
|
63
|
-
}))));
|
|
64
|
-
return promise;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance of receipt with initialised encryption metadata (not in the database).
|
|
30
|
+
* @param user the current user.
|
|
31
|
+
* @param r initialised data for the receipt. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
|
|
32
|
+
* other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
|
|
33
|
+
* @param options optional parameters:
|
|
34
|
+
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
35
|
+
* auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
|
|
36
|
+
* auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
|
|
37
|
+
* access will be possible.
|
|
38
|
+
* @return a new instance of receipt.
|
|
39
|
+
*/
|
|
40
|
+
newInstance(user, r, options = {}) {
|
|
41
|
+
var _a, _b, _c, _d, _e;
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const receipt = new models.Receipt(_.extend({
|
|
44
|
+
id: this.crypto.randomUuid(),
|
|
45
|
+
_type: 'org.taktik.icure.entities.Receipt',
|
|
46
|
+
created: new Date().getTime(),
|
|
47
|
+
modified: new Date().getTime(),
|
|
48
|
+
responsible: this.dataOwnerApi.getDataOwnerIdOf(user),
|
|
49
|
+
author: user.id,
|
|
50
|
+
codes: [],
|
|
51
|
+
tags: [],
|
|
52
|
+
}, r || {}));
|
|
53
|
+
const extraDelegations = [
|
|
54
|
+
...Object.keys((_a = options.additionalDelegates) !== null && _a !== void 0 ? _a : {}),
|
|
55
|
+
...((_c = (_b = user.autoDelegations) === null || _b === void 0 ? void 0 : _b.all) !== null && _c !== void 0 ? _c : []),
|
|
56
|
+
...((_e = (_d = user.autoDelegations) === null || _d === void 0 ? void 0 : _d.medicalInformation) !== null && _e !== void 0 ? _e : []),
|
|
57
|
+
];
|
|
58
|
+
return new models.Receipt(yield this.crypto.entities
|
|
59
|
+
.entityWithInitialisedEncryptedMetadata(receipt, undefined, undefined, true, extraDelegations)
|
|
60
|
+
.then((x) => x.updatedEntity));
|
|
65
61
|
});
|
|
66
62
|
}
|
|
67
63
|
logReceipt(user, docId, refs, blobType, blob) {
|
|
@@ -69,6 +65,48 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
69
65
|
.then((rcpt) => this.createReceipt(rcpt))
|
|
70
66
|
.then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachment(rcpt.id, blobType, '', blob) : Promise.resolve(rcpt)));
|
|
71
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.
|
|
70
|
+
* @param receipt a receipt.
|
|
71
|
+
* @param blobType the type of the attachment.
|
|
72
|
+
* @param attachment a attachment for the receipt.
|
|
73
|
+
* @return the updated receipt.
|
|
74
|
+
*/
|
|
75
|
+
encryptAndSetReceiptAttachment(receipt, blobType, attachment) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const encryptedData = yield this.crypto.entities.encryptDataOf(receipt, attachment);
|
|
78
|
+
return yield this.setReceiptAttachment(receipt.id, blobType, undefined, encryptedData);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.
|
|
83
|
+
* @param receipt a receipt.
|
|
84
|
+
* @param attachmentId id of the attachment of this receipt to retrieve.
|
|
85
|
+
* @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption
|
|
86
|
+
* keys and it is unclear which one should be used this function can help to detect bad decryptions.
|
|
87
|
+
* @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.
|
|
88
|
+
*/
|
|
89
|
+
getAndDecryptReceiptAttachment(receipt, attachmentId, validator = () => Promise.resolve(true)) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
return yield this.crypto.entities.decryptDataOf(receipt, yield this.getReceiptAttachment(receipt.id, attachmentId, ''), (x) => validator(x));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also
|
|
96
|
+
* the encrypted content.
|
|
97
|
+
* @param delegateId the id of the data owner which will be granted access to the receipt.
|
|
98
|
+
* @param receipt the receipt to share.
|
|
99
|
+
* @param options optional parameters to customize the sharing behaviour:
|
|
100
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
101
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
102
|
+
* receipt does not have encrypted content.
|
|
103
|
+
* @return a promise which will contain the updated receipt.
|
|
104
|
+
*/
|
|
105
|
+
shareWith(delegateId, receipt, options = {}) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
return yield this.modifyReceipt(yield this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(receipt, delegateId, undefined, options.shareEncryptionKey, ShareMetadataBehaviour_1.ShareMetadataBehaviour.IF_AVAILABLE));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
72
110
|
}
|
|
73
111
|
exports.IccReceiptXApi = IccReceiptXApi;
|
|
74
112
|
//# sourceMappingURL=icc-receipt-x-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":"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","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as _ from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\n\nexport class IccReceiptXApi extends IccReceiptApi {\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of receipt with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param r initialised data for the receipt. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read\n * access will be possible.\n * @return a new instance of receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n } = {}\n ): Promise<models.Receipt> {\n const receipt = new models.Receipt(\n _.extend(\n {\n id: this.crypto.randomUuid(),\n _type: 'org.taktik.icure.entities.Receipt',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: this.dataOwnerApi.getDataOwnerIdOf(user),\n author: user.id,\n codes: [],\n tags: [],\n },\n r || {}\n )\n )\n\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.medicalInformation ?? []),\n ]\n return new models.Receipt(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(receipt, undefined, undefined, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer) {\n return this.newInstance(user, { documentId: docId, references: refs })\n .then((rcpt) => this.createReceipt(rcpt))\n .then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachment(rcpt.id!, blobType, '', <any>blob) : Promise.resolve(rcpt)))\n }\n\n /**\n * Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async encryptAndSetReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n const encryptedData = await this.crypto.entities.encryptDataOf(receipt, attachment)\n return await this.setReceiptAttachment(receipt.id!, blobType, undefined, encryptedData)\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n */\n async getAndDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n return await this.crypto.entities.decryptDataOf(receipt, await this.getReceiptAttachment(receipt.id!, attachmentId, ''), (x) => validator(x))\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content.\n * @param delegateId the id of the data owner which will be granted access to the receipt.\n * @param receipt the receipt to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * receipt does not have encrypted content.\n * @return a promise which will contain the updated receipt.\n */\n async shareWith(\n delegateId: string,\n receipt: models.Receipt,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Receipt> {\n return await this.modifyReceipt(\n await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(\n receipt,\n delegateId,\n undefined,\n options.shareEncryptionKey,\n ShareMetadataBehaviour.IF_AVAILABLE\n )\n )\n }\n}\n"]}
|
|
@@ -3,7 +3,9 @@ import { User } from '../icc-api/model/User';
|
|
|
3
3
|
import { TimeTable } from '../icc-api/model/TimeTable';
|
|
4
4
|
import { IccCryptoXApi } from './icc-crypto-x-api';
|
|
5
5
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
6
|
+
import * as models from '../icc-api/model/models';
|
|
6
7
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
8
|
+
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
|
|
7
9
|
export declare class IccTimeTableXApi extends IccTimeTableApi {
|
|
8
10
|
i18n: any;
|
|
9
11
|
crypto: IccCryptoXApi;
|
|
@@ -11,14 +13,36 @@ export declare class IccTimeTableXApi extends IccTimeTableApi {
|
|
|
11
13
|
constructor(host: string, headers: {
|
|
12
14
|
[key: string]: string;
|
|
13
15
|
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new instance of timetable with initialised encryption metadata (not in the database).
|
|
18
|
+
* @param user the current user.
|
|
19
|
+
* @param tt initialised data for the timetable. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
|
|
20
|
+
* other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
|
|
21
|
+
* @param options optional parameters:
|
|
22
|
+
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
23
|
+
* auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
|
|
24
|
+
* auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
|
|
25
|
+
* access will be possible.
|
|
26
|
+
* @return a new instance of timetable.
|
|
27
|
+
*/
|
|
28
|
+
newInstance(user: User, tt: TimeTable, options?: {
|
|
29
|
+
additionalDelegates?: {
|
|
30
|
+
[dataOwnerId: string]: 'WRITE';
|
|
31
|
+
};
|
|
32
|
+
}): Promise<TimeTable>;
|
|
33
|
+
/**
|
|
34
|
+
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
35
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
36
|
+
* @param delegateId the id of the data owner which will be granted access to the time table.
|
|
37
|
+
* @param timeTable the time table to share.
|
|
38
|
+
* @param options optional parameters to customize the sharing behaviour:
|
|
39
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
40
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
41
|
+
* time table does not have encrypted content.
|
|
42
|
+
* @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if
|
|
43
|
+
* the operation failed.
|
|
44
|
+
*/
|
|
45
|
+
shareWith(delegateId: string, timeTable: models.TimeTable, options?: {
|
|
46
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
47
|
+
}): Promise<models.TimeTable>;
|
|
24
48
|
}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.IccTimeTableXApi = void 0;
|
|
4
13
|
const i18n = require("./rsrc/contact.i18n");
|
|
5
14
|
const _ = require("lodash");
|
|
6
15
|
const icc_api_1 = require("../icc-api");
|
|
16
|
+
const models = require("../icc-api/model/models");
|
|
7
17
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
18
|
+
const ShareMetadataBehaviour_1 = require("./crypto/ShareMetadataBehaviour");
|
|
8
19
|
class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
9
20
|
constructor(host, headers, crypto, dataOwnerApi, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
10
21
|
? window.fetch
|
|
@@ -16,24 +27,56 @@ class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
|
16
27
|
this.crypto = crypto;
|
|
17
28
|
this.dataOwnerApi = dataOwnerApi;
|
|
18
29
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new instance of timetable with initialised encryption metadata (not in the database).
|
|
32
|
+
* @param user the current user.
|
|
33
|
+
* @param tt initialised data for the timetable. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
|
|
34
|
+
* other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
|
|
35
|
+
* @param options optional parameters:
|
|
36
|
+
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
37
|
+
* auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
|
|
38
|
+
* auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
|
|
39
|
+
* access will be possible.
|
|
40
|
+
* @return a new instance of timetable.
|
|
41
|
+
*/
|
|
42
|
+
newInstance(user, tt, options = {}) {
|
|
43
|
+
var _a, _b, _c, _d, _e;
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const timeTable = _.extend({
|
|
46
|
+
id: this.crypto.primitives.randomUuid(),
|
|
47
|
+
_type: 'org.taktik.icure.entities.TimeTable',
|
|
48
|
+
created: new Date().getTime(),
|
|
49
|
+
modified: new Date().getTime(),
|
|
50
|
+
responsible: this.dataOwnerApi.getDataOwnerIdOf(user),
|
|
51
|
+
author: user.id,
|
|
52
|
+
codes: [],
|
|
53
|
+
tags: [],
|
|
54
|
+
}, tt || {});
|
|
55
|
+
const extraDelegations = [
|
|
56
|
+
...Object.keys((_a = options.additionalDelegates) !== null && _a !== void 0 ? _a : {}),
|
|
57
|
+
...((_c = (_b = user.autoDelegations) === null || _b === void 0 ? void 0 : _b.all) !== null && _c !== void 0 ? _c : []),
|
|
58
|
+
...((_e = (_d = user.autoDelegations) === null || _d === void 0 ? void 0 : _d.administrativeData) !== null && _e !== void 0 ? _e : []),
|
|
59
|
+
];
|
|
60
|
+
return new models.TimeTable(yield this.crypto.entities
|
|
61
|
+
.entityWithInitialisedEncryptedMetadata(timeTable, undefined, undefined, true, extraDelegations)
|
|
62
|
+
.then((x) => x.updatedEntity));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
67
|
+
* the encrypted content, with read-only or read-write permissions.
|
|
68
|
+
* @param delegateId the id of the data owner which will be granted access to the time table.
|
|
69
|
+
* @param timeTable the time table to share.
|
|
70
|
+
* @param options optional parameters to customize the sharing behaviour:
|
|
71
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
72
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
73
|
+
* time table does not have encrypted content.
|
|
74
|
+
* @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if
|
|
75
|
+
* the operation failed.
|
|
76
|
+
*/
|
|
77
|
+
shareWith(delegateId, timeTable, options = {}) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
return yield this.modifyTimeTable(yield this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(timeTable, delegateId, undefined, options.shareEncryptionKey, ShareMetadataBehaviour_1.ShareMetadataBehaviour.IF_AVAILABLE));
|
|
37
80
|
});
|
|
38
81
|
}
|
|
39
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-time-table-x-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-time-table-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA2C;AAE3C,4BAA2B;AAC3B,wCAA4C;AAK5C,kDAAiD;AACjD,0EAAgG;AAChG,4EAAwE;AAExE,MAAa,gBAAiB,SAAQ,yBAAe;IAKnD,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA8B,EAC9B,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAhBzD,SAAI,GAAQ,IAAI,CAAA;QAiBd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;OAWG;IACG,WAAW,CACf,IAAU,EACV,EAAa,EACb,UAEI,EAAE;;;YAEN,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CACxB;gBACE,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE;gBACvC,KAAK,EAAE,qCAAqC;gBAC5C,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;gBAC7B,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;gBAC9B,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACrD,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,EAAE;aACT,EACD,EAAE,IAAI,EAAE,CACT,CAAA;YAED,MAAM,gBAAgB,GAAG;gBACvB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAA,OAAO,CAAC,mBAAmB,mCAAI,EAAE,CAAC;gBACjD,GAAG,CAAC,MAAA,MAAA,IAAI,CAAC,eAAe,0CAAE,GAAG,mCAAI,EAAE,CAAC;gBACpC,GAAG,CAAC,MAAA,MAAA,IAAI,CAAC,eAAe,0CAAE,kBAAkB,mCAAI,EAAE,CAAC;aACpD,CAAA;YACD,OAAO,IAAI,MAAM,CAAC,SAAS,CACzB,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ;iBACvB,sCAAsC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,CAAC;iBAC/F,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAChC,CAAA;;KACF;IAED;;;;;;;;;;;OAWG;IACG,SAAS,CACb,UAAkB,EAClB,SAA2B,EAC3B,UAEI,EAAE;;YAEN,OAAO,MAAM,IAAI,CAAC,eAAe,CAC/B,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,uCAAuC,CAChE,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,CAAC,kBAAkB,EAC1B,+CAAsB,CAAC,YAAY,CACpC,CACF,CAAA;QACH,CAAC;KAAA;CACF;AAhGD,4CAgGC","sourcesContent":["import * as i18n from './rsrc/contact.i18n'\n\nimport * as _ from 'lodash'\nimport { IccTimeTableApi } from '../icc-api'\nimport { User } from '../icc-api/model/User'\nimport { TimeTable } from '../icc-api/model/TimeTable'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport * as models from '../icc-api/model/models'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\n\nexport class IccTimeTableXApi extends IccTimeTableApi {\n i18n: any = i18n\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of timetable with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param tt initialised data for the timetable. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read\n * access will be possible.\n * @return a new instance of timetable.\n */\n async newInstance(\n user: User,\n tt: TimeTable,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n } = {}\n ) {\n const timeTable = _.extend(\n {\n id: this.crypto.primitives.randomUuid(),\n _type: 'org.taktik.icure.entities.TimeTable',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: this.dataOwnerApi.getDataOwnerIdOf(user),\n author: user.id,\n codes: [],\n tags: [],\n },\n tt || {}\n )\n\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.administrativeData ?? []),\n ]\n return new models.TimeTable(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(timeTable, undefined, undefined, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the time table.\n * @param timeTable the time table to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * time table does not have encrypted content.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async shareWith(\n delegateId: string,\n timeTable: models.TimeTable,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.TimeTable> {\n return await this.modifyTimeTable(\n await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(\n timeTable,\n delegateId,\n undefined,\n options.shareEncryptionKey,\n ShareMetadataBehaviour.IF_AVAILABLE\n )\n )\n }\n}\n"]}
|
package/icc-x-api/index.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ import { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api';
|
|
|
20
20
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
21
21
|
import { StorageFacade } from './storage/StorageFacade';
|
|
22
22
|
import { KeyStorageFacade } from './storage/KeyStorageFacade';
|
|
23
|
+
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
24
|
+
import { StorageEntryKeysFactory } from './storage/StorageEntryKeysFactory';
|
|
25
|
+
import { CryptoStrategies } from './crypto/CryptoStrategies';
|
|
26
|
+
import { IccIcureMaintenanceXApi } from './icc-icure-maintenance-x-api';
|
|
23
27
|
export * from './icc-accesslog-x-api';
|
|
24
28
|
export * from './icc-bekmehr-x-api';
|
|
25
29
|
export * from './icc-calendar-item-x-api';
|
|
@@ -71,5 +75,30 @@ export interface Apis {
|
|
|
71
75
|
messageApi: IccMessageXApi;
|
|
72
76
|
maintenanceTaskApi: IccMaintenanceTaskXApi;
|
|
73
77
|
dataOwnerApi: IccDataOwnerXApi;
|
|
78
|
+
icureMaintenanceTaskApi: IccIcureMaintenanceXApi;
|
|
74
79
|
}
|
|
75
|
-
export
|
|
80
|
+
export type ApiOptions = {
|
|
81
|
+
readonly entryKeysFactory?: StorageEntryKeysFactory;
|
|
82
|
+
readonly createMaintenanceTasksOnNewKey?: boolean;
|
|
83
|
+
readonly storage?: StorageFacade<string>;
|
|
84
|
+
readonly keyStorage?: KeyStorageFacade;
|
|
85
|
+
readonly headers?: {
|
|
86
|
+
[headerName: string]: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export type AuthenticationDetails = {
|
|
90
|
+
username: string;
|
|
91
|
+
password: string;
|
|
92
|
+
forceBasic?: boolean;
|
|
93
|
+
};
|
|
94
|
+
export declare const Api: (host: string, authenticationOptions: AuthenticationDetails | AuthenticationProvider, cryptoStrategies: CryptoStrategies, crypto?: Crypto, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>, options?: ApiOptions) => Promise<Apis>;
|
|
95
|
+
export declare const BasicApis: (host: string, username: string, password: string, crypto?: Crypto, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>, forceBasic?: boolean) => Promise<{
|
|
96
|
+
authApi: IccAuthApi;
|
|
97
|
+
codeApi: IccCodeXApi;
|
|
98
|
+
userApi: IccUserXApi;
|
|
99
|
+
permissionApi: IccPermissionApi;
|
|
100
|
+
insuranceApi: IccInsuranceApi;
|
|
101
|
+
entityReferenceApi: IccEntityrefApi;
|
|
102
|
+
agendaApi: IccAgendaApi;
|
|
103
|
+
groupApi: IccGroupApi;
|
|
104
|
+
}>;
|