@icure/api 8.2.0 → 8.2.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/model/RouteOfAdministration.d.ts +1 -0
- package/icc-api/model/RouteOfAdministration.js.map +1 -1
- package/icc-api/model/Vmp.d.ts +2 -0
- package/icc-api/model/Vmp.js.map +1 -1
- package/icc-api/model/VmpGroup.d.ts +2 -0
- package/icc-api/model/VmpGroup.js.map +1 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.d.ts +2 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js +14 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
- package/icc-x-api/icc-bekmehr-x-api.js +1 -1
- package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
- package/icc-x-api/index.js +1 -1
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
- package/test/utils/FakeEncryptionKeysManager.js +1 -1
- package/test/utils/FakeEncryptionKeysManager.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteOfAdministration.js","sourceRoot":"","sources":["../../../icc-api/model/RouteOfAdministration.ts"],"names":[],"mappings":";;;AAcA,MAAa,qBAAqB;IAChC,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAA6B,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC;
|
|
1
|
+
{"version":3,"file":"RouteOfAdministration.js","sourceRoot":"","sources":["../../../icc-api/model/RouteOfAdministration.ts"],"names":[],"mappings":";;;AAcA,MAAa,qBAAqB;IAChC,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAA6B,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC;CAKF;AARD,sDAQC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { CodeStub } from './CodeStub'\nimport { SamText } from './SamText'\n\nexport class RouteOfAdministration {\n constructor(json: JSON | any) {\n Object.assign(this as RouteOfAdministration, json)\n }\n\n code?: string\n name?: SamText\n standardRoutes?: Array<CodeStub>\n}\n"]}
|
package/icc-api/model/Vmp.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { VmpComponent } from './VmpComponent';
|
|
|
15
15
|
import { VmpGroupStub } from './VmpGroupStub';
|
|
16
16
|
import { Vtm } from './Vtm';
|
|
17
17
|
import { Wada } from './Wada';
|
|
18
|
+
import { Quantity } from "./Quantity";
|
|
18
19
|
export declare class Vmp {
|
|
19
20
|
constructor(json: JSON | any);
|
|
20
21
|
id?: string;
|
|
@@ -27,6 +28,7 @@ export declare class Vmp {
|
|
|
27
28
|
to?: number;
|
|
28
29
|
code?: string;
|
|
29
30
|
vmpGroup?: VmpGroupStub;
|
|
31
|
+
singleAdministrationDose?: Quantity;
|
|
30
32
|
name?: SamText;
|
|
31
33
|
abbreviation?: SamText;
|
|
32
34
|
vtm?: Vtm;
|
package/icc-api/model/Vmp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vmp.js","sourceRoot":"","sources":["../../../icc-api/model/Vmp.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Vmp.js","sourceRoot":"","sources":["../../../icc-api/model/Vmp.ts"],"names":[],"mappings":";;;AAmBA,MAAa,GAAG;IACd,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAW,EAAE,IAAI,CAAC,CAAA;IAClC,CAAC;CAmBF;AAtBD,kBAsBC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { CommentedClassification } from './CommentedClassification'\nimport { SamText } from './SamText'\nimport { VmpComponent } from './VmpComponent'\nimport { VmpGroupStub } from './VmpGroupStub'\nimport { Vtm } from './Vtm'\nimport { Wada } from './Wada'\nimport {Quantity} from \"./Quantity\"\n\nexport class Vmp {\n constructor(json: JSON | any) {\n Object.assign(this as Vmp, json)\n }\n\n id?: string\n rev?: string\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n from?: number\n to?: number\n code?: string\n vmpGroup?: VmpGroupStub\n singleAdministrationDose?: Quantity\n name?: SamText\n abbreviation?: SamText\n vtm?: Vtm\n wadas?: Array<Wada>\n components?: Array<VmpComponent>\n commentedClassifications?: Array<CommentedClassification>\n}\n"]}
|
|
@@ -13,6 +13,7 @@ import { NoGenericPrescriptionReason } from './NoGenericPrescriptionReason';
|
|
|
13
13
|
import { NoSwitchReason } from './NoSwitchReason';
|
|
14
14
|
import { SamText } from './SamText';
|
|
15
15
|
import { StandardDosage } from './StandardDosage';
|
|
16
|
+
import { Quantity } from './Quantity';
|
|
16
17
|
export declare class VmpGroup {
|
|
17
18
|
constructor(json: JSON | any);
|
|
18
19
|
id?: string;
|
|
@@ -26,6 +27,7 @@ export declare class VmpGroup {
|
|
|
26
27
|
productId?: string;
|
|
27
28
|
code?: string;
|
|
28
29
|
name?: SamText;
|
|
30
|
+
singleAdministrationDose?: Quantity;
|
|
29
31
|
noGenericPrescriptionReason?: NoGenericPrescriptionReason;
|
|
30
32
|
noSwitchReason?: NoSwitchReason;
|
|
31
33
|
standardDosage?: Array<StandardDosage>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VmpGroup.js","sourceRoot":"","sources":["../../../icc-api/model/VmpGroup.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"VmpGroup.js","sourceRoot":"","sources":["../../../icc-api/model/VmpGroup.ts"],"names":[],"mappings":";;;AAiBA,MAAa,QAAQ;IACnB,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAgB,EAAE,IAAI,CAAC,CAAA;IACvC,CAAC;CAiBF;AApBD,4BAoBC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { NoGenericPrescriptionReason } from './NoGenericPrescriptionReason'\nimport { NoSwitchReason } from './NoSwitchReason'\nimport { SamText } from './SamText'\nimport { StandardDosage } from './StandardDosage'\nimport { Quantity } from './Quantity'\n\nexport class VmpGroup {\n constructor(json: JSON | any) {\n Object.assign(this as VmpGroup, json)\n }\n\n id?: string\n rev?: string\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n from?: number\n to?: number\n productId?: string\n code?: string\n name?: SamText\n singleAdministrationDose?: Quantity\n noGenericPrescriptionReason?: NoGenericPrescriptionReason\n noSwitchReason?: NoSwitchReason\n standardDosage?: Array<StandardDosage>\n}\n"]}
|
|
@@ -16,10 +16,11 @@ export declare class UserEncryptionKeysManager {
|
|
|
16
16
|
private readonly strategies;
|
|
17
17
|
private readonly initialiseParentKeys;
|
|
18
18
|
private readonly keypairRecoverer;
|
|
19
|
+
private readonly selfIsAnonymous;
|
|
19
20
|
private selfId;
|
|
20
21
|
private selfLegacyPublicKey;
|
|
21
22
|
private keysCache;
|
|
22
|
-
constructor(primitives: CryptoPrimitives, dataOwnerApi: IccDataOwnerXApi, icureStorage: IcureStorageFacade, keyRecovery: KeyRecovery, strategies: CryptoStrategies, initialiseParentKeys: boolean, keypairRecoverer: KeyPairRecoverer);
|
|
23
|
+
constructor(primitives: CryptoPrimitives, dataOwnerApi: IccDataOwnerXApi, icureStorage: IcureStorageFacade, keyRecovery: KeyRecovery, strategies: CryptoStrategies, initialiseParentKeys: boolean, keypairRecoverer: KeyPairRecoverer, selfIsAnonymous: boolean);
|
|
23
24
|
/**
|
|
24
25
|
* @internal
|
|
25
26
|
* Get all key pairs available for the current data owner and his parents.
|
|
@@ -19,7 +19,7 @@ const nothingKeyRecovererAndVerifier = (x) => Promise.resolve(x.reduce((acc, { d
|
|
|
19
19
|
* Allows to manage public and private keys for the current user and his parent hierarchy.
|
|
20
20
|
*/
|
|
21
21
|
class UserEncryptionKeysManager {
|
|
22
|
-
constructor(primitives, dataOwnerApi, icureStorage, keyRecovery, strategies, initialiseParentKeys, keypairRecoverer) {
|
|
22
|
+
constructor(primitives, dataOwnerApi, icureStorage, keyRecovery, strategies, initialiseParentKeys, keypairRecoverer, selfIsAnonymous) {
|
|
23
23
|
this.primitives = primitives;
|
|
24
24
|
this.dataOwnerApi = dataOwnerApi;
|
|
25
25
|
this.icureStorage = icureStorage;
|
|
@@ -27,6 +27,7 @@ class UserEncryptionKeysManager {
|
|
|
27
27
|
this.strategies = strategies;
|
|
28
28
|
this.initialiseParentKeys = initialiseParentKeys;
|
|
29
29
|
this.keypairRecoverer = keypairRecoverer;
|
|
30
|
+
this.selfIsAnonymous = selfIsAnonymous;
|
|
30
31
|
this.keysCache = undefined;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
@@ -252,6 +253,18 @@ class UserEncryptionKeysManager {
|
|
|
252
253
|
throw new Error(`No verified key found for ${self.dataOwner.id} and settings do not allow creation of a new key.`);
|
|
253
254
|
}
|
|
254
255
|
else if (typeof whatToDo == 'string' && whatToDo == 'keyless') {
|
|
256
|
+
/*
|
|
257
|
+
* Currently non-anonymous data owners aren't allowed to use keyless mode.
|
|
258
|
+
* Today the delegator is not emitted in views and is not used for access control: an entity without delegation
|
|
259
|
+
* self->self but only a delegation self->other would not be searchable by nor accessible to an explicit data
|
|
260
|
+
* owner.
|
|
261
|
+
* This is not a problem for anonymous data owner, since search and access control use the secure delegation
|
|
262
|
+
* key.
|
|
263
|
+
* Since keyless api was designed for use by patients this is not an issue at the time, but if in future we need
|
|
264
|
+
* to support keyless api for explicit data owner before updating views we can add stubs to legacy delegations.
|
|
265
|
+
*/
|
|
266
|
+
if (!this.selfIsAnonymous)
|
|
267
|
+
throw new Error('Keyless api mode is available only for anonymous data owners.');
|
|
255
268
|
this.keysCache = keysCache;
|
|
256
269
|
return undefined;
|
|
257
270
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserEncryptionKeysManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/UserEncryptionKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+BAA2C;AAC3C,oCAAiC;AAEjC,mCAAuC;AAKvC,yEAA8F;AAgB9F,MAAM,8BAA8B,GAA4B,CAAC,CAAC,EAAE,EAAE,CACpE,OAAO,CAAC,OAAO,CACb,CAAC,CAAC,MAAM,CACN,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,iCAAM,GAAG,KAAE,CAAC,SAAS,CAAC,SAAS,CAAC,EAAG,CAAC,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,IAAG,EAC3G,EAKC,CACF,CACF,CAAA;AAGH;;GAEG;AACH,MAAa,yBAAyB;IAKpC,YACmB,UAA4B,EAC5B,YAA8B,EAC9B,YAAgC,EAChC,WAAwB,EACxB,UAA4B,EAC5B,oBAA6B,EAC7B,gBAAkC;QANlC,eAAU,GAAV,UAAU,CAAkB;QAC5B,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,iBAAY,GAAZ,YAAY,CAAoB;QAChC,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAkB;QAC5B,yBAAoB,GAApB,oBAAoB,CAAS;QAC7B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAT7C,cAAS,GAA2F,SAAS,CAAA;IAUlH,CAAC;IAEJ;;;;;;;OAOG;IACG,wCAAwC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AM,KAAK,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,MAAM;gBAC7G,sBAAsB,CAAC,MAAM,GAAG,CAAC,EACjC;gBACA,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAA;gBACxG,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;oBACtD,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;iBAC3C;aACF;YACD,OAAO,UAAU,CAAA;QACnB,CAAC;KAAA;IAEO,qBAAqB,CAAI,GAAyC;QACxE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAA,qBAAa,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACvF,CAAC;IAEO,cAAc,CAAC,QAAuC;QAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAA;IACxE,CAAC;CACF;AAvZD,8DAuZC","sourcesContent":["import { DataOwnerOrStub, IccDataOwnerXApi } from '../icc-data-owner-x-api'\nimport { KeyPair, ShaVersion } from './RSA'\nimport { ua2hex } from '../utils'\nimport { IcureStorageFacade } from '../storage/IcureStorageFacade'\nimport { fingerprintV1 } from './utils'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { KeyRecovery } from './KeyRecovery'\nimport { CryptoStrategies } from './CryptoStrategies'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { CryptoActorStub, CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { KeyPairRecoverer } from './KeyPairRecoverer'\n\ntype KeyPairData = { pair: KeyPair<CryptoKey>; isVerified: boolean; isDevice: boolean }\ntype KeyRecovererAndVerifier = (\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[]\n) => Promise<{\n [dataOwnerId: string]: {\n recoveredKeys: { [keyPairFingerprint: string]: KeyPair<CryptoKey> }\n keyAuthenticity: { [keyPairFingerprint: string]: boolean }\n }\n}>\nconst nothingKeyRecovererAndVerifier: KeyRecovererAndVerifier = (x) =>\n Promise.resolve(\n x.reduce(\n (acc, { dataOwner }) => ({ ...acc, [dataOwner.dataOwner.id!]: { recoveredKeys: {}, keyAuthenticity: {} } }),\n {} as {\n [dataOwnerId: string]: {\n recoveredKeys: { [keyPairFingerprint: string]: KeyPair<CryptoKey> }\n keyAuthenticity: { [keyPairFingerprint: string]: boolean }\n }\n }\n )\n )\ntype CurrentOwnerKeyGenerator = (self: DataOwnerWithType) => Promise<KeyPair<CryptoKey> | boolean | 'keyless'>\n\n/**\n * Allows to manage public and private keys for the current user and his parent hierarchy.\n */\nexport class UserEncryptionKeysManager {\n private selfId: string | undefined\n private selfLegacyPublicKey: string | undefined\n private keysCache: { [selfOrParentId: string]: { [pubKeyFingerprint: string]: KeyPairData } } | undefined = undefined\n\n constructor(\n private readonly primitives: CryptoPrimitives,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly icureStorage: IcureStorageFacade,\n private readonly keyRecovery: KeyRecovery,\n private readonly strategies: CryptoStrategies,\n private readonly initialiseParentKeys: boolean,\n private readonly keypairRecoverer: KeyPairRecoverer\n ) {}\n\n /**\n * @internal\n * Get all key pairs available for the current data owner and his parents.\n * @return an object with:\n * - `self` an object containing the current data owner id and the list of key pairs available for the current data owner with verification details.\n * - `parents` the list of parents to the current data owner with the list of key pairs available for each parent. The list is ordered from the\n * topmost ancestor (at index 0) to the direct parent of the current data owner (at the last index, may be 0).\n */\n async getCurrentUserHierarchyAvailableKeypairs(): Promise<{\n self: {\n dataOwnerId: string\n keys: { pair: KeyPair<CryptoKey>; verified: boolean }[]\n }\n parents: {\n dataOwnerId: string\n keys: { pair: KeyPair<CryptoKey>; verified: boolean }[]\n }[]\n }> {\n this.ensureInitialised()\n const hierarchy = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()\n const selfId = hierarchy[hierarchy.length - 1]\n const selfKeys = Object.values(this.keysCache![selfId]).map(({ pair, isVerified, isDevice }) => ({ pair, verified: isVerified || isDevice }))\n const remainingHierarchy = hierarchy.slice(0, hierarchy.length - 1)\n return {\n self: {\n dataOwnerId: selfId,\n keys: selfKeys,\n },\n parents: remainingHierarchy.map((x) => ({\n dataOwnerId: x,\n keys: Object.values(this.keysCache![x]).map(({ pair, isVerified, isDevice }) => ({ pair, verified: isVerified || isDevice })),\n })),\n }\n }\n\n /**\n * Get the public keys of available key pairs for the current user in hex-encoded spki representation (uses cached keys: no request is done to the\n * server).\n * By setting {@link verifiedOnly} to true only the public keys for verified key pairs will be returned: these will include only key pairs created\n * on this device or which have been verified using {@link CryptoStrategies} on this device.\n * @param verifiedOnly if true only the verified public keys will be returned.\n * @return the spki representation of public keys of available keypairs for the current user.\n */\n async getCurrentUserAvailablePublicKeysHex(verifiedOnly: boolean): Promise<string[]> {\n this.ensureInitialised()\n let selectedData = Object.values(this.keysCache![this.selfId!])\n if (verifiedOnly) {\n selectedData = selectedData.filter((data) => data.isVerified || data.isDevice)\n }\n return await Promise.all(selectedData.map(async (keyData) => ua2hex(await this.primitives.RSA.exportKey(keyData.pair.publicKey, 'spki'))))\n }\n\n /**\n * Get the public keys of available key pairs for the current user and his parents in hex-encoded spki representation (uses cached keys: no request\n * is done to the server).\n * Note that this will also include unverified keys.\n * @return the spki representation of public keys of available keypairs for the current user.\n */\n async getCurrentUserHierarchyAvailablePublicKeysHex(): Promise<string[]> {\n return await Promise.all(\n Object.values(this.keysCache!)\n .flatMap((pairsForParent) => Object.values(pairsForParent))\n .map(async (keyPairData) => ua2hex(await this.primitives.RSA.exportKey(keyPairData.pair.publicKey, 'spki')))\n )\n }\n\n /**\n * Get a key pair with the provided fingerprint if present.\n * @param fingerprint a key-pair/public-key fingerprint\n * @return the pair associated to the fingerprint and a boolean indicating if the pair is verified, if present, else undefined\n */\n getKeyPairForFingerprint(fingerprint: string): { pair: KeyPair<CryptoKey>; verified: boolean } | undefined {\n const foundVerified = this.getSelfVerifiedKeys().find((x) => x.fingerprint === fingerprint)\n if (foundVerified) return { pair: foundVerified.pair, verified: true }\n const foundOther = this.getDecryptionKeys()[fingerprint]\n if (foundOther) return { pair: foundOther, verified: false }\n return undefined\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Initializes all keys for the current data owner. This method needs to be called before any other method of this class can be used.\n * @throws if the current user is not a data owner, or if there is no key and no new key could be created according to this manager crypt\n * strategies.\n * @return if a new key was created during initialisation the newly created key, else undefined.\n */\n async initialiseKeys(): Promise<{ newKeyPair: KeyPair<CryptoKey>; newKeyFingerprint: string } | undefined> {\n const newKey = await this.doLoadKeys(\n (x) => this.strategies.recoverAndVerifySelfHierarchyKeys(x, this.primitives, this.keypairRecoverer),\n (x) => this.strategies.generateNewKeyForDataOwner(x, this.primitives)\n )\n return newKey ? { newKeyPair: newKey.pair, newKeyFingerprint: newKey.fingerprint } : undefined\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Forces to reload keys for the current data owner. This could be useful if the data owner has logged in from another device in order to update the\n * transfer keys.\n * This method will complete only after keys have been reloaded successfully.\n */\n async reloadKeys(): Promise<void> {\n await this.doLoadKeys(nothingKeyRecovererAndVerifier, (x) => {\n throw new Error(\"Can't create new keys at reload time: it should have already been created on initialisation\")\n })\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Get all verified key pairs for the current data owner which can safely be used for encryption. This includes all key pairs created on the current\n * device and all recovered key pairs which have been verified.\n * The keys returned by this method will be in the following order:\n * 1. Legacy key pair if it is verified\n * 2. All device key pais, in alphabetical order according to the fingerprint\n * 3. Other verified key pairs, in alphabetical order according to the fingerprint\n * @return all verified keys, in order.\n */\n getSelfVerifiedKeys(): { fingerprint: string; pair: KeyPair<CryptoKey> }[] {\n this.ensureInitialised()\n const selfKeys = this.keysCache![this.selfId!]\n const allKeysEntries = Object.entries(selfKeys)\n\n const legacyKeyFp = this.selfLegacyPublicKey && fingerprintV1(this.selfLegacyPublicKey)\n const legacyKeyData = legacyKeyFp ? selfKeys[legacyKeyFp] : undefined\n const legacyEntry = legacyKeyData?.isVerified && legacyKeyFp ? [{ fingerprint: legacyKeyFp, pair: legacyKeyData.pair }] : []\n\n function filteredEntries(filterFunction: (fp: string, data: KeyPairData) => boolean) {\n return allKeysEntries\n .filter(([fp, data]) => filterFunction(fp, data) && fp !== legacyKeyFp)\n .sort(([a], [b]) => {\n // need to make sure that the comparison is independent of the locale, but the actual ordering is not that important\n return a == b ? 0 : a > b ? 1 : -1\n })\n .map(([fingerprint, { pair }]) => ({ fingerprint, pair }))\n }\n return [...legacyEntry, ...filteredEntries((_, data) => data.isDevice), ...filteredEntries((_, data) => !data.isDevice && data.isVerified)]\n }\n\n /**\n * Get all verified keys for a member of the current data owner hierarchy in no particular order.\n * @param dataOwner the current data owner or a member of his hierarchy.\n * @throws if the provided data owner is not part of the current data owner hierarchy\n */\n async getVerifiedPublicKeysFor(dataOwner: DataOwnerOrStub): Promise<string[]> {\n this.ensureInitialised()\n const availableKeys = this.keysCache![dataOwner.id!]\n if (!availableKeys) throw new Error(`Data owner ${dataOwner.id} is not part of the hierarchy of the current data owner ${this.selfId}`)\n const availableVerifiedKeysFp = new Set(Object.entries(availableKeys).flatMap(([fp, info]) => (info.isVerified || info.isDevice ? [fp] : [])))\n const otherVerifiedFp = new Set(\n Object.entries(await this.icureStorage.loadSelfVerifiedKeys(dataOwner.id!)).flatMap(([fp, verified]) => (verified ? [fp] : []))\n )\n return Array.from([\n ...this.dataOwnerApi.getHexPublicKeysWithSha1Of(dataOwner),\n ...this.dataOwnerApi.getHexPublicKeysWithSha256Of(dataOwner),\n ]).filter((key) => {\n const fp = fingerprintV1(key)\n return availableVerifiedKeysFp.has(fp) || otherVerifiedFp.has(fp)\n })\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Get all key pairs for the current data owner and his parents. These keys should be used only for decryption as they may have not been verified.\n * @return all key pairs available for decryption.\n */\n getDecryptionKeys(): { [fingerprint: string]: KeyPair<CryptoKey> } {\n this.ensureInitialised()\n return Object.values(this.keysCache!).reduce((acc, curr) => {\n return {\n ...acc,\n ...this.plainKeysByFingerprint(curr),\n }\n }, {} as { [fp: string]: KeyPair<CryptoKey> })\n }\n\n private async doLoadKeys(\n keyRecovererAndVerifier: KeyRecovererAndVerifier,\n currentOwnerKeyGenerator: CurrentOwnerKeyGenerator\n ): Promise<{ pair: KeyPair<CryptoKey>; fingerprint: string } | undefined> {\n // Load all keys for self from key store\n const hierarchy = (await this.dataOwnerApi.getCurrentDataOwnerHierarchy()).map(({ dataOwner, type }) => {\n if (dataOwner.publicKey == '') {\n if (Object.entries(dataOwner.hcPartyKeys ?? {}).length > 0)\n throw new Error(`Data owner ${dataOwner.id} has \"\" as public key but has non-empty hcPartyKeys`)\n delete dataOwner.publicKey\n }\n return {\n dataOwner,\n type,\n } as DataOwnerWithType\n })\n const self = hierarchy[hierarchy.length - 1]\n this.selfId = self.dataOwner.id!\n const keysData = []\n for (const dowt of this.initialiseParentKeys ? hierarchy : [self]) {\n const availableKeys = await this.loadAndRecoverKeysFor(dowt)\n const availableKeysFpSet = new Set(Object.keys(availableKeys))\n const verifiedKeysMap = await this.icureStorage.loadSelfVerifiedKeys(dowt.dataOwner.id!)\n const allPublicKeys = new Set([\n ...this.dataOwnerApi.getHexPublicKeysWithSha1Of(dowt.dataOwner),\n ...this.dataOwnerApi.getHexPublicKeysWithSha256Of(dowt.dataOwner),\n ])\n const unavailableKeys = Array.from(allPublicKeys).flatMap((key) => {\n return availableKeysFpSet.has(fingerprintV1(key)) ? [] : [key]\n })\n const unknownKeys = Array.from(allPublicKeys).filter(\n (x) => !(fingerprintV1(x) in verifiedKeysMap) && !(availableKeys?.[fingerprintV1(x)]?.isDevice === true)\n )\n keysData.push({ dowt, availableKeys, unavailableKeys, unknownKeys })\n }\n const recoveryInfo = keysData.map(({ dowt, unavailableKeys, unknownKeys }) => ({ dataOwner: dowt, unavailableKeys, unknownKeys }))\n const recoveryAndVerificationResult = recoveryInfo.some((x) => x.unavailableKeys.length > 0 || x.unknownKeys.length > 0)\n ? await keyRecovererAndVerifier(recoveryInfo)\n : await nothingKeyRecovererAndVerifier(recoveryInfo)\n const keysCache: { [dataOwnerId: string]: { [fp: string]: KeyPairData } } = {}\n for (const keyData of keysData) {\n const currAuthenticity = this.ensureFingerprintKeys(recoveryAndVerificationResult[keyData.dowt.dataOwner.id!].keyAuthenticity)\n const currExternallyRecovered = this.ensureFingerprintKeys(recoveryAndVerificationResult[keyData.dowt.dataOwner.id!].recoveredKeys)\n for (const [fp, keyPair] of Object.entries(currExternallyRecovered)) {\n const jwkPair = await this.primitives.RSA.exportKeys(keyPair, 'jwk', 'jwk')\n await this.icureStorage.saveKey(keyData.dowt.dataOwner.id!, fp, jwkPair, true)\n }\n const updatedVerifiedMap = await this.icureStorage.saveSelfVerifiedKeys(\n keyData.dowt.dataOwner.id!,\n [...Object.keys(currAuthenticity), ...Object.keys(currExternallyRecovered)].reduce(\n (acc, currFp) => ({\n ...acc,\n [currFp]: currFp in currExternallyRecovered || currAuthenticity[currFp],\n }),\n {}\n )\n )\n const keysWithExternallyRecovered = {\n ...keyData.availableKeys,\n ...Object.fromEntries(Object.entries(currExternallyRecovered).map(([k, v]) => [k, { pair: v, isDevice: false }])),\n }\n const additionallyRecovered = await this.recoverAndCacheKeys(keyData.dowt, this.plainKeysByFingerprint(keysWithExternallyRecovered))\n const keys = {\n ...keysWithExternallyRecovered,\n ...Object.fromEntries(Object.entries(additionallyRecovered).map(([k, v]) => [k, { pair: v, isDevice: false }])),\n }\n keysCache[keyData.dowt.dataOwner.id!] = this.verifyKeys(keys, updatedVerifiedMap)\n }\n if (Object.entries(keysCache).some(([ownerId, data]) => ownerId !== self.dataOwner.id && !this.hasVerifiedKey(data))) {\n throw new Error('Some parent hcps have no verified keys: impossible to generate locally a new key for a parent.')\n } else if (this.hasVerifiedKey(keysCache[self.dataOwner.id!])) {\n this.keysCache = keysCache\n this.selfLegacyPublicKey = self.dataOwner.publicKey\n return undefined\n } else {\n const whatToDo = await currentOwnerKeyGenerator(self)\n if (whatToDo === false) {\n throw new Error(`No verified key found for ${self.dataOwner.id} and settings do not allow creation of a new key.`)\n } else if (typeof whatToDo == 'string' && whatToDo == 'keyless') {\n this.keysCache = keysCache\n return undefined\n } else {\n const updateInfo = await this.createAndSaveNewKeyPair(whatToDo === true ? undefined : whatToDo, self)\n // self may be outdated now\n this.selfLegacyPublicKey = updateInfo.updatedSelf.stub.publicKey\n this.keysCache = {\n ...keysCache,\n [self.dataOwner.id!]: {\n ...keysCache[self.dataOwner.id!],\n [updateInfo.publicKeyFingerprint]: { pair: updateInfo.keyPair, isDevice: true, isVerified: true },\n },\n }\n return { pair: updateInfo.keyPair, fingerprint: updateInfo.publicKeyFingerprint }\n }\n }\n }\n\n private async createAndSaveNewKeyPair(\n importedKeyPair: undefined | KeyPair<CryptoKey>,\n selfDataOwner: DataOwnerWithType\n ): Promise<{ publicKeyFingerprint: string; keyPair: KeyPair<CryptoKey>; updatedSelf: CryptoActorStubWithType }> {\n const keyPair = importedKeyPair ?? (await this.primitives.RSA.generateKeyPair(ShaVersion.Sha256))\n const publicKeyHex = ua2hex(await this.primitives.RSA.exportKey(keyPair.publicKey, 'spki'))\n const jwKey = await this.primitives.RSA.exportKey(keyPair.publicKey, 'jwk')\n if (jwKey.alg !== 'RSA-OAEP-256') {\n throw new Error('Only keys generated with SHA-256 are currently supported')\n }\n const publicKeyFingerprint = fingerprintV1(publicKeyHex)\n await this.icureStorage.saveKey(\n selfDataOwner.dataOwner.id!,\n publicKeyFingerprint,\n await this.primitives.RSA.exportKeys(keyPair, 'jwk', 'jwk'),\n true\n )\n await this.icureStorage.saveSelfVerifiedKeys(selfDataOwner.dataOwner.id!, { [publicKeyFingerprint]: true })\n const updatedSelf = await this.dataOwnerApi.modifyCryptoActorStub({\n stub: {\n ...CryptoActorStub.fromDataOwner(selfDataOwner.dataOwner),\n publicKeysForOaepWithSha256: [...(selfDataOwner.dataOwner.publicKeysForOaepWithSha256 ?? []), publicKeyHex],\n },\n type: selfDataOwner.type,\n })\n return { publicKeyFingerprint, keyPair: keyPair, updatedSelf }\n }\n\n private async loadStoredKeys(\n dataOwner: DataOwnerWithType,\n pubKeysFingerprints: { [key: string]: string[] }\n ): Promise<{ [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } }> {\n const pubKeysFingerprintsWithVersion = Object.entries(pubKeysFingerprints).flatMap(([shaVersion, fps]) => {\n return fps.map((fp) => [shaVersion, fp] as [ShaVersion, string])\n })\n return await pubKeysFingerprintsWithVersion.reduce(async (acc, [shaVersion, currentFingerprint]) => {\n const awaitedAcc = await acc\n let loadedPair: { pair: KeyPair<CryptoKey>; isDevice: boolean } | undefined = undefined\n try {\n const storedKeypair = await this.icureStorage.loadKey(dataOwner.dataOwner.id!, currentFingerprint, dataOwner.dataOwner.publicKey)\n if (!!storedKeypair) {\n const importedKey = await this.primitives.RSA.importKeyPair(\n 'jwk',\n storedKeypair.pair.privateKey,\n 'jwk',\n storedKeypair.pair.publicKey,\n shaVersion\n )\n loadedPair = { pair: importedKey, isDevice: storedKeypair.isDevice }\n }\n } catch (e) {\n console.warn('Error while loading keypair', currentFingerprint, e)\n }\n return loadedPair\n ? {\n ...awaitedAcc,\n [currentFingerprint]: loadedPair,\n }\n : awaitedAcc\n }, Promise.resolve({} as { [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } }))\n }\n\n private verifyKeys(\n keys: { [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } },\n verifiedKeysMap: { [pubKeyFingerprint: string]: boolean }\n ): { [pubKeyFingerprint: string]: KeyPairData } {\n return Object.fromEntries(\n Object.entries(keys).map(\n ([fp, keyData]) => [fp, { ...keyData, isVerified: keyData.isDevice || verifiedKeysMap?.[fp] === true }] as [string, KeyPairData]\n )\n )\n }\n\n private plainKeysByFingerprint(richKeys: { [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey> } }): {\n [pubKeyFingerprint: string]: KeyPair<CryptoKey>\n } {\n return Object.fromEntries(Object.entries(richKeys).map(([fp, keyData]) => [fp, keyData.pair]))\n }\n\n private ensureInitialised() {\n if (!this.keysCache) throw new Error('Key manager was not properly initialised')\n }\n\n private async recoverAndCacheKeys(\n dataOwner: DataOwnerWithType,\n availableKeys: { [pubKeyFingerprint: string]: KeyPair<CryptoKey> }\n ): Promise<{ [p: string]: KeyPair<CryptoKey> }> {\n const recoveredKeys = await this.keyRecovery.recoverKeys(dataOwner, availableKeys)\n for (const [fp, pair] of Object.entries(recoveredKeys)) {\n await this.icureStorage.saveKey(dataOwner.dataOwner.id!, fp, await this.primitives.RSA.exportKeys(pair, 'jwk', 'jwk'), false)\n }\n return recoveredKeys\n }\n\n private async loadAndRecoverKeysFor(dataOwner: DataOwnerWithType): Promise<{ [keyFp: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } }> {\n const pubKeysFingerprints = {\n 'sha-1': [...new Set(this.dataOwnerApi.getHexPublicKeysWithSha1Of(dataOwner.dataOwner))].map((x) => fingerprintV1(x)),\n 'sha-256': [...new Set(this.dataOwnerApi.getHexPublicKeysWithSha256Of(dataOwner.dataOwner))].map((x) => fingerprintV1(x)),\n }\n const loadedKeys =\n pubKeysFingerprints['sha-1'].length + pubKeysFingerprints['sha-256'].length > 0 ? await this.loadStoredKeys(dataOwner, pubKeysFingerprints) : {}\n const loadedKeysFingerprints = Object.keys(loadedKeys)\n if (\n loadedKeysFingerprints.length !== pubKeysFingerprints['sha-1'].length + pubKeysFingerprints['sha-256'].length &&\n loadedKeysFingerprints.length > 0\n ) {\n const recoveredKeys = await this.recoverAndCacheKeys(dataOwner, this.plainKeysByFingerprint(loadedKeys))\n for (const [fp, pair] of Object.entries(recoveredKeys)) {\n loadedKeys[fp] = { pair, isDevice: false }\n }\n }\n return loadedKeys\n }\n\n private ensureFingerprintKeys<T>(obj: { [shouldBeFingerprint: string]: T }): { [definitelyFingerprint: string]: T } {\n return Object.fromEntries(Object.entries(obj).map(([k, v]) => [fingerprintV1(k), v]))\n }\n\n private hasVerifiedKey(keysData: { [fp: string]: KeyPairData }) {\n return Object.values(keysData).some((x) => x.isVerified || x.isDevice)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UserEncryptionKeysManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/UserEncryptionKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+BAA2C;AAC3C,oCAAiC;AAEjC,mCAAuC;AAKvC,yEAA8F;AAgB9F,MAAM,8BAA8B,GAA4B,CAAC,CAAC,EAAE,EAAE,CACpE,OAAO,CAAC,OAAO,CACb,CAAC,CAAC,MAAM,CACN,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,iCAAM,GAAG,KAAE,CAAC,SAAS,CAAC,SAAS,CAAC,EAAG,CAAC,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,IAAG,EAC3G,EAKC,CACF,CACF,CAAA;AAGH;;GAEG;AACH,MAAa,yBAAyB;IAKpC,YACmB,UAA4B,EAC5B,YAA8B,EAC9B,YAAgC,EAChC,WAAwB,EACxB,UAA4B,EAC5B,oBAA6B,EAC7B,gBAAkC,EAClC,eAAwB;QAPxB,eAAU,GAAV,UAAU,CAAkB;QAC5B,iBAAY,GAAZ,YAAY,CAAk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IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAA;IACxE,CAAC;CACF;AAnaD,8DAmaC","sourcesContent":["import { DataOwnerOrStub, IccDataOwnerXApi } from '../icc-data-owner-x-api'\nimport { KeyPair, ShaVersion } from './RSA'\nimport { ua2hex } from '../utils'\nimport { IcureStorageFacade } from '../storage/IcureStorageFacade'\nimport { fingerprintV1 } from './utils'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { KeyRecovery } from './KeyRecovery'\nimport { CryptoStrategies } from './CryptoStrategies'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { CryptoActorStub, CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { KeyPairRecoverer } from './KeyPairRecoverer'\n\ntype KeyPairData = { pair: KeyPair<CryptoKey>; isVerified: boolean; isDevice: boolean }\ntype KeyRecovererAndVerifier = (\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[]\n) => Promise<{\n [dataOwnerId: string]: {\n recoveredKeys: { [keyPairFingerprint: string]: KeyPair<CryptoKey> }\n keyAuthenticity: { [keyPairFingerprint: string]: boolean }\n }\n}>\nconst nothingKeyRecovererAndVerifier: KeyRecovererAndVerifier = (x) =>\n Promise.resolve(\n x.reduce(\n (acc, { dataOwner }) => ({ ...acc, [dataOwner.dataOwner.id!]: { recoveredKeys: {}, keyAuthenticity: {} } }),\n {} as {\n [dataOwnerId: string]: {\n recoveredKeys: { [keyPairFingerprint: string]: KeyPair<CryptoKey> }\n keyAuthenticity: { [keyPairFingerprint: string]: boolean }\n }\n }\n )\n )\ntype CurrentOwnerKeyGenerator = (self: DataOwnerWithType) => Promise<KeyPair<CryptoKey> | boolean | 'keyless'>\n\n/**\n * Allows to manage public and private keys for the current user and his parent hierarchy.\n */\nexport class UserEncryptionKeysManager {\n private selfId: string | undefined\n private selfLegacyPublicKey: string | undefined\n private keysCache: { [selfOrParentId: string]: { [pubKeyFingerprint: string]: KeyPairData } } | undefined = undefined\n\n constructor(\n private readonly primitives: CryptoPrimitives,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly icureStorage: IcureStorageFacade,\n private readonly keyRecovery: KeyRecovery,\n private readonly strategies: CryptoStrategies,\n private readonly initialiseParentKeys: boolean,\n private readonly keypairRecoverer: KeyPairRecoverer,\n private readonly selfIsAnonymous: boolean\n ) {}\n\n /**\n * @internal\n * Get all key pairs available for the current data owner and his parents.\n * @return an object with:\n * - `self` an object containing the current data owner id and the list of key pairs available for the current data owner with verification details.\n * - `parents` the list of parents to the current data owner with the list of key pairs available for each parent. The list is ordered from the\n * topmost ancestor (at index 0) to the direct parent of the current data owner (at the last index, may be 0).\n */\n async getCurrentUserHierarchyAvailableKeypairs(): Promise<{\n self: {\n dataOwnerId: string\n keys: { pair: KeyPair<CryptoKey>; verified: boolean }[]\n }\n parents: {\n dataOwnerId: string\n keys: { pair: KeyPair<CryptoKey>; verified: boolean }[]\n }[]\n }> {\n this.ensureInitialised()\n const hierarchy = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()\n const selfId = hierarchy[hierarchy.length - 1]\n const selfKeys = Object.values(this.keysCache![selfId]).map(({ pair, isVerified, isDevice }) => ({ pair, verified: isVerified || isDevice }))\n const remainingHierarchy = hierarchy.slice(0, hierarchy.length - 1)\n return {\n self: {\n dataOwnerId: selfId,\n keys: selfKeys,\n },\n parents: remainingHierarchy.map((x) => ({\n dataOwnerId: x,\n keys: Object.values(this.keysCache![x]).map(({ pair, isVerified, isDevice }) => ({ pair, verified: isVerified || isDevice })),\n })),\n }\n }\n\n /**\n * Get the public keys of available key pairs for the current user in hex-encoded spki representation (uses cached keys: no request is done to the\n * server).\n * By setting {@link verifiedOnly} to true only the public keys for verified key pairs will be returned: these will include only key pairs created\n * on this device or which have been verified using {@link CryptoStrategies} on this device.\n * @param verifiedOnly if true only the verified public keys will be returned.\n * @return the spki representation of public keys of available keypairs for the current user.\n */\n async getCurrentUserAvailablePublicKeysHex(verifiedOnly: boolean): Promise<string[]> {\n this.ensureInitialised()\n let selectedData = Object.values(this.keysCache![this.selfId!])\n if (verifiedOnly) {\n selectedData = selectedData.filter((data) => data.isVerified || data.isDevice)\n }\n return await Promise.all(selectedData.map(async (keyData) => ua2hex(await this.primitives.RSA.exportKey(keyData.pair.publicKey, 'spki'))))\n }\n\n /**\n * Get the public keys of available key pairs for the current user and his parents in hex-encoded spki representation (uses cached keys: no request\n * is done to the server).\n * Note that this will also include unverified keys.\n * @return the spki representation of public keys of available keypairs for the current user.\n */\n async getCurrentUserHierarchyAvailablePublicKeysHex(): Promise<string[]> {\n return await Promise.all(\n Object.values(this.keysCache!)\n .flatMap((pairsForParent) => Object.values(pairsForParent))\n .map(async (keyPairData) => ua2hex(await this.primitives.RSA.exportKey(keyPairData.pair.publicKey, 'spki')))\n )\n }\n\n /**\n * Get a key pair with the provided fingerprint if present.\n * @param fingerprint a key-pair/public-key fingerprint\n * @return the pair associated to the fingerprint and a boolean indicating if the pair is verified, if present, else undefined\n */\n getKeyPairForFingerprint(fingerprint: string): { pair: KeyPair<CryptoKey>; verified: boolean } | undefined {\n const foundVerified = this.getSelfVerifiedKeys().find((x) => x.fingerprint === fingerprint)\n if (foundVerified) return { pair: foundVerified.pair, verified: true }\n const foundOther = this.getDecryptionKeys()[fingerprint]\n if (foundOther) return { pair: foundOther, verified: false }\n return undefined\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Initializes all keys for the current data owner. This method needs to be called before any other method of this class can be used.\n * @throws if the current user is not a data owner, or if there is no key and no new key could be created according to this manager crypt\n * strategies.\n * @return if a new key was created during initialisation the newly created key, else undefined.\n */\n async initialiseKeys(): Promise<{ newKeyPair: KeyPair<CryptoKey>; newKeyFingerprint: string } | undefined> {\n const newKey = await this.doLoadKeys(\n (x) => this.strategies.recoverAndVerifySelfHierarchyKeys(x, this.primitives, this.keypairRecoverer),\n (x) => this.strategies.generateNewKeyForDataOwner(x, this.primitives)\n )\n return newKey ? { newKeyPair: newKey.pair, newKeyFingerprint: newKey.fingerprint } : undefined\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Forces to reload keys for the current data owner. This could be useful if the data owner has logged in from another device in order to update the\n * transfer keys.\n * This method will complete only after keys have been reloaded successfully.\n */\n async reloadKeys(): Promise<void> {\n await this.doLoadKeys(nothingKeyRecovererAndVerifier, (x) => {\n throw new Error(\"Can't create new keys at reload time: it should have already been created on initialisation\")\n })\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Get all verified key pairs for the current data owner which can safely be used for encryption. This includes all key pairs created on the current\n * device and all recovered key pairs which have been verified.\n * The keys returned by this method will be in the following order:\n * 1. Legacy key pair if it is verified\n * 2. All device key pais, in alphabetical order according to the fingerprint\n * 3. Other verified key pairs, in alphabetical order according to the fingerprint\n * @return all verified keys, in order.\n */\n getSelfVerifiedKeys(): { fingerprint: string; pair: KeyPair<CryptoKey> }[] {\n this.ensureInitialised()\n const selfKeys = this.keysCache![this.selfId!]\n const allKeysEntries = Object.entries(selfKeys)\n\n const legacyKeyFp = this.selfLegacyPublicKey && fingerprintV1(this.selfLegacyPublicKey)\n const legacyKeyData = legacyKeyFp ? selfKeys[legacyKeyFp] : undefined\n const legacyEntry = legacyKeyData?.isVerified && legacyKeyFp ? [{ fingerprint: legacyKeyFp, pair: legacyKeyData.pair }] : []\n\n function filteredEntries(filterFunction: (fp: string, data: KeyPairData) => boolean) {\n return allKeysEntries\n .filter(([fp, data]) => filterFunction(fp, data) && fp !== legacyKeyFp)\n .sort(([a], [b]) => {\n // need to make sure that the comparison is independent of the locale, but the actual ordering is not that important\n return a == b ? 0 : a > b ? 1 : -1\n })\n .map(([fingerprint, { pair }]) => ({ fingerprint, pair }))\n }\n return [...legacyEntry, ...filteredEntries((_, data) => data.isDevice), ...filteredEntries((_, data) => !data.isDevice && data.isVerified)]\n }\n\n /**\n * Get all verified keys for a member of the current data owner hierarchy in no particular order.\n * @param dataOwner the current data owner or a member of his hierarchy.\n * @throws if the provided data owner is not part of the current data owner hierarchy\n */\n async getVerifiedPublicKeysFor(dataOwner: DataOwnerOrStub): Promise<string[]> {\n this.ensureInitialised()\n const availableKeys = this.keysCache![dataOwner.id!]\n if (!availableKeys) throw new Error(`Data owner ${dataOwner.id} is not part of the hierarchy of the current data owner ${this.selfId}`)\n const availableVerifiedKeysFp = new Set(Object.entries(availableKeys).flatMap(([fp, info]) => (info.isVerified || info.isDevice ? [fp] : [])))\n const otherVerifiedFp = new Set(\n Object.entries(await this.icureStorage.loadSelfVerifiedKeys(dataOwner.id!)).flatMap(([fp, verified]) => (verified ? [fp] : []))\n )\n return Array.from([\n ...this.dataOwnerApi.getHexPublicKeysWithSha1Of(dataOwner),\n ...this.dataOwnerApi.getHexPublicKeysWithSha256Of(dataOwner),\n ]).filter((key) => {\n const fp = fingerprintV1(key)\n return availableVerifiedKeysFp.has(fp) || otherVerifiedFp.has(fp)\n })\n }\n\n /**\n * @internal This method is intended for internal use only and may be changed without notice.\n * Get all key pairs for the current data owner and his parents. These keys should be used only for decryption as they may have not been verified.\n * @return all key pairs available for decryption.\n */\n getDecryptionKeys(): { [fingerprint: string]: KeyPair<CryptoKey> } {\n this.ensureInitialised()\n return Object.values(this.keysCache!).reduce((acc, curr) => {\n return {\n ...acc,\n ...this.plainKeysByFingerprint(curr),\n }\n }, {} as { [fp: string]: KeyPair<CryptoKey> })\n }\n\n private async doLoadKeys(\n keyRecovererAndVerifier: KeyRecovererAndVerifier,\n currentOwnerKeyGenerator: CurrentOwnerKeyGenerator\n ): Promise<{ pair: KeyPair<CryptoKey>; fingerprint: string } | undefined> {\n // Load all keys for self from key store\n const hierarchy = (await this.dataOwnerApi.getCurrentDataOwnerHierarchy()).map(({ dataOwner, type }) => {\n if (dataOwner.publicKey == '') {\n if (Object.entries(dataOwner.hcPartyKeys ?? {}).length > 0)\n throw new Error(`Data owner ${dataOwner.id} has \"\" as public key but has non-empty hcPartyKeys`)\n delete dataOwner.publicKey\n }\n return {\n dataOwner,\n type,\n } as DataOwnerWithType\n })\n const self = hierarchy[hierarchy.length - 1]\n this.selfId = self.dataOwner.id!\n const keysData = []\n for (const dowt of this.initialiseParentKeys ? hierarchy : [self]) {\n const availableKeys = await this.loadAndRecoverKeysFor(dowt)\n const availableKeysFpSet = new Set(Object.keys(availableKeys))\n const verifiedKeysMap = await this.icureStorage.loadSelfVerifiedKeys(dowt.dataOwner.id!)\n const allPublicKeys = new Set([\n ...this.dataOwnerApi.getHexPublicKeysWithSha1Of(dowt.dataOwner),\n ...this.dataOwnerApi.getHexPublicKeysWithSha256Of(dowt.dataOwner),\n ])\n const unavailableKeys = Array.from(allPublicKeys).flatMap((key) => {\n return availableKeysFpSet.has(fingerprintV1(key)) ? [] : [key]\n })\n const unknownKeys = Array.from(allPublicKeys).filter(\n (x) => !(fingerprintV1(x) in verifiedKeysMap) && !(availableKeys?.[fingerprintV1(x)]?.isDevice === true)\n )\n keysData.push({ dowt, availableKeys, unavailableKeys, unknownKeys })\n }\n const recoveryInfo = keysData.map(({ dowt, unavailableKeys, unknownKeys }) => ({ dataOwner: dowt, unavailableKeys, unknownKeys }))\n const recoveryAndVerificationResult = recoveryInfo.some((x) => x.unavailableKeys.length > 0 || x.unknownKeys.length > 0)\n ? await keyRecovererAndVerifier(recoveryInfo)\n : await nothingKeyRecovererAndVerifier(recoveryInfo)\n const keysCache: { [dataOwnerId: string]: { [fp: string]: KeyPairData } } = {}\n for (const keyData of keysData) {\n const currAuthenticity = this.ensureFingerprintKeys(recoveryAndVerificationResult[keyData.dowt.dataOwner.id!].keyAuthenticity)\n const currExternallyRecovered = this.ensureFingerprintKeys(recoveryAndVerificationResult[keyData.dowt.dataOwner.id!].recoveredKeys)\n for (const [fp, keyPair] of Object.entries(currExternallyRecovered)) {\n const jwkPair = await this.primitives.RSA.exportKeys(keyPair, 'jwk', 'jwk')\n await this.icureStorage.saveKey(keyData.dowt.dataOwner.id!, fp, jwkPair, true)\n }\n const updatedVerifiedMap = await this.icureStorage.saveSelfVerifiedKeys(\n keyData.dowt.dataOwner.id!,\n [...Object.keys(currAuthenticity), ...Object.keys(currExternallyRecovered)].reduce(\n (acc, currFp) => ({\n ...acc,\n [currFp]: currFp in currExternallyRecovered || currAuthenticity[currFp],\n }),\n {}\n )\n )\n const keysWithExternallyRecovered = {\n ...keyData.availableKeys,\n ...Object.fromEntries(Object.entries(currExternallyRecovered).map(([k, v]) => [k, { pair: v, isDevice: false }])),\n }\n const additionallyRecovered = await this.recoverAndCacheKeys(keyData.dowt, this.plainKeysByFingerprint(keysWithExternallyRecovered))\n const keys = {\n ...keysWithExternallyRecovered,\n ...Object.fromEntries(Object.entries(additionallyRecovered).map(([k, v]) => [k, { pair: v, isDevice: false }])),\n }\n keysCache[keyData.dowt.dataOwner.id!] = this.verifyKeys(keys, updatedVerifiedMap)\n }\n if (Object.entries(keysCache).some(([ownerId, data]) => ownerId !== self.dataOwner.id && !this.hasVerifiedKey(data))) {\n throw new Error('Some parent hcps have no verified keys: impossible to generate locally a new key for a parent.')\n } else if (this.hasVerifiedKey(keysCache[self.dataOwner.id!])) {\n this.keysCache = keysCache\n this.selfLegacyPublicKey = self.dataOwner.publicKey\n return undefined\n } else {\n const whatToDo = await currentOwnerKeyGenerator(self)\n if (whatToDo === false) {\n throw new Error(`No verified key found for ${self.dataOwner.id} and settings do not allow creation of a new key.`)\n } else if (typeof whatToDo == 'string' && whatToDo == 'keyless') {\n /*\n * Currently non-anonymous data owners aren't allowed to use keyless mode.\n * Today the delegator is not emitted in views and is not used for access control: an entity without delegation\n * self->self but only a delegation self->other would not be searchable by nor accessible to an explicit data\n * owner.\n * This is not a problem for anonymous data owner, since search and access control use the secure delegation\n * key.\n * Since keyless api was designed for use by patients this is not an issue at the time, but if in future we need\n * to support keyless api for explicit data owner before updating views we can add stubs to legacy delegations.\n */\n if (!this.selfIsAnonymous) throw new Error('Keyless api mode is available only for anonymous data owners.')\n this.keysCache = keysCache\n return undefined\n } else {\n const updateInfo = await this.createAndSaveNewKeyPair(whatToDo === true ? undefined : whatToDo, self)\n // self may be outdated now\n this.selfLegacyPublicKey = updateInfo.updatedSelf.stub.publicKey\n this.keysCache = {\n ...keysCache,\n [self.dataOwner.id!]: {\n ...keysCache[self.dataOwner.id!],\n [updateInfo.publicKeyFingerprint]: { pair: updateInfo.keyPair, isDevice: true, isVerified: true },\n },\n }\n return { pair: updateInfo.keyPair, fingerprint: updateInfo.publicKeyFingerprint }\n }\n }\n }\n\n private async createAndSaveNewKeyPair(\n importedKeyPair: undefined | KeyPair<CryptoKey>,\n selfDataOwner: DataOwnerWithType\n ): Promise<{ publicKeyFingerprint: string; keyPair: KeyPair<CryptoKey>; updatedSelf: CryptoActorStubWithType }> {\n const keyPair = importedKeyPair ?? (await this.primitives.RSA.generateKeyPair(ShaVersion.Sha256))\n const publicKeyHex = ua2hex(await this.primitives.RSA.exportKey(keyPair.publicKey, 'spki'))\n const jwKey = await this.primitives.RSA.exportKey(keyPair.publicKey, 'jwk')\n if (jwKey.alg !== 'RSA-OAEP-256') {\n throw new Error('Only keys generated with SHA-256 are currently supported')\n }\n const publicKeyFingerprint = fingerprintV1(publicKeyHex)\n await this.icureStorage.saveKey(\n selfDataOwner.dataOwner.id!,\n publicKeyFingerprint,\n await this.primitives.RSA.exportKeys(keyPair, 'jwk', 'jwk'),\n true\n )\n await this.icureStorage.saveSelfVerifiedKeys(selfDataOwner.dataOwner.id!, { [publicKeyFingerprint]: true })\n const updatedSelf = await this.dataOwnerApi.modifyCryptoActorStub({\n stub: {\n ...CryptoActorStub.fromDataOwner(selfDataOwner.dataOwner),\n publicKeysForOaepWithSha256: [...(selfDataOwner.dataOwner.publicKeysForOaepWithSha256 ?? []), publicKeyHex],\n },\n type: selfDataOwner.type,\n })\n return { publicKeyFingerprint, keyPair: keyPair, updatedSelf }\n }\n\n private async loadStoredKeys(\n dataOwner: DataOwnerWithType,\n pubKeysFingerprints: { [key: string]: string[] }\n ): Promise<{ [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } }> {\n const pubKeysFingerprintsWithVersion = Object.entries(pubKeysFingerprints).flatMap(([shaVersion, fps]) => {\n return fps.map((fp) => [shaVersion, fp] as [ShaVersion, string])\n })\n return await pubKeysFingerprintsWithVersion.reduce(async (acc, [shaVersion, currentFingerprint]) => {\n const awaitedAcc = await acc\n let loadedPair: { pair: KeyPair<CryptoKey>; isDevice: boolean } | undefined = undefined\n try {\n const storedKeypair = await this.icureStorage.loadKey(dataOwner.dataOwner.id!, currentFingerprint, dataOwner.dataOwner.publicKey)\n if (!!storedKeypair) {\n const importedKey = await this.primitives.RSA.importKeyPair(\n 'jwk',\n storedKeypair.pair.privateKey,\n 'jwk',\n storedKeypair.pair.publicKey,\n shaVersion\n )\n loadedPair = { pair: importedKey, isDevice: storedKeypair.isDevice }\n }\n } catch (e) {\n console.warn('Error while loading keypair', currentFingerprint, e)\n }\n return loadedPair\n ? {\n ...awaitedAcc,\n [currentFingerprint]: loadedPair,\n }\n : awaitedAcc\n }, Promise.resolve({} as { [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } }))\n }\n\n private verifyKeys(\n keys: { [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } },\n verifiedKeysMap: { [pubKeyFingerprint: string]: boolean }\n ): { [pubKeyFingerprint: string]: KeyPairData } {\n return Object.fromEntries(\n Object.entries(keys).map(\n ([fp, keyData]) => [fp, { ...keyData, isVerified: keyData.isDevice || verifiedKeysMap?.[fp] === true }] as [string, KeyPairData]\n )\n )\n }\n\n private plainKeysByFingerprint(richKeys: { [pubKeyFingerprint: string]: { pair: KeyPair<CryptoKey> } }): {\n [pubKeyFingerprint: string]: KeyPair<CryptoKey>\n } {\n return Object.fromEntries(Object.entries(richKeys).map(([fp, keyData]) => [fp, keyData.pair]))\n }\n\n private ensureInitialised() {\n if (!this.keysCache) throw new Error('Key manager was not properly initialised')\n }\n\n private async recoverAndCacheKeys(\n dataOwner: DataOwnerWithType,\n availableKeys: { [pubKeyFingerprint: string]: KeyPair<CryptoKey> }\n ): Promise<{ [p: string]: KeyPair<CryptoKey> }> {\n const recoveredKeys = await this.keyRecovery.recoverKeys(dataOwner, availableKeys)\n for (const [fp, pair] of Object.entries(recoveredKeys)) {\n await this.icureStorage.saveKey(dataOwner.dataOwner.id!, fp, await this.primitives.RSA.exportKeys(pair, 'jwk', 'jwk'), false)\n }\n return recoveredKeys\n }\n\n private async loadAndRecoverKeysFor(dataOwner: DataOwnerWithType): Promise<{ [keyFp: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } }> {\n const pubKeysFingerprints = {\n 'sha-1': [...new Set(this.dataOwnerApi.getHexPublicKeysWithSha1Of(dataOwner.dataOwner))].map((x) => fingerprintV1(x)),\n 'sha-256': [...new Set(this.dataOwnerApi.getHexPublicKeysWithSha256Of(dataOwner.dataOwner))].map((x) => fingerprintV1(x)),\n }\n const loadedKeys =\n pubKeysFingerprints['sha-1'].length + pubKeysFingerprints['sha-256'].length > 0 ? await this.loadStoredKeys(dataOwner, pubKeysFingerprints) : {}\n const loadedKeysFingerprints = Object.keys(loadedKeys)\n if (\n loadedKeysFingerprints.length !== pubKeysFingerprints['sha-1'].length + pubKeysFingerprints['sha-256'].length &&\n loadedKeysFingerprints.length > 0\n ) {\n const recoveredKeys = await this.recoverAndCacheKeys(dataOwner, this.plainKeysByFingerprint(loadedKeys))\n for (const [fp, pair] of Object.entries(recoveredKeys)) {\n loadedKeys[fp] = { pair, isDevice: false }\n }\n }\n return loadedKeys\n }\n\n private ensureFingerprintKeys<T>(obj: { [shouldBeFingerprint: string]: T }): { [definitelyFingerprint: string]: T } {\n return Object.fromEntries(Object.entries(obj).map(([k, v]) => [fingerprintV1(k), v]))\n }\n\n private hasVerifiedKey(keysData: { [fp: string]: KeyPairData }) {\n return Object.values(keysData).some((x) => x.isVerified || x.isDevice)\n }\n}\n"]}
|
|
@@ -58,7 +58,7 @@ class IccBekmehrXApi extends icc_api_1.IccBekmehrApi {
|
|
|
58
58
|
const that = this;
|
|
59
59
|
const send = (command, uuid, body) => {
|
|
60
60
|
const data = JSON.stringify({ command, uuid, body });
|
|
61
|
-
socket.send(data.length > 65000 ? (0, binary_utils_1.
|
|
61
|
+
socket.send(data.length > 65000 ? (0, binary_utils_1.utf8_2ua)(data).buffer : data);
|
|
62
62
|
};
|
|
63
63
|
const messageHandler = (msg, event) => {
|
|
64
64
|
if (msg.command === 'decrypt') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-bekmehr-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-bekmehr-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,wCAA0C;AAI1C,uDAA2D;AAC3D,oDAAmF;AACnF,0EAAgG;AAoBhG,MAAa,cAAe,SAAQ,uBAAa;IAM/C,YACE,IAAY,EACZ,OAAkC,EAClC,MAAsB,EACtB,WAA4B,EAC5B,WAA4B,EAC5B,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;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAE9B,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,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AAQ,CAAC,CAAC,CAAA;QACpH,CAAC,CAAC,CACL,CAAA;IACH,CAAC;IAED,6CAA6C,CAC3C,SAAiB,EACjB,iBAAyB,EACzB,QAAgB,EAChB,aAAqB,EACrB,OAAe,EACf,IAAuC,EACvC,WAAsB,EAAE;QAExB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,CAAC,GAAG,EAAE,EAAE,CACN,IAAI,OAAO,CAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAChD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,0CAA0C,GAAG,EAAE,CAAC,CAAA;YAC5F,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;gBAC9B,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,SAAS,CAAC;oBACb,UAAU,EAAE;wBACV,SAAS,EAAE,SAAS;wBACpB,QAAQ,EAAE,QAAQ;wBAClB,aAAa,EAAE,aAAa;wBAC5B,OAAO,EAAE,OAAO;wBAChB,IAAI,EAAE,IAAI;qBACX;iBACF,CAAC,CACH,CAAA;YACH,CAAC,CAAC,CAAA;YACF,sBAAsB;YACtB,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;QACpH,CAAC,CAAC,CACL,CAAA;IACH,CAAC;CACF;AApRD,wCAoRC","sourcesContent":["import * as models from '../icc-api/model/models'\nimport { IccBekmehrApi } from '../icc-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { string2ua, ua2string } from './utils/binary-utils'\nimport { Contact, Document, HealthElement, Service } from '../icc-api/model/models'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\nexport type Patcher = ContactPatcher | HealthElementPatcher | DocumentPatcher | ServicePatcher\nexport interface ContactPatcher {\n type: 'ContactDto'\n patch: (contacts: Contact[]) => Promise<Contact[]>\n}\nexport interface HealthElementPatcher {\n type: 'HealthElementDto'\n patch: (patients: HealthElement[]) => Promise<HealthElement[]>\n}\nexport interface DocumentPatcher {\n type: 'DocumentDto'\n patch: (documents: Document[]) => Promise<Document[]>\n}\nexport interface ServicePatcher {\n type: 'ServiceDto'\n patch: (documents: Service[]) => Promise<Service[]>\n}\n\nexport class IccBekmehrXApi extends IccBekmehrApi {\n private readonly ctcApi: IccContactXApi\n private readonly helementApi: IccHelementXApi\n private readonly documentApi: IccDocumentXApi\n private readonly wssHost: string\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n ctcApi: IccContactXApi,\n helementApi: IccHelementXApi,\n documentApi: IccDocumentXApi,\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.ctcApi = ctcApi\n this.helementApi = helementApi\n this.documentApi = documentApi\n\n this.wssHost = new URL(this.host, typeof window !== 'undefined' ? window.location.href : undefined).href\n .replace(/^http/, 'ws')\n .replace(/\\/rest\\/v.+/, '/ws')\n }\n\n private async getJwt(): Promise<string> {\n const authService = this.authenticationProvider.getAuthService()\n if (!!authService.jwtGetter) {\n const tokens = await authService.jwtGetter()\n if (!tokens) {\n throw new Error('Missing JWT')\n }\n return tokens.token\n } else {\n throw new Error('The existing provider is not a JWT provider')\n }\n }\n\n socketEventListener(\n socket: WebSocket,\n healthcarePartyId: string,\n resolve: (value: Blob) => void,\n reject: (reason?: any) => void,\n patchers: Patcher[],\n progressCallback?: (progress: number) => void\n ) {\n const that = this\n\n const send = (command: string, uuid: string, body: any) => {\n const data = JSON.stringify({ command, uuid, body })\n socket.send(data.length > 65000 ? string2ua(data).buffer : data)\n }\n\n const messageHandler = (msg: any, event: any) => {\n if (msg.command === 'decrypt') {\n if (msg.type === 'ContactDto') {\n that.ctcApi\n .decrypt(healthcarePartyId, msg.body)\n .then((res) =>\n patchers\n .filter((p) => p.type === 'ContactDto')\n .reduce(async (p, patcher) => (patcher as ContactPatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) => send('decryptResponse', msg.uuid, res))\n } else if (msg.type === 'HealthElementDto') {\n that.helementApi\n .decrypt(healthcarePartyId, msg.body)\n .then((res) =>\n patchers\n .filter((p) => p.type === 'HealthElementDto')\n .reduce(async (p, patcher) => (patcher as HealthElementPatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) => send('decryptResponse', msg.uuid, res))\n } else if (msg.type === 'DocumentDto') {\n that.documentApi\n .decrypt(\n healthcarePartyId,\n msg.body.map((d: JSON) => new Document(d))\n )\n .then((res) =>\n patchers\n .filter((p) => p.type === 'DocumentDto')\n .reduce(async (p, patcher) => (patcher as DocumentPatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) =>\n send(\n 'decryptResponse',\n msg.uuid,\n res?.map((d) => {\n const de = d.decryptedAttachment\n const { encryptedAttachment, ...stripped } = d\n return de ? { ...stripped, decryptedAttachment: btoa(ua2string(de)) } : stripped\n })\n )\n )\n } else if (msg.type === 'ServiceDto') {\n that.ctcApi\n .decryptServices(healthcarePartyId, msg.body)\n .then((res) =>\n patchers\n .filter((p) => p.type === 'ServiceDto')\n .reduce(async (p, patcher) => (patcher as ServicePatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) => send('decryptResponse', msg.uuid, res))\n }\n } else if (msg.command === 'progress') {\n if (progressCallback && msg.body && msg.body[0]) {\n progressCallback(msg.body[0].progress)\n }\n } else {\n console.error('error received from backend:' + event.data)\n reject('websocket error: ' + event.data)\n socket.close(4000, 'backend error')\n }\n }\n\n return (event: MessageEvent) => {\n if (typeof event.data === 'string') {\n const msg = JSON.parse(event.data)\n messageHandler(msg, event)\n } else {\n const blob: Blob = event.data\n const subBlob = blob.slice(0, 1)\n const br = new FileReader()\n br.onload = function (e) {\n const firstChar = e.target && new Uint8Array((e.target as any).result as ArrayBuffer)[0]\n\n if (firstChar === 0x7b) {\n const tr = new FileReader()\n tr.onload = function (e) {\n const msg = e.target && JSON.parse((e.target as any).result as string)\n messageHandler(msg, event)\n }\n tr.readAsBinaryString(blob)\n } else {\n resolve(blob)\n socket.close(1000, 'Ok')\n }\n }\n br.readAsArrayBuffer(subBlob)\n }\n }\n }\n\n generateSmfExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SoftwareMedicalFileExport,\n progressCallback?: (progress: number) => void,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateSmf?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers, progressCallback))\n })\n )\n }\n\n generateSumehrExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SumehrExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateSumehr?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n\n generateSumehrV2ExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SumehrExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateSumehrV2?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n\n generateDiaryNoteExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SumehrExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateDiaryNote?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n\n generateMedicationSchemeWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n recipientSafe: string,\n version: number,\n body: models.MedicationSchemeExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateMedicationScheme?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: {\n patientId: patientId,\n language: language,\n recipientSafe: recipientSafe,\n version: version,\n info: body,\n },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-bekmehr-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-bekmehr-x-api.ts"],"names":[],"mappings":";;;;;;;;;;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C,IAAI,CACT,IAAI,CAAC,SAAS,CAAC;oBACb,UAAU,EAAE;wBACV,SAAS,EAAE,SAAS;wBACpB,QAAQ,EAAE,QAAQ;wBAClB,aAAa,EAAE,aAAa;wBAC5B,OAAO,EAAE,OAAO;wBAChB,IAAI,EAAE,IAAI;qBACX;iBACF,CAAC,CACH,CAAA;YACH,CAAC,CAAC,CAAA;YACF,sBAAsB;YACtB,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;QACpH,CAAC,CAAC,CACL,CAAA;IACH,CAAC;CACF;AApRD,wCAoRC","sourcesContent":["import * as models from '../icc-api/model/models'\nimport { IccBekmehrApi } from '../icc-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { ua2string, utf8_2ua } from './utils/binary-utils'\nimport { Contact, Document, HealthElement, Service } from '../icc-api/model/models'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\nexport type Patcher = ContactPatcher | HealthElementPatcher | DocumentPatcher | ServicePatcher\nexport interface ContactPatcher {\n type: 'ContactDto'\n patch: (contacts: Contact[]) => Promise<Contact[]>\n}\nexport interface HealthElementPatcher {\n type: 'HealthElementDto'\n patch: (patients: HealthElement[]) => Promise<HealthElement[]>\n}\nexport interface DocumentPatcher {\n type: 'DocumentDto'\n patch: (documents: Document[]) => Promise<Document[]>\n}\nexport interface ServicePatcher {\n type: 'ServiceDto'\n patch: (documents: Service[]) => Promise<Service[]>\n}\n\nexport class IccBekmehrXApi extends IccBekmehrApi {\n private readonly ctcApi: IccContactXApi\n private readonly helementApi: IccHelementXApi\n private readonly documentApi: IccDocumentXApi\n private readonly wssHost: string\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n ctcApi: IccContactXApi,\n helementApi: IccHelementXApi,\n documentApi: IccDocumentXApi,\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.ctcApi = ctcApi\n this.helementApi = helementApi\n this.documentApi = documentApi\n\n this.wssHost = new URL(this.host, typeof window !== 'undefined' ? window.location.href : undefined).href\n .replace(/^http/, 'ws')\n .replace(/\\/rest\\/v.+/, '/ws')\n }\n\n private async getJwt(): Promise<string> {\n const authService = this.authenticationProvider.getAuthService()\n if (!!authService.jwtGetter) {\n const tokens = await authService.jwtGetter()\n if (!tokens) {\n throw new Error('Missing JWT')\n }\n return tokens.token\n } else {\n throw new Error('The existing provider is not a JWT provider')\n }\n }\n\n socketEventListener(\n socket: WebSocket,\n healthcarePartyId: string,\n resolve: (value: Blob) => void,\n reject: (reason?: any) => void,\n patchers: Patcher[],\n progressCallback?: (progress: number) => void\n ) {\n const that = this\n\n const send = (command: string, uuid: string, body: any) => {\n const data = JSON.stringify({ command, uuid, body })\n socket.send(data.length > 65000 ? utf8_2ua(data).buffer : data)\n }\n\n const messageHandler = (msg: any, event: any) => {\n if (msg.command === 'decrypt') {\n if (msg.type === 'ContactDto') {\n that.ctcApi\n .decrypt(healthcarePartyId, msg.body)\n .then((res) =>\n patchers\n .filter((p) => p.type === 'ContactDto')\n .reduce(async (p, patcher) => (patcher as ContactPatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) => send('decryptResponse', msg.uuid, res))\n } else if (msg.type === 'HealthElementDto') {\n that.helementApi\n .decrypt(healthcarePartyId, msg.body)\n .then((res) =>\n patchers\n .filter((p) => p.type === 'HealthElementDto')\n .reduce(async (p, patcher) => (patcher as HealthElementPatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) => send('decryptResponse', msg.uuid, res))\n } else if (msg.type === 'DocumentDto') {\n that.documentApi\n .decrypt(\n healthcarePartyId,\n msg.body.map((d: JSON) => new Document(d))\n )\n .then((res) =>\n patchers\n .filter((p) => p.type === 'DocumentDto')\n .reduce(async (p, patcher) => (patcher as DocumentPatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) =>\n send(\n 'decryptResponse',\n msg.uuid,\n res?.map((d) => {\n const de = d.decryptedAttachment\n const { encryptedAttachment, ...stripped } = d\n return de ? { ...stripped, decryptedAttachment: btoa(ua2string(de)) } : stripped\n })\n )\n )\n } else if (msg.type === 'ServiceDto') {\n that.ctcApi\n .decryptServices(healthcarePartyId, msg.body)\n .then((res) =>\n patchers\n .filter((p) => p.type === 'ServiceDto')\n .reduce(async (p, patcher) => (patcher as ServicePatcher).patch(await p), Promise.resolve(res))\n )\n .then((res) => send('decryptResponse', msg.uuid, res))\n }\n } else if (msg.command === 'progress') {\n if (progressCallback && msg.body && msg.body[0]) {\n progressCallback(msg.body[0].progress)\n }\n } else {\n console.error('error received from backend:' + event.data)\n reject('websocket error: ' + event.data)\n socket.close(4000, 'backend error')\n }\n }\n\n return (event: MessageEvent) => {\n if (typeof event.data === 'string') {\n const msg = JSON.parse(event.data)\n messageHandler(msg, event)\n } else {\n const blob: Blob = event.data\n const subBlob = blob.slice(0, 1)\n const br = new FileReader()\n br.onload = function (e) {\n const firstChar = e.target && new Uint8Array((e.target as any).result as ArrayBuffer)[0]\n\n if (firstChar === 0x7b) {\n const tr = new FileReader()\n tr.onload = function (e) {\n const msg = e.target && JSON.parse((e.target as any).result as string)\n messageHandler(msg, event)\n }\n tr.readAsBinaryString(blob)\n } else {\n resolve(blob)\n socket.close(1000, 'Ok')\n }\n }\n br.readAsArrayBuffer(subBlob)\n }\n }\n }\n\n generateSmfExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SoftwareMedicalFileExport,\n progressCallback?: (progress: number) => void,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateSmf?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers, progressCallback))\n })\n )\n }\n\n generateSumehrExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SumehrExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateSumehr?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n\n generateSumehrV2ExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SumehrExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateSumehrV2?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n\n generateDiaryNoteExportWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n body: models.SumehrExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateDiaryNote?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: { patientId: patientId, language: language, info: body },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n\n generateMedicationSchemeWithEncryptionSupport(\n patientId: string,\n healthcarePartyId: string,\n language: string,\n recipientSafe: string,\n version: number,\n body: models.MedicationSchemeExportInfo,\n patchers: Patcher[] = []\n ): Promise<Blob | undefined> {\n return this.getJwt().then(\n (jwt) =>\n new Promise<Blob | undefined>((resolve, reject) => {\n const socket = new WebSocket(`${this.wssHost}/be_kmehr/generateMedicationScheme?jwt=${jwt}`)\n socket.addEventListener('open', function () {\n socket.send(\n JSON.stringify({\n parameters: {\n patientId: patientId,\n language: language,\n recipientSafe: recipientSafe,\n version: version,\n info: body,\n },\n })\n )\n })\n // Listen for messages\n socket.addEventListener('message', this.socketEventListener(socket, healthcarePartyId, resolve, reject, patchers))\n })\n )\n }\n}\n"]}
|
package/icc-x-api/index.js
CHANGED
|
@@ -281,7 +281,7 @@ function initialiseCryptoWithProvider(host, fetchImpl, groupSpecificAuthenticati
|
|
|
281
281
|
const keyRecovery = new KeyRecovery_1.KeyRecovery(cryptoPrimitives, dataOwnerApi, baseExchangeKeysManager, baseExchangeDataManager);
|
|
282
282
|
const recoveryDataEncryption = new RecoveryDataEncryption_1.RecoveryDataEncryption(cryptoPrimitives, baseRecoveryDataApi);
|
|
283
283
|
const keyPairRecoverer = new KeyPairRecoverer_1.KeyPairRecoverer(recoveryDataEncryption);
|
|
284
|
-
const userEncryptionKeysManager = new UserEncryptionKeysManager_1.UserEncryptionKeysManager(cryptoPrimitives, dataOwnerApi, icureStorage, keyRecovery, cryptoStrategies, !params.disableParentKeysInitialisation, keyPairRecoverer);
|
|
284
|
+
const userEncryptionKeysManager = new UserEncryptionKeysManager_1.UserEncryptionKeysManager(cryptoPrimitives, dataOwnerApi, icureStorage, keyRecovery, cryptoStrategies, !params.disableParentKeysInitialisation, keyPairRecoverer, dataOwnerRequiresAnonymousDelegation);
|
|
285
285
|
const newKey = yield userEncryptionKeysManager.initialiseKeys();
|
|
286
286
|
yield new TransferKeysManager_1.TransferKeysManager(cryptoPrimitives, baseExchangeDataManager, dataOwnerApi, userEncryptionKeysManager, icureStorage).updateTransferKeys(yield dataOwnerApi.getCurrentDataOwnerStub());
|
|
287
287
|
// TODO customise cache size?
|
package/icc-x-api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCA6BmB;AACnB,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD;AACpD,6DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,6DAAsD;AACtD,yEAAkE;AAClE,uEAA+D;AAC/D,2DAAoD;AACpD,2DAAoD;AACpD,2DAAoD;AACpD,+DAAwD;AACxD,iEAAyD;AACzD,qDAA8C;AAC9C,6EAAqE;AACrE,iEAAyD;AAGzD,iEAA6D;AAC7D,6DAAyD;AACzD,0EAKsC;AACtC,gEAAiF;AACjF,kFAA8E;AAC9E,qEAAiE;AACjE,6FAAyF;AACzF,sDAAkD;AAClD,8EAA0E;AAG1E,sEAAkE;AAClE,kEAA8D;AAC9D,sEAAkE;AAClE,+EAAuE;AACvE,0CAAwD;AACxD,sEAA+F;AAC/F,8EAA0E;AAC1E,mFAA+E;AAC/E,gFAA4E;AAC5E,sFAAkF;AAClF,0EAAsE;AACtE,gFAA4E;AAC5E,gGAA4F;AAC5F,yFAAqF;AACrF,4EAAwE;AACxE,yDAAkD;AAClD,2DAAoD;AACpD,mEAA4D;AAE5D,uDAAgD;AAChD,0DAAsD;AACtD,0EAAsE;AACtE,oFAAgF;AAChF,wEAAoE;AACpE,gEAAgF;AAChF,gEAA4D;AAC5D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AK,GAAW,CAAC,UAAU,KAAK,GAAG;gBAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;;gBACzG,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;SAChC;IACH,CAAC;CAAA","sourcesContent":["import {\n IccAgendaApi,\n IccAnonymousAccessApi,\n IccApplicationsettingsApi,\n IccAuthApi,\n IccBeefactApi,\n IccBeresultexportApi,\n IccBeresultimportApi,\n IccBesamv2Api,\n IccCalendarItemTypeApi,\n IccClassificationTemplateApi,\n IccEntityrefApi,\n IccEntitytemplateApi,\n IccFrontendmigrationApi,\n IccGroupApi,\n IccIcureApi,\n IccInsuranceApi,\n IccKeywordApi,\n IccMedexApi,\n IccMedicallocationApi,\n IccPatientApi,\n IccPermissionApi,\n IccPlaceApi,\n IccPubsubApi,\n IccReplicationApi,\n IccTarificationApi,\n IccTmpApi,\n IccUserApi,\n OAuthThirdParty,\n} from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { StorageFacade } from './storage/StorageFacade'\nimport { KeyStorageFacade } from './storage/KeyStorageFacade'\nimport { LocalStorageImpl } from './storage/LocalStorageImpl'\nimport { KeyStorageImpl } from './storage/KeyStorageImpl'\nimport {\n AuthenticationProvider,\n EnsembleAuthenticationProvider,\n JwtAuthenticationProvider,\n NoAuthenticationProvider,\n} from './auth/AuthenticationProvider'\nimport { CryptoPrimitives, WebCryptoPrimitives } from './crypto/CryptoPrimitives'\nimport { UserEncryptionKeysManager } from './crypto/UserEncryptionKeysManager'\nimport { IcureStorageFacade } from './storage/IcureStorageFacade'\nimport { DefaultStorageEntryKeysFactory } from './storage/DefaultStorageEntryKeysFactory'\nimport { KeyRecovery } from './crypto/KeyRecovery'\nimport { BaseExchangeKeysManager } from './crypto/BaseExchangeKeysManager'\nimport { StorageEntryKeysFactory } from './storage/StorageEntryKeysFactory'\nimport { CryptoStrategies } from './crypto/CryptoStrategies'\nimport { ExchangeKeysManager } from './crypto/ExchangeKeysManager'\nimport { ShamirKeysManager } from './crypto/ShamirKeysManager'\nimport { TransferKeysManager } from './crypto/TransferKeysManager'\nimport { IccIcureMaintenanceXApi } from './icc-icure-maintenance-x-api'\nimport { ensureDelegationForSelf } from './crypto/utils'\nimport { initialiseExchangeDataManagerForCurrentDataOwner } from './crypto/ExchangeDataManager'\nimport { BaseExchangeDataManager } from './crypto/BaseExchangeDataManager'\nimport { IccExchangeDataApi } from '../icc-api/api/internal/IccExchangeDataApi'\nimport { AccessControlSecretUtils } from './crypto/AccessControlSecretUtils'\nimport { SecureDelegationsEncryption } from './crypto/SecureDelegationsEncryption'\nimport { ExtendedApisUtilsImpl } from './crypto/ExtendedApisUtilsImpl'\nimport { SecureDelegationsManager } from './crypto/SecureDelegationsManager'\nimport { AccessControlKeysHeadersProvider } from './crypto/AccessControlKeysHeadersProvider'\nimport { IccExchangeDataMapApi } from '../icc-api/api/internal/IccExchangeDataMapApi'\nimport { ExchangeDataMapManager } from './crypto/ExchangeDataMapManager'\nimport { IccDeviceXApi } from './icc-device-x-api'\nimport { IccBekmehrXApi } from './icc-bekmehr-x-api'\nimport { IccDoctemplateXApi } from './icc-doctemplate-x-api'\nimport { UserGroup } from '../icc-api/model/UserGroup'\nimport { IccTopicXApi } from './icc-topic-x-api'\nimport { IccRoleApi } from '../icc-api/api/IccRoleApi'\nimport { DataOwnerTypeEnum } from '../icc-api/model/DataOwnerTypeEnum'\nimport { DelegationsDeAnonymization } from './crypto/DelegationsDeAnonymization'\nimport { JwtBridgedAuthService } from './auth/JwtBridgedAuthService'\nimport { AuthSecretProvider, SmartAuthProvider } from './auth/SmartAuthProvider'\nimport { KeyPairRecoverer } from './crypto/KeyPairRecoverer'\nimport { IccRecoveryDataApi } from '../icc-api/api/internal/IccRecoveryDataApi'\nimport { RecoveryDataEncryption } from './crypto/RecoveryDataEncryption'\nimport { IccRecoveryXApi } from './icc-recovery-x-api'\nimport { getGroupOfJwt } from './auth/JwtUtils'\nimport { SecurityMetadataDecryptor } from './crypto/SecurityMetadataDecryptor'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './icc-data-owner-x-api'\nexport * from './icc-icure-maintenance-x-api'\nexport * from './icc-maintenance-task-x-api'\nexport * from './icc-recovery-x-api'\nexport * from './utils'\n\nexport * from './crypto/RSA'\nexport * from './crypto/CryptoPrimitives'\nexport * from './crypto/ShareMetadataBehaviour'\nexport * from './auth/AuthenticationProvider'\n\nexport { AuthSecretDetails, AuthSecretType, AuthSecretProvider } from './auth/SmartAuthProvider'\nexport { KeyStorageFacade } from './storage/KeyStorageFacade'\nexport { LocalStorageImpl } from './storage/LocalStorageImpl'\nexport { StorageFacade } from './storage/StorageFacade'\nexport { KeyStorageImpl } from './storage/KeyStorageImpl'\nexport { CryptoStrategies } from './crypto/CryptoStrategies'\nexport { NativeCryptoPrimitivesBridge } from './crypto/NativeCryptoPrimitivesBridge'\nexport { hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of, getShaVersionForKey } from './crypto/utils'\nexport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport interface BasicApis {\n readonly authApi: IccAuthApi\n readonly codeApi: IccCodeXApi\n readonly userApi: IccUserXApi\n readonly permissionApi: IccPermissionApi\n readonly insuranceApi: IccInsuranceApi\n readonly entityReferenceApi: IccEntityrefApi\n readonly agendaApi: IccAgendaApi\n readonly groupApi: IccGroupApi\n readonly healthcarePartyApi: IccHcpartyXApi\n readonly deviceApi: IccDeviceXApi\n readonly patientApi: IccPatientApi\n readonly roleApi: IccRoleApi\n}\nexport interface Apis extends BasicApis {\n readonly calendarItemTypeApi: IccCalendarItemTypeApi\n readonly medicalLocationApi: IccMedicallocationApi\n readonly cryptoApi: IccCryptoXApi\n readonly accessLogApi: IccAccesslogXApi\n readonly contactApi: IccContactXApi\n readonly formApi: IccFormXApi\n readonly invoiceApi: IccInvoiceXApi\n readonly documentApi: IccDocumentXApi\n readonly healthcareElementApi: IccHelementXApi\n readonly classificationApi: IccClassificationXApi\n readonly calendarItemApi: IccCalendarItemXApi\n readonly receiptApi: IccReceiptXApi\n readonly timetableApi: IccTimeTableXApi\n readonly patientApi: IccPatientXApi\n readonly messageApi: IccMessageXApi\n readonly maintenanceTaskApi: IccMaintenanceTaskXApi\n readonly dataOwnerApi: IccDataOwnerXApi\n readonly icureMaintenanceTaskApi: IccIcureMaintenanceXApi\n readonly anonymousAccessApi: IccAnonymousAccessApi\n readonly applicationSettingsApi: IccApplicationsettingsApi\n readonly bekmehrApi: IccBekmehrXApi\n readonly beefactApi: IccBeefactApi\n readonly beresultexportApi: IccBeresultexportApi\n readonly beresultimportApi: IccBeresultimportApi\n readonly besamv2Api: IccBesamv2Api\n readonly classificationTemplateApi: IccClassificationTemplateApi\n readonly doctemplateApi: IccDoctemplateXApi\n readonly entitytemplateApi: IccEntitytemplateApi\n readonly frontendmigrationApi: IccFrontendmigrationApi\n readonly icureApi: IccIcureApi\n readonly keywordApi: IccKeywordApi\n readonly medexApi: IccMedexApi\n readonly placeApi: IccPlaceApi\n readonly pubsubApi: IccPubsubApi\n readonly replicationApi: IccReplicationApi\n readonly tarificationApi: IccTarificationApi\n readonly tmpApi: IccTmpApi\n readonly topicApi: IccTopicXApi\n readonly recoveryApi: IccRecoveryXApi\n}\n\n/**\n * Allows to customise the behaviour of the iCure API by providing various optional parameters.\n */\nexport interface IcureApiOptions {\n /**\n * Specifies how iCure can store string values (e.g. json). In production this should be persistent storage.\n * @default the browser's localStorage.\n */\n readonly storage?: StorageFacade<string>\n /**\n * Specifies how iCure can store cryptographic keys. Preferably this should be some ad-hoc storage key storage.\n * @default stores the json of the jwk representation of the key in {@link storage}.\n */\n readonly keyStorage?: KeyStorageFacade\n /**\n * Specifies where iCure should store his data within the {@link storage} and {@link keyStorage}.\n * @default {@link DefaultStorageEntryKeysFactory}\n */\n readonly entryKeysFactory?: StorageEntryKeysFactory\n /**\n * Specifies if iCure should automatically create maintenance tasks for requesting access back when a new key is generated at initialisation time.\n * Note that the maintenance task will be created only towards HCP data owners: if you want to create a maintenance task also to other types of data\n * owners you should disable this and call {@link IccIcureMaintenanceXApi.createMaintenanceTasksForNewKeypair} yourself.\n * @default true\n */\n readonly createMaintenanceTasksOnNewKey?: boolean\n /**\n * Additional headers to use on each request made by the iCure api.\n * @default no additional headers\n */\n readonly headers?: { [headerName: string]: string }\n /**\n * Specifies which fields should be encrypted for each kind of encryptable entity. You should make sure that every application in your environment\n * specifies the same values for this configuration.\n * @default see documentation for {@link EncryptedFieldsConfig}\n */\n readonly encryptedFieldsConfig?: EncryptedFieldsConfig\n /**\n * Each user may exist in multiple groups, but an instance of {@link IcureApi} is specialised for a single group. This function allows you to decide\n * the group to use for a given user.\n * This functions will be called only if a user exists in at least 2 groups, and takes in input:\n * - the information on the groups the user can access (in no specific order)\n * - if the authentication method uses JWT also the current group id (undefined otherwise)\n * The function must return the id of one of the available groups.\n * @default takes the first group provided. The group chosen by this method may vary between different instantiations of the {@link IcureApi} even\n * if for the same user and if the groups available for the user do not change.\n */\n readonly groupSelector?: (availableGroupsInfo: UserGroup[], currentGroupId?: string) => Promise<string>\n /**\n * Temporary value to support EHR Lite and MedTech api implementations.\n *\n * Currently, all hcps are able to access encrypted data shared with any of their parents, and on initialisation the api will verify that there is a\n * key pair available for the current user and for every parent of the user. If this option is set to true, the api will not load keys for the\n * parent users.\n *\n * This \"implicit data-sharing scheme\" (each parent HCP is essentially sharing data with all its children HCPs), however, may not be ideal for all\n * use cases, and it will be changed in future to be configurable in order to make it more general.\n * @default false, equivalent to previous behaviour.\n */\n readonly disableParentKeysInitialisation?: boolean\n /**\n * If true the Api will not use some endpoints that are available only in the latest versions of kraken lite.\n * Set it to true only for connecting to kraken-lite versions < 0.1.187\n */\n readonly useLiteCompatibilityMode?: boolean\n /**\n * Allows injecting exchange data similarly to {@link IccCryptoXApi.injectExchangeData} but directly on\n * initialization.\n * When possible, this solution should be preferred as it allows minimizing proliferation of exchange data under\n * certain circumstances.\n */\n readonly injectExchangeData?: {\n details: {\n exchangeDataId: string\n accessControlSecret: ArrayBuffer\n exchangeKey: ArrayBuffer\n sharedSignatureKey: ArrayBuffer\n verified: boolean\n }[]\n reEncryptWithOwnKeys: boolean\n }\n}\n\nnamespace IcureApiOptions {\n export namespace Defaults {\n export const entryKeysFactory = new DefaultStorageEntryKeysFactory()\n export const createMaintenanceTasksOnNewKey = true\n export const headers = {}\n }\n\n export class WithDefaults implements IcureApiOptions {\n readonly entryKeysFactory: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey: boolean\n readonly storage: StorageFacade<string>\n readonly keyStorage: KeyStorageFacade\n readonly headers: { [headerName: string]: string }\n readonly encryptedFieldsConfig: EncryptedFieldsConfig\n readonly groupSelector: (availableGroupsInfo: UserGroup[]) => Promise<string>\n readonly disableParentKeysInitialisation: boolean\n readonly injectExchangeData: IcureApiOptions['injectExchangeData'] | undefined\n\n constructor(custom: IcureApiOptions) {\n this.entryKeysFactory = custom.entryKeysFactory ?? Defaults.entryKeysFactory\n this.createMaintenanceTasksOnNewKey = custom.createMaintenanceTasksOnNewKey ?? Defaults.createMaintenanceTasksOnNewKey\n this.storage = custom.storage ?? new LocalStorageImpl()\n this.keyStorage = custom.keyStorage ?? new KeyStorageImpl(this.storage)\n this.headers = custom.headers ?? Defaults.headers\n this.encryptedFieldsConfig = custom.encryptedFieldsConfig ?? {}\n this.groupSelector = custom.groupSelector ?? ((groups) => Promise.resolve(groups[0].groupId!))\n this.disableParentKeysInitialisation = custom.disableParentKeysInitialisation ?? false\n this.injectExchangeData = custom.injectExchangeData\n }\n }\n}\n\n/**\n * Specifies which fields should be encrypted for each kind of encryptable entity.\n *\n * Note that any value you specify here overrides the default values. For example if you specify `['medicalLocationId']` for `healthElement` the\n * fields `['descr', 'note']` which are usually encrypted by default will no longer be encrypted. If you want to add fields to the default values\n * you can use {@link EncryptedFieldsConfig.Defaults}, for example `[...EncryptedFieldsConfig.Defaults.healthElement, 'medicalLocationId'].\n *\n * # Encrypted fields syntax\n *\n * ## Grammar\n *\n * The grammar for each encrypted field is the following:\n * ```\n * fieldName :=\n * regex([a-zA-Z_][a-zA-Z0-9_]+)\n * encryptedField :=\n * fieldName\n * | fieldName + (\".\" | \".*.\" | \"[].\") + encryptedField\n * ```\n *\n * This grammar allows you to specify the fields to encrypt for the object and recursively for nested objects.\n * - A string containing only a single `fieldName` will encrypt the field with the given name.\n * - A string starting with `fieldName.` allows to specify the encrypted fields of a nested object. The encrypted values of the\n * fields in the nested object will be saved in the nested object.\n * - A string starting with `fieldName.*.` treats `fieldName` as a map/dictionary data structure and allows to specify the encrypted fields of the\n * values of the map. Note that the values of the map must be objects as well. The encrypted content of each map value is stored in that value.\n * - A string starting with `fieldName[].` treats `fieldName` as an array and allows to specify the encrypted fields of the values of the array.\n * Note that the values of the array must be objects as well. The encrypted content of each array element is stored in that element.\n *\n * ## Example\n *\n * Consider the following object and encryption keys:\n * ```javascript\n * const obj = {\n * a: { x: 0, y: 1 },\n * b: \"hello\",\n * c: [ { public: \"a\", secret: \"b\" }, { public: \"c\", secret: \"d\" } ],\n * d: \"ok\",\n * e: {\n * info: \"something\",\n * private: \"secret\",\n * dataMap: {\n * \"en\": {\n * a: 1,\n * b: 2\n * },\n * \"fr\": {\n * a: 3,\n * b: 4\n * }\n * }\n * }\n * }\n * const encryptedFields = [\n * \"a\",\n * \"c[].secret\",\n * \"d\",\n * \"e.private\",\n * \"e.datamap.*.a\"\n * ]\n * ```\n * If you use them with the crypt method you will get the following result:\n * ```json\n * {\n * b: \"hello\",\n * c: [\n * { public: \"a\", encryptedSelf: 'encrypted+encoded { secret: \"b\" }' },\n * { public: \"c\", encryptedSelf: 'encrypted+encoded { secret: \"d\" }' }\n * ],\n * e: {\n * info: \"something\",\n * dataMap: {\n * \"en\": { b: 2, encryptedSelf: 'encrypted+encoded { a: 1 }' },\n * \"fr\": { b: 4, encryptedSelf: 'encrypted+encoded { a: 3 }' }\n * },\n * encryptedSelf: 'encrypted+encoded { private: \"secret\" }'\n * },\n * encryptedSelf: 'encrypted+encoded { a: { x: 0, y: 1 }, d: \"ok\" }'\n * }\n * ```\n *\n * ## Shortened representation\n *\n * You can also group encrypted fields having the same prefix by concatenating to the prefix the JSON representation of an array of all the postfixes.\n * For example the following encrypted fields:\n * ```javascript\n * const encryptedFields = [\"a.b.c.d.e.f1\", \"a.b.c.d.e.f2\", \"a.b.c.d.e.f3\", \"a.b.c.d.e.f4\"]\n * ```\n * can be shortened to\n * ```javascript\n * const encryptedFields = ['a.b.c.d.e.[\"f1\",\"f2\",\"f3\",\"f4\"]'] // Note the use of single quotes to avoid escaping the double quotes\n * ```\n * If you use the shortened representation you may need to escape nested json representations. In that case the use of `JSON.stringify` is\n * recommended.\n */\nexport interface EncryptedFieldsConfig {\n /**\n * Fields to encrypt for entities of type {@link AccessLog}\n * @default ['detail', 'objectId']\n */\n readonly accessLog?: string[]\n /**\n * Fields to encrypt for entities of type {@link CalendarItem}\n * @default ['details', 'title', 'patientId']\n */\n readonly calendarItem?: string[]\n /**\n * Fields to encrypt for entities of type {@link Contact}, excluding `services`. You can specify which fields of `services` should be encrypted\n * using {@link service}.\n * @default ['descr'] // encryption of `services` is managed through {@link service}\n */\n readonly contact?: string[]\n /**\n * Fields to encrypt for entities of type {@link Service}. Note that encryption of the `content` field and recursively contained `Services` through\n * `content.compoundValue` is automatically managed by the sdk, and you are not allowed to modify it.\n *\n * Note: any non-empty values for this field will break bi-directional data compatibility between v7 and previous: Contacts created with\n * v7 will not be read properly by previous versions. If you want\n * @default ['notes[].markdown'] // encryption of `content` is managed in a special way\n */\n readonly service?: string[]\n /**\n * Fields to encrypt for entities of type {@link HealthElement}\n * @default ['descr', 'note', 'notes[].markdown']\n */\n readonly healthElement?: string[]\n /**\n * Fields to encrypt for entities of type {@link MaintenanceTask}\n * @default ['properties']\n */\n readonly maintenanceTask?: string[]\n /**\n * Fields to encrypt for entities of type {@link Patient}\n * @default ['note', 'notes[].markdown']\n */\n readonly patient?: string[]\n\n /**\n * Fields to encrypt for entities of type {@link Message}\n * @default []\n */\n readonly message?: string[]\n\n /**\n * Fields to encrypt for entities of type {@link Topic}\n * @default ['description']\n */\n readonly topic?: string[]\n}\n\nexport namespace EncryptedFieldsConfig {\n export const Defaults = {\n accessLog: ['detail', 'objectId'],\n calendarItem: ['details', 'title', 'patientId'],\n contact: ['descr', 'notes[].markdown'],\n service: ['notes[].markdown'],\n healthElement: ['descr', 'note', 'notes[].markdown'],\n maintenanceTask: ['properties'],\n patient: ['note', 'notes[].markdown'],\n message: [],\n topic: ['description', 'linkedServices', 'linkedHealthElements'],\n }\n}\n\n/**\n * Details for the authentication of a user\n */\nexport type AuthenticationDetails =\n | {\n username: string\n password: string\n thirdPartyTokens?: { [thirdParty: string]: string }\n }\n | {\n icureTokens: { token: string; refreshToken: string }\n credentials?: { username: string; password: string }\n }\n | {\n thirdPartyTokens: { [thirdParty: string]: string }\n }\n | SmartAuthenticationDetails\n\n/**\n * Allows to perform authentication through an {@link AuthSecretProvider}.\n *\n * The iCure SDK can authenticate to the backend using different kinds of secrets, such as passwords, long-lived authentication tokens, and\n * short-lived authentication tokens generated through the message gateway. iCure associates to each kind of secret a certain security level, and for\n * some sensitive operations, depending on the configurations of the user and his group, some operations may require a secret of a certain security\n * level. For example, with the default configurations, in order to change his own email the user can't have logged in with a long-lived token, but he\n * needs to provide his current password or a short-lived token.\n *\n * By using this authentication option, the iCure SDK will automatically request and cache the secret from the {@link AuthSecretProvider} only when\n * needed, which should help to minimise the interaction with the user.\n *\n * Another advantage of using this authentication option over others is that in case all the cached tokens and secrets were to expire while performing\n * a request, instead of having the request fail the SDK will ask for a new secret from the {@link SmartAuthProvider} and the request will\n * automatically be retried with the new secret.\n *\n * You must provide the following information:\n * - username: any kind of value that can identify the user (userId, groupId/userId, username, email, ...). More generic identifiers, valid\n * on multiple groups, allow for simpler group switching by using {@link IcureApi.switchGroup}.\n * - secretProvider: the secret provider to use for authentication. Will handle interaction with the gui.\n *\n * You can also provide the following optional information, which may allow to reduce the requests for secrets initially:\n * - initialSecret: an initial secret (password, token, ...) that will be used to get new authentication tokens as needed. If it is expired it will be ignored.\n * - initialAuthToken: an initial authentication token used on each request. If it is expired it will be ignored.\n * - initialRefreshToken: an initial refresh token used to get new authentication tokens as needed. If it is expired it will be ignored.\n */\nexport type SmartAuthenticationDetails = {\n username: string\n secretProvider: AuthSecretProvider\n initialSecret?:\n | {\n password: string\n }\n | {\n longToken: string\n }\n | {\n oauthToken: string\n oauthType: OAuthThirdParty\n }\n initialAuthToken?: string\n initialRefreshToken?: string\n}\n\n/**\n * Main entry point for the iCure API. Provides entity-specific sub-apis and some general methods which are not related to a specific entity.\n */\nexport interface IcureApi extends Apis {\n /**\n * Get the information on groups that the current user can access and the current group that this api instance is working on.\n * Note that the values you will get for `availableGroups` may differ from the values you would get if you call {@link IccUserApi.getMatchingUsers}\n * on {@link Apis.userApi}, since the latter is specialised on the specific instance of the user in `currentGroup`.\n * - `currentGroup`: the group that this api instance is working on, or undefined if the backend environment is not multi-group.\n * - `availableGroups`: the list of groups that the current user can access with the provided secret. Empty if the backend environment is not\n * multi-group.\n */\n getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }>\n\n /**\n * Switches the api to allow the user to work on a different group.\n * @param newGroupId the id of the group to switch to.\n * @return a new api for the specified group.\n */\n switchGroup(newGroupId: string): Promise<IcureApi>\n}\n\nexport namespace IcureApi {\n /**\n * Initialises a new instance of the iCure API.\n */\n export async function initialise(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n cryptoStrategies: CryptoStrategies,\n crypto: Crypto | CryptoPrimitives = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n options: IcureApiOptions = {}\n ): Promise<IcureApi> {\n const params = new IcureApiOptions.WithDefaults(options)\n let authenticationProviderInfo = await initialiseAuthProviderWithGroupSelector(\n host,\n authenticationOptions,\n params.headers,\n fetchImpl,\n params.groupSelector\n )\n const cryptoInitInfo = await initialiseCryptoWithProvider(\n host,\n fetchImpl,\n authenticationProviderInfo.groupSpecificAuthenticationProvider,\n params,\n cryptoStrategies,\n crypto,\n options.useLiteCompatibilityMode ?? false\n )\n return new IcureApiImpl(\n cryptoInitInfo,\n host,\n authenticationProviderInfo.groupSpecificAuthenticationProvider,\n fetch,\n authenticationProviderInfo.grouplessUserApi,\n authenticationProviderInfo.matches,\n authenticationProviderInfo.matches.find((match) => match.groupId === authenticationProviderInfo.chosenGroupId),\n params,\n cryptoStrategies,\n options.useLiteCompatibilityMode ?? false\n )\n }\n}\n\nasync function getAuthenticationProvider(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n headers: { [headerName: string]: string },\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n) {\n let authenticationProvider: AuthenticationProvider\n if ('getIcureTokens' in authenticationOptions && 'switchGroup' in authenticationOptions && 'getAuthService' in authenticationOptions) {\n authenticationProvider = authenticationOptions\n } else if ('icureTokens' in authenticationOptions && !!authenticationOptions.icureTokens) {\n authenticationProvider = new JwtAuthenticationProvider(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions?.credentials?.username,\n authenticationOptions?.credentials?.password,\n undefined,\n authenticationOptions.icureTokens\n )\n } else if (\n 'username' in authenticationOptions &&\n 'password' in authenticationOptions &&\n !!authenticationOptions.username &&\n !!authenticationOptions.password\n ) {\n authenticationProvider = new EnsembleAuthenticationProvider(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions.username,\n authenticationOptions.password,\n 3600,\n undefined,\n undefined,\n authenticationOptions.thirdPartyTokens\n )\n } else if ('thirdPartyTokens' in authenticationOptions && !!authenticationOptions.thirdPartyTokens) {\n authenticationProvider = new JwtAuthenticationProvider(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n undefined,\n undefined,\n new JwtBridgedAuthService(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n undefined,\n undefined,\n authenticationOptions.thirdPartyTokens,\n undefined\n )\n )\n } else if ('username' in authenticationOptions && 'secretProvider' in authenticationOptions) {\n authenticationProvider = SmartAuthProvider.initialise(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions.username,\n authenticationOptions.secretProvider,\n {\n initialSecret: authenticationOptions.initialSecret,\n initialAuthToken: authenticationOptions.initialAuthToken,\n initialRefreshToken: authenticationOptions.initialRefreshToken,\n }\n )\n } else {\n throw new Error('Invalid authentication options provided')\n }\n return authenticationProvider\n}\n\nasync function initialiseAuthProviderWithGroupSelector(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n headers: { [headerName: string]: string },\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n groupSelector: ((availableGroupsInfo: UserGroup[], currentGroupId?: string) => Promise<string>) | undefined\n) {\n let grouplessAuthenticationProvider = await getAuthenticationProvider(host, authenticationOptions, headers, fetchImpl)\n const grouplessUserApi = new IccUserApi(host, headers, grouplessAuthenticationProvider, fetchImpl)\n const matches = await getMatchesOrEmpty(grouplessUserApi)\n const tokens = await grouplessAuthenticationProvider.getIcureTokens()\n const currentGroupId = tokens ? getGroupOfJwt(tokens.token) : undefined\n const chosenGroupId = matches.length > 1 && !!groupSelector ? await groupSelector(matches, currentGroupId) : matches[0]?.groupId\n /*TODO\n * On new very new users switching the authentication provider to a specific group may fail and block the user for too many requests. This is\n * probably linked to replication of the user in the fallback database.\n */\n /*\n * If the auth provider is initialized with credentials and jwt not switching the group will may cause issues:\n * 1. The default group for the user is group A\n * 2. The user logs in to group B -> the provider is switched\n * 3. The user refreshes the page -> a new instance of the api with initial iCure tokens is created\n * 4. The refresh token is expired / the user needs to do a high security operation -> a new login is done .If we did\n * not switch the provider here the login would default to group A, potentially causing a lot of issues...\n */\n const groupSpecificAuthenticationProvider = !!chosenGroupId\n ? await grouplessAuthenticationProvider.switchGroup(chosenGroupId, matches)\n : grouplessAuthenticationProvider\n return {\n groupSpecificAuthenticationProvider,\n // No need for a groupless user api on a group-specific smart auth provider\n grouplessUserApi: groupSpecificAuthenticationProvider instanceof SmartAuthProvider ? undefined : grouplessUserApi,\n matches,\n chosenGroupId,\n }\n}\n\n// Apis which are used during crypto api initialisation, to avoid re-instantiating them later\ntype CryptoInitialisationInfo = {\n cryptoApi: IccCryptoXApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceXApi\n // no patient api since it is base\n dataOwnerApi: IccDataOwnerXApi\n userApi: IccUserXApi\n icureMaintenanceTaskApi: IccIcureMaintenanceXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n headers: { [headerName: string]: string }\n dataOwnerRequiresAnonymousDelegation: boolean\n recoveryApi: IccRecoveryXApi\n}\n\nconst REQUEST_AUTOFIX_ANONYMITY_HEADER = 'Icure-Request-Autofix-Anonymity'\n\nasync function initialiseCryptoWithProvider(\n host: string,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n groupSpecificAuthenticationProvider: AuthenticationProvider,\n params: IcureApiOptions.WithDefaults,\n cryptoStrategies: CryptoStrategies,\n crypto: Crypto | CryptoPrimitives,\n useLiteCompatibilityMode: boolean\n): Promise<CryptoInitialisationInfo> {\n const initialDataOwnerStub = await new IccDataOwnerXApi(\n host,\n params.headers,\n groupSpecificAuthenticationProvider,\n fetchImpl\n ).getCurrentDataOwnerStub()\n const dataOwnerRequiresAnonymousDelegation = cryptoStrategies.dataOwnerRequiresAnonymousDelegation(initialDataOwnerStub)\n let updatedHeaders = params.headers\n if (!Object.keys(updatedHeaders).includes(REQUEST_AUTOFIX_ANONYMITY_HEADER)) {\n if (initialDataOwnerStub.type == DataOwnerTypeEnum.Patient || initialDataOwnerStub.type == DataOwnerTypeEnum.Device) {\n if (!dataOwnerRequiresAnonymousDelegation) {\n updatedHeaders = { ...updatedHeaders, [REQUEST_AUTOFIX_ANONYMITY_HEADER]: 'false' }\n }\n } else {\n if (dataOwnerRequiresAnonymousDelegation) {\n updatedHeaders = { ...updatedHeaders, [REQUEST_AUTOFIX_ANONYMITY_HEADER]: 'true' }\n }\n }\n }\n\n const authApi = new IccAuthApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, authApi, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, authApi, fetchImpl)\n const deviceApi = new IccDeviceXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, userApi, authApi, fetchImpl)\n const basePatientApi = new IccPatientApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const dataOwnerApi = new IccDataOwnerXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const exchangeDataApi = new IccExchangeDataApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const baseRecoveryDataApi = new IccRecoveryDataApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n // Crypto initialisation\n const icureStorage = new IcureStorageFacade(params.keyStorage, params.storage, params.entryKeysFactory)\n const cryptoPrimitives = 'AES' in crypto && 'RSA' in crypto && 'HMAC' in crypto ? crypto : new WebCryptoPrimitives(crypto)\n const baseExchangeKeysManager = new BaseExchangeKeysManager(cryptoPrimitives, dataOwnerApi, healthcarePartyApi, basePatientApi, deviceApi)\n const baseExchangeDataManager = new BaseExchangeDataManager(\n exchangeDataApi,\n dataOwnerApi,\n cryptoPrimitives,\n dataOwnerRequiresAnonymousDelegation,\n useLiteCompatibilityMode\n )\n const keyRecovery = new KeyRecovery(cryptoPrimitives, dataOwnerApi, baseExchangeKeysManager, baseExchangeDataManager)\n const recoveryDataEncryption = new RecoveryDataEncryption(cryptoPrimitives, baseRecoveryDataApi)\n const keyPairRecoverer = new KeyPairRecoverer(recoveryDataEncryption)\n const userEncryptionKeysManager = new UserEncryptionKeysManager(\n cryptoPrimitives,\n dataOwnerApi,\n icureStorage,\n keyRecovery,\n cryptoStrategies,\n !params.disableParentKeysInitialisation,\n keyPairRecoverer\n )\n const newKey = await userEncryptionKeysManager.initialiseKeys()\n await new TransferKeysManager(cryptoPrimitives, baseExchangeDataManager, dataOwnerApi, userEncryptionKeysManager, icureStorage).updateTransferKeys(\n await dataOwnerApi.getCurrentDataOwnerStub()\n )\n // TODO customise cache size?\n const exchangeKeysManager = new ExchangeKeysManager(userEncryptionKeysManager, baseExchangeKeysManager, dataOwnerApi)\n // noinspection ES6MissingAwait\n exchangeKeysManager.reloadCache() // Intentionally not awaited to make login feel faster\n const accessControlSecretUtils = new AccessControlSecretUtils(cryptoPrimitives)\n const exchangeDataManager = await initialiseExchangeDataManagerForCurrentDataOwner(\n baseExchangeDataManager,\n userEncryptionKeysManager,\n accessControlSecretUtils,\n cryptoStrategies,\n dataOwnerApi,\n cryptoPrimitives,\n !params.disableParentKeysInitialisation\n )\n if (params.injectExchangeData != null && params.injectExchangeData.details.length > 0) {\n await exchangeDataManager.injectDecryptedExchangeData(params.injectExchangeData.details, params.injectExchangeData.reEncryptWithOwnKeys)\n }\n const exchangeDataMapManager = new ExchangeDataMapManager(\n new IccExchangeDataMapApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n )\n const secureDelegationsEncryption = new SecureDelegationsEncryption(userEncryptionKeysManager, cryptoPrimitives)\n const secureDelegationsSecurityMetadataEncryption = new SecurityMetadataDecryptor(\n exchangeKeysManager,\n cryptoPrimitives,\n exchangeDataManager,\n exchangeDataMapManager,\n secureDelegationsEncryption,\n dataOwnerApi\n )\n const xApiUtils = new ExtendedApisUtilsImpl(\n cryptoPrimitives,\n dataOwnerApi,\n secureDelegationsSecurityMetadataEncryption,\n new SecureDelegationsManager(\n exchangeDataManager,\n exchangeDataMapManager,\n secureDelegationsEncryption,\n accessControlSecretUtils,\n userEncryptionKeysManager,\n cryptoPrimitives,\n dataOwnerApi,\n cryptoStrategies,\n dataOwnerRequiresAnonymousDelegation\n ),\n userApi,\n !params.disableParentKeysInitialisation\n )\n const shamirManager = new ShamirKeysManager(cryptoPrimitives, dataOwnerApi, userEncryptionKeysManager, exchangeDataManager)\n if (userEncryptionKeysManager.getSelfVerifiedKeys().length > 0) {\n await ensureDelegationForSelf(dataOwnerApi, xApiUtils, basePatientApi, cryptoPrimitives)\n }\n const accessControlKeysHeadersProvider = new AccessControlKeysHeadersProvider(exchangeDataManager)\n const delegationsDeAnonymisation = new DelegationsDeAnonymization(\n dataOwnerApi,\n secureDelegationsSecurityMetadataEncryption,\n xApiUtils,\n cryptoPrimitives,\n accessControlSecretUtils,\n host,\n updatedHeaders,\n groupSpecificAuthenticationProvider,\n fetchImpl,\n accessControlKeysHeadersProvider\n )\n const cryptoApi = new IccCryptoXApi(\n exchangeKeysManager,\n cryptoPrimitives,\n userEncryptionKeysManager,\n dataOwnerApi,\n xApiUtils,\n shamirManager,\n params.storage,\n params.keyStorage,\n exchangeDataManager,\n accessControlKeysHeadersProvider,\n delegationsDeAnonymisation\n )\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(\n host,\n updatedHeaders,\n cryptoApi,\n healthcarePartyApi,\n dataOwnerApi,\n userApi,\n authApi,\n !dataOwnerRequiresAnonymousDelegation,\n params.encryptedFieldsConfig.maintenanceTask ?? EncryptedFieldsConfig.Defaults.maintenanceTask,\n groupSpecificAuthenticationProvider,\n fetchImpl\n )\n const icureMaintenanceTaskApi = new IccIcureMaintenanceXApi(cryptoApi, maintenanceTaskApi, dataOwnerApi, exchangeDataApi)\n\n if (newKey && params.createMaintenanceTasksOnNewKey) {\n await icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(await userApi.getCurrentUser(), newKey.newKeyPair)\n }\n return {\n cryptoApi,\n userApi,\n healthcarePartyApi,\n deviceApi,\n maintenanceTaskApi,\n dataOwnerApi,\n icureMaintenanceTaskApi,\n headers: updatedHeaders,\n dataOwnerRequiresAnonymousDelegation,\n recoveryApi: new IccRecoveryXApi(\n baseRecoveryDataApi,\n recoveryDataEncryption,\n userEncryptionKeysManager,\n dataOwnerApi,\n cryptoPrimitives,\n exchangeDataManager\n ),\n }\n}\n\nclass IcureApiImpl implements IcureApi {\n private latestGroupsRequest: Promise<UserGroup[]>\n\n constructor(\n private readonly cryptoInitInfos: CryptoInitialisationInfo,\n private readonly host: string,\n private readonly groupSpecificAuthenticationProvider: AuthenticationProvider,\n private readonly fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n private readonly grouplessUserApi: IccUserApi | undefined,\n latestMatches: UserGroup[],\n private readonly currentGroupInfo: UserGroup | undefined,\n private readonly params: IcureApiOptions.WithDefaults,\n private readonly cryptoStrategies: CryptoStrategies,\n private readonly useLiteCompatibilityMode: boolean\n ) {\n this.latestGroupsRequest = Promise.resolve(latestMatches)\n }\n\n private _authApi: IccAuthApi | undefined\n\n get recoveryApi(): IccRecoveryXApi {\n return this.cryptoInitInfos.recoveryApi\n }\n\n get authApi(): IccAuthApi {\n return (\n this._authApi ?? (this._authApi = new IccAuthApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _codeApi: IccCodeXApi | undefined\n\n get codeApi(): IccCodeXApi {\n return (\n this._codeApi ??\n (this._codeApi = new IccCodeXApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _calendarItemTypeApi: IccCalendarItemTypeApi | undefined\n\n get calendarItemTypeApi(): IccCalendarItemTypeApi {\n return (\n this._calendarItemTypeApi ??\n (this._calendarItemTypeApi = new IccCalendarItemTypeApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _medicalLocationApi: IccMedicallocationApi | undefined\n\n get medicalLocationApi(): IccMedicallocationApi {\n return (\n this._medicalLocationApi ??\n (this._medicalLocationApi = new IccMedicallocationApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _roleApi: IccRoleApi | undefined\n\n get roleApi(): IccRoleApi {\n return this._roleApi ?? (this._roleApi = new IccRoleApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n\n private _entityReferenceApi: IccEntityrefApi | undefined\n\n get entityReferenceApi(): IccEntityrefApi {\n return (\n this._entityReferenceApi ??\n (this._entityReferenceApi = new IccEntityrefApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _permissionApi: IccPermissionApi | undefined\n\n get permissionApi(): IccPermissionApi {\n return (\n this._permissionApi ??\n (this._permissionApi = new IccPermissionApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _accessLogApi: IccAccesslogXApi | undefined\n\n get accessLogApi(): IccAccesslogXApi {\n return (\n this._accessLogApi ??\n (this._accessLogApi = new IccAccesslogXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.accessLog ?? EncryptedFieldsConfig.Defaults.accessLog,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _agendaApi: IccAgendaApi | undefined\n\n get agendaApi(): IccAgendaApi {\n return (\n this._agendaApi ??\n (this._agendaApi = new IccAgendaApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _contactApi: IccContactXApi | undefined\n\n get contactApi(): IccContactXApi {\n return (\n this._contactApi ??\n (this._contactApi = new IccContactXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.userApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch,\n this.params.encryptedFieldsConfig.contact ?? EncryptedFieldsConfig.Defaults.contact,\n this.params.encryptedFieldsConfig.service ?? EncryptedFieldsConfig.Defaults.service\n ))\n )\n }\n\n private _formApi: IccFormXApi | undefined\n\n get formApi(): IccFormXApi {\n return (\n this._formApi ??\n (this._formApi = new IccFormXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _groupApi: IccGroupApi | undefined\n\n get groupApi(): IccGroupApi {\n return (\n this._groupApi ??\n (this._groupApi = new IccGroupApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _invoiceApi: IccInvoiceXApi | undefined\n\n get invoiceApi(): IccInvoiceXApi {\n return (\n this._invoiceApi ??\n (this._invoiceApi = new IccInvoiceXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.entityReferenceApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _insuranceApi: IccInsuranceApi | undefined\n\n get insuranceApi(): IccInsuranceApi {\n return (\n this._insuranceApi ??\n (this._insuranceApi = new IccInsuranceApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _documentApi: IccDocumentXApi | undefined\n\n get documentApi(): IccDocumentXApi {\n return (\n this._documentApi ??\n (this._documentApi = new IccDocumentXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.authApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _healthcareElementApi: IccHelementXApi | undefined\n\n get healthcareElementApi(): IccHelementXApi {\n return (\n this._healthcareElementApi ??\n (this._healthcareElementApi = new IccHelementXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.userApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.healthElement ?? EncryptedFieldsConfig.Defaults.healthElement,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _classificationApi: IccClassificationXApi | undefined\n\n get classificationApi(): IccClassificationXApi {\n return (\n this._classificationApi ??\n (this._classificationApi = new IccClassificationXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _calendarItemApi: IccCalendarItemXApi | undefined\n\n get calendarItemApi(): IccCalendarItemXApi {\n return (\n this._calendarItemApi ??\n (this._calendarItemApi = new IccCalendarItemXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.calendarItem ?? EncryptedFieldsConfig.Defaults.calendarItem,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _receiptApi: IccReceiptXApi | undefined\n\n get receiptApi(): IccReceiptXApi {\n return (\n this._receiptApi ??\n (this._receiptApi = new IccReceiptXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _timetableApi: IccTimeTableXApi | undefined\n\n get timetableApi(): IccTimeTableXApi {\n return (\n this._timetableApi ??\n (this._timetableApi = new IccTimeTableXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _patientApi: IccPatientXApi | undefined\n\n get patientApi(): IccPatientXApi {\n return (\n this._patientApi ??\n (this._patientApi = new IccPatientXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.contactApi,\n this.formApi,\n this.healthcareElementApi,\n this.invoiceApi,\n this.documentApi,\n this.healthcarePartyApi,\n this.classificationApi,\n this.dataOwnerApi,\n this.calendarItemApi,\n this.userApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.patient ?? EncryptedFieldsConfig.Defaults.patient,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _messageApi: IccMessageXApi | undefined\n\n get messageApi(): IccMessageXApi {\n return (\n this._messageApi ??\n (this._messageApi = new IccMessageXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.params.encryptedFieldsConfig.message ?? EncryptedFieldsConfig.Defaults.message,\n this.fetch\n ))\n )\n }\n\n private _topicApi: IccTopicXApi | undefined\n\n get topicApi(): IccTopicXApi {\n return (\n this._topicApi ??\n (this._topicApi = new IccTopicXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.params.encryptedFieldsConfig.topic ?? EncryptedFieldsConfig.Defaults.topic,\n this.fetch\n ))\n )\n }\n\n private _anonymousAccessApi: IccAnonymousAccessApi | undefined\n\n get anonymousAccessApi(): IccAnonymousAccessApi {\n return (\n this._anonymousAccessApi ??\n (this._anonymousAccessApi = new IccAnonymousAccessApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _applicationSettingsApi: IccApplicationsettingsApi | undefined\n\n get applicationSettingsApi(): IccApplicationsettingsApi {\n return (\n this._applicationSettingsApi ??\n (this._applicationSettingsApi = new IccApplicationsettingsApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _bekmehrApi: IccBekmehrXApi | undefined\n\n get bekmehrApi(): IccBekmehrXApi {\n return (\n this._bekmehrApi ??\n (this._bekmehrApi = new IccBekmehrXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.contactApi,\n this.healthcareElementApi,\n this.documentApi,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _beefactApi: IccBeefactApi | undefined\n\n get beefactApi(): IccBeefactApi {\n return (\n this._beefactApi ??\n (this._beefactApi = new IccBeefactApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _beresultexportApi: IccBeresultexportApi | undefined\n\n get beresultexportApi(): IccBeresultexportApi {\n return (\n this._beresultexportApi ??\n (this._beresultexportApi = new IccBeresultexportApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _beresultimportApi: IccBeresultimportApi | undefined\n\n get beresultimportApi(): IccBeresultimportApi {\n return (\n this._beresultimportApi ??\n (this._beresultimportApi = new IccBeresultimportApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _besamv2Api: IccBesamv2Api | undefined\n\n get besamv2Api(): IccBesamv2Api {\n return (\n this._besamv2Api ??\n (this._besamv2Api = new IccBesamv2Api(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _classificationTemplateApi: IccClassificationTemplateApi | undefined\n\n get classificationTemplateApi(): IccClassificationTemplateApi {\n return (\n this._classificationTemplateApi ??\n (this._classificationTemplateApi = new IccClassificationTemplateApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _doctemplateApi: IccDoctemplateXApi | undefined\n\n get doctemplateApi(): IccDoctemplateXApi {\n return (\n this._doctemplateApi ??\n (this._doctemplateApi = new IccDoctemplateXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _entitytemplateApi: IccEntitytemplateApi | undefined\n\n get entitytemplateApi(): IccEntitytemplateApi {\n return (\n this._entitytemplateApi ??\n (this._entitytemplateApi = new IccEntitytemplateApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _frontendmigrationApi: IccFrontendmigrationApi | undefined\n\n get frontendmigrationApi(): IccFrontendmigrationApi {\n return (\n this._frontendmigrationApi ??\n (this._frontendmigrationApi = new IccFrontendmigrationApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _icureApi: IccIcureApi | undefined\n\n get icureApi(): IccIcureApi {\n return (\n this._icureApi ??\n (this._icureApi = new IccIcureApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _keywordApi: IccKeywordApi | undefined\n\n get keywordApi(): IccKeywordApi {\n return (\n this._keywordApi ??\n (this._keywordApi = new IccKeywordApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _medexApi: IccMedexApi | undefined\n\n get medexApi(): IccMedexApi {\n return (\n this._medexApi ??\n (this._medexApi = new IccMedexApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _placeApi: IccPlaceApi | undefined\n\n get placeApi(): IccPlaceApi {\n return (\n this._placeApi ??\n (this._placeApi = new IccPlaceApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _pubsubApi: IccPubsubApi | undefined\n\n get pubsubApi(): IccPubsubApi {\n return (\n this._pubsubApi ??\n (this._pubsubApi = new IccPubsubApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _replicationApi: IccReplicationApi | undefined\n\n get replicationApi(): IccReplicationApi {\n return (\n this._replicationApi ??\n (this._replicationApi = new IccReplicationApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _tarificationApi: IccTarificationApi | undefined\n\n get tarificationApi(): IccTarificationApi {\n return (\n this._tarificationApi ??\n (this._tarificationApi = new IccTarificationApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _tmpApi: IccTmpApi | undefined\n\n get tmpApi(): IccTmpApi {\n return (\n this._tmpApi ?? (this._tmpApi = new IccTmpApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n get cryptoApi(): IccCryptoXApi {\n return this.cryptoInitInfos.cryptoApi\n }\n\n get dataOwnerApi(): IccDataOwnerXApi {\n return this.cryptoInitInfos.dataOwnerApi\n }\n\n get deviceApi(): IccDeviceXApi {\n return this.cryptoInitInfos.deviceApi\n }\n\n get healthcarePartyApi(): IccHcpartyXApi {\n return this.cryptoInitInfos.healthcarePartyApi\n }\n\n get icureMaintenanceTaskApi(): IccIcureMaintenanceXApi {\n return this.cryptoInitInfos.icureMaintenanceTaskApi\n }\n\n get maintenanceTaskApi(): IccMaintenanceTaskXApi {\n return this.cryptoInitInfos.maintenanceTaskApi\n }\n\n get userApi(): IccUserXApi {\n return this.cryptoInitInfos.userApi\n }\n\n async getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }> {\n this.latestGroupsRequest = (this.grouplessUserApi ?? this.userApi).getMatchingUsers()\n return { currentGroup: this.currentGroupInfo, availableGroups: await this.latestGroupsRequest }\n }\n\n async switchGroup(newGroupId: string): Promise<IcureApi> {\n const availableGroups = await this.latestGroupsRequest\n const switchedProvider = await this.groupSpecificAuthenticationProvider.switchGroup(newGroupId, availableGroups)\n const cryptoInitInfos = await initialiseCryptoWithProvider(\n this.host,\n this.fetch,\n switchedProvider,\n this.params,\n this.cryptoStrategies,\n this.cryptoApi.primitives,\n this.useLiteCompatibilityMode\n )\n return new IcureApiImpl(\n cryptoInitInfos,\n this.host,\n switchedProvider,\n this.fetch,\n this.grouplessUserApi,\n availableGroups,\n availableGroups.find((x) => x.groupId === newGroupId)!,\n this.params,\n this.cryptoStrategies,\n this.useLiteCompatibilityMode\n )\n }\n}\n\nexport interface IcureBasicApi extends BasicApis {\n /**\n * Get the information on groups that the current user can access and the current group that this api instance is working on.\n * Note that the values you will get for `availableGroups` may differ from the values you would get if you call {@link IccUserApi.getMatchingUsers}\n * on {@link Apis.userApi}, since the latter is specialised on the specific instance of the user in `currentGroup`.\n * - `currentGroup`: the group that this api instance is working on, or undefined if the backend environment is not multi-group.\n * - `availableGroups`: the list of groups that the current user can access with the provided secret. Empty if the backend environment is not\n * multi-group.\n */\n getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }>\n\n /**\n * Switches the api to allow the user to work on a different group.\n * @param newGroupId the id of the group to switch to.\n * @return a new api for the specified group.\n */\n switchGroup(newGroupId: string): Promise<IcureBasicApi>\n}\n\nclass IcureBasicApiImpl implements IcureBasicApi {\n private latestGroupsRequest: Promise<UserGroup[]>\n private _agendaApi: IccAgendaApi | undefined\n private _authApi: IccAuthApi | undefined\n private _codeApi: IccCodeXApi | undefined\n private _deviceApi: IccDeviceXApi | undefined\n private _entityReferenceApi: IccEntityrefApi | undefined\n private _groupApi: IccGroupApi | undefined\n private _healthcarePartyApi: IccHcpartyXApi | undefined\n private _insuranceApi: IccInsuranceApi | undefined\n private _permissionApi: IccPermissionApi | undefined\n private _userApi: IccUserXApi | undefined\n private _patientApi: IccPatientApi | undefined\n private _roleApi: IccRoleApi | undefined\n\n get agendaApi(): IccAgendaApi {\n return (\n this._agendaApi ?? (this._agendaApi = new IccAgendaApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get authApi(): IccAuthApi {\n return this._authApi ?? (this._authApi = new IccAuthApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n get codeApi(): IccCodeXApi {\n return this._codeApi ?? (this._codeApi = new IccCodeXApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n get deviceApi(): IccDeviceXApi {\n return (\n this._deviceApi ??\n (this._deviceApi = new IccDeviceXApi(\n this.host,\n this.params.headers,\n this.groupSpecificAuthenticationProvider,\n this.userApi,\n this.authApi,\n this.fetch\n ))\n )\n }\n get entityReferenceApi(): IccEntityrefApi {\n return (\n this._entityReferenceApi ??\n (this._entityReferenceApi = new IccEntityrefApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get groupApi(): IccGroupApi {\n return this._groupApi ?? (this._groupApi = new IccGroupApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n get healthcarePartyApi(): IccHcpartyXApi {\n return (\n this._healthcarePartyApi ??\n (this._healthcarePartyApi = new IccHcpartyXApi(\n this.host,\n this.params.headers,\n this.groupSpecificAuthenticationProvider,\n this.authApi,\n this.fetch\n ))\n )\n }\n get insuranceApi(): IccInsuranceApi {\n return (\n this._insuranceApi ??\n (this._insuranceApi = new IccInsuranceApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get permissionApi(): IccPermissionApi {\n return (\n this._permissionApi ??\n (this._permissionApi = new IccPermissionApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get userApi(): IccUserXApi {\n return (\n this._userApi ??\n (this._userApi = new IccUserXApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.authApi, this.fetch))\n )\n }\n\n async getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }> {\n if (!this.currentGroupInfo) return { currentGroup: undefined, availableGroups: [] }\n this.latestGroupsRequest = (this.grouplessUserApi ?? this.userApi).getMatchingUsers()\n return { currentGroup: this.currentGroupInfo, availableGroups: await this.latestGroupsRequest }\n }\n\n get patientApi(): IccPatientApi {\n return (\n this._patientApi ?? (this._patientApi = new IccPatientApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n get roleApi(): IccRoleApi {\n return this._roleApi ?? (this._roleApi = new IccRoleApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n\n async switchGroup(newGroupId: string): Promise<IcureBasicApi> {\n if (!this.currentGroupInfo) throw new Error('Cannot switch group: the backend environment does not support multiple groups.')\n const availableGroups = await this.latestGroupsRequest\n const switchedProvider = await this.groupSpecificAuthenticationProvider.switchGroup(newGroupId, availableGroups)\n return new IcureBasicApiImpl(\n this.host,\n switchedProvider,\n this.fetch,\n this.grouplessUserApi,\n availableGroups,\n availableGroups.find((x) => x.groupId === newGroupId)!,\n this.params\n )\n }\n\n constructor(\n private readonly host: string,\n private readonly groupSpecificAuthenticationProvider: AuthenticationProvider,\n private readonly fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n private readonly grouplessUserApi: IccUserApi | undefined,\n latestMatches: UserGroup[],\n private readonly currentGroupInfo: UserGroup | undefined,\n private readonly params: IcureBasicApiOptions.WithDefaults\n ) {\n this.latestGroupsRequest = Promise.resolve(latestMatches)\n }\n}\n\nexport interface IcureBasicApiOptions {\n /**\n * Additional headers to use on each request made by the iCure api.\n * @default no additional headers\n */\n readonly headers?: { [headerName: string]: string }\n /**\n * Each user may exist in multiple groups, but an instance of {@link IcureApi} is specialised for a single group. This function allows you to decide\n * the group to use for a given user.\n * This functions will be called only if a user exists in at least 2 groups, and takes in input:\n * - the information on the groups the user can access (in no specific order)\n * - if the authentication method uses JWT also the current group id (undefined otherwise)\n * The function must return the id of one of the available groups.\n * @default takes the first group provided. The group chosen by this method may vary between different instantiations of the {@link IcureApi} even\n * if for the same user and if the groups available for the user do not change.\n */\n readonly groupSelector?: (availableGroupsInfo: UserGroup[], currentGroupId?: string) => Promise<string>\n}\n\nnamespace IcureBasicApiOptions {\n export namespace Defaults {\n export const headers = {}\n }\n export class WithDefaults implements IcureBasicApiOptions {\n constructor(custom: IcureBasicApiOptions) {\n this.headers = custom.headers ?? Defaults.headers\n this.groupSelector = custom.groupSelector ?? ((groups) => Promise.resolve(groups[0].groupId!))\n }\n\n readonly headers: { [headerName: string]: string }\n readonly groupSelector: (availableGroupsInfo: UserGroup[]) => Promise<string>\n }\n}\n\nexport namespace IcureBasicApi {\n /**\n * Initialises a new instance of the iCure API.\n */\n export async function initialise(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n options: IcureBasicApiOptions = {}\n ): Promise<IcureBasicApi> {\n const params = new IcureBasicApiOptions.WithDefaults(options)\n const authProviderInfo = await initialiseAuthProviderWithGroupSelector(\n host,\n authenticationOptions,\n params.headers ?? {},\n fetchImpl,\n params.groupSelector\n )\n return new IcureBasicApiImpl(\n host,\n authProviderInfo.groupSpecificAuthenticationProvider,\n fetch,\n authProviderInfo.grouplessUserApi,\n authProviderInfo.matches,\n authProviderInfo.matches.find((match) => match.groupId === authProviderInfo.chosenGroupId),\n params\n )\n }\n}\n\nasync function getMatchesOrEmpty(userApi: IccUserApi): Promise<UserGroup[]> {\n try {\n return await userApi.getMatchingUsers()\n } catch (err) {\n if (err instanceof Error && 'statusCode' in err && (err as any).statusCode === 404) return Promise.resolve([])\n else return Promise.reject(err)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCA6BmB;AACnB,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD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,CAAC,CAAA;YAC7D,MAAM,gBAAgB,GAAG,MAAM,uCAAuC,CACpE,IAAI,EACJ,qBAAqB,EACrB,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,EACpB,SAAS,EACT,MAAM,CAAC,aAAa,CACrB,CAAA;YACD,OAAO,IAAI,iBAAiB,CAC1B,IAAI,EACJ,gBAAgB,CAAC,mCAAmC,EACpD,KAAK,EACL,gBAAgB,CAAC,gBAAgB,EACjC,gBAAgB,CAAC,OAAO,EACxB,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,gBAAgB,CAAC,aAAa,CAAC,EAC1F,MAAM,CACP,CAAA;;KACF;IA3BqB,wBAAU,aA2B/B,CAAA;AACH,CAAC,EAhCgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAgC7B;AAED,SAAe,iBAAiB,CAAC,OAAmB;;QAClD,IAAI;YACF,OAAO,MAAM,OAAO,CAAC,gBAAgB,EAAE,CAAA;SACxC;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,YAAY,KAAK,IAAI,YAAY,IAAI,GAAG,IAAK,GAAW,CAAC,UAAU,KAAK,GAAG;gBAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;;gBACzG,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;SAChC;IACH,CAAC;CAAA","sourcesContent":["import {\n IccAgendaApi,\n IccAnonymousAccessApi,\n IccApplicationsettingsApi,\n IccAuthApi,\n IccBeefactApi,\n IccBeresultexportApi,\n IccBeresultimportApi,\n IccBesamv2Api,\n IccCalendarItemTypeApi,\n IccClassificationTemplateApi,\n IccEntityrefApi,\n IccEntitytemplateApi,\n IccFrontendmigrationApi,\n IccGroupApi,\n IccIcureApi,\n IccInsuranceApi,\n IccKeywordApi,\n IccMedexApi,\n IccMedicallocationApi,\n IccPatientApi,\n IccPermissionApi,\n IccPlaceApi,\n IccPubsubApi,\n IccReplicationApi,\n IccTarificationApi,\n IccTmpApi,\n IccUserApi,\n OAuthThirdParty,\n} from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { StorageFacade } from './storage/StorageFacade'\nimport { KeyStorageFacade } from './storage/KeyStorageFacade'\nimport { LocalStorageImpl } from './storage/LocalStorageImpl'\nimport { KeyStorageImpl } from './storage/KeyStorageImpl'\nimport {\n AuthenticationProvider,\n EnsembleAuthenticationProvider,\n JwtAuthenticationProvider,\n NoAuthenticationProvider,\n} from './auth/AuthenticationProvider'\nimport { CryptoPrimitives, WebCryptoPrimitives } from './crypto/CryptoPrimitives'\nimport { UserEncryptionKeysManager } from './crypto/UserEncryptionKeysManager'\nimport { IcureStorageFacade } from './storage/IcureStorageFacade'\nimport { DefaultStorageEntryKeysFactory } from './storage/DefaultStorageEntryKeysFactory'\nimport { KeyRecovery } from './crypto/KeyRecovery'\nimport { BaseExchangeKeysManager } from './crypto/BaseExchangeKeysManager'\nimport { StorageEntryKeysFactory } from './storage/StorageEntryKeysFactory'\nimport { CryptoStrategies } from './crypto/CryptoStrategies'\nimport { ExchangeKeysManager } from './crypto/ExchangeKeysManager'\nimport { ShamirKeysManager } from './crypto/ShamirKeysManager'\nimport { TransferKeysManager } from './crypto/TransferKeysManager'\nimport { IccIcureMaintenanceXApi } from './icc-icure-maintenance-x-api'\nimport { ensureDelegationForSelf } from './crypto/utils'\nimport { initialiseExchangeDataManagerForCurrentDataOwner } from './crypto/ExchangeDataManager'\nimport { BaseExchangeDataManager } from './crypto/BaseExchangeDataManager'\nimport { IccExchangeDataApi } from '../icc-api/api/internal/IccExchangeDataApi'\nimport { AccessControlSecretUtils } from './crypto/AccessControlSecretUtils'\nimport { SecureDelegationsEncryption } from './crypto/SecureDelegationsEncryption'\nimport { ExtendedApisUtilsImpl } from './crypto/ExtendedApisUtilsImpl'\nimport { SecureDelegationsManager } from './crypto/SecureDelegationsManager'\nimport { AccessControlKeysHeadersProvider } from './crypto/AccessControlKeysHeadersProvider'\nimport { IccExchangeDataMapApi } from '../icc-api/api/internal/IccExchangeDataMapApi'\nimport { ExchangeDataMapManager } from './crypto/ExchangeDataMapManager'\nimport { IccDeviceXApi } from './icc-device-x-api'\nimport { IccBekmehrXApi } from './icc-bekmehr-x-api'\nimport { IccDoctemplateXApi } from './icc-doctemplate-x-api'\nimport { UserGroup } from '../icc-api/model/UserGroup'\nimport { IccTopicXApi } from './icc-topic-x-api'\nimport { IccRoleApi } from '../icc-api/api/IccRoleApi'\nimport { DataOwnerTypeEnum } from '../icc-api/model/DataOwnerTypeEnum'\nimport { DelegationsDeAnonymization } from './crypto/DelegationsDeAnonymization'\nimport { JwtBridgedAuthService } from './auth/JwtBridgedAuthService'\nimport { AuthSecretProvider, SmartAuthProvider } from './auth/SmartAuthProvider'\nimport { KeyPairRecoverer } from './crypto/KeyPairRecoverer'\nimport { IccRecoveryDataApi } from '../icc-api/api/internal/IccRecoveryDataApi'\nimport { RecoveryDataEncryption } from './crypto/RecoveryDataEncryption'\nimport { IccRecoveryXApi } from './icc-recovery-x-api'\nimport { getGroupOfJwt } from './auth/JwtUtils'\nimport { SecurityMetadataDecryptor } from './crypto/SecurityMetadataDecryptor'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './icc-data-owner-x-api'\nexport * from './icc-icure-maintenance-x-api'\nexport * from './icc-maintenance-task-x-api'\nexport * from './icc-recovery-x-api'\nexport * from './utils'\n\nexport * from './crypto/RSA'\nexport * from './crypto/CryptoPrimitives'\nexport * from './crypto/ShareMetadataBehaviour'\nexport * from './auth/AuthenticationProvider'\n\nexport { AuthSecretDetails, AuthSecretType, AuthSecretProvider } from './auth/SmartAuthProvider'\nexport { KeyStorageFacade } from './storage/KeyStorageFacade'\nexport { LocalStorageImpl } from './storage/LocalStorageImpl'\nexport { StorageFacade } from './storage/StorageFacade'\nexport { KeyStorageImpl } from './storage/KeyStorageImpl'\nexport { CryptoStrategies } from './crypto/CryptoStrategies'\nexport { NativeCryptoPrimitivesBridge } from './crypto/NativeCryptoPrimitivesBridge'\nexport { hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of, getShaVersionForKey } from './crypto/utils'\nexport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport interface BasicApis {\n readonly authApi: IccAuthApi\n readonly codeApi: IccCodeXApi\n readonly userApi: IccUserXApi\n readonly permissionApi: IccPermissionApi\n readonly insuranceApi: IccInsuranceApi\n readonly entityReferenceApi: IccEntityrefApi\n readonly agendaApi: IccAgendaApi\n readonly groupApi: IccGroupApi\n readonly healthcarePartyApi: IccHcpartyXApi\n readonly deviceApi: IccDeviceXApi\n readonly patientApi: IccPatientApi\n readonly roleApi: IccRoleApi\n}\nexport interface Apis extends BasicApis {\n readonly calendarItemTypeApi: IccCalendarItemTypeApi\n readonly medicalLocationApi: IccMedicallocationApi\n readonly cryptoApi: IccCryptoXApi\n readonly accessLogApi: IccAccesslogXApi\n readonly contactApi: IccContactXApi\n readonly formApi: IccFormXApi\n readonly invoiceApi: IccInvoiceXApi\n readonly documentApi: IccDocumentXApi\n readonly healthcareElementApi: IccHelementXApi\n readonly classificationApi: IccClassificationXApi\n readonly calendarItemApi: IccCalendarItemXApi\n readonly receiptApi: IccReceiptXApi\n readonly timetableApi: IccTimeTableXApi\n readonly patientApi: IccPatientXApi\n readonly messageApi: IccMessageXApi\n readonly maintenanceTaskApi: IccMaintenanceTaskXApi\n readonly dataOwnerApi: IccDataOwnerXApi\n readonly icureMaintenanceTaskApi: IccIcureMaintenanceXApi\n readonly anonymousAccessApi: IccAnonymousAccessApi\n readonly applicationSettingsApi: IccApplicationsettingsApi\n readonly bekmehrApi: IccBekmehrXApi\n readonly beefactApi: IccBeefactApi\n readonly beresultexportApi: IccBeresultexportApi\n readonly beresultimportApi: IccBeresultimportApi\n readonly besamv2Api: IccBesamv2Api\n readonly classificationTemplateApi: IccClassificationTemplateApi\n readonly doctemplateApi: IccDoctemplateXApi\n readonly entitytemplateApi: IccEntitytemplateApi\n readonly frontendmigrationApi: IccFrontendmigrationApi\n readonly icureApi: IccIcureApi\n readonly keywordApi: IccKeywordApi\n readonly medexApi: IccMedexApi\n readonly placeApi: IccPlaceApi\n readonly pubsubApi: IccPubsubApi\n readonly replicationApi: IccReplicationApi\n readonly tarificationApi: IccTarificationApi\n readonly tmpApi: IccTmpApi\n readonly topicApi: IccTopicXApi\n readonly recoveryApi: IccRecoveryXApi\n}\n\n/**\n * Allows to customise the behaviour of the iCure API by providing various optional parameters.\n */\nexport interface IcureApiOptions {\n /**\n * Specifies how iCure can store string values (e.g. json). In production this should be persistent storage.\n * @default the browser's localStorage.\n */\n readonly storage?: StorageFacade<string>\n /**\n * Specifies how iCure can store cryptographic keys. Preferably this should be some ad-hoc storage key storage.\n * @default stores the json of the jwk representation of the key in {@link storage}.\n */\n readonly keyStorage?: KeyStorageFacade\n /**\n * Specifies where iCure should store his data within the {@link storage} and {@link keyStorage}.\n * @default {@link DefaultStorageEntryKeysFactory}\n */\n readonly entryKeysFactory?: StorageEntryKeysFactory\n /**\n * Specifies if iCure should automatically create maintenance tasks for requesting access back when a new key is generated at initialisation time.\n * Note that the maintenance task will be created only towards HCP data owners: if you want to create a maintenance task also to other types of data\n * owners you should disable this and call {@link IccIcureMaintenanceXApi.createMaintenanceTasksForNewKeypair} yourself.\n * @default true\n */\n readonly createMaintenanceTasksOnNewKey?: boolean\n /**\n * Additional headers to use on each request made by the iCure api.\n * @default no additional headers\n */\n readonly headers?: { [headerName: string]: string }\n /**\n * Specifies which fields should be encrypted for each kind of encryptable entity. You should make sure that every application in your environment\n * specifies the same values for this configuration.\n * @default see documentation for {@link EncryptedFieldsConfig}\n */\n readonly encryptedFieldsConfig?: EncryptedFieldsConfig\n /**\n * Each user may exist in multiple groups, but an instance of {@link IcureApi} is specialised for a single group. This function allows you to decide\n * the group to use for a given user.\n * This functions will be called only if a user exists in at least 2 groups, and takes in input:\n * - the information on the groups the user can access (in no specific order)\n * - if the authentication method uses JWT also the current group id (undefined otherwise)\n * The function must return the id of one of the available groups.\n * @default takes the first group provided. The group chosen by this method may vary between different instantiations of the {@link IcureApi} even\n * if for the same user and if the groups available for the user do not change.\n */\n readonly groupSelector?: (availableGroupsInfo: UserGroup[], currentGroupId?: string) => Promise<string>\n /**\n * Temporary value to support EHR Lite and MedTech api implementations.\n *\n * Currently, all hcps are able to access encrypted data shared with any of their parents, and on initialisation the api will verify that there is a\n * key pair available for the current user and for every parent of the user. If this option is set to true, the api will not load keys for the\n * parent users.\n *\n * This \"implicit data-sharing scheme\" (each parent HCP is essentially sharing data with all its children HCPs), however, may not be ideal for all\n * use cases, and it will be changed in future to be configurable in order to make it more general.\n * @default false, equivalent to previous behaviour.\n */\n readonly disableParentKeysInitialisation?: boolean\n /**\n * If true the Api will not use some endpoints that are available only in the latest versions of kraken lite.\n * Set it to true only for connecting to kraken-lite versions < 0.1.187\n */\n readonly useLiteCompatibilityMode?: boolean\n /**\n * Allows injecting exchange data similarly to {@link IccCryptoXApi.injectExchangeData} but directly on\n * initialization.\n * When possible, this solution should be preferred as it allows minimizing proliferation of exchange data under\n * certain circumstances.\n */\n readonly injectExchangeData?: {\n details: {\n exchangeDataId: string\n accessControlSecret: ArrayBuffer\n exchangeKey: ArrayBuffer\n sharedSignatureKey: ArrayBuffer\n verified: boolean\n }[]\n reEncryptWithOwnKeys: boolean\n }\n}\n\nnamespace IcureApiOptions {\n export namespace Defaults {\n export const entryKeysFactory = new DefaultStorageEntryKeysFactory()\n export const createMaintenanceTasksOnNewKey = true\n export const headers = {}\n }\n\n export class WithDefaults implements IcureApiOptions {\n readonly entryKeysFactory: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey: boolean\n readonly storage: StorageFacade<string>\n readonly keyStorage: KeyStorageFacade\n readonly headers: { [headerName: string]: string }\n readonly encryptedFieldsConfig: EncryptedFieldsConfig\n readonly groupSelector: (availableGroupsInfo: UserGroup[]) => Promise<string>\n readonly disableParentKeysInitialisation: boolean\n readonly injectExchangeData: IcureApiOptions['injectExchangeData'] | undefined\n\n constructor(custom: IcureApiOptions) {\n this.entryKeysFactory = custom.entryKeysFactory ?? Defaults.entryKeysFactory\n this.createMaintenanceTasksOnNewKey = custom.createMaintenanceTasksOnNewKey ?? Defaults.createMaintenanceTasksOnNewKey\n this.storage = custom.storage ?? new LocalStorageImpl()\n this.keyStorage = custom.keyStorage ?? new KeyStorageImpl(this.storage)\n this.headers = custom.headers ?? Defaults.headers\n this.encryptedFieldsConfig = custom.encryptedFieldsConfig ?? {}\n this.groupSelector = custom.groupSelector ?? ((groups) => Promise.resolve(groups[0].groupId!))\n this.disableParentKeysInitialisation = custom.disableParentKeysInitialisation ?? false\n this.injectExchangeData = custom.injectExchangeData\n }\n }\n}\n\n/**\n * Specifies which fields should be encrypted for each kind of encryptable entity.\n *\n * Note that any value you specify here overrides the default values. For example if you specify `['medicalLocationId']` for `healthElement` the\n * fields `['descr', 'note']` which are usually encrypted by default will no longer be encrypted. If you want to add fields to the default values\n * you can use {@link EncryptedFieldsConfig.Defaults}, for example `[...EncryptedFieldsConfig.Defaults.healthElement, 'medicalLocationId'].\n *\n * # Encrypted fields syntax\n *\n * ## Grammar\n *\n * The grammar for each encrypted field is the following:\n * ```\n * fieldName :=\n * regex([a-zA-Z_][a-zA-Z0-9_]+)\n * encryptedField :=\n * fieldName\n * | fieldName + (\".\" | \".*.\" | \"[].\") + encryptedField\n * ```\n *\n * This grammar allows you to specify the fields to encrypt for the object and recursively for nested objects.\n * - A string containing only a single `fieldName` will encrypt the field with the given name.\n * - A string starting with `fieldName.` allows to specify the encrypted fields of a nested object. The encrypted values of the\n * fields in the nested object will be saved in the nested object.\n * - A string starting with `fieldName.*.` treats `fieldName` as a map/dictionary data structure and allows to specify the encrypted fields of the\n * values of the map. Note that the values of the map must be objects as well. The encrypted content of each map value is stored in that value.\n * - A string starting with `fieldName[].` treats `fieldName` as an array and allows to specify the encrypted fields of the values of the array.\n * Note that the values of the array must be objects as well. The encrypted content of each array element is stored in that element.\n *\n * ## Example\n *\n * Consider the following object and encryption keys:\n * ```javascript\n * const obj = {\n * a: { x: 0, y: 1 },\n * b: \"hello\",\n * c: [ { public: \"a\", secret: \"b\" }, { public: \"c\", secret: \"d\" } ],\n * d: \"ok\",\n * e: {\n * info: \"something\",\n * private: \"secret\",\n * dataMap: {\n * \"en\": {\n * a: 1,\n * b: 2\n * },\n * \"fr\": {\n * a: 3,\n * b: 4\n * }\n * }\n * }\n * }\n * const encryptedFields = [\n * \"a\",\n * \"c[].secret\",\n * \"d\",\n * \"e.private\",\n * \"e.datamap.*.a\"\n * ]\n * ```\n * If you use them with the crypt method you will get the following result:\n * ```json\n * {\n * b: \"hello\",\n * c: [\n * { public: \"a\", encryptedSelf: 'encrypted+encoded { secret: \"b\" }' },\n * { public: \"c\", encryptedSelf: 'encrypted+encoded { secret: \"d\" }' }\n * ],\n * e: {\n * info: \"something\",\n * dataMap: {\n * \"en\": { b: 2, encryptedSelf: 'encrypted+encoded { a: 1 }' },\n * \"fr\": { b: 4, encryptedSelf: 'encrypted+encoded { a: 3 }' }\n * },\n * encryptedSelf: 'encrypted+encoded { private: \"secret\" }'\n * },\n * encryptedSelf: 'encrypted+encoded { a: { x: 0, y: 1 }, d: \"ok\" }'\n * }\n * ```\n *\n * ## Shortened representation\n *\n * You can also group encrypted fields having the same prefix by concatenating to the prefix the JSON representation of an array of all the postfixes.\n * For example the following encrypted fields:\n * ```javascript\n * const encryptedFields = [\"a.b.c.d.e.f1\", \"a.b.c.d.e.f2\", \"a.b.c.d.e.f3\", \"a.b.c.d.e.f4\"]\n * ```\n * can be shortened to\n * ```javascript\n * const encryptedFields = ['a.b.c.d.e.[\"f1\",\"f2\",\"f3\",\"f4\"]'] // Note the use of single quotes to avoid escaping the double quotes\n * ```\n * If you use the shortened representation you may need to escape nested json representations. In that case the use of `JSON.stringify` is\n * recommended.\n */\nexport interface EncryptedFieldsConfig {\n /**\n * Fields to encrypt for entities of type {@link AccessLog}\n * @default ['detail', 'objectId']\n */\n readonly accessLog?: string[]\n /**\n * Fields to encrypt for entities of type {@link CalendarItem}\n * @default ['details', 'title', 'patientId']\n */\n readonly calendarItem?: string[]\n /**\n * Fields to encrypt for entities of type {@link Contact}, excluding `services`. You can specify which fields of `services` should be encrypted\n * using {@link service}.\n * @default ['descr'] // encryption of `services` is managed through {@link service}\n */\n readonly contact?: string[]\n /**\n * Fields to encrypt for entities of type {@link Service}. Note that encryption of the `content` field and recursively contained `Services` through\n * `content.compoundValue` is automatically managed by the sdk, and you are not allowed to modify it.\n *\n * Note: any non-empty values for this field will break bi-directional data compatibility between v7 and previous: Contacts created with\n * v7 will not be read properly by previous versions. If you want\n * @default ['notes[].markdown'] // encryption of `content` is managed in a special way\n */\n readonly service?: string[]\n /**\n * Fields to encrypt for entities of type {@link HealthElement}\n * @default ['descr', 'note', 'notes[].markdown']\n */\n readonly healthElement?: string[]\n /**\n * Fields to encrypt for entities of type {@link MaintenanceTask}\n * @default ['properties']\n */\n readonly maintenanceTask?: string[]\n /**\n * Fields to encrypt for entities of type {@link Patient}\n * @default ['note', 'notes[].markdown']\n */\n readonly patient?: string[]\n\n /**\n * Fields to encrypt for entities of type {@link Message}\n * @default []\n */\n readonly message?: string[]\n\n /**\n * Fields to encrypt for entities of type {@link Topic}\n * @default ['description']\n */\n readonly topic?: string[]\n}\n\nexport namespace EncryptedFieldsConfig {\n export const Defaults = {\n accessLog: ['detail', 'objectId'],\n calendarItem: ['details', 'title', 'patientId'],\n contact: ['descr', 'notes[].markdown'],\n service: ['notes[].markdown'],\n healthElement: ['descr', 'note', 'notes[].markdown'],\n maintenanceTask: ['properties'],\n patient: ['note', 'notes[].markdown'],\n message: [],\n topic: ['description', 'linkedServices', 'linkedHealthElements'],\n }\n}\n\n/**\n * Details for the authentication of a user\n */\nexport type AuthenticationDetails =\n | {\n username: string\n password: string\n thirdPartyTokens?: { [thirdParty: string]: string }\n }\n | {\n icureTokens: { token: string; refreshToken: string }\n credentials?: { username: string; password: string }\n }\n | {\n thirdPartyTokens: { [thirdParty: string]: string }\n }\n | SmartAuthenticationDetails\n\n/**\n * Allows to perform authentication through an {@link AuthSecretProvider}.\n *\n * The iCure SDK can authenticate to the backend using different kinds of secrets, such as passwords, long-lived authentication tokens, and\n * short-lived authentication tokens generated through the message gateway. iCure associates to each kind of secret a certain security level, and for\n * some sensitive operations, depending on the configurations of the user and his group, some operations may require a secret of a certain security\n * level. For example, with the default configurations, in order to change his own email the user can't have logged in with a long-lived token, but he\n * needs to provide his current password or a short-lived token.\n *\n * By using this authentication option, the iCure SDK will automatically request and cache the secret from the {@link AuthSecretProvider} only when\n * needed, which should help to minimise the interaction with the user.\n *\n * Another advantage of using this authentication option over others is that in case all the cached tokens and secrets were to expire while performing\n * a request, instead of having the request fail the SDK will ask for a new secret from the {@link SmartAuthProvider} and the request will\n * automatically be retried with the new secret.\n *\n * You must provide the following information:\n * - username: any kind of value that can identify the user (userId, groupId/userId, username, email, ...). More generic identifiers, valid\n * on multiple groups, allow for simpler group switching by using {@link IcureApi.switchGroup}.\n * - secretProvider: the secret provider to use for authentication. Will handle interaction with the gui.\n *\n * You can also provide the following optional information, which may allow to reduce the requests for secrets initially:\n * - initialSecret: an initial secret (password, token, ...) that will be used to get new authentication tokens as needed. If it is expired it will be ignored.\n * - initialAuthToken: an initial authentication token used on each request. If it is expired it will be ignored.\n * - initialRefreshToken: an initial refresh token used to get new authentication tokens as needed. If it is expired it will be ignored.\n */\nexport type SmartAuthenticationDetails = {\n username: string\n secretProvider: AuthSecretProvider\n initialSecret?:\n | {\n password: string\n }\n | {\n longToken: string\n }\n | {\n oauthToken: string\n oauthType: OAuthThirdParty\n }\n initialAuthToken?: string\n initialRefreshToken?: string\n}\n\n/**\n * Main entry point for the iCure API. Provides entity-specific sub-apis and some general methods which are not related to a specific entity.\n */\nexport interface IcureApi extends Apis {\n /**\n * Get the information on groups that the current user can access and the current group that this api instance is working on.\n * Note that the values you will get for `availableGroups` may differ from the values you would get if you call {@link IccUserApi.getMatchingUsers}\n * on {@link Apis.userApi}, since the latter is specialised on the specific instance of the user in `currentGroup`.\n * - `currentGroup`: the group that this api instance is working on, or undefined if the backend environment is not multi-group.\n * - `availableGroups`: the list of groups that the current user can access with the provided secret. Empty if the backend environment is not\n * multi-group.\n */\n getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }>\n\n /**\n * Switches the api to allow the user to work on a different group.\n * @param newGroupId the id of the group to switch to.\n * @return a new api for the specified group.\n */\n switchGroup(newGroupId: string): Promise<IcureApi>\n}\n\nexport namespace IcureApi {\n /**\n * Initialises a new instance of the iCure API.\n */\n export async function initialise(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n cryptoStrategies: CryptoStrategies,\n crypto: Crypto | CryptoPrimitives = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n options: IcureApiOptions = {}\n ): Promise<IcureApi> {\n const params = new IcureApiOptions.WithDefaults(options)\n let authenticationProviderInfo = await initialiseAuthProviderWithGroupSelector(\n host,\n authenticationOptions,\n params.headers,\n fetchImpl,\n params.groupSelector\n )\n const cryptoInitInfo = await initialiseCryptoWithProvider(\n host,\n fetchImpl,\n authenticationProviderInfo.groupSpecificAuthenticationProvider,\n params,\n cryptoStrategies,\n crypto,\n options.useLiteCompatibilityMode ?? false\n )\n return new IcureApiImpl(\n cryptoInitInfo,\n host,\n authenticationProviderInfo.groupSpecificAuthenticationProvider,\n fetch,\n authenticationProviderInfo.grouplessUserApi,\n authenticationProviderInfo.matches,\n authenticationProviderInfo.matches.find((match) => match.groupId === authenticationProviderInfo.chosenGroupId),\n params,\n cryptoStrategies,\n options.useLiteCompatibilityMode ?? false\n )\n }\n}\n\nasync function getAuthenticationProvider(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n headers: { [headerName: string]: string },\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n) {\n let authenticationProvider: AuthenticationProvider\n if ('getIcureTokens' in authenticationOptions && 'switchGroup' in authenticationOptions && 'getAuthService' in authenticationOptions) {\n authenticationProvider = authenticationOptions\n } else if ('icureTokens' in authenticationOptions && !!authenticationOptions.icureTokens) {\n authenticationProvider = new JwtAuthenticationProvider(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions?.credentials?.username,\n authenticationOptions?.credentials?.password,\n undefined,\n authenticationOptions.icureTokens\n )\n } else if (\n 'username' in authenticationOptions &&\n 'password' in authenticationOptions &&\n !!authenticationOptions.username &&\n !!authenticationOptions.password\n ) {\n authenticationProvider = new EnsembleAuthenticationProvider(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions.username,\n authenticationOptions.password,\n 3600,\n undefined,\n undefined,\n authenticationOptions.thirdPartyTokens\n )\n } else if ('thirdPartyTokens' in authenticationOptions && !!authenticationOptions.thirdPartyTokens) {\n authenticationProvider = new JwtAuthenticationProvider(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n undefined,\n undefined,\n new JwtBridgedAuthService(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n undefined,\n undefined,\n authenticationOptions.thirdPartyTokens,\n undefined\n )\n )\n } else if ('username' in authenticationOptions && 'secretProvider' in authenticationOptions) {\n authenticationProvider = SmartAuthProvider.initialise(\n new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions.username,\n authenticationOptions.secretProvider,\n {\n initialSecret: authenticationOptions.initialSecret,\n initialAuthToken: authenticationOptions.initialAuthToken,\n initialRefreshToken: authenticationOptions.initialRefreshToken,\n }\n )\n } else {\n throw new Error('Invalid authentication options provided')\n }\n return authenticationProvider\n}\n\nasync function initialiseAuthProviderWithGroupSelector(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n headers: { [headerName: string]: string },\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n groupSelector: ((availableGroupsInfo: UserGroup[], currentGroupId?: string) => Promise<string>) | undefined\n) {\n let grouplessAuthenticationProvider = await getAuthenticationProvider(host, authenticationOptions, headers, fetchImpl)\n const grouplessUserApi = new IccUserApi(host, headers, grouplessAuthenticationProvider, fetchImpl)\n const matches = await getMatchesOrEmpty(grouplessUserApi)\n const tokens = await grouplessAuthenticationProvider.getIcureTokens()\n const currentGroupId = tokens ? getGroupOfJwt(tokens.token) : undefined\n const chosenGroupId = matches.length > 1 && !!groupSelector ? await groupSelector(matches, currentGroupId) : matches[0]?.groupId\n /*TODO\n * On new very new users switching the authentication provider to a specific group may fail and block the user for too many requests. This is\n * probably linked to replication of the user in the fallback database.\n */\n /*\n * If the auth provider is initialized with credentials and jwt not switching the group will may cause issues:\n * 1. The default group for the user is group A\n * 2. The user logs in to group B -> the provider is switched\n * 3. The user refreshes the page -> a new instance of the api with initial iCure tokens is created\n * 4. The refresh token is expired / the user needs to do a high security operation -> a new login is done .If we did\n * not switch the provider here the login would default to group A, potentially causing a lot of issues...\n */\n const groupSpecificAuthenticationProvider = !!chosenGroupId\n ? await grouplessAuthenticationProvider.switchGroup(chosenGroupId, matches)\n : grouplessAuthenticationProvider\n return {\n groupSpecificAuthenticationProvider,\n // No need for a groupless user api on a group-specific smart auth provider\n grouplessUserApi: groupSpecificAuthenticationProvider instanceof SmartAuthProvider ? undefined : grouplessUserApi,\n matches,\n chosenGroupId,\n }\n}\n\n// Apis which are used during crypto api initialisation, to avoid re-instantiating them later\ntype CryptoInitialisationInfo = {\n cryptoApi: IccCryptoXApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceXApi\n // no patient api since it is base\n dataOwnerApi: IccDataOwnerXApi\n userApi: IccUserXApi\n icureMaintenanceTaskApi: IccIcureMaintenanceXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n headers: { [headerName: string]: string }\n dataOwnerRequiresAnonymousDelegation: boolean\n recoveryApi: IccRecoveryXApi\n}\n\nconst REQUEST_AUTOFIX_ANONYMITY_HEADER = 'Icure-Request-Autofix-Anonymity'\n\nasync function initialiseCryptoWithProvider(\n host: string,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n groupSpecificAuthenticationProvider: AuthenticationProvider,\n params: IcureApiOptions.WithDefaults,\n cryptoStrategies: CryptoStrategies,\n crypto: Crypto | CryptoPrimitives,\n useLiteCompatibilityMode: boolean\n): Promise<CryptoInitialisationInfo> {\n const initialDataOwnerStub = await new IccDataOwnerXApi(\n host,\n params.headers,\n groupSpecificAuthenticationProvider,\n fetchImpl\n ).getCurrentDataOwnerStub()\n const dataOwnerRequiresAnonymousDelegation = cryptoStrategies.dataOwnerRequiresAnonymousDelegation(initialDataOwnerStub)\n let updatedHeaders = params.headers\n if (!Object.keys(updatedHeaders).includes(REQUEST_AUTOFIX_ANONYMITY_HEADER)) {\n if (initialDataOwnerStub.type == DataOwnerTypeEnum.Patient || initialDataOwnerStub.type == DataOwnerTypeEnum.Device) {\n if (!dataOwnerRequiresAnonymousDelegation) {\n updatedHeaders = { ...updatedHeaders, [REQUEST_AUTOFIX_ANONYMITY_HEADER]: 'false' }\n }\n } else {\n if (dataOwnerRequiresAnonymousDelegation) {\n updatedHeaders = { ...updatedHeaders, [REQUEST_AUTOFIX_ANONYMITY_HEADER]: 'true' }\n }\n }\n }\n\n const authApi = new IccAuthApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, authApi, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, authApi, fetchImpl)\n const deviceApi = new IccDeviceXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, userApi, authApi, fetchImpl)\n const basePatientApi = new IccPatientApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const dataOwnerApi = new IccDataOwnerXApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const exchangeDataApi = new IccExchangeDataApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n const baseRecoveryDataApi = new IccRecoveryDataApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n // Crypto initialisation\n const icureStorage = new IcureStorageFacade(params.keyStorage, params.storage, params.entryKeysFactory)\n const cryptoPrimitives = 'AES' in crypto && 'RSA' in crypto && 'HMAC' in crypto ? crypto : new WebCryptoPrimitives(crypto)\n const baseExchangeKeysManager = new BaseExchangeKeysManager(cryptoPrimitives, dataOwnerApi, healthcarePartyApi, basePatientApi, deviceApi)\n const baseExchangeDataManager = new BaseExchangeDataManager(\n exchangeDataApi,\n dataOwnerApi,\n cryptoPrimitives,\n dataOwnerRequiresAnonymousDelegation,\n useLiteCompatibilityMode\n )\n const keyRecovery = new KeyRecovery(cryptoPrimitives, dataOwnerApi, baseExchangeKeysManager, baseExchangeDataManager)\n const recoveryDataEncryption = new RecoveryDataEncryption(cryptoPrimitives, baseRecoveryDataApi)\n const keyPairRecoverer = new KeyPairRecoverer(recoveryDataEncryption)\n const userEncryptionKeysManager = new UserEncryptionKeysManager(\n cryptoPrimitives,\n dataOwnerApi,\n icureStorage,\n keyRecovery,\n cryptoStrategies,\n !params.disableParentKeysInitialisation,\n keyPairRecoverer,\n dataOwnerRequiresAnonymousDelegation\n )\n const newKey = await userEncryptionKeysManager.initialiseKeys()\n await new TransferKeysManager(cryptoPrimitives, baseExchangeDataManager, dataOwnerApi, userEncryptionKeysManager, icureStorage).updateTransferKeys(\n await dataOwnerApi.getCurrentDataOwnerStub()\n )\n // TODO customise cache size?\n const exchangeKeysManager = new ExchangeKeysManager(userEncryptionKeysManager, baseExchangeKeysManager, dataOwnerApi)\n // noinspection ES6MissingAwait\n exchangeKeysManager.reloadCache() // Intentionally not awaited to make login feel faster\n const accessControlSecretUtils = new AccessControlSecretUtils(cryptoPrimitives)\n const exchangeDataManager = await initialiseExchangeDataManagerForCurrentDataOwner(\n baseExchangeDataManager,\n userEncryptionKeysManager,\n accessControlSecretUtils,\n cryptoStrategies,\n dataOwnerApi,\n cryptoPrimitives,\n !params.disableParentKeysInitialisation\n )\n if (params.injectExchangeData != null && params.injectExchangeData.details.length > 0) {\n await exchangeDataManager.injectDecryptedExchangeData(params.injectExchangeData.details, params.injectExchangeData.reEncryptWithOwnKeys)\n }\n const exchangeDataMapManager = new ExchangeDataMapManager(\n new IccExchangeDataMapApi(host, updatedHeaders, groupSpecificAuthenticationProvider, fetchImpl)\n )\n const secureDelegationsEncryption = new SecureDelegationsEncryption(userEncryptionKeysManager, cryptoPrimitives)\n const secureDelegationsSecurityMetadataEncryption = new SecurityMetadataDecryptor(\n exchangeKeysManager,\n cryptoPrimitives,\n exchangeDataManager,\n exchangeDataMapManager,\n secureDelegationsEncryption,\n dataOwnerApi\n )\n const xApiUtils = new ExtendedApisUtilsImpl(\n cryptoPrimitives,\n dataOwnerApi,\n secureDelegationsSecurityMetadataEncryption,\n new SecureDelegationsManager(\n exchangeDataManager,\n exchangeDataMapManager,\n secureDelegationsEncryption,\n accessControlSecretUtils,\n userEncryptionKeysManager,\n cryptoPrimitives,\n dataOwnerApi,\n cryptoStrategies,\n dataOwnerRequiresAnonymousDelegation\n ),\n userApi,\n !params.disableParentKeysInitialisation\n )\n const shamirManager = new ShamirKeysManager(cryptoPrimitives, dataOwnerApi, userEncryptionKeysManager, exchangeDataManager)\n if (userEncryptionKeysManager.getSelfVerifiedKeys().length > 0) {\n await ensureDelegationForSelf(dataOwnerApi, xApiUtils, basePatientApi, cryptoPrimitives)\n }\n const accessControlKeysHeadersProvider = new AccessControlKeysHeadersProvider(exchangeDataManager)\n const delegationsDeAnonymisation = new DelegationsDeAnonymization(\n dataOwnerApi,\n secureDelegationsSecurityMetadataEncryption,\n xApiUtils,\n cryptoPrimitives,\n accessControlSecretUtils,\n host,\n updatedHeaders,\n groupSpecificAuthenticationProvider,\n fetchImpl,\n accessControlKeysHeadersProvider\n )\n const cryptoApi = new IccCryptoXApi(\n exchangeKeysManager,\n cryptoPrimitives,\n userEncryptionKeysManager,\n dataOwnerApi,\n xApiUtils,\n shamirManager,\n params.storage,\n params.keyStorage,\n exchangeDataManager,\n accessControlKeysHeadersProvider,\n delegationsDeAnonymisation\n )\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(\n host,\n updatedHeaders,\n cryptoApi,\n healthcarePartyApi,\n dataOwnerApi,\n userApi,\n authApi,\n !dataOwnerRequiresAnonymousDelegation,\n params.encryptedFieldsConfig.maintenanceTask ?? EncryptedFieldsConfig.Defaults.maintenanceTask,\n groupSpecificAuthenticationProvider,\n fetchImpl\n )\n const icureMaintenanceTaskApi = new IccIcureMaintenanceXApi(cryptoApi, maintenanceTaskApi, dataOwnerApi, exchangeDataApi)\n\n if (newKey && params.createMaintenanceTasksOnNewKey) {\n await icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(await userApi.getCurrentUser(), newKey.newKeyPair)\n }\n return {\n cryptoApi,\n userApi,\n healthcarePartyApi,\n deviceApi,\n maintenanceTaskApi,\n dataOwnerApi,\n icureMaintenanceTaskApi,\n headers: updatedHeaders,\n dataOwnerRequiresAnonymousDelegation,\n recoveryApi: new IccRecoveryXApi(\n baseRecoveryDataApi,\n recoveryDataEncryption,\n userEncryptionKeysManager,\n dataOwnerApi,\n cryptoPrimitives,\n exchangeDataManager\n ),\n }\n}\n\nclass IcureApiImpl implements IcureApi {\n private latestGroupsRequest: Promise<UserGroup[]>\n\n constructor(\n private readonly cryptoInitInfos: CryptoInitialisationInfo,\n private readonly host: string,\n private readonly groupSpecificAuthenticationProvider: AuthenticationProvider,\n private readonly fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n private readonly grouplessUserApi: IccUserApi | undefined,\n latestMatches: UserGroup[],\n private readonly currentGroupInfo: UserGroup | undefined,\n private readonly params: IcureApiOptions.WithDefaults,\n private readonly cryptoStrategies: CryptoStrategies,\n private readonly useLiteCompatibilityMode: boolean\n ) {\n this.latestGroupsRequest = Promise.resolve(latestMatches)\n }\n\n private _authApi: IccAuthApi | undefined\n\n get recoveryApi(): IccRecoveryXApi {\n return this.cryptoInitInfos.recoveryApi\n }\n\n get authApi(): IccAuthApi {\n return (\n this._authApi ?? (this._authApi = new IccAuthApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _codeApi: IccCodeXApi | undefined\n\n get codeApi(): IccCodeXApi {\n return (\n this._codeApi ??\n (this._codeApi = new IccCodeXApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _calendarItemTypeApi: IccCalendarItemTypeApi | undefined\n\n get calendarItemTypeApi(): IccCalendarItemTypeApi {\n return (\n this._calendarItemTypeApi ??\n (this._calendarItemTypeApi = new IccCalendarItemTypeApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _medicalLocationApi: IccMedicallocationApi | undefined\n\n get medicalLocationApi(): IccMedicallocationApi {\n return (\n this._medicalLocationApi ??\n (this._medicalLocationApi = new IccMedicallocationApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _roleApi: IccRoleApi | undefined\n\n get roleApi(): IccRoleApi {\n return this._roleApi ?? (this._roleApi = new IccRoleApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n\n private _entityReferenceApi: IccEntityrefApi | undefined\n\n get entityReferenceApi(): IccEntityrefApi {\n return (\n this._entityReferenceApi ??\n (this._entityReferenceApi = new IccEntityrefApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _permissionApi: IccPermissionApi | undefined\n\n get permissionApi(): IccPermissionApi {\n return (\n this._permissionApi ??\n (this._permissionApi = new IccPermissionApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _accessLogApi: IccAccesslogXApi | undefined\n\n get accessLogApi(): IccAccesslogXApi {\n return (\n this._accessLogApi ??\n (this._accessLogApi = new IccAccesslogXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.accessLog ?? EncryptedFieldsConfig.Defaults.accessLog,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _agendaApi: IccAgendaApi | undefined\n\n get agendaApi(): IccAgendaApi {\n return (\n this._agendaApi ??\n (this._agendaApi = new IccAgendaApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _contactApi: IccContactXApi | undefined\n\n get contactApi(): IccContactXApi {\n return (\n this._contactApi ??\n (this._contactApi = new IccContactXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.userApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch,\n this.params.encryptedFieldsConfig.contact ?? EncryptedFieldsConfig.Defaults.contact,\n this.params.encryptedFieldsConfig.service ?? EncryptedFieldsConfig.Defaults.service\n ))\n )\n }\n\n private _formApi: IccFormXApi | undefined\n\n get formApi(): IccFormXApi {\n return (\n this._formApi ??\n (this._formApi = new IccFormXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _groupApi: IccGroupApi | undefined\n\n get groupApi(): IccGroupApi {\n return (\n this._groupApi ??\n (this._groupApi = new IccGroupApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _invoiceApi: IccInvoiceXApi | undefined\n\n get invoiceApi(): IccInvoiceXApi {\n return (\n this._invoiceApi ??\n (this._invoiceApi = new IccInvoiceXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.entityReferenceApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _insuranceApi: IccInsuranceApi | undefined\n\n get insuranceApi(): IccInsuranceApi {\n return (\n this._insuranceApi ??\n (this._insuranceApi = new IccInsuranceApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _documentApi: IccDocumentXApi | undefined\n\n get documentApi(): IccDocumentXApi {\n return (\n this._documentApi ??\n (this._documentApi = new IccDocumentXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.authApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _healthcareElementApi: IccHelementXApi | undefined\n\n get healthcareElementApi(): IccHelementXApi {\n return (\n this._healthcareElementApi ??\n (this._healthcareElementApi = new IccHelementXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.userApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.healthElement ?? EncryptedFieldsConfig.Defaults.healthElement,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _classificationApi: IccClassificationXApi | undefined\n\n get classificationApi(): IccClassificationXApi {\n return (\n this._classificationApi ??\n (this._classificationApi = new IccClassificationXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _calendarItemApi: IccCalendarItemXApi | undefined\n\n get calendarItemApi(): IccCalendarItemXApi {\n return (\n this._calendarItemApi ??\n (this._calendarItemApi = new IccCalendarItemXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.calendarItem ?? EncryptedFieldsConfig.Defaults.calendarItem,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _receiptApi: IccReceiptXApi | undefined\n\n get receiptApi(): IccReceiptXApi {\n return (\n this._receiptApi ??\n (this._receiptApi = new IccReceiptXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _timetableApi: IccTimeTableXApi | undefined\n\n get timetableApi(): IccTimeTableXApi {\n return (\n this._timetableApi ??\n (this._timetableApi = new IccTimeTableXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _patientApi: IccPatientXApi | undefined\n\n get patientApi(): IccPatientXApi {\n return (\n this._patientApi ??\n (this._patientApi = new IccPatientXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.contactApi,\n this.formApi,\n this.healthcareElementApi,\n this.invoiceApi,\n this.documentApi,\n this.healthcarePartyApi,\n this.classificationApi,\n this.dataOwnerApi,\n this.calendarItemApi,\n this.userApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.params.encryptedFieldsConfig.patient ?? EncryptedFieldsConfig.Defaults.patient,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _messageApi: IccMessageXApi | undefined\n\n get messageApi(): IccMessageXApi {\n return (\n this._messageApi ??\n (this._messageApi = new IccMessageXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.params.encryptedFieldsConfig.message ?? EncryptedFieldsConfig.Defaults.message,\n this.fetch\n ))\n )\n }\n\n private _topicApi: IccTopicXApi | undefined\n\n get topicApi(): IccTopicXApi {\n return (\n this._topicApi ??\n (this._topicApi = new IccTopicXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.dataOwnerApi,\n this.authApi,\n !this.cryptoInitInfos.dataOwnerRequiresAnonymousDelegation,\n this.groupSpecificAuthenticationProvider,\n this.params.encryptedFieldsConfig.topic ?? EncryptedFieldsConfig.Defaults.topic,\n this.fetch\n ))\n )\n }\n\n private _anonymousAccessApi: IccAnonymousAccessApi | undefined\n\n get anonymousAccessApi(): IccAnonymousAccessApi {\n return (\n this._anonymousAccessApi ??\n (this._anonymousAccessApi = new IccAnonymousAccessApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _applicationSettingsApi: IccApplicationsettingsApi | undefined\n\n get applicationSettingsApi(): IccApplicationsettingsApi {\n return (\n this._applicationSettingsApi ??\n (this._applicationSettingsApi = new IccApplicationsettingsApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _bekmehrApi: IccBekmehrXApi | undefined\n\n get bekmehrApi(): IccBekmehrXApi {\n return (\n this._bekmehrApi ??\n (this._bekmehrApi = new IccBekmehrXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.contactApi,\n this.healthcareElementApi,\n this.documentApi,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _beefactApi: IccBeefactApi | undefined\n\n get beefactApi(): IccBeefactApi {\n return (\n this._beefactApi ??\n (this._beefactApi = new IccBeefactApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _beresultexportApi: IccBeresultexportApi | undefined\n\n get beresultexportApi(): IccBeresultexportApi {\n return (\n this._beresultexportApi ??\n (this._beresultexportApi = new IccBeresultexportApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _beresultimportApi: IccBeresultimportApi | undefined\n\n get beresultimportApi(): IccBeresultimportApi {\n return (\n this._beresultimportApi ??\n (this._beresultimportApi = new IccBeresultimportApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _besamv2Api: IccBesamv2Api | undefined\n\n get besamv2Api(): IccBesamv2Api {\n return (\n this._besamv2Api ??\n (this._besamv2Api = new IccBesamv2Api(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _classificationTemplateApi: IccClassificationTemplateApi | undefined\n\n get classificationTemplateApi(): IccClassificationTemplateApi {\n return (\n this._classificationTemplateApi ??\n (this._classificationTemplateApi = new IccClassificationTemplateApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _doctemplateApi: IccDoctemplateXApi | undefined\n\n get doctemplateApi(): IccDoctemplateXApi {\n return (\n this._doctemplateApi ??\n (this._doctemplateApi = new IccDoctemplateXApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.cryptoApi,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _entitytemplateApi: IccEntitytemplateApi | undefined\n\n get entitytemplateApi(): IccEntitytemplateApi {\n return (\n this._entitytemplateApi ??\n (this._entitytemplateApi = new IccEntitytemplateApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _frontendmigrationApi: IccFrontendmigrationApi | undefined\n\n get frontendmigrationApi(): IccFrontendmigrationApi {\n return (\n this._frontendmigrationApi ??\n (this._frontendmigrationApi = new IccFrontendmigrationApi(\n this.host,\n this.cryptoInitInfos.headers,\n this.groupSpecificAuthenticationProvider,\n this.fetch\n ))\n )\n }\n\n private _icureApi: IccIcureApi | undefined\n\n get icureApi(): IccIcureApi {\n return (\n this._icureApi ??\n (this._icureApi = new IccIcureApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _keywordApi: IccKeywordApi | undefined\n\n get keywordApi(): IccKeywordApi {\n return (\n this._keywordApi ??\n (this._keywordApi = new IccKeywordApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _medexApi: IccMedexApi | undefined\n\n get medexApi(): IccMedexApi {\n return (\n this._medexApi ??\n (this._medexApi = new IccMedexApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _placeApi: IccPlaceApi | undefined\n\n get placeApi(): IccPlaceApi {\n return (\n this._placeApi ??\n (this._placeApi = new IccPlaceApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _pubsubApi: IccPubsubApi | undefined\n\n get pubsubApi(): IccPubsubApi {\n return (\n this._pubsubApi ??\n (this._pubsubApi = new IccPubsubApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _replicationApi: IccReplicationApi | undefined\n\n get replicationApi(): IccReplicationApi {\n return (\n this._replicationApi ??\n (this._replicationApi = new IccReplicationApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _tarificationApi: IccTarificationApi | undefined\n\n get tarificationApi(): IccTarificationApi {\n return (\n this._tarificationApi ??\n (this._tarificationApi = new IccTarificationApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n private _tmpApi: IccTmpApi | undefined\n\n get tmpApi(): IccTmpApi {\n return (\n this._tmpApi ?? (this._tmpApi = new IccTmpApi(this.host, this.cryptoInitInfos.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n get cryptoApi(): IccCryptoXApi {\n return this.cryptoInitInfos.cryptoApi\n }\n\n get dataOwnerApi(): IccDataOwnerXApi {\n return this.cryptoInitInfos.dataOwnerApi\n }\n\n get deviceApi(): IccDeviceXApi {\n return this.cryptoInitInfos.deviceApi\n }\n\n get healthcarePartyApi(): IccHcpartyXApi {\n return this.cryptoInitInfos.healthcarePartyApi\n }\n\n get icureMaintenanceTaskApi(): IccIcureMaintenanceXApi {\n return this.cryptoInitInfos.icureMaintenanceTaskApi\n }\n\n get maintenanceTaskApi(): IccMaintenanceTaskXApi {\n return this.cryptoInitInfos.maintenanceTaskApi\n }\n\n get userApi(): IccUserXApi {\n return this.cryptoInitInfos.userApi\n }\n\n async getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }> {\n this.latestGroupsRequest = (this.grouplessUserApi ?? this.userApi).getMatchingUsers()\n return { currentGroup: this.currentGroupInfo, availableGroups: await this.latestGroupsRequest }\n }\n\n async switchGroup(newGroupId: string): Promise<IcureApi> {\n const availableGroups = await this.latestGroupsRequest\n const switchedProvider = await this.groupSpecificAuthenticationProvider.switchGroup(newGroupId, availableGroups)\n const cryptoInitInfos = await initialiseCryptoWithProvider(\n this.host,\n this.fetch,\n switchedProvider,\n this.params,\n this.cryptoStrategies,\n this.cryptoApi.primitives,\n this.useLiteCompatibilityMode\n )\n return new IcureApiImpl(\n cryptoInitInfos,\n this.host,\n switchedProvider,\n this.fetch,\n this.grouplessUserApi,\n availableGroups,\n availableGroups.find((x) => x.groupId === newGroupId)!,\n this.params,\n this.cryptoStrategies,\n this.useLiteCompatibilityMode\n )\n }\n}\n\nexport interface IcureBasicApi extends BasicApis {\n /**\n * Get the information on groups that the current user can access and the current group that this api instance is working on.\n * Note that the values you will get for `availableGroups` may differ from the values you would get if you call {@link IccUserApi.getMatchingUsers}\n * on {@link Apis.userApi}, since the latter is specialised on the specific instance of the user in `currentGroup`.\n * - `currentGroup`: the group that this api instance is working on, or undefined if the backend environment is not multi-group.\n * - `availableGroups`: the list of groups that the current user can access with the provided secret. Empty if the backend environment is not\n * multi-group.\n */\n getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }>\n\n /**\n * Switches the api to allow the user to work on a different group.\n * @param newGroupId the id of the group to switch to.\n * @return a new api for the specified group.\n */\n switchGroup(newGroupId: string): Promise<IcureBasicApi>\n}\n\nclass IcureBasicApiImpl implements IcureBasicApi {\n private latestGroupsRequest: Promise<UserGroup[]>\n private _agendaApi: IccAgendaApi | undefined\n private _authApi: IccAuthApi | undefined\n private _codeApi: IccCodeXApi | undefined\n private _deviceApi: IccDeviceXApi | undefined\n private _entityReferenceApi: IccEntityrefApi | undefined\n private _groupApi: IccGroupApi | undefined\n private _healthcarePartyApi: IccHcpartyXApi | undefined\n private _insuranceApi: IccInsuranceApi | undefined\n private _permissionApi: IccPermissionApi | undefined\n private _userApi: IccUserXApi | undefined\n private _patientApi: IccPatientApi | undefined\n private _roleApi: IccRoleApi | undefined\n\n get agendaApi(): IccAgendaApi {\n return (\n this._agendaApi ?? (this._agendaApi = new IccAgendaApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get authApi(): IccAuthApi {\n return this._authApi ?? (this._authApi = new IccAuthApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n get codeApi(): IccCodeXApi {\n return this._codeApi ?? (this._codeApi = new IccCodeXApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n get deviceApi(): IccDeviceXApi {\n return (\n this._deviceApi ??\n (this._deviceApi = new IccDeviceXApi(\n this.host,\n this.params.headers,\n this.groupSpecificAuthenticationProvider,\n this.userApi,\n this.authApi,\n this.fetch\n ))\n )\n }\n get entityReferenceApi(): IccEntityrefApi {\n return (\n this._entityReferenceApi ??\n (this._entityReferenceApi = new IccEntityrefApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get groupApi(): IccGroupApi {\n return this._groupApi ?? (this._groupApi = new IccGroupApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n get healthcarePartyApi(): IccHcpartyXApi {\n return (\n this._healthcarePartyApi ??\n (this._healthcarePartyApi = new IccHcpartyXApi(\n this.host,\n this.params.headers,\n this.groupSpecificAuthenticationProvider,\n this.authApi,\n this.fetch\n ))\n )\n }\n get insuranceApi(): IccInsuranceApi {\n return (\n this._insuranceApi ??\n (this._insuranceApi = new IccInsuranceApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get permissionApi(): IccPermissionApi {\n return (\n this._permissionApi ??\n (this._permissionApi = new IccPermissionApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n get userApi(): IccUserXApi {\n return (\n this._userApi ??\n (this._userApi = new IccUserXApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.authApi, this.fetch))\n )\n }\n\n async getGroupsInfo(): Promise<{ currentGroup: UserGroup | undefined; availableGroups: UserGroup[] }> {\n if (!this.currentGroupInfo) return { currentGroup: undefined, availableGroups: [] }\n this.latestGroupsRequest = (this.grouplessUserApi ?? this.userApi).getMatchingUsers()\n return { currentGroup: this.currentGroupInfo, availableGroups: await this.latestGroupsRequest }\n }\n\n get patientApi(): IccPatientApi {\n return (\n this._patientApi ?? (this._patientApi = new IccPatientApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n )\n }\n\n get roleApi(): IccRoleApi {\n return this._roleApi ?? (this._roleApi = new IccRoleApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch))\n }\n\n async switchGroup(newGroupId: string): Promise<IcureBasicApi> {\n if (!this.currentGroupInfo) throw new Error('Cannot switch group: the backend environment does not support multiple groups.')\n const availableGroups = await this.latestGroupsRequest\n const switchedProvider = await this.groupSpecificAuthenticationProvider.switchGroup(newGroupId, availableGroups)\n return new IcureBasicApiImpl(\n this.host,\n switchedProvider,\n this.fetch,\n this.grouplessUserApi,\n availableGroups,\n availableGroups.find((x) => x.groupId === newGroupId)!,\n this.params\n )\n }\n\n constructor(\n private readonly host: string,\n private readonly groupSpecificAuthenticationProvider: AuthenticationProvider,\n private readonly fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\n private readonly grouplessUserApi: IccUserApi | undefined,\n latestMatches: UserGroup[],\n private readonly currentGroupInfo: UserGroup | undefined,\n private readonly params: IcureBasicApiOptions.WithDefaults\n ) {\n this.latestGroupsRequest = Promise.resolve(latestMatches)\n }\n}\n\nexport interface IcureBasicApiOptions {\n /**\n * Additional headers to use on each request made by the iCure api.\n * @default no additional headers\n */\n readonly headers?: { [headerName: string]: string }\n /**\n * Each user may exist in multiple groups, but an instance of {@link IcureApi} is specialised for a single group. This function allows you to decide\n * the group to use for a given user.\n * This functions will be called only if a user exists in at least 2 groups, and takes in input:\n * - the information on the groups the user can access (in no specific order)\n * - if the authentication method uses JWT also the current group id (undefined otherwise)\n * The function must return the id of one of the available groups.\n * @default takes the first group provided. The group chosen by this method may vary between different instantiations of the {@link IcureApi} even\n * if for the same user and if the groups available for the user do not change.\n */\n readonly groupSelector?: (availableGroupsInfo: UserGroup[], currentGroupId?: string) => Promise<string>\n}\n\nnamespace IcureBasicApiOptions {\n export namespace Defaults {\n export const headers = {}\n }\n export class WithDefaults implements IcureBasicApiOptions {\n constructor(custom: IcureBasicApiOptions) {\n this.headers = custom.headers ?? Defaults.headers\n this.groupSelector = custom.groupSelector ?? ((groups) => Promise.resolve(groups[0].groupId!))\n }\n\n readonly headers: { [headerName: string]: string }\n readonly groupSelector: (availableGroupsInfo: UserGroup[]) => Promise<string>\n }\n}\n\nexport namespace IcureBasicApi {\n /**\n * Initialises a new instance of the iCure API.\n */\n export async function initialise(\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n options: IcureBasicApiOptions = {}\n ): Promise<IcureBasicApi> {\n const params = new IcureBasicApiOptions.WithDefaults(options)\n const authProviderInfo = await initialiseAuthProviderWithGroupSelector(\n host,\n authenticationOptions,\n params.headers ?? {},\n fetchImpl,\n params.groupSelector\n )\n return new IcureBasicApiImpl(\n host,\n authProviderInfo.groupSpecificAuthenticationProvider,\n fetch,\n authProviderInfo.grouplessUserApi,\n authProviderInfo.matches,\n authProviderInfo.matches.find((match) => match.groupId === authProviderInfo.chosenGroupId),\n params\n )\n }\n}\n\nasync function getMatchesOrEmpty(userApi: IccUserApi): Promise<UserGroup[]> {\n try {\n return await userApi.getMatchingUsers()\n } catch (err) {\n if (err instanceof Error && 'statusCode' in err && (err as any).statusCode === 404) return Promise.resolve([])\n else return Promise.reject(err)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ const _ = require("lodash");
|
|
|
17
17
|
const utils_1 = require("../../icc-x-api/crypto/utils");
|
|
18
18
|
class FakeEncryptionKeysManager extends UserEncryptionKeysManager_1.UserEncryptionKeysManager {
|
|
19
19
|
constructor(keys) {
|
|
20
|
-
super(null, null, null, null, null, null, null);
|
|
20
|
+
super(null, null, null, null, null, null, null, null);
|
|
21
21
|
this.keys = keys;
|
|
22
22
|
}
|
|
23
23
|
static create(primitives, verifiedKeys, unverifiedKeys = []) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeEncryptionKeysManager.js","sourceRoot":"","sources":["../../../test/utils/FakeEncryptionKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gGAA4F;AAE5F,oDAAgE;AAEhE,+CAAwC;AACxC,4BAA2B;AAC3B,wDAA4D;AAE5D,MAAa,yBAA0B,SAAQ,qDAAyB;IACtE,YAA6B,IAAgF;QAC3G,KAAK,CAAC,IAAW,EAAE,IAAW,EAAE,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C,EAAU;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACtB,CAAC;IAEK,cAAc,CAAC,UAA4B,EAAE,IAAwB,EAAE,QAAiB;;YAC5F,MAAM,EAAE,GAAG,IAAA,qBAAa,EAAC,IAAA,kBAAM,EAAC,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;YACxF,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;QACpC,CAAC;KAAA;IAEK,wCAAwC,CAAC,UAA4B;;YACzE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACjC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAA;YACpB,CAAC,CAAC,CAAA;YACF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,gBAAU,CAAC,MAAM,CAAC,CAAA;YACtE,MAAM,QAAQ,GAAG,IAAA,qBAAa,EAAC,IAAA,kBAAM,EAAC,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;YAChG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QACxD,CAAC;KAAA;CACF;AA3ED,8DA2EC","sourcesContent":["import { UserEncryptionKeysManager } from '../../icc-x-api/crypto/UserEncryptionKeysManager'\nimport { DataOwner } from '../../icc-x-api/icc-data-owner-x-api'\nimport { KeyPair, ShaVersion } from '../../icc-x-api/crypto/RSA'\nimport { CryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { ua2hex } from '../../icc-x-api'\nimport * as _ from 'lodash'\nimport { fingerprintV1 } from '../../icc-x-api/crypto/utils'\n\nexport class FakeEncryptionKeysManager extends UserEncryptionKeysManager {\n constructor(private readonly keys: { [fingerprint: string]: { pair: KeyPair<CryptoKey>; verified: boolean } }) {\n super(null as any, null as any, null as any, null as any, null as any, null as any, null as any, null as any)\n }\n\n static async create(\n primitives: CryptoPrimitives,\n verifiedKeys: KeyPair<CryptoKey>[],\n unverifiedKeys: KeyPair<CryptoKey>[] = []\n ): Promise<FakeEncryptionKeysManager> {\n const keysByFingerprint = {} as { [fingerprint: string]: { pair: KeyPair<CryptoKey>; verified: boolean } }\n for (const key of verifiedKeys) {\n const fingerprint = fingerprintV1(ua2hex(await primitives.RSA.exportKey(key.publicKey, 'spki')))\n keysByFingerprint[fingerprint] = { pair: key, verified: true }\n }\n for (const key of unverifiedKeys) {\n const fingerprint = fingerprintV1(ua2hex(await primitives.RSA.exportKey(key.publicKey, 'spki')))\n keysByFingerprint[fingerprint] = { pair: key, verified: false }\n }\n return new FakeEncryptionKeysManager(keysByFingerprint)\n }\n\n async getCurrentUserAvailablePublicKeysHex(verifiedOnly: boolean): Promise<string[]> {\n throw new Error('Not implemented')\n }\n\n async getCurrentUserHierarchyAvailablePublicKeysHex(): Promise<string[]> {\n throw new Error('Not implemented')\n }\n\n getKeyPairForFingerprint(fingerprint: string): { pair: KeyPair<CryptoKey>; verified: boolean } | undefined {\n const key = this.keys[fingerprint]\n if (key) return _.cloneDeep(key)\n return undefined\n }\n\n async initialiseKeys(): Promise<{ newKeyPair: KeyPair<CryptoKey>; newKeyFingerprint: string } | undefined> {\n return Promise.resolve(undefined)\n }\n\n async reloadKeys(): Promise<void> {}\n\n getSelfVerifiedKeys(): { fingerprint: string; pair: KeyPair<CryptoKey> }[] {\n const res = []\n for (const [fingerprint, { pair, verified }] of Object.entries(this.keys)) {\n if (verified) res.push({ fingerprint, pair })\n }\n return res\n }\n\n async getVerifiedPublicKeysFor(dataOwner: DataOwner): Promise<string[]> {\n throw new Error('Not implemented')\n }\n\n getDecryptionKeys(): { [p: string]: KeyPair<CryptoKey> } {\n return Object.fromEntries(Object.entries(this.keys).map(([fp, { pair }]) => [fp, pair]))\n }\n\n deleteKey(fp: string) {\n delete this.keys[fp]\n }\n\n async addOrUpdateKey(primitives: CryptoPrimitives, pair: KeyPair<CryptoKey>, verified: boolean) {\n const fp = fingerprintV1(ua2hex(await primitives.RSA.exportKey(pair.publicKey, 'spki')))\n this.keys[fp] = { pair, verified }\n }\n\n async unverifyExistingKeysAndCreateNewVerified(primitives: CryptoPrimitives) {\n Object.values(this.keys).map((x) => {\n x.verified = false\n })\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const newKeyFp = fingerprintV1(ua2hex(await primitives.RSA.exportKey(newKey.publicKey, 'spki')))\n this.keys[newKeyFp] = { pair: newKey, verified: true }\n }\n}\n"]}
|