@icure/api 7.0.0-beta.2 → 7.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccDataownerApi.d.ts +13 -2
- package/icc-api/api/IccDataownerApi.js +30 -4
- package/icc-api/api/IccDataownerApi.js.map +1 -1
- package/icc-api/model/CryptoActorStub.d.ts +55 -0
- package/icc-api/model/CryptoActorStub.js +35 -0
- package/icc-api/model/CryptoActorStub.js.map +1 -0
- package/icc-api/model/DataOwnerTypeEnum.d.ts +8 -0
- package/icc-api/model/DataOwnerTypeEnum.js +13 -0
- package/icc-api/model/DataOwnerTypeEnum.js.map +1 -0
- package/icc-api/model/DataOwnerWithType.d.ts +16 -3
- package/icc-api/model/DataOwnerWithType.js +22 -7
- package/icc-api/model/DataOwnerWithType.js.map +1 -1
- package/icc-api/model/Device.d.ts +4 -0
- package/icc-api/model/Device.js.map +1 -1
- package/icc-api/model/HealthcareParty.d.ts +4 -0
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/Patient.d.ts +4 -0
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-x-api/crypto/AES.js +9 -1
- package/icc-x-api/crypto/AES.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeKeysManager.d.ts +4 -2
- package/icc-x-api/crypto/BaseExchangeKeysManager.js +32 -31
- package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
- package/icc-x-api/crypto/CryptoStrategies.d.ts +5 -4
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/EntitiesEncryption.js +2 -2
- package/icc-x-api/crypto/EntitiesEncryption.js.map +1 -1
- package/icc-x-api/crypto/ExchangeKeysManager.d.ts +3 -2
- package/icc-x-api/crypto/ExchangeKeysManager.js +3 -3
- package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -1
- package/icc-x-api/crypto/KeyManager.js +4 -4
- package/icc-x-api/crypto/KeyManager.js.map +1 -1
- package/icc-x-api/crypto/KeyRecovery.d.ts +2 -1
- package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
- package/icc-x-api/crypto/LegacyCryptoStrategies.d.ts +5 -4
- package/icc-x-api/crypto/LegacyCryptoStrategies.js +1 -1
- package/icc-x-api/crypto/LegacyCryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/ShamirKeysManager.d.ts +4 -3
- package/icc-x-api/crypto/ShamirKeysManager.js +8 -7
- package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
- package/icc-x-api/crypto/TransferKeysManager.d.ts +3 -2
- package/icc-x-api/crypto/TransferKeysManager.js +6 -6
- package/icc-x-api/crypto/TransferKeysManager.js.map +1 -1
- package/icc-x-api/crypto/utils.d.ts +7 -6
- package/icc-x-api/crypto/utils.js +4 -7
- package/icc-x-api/crypto/utils.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.js +3 -0
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +6 -6
- package/icc-x-api/icc-crypto-x-api.js +4 -4
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-data-owner-x-api.d.ts +21 -52
- package/icc-x-api/icc-data-owner-x-api.js +36 -68
- package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
- package/icc-x-api/icc-icure-maintenance-x-api.js +4 -4
- package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -1
- package/icc-x-api/index.js +4 -3
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-data-owner-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-data-owner-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,0CAAgD;AAEhD,4CAAwC;AAM3B,QAAA,iBAAiB,GAAyC;IACrE,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,GAAG,E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,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAA;YACtE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC5C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAA;YACrC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAA;YAChB,OAAQ,IAAI,CAAC,SAA6B,CAAC,QAAQ,EAAE;gBACnD,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAE,IAAI,CAAC,SAA6B,CAAC,QAAS,CAAC,CAAA;gBAC7E,GAAG,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAA;aACrB;YACD,IAAI,CAAC,4BAA4B,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAG,CAAC,CAAA;YACnE,OAAO,GAAG,CAAA;QACZ,CAAC;KAAA;IAEO,WAAW,CAAC,CAAe;QACjC,MAAM,CAAC,CAAA;IACT,CAAC;CACF;AA1MD,4CA0MC","sourcesContent":["import { User } from '../icc-api/model/User'\nimport { IccDeviceApi, IccPatientApi, IccUserApi } from '../icc-api'\nimport { HealthcareParty } from '../icc-api/model/HealthcareParty'\nimport { Patient } from '../icc-api/model/Patient'\nimport { Device } from '../icc-api/model/Device'\nimport { hexPublicKeysOf } from './crypto/utils'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { XHR } from '../icc-api/api/XHR'\n\n/**\n * Represents a type of data owner.\n */\nexport type DataOwnerTypeEnum = 'patient' | 'device' | 'hcp'\nexport const DataOwnerTypeEnum: { [key: string]: DataOwnerTypeEnum } = {\n Patient: 'patient',\n Device: 'device',\n Hcp: 'hcp',\n}\n\n/**\n * Represents any data owner.\n */\n// Trick to make typechecking work: without this you can pass anything to a data owner\nexport type DataOwner = (Patient | Device | HealthcareParty) & { id: string }\n\n/**\n * Represents any data owner enriched with type information.\n */\nexport type DataOwnerWithType =\n | { type: 'patient'; dataOwner: Patient & DataOwner }\n | { type: 'device'; dataOwner: Device & DataOwner }\n | { type: 'hcp'; dataOwner: HealthcareParty & DataOwner }\n\nexport class IccDataOwnerXApi {\n private readonly userBaseApi: IccUserApi\n private readonly hcpartyBaseApi: IccHcpartyXApi\n private readonly patientBaseApi: IccPatientApi\n private readonly deviceBaseApi: IccDeviceApi\n private currentDataOwnerType: DataOwnerTypeEnum | undefined\n private currentDataOwnerHierarchyIds: string[] | undefined\n\n private get selfDataOwnerId(): string | undefined {\n if (!this.currentDataOwnerHierarchyIds) return undefined\n return this.currentDataOwnerHierarchyIds[this.currentDataOwnerHierarchyIds.length - 1]\n }\n\n constructor(\n userBaseApi: IccUserApi,\n hcpartyBaseApi: IccHcpartyXApi, //Init with a hcparty x api for better performances\n patientBaseApi: IccPatientApi,\n deviceBaseApi: IccDeviceApi\n ) {\n this.userBaseApi = userBaseApi\n this.hcpartyBaseApi = hcpartyBaseApi\n this.patientBaseApi = patientBaseApi\n this.deviceBaseApi = deviceBaseApi\n }\n\n /**\n * If the logged user is a data owner get the current data owner. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerId(): Promise<string> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n return this.currentDataOwnerHierarchyIds![this.currentDataOwnerHierarchyIds!.length - 1]\n }\n\n /**\n * If the logged user is a data owner get its parent hierarchy. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * The resulting array starts with the topmost parent (the only ancestor without a parent) and ends with the data owner itself.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerHierarchyIds(): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return [...this.currentDataOwnerHierarchyIds!]\n }\n\n /**\n * Get the hierarchy for the current data owner starting from the specified parent.\n * @throws an array starting at the topmost parent and ending at the provided parent id. If the provided id is not part of the hierarchy throws an\n * error.\n */\n async getCurrentDataOwnerHierarchyIdsFrom(parentId: string): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n const res = []\n for (const dataOwnerId of this.currentDataOwnerHierarchyIds!) {\n res.push(dataOwnerId)\n if (dataOwnerId === parentId) return res\n }\n throw new Error(`${parentId} is not part of the data owner hierarchy for the current user`)\n }\n\n /**\n * If the logged user is a data owner get the current data owner.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwner(): Promise<DataOwnerWithType> {\n if (!this.currentDataOwnerHierarchyIds) {\n const dataOwnerHierarchy = await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n return dataOwnerHierarchy[dataOwnerHierarchy.length - 1]\n } else return this.getDataOwner(await this.getCurrentDataOwnerId())\n }\n\n /**\n * If the logged user is a data owner get the current data owner and all of his parents.\n * @throws if the current user is not a data owner.\n * @return the current data owner hierarchy, starting from the topmost parent to the current data owner.\n */\n async getCurrentDataOwnerHierarchy(): Promise<DataOwnerWithType[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n return await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n } else return Promise.all(this.currentDataOwnerHierarchyIds!.map((id) => this.getDataOwner(id)))\n }\n\n /**\n * If the logged user is a data owner get the type of the current data owner. This information is cached.\n * @throws if the current user is not a data owner\n */\n async getCurrentDataOwnerType(): Promise<DataOwnerTypeEnum> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return this.currentDataOwnerType!\n }\n\n /**\n * Get the id of the data owner entity for a user.\n * @param user a user that is also a data owner.\n * @return the id of the data owner corresponding to the provided user.\n * @throws if the user is not a data owner.\n */\n getDataOwnerIdOf(user: User): string {\n const dataOwnerId = user.healthcarePartyId ?? user.patientId ?? user.deviceId\n if (dataOwnerId == undefined) {\n throw Error(`User ${user.id} is not a data owner`)\n }\n return dataOwnerId\n }\n\n /**\n * Get a data owner. Uses a cache to improve performance.\n * @param ownerId id of the data owner to retrieve (patient, medical device, hcp, ...)\n * @return the data owner or undefined if loadIfMissingFromCache is false and there is no data owner with provided id in cache.\n * @throws if no data owner with the provided id could be found on an error occurred while attempting to retrieve it.\n */\n async getDataOwner(ownerId: string): Promise<DataOwnerWithType> {\n const _url = this.userBaseApi.host + `/dataowner/` + ownerId + '?ts=' + new Date().getTime()\n let headers = this.userBaseApi.headers\n return XHR.sendCommand(\n 'GET',\n _url,\n headers,\n null,\n this.userBaseApi.fetchImpl,\n undefined,\n this.userBaseApi.authenticationProvider.getAuthService()\n )\n .then((doc) => doc.body as DataOwnerWithType)\n .then((dowt) => {\n if (dowt.dataOwner.id === this.selfDataOwnerId) this.checkDataOwnerIntegrity(dowt.dataOwner)\n return dowt\n })\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Gets the public keys of a data owner in hex format.\n * @param dataOwner a data owner.\n * @return the public keys for the data owner in hex format.\n */\n getHexPublicKeysOf(dataOwner: DataOwner): Set<string> {\n return hexPublicKeysOf(dataOwner)\n }\n\n /**\n * Clears the cache of current data owner id and parent hierarchy ids. The hierarchy of a data owner should not normally change over time, so this\n * method should be rarely needed.\n */\n clearCurrentDataOwnerIdsCache() {\n this.currentDataOwnerHierarchyIds = undefined\n }\n\n /**\n * @internal This method is intended only for internal use and may be changed without notice.\n * Updates a data owner and its cached value.\n * @param dataOwner a data owner with updated value.\n * @return the updated data owner, with updated revision.\n */\n async updateDataOwner(dataOwner: DataOwnerWithType): Promise<DataOwnerWithType> {\n const ownerType = dataOwner.type\n const ownerToUpdate = dataOwner.dataOwner\n if (ownerType === 'hcp') {\n return await this.hcpartyBaseApi\n .modifyHealthcareParty(ownerToUpdate as HealthcareParty)\n .then((x) => ({ type: 'hcp', dataOwner: x } as DataOwnerWithType))\n } else if (ownerType === 'patient') {\n return await this.patientBaseApi.modifyPatient(ownerToUpdate as Patient).then((x) => ({ type: 'patient', dataOwner: x } as DataOwnerWithType))\n } else if (ownerType === 'device') {\n return await this.deviceBaseApi.updateDevice(ownerToUpdate as Device).then((x) => ({ type: 'device', dataOwner: x } as DataOwnerWithType))\n } else throw new Error(`Unrecognised data owner type: ${ownerType}`)\n }\n\n private checkDataOwnerIntegrity(dataOwner: DataOwner) {\n const keys = this.getHexPublicKeysOf(dataOwner)\n if (new Set(Array.from(keys).map((x) => x.slice(-32))).size != keys.size)\n throw new Error(\n `Different public keys for ${dataOwner.id} have the same fingerprint; this should not happen in normal circumstances. Please report this error to iCure.`\n )\n }\n\n private async forceLoadCurrentDataOwnerHierarchyAndCacheIds(): Promise<DataOwnerWithType[]> {\n const currentUser = await this.userBaseApi.getCurrentUser()\n let curr = await this.getDataOwner(this.getDataOwnerIdOf(currentUser))\n this.checkDataOwnerIntegrity(curr.dataOwner)\n this.currentDataOwnerType = curr.type\n let res = [curr]\n while ((curr.dataOwner as HealthcareParty).parentId) {\n curr = await this.getDataOwner((curr.dataOwner as HealthcareParty).parentId!)\n res = [curr, ...res]\n }\n this.currentDataOwnerHierarchyIds = res.map((x) => x.dataOwner.id!)\n return res\n }\n\n private handleError(e: XHR.XHRError): never {\n throw e\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-data-owner-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-data-owner-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,0CAAgD;AAGhD,oEAAgE;AAChE,0EAAgG;AAMhG,MAAa,gBAAiB,SAAQ,iCAAe;IAInD,IAAY,eAAe;QACzB,IAAI,CAAC,IAAI,CAAC,4BAA4B;YAAE,OAAO,SAAS,CAAA;QACxD,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,4BAA4B,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACxF,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EAClC,yBAAiD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C,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAG,CAAC,CAAA;YACnE,OAAO,GAAG,CAAA;QACZ,CAAC;KAAA;CACF;AAlKD,4CAkKC","sourcesContent":["import { User } from '../icc-api/model/User'\nimport { HealthcareParty } from '../icc-api/model/HealthcareParty'\nimport { Patient } from '../icc-api/model/Patient'\nimport { Device } from '../icc-api/model/Device'\nimport { hexPublicKeysOf } from './crypto/utils'\nimport { DataOwnerTypeEnum } from 'icc-api/model/DataOwnerTypeEnum'\nimport { CryptoActorStub, CryptoActorStubWithType } from '../icc-api/model/CryptoActorStub'\nimport { IccDataownerApi } from '../icc-api/api/IccDataownerApi'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { DataOwnerWithType } from '../icc-api/model/DataOwnerWithType'\n\nexport type DataOwnerOrStub = DataOwner | CryptoActorStub\nexport type DataOwner = HealthcareParty | Patient | Device\n\nexport class IccDataOwnerXApi extends IccDataownerApi {\n private currentDataOwnerType: DataOwnerTypeEnum | undefined\n private currentDataOwnerHierarchyIds: string[] | undefined\n\n private get selfDataOwnerId(): string | undefined {\n if (!this.currentDataOwnerHierarchyIds) return undefined\n return this.currentDataOwnerHierarchyIds[this.currentDataOwnerHierarchyIds.length - 1]\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\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 }\n\n /**\n * If the logged user is a data owner get the current data owner. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerId(): Promise<string> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n return this.currentDataOwnerHierarchyIds![this.currentDataOwnerHierarchyIds!.length - 1]\n }\n\n /**\n * If the logged user is a data owner get its parent hierarchy. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * The resulting array starts with the topmost parent (the only ancestor without a parent) and ends with the data owner itself.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerHierarchyIds(): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return [...this.currentDataOwnerHierarchyIds!]\n }\n\n /**\n * Get the hierarchy for the current data owner starting from the specified parent.\n * @throws an array starting at the topmost parent and ending at the provided parent id. If the provided id is not part of the hierarchy throws an\n * error.\n */\n async getCurrentDataOwnerHierarchyIdsFrom(parentId: string): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n const res = []\n for (const dataOwnerId of this.currentDataOwnerHierarchyIds!) {\n res.push(dataOwnerId)\n if (dataOwnerId === parentId) return res\n }\n throw new Error(`${parentId} is not part of the data owner hierarchy for the current user`)\n }\n\n /**\n * If the logged user is a data owner get the current data owner and all of his parents.\n * @throws if the current user is not a data owner.\n * @return the current data owner hierarchy, starting from the topmost parent to the current data owner.\n */\n async getCurrentDataOwnerHierarchy(): Promise<DataOwnerWithType[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n return await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n } else return Promise.all(this.currentDataOwnerHierarchyIds!.map((id) => this.getDataOwner(id)))\n }\n\n /**\n * If the logged user is a data owner get the type of the current data owner. This information is cached.\n * @throws if the current user is not a data owner\n */\n async getCurrentDataOwnerType(): Promise<DataOwnerTypeEnum> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return this.currentDataOwnerType!\n }\n\n /**\n * Get the id of the data owner entity for a user.\n * @param user a user that is also a data owner.\n * @return the id of the data owner corresponding to the provided user.\n * @throws if the user is not a data owner.\n */\n getDataOwnerIdOf(user: User): string {\n const dataOwnerId = user.healthcarePartyId ?? user.patientId ?? user.deviceId\n if (dataOwnerId == undefined) {\n throw Error(`User ${user.id} is not a data owner`)\n }\n return dataOwnerId\n }\n\n /**\n * Get a data owner. Note that this does not decrpyt patient data owners.\n * @param ownerId id of the data owner to retrieve (patient, medical device, hcp, ...)\n * @return the data owner with the provided id\n * @throws if you have no access to the data owner. Use {@link getCryptoActorStub}.\n */\n async getDataOwner(ownerId: string): Promise<DataOwnerWithType> {\n return super.getDataOwner(ownerId).then((dowt) => {\n if (dowt.dataOwner.id === this.selfDataOwnerId) this.checkDataOwnerIntegrity(dowt.dataOwner)\n return dowt\n })\n }\n\n /**\n * Get a crypto actor stub for a data owner.\n * @param ownerId id of the data owner for which you want to retrieve the stub (patient, medical device, hcp, ...)\n * @return the crypto actor stub of the data owner with the provided id\n */\n async getCryptoActorStub(ownerId: string): Promise<CryptoActorStubWithType> {\n return super.getCryptoActorStub(ownerId).then((dowt) => {\n if (dowt.stub.id === this.selfDataOwnerId) this.checkDataOwnerIntegrity(dowt.stub)\n return dowt\n })\n }\n\n /**\n * Gets the public keys of a data owner in hex format.\n * @param dataOwner a data owner.\n * @return the public keys for the data owner in hex format.\n */\n getHexPublicKeysOf(dataOwner: DataOwnerOrStub): Set<string> {\n return hexPublicKeysOf(dataOwner)\n }\n\n /**\n * Clears the cache of current data owner id and parent hierarchy ids. The hierarchy of a data owner should not normally change over time, so this\n * method should be rarely needed.\n */\n clearCurrentDataOwnerIdsCache() {\n this.currentDataOwnerHierarchyIds = undefined\n }\n\n private checkDataOwnerIntegrity(dataOwner: DataOwnerOrStub) {\n const keys = this.getHexPublicKeysOf(dataOwner)\n if (new Set(Array.from(keys).map((x) => x.slice(-32))).size != keys.size)\n throw new Error(\n `Different public keys for ${dataOwner.id} have the same fingerprint; this should not happen in normal circumstances. Please report this error to iCure.`\n )\n }\n\n private async forceLoadCurrentDataOwnerHierarchyAndCacheIds(): Promise<DataOwnerWithType[]> {\n let curr = await this.getCurrentDataOwner()\n this.checkDataOwnerIntegrity(curr.dataOwner)\n this.currentDataOwnerType = curr.type\n let res = [curr]\n while ((curr.dataOwner as HealthcareParty).parentId) {\n curr = await this.getDataOwner((curr.dataOwner as HealthcareParty).parentId!)\n res = [curr, ...res]\n }\n this.currentDataOwnerHierarchyIds = res.map((x) => x.dataOwner.id!)\n return res\n }\n}\n"]}
|
|
@@ -16,7 +16,7 @@ const PropertyStub_1 = require("../icc-api/model/PropertyStub");
|
|
|
16
16
|
const PropertyTypeStub_1 = require("../icc-api/model/PropertyTypeStub");
|
|
17
17
|
const TypedValueObject_1 = require("../icc-api/model/TypedValueObject");
|
|
18
18
|
const KeyPairUpdateRequest_1 = require("./maintenance/KeyPairUpdateRequest");
|
|
19
|
-
const
|
|
19
|
+
const DataOwnerTypeEnum_1 = require("../icc-api/model/DataOwnerTypeEnum");
|
|
20
20
|
/**
|
|
21
21
|
* Api for interpreting maintenance tasks and applying required client-side actions.
|
|
22
22
|
*/
|
|
@@ -47,11 +47,11 @@ class IccIcureMaintenanceXApi {
|
|
|
47
47
|
createMaintenanceTasksForNewKeypair(user, keypair) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
const currentUserType = yield this.dataOwnerApi.getCurrentDataOwnerType();
|
|
50
|
-
if (currentUserType ===
|
|
50
|
+
if (currentUserType === DataOwnerTypeEnum_1.DataOwnerTypeEnum.Device) {
|
|
51
51
|
console.warn('Current data owner is a device and there is no need to create maintenance tasks for updated keypair.');
|
|
52
52
|
}
|
|
53
|
-
else if (currentUserType ===
|
|
54
|
-
const requestsToOwnerTypes = currentUserType ===
|
|
53
|
+
else if (currentUserType === DataOwnerTypeEnum_1.DataOwnerTypeEnum.Patient || currentUserType === DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp) {
|
|
54
|
+
const requestsToOwnerTypes = currentUserType === DataOwnerTypeEnum_1.DataOwnerTypeEnum.Patient ? [DataOwnerTypeEnum_1.DataOwnerTypeEnum.Patient, DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp] : [DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp];
|
|
55
55
|
const hexNewPubKey = (0, utils_1.ua2hex)(yield this.crypto.primitives.RSA.exportKey(keypair.publicKey, 'spki'));
|
|
56
56
|
const hexNewPubKeyFp = hexNewPubKey.slice(-32);
|
|
57
57
|
const selfId = yield this.dataOwnerApi.getCurrentDataOwnerId();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-icure-maintenance-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-icure-maintenance-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sEAAkE;AAClE,mCAAgC;AAChC,gEAA4D;AAC5D,wEAAoE;AACpE,wEAAoE;AAEpE,6EAAyE;AACzE,iEAA4E;AAK5E;;GAEG;AACH,MAAa,uBAAuB;IAKlC,YAAY,MAAqB,EAAE,QAAgC,EAAE,YAA8B;QACjG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,iEAAiE;IAEjE;;;;;OAKG;IACG,kBAAkB,CAAC,MAA4B;;YACnD,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAClD,MAAM,CAAC,oBAAoB,EAC3B,MAAM,CAAC,YAAY,EACnB,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAChD,CAAA;QACH,CAAC;KAAA;IAED;;;;;OAKG;IACG,mCAAmC,CAAC,IAAU,EAAE,OAA2B;;YAC/E,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,uBAAuB,EAAE,CAAA;YACzE,IAAI,eAAe,KAAK,wCAAiB,CAAC,MAAM,EAAE;gBAChD,OAAO,CAAC,IAAI,CAAC,sGAA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AAI,EAAE,mCAAgB,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACtE,UAAU,EAAE,IAAI,mCAAgB,CAAC;wBAC/B,IAAI,EAAE,mCAAgB,CAAC,QAAQ,CAAC,MAAM;wBACtC,WAAW,EAAE,eAAe;qBAC7B,CAAC;iBACH,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AA5GD,0DA4GC","sourcesContent":["import { KeyPair } from './crypto/RSA'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { MaintenanceTask } from '../icc-api/model/MaintenanceTask'\nimport { ua2hex } from './utils'\nimport { PropertyStub } from '../icc-api/model/PropertyStub'\nimport { PropertyTypeStub } from '../icc-api/model/PropertyTypeStub'\nimport { TypedValueObject } from '../icc-api/model/TypedValueObject'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { KeyPairUpdateRequest } from './maintenance/KeyPairUpdateRequest'\nimport { DataOwnerTypeEnum, IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { User } from '../icc-api/model/User'\n\ntype ExchangeKeyInfo = { delegator: string; delegate: string; fingerprints: Set<string> }\n\n/**\n * Api for interpreting maintenance tasks and applying required client-side actions.\n */\nexport class IccIcureMaintenanceXApi {\n private readonly crypto: IccCryptoXApi\n private readonly tasksApi: IccMaintenanceTaskXApi\n private readonly dataOwnerApi: IccDataOwnerXApi\n\n constructor(crypto: IccCryptoXApi, tasksApi: IccMaintenanceTaskXApi, dataOwnerApi: IccDataOwnerXApi) {\n this.crypto = crypto\n this.tasksApi = tasksApi\n this.dataOwnerApi = dataOwnerApi\n }\n\n // TODO api to get all tasks for current owner from owner with id\n\n /**\n * Applies a key pair update request between another data owner and the current data owner to allow the other data owner to access existing exchange\n * keys shared with the current data owner. IMPORTANT: it is your responsibility to verify the authenticity of the public key / update request\n * before calling this method: this method assumes the new public key for the concerned data owner is authentic.\n * @param update a keypair update request to the current data owner.\n */\n async applyKeyPairUpdate(update: KeyPairUpdateRequest) {\n await this.crypto.exchangeKeys.base.giveAccessBackTo(\n update.concernedDataOwnerId,\n update.newPublicKey,\n this.crypto.userKeysManager.getDecryptionKeys()\n )\n }\n\n /**\n * @internal This method is intended only for internal use and may be changed without notice.\n * Creates the necessary maintenance tasks to request access to existing exchange keys with the new key pair for the current user.\n * @param user the user which owns the new key pair.\n * @param keypair a new key pair for the current user.\n */\n async createMaintenanceTasksForNewKeypair(user: User, keypair: KeyPair<CryptoKey>): Promise<void> {\n const currentUserType = await this.dataOwnerApi.getCurrentDataOwnerType()\n if (currentUserType === DataOwnerTypeEnum.Device) {\n console.warn('Current data owner is a device and there is no need to create maintenance tasks for updated keypair.')\n } else if (currentUserType === DataOwnerTypeEnum.Patient || currentUserType === DataOwnerTypeEnum.Hcp) {\n const requestsToOwnerTypes =\n currentUserType === DataOwnerTypeEnum.Patient ? [DataOwnerTypeEnum.Patient, DataOwnerTypeEnum.Hcp] : [DataOwnerTypeEnum.Hcp]\n const hexNewPubKey = ua2hex(await this.crypto.primitives.RSA.exportKey(keypair.publicKey, 'spki'))\n const hexNewPubKeyFp = hexNewPubKey.slice(-32)\n const selfId = await this.dataOwnerApi.getCurrentDataOwnerId()\n const keysInfo = await this.getExchangeKeysInfosOf(selfId, requestsToOwnerTypes)\n const requestDataOwners = keysInfo\n .filter((info) => !info.fingerprints.has(hexNewPubKeyFp))\n .flatMap((info) => [info.delegate, info.delegator])\n .filter((dataOwner) => dataOwner !== selfId)\n if (requestDataOwners.length > 0) {\n const tasksToCreate = requestDataOwners.map((dataOwner) => ({\n delegate: dataOwner,\n task: this.createMaintenanceTask(selfId, hexNewPubKey),\n }))\n for (const taskToCreate of tasksToCreate) {\n const instance = await this.tasksApi.newInstance(user, taskToCreate.task, { additionalDelegates: { [taskToCreate.delegate]: 'WRITE' } })\n if (instance) {\n // TODO create in bulk\n await this.tasksApi.createMaintenanceTaskWithUser(user, instance)\n }\n }\n }\n } else throw new Error(`Unknown data owner type for current user ${currentUserType}`)\n }\n\n private async getExchangeKeysInfosOf(dataOwnerId: string, otherOwnerTypes: DataOwnerTypeEnum[]): Promise<ExchangeKeyInfo[]> {\n const allExchangeKeys = await this.crypto.exchangeKeys.base.getAllExchangeKeysWith(dataOwnerId, otherOwnerTypes)\n const infoTo = Object.entries(allExchangeKeys.keysToOwner).flatMap(([delegatorId, delegatorFpToKeys]) =>\n Object.values(delegatorFpToKeys).map((encryptedKeys) => ({\n delegator: delegatorId,\n delegate: dataOwnerId,\n fingerprints: new Set(Object.keys(encryptedKeys).map((x) => x.slice(-32))),\n }))\n )\n const infoFrom = Object.values(allExchangeKeys.keysFromOwner).flatMap((delegateIdToKeys) =>\n Object.entries(delegateIdToKeys).map(([delegateId, encryptedKeys]) => ({\n delegator: dataOwnerId,\n delegate: delegateId,\n fingerprints: new Set(Object.keys(encryptedKeys).map((x) => x.slice(-32))),\n }))\n )\n return [...infoFrom, ...infoTo]\n }\n\n private createMaintenanceTask(ownerId: string, concernedPubKey: string) {\n return new MaintenanceTask({\n id: this.crypto.primitives.randomUuid(),\n taskType: KeyPairUpdateRequest.TASK_TYPE,\n status: MaintenanceTask.StatusEnum.Pending,\n properties: [\n new PropertyStub({\n id: KeyPairUpdateRequest.OWNER_ID_PROP_ID,\n type: new PropertyTypeStub({ type: PropertyTypeStub.TypeEnum.STRING }),\n typedValue: new TypedValueObject({\n type: TypedValueObject.TypeEnum.STRING,\n stringValue: ownerId,\n }),\n }),\n new PropertyStub({\n id: KeyPairUpdateRequest.OWNER_PUB_PROP_ID,\n type: new PropertyTypeStub({ type: PropertyTypeStub.TypeEnum.STRING }),\n typedValue: new TypedValueObject({\n type: TypedValueObject.TypeEnum.STRING,\n stringValue: concernedPubKey,\n }),\n }),\n ],\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-icure-maintenance-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-icure-maintenance-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sEAAkE;AAClE,mCAAgC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3E,CAAC,CAAC,CACJ,CAAA;YACD,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAA;QACjC,CAAC;KAAA;IAEO,qBAAqB,CAAC,OAAe,EAAE,eAAuB;QACpE,OAAO,IAAI,iCAAe,CAAC;YACzB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE;YACvC,QAAQ,EAAE,2CAAoB,CAAC,SAAS;YACxC,MAAM,EAAE,iCAAe,CAAC,UAAU,CAAC,OAAO;YAC1C,UAAU,EAAE;gBACV,IAAI,2BAAY,CAAC;oBACf,EAAE,EAAE,2CAAoB,CAAC,gBAAgB;oBACzC,IAAI,EAAE,IAAI,mCAAgB,CAAC,EAAE,IAAI,EAAE,mCAAgB,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACtE,UAAU,EAAE,IAAI,mCAAgB,CAAC;wBAC/B,IAAI,EAAE,mCAAgB,CAAC,QAAQ,CAAC,MAAM;wBACtC,WAAW,EAAE,OAAO;qBACrB,CAAC;iBACH,CAAC;gBACF,IAAI,2BAAY,CAAC;oBACf,EAAE,EAAE,2CAAoB,CAAC,iBAAiB;oBAC1C,IAAI,EAAE,IAAI,mCAAgB,CAAC,EAAE,IAAI,EAAE,mCAAgB,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACtE,UAAU,EAAE,IAAI,mCAAgB,CAAC;wBAC/B,IAAI,EAAE,mCAAgB,CAAC,QAAQ,CAAC,MAAM;wBACtC,WAAW,EAAE,eAAe;qBAC7B,CAAC;iBACH,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AA5GD,0DA4GC","sourcesContent":["import { KeyPair } from './crypto/RSA'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { MaintenanceTask } from '../icc-api/model/MaintenanceTask'\nimport { ua2hex } from './utils'\nimport { PropertyStub } from '../icc-api/model/PropertyStub'\nimport { PropertyTypeStub } from '../icc-api/model/PropertyTypeStub'\nimport { TypedValueObject } from '../icc-api/model/TypedValueObject'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { KeyPairUpdateRequest } from './maintenance/KeyPairUpdateRequest'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { User } from '../icc-api/model/User'\nimport { DataOwnerTypeEnum } from '../icc-api/model/DataOwnerTypeEnum'\n\ntype ExchangeKeyInfo = { delegator: string; delegate: string; fingerprints: Set<string> }\n\n/**\n * Api for interpreting maintenance tasks and applying required client-side actions.\n */\nexport class IccIcureMaintenanceXApi {\n private readonly crypto: IccCryptoXApi\n private readonly tasksApi: IccMaintenanceTaskXApi\n private readonly dataOwnerApi: IccDataOwnerXApi\n\n constructor(crypto: IccCryptoXApi, tasksApi: IccMaintenanceTaskXApi, dataOwnerApi: IccDataOwnerXApi) {\n this.crypto = crypto\n this.tasksApi = tasksApi\n this.dataOwnerApi = dataOwnerApi\n }\n\n // TODO api to get all tasks for current owner from owner with id\n\n /**\n * Applies a key pair update request between another data owner and the current data owner to allow the other data owner to access existing exchange\n * keys shared with the current data owner. IMPORTANT: it is your responsibility to verify the authenticity of the public key / update request\n * before calling this method: this method assumes the new public key for the concerned data owner is authentic.\n * @param update a keypair update request to the current data owner.\n */\n async applyKeyPairUpdate(update: KeyPairUpdateRequest) {\n await this.crypto.exchangeKeys.base.giveAccessBackTo(\n update.concernedDataOwnerId,\n update.newPublicKey,\n this.crypto.userKeysManager.getDecryptionKeys()\n )\n }\n\n /**\n * @internal This method is intended only for internal use and may be changed without notice.\n * Creates the necessary maintenance tasks to request access to existing exchange keys with the new key pair for the current user.\n * @param user the user which owns the new key pair.\n * @param keypair a new key pair for the current user.\n */\n async createMaintenanceTasksForNewKeypair(user: User, keypair: KeyPair<CryptoKey>): Promise<void> {\n const currentUserType = await this.dataOwnerApi.getCurrentDataOwnerType()\n if (currentUserType === DataOwnerTypeEnum.Device) {\n console.warn('Current data owner is a device and there is no need to create maintenance tasks for updated keypair.')\n } else if (currentUserType === DataOwnerTypeEnum.Patient || currentUserType === DataOwnerTypeEnum.Hcp) {\n const requestsToOwnerTypes =\n currentUserType === DataOwnerTypeEnum.Patient ? [DataOwnerTypeEnum.Patient, DataOwnerTypeEnum.Hcp] : [DataOwnerTypeEnum.Hcp]\n const hexNewPubKey = ua2hex(await this.crypto.primitives.RSA.exportKey(keypair.publicKey, 'spki'))\n const hexNewPubKeyFp = hexNewPubKey.slice(-32)\n const selfId = await this.dataOwnerApi.getCurrentDataOwnerId()\n const keysInfo = await this.getExchangeKeysInfosOf(selfId, requestsToOwnerTypes)\n const requestDataOwners = keysInfo\n .filter((info) => !info.fingerprints.has(hexNewPubKeyFp))\n .flatMap((info) => [info.delegate, info.delegator])\n .filter((dataOwner) => dataOwner !== selfId)\n if (requestDataOwners.length > 0) {\n const tasksToCreate = requestDataOwners.map((dataOwner) => ({\n delegate: dataOwner,\n task: this.createMaintenanceTask(selfId, hexNewPubKey),\n }))\n for (const taskToCreate of tasksToCreate) {\n const instance = await this.tasksApi.newInstance(user, taskToCreate.task, { additionalDelegates: { [taskToCreate.delegate]: 'WRITE' } })\n if (instance) {\n // TODO create in bulk\n await this.tasksApi.createMaintenanceTaskWithUser(user, instance)\n }\n }\n }\n } else throw new Error(`Unknown data owner type for current user ${currentUserType}`)\n }\n\n private async getExchangeKeysInfosOf(dataOwnerId: string, otherOwnerTypes: DataOwnerTypeEnum[]): Promise<ExchangeKeyInfo[]> {\n const allExchangeKeys = await this.crypto.exchangeKeys.base.getAllExchangeKeysWith(dataOwnerId, otherOwnerTypes)\n const infoTo = Object.entries(allExchangeKeys.keysToOwner).flatMap(([delegatorId, delegatorFpToKeys]) =>\n Object.values(delegatorFpToKeys).map((encryptedKeys) => ({\n delegator: delegatorId,\n delegate: dataOwnerId,\n fingerprints: new Set(Object.keys(encryptedKeys).map((x) => x.slice(-32))),\n }))\n )\n const infoFrom = Object.values(allExchangeKeys.keysFromOwner).flatMap((delegateIdToKeys) =>\n Object.entries(delegateIdToKeys).map(([delegateId, encryptedKeys]) => ({\n delegator: dataOwnerId,\n delegate: delegateId,\n fingerprints: new Set(Object.keys(encryptedKeys).map((x) => x.slice(-32))),\n }))\n )\n return [...infoFrom, ...infoTo]\n }\n\n private createMaintenanceTask(ownerId: string, concernedPubKey: string) {\n return new MaintenanceTask({\n id: this.crypto.primitives.randomUuid(),\n taskType: KeyPairUpdateRequest.TASK_TYPE,\n status: MaintenanceTask.StatusEnum.Pending,\n properties: [\n new PropertyStub({\n id: KeyPairUpdateRequest.OWNER_ID_PROP_ID,\n type: new PropertyTypeStub({ type: PropertyTypeStub.TypeEnum.STRING }),\n typedValue: new TypedValueObject({\n type: TypedValueObject.TypeEnum.STRING,\n stringValue: ownerId,\n }),\n }),\n new PropertyStub({\n id: KeyPairUpdateRequest.OWNER_PUB_PROP_ID,\n type: new PropertyTypeStub({ type: PropertyTypeStub.TypeEnum.STRING }),\n typedValue: new TypedValueObject({\n type: TypedValueObject.TypeEnum.STRING,\n stringValue: concernedPubKey,\n }),\n }),\n ],\n })\n }\n}\n"]}
|
package/icc-x-api/index.js
CHANGED
|
@@ -60,6 +60,7 @@ const icc_icure_maintenance_x_api_1 = require("./icc-icure-maintenance-x-api");
|
|
|
60
60
|
const EntitiesEncryption_1 = require("./crypto/EntitiesEncryption");
|
|
61
61
|
const ConfidentialEntities_1 = require("./crypto/ConfidentialEntities");
|
|
62
62
|
const utils_1 = require("./crypto/utils");
|
|
63
|
+
const CryptoActorStub_1 = require("../icc-api/model/CryptoActorStub");
|
|
63
64
|
__exportStar(require("./icc-accesslog-x-api"), exports);
|
|
64
65
|
__exportStar(require("./icc-bekmehr-x-api"), exports);
|
|
65
66
|
__exportStar(require("./icc-calendar-item-x-api"), exports);
|
|
@@ -118,7 +119,7 @@ const Api = function (host, authenticationOptions, cryptoStrategies, crypto = ty
|
|
|
118
119
|
const healthcarePartyApi = new icc_hcparty_x_api_1.IccHcpartyXApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
119
120
|
const deviceApi = new IccDeviceApi_1.IccDeviceApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
120
121
|
const basePatientApi = new icc_api_1.IccPatientApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
121
|
-
const dataOwnerApi = new icc_data_owner_x_api_1.IccDataOwnerXApi(
|
|
122
|
+
const dataOwnerApi = new icc_data_owner_x_api_1.IccDataOwnerXApi(host, params.headers, authenticationProvider, fetchImpl);
|
|
122
123
|
// Crypto initialisation
|
|
123
124
|
const icureStorage = new IcureStorageFacade_1.IcureStorageFacade(params.keyStorage, params.storage, params.entryKeysFactory);
|
|
124
125
|
const cryptoPrimitives = new CryptoPrimitives_1.CryptoPrimitives(crypto);
|
|
@@ -126,13 +127,13 @@ const Api = function (host, authenticationOptions, cryptoStrategies, crypto = ty
|
|
|
126
127
|
const keyRecovery = new KeyRecovery_1.KeyRecovery(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi);
|
|
127
128
|
const keyManager = new KeyManager_1.KeyManager(cryptoPrimitives, dataOwnerApi, icureStorage, keyRecovery, baseExchangeKeysManager, cryptoStrategies);
|
|
128
129
|
const newKey = yield keyManager.initialiseKeys();
|
|
129
|
-
yield new TransferKeysManager_1.TransferKeysManager(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi, keyManager, icureStorage).updateTransferKeys(yield dataOwnerApi.getCurrentDataOwner());
|
|
130
|
+
yield new TransferKeysManager_1.TransferKeysManager(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi, keyManager, icureStorage).updateTransferKeys(CryptoActorStub_1.CryptoActorStubWithType.fromDataOwner(yield dataOwnerApi.getCurrentDataOwner()));
|
|
130
131
|
// TODO customise cache size?
|
|
131
132
|
const exchangeKeysManager = new ExchangeKeysManager_1.ExchangeKeysManager(100, 500, 60000, 600000, cryptoStrategies, cryptoPrimitives, keyManager, baseExchangeKeysManager, dataOwnerApi, icureStorage);
|
|
132
133
|
const entitiesEncryption = new EntitiesEncryption_1.EntitiesEncryption(cryptoPrimitives, dataOwnerApi, exchangeKeysManager);
|
|
133
134
|
const shamirManager = new ShamirKeysManager_1.ShamirKeysManager(cryptoPrimitives, dataOwnerApi, keyManager, exchangeKeysManager);
|
|
134
135
|
const confidentialEntitites = new ConfidentialEntities_1.ConfidentialEntities(entitiesEncryption, cryptoPrimitives, dataOwnerApi);
|
|
135
|
-
yield (0, utils_1.ensureDelegationForSelf)(dataOwnerApi, entitiesEncryption, cryptoPrimitives);
|
|
136
|
+
yield (0, utils_1.ensureDelegationForSelf)(dataOwnerApi, entitiesEncryption, cryptoPrimitives, basePatientApi);
|
|
136
137
|
const cryptoApi = new icc_crypto_x_api_1.IccCryptoXApi(exchangeKeysManager, cryptoPrimitives, keyManager, dataOwnerApi, entitiesEncryption, shamirManager, params.storage, params.keyStorage, icureStorage, healthcarePartyApi, confidentialEntitites);
|
|
137
138
|
const accessLogApi = new icc_accesslog_x_api_1.IccAccesslogXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl);
|
|
138
139
|
const agendaApi = new icc_api_1.IccAgendaApi(host, params.headers, authenticationProvider, fetchImpl);
|
package/icc-x-api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAUmB;AACnB,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD;AACpD,6DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,6DAAsD;AACtD,yEAAkE;AAClE,uEAA+D;AAC/D,2DAAoD;AACpD,2DAAoD;AACpD,2DAAoD;AACpD,+DAAwD;AACxD,iEAAyD;AACzD,8DAA0D;AAC1D,qDAA8C;AAC9C,6EAAqE;AACrE,iEAAyD;AAGzD,iEAA6D;AAC7D,6DAAyD;AACzD,0EAKsC;AACtC,gEAA4D;AAC5D,oDAAgD;AAChD,qEA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EhF,MAAM,OAAO,GAAG,IAAI,4BAAW,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACjF,MAAM,kBAAkB,GAAG,IAAI,yBAAe,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAChG,MAAM,OAAO,GAAG,IAAI,4BAAW,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACjF,MAAM,aAAa,GAAG,IAAI,0BAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAC5F,MAAM,SAAS,GAAG,IAAI,sBAAY,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACpF,MAAM,QAAQ,GAAG,IAAI,qBAAW,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAA;QACvE,MAAM,YAAY,GAAG,IAAI,yBAAe,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAE1F,OAAO;YACL,OAAO;YACP,OAAO;YACP,OAAO;YACP,aAAa;YACb,YAAY;YACZ,kBAAkB;YAClB,SAAS;YACT,QAAQ;SACT,CAAA;IACH,CAAC;CAAA,CAAA;AApCY,QAAA,SAAS,aAoCrB","sourcesContent":["import {\n IccAgendaApi,\n IccAuthApi,\n IccCalendarItemTypeApi,\n IccEntityrefApi,\n IccGroupApi,\n IccInsuranceApi,\n IccMedicallocationApi,\n IccPatientApi,\n IccPermissionApi,\n} from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccDeviceApi } from '../icc-api/api/IccDeviceApi'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { StorageFacade } from './storage/StorageFacade'\nimport { KeyStorageFacade } from './storage/KeyStorageFacade'\nimport { LocalStorageImpl } from './storage/LocalStorageImpl'\nimport { KeyStorageImpl } from './storage/KeyStorageImpl'\nimport {\n AuthenticationProvider,\n BasicAuthenticationProvider,\n EnsembleAuthenticationProvider,\n NoAuthenticationProvider,\n} from './auth/AuthenticationProvider'\nimport { CryptoPrimitives } from './crypto/CryptoPrimitives'\nimport { KeyManager } from './crypto/KeyManager'\nimport { IcureStorageFacade } from './storage/IcureStorageFacade'\nimport { DefaultStorageEntryKeysFactory } from './storage/DefaultStorageEntryKeysFactory'\nimport { KeyRecovery } from './crypto/KeyRecovery'\nimport { BaseExchangeKeysManager } from './crypto/BaseExchangeKeysManager'\nimport { StorageEntryKeysFactory } from './storage/StorageEntryKeysFactory'\nimport { CryptoStrategies } from './crypto/CryptoStrategies'\nimport { ExchangeKeysManager } from './crypto/ExchangeKeysManager'\nimport { ShamirKeysManager } from './crypto/ShamirKeysManager'\nimport { TransferKeysManager } from './crypto/TransferKeysManager'\nimport { IccIcureMaintenanceXApi } from './icc-icure-maintenance-x-api'\nimport { EntitiesEncryption } from './crypto/EntitiesEncryption'\nimport { ConfidentialEntities } from './crypto/ConfidentialEntities'\nimport { ensureDelegationForSelf } from './crypto/utils'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './utils'\nexport { KeyStorageFacade } from './storage/KeyStorageFacade'\nexport { LocalStorageImpl } from './storage/LocalStorageImpl'\nexport { StorageFacade } from './storage/StorageFacade'\nexport { KeyStorageImpl } from './storage/KeyStorageImpl'\n\nexport interface Apis {\n authApi: IccAuthApi\n codeApi: IccCodeXApi\n calendarItemTypeApi: IccCalendarItemTypeApi\n medicalLocationApi: IccMedicallocationApi\n entityReferenceApi: IccEntityrefApi\n userApi: IccUserXApi\n permissionApi: IccPermissionApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceApi\n cryptoApi: IccCryptoXApi\n accessLogApi: IccAccesslogXApi\n agendaApi: IccAgendaApi\n contactApi: IccContactXApi\n formApi: IccFormXApi\n groupApi: IccGroupApi\n invoiceApi: IccInvoiceXApi\n insuranceApi: IccInsuranceApi\n documentApi: IccDocumentXApi\n healthcareElementApi: IccHelementXApi\n classificationApi: IccClassificationXApi\n calendarItemApi: IccCalendarItemXApi\n receiptApi: IccReceiptXApi\n timetableApi: IccTimeTableXApi\n patientApi: IccPatientXApi\n messageApi: IccMessageXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n dataOwnerApi: IccDataOwnerXApi\n icureMaintenanceTaskApi: IccIcureMaintenanceXApi\n}\n\nexport type ApiOptions = {\n readonly entryKeysFactory?: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey?: boolean\n readonly storage?: StorageFacade<string>\n readonly keyStorage?: KeyStorageFacade\n readonly headers?: { [headerName: string]: string }\n}\n\nclass NamedApiParametersWithDefault implements ApiOptions {\n constructor(custom: ApiOptions) {\n this.entryKeysFactory = custom.entryKeysFactory ?? new DefaultStorageEntryKeysFactory()\n this.createMaintenanceTasksOnNewKey = custom.createMaintenanceTasksOnNewKey ?? false\n this.storage = custom.storage ?? new LocalStorageImpl()\n this.keyStorage = custom.keyStorage ?? new KeyStorageImpl(this.storage)\n this.headers = custom.headers ?? {}\n }\n\n readonly entryKeysFactory: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey: boolean\n readonly storage: StorageFacade<string>\n readonly keyStorage: KeyStorageFacade\n readonly headers: { [headerName: string]: string }\n}\n\nexport type AuthenticationDetails = {\n username: string\n password: string\n forceBasic?: boolean // default false\n}\n\nexport const Api = async function (\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n cryptoStrategies: CryptoStrategies,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n options: ApiOptions = {}\n): Promise<Apis> {\n const params = new NamedApiParametersWithDefault(options)\n let authenticationProvider: AuthenticationProvider\n if ('username' in authenticationOptions && 'password' in authenticationOptions) {\n authenticationProvider = authenticationOptions.forceBasic\n ? new BasicAuthenticationProvider(authenticationOptions.username, authenticationOptions.password)\n : new EnsembleAuthenticationProvider(\n new IccAuthApi(host, params.headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions.username,\n authenticationOptions.password\n )\n } else {\n authenticationProvider = authenticationOptions\n }\n\n // Here I instantiate a separate instance of the AuthApi that can call also login-protected methods (logout)\n const authApi = new IccAuthApi(host, params.headers, authenticationProvider, fetchImpl)\n const codeApi = new IccCodeXApi(host, params.headers, authenticationProvider, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, params.headers, authenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, params.headers, authenticationProvider, fetchImpl)\n const permissionApi = new IccPermissionApi(host, params.headers, authenticationProvider, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, params.headers, authenticationProvider, fetchImpl)\n const deviceApi = new IccDeviceApi(host, params.headers, authenticationProvider, fetchImpl)\n const basePatientApi = new IccPatientApi(host, params.headers, authenticationProvider, fetchImpl)\n const dataOwnerApi = new IccDataOwnerXApi(userApi, healthcarePartyApi, basePatientApi, deviceApi)\n // Crypto initialisation\n const icureStorage = new IcureStorageFacade(params.keyStorage, params.storage, params.entryKeysFactory)\n const cryptoPrimitives = new CryptoPrimitives(crypto)\n const baseExchangeKeysManager = new BaseExchangeKeysManager(cryptoPrimitives, dataOwnerApi, healthcarePartyApi, basePatientApi, deviceApi)\n const keyRecovery = new KeyRecovery(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi)\n const keyManager = new KeyManager(cryptoPrimitives, dataOwnerApi, icureStorage, keyRecovery, baseExchangeKeysManager, cryptoStrategies)\n const newKey = await keyManager.initialiseKeys()\n await new TransferKeysManager(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi, keyManager, icureStorage).updateTransferKeys(\n await dataOwnerApi.getCurrentDataOwner()\n )\n // TODO customise cache size?\n const exchangeKeysManager = new ExchangeKeysManager(\n 100,\n 500,\n 60000,\n 600000,\n cryptoStrategies,\n cryptoPrimitives,\n keyManager,\n baseExchangeKeysManager,\n dataOwnerApi,\n icureStorage\n )\n const entitiesEncryption = new EntitiesEncryption(cryptoPrimitives, dataOwnerApi, exchangeKeysManager)\n const shamirManager = new ShamirKeysManager(cryptoPrimitives, dataOwnerApi, keyManager, exchangeKeysManager)\n const confidentialEntitites = new ConfidentialEntities(entitiesEncryption, cryptoPrimitives, dataOwnerApi)\n await ensureDelegationForSelf(dataOwnerApi, entitiesEncryption, cryptoPrimitives)\n const cryptoApi = new IccCryptoXApi(\n exchangeKeysManager,\n cryptoPrimitives,\n keyManager,\n dataOwnerApi,\n entitiesEncryption,\n shamirManager,\n params.storage,\n params.keyStorage,\n icureStorage,\n healthcarePartyApi,\n confidentialEntitites\n )\n const accessLogApi = new IccAccesslogXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const agendaApi = new IccAgendaApi(host, params.headers, authenticationProvider, fetchImpl)\n const contactApi = new IccContactXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const formApi = new IccFormXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const groupApi = new IccGroupApi(host, params.headers, authenticationProvider)\n const medicalLocationApi = new IccMedicallocationApi(host, params.headers, authenticationProvider)\n const calendarItemTypeApi = new IccCalendarItemTypeApi(host, params.headers, authenticationProvider)\n const invoiceApi = new IccInvoiceXApi(host, params.headers, cryptoApi, entityReferenceApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const insuranceApi = new IccInsuranceApi(host, params.headers, authenticationProvider, fetchImpl)\n const documentApi = new IccDocumentXApi(host, params.headers, cryptoApi, authApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const healthcareElementApi = new IccHelementXApi(\n host,\n params.headers,\n cryptoApi,\n dataOwnerApi,\n ['descr', 'note'],\n authenticationProvider,\n fetchImpl\n )\n const classificationApi = new IccClassificationXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const calendarItemApi = new IccCalendarItemXApi(\n host,\n params.headers,\n cryptoApi,\n dataOwnerApi,\n ['details', 'title', 'patientId'],\n authenticationProvider,\n fetchImpl\n )\n const receiptApi = new IccReceiptXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const timetableApi = new IccTimeTableXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const patientApi = new IccPatientXApi(\n host,\n params.headers,\n cryptoApi,\n contactApi,\n formApi,\n healthcareElementApi,\n invoiceApi,\n documentApi,\n healthcarePartyApi,\n classificationApi,\n dataOwnerApi,\n calendarItemApi,\n ['note'],\n authenticationProvider,\n fetchImpl\n )\n const messageApi = new IccMessageXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(\n host,\n params.headers,\n cryptoApi,\n healthcarePartyApi,\n dataOwnerApi,\n ['properties'],\n authenticationProvider,\n fetchImpl\n )\n const icureMaintenanceTaskApi = new IccIcureMaintenanceXApi(cryptoApi, maintenanceTaskApi, dataOwnerApi)\n\n if (newKey && params.createMaintenanceTasksOnNewKey) {\n await icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(await userApi.getCurrentUser(), newKey.newKeyPair)\n }\n return {\n cryptoApi,\n authApi,\n codeApi,\n calendarItemTypeApi,\n medicalLocationApi,\n userApi,\n permissionApi,\n patientApi,\n healthcarePartyApi,\n deviceApi,\n accessLogApi,\n contactApi,\n healthcareElementApi,\n documentApi,\n formApi,\n invoiceApi,\n insuranceApi,\n messageApi,\n entityReferenceApi,\n receiptApi,\n agendaApi,\n calendarItemApi,\n classificationApi,\n timetableApi,\n groupApi,\n maintenanceTaskApi,\n dataOwnerApi,\n icureMaintenanceTaskApi,\n }\n}\n\nexport const BasicApis = async function (\n host: string,\n username: string,\n password: string,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n forceBasic: boolean = false\n) {\n const headers = {}\n const authenticationProvider = forceBasic\n ? new BasicAuthenticationProvider(username, password)\n : new EnsembleAuthenticationProvider(new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl), username, password)\n const authApi = new IccAuthApi(host, headers, authenticationProvider, fetchImpl)\n\n const codeApi = new IccCodeXApi(host, headers, authenticationProvider, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, headers, authenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, headers, authenticationProvider, fetchImpl)\n const permissionApi = new IccPermissionApi(host, headers, authenticationProvider, fetchImpl)\n const agendaApi = new IccAgendaApi(host, headers, authenticationProvider, fetchImpl)\n const groupApi = new IccGroupApi(host, headers, authenticationProvider)\n const insuranceApi = new IccInsuranceApi(host, headers, authenticationProvider, fetchImpl)\n\n return {\n authApi,\n codeApi,\n userApi,\n permissionApi,\n insuranceApi,\n entityReferenceApi,\n agendaApi,\n groupApi,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAUmB;AACnB,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD;AACpD,6DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,6DAAsD;AACtD,yEAAkE;AAClE,uEAA+D;AAC/D,2DAAoD;AACpD,2DAAoD;AACpD,2DAAoD;AACpD,+DAAwD;AACxD,iEAAyD;AACzD,8DAA0D;AAC1D,qDAA8C;AAC9C,6EAAqE;AACrE,iEAAyD;AAGzD,iEAA6D;AAC7D,6DAAyD;AACzD,0EAKsC;AACtC,gEAA4D;AAC5D,oDAAgD;AAChD,qEAAiE;AACjE,6FAAyF;AACzF,sDAAkD;AAClD,8EAA0E;AAG1E,sEAAkE;AAClE,kEAA8D;AAC9D,sEAAkE;AAClE,+EAAuE;AACvE,oEAAgE;AAChE,wEAAoE;AACpE,0CAAwD;AACxD,sEAA2F;AAE3F,wDAAqC;AACrC,sDAAmC;AACnC,4DAAyC;AACzC,6DAA0C;AAC1C,mDAAgC;AAChC,sDAAmC;AACnC,qDAAkC;AAClC,0DAAuC;AACvC,uDAAoC;AACpC,mDAAgC;AAChC,s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I,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACjF,MAAM,aAAa,GAAG,IAAI,0BAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAC5F,MAAM,SAAS,GAAG,IAAI,sBAAY,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACpF,MAAM,QAAQ,GAAG,IAAI,qBAAW,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAA;QACvE,MAAM,YAAY,GAAG,IAAI,yBAAe,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAE1F,OAAO;YACL,OAAO;YACP,OAAO;YACP,OAAO;YACP,aAAa;YACb,YAAY;YACZ,kBAAkB;YAClB,SAAS;YACT,QAAQ;SACT,CAAA;IACH,CAAC;CAAA,CAAA;AApCY,QAAA,SAAS,aAoCrB","sourcesContent":["import {\n IccAgendaApi,\n IccAuthApi,\n IccCalendarItemTypeApi,\n IccEntityrefApi,\n IccGroupApi,\n IccInsuranceApi,\n IccMedicallocationApi,\n IccPatientApi,\n IccPermissionApi,\n} from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccDeviceApi } from '../icc-api/api/IccDeviceApi'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { StorageFacade } from './storage/StorageFacade'\nimport { KeyStorageFacade } from './storage/KeyStorageFacade'\nimport { LocalStorageImpl } from './storage/LocalStorageImpl'\nimport { KeyStorageImpl } from './storage/KeyStorageImpl'\nimport {\n AuthenticationProvider,\n BasicAuthenticationProvider,\n EnsembleAuthenticationProvider,\n NoAuthenticationProvider,\n} from './auth/AuthenticationProvider'\nimport { CryptoPrimitives } from './crypto/CryptoPrimitives'\nimport { KeyManager } from './crypto/KeyManager'\nimport { IcureStorageFacade } from './storage/IcureStorageFacade'\nimport { DefaultStorageEntryKeysFactory } from './storage/DefaultStorageEntryKeysFactory'\nimport { KeyRecovery } from './crypto/KeyRecovery'\nimport { BaseExchangeKeysManager } from './crypto/BaseExchangeKeysManager'\nimport { StorageEntryKeysFactory } from './storage/StorageEntryKeysFactory'\nimport { CryptoStrategies } from './crypto/CryptoStrategies'\nimport { ExchangeKeysManager } from './crypto/ExchangeKeysManager'\nimport { ShamirKeysManager } from './crypto/ShamirKeysManager'\nimport { TransferKeysManager } from './crypto/TransferKeysManager'\nimport { IccIcureMaintenanceXApi } from './icc-icure-maintenance-x-api'\nimport { EntitiesEncryption } from './crypto/EntitiesEncryption'\nimport { ConfidentialEntities } from './crypto/ConfidentialEntities'\nimport { ensureDelegationForSelf } from './crypto/utils'\nimport { CryptoActorStub, CryptoActorStubWithType } from '../icc-api/model/CryptoActorStub'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './utils'\nexport { KeyStorageFacade } from './storage/KeyStorageFacade'\nexport { LocalStorageImpl } from './storage/LocalStorageImpl'\nexport { StorageFacade } from './storage/StorageFacade'\nexport { KeyStorageImpl } from './storage/KeyStorageImpl'\n\nexport interface Apis {\n authApi: IccAuthApi\n codeApi: IccCodeXApi\n calendarItemTypeApi: IccCalendarItemTypeApi\n medicalLocationApi: IccMedicallocationApi\n entityReferenceApi: IccEntityrefApi\n userApi: IccUserXApi\n permissionApi: IccPermissionApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceApi\n cryptoApi: IccCryptoXApi\n accessLogApi: IccAccesslogXApi\n agendaApi: IccAgendaApi\n contactApi: IccContactXApi\n formApi: IccFormXApi\n groupApi: IccGroupApi\n invoiceApi: IccInvoiceXApi\n insuranceApi: IccInsuranceApi\n documentApi: IccDocumentXApi\n healthcareElementApi: IccHelementXApi\n classificationApi: IccClassificationXApi\n calendarItemApi: IccCalendarItemXApi\n receiptApi: IccReceiptXApi\n timetableApi: IccTimeTableXApi\n patientApi: IccPatientXApi\n messageApi: IccMessageXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n dataOwnerApi: IccDataOwnerXApi\n icureMaintenanceTaskApi: IccIcureMaintenanceXApi\n}\n\nexport type ApiOptions = {\n readonly entryKeysFactory?: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey?: boolean\n readonly storage?: StorageFacade<string>\n readonly keyStorage?: KeyStorageFacade\n readonly headers?: { [headerName: string]: string }\n}\n\nclass NamedApiParametersWithDefault implements ApiOptions {\n constructor(custom: ApiOptions) {\n this.entryKeysFactory = custom.entryKeysFactory ?? new DefaultStorageEntryKeysFactory()\n this.createMaintenanceTasksOnNewKey = custom.createMaintenanceTasksOnNewKey ?? false\n this.storage = custom.storage ?? new LocalStorageImpl()\n this.keyStorage = custom.keyStorage ?? new KeyStorageImpl(this.storage)\n this.headers = custom.headers ?? {}\n }\n\n readonly entryKeysFactory: StorageEntryKeysFactory\n readonly createMaintenanceTasksOnNewKey: boolean\n readonly storage: StorageFacade<string>\n readonly keyStorage: KeyStorageFacade\n readonly headers: { [headerName: string]: string }\n}\n\nexport type AuthenticationDetails = {\n username: string\n password: string\n forceBasic?: boolean // default false\n}\n\nexport const Api = async function (\n host: string,\n authenticationOptions: AuthenticationDetails | AuthenticationProvider,\n cryptoStrategies: CryptoStrategies,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n options: ApiOptions = {}\n): Promise<Apis> {\n const params = new NamedApiParametersWithDefault(options)\n let authenticationProvider: AuthenticationProvider\n if ('username' in authenticationOptions && 'password' in authenticationOptions) {\n authenticationProvider = authenticationOptions.forceBasic\n ? new BasicAuthenticationProvider(authenticationOptions.username, authenticationOptions.password)\n : new EnsembleAuthenticationProvider(\n new IccAuthApi(host, params.headers, new NoAuthenticationProvider(), fetchImpl),\n authenticationOptions.username,\n authenticationOptions.password\n )\n } else {\n authenticationProvider = authenticationOptions\n }\n\n // Here I instantiate a separate instance of the AuthApi that can call also login-protected methods (logout)\n const authApi = new IccAuthApi(host, params.headers, authenticationProvider, fetchImpl)\n const codeApi = new IccCodeXApi(host, params.headers, authenticationProvider, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, params.headers, authenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, params.headers, authenticationProvider, fetchImpl)\n const permissionApi = new IccPermissionApi(host, params.headers, authenticationProvider, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, params.headers, authenticationProvider, fetchImpl)\n const deviceApi = new IccDeviceApi(host, params.headers, authenticationProvider, fetchImpl)\n const basePatientApi = new IccPatientApi(host, params.headers, authenticationProvider, fetchImpl)\n const dataOwnerApi = new IccDataOwnerXApi(host, params.headers, authenticationProvider, fetchImpl)\n // Crypto initialisation\n const icureStorage = new IcureStorageFacade(params.keyStorage, params.storage, params.entryKeysFactory)\n const cryptoPrimitives = new CryptoPrimitives(crypto)\n const baseExchangeKeysManager = new BaseExchangeKeysManager(cryptoPrimitives, dataOwnerApi, healthcarePartyApi, basePatientApi, deviceApi)\n const keyRecovery = new KeyRecovery(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi)\n const keyManager = new KeyManager(cryptoPrimitives, dataOwnerApi, icureStorage, keyRecovery, baseExchangeKeysManager, cryptoStrategies)\n const newKey = await keyManager.initialiseKeys()\n await new TransferKeysManager(cryptoPrimitives, baseExchangeKeysManager, dataOwnerApi, keyManager, icureStorage).updateTransferKeys(\n CryptoActorStubWithType.fromDataOwner(await dataOwnerApi.getCurrentDataOwner())\n )\n // TODO customise cache size?\n const exchangeKeysManager = new ExchangeKeysManager(\n 100,\n 500,\n 60000,\n 600000,\n cryptoStrategies,\n cryptoPrimitives,\n keyManager,\n baseExchangeKeysManager,\n dataOwnerApi,\n icureStorage\n )\n const entitiesEncryption = new EntitiesEncryption(cryptoPrimitives, dataOwnerApi, exchangeKeysManager)\n const shamirManager = new ShamirKeysManager(cryptoPrimitives, dataOwnerApi, keyManager, exchangeKeysManager)\n const confidentialEntitites = new ConfidentialEntities(entitiesEncryption, cryptoPrimitives, dataOwnerApi)\n await ensureDelegationForSelf(dataOwnerApi, entitiesEncryption, cryptoPrimitives, basePatientApi)\n const cryptoApi = new IccCryptoXApi(\n exchangeKeysManager,\n cryptoPrimitives,\n keyManager,\n dataOwnerApi,\n entitiesEncryption,\n shamirManager,\n params.storage,\n params.keyStorage,\n icureStorage,\n healthcarePartyApi,\n confidentialEntitites\n )\n const accessLogApi = new IccAccesslogXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const agendaApi = new IccAgendaApi(host, params.headers, authenticationProvider, fetchImpl)\n const contactApi = new IccContactXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const formApi = new IccFormXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const groupApi = new IccGroupApi(host, params.headers, authenticationProvider)\n const medicalLocationApi = new IccMedicallocationApi(host, params.headers, authenticationProvider)\n const calendarItemTypeApi = new IccCalendarItemTypeApi(host, params.headers, authenticationProvider)\n const invoiceApi = new IccInvoiceXApi(host, params.headers, cryptoApi, entityReferenceApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const insuranceApi = new IccInsuranceApi(host, params.headers, authenticationProvider, fetchImpl)\n const documentApi = new IccDocumentXApi(host, params.headers, cryptoApi, authApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const healthcareElementApi = new IccHelementXApi(\n host,\n params.headers,\n cryptoApi,\n dataOwnerApi,\n ['descr', 'note'],\n authenticationProvider,\n fetchImpl\n )\n const classificationApi = new IccClassificationXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const calendarItemApi = new IccCalendarItemXApi(\n host,\n params.headers,\n cryptoApi,\n dataOwnerApi,\n ['details', 'title', 'patientId'],\n authenticationProvider,\n fetchImpl\n )\n const receiptApi = new IccReceiptXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const timetableApi = new IccTimeTableXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const patientApi = new IccPatientXApi(\n host,\n params.headers,\n cryptoApi,\n contactApi,\n formApi,\n healthcareElementApi,\n invoiceApi,\n documentApi,\n healthcarePartyApi,\n classificationApi,\n dataOwnerApi,\n calendarItemApi,\n ['note'],\n authenticationProvider,\n fetchImpl\n )\n const messageApi = new IccMessageXApi(host, params.headers, cryptoApi, dataOwnerApi, authenticationProvider, fetchImpl)\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(\n host,\n params.headers,\n cryptoApi,\n healthcarePartyApi,\n dataOwnerApi,\n ['properties'],\n authenticationProvider,\n fetchImpl\n )\n const icureMaintenanceTaskApi = new IccIcureMaintenanceXApi(cryptoApi, maintenanceTaskApi, dataOwnerApi)\n\n if (newKey && params.createMaintenanceTasksOnNewKey) {\n await icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(await userApi.getCurrentUser(), newKey.newKeyPair)\n }\n return {\n cryptoApi,\n authApi,\n codeApi,\n calendarItemTypeApi,\n medicalLocationApi,\n userApi,\n permissionApi,\n patientApi,\n healthcarePartyApi,\n deviceApi,\n accessLogApi,\n contactApi,\n healthcareElementApi,\n documentApi,\n formApi,\n invoiceApi,\n insuranceApi,\n messageApi,\n entityReferenceApi,\n receiptApi,\n agendaApi,\n calendarItemApi,\n classificationApi,\n timetableApi,\n groupApi,\n maintenanceTaskApi,\n dataOwnerApi,\n icureMaintenanceTaskApi,\n }\n}\n\nexport const BasicApis = async function (\n host: string,\n username: string,\n password: string,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n forceBasic: boolean = false\n) {\n const headers = {}\n const authenticationProvider = forceBasic\n ? new BasicAuthenticationProvider(username, password)\n : new EnsembleAuthenticationProvider(new IccAuthApi(host, headers, new NoAuthenticationProvider(), fetchImpl), username, password)\n const authApi = new IccAuthApi(host, headers, authenticationProvider, fetchImpl)\n\n const codeApi = new IccCodeXApi(host, headers, authenticationProvider, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, headers, authenticationProvider, fetchImpl)\n const userApi = new IccUserXApi(host, headers, authenticationProvider, fetchImpl)\n const permissionApi = new IccPermissionApi(host, headers, authenticationProvider, fetchImpl)\n const agendaApi = new IccAgendaApi(host, headers, authenticationProvider, fetchImpl)\n const groupApi = new IccGroupApi(host, headers, authenticationProvider)\n const insuranceApi = new IccInsuranceApi(host, headers, authenticationProvider, fetchImpl)\n\n return {\n authApi,\n codeApi,\n userApi,\n permissionApi,\n insuranceApi,\n entityReferenceApi,\n agendaApi,\n groupApi,\n }\n}\n"]}
|