@icure/api 8.3.2 → 8.3.4

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.
@@ -45,9 +45,9 @@ export declare class IccPatientApi {
45
45
  */
46
46
  bulkUpdatePatients(body?: Array<Patient>): Promise<Array<IdWithRev>>;
47
47
  /**
48
- * Returns the count of patients
49
- * @summary Get count of patients for a specific HcParty or for the current HcParty
50
- * @param hcPartyId Healthcare party id
48
+ * Returns the count of patients shared directly with the provided hcp (ignoring hierarchies).
49
+ * WARNING: the current implementation can count some patients twice if they have both security metadata and legacy
50
+ * delegations from before v8.
51
51
  */
52
52
  countOfPatients(hcPartyId: string): Promise<Content>;
53
53
  /**
@@ -210,16 +210,26 @@ export declare class IccPatientApi {
210
210
  */
211
211
  listOfPatientsModifiedAfter(date: number, startKey?: number, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient>;
212
212
  /**
213
- * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.
214
- * @summary List patients for a specific HcParty
215
- * @param hcPartyId Healthcare party id
216
- * @param sortField Optional value for sorting results by a given field (&#x27;name&#x27;, &#x27;ssin&#x27;, &#x27;dateOfBirth&#x27;). Specifying this deactivates filtering
217
- * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey
218
- * @param startDocumentId A patient document ID
219
- * @param limit Number of rows
220
- * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.
213
+ * @deprecated This method is not intuitive and will be removed in a future version
214
+ * Currently there is no direct replacement that can do everything this method does.
215
+ * If you need all patients unsorted or sorted by ssin/date of birth use `PatientByHcPartyFilter`/`PatientByHcPartyDateOfBirthFilter`
216
+ * with {@link matchPatientsBy} to get the ids of all the patients shared directly with an HCP (ignoring hierarchies).
217
+ * Note that on databases with many patients (>50k) the matches request could take various seconds as it is not
218
+ * paginated.
219
+ * If you want to use pagination or need to sort by name instead you can use the {@link listPatientsSortedByName}.
220
+ * Usage of PatientByHcPartyNameFilter or PatientByHcPartyNameContainsFuzzyFilter as a replacement of this method is
221
+ * discouraged as the sorting done by those filter is unintuitive.
222
+ * Contact us if your use case is not covered by the suggested alternatives.
223
+ *
224
+ * This method returns all the patients (with pagination) that are shared directly with the parent of {@link hcPartyId},
225
+ * or if undefined the current user's parent. Note that this doesn't allow to get patients that are shared only with
226
+ * the current user and not its parent.
221
227
  */
222
228
  listPatients(hcPartyId?: string, sortField?: string, startKey?: string, startDocumentId?: string, limit?: number, sortDirection?: string): Promise<PaginatedListPatient>;
229
+ /**
230
+ * Get all patients shared directly with the provided hcparty (ignoring hierarchies) sorted by lastName, firstName.
231
+ */
232
+ listPatientsSortedByName(hcPartyId?: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient>;
223
233
  /**
224
234
  * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.
225
235
  * @summary List patients for a specific HcParty or for the current HcParty
@@ -83,9 +83,9 @@ class IccPatientApi {
83
83
  });
84
84
  }
85
85
  /**
86
- * Returns the count of patients
87
- * @summary Get count of patients for a specific HcParty or for the current HcParty
88
- * @param hcPartyId Healthcare party id
86
+ * Returns the count of patients shared directly with the provided hcp (ignoring hierarchies).
87
+ * WARNING: the current implementation can count some patients twice if they have both security metadata and legacy
88
+ * delegations from before v8.
89
89
  */
90
90
  countOfPatients(hcPartyId) {
91
91
  return __awaiter(this, void 0, void 0, function* () {
@@ -486,14 +486,20 @@ class IccPatientApi {
486
486
  });
487
487
  }
488
488
  /**
489
- * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.
490
- * @summary List patients for a specific HcParty
491
- * @param hcPartyId Healthcare party id
492
- * @param sortField Optional value for sorting results by a given field (&#x27;name&#x27;, &#x27;ssin&#x27;, &#x27;dateOfBirth&#x27;). Specifying this deactivates filtering
493
- * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey
494
- * @param startDocumentId A patient document ID
495
- * @param limit Number of rows
496
- * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.
489
+ * @deprecated This method is not intuitive and will be removed in a future version
490
+ * Currently there is no direct replacement that can do everything this method does.
491
+ * If you need all patients unsorted or sorted by ssin/date of birth use `PatientByHcPartyFilter`/`PatientByHcPartyDateOfBirthFilter`
492
+ * with {@link matchPatientsBy} to get the ids of all the patients shared directly with an HCP (ignoring hierarchies).
493
+ * Note that on databases with many patients (>50k) the matches request could take various seconds as it is not
494
+ * paginated.
495
+ * If you want to use pagination or need to sort by name instead you can use the {@link listPatientsSortedByName}.
496
+ * Usage of PatientByHcPartyNameFilter or PatientByHcPartyNameContainsFuzzyFilter as a replacement of this method is
497
+ * discouraged as the sorting done by those filter is unintuitive.
498
+ * Contact us if your use case is not covered by the suggested alternatives.
499
+ *
500
+ * This method returns all the patients (with pagination) that are shared directly with the parent of {@link hcPartyId},
501
+ * or if undefined the current user's parent. Note that this doesn't allow to get patients that are shared only with
502
+ * the current user and not its parent.
497
503
  */
498
504
  listPatients(hcPartyId, sortField, startKey, startDocumentId, limit, sortDirection) {
499
505
  return __awaiter(this, void 0, void 0, function* () {
@@ -514,6 +520,26 @@ class IccPatientApi {
514
520
  .catch((err) => this.handleError(err));
515
521
  });
516
522
  }
523
+ /**
524
+ * Get all patients shared directly with the provided hcparty (ignoring hierarchies) sorted by lastName, firstName.
525
+ */
526
+ listPatientsSortedByName(hcPartyId, startKey, startDocumentId, limit) {
527
+ return __awaiter(this, void 0, void 0, function* () {
528
+ let _body = null;
529
+ const _url = this.host +
530
+ `/patient/byHcPartyId` +
531
+ '?ts=' +
532
+ new Date().getTime() +
533
+ (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +
534
+ (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
535
+ (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
536
+ (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
537
+ let headers = yield this.headers;
538
+ return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
539
+ .then((doc) => new PaginatedListPatient_1.PaginatedListPatient(doc.body))
540
+ .catch((err) => this.handleError(err));
541
+ });
542
+ }
517
543
  /**
518
544
  * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.
519
545
  * @summary List patients for a specific HcParty or for the current HcParty
@@ -1 +1 @@
1
- {"version":3,"file":"IccPatientApi.js","sourceRoot":"","sources":["../../../icc-api/api/IccPatientApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,+BAA2B;AAE3B,8CAA0C;AAC1C,wFAAoF;AAEpF,0DAAsD;AAEtD,kDAA8C;AAE9C,wEAAoE;AACpE,sEAAkE;AAClE,8CAA0C;AAC1C,wFAA8G;AAC9G,qDAAiD;AACjD,mFAA+E;AAG/E,MAAa,aAAa;IAMxB,IAAI,OAAO;QACT,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACvC,CAAC;IAED,YACE,IAAY,EACZ,OAAY,EACZ,sBAA+C,EAC/C,SAAyE;QAEzE,IAAI,CAAC,IAAI,GAAG,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAA;QAChC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,SAAG,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9E,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,iDAAwB,EAAE,CAAA;QAChH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;;YACnF,IAAI,KAAK,GAAG,WAAW,CAAA;YAEvB,MAAM,IAAI,GACR,IAAI,CAAC,IAAI;gBACT,sBAAsB,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,SAAS,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE;gBAC7G,MAAM;gBACN,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;gBACpB,mBAAmB;gBACnB,kBAAkB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAA;YAC7C,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAA;YAChC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,MAAM,CAAC,IAAI,SAAG,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAA;YACvH,OAAO,SAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,CAAC;iBACzH,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,GAAG,CAAC,IAAY,CAAC,CAAC;iBAC5C,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1C,CAAC;KAAA;CACF;AApyBD,sCAoyBC","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 { XHR } from './XHR'\nimport { AbstractFilterPatient } from '../model/AbstractFilterPatient'\nimport { Content } from '../model/Content'\nimport { DataOwnerRegistrationSuccess } from '../model/DataOwnerRegistrationSuccess'\nimport { Delegation } from '../model/Delegation'\nimport { DocIdentifier } from '../model/DocIdentifier'\nimport { FilterChainPatient } from '../model/FilterChainPatient'\nimport { IdWithRev } from '../model/IdWithRev'\nimport { ListOfIds } from '../model/ListOfIds'\nimport { PaginatedListPatient } from '../model/PaginatedListPatient'\nimport { PaginatedListString } from '../model/PaginatedListString'\nimport { Patient } from '../model/Patient'\nimport { AuthenticationProvider, NoAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { iccRestApiPath } from './IccRestApiPath'\nimport { EntityBulkShareResult } from '../model/requests/EntityBulkShareResult'\nimport { BulkShareOrUpdateMetadataParams } from '../model/requests/BulkShareOrUpdateMetadataParams'\n\nexport class IccPatientApi {\n host: string\n _headers: Array<XHR.Header>\n authenticationProvider: AuthenticationProvider\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n get headers(): Promise<Array<XHR.Header>> {\n return Promise.resolve(this._headers)\n }\n\n constructor(\n host: string,\n headers: any,\n authenticationProvider?: AuthenticationProvider,\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n ) {\n this.host = iccRestApiPath(host)\n this._headers = Object.keys(headers).map((k) => new XHR.Header(k, headers[k]))\n this.authenticationProvider = !!authenticationProvider ? authenticationProvider : new NoAuthenticationProvider()\n this.fetchImpl = fetchImpl\n }\n setHeaders(h: Array<XHR.Header>) {\n this._headers = h\n }\n\n handleError(e: XHR.XHRError): never {\n throw e\n }\n\n /**\n * Returns the id and _rev of created patients\n * @summary Create patients in bulk\n * @param body\n */\n async bulkCreatePatients(body?: Array<Patient>): Promise<Array<IdWithRev>> {\n let _body = null\n _body = body\n\n const _url = this.host + `/patient/batch` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new IdWithRev(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns the id and _rev of modified patients\n * @summary Modify patients in bulk\n * @param body\n */\n async bulkUpdatePatients(body?: Array<Patient>): Promise<Array<IdWithRev>> {\n let _body = null\n _body = body\n\n const _url = this.host + `/patient/batch` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new IdWithRev(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns the count of patients\n * @summary Get count of patients for a specific HcParty or for the current HcParty\n * @param hcPartyId Healthcare party id\n */\n async countOfPatients(hcPartyId: string): Promise<Content> {\n let _body = null\n\n const _url = this.host + `/patient/hcParty/${encodeURIComponent(String(hcPartyId))}/count` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Content(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Name, last name, date of birth, and gender are required. After creation of the patient and obtaining the ID, you need to create an initial delegation.\n * @summary Create a patient\n * @param body\n */\n async createPatient(body?: Patient): Promise<Patient> {\n const _url = this.host + `/patient` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @summary Deletes a batch of patients.\n *\n * @param patientIds a ListOfIds containing the ids of the patients to delete.\n * @return a Promise that will resolve in an array of DocIdentifiers of the successfully deleted patients.\n */\n async deletePatients(patientIds: ListOfIds): Promise<Array<DocIdentifier>> {\n const headers = (await this.headers).filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand(\n 'POST',\n this.host + `/patient/delete/batch` + '?ts=' + new Date().getTime(),\n headers,\n patientIds,\n this.fetchImpl,\n undefined,\n this.authenticationProvider.getAuthService()\n )\n .then((doc) => (doc.body as Array<JSON>).map((it) => new DocIdentifier(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @summary Deletes a single patient by id.\n *\n * @param patientId the id of the patient to delete.\n * @return a Promise that will resolve in the DocIdentifier of the deleted patient.\n */\n async deletePatient(patientId: string): Promise<DocIdentifier> {\n return XHR.sendCommand(\n 'DELETE',\n this.host + `/patient/${encodeURIComponent(patientId)}` + '?ts=' + new Date().getTime(),\n await this.headers,\n null,\n this.fetchImpl,\n undefined,\n this.authenticationProvider.getAuthService()\n )\n .then((doc) => new DocIdentifier(doc.body))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary Filter patients for the current user (HcParty)\n * @param body\n * @param startKey The start key for pagination, depends on the filters used\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param skip Skip rows\n * @param sort Sort key\n * @param desc Descending\n */\n async filterPatientsBy(\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n body?: FilterChainPatient\n ): Promise<PaginatedListPatient> {\n let _body = null\n _body = body\n\n const _url =\n this.host +\n `/patient/filter` +\n '?ts=' +\n new Date().getTime() +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (skip ? '&skip=' + encodeURIComponent(String(skip)) : '') +\n (sort ? '&sort=' + encodeURIComponent(String(sort)) : '') +\n (desc ? '&desc=' + encodeURIComponent(String(desc)) : '')\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Get Paginated List of Patients sorted by Access logs descending\n * @param userId A User ID\n * @param accessType The type of access (COMPUTER or USER)\n * @param startDate The start search epoch\n * @param startKey The start key for pagination\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async findByAccessLogUserAfterDate(\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/byAccess/${encodeURIComponent(String(userId))}` +\n '?ts=' +\n new Date().getTime() +\n (accessType ? '&accessType=' + encodeURIComponent(String(accessType)) : '') +\n (startDate ? '&startDate=' + encodeURIComponent(String(startDate)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Get the patient having the provided externalId\n * @param externalId A external ID\n */\n async findByExternalId(externalId: string): Promise<Patient> {\n let _body = null\n\n const _url = this.host + `/patient/byExternalId/${encodeURIComponent(String(externalId))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary Find patients for the current user (HcParty)\n * @param healthcarePartyId HealthcareParty Id. If not set, will use user&#x27;s hcpId\n * @param filterValue Optional value for filtering results\n * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.\n */\n async findByNameBirthSsinAuto(\n healthcarePartyId?: string,\n filterValue?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/byNameBirthSsinAuto` +\n '?ts=' +\n new Date().getTime() +\n (healthcarePartyId ? '&healthcarePartyId=' + encodeURIComponent(String(healthcarePartyId)) : '') +\n (filterValue ? '&filterValue=' + encodeURIComponent(String(filterValue)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Provides a paginated list of patients with duplicate name for an hecparty\n * @param hcPartyId Healthcare party id\n * @param startKey The start key for pagination, depends on the filters used\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async findDuplicatesByName(hcPartyId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/duplicates/name` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Provides a paginated list of patients with duplicate ssin for an hecparty\n * @param hcPartyId Healthcare party id\n * @param startKey The start key for pagination, depends on the filters used\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async findDuplicatesBySsin(hcPartyId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/duplicates/ssin` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients\n * @summary Filter patients for the current user (HcParty)\n * @param firstName The first name\n * @param lastName The last name\n * @param dateOfBirth The date of birth\n */\n async fuzzySearch(firstName?: string, lastName?: string, dateOfBirth?: number): Promise<Array<Patient>> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/fuzzy` +\n '?ts=' +\n new Date().getTime() +\n (firstName ? '&firstName=' + encodeURIComponent(String(firstName)) : '') +\n (lastName ? '&lastName=' + encodeURIComponent(String(lastName)) : '') +\n (dateOfBirth ? '&dateOfBirth=' + encodeURIComponent(String(dateOfBirth)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * It gets patient administrative data.\n * @summary Get patient\n * @param patientId\n */\n async getPatient(patientId: string): Promise<Patient> {\n let _body = null\n\n const _url = this.host + `/patient/${encodeURIComponent(String(patientId))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * (key, value) of the map is as follows: (ID of the owner of the encrypted AES key, encrypted AES keys)\n * @summary Get the HcParty encrypted AES keys indexed by owner.\n * @param patientId\n */\n async getPatientAesExchangeKeysForDelegate(\n patientId: string\n ): Promise<{ [delegatorId: string]: { [delegatorPubKeyFingerprint: string]: { [delegatePubKeyFingerprint: string]: string } } }> {\n let _body = null\n\n const _url = this.host + `/patient/${encodeURIComponent(String(patientId))}/aesExchangeKeys` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => JSON.parse(JSON.stringify(doc.body)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * It gets patient administrative data based on the identifier (root & extension) parameters.\n * @summary Get patient by identifier\n * @param hcPartyId\n * @param id\n * @param system\n */\n async getPatientByHealthcarepartyAndIdentifier(hcPartyId: string, id: string, system?: string): Promise<Patient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/${encodeURIComponent(String(hcPartyId))}/${encodeURIComponent(String(id))}` +\n '?ts=' +\n new Date().getTime() +\n (system ? '&system=' + encodeURIComponent(String(system)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * This endpoint is used to recover all keys that have already been created and that can be used to share information with this patient. It returns a map with the following structure: ID of the owner of the encrypted AES key -> encrypted AES key. The returned encrypted AES keys will have to be decrypted using the patient's private key. { \\\"hcparty 1 delegator ID\\\": \\\"AES hcparty key (encrypted using patient public RSA key)\\\" \\\"hcparty 2 delegator ID\\\": \\\"other AES hcparty key (encrypted using patient public RSA key)\\\" }\n * @summary Get the patient (identified by patientId) hcparty keys. Those keys are AES keys (encrypted) used to share information between HCPs and a patient.\n * @param patientId The patient Id for which information is shared\n */\n async getPatientHcPartyKeysForDelegate(patientId: string): Promise<{ [key: string]: string }> {\n let _body = null\n\n const _url = this.host + `/patient/${encodeURIComponent(String(patientId))}/keys` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => JSON.parse(JSON.stringify(doc.body)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * It gets patient administrative data.\n * @summary Get patients by id\n * @param body\n */\n async getPatients(body?: ListOfIds): Promise<Array<Patient>> {\n const _url = this.host + `/patient/byIds` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of deleted patients, within the specified time period, if any.\n * @summary Find deleted patients\n * @param startDate Filter deletions after this date (unix epoch), included\n * @param endDate Filter deletions before this date (unix epoch), included\n * @param startKey the startKey provided by the previous page or undefined for the first page.\n * @param desc Descending\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async listDeletedPatients(\n startDate?: number,\n endDate?: number,\n desc?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListPatient> {\n const _url =\n this.host +\n `/patient/deleted/byDate` +\n '?ts=' +\n new Date().getTime() +\n (startDate ? '&startDate=' + encodeURIComponent(startDate) : '') +\n (endDate ? '&endDate=' + encodeURIComponent(endDate) : '') +\n (desc ? '&desc=' + encodeURIComponent(desc) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(startKey) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(startDocumentId) : '') +\n (limit ? '&limit=' + encodeURIComponent(limit) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of deleted patients, by name and/or firstname prefix, if any.\n * @summary Find deleted patients\n * @param firstName First name prefix\n * @param lastName Last name prefix\n */\n async listDeletedPatientsByName(firstName?: string, lastName?: string): Promise<Array<Patient>> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/deleted/by_name` +\n '?ts=' +\n new Date().getTime() +\n (firstName ? '&firstName=' + encodeURIComponent(String(firstName)) : '') +\n (lastName ? '&lastName=' + encodeURIComponent(String(lastName)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients that have been merged after the provided date\n * @summary List patients that have been merged towards another patient\n * @param date\n */\n async listOfMergesAfter(date: number): Promise<Array<Patient>> {\n let _body = null\n\n const _url = this.host + `/patient/merges/${encodeURIComponent(String(date))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients that have been modified after the provided date\n * @summary List patients that have been modified after the provided date\n * @param date\n * @param startKey The start key for pagination the date of the first element of the new page\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async listOfPatientsModifiedAfter(date: number, startKey?: number, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/modifiedAfter/${encodeURIComponent(String(date))}` +\n '?ts=' +\n new Date().getTime() +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary List patients for a specific HcParty\n * @param hcPartyId Healthcare party id\n * @param sortField Optional value for sorting results by a given field (&#x27;name&#x27;, &#x27;ssin&#x27;, &#x27;dateOfBirth&#x27;). Specifying this deactivates filtering\n * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.\n */\n async listPatients(\n hcPartyId?: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (sortField ? '&sortField=' + encodeURIComponent(String(sortField)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary List patients for a specific HcParty or for the current HcParty\n * @param hcPartyId\n * @param sortField Optional value for sorting results by a given field (&#x27;name&#x27;, &#x27;ssin&#x27;, &#x27;dateOfBirth&#x27;). Specifying this deactivates filtering\n * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.\n */\n async listPatientsByHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/hcParty/${encodeURIComponent(String(hcPartyId))}` +\n '?ts=' +\n new Date().getTime() +\n (sortField ? '&sortField=' + encodeURIComponent(String(sortField)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary List patients by pages for a specific HcParty\n * @param hcPartyId Healthcare party id\n * @param startKey The page first id\n * @param startDocumentId A patient document ID\n * @param limit Page size\n */\n async listPatientsIds(hcPartyId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListString> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/byHcPartyId` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListString(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary List patients of a specific HcParty or of the current HcParty\n * @param hcPartyId\n * @param sortField Optional value for sorting results by a given field (&#x27;name&#x27;, &#x27;ssin&#x27;, &#x27;dateOfBirth&#x27;). Specifying this deactivates filtering\n * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.\n */\n async listPatientsOfHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/ofHcParty/${encodeURIComponent(String(hcPartyId))}` +\n '?ts=' +\n new Date().getTime() +\n (sortField ? '&sortField=' + encodeURIComponent(String(sortField)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Get ids of patients matching the provided filter for the current user (HcParty)\n * @param body\n */\n async matchPatientsBy(body?: AbstractFilterPatient): Promise<Array<string>> {\n const _url = this.host + `/patient/match` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => JSON.parse(JSON.stringify(it))))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Merge a series of patients into another patient\n * @param toId\n * @param fromIds\n */\n async mergeInto(toId: string, fromIds: string): Promise<Patient> {\n let _body = null\n\n const _url =\n this.host + `/patient/mergeInto/${encodeURIComponent(String(toId))}/from/${encodeURIComponent(String(fromIds))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * No particular return value. It's just a message.\n * @summary Modify a patient\n * @param body\n */\n async modifyPatient(body?: Patient): Promise<Patient> {\n let _body = null\n _body = body\n\n const _url = this.host + `/patient` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Set a patient referral doctor\n * @param patientId\n * @param referralId The referal id. Accepts &#x27;none&#x27; for referral removal.\n * @param start Optional value for start of referral\n * @param end Optional value for end of referral\n */\n async modifyPatientReferral(patientId: string, referralId: string, start?: number, end?: number): Promise<Patient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/${encodeURIComponent(String(patientId))}/referral/${encodeURIComponent(String(referralId))}` +\n '?ts=' +\n new Date().getTime() +\n (start ? '&start=' + encodeURIComponent(String(start)) : '') +\n (end ? '&end=' + encodeURIComponent(String(end)) : '')\n let headers = await this.headers\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Register a new patient into the system\n * @summary Register a patient\n * @param body\n * @param hcPartyId\n * @param groupId\n * @param token\n * @param useShortToken\n */\n async registerPatient(\n hcPartyId: string,\n groupId: string,\n token?: string,\n useShortToken?: boolean,\n body?: Patient\n ): Promise<DataOwnerRegistrationSuccess> {\n let _body = null\n _body = body\n\n const _url =\n this.host +\n `/patient/register/forHcp/${encodeURIComponent(String(hcPartyId))}/inGroup/${encodeURIComponent(String(groupId))}` +\n '?ts=' +\n new Date().getTime() +\n (token ? '&token=' + encodeURIComponent(String(token)) : '') +\n (useShortToken ? '&useShortToken=' + encodeURIComponent(String(useShortToken)) : '')\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new DataOwnerRegistrationSuccess(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Response is an array containing the ID of undeleted patient..\n * @summary undelete previously deleted patients\n * @param patientIds\n */\n async undeletePatient(patientIds: string): Promise<Array<DocIdentifier>> {\n let _body = null\n\n const _url = this.host + `/patient/undelete/${encodeURIComponent(String(patientIds))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new DocIdentifier(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice\n */\n async bulkSharePatients(request: BulkShareOrUpdateMetadataParams): Promise<EntityBulkShareResult<Patient>[]> {\n const _url = this.host + '/patient/bulkSharedMetadataUpdate' + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((x) => new EntityBulkShareResult<Patient>(x, Patient)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @internal use mergePatients from the extended api instead\n */\n async baseMergePatients(fromId: string, expectedFromRev: string, updatedInto: Patient) {\n let _body = updatedInto\n\n const _url =\n this.host +\n `/patient/mergeInto/${encodeURIComponent(String(updatedInto.id))}/from/${encodeURIComponent(String(fromId))}` +\n '?ts=' +\n new Date().getTime() +\n '&expectedFromRev=' +\n encodeURIComponent(String(expectedFromRev))\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n}\n"]}
1
+ {"version":3,"file":"IccPatientApi.js","sourceRoot":"","sources":["../../../icc-api/api/IccPatientApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,+BAA2B;AAE3B,8CAA0C;AAC1C,wFAAoF;AAEpF,0DAAsD;AAEtD,kDAA8C;AAE9C,wEAAoE;AACpE,sEAAkE;AAClE,8CAA0C;AAC1C,wFAA8G;AAC9G,qDAAiD;AACjD,mFAA+E;AAG/E,MAAa,aAAa;IAMxB,IAAI,OAAO;QACT,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACvC,CAAC;IAED,YACE,IAAY,EACZ,OAAY,EACZ,sBAA+C,EAC/C,SAAyE;QAEzE,IAAI,CAAC,IAAI,GAAG,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAA;QAChC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,SAAG,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9E,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,iDAAwB,EAAE,CAAA;QAChH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IACD,UAAU,CAAC,CAAoB;QAC7B,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;IACnB,CAAC;IAED,WAAW,CAAC,CAAe;QACzB,MAAM,CAAC,CAAA;IACT,CAAC;IAED;;;;OAIG;IACG,kBAAkB,CAAC,IAAqB;;YAC5C,IAAI,KAAK,GAAG,IAAI,CAAA;YAChB,KAAK,GAAG,IAAI,CAAA;YAEZ,MAAM,IAAI,GAAG,IAAI,CAAC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,CAAA;YAChC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,MAAM,CAAC,IAAI,SAAG,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAA;YACvH,OAAO,SAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,CAAC;iBACzH,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,GAAG,CAAC,IAAY,CAAC,CAAC;iBAC5C,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1C,CAAC;KAAA;CACF;AA/zBD,sCA+zBC","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 { XHR } from './XHR'\nimport { AbstractFilterPatient } from '../model/AbstractFilterPatient'\nimport { Content } from '../model/Content'\nimport { DataOwnerRegistrationSuccess } from '../model/DataOwnerRegistrationSuccess'\nimport { Delegation } from '../model/Delegation'\nimport { DocIdentifier } from '../model/DocIdentifier'\nimport { FilterChainPatient } from '../model/FilterChainPatient'\nimport { IdWithRev } from '../model/IdWithRev'\nimport { ListOfIds } from '../model/ListOfIds'\nimport { PaginatedListPatient } from '../model/PaginatedListPatient'\nimport { PaginatedListString } from '../model/PaginatedListString'\nimport { Patient } from '../model/Patient'\nimport { AuthenticationProvider, NoAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { iccRestApiPath } from './IccRestApiPath'\nimport { EntityBulkShareResult } from '../model/requests/EntityBulkShareResult'\nimport { BulkShareOrUpdateMetadataParams } from '../model/requests/BulkShareOrUpdateMetadataParams'\n\nexport class IccPatientApi {\n host: string\n _headers: Array<XHR.Header>\n authenticationProvider: AuthenticationProvider\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n get headers(): Promise<Array<XHR.Header>> {\n return Promise.resolve(this._headers)\n }\n\n constructor(\n host: string,\n headers: any,\n authenticationProvider?: AuthenticationProvider,\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n ) {\n this.host = iccRestApiPath(host)\n this._headers = Object.keys(headers).map((k) => new XHR.Header(k, headers[k]))\n this.authenticationProvider = !!authenticationProvider ? authenticationProvider : new NoAuthenticationProvider()\n this.fetchImpl = fetchImpl\n }\n setHeaders(h: Array<XHR.Header>) {\n this._headers = h\n }\n\n handleError(e: XHR.XHRError): never {\n throw e\n }\n\n /**\n * Returns the id and _rev of created patients\n * @summary Create patients in bulk\n * @param body\n */\n async bulkCreatePatients(body?: Array<Patient>): Promise<Array<IdWithRev>> {\n let _body = null\n _body = body\n\n const _url = this.host + `/patient/batch` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new IdWithRev(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns the id and _rev of modified patients\n * @summary Modify patients in bulk\n * @param body\n */\n async bulkUpdatePatients(body?: Array<Patient>): Promise<Array<IdWithRev>> {\n let _body = null\n _body = body\n\n const _url = this.host + `/patient/batch` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new IdWithRev(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns the count of patients shared directly with the provided hcp (ignoring hierarchies).\n * WARNING: the current implementation can count some patients twice if they have both security metadata and legacy\n * delegations from before v8.\n */\n async countOfPatients(hcPartyId: string): Promise<Content> {\n let _body = null\n\n const _url = this.host + `/patient/hcParty/${encodeURIComponent(String(hcPartyId))}/count` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Content(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Name, last name, date of birth, and gender are required. After creation of the patient and obtaining the ID, you need to create an initial delegation.\n * @summary Create a patient\n * @param body\n */\n async createPatient(body?: Patient): Promise<Patient> {\n const _url = this.host + `/patient` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @summary Deletes a batch of patients.\n *\n * @param patientIds a ListOfIds containing the ids of the patients to delete.\n * @return a Promise that will resolve in an array of DocIdentifiers of the successfully deleted patients.\n */\n async deletePatients(patientIds: ListOfIds): Promise<Array<DocIdentifier>> {\n const headers = (await this.headers).filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand(\n 'POST',\n this.host + `/patient/delete/batch` + '?ts=' + new Date().getTime(),\n headers,\n patientIds,\n this.fetchImpl,\n undefined,\n this.authenticationProvider.getAuthService()\n )\n .then((doc) => (doc.body as Array<JSON>).map((it) => new DocIdentifier(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @summary Deletes a single patient by id.\n *\n * @param patientId the id of the patient to delete.\n * @return a Promise that will resolve in the DocIdentifier of the deleted patient.\n */\n async deletePatient(patientId: string): Promise<DocIdentifier> {\n return XHR.sendCommand(\n 'DELETE',\n this.host + `/patient/${encodeURIComponent(patientId)}` + '?ts=' + new Date().getTime(),\n await this.headers,\n null,\n this.fetchImpl,\n undefined,\n this.authenticationProvider.getAuthService()\n )\n .then((doc) => new DocIdentifier(doc.body))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary Filter patients for the current user (HcParty)\n * @param body\n * @param startKey The start key for pagination, depends on the filters used\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param skip Skip rows\n * @param sort Sort key\n * @param desc Descending\n */\n async filterPatientsBy(\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n body?: FilterChainPatient\n ): Promise<PaginatedListPatient> {\n let _body = null\n _body = body\n\n const _url =\n this.host +\n `/patient/filter` +\n '?ts=' +\n new Date().getTime() +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (skip ? '&skip=' + encodeURIComponent(String(skip)) : '') +\n (sort ? '&sort=' + encodeURIComponent(String(sort)) : '') +\n (desc ? '&desc=' + encodeURIComponent(String(desc)) : '')\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Get Paginated List of Patients sorted by Access logs descending\n * @param userId A User ID\n * @param accessType The type of access (COMPUTER or USER)\n * @param startDate The start search epoch\n * @param startKey The start key for pagination\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async findByAccessLogUserAfterDate(\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/byAccess/${encodeURIComponent(String(userId))}` +\n '?ts=' +\n new Date().getTime() +\n (accessType ? '&accessType=' + encodeURIComponent(String(accessType)) : '') +\n (startDate ? '&startDate=' + encodeURIComponent(String(startDate)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Get the patient having the provided externalId\n * @param externalId A external ID\n */\n async findByExternalId(externalId: string): Promise<Patient> {\n let _body = null\n\n const _url = this.host + `/patient/byExternalId/${encodeURIComponent(String(externalId))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary Find patients for the current user (HcParty)\n * @param healthcarePartyId HealthcareParty Id. If not set, will use user&#x27;s hcpId\n * @param filterValue Optional value for filtering results\n * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.\n */\n async findByNameBirthSsinAuto(\n healthcarePartyId?: string,\n filterValue?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/byNameBirthSsinAuto` +\n '?ts=' +\n new Date().getTime() +\n (healthcarePartyId ? '&healthcarePartyId=' + encodeURIComponent(String(healthcarePartyId)) : '') +\n (filterValue ? '&filterValue=' + encodeURIComponent(String(filterValue)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Provides a paginated list of patients with duplicate name for an hecparty\n * @param hcPartyId Healthcare party id\n * @param startKey The start key for pagination, depends on the filters used\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async findDuplicatesByName(hcPartyId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/duplicates/name` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Provides a paginated list of patients with duplicate ssin for an hecparty\n * @param hcPartyId Healthcare party id\n * @param startKey The start key for pagination, depends on the filters used\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async findDuplicatesBySsin(hcPartyId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/duplicates/ssin` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients\n * @summary Filter patients for the current user (HcParty)\n * @param firstName The first name\n * @param lastName The last name\n * @param dateOfBirth The date of birth\n */\n async fuzzySearch(firstName?: string, lastName?: string, dateOfBirth?: number): Promise<Array<Patient>> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/fuzzy` +\n '?ts=' +\n new Date().getTime() +\n (firstName ? '&firstName=' + encodeURIComponent(String(firstName)) : '') +\n (lastName ? '&lastName=' + encodeURIComponent(String(lastName)) : '') +\n (dateOfBirth ? '&dateOfBirth=' + encodeURIComponent(String(dateOfBirth)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * It gets patient administrative data.\n * @summary Get patient\n * @param patientId\n */\n async getPatient(patientId: string): Promise<Patient> {\n let _body = null\n\n const _url = this.host + `/patient/${encodeURIComponent(String(patientId))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * (key, value) of the map is as follows: (ID of the owner of the encrypted AES key, encrypted AES keys)\n * @summary Get the HcParty encrypted AES keys indexed by owner.\n * @param patientId\n */\n async getPatientAesExchangeKeysForDelegate(\n patientId: string\n ): Promise<{ [delegatorId: string]: { [delegatorPubKeyFingerprint: string]: { [delegatePubKeyFingerprint: string]: string } } }> {\n let _body = null\n\n const _url = this.host + `/patient/${encodeURIComponent(String(patientId))}/aesExchangeKeys` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => JSON.parse(JSON.stringify(doc.body)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * It gets patient administrative data based on the identifier (root & extension) parameters.\n * @summary Get patient by identifier\n * @param hcPartyId\n * @param id\n * @param system\n */\n async getPatientByHealthcarepartyAndIdentifier(hcPartyId: string, id: string, system?: string): Promise<Patient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/${encodeURIComponent(String(hcPartyId))}/${encodeURIComponent(String(id))}` +\n '?ts=' +\n new Date().getTime() +\n (system ? '&system=' + encodeURIComponent(String(system)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * This endpoint is used to recover all keys that have already been created and that can be used to share information with this patient. It returns a map with the following structure: ID of the owner of the encrypted AES key -> encrypted AES key. The returned encrypted AES keys will have to be decrypted using the patient's private key. { \\\"hcparty 1 delegator ID\\\": \\\"AES hcparty key (encrypted using patient public RSA key)\\\" \\\"hcparty 2 delegator ID\\\": \\\"other AES hcparty key (encrypted using patient public RSA key)\\\" }\n * @summary Get the patient (identified by patientId) hcparty keys. Those keys are AES keys (encrypted) used to share information between HCPs and a patient.\n * @param patientId The patient Id for which information is shared\n */\n async getPatientHcPartyKeysForDelegate(patientId: string): Promise<{ [key: string]: string }> {\n let _body = null\n\n const _url = this.host + `/patient/${encodeURIComponent(String(patientId))}/keys` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => JSON.parse(JSON.stringify(doc.body)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * It gets patient administrative data.\n * @summary Get patients by id\n * @param body\n */\n async getPatients(body?: ListOfIds): Promise<Array<Patient>> {\n const _url = this.host + `/patient/byIds` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of deleted patients, within the specified time period, if any.\n * @summary Find deleted patients\n * @param startDate Filter deletions after this date (unix epoch), included\n * @param endDate Filter deletions before this date (unix epoch), included\n * @param startKey the startKey provided by the previous page or undefined for the first page.\n * @param desc Descending\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async listDeletedPatients(\n startDate?: number,\n endDate?: number,\n desc?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListPatient> {\n const _url =\n this.host +\n `/patient/deleted/byDate` +\n '?ts=' +\n new Date().getTime() +\n (startDate ? '&startDate=' + encodeURIComponent(startDate) : '') +\n (endDate ? '&endDate=' + encodeURIComponent(endDate) : '') +\n (desc ? '&desc=' + encodeURIComponent(desc) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(startKey) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(startDocumentId) : '') +\n (limit ? '&limit=' + encodeURIComponent(limit) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of deleted patients, by name and/or firstname prefix, if any.\n * @summary Find deleted patients\n * @param firstName First name prefix\n * @param lastName Last name prefix\n */\n async listDeletedPatientsByName(firstName?: string, lastName?: string): Promise<Array<Patient>> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/deleted/by_name` +\n '?ts=' +\n new Date().getTime() +\n (firstName ? '&firstName=' + encodeURIComponent(String(firstName)) : '') +\n (lastName ? '&lastName=' + encodeURIComponent(String(lastName)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients that have been merged after the provided date\n * @summary List patients that have been merged towards another patient\n * @param date\n */\n async listOfMergesAfter(date: number): Promise<Array<Patient>> {\n let _body = null\n\n const _url = this.host + `/patient/merges/${encodeURIComponent(String(date))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new Patient(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients that have been modified after the provided date\n * @summary List patients that have been modified after the provided date\n * @param date\n * @param startKey The start key for pagination the date of the first element of the new page\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n */\n async listOfPatientsModifiedAfter(date: number, startKey?: number, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/modifiedAfter/${encodeURIComponent(String(date))}` +\n '?ts=' +\n new Date().getTime() +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @deprecated This method is not intuitive and will be removed in a future version\n * Currently there is no direct replacement that can do everything this method does.\n * If you need all patients unsorted or sorted by ssin/date of birth use `PatientByHcPartyFilter`/`PatientByHcPartyDateOfBirthFilter`\n * with {@link matchPatientsBy} to get the ids of all the patients shared directly with an HCP (ignoring hierarchies).\n * Note that on databases with many patients (>50k) the matches request could take various seconds as it is not\n * paginated.\n * If you want to use pagination or need to sort by name instead you can use the {@link listPatientsSortedByName}.\n * Usage of PatientByHcPartyNameFilter or PatientByHcPartyNameContainsFuzzyFilter as a replacement of this method is\n * discouraged as the sorting done by those filter is unintuitive.\n * Contact us if your use case is not covered by the suggested alternatives.\n *\n * This method returns all the patients (with pagination) that are shared directly with the parent of {@link hcPartyId},\n * or if undefined the current user's parent. Note that this doesn't allow to get patients that are shared only with\n * the current user and not its parent.\n */\n async listPatients(\n hcPartyId?: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (sortField ? '&sortField=' + encodeURIComponent(String(sortField)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Get all patients shared directly with the provided hcparty (ignoring hierarchies) sorted by lastName, firstName.\n */\n async listPatientsSortedByName(hcPartyId?: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/byHcPartyId` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary List patients for a specific HcParty or for the current HcParty\n * @param hcPartyId\n * @param sortField Optional value for sorting results by a given field (&#x27;name&#x27;, &#x27;ssin&#x27;, &#x27;dateOfBirth&#x27;). Specifying this deactivates filtering\n * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.\n */\n async listPatientsByHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/hcParty/${encodeURIComponent(String(hcPartyId))}` +\n '?ts=' +\n new Date().getTime() +\n (sortField ? '&sortField=' + encodeURIComponent(String(sortField)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary List patients by pages for a specific HcParty\n * @param hcPartyId Healthcare party id\n * @param startKey The page first id\n * @param startDocumentId A patient document ID\n * @param limit Page size\n */\n async listPatientsIds(hcPartyId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListString> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/byHcPartyId` +\n '?ts=' +\n new Date().getTime() +\n (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListString(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Returns a list of patients along with next start keys and Document ID. If the nextStartKey is Null it means that this is the last page.\n * @summary List patients of a specific HcParty or of the current HcParty\n * @param hcPartyId\n * @param sortField Optional value for sorting results by a given field (&#x27;name&#x27;, &#x27;ssin&#x27;, &#x27;dateOfBirth&#x27;). Specifying this deactivates filtering\n * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey\n * @param startDocumentId A patient document ID\n * @param limit Number of rows\n * @param sortDirection Optional value for providing a sorting direction (&#x27;asc&#x27;, &#x27;desc&#x27;). Set to &#x27;asc&#x27; by default.\n */\n async listPatientsOfHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<PaginatedListPatient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/ofHcParty/${encodeURIComponent(String(hcPartyId))}` +\n '?ts=' +\n new Date().getTime() +\n (sortField ? '&sortField=' + encodeURIComponent(String(sortField)) : '') +\n (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +\n (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +\n (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +\n (sortDirection ? '&sortDirection=' + encodeURIComponent(String(sortDirection)) : '')\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListPatient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Get ids of patients matching the provided filter for the current user (HcParty)\n * @param body\n */\n async matchPatientsBy(body?: AbstractFilterPatient): Promise<Array<string>> {\n const _url = this.host + `/patient/match` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => JSON.parse(JSON.stringify(it))))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Merge a series of patients into another patient\n * @param toId\n * @param fromIds\n */\n async mergeInto(toId: string, fromIds: string): Promise<Patient> {\n let _body = null\n\n const _url =\n this.host + `/patient/mergeInto/${encodeURIComponent(String(toId))}/from/${encodeURIComponent(String(fromIds))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * No particular return value. It's just a message.\n * @summary Modify a patient\n * @param body\n */\n async modifyPatient(body?: Patient): Promise<Patient> {\n let _body = null\n _body = body\n\n const _url = this.host + `/patient` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Set a patient referral doctor\n * @param patientId\n * @param referralId The referal id. Accepts &#x27;none&#x27; for referral removal.\n * @param start Optional value for start of referral\n * @param end Optional value for end of referral\n */\n async modifyPatientReferral(patientId: string, referralId: string, start?: number, end?: number): Promise<Patient> {\n let _body = null\n\n const _url =\n this.host +\n `/patient/${encodeURIComponent(String(patientId))}/referral/${encodeURIComponent(String(referralId))}` +\n '?ts=' +\n new Date().getTime() +\n (start ? '&start=' + encodeURIComponent(String(start)) : '') +\n (end ? '&end=' + encodeURIComponent(String(end)) : '')\n let headers = await this.headers\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Register a new patient into the system\n * @summary Register a patient\n * @param body\n * @param hcPartyId\n * @param groupId\n * @param token\n * @param useShortToken\n */\n async registerPatient(\n hcPartyId: string,\n groupId: string,\n token?: string,\n useShortToken?: boolean,\n body?: Patient\n ): Promise<DataOwnerRegistrationSuccess> {\n let _body = null\n _body = body\n\n const _url =\n this.host +\n `/patient/register/forHcp/${encodeURIComponent(String(hcPartyId))}/inGroup/${encodeURIComponent(String(groupId))}` +\n '?ts=' +\n new Date().getTime() +\n (token ? '&token=' + encodeURIComponent(String(token)) : '') +\n (useShortToken ? '&useShortToken=' + encodeURIComponent(String(useShortToken)) : '')\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new DataOwnerRegistrationSuccess(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * Response is an array containing the ID of undeleted patient..\n * @summary undelete previously deleted patients\n * @param patientIds\n */\n async undeletePatient(patientIds: string): Promise<Array<DocIdentifier>> {\n let _body = null\n\n const _url = this.host + `/patient/undelete/${encodeURIComponent(String(patientIds))}` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new DocIdentifier(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice\n */\n async bulkSharePatients(request: BulkShareOrUpdateMetadataParams): Promise<EntityBulkShareResult<Patient>[]> {\n const _url = this.host + '/patient/bulkSharedMetadataUpdate' + '?ts=' + new Date().getTime()\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((x) => new EntityBulkShareResult<Patient>(x, Patient)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @internal use mergePatients from the extended api instead\n */\n async baseMergePatients(fromId: string, expectedFromRev: string, updatedInto: Patient) {\n let _body = updatedInto\n\n const _url =\n this.host +\n `/patient/mergeInto/${encodeURIComponent(String(updatedInto.id))}/from/${encodeURIComponent(String(fromId))}` +\n '?ts=' +\n new Date().getTime() +\n '&expectedFromRev=' +\n encodeURIComponent(String(expectedFromRev))\n let headers = await this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Patient(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n}\n"]}
@@ -207,8 +207,14 @@ class UserEncryptionKeysManager {
207
207
  const self = hierarchy[hierarchy.length - 1];
208
208
  this.selfId = self.dataOwner.id;
209
209
  const keysData = [];
210
- for (const dowt of this.initialiseParentKeys ? hierarchy : [self]) {
211
- const availableKeys = yield this.loadAndRecoverKeysFor(dowt);
210
+ const toInit = this.initialiseParentKeys ? hierarchy : [self];
211
+ for (let i = 0; i < toInit.length; i++) {
212
+ const dowt = toInit[i];
213
+ let parentKeysForRecovery = {};
214
+ for (let j = 0; j < i; j++) {
215
+ parentKeysForRecovery = Object.assign(Object.assign({}, keysData[j].availableKeys), parentKeysForRecovery);
216
+ }
217
+ const availableKeys = yield this.loadAndRecoverKeysFor(dowt, parentKeysForRecovery);
212
218
  const availableKeysFpSet = new Set(Object.keys(availableKeys));
213
219
  const verifiedKeysMap = yield this.icureStorage.loadSelfVerifiedKeys(dowt.dataOwner.id);
214
220
  const allPublicKeys = new Set([
@@ -226,7 +232,8 @@ class UserEncryptionKeysManager {
226
232
  ? yield keyRecovererAndVerifier(recoveryInfo)
227
233
  : yield nothingKeyRecovererAndVerifier(recoveryInfo);
228
234
  const keysCache = {};
229
- for (const keyData of keysData) {
235
+ for (let i = 0; i < keysData.length; i++) {
236
+ const keyData = keysData[i];
230
237
  const currAuthenticity = this.ensureFingerprintKeys(recoveryAndVerificationResult[keyData.dowt.dataOwner.id].keyAuthenticity);
231
238
  const currExternallyRecovered = this.ensureFingerprintKeys(recoveryAndVerificationResult[keyData.dowt.dataOwner.id].recoveredKeys);
232
239
  for (const [fp, keyPair] of Object.entries(currExternallyRecovered)) {
@@ -235,7 +242,11 @@ class UserEncryptionKeysManager {
235
242
  }
236
243
  const updatedVerifiedMap = yield this.icureStorage.saveSelfVerifiedKeys(keyData.dowt.dataOwner.id, [...Object.keys(currAuthenticity), ...Object.keys(currExternallyRecovered)].reduce((acc, currFp) => (Object.assign(Object.assign({}, acc), { [currFp]: currFp in currExternallyRecovered || currAuthenticity[currFp] })), {}));
237
244
  const keysWithExternallyRecovered = Object.assign(Object.assign({}, keyData.availableKeys), Object.fromEntries(Object.entries(currExternallyRecovered).map(([k, v]) => [k, { pair: v, isDevice: false }])));
238
- const additionallyRecovered = yield this.recoverAndCacheKeys(keyData.dowt, this.plainKeysByFingerprint(keysWithExternallyRecovered));
245
+ let parentKeysForRecovery = {};
246
+ for (let j = 0; j < i; j++) {
247
+ parentKeysForRecovery = Object.assign(Object.assign({}, keysCache[keysData[j].dowt.dataOwner.id]), parentKeysForRecovery);
248
+ }
249
+ const additionallyRecovered = yield this.recoverAndCacheKeys(keyData.dowt, this.plainKeysByFingerprint(Object.assign(Object.assign({}, keysWithExternallyRecovered), parentKeysForRecovery)));
239
250
  const keys = Object.assign(Object.assign({}, keysWithExternallyRecovered), Object.fromEntries(Object.entries(additionallyRecovered).map(([k, v]) => [k, { pair: v, isDevice: false }])));
240
251
  keysCache[keyData.dowt.dataOwner.id] = this.verifyKeys(keys, updatedVerifiedMap);
241
252
  }
@@ -339,7 +350,7 @@ class UserEncryptionKeysManager {
339
350
  return recoveredKeys;
340
351
  });
341
352
  }
342
- loadAndRecoverKeysFor(dataOwner) {
353
+ loadAndRecoverKeysFor(dataOwner, ancestorsKeys) {
343
354
  return __awaiter(this, void 0, void 0, function* () {
344
355
  const pubKeysFingerprints = {
345
356
  'sha-1': [...new Set(this.dataOwnerApi.getHexPublicKeysWithSha1Of(dataOwner.dataOwner))].map((x) => (0, utils_2.fingerprintV1)(x)),
@@ -348,8 +359,8 @@ class UserEncryptionKeysManager {
348
359
  const loadedKeys = pubKeysFingerprints['sha-1'].length + pubKeysFingerprints['sha-256'].length > 0 ? yield this.loadStoredKeys(dataOwner, pubKeysFingerprints) : {};
349
360
  const loadedKeysFingerprints = Object.keys(loadedKeys);
350
361
  if (loadedKeysFingerprints.length !== pubKeysFingerprints['sha-1'].length + pubKeysFingerprints['sha-256'].length &&
351
- loadedKeysFingerprints.length > 0) {
352
- const recoveredKeys = yield this.recoverAndCacheKeys(dataOwner, this.plainKeysByFingerprint(loadedKeys));
362
+ (loadedKeysFingerprints.length > 0 || Object.keys(ancestorsKeys).length > 0)) {
363
+ const recoveredKeys = yield this.recoverAndCacheKeys(dataOwner, this.plainKeysByFingerprint(Object.assign(Object.assign({}, loadedKeys), ancestorsKeys)));
353
364
  for (const [fp, pair] of Object.entries(recoveredKeys)) {
354
365
  loadedKeys[fp] = { pair, isDevice: false };
355
366
  }
@@ -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,UAA4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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;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"]}
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,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;QACl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AK,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,MAAM;gBAC7G,CAAC,sBAAsB,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAC5E,CAAC;gBACD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,sBAAsB,iCAAM,UAAU,GAAK,aAAa,EAAG,CAAC,CAAA;gBACjI,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;oBACvD,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;gBAC5C,CAAC;YACH,CAAC;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;AA7bD,8DA6bC","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 const toInit = this.initialiseParentKeys ? hierarchy : [self]\n for (let i = 0; i < toInit.length; i++) {\n const dowt = toInit[i]\n let parentKeysForRecovery: { [keyFp: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } } = {}\n for (let j = 0; j < i; j++) {\n parentKeysForRecovery = {\n ...keysData[j].availableKeys,\n ...parentKeysForRecovery,\n }\n }\n const availableKeys = await this.loadAndRecoverKeysFor(dowt, parentKeysForRecovery)\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 (let i = 0; i < keysData.length; i++) {\n const keyData = keysData[i]\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 let parentKeysForRecovery: { [p: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } } = {}\n for (let j = 0; j < i; j++) {\n parentKeysForRecovery = {\n ...keysCache[keysData[j].dowt.dataOwner.id!],\n ...parentKeysForRecovery,\n }\n }\n const additionallyRecovered = await this.recoverAndCacheKeys(\n keyData.dowt,\n this.plainKeysByFingerprint({\n ...keysWithExternallyRecovered,\n ...parentKeysForRecovery,\n })\n )\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(\n dataOwner: DataOwnerWithType,\n ancestorsKeys: { [keyFp: string]: { pair: KeyPair<CryptoKey>; isDevice: boolean } }\n ): 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 || Object.keys(ancestorsKeys).length > 0)\n ) {\n const recoveredKeys = await this.recoverAndCacheKeys(dataOwner, this.plainKeysByFingerprint({ ...loadedKeys, ...ancestorsKeys }))\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icure/api",
3
- "version": "8.3.2",
3
+ "version": "8.3.4",
4
4
  "description": "Typescript version of iCure standalone API client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const test_utils_1 = require("../utils/test_utils");
13
+ const icc_x_api_1 = require("../../icc-x-api");
14
+ const crypto_1 = require("crypto");
15
+ const chai_1 = require("chai");
16
+ require("isomorphic-fetch");
17
+ const types_1 = require("@icure/test-setup/types");
18
+ const chaiAsPromised = require("chai-as-promised");
19
+ const utils_1 = require("../../icc-x-api/crypto/utils");
20
+ const TestStorage_1 = require("../utils/TestStorage");
21
+ const DataOwnerTypeEnum_1 = require("../../icc-api/model/DataOwnerTypeEnum");
22
+ (0, test_utils_1.setLocalStorage)(fetch);
23
+ (0, chai_1.use)(chaiAsPromised);
24
+ let env;
25
+ class RecoverParentKeyVerifySelfKeyStrategy {
26
+ constructor(parentKeys, selfPub) {
27
+ this.parentKeys = parentKeys;
28
+ this.selfPub = selfPub;
29
+ }
30
+ dataOwnerRequiresAnonymousDelegation(dataOwner) {
31
+ return dataOwner.type != DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp;
32
+ }
33
+ generateNewKeyForDataOwner(self, cryptoPrimitives) {
34
+ return Promise.resolve(false);
35
+ }
36
+ recoverAndVerifySelfHierarchyKeys(keysData, cryptoPrimitives, keyPairRecoverer) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ (0, chai_1.expect)(keysData).to.have.length(2);
39
+ return {
40
+ [keysData[0].dataOwner.dataOwner.id]: {
41
+ recoveredKeys: {
42
+ [(0, utils_1.fingerprintV1)((0, icc_x_api_1.ua2hex)(yield cryptoPrimitives.RSA.exportKey(this.parentKeys.publicKey, 'spki')))]: this.parentKeys,
43
+ },
44
+ keyAuthenticity: {},
45
+ },
46
+ [keysData[1].dataOwner.dataOwner.id]: {
47
+ recoveredKeys: {},
48
+ keyAuthenticity: {
49
+ [(0, utils_1.fingerprintV1)(this.selfPub)]: true,
50
+ },
51
+ },
52
+ };
53
+ });
54
+ }
55
+ verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
56
+ return Promise.resolve(publicKeys);
57
+ }
58
+ }
59
+ class VerifySelfKeyStrategy {
60
+ constructor(selfPub) {
61
+ this.selfPub = selfPub;
62
+ }
63
+ dataOwnerRequiresAnonymousDelegation(dataOwner) {
64
+ return dataOwner.type != DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp;
65
+ }
66
+ generateNewKeyForDataOwner(self, cryptoPrimitives) {
67
+ return Promise.resolve(false);
68
+ }
69
+ recoverAndVerifySelfHierarchyKeys(keysData, cryptoPrimitives, keyPairRecoverer) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ (0, chai_1.expect)(keysData).to.have.length(2);
72
+ (0, chai_1.expect)(keysData.every((x) => x.unavailableKeys.length == 0)).to.be.true;
73
+ (0, chai_1.expect)(keysData[1].unknownKeys).to.have.length(1);
74
+ (0, chai_1.expect)(keysData[1].unknownKeys[0]).to.eq(this.selfPub);
75
+ return {
76
+ [keysData[0].dataOwner.dataOwner.id]: {
77
+ recoveredKeys: {},
78
+ keyAuthenticity: {},
79
+ },
80
+ [keysData[1].dataOwner.dataOwner.id]: {
81
+ recoveredKeys: {},
82
+ keyAuthenticity: { [(0, utils_1.fingerprintV1)(this.selfPub)]: true },
83
+ },
84
+ };
85
+ });
86
+ }
87
+ verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
88
+ return Promise.resolve(publicKeys);
89
+ }
90
+ }
91
+ describe('CSM-543', function () {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ before(function () {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ this.timeout(600000);
96
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
97
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
98
+ });
99
+ });
100
+ function init() {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ const { grandUser: parentUser, grandApi: parentApi, grandCredentials: parentCredentials, parentUser: childUser, parentApi: childApi, parentCredentials: childCredentials, } = yield (0, test_utils_1.createHcpHierarchyApis)(env);
103
+ const initialKeys = yield childApi.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy();
104
+ (0, chai_1.expect)(initialKeys.self.keys).to.have.length(1);
105
+ (0, chai_1.expect)(initialKeys.self.keys[0].verified).to.eq(true);
106
+ (0, chai_1.expect)(initialKeys.parents).to.have.length(1);
107
+ (0, chai_1.expect)(initialKeys.parents[0].keys).to.have.length(1);
108
+ (0, chai_1.expect)(initialKeys.parents[0].keys[0].verified).to.eq(true);
109
+ const selfKeyPub = (0, icc_x_api_1.ua2hex)(yield childApi.cryptoApi.primitives.RSA.exportKey(initialKeys.self.keys[0].pair.publicKey, 'spki'));
110
+ yield childApi.cryptoApi.shamirKeysManager.updateSelfSplits({ [(0, utils_1.fingerprintV1)(selfKeyPub)]: { notariesIds: [parentCredentials.dataOwnerId], minShares: 1 } }, []);
111
+ return {
112
+ childCredentials,
113
+ selfKeyPub,
114
+ parentKey: initialKeys.parents[0].keys[0].pair,
115
+ parentCredentials,
116
+ };
117
+ });
118
+ }
119
+ function checkKeys(api, expectedSelfKey) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const recoveredKeys = yield api.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy();
122
+ (0, chai_1.expect)(recoveredKeys.self.keys).to.have.length(1);
123
+ (0, chai_1.expect)(recoveredKeys.self.keys[0].verified).to.eq(true);
124
+ (0, chai_1.expect)(recoveredKeys.parents).to.have.length(1);
125
+ (0, chai_1.expect)(recoveredKeys.parents[0].keys).to.have.length(1);
126
+ (0, chai_1.expect)(recoveredKeys.parents[0].keys[0].verified).to.eq(true);
127
+ (0, chai_1.expect)((0, icc_x_api_1.ua2hex)(yield api.cryptoApi.primitives.RSA.exportKey(recoveredKeys.self.keys[0].pair.publicKey, 'spki'))).to.eq(expectedSelfKey);
128
+ });
129
+ }
130
+ it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key recovered by crypto strategies', function () {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ const { childCredentials, selfKeyPub, parentKey } = yield init();
133
+ const apiWithLostKey = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: childCredentials.user, password: childCredentials.password }, new RecoverParentKeyVerifySelfKeyStrategy(parentKey, selfKeyPub), crypto_1.webcrypto, fetch, {
134
+ storage: new TestStorage_1.TestStorage(),
135
+ keyStorage: new TestStorage_1.TestKeyStorage(),
136
+ });
137
+ yield checkKeys(apiWithLostKey, selfKeyPub);
138
+ });
139
+ });
140
+ it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key available in storage', function () {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ const { childCredentials, selfKeyPub, parentCredentials } = yield init();
143
+ const storageWithParentKey = yield (0, TestStorage_1.testStorageWithKeys)([
144
+ {
145
+ dataOwnerId: parentCredentials.dataOwnerId,
146
+ pairs: [
147
+ {
148
+ keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey },
149
+ shaVersion: icc_x_api_1.ShaVersion.Sha1,
150
+ },
151
+ ],
152
+ },
153
+ ]);
154
+ const apiWithLostKey = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: childCredentials.user, password: childCredentials.password }, new VerifySelfKeyStrategy(selfKeyPub), crypto_1.webcrypto, fetch, {
155
+ storage: storageWithParentKey.storage,
156
+ keyStorage: storageWithParentKey.keyStorage,
157
+ entryKeysFactory: storageWithParentKey.keyFactory,
158
+ });
159
+ yield checkKeys(apiWithLostKey, selfKeyPub);
160
+ });
161
+ });
162
+ });
163
+ });
164
+ //# sourceMappingURL=CSM-543.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CSM-543.js","sourceRoot":"","sources":["../../../test/support/CSM-543.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAwG;AACxG,+CAA2G;AAC3G,mCAAkC;AAClC,+BAA6C;AAC7C,4BAAyB;AACzB,mDAAmE;AACnE,mDAAkD;AAClD,wDAA4D;AAC5D,sDAAuF;AAIvF,6EAAyE;AAEzE,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAA,UAAO,EAAC,cAAc,CAAC,CAAA;AAEvB,IAAI,GAAa,CAAA;AAEjB,MAAM,qCAAqC;IACzC,YAA6B,UAA8B,EAAmB,OAAe;QAAhE,eAAU,GAAV,UAAU,CAAoB;QAAmB,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEjG,oCAAoC,CAAC,SAAkC;QACrE,OAAO,SAAS,CAAC,IAAI,IAAI,qCAAiB,CAAC,GAAG,CAAA;IAChD,CAAC;IAED,0BAA0B,CAAC,IAAuB,EAAE,gBAAkC;QACpF,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC/B,CA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;gCAC7F,UAAU,EAAE,sBAAU,CAAC,IAAI;6BAC5B;yBACF;qBACF;iBACF,CAAC,CAAA;gBACF,MAAM,cAAc,GAAG,MAAM,oBAAQ,CAAC,UAAU,CAC9C,GAAG,CAAC,QAAQ,EACZ,EAAE,QAAQ,EAAE,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,EAAE,EACxE,IAAI,qBAAqB,CAAC,UAAU,CAAC,EACrC,kBAAgB,EAChB,KAAK,EACL;oBACE,OAAO,EAAE,oBAAoB,CAAC,OAAO;oBACrC,UAAU,EAAE,oBAAoB,CAAC,UAAU;oBAC3C,gBAAgB,EAAE,oBAAoB,CAAC,UAAU;iBAClD,CACF,CAAA;gBACD,MAAM,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;YAC7C,CAAC;SAAA,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { createHcpHierarchyApis, getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { CryptoPrimitives, CryptoStrategies, IcureApi, KeyPair, ShaVersion, ua2hex } from '../../icc-x-api'\nimport { webcrypto } from 'crypto'\nimport { expect, use as chaiUse } from 'chai'\nimport 'isomorphic-fetch'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { fingerprintV1 } from '../../icc-x-api/crypto/utils'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../utils/TestStorage'\nimport { KeyPairRecoverer } from '../../icc-x-api/crypto/KeyPairRecoverer'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\n\nsetLocalStorage(fetch)\n\nchaiUse(chaiAsPromised)\n\nlet env: TestVars\n\nclass RecoverParentKeyVerifySelfKeyStrategy implements CryptoStrategies {\n constructor(private readonly parentKeys: KeyPair<CryptoKey>, private readonly selfPub: string) {}\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return dataOwner.type != DataOwnerTypeEnum.Hcp\n }\n\n generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean | 'keyless'> {\n return Promise.resolve(false)\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives,\n keyPairRecoverer: KeyPairRecoverer\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n expect(keysData).to.have.length(2)\n return {\n [keysData[0].dataOwner.dataOwner.id!]: {\n recoveredKeys: {\n [fingerprintV1(ua2hex(await cryptoPrimitives.RSA.exportKey(this.parentKeys.publicKey, 'spki')))]: this.parentKeys,\n },\n keyAuthenticity: {},\n },\n [keysData[1].dataOwner.dataOwner.id!]: {\n recoveredKeys: {},\n keyAuthenticity: {\n [fingerprintV1(this.selfPub)]: true,\n },\n },\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\n\nclass VerifySelfKeyStrategy implements CryptoStrategies {\n constructor(private readonly selfPub: string) {}\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return dataOwner.type != DataOwnerTypeEnum.Hcp\n }\n\n generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean | 'keyless'> {\n return Promise.resolve(false)\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives,\n keyPairRecoverer: KeyPairRecoverer\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n expect(keysData).to.have.length(2)\n expect(keysData.every((x) => x.unavailableKeys.length == 0)).to.be.true\n expect(keysData[1].unknownKeys).to.have.length(1)\n expect(keysData[1].unknownKeys[0]).to.eq(this.selfPub)\n return {\n [keysData[0].dataOwner.dataOwner.id!]: {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n [keysData[1].dataOwner.dataOwner.id!]: {\n recoveredKeys: {},\n keyAuthenticity: { [fingerprintV1(this.selfPub)]: true },\n },\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\n\ndescribe('CSM-543', async function () {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n async function init() {\n const {\n grandUser: parentUser,\n grandApi: parentApi,\n grandCredentials: parentCredentials,\n parentUser: childUser,\n parentApi: childApi,\n parentCredentials: childCredentials,\n } = await createHcpHierarchyApis(env)\n const initialKeys = await childApi.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy()\n expect(initialKeys.self.keys).to.have.length(1)\n expect(initialKeys.self.keys[0].verified).to.eq(true)\n expect(initialKeys.parents).to.have.length(1)\n expect(initialKeys.parents[0].keys).to.have.length(1)\n expect(initialKeys.parents[0].keys[0].verified).to.eq(true)\n const selfKeyPub = ua2hex(await childApi.cryptoApi.primitives.RSA.exportKey(initialKeys.self.keys[0].pair.publicKey, 'spki'))\n await childApi.cryptoApi.shamirKeysManager.updateSelfSplits(\n { [fingerprintV1(selfKeyPub)]: { notariesIds: [parentCredentials.dataOwnerId], minShares: 1 } },\n []\n )\n return {\n childCredentials,\n selfKeyPub,\n parentKey: initialKeys.parents[0].keys[0].pair,\n parentCredentials,\n }\n }\n\n async function checkKeys(api: IcureApi, expectedSelfKey: string) {\n const recoveredKeys = await api.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy()\n expect(recoveredKeys.self.keys).to.have.length(1)\n expect(recoveredKeys.self.keys[0].verified).to.eq(true)\n expect(recoveredKeys.parents).to.have.length(1)\n expect(recoveredKeys.parents[0].keys).to.have.length(1)\n expect(recoveredKeys.parents[0].keys[0].verified).to.eq(true)\n expect(ua2hex(await api.cryptoApi.primitives.RSA.exportKey(recoveredKeys.self.keys[0].pair.publicKey, 'spki'))).to.eq(expectedSelfKey)\n }\n\n it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key recovered by crypto strategies', async function () {\n const { childCredentials, selfKeyPub, parentKey } = await init()\n const apiWithLostKey = await IcureApi.initialise(\n env.iCureUrl,\n { username: childCredentials.user, password: childCredentials.password },\n new RecoverParentKeyVerifySelfKeyStrategy(parentKey, selfKeyPub),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n await checkKeys(apiWithLostKey, selfKeyPub)\n })\n\n it('Sdk should be able to use recovery data accessible with parent key to recover key of user - parent key available in storage', async function () {\n const { childCredentials, selfKeyPub, parentCredentials } = await init()\n const storageWithParentKey = await testStorageWithKeys([\n {\n dataOwnerId: parentCredentials.dataOwnerId!,\n pairs: [\n {\n keyPair: { privateKey: parentCredentials.privateKey, publicKey: parentCredentials.publicKey },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apiWithLostKey = await IcureApi.initialise(\n env.iCureUrl,\n { username: childCredentials.user, password: childCredentials.password },\n new VerifySelfKeyStrategy(selfKeyPub),\n webcrypto as any,\n fetch,\n {\n storage: storageWithParentKey.storage,\n keyStorage: storageWithParentKey.keyStorage,\n entryKeysFactory: storageWithParentKey.keyFactory,\n }\n )\n await checkKeys(apiWithLostKey, selfKeyPub)\n })\n})\n"]}
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- require("isomorphic-fetch");
13
- const mocha_1 = require("mocha");
14
- const test_utils_1 = require("../utils/test_utils");
15
- const icc_x_api_1 = require("../../icc-x-api");
16
- var initApi = test_utils_1.TestUtils.initApi;
17
- const crypto_1 = require("crypto");
18
- const TimeTable_1 = require("../../icc-api/model/TimeTable");
19
- const Code_1 = require("../../icc-api/model/Code");
20
- const TimeTableItem_1 = require("../../icc-api/model/TimeTableItem");
21
- const TimeTableHour_1 = require("../../icc-api/model/TimeTableHour");
22
- const chai_1 = require("chai");
23
- const types_1 = require("@icure/test-setup/types");
24
- (0, test_utils_1.setLocalStorage)(fetch);
25
- let env;
26
- function instanceTimeTableFor(timeTableApi, user) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return new TimeTable_1.TimeTable({
29
- id: (0, crypto_1.randomUUID)(),
30
- tags: [
31
- new Code_1.Code({
32
- id: 'ICURE|MY-CODE|1',
33
- code: 'MY-CODE',
34
- type: 'ICURE',
35
- version: '1',
36
- }),
37
- ],
38
- name: 'Main TimeTable',
39
- startTime: 20221101000,
40
- endTime: 20221128000,
41
- items: [
42
- new TimeTableItem_1.TimeTableItem({
43
- id: (0, crypto_1.randomUUID)(),
44
- rrule: 'RRULE:FREQ=WEEKLY;BYDAY=TU;COUNT=10',
45
- days: ['monday', 'tuesday', 'thursday'],
46
- hours: [
47
- new TimeTableHour_1.TimeTableHour({
48
- startHour: 1000,
49
- endHour: 1800,
50
- }),
51
- ],
52
- }),
53
- ],
54
- });
55
- });
56
- }
57
- describe('icc-x-time-table-api Tests', () => {
58
- (0, mocha_1.before)(function () {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- this.timeout(600000);
61
- const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
62
- env = yield initializer.execute((0, types_1.getEnvVariables)());
63
- });
64
- });
65
- it('Create TimeTable Success', () => __awaiter(void 0, void 0, void 0, function* () {
66
- // Given
67
- const { userApi: userApiForHcp, timetableApi: timeTableApiForHcp, cryptoApi } = yield initApi(env, test_utils_1.hcp1Username);
68
- const hcpUser = yield userApiForHcp.getCurrentUser();
69
- const baseTimeTable = yield instanceTimeTableFor(timeTableApiForHcp, hcpUser);
70
- // When
71
- const createdTimeTable = yield timeTableApiForHcp.createTimeTable(baseTimeTable);
72
- // Then
73
- (0, chai_1.expect)(createdTimeTable.id).to.equals(baseTimeTable.id);
74
- (0, chai_1.expect)(createdTimeTable.name).to.equals(baseTimeTable.name);
75
- (0, chai_1.expect)(createdTimeTable.startTime).to.equals(baseTimeTable.startTime);
76
- (0, chai_1.expect)(createdTimeTable.items.length).to.equals(1);
77
- (0, chai_1.expect)(yield cryptoApi.xapi.encryptionKeysOf({ entity: createdTimeTable, type: icc_x_api_1.EntityWithDelegationTypeName.TimeTable }, undefined)).to.have.length(1);
78
- (0, chai_1.expect)(yield cryptoApi.xapi.secretIdsOf({ entity: createdTimeTable, type: icc_x_api_1.EntityWithDelegationTypeName.TimeTable }, undefined)).to.have.length(0);
79
- (0, chai_1.expect)(yield cryptoApi.xapi.owningEntityIdsOf({ entity: createdTimeTable, type: icc_x_api_1.EntityWithDelegationTypeName.TimeTable }, undefined)).to.have.length(0);
80
- }));
81
- });
82
- //# sourceMappingURL=icc-time-table-x-api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../../test/icc-x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AAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,wCAA4B,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACjJ,IAAA,aAAM,EACJ,MAAM,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,wCAA4B,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAC9H,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC,CAAA,CAAC,CAAA;AAEJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\n\nimport { before } from 'mocha'\nimport { getEnvironmentInitializer, hcp1Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { EntityWithDelegationTypeName } from '../../icc-x-api'\nimport initApi = TestUtils.initApi\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { TimeTable } from '../../icc-api/model/TimeTable'\nimport { Code } from '../../icc-api/model/Code'\nimport { TimeTableItem } from '../../icc-api/model/TimeTableItem'\nimport { TimeTableHour } from '../../icc-api/model/TimeTableHour'\nimport { expect } from 'chai'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport {IccTimeTableApi} from \"../../icc-api\"\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\nasync function instanceTimeTableFor(timeTableApi: IccTimeTableApi, user: User): Promise<TimeTable> {\n return new TimeTable({\n id: randomUUID(),\n tags: [\n new Code({\n id: 'ICURE|MY-CODE|1',\n code: 'MY-CODE',\n type: 'ICURE',\n version: '1',\n }),\n ],\n name: 'Main TimeTable',\n startTime: 20221101000,\n endTime: 20221128000,\n items: [\n new TimeTableItem({\n id: randomUUID(),\n rrule: 'RRULE:FREQ=WEEKLY;BYDAY=TU;COUNT=10',\n days: ['monday', 'tuesday', 'thursday'],\n hours: [\n new TimeTableHour({\n startHour: 1000,\n endHour: 1800,\n }),\n ],\n }),\n ],\n })\n}\n\ndescribe('icc-x-time-table-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('Create TimeTable Success', async () => {\n // Given\n const { userApi: userApiForHcp, timetableApi: timeTableApiForHcp, cryptoApi } = await initApi(env, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const baseTimeTable = await instanceTimeTableFor(timeTableApiForHcp, hcpUser)\n\n // When\n const createdTimeTable = await timeTableApiForHcp.createTimeTable(baseTimeTable)\n\n // Then\n expect(createdTimeTable.id).to.equals(baseTimeTable.id)\n expect(createdTimeTable.name).to.equals(baseTimeTable.name)\n expect(createdTimeTable.startTime).to.equals(baseTimeTable.startTime)\n expect(createdTimeTable.items!.length).to.equals(1)\n expect(\n await cryptoApi.xapi.encryptionKeysOf({ entity: createdTimeTable, type: EntityWithDelegationTypeName.TimeTable }, undefined)\n ).to.have.length(1)\n expect(await cryptoApi.xapi.secretIdsOf({ entity: createdTimeTable, type: EntityWithDelegationTypeName.TimeTable }, undefined)).to.have.length(0)\n expect(\n await cryptoApi.xapi.owningEntityIdsOf({ entity: createdTimeTable, type: EntityWithDelegationTypeName.TimeTable }, undefined)\n ).to.have.length(0)\n })\n\n})\n"]}